kiki-agent 0.4.2 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (171) hide show
  1. package/dist/docs/en/configuration/config-files.md +32 -19
  2. package/dist/docs/en/configuration/data-locations.md +23 -1
  3. package/dist/docs/en/configuration/env-vars.md +6 -8
  4. package/dist/docs/en/configuration/overrides.md +19 -8
  5. package/dist/docs/en/configuration/providers.md +75 -4
  6. package/dist/docs/en/customization/agents-and-subagents.md +6 -2
  7. package/dist/docs/en/customization/personas.md +36 -2
  8. package/dist/docs/en/customization/plugins.md +41 -1
  9. package/dist/docs/en/customization/prompt-fields.md +4 -0
  10. package/dist/docs/en/features/agent-workflows.md +8 -8
  11. package/dist/docs/en/features/browser-and-computer.md +40 -0
  12. package/dist/docs/en/features/daily.md +10 -10
  13. package/dist/docs/en/features/ecosystem.md +5 -5
  14. package/dist/docs/en/features/extend.md +9 -8
  15. package/dist/docs/en/features/freedom.md +8 -8
  16. package/dist/docs/en/features/index.md +44 -28
  17. package/dist/docs/en/features/long-work.md +9 -9
  18. package/dist/docs/en/features/look.md +5 -5
  19. package/dist/docs/en/features/people.md +6 -6
  20. package/dist/docs/en/features/phone.md +5 -3
  21. package/dist/docs/en/features/spaces.md +7 -7
  22. package/dist/docs/en/features/workbench.md +8 -8
  23. package/dist/docs/en/guides/interface.md +16 -4
  24. package/dist/docs/en/guides/sessions.md +6 -2
  25. package/dist/docs/en/guides/settings.md +15 -2
  26. package/dist/docs/en/reference/command.md +58 -1
  27. package/dist/docs/en/reference/tools.md +25 -5
  28. package/dist/docs/en/server/acp.md +3 -1
  29. package/dist/docs/en/server/mcp.md +5 -1
  30. package/dist/docs/en/server/rest-api.md +115 -4
  31. package/dist/docs/zh/configuration/config-files.md +32 -19
  32. package/dist/docs/zh/configuration/data-locations.md +23 -1
  33. package/dist/docs/zh/configuration/env-vars.md +6 -8
  34. package/dist/docs/zh/configuration/overrides.md +19 -8
  35. package/dist/docs/zh/configuration/providers.md +75 -4
  36. package/dist/docs/zh/customization/agents-and-subagents.md +6 -2
  37. package/dist/docs/zh/customization/personas.md +36 -2
  38. package/dist/docs/zh/customization/plugins.md +41 -1
  39. package/dist/docs/zh/customization/prompt-fields.md +4 -0
  40. package/dist/docs/zh/features/agent-workflows.md +10 -10
  41. package/dist/docs/zh/features/browser-and-computer.md +40 -0
  42. package/dist/docs/zh/features/daily.md +10 -10
  43. package/dist/docs/zh/features/ecosystem.md +5 -5
  44. package/dist/docs/zh/features/extend.md +8 -7
  45. package/dist/docs/zh/features/freedom.md +8 -8
  46. package/dist/docs/zh/features/index.md +44 -28
  47. package/dist/docs/zh/features/long-work.md +8 -8
  48. package/dist/docs/zh/features/look.md +5 -5
  49. package/dist/docs/zh/features/people.md +5 -5
  50. package/dist/docs/zh/features/phone.md +5 -3
  51. package/dist/docs/zh/features/spaces.md +7 -7
  52. package/dist/docs/zh/features/workbench.md +8 -8
  53. package/dist/docs/zh/guides/interface.md +16 -4
  54. package/dist/docs/zh/guides/sessions.md +6 -2
  55. package/dist/docs/zh/guides/settings.md +15 -2
  56. package/dist/docs/zh/reference/command.md +58 -1
  57. package/dist/docs/zh/reference/tools.md +25 -5
  58. package/dist/docs/zh/server/acp.md +3 -1
  59. package/dist/docs/zh/server/mcp.md +5 -1
  60. package/dist/docs/zh/server/rest-api.md +114 -3
  61. package/dist/hostRunner.mjs +92 -1
  62. package/dist/mailbox-worker.mjs +297 -0
  63. package/dist/main.mjs +2 -2
  64. package/dist/native/windows-process-helper.exe +0 -0
  65. package/dist/query-store-worker.mjs +446 -0
  66. package/dist/sqlite-indexer.mjs +223 -401
  67. package/dist/sqlite-query-worker.mjs +226 -249
  68. package/dist/usage-parser-worker.mjs +24 -5
  69. package/dist/web/assets/AppErrorBoundary-BN6IDdP1.js +1 -0
  70. package/dist/web/assets/{LifeMark-CL6-HWDu.js → LifeMark-UBMVaTWr.js} +1 -1
  71. package/dist/web/assets/{NavScopeBoundary-CFCnvZR0.js → NavScopeBoundary-BCryw-UG.js} +1 -1
  72. package/dist/web/assets/{arc-DYDCMlOS.js → arc-C7IAvCCJ.js} +1 -1
  73. package/dist/web/assets/{architectureDiagram-3BPJPVTR-C9Y7T0O2.js → architectureDiagram-3BPJPVTR-CbwFBxn7.js} +1 -1
  74. package/dist/web/assets/{blockDiagram-GPEHLZMM-CdUrp-tD.js → blockDiagram-GPEHLZMM-B20N4t8r.js} +1 -1
  75. package/dist/web/assets/{c4Diagram-AAUBKEIU-PrwvB9IJ.js → c4Diagram-AAUBKEIU-3BYtlcP-.js} +1 -1
  76. package/dist/web/assets/channel-BJs5vJuh.js +1 -0
  77. package/dist/web/assets/{chunk-2J33WTMH-BL56g_Es.js → chunk-2J33WTMH-CpjgczxM.js} +1 -1
  78. package/dist/web/assets/{chunk-4BX2VUAB-DvJD5M9M.js → chunk-4BX2VUAB-BScxUF5G.js} +1 -1
  79. package/dist/web/assets/{chunk-55IACEB6-C8f-nzvx.js → chunk-55IACEB6-CrcLYJXd.js} +1 -1
  80. package/dist/web/assets/{chunk-727SXJPM-DOGkWKkV.js → chunk-727SXJPM-BwlyIOjw.js} +1 -1
  81. package/dist/web/assets/{chunk-AQP2D5EJ-fFOuz7g6.js → chunk-AQP2D5EJ-DKKIRkRv.js} +1 -1
  82. package/dist/web/assets/{chunk-FMBD7UC4-BpeXZ9LM.js → chunk-FMBD7UC4-CVDMj2kX.js} +1 -1
  83. package/dist/web/assets/{chunk-ND2GUHAM-CRUh76fb.js → chunk-ND2GUHAM-CL-PM6r8.js} +1 -1
  84. package/dist/web/assets/{chunk-QZHKN3VN-uNfxaPk0.js → chunk-QZHKN3VN-DPV2KbKZ.js} +1 -1
  85. package/dist/web/assets/classDiagram-4FO5ZUOK-BookeACB.js +1 -0
  86. package/dist/web/assets/classDiagram-v2-Q7XG4LA2-BookeACB.js +1 -0
  87. package/dist/web/assets/client-CXcrCawx.js +3 -0
  88. package/dist/web/assets/connection-C8nwzwXB.js +1 -0
  89. package/dist/web/assets/{cose-bilkent-S5V4N54A-BNkxG-qX.js → cose-bilkent-S5V4N54A-D1CEiQM6.js} +1 -1
  90. package/dist/web/assets/{dagre-BM42HDAG-BerioUei.js → dagre-BM42HDAG-BlFV941E.js} +1 -1
  91. package/dist/web/assets/{diagram-2AECGRRQ-Czv2SR07.js → diagram-2AECGRRQ-BC0ldkFY.js} +1 -1
  92. package/dist/web/assets/{diagram-5GNKFQAL-Uzi1weGK.js → diagram-5GNKFQAL-B22Iej6G.js} +1 -1
  93. package/dist/web/assets/{diagram-KO2AKTUF-W36h_ff3.js → diagram-KO2AKTUF-B75UNw6D.js} +1 -1
  94. package/dist/web/assets/{diagram-LMA3HP47-FG4dDk52.js → diagram-LMA3HP47-CypI7IJM.js} +1 -1
  95. package/dist/web/assets/{diagram-OG6HWLK6-CQoEjIAY.js → diagram-OG6HWLK6-OsXumvcD.js} +1 -1
  96. package/dist/web/assets/{erDiagram-TEJ5UH35-Ck06KVyZ.js → erDiagram-TEJ5UH35-3756GOvS.js} +1 -1
  97. package/dist/web/assets/{export-T_izwEkQ.js → export-Bn8PqPg4.js} +1 -1
  98. package/dist/web/assets/{flowDiagram-I6XJVG4X-C5hgxdFZ.js → flowDiagram-I6XJVG4X-DB6Y_UDg.js} +1 -1
  99. package/dist/web/assets/{ganttDiagram-6RSMTGT7-BS52Pw5_.js → ganttDiagram-6RSMTGT7-CHJeuoAY.js} +1 -1
  100. package/dist/web/assets/{gitGraphDiagram-PVQCEYII-DLlQKZHs.js → gitGraphDiagram-PVQCEYII-Dj85554Y.js} +1 -1
  101. package/dist/web/assets/{highlighted-body-OFNGDK62-Btm6MuZ4.js → highlighted-body-OFNGDK62-DMgPHetp.js} +1 -1
  102. package/dist/web/assets/{index-CZX3qUe2.js → index-0tHq8zh2.js} +1 -1
  103. package/dist/web/assets/index-7ySDqvaN.css +1 -0
  104. package/dist/web/assets/index-B0KPRi1U.js +166 -0
  105. package/dist/web/assets/{index-CRDDqofN.js → index-B599VnpP.js} +1 -1
  106. package/dist/web/assets/{index-Cd62y0wD.js → index-BFK-GypQ.js} +1 -1
  107. package/dist/web/assets/{index-BMWid2q9.js → index-BPX8gmpB.js} +1 -1
  108. package/dist/web/assets/{index-5_yzg61S.js → index-BSGYc1tb.js} +1 -1
  109. package/dist/web/assets/{index-CJ92kLtO.js → index-BTt9Q5iv.js} +1 -1
  110. package/dist/web/assets/{index-B4iu4SJW.js → index-BWzUsoY_.js} +1 -1
  111. package/dist/web/assets/{index-CgcJPsK6.js → index-BYlSV3FO.js} +1 -1
  112. package/dist/web/assets/{index-BkPV0psm.js → index-BpXQ1q-u.js} +1 -1
  113. package/dist/web/assets/{index-Dceu0bqY.js → index-BqPxpGUh.js} +1 -1
  114. package/dist/web/assets/{index-CM-nNfuV.js → index-C6qeLCPw.js} +4 -4
  115. package/dist/web/assets/{index-ByiwExpV.js → index-C7mOS2T4.js} +1 -1
  116. package/dist/web/assets/{index-CG8uIlD7.js → index-C8OFfbEs.js} +1 -1
  117. package/dist/web/assets/{index-B-6LiYTY.js → index-CI7yuMGZ.js} +1 -1
  118. package/dist/web/assets/{index-B2Pu0Iuu.js → index-CJqIcuAl.js} +1 -1
  119. package/dist/web/assets/{index-BECSk4If.js → index-CTRJmDep.js} +1 -1
  120. package/dist/web/assets/{index-Bezli3SF.js → index-CXGCKoId.js} +1 -1
  121. package/dist/web/assets/{index-hG2s2Spn.js → index-CsY571EL.js} +1 -1
  122. package/dist/web/assets/{index-BFcyN2Zw.js → index-CwQG_9rB.js} +1 -1
  123. package/dist/web/assets/{index-BLU8_Um7.js → index-D--cw39y.js} +1 -1
  124. package/dist/web/assets/{index-B9MlqF7J.js → index-D260jsUJ.js} +1 -1
  125. package/dist/web/assets/{index-D_oPSlBL.js → index-DJjmEXx4.js} +1 -1
  126. package/dist/web/assets/{index-BNch_a4L.js → index-DRMjjql1.js} +1 -1
  127. package/dist/web/assets/{index-BeMvPEXs.js → index-DUxOVxHS.js} +1 -1
  128. package/dist/web/assets/{index-Ca607_hK.js → index-DZMkZKhW.js} +1 -1
  129. package/dist/web/assets/{index-BwcG86o3.js → index-DqK8MfQN.js} +1 -1
  130. package/dist/web/assets/{index-DKIysLbI.js → index-DxUmR9aV.js} +1 -1
  131. package/dist/web/assets/{index-Cy8C_eFR.js → index-GK8aa9pT.js} +1 -1
  132. package/dist/web/assets/{index-Bg99yVX_.js → index-bYtKyBMB.js} +1 -1
  133. package/dist/web/assets/{index-eUyF-8Sq.js → index-wxHFHTgD.js} +1 -1
  134. package/dist/web/assets/{infoDiagram-5YYISTIA-CD4XJGFm.js → infoDiagram-5YYISTIA-DeDPIdEH.js} +1 -1
  135. package/dist/web/assets/{ishikawaDiagram-YF4QCWOH-fu5E3_CT.js → ishikawaDiagram-YF4QCWOH-ButuBiBW.js} +1 -1
  136. package/dist/web/assets/{journeyDiagram-JHISSGLW-CXcnKBfJ.js → journeyDiagram-JHISSGLW-Dlbmqm-j.js} +1 -1
  137. package/dist/web/assets/{kanban-definition-UN3LZRKU-BawKH6Pl.js → kanban-definition-UN3LZRKU-tlQK1cOz.js} +1 -1
  138. package/dist/web/assets/{linear-BplJuXph.js → linear-iXuNfUWp.js} +1 -1
  139. package/dist/web/assets/mermaid-GHXKKRXX-sDJax95P.js +624 -0
  140. package/dist/web/assets/{mindmap-definition-RKZ34NQL-DA1SE2uy.js → mindmap-definition-RKZ34NQL-2qPv-mwT.js} +1 -1
  141. package/dist/web/assets/{pieDiagram-4H26LBE5-6i021QeX.js → pieDiagram-4H26LBE5-CrLe1C-O.js} +1 -1
  142. package/dist/web/assets/{quadrantDiagram-W4KKPZXB-CcKSZDMT.js → quadrantDiagram-W4KKPZXB-DfeIFxc0.js} +1 -1
  143. package/dist/web/assets/{requirementDiagram-4Y6WPE33-lYVuWRuD.js → requirementDiagram-4Y6WPE33-BWtjdxie.js} +1 -1
  144. package/dist/web/assets/{sankeyDiagram-5OEKKPKP-4Zfb4_h4.js → sankeyDiagram-5OEKKPKP-B5TxJ6mb.js} +1 -1
  145. package/dist/web/assets/{sequenceDiagram-3UESZ5HK-DqltKmlY.js → sequenceDiagram-3UESZ5HK-Cf92ZCl1.js} +1 -1
  146. package/dist/web/assets/{spaces-CjuXbmxF.js → spaces-DqMTtCXX.js} +1 -1
  147. package/dist/web/assets/{stateDiagram-AJRCARHV-HFdhqxzx.js → stateDiagram-AJRCARHV-NR9I-Q4d.js} +1 -1
  148. package/dist/web/assets/stateDiagram-v2-BHNVJYJU-BiegFWxE.js +1 -0
  149. package/dist/web/assets/{theme-beWE_6f8.js → theme-6OL1RXgY.js} +1 -1
  150. package/dist/web/assets/{timeline-definition-PNZ67QCA-HNRxaB3t.js → timeline-definition-PNZ67QCA-CBAOVMfm.js} +1 -1
  151. package/dist/web/assets/{vennDiagram-CIIHVFJN-DwsCTyaD.js → vennDiagram-CIIHVFJN-C68x6TdS.js} +1 -1
  152. package/dist/web/assets/{wardley-L42UT6IY-BWW2wtVO.js → wardley-L42UT6IY-DuZZr5jm.js} +1 -1
  153. package/dist/web/assets/{wardleyDiagram-YWT4CUSO-C-ktKm7v.js → wardleyDiagram-YWT4CUSO-D6dVGtHd.js} +1 -1
  154. package/dist/web/assets/{xychartDiagram-2RQKCTM6-48AxNW9k.js → xychartDiagram-2RQKCTM6-DYLUhZX4.js} +1 -1
  155. package/dist/web/index.html +2 -2
  156. package/native/auth-native/prebuilds/linux-arm64/auth-native.node +0 -0
  157. package/native/auth-native/prebuilds/linux-x64/auth-native.node +0 -0
  158. package/native/auth-native/prebuilds/win32-arm64/auth-native.node +0 -0
  159. package/native/auth-native/prebuilds/win32-x64/auth-native.node +0 -0
  160. package/package.json +2 -2
  161. package/dist/search-worker.mjs +0 -14177
  162. package/dist/web/assets/AppErrorBoundary-DiGMUg4r.js +0 -1
  163. package/dist/web/assets/channel-Bj_gZ_Lv.js +0 -1
  164. package/dist/web/assets/classDiagram-4FO5ZUOK-ssCwe2R4.js +0 -1
  165. package/dist/web/assets/classDiagram-v2-Q7XG4LA2-ssCwe2R4.js +0 -1
  166. package/dist/web/assets/client-DGj93bGT.js +0 -3
  167. package/dist/web/assets/connection-Bpf-EjrL.js +0 -1
  168. package/dist/web/assets/index-BIebkSEI.css +0 -1
  169. package/dist/web/assets/index-D8z7lcQn.js +0 -166
  170. package/dist/web/assets/mermaid-GHXKKRXX-BO9hkP3Z.js +0 -621
  171. package/dist/web/assets/stateDiagram-v2-BHNVJYJU-Dx28QuZF.js +0 -1
@@ -1,4 +1,4 @@
1
- import{_ as w,a1 as de,F as Q,H as J,L as he,e as ue,l as K,bc as P,d as Y,b as pe,a as fe,q as me,t as ge,g as ye,s as Se,I as ve,bd as xe,A as be}from"./index-CM-nNfuV.js";import{s as we}from"./chunk-2J33WTMH-BL56g_Es.js";import{p as Ce}from"./chunk-4BX2VUAB-DvJD5M9M.js";import{p as Te}from"./wardley-L42UT6IY-BWW2wtVO.js";import{b as I}from"./defaultLocale-DX6XiGOO.js";import{o as Z}from"./ordinal-Cboi1Yqb.js";import"./index-D8z7lcQn.js";import"./init-Gi6I4Gst.js";function Le(e){var a=0,n=e.children,l=n&&n.length;if(!l)a=1;else for(;--l>=0;)a+=n[l].value;e.value=a}function $e(){return this.eachAfter(Le)}function Ae(e,a){let n=-1;for(const l of this)e.call(a,l,++n,this);return this}function Fe(e,a){for(var n=this,l=[n],r,o,d=-1;n=l.pop();)if(e.call(a,n,++d,this),r=n.children)for(o=r.length-1;o>=0;--o)l.push(r[o]);return this}function Ne(e,a){for(var n=this,l=[n],r=[],o,d,h,m=-1;n=l.pop();)if(r.push(n),o=n.children)for(d=0,h=o.length;d<h;++d)l.push(o[d]);for(;n=r.pop();)e.call(a,n,++m,this);return this}function Me(e,a){let n=-1;for(const l of this)if(e.call(a,l,++n,this))return l}function Ve(e){return this.eachAfter(function(a){for(var n=+e(a.data)||0,l=a.children,r=l&&l.length;--r>=0;)n+=l[r].value;a.value=n})}function _e(e){return this.eachBefore(function(a){a.children&&a.children.sort(e)})}function ke(e){for(var a=this,n=ze(a,e),l=[a];a!==n;)a=a.parent,l.push(a);for(var r=l.length;e!==n;)l.splice(r,0,e),e=e.parent;return l}function ze(e,a){if(e===a)return e;var n=e.ancestors(),l=a.ancestors(),r=null;for(e=n.pop(),a=l.pop();e===a;)r=e,e=n.pop(),a=l.pop();return r}function De(){for(var e=this,a=[e];e=e.parent;)a.push(e);return a}function Pe(){return Array.from(this)}function Be(){var e=[];return this.eachBefore(function(a){a.children||e.push(a)}),e}function Re(){var e=this,a=[];return e.each(function(n){n!==e&&a.push({source:n.parent,target:n})}),a}function*Ee(){var e=this,a,n=[e],l,r,o;do for(a=n.reverse(),n=[];e=a.pop();)if(yield e,l=e.children)for(r=0,o=l.length;r<o;++r)n.push(l[r]);while(n.length)}function ee(e,a){e instanceof Map?(e=[void 0,e],a===void 0&&(a=Ie)):a===void 0&&(a=He);for(var n=new j(e),l,r=[n],o,d,h,m;l=r.pop();)if((d=a(l.data))&&(m=(d=Array.from(d)).length))for(l.children=d,h=m-1;h>=0;--h)r.push(o=d[h]=new j(d[h])),o.parent=l,o.depth=l.depth+1;return n.eachBefore(qe)}function We(){return ee(this).eachBefore(Oe)}function He(e){return e.children}function Ie(e){return Array.isArray(e)?e[1]:null}function Oe(e){e.data.value!==void 0&&(e.value=e.data.value),e.data=e.data.data}function qe(e){var a=0;do e.height=a;while((e=e.parent)&&e.height<++a)}function j(e){this.data=e,this.depth=this.height=0,this.parent=null}j.prototype=ee.prototype={constructor:j,count:$e,each:Ae,eachAfter:Ne,eachBefore:Fe,find:Me,sum:Ve,sort:_e,path:ke,ancestors:De,descendants:Pe,leaves:Be,links:Re,copy:We,[Symbol.iterator]:Ee};function Ge(e){if(typeof e!="function")throw new Error;return e}function O(){return 0}function q(e){return function(){return e}}function Xe(e){e.x0=Math.round(e.x0),e.y0=Math.round(e.y0),e.x1=Math.round(e.x1),e.y1=Math.round(e.y1)}function Ye(e,a,n,l,r){for(var o=e.children,d,h=-1,m=o.length,c=e.value&&(l-a)/e.value;++h<m;)d=o[h],d.y0=n,d.y1=r,d.x0=a,d.x1=a+=d.value*c}function je(e,a,n,l,r){for(var o=e.children,d,h=-1,m=o.length,c=e.value&&(r-n)/e.value;++h<m;)d=o[h],d.x0=a,d.x1=l,d.y0=n,d.y1=n+=d.value*c}var Ue=(1+Math.sqrt(5))/2;function Ze(e,a,n,l,r,o){for(var d=[],h=a.children,m,c,u=0,b=0,s=h.length,x,S,v=a.value,p,g,M,N,z,R,V;u<s;){x=r-n,S=o-l;do p=h[b++].value;while(!p&&b<s);for(g=M=p,R=Math.max(S/x,x/S)/(v*e),V=p*p*R,z=Math.max(M/V,V/g);b<s;++b){if(p+=c=h[b].value,c<g&&(g=c),c>M&&(M=c),V=p*p*R,N=Math.max(M/V,V/g),N>z){p-=c;break}z=N}d.push(m={value:p,dice:x<S,children:h.slice(u,b)}),m.dice?Ye(m,n,l,r,v?l+=S*p/v:o):je(m,n,l,v?n+=x*p/v:r,o),v-=p,u=b}return d}const Je=(function e(a){function n(l,r,o,d,h){Ze(a,l,r,o,d,h)}return n.ratio=function(l){return e((l=+l)>1?l:1)},n})(Ue);function Ke(){var e=Je,a=!1,n=1,l=1,r=[0],o=O,d=O,h=O,m=O,c=O;function u(s){return s.x0=s.y0=0,s.x1=n,s.y1=l,s.eachBefore(b),r=[0],a&&s.eachBefore(Xe),s}function b(s){var x=r[s.depth],S=s.x0+x,v=s.y0+x,p=s.x1-x,g=s.y1-x;p<S&&(S=p=(S+p)/2),g<v&&(v=g=(v+g)/2),s.x0=S,s.y0=v,s.x1=p,s.y1=g,s.children&&(x=r[s.depth+1]=o(s)/2,S+=c(s)-x,v+=d(s)-x,p-=h(s)-x,g-=m(s)-x,p<S&&(S=p=(S+p)/2),g<v&&(v=g=(v+g)/2),e(s,S,v,p,g))}return u.round=function(s){return arguments.length?(a=!!s,u):a},u.size=function(s){return arguments.length?(n=+s[0],l=+s[1],u):[n,l]},u.tile=function(s){return arguments.length?(e=Ge(s),u):e},u.padding=function(s){return arguments.length?u.paddingInner(s).paddingOuter(s):u.paddingInner()},u.paddingInner=function(s){return arguments.length?(o=typeof s=="function"?s:q(+s),u):o},u.paddingOuter=function(s){return arguments.length?u.paddingTop(s).paddingRight(s).paddingBottom(s).paddingLeft(s):u.paddingTop()},u.paddingTop=function(s){return arguments.length?(d=typeof s=="function"?s:q(+s),u):d},u.paddingRight=function(s){return arguments.length?(h=typeof s=="function"?s:q(+s),u):h},u.paddingBottom=function(s){return arguments.length?(m=typeof s=="function"?s:q(+s),u):m},u.paddingLeft=function(s){return arguments.length?(c=typeof s=="function"?s:q(+s),u):c},u}var ae=class{constructor(){this.nodes=[],this.levels=new Map,this.outerNodes=[],this.classes=new Map,this.setAccTitle=pe,this.getAccTitle=fe,this.setDiagramTitle=me,this.getDiagramTitle=ge,this.getAccDescription=ye,this.setAccDescription=Se}static{w(this,"TreeMapDB")}getNodes(){return this.nodes}getConfig(){const e=ve,a=Q();return J({...e.treemap,...a.treemap??{}})}addNode(e,a){this.nodes.push(e),this.levels.set(e,a),a===0&&(this.outerNodes.push(e),this.root??=e)}getRoot(){return{name:"",children:this.outerNodes}}addClass(e,a){const n=this.classes.get(e)??{id:e,styles:[],textStyles:[]},l=a.replace(/\\,/g,"§§§").replace(/,/g,";").replace(/§§§/g,",").split(";");l&&l.forEach(r=>{xe(r)&&(n?.textStyles?n.textStyles.push(r):n.textStyles=[r]),n?.styles?n.styles.push(r):n.styles=[r]}),this.classes.set(e,n)}getClasses(){return this.classes}getStylesForClass(e){return this.classes.get(e)?.styles??[]}clear(){be(),this.nodes=[],this.levels=new Map,this.outerNodes=[],this.classes=new Map,this.root=void 0}};function ne(e){if(!e.length)return[];const a=[],n=[];return e.forEach(l=>{const r={name:l.name,children:l.type==="Leaf"?void 0:[]};for(r.classSelector=l?.classSelector,l?.cssCompiledStyles&&(r.cssCompiledStyles=l.cssCompiledStyles),l.type==="Leaf"&&l.value!==void 0&&(r.value=l.value);n.length>0&&n[n.length-1].level>=l.level;)n.pop();if(n.length===0)a.push(r);else{const o=n[n.length-1].node;o.children?o.children.push(r):o.children=[r]}l.type!=="Leaf"&&n.push({node:r,level:l.level})}),a}w(ne,"buildHierarchy");var Qe=w((e,a)=>{Ce(e,a);const n=[];for(const o of e.TreemapRows??[])o.$type==="ClassDefStatement"&&a.addClass(o.className??"",o.styleText??"");for(const o of e.TreemapRows??[]){const d=o.item;if(!d)continue;const h=o.indent?parseInt(o.indent):0,m=et(d),c=d.classSelector?a.getStylesForClass(d.classSelector):[],u=c.length>0?c:void 0,b={level:h,name:m,type:d.$type,value:d.value,classSelector:d.classSelector,cssCompiledStyles:u};n.push(b)}const l=ne(n),r=w((o,d)=>{for(const h of o)a.addNode(h,d),h.children&&h.children.length>0&&r(h.children,d+1)},"addNodesRecursively");r(l,0)},"populate"),et=w(e=>e.name?String(e.name):"","getItemName"),le={parser:{yy:void 0},parse:w(async e=>{try{const n=await Te("treemap",e);K.debug("Treemap AST:",n);const l=le.parser?.yy;if(!(l instanceof ae))throw new Error("parser.parser?.yy was not a TreemapDB. This is due to a bug within Mermaid, please report this issue at https://github.com/mermaid-js/mermaid/issues.");Qe(n,l)}catch(a){throw K.error("Error parsing treemap:",a),a}},"parse")},tt=10,B=10,G=25,at=w((e,a,n,l)=>{const r=l.db,o=r.getConfig(),d=o.padding??tt,h=r.getDiagramTitle(),m=r.getRoot(),{themeVariables:c}=Q();if(!m)return;const u=h?30:0,b=he(a),s=o.nodeWidth?o.nodeWidth*B:960,x=o.nodeHeight?o.nodeHeight*B:500,S=s,v=x+u;b.attr("viewBox",`0 0 ${S} ${v}`),ue(b,v,S,o.useMaxWidth);let p;try{const t=o.valueFormat||",";if(t==="$0,0")p=w(i=>"$"+I(",")(i),"valueFormat");else if(t.startsWith("$")&&t.includes(",")){const i=/\.\d+/.exec(t),f=i?i[0]:"";p=w(C=>"$"+I(","+f)(C),"valueFormat")}else if(t.startsWith("$")){const i=t.substring(1);p=w(f=>"$"+I(i||"")(f),"valueFormat")}else p=I(t)}catch(t){K.error("Error creating format function:",t),p=I(",")}const g=Z().range(["transparent",c.cScale0,c.cScale1,c.cScale2,c.cScale3,c.cScale4,c.cScale5,c.cScale6,c.cScale7,c.cScale8,c.cScale9,c.cScale10,c.cScale11]),M=Z().range(["transparent",c.cScalePeer0,c.cScalePeer1,c.cScalePeer2,c.cScalePeer3,c.cScalePeer4,c.cScalePeer5,c.cScalePeer6,c.cScalePeer7,c.cScalePeer8,c.cScalePeer9,c.cScalePeer10,c.cScalePeer11]),N=Z().range([c.cScaleLabel0,c.cScaleLabel1,c.cScaleLabel2,c.cScaleLabel3,c.cScaleLabel4,c.cScaleLabel5,c.cScaleLabel6,c.cScaleLabel7,c.cScaleLabel8,c.cScaleLabel9,c.cScaleLabel10,c.cScaleLabel11]);h&&b.append("text").attr("x",S/2).attr("y",u/2).attr("class","treemapTitle").attr("text-anchor","middle").attr("dominant-baseline","middle").text(h);const z=b.append("g").attr("transform",`translate(0, ${u})`).attr("class","treemapContainer"),R=ee(m).sum(t=>t.value??0).sort((t,i)=>(i.value??0)-(t.value??0)),te=Ke().size([s,x]).paddingTop(t=>t.children&&t.children.length>0?G+B:0).paddingInner(d).paddingLeft(t=>t.children&&t.children.length>0?B:0).paddingRight(t=>t.children&&t.children.length>0?B:0).paddingBottom(t=>t.children&&t.children.length>0?B:0).round(!0)(R),re=te.descendants().filter(t=>t.children&&t.children.length>0),E=z.selectAll(".treemapSection").data(re).enter().append("g").attr("class","treemapSection").attr("transform",t=>`translate(${t.x0},${t.y0})`);E.append("rect").attr("width",t=>t.x1-t.x0).attr("height",G).attr("class","treemapSectionHeader").attr("fill","none").attr("fill-opacity",.6).attr("stroke-width",.6).attr("style",t=>t.depth===0?"display: none;":""),E.append("clipPath").attr("id",(t,i)=>`clip-section-${a}-${i}`).append("rect").attr("width",t=>Math.max(0,t.x1-t.x0-12)).attr("height",G),E.append("rect").attr("width",t=>t.x1-t.x0).attr("height",t=>t.y1-t.y0).attr("class",(t,i)=>`treemapSection section${i}`).attr("fill",t=>g(t.data.name)).attr("fill-opacity",.6).attr("stroke",t=>M(t.data.name)).attr("stroke-width",2).attr("stroke-opacity",.4).attr("style",t=>{if(t.depth===0)return"display: none;";const i=P({cssCompiledStyles:t.data.cssCompiledStyles});return i.nodeStyles+";"+i.borderStyles.join(";")}),E.append("text").attr("class","treemapSectionLabel").attr("x",6).attr("y",G/2).attr("dominant-baseline","middle").text(t=>t.depth===0?"":t.data.name).attr("font-weight","bold").attr("style",t=>{if(t.depth===0)return"display: none;";const i="dominant-baseline: middle; font-size: 12px; fill:"+N(t.data.name)+"; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;",f=P({cssCompiledStyles:t.data.cssCompiledStyles});return i+f.labelStyles.replace("color:","fill:")}).each(function(t){if(t.depth===0)return;const i=Y(this),f=t.data.name;i.text(f);const C=t.x1-t.x0,L=6;let $;o.showValues!==!1&&t.value?$=C-10-30-10-L:$=C-L-6;const A=Math.max(15,$),y=i.node();if(y.getComputedTextLength()>A){let T=f;for(;T.length>0;){if(T=f.substring(0,T.length-1),T.length===0){i.text("..."),y.getComputedTextLength()>A&&i.text("");break}if(i.text(T+"..."),y.getComputedTextLength()<=A)break}}}),o.showValues!==!1&&E.append("text").attr("class","treemapSectionValue").attr("x",t=>t.x1-t.x0-10).attr("y",G/2).attr("text-anchor","end").attr("dominant-baseline","middle").text(t=>t.value?p(t.value):"").attr("font-style","italic").attr("style",t=>{if(t.depth===0)return"display: none;";const i="text-anchor: end; dominant-baseline: middle; font-size: 10px; fill:"+N(t.data.name)+"; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;",f=P({cssCompiledStyles:t.data.cssCompiledStyles});return i+f.labelStyles.replace("color:","fill:")});const se=te.leaves(),X=z.selectAll(".treemapLeafGroup").data(se).enter().append("g").attr("class",(t,i)=>`treemapNode treemapLeafGroup leaf${i}${t.data.classSelector?` ${t.data.classSelector}`:""}x`).attr("transform",t=>`translate(${t.x0},${t.y0})`);X.append("rect").attr("width",t=>t.x1-t.x0).attr("height",t=>t.y1-t.y0).attr("class","treemapLeaf").attr("fill",t=>t.parent?g(t.parent.data.name):g(t.data.name)).attr("style",t=>P({cssCompiledStyles:t.data.cssCompiledStyles}).nodeStyles).attr("fill-opacity",.3).attr("stroke",t=>t.parent?g(t.parent.data.name):g(t.data.name)).attr("stroke-width",3),X.append("clipPath").attr("id",(t,i)=>`clip-${a}-${i}`).append("rect").attr("width",t=>Math.max(0,t.x1-t.x0-4)).attr("height",t=>Math.max(0,t.y1-t.y0-4)),X.append("text").attr("class","treemapLabel").attr("x",t=>(t.x1-t.x0)/2).attr("y",t=>(t.y1-t.y0)/2).attr("style",t=>{const i="text-anchor: middle; dominant-baseline: middle; font-size: 38px;fill:"+N(t.data.name)+";",f=P({cssCompiledStyles:t.data.cssCompiledStyles});return i+f.labelStyles.replace("color:","fill:")}).attr("clip-path",(t,i)=>`url(#clip-${a}-${i})`).text(t=>t.data.name).each(function(t){const i=Y(this),f=t.x1-t.x0,C=t.y1-t.y0,L=i.node(),$=4,D=f-2*$,A=C-2*$;if(D<10||A<10){i.style("display","none");return}let y=parseInt(i.style("font-size"),10);const _=8,F=28,T=.6,k=6,W=2;for(;L.getComputedTextLength()>D&&y>_;)y--,i.style("font-size",`${y}px`);let H=Math.max(k,Math.min(F,Math.round(y*T))),U=y+W+H;for(;U>A&&y>_&&(y--,H=Math.max(k,Math.min(F,Math.round(y*T))),!(H<k&&y===_));)i.style("font-size",`${y}px`),U=y+W+H;i.style("font-size",`${y}px`),(L.getComputedTextLength()>D||y<_||A<y)&&i.style("display","none")}),o.showValues!==!1&&X.append("text").attr("class","treemapValue").attr("x",i=>(i.x1-i.x0)/2).attr("y",function(i){return(i.y1-i.y0)/2}).attr("style",i=>{const f="text-anchor: middle; dominant-baseline: hanging; font-size: 28px;fill:"+N(i.data.name)+";",C=P({cssCompiledStyles:i.data.cssCompiledStyles});return f+C.labelStyles.replace("color:","fill:")}).attr("clip-path",(i,f)=>`url(#clip-${a}-${f})`).text(i=>i.value?p(i.value):"").each(function(i){const f=Y(this),C=this.parentNode;if(!C){f.style("display","none");return}const L=Y(C).select(".treemapLabel");if(L.empty()||L.style("display")==="none"){f.style("display","none");return}const $=parseFloat(L.style("font-size")),D=28,A=.6,y=6,_=2,F=Math.max(y,Math.min(D,Math.round($*A)));f.style("font-size",`${F}px`);const k=(i.y1-i.y0)/2+$/2+_;f.attr("y",k);const W=i.x1-i.x0,oe=i.y1-i.y0-4,ce=W-8;f.node().getComputedTextLength()>ce||k+F>oe||F<y?f.style("display","none"):f.style("display",null)});const ie=o.diagramPadding??8;we(b,ie,"flowchart",o?.useMaxWidth||!1)},"draw"),nt=w(function(e,a){return a.db.getClasses()},"getClasses"),lt={draw:at,getClasses:nt},rt={sectionStrokeColor:"black",sectionStrokeWidth:"1",sectionFillColor:"#efefef",leafStrokeColor:"black",leafStrokeWidth:"1",leafFillColor:"#efefef",labelFontSize:"12px",valueFontSize:"10px",titleFontSize:"14px"},st=w(({treemap:e}={})=>{const a=de(),n=Q(),l=J(a,n.themeVariables),r=J(rt,e),o=r.titleColor??l.titleColor,d=r.labelColor??l.textColor,h=r.valueColor??l.textColor;return`
1
+ import{_ as w,a1 as de,F as Q,H as J,L as he,e as ue,l as K,bc as P,d as Y,b as pe,a as fe,q as me,t as ge,g as ye,s as Se,I as ve,bd as xe,A as be}from"./index-C6qeLCPw.js";import{s as we}from"./chunk-2J33WTMH-CpjgczxM.js";import{p as Ce}from"./chunk-4BX2VUAB-BScxUF5G.js";import{p as Te}from"./wardley-L42UT6IY-DuZZr5jm.js";import{b as I}from"./defaultLocale-DX6XiGOO.js";import{o as Z}from"./ordinal-Cboi1Yqb.js";import"./index-B0KPRi1U.js";import"./init-Gi6I4Gst.js";function Le(e){var a=0,n=e.children,l=n&&n.length;if(!l)a=1;else for(;--l>=0;)a+=n[l].value;e.value=a}function $e(){return this.eachAfter(Le)}function Ae(e,a){let n=-1;for(const l of this)e.call(a,l,++n,this);return this}function Fe(e,a){for(var n=this,l=[n],r,o,d=-1;n=l.pop();)if(e.call(a,n,++d,this),r=n.children)for(o=r.length-1;o>=0;--o)l.push(r[o]);return this}function Ne(e,a){for(var n=this,l=[n],r=[],o,d,h,m=-1;n=l.pop();)if(r.push(n),o=n.children)for(d=0,h=o.length;d<h;++d)l.push(o[d]);for(;n=r.pop();)e.call(a,n,++m,this);return this}function Me(e,a){let n=-1;for(const l of this)if(e.call(a,l,++n,this))return l}function Ve(e){return this.eachAfter(function(a){for(var n=+e(a.data)||0,l=a.children,r=l&&l.length;--r>=0;)n+=l[r].value;a.value=n})}function _e(e){return this.eachBefore(function(a){a.children&&a.children.sort(e)})}function ke(e){for(var a=this,n=ze(a,e),l=[a];a!==n;)a=a.parent,l.push(a);for(var r=l.length;e!==n;)l.splice(r,0,e),e=e.parent;return l}function ze(e,a){if(e===a)return e;var n=e.ancestors(),l=a.ancestors(),r=null;for(e=n.pop(),a=l.pop();e===a;)r=e,e=n.pop(),a=l.pop();return r}function De(){for(var e=this,a=[e];e=e.parent;)a.push(e);return a}function Pe(){return Array.from(this)}function Be(){var e=[];return this.eachBefore(function(a){a.children||e.push(a)}),e}function Re(){var e=this,a=[];return e.each(function(n){n!==e&&a.push({source:n.parent,target:n})}),a}function*Ee(){var e=this,a,n=[e],l,r,o;do for(a=n.reverse(),n=[];e=a.pop();)if(yield e,l=e.children)for(r=0,o=l.length;r<o;++r)n.push(l[r]);while(n.length)}function ee(e,a){e instanceof Map?(e=[void 0,e],a===void 0&&(a=Ie)):a===void 0&&(a=He);for(var n=new j(e),l,r=[n],o,d,h,m;l=r.pop();)if((d=a(l.data))&&(m=(d=Array.from(d)).length))for(l.children=d,h=m-1;h>=0;--h)r.push(o=d[h]=new j(d[h])),o.parent=l,o.depth=l.depth+1;return n.eachBefore(qe)}function We(){return ee(this).eachBefore(Oe)}function He(e){return e.children}function Ie(e){return Array.isArray(e)?e[1]:null}function Oe(e){e.data.value!==void 0&&(e.value=e.data.value),e.data=e.data.data}function qe(e){var a=0;do e.height=a;while((e=e.parent)&&e.height<++a)}function j(e){this.data=e,this.depth=this.height=0,this.parent=null}j.prototype=ee.prototype={constructor:j,count:$e,each:Ae,eachAfter:Ne,eachBefore:Fe,find:Me,sum:Ve,sort:_e,path:ke,ancestors:De,descendants:Pe,leaves:Be,links:Re,copy:We,[Symbol.iterator]:Ee};function Ge(e){if(typeof e!="function")throw new Error;return e}function O(){return 0}function q(e){return function(){return e}}function Xe(e){e.x0=Math.round(e.x0),e.y0=Math.round(e.y0),e.x1=Math.round(e.x1),e.y1=Math.round(e.y1)}function Ye(e,a,n,l,r){for(var o=e.children,d,h=-1,m=o.length,c=e.value&&(l-a)/e.value;++h<m;)d=o[h],d.y0=n,d.y1=r,d.x0=a,d.x1=a+=d.value*c}function je(e,a,n,l,r){for(var o=e.children,d,h=-1,m=o.length,c=e.value&&(r-n)/e.value;++h<m;)d=o[h],d.x0=a,d.x1=l,d.y0=n,d.y1=n+=d.value*c}var Ue=(1+Math.sqrt(5))/2;function Ze(e,a,n,l,r,o){for(var d=[],h=a.children,m,c,u=0,b=0,s=h.length,x,S,v=a.value,p,g,M,N,z,R,V;u<s;){x=r-n,S=o-l;do p=h[b++].value;while(!p&&b<s);for(g=M=p,R=Math.max(S/x,x/S)/(v*e),V=p*p*R,z=Math.max(M/V,V/g);b<s;++b){if(p+=c=h[b].value,c<g&&(g=c),c>M&&(M=c),V=p*p*R,N=Math.max(M/V,V/g),N>z){p-=c;break}z=N}d.push(m={value:p,dice:x<S,children:h.slice(u,b)}),m.dice?Ye(m,n,l,r,v?l+=S*p/v:o):je(m,n,l,v?n+=x*p/v:r,o),v-=p,u=b}return d}const Je=(function e(a){function n(l,r,o,d,h){Ze(a,l,r,o,d,h)}return n.ratio=function(l){return e((l=+l)>1?l:1)},n})(Ue);function Ke(){var e=Je,a=!1,n=1,l=1,r=[0],o=O,d=O,h=O,m=O,c=O;function u(s){return s.x0=s.y0=0,s.x1=n,s.y1=l,s.eachBefore(b),r=[0],a&&s.eachBefore(Xe),s}function b(s){var x=r[s.depth],S=s.x0+x,v=s.y0+x,p=s.x1-x,g=s.y1-x;p<S&&(S=p=(S+p)/2),g<v&&(v=g=(v+g)/2),s.x0=S,s.y0=v,s.x1=p,s.y1=g,s.children&&(x=r[s.depth+1]=o(s)/2,S+=c(s)-x,v+=d(s)-x,p-=h(s)-x,g-=m(s)-x,p<S&&(S=p=(S+p)/2),g<v&&(v=g=(v+g)/2),e(s,S,v,p,g))}return u.round=function(s){return arguments.length?(a=!!s,u):a},u.size=function(s){return arguments.length?(n=+s[0],l=+s[1],u):[n,l]},u.tile=function(s){return arguments.length?(e=Ge(s),u):e},u.padding=function(s){return arguments.length?u.paddingInner(s).paddingOuter(s):u.paddingInner()},u.paddingInner=function(s){return arguments.length?(o=typeof s=="function"?s:q(+s),u):o},u.paddingOuter=function(s){return arguments.length?u.paddingTop(s).paddingRight(s).paddingBottom(s).paddingLeft(s):u.paddingTop()},u.paddingTop=function(s){return arguments.length?(d=typeof s=="function"?s:q(+s),u):d},u.paddingRight=function(s){return arguments.length?(h=typeof s=="function"?s:q(+s),u):h},u.paddingBottom=function(s){return arguments.length?(m=typeof s=="function"?s:q(+s),u):m},u.paddingLeft=function(s){return arguments.length?(c=typeof s=="function"?s:q(+s),u):c},u}var ae=class{constructor(){this.nodes=[],this.levels=new Map,this.outerNodes=[],this.classes=new Map,this.setAccTitle=pe,this.getAccTitle=fe,this.setDiagramTitle=me,this.getDiagramTitle=ge,this.getAccDescription=ye,this.setAccDescription=Se}static{w(this,"TreeMapDB")}getNodes(){return this.nodes}getConfig(){const e=ve,a=Q();return J({...e.treemap,...a.treemap??{}})}addNode(e,a){this.nodes.push(e),this.levels.set(e,a),a===0&&(this.outerNodes.push(e),this.root??=e)}getRoot(){return{name:"",children:this.outerNodes}}addClass(e,a){const n=this.classes.get(e)??{id:e,styles:[],textStyles:[]},l=a.replace(/\\,/g,"§§§").replace(/,/g,";").replace(/§§§/g,",").split(";");l&&l.forEach(r=>{xe(r)&&(n?.textStyles?n.textStyles.push(r):n.textStyles=[r]),n?.styles?n.styles.push(r):n.styles=[r]}),this.classes.set(e,n)}getClasses(){return this.classes}getStylesForClass(e){return this.classes.get(e)?.styles??[]}clear(){be(),this.nodes=[],this.levels=new Map,this.outerNodes=[],this.classes=new Map,this.root=void 0}};function ne(e){if(!e.length)return[];const a=[],n=[];return e.forEach(l=>{const r={name:l.name,children:l.type==="Leaf"?void 0:[]};for(r.classSelector=l?.classSelector,l?.cssCompiledStyles&&(r.cssCompiledStyles=l.cssCompiledStyles),l.type==="Leaf"&&l.value!==void 0&&(r.value=l.value);n.length>0&&n[n.length-1].level>=l.level;)n.pop();if(n.length===0)a.push(r);else{const o=n[n.length-1].node;o.children?o.children.push(r):o.children=[r]}l.type!=="Leaf"&&n.push({node:r,level:l.level})}),a}w(ne,"buildHierarchy");var Qe=w((e,a)=>{Ce(e,a);const n=[];for(const o of e.TreemapRows??[])o.$type==="ClassDefStatement"&&a.addClass(o.className??"",o.styleText??"");for(const o of e.TreemapRows??[]){const d=o.item;if(!d)continue;const h=o.indent?parseInt(o.indent):0,m=et(d),c=d.classSelector?a.getStylesForClass(d.classSelector):[],u=c.length>0?c:void 0,b={level:h,name:m,type:d.$type,value:d.value,classSelector:d.classSelector,cssCompiledStyles:u};n.push(b)}const l=ne(n),r=w((o,d)=>{for(const h of o)a.addNode(h,d),h.children&&h.children.length>0&&r(h.children,d+1)},"addNodesRecursively");r(l,0)},"populate"),et=w(e=>e.name?String(e.name):"","getItemName"),le={parser:{yy:void 0},parse:w(async e=>{try{const n=await Te("treemap",e);K.debug("Treemap AST:",n);const l=le.parser?.yy;if(!(l instanceof ae))throw new Error("parser.parser?.yy was not a TreemapDB. This is due to a bug within Mermaid, please report this issue at https://github.com/mermaid-js/mermaid/issues.");Qe(n,l)}catch(a){throw K.error("Error parsing treemap:",a),a}},"parse")},tt=10,B=10,G=25,at=w((e,a,n,l)=>{const r=l.db,o=r.getConfig(),d=o.padding??tt,h=r.getDiagramTitle(),m=r.getRoot(),{themeVariables:c}=Q();if(!m)return;const u=h?30:0,b=he(a),s=o.nodeWidth?o.nodeWidth*B:960,x=o.nodeHeight?o.nodeHeight*B:500,S=s,v=x+u;b.attr("viewBox",`0 0 ${S} ${v}`),ue(b,v,S,o.useMaxWidth);let p;try{const t=o.valueFormat||",";if(t==="$0,0")p=w(i=>"$"+I(",")(i),"valueFormat");else if(t.startsWith("$")&&t.includes(",")){const i=/\.\d+/.exec(t),f=i?i[0]:"";p=w(C=>"$"+I(","+f)(C),"valueFormat")}else if(t.startsWith("$")){const i=t.substring(1);p=w(f=>"$"+I(i||"")(f),"valueFormat")}else p=I(t)}catch(t){K.error("Error creating format function:",t),p=I(",")}const g=Z().range(["transparent",c.cScale0,c.cScale1,c.cScale2,c.cScale3,c.cScale4,c.cScale5,c.cScale6,c.cScale7,c.cScale8,c.cScale9,c.cScale10,c.cScale11]),M=Z().range(["transparent",c.cScalePeer0,c.cScalePeer1,c.cScalePeer2,c.cScalePeer3,c.cScalePeer4,c.cScalePeer5,c.cScalePeer6,c.cScalePeer7,c.cScalePeer8,c.cScalePeer9,c.cScalePeer10,c.cScalePeer11]),N=Z().range([c.cScaleLabel0,c.cScaleLabel1,c.cScaleLabel2,c.cScaleLabel3,c.cScaleLabel4,c.cScaleLabel5,c.cScaleLabel6,c.cScaleLabel7,c.cScaleLabel8,c.cScaleLabel9,c.cScaleLabel10,c.cScaleLabel11]);h&&b.append("text").attr("x",S/2).attr("y",u/2).attr("class","treemapTitle").attr("text-anchor","middle").attr("dominant-baseline","middle").text(h);const z=b.append("g").attr("transform",`translate(0, ${u})`).attr("class","treemapContainer"),R=ee(m).sum(t=>t.value??0).sort((t,i)=>(i.value??0)-(t.value??0)),te=Ke().size([s,x]).paddingTop(t=>t.children&&t.children.length>0?G+B:0).paddingInner(d).paddingLeft(t=>t.children&&t.children.length>0?B:0).paddingRight(t=>t.children&&t.children.length>0?B:0).paddingBottom(t=>t.children&&t.children.length>0?B:0).round(!0)(R),re=te.descendants().filter(t=>t.children&&t.children.length>0),E=z.selectAll(".treemapSection").data(re).enter().append("g").attr("class","treemapSection").attr("transform",t=>`translate(${t.x0},${t.y0})`);E.append("rect").attr("width",t=>t.x1-t.x0).attr("height",G).attr("class","treemapSectionHeader").attr("fill","none").attr("fill-opacity",.6).attr("stroke-width",.6).attr("style",t=>t.depth===0?"display: none;":""),E.append("clipPath").attr("id",(t,i)=>`clip-section-${a}-${i}`).append("rect").attr("width",t=>Math.max(0,t.x1-t.x0-12)).attr("height",G),E.append("rect").attr("width",t=>t.x1-t.x0).attr("height",t=>t.y1-t.y0).attr("class",(t,i)=>`treemapSection section${i}`).attr("fill",t=>g(t.data.name)).attr("fill-opacity",.6).attr("stroke",t=>M(t.data.name)).attr("stroke-width",2).attr("stroke-opacity",.4).attr("style",t=>{if(t.depth===0)return"display: none;";const i=P({cssCompiledStyles:t.data.cssCompiledStyles});return i.nodeStyles+";"+i.borderStyles.join(";")}),E.append("text").attr("class","treemapSectionLabel").attr("x",6).attr("y",G/2).attr("dominant-baseline","middle").text(t=>t.depth===0?"":t.data.name).attr("font-weight","bold").attr("style",t=>{if(t.depth===0)return"display: none;";const i="dominant-baseline: middle; font-size: 12px; fill:"+N(t.data.name)+"; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;",f=P({cssCompiledStyles:t.data.cssCompiledStyles});return i+f.labelStyles.replace("color:","fill:")}).each(function(t){if(t.depth===0)return;const i=Y(this),f=t.data.name;i.text(f);const C=t.x1-t.x0,L=6;let $;o.showValues!==!1&&t.value?$=C-10-30-10-L:$=C-L-6;const A=Math.max(15,$),y=i.node();if(y.getComputedTextLength()>A){let T=f;for(;T.length>0;){if(T=f.substring(0,T.length-1),T.length===0){i.text("..."),y.getComputedTextLength()>A&&i.text("");break}if(i.text(T+"..."),y.getComputedTextLength()<=A)break}}}),o.showValues!==!1&&E.append("text").attr("class","treemapSectionValue").attr("x",t=>t.x1-t.x0-10).attr("y",G/2).attr("text-anchor","end").attr("dominant-baseline","middle").text(t=>t.value?p(t.value):"").attr("font-style","italic").attr("style",t=>{if(t.depth===0)return"display: none;";const i="text-anchor: end; dominant-baseline: middle; font-size: 10px; fill:"+N(t.data.name)+"; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;",f=P({cssCompiledStyles:t.data.cssCompiledStyles});return i+f.labelStyles.replace("color:","fill:")});const se=te.leaves(),X=z.selectAll(".treemapLeafGroup").data(se).enter().append("g").attr("class",(t,i)=>`treemapNode treemapLeafGroup leaf${i}${t.data.classSelector?` ${t.data.classSelector}`:""}x`).attr("transform",t=>`translate(${t.x0},${t.y0})`);X.append("rect").attr("width",t=>t.x1-t.x0).attr("height",t=>t.y1-t.y0).attr("class","treemapLeaf").attr("fill",t=>t.parent?g(t.parent.data.name):g(t.data.name)).attr("style",t=>P({cssCompiledStyles:t.data.cssCompiledStyles}).nodeStyles).attr("fill-opacity",.3).attr("stroke",t=>t.parent?g(t.parent.data.name):g(t.data.name)).attr("stroke-width",3),X.append("clipPath").attr("id",(t,i)=>`clip-${a}-${i}`).append("rect").attr("width",t=>Math.max(0,t.x1-t.x0-4)).attr("height",t=>Math.max(0,t.y1-t.y0-4)),X.append("text").attr("class","treemapLabel").attr("x",t=>(t.x1-t.x0)/2).attr("y",t=>(t.y1-t.y0)/2).attr("style",t=>{const i="text-anchor: middle; dominant-baseline: middle; font-size: 38px;fill:"+N(t.data.name)+";",f=P({cssCompiledStyles:t.data.cssCompiledStyles});return i+f.labelStyles.replace("color:","fill:")}).attr("clip-path",(t,i)=>`url(#clip-${a}-${i})`).text(t=>t.data.name).each(function(t){const i=Y(this),f=t.x1-t.x0,C=t.y1-t.y0,L=i.node(),$=4,D=f-2*$,A=C-2*$;if(D<10||A<10){i.style("display","none");return}let y=parseInt(i.style("font-size"),10);const _=8,F=28,T=.6,k=6,W=2;for(;L.getComputedTextLength()>D&&y>_;)y--,i.style("font-size",`${y}px`);let H=Math.max(k,Math.min(F,Math.round(y*T))),U=y+W+H;for(;U>A&&y>_&&(y--,H=Math.max(k,Math.min(F,Math.round(y*T))),!(H<k&&y===_));)i.style("font-size",`${y}px`),U=y+W+H;i.style("font-size",`${y}px`),(L.getComputedTextLength()>D||y<_||A<y)&&i.style("display","none")}),o.showValues!==!1&&X.append("text").attr("class","treemapValue").attr("x",i=>(i.x1-i.x0)/2).attr("y",function(i){return(i.y1-i.y0)/2}).attr("style",i=>{const f="text-anchor: middle; dominant-baseline: hanging; font-size: 28px;fill:"+N(i.data.name)+";",C=P({cssCompiledStyles:i.data.cssCompiledStyles});return f+C.labelStyles.replace("color:","fill:")}).attr("clip-path",(i,f)=>`url(#clip-${a}-${f})`).text(i=>i.value?p(i.value):"").each(function(i){const f=Y(this),C=this.parentNode;if(!C){f.style("display","none");return}const L=Y(C).select(".treemapLabel");if(L.empty()||L.style("display")==="none"){f.style("display","none");return}const $=parseFloat(L.style("font-size")),D=28,A=.6,y=6,_=2,F=Math.max(y,Math.min(D,Math.round($*A)));f.style("font-size",`${F}px`);const k=(i.y1-i.y0)/2+$/2+_;f.attr("y",k);const W=i.x1-i.x0,oe=i.y1-i.y0-4,ce=W-8;f.node().getComputedTextLength()>ce||k+F>oe||F<y?f.style("display","none"):f.style("display",null)});const ie=o.diagramPadding??8;we(b,ie,"flowchart",o?.useMaxWidth||!1)},"draw"),nt=w(function(e,a){return a.db.getClasses()},"getClasses"),lt={draw:at,getClasses:nt},rt={sectionStrokeColor:"black",sectionStrokeWidth:"1",sectionFillColor:"#efefef",leafStrokeColor:"black",leafStrokeWidth:"1",leafFillColor:"#efefef",labelFontSize:"12px",valueFontSize:"10px",titleFontSize:"14px"},st=w(({treemap:e}={})=>{const a=de(),n=Q(),l=J(a,n.themeVariables),r=J(rt,e),o=r.titleColor??l.titleColor,d=r.labelColor??l.textColor,h=r.valueColor??l.textColor;return`
2
2
  .treemapNode.section {
3
3
  stroke: ${r.sectionStrokeColor};
4
4
  stroke-width: ${r.sectionStrokeWidth};
@@ -1,4 +1,4 @@
1
- import{g as Mt}from"./chunk-55IACEB6-C8f-nzvx.js";import{s as Bt}from"./chunk-2J33WTMH-BL56g_Es.js";import{_ as l,b as Ft,a as Yt,s as Pt,g as zt,q as Gt,t as Kt,c as it,l as V,A as Ut,y as Zt,C as jt,E as Wt,p as Qt,r as Xt,d as Ht,u as qt}from"./index-CM-nNfuV.js";import{c as Jt}from"./channel-Bj_gZ_Lv.js";import"./index-D8z7lcQn.js";var _t=(function(){var e=l(function(C,n,c,o){for(c=c||{},o=C.length;o--;c[C[o]]=n);return c},"o"),i=[6,8,10,22,24,26,28,33,34,35,36,37,40,43,44,48,50,51,52],h=[1,10],a=[1,11],u=[1,12],d=[1,13],y=[1,23],f=[1,24],m=[1,25],j=[1,26],W=[1,27],T=[1,19],Q=[1,28],M=[1,29],D=[1,20],I=[1,18],S=[1,21],R=[1,22],nt=[1,36],at=[1,37],ct=[1,38],ot=[1,39],lt=[1,40],B=[6,8,10,13,15,17,20,21,22,24,26,28,33,34,35,36,37,40,43,44,48,50,51,52,65,66,67,68,69],O=[1,45],A=[1,46],F=[1,55],Y=[40,48,50,51,52,70,71],P=[1,66],z=[1,64],N=[1,61],G=[1,65],K=[1,67],X=[6,8,10,13,17,22,24,26,28,33,34,35,36,37,40,41,42,43,44,48,49,50,51,52,65,66,67,68,69],gt=[65,66,67,68,69],bt=[1,84],kt=[1,83],mt=[1,81],Et=[1,82],Tt=[6,10,42,47],L=[6,10,13,41,42,47,48,49],H=[1,92],q=[1,91],J=[1,90],U=[19,58],St=[1,101],Ot=[1,100],ht=[19,58,60,62],ut={trace:l(function(){},"trace"),yy:{},symbols_:{error:2,start:3,ER_DIAGRAM:4,document:5,EOF:6,line:7,SPACE:8,statement:9,NEWLINE:10,entityName:11,relSpec:12,COLON:13,role:14,STYLE_SEPARATOR:15,idList:16,BLOCK_START:17,attributes:18,BLOCK_STOP:19,SQS:20,SQE:21,title:22,title_value:23,acc_title:24,acc_title_value:25,acc_descr:26,acc_descr_value:27,acc_descr_multiline_value:28,direction:29,classDefStatement:30,classStatement:31,styleStatement:32,direction_tb:33,direction_bt:34,direction_rl:35,direction_lr:36,CLASSDEF:37,stylesOpt:38,separator:39,UNICODE_TEXT:40,STYLE_TEXT:41,COMMA:42,CLASS:43,STYLE:44,style:45,styleComponent:46,SEMI:47,NUM:48,BRKT:49,ENTITY_NAME:50,DECIMAL_NUM:51,ENTITY_ONE:52,attribute:53,attributeType:54,attributeName:55,attributeKeyTypeList:56,attributeComment:57,ATTRIBUTE_WORD:58,attributeKeyType:59,",":60,ATTRIBUTE_KEY:61,COMMENT:62,cardinality:63,relType:64,ZERO_OR_ONE:65,ZERO_OR_MORE:66,ONE_OR_MORE:67,ONLY_ONE:68,MD_PARENT:69,NON_IDENTIFYING:70,IDENTIFYING:71,WORD:72,$accept:0,$end:1},terminals_:{2:"error",4:"ER_DIAGRAM",6:"EOF",8:"SPACE",10:"NEWLINE",13:"COLON",15:"STYLE_SEPARATOR",17:"BLOCK_START",19:"BLOCK_STOP",20:"SQS",21:"SQE",22:"title",23:"title_value",24:"acc_title",25:"acc_title_value",26:"acc_descr",27:"acc_descr_value",28:"acc_descr_multiline_value",33:"direction_tb",34:"direction_bt",35:"direction_rl",36:"direction_lr",37:"CLASSDEF",40:"UNICODE_TEXT",41:"STYLE_TEXT",42:"COMMA",43:"CLASS",44:"STYLE",47:"SEMI",48:"NUM",49:"BRKT",50:"ENTITY_NAME",51:"DECIMAL_NUM",52:"ENTITY_ONE",58:"ATTRIBUTE_WORD",60:",",61:"ATTRIBUTE_KEY",62:"COMMENT",65:"ZERO_OR_ONE",66:"ZERO_OR_MORE",67:"ONE_OR_MORE",68:"ONLY_ONE",69:"MD_PARENT",70:"NON_IDENTIFYING",71:"IDENTIFYING",72:"WORD"},productions_:[0,[3,3],[5,0],[5,2],[7,2],[7,1],[7,1],[7,1],[9,5],[9,9],[9,7],[9,7],[9,4],[9,6],[9,3],[9,5],[9,1],[9,3],[9,7],[9,9],[9,6],[9,8],[9,4],[9,6],[9,2],[9,2],[9,2],[9,1],[9,1],[9,1],[9,1],[9,1],[29,1],[29,1],[29,1],[29,1],[30,4],[16,1],[16,1],[16,3],[16,3],[31,3],[32,4],[38,1],[38,3],[45,1],[45,2],[39,1],[39,1],[39,1],[46,1],[46,1],[46,1],[46,1],[11,1],[11,1],[11,1],[11,1],[11,1],[18,1],[18,2],[53,2],[53,3],[53,3],[53,4],[54,1],[55,1],[56,1],[56,3],[59,1],[57,1],[12,3],[63,1],[63,1],[63,1],[63,1],[63,1],[64,1],[64,1],[14,1],[14,1],[14,1]],performAction:l(function(n,c,o,r,p,t,Z){var s=t.length-1;switch(p){case 1:break;case 2:this.$=[];break;case 3:t[s-1].push(t[s]),this.$=t[s-1];break;case 4:case 5:this.$=t[s];break;case 6:case 7:this.$=[];break;case 8:r.addEntity(t[s-4]),r.addEntity(t[s-2]),r.addRelationship(t[s-4],t[s],t[s-2],t[s-3]);break;case 9:r.addEntity(t[s-8]),r.addEntity(t[s-4]),r.addRelationship(t[s-8],t[s],t[s-4],t[s-5]),r.setClass([t[s-8]],t[s-6]),r.setClass([t[s-4]],t[s-2]);break;case 10:r.addEntity(t[s-6]),r.addEntity(t[s-2]),r.addRelationship(t[s-6],t[s],t[s-2],t[s-3]),r.setClass([t[s-6]],t[s-4]);break;case 11:r.addEntity(t[s-6]),r.addEntity(t[s-4]),r.addRelationship(t[s-6],t[s],t[s-4],t[s-5]),r.setClass([t[s-4]],t[s-2]);break;case 12:r.addEntity(t[s-3]),r.addAttributes(t[s-3],t[s-1]);break;case 13:r.addEntity(t[s-5]),r.addAttributes(t[s-5],t[s-1]),r.setClass([t[s-5]],t[s-3]);break;case 14:r.addEntity(t[s-2]);break;case 15:r.addEntity(t[s-4]),r.setClass([t[s-4]],t[s-2]);break;case 16:r.addEntity(t[s]);break;case 17:r.addEntity(t[s-2]),r.setClass([t[s-2]],t[s]);break;case 18:r.addEntity(t[s-6],t[s-4]),r.addAttributes(t[s-6],t[s-1]);break;case 19:r.addEntity(t[s-8],t[s-6]),r.addAttributes(t[s-8],t[s-1]),r.setClass([t[s-8]],t[s-3]);break;case 20:r.addEntity(t[s-5],t[s-3]);break;case 21:r.addEntity(t[s-7],t[s-5]),r.setClass([t[s-7]],t[s-2]);break;case 22:r.addEntity(t[s-3],t[s-1]);break;case 23:r.addEntity(t[s-5],t[s-3]),r.setClass([t[s-5]],t[s]);break;case 24:case 25:this.$=t[s].trim(),r.setAccTitle(this.$);break;case 26:case 27:this.$=t[s].trim(),r.setAccDescription(this.$);break;case 32:r.setDirection("TB");break;case 33:r.setDirection("BT");break;case 34:r.setDirection("RL");break;case 35:r.setDirection("LR");break;case 36:this.$=t[s-3],r.addClass(t[s-2],t[s-1]);break;case 37:case 38:case 59:case 67:this.$=[t[s]];break;case 39:case 40:this.$=t[s-2].concat([t[s]]);break;case 41:this.$=t[s-2],r.setClass(t[s-1],t[s]);break;case 42:this.$=t[s-3],r.addCssStyles(t[s-2],t[s-1]);break;case 43:this.$=[t[s]];break;case 44:t[s-2].push(t[s]),this.$=t[s-2];break;case 46:this.$=t[s-1]+t[s];break;case 54:case 79:case 80:this.$=t[s].replace(/"/g,"");break;case 55:case 56:case 57:case 58:case 81:this.$=t[s];break;case 60:t[s].push(t[s-1]),this.$=t[s];break;case 61:this.$={type:t[s-1],name:t[s]};break;case 62:this.$={type:t[s-2],name:t[s-1],keys:t[s]};break;case 63:this.$={type:t[s-2],name:t[s-1],comment:t[s]};break;case 64:this.$={type:t[s-3],name:t[s-2],keys:t[s-1],comment:t[s]};break;case 65:case 66:case 69:this.$=t[s];break;case 68:t[s-2].push(t[s]),this.$=t[s-2];break;case 70:this.$=t[s].replace(/"/g,"");break;case 71:this.$={cardA:t[s],relType:t[s-1],cardB:t[s-2]};break;case 72:this.$=r.Cardinality.ZERO_OR_ONE;break;case 73:this.$=r.Cardinality.ZERO_OR_MORE;break;case 74:this.$=r.Cardinality.ONE_OR_MORE;break;case 75:this.$=r.Cardinality.ONLY_ONE;break;case 76:this.$=r.Cardinality.MD_PARENT;break;case 77:this.$=r.Identification.NON_IDENTIFYING;break;case 78:this.$=r.Identification.IDENTIFYING;break}},"anonymous"),table:[{3:1,4:[1,2]},{1:[3]},e(i,[2,2],{5:3}),{6:[1,4],7:5,8:[1,6],9:7,10:[1,8],11:9,22:h,24:a,26:u,28:d,29:14,30:15,31:16,32:17,33:y,34:f,35:m,36:j,37:W,40:T,43:Q,44:M,48:D,50:I,51:S,52:R},e(i,[2,7],{1:[2,1]}),e(i,[2,3]),{9:30,11:9,22:h,24:a,26:u,28:d,29:14,30:15,31:16,32:17,33:y,34:f,35:m,36:j,37:W,40:T,43:Q,44:M,48:D,50:I,51:S,52:R},e(i,[2,5]),e(i,[2,6]),e(i,[2,16],{12:31,63:35,15:[1,32],17:[1,33],20:[1,34],65:nt,66:at,67:ct,68:ot,69:lt}),{23:[1,41]},{25:[1,42]},{27:[1,43]},e(i,[2,27]),e(i,[2,28]),e(i,[2,29]),e(i,[2,30]),e(i,[2,31]),e(B,[2,54]),e(B,[2,55]),e(B,[2,56]),e(B,[2,57]),e(B,[2,58]),e(i,[2,32]),e(i,[2,33]),e(i,[2,34]),e(i,[2,35]),{16:44,40:O,41:A},{16:47,40:O,41:A},{16:48,40:O,41:A},e(i,[2,4]),{11:49,40:T,48:D,50:I,51:S,52:R},{16:50,40:O,41:A},{18:51,19:[1,52],53:53,54:54,58:F},{11:56,40:T,48:D,50:I,51:S,52:R},{64:57,70:[1,58],71:[1,59]},e(Y,[2,72]),e(Y,[2,73]),e(Y,[2,74]),e(Y,[2,75]),e(Y,[2,76]),e(i,[2,24]),e(i,[2,25]),e(i,[2,26]),{13:P,38:60,41:z,42:N,45:62,46:63,48:G,49:K},e(X,[2,37]),e(X,[2,38]),{16:68,40:O,41:A,42:N},{13:P,38:69,41:z,42:N,45:62,46:63,48:G,49:K},{13:[1,70],15:[1,71]},e(i,[2,17],{63:35,12:72,17:[1,73],42:N,65:nt,66:at,67:ct,68:ot,69:lt}),{19:[1,74]},e(i,[2,14]),{18:75,19:[2,59],53:53,54:54,58:F},{55:76,58:[1,77]},{58:[2,65]},{21:[1,78]},{63:79,65:nt,66:at,67:ct,68:ot,69:lt},e(gt,[2,77]),e(gt,[2,78]),{6:bt,10:kt,39:80,42:mt,47:Et},{40:[1,85],41:[1,86]},e(Tt,[2,43],{46:87,13:P,41:z,48:G,49:K}),e(L,[2,45]),e(L,[2,50]),e(L,[2,51]),e(L,[2,52]),e(L,[2,53]),e(i,[2,41],{42:N}),{6:bt,10:kt,39:88,42:mt,47:Et},{14:89,40:H,50:q,72:J},{16:93,40:O,41:A},{11:94,40:T,48:D,50:I,51:S,52:R},{18:95,19:[1,96],53:53,54:54,58:F},e(i,[2,12]),{19:[2,60]},e(U,[2,61],{56:97,57:98,59:99,61:St,62:Ot}),e([19,58,61,62],[2,66]),e(i,[2,22],{15:[1,103],17:[1,102]}),e([40,48,50,51,52],[2,71]),e(i,[2,36]),{13:P,41:z,45:104,46:63,48:G,49:K},e(i,[2,47]),e(i,[2,48]),e(i,[2,49]),e(X,[2,39]),e(X,[2,40]),e(L,[2,46]),e(i,[2,42]),e(i,[2,8]),e(i,[2,79]),e(i,[2,80]),e(i,[2,81]),{13:[1,105],42:N},{13:[1,107],15:[1,106]},{19:[1,108]},e(i,[2,15]),e(U,[2,62],{57:109,60:[1,110],62:Ot}),e(U,[2,63]),e(ht,[2,67]),e(U,[2,70]),e(ht,[2,69]),{18:111,19:[1,112],53:53,54:54,58:F},{16:113,40:O,41:A},e(Tt,[2,44],{46:87,13:P,41:z,48:G,49:K}),{14:114,40:H,50:q,72:J},{16:115,40:O,41:A},{14:116,40:H,50:q,72:J},e(i,[2,13]),e(U,[2,64]),{59:117,61:St},{19:[1,118]},e(i,[2,20]),e(i,[2,23],{17:[1,119],42:N}),e(i,[2,11]),{13:[1,120],42:N},e(i,[2,10]),e(ht,[2,68]),e(i,[2,18]),{18:121,19:[1,122],53:53,54:54,58:F},{14:123,40:H,50:q,72:J},{19:[1,124]},e(i,[2,21]),e(i,[2,9]),e(i,[2,19])],defaultActions:{55:[2,65],75:[2,60]},parseError:l(function(n,c){if(c.recoverable)this.trace(n);else{var o=new Error(n);throw o.hash=c,o}},"parseError"),parse:l(function(n){var c=this,o=[0],r=[],p=[null],t=[],Z=this.table,s="",tt=0,At=0,Dt=2,Nt=1,Lt=t.slice.call(arguments,1),_=Object.create(this.lexer),x={yy:{}};for(var dt in this.yy)Object.prototype.hasOwnProperty.call(this.yy,dt)&&(x.yy[dt]=this.yy[dt]);_.setInput(n,x.yy),x.yy.lexer=_,x.yy.parser=this,typeof _.yylloc>"u"&&(_.yylloc={});var pt=_.yylloc;t.push(pt);var wt=_.options&&_.options.ranges;typeof x.yy.parseError=="function"?this.parseError=x.yy.parseError:this.parseError=Object.getPrototypeOf(this).parseError;function Vt(b){o.length=o.length-2*b,p.length=p.length-b,t.length=t.length-b}l(Vt,"popStack");function Ct(){var b;return b=r.pop()||_.lex()||Nt,typeof b!="number"&&(b instanceof Array&&(r=b,b=r.pop()),b=c.symbols_[b]||b),b}l(Ct,"lex");for(var g,v,k,ft,w={},et,E,It,st;;){if(v=o[o.length-1],this.defaultActions[v]?k=this.defaultActions[v]:((g===null||typeof g>"u")&&(g=Ct()),k=Z[v]&&Z[v][g]),typeof k>"u"||!k.length||!k[0]){var yt="";st=[];for(et in Z[v])this.terminals_[et]&&et>Dt&&st.push("'"+this.terminals_[et]+"'");_.showPosition?yt="Parse error on line "+(tt+1)+`:
1
+ import{g as Mt}from"./chunk-55IACEB6-CrcLYJXd.js";import{s as Bt}from"./chunk-2J33WTMH-CpjgczxM.js";import{_ as l,b as Ft,a as Yt,s as Pt,g as zt,q as Gt,t as Kt,c as it,l as V,A as Ut,y as Zt,C as jt,E as Wt,p as Qt,r as Xt,d as Ht,u as qt}from"./index-C6qeLCPw.js";import{c as Jt}from"./channel-BJs5vJuh.js";import"./index-B0KPRi1U.js";var _t=(function(){var e=l(function(C,n,c,o){for(c=c||{},o=C.length;o--;c[C[o]]=n);return c},"o"),i=[6,8,10,22,24,26,28,33,34,35,36,37,40,43,44,48,50,51,52],h=[1,10],a=[1,11],u=[1,12],d=[1,13],y=[1,23],f=[1,24],m=[1,25],j=[1,26],W=[1,27],T=[1,19],Q=[1,28],M=[1,29],D=[1,20],I=[1,18],S=[1,21],R=[1,22],nt=[1,36],at=[1,37],ct=[1,38],ot=[1,39],lt=[1,40],B=[6,8,10,13,15,17,20,21,22,24,26,28,33,34,35,36,37,40,43,44,48,50,51,52,65,66,67,68,69],O=[1,45],A=[1,46],F=[1,55],Y=[40,48,50,51,52,70,71],P=[1,66],z=[1,64],N=[1,61],G=[1,65],K=[1,67],X=[6,8,10,13,17,22,24,26,28,33,34,35,36,37,40,41,42,43,44,48,49,50,51,52,65,66,67,68,69],gt=[65,66,67,68,69],bt=[1,84],kt=[1,83],mt=[1,81],Et=[1,82],Tt=[6,10,42,47],L=[6,10,13,41,42,47,48,49],H=[1,92],q=[1,91],J=[1,90],U=[19,58],St=[1,101],Ot=[1,100],ht=[19,58,60,62],ut={trace:l(function(){},"trace"),yy:{},symbols_:{error:2,start:3,ER_DIAGRAM:4,document:5,EOF:6,line:7,SPACE:8,statement:9,NEWLINE:10,entityName:11,relSpec:12,COLON:13,role:14,STYLE_SEPARATOR:15,idList:16,BLOCK_START:17,attributes:18,BLOCK_STOP:19,SQS:20,SQE:21,title:22,title_value:23,acc_title:24,acc_title_value:25,acc_descr:26,acc_descr_value:27,acc_descr_multiline_value:28,direction:29,classDefStatement:30,classStatement:31,styleStatement:32,direction_tb:33,direction_bt:34,direction_rl:35,direction_lr:36,CLASSDEF:37,stylesOpt:38,separator:39,UNICODE_TEXT:40,STYLE_TEXT:41,COMMA:42,CLASS:43,STYLE:44,style:45,styleComponent:46,SEMI:47,NUM:48,BRKT:49,ENTITY_NAME:50,DECIMAL_NUM:51,ENTITY_ONE:52,attribute:53,attributeType:54,attributeName:55,attributeKeyTypeList:56,attributeComment:57,ATTRIBUTE_WORD:58,attributeKeyType:59,",":60,ATTRIBUTE_KEY:61,COMMENT:62,cardinality:63,relType:64,ZERO_OR_ONE:65,ZERO_OR_MORE:66,ONE_OR_MORE:67,ONLY_ONE:68,MD_PARENT:69,NON_IDENTIFYING:70,IDENTIFYING:71,WORD:72,$accept:0,$end:1},terminals_:{2:"error",4:"ER_DIAGRAM",6:"EOF",8:"SPACE",10:"NEWLINE",13:"COLON",15:"STYLE_SEPARATOR",17:"BLOCK_START",19:"BLOCK_STOP",20:"SQS",21:"SQE",22:"title",23:"title_value",24:"acc_title",25:"acc_title_value",26:"acc_descr",27:"acc_descr_value",28:"acc_descr_multiline_value",33:"direction_tb",34:"direction_bt",35:"direction_rl",36:"direction_lr",37:"CLASSDEF",40:"UNICODE_TEXT",41:"STYLE_TEXT",42:"COMMA",43:"CLASS",44:"STYLE",47:"SEMI",48:"NUM",49:"BRKT",50:"ENTITY_NAME",51:"DECIMAL_NUM",52:"ENTITY_ONE",58:"ATTRIBUTE_WORD",60:",",61:"ATTRIBUTE_KEY",62:"COMMENT",65:"ZERO_OR_ONE",66:"ZERO_OR_MORE",67:"ONE_OR_MORE",68:"ONLY_ONE",69:"MD_PARENT",70:"NON_IDENTIFYING",71:"IDENTIFYING",72:"WORD"},productions_:[0,[3,3],[5,0],[5,2],[7,2],[7,1],[7,1],[7,1],[9,5],[9,9],[9,7],[9,7],[9,4],[9,6],[9,3],[9,5],[9,1],[9,3],[9,7],[9,9],[9,6],[9,8],[9,4],[9,6],[9,2],[9,2],[9,2],[9,1],[9,1],[9,1],[9,1],[9,1],[29,1],[29,1],[29,1],[29,1],[30,4],[16,1],[16,1],[16,3],[16,3],[31,3],[32,4],[38,1],[38,3],[45,1],[45,2],[39,1],[39,1],[39,1],[46,1],[46,1],[46,1],[46,1],[11,1],[11,1],[11,1],[11,1],[11,1],[18,1],[18,2],[53,2],[53,3],[53,3],[53,4],[54,1],[55,1],[56,1],[56,3],[59,1],[57,1],[12,3],[63,1],[63,1],[63,1],[63,1],[63,1],[64,1],[64,1],[14,1],[14,1],[14,1]],performAction:l(function(n,c,o,r,p,t,Z){var s=t.length-1;switch(p){case 1:break;case 2:this.$=[];break;case 3:t[s-1].push(t[s]),this.$=t[s-1];break;case 4:case 5:this.$=t[s];break;case 6:case 7:this.$=[];break;case 8:r.addEntity(t[s-4]),r.addEntity(t[s-2]),r.addRelationship(t[s-4],t[s],t[s-2],t[s-3]);break;case 9:r.addEntity(t[s-8]),r.addEntity(t[s-4]),r.addRelationship(t[s-8],t[s],t[s-4],t[s-5]),r.setClass([t[s-8]],t[s-6]),r.setClass([t[s-4]],t[s-2]);break;case 10:r.addEntity(t[s-6]),r.addEntity(t[s-2]),r.addRelationship(t[s-6],t[s],t[s-2],t[s-3]),r.setClass([t[s-6]],t[s-4]);break;case 11:r.addEntity(t[s-6]),r.addEntity(t[s-4]),r.addRelationship(t[s-6],t[s],t[s-4],t[s-5]),r.setClass([t[s-4]],t[s-2]);break;case 12:r.addEntity(t[s-3]),r.addAttributes(t[s-3],t[s-1]);break;case 13:r.addEntity(t[s-5]),r.addAttributes(t[s-5],t[s-1]),r.setClass([t[s-5]],t[s-3]);break;case 14:r.addEntity(t[s-2]);break;case 15:r.addEntity(t[s-4]),r.setClass([t[s-4]],t[s-2]);break;case 16:r.addEntity(t[s]);break;case 17:r.addEntity(t[s-2]),r.setClass([t[s-2]],t[s]);break;case 18:r.addEntity(t[s-6],t[s-4]),r.addAttributes(t[s-6],t[s-1]);break;case 19:r.addEntity(t[s-8],t[s-6]),r.addAttributes(t[s-8],t[s-1]),r.setClass([t[s-8]],t[s-3]);break;case 20:r.addEntity(t[s-5],t[s-3]);break;case 21:r.addEntity(t[s-7],t[s-5]),r.setClass([t[s-7]],t[s-2]);break;case 22:r.addEntity(t[s-3],t[s-1]);break;case 23:r.addEntity(t[s-5],t[s-3]),r.setClass([t[s-5]],t[s]);break;case 24:case 25:this.$=t[s].trim(),r.setAccTitle(this.$);break;case 26:case 27:this.$=t[s].trim(),r.setAccDescription(this.$);break;case 32:r.setDirection("TB");break;case 33:r.setDirection("BT");break;case 34:r.setDirection("RL");break;case 35:r.setDirection("LR");break;case 36:this.$=t[s-3],r.addClass(t[s-2],t[s-1]);break;case 37:case 38:case 59:case 67:this.$=[t[s]];break;case 39:case 40:this.$=t[s-2].concat([t[s]]);break;case 41:this.$=t[s-2],r.setClass(t[s-1],t[s]);break;case 42:this.$=t[s-3],r.addCssStyles(t[s-2],t[s-1]);break;case 43:this.$=[t[s]];break;case 44:t[s-2].push(t[s]),this.$=t[s-2];break;case 46:this.$=t[s-1]+t[s];break;case 54:case 79:case 80:this.$=t[s].replace(/"/g,"");break;case 55:case 56:case 57:case 58:case 81:this.$=t[s];break;case 60:t[s].push(t[s-1]),this.$=t[s];break;case 61:this.$={type:t[s-1],name:t[s]};break;case 62:this.$={type:t[s-2],name:t[s-1],keys:t[s]};break;case 63:this.$={type:t[s-2],name:t[s-1],comment:t[s]};break;case 64:this.$={type:t[s-3],name:t[s-2],keys:t[s-1],comment:t[s]};break;case 65:case 66:case 69:this.$=t[s];break;case 68:t[s-2].push(t[s]),this.$=t[s-2];break;case 70:this.$=t[s].replace(/"/g,"");break;case 71:this.$={cardA:t[s],relType:t[s-1],cardB:t[s-2]};break;case 72:this.$=r.Cardinality.ZERO_OR_ONE;break;case 73:this.$=r.Cardinality.ZERO_OR_MORE;break;case 74:this.$=r.Cardinality.ONE_OR_MORE;break;case 75:this.$=r.Cardinality.ONLY_ONE;break;case 76:this.$=r.Cardinality.MD_PARENT;break;case 77:this.$=r.Identification.NON_IDENTIFYING;break;case 78:this.$=r.Identification.IDENTIFYING;break}},"anonymous"),table:[{3:1,4:[1,2]},{1:[3]},e(i,[2,2],{5:3}),{6:[1,4],7:5,8:[1,6],9:7,10:[1,8],11:9,22:h,24:a,26:u,28:d,29:14,30:15,31:16,32:17,33:y,34:f,35:m,36:j,37:W,40:T,43:Q,44:M,48:D,50:I,51:S,52:R},e(i,[2,7],{1:[2,1]}),e(i,[2,3]),{9:30,11:9,22:h,24:a,26:u,28:d,29:14,30:15,31:16,32:17,33:y,34:f,35:m,36:j,37:W,40:T,43:Q,44:M,48:D,50:I,51:S,52:R},e(i,[2,5]),e(i,[2,6]),e(i,[2,16],{12:31,63:35,15:[1,32],17:[1,33],20:[1,34],65:nt,66:at,67:ct,68:ot,69:lt}),{23:[1,41]},{25:[1,42]},{27:[1,43]},e(i,[2,27]),e(i,[2,28]),e(i,[2,29]),e(i,[2,30]),e(i,[2,31]),e(B,[2,54]),e(B,[2,55]),e(B,[2,56]),e(B,[2,57]),e(B,[2,58]),e(i,[2,32]),e(i,[2,33]),e(i,[2,34]),e(i,[2,35]),{16:44,40:O,41:A},{16:47,40:O,41:A},{16:48,40:O,41:A},e(i,[2,4]),{11:49,40:T,48:D,50:I,51:S,52:R},{16:50,40:O,41:A},{18:51,19:[1,52],53:53,54:54,58:F},{11:56,40:T,48:D,50:I,51:S,52:R},{64:57,70:[1,58],71:[1,59]},e(Y,[2,72]),e(Y,[2,73]),e(Y,[2,74]),e(Y,[2,75]),e(Y,[2,76]),e(i,[2,24]),e(i,[2,25]),e(i,[2,26]),{13:P,38:60,41:z,42:N,45:62,46:63,48:G,49:K},e(X,[2,37]),e(X,[2,38]),{16:68,40:O,41:A,42:N},{13:P,38:69,41:z,42:N,45:62,46:63,48:G,49:K},{13:[1,70],15:[1,71]},e(i,[2,17],{63:35,12:72,17:[1,73],42:N,65:nt,66:at,67:ct,68:ot,69:lt}),{19:[1,74]},e(i,[2,14]),{18:75,19:[2,59],53:53,54:54,58:F},{55:76,58:[1,77]},{58:[2,65]},{21:[1,78]},{63:79,65:nt,66:at,67:ct,68:ot,69:lt},e(gt,[2,77]),e(gt,[2,78]),{6:bt,10:kt,39:80,42:mt,47:Et},{40:[1,85],41:[1,86]},e(Tt,[2,43],{46:87,13:P,41:z,48:G,49:K}),e(L,[2,45]),e(L,[2,50]),e(L,[2,51]),e(L,[2,52]),e(L,[2,53]),e(i,[2,41],{42:N}),{6:bt,10:kt,39:88,42:mt,47:Et},{14:89,40:H,50:q,72:J},{16:93,40:O,41:A},{11:94,40:T,48:D,50:I,51:S,52:R},{18:95,19:[1,96],53:53,54:54,58:F},e(i,[2,12]),{19:[2,60]},e(U,[2,61],{56:97,57:98,59:99,61:St,62:Ot}),e([19,58,61,62],[2,66]),e(i,[2,22],{15:[1,103],17:[1,102]}),e([40,48,50,51,52],[2,71]),e(i,[2,36]),{13:P,41:z,45:104,46:63,48:G,49:K},e(i,[2,47]),e(i,[2,48]),e(i,[2,49]),e(X,[2,39]),e(X,[2,40]),e(L,[2,46]),e(i,[2,42]),e(i,[2,8]),e(i,[2,79]),e(i,[2,80]),e(i,[2,81]),{13:[1,105],42:N},{13:[1,107],15:[1,106]},{19:[1,108]},e(i,[2,15]),e(U,[2,62],{57:109,60:[1,110],62:Ot}),e(U,[2,63]),e(ht,[2,67]),e(U,[2,70]),e(ht,[2,69]),{18:111,19:[1,112],53:53,54:54,58:F},{16:113,40:O,41:A},e(Tt,[2,44],{46:87,13:P,41:z,48:G,49:K}),{14:114,40:H,50:q,72:J},{16:115,40:O,41:A},{14:116,40:H,50:q,72:J},e(i,[2,13]),e(U,[2,64]),{59:117,61:St},{19:[1,118]},e(i,[2,20]),e(i,[2,23],{17:[1,119],42:N}),e(i,[2,11]),{13:[1,120],42:N},e(i,[2,10]),e(ht,[2,68]),e(i,[2,18]),{18:121,19:[1,122],53:53,54:54,58:F},{14:123,40:H,50:q,72:J},{19:[1,124]},e(i,[2,21]),e(i,[2,9]),e(i,[2,19])],defaultActions:{55:[2,65],75:[2,60]},parseError:l(function(n,c){if(c.recoverable)this.trace(n);else{var o=new Error(n);throw o.hash=c,o}},"parseError"),parse:l(function(n){var c=this,o=[0],r=[],p=[null],t=[],Z=this.table,s="",tt=0,At=0,Dt=2,Nt=1,Lt=t.slice.call(arguments,1),_=Object.create(this.lexer),x={yy:{}};for(var dt in this.yy)Object.prototype.hasOwnProperty.call(this.yy,dt)&&(x.yy[dt]=this.yy[dt]);_.setInput(n,x.yy),x.yy.lexer=_,x.yy.parser=this,typeof _.yylloc>"u"&&(_.yylloc={});var pt=_.yylloc;t.push(pt);var wt=_.options&&_.options.ranges;typeof x.yy.parseError=="function"?this.parseError=x.yy.parseError:this.parseError=Object.getPrototypeOf(this).parseError;function Vt(b){o.length=o.length-2*b,p.length=p.length-b,t.length=t.length-b}l(Vt,"popStack");function Ct(){var b;return b=r.pop()||_.lex()||Nt,typeof b!="number"&&(b instanceof Array&&(r=b,b=r.pop()),b=c.symbols_[b]||b),b}l(Ct,"lex");for(var g,v,k,ft,w={},et,E,It,st;;){if(v=o[o.length-1],this.defaultActions[v]?k=this.defaultActions[v]:((g===null||typeof g>"u")&&(g=Ct()),k=Z[v]&&Z[v][g]),typeof k>"u"||!k.length||!k[0]){var yt="";st=[];for(et in Z[v])this.terminals_[et]&&et>Dt&&st.push("'"+this.terminals_[et]+"'");_.showPosition?yt="Parse error on line "+(tt+1)+`:
2
2
  `+_.showPosition()+`
3
3
  Expecting `+st.join(", ")+", got '"+(this.terminals_[g]||g)+"'":yt="Parse error on line "+(tt+1)+": Unexpected "+(g==Nt?"end of input":"'"+(this.terminals_[g]||g)+"'"),this.parseError(yt,{text:_.match,token:this.terminals_[g]||g,line:_.yylineno,loc:pt,expected:st})}if(k[0]instanceof Array&&k.length>1)throw new Error("Parse Error: multiple actions possible at state: "+v+", token: "+g);switch(k[0]){case 1:o.push(g),p.push(_.yytext),t.push(_.yylloc),o.push(k[1]),g=null,At=_.yyleng,s=_.yytext,tt=_.yylineno,pt=_.yylloc;break;case 2:if(E=this.productions_[k[1]][1],w.$=p[p.length-E],w._$={first_line:t[t.length-(E||1)].first_line,last_line:t[t.length-1].last_line,first_column:t[t.length-(E||1)].first_column,last_column:t[t.length-1].last_column},wt&&(w._$.range=[t[t.length-(E||1)].range[0],t[t.length-1].range[1]]),ft=this.performAction.apply(w,[s,At,tt,x.yy,k[1],p,t].concat(Lt)),typeof ft<"u")return ft;E&&(o=o.slice(0,-1*E*2),p=p.slice(0,-1*E),t=t.slice(0,-1*E)),o.push(this.productions_[k[1]][0]),p.push(w.$),t.push(w._$),It=Z[o[o.length-2]][o[o.length-1]],o.push(It);break;case 3:return!0}}return!0},"parse")},vt=(function(){var C={EOF:1,parseError:l(function(c,o){if(this.yy.parser)this.yy.parser.parseError(c,o);else throw new Error(c)},"parseError"),setInput:l(function(n,c){return this.yy=c||this.yy||{},this._input=n,this._more=this._backtrack=this.done=!1,this.yylineno=this.yyleng=0,this.yytext=this.matched=this.match="",this.conditionStack=["INITIAL"],this.yylloc={first_line:1,first_column:0,last_line:1,last_column:0},this.options.ranges&&(this.yylloc.range=[0,0]),this.offset=0,this},"setInput"),input:l(function(){var n=this._input[0];this.yytext+=n,this.yyleng++,this.offset++,this.match+=n,this.matched+=n;var c=n.match(/(?:\r\n?|\n).*/g);return c?(this.yylineno++,this.yylloc.last_line++):this.yylloc.last_column++,this.options.ranges&&this.yylloc.range[1]++,this._input=this._input.slice(1),n},"input"),unput:l(function(n){var c=n.length,o=n.split(/(?:\r\n?|\n)/g);this._input=n+this._input,this.yytext=this.yytext.substr(0,this.yytext.length-c),this.offset-=c;var r=this.match.split(/(?:\r\n?|\n)/g);this.match=this.match.substr(0,this.match.length-1),this.matched=this.matched.substr(0,this.matched.length-1),o.length-1&&(this.yylineno-=o.length-1);var p=this.yylloc.range;return this.yylloc={first_line:this.yylloc.first_line,last_line:this.yylineno+1,first_column:this.yylloc.first_column,last_column:o?(o.length===r.length?this.yylloc.first_column:0)+r[r.length-o.length].length-o[0].length:this.yylloc.first_column-c},this.options.ranges&&(this.yylloc.range=[p[0],p[0]+this.yyleng-c]),this.yyleng=this.yytext.length,this},"unput"),more:l(function(){return this._more=!0,this},"more"),reject:l(function(){if(this.options.backtrack_lexer)this._backtrack=!0;else return this.parseError("Lexical error on line "+(this.yylineno+1)+`. You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).
4
4
  `+this.showPosition(),{text:"",token:null,line:this.yylineno});return this},"reject"),less:l(function(n){this.unput(this.match.slice(n))},"less"),pastInput:l(function(){var n=this.matched.substr(0,this.matched.length-this.match.length);return(n.length>20?"...":"")+n.substr(-20).replace(/\n/g,"")},"pastInput"),upcomingInput:l(function(){var n=this.match;return n.length<20&&(n+=this._input.substr(0,20-n.length)),(n.substr(0,20)+(n.length>20?"...":"")).replace(/\n/g,"")},"upcomingInput"),showPosition:l(function(){var n=this.pastInput(),c=new Array(n.length+1).join("-");return n+this.upcomingInput()+`
@@ -1,2 +1,2 @@
1
- import{K as qn,u as Xn,M as E,N as Qn,O as Zn,P as et,Q as nt,T as yn,a as tt,U as rt,V as An,W as ot,X as Xe}from"./index-D8z7lcQn.js";import{M as Cn,h as it}from"./spaces-CjuXbmxF.js";function st(e,n){const t=n?.current_space_id;return!n?.server_id||t===void 0||t!==Cn&&!qn.test(t)?null:{client:e,identity:{serverId:n.server_id,homeId:t}}}function Sr(e){return e!==null&&e.identity.homeId!==Cn}const Qe=new WeakMap;let at=0;function ct(e){let n=Qe.get(e);return n===void 0&&(n=++at,Qe.set(e,n)),n}function Er(e,n){const t=Xn({queryKey:["space-settings","meta",e===null?null:ct(e)],queryFn:async({signal:r})=>{if(e===null)throw new Error("Space client unavailable");const o=await e.meta();return r.throwIfAborted(),o},enabled:e!==null&&n===void 0,staleTime:3e4,retry:!1});return e===null?null:st(e,n===void 0?t.data:n)}function Ke(e){return it(e)}const yr={all:["space-settings"],detail:e=>["space-settings","detail",e]},lt=["config","appearance","agents","instructions","skills","mcp","credentials","plugins"],Dn="generic_roots";function Ar(e){return`st.spaces.group.${e}`}const ne={theme:"pref:theme",skin:"pref:skin",tweaks:"pref:tweaks",background:"pref:background",proseFont:"pref:proseFont",defaultAppendTiming:"pref:defaultAppendTiming",foldSteps:"pref:foldSteps",worktreeSkipConfirm:"pref:worktreeSkipConfirm"};function Cr(e,n){return e?.items.find(t=>t.id===n)}function ut(e){return e.replaceAll(/[A-Z]/g,n=>`_${n.toLowerCase()}`)}function Dr(e,n=[]){return`config:${[e,...n].map(ut).join(".")}`}const dt={"pref:theme":"st.appearance.theme","pref:skin":"st.skin.title","pref:tweaks":"st.skin.tweaks","pref:background":"st.bg.title","pref:proseFont":"st.appearance.prose","pref:defaultAppendTiming":"st.communication.appendTimingTitle","pref:foldSteps":"st.transcript.foldSteps","pref:worktreeSkipConfirm":"st.composer.worktreeConfirm","config:default_model":"st.defaults.globalModelLabel","config:fast_model":"st.defaults.row.fast","config:subagent.default_model":"st.defaults.row.subagent","config:session_title.model":"st.defaults.row.title","config:default_permission_mode":"st.defaults.permissionMode","config:default_plan_mode":"st.defaults.planMode","config:thinking.effort":"st.profiles.effort","source:credentials":"st.spaces.group.credentials","source:instructions":"st.spaces.group.instructions","source:generic_roots":"st.spaces.group.generic_roots"};function Ir(e,n,t){const r=dt[e];return r===void 0?n:t(r)}function ft(e,n){const t=e.groups.find(r=>r.domain===n);if(t!==void 0)return{mode:t.mode,fixedCount:t.fixed_count,followCount:t.follow_count,stacked:n==="instructions"&&e.inherit.instructions==="stack"}}function Br(e,n,t){const r=ft(e,n);return r===void 0?t("st.spaces.origin.unknown"):n==="credentials"?t(e.inherit.credentials==="shared"?"st.spaces.group.shared":"st.spaces.group.isolated"):n===Dn?t(e.inherit.generic_roots?"st.spaces.group.available":"st.spaces.group.unavailable"):e.primary?t("st.spaces.group.items",{count:r.fixedCount}):r.mode==="follow"?r.stacked?t("st.spaces.group.stacked"):r.fixedCount===0?t("st.spaces.group.follow"):t("st.spaces.group.followFixed",{count:r.fixedCount}):r.followCount===0?t("st.spaces.group.fixed"):t("st.spaces.group.fixedFollow",{count:r.followCount})}function wr(e){const n=new Map([...lt,Dn].map((t,r)=>[t,r]));return e.items.filter(t=>t.kind!=="source"&&t.origin==="home").toSorted((t,r)=>(n.get(t.domain)??99)-(n.get(r.domain)??99)||t.name.localeCompare(r.name))}const pt={"pref:theme":"/settings/appearance","pref:skin":"/settings/appearance","pref:tweaks":"/settings/appearance","pref:background":"/settings/appearance","pref:proseFont":"/settings/appearance","pref:defaultAppendTiming":"/settings/general","pref:foldSteps":"/settings/general","pref:worktreeSkipConfirm":"/settings/general","config:default_model":"/settings/ai","config:fast_model":"/settings/ai","config:thinking.effort":"/settings/ai","config:session_title.model":"/settings/ai","config:default_permission_mode":"/settings/permissions"},kt=[["resource:agents:","/settings/agents"],["resource:skills:","/settings/skills"],["resource:mcp:","/settings/mcp"],["resource:plugins:","/settings/plugins"],["resource:appearance:","/settings/appearance"]];function _r(e){const n=pt[e];return n!==void 0?n:kt.find(([t])=>e.startsWith(t))?.[1]}function ze(e,n=48){return e.length>n?`${e.slice(0,n-1)}…`:e}function mt(e){try{return ze(JSON.stringify(e),72)}catch{return""}}function ht(e,n,t){if(e==="pref:background"&&n==null)return t("st.spaces.value.backgroundNone");if(e==="pref:theme"&&(n==="light"||n==="dark"||n==="system"))return t(`st.appearance.theme.${n}`);if(e==="pref:proseFont"&&(n==="serif"||n==="sans"))return t(`st.appearance.prose.${n}`);if(e==="pref:defaultAppendTiming"&&(n==="agent_idle"||n==="subagents_done"||n==="tasks_done"))return t(`st.spaces.value.appendTiming.${n}`);if(e==="pref:skin"&&typeof n=="object"&&n!==null){const r=n;if(typeof r.id!="string")return;const o=r.source==="pack"?"st.spaces.value.skinPack":r.source==="user"?"st.spaces.value.skinUser":"st.spaces.value.skinBuiltin";return t(o,{id:r.id})}if(e==="pref:tweaks"&&typeof n=="object"&&n!==null){const r=Object.keys(n).length;return r===0?t("st.spaces.value.tweaksNone"):t("st.spaces.value.tweaksCount",{count:r})}if(e==="pref:background"&&typeof n=="object"&&n!==null){const r=n,o=(r.linked===!1?r.dark:r.light)??r.light??r.dark;if(o==null||typeof o!="object")return t("st.spaces.value.backgroundNone");const i=o.media;if(!Array.isArray(i)||i.length===0)return t("st.spaces.value.backgroundNone");if(i.length>1)return t("st.spaces.value.backgroundCount",{count:i.length});const s=i[0],c=typeof s?.name=="string"&&s.name!==""?s.name:typeof s?.id=="string"?s.id.split("/").at(-1)??s.id:"";return c===""?t("st.spaces.value.backgroundCount",{count:i.length}):ze(c,32)}}function Or(e,n,t){const r=ht(e,n,t);return r!==void 0?r:n==null?t("st.spaces.value.none"):typeof n=="boolean"?t(n?"st.spaces.value.on":"st.spaces.value.off"):typeof n=="string"?ze(n):typeof n=="number"?String(n):Array.isArray(n)?t("st.spaces.group.items",{count:n.length}):mt(n)}function Pr(e){const n=[],t=[],r=[];for(const o of e.rows)o.id.startsWith("group:")?n.push(o):o.same_value?r.push(o):t.push(o);return{changed:t,same:r,groups:n}}function Mr(e){return e.blocked_reason===void 0}const gt=[["Resource content is unavailable","st.spaces.blocked.resourceUnavailable"],["Only resources can be excluded","st.spaces.blocked.onlyResources"],["This item cannot be shared through the ordinary push flow","st.spaces.blocked.notShareable"],["Edit this resource through its resource editor","st.spaces.blocked.editResource"],["Main space has no parent source","st.spaces.blocked.mainNoParent"]];function Nr(e,n){if(e.startsWith("Connection contains account data"))return n("st.spaces.blocked.accountData");const t=gt.find(([r])=>r===e);return t===void 0?e:n(t[1])}function F(e){return`${e.serverId}|${e.homeId}`}const In="kiki.spacePreferences.cache",Ze={entries:{},authorities:{},lastKnown:null,resolved:{}};function de(){try{const e=localStorage.getItem(In);if(e===null)return Ze;const n=JSON.parse(e);return{entries:typeof n.entries=="object"&&n.entries!==null?n.entries:{},authorities:typeof n.authorities=="object"&&n.authorities!==null?n.authorities:{},lastKnown:n.lastKnown??null,resolved:typeof n.resolved=="object"&&n.resolved!==null?n.resolved:{}}}catch{return Ze}}function Bn(e){try{localStorage.setItem(In,JSON.stringify(e))}catch{}}const L={identity:null,confirmed:null,authoritative:!1,drafts:{},writes:{},deviceConflict:!1,loaded:!1};let u=L,K=0,Ft=0,_=0,Ce={},z={};const De=new Set;function b(e){return u.identity!==null&&F(u.identity)===F(e)}function fe(){K+=1,Ce={},z={}}function wn(e){return De.add(e),()=>{De.delete(e)}}function _n(){return u}function Tr(){return L}function C(e){u=e;for(const n of De)n();vt()}function V(e,n,t=!0){const r=de(),o=n.preferences;Bn({...r,entries:{...r.entries,[F(e)]:o},authorities:{...r.authorities,[F(e)]:n.preference_authority},lastKnown:t?{homeId:e.homeId,serverId:e.serverId,values:o}:r.lastKnown})}function Rr(e){return de().resolved[F(e)]===!0}function Lr(e,n){const t=de(),r=t.lastKnown?.homeId===e?t.lastKnown:null,o=n===void 0?r===null?null:{serverId:r.serverId,homeId:e}:{serverId:n,homeId:e};if(o===null||b(o)&&u.loaded)return;const i=n===void 0?r?.values??null:t.entries[F(o)]??null,s=t.authorities[F(o)]===!0?i:null;b(o)||fe(),C({...L,identity:o,confirmed:s})}function $r(e,n){const t=b(e);t||fe(),V(e,n),C({...t?u:L,identity:e,confirmed:n.preferences,authoritative:n.preference_authority,loaded:!0})}function Hr(){u!==L&&(fe(),C(L))}function Ur(){u.deviceConflict||C({...u,deviceConflict:!0})}function xr(e){const n=e??u.identity;if(n!==null){const t=de();Bn({...t,resolved:{...t.resolved,[F(n)]:!0}})}n!==null&&b(n)&&u.deviceConflict&&C({...u,deviceConflict:!1})}function Ie(e){const n=u.drafts[e];return n!==void 0?n:u.confirmed===null?void 0:u.confirmed[e]}function te(){return u.confirmed!==null||Y!==void 0}let Y;const bt=new Set;function jr(e){Y=e}function vt(){for(const e of bt)e()}function Ve(e,n,t,r=[]){if(!b(e)||u.confirmed===null)return n;const o={...n.preferences};for(const s of Object.keys(ne))((z[s]??0)>t||r.includes(s))&&Object.assign(o,{[s]:u.confirmed[s]});const i=Object.values(z).some(s=>s>t);return{...n,preferences:o,preference_authority:i?u.authoritative:n.preference_authority}}async function Kr(e,n){const t=_,r=await Ke(e).detail(n.homeId);return Ve(n,r,t)}async function Be(e,n){const t=Y,r=t?.client()??null,o=t?.identity()??null;return t===void 0||r===null||o===null||t.spaceId()!==o.homeId?!1:St(r,o,{[e]:n})}async function St(e,n,t){if(!b(n))return!1;const r=Object.keys(ne).filter(l=>t[l]!==void 0);if(r.length===0)return!1;const o=Y,i=K,s=_,c=++Ft,d={...u.drafts},f={...u.writes};for(const l of r)Ce[l]=c,d[l]=t[l],f[l]={state:"saving"};C({...u,drafts:d,writes:f});const h=()=>K===i&&b(n),y=()=>r.filter(l=>Ce[l]===c);try{const l=Ke(e),a=r.map(m=>({id:ne[m],value:t[m]})),M=await l.preview(n.homeId,{action:"edit",changes:a});for(const m of a){const ge=M.rows.find(Yn=>Yn.id===m.id);if(ge===void 0||ge.blocked_reason!==void 0)throw new Error(ge?.blocked_reason??`The server returned no plan for ${m.id}`)}const q=await l.apply(n.homeId,{token:M.token,selected:a.map(m=>m.id)});if(!h())return b(n)||V(n,q.detail,!1),!0;const me=y();if(me.length===0)return!0;const X=Ve(n,q.detail,s,r.filter(m=>!me.includes(m))),Ye={...u.drafts},qe={...u.writes};_+=1;for(const m of me)z[m]=_,delete Ye[m],delete qe[m];V(n,X),C({...u,confirmed:X.preferences,authoritative:X.preference_authority,loaded:!0,drafts:Ye,writes:qe});const he=o?.identity();return h()&&he!==null&&he!==void 0&&F(he)===F(n)&&o?.onDetail?.(X),!0}catch(l){if(h()){const a={...u.writes};for(const M of y())a[M]={state:"error",error:l};y().length>0&&C({...u,writes:a})}return!1}}async function zr(e,n,t,r){const o=K,i=_,s=Y;try{const c=await Ke(e).importPreferences(n.homeId,{values:r,device_id:t});if(K!==o||u.identity!==null&&!b(n))return b(n)||V(n,c.detail,!1),{imported:c.imported,conflict:c.device_conflict};const d=Ve(n,c.detail,i);u.identity===null&&fe(),_+=1;for(const h of Object.keys(ne))z[h]=_;V(n,d),C({...u,identity:n,confirmed:d.preferences,authoritative:d.preference_authority,deviceConflict:c.device_conflict,loaded:!0});const f=s?.identity();return b(n)&&f!==null&&f!==void 0&&F(f)===F(n)&&s?.onDetail?.(d),{imported:c.imported,conflict:c.device_conflict}}catch{return null}}function Vr(){const e="kiki.deviceId";try{const n=localStorage.getItem(e);if(n!==null&&n!=="")return n;const t=globalThis.crypto?.randomUUID?.()??`device-${Date.now().toString(36)}`;return localStorage.setItem(e,t),t}catch{return"device-unknown"}}const J={light:null,dark:null,linked:!0,assist:!0},we="kiki.background";function v(e,n,t,r){return typeof e=="number"&&Number.isFinite(e)?Math.min(t,Math.max(n,e)):r}function Fe(e,n,t){return typeof e=="string"&&n.includes(e)?e:t}function On(e){const n=typeof e=="object"&&e!==null?e:{},t=Qn;return{fit:Fe(n.fit,nt,t.fit),alignment:Fe(n.alignment,et,t.alignment),opacity:v(n.opacity,0,1,t.opacity),blur:v(n.blur,0,40,t.blur),brightness:v(n.brightness,.4,1.4,t.brightness),scrim:v(n.scrim,0,.9,t.scrim),scope:Fe(n.scope,Zn,t.scope),surfaceOpacity:v(n.surfaceOpacity,.3,1,t.surfaceOpacity),surfaceBlur:v(n.surfaceBlur,0,32,t.surfaceBlur)}}function en(e){if(typeof e!="object"||e===null)return null;const n=e;return typeof n.id!="string"||!/^(?:local-[\w-]{1,80}|pack:[a-z0-9][a-z0-9-]{0,63}\/[A-Za-z0-9][A-Za-z0-9._-]{0,99})$/.test(n.id)||n.kind!=="image"&&n.kind!=="video"||typeof n.mime!="string"||!/^(image|video)\/[\w.+-]+$/.test(n.mime)?null:{id:n.id,kind:n.kind,mime:n.mime,name:typeof n.name=="string"?n.name.slice(0,200):n.id,bytes:v(n.bytes,0,Number.MAX_SAFE_INTEGER,0)}}function Et(e){if(typeof e!="object"||e===null)return;const n=e;if(!(typeof n.dark!="number"||typeof n.light!="number"))return{dark:v(n.dark,0,1,0),light:v(n.light,0,1,1)}}function nn(e){if(typeof e!="object"||e===null)return null;const n=e,t=(Array.isArray(n.media)?n.media:[]).map(en).filter(o=>o!==null).slice(0,12);if(t.length===0)return null;const r=en(n.poster)??void 0;return{media:t,poster:r,interval:v(n.interval,0,3600,0),look:On(n.look),packId:typeof n.packId=="string"&&/^[a-z0-9][a-z0-9-]{0,63}$/.test(n.packId)?n.packId:void 0,sample:Et(n.sample)}}function Je(e){if(typeof e!="object"||e===null)return J;const n=e;return{light:nn(n.light),dark:nn(n.dark),linked:n.linked!==!1,assist:n.assist!==!1}}const re=new Set;let g;function Pn(){try{const e=E.getItem(we);return e===null?J:Je(JSON.parse(e))}catch{return J}}function Jr(e){return re.add(e),()=>{re.delete(e)}}function Gr(){return Pn()}function tn(e){return{id:e.id,kind:e.kind,mime:e.mime,name:e.name,bytes:e.bytes}}function oe(e){return e===null?null:{media:e.media.map(tn),...e.poster===void 0?{}:{poster:tn(e.poster)},interval:e.interval,look:e.look,...e.packId===void 0?{}:{packId:e.packId},...e.sample===void 0?{}:{sample:e.sample}}}function S(e){return e===null?!0:[...e.media,...e.poster===void 0?[]:[e.poster]].every(n=>n.id.startsWith("pack:"))}function Wr(e){if(!(!S(e.light)||!S(e.dark)))return{light:oe(e.light),dark:oe(e.dark),linked:e.linked,assist:e.assist}}function yt(){const e=Ie("background");if(e!==void 0)return Je(e)}let rn,on,sn=!1;function At(){const e=_n();return(!sn||rn!==e)&&(rn=e,on=yt(),sn=!0),on}function Yr(){const e=pe();return te()&&!(S(e.light)&&S(e.dark))}function pe(){return g??=Pn(),!S(g.light)||!S(g.dark)?g:At()??g}function qr(){return J}function Ct(e){const n=Je({...e,assist:e.assist??pe().assist});if(te()&&S(n.light)&&S(n.dark)){g!==void 0&&(!S(g.light)||!S(g.dark))&&an(n),Be("background",{light:oe(n.light),dark:oe(n.dark),linked:n.linked,assist:n.assist});return}an(n)}function an(e){try{e.light===null&&e.dark===null&&e.linked&&e.assist?E.removeItem(we):E.setItem(we,JSON.stringify(e))}catch{}JSON.stringify(e)!==JSON.stringify(g)&&(g=e);for(const n of re)n()}wn(()=>{g=void 0;for(const e of re)e()});function Xr(){return pe()}function Qr(){g=void 0}function Zr(e,n){return e.linked?e.light??e.dark:e[n]}function eo(e,n){return e.linked?"light":n}function be(e){const n=e.trim().replace("#",""),t=n.length===3?n.split("").map(r=>`${r}${r}`).join(""):n;return/^[0-9a-fA-F]{6}$/.test(t)?[0,2,4].map(r=>Number.parseInt(t.slice(r,r+2),16)/255):null}const ve=e=>e<=.04045?e/12.92:((e+.055)/1.055)**2.4,Dt=e=>e<=.0031308?e*12.92:1.055*e**(1/2.4)-.055;function _e(e){return .2126*ve(e[0])+.7152*ve(e[1])+.0722*ve(e[2])}function It(e,n){const[t,r]=e>n?[e,n]:[n,e];return(t+.05)/(r+.05)}function cn(e,n,t){return[0,1,2].map(r=>e[r]*t+n[r]*(1-t))}function Bt(e){const n=Dt(Math.min(1,Math.max(0,e)));return[n,n,n]}const wt=4.5,_t=.15;function Ot(e,n,t,r){const o=be(e.surface),i=be(e.ground),s=e.texts.map(be).filter(l=>l!==null);if(o===null||i===null||s.length===0)return 1;const c=n.opacity*(1-n.scrim),d=[t?.dark??0,t?.light??1].map(l=>{const a=Bt(Math.min(1,l*n.brightness));return cn(a,i,c)}),f=l=>d.every(a=>{const M=_e(cn(o,a,l));return s.every(q=>It(_e(q),M)>=wt+_t)});if(f(r))return r;let h=r,y=1;for(let l=0;l<16;l+=1){const a=(h+y)/2;f(a)?y=a:h=a}return Math.min(1,Math.ceil(y*100)/100)}function Pt(e){const n=[];for(let r=0;r+3<e.length;r+=4)e[r+3]<16||n.push(_e([e[r]/255,e[r+1]/255,e[r+2]/255]));if(n.length===0)return{dark:0,light:1};n.sort((r,o)=>r-o);const t=r=>n[Math.min(n.length-1,Math.floor(r*n.length))];return{dark:t(.05),light:t(.95)}}const Mt={center:"center",top:"center top",bottom:"center bottom",left:"left center",right:"right center",topLeft:"left top",topRight:"right top",bottomLeft:"left bottom",bottomRight:"right bottom"};function ln(e){return Mt[e]}const Mn="paper",Nt=new Set(["linen","graphite","forest","claret","heather","nocturne","sand","slate"]),Oe="'Instrument Sans Variable', 'Instrument Sans', ui-sans-serif, system-ui, 'Segoe UI', 'PingFang SC', 'Noto Sans SC', sans-serif",un=Oe,Tt=[{kind:"kiki-skin",version:1,id:Mn,name:"纸色 Paper × 墨砚 Inkstone",description:"Warm white paper and ink-blue marks; cool charcoal and copper after dark.",variants:{light:{colors:{canvas:"#F2EFE8",paper:"#FBFAF6",panel:"#FFFDFA",hairline:"#E4DDD0",hairlineStrong:"#CDC3B1",ink:"#1B1A17",inkSoft:"#4B453E",inkFaint:"#665E54",accent:"#C8401A",accentDeep:"#9C3012",accentSoft:"#F8E3D8",accentInk:"#9C3012",onAccent:"#FFFFFF",sectionInk:"#4B453E",selected:"#DFE8F0",selectedInk:"#1D4D6D",attention:"#B33A12",attentionSoft:"#FAE3D7",amberInk:"#87480B",amberCard:"#F8EEDD",amberRule:"#D9A441",success:"#2F6B45",danger:"#B0261E",onDanger:"#FFFFFF",bubbleUser:"#EEE8DC",scrollbar:"#D8D0C1",scrollbarHover:"#C4BAA8",termScrollbar:"#4A4238",shell:"#1F1B16",shellInk:"#E8DCC4",shellInkStrong:"#F3E9D8",shellInkSoft:"#9B8E7A",shellDanger:"#D9A08A",shellHairline:"#332D24",shellHover:"#2A251D",shadowInk:"#1B1A17"}},dark:{colors:{canvas:"#13191C",paper:"#1B2226",panel:"#252D31",hairline:"#354047",hairlineStrong:"#596870",ink:"#EEEAE2",inkSoft:"#C1C5C5",inkFaint:"#A2ACAF",accent:"#EB946F",accentDeep:"#F4B08F",accentSoft:"#382A25",accentInk:"#F4AE8D",onAccent:"#261A14",sectionInk:"#C1C5C5",selected:"#24323B",selectedInk:"#A3CBDE",attention:"#F4AE8D",attentionSoft:"#382A25",amberInk:"#E6BD78",amberCard:"#322B20",amberRule:"#96783F",success:"#9AC6AE",danger:"#F1A29A",onDanger:"#301414",bubbleUser:"#293238",scrollbar:"#4F5F68",scrollbarHover:"#74838C",termScrollbar:"#526068",shell:"#101518",shellInk:"#D1D9DA",shellInkStrong:"#F0F2EF",shellInkSoft:"#9AA7AB",shellDanger:"#F1A29A",shellHairline:"#354047",shellHover:"#202B30",shadowInk:"#000000"}}}},{kind:"kiki-skin",version:1,id:"porcelain",name:"瓷白 Porcelain × 深海 Deepwater",description:"Cool white paper and cobalt details; layered navy and mist-blue controls at night.",variants:{light:{colors:{canvas:"#E7EDF4",paper:"#F8FBFF",panel:"#FFFFFF",hairline:"#D2DDE9",hairlineStrong:"#A9B9CA",ink:"#17283D",inkSoft:"#405570",inkFaint:"#516279",accent:"#2856A6",accentDeep:"#1B3F84",accentSoft:"#E2EBFA",accentInk:"#204986",onAccent:"#FFFFFF",sectionInk:"#405570",selected:"#DEE8F7",selectedInk:"#204986",attention:"#9C461C",attentionSoft:"#F9E8DC",amberInk:"#7E520D",amberCard:"#F8EED9",amberRule:"#B58A3B",success:"#28664B",danger:"#AF343E",onDanger:"#FFFFFF",bubbleUser:"#E6EDF6",scrollbar:"#B6C5D6",scrollbarHover:"#8B9FB5",termScrollbar:"#52657C",shell:"#142033",shellInk:"#D8E3F1",shellInkStrong:"#F2F7FF",shellInkSoft:"#9CACC2",shellDanger:"#F1A6AB",shellHairline:"#35475E",shellHover:"#24354C",shadowInk:"#132237"}},dark:{colors:{canvas:"#0D1624",paper:"#152238",panel:"#1E304A",hairline:"#304761",hairlineStrong:"#586E88",ink:"#E4EDF9",inkSoft:"#B8C9E0",inkFaint:"#98B0CB",accent:"#9DAEF5",accentDeep:"#BAC8FF",accentSoft:"#283653",accentInk:"#BAC8FF",onAccent:"#17203C",sectionInk:"#B8C9E0",selected:"#293A55",selectedInk:"#BAD1F5",attention:"#F1C28C",attentionSoft:"#362D26",amberInk:"#E9C474",amberCard:"#332D20",amberRule:"#927A46",success:"#99D0B5",danger:"#F2A4AE",onDanger:"#351724",bubbleUser:"#223551",scrollbar:"#455F7E",scrollbarHover:"#6D88A8",termScrollbar:"#4D627C",shell:"#090F1A",shellInk:"#CFDDF0",shellInkStrong:"#EDF4FF",shellInkSoft:"#98ADC8",shellDanger:"#F2A4AE",shellHairline:"#283B53",shellHover:"#17273D",shadowInk:"#000000"}}}},{kind:"kiki-skin",version:1,id:"celadon",name:"青瓷 Celadon × 夜园 Night Garden",description:"Celadon glaze and soft white paper; deep pine surfaces and jade details at night.",variants:{light:{colors:{canvas:"#DDE7DE",paper:"#F2F7EF",panel:"#FCFEF9",hairline:"#C8D8CB",hairlineStrong:"#9DB6A7",ink:"#21382F",inkSoft:"#435D50",inkFaint:"#4D6253",accent:"#24675F",accentDeep:"#174F4A",accentSoft:"#DCECE6",accentInk:"#1E5650",onAccent:"#FFFFFF",sectionInk:"#435D50",selected:"#D7E9DE",selectedInk:"#20594D",attention:"#984B21",attentionSoft:"#F5E7DA",amberInk:"#79520D",amberCard:"#F6EED5",amberRule:"#A1843C",success:"#3E642A",danger:"#A9363C",onDanger:"#FFFFFF",bubbleUser:"#E2ECDD",scrollbar:"#AEC3B1",scrollbarHover:"#839E8B",termScrollbar:"#526A5D",shell:"#14251E",shellInk:"#DDE8DB",shellInkStrong:"#F4F9ED",shellInkSoft:"#9CAC9F",shellDanger:"#F0A8A5",shellHairline:"#364D3F",shellHover:"#253A2F",shadowInk:"#172A23"}},dark:{colors:{canvas:"#111C1A",paper:"#1A2925",panel:"#243830",hairline:"#354E43",hairlineStrong:"#597968",ink:"#E5EEE3",inkSoft:"#BDCEC1",inkFaint:"#9DB4A4",accent:"#8FCBB8",accentDeep:"#ACDCCD",accentSoft:"#283F36",accentInk:"#ACDCCD",onAccent:"#122C23",sectionInk:"#BDCEC1",selected:"#2A4036",selectedInk:"#B4DCC2",attention:"#E8BD86",attentionSoft:"#3B3023",amberInk:"#E2C47E",amberCard:"#34311E",amberRule:"#8C824A",success:"#C0D58F",danger:"#F0AAA4",onDanger:"#351915",bubbleUser:"#2B3E33",scrollbar:"#4E6C5B",scrollbarHover:"#799A85",termScrollbar:"#526B5D",shell:"#0C1512",shellInk:"#D2E1D4",shellInkStrong:"#F0F6EA",shellInkSoft:"#9FB5A6",shellDanger:"#F0AAA4",shellHairline:"#2D493A",shellHover:"#1D3026",shadowInk:"#000000"}}}},{kind:"kiki-skin",version:1,id:"apricot",name:"杏云 Apricot × 晚霞 Afterglow",description:"Apricot-white paper and berry controls; plum-charcoal layers and peach light after dark.",variants:{light:{colors:{canvas:"#F4DED5",paper:"#FFF3EB",panel:"#FFFAF5",hairline:"#DFC7C0",hairlineStrong:"#B698A0",ink:"#382C38",inkSoft:"#604F5C",inkFaint:"#6B5563",accent:"#A13B55",accentDeep:"#822C46",accentSoft:"#F9DFE4",accentInk:"#822C46",onAccent:"#FFFFFF",sectionInk:"#604F5C",selected:"#F2DEE2",selectedInk:"#7D3553",attention:"#934018",attentionSoft:"#FAE2CF",amberInk:"#794C0B",amberCard:"#F8EBD0",amberRule:"#B38A42",success:"#3E674E",danger:"#AF263C",onDanger:"#FFFFFF",bubbleUser:"#F7E3DB",scrollbar:"#CDB0B1",scrollbarHover:"#AC8C96",termScrollbar:"#68576A",shell:"#251D29",shellInk:"#EADDE8",shellInkStrong:"#FFF3F0",shellInkSoft:"#B7A3B6",shellDanger:"#F0A3AD",shellHairline:"#4B3B4C",shellHover:"#382C3A",shadowInk:"#372635"}},dark:{colors:{canvas:"#201A22",paper:"#2C2430",panel:"#3A303E",hairline:"#51404F",hairlineStrong:"#816477",ink:"#F4E9E7",inkSoft:"#D8C2CD",inkFaint:"#C1A9B8",accent:"#F4B29C",accentDeep:"#FFCCB6",accentSoft:"#49323C",accentInk:"#FFCCB6",onAccent:"#351D22",sectionInk:"#D8C2CD",selected:"#443440",selectedInk:"#F3BED0",attention:"#F5C27F",attentionSoft:"#493824",amberInk:"#EDCE8E",amberCard:"#413821",amberRule:"#A48C50",success:"#AFD4B0",danger:"#F8ABB8",onDanger:"#381A29",bubbleUser:"#41323D",scrollbar:"#705768",scrollbarHover:"#9C7F90",termScrollbar:"#705B71",shell:"#17131D",shellInk:"#E5D6E3",shellInkStrong:"#F9EDF1",shellInkSoft:"#BAA3BC",shellDanger:"#F8ABB8",shellHairline:"#46384D",shellHover:"#302638",shadowInk:"#000000"}}}},{kind:"kiki-skin",version:1,id:"iris",name:"鸢尾 Iris × 星幕 Starveil",description:"Violet-white paper and iris ink; indigo-violet layers and silver-lilac controls at night.",variants:{light:{colors:{canvas:"#E7E3F2",paper:"#F6F3FC",panel:"#FCFAFF",hairline:"#D5CEE5",hairlineStrong:"#A99BBF",ink:"#302B48",inkSoft:"#514964",inkFaint:"#615775",accent:"#6542A5",accentDeep:"#4D2F86",accentSoft:"#EAE1F7",accentInk:"#53318B",onAccent:"#FFFFFF",sectionInk:"#514964",selected:"#E7DEF4",selectedInk:"#593793",attention:"#98491B",attentionSoft:"#F7E5D5",amberInk:"#78500B",amberCard:"#F7ECCF",amberRule:"#AE8E45",success:"#306448",danger:"#B1294E",onDanger:"#FFFFFF",bubbleUser:"#ECE6F6",scrollbar:"#BEB1D5",scrollbarHover:"#9985BA",termScrollbar:"#595179",shell:"#211D34",shellInk:"#DED9F0",shellInkStrong:"#F5F0FF",shellInkSoft:"#AAA0C5",shellDanger:"#F0A5BF",shellHairline:"#413857",shellHover:"#312A49",shadowInk:"#29203F"}},dark:{colors:{canvas:"#171626",paper:"#232137",panel:"#312F4A",hairline:"#44405F",hairlineStrong:"#71668F",ink:"#EEECFA",inkSoft:"#CAC3E2",inkFaint:"#ADA4C7",accent:"#C5ADF6",accentDeep:"#DECCFF",accentSoft:"#3D305B",accentInk:"#DECCFF",onAccent:"#27183F",sectionInk:"#CAC3E2",selected:"#35304F",selectedInk:"#D4C6F7",attention:"#F1BE86",attentionSoft:"#413226",amberInk:"#E8CC87",amberCard:"#3C3422",amberRule:"#9E884C",success:"#A5D6BA",danger:"#F3A6C2",onDanger:"#34182A",bubbleUser:"#36304D",scrollbar:"#63577E",scrollbarHover:"#9180B2",termScrollbar:"#615577",shell:"#100F1B",shellInk:"#D8D1EF",shellInkStrong:"#F3EFFF",shellInkSoft:"#ABA0C9",shellDanger:"#F3A6C2",shellHairline:"#39304E",shellHover:"#272238",shadowInk:"#000000"}}}},{kind:"kiki-skin",version:1,id:"contrast",name:"高对比 High contrast × 高对比·黑曜 Obsidian",description:"White paper, black text and visible borders; layered charcoal, ice-cyan focus and near-white controls at night.",variants:{light:{colors:{canvas:"#E7E9EC",paper:"#FFFFFF",panel:"#FFFFFF",hairline:"#6E7781",hairlineStrong:"#20252C",ink:"#0E1116",inkSoft:"#20252C",inkFaint:"#353B44",accent:"#0349B4",accentDeep:"#023787",accentSoft:"#DBE7FB",accentInk:"#023B95",onAccent:"#FFFFFF",sectionInk:"#0E1116",selected:"#DBE7FB",selectedInk:"#023B95",attention:"#A2280A",attentionSoft:"#FDE3D9",amberInk:"#6B3D00",amberCard:"#FDF0CF",amberRule:"#8A5A00",success:"#055D20",danger:"#A0111F",onDanger:"#FFFFFF",bubbleUser:"#F3F3F3",scrollbar:"#C9CBCE",scrollbarHover:"#B3B5B9",termScrollbar:"#4D4F53",shell:"#0E1116",shellInk:"#D4D4D5",shellInkStrong:"#F1F1F1",shellInkSoft:"#939698",shellDanger:"#F0A39C",shellHairline:"#303237",shellHover:"#212429",shadowInk:"#0A0C0F"},fonts:{display:un,sans:Oe},shape:{radius:8}},dark:{colors:{canvas:"#101214",paper:"#1C2024",panel:"#2A3036",hairline:"#8A949E",hairlineStrong:"#C5CDD5",ink:"#F7F9FB",inkSoft:"#E1E6EB",inkFaint:"#C2CBD3",accent:"#E7EDF4",accentDeep:"#FFFFFF",accentSoft:"#303840",accentInk:"#F4F7FA",onAccent:"#11171C",sectionInk:"#F7F9FB",selected:"#303840",selectedInk:"#8DE3F0",attention:"#FFD080",attentionSoft:"#30343A",amberInk:"#F5D58C",amberCard:"#30343A",amberRule:"#BAA276",success:"#A4E0B2",danger:"#FFADB8",onDanger:"#241318",bubbleUser:"#30363C",scrollbar:"#8A949E",scrollbarHover:"#C5CDD5",termScrollbar:"#89939D",shell:"#0C0F12",shellInk:"#E1E6EB",shellInkStrong:"#F7F9FB",shellInkSoft:"#BBC6D0",shellDanger:"#FFADB8",shellHairline:"#89939D",shellHover:"#22282E",shadowInk:"#000000"},fonts:{display:un,sans:Oe},shape:{radius:8}}}}];function Nn(e){return Tt.find(n=>n.id===e)}const dn={paper:"st.skin.desc.paperPair",porcelain:"st.skin.desc.porcelain",celadon:"st.skin.desc.celadon",apricot:"st.skin.desc.apricot",iris:"st.skin.desc.iris",contrast:"st.skin.desc.contrastPair"},fn={paper:"st.skin.name.paper",porcelain:"st.skin.name.porcelain",celadon:"st.skin.name.celadon",apricot:"st.skin.name.apricot",iris:"st.skin.name.iris",contrast:"st.skin.name.contrast"};function no(e){return e!==void 0&&Object.hasOwn(dn,e)?dn[e]:void 0}function to(e){return e!==void 0&&Object.hasOwn(fn,e)?fn[e]:void 0}const Rt=/^[a-z0-9][a-z0-9-]{0,63}$|^[a-z0-9][a-z0-9_-]{0,63}:[a-z0-9][a-z0-9-]{0,63}$/,O={selection:{source:"builtin",id:Mn},tweaks:{}},Tn="kiki.skin",Lt=/^#(?:[0-9a-fA-F]{3}|[0-9a-fA-F]{6})$/,Se=/^[\p{L}\p{N}\u4e00-\u9fff '",\-_. ]{1,200}$/u;function Ge(e){if(typeof e!="object"||e===null)return O;const n=e,t=n.selection,r=typeof t?.id=="string"&&Rt.test(t.id)&&(t.source==="builtin"||t.source==="user"||t.source==="pack")?{source:t.source,id:t.id}:O.selection,o=n.tweaks??{},i={...typeof o.accent=="string"&&Lt.test(o.accent)?{accent:o.accent}:{},...typeof o.fontSans=="string"&&Se.test(o.fontSans)?{fontSans:o.fontSans}:{},...typeof o.fontMono=="string"&&Se.test(o.fontMono)?{fontMono:o.fontMono}:{},...typeof o.fontProse=="string"&&Se.test(o.fontProse)?{fontProse:o.fontProse}:{},...typeof o.radius=="number"&&o.radius>=0&&o.radius<=28?{radius:o.radius}:{},...typeof o.spacing=="number"&&o.spacing>=.19&&o.spacing<=.33?{spacing:o.spacing}:{}};return{selection:$t(r),tweaks:i}}function $t(e){return e.source==="builtin"&&Nt.has(e.id)?O.selection:e}function Ht(){try{const e=E.getItem(Tn);return e===null?O:Ge(JSON.parse(e))}catch{return O}}const ie=.25;function Rn(e){const n=Ge(e),t=e.tweaks.spacing;return t===void 0||!Number.isFinite(t)||t<.5*ie||t>2*ie?n:{...n,tweaks:{...n.tweaks,spacing:t}}}function Ut(e){return{...e.accent===void 0?{}:{accent:e.accent},...e.fontSans===void 0?{}:{fontSans:e.fontSans},...e.fontMono===void 0?{}:{fontMono:e.fontMono},...e.fontProse===void 0?{}:{fontProse:e.fontProse},...e.radius===void 0?{}:{radius:e.radius},...e.spacing===void 0?{}:{spacing:e.spacing*ie}}}function xt(e){return{...e.accent===void 0?{}:{accent:e.accent},...e.fontSans===void 0?{}:{fontSans:e.fontSans},...e.fontMono===void 0?{}:{fontMono:e.fontMono},...e.fontProse===void 0?{}:{fontProse:e.fontProse},...e.radius===void 0?{}:{radius:e.radius},...e.spacing===void 0?{}:{spacing:Number((e.spacing/ie).toFixed(4))}}}function jt(){const e=Ie("skin");if(e!==void 0)return Rn({selection:e,tweaks:Ut(Ie("tweaks")??{})})}let pn,kn,mn=!1;function Kt(){const e=_n();return(!mn||pn!==e)&&(pn=e,kn=jt(),mn=!0),kn}const Pe=new Set;let T;function ro(e){return Pe.add(e),()=>{Pe.delete(e)}}function We(){const e=Kt();return e!==void 0?(T=e,e):(T??=Ht(),T)}function oo(){return O}function $(){for(const e of Pe)e()}function zt(e){if(JSON.stringify(e)===JSON.stringify(T)){$();return}T=e,$()}function Vt(e){const n={...We(),...e},t=te()?Rn(n):Ge(n);if(te()){Be("skin",t.selection),e.tweaks!==void 0&&Be("tweaks",xt(t.tweaks));return}try{E.setItem(Tn,JSON.stringify(t))}catch{}zt(t)}wn(()=>{T=void 0,$()});let se=null;function io(e){const n=JSON.stringify(e)!==JSON.stringify(se);se=e,n&&$()}function so(){return se}function Jt(){return se??We()}const Me="kiki.skin.cache";function Gt(){try{const e=E.getItem(Me);return e===null?null:yn(JSON.parse(e)).skin}catch{return null}}function Ln(e){try{e===null?E.removeItem(Me):E.setItem(Me,JSON.stringify(e))}catch{}}let ae=[],Ne=null,U=null,ce=!1;function ao(e,n){const t=n!==Ne||JSON.stringify(e)!==JSON.stringify(ae);ae=e,Ne=n;const r=Jt().selection;if(r.source==="user"){const o=e.find(i=>i.id===r.id)??null;U=o,ce=!0,Ln(o)}t&&$()}function co(){return ae}function lo(){return Ne}let Te=Wt();const $n="kiki.skin.packCache";function Wt(){try{const e=E.getItem($n);if(e===null)return[];const n=JSON.parse(e);return Array.isArray(n)?n.map(t=>yn(t).skin).filter(t=>t!==null):[]}catch{return[]}}function uo(e){if(JSON.stringify(e)!==JSON.stringify(Te)){Te=e;try{E.setItem($n,JSON.stringify(e))}catch{}$()}}function fo(){U=null,ce=!1,Ln(null)}function Yt(e){if(e.source==="builtin")return Nn(e.id)??null;if(e.source==="pack")return Te.find(t=>t.id===e.id)??null;const n=ae.find(t=>t.id===e.id);return n!==void 0?n:(ce||(U=Gt(),ce=!0),U?.id===e.id?U:null)}function po(e){if(typeof document>"u")return;const n=document.documentElement;n.dataset.kikiMotion=e.motion,n.dataset.kikiProse=e.proseFont}const Q={theme:"system",motion:"system",proseFont:"serif",skin:O,background:J};function ko(){const e=tt();return{theme:e.theme,motion:e.motion,proseFont:e.proseFont,skin:We(),background:pe()}}function mo(e){return e.motion===Q.motion&&e.proseFont===Q.proseFont&&JSON.stringify(e.skin)===JSON.stringify(Q.skin)&&e.background.light===null&&e.background.dark===null}function ho(e){return{...Q,theme:e.theme}}function go(e){rt({theme:e.theme,motion:e.motion,proseFont:e.proseFont}),Vt(e.skin),Ct(e.background)}const Z={canvas:["--color-canvas"],paper:["--color-paper","--color-muted","--color-sidebar"],panel:["--color-panel","--color-background"],hairline:["--color-hairline","--color-border","--color-input"],hairlineStrong:["--color-hairline-strong"],ink:["--color-ink","--color-foreground"],inkSoft:["--color-ink-soft","--color-muted-foreground"],inkFaint:["--color-ink-faint"],accent:["--color-accent","--color-primary"],accentDeep:["--color-accent-deep"],accentSoft:["--color-accent-soft"],accentInk:["--color-accent-ink"],onAccent:["--color-on-accent","--color-primary-foreground"],sectionInk:["--color-section-ink"],selected:["--color-selected"],selectedInk:["--color-selected-ink"],attention:["--color-attention"],attentionSoft:["--color-attention-soft"],amberInk:["--color-amber-ink"],amberCard:["--color-amber-card"],amberRule:["--color-amber-rule"],success:["--color-success"],danger:["--color-danger"],onDanger:["--color-on-danger"],bubbleUser:["--color-bubble-user"],scrollbar:["--color-scrollbar"],scrollbarHover:["--color-scrollbar-hover"],termScrollbar:["--color-term-scrollbar"],shell:["--color-shell"],shellInk:["--color-shell-ink"],shellInkStrong:["--color-shell-ink-strong"],shellInkSoft:["--color-shell-ink-soft"],shellDanger:["--color-shell-danger"],shellHairline:["--color-shell-hairline"],shellHover:["--color-shell-hover"],shadowInk:[]},Hn={display:["--font-display"],sans:["--font-sans"],mono:["--font-mono"]};function qt(e){const n=e.replace("#",""),t=n.length===3?n.split("").map(o=>`${o}${o}`).join(""):n;return/^[0-9a-fA-F]{6}$/.test(t)?[0,2,4].map(o=>Number.parseInt(t.slice(o,o+2),16)).join(" "):null}function Fo(e,n){return e.variants[n]??null}function Xt(e){const n=[];return e.variants.light!==void 0&&n.push("light"),e.variants.dark!==void 0&&n.push("dark"),n}const hn="color-mix(in oklab, var(--color-accent) 72%, var(--color-ink))",Qt={sectionInk:"var(--color-ink-soft)",selected:"color-mix(in oklab, var(--color-accent) 12%, var(--color-panel))",selectedInk:"var(--color-accent-ink)",attention:"var(--color-accent-ink)",attentionSoft:"var(--color-accent-soft)"};function bo(e,n={}){const t={};for(const[o,i]of Object.entries(e?.colors??{}))if(typeof i=="string"){if(o==="shadowInk"){const s=qt(i);s!==null&&(t["--kiki-shadow-ink"]=s);continue}for(const s of Z[o]??[])t[s]=i}for(const[o,i]of Object.entries(e?.fonts??{}))if(typeof i=="string")for(const s of Hn[o]??[])t[s]=i;if(e?.colors?.accent!==void 0&&e.colors.accentInk===void 0&&(t["--color-accent-ink"]=hn),e?.colors!==void 0&&Object.keys(e.colors).length>0){for(const[o,i]of Object.entries(Qt))if(e.colors[o]===void 0)for(const s of Z[o])t[s]=i}const r=e?.shape;if(r?.radius!==void 0&&(t["--kiki-sheet-radius"]=`${r.radius}px`),r?.stageGap!==void 0&&(t["--kiki-stage-gap"]=`${r.stageGap}px`),r?.spacing!==void 0&&(t["--spacing"]=`${r.spacing}rem`),n.accent!==void 0){for(const o of Z.accent)t[o]=n.accent;t["--color-accent-deep"]=`color-mix(in oklab, ${n.accent} 78%, black)`,t["--color-accent-soft"]=`color-mix(in oklab, ${n.accent} 14%, var(--color-panel))`,t["--color-accent-ink"]=hn}return n.fontSans!==void 0&&(t["--font-sans"]=n.fontSans),n.fontMono!==void 0&&(t["--font-mono"]=n.fontMono),n.fontProse!==void 0&&(t["--kiki-prose-user"]=n.fontProse),n.radius!==void 0&&(t["--kiki-sheet-radius"]=`${n.radius}px`),n.spacing!==void 0&&(t["--spacing"]=`${n.spacing}rem`),t}function Zt(){return[...Object.values(Z).flat(),...Object.values(Hn).flat(),"--kiki-shadow-ink","--kiki-prose-user","--kiki-sheet-radius","--kiki-stage-gap","--spacing","--color-accent-deep","--color-accent-soft","--color-accent-ink"]}function vo(e,n){for(const t of Zt())e.style.removeProperty(t);for(const[t,r]of Object.entries(n))e.style.setProperty(t,r)}const A=new Map,er=8;function nr(){if(typeof window>"u")return 2560;const e=Math.min(2,window.devicePixelRatio||1),n=Math.max(window.screen?.width??0,window.screen?.height??0,window.innerWidth,window.innerHeight);return Math.min(3840,Math.max(1920,Math.ceil(n*e)))}const tr=320;function rr(){return typeof createImageBitmap=="function"&&typeof OffscreenCanvas<"u"}async function or(e,n){if(!e.type.startsWith("image/")||e.type==="image/gif"||!rr())return e;let t,r;try{t=await createImageBitmap(e);const o=Math.max(t.width,t.height);if(o<=n)return e;const i=n/o,s=Math.max(1,Math.round(t.width*i)),c=Math.max(1,Math.round(t.height*i));r=await createImageBitmap(t,{resizeWidth:s,resizeHeight:c,resizeQuality:"high"});const d=new OffscreenCanvas(s,c),f=d.getContext("bitmaprenderer");return f===null?e:(f.transferFromImageBitmap(r),r=void 0,await d.convertToBlob({type:"image/webp",quality:.9}))}catch{return e}finally{t?.close(),r?.close()}}function ir(){for(;A.size>er;){const e=A.keys().next().value;A.delete(e)}}function Un(e,n,t){const r=`${e}|${n}`,o=A.get(r);if(o!==void 0)return A.delete(r),A.set(r,o),o.catch(()=>null);const i=t().then(s=>s===null?Promise.reject(new Error("missing")):or(s,n));return A.set(r,i),ir(),i.catch(()=>(A.get(r)===i&&A.delete(r),null))}const sr="kiki-appearance",Re="media",P=new Map;let Le=null;function xn(){return Le??=new Promise(e=>{if(typeof indexedDB>"u"){e(null);return}try{const n=indexedDB.open(sr,1);n.onupgradeneeded=()=>{n.result.createObjectStore(Re)},n.onsuccess=()=>{e(n.result)},n.onerror=()=>{e(null)}}catch{e(null)}}),Le}function ke(e,n){return xn().then(t=>new Promise((r,o)=>{if(t===null){r(void 0);return}const i=t.transaction(Re,e),s=n(i.objectStore(Re));i.oncomplete=()=>{r(s.result)},i.onabort=()=>{o(i.error??new Error("media store aborted"))},i.onerror=()=>{o(i.error??new Error("media store failed"))},s.onerror=()=>{o(s.error??new Error("media store failed"))}}))}const G=new Set;async function So(){return await xn()!==null&&G.size===0}async function ar(e,n){P.set(e,n),await ke("readwrite",r=>r.put(n,e)).catch(()=>{})===void 0?G.add(e):G.delete(e)}async function cr(e){const n=P.get(e);if(n!==void 0)return n;const t=await ke("readonly",r=>r.get(e)).catch(()=>{});return t===void 0?null:(P.set(e,t),t)}async function lr(e){P.delete(e),G.delete(e),await ke("readwrite",n=>n.delete(e)).catch(()=>{})}async function Eo(e,n=e.name){const t=n===void 0?null:An(n),r=await ur(e),o=ot(r);if(o===null)return{ok:!1,reason:t===null?"type":"content"};if(t!==null&&t.mime!==o)return{ok:!1,reason:"content"};const i=o.startsWith("video/")?"video":"image",s=i==="video"?Xe.videoBytes:Xe.imageBytes;return e.size>s?{ok:!1,reason:"size"}:{ok:!0,kind:i,mime:o}}function ur(e){return new Promise(n=>{const t=new FileReader;t.onload=()=>{n(new Uint8Array(t.result))},t.onerror=()=>{n(new Uint8Array)},t.readAsArrayBuffer(e.slice(0,32))})}function yo(e,n){const t=e.type===n.mime?e:new Blob([e],{type:n.mime}),r=URL.createObjectURL(t),o=document.createElement(n.kind==="video"?"video":"img");return new Promise(i=>{const s=d=>{clearTimeout(c),o.onload=null,o.onerror=null,o instanceof HTMLVideoElement?(o.onloadeddata=null,o.removeAttribute("src"),o.load()):o.removeAttribute("src"),URL.revokeObjectURL(r),i(d)},c=setTimeout(()=>{s(!1)},15e3);o.onerror=()=>{s(!1)},o instanceof HTMLVideoElement?(o.muted=!0,o.preload="auto",o.onloadeddata=()=>{s(o.videoWidth>0&&o.videoHeight>0)}):o.onload=()=>{s(o.naturalWidth>0)},o.src=r})}let gn=0;async function Ao(e,n,t){gn+=1;const r=`local-${Date.now().toString(36)}-${gn.toString(36)}`;return await ar(r,e.type===n.mime?e:new Blob([e],{type:n.mime})),{id:r,kind:n.kind,mime:n.mime,name:t.slice(0,200),bytes:e.size}}async function Co(e){for(const t of Array.from(P.keys()))e.has(t)||P.delete(t);const n=await ke("readonly",t=>t.getAllKeys()).catch(()=>{});for(const t of n??[])typeof t=="string"&&!e.has(t)&&await lr(t)}function Do(){P.clear(),G.clear(),Le=null}const jn={missing:!1,heavyVideo:!1,paused:null,surfaceAlpha:null,textAlpha:null};let ee=jn;const $e=new Set;function Io(){return ee}function Bo(e){return $e.add(e),()=>{$e.delete(e)}}function B(e){const n={...ee,...e};if(JSON.stringify(n)!==JSON.stringify(ee)){ee=n;for(const t of $e)t()}}const le=new Map;let He=!0;function dr(e){return le.get(e)}function Kn(e,n){if(!(le.has(n)||typeof document>"u"))try{const t=document.createElement("canvas");t.width=48,t.height=32;const r=t.getContext("2d",{willReadFrequently:!0});if(r===null)return;r.drawImage(e,0,0,t.width,t.height),le.set(n,Pt(r.getImageData(0,0,t.width,t.height).data))}catch{}}function Ee(e){return getComputedStyle(document.documentElement).getPropertyValue(e).trim()}function fr(){const e=["--color-ink","--color-ink-soft","--color-ink-faint"].map(Ee),n=Ee("--color-canvas");return["--color-canvas","--color-paper","--color-panel"].map(t=>({surface:Ee(t),ground:n,texts:e}))}let I=null,p={key:"",element:null,urls:[]},N=null,x,w=0,k=null,R=0;function zn(){if(I!==null&&I.root.isConnected)return I;const e=document.createElement("div");e.dataset.kikiBackdrop="",e.setAttribute("aria-hidden","true");const n=document.createElement("div");n.dataset.kikiBackdropMedia="";const t=document.createElement("div");return t.dataset.kikiBackdropScrim="",e.append(n,t),document.body.prepend(e),I={root:e,media:n,scrim:t},I}function Vn(){const e=document.documentElement.dataset.kikiMotion;return e==="reduce"?!1:e==="full"?!0:!window.matchMedia?.("(prefers-reduced-motion: reduce)").matches}let Jn=!1;function pr(){navigator.getBattery?.().then(n=>{const t=()=>{Jn=!n.charging&&n.level<.2,W()};n.addEventListener("levelchange",t),n.addEventListener("chargingchange",t),t()}).catch(()=>{})}function kr(){return Vn()?document.visibilityState==="hidden"||!document.hasFocus()?"hidden":Jn?"power":null:"motion"}function W(){const e=p.element instanceof HTMLVideoElement?p.element:null;if(e===null){B({paused:null});return}const n=kr();B({paused:n==="hidden"?null:n}),n===null?e.play().catch(()=>{}):e.pause()}function Gn(){for(const e of p.urls)URL.revokeObjectURL(e);p={key:"",element:null,urls:[]},N=null}async function Fn(e,n,t,r=!1){const o=e.kind==="image"&&!r?await Un(e.id,nr(),()=>n(e)):await n(e);if(o===null)return null;const i=URL.createObjectURL(o);return t.push(i),i}async function mr(e){if(le.has(e.id)||typeof createImageBitmap!="function")return;const n=await Un(e.id,tr,()=>H(e));if(n!==null)try{const t=await createImageBitmap(n,{resizeWidth:48,resizeHeight:32,resizeQuality:"low"});Kn(t,e.id),t.close()}catch{}}let H=e=>cr(e.id);function wo(e){e!==H&&(H=e,k!==null&&p.element===null&&(N=null,Ue(k,w,R)))}function _o(e){return H(e)}function bn(e,n,t){const{look:r}=n,o=[r.blur>0?`blur(${r.blur}px)`:"",r.brightness!==1?`brightness(${r.brightness})`:""].filter(Boolean).join(" ");if(e.style.opacity=String(r.opacity),e.style.filter=o,t!==null){e.style.backgroundImage=`url("${t}")`,e.style.backgroundRepeat="repeat",e.style.backgroundPosition=ln(r.alignment);return}e.style.objectFit=r.fit==="contain"?"contain":r.fit==="center"?"none":"cover",e.style.objectPosition=ln(r.alignment)}async function Ue(e,n,t){const{media:r}=zn(),o=e.media[n%e.media.length],i=`${e.packId??""}|${o.id}|${e.look.fit}`;if(p.key===i&&p.element!==null){bn(p.element,e,p.element instanceof HTMLDivElement?p.urls[0]??null:null),W();return}if(N?.key===i)return;const s={key:i};N=s;const c=[],d=()=>t!==R||N!==s,f=await Fn(o,H,c,e.look.fit==="tile");let h=null;if(f!==null&&o.kind==="video"&&e.poster!==void 0&&!d()&&(h=await Fn(e.poster,H,c)),d()){for(const a of c)URL.revokeObjectURL(a);return}N=null;const y=k??e;if(f===null){Gn(),r.replaceChildren(),B({missing:!0});return}let l;if(o.kind==="video"){const a=document.createElement("video");a.muted=!0,a.defaultMuted=!0,a.loop=!0,a.playsInline=!0,a.autoplay=!1,a.preload="auto",a.disablePictureInPicture=!0,a.setAttribute("muted",""),a.setAttribute("playsinline",""),h!==null&&(a.poster=h),a.addEventListener("loadeddata",()=>{p.element===a&&(Kn(a,o.id),B({heavyVideo:a.videoWidth*a.videoHeight>2560*1440}),k!==null&&xe(k))},{once:!0}),a.src=f,l=a}else{if(e.look.fit==="tile")l=document.createElement("div");else{const a=document.createElement("img");a.decoding="async",a.alt="",a.src=f,l=a}mr(o).then(()=>{k!==null&&p.key===i&&xe(k)})}l.addEventListener("error",()=>{p.element===l&&B({missing:!0,heavyVideo:!1})},{once:!0}),l.dataset.kikiBackdropItem=o.kind,bn(l,y,l instanceof HTMLDivElement?f:null),r.replaceChildren(l);for(const a of p.urls)URL.revokeObjectURL(a);p={key:i,element:l,urls:c},B({missing:!1,heavyVideo:!1}),W()}function xe(e){const n=document.documentElement,t=e.sample??dr(e.media[w%e.media.length].id),r=e.look.surfaceOpacity,o=He?Math.max(...fr().map(s=>Ot(s,e.look,t,r))):r,i=r>=1?0:Math.max(0,(o-r)/(1-r));n.style.setProperty("--kiki-surface-alpha",`${Math.round(r*100)}%`),n.style.setProperty("--kiki-text-alpha",`${Math.ceil(i*100)}%`),n.style.setProperty("--kiki-solid-alpha",`${Math.ceil(o*100)}%`),n.style.setProperty("--kiki-surface-blur",`${e.look.surfaceBlur}px`),n.style.setProperty("--kiki-backdrop-scrim",String(e.look.scrim)),n.style.setProperty("--kiki-backdrop-overscan",`${Math.ceil(e.look.blur*3)}px`),He?n.dataset.kikiBgAssist="":delete n.dataset.kikiBgAssist,B({surfaceAlpha:r,textAlpha:o})}function Wn(){R+=1,clearInterval(x),x=void 0,k=null,Gn(),I?.root.remove(),I=null;const e=document.documentElement;delete e.dataset.kikiBg,delete e.dataset.kikiBgAssist;for(const n of["--kiki-surface-alpha","--kiki-text-alpha","--kiki-solid-alpha","--kiki-surface-blur","--kiki-backdrop-scrim","--kiki-backdrop-overscan"])e.style.removeProperty(n);B(jn)}function Oo(e,n=!0){if(typeof document>"u")return;if(He=n,e===null){(k!==null||I!==null)&&Wn();return}const t=JSON.stringify(k?.media)!==JSON.stringify(e.media)||k?.packId!==e.packId;k=e,t&&(R+=1,w=0),document.documentElement.dataset.kikiBg=e.look.scope,zn().root.dataset.scope=e.look.scope,e.look.scope!=="window"&&(vn(),requestAnimationFrame(vn)),xe(e),Ue(e,w,R),clearInterval(x),x=void 0,e.media.length>1&&e.interval>0&&Vn()&&(x=setInterval(()=>{k===null||document.visibilityState==="hidden"||(w=(w+1)%k.media.length,Ue(k,w,R))},e.interval*1e3))}let j=null,D=null;function ue(){const e=D?.getBoundingClientRect().right??0;document.documentElement.style.setProperty("--kiki-backdrop-sidebar",`${Math.round(e)}px`)}function vn(){if(typeof ResizeObserver>"u")return;const e=document.querySelector(".app-sidebar");e!==D&&(j??=new ResizeObserver(ue),D!==null&&j.unobserve(D),D=e,D!==null&&j.observe(D),ue())}function hr(){return window.addEventListener("resize",ue),()=>{window.removeEventListener("resize",ue),j?.disconnect(),j=null,D=null,document.documentElement.style.removeProperty("--kiki-backdrop-sidebar")}}let ye=!1;function Po(){if(ye||typeof window>"u")return()=>{};ye=!0;const e=()=>{W()};document.addEventListener("visibilitychange",e),window.addEventListener("focus",e),window.addEventListener("blur",e);const n=window.matchMedia?.("(prefers-reduced-motion: reduce)");n?.addEventListener?.("change",e),pr();const t=hr();return()=>{ye=!1,t(),document.removeEventListener("visibilitychange",e),window.removeEventListener("focus",e),window.removeEventListener("blur",e),n?.removeEventListener?.("change",e),Wn()}}function Mo(){typeof document<"u"&&W()}const je="pack:";function gr(e,n){return`${je}${e}/${n}`}function No(e){if(!e.startsWith(je))return null;const n=e.slice(je.length),t=n.indexOf("/");return t<=0?null:{packId:n.slice(0,t),file:n.slice(t+1)}}function Sn(e,n){const t=An(n);return t===null?null:{id:gr(e,n),kind:t.kind,mime:t.mime,name:n,bytes:0}}function En(e,n){if(n===void 0)return null;const{media:t,poster:r,interval:o,shuffle:i,...s}=n,c=t.map(d=>Sn(e,d)).filter(d=>d!==null);return c.length===0?null:{media:c,poster:r===void 0?void 0:Sn(e,r)??void 0,interval:o??0,look:On(s),packId:e}}function To(e){const n=En(e.id,e.variants.light?.background),t=En(e.id,e.variants.dark?.background);return n===null||t===null?{light:n??t,dark:null,linked:!0}:{light:n,dark:t,linked:!1}}function Ro(e){const n=o=>{const i=e.variants[o];if(i===void 0)return;const{background:s,...c}=i;return c.colors===void 0&&c.fonts===void 0&&c.shape===void 0?void 0:c},t=n("light"),r=n("dark");return t===void 0&&r===void 0?null:{kind:"kiki-skin",version:1,id:e.id,name:e.name,description:e.description,author:e.author,variants:{light:t,dark:r}}}function Ae(e,n){const t={...e.colors};n.tweaks.accent!==void 0&&(t.accent=n.tweaks.accent);const r={...e.fonts};n.tweaks.fontSans!==void 0&&(r.sans=n.tweaks.fontSans),n.tweaks.fontMono!==void 0&&(r.mono=n.tweaks.fontMono);const o={...e.shape};return n.tweaks.radius!==void 0&&(o.radius=n.tweaks.radius),n.tweaks.spacing!==void 0&&(o.spacing=n.tweaks.spacing),{...e.base!==void 0?{base:e.base}:{},...Object.keys(t).length>0?{colors:t}:{},...Object.keys(r).length>0?{fonts:r}:{},...Object.keys(o).length>0?{shape:o}:{}}}function Lo(e,n){const t=Yt(e.selection)??Nn("paper")??null,r=Fr(n)||"my-skin",o={};for(const s of t===null?[]:Xt(t))o[s]=Ae(t?.variants[s]??{},e);Object.keys(o).length===0&&(o.light=Ae({},e),o.dark=Ae({},e));const i={$schema:"https://kiki.dev/schema/skin-v1.json",kind:"kiki-skin",version:1,id:r,name:n.trim()===""?"My skin":n.trim(),...t?.description!==void 0?{description:t.description}:{},variants:o};return{filename:`${r}.json`,json:`${JSON.stringify(i,null,2)}
1
+ import{K as qn,u as Xn,M as E,N as Qn,O as Zn,P as et,Q as nt,T as yn,a as tt,U as rt,V as An,W as ot,X as Xe}from"./index-B0KPRi1U.js";import{M as Cn,h as it}from"./spaces-DqMTtCXX.js";function st(e,n){const t=n?.current_space_id;return!n?.server_id||t===void 0||t!==Cn&&!qn.test(t)?null:{client:e,identity:{serverId:n.server_id,homeId:t}}}function Sr(e){return e!==null&&e.identity.homeId!==Cn}const Qe=new WeakMap;let at=0;function ct(e){let n=Qe.get(e);return n===void 0&&(n=++at,Qe.set(e,n)),n}function Er(e,n){const t=Xn({queryKey:["space-settings","meta",e===null?null:ct(e)],queryFn:async({signal:r})=>{if(e===null)throw new Error("Space client unavailable");const o=await e.meta();return r.throwIfAborted(),o},enabled:e!==null&&n===void 0,staleTime:3e4,retry:!1});return e===null?null:st(e,n===void 0?t.data:n)}function Ke(e){return it(e)}const yr={all:["space-settings"],detail:e=>["space-settings","detail",e]},lt=["config","appearance","agents","instructions","skills","mcp","credentials","plugins"],Dn="generic_roots";function Ar(e){return`st.spaces.group.${e}`}const ne={theme:"pref:theme",skin:"pref:skin",tweaks:"pref:tweaks",background:"pref:background",proseFont:"pref:proseFont",defaultAppendTiming:"pref:defaultAppendTiming",foldSteps:"pref:foldSteps",worktreeSkipConfirm:"pref:worktreeSkipConfirm"};function Cr(e,n){return e?.items.find(t=>t.id===n)}function ut(e){return e.replaceAll(/[A-Z]/g,n=>`_${n.toLowerCase()}`)}function Dr(e,n=[]){return`config:${[e,...n].map(ut).join(".")}`}const dt={"pref:theme":"st.appearance.theme","pref:skin":"st.skin.title","pref:tweaks":"st.skin.tweaks","pref:background":"st.bg.title","pref:proseFont":"st.appearance.prose","pref:defaultAppendTiming":"st.communication.appendTimingTitle","pref:foldSteps":"st.transcript.foldSteps","pref:worktreeSkipConfirm":"st.composer.worktreeConfirm","config:default_model":"st.defaults.globalModelLabel","config:fast_model":"st.defaults.row.fast","config:subagent.default_model":"st.defaults.row.subagent","config:session_title.model":"st.defaults.row.title","config:default_permission_mode":"st.defaults.permissionMode","config:default_plan_mode":"st.defaults.planMode","config:thinking.effort":"st.profiles.effort","source:credentials":"st.spaces.group.credentials","source:instructions":"st.spaces.group.instructions","source:generic_roots":"st.spaces.group.generic_roots"};function Ir(e,n,t){const r=dt[e];return r===void 0?n:t(r)}function ft(e,n){const t=e.groups.find(r=>r.domain===n);if(t!==void 0)return{mode:t.mode,fixedCount:t.fixed_count,followCount:t.follow_count,stacked:n==="instructions"&&e.inherit.instructions==="stack"}}function Br(e,n,t){const r=ft(e,n);return r===void 0?t("st.spaces.origin.unknown"):n==="credentials"?t(e.inherit.credentials==="shared"?"st.spaces.group.shared":"st.spaces.group.isolated"):n===Dn?t(e.inherit.generic_roots?"st.spaces.group.available":"st.spaces.group.unavailable"):e.primary?t("st.spaces.group.items",{count:r.fixedCount}):r.mode==="follow"?r.stacked?t("st.spaces.group.stacked"):r.fixedCount===0?t("st.spaces.group.follow"):t("st.spaces.group.followFixed",{count:r.fixedCount}):r.followCount===0?t("st.spaces.group.fixed"):t("st.spaces.group.fixedFollow",{count:r.followCount})}function wr(e){const n=new Map([...lt,Dn].map((t,r)=>[t,r]));return e.items.filter(t=>t.kind!=="source"&&t.origin==="home").toSorted((t,r)=>(n.get(t.domain)??99)-(n.get(r.domain)??99)||t.name.localeCompare(r.name))}const pt={"pref:theme":"/settings/appearance","pref:skin":"/settings/appearance","pref:tweaks":"/settings/appearance","pref:background":"/settings/appearance","pref:proseFont":"/settings/appearance","pref:defaultAppendTiming":"/settings/general","pref:foldSteps":"/settings/general","pref:worktreeSkipConfirm":"/settings/general","config:default_model":"/settings/ai","config:fast_model":"/settings/ai","config:thinking.effort":"/settings/ai","config:session_title.model":"/settings/ai","config:default_permission_mode":"/settings/permissions"},kt=[["resource:agents:","/settings/agents"],["resource:skills:","/settings/skills"],["resource:mcp:","/settings/mcp"],["resource:plugins:","/settings/plugins"],["resource:appearance:","/settings/appearance"]];function _r(e){const n=pt[e];return n!==void 0?n:kt.find(([t])=>e.startsWith(t))?.[1]}function ze(e,n=48){return e.length>n?`${e.slice(0,n-1)}…`:e}function mt(e){try{return ze(JSON.stringify(e),72)}catch{return""}}function ht(e,n,t){if(e==="pref:background"&&n==null)return t("st.spaces.value.backgroundNone");if(e==="pref:theme"&&(n==="light"||n==="dark"||n==="system"))return t(`st.appearance.theme.${n}`);if(e==="pref:proseFont"&&(n==="serif"||n==="sans"))return t(`st.appearance.prose.${n}`);if(e==="pref:defaultAppendTiming"&&(n==="agent_idle"||n==="subagents_done"||n==="tasks_done"))return t(`st.spaces.value.appendTiming.${n}`);if(e==="pref:skin"&&typeof n=="object"&&n!==null){const r=n;if(typeof r.id!="string")return;const o=r.source==="pack"?"st.spaces.value.skinPack":r.source==="user"?"st.spaces.value.skinUser":"st.spaces.value.skinBuiltin";return t(o,{id:r.id})}if(e==="pref:tweaks"&&typeof n=="object"&&n!==null){const r=Object.keys(n).length;return r===0?t("st.spaces.value.tweaksNone"):t("st.spaces.value.tweaksCount",{count:r})}if(e==="pref:background"&&typeof n=="object"&&n!==null){const r=n,o=(r.linked===!1?r.dark:r.light)??r.light??r.dark;if(o==null||typeof o!="object")return t("st.spaces.value.backgroundNone");const i=o.media;if(!Array.isArray(i)||i.length===0)return t("st.spaces.value.backgroundNone");if(i.length>1)return t("st.spaces.value.backgroundCount",{count:i.length});const s=i[0],c=typeof s?.name=="string"&&s.name!==""?s.name:typeof s?.id=="string"?s.id.split("/").at(-1)??s.id:"";return c===""?t("st.spaces.value.backgroundCount",{count:i.length}):ze(c,32)}}function Or(e,n,t){const r=ht(e,n,t);return r!==void 0?r:n==null?t("st.spaces.value.none"):typeof n=="boolean"?t(n?"st.spaces.value.on":"st.spaces.value.off"):typeof n=="string"?ze(n):typeof n=="number"?String(n):Array.isArray(n)?t("st.spaces.group.items",{count:n.length}):mt(n)}function Pr(e){const n=[],t=[],r=[];for(const o of e.rows)o.id.startsWith("group:")?n.push(o):o.same_value?r.push(o):t.push(o);return{changed:t,same:r,groups:n}}function Mr(e){return e.blocked_reason===void 0}const gt=[["Resource content is unavailable","st.spaces.blocked.resourceUnavailable"],["Only resources can be excluded","st.spaces.blocked.onlyResources"],["This item cannot be shared through the ordinary push flow","st.spaces.blocked.notShareable"],["Edit this resource through its resource editor","st.spaces.blocked.editResource"],["Main space has no parent source","st.spaces.blocked.mainNoParent"]];function Nr(e,n){if(e.startsWith("Connection contains account data"))return n("st.spaces.blocked.accountData");const t=gt.find(([r])=>r===e);return t===void 0?e:n(t[1])}function F(e){return`${e.serverId}|${e.homeId}`}const In="kiki.spacePreferences.cache",Ze={entries:{},authorities:{},lastKnown:null,resolved:{}};function de(){try{const e=localStorage.getItem(In);if(e===null)return Ze;const n=JSON.parse(e);return{entries:typeof n.entries=="object"&&n.entries!==null?n.entries:{},authorities:typeof n.authorities=="object"&&n.authorities!==null?n.authorities:{},lastKnown:n.lastKnown??null,resolved:typeof n.resolved=="object"&&n.resolved!==null?n.resolved:{}}}catch{return Ze}}function Bn(e){try{localStorage.setItem(In,JSON.stringify(e))}catch{}}const L={identity:null,confirmed:null,authoritative:!1,drafts:{},writes:{},deviceConflict:!1,loaded:!1};let u=L,K=0,Ft=0,_=0,Ce={},z={};const De=new Set;function b(e){return u.identity!==null&&F(u.identity)===F(e)}function fe(){K+=1,Ce={},z={}}function wn(e){return De.add(e),()=>{De.delete(e)}}function _n(){return u}function Tr(){return L}function C(e){u=e;for(const n of De)n();vt()}function V(e,n,t=!0){const r=de(),o=n.preferences;Bn({...r,entries:{...r.entries,[F(e)]:o},authorities:{...r.authorities,[F(e)]:n.preference_authority},lastKnown:t?{homeId:e.homeId,serverId:e.serverId,values:o}:r.lastKnown})}function Rr(e){return de().resolved[F(e)]===!0}function Lr(e,n){const t=de(),r=t.lastKnown?.homeId===e?t.lastKnown:null,o=n===void 0?r===null?null:{serverId:r.serverId,homeId:e}:{serverId:n,homeId:e};if(o===null||b(o)&&u.loaded)return;const i=n===void 0?r?.values??null:t.entries[F(o)]??null,s=t.authorities[F(o)]===!0?i:null;b(o)||fe(),C({...L,identity:o,confirmed:s})}function $r(e,n){const t=b(e);t||fe(),V(e,n),C({...t?u:L,identity:e,confirmed:n.preferences,authoritative:n.preference_authority,loaded:!0})}function Hr(){u!==L&&(fe(),C(L))}function Ur(){u.deviceConflict||C({...u,deviceConflict:!0})}function xr(e){const n=e??u.identity;if(n!==null){const t=de();Bn({...t,resolved:{...t.resolved,[F(n)]:!0}})}n!==null&&b(n)&&u.deviceConflict&&C({...u,deviceConflict:!1})}function Ie(e){const n=u.drafts[e];return n!==void 0?n:u.confirmed===null?void 0:u.confirmed[e]}function te(){return u.confirmed!==null||Y!==void 0}let Y;const bt=new Set;function jr(e){Y=e}function vt(){for(const e of bt)e()}function Ve(e,n,t,r=[]){if(!b(e)||u.confirmed===null)return n;const o={...n.preferences};for(const s of Object.keys(ne))((z[s]??0)>t||r.includes(s))&&Object.assign(o,{[s]:u.confirmed[s]});const i=Object.values(z).some(s=>s>t);return{...n,preferences:o,preference_authority:i?u.authoritative:n.preference_authority}}async function Kr(e,n){const t=_,r=await Ke(e).detail(n.homeId);return Ve(n,r,t)}async function Be(e,n){const t=Y,r=t?.client()??null,o=t?.identity()??null;return t===void 0||r===null||o===null||t.spaceId()!==o.homeId?!1:St(r,o,{[e]:n})}async function St(e,n,t){if(!b(n))return!1;const r=Object.keys(ne).filter(l=>t[l]!==void 0);if(r.length===0)return!1;const o=Y,i=K,s=_,c=++Ft,d={...u.drafts},f={...u.writes};for(const l of r)Ce[l]=c,d[l]=t[l],f[l]={state:"saving"};C({...u,drafts:d,writes:f});const h=()=>K===i&&b(n),y=()=>r.filter(l=>Ce[l]===c);try{const l=Ke(e),a=r.map(m=>({id:ne[m],value:t[m]})),M=await l.preview(n.homeId,{action:"edit",changes:a});for(const m of a){const ge=M.rows.find(Yn=>Yn.id===m.id);if(ge===void 0||ge.blocked_reason!==void 0)throw new Error(ge?.blocked_reason??`The server returned no plan for ${m.id}`)}const q=await l.apply(n.homeId,{token:M.token,selected:a.map(m=>m.id)});if(!h())return b(n)||V(n,q.detail,!1),!0;const me=y();if(me.length===0)return!0;const X=Ve(n,q.detail,s,r.filter(m=>!me.includes(m))),Ye={...u.drafts},qe={...u.writes};_+=1;for(const m of me)z[m]=_,delete Ye[m],delete qe[m];V(n,X),C({...u,confirmed:X.preferences,authoritative:X.preference_authority,loaded:!0,drafts:Ye,writes:qe});const he=o?.identity();return h()&&he!==null&&he!==void 0&&F(he)===F(n)&&o?.onDetail?.(X),!0}catch(l){if(h()){const a={...u.writes};for(const M of y())a[M]={state:"error",error:l};y().length>0&&C({...u,writes:a})}return!1}}async function zr(e,n,t,r){const o=K,i=_,s=Y;try{const c=await Ke(e).importPreferences(n.homeId,{values:r,device_id:t});if(K!==o||u.identity!==null&&!b(n))return b(n)||V(n,c.detail,!1),{imported:c.imported,conflict:c.device_conflict};const d=Ve(n,c.detail,i);u.identity===null&&fe(),_+=1;for(const h of Object.keys(ne))z[h]=_;V(n,d),C({...u,identity:n,confirmed:d.preferences,authoritative:d.preference_authority,deviceConflict:c.device_conflict,loaded:!0});const f=s?.identity();return b(n)&&f!==null&&f!==void 0&&F(f)===F(n)&&s?.onDetail?.(d),{imported:c.imported,conflict:c.device_conflict}}catch{return null}}function Vr(){const e="kiki.deviceId";try{const n=localStorage.getItem(e);if(n!==null&&n!=="")return n;const t=globalThis.crypto?.randomUUID?.()??`device-${Date.now().toString(36)}`;return localStorage.setItem(e,t),t}catch{return"device-unknown"}}const J={light:null,dark:null,linked:!0,assist:!0},we="kiki.background";function v(e,n,t,r){return typeof e=="number"&&Number.isFinite(e)?Math.min(t,Math.max(n,e)):r}function Fe(e,n,t){return typeof e=="string"&&n.includes(e)?e:t}function On(e){const n=typeof e=="object"&&e!==null?e:{},t=Qn;return{fit:Fe(n.fit,nt,t.fit),alignment:Fe(n.alignment,et,t.alignment),opacity:v(n.opacity,0,1,t.opacity),blur:v(n.blur,0,40,t.blur),brightness:v(n.brightness,.4,1.4,t.brightness),scrim:v(n.scrim,0,.9,t.scrim),scope:Fe(n.scope,Zn,t.scope),surfaceOpacity:v(n.surfaceOpacity,.3,1,t.surfaceOpacity),surfaceBlur:v(n.surfaceBlur,0,32,t.surfaceBlur)}}function en(e){if(typeof e!="object"||e===null)return null;const n=e;return typeof n.id!="string"||!/^(?:local-[\w-]{1,80}|pack:[a-z0-9][a-z0-9-]{0,63}\/[A-Za-z0-9][A-Za-z0-9._-]{0,99})$/.test(n.id)||n.kind!=="image"&&n.kind!=="video"||typeof n.mime!="string"||!/^(image|video)\/[\w.+-]+$/.test(n.mime)?null:{id:n.id,kind:n.kind,mime:n.mime,name:typeof n.name=="string"?n.name.slice(0,200):n.id,bytes:v(n.bytes,0,Number.MAX_SAFE_INTEGER,0)}}function Et(e){if(typeof e!="object"||e===null)return;const n=e;if(!(typeof n.dark!="number"||typeof n.light!="number"))return{dark:v(n.dark,0,1,0),light:v(n.light,0,1,1)}}function nn(e){if(typeof e!="object"||e===null)return null;const n=e,t=(Array.isArray(n.media)?n.media:[]).map(en).filter(o=>o!==null).slice(0,12);if(t.length===0)return null;const r=en(n.poster)??void 0;return{media:t,poster:r,interval:v(n.interval,0,3600,0),look:On(n.look),packId:typeof n.packId=="string"&&/^[a-z0-9][a-z0-9-]{0,63}$/.test(n.packId)?n.packId:void 0,sample:Et(n.sample)}}function Je(e){if(typeof e!="object"||e===null)return J;const n=e;return{light:nn(n.light),dark:nn(n.dark),linked:n.linked!==!1,assist:n.assist!==!1}}const re=new Set;let g;function Pn(){try{const e=E.getItem(we);return e===null?J:Je(JSON.parse(e))}catch{return J}}function Jr(e){return re.add(e),()=>{re.delete(e)}}function Gr(){return Pn()}function tn(e){return{id:e.id,kind:e.kind,mime:e.mime,name:e.name,bytes:e.bytes}}function oe(e){return e===null?null:{media:e.media.map(tn),...e.poster===void 0?{}:{poster:tn(e.poster)},interval:e.interval,look:e.look,...e.packId===void 0?{}:{packId:e.packId},...e.sample===void 0?{}:{sample:e.sample}}}function S(e){return e===null?!0:[...e.media,...e.poster===void 0?[]:[e.poster]].every(n=>n.id.startsWith("pack:"))}function Wr(e){if(!(!S(e.light)||!S(e.dark)))return{light:oe(e.light),dark:oe(e.dark),linked:e.linked,assist:e.assist}}function yt(){const e=Ie("background");if(e!==void 0)return Je(e)}let rn,on,sn=!1;function At(){const e=_n();return(!sn||rn!==e)&&(rn=e,on=yt(),sn=!0),on}function Yr(){const e=pe();return te()&&!(S(e.light)&&S(e.dark))}function pe(){return g??=Pn(),!S(g.light)||!S(g.dark)?g:At()??g}function qr(){return J}function Ct(e){const n=Je({...e,assist:e.assist??pe().assist});if(te()&&S(n.light)&&S(n.dark)){g!==void 0&&(!S(g.light)||!S(g.dark))&&an(n),Be("background",{light:oe(n.light),dark:oe(n.dark),linked:n.linked,assist:n.assist});return}an(n)}function an(e){try{e.light===null&&e.dark===null&&e.linked&&e.assist?E.removeItem(we):E.setItem(we,JSON.stringify(e))}catch{}JSON.stringify(e)!==JSON.stringify(g)&&(g=e);for(const n of re)n()}wn(()=>{g=void 0;for(const e of re)e()});function Xr(){return pe()}function Qr(){g=void 0}function Zr(e,n){return e.linked?e.light??e.dark:e[n]}function eo(e,n){return e.linked?"light":n}function be(e){const n=e.trim().replace("#",""),t=n.length===3?n.split("").map(r=>`${r}${r}`).join(""):n;return/^[0-9a-fA-F]{6}$/.test(t)?[0,2,4].map(r=>Number.parseInt(t.slice(r,r+2),16)/255):null}const ve=e=>e<=.04045?e/12.92:((e+.055)/1.055)**2.4,Dt=e=>e<=.0031308?e*12.92:1.055*e**(1/2.4)-.055;function _e(e){return .2126*ve(e[0])+.7152*ve(e[1])+.0722*ve(e[2])}function It(e,n){const[t,r]=e>n?[e,n]:[n,e];return(t+.05)/(r+.05)}function cn(e,n,t){return[0,1,2].map(r=>e[r]*t+n[r]*(1-t))}function Bt(e){const n=Dt(Math.min(1,Math.max(0,e)));return[n,n,n]}const wt=4.5,_t=.15;function Ot(e,n,t,r){const o=be(e.surface),i=be(e.ground),s=e.texts.map(be).filter(l=>l!==null);if(o===null||i===null||s.length===0)return 1;const c=n.opacity*(1-n.scrim),d=[t?.dark??0,t?.light??1].map(l=>{const a=Bt(Math.min(1,l*n.brightness));return cn(a,i,c)}),f=l=>d.every(a=>{const M=_e(cn(o,a,l));return s.every(q=>It(_e(q),M)>=wt+_t)});if(f(r))return r;let h=r,y=1;for(let l=0;l<16;l+=1){const a=(h+y)/2;f(a)?y=a:h=a}return Math.min(1,Math.ceil(y*100)/100)}function Pt(e){const n=[];for(let r=0;r+3<e.length;r+=4)e[r+3]<16||n.push(_e([e[r]/255,e[r+1]/255,e[r+2]/255]));if(n.length===0)return{dark:0,light:1};n.sort((r,o)=>r-o);const t=r=>n[Math.min(n.length-1,Math.floor(r*n.length))];return{dark:t(.05),light:t(.95)}}const Mt={center:"center",top:"center top",bottom:"center bottom",left:"left center",right:"right center",topLeft:"left top",topRight:"right top",bottomLeft:"left bottom",bottomRight:"right bottom"};function ln(e){return Mt[e]}const Mn="paper",Nt=new Set(["linen","graphite","forest","claret","heather","nocturne","sand","slate"]),Oe="'Instrument Sans Variable', 'Instrument Sans', ui-sans-serif, system-ui, 'Segoe UI', 'PingFang SC', 'Noto Sans SC', sans-serif",un=Oe,Tt=[{kind:"kiki-skin",version:1,id:Mn,name:"纸色 Paper × 墨砚 Inkstone",description:"Warm white paper and ink-blue marks; cool charcoal and copper after dark.",variants:{light:{colors:{canvas:"#F2EFE8",paper:"#FBFAF6",panel:"#FFFDFA",hairline:"#E4DDD0",hairlineStrong:"#CDC3B1",ink:"#1B1A17",inkSoft:"#4B453E",inkFaint:"#665E54",accent:"#C8401A",accentDeep:"#9C3012",accentSoft:"#F8E3D8",accentInk:"#9C3012",onAccent:"#FFFFFF",sectionInk:"#4B453E",selected:"#DFE8F0",selectedInk:"#1D4D6D",attention:"#B33A12",attentionSoft:"#FAE3D7",amberInk:"#87480B",amberCard:"#F8EEDD",amberRule:"#D9A441",success:"#2F6B45",danger:"#B0261E",onDanger:"#FFFFFF",bubbleUser:"#EEE8DC",scrollbar:"#D8D0C1",scrollbarHover:"#C4BAA8",termScrollbar:"#4A4238",shell:"#1F1B16",shellInk:"#E8DCC4",shellInkStrong:"#F3E9D8",shellInkSoft:"#9B8E7A",shellDanger:"#D9A08A",shellHairline:"#332D24",shellHover:"#2A251D",shadowInk:"#1B1A17"}},dark:{colors:{canvas:"#13191C",paper:"#1B2226",panel:"#252D31",hairline:"#354047",hairlineStrong:"#596870",ink:"#EEEAE2",inkSoft:"#C1C5C5",inkFaint:"#A2ACAF",accent:"#EB946F",accentDeep:"#F4B08F",accentSoft:"#382A25",accentInk:"#F4AE8D",onAccent:"#261A14",sectionInk:"#C1C5C5",selected:"#24323B",selectedInk:"#A3CBDE",attention:"#F4AE8D",attentionSoft:"#382A25",amberInk:"#E6BD78",amberCard:"#322B20",amberRule:"#96783F",success:"#9AC6AE",danger:"#F1A29A",onDanger:"#301414",bubbleUser:"#293238",scrollbar:"#4F5F68",scrollbarHover:"#74838C",termScrollbar:"#526068",shell:"#101518",shellInk:"#D1D9DA",shellInkStrong:"#F0F2EF",shellInkSoft:"#9AA7AB",shellDanger:"#F1A29A",shellHairline:"#354047",shellHover:"#202B30",shadowInk:"#000000"}}}},{kind:"kiki-skin",version:1,id:"porcelain",name:"瓷白 Porcelain × 深海 Deepwater",description:"Cool white paper and cobalt details; layered navy and mist-blue controls at night.",variants:{light:{colors:{canvas:"#E7EDF4",paper:"#F8FBFF",panel:"#FFFFFF",hairline:"#D2DDE9",hairlineStrong:"#A9B9CA",ink:"#17283D",inkSoft:"#405570",inkFaint:"#516279",accent:"#2856A6",accentDeep:"#1B3F84",accentSoft:"#E2EBFA",accentInk:"#204986",onAccent:"#FFFFFF",sectionInk:"#405570",selected:"#DEE8F7",selectedInk:"#204986",attention:"#9C461C",attentionSoft:"#F9E8DC",amberInk:"#7E520D",amberCard:"#F8EED9",amberRule:"#B58A3B",success:"#28664B",danger:"#AF343E",onDanger:"#FFFFFF",bubbleUser:"#E6EDF6",scrollbar:"#B6C5D6",scrollbarHover:"#8B9FB5",termScrollbar:"#52657C",shell:"#142033",shellInk:"#D8E3F1",shellInkStrong:"#F2F7FF",shellInkSoft:"#9CACC2",shellDanger:"#F1A6AB",shellHairline:"#35475E",shellHover:"#24354C",shadowInk:"#132237"}},dark:{colors:{canvas:"#0D1624",paper:"#152238",panel:"#1E304A",hairline:"#304761",hairlineStrong:"#586E88",ink:"#E4EDF9",inkSoft:"#B8C9E0",inkFaint:"#98B0CB",accent:"#9DAEF5",accentDeep:"#BAC8FF",accentSoft:"#283653",accentInk:"#BAC8FF",onAccent:"#17203C",sectionInk:"#B8C9E0",selected:"#293A55",selectedInk:"#BAD1F5",attention:"#F1C28C",attentionSoft:"#362D26",amberInk:"#E9C474",amberCard:"#332D20",amberRule:"#927A46",success:"#99D0B5",danger:"#F2A4AE",onDanger:"#351724",bubbleUser:"#223551",scrollbar:"#455F7E",scrollbarHover:"#6D88A8",termScrollbar:"#4D627C",shell:"#090F1A",shellInk:"#CFDDF0",shellInkStrong:"#EDF4FF",shellInkSoft:"#98ADC8",shellDanger:"#F2A4AE",shellHairline:"#283B53",shellHover:"#17273D",shadowInk:"#000000"}}}},{kind:"kiki-skin",version:1,id:"celadon",name:"青瓷 Celadon × 夜园 Night Garden",description:"Celadon glaze and soft white paper; deep pine surfaces and jade details at night.",variants:{light:{colors:{canvas:"#DDE7DE",paper:"#F2F7EF",panel:"#FCFEF9",hairline:"#C8D8CB",hairlineStrong:"#9DB6A7",ink:"#21382F",inkSoft:"#435D50",inkFaint:"#4D6253",accent:"#24675F",accentDeep:"#174F4A",accentSoft:"#DCECE6",accentInk:"#1E5650",onAccent:"#FFFFFF",sectionInk:"#435D50",selected:"#D7E9DE",selectedInk:"#20594D",attention:"#984B21",attentionSoft:"#F5E7DA",amberInk:"#79520D",amberCard:"#F6EED5",amberRule:"#A1843C",success:"#3E642A",danger:"#A9363C",onDanger:"#FFFFFF",bubbleUser:"#E2ECDD",scrollbar:"#AEC3B1",scrollbarHover:"#839E8B",termScrollbar:"#526A5D",shell:"#14251E",shellInk:"#DDE8DB",shellInkStrong:"#F4F9ED",shellInkSoft:"#9CAC9F",shellDanger:"#F0A8A5",shellHairline:"#364D3F",shellHover:"#253A2F",shadowInk:"#172A23"}},dark:{colors:{canvas:"#111C1A",paper:"#1A2925",panel:"#243830",hairline:"#354E43",hairlineStrong:"#597968",ink:"#E5EEE3",inkSoft:"#BDCEC1",inkFaint:"#9DB4A4",accent:"#8FCBB8",accentDeep:"#ACDCCD",accentSoft:"#283F36",accentInk:"#ACDCCD",onAccent:"#122C23",sectionInk:"#BDCEC1",selected:"#2A4036",selectedInk:"#B4DCC2",attention:"#E8BD86",attentionSoft:"#3B3023",amberInk:"#E2C47E",amberCard:"#34311E",amberRule:"#8C824A",success:"#C0D58F",danger:"#F0AAA4",onDanger:"#351915",bubbleUser:"#2B3E33",scrollbar:"#4E6C5B",scrollbarHover:"#799A85",termScrollbar:"#526B5D",shell:"#0C1512",shellInk:"#D2E1D4",shellInkStrong:"#F0F6EA",shellInkSoft:"#9FB5A6",shellDanger:"#F0AAA4",shellHairline:"#2D493A",shellHover:"#1D3026",shadowInk:"#000000"}}}},{kind:"kiki-skin",version:1,id:"apricot",name:"杏云 Apricot × 晚霞 Afterglow",description:"Apricot-white paper and berry controls; plum-charcoal layers and peach light after dark.",variants:{light:{colors:{canvas:"#F4DED5",paper:"#FFF3EB",panel:"#FFFAF5",hairline:"#DFC7C0",hairlineStrong:"#B698A0",ink:"#382C38",inkSoft:"#604F5C",inkFaint:"#6B5563",accent:"#A13B55",accentDeep:"#822C46",accentSoft:"#F9DFE4",accentInk:"#822C46",onAccent:"#FFFFFF",sectionInk:"#604F5C",selected:"#F2DEE2",selectedInk:"#7D3553",attention:"#934018",attentionSoft:"#FAE2CF",amberInk:"#794C0B",amberCard:"#F8EBD0",amberRule:"#B38A42",success:"#3E674E",danger:"#AF263C",onDanger:"#FFFFFF",bubbleUser:"#F7E3DB",scrollbar:"#CDB0B1",scrollbarHover:"#AC8C96",termScrollbar:"#68576A",shell:"#251D29",shellInk:"#EADDE8",shellInkStrong:"#FFF3F0",shellInkSoft:"#B7A3B6",shellDanger:"#F0A3AD",shellHairline:"#4B3B4C",shellHover:"#382C3A",shadowInk:"#372635"}},dark:{colors:{canvas:"#201A22",paper:"#2C2430",panel:"#3A303E",hairline:"#51404F",hairlineStrong:"#816477",ink:"#F4E9E7",inkSoft:"#D8C2CD",inkFaint:"#C1A9B8",accent:"#F4B29C",accentDeep:"#FFCCB6",accentSoft:"#49323C",accentInk:"#FFCCB6",onAccent:"#351D22",sectionInk:"#D8C2CD",selected:"#443440",selectedInk:"#F3BED0",attention:"#F5C27F",attentionSoft:"#493824",amberInk:"#EDCE8E",amberCard:"#413821",amberRule:"#A48C50",success:"#AFD4B0",danger:"#F8ABB8",onDanger:"#381A29",bubbleUser:"#41323D",scrollbar:"#705768",scrollbarHover:"#9C7F90",termScrollbar:"#705B71",shell:"#17131D",shellInk:"#E5D6E3",shellInkStrong:"#F9EDF1",shellInkSoft:"#BAA3BC",shellDanger:"#F8ABB8",shellHairline:"#46384D",shellHover:"#302638",shadowInk:"#000000"}}}},{kind:"kiki-skin",version:1,id:"iris",name:"鸢尾 Iris × 星幕 Starveil",description:"Violet-white paper and iris ink; indigo-violet layers and silver-lilac controls at night.",variants:{light:{colors:{canvas:"#E7E3F2",paper:"#F6F3FC",panel:"#FCFAFF",hairline:"#D5CEE5",hairlineStrong:"#A99BBF",ink:"#302B48",inkSoft:"#514964",inkFaint:"#615775",accent:"#6542A5",accentDeep:"#4D2F86",accentSoft:"#EAE1F7",accentInk:"#53318B",onAccent:"#FFFFFF",sectionInk:"#514964",selected:"#E7DEF4",selectedInk:"#593793",attention:"#98491B",attentionSoft:"#F7E5D5",amberInk:"#78500B",amberCard:"#F7ECCF",amberRule:"#AE8E45",success:"#306448",danger:"#B1294E",onDanger:"#FFFFFF",bubbleUser:"#ECE6F6",scrollbar:"#BEB1D5",scrollbarHover:"#9985BA",termScrollbar:"#595179",shell:"#211D34",shellInk:"#DED9F0",shellInkStrong:"#F5F0FF",shellInkSoft:"#AAA0C5",shellDanger:"#F0A5BF",shellHairline:"#413857",shellHover:"#312A49",shadowInk:"#29203F"}},dark:{colors:{canvas:"#171626",paper:"#232137",panel:"#312F4A",hairline:"#44405F",hairlineStrong:"#71668F",ink:"#EEECFA",inkSoft:"#CAC3E2",inkFaint:"#ADA4C7",accent:"#C5ADF6",accentDeep:"#DECCFF",accentSoft:"#3D305B",accentInk:"#DECCFF",onAccent:"#27183F",sectionInk:"#CAC3E2",selected:"#35304F",selectedInk:"#D4C6F7",attention:"#F1BE86",attentionSoft:"#413226",amberInk:"#E8CC87",amberCard:"#3C3422",amberRule:"#9E884C",success:"#A5D6BA",danger:"#F3A6C2",onDanger:"#34182A",bubbleUser:"#36304D",scrollbar:"#63577E",scrollbarHover:"#9180B2",termScrollbar:"#615577",shell:"#100F1B",shellInk:"#D8D1EF",shellInkStrong:"#F3EFFF",shellInkSoft:"#ABA0C9",shellDanger:"#F3A6C2",shellHairline:"#39304E",shellHover:"#272238",shadowInk:"#000000"}}}},{kind:"kiki-skin",version:1,id:"contrast",name:"高对比 High contrast × 高对比·黑曜 Obsidian",description:"White paper, black text and visible borders; layered charcoal, ice-cyan focus and near-white controls at night.",variants:{light:{colors:{canvas:"#E7E9EC",paper:"#FFFFFF",panel:"#FFFFFF",hairline:"#6E7781",hairlineStrong:"#20252C",ink:"#0E1116",inkSoft:"#20252C",inkFaint:"#353B44",accent:"#0349B4",accentDeep:"#023787",accentSoft:"#DBE7FB",accentInk:"#023B95",onAccent:"#FFFFFF",sectionInk:"#0E1116",selected:"#DBE7FB",selectedInk:"#023B95",attention:"#A2280A",attentionSoft:"#FDE3D9",amberInk:"#6B3D00",amberCard:"#FDF0CF",amberRule:"#8A5A00",success:"#055D20",danger:"#A0111F",onDanger:"#FFFFFF",bubbleUser:"#F3F3F3",scrollbar:"#C9CBCE",scrollbarHover:"#B3B5B9",termScrollbar:"#4D4F53",shell:"#0E1116",shellInk:"#D4D4D5",shellInkStrong:"#F1F1F1",shellInkSoft:"#939698",shellDanger:"#F0A39C",shellHairline:"#303237",shellHover:"#212429",shadowInk:"#0A0C0F"},fonts:{display:un,sans:Oe},shape:{radius:8}},dark:{colors:{canvas:"#101214",paper:"#1C2024",panel:"#2A3036",hairline:"#8A949E",hairlineStrong:"#C5CDD5",ink:"#F7F9FB",inkSoft:"#E1E6EB",inkFaint:"#C2CBD3",accent:"#E7EDF4",accentDeep:"#FFFFFF",accentSoft:"#303840",accentInk:"#F4F7FA",onAccent:"#11171C",sectionInk:"#F7F9FB",selected:"#303840",selectedInk:"#8DE3F0",attention:"#FFD080",attentionSoft:"#30343A",amberInk:"#F5D58C",amberCard:"#30343A",amberRule:"#BAA276",success:"#A4E0B2",danger:"#FFADB8",onDanger:"#241318",bubbleUser:"#30363C",scrollbar:"#8A949E",scrollbarHover:"#C5CDD5",termScrollbar:"#89939D",shell:"#0C0F12",shellInk:"#E1E6EB",shellInkStrong:"#F7F9FB",shellInkSoft:"#BBC6D0",shellDanger:"#FFADB8",shellHairline:"#89939D",shellHover:"#22282E",shadowInk:"#000000"},fonts:{display:un,sans:Oe},shape:{radius:8}}}}];function Nn(e){return Tt.find(n=>n.id===e)}const dn={paper:"st.skin.desc.paperPair",porcelain:"st.skin.desc.porcelain",celadon:"st.skin.desc.celadon",apricot:"st.skin.desc.apricot",iris:"st.skin.desc.iris",contrast:"st.skin.desc.contrastPair"},fn={paper:"st.skin.name.paper",porcelain:"st.skin.name.porcelain",celadon:"st.skin.name.celadon",apricot:"st.skin.name.apricot",iris:"st.skin.name.iris",contrast:"st.skin.name.contrast"};function no(e){return e!==void 0&&Object.hasOwn(dn,e)?dn[e]:void 0}function to(e){return e!==void 0&&Object.hasOwn(fn,e)?fn[e]:void 0}const Rt=/^[a-z0-9][a-z0-9-]{0,63}$|^[a-z0-9][a-z0-9_-]{0,63}:[a-z0-9][a-z0-9-]{0,63}$/,O={selection:{source:"builtin",id:Mn},tweaks:{}},Tn="kiki.skin",Lt=/^#(?:[0-9a-fA-F]{3}|[0-9a-fA-F]{6})$/,Se=/^[\p{L}\p{N}\u4e00-\u9fff '",\-_. ]{1,200}$/u;function Ge(e){if(typeof e!="object"||e===null)return O;const n=e,t=n.selection,r=typeof t?.id=="string"&&Rt.test(t.id)&&(t.source==="builtin"||t.source==="user"||t.source==="pack")?{source:t.source,id:t.id}:O.selection,o=n.tweaks??{},i={...typeof o.accent=="string"&&Lt.test(o.accent)?{accent:o.accent}:{},...typeof o.fontSans=="string"&&Se.test(o.fontSans)?{fontSans:o.fontSans}:{},...typeof o.fontMono=="string"&&Se.test(o.fontMono)?{fontMono:o.fontMono}:{},...typeof o.fontProse=="string"&&Se.test(o.fontProse)?{fontProse:o.fontProse}:{},...typeof o.radius=="number"&&o.radius>=0&&o.radius<=28?{radius:o.radius}:{},...typeof o.spacing=="number"&&o.spacing>=.19&&o.spacing<=.33?{spacing:o.spacing}:{}};return{selection:$t(r),tweaks:i}}function $t(e){return e.source==="builtin"&&Nt.has(e.id)?O.selection:e}function Ht(){try{const e=E.getItem(Tn);return e===null?O:Ge(JSON.parse(e))}catch{return O}}const ie=.25;function Rn(e){const n=Ge(e),t=e.tweaks.spacing;return t===void 0||!Number.isFinite(t)||t<.5*ie||t>2*ie?n:{...n,tweaks:{...n.tweaks,spacing:t}}}function Ut(e){return{...e.accent===void 0?{}:{accent:e.accent},...e.fontSans===void 0?{}:{fontSans:e.fontSans},...e.fontMono===void 0?{}:{fontMono:e.fontMono},...e.fontProse===void 0?{}:{fontProse:e.fontProse},...e.radius===void 0?{}:{radius:e.radius},...e.spacing===void 0?{}:{spacing:e.spacing*ie}}}function xt(e){return{...e.accent===void 0?{}:{accent:e.accent},...e.fontSans===void 0?{}:{fontSans:e.fontSans},...e.fontMono===void 0?{}:{fontMono:e.fontMono},...e.fontProse===void 0?{}:{fontProse:e.fontProse},...e.radius===void 0?{}:{radius:e.radius},...e.spacing===void 0?{}:{spacing:Number((e.spacing/ie).toFixed(4))}}}function jt(){const e=Ie("skin");if(e!==void 0)return Rn({selection:e,tweaks:Ut(Ie("tweaks")??{})})}let pn,kn,mn=!1;function Kt(){const e=_n();return(!mn||pn!==e)&&(pn=e,kn=jt(),mn=!0),kn}const Pe=new Set;let T;function ro(e){return Pe.add(e),()=>{Pe.delete(e)}}function We(){const e=Kt();return e!==void 0?(T=e,e):(T??=Ht(),T)}function oo(){return O}function $(){for(const e of Pe)e()}function zt(e){if(JSON.stringify(e)===JSON.stringify(T)){$();return}T=e,$()}function Vt(e){const n={...We(),...e},t=te()?Rn(n):Ge(n);if(te()){Be("skin",t.selection),e.tweaks!==void 0&&Be("tweaks",xt(t.tweaks));return}try{E.setItem(Tn,JSON.stringify(t))}catch{}zt(t)}wn(()=>{T=void 0,$()});let se=null;function io(e){const n=JSON.stringify(e)!==JSON.stringify(se);se=e,n&&$()}function so(){return se}function Jt(){return se??We()}const Me="kiki.skin.cache";function Gt(){try{const e=E.getItem(Me);return e===null?null:yn(JSON.parse(e)).skin}catch{return null}}function Ln(e){try{e===null?E.removeItem(Me):E.setItem(Me,JSON.stringify(e))}catch{}}let ae=[],Ne=null,U=null,ce=!1;function ao(e,n){const t=n!==Ne||JSON.stringify(e)!==JSON.stringify(ae);ae=e,Ne=n;const r=Jt().selection;if(r.source==="user"){const o=e.find(i=>i.id===r.id)??null;U=o,ce=!0,Ln(o)}t&&$()}function co(){return ae}function lo(){return Ne}let Te=Wt();const $n="kiki.skin.packCache";function Wt(){try{const e=E.getItem($n);if(e===null)return[];const n=JSON.parse(e);return Array.isArray(n)?n.map(t=>yn(t).skin).filter(t=>t!==null):[]}catch{return[]}}function uo(e){if(JSON.stringify(e)!==JSON.stringify(Te)){Te=e;try{E.setItem($n,JSON.stringify(e))}catch{}$()}}function fo(){U=null,ce=!1,Ln(null)}function Yt(e){if(e.source==="builtin")return Nn(e.id)??null;if(e.source==="pack")return Te.find(t=>t.id===e.id)??null;const n=ae.find(t=>t.id===e.id);return n!==void 0?n:(ce||(U=Gt(),ce=!0),U?.id===e.id?U:null)}function po(e){if(typeof document>"u")return;const n=document.documentElement;n.dataset.kikiMotion=e.motion,n.dataset.kikiProse=e.proseFont}const Q={theme:"system",motion:"system",proseFont:"serif",skin:O,background:J};function ko(){const e=tt();return{theme:e.theme,motion:e.motion,proseFont:e.proseFont,skin:We(),background:pe()}}function mo(e){return e.motion===Q.motion&&e.proseFont===Q.proseFont&&JSON.stringify(e.skin)===JSON.stringify(Q.skin)&&e.background.light===null&&e.background.dark===null}function ho(e){return{...Q,theme:e.theme}}function go(e){rt({theme:e.theme,motion:e.motion,proseFont:e.proseFont}),Vt(e.skin),Ct(e.background)}const Z={canvas:["--color-canvas"],paper:["--color-paper","--color-muted","--color-sidebar"],panel:["--color-panel","--color-background"],hairline:["--color-hairline","--color-border","--color-input"],hairlineStrong:["--color-hairline-strong"],ink:["--color-ink","--color-foreground"],inkSoft:["--color-ink-soft","--color-muted-foreground"],inkFaint:["--color-ink-faint"],accent:["--color-accent","--color-primary"],accentDeep:["--color-accent-deep"],accentSoft:["--color-accent-soft"],accentInk:["--color-accent-ink"],onAccent:["--color-on-accent","--color-primary-foreground"],sectionInk:["--color-section-ink"],selected:["--color-selected"],selectedInk:["--color-selected-ink"],attention:["--color-attention"],attentionSoft:["--color-attention-soft"],amberInk:["--color-amber-ink"],amberCard:["--color-amber-card"],amberRule:["--color-amber-rule"],success:["--color-success"],danger:["--color-danger"],onDanger:["--color-on-danger"],bubbleUser:["--color-bubble-user"],scrollbar:["--color-scrollbar"],scrollbarHover:["--color-scrollbar-hover"],termScrollbar:["--color-term-scrollbar"],shell:["--color-shell"],shellInk:["--color-shell-ink"],shellInkStrong:["--color-shell-ink-strong"],shellInkSoft:["--color-shell-ink-soft"],shellDanger:["--color-shell-danger"],shellHairline:["--color-shell-hairline"],shellHover:["--color-shell-hover"],shadowInk:[]},Hn={display:["--font-display"],sans:["--font-sans"],mono:["--font-mono"]};function qt(e){const n=e.replace("#",""),t=n.length===3?n.split("").map(o=>`${o}${o}`).join(""):n;return/^[0-9a-fA-F]{6}$/.test(t)?[0,2,4].map(o=>Number.parseInt(t.slice(o,o+2),16)).join(" "):null}function Fo(e,n){return e.variants[n]??null}function Xt(e){const n=[];return e.variants.light!==void 0&&n.push("light"),e.variants.dark!==void 0&&n.push("dark"),n}const hn="color-mix(in oklab, var(--color-accent) 72%, var(--color-ink))",Qt={sectionInk:"var(--color-ink-soft)",selected:"color-mix(in oklab, var(--color-accent) 12%, var(--color-panel))",selectedInk:"var(--color-accent-ink)",attention:"var(--color-accent-ink)",attentionSoft:"var(--color-accent-soft)"};function bo(e,n={}){const t={};for(const[o,i]of Object.entries(e?.colors??{}))if(typeof i=="string"){if(o==="shadowInk"){const s=qt(i);s!==null&&(t["--kiki-shadow-ink"]=s);continue}for(const s of Z[o]??[])t[s]=i}for(const[o,i]of Object.entries(e?.fonts??{}))if(typeof i=="string")for(const s of Hn[o]??[])t[s]=i;if(e?.colors?.accent!==void 0&&e.colors.accentInk===void 0&&(t["--color-accent-ink"]=hn),e?.colors!==void 0&&Object.keys(e.colors).length>0){for(const[o,i]of Object.entries(Qt))if(e.colors[o]===void 0)for(const s of Z[o])t[s]=i}const r=e?.shape;if(r?.radius!==void 0&&(t["--kiki-sheet-radius"]=`${r.radius}px`),r?.stageGap!==void 0&&(t["--kiki-stage-gap"]=`${r.stageGap}px`),r?.spacing!==void 0&&(t["--spacing"]=`${r.spacing}rem`),n.accent!==void 0){for(const o of Z.accent)t[o]=n.accent;t["--color-accent-deep"]=`color-mix(in oklab, ${n.accent} 78%, black)`,t["--color-accent-soft"]=`color-mix(in oklab, ${n.accent} 14%, var(--color-panel))`,t["--color-accent-ink"]=hn}return n.fontSans!==void 0&&(t["--font-sans"]=n.fontSans),n.fontMono!==void 0&&(t["--font-mono"]=n.fontMono),n.fontProse!==void 0&&(t["--kiki-prose-user"]=n.fontProse),n.radius!==void 0&&(t["--kiki-sheet-radius"]=`${n.radius}px`),n.spacing!==void 0&&(t["--spacing"]=`${n.spacing}rem`),t}function Zt(){return[...Object.values(Z).flat(),...Object.values(Hn).flat(),"--kiki-shadow-ink","--kiki-prose-user","--kiki-sheet-radius","--kiki-stage-gap","--spacing","--color-accent-deep","--color-accent-soft","--color-accent-ink"]}function vo(e,n){for(const t of Zt())e.style.removeProperty(t);for(const[t,r]of Object.entries(n))e.style.setProperty(t,r)}const A=new Map,er=8;function nr(){if(typeof window>"u")return 2560;const e=Math.min(2,window.devicePixelRatio||1),n=Math.max(window.screen?.width??0,window.screen?.height??0,window.innerWidth,window.innerHeight);return Math.min(3840,Math.max(1920,Math.ceil(n*e)))}const tr=320;function rr(){return typeof createImageBitmap=="function"&&typeof OffscreenCanvas<"u"}async function or(e,n){if(!e.type.startsWith("image/")||e.type==="image/gif"||!rr())return e;let t,r;try{t=await createImageBitmap(e);const o=Math.max(t.width,t.height);if(o<=n)return e;const i=n/o,s=Math.max(1,Math.round(t.width*i)),c=Math.max(1,Math.round(t.height*i));r=await createImageBitmap(t,{resizeWidth:s,resizeHeight:c,resizeQuality:"high"});const d=new OffscreenCanvas(s,c),f=d.getContext("bitmaprenderer");return f===null?e:(f.transferFromImageBitmap(r),r=void 0,await d.convertToBlob({type:"image/webp",quality:.9}))}catch{return e}finally{t?.close(),r?.close()}}function ir(){for(;A.size>er;){const e=A.keys().next().value;A.delete(e)}}function Un(e,n,t){const r=`${e}|${n}`,o=A.get(r);if(o!==void 0)return A.delete(r),A.set(r,o),o.catch(()=>null);const i=t().then(s=>s===null?Promise.reject(new Error("missing")):or(s,n));return A.set(r,i),ir(),i.catch(()=>(A.get(r)===i&&A.delete(r),null))}const sr="kiki-appearance",Re="media",P=new Map;let Le=null;function xn(){return Le??=new Promise(e=>{if(typeof indexedDB>"u"){e(null);return}try{const n=indexedDB.open(sr,1);n.onupgradeneeded=()=>{n.result.createObjectStore(Re)},n.onsuccess=()=>{e(n.result)},n.onerror=()=>{e(null)}}catch{e(null)}}),Le}function ke(e,n){return xn().then(t=>new Promise((r,o)=>{if(t===null){r(void 0);return}const i=t.transaction(Re,e),s=n(i.objectStore(Re));i.oncomplete=()=>{r(s.result)},i.onabort=()=>{o(i.error??new Error("media store aborted"))},i.onerror=()=>{o(i.error??new Error("media store failed"))},s.onerror=()=>{o(s.error??new Error("media store failed"))}}))}const G=new Set;async function So(){return await xn()!==null&&G.size===0}async function ar(e,n){P.set(e,n),await ke("readwrite",r=>r.put(n,e)).catch(()=>{})===void 0?G.add(e):G.delete(e)}async function cr(e){const n=P.get(e);if(n!==void 0)return n;const t=await ke("readonly",r=>r.get(e)).catch(()=>{});return t===void 0?null:(P.set(e,t),t)}async function lr(e){P.delete(e),G.delete(e),await ke("readwrite",n=>n.delete(e)).catch(()=>{})}async function Eo(e,n=e.name){const t=n===void 0?null:An(n),r=await ur(e),o=ot(r);if(o===null)return{ok:!1,reason:t===null?"type":"content"};if(t!==null&&t.mime!==o)return{ok:!1,reason:"content"};const i=o.startsWith("video/")?"video":"image",s=i==="video"?Xe.videoBytes:Xe.imageBytes;return e.size>s?{ok:!1,reason:"size"}:{ok:!0,kind:i,mime:o}}function ur(e){return new Promise(n=>{const t=new FileReader;t.onload=()=>{n(new Uint8Array(t.result))},t.onerror=()=>{n(new Uint8Array)},t.readAsArrayBuffer(e.slice(0,32))})}function yo(e,n){const t=e.type===n.mime?e:new Blob([e],{type:n.mime}),r=URL.createObjectURL(t),o=document.createElement(n.kind==="video"?"video":"img");return new Promise(i=>{const s=d=>{clearTimeout(c),o.onload=null,o.onerror=null,o instanceof HTMLVideoElement?(o.onloadeddata=null,o.removeAttribute("src"),o.load()):o.removeAttribute("src"),URL.revokeObjectURL(r),i(d)},c=setTimeout(()=>{s(!1)},15e3);o.onerror=()=>{s(!1)},o instanceof HTMLVideoElement?(o.muted=!0,o.preload="auto",o.onloadeddata=()=>{s(o.videoWidth>0&&o.videoHeight>0)}):o.onload=()=>{s(o.naturalWidth>0)},o.src=r})}let gn=0;async function Ao(e,n,t){gn+=1;const r=`local-${Date.now().toString(36)}-${gn.toString(36)}`;return await ar(r,e.type===n.mime?e:new Blob([e],{type:n.mime})),{id:r,kind:n.kind,mime:n.mime,name:t.slice(0,200),bytes:e.size}}async function Co(e){for(const t of Array.from(P.keys()))e.has(t)||P.delete(t);const n=await ke("readonly",t=>t.getAllKeys()).catch(()=>{});for(const t of n??[])typeof t=="string"&&!e.has(t)&&await lr(t)}function Do(){P.clear(),G.clear(),Le=null}const jn={missing:!1,heavyVideo:!1,paused:null,surfaceAlpha:null,textAlpha:null};let ee=jn;const $e=new Set;function Io(){return ee}function Bo(e){return $e.add(e),()=>{$e.delete(e)}}function B(e){const n={...ee,...e};if(JSON.stringify(n)!==JSON.stringify(ee)){ee=n;for(const t of $e)t()}}const le=new Map;let He=!0;function dr(e){return le.get(e)}function Kn(e,n){if(!(le.has(n)||typeof document>"u"))try{const t=document.createElement("canvas");t.width=48,t.height=32;const r=t.getContext("2d",{willReadFrequently:!0});if(r===null)return;r.drawImage(e,0,0,t.width,t.height),le.set(n,Pt(r.getImageData(0,0,t.width,t.height).data))}catch{}}function Ee(e){return getComputedStyle(document.documentElement).getPropertyValue(e).trim()}function fr(){const e=["--color-ink","--color-ink-soft","--color-ink-faint"].map(Ee),n=Ee("--color-canvas");return["--color-canvas","--color-paper","--color-panel"].map(t=>({surface:Ee(t),ground:n,texts:e}))}let I=null,p={key:"",element:null,urls:[]},N=null,x,w=0,k=null,R=0;function zn(){if(I!==null&&I.root.isConnected)return I;const e=document.createElement("div");e.dataset.kikiBackdrop="",e.setAttribute("aria-hidden","true");const n=document.createElement("div");n.dataset.kikiBackdropMedia="";const t=document.createElement("div");return t.dataset.kikiBackdropScrim="",e.append(n,t),document.body.prepend(e),I={root:e,media:n,scrim:t},I}function Vn(){const e=document.documentElement.dataset.kikiMotion;return e==="reduce"?!1:e==="full"?!0:!window.matchMedia?.("(prefers-reduced-motion: reduce)").matches}let Jn=!1;function pr(){navigator.getBattery?.().then(n=>{const t=()=>{Jn=!n.charging&&n.level<.2,W()};n.addEventListener("levelchange",t),n.addEventListener("chargingchange",t),t()}).catch(()=>{})}function kr(){return Vn()?document.visibilityState==="hidden"||!document.hasFocus()?"hidden":Jn?"power":null:"motion"}function W(){const e=p.element instanceof HTMLVideoElement?p.element:null;if(e===null){B({paused:null});return}const n=kr();B({paused:n==="hidden"?null:n}),n===null?e.play().catch(()=>{}):e.pause()}function Gn(){for(const e of p.urls)URL.revokeObjectURL(e);p={key:"",element:null,urls:[]},N=null}async function Fn(e,n,t,r=!1){const o=e.kind==="image"&&!r?await Un(e.id,nr(),()=>n(e)):await n(e);if(o===null)return null;const i=URL.createObjectURL(o);return t.push(i),i}async function mr(e){if(le.has(e.id)||typeof createImageBitmap!="function")return;const n=await Un(e.id,tr,()=>H(e));if(n!==null)try{const t=await createImageBitmap(n,{resizeWidth:48,resizeHeight:32,resizeQuality:"low"});Kn(t,e.id),t.close()}catch{}}let H=e=>cr(e.id);function wo(e){e!==H&&(H=e,k!==null&&p.element===null&&(N=null,Ue(k,w,R)))}function _o(e){return H(e)}function bn(e,n,t){const{look:r}=n,o=[r.blur>0?`blur(${r.blur}px)`:"",r.brightness!==1?`brightness(${r.brightness})`:""].filter(Boolean).join(" ");if(e.style.opacity=String(r.opacity),e.style.filter=o,t!==null){e.style.backgroundImage=`url("${t}")`,e.style.backgroundRepeat="repeat",e.style.backgroundPosition=ln(r.alignment);return}e.style.objectFit=r.fit==="contain"?"contain":r.fit==="center"?"none":"cover",e.style.objectPosition=ln(r.alignment)}async function Ue(e,n,t){const{media:r}=zn(),o=e.media[n%e.media.length],i=`${e.packId??""}|${o.id}|${e.look.fit}`;if(p.key===i&&p.element!==null){bn(p.element,e,p.element instanceof HTMLDivElement?p.urls[0]??null:null),W();return}if(N?.key===i)return;const s={key:i};N=s;const c=[],d=()=>t!==R||N!==s,f=await Fn(o,H,c,e.look.fit==="tile");let h=null;if(f!==null&&o.kind==="video"&&e.poster!==void 0&&!d()&&(h=await Fn(e.poster,H,c)),d()){for(const a of c)URL.revokeObjectURL(a);return}N=null;const y=k??e;if(f===null){Gn(),r.replaceChildren(),B({missing:!0});return}let l;if(o.kind==="video"){const a=document.createElement("video");a.muted=!0,a.defaultMuted=!0,a.loop=!0,a.playsInline=!0,a.autoplay=!1,a.preload="auto",a.disablePictureInPicture=!0,a.setAttribute("muted",""),a.setAttribute("playsinline",""),h!==null&&(a.poster=h),a.addEventListener("loadeddata",()=>{p.element===a&&(Kn(a,o.id),B({heavyVideo:a.videoWidth*a.videoHeight>2560*1440}),k!==null&&xe(k))},{once:!0}),a.src=f,l=a}else{if(e.look.fit==="tile")l=document.createElement("div");else{const a=document.createElement("img");a.decoding="async",a.alt="",a.src=f,l=a}mr(o).then(()=>{k!==null&&p.key===i&&xe(k)})}l.addEventListener("error",()=>{p.element===l&&B({missing:!0,heavyVideo:!1})},{once:!0}),l.dataset.kikiBackdropItem=o.kind,bn(l,y,l instanceof HTMLDivElement?f:null),r.replaceChildren(l);for(const a of p.urls)URL.revokeObjectURL(a);p={key:i,element:l,urls:c},B({missing:!1,heavyVideo:!1}),W()}function xe(e){const n=document.documentElement,t=e.sample??dr(e.media[w%e.media.length].id),r=e.look.surfaceOpacity,o=He?Math.max(...fr().map(s=>Ot(s,e.look,t,r))):r,i=r>=1?0:Math.max(0,(o-r)/(1-r));n.style.setProperty("--kiki-surface-alpha",`${Math.round(r*100)}%`),n.style.setProperty("--kiki-text-alpha",`${Math.ceil(i*100)}%`),n.style.setProperty("--kiki-solid-alpha",`${Math.ceil(o*100)}%`),n.style.setProperty("--kiki-surface-blur",`${e.look.surfaceBlur}px`),n.style.setProperty("--kiki-backdrop-scrim",String(e.look.scrim)),n.style.setProperty("--kiki-backdrop-overscan",`${Math.ceil(e.look.blur*3)}px`),He?n.dataset.kikiBgAssist="":delete n.dataset.kikiBgAssist,B({surfaceAlpha:r,textAlpha:o})}function Wn(){R+=1,clearInterval(x),x=void 0,k=null,Gn(),I?.root.remove(),I=null;const e=document.documentElement;delete e.dataset.kikiBg,delete e.dataset.kikiBgAssist;for(const n of["--kiki-surface-alpha","--kiki-text-alpha","--kiki-solid-alpha","--kiki-surface-blur","--kiki-backdrop-scrim","--kiki-backdrop-overscan"])e.style.removeProperty(n);B(jn)}function Oo(e,n=!0){if(typeof document>"u")return;if(He=n,e===null){(k!==null||I!==null)&&Wn();return}const t=JSON.stringify(k?.media)!==JSON.stringify(e.media)||k?.packId!==e.packId;k=e,t&&(R+=1,w=0),document.documentElement.dataset.kikiBg=e.look.scope,zn().root.dataset.scope=e.look.scope,e.look.scope!=="window"&&(vn(),requestAnimationFrame(vn)),xe(e),Ue(e,w,R),clearInterval(x),x=void 0,e.media.length>1&&e.interval>0&&Vn()&&(x=setInterval(()=>{k===null||document.visibilityState==="hidden"||(w=(w+1)%k.media.length,Ue(k,w,R))},e.interval*1e3))}let j=null,D=null;function ue(){const e=D?.getBoundingClientRect().right??0;document.documentElement.style.setProperty("--kiki-backdrop-sidebar",`${Math.round(e)}px`)}function vn(){if(typeof ResizeObserver>"u")return;const e=document.querySelector(".app-sidebar");e!==D&&(j??=new ResizeObserver(ue),D!==null&&j.unobserve(D),D=e,D!==null&&j.observe(D),ue())}function hr(){return window.addEventListener("resize",ue),()=>{window.removeEventListener("resize",ue),j?.disconnect(),j=null,D=null,document.documentElement.style.removeProperty("--kiki-backdrop-sidebar")}}let ye=!1;function Po(){if(ye||typeof window>"u")return()=>{};ye=!0;const e=()=>{W()};document.addEventListener("visibilitychange",e),window.addEventListener("focus",e),window.addEventListener("blur",e);const n=window.matchMedia?.("(prefers-reduced-motion: reduce)");n?.addEventListener?.("change",e),pr();const t=hr();return()=>{ye=!1,t(),document.removeEventListener("visibilitychange",e),window.removeEventListener("focus",e),window.removeEventListener("blur",e),n?.removeEventListener?.("change",e),Wn()}}function Mo(){typeof document<"u"&&W()}const je="pack:";function gr(e,n){return`${je}${e}/${n}`}function No(e){if(!e.startsWith(je))return null;const n=e.slice(je.length),t=n.indexOf("/");return t<=0?null:{packId:n.slice(0,t),file:n.slice(t+1)}}function Sn(e,n){const t=An(n);return t===null?null:{id:gr(e,n),kind:t.kind,mime:t.mime,name:n,bytes:0}}function En(e,n){if(n===void 0)return null;const{media:t,poster:r,interval:o,shuffle:i,...s}=n,c=t.map(d=>Sn(e,d)).filter(d=>d!==null);return c.length===0?null:{media:c,poster:r===void 0?void 0:Sn(e,r)??void 0,interval:o??0,look:On(s),packId:e}}function To(e){const n=En(e.id,e.variants.light?.background),t=En(e.id,e.variants.dark?.background);return n===null||t===null?{light:n??t,dark:null,linked:!0}:{light:n,dark:t,linked:!1}}function Ro(e){const n=o=>{const i=e.variants[o];if(i===void 0)return;const{background:s,...c}=i;return c.colors===void 0&&c.fonts===void 0&&c.shape===void 0?void 0:c},t=n("light"),r=n("dark");return t===void 0&&r===void 0?null:{kind:"kiki-skin",version:1,id:e.id,name:e.name,description:e.description,author:e.author,variants:{light:t,dark:r}}}function Ae(e,n){const t={...e.colors};n.tweaks.accent!==void 0&&(t.accent=n.tweaks.accent);const r={...e.fonts};n.tweaks.fontSans!==void 0&&(r.sans=n.tweaks.fontSans),n.tweaks.fontMono!==void 0&&(r.mono=n.tweaks.fontMono);const o={...e.shape};return n.tweaks.radius!==void 0&&(o.radius=n.tweaks.radius),n.tweaks.spacing!==void 0&&(o.spacing=n.tweaks.spacing),{...e.base!==void 0?{base:e.base}:{},...Object.keys(t).length>0?{colors:t}:{},...Object.keys(r).length>0?{fonts:r}:{},...Object.keys(o).length>0?{shape:o}:{}}}function Lo(e,n){const t=Yt(e.selection)??Nn("paper")??null,r=Fr(n)||"my-skin",o={};for(const s of t===null?[]:Xt(t))o[s]=Ae(t?.variants[s]??{},e);Object.keys(o).length===0&&(o.light=Ae({},e),o.dark=Ae({},e));const i={$schema:"https://kiki.dev/schema/skin-v1.json",kind:"kiki-skin",version:1,id:r,name:n.trim()===""?"My skin":n.trim(),...t?.description!==void 0?{description:t.description}:{},variants:o};return{filename:`${r}.json`,json:`${JSON.stringify(i,null,2)}
2
2
  `}}function Fr(e){return e.trim().toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").slice(0,64).replace(/^[^a-z0-9]+/,"")}export{Ge as $,hn as A,Tt as B,Z as C,Q as D,no as E,Qt as F,to as G,yo as H,Eo as I,fo as J,It as K,ho as L,lr as M,eo as N,Nn as O,je as P,cr as Q,Nt as R,co as S,wt as T,lo as U,qt as V,mo as W,So as X,dr as Y,Je as Z,On as _,po as a,ne as a$,nn as a0,ln as a1,To as a2,gr as a3,Ro as a4,be as a5,No as a6,Co as a7,ar as a8,ko as a9,tr as aA,wn as aB,Hr as aC,Lr as aD,jr as aE,Rr as aF,$r as aG,Ur as aH,zr as aI,Vr as aJ,_n as aK,Tr as aL,St as aM,xr as aN,Be as aO,yr as aP,Kr as aQ,ct as aR,Ke as aS,Mr as aT,Pr as aU,Ir as aV,Nr as aW,Or as aX,st as aY,Sr as aZ,Cr as a_,Ht as aa,Gr as ab,Ot as ac,_e as ad,Qr as ae,Do as af,_o as ag,Pt as ah,wo as ai,uo as aj,io as ak,ao as al,oo as am,We as an,so as ao,Fr as ap,Wr as aq,yt as ar,jt as as,xt as at,Ao as au,Bo as av,go as aw,Ct as ax,Vt as ay,Un as az,vo as b,Dr as b0,F as b1,wr as b2,lt as b3,_r as b4,Ar as b5,Br as b6,Dn as b7,Er as b8,Xr as c,Oo as d,Jt as e,Mo as f,Xt as g,Fo as h,ro as i,Jr as j,dn as k,fn as l,J as m,Mn as n,O as o,Hn as p,Zt as q,Yt as r,Zr as s,Io as t,Yr as u,bo as v,Po as w,qr as x,pe as y,Lo as z};
@@ -1,4 +1,4 @@
1
- import{g as qe}from"./chunk-FMBD7UC4-BpeXZ9LM.js";import{_ as b,o as Oe,l as Q,c as g1,p as He,r as Xe,u as ie,b as Qe,s as Je,q as Ze,a as $e,g as et,t as tt,k as st,v as it,J as rt,x as at,y as te,d as se,z as nt,A as ut,B as ot,C as lt}from"./index-CM-nNfuV.js";import{c as ct}from"./chunk-ND2GUHAM-CRUh76fb.js";import{g as ht}from"./chunk-55IACEB6-C8f-nzvx.js";import{s as dt}from"./chunk-2J33WTMH-BL56g_Es.js";import{c as pt}from"./channel-Bj_gZ_Lv.js";import"./index-D8z7lcQn.js";var ft="flowchart-",gt=class{constructor(){this.vertexCounter=0,this.config=g1(),this.diagramId="",this.vertices=new Map,this.edges=[],this.classes=new Map,this.subGraphs=[],this.subGraphLookup=new Map,this.tooltips=new Map,this.subCount=0,this.firstGraphFlag=!0,this.secCount=-1,this.posCrossRef=[],this.funs=[],this.setAccTitle=Qe,this.setAccDescription=Je,this.setDiagramTitle=Ze,this.getAccTitle=$e,this.getAccDescription=et,this.getDiagramTitle=tt,this.funs.push(this.setupToolTips.bind(this)),this.addVertex=this.addVertex.bind(this),this.firstGraph=this.firstGraph.bind(this),this.setDirection=this.setDirection.bind(this),this.addSubGraph=this.addSubGraph.bind(this),this.addLink=this.addLink.bind(this),this.setLink=this.setLink.bind(this),this.updateLink=this.updateLink.bind(this),this.addClass=this.addClass.bind(this),this.setClass=this.setClass.bind(this),this.destructLink=this.destructLink.bind(this),this.setClickEvent=this.setClickEvent.bind(this),this.setTooltip=this.setTooltip.bind(this),this.updateLinkInterpolate=this.updateLinkInterpolate.bind(this),this.setClickFun=this.setClickFun.bind(this),this.bindFunctions=this.bindFunctions.bind(this),this.lex={firstGraph:this.firstGraph.bind(this)},this.clear(),this.setGen("gen-2")}static{b(this,"FlowDB")}sanitizeText(e){return st.sanitizeText(e,this.config)}sanitizeNodeLabelType(e){switch(e){case"markdown":case"string":case"text":return e;default:return"markdown"}}setDiagramId(e){this.diagramId=e}lookUpDomId(e){for(const i of this.vertices.values())if(i.id===e)return this.diagramId?`${this.diagramId}-${i.domId}`:i.domId;return this.diagramId?`${this.diagramId}-${e}`:e}addVertex(e,i,r,a,o,d,l={},f){if(!e||e.trim().length===0)return;let n;if(f!==void 0){let E;f.includes(`
1
+ import{g as qe}from"./chunk-FMBD7UC4-CVDMj2kX.js";import{_ as b,o as Oe,l as Q,c as g1,p as He,r as Xe,u as ie,b as Qe,s as Je,q as Ze,a as $e,g as et,t as tt,k as st,v as it,J as rt,x as at,y as te,d as se,z as nt,A as ut,B as ot,C as lt}from"./index-C6qeLCPw.js";import{c as ct}from"./chunk-ND2GUHAM-CL-PM6r8.js";import{g as ht}from"./chunk-55IACEB6-CrcLYJXd.js";import{s as dt}from"./chunk-2J33WTMH-CpjgczxM.js";import{c as pt}from"./channel-BJs5vJuh.js";import"./index-B0KPRi1U.js";var ft="flowchart-",gt=class{constructor(){this.vertexCounter=0,this.config=g1(),this.diagramId="",this.vertices=new Map,this.edges=[],this.classes=new Map,this.subGraphs=[],this.subGraphLookup=new Map,this.tooltips=new Map,this.subCount=0,this.firstGraphFlag=!0,this.secCount=-1,this.posCrossRef=[],this.funs=[],this.setAccTitle=Qe,this.setAccDescription=Je,this.setDiagramTitle=Ze,this.getAccTitle=$e,this.getAccDescription=et,this.getDiagramTitle=tt,this.funs.push(this.setupToolTips.bind(this)),this.addVertex=this.addVertex.bind(this),this.firstGraph=this.firstGraph.bind(this),this.setDirection=this.setDirection.bind(this),this.addSubGraph=this.addSubGraph.bind(this),this.addLink=this.addLink.bind(this),this.setLink=this.setLink.bind(this),this.updateLink=this.updateLink.bind(this),this.addClass=this.addClass.bind(this),this.setClass=this.setClass.bind(this),this.destructLink=this.destructLink.bind(this),this.setClickEvent=this.setClickEvent.bind(this),this.setTooltip=this.setTooltip.bind(this),this.updateLinkInterpolate=this.updateLinkInterpolate.bind(this),this.setClickFun=this.setClickFun.bind(this),this.bindFunctions=this.bindFunctions.bind(this),this.lex={firstGraph:this.firstGraph.bind(this)},this.clear(),this.setGen("gen-2")}static{b(this,"FlowDB")}sanitizeText(e){return st.sanitizeText(e,this.config)}sanitizeNodeLabelType(e){switch(e){case"markdown":case"string":case"text":return e;default:return"markdown"}}setDiagramId(e){this.diagramId=e}lookUpDomId(e){for(const i of this.vertices.values())if(i.id===e)return this.diagramId?`${this.diagramId}-${i.domId}`:i.domId;return this.diagramId?`${this.diagramId}-${e}`:e}addVertex(e,i,r,a,o,d,l={},f){if(!e||e.trim().length===0)return;let n;if(f!==void 0){let E;f.includes(`
2
2
  `)?E=f+`
3
3
  `:E=`{
4
4
  `+f+`