@krantho/studio 0.0.0-stage → 1.0.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 (132) hide show
  1. package/LICENSE +21 -0
  2. package/dist/assets/AssistantPanel-CzFfUizn.js +8 -0
  3. package/dist/assets/AssistantPanel-DB6gluI1.css +1 -0
  4. package/dist/assets/GraphBrowser-DvcHXw-i.js +2 -0
  5. package/dist/assets/GraphBrowser-U_-D112C.css +1 -0
  6. package/dist/assets/GraphCanvas-Bq75rYgC.js +1 -0
  7. package/dist/assets/GraphCanvas-C_Wsk21g.css +1 -0
  8. package/dist/assets/action-button-Co7fp7HS.js +1 -0
  9. package/dist/assets/api-client-BRi_ki2Y.js +1 -0
  10. package/dist/assets/api-seo-2H6_VoWE.js +1 -0
  11. package/dist/assets/arduino-CEYAtK6G.js +1 -0
  12. package/dist/assets/arrow-down-CsgZZR1B.js +1 -0
  13. package/dist/assets/arrow-left-DKjipJjb.js +1 -0
  14. package/dist/assets/auth-GRfs02w7.js +1 -0
  15. package/dist/assets/bash-4sOSYtlG.js +1 -0
  16. package/dist/assets/basic-2Y4JmWk4.js +1 -0
  17. package/dist/assets/bricolage-grotesque-latin-ext-wght-normal-CcLUaPy7.woff2 +0 -0
  18. package/dist/assets/bricolage-grotesque-latin-wght-normal-DLoelf7F.woff2 +0 -0
  19. package/dist/assets/bricolage-grotesque-vietnamese-wght-normal-BUzh504Q.woff2 +0 -0
  20. package/dist/assets/c-C8PoWFx3.js +1 -0
  21. package/dist/assets/catalog-offer-CeRRk2Zo.js +1 -0
  22. package/dist/assets/circle-check-big-zoQrH4Hp.js +1 -0
  23. package/dist/assets/circle-dashed-Cu2MEHnb.js +1 -0
  24. package/dist/assets/circle-x-DMb3ZtiK.js +1 -0
  25. package/dist/assets/clike-jjKDqbJf.js +1 -0
  26. package/dist/assets/clock-CzpAlvS3.js +1 -0
  27. package/dist/assets/collection-view-BlqX2SDN.js +5 -0
  28. package/dist/assets/collection-view-Dllo4l_w.css +1 -0
  29. package/dist/assets/copy-DloNx7rC.js +1 -0
  30. package/dist/assets/corner-down-right-D2cWjQTP.js +1 -0
  31. package/dist/assets/cpp-BNrDeSFM.js +1 -0
  32. package/dist/assets/createLucideIcon-DO6kYgVn.css +1 -0
  33. package/dist/assets/createLucideIcon-D_HN41p3.js +1 -0
  34. package/dist/assets/csharp-C2EQRp-I.js +1 -0
  35. package/dist/assets/css-BLUnUyF9.js +1 -0
  36. package/dist/assets/data-table-D8BsE1pn.js +1 -0
  37. package/dist/assets/data-table-Dm9uZXES.css +1 -0
  38. package/dist/assets/diff-CnVbg4kZ.js +3 -0
  39. package/dist/assets/editor-page-C8G81B5n.js +27 -0
  40. package/dist/assets/editor-page-D-qGDgmd.css +1 -0
  41. package/dist/assets/empty-state-Bvnil5AQ.css +1 -0
  42. package/dist/assets/empty-state-CU7q3Ypl.js +1 -0
  43. package/dist/assets/export-helpers-B2KV_EB5.js +1 -0
  44. package/dist/assets/external-link-BRKJTCZG.js +1 -0
  45. package/dist/assets/fill-job-D41ra-DR.js +1 -0
  46. package/dist/assets/fill-run-view-BhqhXo7I.css +1 -0
  47. package/dist/assets/fill-run-view-DFeyjdsI.js +1 -0
  48. package/dist/assets/findability-CUYOthYI.js +1 -0
  49. package/dist/assets/format-pPdsDgeS.js +1 -0
  50. package/dist/assets/go-BTdFQSkQ.js +1 -0
  51. package/dist/assets/graph-config-ZUe9BjGK.js +1 -0
  52. package/dist/assets/graph-config-mZyX0Lqo.css +1 -0
  53. package/dist/assets/guards-BFEDbduR.js +1 -0
  54. package/dist/assets/image-editor-BTlqjPtS.css +1 -0
  55. package/dist/assets/image-editor-Bmjrioxz.js +1 -0
  56. package/dist/assets/index-Buq8auz3.css +1 -0
  57. package/dist/assets/index-DVe5jFLX.js +2 -0
  58. package/dist/assets/info-B69U-gXd.js +1 -0
  59. package/dist/assets/ini-_H0-Wnh8.js +1 -0
  60. package/dist/assets/java-OEPW09uX.js +1 -0
  61. package/dist/assets/javascript-DWFokqmn.js +1 -0
  62. package/dist/assets/jetbrains-mono-cyrillic-wght-normal-D73BlboJ.woff2 +0 -0
  63. package/dist/assets/jetbrains-mono-greek-wght-normal-Bw9x6K1M.woff2 +0 -0
  64. package/dist/assets/jetbrains-mono-latin-ext-wght-normal-DBQx-q_a.woff2 +0 -0
  65. package/dist/assets/jetbrains-mono-latin-wght-normal-B9CIFXIH.woff2 +0 -0
  66. package/dist/assets/jetbrains-mono-vietnamese-wght-normal-Bt-aOZkq.woff2 +0 -0
  67. package/dist/assets/json-B02E3pk2.js +1 -0
  68. package/dist/assets/kotlin-lSpEPTBz.js +1 -0
  69. package/dist/assets/layers-BQ89qo5R.js +1 -0
  70. package/dist/assets/less-DZtXz-rP.js +1 -0
  71. package/dist/assets/list-checks-DmMdd-uP.js +1 -0
  72. package/dist/assets/live-markdown-editor-CTvxOTrh.js +53 -0
  73. package/dist/assets/lua-Dl7axvik.js +1 -0
  74. package/dist/assets/makefile-C7Vj606s.js +1 -0
  75. package/dist/assets/markdown-D0Y7CUbI.js +1 -0
  76. package/dist/assets/markup-Bfi2BWVm.js +1 -0
  77. package/dist/assets/markup-templating-BkH2dBCn.js +1 -0
  78. package/dist/assets/media-model-D4F1Farw.js +1 -0
  79. package/dist/assets/media-page-DBdAvFvu.css +1 -0
  80. package/dist/assets/media-page-DYRRse48.js +1 -0
  81. package/dist/assets/meter-WebPk4WX.css +1 -0
  82. package/dist/assets/meter-mJxPk3I3.js +1 -0
  83. package/dist/assets/objectivec-Cv_qlwGW.js +1 -0
  84. package/dist/assets/pen-line-CZkcVGBd.js +1 -0
  85. package/dist/assets/pencil-BHnNXVY1.js +1 -0
  86. package/dist/assets/perl-Ci2iz3Xf.js +1 -0
  87. package/dist/assets/php-MrfIyKXK.js +1 -0
  88. package/dist/assets/pulse-page-B44AnguJ.js +1 -0
  89. package/dist/assets/pulse-page-HgFM-MfC.css +1 -0
  90. package/dist/assets/python-PcNiIBxw.js +1 -0
  91. package/dist/assets/r-CjN4PMnd.js +1 -0
  92. package/dist/assets/regex-Dv2vm_uO.js +1 -0
  93. package/dist/assets/rolldown-runtime-Dd_uD5pT.js +1 -0
  94. package/dist/assets/rotate-ccw-CjpQmti_.js +1 -0
  95. package/dist/assets/ruby-DGkU311C.js +1 -0
  96. package/dist/assets/rust-CYWeblTv.js +1 -0
  97. package/dist/assets/sass-RhMvkm29.js +1 -0
  98. package/dist/assets/save-kXwhieDK.js +1 -0
  99. package/dist/assets/scss-BSDGjs1D.js +1 -0
  100. package/dist/assets/send-ib_sr-OU.js +1 -0
  101. package/dist/assets/setup-page-Bc799yav.css +1 -0
  102. package/dist/assets/setup-page-x51U8px6.js +1 -0
  103. package/dist/assets/site-XpqFn80l.js +1 -0
  104. package/dist/assets/site-lUERQFzn.css +1 -0
  105. package/dist/assets/site-model-DX8WxTJg.js +1 -0
  106. package/dist/assets/site-overview--k6hNYk0.js +1 -0
  107. package/dist/assets/source-CGZGd3Xy.js +1 -0
  108. package/dist/assets/sql-DL4klaVE.js +1 -0
  109. package/dist/assets/structure-page-BW1y8L1n.js +2 -0
  110. package/dist/assets/structure-page-DVSxQzgj.css +1 -0
  111. package/dist/assets/swift-7bJ1Hzvg.js +1 -0
  112. package/dist/assets/trash-Cknp3eZ5.js +1 -0
  113. package/dist/assets/triangle-alert-C4yqbtOC.js +1 -0
  114. package/dist/assets/typescript-Brau3Puh.js +1 -0
  115. package/dist/assets/upload-BvBYjswd.js +1 -0
  116. package/dist/assets/use-drawer-actions-DChrztN2.js +1 -0
  117. package/dist/assets/use-drawer-actions-DeFJMhBn.css +1 -0
  118. package/dist/assets/use-loaded-C3hBdQe0.js +1 -0
  119. package/dist/assets/use-locale-versions-Bp4V9fN-.js +1 -0
  120. package/dist/assets/vbnet-BCRrhSDY.js +1 -0
  121. package/dist/assets/vendor-diff-Dm2YfgXt.js +138 -0
  122. package/dist/assets/vendor-markdown-DlwjVoJi.js +66 -0
  123. package/dist/assets/vendor-media-DJOnVxEf.css +1 -0
  124. package/dist/assets/vendor-media-yY6fAUvp.js +1 -0
  125. package/dist/assets/vendor-react-DLioOiRN.css +1 -0
  126. package/dist/assets/vendor-react-DMqGe90A.js +15 -0
  127. package/dist/assets/vendor-reactflow-5Qvgw90M.js +1 -0
  128. package/dist/assets/vendor-router-DjV3D6zM.js +1 -0
  129. package/dist/assets/yaml-n53w1Kfi.js +1 -0
  130. package/dist/index.html +36 -0
  131. package/package.json +63 -3
  132. package/README.md +0 -3
@@ -0,0 +1,27 @@
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/vendor-diff-Dm2YfgXt.js","assets/rolldown-runtime-Dd_uD5pT.js","assets/GraphBrowser-DvcHXw-i.js","assets/createLucideIcon-D_HN41p3.js","assets/createLucideIcon-DO6kYgVn.css","assets/graph-config-ZUe9BjGK.js","assets/use-loaded-C3hBdQe0.js","assets/index-DVe5jFLX.js","assets/vendor-react-DMqGe90A.js","assets/vendor-react-DLioOiRN.css","assets/vendor-router-DjV3D6zM.js","assets/auth-GRfs02w7.js","assets/format-pPdsDgeS.js","assets/api-client-BRi_ki2Y.js","assets/index-Buq8auz3.css","assets/copy-DloNx7rC.js","assets/corner-down-right-D2cWjQTP.js","assets/findability-CUYOthYI.js","assets/layers-BQ89qo5R.js","assets/guards-BFEDbduR.js","assets/graph-config-mZyX0Lqo.css","assets/circle-check-big-zoQrH4Hp.js","assets/circle-x-DMb3ZtiK.js","assets/export-helpers-B2KV_EB5.js","assets/external-link-BRKJTCZG.js","assets/save-kXwhieDK.js","assets/trash-Cknp3eZ5.js","assets/triangle-alert-C4yqbtOC.js","assets/upload-BvBYjswd.js","assets/catalog-offer-CeRRk2Zo.js","assets/GraphBrowser-U_-D112C.css","assets/live-markdown-editor-CTvxOTrh.js","assets/arrow-down-CsgZZR1B.js","assets/arrow-left-DKjipJjb.js","assets/use-drawer-actions-DChrztN2.js","assets/media-model-D4F1Farw.js","assets/action-button-Co7fp7HS.js","assets/use-drawer-actions-DeFJMhBn.css"])))=>i.map(i=>d[i]);
2
+ import{i as e}from"./rolldown-runtime-Dd_uD5pT.js";import{a as t,o as n,s as r}from"./vendor-diff-Dm2YfgXt.js";import{m as i}from"./vendor-react-DMqGe90A.js";import{f as a,r as o,s,t as c,u as l}from"./vendor-router-DjV3D6zM.js";import{i as u}from"./auth-GRfs02w7.js";import{a as d,d as f,i as p,o as m,r as h,t as g,u as _}from"./format-pPdsDgeS.js";import{i as v,n as y,r as b,t as x}from"./createLucideIcon-D_HN41p3.js";import{t as ee}from"./arrow-left-DKjipJjb.js";import{D as te,a as ne,d as re,i as ie,l as ae,n as oe,o as se,r as ce,t as le,u as ue,x as de}from"./graph-config-ZUe9BjGK.js";import{n as fe,t as pe}from"./use-loaded-C3hBdQe0.js";import{a as me,c as he,d as ge,f as _e,i as ve,l as ye,p as be,s as xe,u as Se}from"./use-drawer-actions-DChrztN2.js";import{t as Ce}from"./circle-x-DMb3ZtiK.js";import{t as we}from"./clock-CzpAlvS3.js";import{t as Te}from"./external-link-BRKJTCZG.js";import{t as Ee}from"./findability-CUYOthYI.js";import{t as De}from"./info-B69U-gXd.js";import{t as Oe}from"./pen-line-CZkcVGBd.js";import{t as ke}from"./rotate-ccw-CjpQmti_.js";import{d as Ae,f as je,l as Me,o as Ne,s as Pe,t as Fe,u as Ie,y as Le}from"./api-seo-2H6_VoWE.js";import{c as Re,l as ze,s as Be,u as Ve}from"./fill-job-D41ra-DR.js";import{t as He}from"./triangle-alert-C4yqbtOC.js";import{i as Ue,r as We,t as Ge}from"./api-client-BRi_ki2Y.js";import{E as Ke,k as qe,r as Je,y as Ye}from"./media-model-D4F1Farw.js";import{$ as Xe,B as Ze,C as Qe,D as $e,Et as et,F as tt,G as nt,H as S,M as rt,Q as it,S as at,Tt as ot,U as st,V as ct,Y as lt,Z as ut,_t as dt,at as ft,c as C,ct as pt,d as w,et as T,f as E,ft as D,g as mt,gt as ht,j as gt,lt as _t,m as vt,mt as yt,n as bt,o as xt,ot as St,p as Ct,pt as wt,r as O,s as k,st as Tt,t as Et,tt as Dt,u as Ot,vt as kt,x as At,xt as jt}from"./index-DVe5jFLX.js";import{n as Mt,r as Nt}from"./vendor-markdown-DlwjVoJi.js";import{t as Pt}from"./empty-state-CU7q3Ypl.js";import{a as Ft,f as It}from"./site-model-DX8WxTJg.js";import{t as A}from"./action-button-Co7fp7HS.js";import{i as Lt,t as Rt}from"./meter-mJxPk3I3.js";import{n as zt}from"./use-locale-versions-Bp4V9fN-.js";var Bt={name:`chevron-up`,size:24,node:[[`path`,{d:`m18 15-6-6-6 6`,key:`153udz`}]]};Bt.node;var Vt=x(Bt),Ht={name:`eye`,size:24,node:[[`path`,{d:`M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0`,key:`1nclc0`}],[`circle`,{cx:`12`,cy:`12`,r:`3`,key:`1v7zrd`}]]};Ht.node;var Ut=x(Ht),Wt={name:`file-question-mark`,size:24,node:[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M12 17h.01`,key:`p32p05`}],[`path`,{d:`M9.1 9a3 3 0 0 1 5.82 1c0 2-3 3-3 3`,key:`mhlwft`}]],aliases:[`file-question`]};Wt.node;var Gt=x(Wt),Kt={name:`lock-open`,size:24,node:[[`rect`,{width:`18`,height:`11`,x:`3`,y:`11`,rx:`2`,ry:`2`,key:`1w4ew1`}],[`path`,{d:`M7 11V7a5 5 0 0 1 9.9-1`,key:`1mm8w8`}]],aliases:[`unlock`]};Kt.node;var qt=x(Kt),Jt={name:`monitor-x`,size:24,node:[[`path`,{d:`m14.5 12.5-5-5`,key:`1jahn5`}],[`path`,{d:`m9.5 12.5 5-5`,key:`1k2t7b`}],[`rect`,{width:`20`,height:`14`,x:`2`,y:`3`,rx:`2`,key:`48i651`}],[`path`,{d:`M12 17v4`,key:`1riwvh`}],[`path`,{d:`M8 21h8`,key:`1ev6f3`}]]};Jt.node;var Yt=x(Jt),Xt={name:`panel-right-close`,size:24,node:[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M15 3v18`,key:`14nvp0`}],[`path`,{d:`m8 9 3 3-3 3`,key:`12hl5m`}]]};Xt.node;var Zt=x(Xt),Qt={name:`panel-right-open`,size:24,node:[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M15 3v18`,key:`14nvp0`}],[`path`,{d:`m10 15-3-3 3-3`,key:`1pgupc`}]]};Qt.node;var $t=x(Qt),en={name:`scan-search`,size:24,node:[[`path`,{d:`M3 7V5a2 2 0 0 1 2-2h2`,key:`aa7l1z`}],[`path`,{d:`M17 3h2a2 2 0 0 1 2 2v2`,key:`4qcy5o`}],[`path`,{d:`M21 17v2a2 2 0 0 1-2 2h-2`,key:`6vwrx8`}],[`path`,{d:`M7 21H5a2 2 0 0 1-2-2v-2`,key:`ioqczr`}],[`circle`,{cx:`12`,cy:`12`,r:`3`,key:`1v7zrd`}],[`path`,{d:`m16 16-1.9-1.9`,key:`1dq9hf`}]]};en.node;var tn=x(en);async function nn(e,t,n){return Ue(`/content/${e}/${t}/versions${We(n)}`)}async function rn(e,t,n,r){let i=await Ue(`/content/${e}/${t}/versions/${n}${We(r)}`);return{version:i.meta.version,metadata:i.metadata,contract:i.contract,defaults:i.defaults,repositoryBasis:i.repositoryBasis,fields:i.fields,body:i.body,changedBy:i.meta.changedBy,createdAt:i.meta.createdAt}}async function an(e,t,n,r){return Ue(`/content/${e}/${t}/restore/${n}${We(r)}`,{method:`POST`})}var j=e(r(),1),M=t();function N({title:e,lead:t,aside:n,children:r}){let i=(0,j.useId)();return(0,M.jsxs)(`section`,{className:`data-card`,"aria-labelledby":i,children:[(0,M.jsxs)(`div`,{className:`data-card-head`,children:[(0,M.jsx)(`h2`,{id:i,className:`data-card-title`,children:e}),n&&(0,M.jsx)(`div`,{className:`data-card-aside`,children:n})]}),t&&(0,M.jsx)(`p`,{className:`data-card-lead`,children:t}),r]})}function P({children:e,tone:t}){return(0,M.jsx)(`p`,{className:t===`error`?`data-note data-note--error`:`data-note`,children:e})}function on({children:e}){return(0,M.jsx)(`p`,{role:`alert`,className:`data-note data-note--error`,children:e})}function sn(e,t){return{live:e===t.liveVersion,current:e===t.version}}function cn(e,t){return{version:(e[0]?.version??0)+1,metadata:t.metadata,contract:null,defaults:[],repositoryBasis:null,fields:t.fields,body:t.body,changedBy:null,createdAt:new Date().toISOString()}}function ln(e,t){let n=`v${e} is saved again as the newest version; the versions in between stay, and the live page is unchanged until you publish.`;return t?`${n} Your unsaved changes in the form will be lost.`:n}function un(e,t){return`v${e} could not be restored: ${t}`}function dn(e,t){return`v${e} was restored as v${t}, but the page could not be refreshed. Reload it to see the restored version.`}function fn(e){let t=(0,j.useRef)(null);return(0,M.jsx)(w,{title:`Restore v${e.version}?`,onClose:e.onClose,initialFocus:t,actions:(0,M.jsxs)(M.Fragment,{children:[(0,M.jsx)(y,{ref:t,onClick:e.onClose,children:`Cancel`}),(0,M.jsx)(y,{variant:`danger`,onClick:e.onConfirm,children:`Restore`})]}),children:(0,M.jsx)(`p`,{children:ln(e.version,e.unsaved)})})}function pn({n:e,actions:t,restoring:n}){return(0,M.jsxs)(`span`,{className:`data-version-actions`,children:[t.diff&&(0,M.jsx)(y,{size:`sm`,variant:`ghost`,"aria-label":`Diff v${e} with the version before`,onClick:t.diff,children:`Diff`}),t.compare&&(0,M.jsx)(y,{size:`sm`,variant:`ghost`,"aria-label":`Compare v${e} with your form`,onClick:t.compare,children:`Compare`}),t.restore&&(0,M.jsx)(y,{size:`sm`,"aria-label":`Restore v${e}`,"aria-disabled":n,title:n?`A restore is under way.`:void 0,onClick:n?void 0:t.restore,children:`Restore`})]})}function mn({version:e,props:t,actions:n,restoring:r}){let i=sn(e.version,t.saved);return(0,M.jsxs)(`li`,{className:`data-version`,children:[(0,M.jsxs)(`span`,{className:`data-version-number`,children:[`v`,e.version]}),(0,M.jsxs)(`span`,{className:`data-version-meta`,children:[(0,M.jsx)(`time`,{dateTime:e.createdAt,children:h(e.createdAt)}),(0,M.jsx)(`span`,{children:e.changedBy?O(e.changedBy):`Unknown author`})]}),(0,M.jsxs)(`span`,{className:`data-version-chips`,children:[i.live&&(0,M.jsx)(k,{tone:`success`,children:`live`}),i.current&&(0,M.jsx)(k,{tone:`accent`,children:`current`})]}),(0,M.jsx)(pn,{n:e.version,actions:n,restoring:r})]})}var hn=(0,j.lazy)(()=>n(()=>import(`./vendor-diff-Dm2YfgXt.js`).then(e=>e.t),__vite__mapDeps([0,1])));function gn(){let e=document.documentElement.getAttribute(`data-theme`);return e===`dark`?!0:e===`light`?!1:window.matchMedia?.(`(prefers-color-scheme: dark)`).matches??!1}function _n(){let[e,t]=(0,j.useState)(gn);return(0,j.useEffect)(()=>{let e=()=>t(gn()),n=new MutationObserver(e);n.observe(document.documentElement,{attributes:!0,attributeFilter:[`data-theme`]});let r=window.matchMedia?.(`(prefers-color-scheme: dark)`);return r?.addEventListener(`change`,e),()=>{n.disconnect(),r?.removeEventListener(`change`,e)}},[]),e}function vn(e,t){return t?`Your form`:`v${e.version}`}function yn({pressed:e,onPress:t,children:n}){return(0,M.jsx)(y,{size:`sm`,variant:e?`secondary`:`ghost`,"aria-pressed":e,onClick:t,children:n})}function bn({view:e,onView:t,onClose:n}){return(0,M.jsxs)(`div`,{className:`data-diff-controls`,children:[(0,M.jsx)(yn,{pressed:e.part===`fields`,onPress:()=>t({...e,part:`fields`}),children:`Fields`}),(0,M.jsx)(yn,{pressed:e.part===`metadata`,onPress:()=>t({...e,part:`metadata`}),children:`Details`}),(0,M.jsx)(yn,{pressed:e.part===`body`,onPress:()=>t({...e,part:`body`}),children:`Body`}),(0,M.jsx)(yn,{pressed:e.split,onPress:()=>t({...e,split:!e.split}),children:`Split`}),(0,M.jsx)(b,{icon:Dt,label:`Close the diff`,size:`sm`,onClick:n})]})}function xn({comparison:e,onClose:t}){let[n,r]=(0,j.useState)({part:`fields`,split:!1}),i=_n(),a=(0,j.useId)(),o=(0,j.useRef)(null),{base:s,compare:c,form:l}=e;(0,j.useEffect)(()=>o.current?.focus(),[e]);let u=e=>n.part===`body`?e.body:JSON.stringify(n.part===`fields`?e.fields:e.metadata,null,2);return(0,M.jsxs)(`section`,{className:`data-diff`,"aria-labelledby":a,children:[(0,M.jsxs)(`div`,{className:`data-diff-head`,children:[(0,M.jsxs)(`h3`,{id:a,ref:o,tabIndex:-1,className:`data-diff-title`,children:[`v`,s.version,` → `,vn(c,l)]}),(0,M.jsx)(bn,{view:n,onView:r,onClose:t})]}),(0,M.jsx)(j.Suspense,{fallback:(0,M.jsx)(P,{children:`Loading the diff…`}),children:(0,M.jsx)(`div`,{className:`data-diff-body`,children:(0,M.jsx)(hn,{oldValue:u(s),newValue:u(c),splitView:n.split,useDarkTheme:i,leftTitle:`v${s.version}`,rightTitle:vn(c,l)})})})]})}function Sn(e){let t=e.seo;return!t||!Array.isArray(t.entities)?null:t}function Cn(e){let t=Sn(e)?.entities[0]?.properties??{},n=e.sharing??{},r=e.editorial??{},i=e.publication??{};return{...t,...n.title===void 0?{}:{headline:n.title},...n.description===void 0?{}:{description:n.description},...n.image===void 0?{}:{image:n.image},...n.canonicalUrl===void 0?{}:{url:n.canonicalUrl},...r.byline===void 0?{}:{author:r.byline},...i.date===void 0?{}:{datePublished:i.date}}}var F={title:[`title`,`name`],description:[`meta-description`,`description`,`ingress`,`excerpt`],author:[`author`],datePublished:[`published-date`,`date`],image:[`og-image`,`image`,`hero-image`],canonicalUrl:[`canonical-url`],robotsIndex:[`robots-index`],robotsFollow:[`robots-follow`],ogTitle:[`og-title`],ogDescription:[`og-description`],ogImage:[`og-image`,`image`],ogType:[`og-type`]};function I(e){let t=new Set(e);function n(e){return e.find(e=>t.has(e))??null}return{title:n(F.title),description:n(F.description),author:n(F.author),datePublished:n(F.datePublished),image:n(F.image),canonicalUrl:n(F.canonicalUrl),robotsIndex:n(F.robotsIndex),robotsFollow:n(F.robotsFollow),ogTitle:n(F.ogTitle),ogDescription:n(F.ogDescription),ogImage:n(F.ogImage),ogType:n(F.ogType)}}function L(e,t,n){let r=e[t];if(!r)return``;let i=n[r];return typeof i==`string`&&i.length>0?i:``}var wn=new Set([`status`]);function Tn(e){return e.description?.match(/^ref:(\w+)/)?.[1]??null}function En(e,t){return e.format===`date`||e.format===`date-time`?`date`:t.includes(`color`)||t.includes(`colour`)?`color`:e.maxLength!==void 0&&e.maxLength>200||t.includes(`description`)||t.includes(`ingress`)||t.includes(`intro`)?`textarea`:`text`}function R(e,t){return e.description===`media`?`media`:Tn(e)?`reference`:e.enum?`enum`:e.type===`boolean`?`boolean`:e.type===`number`||e.type===`integer`?`number`:e.type===`array`&&e.items?.type===`string`?`tags`:e.type===`string`?En(e,t):`text`}function Dn(e,t){return e.type===`string`?e.format===`uri`||e.format===`url`?`url`:e.format===`email`?`email`:e.format===`date`?`date`:e.format===`date-time`?`datetime-local`:t.includes(`url`)||t.includes(`link`)||t.includes(`href`)?`url`:t.includes(`email`)||t.includes(`e-mail`)?`email`:`text`:`text`}function On(e,t){return e.format===`date-time`?`date and time`:e.format===`date`?`date`:e.format===`uri`||e.format===`url`?`web address`:e.format===`email`?`email`:t.endsWith(`-slug`)||t===`slug`?`URL name`:`text`}var kn={media:`image or file`,reference:`link to a page`,enum:`choice`,color:`color`};function An(e,t){return kn[R(e,t)]||(e.type===`array`?e.items?.type===`string`?`list of text`:`list`:e.type===`string`?On(e,t):e.type===`integer`?`number`:e.type===`boolean`?`yes/no`:e.type===`object`?`group`:e.type??`text`)}function jn(e){return e.description===`media`||Tn(e)!==null?null:e.description?.trim()||null}var Mn={title:`title`,description:`meta description`,author:`author`,datePublished:`date published`,image:`image`,canonicalUrl:`canonical address`,robotsIndex:`search indexing`,robotsFollow:`link following`,ogTitle:`sharing title`,ogDescription:`sharing description`,ogImage:`sharing image`,ogType:`sharing type`},Nn=Object.keys(F);function Pn(e,t,n){let r=e.get(t)??[];r.includes(n)||r.push(n),e.set(t,r)}function Fn(e){let t=new Set(e),n=I(e),r=new Map,i=new Map;for(let e of Nn)for(let a of F[e])t.has(a)&&Pn(n[e]===a?r:i,a,Mn[e]);let a=new Map;for(let t of e){let e=r.get(t),n=i.get(t)?.filter(t=>!e?.includes(t)),o=[...e??[],...n?.length?[`backup for ${n.join(`, `)}`]:[]];o.length>0&&a.set(t,o.join(` · `))}return a}var In=i(),Ln=20;function Rn(e){let[t,n]=(0,j.useState)({state:`loading`});return(0,j.useEffect)(()=>{let t=!0;return n({state:`loading`}),Ke({limit:Ln,offset:e*Ln}).then(e=>t&&n({state:`ready`,...e})).catch(e=>t&&n({state:`failed`,message:E(e,`Media could not be read`)})),()=>{t=!1}},[e]),t}function zn({library:e,onSelect:t}){return e.state===`loading`?(0,M.jsx)(`p`,{role:`status`,children:`Loading media…`}):e.state===`failed`?(0,M.jsx)(`p`,{role:`alert`,children:e.message}):e.items.length===0?(0,M.jsx)(`p`,{children:`No media yet. Upload an image above.`}):(0,M.jsx)(`ul`,{className:`media-picker-grid`,"aria-label":`Library`,children:e.items.map(e=>(0,M.jsx)(`li`,{children:(0,M.jsxs)(`button`,{type:`button`,className:`media-picker-file`,onClick:()=>t(e),children:[(0,M.jsx)(`img`,{src:Ye(e,`sm`),alt:``}),(0,M.jsx)(`span`,{className:`media-picker-name`,children:e.filename})]})},e.id))})}function Bn({onSelect:e,onUpload:t,onClose:n}){let[r,i]=(0,j.useState)(0),a=Rn(r),{hasRole:o}=u(),s=a.state===`ready`?Math.ceil(a.total/Ln):0;return(0,M.jsxs)(M.Fragment,{children:[(0,M.jsx)(he,{multiple:!1,blocked:o(`editor`)?null:Je,onUploaded:([e])=>e&&t(e)}),(0,M.jsx)(zn,{library:a,onSelect:e}),(0,M.jsx)(xe,{page:r,count:s,onPage:i}),(0,M.jsx)(`div`,{className:`media-picker-actions`,children:(0,M.jsx)(y,{onClick:n,children:`Cancel`})})]})}function Vn(e){let t=(0,j.useRef)(null),n=(0,j.useId)();Xe(t,!0);function r(t){t.key===`Escape`&&(t.stopPropagation(),e.onClose())}return(0,In.createPortal)((0,M.jsxs)(`div`,{className:`media-picker-layer`,children:[(0,M.jsx)(`div`,{className:`media-picker-scrim`,"aria-hidden":`true`,onClick:e.onClose}),(0,M.jsxs)(`div`,{ref:t,className:`media-picker`,role:`dialog`,"aria-modal":`true`,"aria-labelledby":n,tabIndex:-1,onKeyDown:r,children:[(0,M.jsx)(`h2`,{id:n,className:`media-picker-title`,children:`Choose an image`}),(0,M.jsx)(Bn,{...e})]})]}),document.body)}function Hn(e){let[t,n]=(0,j.useState)({state:e?`loading`:`none`});return(0,j.useEffect)(()=>{if(!e){n({state:`none`});return}let t=!0;return n(t=>t.state===`ready`&&t.item.id===e?t:{state:`loading`}),qe(e).then(e=>t&&n({state:`ready`,item:e})).catch(()=>t&&n({state:`missing`,id:e})),()=>{t=!1}},[e]),[t,e=>n({state:`ready`,item:e})]}function Un({item:e}){let t=e.altText.trim()!==``;return(0,M.jsxs)(M.Fragment,{children:[(0,M.jsx)(`img`,{className:`editor-media-thumb`,src:Ye(e,`sm`),alt:``}),(0,M.jsxs)(`div`,{className:`editor-media-text`,children:[(0,M.jsx)(`span`,{className:`editor-media-name`,children:e.filename}),(0,M.jsxs)(`span`,{className:`editor-media-meta`,children:[e.width!==null&&e.height!==null&&`${e.width} × ${e.height} · `,p(e.size)]}),(0,M.jsxs)(`span`,{className:t?`editor-media-alt`:`editor-media-alt editor-media-alt--missing`,children:[t?(0,M.jsx)(D,{"aria-hidden":`true`}):(0,M.jsx)(wt,{"aria-hidden":`true`}),t?`Alt text set`:`No alt text`]})]})]})}function Wn({selected:e}){if(e.state===`ready`)return(0,M.jsx)(Un,{item:e.item});let t=e.state===`loading`?`Loading…`:e.state===`missing`?`Media ${e.id} was not found`:`No image chosen`;return(0,M.jsxs)(M.Fragment,{children:[(0,M.jsx)(`span`,{className:`editor-media-thumb editor-media-thumb--empty`,"aria-hidden":`true`,children:(0,M.jsx)(Se,{})}),(0,M.jsx)(`span`,{className:`editor-media-text editor-media-meta`,children:t})]})}function Gn({id:e,current:t,describedBy:n,changeRef:r,onPick:i,onClear:a}){return(0,M.jsxs)(`div`,{className:`editor-media-actions`,children:[(0,M.jsx)(y,{id:e,ref:r,size:`sm`,"aria-describedby":n,onClick:i,children:t?`Change`:`Choose image`}),t&&(0,M.jsx)(y,{size:`sm`,variant:`ghost`,onClick:()=>{a(),r.current?.focus()},children:`Clear`})]})}function Kn(e,t){let n=[e?`Required`:null,t?`not valid`:null].filter(Boolean);return n.length>0?n.join(`, `):null}function qn(e){let{id:t,labelId:n,name:r,value:i,onChange:a}=e,o=typeof i==`string`?i:``,[s,c]=Hn(o),[l,u]=(0,j.useState)(!1),d=(0,j.useRef)(null),f=Kn(e.required,e.invalid),p=[f?`${t}-state`:null,e.describedBy].filter(Boolean).join(` `)||void 0;function m(e){c(e),a(r,e.id),u(!1)}return(0,M.jsxs)(`fieldset`,{className:`editor-media`,"aria-labelledby":n,"aria-describedby":p,children:[f&&(0,M.jsx)(`span`,{id:`${t}-state`,className:`visually-hidden`,children:f}),(0,M.jsx)(Wn,{selected:s}),(0,M.jsx)(Gn,{id:t,current:o,describedBy:p,changeRef:d,onPick:()=>u(!0),onClear:()=>a(r,``)}),l&&(0,M.jsx)(Vn,{onSelect:m,onUpload:m,onClose:()=>u(!1)})]})}function Jn(e){let[t,n]=(0,j.useState)(null);return(0,j.useEffect)(()=>{let t=!0;return Ze(e).then(({items:e})=>{t&&n(e.map(({meta:e,fields:t})=>({slug:e.slug,label:typeof t.title==`string`?t.title:e.slug})))}).catch(()=>{t&&n([])}),()=>{t=!1}},[e]),t}function Yn(e){let{id:t,name:n,property:r,value:i,describedBy:a,invalid:o,required:s,onChange:c}=e,l=Tn(r)??``,u=Jn(l),d=typeof i==`string`?i:``,f=d!==``&&u!==null&&!u.some(e=>e.slug===d);return(0,M.jsxs)(`select`,{id:t,name:n,className:`editor-control editor-control--short`,value:d,"aria-describedby":a,"aria-invalid":o||void 0,"aria-required":s||void 0,"aria-busy":u===null||void 0,onChange:e=>c(n,e.target.value),children:[(0,M.jsx)(`option`,{value:``,children:u===null?`Loading…`:`Choose from ${l}…`}),f&&(0,M.jsx)(`option`,{value:d,children:d}),u?.map(e=>(0,M.jsx)(`option`,{value:e.slug,children:e.label},e.slug))]})}function Xn(e){return Array.isArray(e)?e.filter(e=>typeof e==`string`):[]}function Zn({tags:e,onRemove:t}){return e.length===0?null:(0,M.jsx)(`ul`,{className:`editor-tags-list`,children:e.map((e,n)=>(0,M.jsxs)(`li`,{className:`editor-tag`,children:[e,(0,M.jsx)(`button`,{type:`button`,className:`editor-tag-remove`,"aria-label":`Remove ${e}`,onClick:()=>t(n),children:(0,M.jsx)(Dt,{"aria-hidden":`true`})})]},`${e}-${n}`))})}function Qn(e){let{id:t,name:n,value:r,describedBy:i,invalid:a,required:o,onChange:s}=e,[c,l]=(0,j.useState)(``),u=(0,j.useRef)(null),d=Xn(r);function f(e){e.key===`Enter`&&c.trim()&&(e.preventDefault(),s(n,[...d,c.trim()]),l(``))}function p(e){s(n,d.filter((t,n)=>n!==e)),u.current?.focus()}return(0,M.jsxs)(`div`,{className:`editor-tags`,children:[(0,M.jsx)(Zn,{tags:d,onRemove:p}),(0,M.jsx)(`input`,{ref:u,id:t,name:n,type:`text`,className:`editor-control`,placeholder:`Type and press Enter`,value:c,"aria-describedby":i,"aria-invalid":a||void 0,"aria-required":o||void 0,onChange:e=>l(e.target.value),onKeyDown:f})]})}function $n(e){if(typeof e!=`string`||e===``)return``;let t=new Date(e);if(Number.isNaN(t.getTime()))return``;let n=e=>String(e).padStart(2,`0`);return`${`${t.getFullYear()}-${n(t.getMonth()+1)}-${n(t.getDate())}`}T${n(t.getHours())}:${n(t.getMinutes())}`}function er(e){if(e===``)return``;let t=new Date(e);return Number.isNaN(t.getTime())?``:`${t.toISOString().slice(0,19)}Z`}function z(e){return typeof e==`string`?e:``}function B(e){return{id:e.id,name:e.name,"aria-describedby":e.describedBy,"aria-invalid":e.invalid||void 0,"aria-required":e.required||void 0}}function tr(e){let{name:t,property:n,value:r,onChange:i}=e;return(0,M.jsx)(`input`,{...B(e),type:Dn(n,t),className:`editor-control`,value:z(r),maxLength:n.maxLength,pattern:n.pattern,onChange:e=>i(t,e.target.value)})}function nr(e){let{id:t,name:n,property:r,value:i,onChange:a}=e,o=z(i).length,s=r.maxLength!==void 0,c=`${t}-count`,l=[e.describedBy,s?c:null].filter(Boolean).join(` `);return(0,M.jsxs)(M.Fragment,{children:[(0,M.jsx)(`textarea`,{...B(e),"aria-describedby":l||void 0,className:`editor-control editor-control--area`,value:z(i),rows:3,maxLength:r.maxLength,onChange:e=>a(n,e.target.value)}),s&&(0,M.jsxs)(`span`,{id:c,className:`editor-field-counter`,children:[o,` of `,r.maxLength,` characters`]})]})}function rr(e){let{name:t,property:n,value:r,onChange:i}=e;return(0,M.jsx)(`input`,{...B(e),type:`number`,className:`editor-control editor-control--short`,value:typeof r==`number`&&!Number.isNaN(r)?r:``,min:n.minimum,max:n.maximum,onChange:e=>i(t,e.target.value===``?void 0:e.target.valueAsNumber)})}function ir(e){let{name:t,value:n,onChange:r}=e;return(0,M.jsx)(`input`,{...B(e),type:`checkbox`,className:`editor-checkbox`,checked:n===!0,onChange:e=>r(t,e.target.checked)})}function ar(e){let{name:t,property:n,value:r,onChange:i}=e;return(0,M.jsxs)(`select`,{...B(e),className:`editor-control editor-control--short`,value:z(r),onChange:e=>i(t,e.target.value),children:[(0,M.jsx)(`option`,{value:``,children:`Choose…`}),n.enum?.map(e=>(0,M.jsx)(`option`,{value:e,children:e},e))]})}function or(e){let{name:t,value:n,onChange:r}=e;return(0,M.jsxs)(`span`,{className:`editor-color`,children:[(0,M.jsx)(`input`,{type:`color`,className:`editor-color-swatch`,"aria-label":`${t}, colour picker`,value:z(n),onChange:e=>r(t,e.target.value)}),(0,M.jsx)(`input`,{...B(e),type:`text`,className:`editor-control editor-control--short`,value:z(n),placeholder:`#rrggbb`,onChange:e=>r(t,e.target.value)})]})}function sr(e){let{name:t,property:n,value:r,onChange:i}=e,a=Dn(n,t),o=a===`datetime-local`,s=(0,M.jsx)(`input`,{...B(e),type:a,className:`editor-control editor-control--short`,value:o?$n(r):z(r).slice(0,10),onChange:e=>{let n=e.target.value;i(t,o?er(n):n)}});return o?(0,M.jsxs)(`span`,{className:`editor-timestamp`,children:[s,(0,M.jsx)(`small`,{className:`editor-timestamp-shown`,children:d(r)})]}):s}var cr={media:qn,reference:Yn,enum:ar,boolean:ir,number:rr,tags:Qn,textarea:nr,color:or,date:sr,text:tr};function V(e,t){let n=e.replace(/([a-z])([A-Z])/g,`$1 $2`).replace(/[-_]/g,` `);return t.title??n.charAt(0).toUpperCase()+n.slice(1)}function lr(e){return typeof e==`object`&&e&&!Array.isArray(e)?e:{}}function H(e){let{property:t,value:n,onValue:r}=e,i=V(e.name,t),a=t.anyOf??t.oneOf;if(a?.some(e=>e.type===`null`)){let o=a.find(e=>e.type!==`null`)??{};return(0,M.jsxs)(`div`,{className:`metadata-property`,children:[n===null?(0,M.jsxs)(M.Fragment,{children:[(0,M.jsxs)(`p`,{children:[i,`: No value`]}),(0,M.jsxs)(y,{size:`sm`,onClick:()=>r(o.default??(o.type===`object`?{}:o.type===`array`?[]:o.type===`boolean`?!1:o.type===`number`?0:``)),children:[`Set `,i.toLowerCase()]})]}):(0,M.jsx)(H,{...e,property:{...t,...o,anyOf:void 0,oneOf:void 0}}),n!==null&&(0,M.jsx)(y,{variant:`ghost`,size:`sm`,onClick:()=>r(null),children:`Use no value`})]})}if(t.type===`object`)return(0,M.jsxs)(`fieldset`,{className:`metadata-object`,children:[(0,M.jsx)(`legend`,{children:i}),(0,M.jsx)(dr,{property:t,values:lr(n),path:e.path,errors:e.errors,sources:e.sources,onValues:r})]});if(t.type===`array`&&t.items?.type!==`string`){let a=Array.isArray(n)?n:[];return(0,M.jsxs)(`fieldset`,{className:`metadata-array`,children:[(0,M.jsx)(`legend`,{children:i}),a.map((n,o)=>(0,M.jsxs)(`div`,{className:`metadata-array-item`,children:[(0,M.jsx)(H,{...e,name:`${i} ${o+1}`,path:`${e.path}.${o}`,property:t.items??{},value:n,onValue:e=>r(a.map((t,n)=>n===o?e:t))}),(0,M.jsx)(y,{variant:`ghost`,size:`sm`,onClick:()=>r(a.filter((e,t)=>t!==o)),children:`Remove`})]},`${e.path}.${o}`)),(0,M.jsx)(y,{variant:`secondary`,size:`sm`,onClick:()=>r([...a,t.items?.type===`object`?{}:``]),children:`Add item`})]})}return(0,M.jsx)(ur,{...e})}function ur(e){let t=(0,j.useId)(),n=V(e.name,e.property),r=jn(e.property),i=e.errors[e.path]??(e.path.startsWith(`fields.`)?e.errors[e.path.slice(7)]:void 0),a=cr[R(e.property,e.name)],o=[r?`${t}-help`:``,i?`${t}-error`:``].filter(Boolean).join(` `)||void 0;return(0,M.jsxs)(`div`,{className:`metadata-property`,children:[(0,M.jsxs)(`div`,{className:`metadata-label-row`,children:[(0,M.jsxs)(`label`,{id:`${t}-label`,htmlFor:t,children:[n,e.required&&(0,M.jsx)(`span`,{"aria-hidden":`true`,children:` *`})]}),!e.required&&e.value!==void 0&&e.property.type!==`boolean`&&(0,M.jsx)(b,{icon:ke,size:`sm`,label:`Reset ${n.toLowerCase()}`,onClick:()=>e.onValue(void 0)})]}),e.property.type===`boolean`&&!e.required?(0,M.jsxs)(`select`,{id:t,className:`editor-control`,"aria-describedby":o,"aria-invalid":!!i||void 0,value:e.value===void 0?``:String(e.value),onChange:t=>e.onValue(t.target.value===``?void 0:t.target.value===`true`),children:[(0,M.jsx)(`option`,{value:``,children:`Use default`}),(0,M.jsx)(`option`,{value:`true`,children:`Yes`}),(0,M.jsx)(`option`,{value:`false`,children:`No`})]}):(0,M.jsx)(a,{id:t,labelId:`${t}-label`,name:e.path,property:e.property,value:e.value,required:e.required,describedBy:o,invalid:!!i,onChange:(t,n)=>e.onValue(n)}),e.sources?.[e.path]&&(0,M.jsxs)(`p`,{className:`metadata-source`,children:[`Copied from `,e.sources[e.path]]}),r&&(0,M.jsx)(`p`,{id:`${t}-help`,className:`metadata-help`,children:r}),i&&(0,M.jsx)(`p`,{id:`${t}-error`,role:`alert`,children:i})]})}function dr(e){let t=new Set(e.property.required??[]),n=e.property.properties??{},r=e.property.additionalProperties,i=r!==void 0&&r!==!1;return(0,M.jsxs)(M.Fragment,{children:[Object.entries(n).filter(([t])=>e.path!==`fields`||!wn.has(t)).map(([n,r])=>(0,M.jsx)(H,{name:n,path:`${e.path}.${n}`,property:r,value:e.values[n],required:t.has(n),errors:e.errors,sources:e.sources,onValue:t=>{let r={...e.values};t===void 0?delete r[n]:r[n]=t,e.onValues(r)}},n)),i&&(0,M.jsx)(pr,{...e,properties:n,additional:typeof r==`object`?r:{}}),!i&&Object.entries(e.values).filter(([e])=>!Object.hasOwn(n,e)).map(([t,n])=>(0,M.jsxs)(`div`,{className:`metadata-property`,children:[(0,M.jsxs)(`p`,{children:[V(t,{}),`:`,` `,typeof n==`string`?n:JSON.stringify(n)]}),(0,M.jsx)(`p`,{children:`This property is outside the current content form. Review it before removing it.`}),(0,M.jsxs)(y,{variant:`ghost`,size:`sm`,onClick:()=>{let n={...e.values};delete n[t],e.onValues(n)},children:[`Remove `,V(t,{})]})]},t))]})}function fr(e){return Array.isArray(e)?{type:`array`,items:fr(e[0])}:typeof e==`object`&&e?{type:`object`,additionalProperties:!0}:{type:typeof e==`boolean`?`boolean`:typeof e==`number`?`number`:`string`}}function pr(e){let[t,n]=(0,j.useState)(``),r=(0,j.useId)();return(0,M.jsxs)(`div`,{className:`metadata-record`,children:[Object.entries(e.values).filter(([t])=>!Object.hasOwn(e.properties,t)).map(([t,n])=>(0,M.jsx)(H,{name:t,path:`${e.path}.${t}`,value:n,property:e.additional.type?e.additional:fr(n),required:!1,errors:e.errors,sources:e.sources,onValue:n=>{let r={...e.values};n===void 0?delete r[t]:r[t]=n,e.onValues(r)}},t)),(0,M.jsx)(`label`,{htmlFor:r,children:`New property name`}),(0,M.jsx)(`input`,{id:r,value:t,onChange:e=>n(e.target.value)}),(0,M.jsx)(y,{size:`sm`,disabled:!t.trim()||Object.hasOwn(e.values,t.trim())||[`__proto__`,`constructor`,`prototype`].includes(t.trim()),onClick:()=>{e.onValues({...e.values,[t.trim()]:e.additional.default??``}),n(``)},children:`Add property`})]})}function mr(e){let t=I(Object.keys(e.fields)),n={title:L(t,`title`,e.fields),description:L(t,`description`,e.fields)};function r(t,n){let r={...e.values};n===void 0?delete r[t]:r[t]=n,e.onValues(r)}function i(t,n){return(0,M.jsx)(H,{name:t,path:`${e.path}.${t}`,property:{...e.schema.properties?.[t],title:n},value:e.values[t],required:!1,errors:e.errors,sources:e.sources,onValue:e=>r(t,e)})}return(0,M.jsxs)(`div`,{className:`metadata-sharing`,children:[[`title`,`description`].map(t=>(0,M.jsxs)(`div`,{className:`metadata-search-value`,children:[e.values[t]===void 0?(0,M.jsxs)(`div`,{className:`metadata-label-row`,children:[(0,M.jsxs)(`span`,{children:[`Search `,t,` `,(0,M.jsxs)(`span`,{className:`metadata-default-label`,children:[`uses the page `,t]})]}),!e.readOnly&&(0,M.jsx)(y,{className:`metadata-change`,size:`sm`,variant:`secondary`,"aria-label":`Write a different search ${t}`,onClick:()=>{let e=n[t];r(t,typeof e==`string`?e:``)},children:`Write your own`})]}):i(t,`Search ${t}`),e.below?.[t]]},t)),i(`image`,`Sharing image`),e.below?.image,(0,M.jsxs)(`details`,{className:`metadata-advanced`,children:[(0,M.jsx)(`summary`,{children:`Advanced search settings`}),i(`canonicalUrl`,`Canonical URL`),i(`index`,`Show in search results`),i(`follow`,`Allow search engines to follow links`)]})]})}function hr(e){let{meta:t}=e,n=t.changedBy?`saved by ${O(t.changedBy)}, ${Lt(t.createdAt)}`:`saved ${Lt(t.createdAt)}`;return(0,M.jsxs)(`p`,{className:`metadata-system`,title:d(t.createdAt),children:[(0,M.jsx)(`span`,{className:`visually-hidden`,children:`System: `}),[gt[rt(t)],`v${t.version}`,t.locale.toUpperCase(),n].join(` · `)]})}function gr(e,t){return Object.fromEntries(e.flatMap(e=>e.paths.flatMap(n=>{let r=n.slice(1).split(`/`).map(e=>e.replaceAll(`~1`,`/`).replaceAll(`~0`,`~`)),i=t;for(let e of r.slice(1)){if(!i||typeof i!=`object`)return[];i=i[e]}return JSON.stringify(i)===JSON.stringify(e.values[n])?[[r.join(`.`),`${e.collection}/${e.slug} · v${e.version}`]]:[]})))}var _r=`krantho/sharing`;function vr(e,t){return e===`all`||t.id===_r==(e===`sharing`)}function yr(e){let{group:t,slot:n}=e,r=(0,M.jsxs)(M.Fragment,{children:[t.label,(0,M.jsx)(`code`,{className:`metadata-key`,title:`The name your page reads it by`,children:n}),t.required&&(0,M.jsx)(`span`,{className:`metadata-help`,children:` · Required`})]});return e.bare?(0,M.jsx)(`div`,{className:`metadata-group metadata-group--bare`,children:e.children}):e.sharing?(0,M.jsxs)(`details`,{className:`metadata-group`,open:t.required||e.invalid,children:[(0,M.jsx)(`summary`,{children:t.label}),e.children]}):(0,M.jsxs)(`section`,{className:`metadata-group`,"aria-label":t.label,children:[(0,M.jsx)(`h4`,{className:`metadata-group-title`,children:r}),e.children]})}function U(e){let t=e.scope??`all`,n=Object.entries(e.contract.metadata).filter(([,e])=>vr(t,e)),r=Object.entries(e.metadata).filter(([n])=>t!==`sharing`&&!Object.hasOwn(e.contract.metadata,n));if(n.length===0&&r.length===0)return null;let i=gr(e.defaults??[],e.metadata),a=t===`sharing`?`Search and sharing`:`Metadata`;return(0,M.jsxs)(`section`,{className:`editor-metadata`,"aria-label":a,children:[(0,M.jsx)(`h3`,{children:a}),(0,M.jsx)(`p`,{className:`metadata-intro`,children:t===`sharing`?`How this page appears in search results and when it is shared.`:`Saved with the page, and published with it.`}),(0,M.jsxs)(`fieldset`,{disabled:e.readOnly,className:`metadata-groups`,children:[n.map(([n,r])=>{let a=e.metadata[n],o=a!==void 0||r.required,s=t=>e.onMetadata({...e.metadata,[n]:t});return n===`seo`&&r.schema.properties?.entities?(0,M.jsxs)(`div`,{className:`metadata-group metadata-graph-link`,children:[(0,M.jsxs)(`div`,{children:[(0,M.jsx)(`strong`,{children:`Structured data`}),(0,M.jsx)(`p`,{className:`metadata-help`,children:`Manage how this page is described to search engines.`})]}),e.onOpenData?(0,M.jsx)(y,{size:`sm`,variant:`secondary`,onClick:e.onOpenData,children:`Open graph editor`}):(0,M.jsx)(`p`,{className:`metadata-help`,children:`Available in Data view.`})]},n):!o&&r.id!==_r?(0,M.jsxs)(`div`,{className:`metadata-group metadata-group--absent`,children:[(0,M.jsx)(`strong`,{children:r.label}),!e.readOnly&&(0,M.jsx)(y,{variant:`secondary`,size:`sm`,onClick:()=>s({}),children:`Add`})]},n):(0,M.jsxs)(yr,{sharing:r.id===_r,bare:t===`sharing`,group:r,slot:n,invalid:Object.keys(e.errors).some(e=>e.startsWith(`metadata.${n}`)),children:[r.id===_r?(0,M.jsx)(mr,{below:e.checks,fields:e.fields??{},values:a??{},schema:r.schema,path:`metadata.${n}`,errors:e.errors,sources:i,readOnly:e.readOnly,onValues:s}):(0,M.jsx)(dr,{property:r.schema,values:a??{},path:`metadata.${n}`,errors:e.errors,sources:i,onValues:s}),o&&!r.required&&!e.readOnly&&(0,M.jsxs)(y,{className:`metadata-remove-group`,variant:`ghost`,size:`sm`,onClick:()=>{let t={...e.metadata};delete t[n],e.onMetadata(t)},children:[`Remove `,r.label.toLowerCase()]}),!e.readOnly&&e.groupActions?.(n),e.errors[`metadata.${n}`]&&(0,M.jsx)(`p`,{role:`alert`,children:e.errors[`metadata.${n}`]})]},n)}),r.map(([t,n])=>(0,M.jsxs)(`details`,{className:`metadata-group`,children:[(0,M.jsx)(`summary`,{children:V(t,{})}),(0,M.jsx)(`p`,{children:`These details are outside the current content form. Review them before removing them from this draft.`}),(0,M.jsx)(`dl`,{children:Object.entries(n).map(([e,t])=>(0,M.jsxs)(`div`,{children:[(0,M.jsx)(`dt`,{children:V(e,{})}),(0,M.jsx)(`dd`,{children:typeof t==`string`?t:JSON.stringify(t)})]},e))}),(0,M.jsx)(y,{variant:`ghost`,size:`sm`,onClick:()=>{let n={...e.metadata};delete n[t],e.onMetadata(n)},children:`Remove these details`})]},t))]}),e.system&&t!==`sharing`&&(0,M.jsx)(hr,{meta:e.system})]})}function br(e){let{collection:t,slug:n,locale:r,version:i}=e,a=(0,j.useCallback)(async()=>{let e=await rn(t,n,i,r),a=Nt.sanitize(await Mt.parse(e.body));return{...e,html:a}},[t,n,r,i]),{loaded:o,reload:s}=pe(a,`This snapshot could not be read`);return(0,M.jsxs)(w,{title:`Snapshot v${i}`,onClose:e.onClose,actions:(0,M.jsx)(y,{onClick:e.onClose,children:`Close`}),children:[(0,M.jsx)(`p`,{className:`snapshot-preview-note`,children:`Read-only snapshot. Your draft is unchanged.`}),o.state===`loading`&&(0,M.jsx)(`p`,{role:`status`,children:`Reading the snapshot…`}),o.state===`error`&&(0,M.jsxs)(`div`,{role:`alert`,children:[(0,M.jsx)(`p`,{children:o.message}),(0,M.jsx)(y,{onClick:s,children:`Retry`})]}),o.state===`ready`&&(0,M.jsxs)(M.Fragment,{children:[(0,M.jsx)(`time`,{dateTime:o.data.createdAt,children:h(o.data.createdAt)}),(0,M.jsxs)(`details`,{className:`snapshot-fields`,children:[(0,M.jsx)(`summary`,{children:`Fields`}),(0,M.jsx)(`pre`,{children:JSON.stringify(o.data.fields,null,2)})]}),o.data.contract&&(0,M.jsx)(U,{contract:o.data.contract,metadata:o.data.metadata,fields:o.data.fields,defaults:o.data.defaults,readOnly:!0,errors:{},onMetadata:()=>{}}),typeof o.data.fields.title==`string`&&(0,M.jsx)(`h3`,{children:o.data.fields.title}),(0,M.jsx)(`article`,{className:`snapshot-body`,dangerouslySetInnerHTML:{__html:o.data.html}})]})]})}function xr(e){let[t,n]=(0,j.useState)(!1),r=(0,j.useRef)(null),i=(0,j.useRef)(null),a=(0,j.useId)();return(0,j.useEffect)(()=>{if(!t)return;let e=e=>{let t=e.target;t?.closest(`.ui-modal-layer`)||r.current?.contains(t)||n(!1)};return document.addEventListener(`pointerdown`,e),()=>document.removeEventListener(`pointerdown`,e)},[t]),(0,M.jsxs)(`fieldset`,{ref:r,className:`snapshot-disclosure`,onKeyDown:e=>{e.key===`Escape`&&t&&(e.stopPropagation(),n(!1),i.current?.focus())},children:[(0,M.jsxs)(y,{ref:i,size:`sm`,variant:`ghost`,"aria-label":`Snapshot details`,"aria-expanded":t,"aria-controls":a,onClick:()=>n(!t),children:[`v`,e.entry.version,` · Details`,t?(0,M.jsx)(Vt,{size:14,"aria-hidden":`true`}):(0,M.jsx)(be,{size:14,"aria-hidden":`true`})]}),t&&(0,M.jsxs)(`section`,{id:a,className:`snapshot-popover`,"aria-label":`Selected snapshot`,children:[(0,M.jsxs)(`strong`,{children:[`Snapshot v`,e.entry.version]}),(0,M.jsx)(`time`,{dateTime:e.entry.createdAt,children:h(e.entry.createdAt)}),(0,M.jsx)(`span`,{children:e.entry.changedBy?O(e.entry.changedBy):`Unknown author`}),(0,M.jsxs)(`div`,{className:`snapshot-actions`,children:[(0,M.jsx)(y,{size:`sm`,variant:`ghost`,icon:Ut,onClick:e.onPreview,children:`Preview snapshot`}),e.actions]})]})]})}function Sr(e){let[t,n]=(0,j.useState)(null),r=t?.saved===e.saved.version?t.version:e.saved.version,[i,a]=(0,j.useState)(null),[o,s]=(0,j.useState)(null),c=o??e.versions.length>1,l=(0,j.useRef)(null),u=(0,j.useId)(),d=Math.max(0,e.versions.findIndex(e=>e.version===r)),f=e.versions[d],p=[...e.versions].reverse(),m=p.length-1-d,g=(0,j.useRef)(!1),_=()=>{let e=l.current,t=e?.querySelector(`[aria-pressed="true"]`);if(!e||!t)return;let n=t.offsetLeft-(e.clientWidth-t.offsetWidth)/2;e.scrollTo?.({left:n,behavior:`instant`})};(0,j.useEffect)(()=>{c&&!g.current&&_()},[m,c]);let v=t=>{let r=p[t];r&&n({saved:e.saved.version,version:r.version})};return(0,M.jsxs)(M.Fragment,{children:[(0,M.jsxs)(`div`,{className:`snapshot-heading`,children:[(0,M.jsxs)(y,{size:`sm`,variant:`ghost`,icon:we,"aria-label":c?`Collapse snapshot timeline`:`Expand snapshot timeline`,"aria-expanded":c,"aria-controls":u,onClick:()=>s(!c),children:[`Snapshots `,(0,M.jsx)(`small`,{children:e.versions.length}),c?(0,M.jsx)(Vt,{size:14,"aria-hidden":`true`}):(0,M.jsx)(be,{size:14,"aria-hidden":`true`})]}),e.unsaved&&(0,M.jsx)(k,{tone:`accent`,children:`Unsaved changes`}),f&&(0,M.jsx)(xr,{entry:f,actions:e.actions(d),onPreview:()=>a(f.version)})]}),c&&(0,M.jsxs)(`div`,{id:u,className:`snapshot-navigation`,children:[(0,M.jsx)(b,{icon:_e,label:`Older snapshot`,size:`sm`,disabled:m<=0,onClick:()=>v(m-1)}),(0,M.jsx)(`div`,{ref:l,className:`snapshot-viewport`,children:(0,M.jsxs)(`div`,{className:`snapshot-ruler`,style:{minWidth:`${Math.max(1,p.length)*104}px`,"--snapshot-edge":`${50/Math.max(1,p.length)}%`},children:[(0,M.jsx)(`ol`,{className:`snapshot-markers`,"aria-label":`Saved snapshots`,children:p.map((t,n)=>(0,M.jsx)(`li`,{children:(0,M.jsxs)(`button`,{type:`button`,className:`snapshot-stop`,"aria-label":`Select snapshot v${t.version}`,"aria-pressed":n===m,title:h(t.createdAt),onClick:()=>v(n),children:[(0,M.jsxs)(`span`,{className:`snapshot-label`,children:[`v`,t.version,t.version===e.saved.version&&(0,M.jsx)(`span`,{children:`Current`}),t.version===e.saved.liveVersion&&(0,M.jsx)(`span`,{className:`snapshot-live`,children:`Live`})]}),(0,M.jsx)(`span`,{className:`snapshot-tick`,"aria-hidden":`true`}),(0,M.jsx)(`time`,{dateTime:t.createdAt,children:new Date(t.createdAt).toLocaleDateString(void 0,{month:`short`,day:`numeric`})})]})},t.version))}),p.length>1&&(0,M.jsx)(`input`,{className:`snapshot-slider`,onPointerDown:()=>{g.current=!0},onPointerUp:()=>{g.current=!1,_()},onPointerCancel:()=>{g.current=!1,_()},type:`range`,"aria-label":`Snapshot selection`,min:0,max:p.length-1,step:1,value:m,"aria-valuetext":`v${f?.version}: ${h(f?.createdAt??``)}`,onChange:e=>v(Number(e.target.value))}),p.length===1&&(0,M.jsx)(`span`,{className:`snapshot-single`,"aria-hidden":`true`})]})}),(0,M.jsx)(b,{icon:yt,label:`Newer snapshot`,size:`sm`,disabled:m>=p.length-1,onClick:()=>v(m+1)})]}),i!==null&&(0,M.jsx)(br,{collection:e.collection,slug:e.slug,locale:e.locale,version:i,onClose:()=>a(null)})]})}function Cr(e){let{collection:t,slug:n,locale:r}=e,i=(0,j.useCallback)(()=>nn(t,n,r).then(e=>e.versions),[t,n,r]),{loaded:a,reload:o}=pe(i,`The history could not be read`),s=(0,j.useRef)(e.saved.version);return(0,j.useEffect)(()=>{s.current!==e.saved.version&&(s.current=e.saved.version,o())},[e.saved.version,o]),{loaded:a,reload:o}}function wr(e){let[t,n]=(0,j.useState)(null),r=(0,j.useRef)(null),i=(0,j.useRef)(0);return{comparison:t,show:t=>{r.current=document.activeElement instanceof HTMLElement?document.activeElement:null,e(null);let a=++i.current;t().then(e=>{a===i.current&&n(e)}).catch(t=>{a===i.current&&e(E(t,`The versions to compare could not be read`))})},close:()=>{n(null),r.current?.focus()}}}function Tr(e,t,n,r){let i=t=>rn(e.collection,e.slug,t,e.locale);return a=>{let o=t[a];if(!o)return{diff:null,compare:null,restore:null};let s=t[a+1],c=async e=>{let[t,n]=await Promise.all([i(e),i(o.version)]);return{base:t,compare:n,form:!1}},l=async()=>({base:await i(o.version),compare:cn(t,e.draft),form:!0});return{diff:s?()=>n(()=>c(s.version)):null,compare:e.unsaved||a>0?()=>n(l):null,restore:e.canRestore&&a>0?()=>r(o.version):null}}}function Er(e,t){let[n,r]=(0,j.useState)(null),[i,a]=(0,j.useState)(!1),o=T(),s=async n=>{t(null);let r;try{r=await an(e.collection,e.slug,n,e.locale)}catch(e){t(un(n,E(e,`the store refused it`)));return}try{await e.onRestored()}catch{t(dn(n,r.version));return}o({text:`v${n} restored as v${r.version}. The live page is unchanged until you publish.`})};return{asked:n,restoring:i,ask:r,cancel:()=>r(null),confirm:()=>{n===null||i||(r(null),a(!0),s(n).finally(()=>a(!1)))}}}function Dr(e){let[t,n]=(0,j.useState)(null),r=wr(n),[i,a]=(0,j.useState)(null);async function o(t){try{let n=await rn(e.collection,e.slug,t,e.locale);e.onPrepare({fields:n.fields,metadata:n.metadata,body:n.body,defaults:n.defaults}),a(null)}catch(e){n(E(e,`The snapshot could not be read`))}}let s=Er(e,n),c=Tr(e,e.versions,r.show,s.ask);return(0,M.jsxs)(M.Fragment,{children:[t&&(0,M.jsx)(on,{children:t}),e.canRestore&&e.versions.length>1&&(0,M.jsxs)(`details`,{className:`data-disclosure`,children:[(0,M.jsx)(`summary`,{children:`Prepare an earlier snapshot as a draft`}),(0,M.jsx)(`p`,{children:`Bring its values into the current content form for review and correction. Nothing is saved or published.`}),e.versions.slice(1).map(e=>(0,M.jsxs)(y,{size:`sm`,onClick:()=>a(e.version),children:[`Prepare v`,e.version]},e.version))]}),i!==null&&(0,M.jsx)(w,{title:`Prepare v${i} as a draft?`,onClose:()=>a(null),actions:(0,M.jsxs)(M.Fragment,{children:[(0,M.jsx)(y,{onClick:()=>a(null),children:`Cancel`}),(0,M.jsx)(y,{onClick:()=>{o(i)},children:`Prepare draft`})]}),children:(0,M.jsxs)(`p`,{children:[`Replace the current form with this snapshot’s values. Review them against today’s content form before saving.`,e.unsaved?` Your unsaved form changes will be replaced.`:``]})}),e.timeline?(0,M.jsx)(Sr,{...e,actions:t=>(0,M.jsx)(pn,{n:e.versions[t]?.version??0,actions:c(t),restoring:s.restoring})}):(0,M.jsx)(`ol`,{className:`data-versions`,"aria-label":`Versions`,children:e.versions.map((t,n)=>(0,M.jsx)(mn,{version:t,props:e,actions:c(n),restoring:s.restoring},t.version))}),r.comparison&&(0,M.jsx)(xn,{comparison:r.comparison,onClose:r.close}),s.asked!==null&&(0,M.jsx)(fn,{version:s.asked,unsaved:e.unsaved,onConfirm:s.confirm,onClose:s.cancel})]})}function Or(e){let{loaded:t,reload:n}=Cr(e),r=(0,M.jsxs)(M.Fragment,{children:[t.state===`loading`&&(0,M.jsx)(P,{children:`Reading the history…`}),t.state===`error`&&(0,M.jsxs)(`div`,{children:[(0,M.jsx)(P,{tone:`error`,children:t.message}),(0,M.jsx)(y,{size:`sm`,onClick:n,children:`Retry history`})]}),t.state===`ready`&&(t.data.length===0?(0,M.jsx)(P,{children:`No version history yet.`}):(0,M.jsx)(Dr,{...e,versions:t.data}))]});return e.timeline?(0,M.jsx)(`section`,{className:`snapshot-timeline`,"aria-label":`Article snapshots`,children:r}):(0,M.jsx)(N,{title:`History`,lead:`The ${e.locale.toUpperCase()} version's saved versions, newest first. Restore saves an earlier one again as a new version.`,children:r})}var kr=0,Ar=new Set;function jr(e){return Ar.add(e),()=>Ar.delete(e)}function Mr(){return kr}function Nr(){kr+=1;for(let e of Ar)e()}function Pr(){return(0,j.useSyncExternalStore)(jr,Mr,Mr)}function Fr(e,t,n){let r=t.items.find(e=>e.collection===n.collection&&e.slug===n.slug);return r?r.status===`complete`?{step:e,state:`generated`,text:r.result??`Filled`}:r.status===`error`?{step:e,state:`error`,text:r.error??`Failed`}:{step:e,state:`skipped`,text:r.result??`Nothing missing`}:{step:e,state:`skipped`,text:`Not part of the job`}}function Ir(e){return e.saved?!e.canEdit||!e.admin?`Enrichment is run by an admin.`:e.lockedBy?`${O(e.lockedBy)} is editing: enrichment waits until they finish.`:e.defaultLocaleName===null?`The site's locales could not be read: enrichment works on the default locale's version only.`:e.defaultLocale?e.dirty?`Save or discard your changes first: enrichment saves a new version of the document.`:null:`Enrichment reads and writes the ${e.defaultLocaleName.toUpperCase()} version: open it to enrich.`:`Save the page first: enrichment works on saved documents.`}function Lr(e){return e.some(e=>e.step===`meta-descriptions`&&e.state===`generated`)}async function Rr(e,t,n){let r=await ze(e,{scope:`item`,...t},n);return r?r.state===`empty`?{step:e,state:`skipped`,text:r.message}:Fr(e,r.status,t):null}function zr(e,t){let[n,r]=(0,j.useState)({state:`idle`}),i=(0,j.useRef)(!0);(0,j.useEffect)(()=>(i.current=!0,()=>{i.current=!1}),[]);let a=(0,j.useRef)(t);(0,j.useLayoutEffect)(()=>{a.current=t});let o=(0,j.useRef)(!1),{collection:s,slug:c}=e;return{run:n,start:(0,j.useCallback)(e=>{if(o.current)return;o.current=!0;let t=()=>i.current;(async()=>{let n=[];try{for(let i of e){r({state:`running`,step:i});let e=await Rr(i,{collection:s,slug:c},t);if(!e)return;n.push(e)}if(!t())return;r({state:`done`,outcomes:n}),a.current(n)}catch(e){if(!t())return;r({state:`failed`,message:E(e,`Enrichment failed`)}),n.length>0&&a.current(n)}finally{o.current=!1}})()},[s,c])}}var Br={generated:D,skipped:te,error:Ce};function Vr({outcomes:e}){return(0,M.jsx)(`ul`,{className:`data-outcomes`,children:e.map(e=>{let t=Br[e.state];return(0,M.jsxs)(`li`,{className:`data-outcome data-outcome--${e.state}`,children:[(0,M.jsx)(t,{"aria-hidden":`true`}),(0,M.jsxs)(`span`,{children:[(0,M.jsx)(`strong`,{children:Re[e.step]}),` · `,e.text]})]},e.step)})})}function Hr(e){switch(e.state){case`running`:return`Enriching · ${Re[e.step]}…`;case`failed`:return`Enrichment failed: ${e.message}`;case`done`:return`Enrichment finished. ${e.outcomes.map(e=>`${Re[e.step]}: ${e.text}`).join(`. `)}`;default:return``}}function Ur({run:e}){return(0,M.jsxs)(M.Fragment,{children:[(0,M.jsx)(`p`,{className:`visually-hidden`,role:`status`,children:Hr(e)}),e.state===`running`&&(0,M.jsxs)(P,{children:[`Enriching · `,Re[e.step],`…`]}),e.state===`failed`&&(0,M.jsx)(P,{tone:`error`,children:e.message}),e.state===`done`&&(0,M.jsx)(Vr,{outcomes:e.outcomes})]})}function Wr(){return(0,M.jsxs)(P,{children:[`No language model is set up. Set one up in `,(0,M.jsx)(c,{to:jt,children:`Setup › AI provider`}),`.`]})}function Gr(e){let{run:t,start:n}=zr(e.target,e.onFinished),r=Be(),i=t.state===`running`,a=i?`Enrichment is running.`:r.state===`running`?`A run across the site is going, and the API runs one job at a time. Enrich this document when it ends.`:Ir(e.facts);return(0,M.jsxs)(M.Fragment,{children:[(0,M.jsx)(`div`,{className:`data-actions`,children:(0,M.jsx)(A,{reason:a,variant:`primary`,icon:Ve,onClick:()=>n([`meta-descriptions`,`archetype`]),children:`Enrich this document`})}),a&&!i&&(0,M.jsx)(P,{children:a}),(0,M.jsx)(Ur,{run:t})]})}function Kr(e){let t=ue();return(0,M.jsxs)(N,{title:`Enrichment`,lead:(0,M.jsxs)(M.Fragment,{children:[`Fills what is `,(0,M.jsx)(`em`,{children:`missing`}),` — a meta description and the Schema.org properties no one has set — with the language model set up in Setup › AI provider. It never overwrites a value someone set. What it fills is saved to the document at once: the meta description as a new version and in the document's SEO settings, the Schema.org properties in those settings. The SEO settings have no versions, so the structured data on the live page — and the meta description the site reads from them first — changes straight away.`]}),children:[t===`loading`&&(0,M.jsx)(P,{children:`Reading the AI provider…`}),t===`missing`&&(0,M.jsx)(Wr,{}),(t===`configured`||t===`unknown`)&&(0,M.jsx)(Gr,{...e})]})}var qr={error:{icon:Ce,label:`Error`,order:0},warning:{icon:He,label:`Warning`,order:1},info:{icon:De,label:`Note`,order:2}};function Jr({finding:e,reader:t}){let{icon:n,label:r}=qr[e.severity];return(0,M.jsxs)(`li`,{className:`editor-finding editor-finding--${e.severity}`,children:[(0,M.jsx)(n,{className:`editor-finding-icon`,role:`img`,"aria-label":r}),(0,M.jsxs)(`span`,{className:`editor-finding-text`,children:[t&&(0,M.jsxs)(`span`,{className:`editor-finding-reader`,children:[t,`: `]}),e.message,e.property&&(0,M.jsxs)(M.Fragment,{children:[` `,(0,M.jsxs)(`code`,{children:[e.type?`${e.type}.`:``,e.property]})]}),e.source&&(0,M.jsxs)(`a`,{className:`editor-finding-source`,href:e.source,target:`_blank`,rel:`noreferrer`,children:[`Documentation`,(0,M.jsx)(Te,{"aria-hidden":`true`}),(0,M.jsx)(`span`,{className:`visually-hidden`,children:` (opens in a new tab)`})]})]})]})}function Yr(e,t){let n=[{id:`page`,label:`Title and meta description`,findings:[]},{id:`schema.org`,label:`Schema.org`,findings:[]},...t.map(e=>({id:e.id,label:e.name,findings:[]}))];for(let t of e){let e=t.check===`structured-data`?t.reader??`schema.org`:`page`,r=n.find(t=>t.id===e);r||(r={id:e,label:e,findings:[]},n.push(r)),r.findings.push(t)}let r=e=>qr[e.severity].order;for(let e of n)e.findings.sort((e,t)=>r(e)-r(t));return n}function Xr(e){let t=e.filter(e=>e.severity===`error`).length,n=e.filter(e=>e.severity===`warning`).length;return t>0?{tone:`danger`,text:`${t} error${t===1?``:`s`}`}:n>0?{tone:`warning`,text:`${n} warning${n===1?``:`s`}`}:{tone:`success`,text:`Passes`}}function Zr({group:e}){let t=(0,j.useId)(),{tone:n,text:r}=Xr(e.findings);return(0,M.jsxs)(`section`,{className:`data-finding-group`,"aria-labelledby":t,children:[(0,M.jsxs)(`div`,{className:`data-finding-head`,children:[(0,M.jsx)(`h3`,{id:t,className:`data-finding-title`,children:e.label}),(0,M.jsx)(k,{tone:n,children:r})]}),e.findings.length===0?(0,M.jsxs)(`p`,{className:`data-finding-clean`,children:[(0,M.jsx)(D,{"aria-hidden":`true`}),`No findings.`]}):(0,M.jsx)(`ul`,{className:`data-finding-list`,children:e.findings.map((e,t)=>(0,M.jsx)(Jr,{finding:e},`${e.code??e.check}-${e.property??``}-${t}`))})]})}function Qr({findings:e,readers:t}){return(0,M.jsx)(`div`,{className:`data-findings`,children:Yr(e,t).map(e=>(0,M.jsx)(Zr,{group:e},e.id))})}function $r({findings:e,version:t}){return(0,M.jsxs)(N,{title:`Findings per search engine`,lead:`The saved version, v${t}, checked against Schema.org and the rules of each search engine the site targets. Errors make the markup invalid; warnings keep the page from a search feature.`,children:[e.state===`loading`&&(0,M.jsx)(P,{children:`Checking…`}),e.state===`error`&&(0,M.jsx)(P,{tone:`error`,children:e.message}),e.state===`ready`&&(0,M.jsx)(Qr,{findings:e.data.findings,readers:e.data.readers})]})}var ei=(0,j.lazy)(()=>n(()=>import(`./GraphBrowser-DvcHXw-i.js`).then(e=>({default:e.GraphBrowser})),__vite__mapDeps([2,1,0,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30])));function ti(e){let{source:t,collection:n,slug:r,readOnly:i,onStage:a}=e,o=T();async function s(e){a(e),o({text:`Graph added to your draft. Save draft, then publish when ready.`})}return(0,M.jsxs)(`div`,{className:`data-graph-editor`,children:[i?(0,M.jsx)(P,{children:i}):(0,M.jsx)(P,{children:`Apply adds your graph changes to this document’s draft. Save draft keeps a snapshot; Publish updates the live page.`}),(0,M.jsx)(j.Suspense,{fallback:(0,M.jsx)(P,{children:`Loading the graph editor…`}),children:(0,M.jsx)(ei,{saveLabel:`Apply to draft`,model:t.model,catalogTypes:t.catalogTypes,catalogDetails:t.catalogDetails,rawData:t.emitted,collection:n,slug:r,configData:i?void 0:e.draftConfig??t.editable,onSave:i?void 0:s})})]})}function ni(e,t){return(0,j.useMemo)(()=>{if(e.state!==`ready`||t.state!==`ready`)return[];let n=new Set(t.data.catalogTypes.filter(e=>e.siteLevel).map(e=>e.type));return se({nodes:t.data.nodes,resolved:e.data,siteTypes:n})},[e,t])}function ri({resolved:e,graph:t}){let n=ni(e,t),r=[e,t].find(e=>e.state===`error`);return r?.state===`error`?(0,M.jsx)(P,{tone:`error`,children:r.message}):e.state===`loading`||t.state===`loading`?(0,M.jsx)(P,{children:`Reading the structured data…`}):n.length===0?(0,M.jsx)(P,{children:`The page emits no entities.`}):(0,M.jsxs)(M.Fragment,{children:[(0,M.jsx)(ne,{counts:ae(n)}),(0,M.jsx)(ie,{views:n})]})}function ii({graph:e}){return e.state===`loading`?(0,M.jsx)(P,{children:`Composing the JSON-LD…`}):e.state===`error`?(0,M.jsx)(P,{tone:`error`,children:e.message}):(0,M.jsxs)(`details`,{className:`data-disclosure`,children:[(0,M.jsx)(`summary`,{children:`What the page emits · view-source`}),(0,M.jsx)(re,{data:e.data.emitted,label:`application/ld+json`})]})}function ai({open:e,readOnly:t,controls:n,onToggle:r}){return(0,M.jsx)(y,{size:`sm`,icon:t?Tt:Oe,"aria-expanded":e,"aria-controls":n,onClick:r,children:e?`Close the graph editor`:t?`Browse the graph`:`Edit the graph`})}function oi(e){let{graph:t}=e,[n,r]=(0,j.useState)(e.initialOpen??!1),i=(0,j.useId)();return(0,M.jsxs)(N,{title:`JSON-LD graph · what this page emits`,lead:`Every node the page emits, with its type, @id and scope, and each value with where it comes from; a value krantho adds while composing the page reads computed. Sources are read for the saved version, v${e.version}.`,aside:t.state===`ready`?(0,M.jsx)(ai,{open:n,readOnly:e.readOnly,controls:i,onToggle:()=>r(e=>!e)}):null,children:[(0,M.jsx)(ri,{resolved:e.resolved,graph:t}),(0,M.jsx)(ii,{graph:t}),(0,M.jsx)(`div`,{id:i,children:n&&t.state===`ready`&&(0,M.jsx)(ti,{source:t.data,collection:e.collection,slug:e.slug,readOnly:e.readOnly,onStage:e.onStage,draftConfig:e.draftConfig})})]})}function W(e){return typeof e==`string`&&e.trim()!==``?e:``}function si(e){let{fields:t,documentSeo:n,siteSeo:r}=e,i=I(Object.keys(t)),a=e=>W(L(i,e,t)),o=W(n.headline)||W(n.name)||a(`title`)||e.slug,s=W(n.description)||a(`description`),c=W(n.image)||a(`image`)||W(r[`og-default-image`]),l=a(`ogImage`)||c;return{title:o,description:s,url:W(n.url)||a(`canonicalUrl`)||e.pageUrl,social:{title:a(`ogTitle`)||o,description:a(`ogDescription`)||s,image:l||null,type:a(`ogType`)||`website`,siteName:W(r.name)||e.siteName},twitterCard:l?`summary_large_image`:`summary`}}function ci(e){if(!e)return{host:``,trail:``};try{let t=new URL(e),n=t.pathname.split(`/`).filter(Boolean).map(decodeURIComponent);return{host:t.host,trail:n.map(e=>` › ${e}`).join(``)}}catch{return{host:e,trail:``}}}function li(e){return/^(https?:)?\/\//.test(e)||e.startsWith(`/`)?e:`/api/media/${encodeURIComponent(e)}/image?preset=lg`}function ui(e){return e?.entities[0]?.properties??{}}function di(e){switch(e.state){case`not-live`:return`Checked once the page is live: the search engines read the live page.`;case`other-locale`:return`Checked for the default locale's live page only.`;case`unlisted`:return`Not among the site's checked live pages.`;case`error`:return`The rich results could not be read.`;default:return null}}function fi({feature:e}){return(0,M.jsxs)(`li`,{className:`data-rich`,children:[e.eligible?(0,M.jsx)(D,{className:`data-rich-icon data-rich-icon--eligible`,"aria-hidden":`true`}):(0,M.jsx)(te,{className:`data-rich-icon`,"aria-hidden":`true`}),(0,M.jsx)(`span`,{className:`data-rich-name`,children:e.feature}),(0,M.jsxs)(`span`,{className:`data-rich-reader`,children:[e.reader,` · `,(0,M.jsx)(`code`,{children:e.type})]}),(0,M.jsx)(k,{tone:e.eligible?`success`:`neutral`,children:e.eligible?`Eligible`:`Not eligible`})]})}function pi({rich:e}){if(e.state===`loading`)return(0,M.jsx)(P,{children:`Reading the rich results…`});if(e.state===`error`)return(0,M.jsx)(P,{tone:`error`,children:e.message});let t=di(e.data);if(t)return(0,M.jsx)(P,{children:t});let n=e.data.state===`listed`?e.data.features:[];return n.length===0?(0,M.jsx)(P,{children:`No search feature the readers still show applies to this page.`}):(0,M.jsx)(`ul`,{className:`data-rich-list`,"aria-label":`Rich results`,children:n.map(e=>(0,M.jsx)(fi,{feature:e},`${e.reader}-${e.feature}-${e.type}`))})}function mi({rich:e}){return(0,M.jsx)(N,{title:`Rich results`,lead:`From the search engines' own rules: only the features they still show. What keeps the page from one is under Findings.`,children:(0,M.jsx)(pi,{rich:e})})}function hi(e,t){let n=I(Object.keys(e)),r={};for(let i of t)r[i]=L(n,i,e);return r}function gi(e,t){let n=t?.title.maxChars;return e.length===0?{label:`Page title`,pass:!1,hint:`Missing title`}:n===void 0?{label:`Page title`,pass:!0,hint:`${e.length} chars`}:{label:`Page title`,pass:e.length<=n,hint:e.length>n?`Too long (${e.length}/${n})`:`${e.length}/${n} chars`}}function _i(e,t){let n=`Meta description`,r=e.length;if(r===0)return{label:n,pass:!1,hint:`Missing`};if(!t)return{label:n,pass:!0,hint:`${r} chars`};let{minChars:i,maxChars:a}=t.metaDescription;return r<i?{label:n,pass:!1,hint:`Too short (${r}/${i}–${a})`}:r>a?{label:n,pass:!1,hint:`Too long (${r}/${a})`}:{label:n,pass:!0,hint:`${r}/${a} chars`}}function vi(e,t,n){let{description:r,title:i}=hi(e,[`description`,`title`]),a=[gi(i,n),_i(r,n)];a.push({label:`Body content`,pass:t.length>100,hint:t.length===0?`Empty body`:t.length<100?`Very short content`:`${t.length} chars`});let o=(t.match(/^## /gm)??[]).length;a.push({label:`Heading structure`,pass:o>0,hint:o===0?`No ## headings found`:`${o} section heading(s)`});let s=(t.match(/\[.*?\]\(.*?\)/g)??[]).length;return a.push({label:`Links`,pass:s>0,hint:s===0?`No links in content`:`${s} link(s)`}),a}function yi({id:e,label:t,help:n,children:r}){return(0,M.jsxs)(`div`,{className:`data-field`,children:[(0,M.jsx)(`label`,{htmlFor:e,className:`data-field-label`,children:t}),r,n&&(0,M.jsx)(`p`,{id:`${e}-help`,className:`data-field-help`,children:n})]})}function bi(e){return typeof e==`string`?e:``}function xi({title:e,description:t,url:n}){let{host:r,trail:i}=ci(n);return(0,M.jsxs)(`div`,{className:`serp-preview`,children:[(0,M.jsxs)(`div`,{className:`serp-preview-url-row`,children:[(0,M.jsx)(`span`,{className:`serp-preview-favicon`,"aria-hidden":`true`}),(0,M.jsxs)(`div`,{className:`serp-preview-url-group`,children:[(0,M.jsx)(`span`,{className:`serp-preview-site-name`,children:r||`Address not known`}),(0,M.jsxs)(`span`,{className:`serp-preview-breadcrumb`,children:[r,i]})]})]}),(0,M.jsx)(`p`,{className:`serp-preview-title`,children:e}),(0,M.jsx)(`p`,{className:`serp-preview-description`,children:t||`No description: a search engine picks text from the page.`})]})}function Si({preview:e}){return(0,M.jsx)(N,{title:`Search result`,lead:`From the draft's current values, before you save. The live page changes when you publish.`,children:(0,M.jsx)(xi,{title:e.title,description:e.description,url:e.url})})}function Ci({draft:e,limits:t}){let n=vi(e.fields,e.body,t),r=n.filter(e=>!e.pass).length;return(0,M.jsx)(N,{title:`Checks`,aside:(0,M.jsx)(k,{tone:r===0?`success`:`warning`,children:r===0?`All pass`:`${r} to review`}),children:(0,M.jsx)(`ul`,{className:`data-checks`,"aria-label":`Checks`,children:n.map(e=>(0,M.jsxs)(`li`,{className:e.pass?`data-check`:`data-check data-check--open`,children:[e.pass?(0,M.jsx)(D,{className:`data-check-icon`,role:`img`,"aria-label":`Passes`}):(0,M.jsx)(wt,{className:`data-check-icon`,role:`img`,"aria-label":`To review`}),(0,M.jsx)(`span`,{className:`data-check-label`,children:e.label}),(0,M.jsx)(`span`,{className:`data-check-hint`,children:e.hint})]},e.label))})})}function wi({name:e,label:t,hint:n,fields:r,onField:i}){return(0,M.jsxs)(`label`,{className:`data-toggle`,children:[(0,M.jsx)(`input`,{type:`checkbox`,checked:r[e]!==!1,onChange:t=>i(e,t.target.checked)}),(0,M.jsx)(`span`,{children:t}),(0,M.jsx)(`span`,{className:`data-toggle-hint`,children:n})]})}function Ti({fields:e,pageUrl:t,onField:n}){let r=(0,j.useId)();return(0,M.jsx)(yi,{id:r,label:`canonical-url`,help:t?`Empty: the page's own address, ${t}`:void 0,children:(0,M.jsx)(`input`,{id:r,type:`url`,className:`editor-control`,value:bi(e[`canonical-url`]),placeholder:t??void 0,"aria-describedby":t?`${r}-help`:void 0,onChange:e=>n(`canonical-url`,e.target.value)})})}function Ei({fields:e,pageUrl:t,readOnly:n,onField:r}){let i=e[`robots-index`]===!1?`noindex`:`index`,a=e[`robots-follow`]===!1?`nofollow`:`follow`;return(0,M.jsx)(N,{title:`Indexing`,lead:`Saved with the draft, as the fields canonical-url, robots-index and robots-follow.`,children:(0,M.jsxs)(`fieldset`,{className:`data-fields`,disabled:n,children:[(0,M.jsx)(`legend`,{className:`visually-hidden`,children:`Indexing`}),(0,M.jsx)(Ti,{fields:e,pageUrl:t,onField:r}),(0,M.jsx)(wi,{name:`robots-index`,label:`Index`,hint:`Search engines may list the page`,fields:e,onField:r}),(0,M.jsx)(wi,{name:`robots-follow`,label:`Follow`,hint:`Search engines may follow its links`,fields:e,onField:r}),(0,M.jsx)(`code`,{className:`data-tag`,children:`<meta name="robots" content="${i}, ${a}" />`})]})})}function Di({image:e}){let[t,n]=(0,j.useState)(null);return!e||t===e?(0,M.jsxs)(`div`,{className:`social-card-image social-card-image--empty`,children:[(0,M.jsx)(Se,{"aria-hidden":`true`}),(0,M.jsx)(`span`,{children:e?`The image could not load`:`No social image`})]}):(0,M.jsx)(`div`,{className:`social-card-image`,children:(0,M.jsx)(`img`,{src:li(e),alt:``,onError:()=>n(e)})})}function Oi(e){if(!e)return``;try{return new URL(e).host}catch{return e}}function ki({preview:e}){let{social:t,twitterCard:n}=e,r=Oi(e.url),i=n===`summary_large_image`;return(0,M.jsxs)(`div`,{className:`social-previews`,children:[(0,M.jsxs)(`figure`,{className:`social-preview`,children:[(0,M.jsxs)(`figcaption`,{className:`social-preview-label`,children:[`Open Graph · og:type `,t.type]}),(0,M.jsxs)(`div`,{className:`social-card`,children:[(0,M.jsx)(Di,{image:t.image}),(0,M.jsxs)(`div`,{className:`social-card-text`,children:[(0,M.jsx)(`span`,{className:`social-card-site`,children:t.siteName||r}),(0,M.jsx)(`span`,{className:`social-card-title`,children:t.title}),(0,M.jsx)(`span`,{className:`social-card-description`,children:t.description})]})]})]}),(0,M.jsxs)(`figure`,{className:`social-preview`,children:[(0,M.jsxs)(`figcaption`,{className:`social-preview-label`,children:[`X · `,n]}),(0,M.jsxs)(`div`,{className:i?`social-card`:`social-card social-card--summary`,children:[i?(0,M.jsx)(Di,{image:t.image}):null,(0,M.jsxs)(`div`,{className:`social-card-text`,children:[(0,M.jsx)(`span`,{className:`social-card-title`,children:t.title}),(0,M.jsx)(`span`,{className:`social-card-site`,children:r})]})]})]})]})}var Ai=[`website`,`article`,`product`,`profile`];function ji({value:e,chooseRef:t,onChoose:n,onClear:r}){return(0,M.jsxs)(M.Fragment,{children:[(0,M.jsx)(y,{ref:t,size:`sm`,onClick:n,children:e?`Change`:`Choose image`}),e&&(0,M.jsx)(y,{size:`sm`,variant:`ghost`,onClick:()=>{r(),t.current?.focus()},children:`Clear`})]})}function Mi({fields:e,readOnly:t,onField:n}){let r=bi(e[`og-image`]),[i,a]=(0,j.useState)(!1),o=(0,j.useRef)(null);function s(e){n(`og-image`,e.url),a(!1)}return(0,M.jsxs)(`fieldset`,{className:`data-field data-image-field`,disabled:t,children:[(0,M.jsx)(`legend`,{className:`data-field-label`,children:`og-image`}),(0,M.jsxs)(`div`,{className:`data-image-choice`,children:[(0,M.jsx)(`code`,{className:`data-image-value`,children:r||`None: the page image or the site default`}),(0,M.jsx)(ji,{value:r,chooseRef:o,onChoose:()=>a(!0),onClear:()=>n(`og-image`,``)})]}),(0,M.jsx)(`p`,{className:`data-field-help`,children:`1200 × 630 pixels suits most networks.`}),i&&(0,M.jsx)(Vn,{onSelect:s,onUpload:s,onClose:()=>a(!1)})]})}function Ni({name:e,help:t,area:n,fields:r,onField:i}){let a=(0,j.useId)(),o={id:a,value:bi(r[e]),"aria-describedby":`${a}-help`,onChange:t=>i(e,t.target.value)};return(0,M.jsx)(yi,{id:a,label:e,help:t,children:n?(0,M.jsx)(`textarea`,{...o,className:`editor-control editor-control--area`,rows:2}):(0,M.jsx)(`input`,{...o,className:`editor-control`})})}function Pi({fields:e,onField:t}){let n=(0,j.useId)();return(0,M.jsx)(yi,{id:n,label:`og-type`,help:`Auto: website.`,children:(0,M.jsxs)(`select`,{id:n,className:`editor-control editor-control--short`,value:bi(e[`og-type`]),"aria-describedby":`${n}-help`,onChange:e=>t(`og-type`,e.target.value),children:[(0,M.jsx)(`option`,{value:``,children:`Auto`}),Ai.map(e=>(0,M.jsx)(`option`,{value:e,children:e},e))]})})}function Fi(e){let{fields:t,readOnly:n,onField:r}=e;return(0,M.jsxs)(N,{title:`Social cards`,lead:`From the draft's current values. The overrides are fields of the document, saved with the draft.`,children:[(0,M.jsx)(ki,{preview:e.preview}),(0,M.jsxs)(`fieldset`,{className:`data-fields`,disabled:n,children:[(0,M.jsx)(`legend`,{className:`data-fields-legend`,children:`Overrides for sharing`}),(0,M.jsx)(Ni,{name:`og-title`,help:`Empty: the page title.`,area:!1,fields:t,onField:r}),(0,M.jsx)(Ni,{name:`og-description`,help:`Empty: the meta description.`,area:!0,fields:t,onField:r}),(0,M.jsx)(Pi,{fields:t,onField:r})]}),(0,M.jsx)(Mi,{fields:t,readOnly:n,onField:r})]})}async function Ii(e){if(!e.live)return{state:`not-live`};if(!e.defaultLocale)return{state:`other-locale`};try{let{pages:t,readers:n}=await je(),r=t.find(t=>t.collection===e.collection&&t.slug===e.slug);if(!r)return{state:`unlisted`};let i=e=>n.find(t=>t.id===e)?.name??e;return{state:`listed`,features:r.features.map(e=>({feature:e.feature,type:e.type,reader:i(e.reader),eligible:e.eligible}))}}catch{return{state:`error`}}}async function Li(e){try{return(await Pe(e)).config?.config??null}catch(e){if(e instanceof Ge&&e.status===501)return null;throw e}}async function Ri(e){let t=await Promise.allSettled(e.map(Fe)),n=new Map;for(let e of t)e.status===`fulfilled`&&n.set(e.value.type.type,e.value);return n}async function zi(e,t,n){let[r,i,a,o,s]=await Promise.all([Ie(e,t,n),Li(`doc:${e}/${t}`),Li(`collection:${e}`),Li(`site`),Ne().catch(()=>({types:[]}))]),c=oe(r),l={document:i,collection:a,site:o};return{emitted:r,nodes:c,model:de(r),editable:le(c,l),configs:l,catalogTypes:s.types,catalogDetails:await Ri(ce(c))}}function Bi(e,t,n){let{loaded:r,reload:i}=pe(e,t),a=(0,j.useRef)(n);return(0,j.useEffect)(()=>{a.current!==n&&(a.current=n,i())},[n,i]),r}function Vi(e,t){let{collection:n,slug:r,locale:i,live:a,defaultLocale:o}=e,s=(0,j.useCallback)(()=>Ae(n,r,i).then(e=>e.entities),[n,r,i]),c=(0,j.useCallback)(()=>Me(n,r,i),[n,r,i]),l=(0,j.useCallback)(()=>Ii({collection:n,slug:r,live:a,defaultLocale:o}),[n,r,a,o]),u=(0,j.useCallback)(()=>zi(n,r,i),[n,r,i]),d=`${e.version}:${t}`;return{resolved:Bi(s,`The structured data could not be read`,d),findings:Bi(c,`The findings could not be read`,d),rich:Bi(l,`The rich results could not be read`,d),graph:Bi(u,`The emitted graph could not be read`,d)}}function Hi(e,t){let n=e.collection?xt(e.collection,t):null,r=e.site?.site.baseUrl;return n!==null&&r?Ft(r,n):null}function Ui(e,t,n,r){return si({fields:e.draft.draft.fields,slug:n.meta.slug,pageUrl:Hi(t,n.meta.slug),documentSeo:Cn(e.draft.draft.metadata),siteSeo:ui(r?.configs.site??null),siteName:t.site?.site.name??``})}function Wi(e,t){let{meta:n}=e;return{collection:n.collection,slug:n.slug,locale:n.locale,version:n.version,live:n.liveVersion!==null,defaultLocale:t.locales!==null&&n.locale===t.locales.defaultLocale}}function Gi(e,t,n){return{saved:!0,admin:e.isAdmin,canEdit:e.canEdit,lockedBy:e.facts.lockedBy,dirty:e.draft.dirty,defaultLocale:n.defaultLocale,defaultLocaleName:t.locales?.defaultLocale??null}}function Ki(e){return e.readOnly?`Read-only: the graph can be browsed and exported, not changed.`:e.schema?.contract.metadata.seo?null:`This content form does not include structured data overrides.`}function qi({ws:e,source:t,document:n,preview:r}){let{fields:i}=e.draft.draft;return(0,M.jsxs)(M.Fragment,{children:[(0,M.jsx)(Si,{preview:r}),(0,M.jsx)(Fi,{preview:r,fields:i,readOnly:e.readOnly,onField:e.setField}),(0,M.jsx)(Ei,{fields:i,pageUrl:Hi(t,n.meta.slug),readOnly:e.readOnly,onField:e.setField}),(0,M.jsx)(Ci,{draft:e.draft.draft,limits:t.site?.seo.limits??null})]})}function Ji(e,t){let{reloadDocument:n}=e;return(0,j.useCallback)(e=>{t(),Lr(e)&&n()},[t,n])}function Yi({ws:e,source:t,document:n,initialGraphOpen:r}){let[i,a]=(0,j.useState)(0),o=Wi(n,t),s=Vi(o,i),c=Ji(e,(0,j.useCallback)(()=>{a(e=>e+1),Nr()},[])),l=s.graph.state===`ready`?s.graph.data:null,{meta:u}=n;return(0,M.jsxs)(M.Fragment,{children:[(0,M.jsx)(qi,{ws:e,source:t,document:n,preview:Ui(e,t,n,l)}),(0,M.jsx)(oi,{initialOpen:r,resolved:s.resolved,graph:s.graph,collection:u.collection,slug:u.slug,version:u.version,readOnly:Ki(e),onStage:t=>e.draft.setMetadata({...e.draft.draft.metadata,seo:t}),draftConfig:e.draft.draft.metadata.seo}),(0,M.jsx)(mi,{rich:s.rich}),(0,M.jsx)($r,{findings:s.findings,version:u.version}),(0,M.jsx)(Kr,{target:{collection:u.collection,slug:u.slug},facts:Gi(e,t,o),onFinished:c})]})}function Xi({seo:e}){return(0,M.jsx)(N,{title:`Structured data`,children:(0,M.jsx)(P,{children:e?`This collection's documents have no page, so they emit no structured data and search engines do not read them.`:`SEO is off on this site: no structured data, previews or findings are made.`})})}function Zi({ws:e,document:t}){let{meta:n}=t;return(0,M.jsx)(Or,{collection:n.collection,slug:n.slug,locale:n.locale,saved:{version:n.version,liveVersion:n.liveVersion},draft:e.draft.draft,unsaved:e.draft.dirty,canRestore:e.isAdmin&&!e.readOnly,onRestored:e.reloadDocument,onPrepare:e.prepareSnapshot})}function Qi({ws:e,source:t,initialGraphOpen:n}){let r=_(f(),`seo`),{document:i}=e;if(!i)return(0,M.jsx)(`div`,{className:`data-mode`,children:(0,M.jsx)(Pt,{icon:Gt,title:`Nothing saved yet`,children:`Data mode reads the saved page: its structured data, findings and history. Save a draft first.`})});let a=t.collection?.pages??!1;return(0,M.jsxs)(`div`,{className:`data-mode`,children:[r&&a?(0,M.jsx)(Yi,{ws:e,source:t,document:i,initialGraphOpen:n}):(0,M.jsx)(Xi,{seo:r}),(0,M.jsx)(Zi,{ws:e,document:i})]})}function $i(e){return e?rt(e):`draft`}function ea(e){if(!e)return`Not saved yet`;let{version:t,liveVersion:n}=e;return n===null?`Draft v${t} · nothing is live`:n>=t?`v${t} is live`:`Draft v${t} · live is v${n}`}function ta(e){return e.canEdit?e.lockedBy?`${e.lockedBy} is editing`:e.busy?`Working…`:e.saved&&!e.dirty&&!e.rebased?`No unsaved changes`:null:`Your role cannot edit`}function na(e){return e.canEdit?e.saved?e.lockedBy?`${e.lockedBy} is editing`:e.busy?`Working…`:e.dirty?`Save the draft first: Publish makes the saved version live`:$i(e.saved)===`live`?`v${e.saved.version} is live`:null:`Save the draft first`:`Your role cannot publish`}function ra(e){return e.lockedBy?`${e.lockedBy} is editing`:e.busy?`Working…`:e.conflict?`Answer the version conflict first`:e.dirty||e.rebased?`Save the draft first`:null}function ia(e){let{version:t,liveVersion:n}=e;return n!==null&&n>=t?`Saved · v${t}. It is live: this store publishes every save.`:n===null?`Draft saved · v${t}. Nothing is live until you publish.`:`Draft saved · v${t}. The live page is unchanged until you publish.`}function aa(e,t){return`Publish ${e} v${t}?`}function oa(e){return e.liveVersion===null?`Nothing is live yet. Visitors will see v${e.version}.`:`Visitors see v${e.liveVersion} now and will see v${e.version}.`}function sa(e){let{collection:t,slug:n,liveVersion:r,preview:i,baseUrl:a}=e,o=t?xt(t,n):null;return!t||o===null?null:i?{kind:`preview`,href:`/api/preview?${new URLSearchParams({collection:t.name,slug:n})}`}:r===null||!a?null:{kind:`live`,href:Ft(a,o)}}function ca(e){let{seo:t,collection:n,slug:r,locale:i,version:a}=e,[o,s]=(0,j.useState)({state:`loading`});return(0,j.useEffect)(()=>{if(!t)return;let e=!0;return s({state:`loading`}),Me(n,r,i).then(t=>e&&s({state:`ready`,...t})).catch(()=>e&&s({state:`error`})),()=>{e=!1}},[t,n,r,i,a]),t?o:{state:`off`}}function la(e,t){return`${e} ${t}${e===1?``:`s`}`}function ua(e){return e.filter(e=>e.severity!==`info`).sort((e,t)=>qr[e.severity].order-qr[t.severity].order)}function da({findings:e,version:t}){if(e.state===`off`)return null;if(e.state===`loading`)return(0,M.jsx)(`p`,{role:`status`,className:`editor-publish-findings`,children:`Checking the page's SEO findings…`});if(e.state===`error`)return(0,M.jsx)(`p`,{className:`editor-publish-findings`,children:`The page's SEO findings could not be read. Publishing still works.`});let n=ua(e.findings);if(n.length===0)return(0,M.jsxs)(`p`,{className:`editor-publish-findings`,children:[`No SEO errors or warnings in v`,t,`.`]});let r=n.filter(e=>e.severity===`error`).length,i=new Map(e.readers.map(e=>[e.id,e.name]));return(0,M.jsxs)(`div`,{className:`editor-publish-findings`,children:[(0,M.jsxs)(`p`,{children:[`SEO findings in v`,t,`: `,la(r,`error`),` ·`,` `,la(n.length-r,`warning`),`. They do not stop publishing.`]}),(0,M.jsx)(`ul`,{className:`editor-findings`,children:n.map((e,t)=>(0,M.jsx)(Jr,{finding:e,reader:e.reader?i.get(e.reader)??e.reader:void 0},`${e.code??e.check}-${e.property??``}-${t}`))})]})}function fa(e,t,n){let[r,i]=(0,j.useState)({state:`loading`});return(0,j.useEffect)(()=>{let r=!0;return st(e,t,n).then(e=>r&&i({state:`ready`,impact:e})).catch(()=>r&&i({state:`error`})),()=>{r=!1}},[e,t,n]),r}function pa({impact:e}){return(0,M.jsxs)(`ul`,{className:`editor-impact`,children:[e.paths.map(e=>(0,M.jsxs)(`li`,{children:[`the page `,(0,M.jsx)(`code`,{children:e})]},e)),e.lists.map(e=>(0,M.jsxs)(`li`,{children:[`the lists of `,g(e).toLowerCase()]},e)),e.everyPageReading&&(0,M.jsx)(`li`,{children:`every page that reads it, as visitors open them`}),e.cachedEntries!==null&&(0,M.jsxs)(`li`,{children:[e.cachedEntries===1?`1 cached entry`:`${e.cachedEntries} cached entries`,` `,`carrying it`]})]})}function ma({impact:e}){return e.state===`loading`?(0,M.jsx)(`p`,{role:`status`,children:`Reading what publishing refreshes…`}):e.state===`error`?(0,M.jsx)(`p`,{children:`What publishing refreshes could not be read. Publishing still works.`}):(0,M.jsxs)(M.Fragment,{children:[(0,M.jsx)(`p`,{children:`Publishing refreshes:`}),(0,M.jsx)(pa,{impact:e.impact})]})}function ha(e){let{collection:t,slug:n,locale:r,saved:i,hasPage:a,busy:o,onConfirm:s,onClose:c}=e,l=fa(t,n,r),u=ca({seo:_(f(),`seo`)&&a,collection:t,slug:n,locale:r,version:i.version}),d=(0,j.useRef)(null);return(0,M.jsxs)(w,{title:aa(n,i.version),onClose:o?()=>void 0:c,initialFocus:d,busy:o,actions:(0,M.jsxs)(M.Fragment,{children:[(0,M.jsx)(y,{onClick:o?void 0:c,"aria-disabled":o,children:`Cancel`}),(0,M.jsx)(y,{ref:d,variant:`primary`,onClick:o?void 0:s,"aria-disabled":o,children:o?`Publishing…`:`Publish`})]}),children:[(0,M.jsx)(`p`,{children:oa(i)}),(0,M.jsx)(ma,{impact:l}),(0,M.jsx)(da,{findings:u,version:i.version})]})}var ga=`A global has no page of its own. Publishing it marks every page that reads it stale; they refresh as visitors open them.`;function _a(){return(0,M.jsxs)(`p`,{className:`globals-banner`,role:`note`,children:[(0,M.jsx)(De,{className:`globals-banner-icon`,"aria-hidden":`true`}),(0,M.jsx)(`span`,{children:ga})]})}function va(e){return`${e===1?`1 cached entry`:`${e} cached entries`} in the site's shared page cache carry it now — pages and data alike, so not a count of pages.`}function ya({impact:e}){let{paths:t,everyPageReading:n,cachedEntries:r}=e;return(0,M.jsxs)(M.Fragment,{children:[t.length>0&&(0,M.jsx)(`ul`,{className:`globals-paths`,"aria-label":`The pages publishing refreshes`,children:t.map(e=>(0,M.jsx)(`li`,{children:(0,M.jsx)(`code`,{children:e})},e))}),n&&(0,M.jsx)(`p`,{className:`globals-rule`,children:`Every page that reads it. krantho knows this rule, not a list of those pages, so none is named here.`}),r!==null&&(0,M.jsx)(P,{children:va(r)})]})}function ba({meta:e}){let t=fa(e.collection,e.slug,e.locale);return(0,M.jsxs)(N,{title:`Pages that read it`,lead:`As far as krantho knows: what publishing it refreshes.`,children:[t.state===`loading`&&(0,M.jsx)(P,{children:`Reading which pages read it…`}),t.state===`error`&&(0,M.jsx)(P,{tone:`error`,children:`Which pages read it could not be read.`}),t.state===`ready`&&(0,M.jsx)(ya,{impact:t.impact})]})}function xa({ws:e}){let{document:t}=e;return(0,M.jsxs)(`div`,{className:`data-mode`,children:[(0,M.jsx)(_a,{}),t?(0,M.jsxs)(M.Fragment,{children:[(0,M.jsx)(ba,{meta:t.meta}),(0,M.jsx)(Zi,{ws:e,document:t})]}):(0,M.jsx)(Pt,{icon:Gt,title:`Nothing saved yet`,children:`Where it appears reads the saved global and its history. Save it first.`})]})}function Sa(){return(0,M.jsx)(`p`,{className:`live-toolbar side-note`,role:`status`,children:`No element of this page carries the document’s marks: edit it in Structure mode.`})}function Ca({marks:e}){return e.length===0?(0,M.jsx)(Sa,{}):(0,M.jsx)(`p`,{className:`live-toolbar side-note`,children:`Click text on the page to edit it. To edit with the keyboard, use Structure.`})}function wa({frame:e,onReload:t}){let{state:n}=e;return n.kind===`ready`?(0,M.jsx)(Ca,{marks:e.marks}):n.kind===`moved`?(0,M.jsxs)(`div`,{className:`live-toolbar live-moved`,role:`alert`,children:[(0,M.jsxs)(`p`,{children:[`The preview moved to `,(0,M.jsx)(`code`,{children:n.path})]}),(0,M.jsx)(y,{size:`sm`,onClick:t,children:`Back to the page`})]}):(0,M.jsx)(`p`,{className:`live-toolbar side-note`,role:`status`,children:`Loading the draft preview…`})}var Ta=`__lead`,Ea=/^##\s+(.+?)\s*#*\s*$/,Da=/^\s*(`{3,}|~{3,})/;function Oa(e){return Da.exec(e)?.[1]}function G(e){let t=[],n=[],r;for(let i of e.split(`
3
+ `)){let e=Oa(i);e&&(!r||e[0]===r[0]&&e.length>=r.length)&&(r=r?void 0:e);let a=r||e?null:Ea.exec(i);if(a?.[1]){n.push({heading:a[1],lines:[]});continue}let o=n.at(-1);o?o.lines.push(i):t.push(i)}return{lead:t.join(`
4
+ `).trim(),sections:n.map(e=>({heading:e.heading,markdown:e.lines.join(`
5
+ `).trim()}))}}function ka(e,t){let n=`sections`in e?e.sections:e,r=t.trim().toLowerCase();return n.find(e=>e.heading.toLowerCase()===r)}var Aa=`data-krantho-document`,ja=`data-krantho-field`,Ma=`data-krantho-section`;Object.freeze({});function Na(e,t){let n={heading:e,markdown:``};return t.some(e=>ka([n],e)!==void 0)}function Pa(e,t){let n=G(e),r=t.map(e=>{let t=ka(n,e);return{name:e,found:t?{heading:t.heading,index:n.sections.indexOf(t)}:null}}),i=n.sections.map((e,t)=>({heading:e.heading,index:t})).filter(e=>!Na(e.heading,t));return{lead:n.lead,designed:r,prose:i,present:r.filter(e=>e.found!==null).length}}function Fa(e){let t=[0];for(let n=e.indexOf(`
6
+ `);n!==-1;n=e.indexOf(`
7
+ `,n+1))t.push(n+1);return t}function Ia(e,t){let n=Fa(e),r=0,i=n.length-1;for(;r<i;){let a=Math.floor((r+i)/2),o=(n[a+1]??e.length+1)-1;G(e.slice(0,o)).sections.length>t?i=a:r=a+1}return n[r]??e.length}function La(e){return e.includes(`\r
8
+ `)?`\r
9
+ `:`
10
+ `}function Ra(e,t,n){return e.trim()===``?`${e}${t}`:`${e}${e.endsWith(`${n}${n}`)?``:e.endsWith(n)?n:`${n}${n}`}${t}`}function za(e,t,n){let{sections:r}=G(e),i=La(e),a=t.slice(t.indexOf(n)+1),o=r.findIndex(e=>Na(e.heading,a));if(o===-1)return{body:Ra(e,`## ${n}${i}`,i),index:r.length};let s=Ia(e,o);return{body:`${e.slice(0,s)}## ${n}${i}${i}${e.slice(s)}`,index:o}}function Ba(e){let t=e.endsWith(`
11
+ `)?e.length-1:e.lastIndexOf(`
12
+ `);return t<0?null:e[t-1]===`\r`?`\r
13
+ `:`
14
+ `}function Va(e,t,n){for(let n of[e,t]){if(n.includes(`\r
15
+ `))return`\r
16
+ `;if(n.includes(`
17
+ `))return`
18
+ `}return Ba(n)??La(n)}function Ha(e,t,n,r){let i=e.slice(t,n),a=i.trim(),o=Va(a,i,e.slice(0,t));if(a===``)return{prefix:e.slice(0,t),text:``,suffix:e.slice(t),eol:o,breakBefore:r};let s=i.length-i.trimStart().length,c=i.length-i.trimEnd().length;return{prefix:e.slice(0,t+s),text:a.replaceAll(`\r
19
+ `,`
20
+ `),suffix:e.slice(n-c),eol:o,breakBefore:r}}function Ua(e,t){let n=G(e).sections.length;if(t<0||t>=n)return null;let r=Ia(e,t),i=e.indexOf(`
21
+ `,r);return Ha(e,i===-1?e.length:i+1,t+1<n?Ia(e,t+1):e.length,i===-1)}function Wa(e){return Ha(e,0,G(e).sections.length>0?Ia(e,0):e.length,!1)}function Ga(e,t){let n=e.eol===`
22
+ `?t:t.replace(/\r?\n/g,`\r
23
+ `);if(n===``)return`${e.prefix}${e.suffix}`;let r=e.breakBefore?e.eol:``,i=e.suffix!==``&&!/^\s/.test(e.suffix)&&!n.endsWith(`
24
+ `);return`${e.prefix}${r}${n}${i?e.eol:``}${e.suffix}`}function Ka(e,t,n){let{sections:r}=G(e),i=r[n];if(i?.heading===t)return{section:i,index:n};let a=r.flatMap((e,n)=>e.heading===t?[n]:[]),[o]=a;if(a.length!==1||o===void 0)return null;let s=r[o];return s?{section:s,index:o}:null}function qa(e){return G(e).lead}function Ja(e){if(typeof Intl.Segmenter==`function`){let t=new Intl.Segmenter(void 0,{granularity:`word`}).segment(e),n=0;for(let e of t)e.isWordLike&&n++;return n}return e.split(/\s+/).filter(e=>/[\p{L}\p{N}]/u.test(e)).length}function Ya(e){return`meta-description-${e}`}function Xa(e){return`sections[${JSON.stringify(e)}]`}function Za(e,t){return`${e}/${t}`}function Qa(e,t){let n=[];for(let r of e.querySelectorAll(`[${Aa}]`)){if(r.getAttribute(`data-krantho-document`)!==t)continue;let e=r.getAttribute(ja),i=r.getAttribute(Ma);e?n.push({element:r,target:{kind:`field`,name:e}}):i===`__lead`?n.push({element:r,target:{kind:`lead`}}):i&&n.push({element:r,target:{kind:`section`,heading:i,occurrence:null}})}return n}function $a(e){return e.ownerDocument.defaultView?.getComputedStyle(e).display===`contents`}function eo(e){if(!e||typeof e!=`object`)return null;let t=e;return typeof t.closest==`function`?e:t.parentElement??null}function to(e,t){return e.getAttribute(`data-krantho-document`)===t?e.hasAttribute(`data-krantho-field`)||e.hasAttribute(`data-krantho-section`):!1}function no(e,t){let n=`[${Aa}]`,r=eo(e)?.closest(n)??null;for(;r&&!to(r,t);)r=r.parentElement?.closest(n)??null;return r}function K(e){return e.kind===`field`?`field:${e.name}`:e.kind===`section`?`section:${e.occurrence??`own`}:${e.heading}`:`lead`}function ro(e){let t=e.filter(e=>e!==null);if(t.length===0)return null;let n=Math.min(...t.map(e=>e.top)),r=Math.min(...t.map(e=>e.left)),i=Math.max(...t.map(e=>e.top+e.height));return{top:n,left:r,width:Math.max(...t.map(e=>e.left+e.width))-r,height:i-n}}function io(e){if($a(e))return ro([...e.children].map(io));let t=e.getBoundingClientRect();return t.width===0&&t.height===0?null:{top:t.top,left:t.left,width:t.width,height:t.height}}function ao(e,t){if(e.kind===`field`)return`field · ${e.name}`;if(e.kind===`lead`)return`section · lead`;let n=Na(e.heading,t)?`designed`:`prose`;return`section · ${e.heading} · ${n}`}function oo(e){let t=new Set,n=new Set;for(let{target:r}of e)r.kind===`field`?t.add(r.name):n.add(r.kind===`lead`?Ta:r.heading);return{fields:t,sections:n}}function so(e,t,n){let r=t.schema.properties?.[e];if(!r)return typeof n.fields[e]==`string`?`text`:`other`;let i=R(r,e);return i===`media`?`media`:i===`text`||i===`textarea`?`text`:`other`}function co(e,t){let n=t.schema.properties?.[e];return n!==void 0&&R(n,e)===`textarea`}function lo(e,t){for(let n of e)n.textContent=t}function uo(e){return Nt.sanitize(Mt.parse(e,{async:!1}))}function fo(e,t,n){e.innerHTML=uo(n!==null&&e.firstElementChild?.tagName===`H2`?`## ${n}\n\n${t}`:t)}var po=3,mo=`http://www.w3.org/1999/xhtml`,ho=new Set([`img`,`input`,`textarea`,`select`,`video`,`audio`,`canvas`,`iframe`,`object`,`embed`]);function go(e){return e.namespaceURI!==mo||ho.has(e.localName)||$a(e)?!1:[...e.childNodes].every(e=>e.nodeType===po)}function _o(e){return e.textContent??``}function vo(e,t){let n=e,r=n.caretPositionFromPoint?.(t.x,t.y);if(r)return{node:r.offsetNode,offset:r.offset};let i=n.caretRangeFromPoint?.(t.x,t.y);return i?{node:i.startContainer,offset:i.startOffset}:null}function yo(e,t){let n=e.ownerDocument,r=n.getSelection();if(!r)return;let i=n.createRange(),a=t?vo(n,t):null;a&&e.contains(a.node)?(i.setStart(a.node,a.offset),i.collapse(!0)):(i.selectNodeContents(e),i.collapse(!1)),r.removeAllRanges(),r.addRange(i)}function bo(e,t,n){let r=e.getAttribute(t);return e.setAttribute(t,n),()=>r===null?e.removeAttribute(t):e.setAttribute(t,r)}function xo(e){let t=bo(e,`contenteditable`,`plaintext-only`);return e.contentEditable===`inherit`?(e.setAttribute(`contenteditable`,`true`),{plain:!1,restore:t}):{plain:!0,restore:t}}function So(e){return e.style.setProperty(`white-space`,`pre-wrap`),()=>{e.style.removeProperty(`white-space`),e.getAttribute(`style`)===``&&e.removeAttribute(`style`)}}function Co(e,t,n){let r=[bo(e,`role`,`textbox`),bo(e,`aria-label`,t),bo(e,`aria-multiline`,String(n))];return()=>{for(let e of r)e()}}function wo(e,t,n){let r=e.ownerDocument,i=r;if(n.plain&&i.execCommand?.(`insertText`,!1,t))return;let a=r.getSelection();if(!a||a.rangeCount===0)return;let o=a.getRangeAt(0);o.deleteContents();let s=r.createTextNode(t);o.insertNode(s),o.setStartAfter(s),o.collapse(!0),a.removeAllRanges(),a.addRange(o),n.onText(_o(e))}function To(e,t){let n=e.clipboardData?.getData(`text/plain`);return n===void 0?null:t?n.replace(/\r\n?/g,`
25
+ `):n.replace(/\s*[\r\n]+\s*/g,` `)}function Eo(e){return e.ownerDocument.activeElement!==e||document.hasFocus()}function Do(e,t,n){let{multiline:r,onText:i,onClose:a,onDismiss:o}=n,s,c={input:()=>i(_o(e)),keydown:n=>{let o=n,s=o.key===`Enter`&&!o.isComposing;(o.key===`Escape`||s)&&(s&&r&&t||(o.preventDefault(),o.stopPropagation(),o.key===`Escape`||!r?a():wo(e,`
26
+ `,{plain:t,onText:i})))},paste:n=>{let a=To(n,r);a!==null&&(n.preventDefault(),wo(e,a,{plain:t,onText:i}))},drop:e=>e.preventDefault(),blur:()=>{s=setTimeout(()=>{Eo(e)&&o()})}};for(let[t,n]of Object.entries(c))e.addEventListener(t,n);return{stop:()=>{clearTimeout(s);for(let[t,n]of Object.entries(c))e.removeEventListener(t,n)}}}function Oo(e,t){let{plain:n,restore:r}=xo(e),i=[r,Co(e,t.label,t.multiline)];t.multiline&&i.push(So(e));let a=Do(e,n,t);return e.focus({preventScroll:!0}),yo(e,t.point),()=>{a.stop(),e.ownerDocument.activeElement===e&&e.blur(),e.textContent=_o(e);for(let e of i)e()}}function ko(e,t){let{sections:n}=G(e),r=e=>n.flatMap((t,n)=>e(t.heading)?[n]:[]),i=r(e=>e===t);if(i.length>0)return i;let a=t.trim().toLowerCase();return r(e=>e.toLowerCase()===a)}function Ao(e,t){let n=e?t.get(e):void 0;if(n&&n.kind!==`field`)return n.kind===`lead`?null:n.heading}function jo(e,t,n){let r=e;Ao(r,n)===null&&(r=r.nextElementSibling);let i=[];for(let e of t){if(!r||Ao(r,n)!==e)return null;i.push(r),r=r.nextElementSibling}return i}function Mo(e,t){let n=new Map;return new Map(e.map((e,r)=>{let i=t[r]??``,a=n.get(i)??0;return n.set(i,a+1),[e,a]}))}function No(e,t){let n=G(t).sections.map(e=>e.heading),r=new Map;for(let{element:t,target:n}of e)n.kind!==`field`&&$a(t)&&r.set(t,n);let i=(n.length===0?[]:[...r.keys()]).map(e=>jo(e,n,r)).filter(e=>e!==null),a=new Set(i.map(e=>e[0])),[o]=i;if(!o||a.size!==1)return[...e];let s=Mo(o,n);return e.map(e=>{let t=s.get(e.element);return t===void 0||e.target.kind!==`section`?e:{element:e.element,target:{...e.target,occurrence:t}}})}function Po(e,t,n){let r=ko(e,t),[i]=r;if(i===void 0)return{kind:`missing`};if(r.length===1)return{kind:`index`,index:i};if(n===null)return{kind:`ambiguous`};let a=r[n];return a===void 0?{kind:`missing`}:{kind:`index`,index:a}}function Fo(e,t){if(t.kind!==`section`)return null;let n=Po(e,t.heading,t.occurrence);return n.kind===`index`?n.index:null}function Io(e,t,n){let r=Fo(n,t),i=K(t);return e.filter(e=>r===null?K(e.target)===i:Fo(n,e.target)===r).map(e=>e.element)}function Lo(e,t,n){let r=e.filter(e=>Fo(t,e.target)===n);return r.find(({target:e})=>e.kind===`section`&&e.occurrence!==null)??r[0]??null}function Ro(e,t,n){let r=Pa(e,t).designed,i=t=>{let r=t.found?Lo(n,e,t.found.index):null;return r&&t.found?{mark:r,heading:t.found.heading}:null},a=e=>e.map(i).find(e=>e!==null)??null;return r.flatMap((e,t)=>{if(e.found)return[];let n=a(r.slice(0,t).reverse());if(n)return[{name:e.name,side:`after`,...zo(n)}];let i=a(r.slice(t+1));return i?[{name:e.name,side:`before`,...zo(i)}]:[{name:e.name,side:`after`,mark:null,neighbour:null}]})}function zo(e){return{mark:e.mark,neighbour:e.heading}}var Bo={kind:`none`};function Vo(e,t){return e.kind===`field`&&t.kind===`field`?e.name===t.name:e.kind===`section`&&t.kind===`section`?e.index===t.index&&e.heading===t.heading&&!e.ambiguous==!t.ambiguous:e.kind===t.kind}function Ho(e,t){let n=e.indexOf(`
27
+ `,Math.max(0,t)),r=G(n===-1?e:e.slice(0,n)).sections,i=r.length-1,a=r[i];return a?{kind:`section`,heading:G(e).sections[i]?.heading??a.heading,index:i}:{kind:`lead`}}function Uo(e){switch(e.kind){case`field`:return`Field · ${e.name}`;case`section`:return`Section · ${e.heading}`;case`lead`:return`Lead`;default:return`Page overview`}}function Wo(e){return e.length===1||e===`Backspace`||e===`Delete`||e===`Enter`}var Go=`The section changed elsewhere; open it again to edit.`,Ko=`The field changed elsewhere; open it again to edit.`;function qo(e,t){if(e.kind===`field`)return{kind:`field`,name:e.name};if(e.kind===`lead`)return{kind:`lead`};let n=Po(t,e.heading,e.occurrence);if(n.kind===`ambiguous`)return{kind:`section`,heading:e.heading,index:-1,ambiguous:!0};let r=n.kind===`index`?n.index:-1;return{kind:`section`,heading:G(t).sections[r]?.heading??e.heading,index:r}}function Jo(e,t){return t.readOnly?!1:e.kind===`field`?so(e.name,t.schema,t.draft)===`text`:e.kind===`lead`||Po(t.draft.body,e.heading,e.occurrence).kind===`index`}function Yo(e,t){return e?.kind===`field`?t.fields[e.name]:t.body}function Xo(e,t,n){let r=t?K(t):null,i=Yo(t,e),a=(0,j.useRef)({key:r,value:i}),o=t?.kind===`field`?Ko:Go;return(0,j.useLayoutEffect)(()=>{let e=a.current;r===null||e.key!==r?a.current={key:r,value:i}:Object.is(i,e.value)||n(o)},[r,i,o,n]),(0,j.useCallback)(e=>{a.current={...a.current,value:e}},[])}function Zo(e,t){let n=e.kind===`none`;(0,j.useEffect)(()=>{n&&t()},[n,t])}function Qo(){let[e,t]=(0,j.useState)(null),[n,r]=(0,j.useState)(null),[i,a]=(0,j.useState)(``);return{selected:e,setSelected:t,edit:n,setEdit:r,notice:i,setNotice:a,closeOnly:(0,j.useCallback)(e=>{r(null),a(e)},[]),clear:(0,j.useCallback)(()=>{t(null),r(null)},[])}}function $o(e,t,n){if(!t.element)return null;if(e.kind!==`field`){let e=t.element.ownerDocument.defaultView;return e&&t.element instanceof e.HTMLElement?{element:t.element,point:t.point}:null}if(!go(t.element))return null;let r=n.fields[e.name];return t.element.textContent===(typeof r==`string`?r:``)?{element:t.element,point:t.point}:null}function es(e,t){return{onBody:n=>{e(n),t.onBody(n)},onField:(n,r)=>{e(r),t.onField(n,r)}}}function ts(e){let t=Qo(),{selected:n,notice:r,closeOnly:i,clear:a}=t,o=t.edit?.target??null,s=(0,j.useRef)(null),c=Xo(e.draft,o,i);Zo(e.selection,a);function l(n,r,i){let a=Jo(n,e);a&&i.element&&i.element===t.edit?.inPlace?.element||(t.setSelected(n),t.setNotice(``),e.onSelect(qo(n,e.draft.body),!a),s.current=r,t.setEdit(a?{target:n,inPlace:$o(n,i,e.draft)}:null))}function u(){a(),e.onSelect(Bo)}let d=()=>{u(),s.current?.focus()},f=(0,j.useCallback)(()=>i(``),[i]);return{selected:n,editing:e.readOnly?null:o,inPlace:e.readOnly?null:t.edit?.inPlace??null,notice:r,pick:l,close:d,dismiss:u,closeFirst:f,...es(c,e)}}function q(e){try{e()}catch{}}function ns(e){try{return e()}catch{return null}}function rs(e){let t=e;try{t=decodeURIComponent(e)}catch{}return t.length>1?t.replace(/\/+$/,``):t}function is(e,t){return rs(e)===rs(t)}function as(e){return e.defaultView?.performance?.getEntriesByType?.(`navigation`)[0]?.responseStatus??0}function os(e,t,n){try{let r=e?.contentDocument??null;if(!r)return{kind:`unreadable`};if(r.URL===`about:blank`&&t!==`about:blank`)return{kind:`blank`};let i=new URL(r.URL).pathname,a=as(r);return r.contentType!==`text/html`||a>=400?{kind:`error`,path:i,status:a}:is(i,n)?{kind:`page`,doc:r}:{kind:`other`,path:i}}catch{return{kind:`unreadable`}}}function ss(e,t){let n=e.kind===`ready`||e.kind===`moved`;switch(t.kind){case`blank`:return e;case`page`:return e.kind===`ready`&&e.doc===t.doc?e:{kind:`ready`,doc:t.doc};case`timeout`:return e.kind===`loading`?{kind:`failed`,why:`timeout`}:e;case`unreadable`:return{kind:`failed`,why:n?`left`:`unreadable`};default:if(!n){let e=t.kind===`error`?t.status:0;return{kind:`failed`,why:`error`,path:t.path,status:e}}return e.kind===`moved`&&e.path===t.path?e:{kind:`moved`,path:t.path}}}function cs(){let e=document.activeElement;return!e||e===document.body||!e.isConnected}function ls(e,t){let n=(0,j.useRef)(!1),r=t.state.kind===`ready`?ns(()=>t.frameRef.current?.contentDocument):null;return(0,j.useEffect)(()=>{let t=t=>{let r=t.target;n.current=r instanceof Node&&(e.current?.contains(r)??!1)};document.addEventListener(`focusin`,t);let i=()=>{n.current=!0};return q(()=>r?.addEventListener(`focusin`,i)),()=>{document.removeEventListener(`focusin`,t),q(()=>r?.removeEventListener(`focusin`,i))}},[e,r]),n}function us(e,t,n,r){let i=ls(e,t),a=`${t.reload}:${t.state.kind}:${n}`,o=(0,j.useRef)(a);(0,j.useLayoutEffect)(()=>{if(a===o.current)return;o.current=a;let n=i.current||r.current;r.current=!1,n&&cs()&&(e.current?.querySelector(`.live-moved button`)??t.frameRef.current)?.focus()},[a,i,r,e,t.frameRef]);let s=t.state.kind===`ready`;(0,j.useEffect)(()=>{let e=t.frameRef.current;s&&e&&document.activeElement===e&&q(()=>e.contentWindow?.focus())},[s,t.frameRef])}function ds(e){let t=(0,j.useRef)(null);return(0,j.useEffect)(()=>{e&&cs()&&t.current?.focus()},[e]),t}function fs(e){let{title:t,detail:n,tried:r,onReload:i,onStructure:a,announce:o=!1}=e,s=ds(o);return(0,M.jsx)(`div`,{className:`live-empty`,role:o?`alert`:void 0,children:(0,M.jsxs)(`div`,{className:`ui-empty-state`,children:[(0,M.jsx)(`span`,{className:`ui-empty-state-icon`,"aria-hidden":`true`,children:(0,M.jsx)(Yt,{})}),(0,M.jsx)(`h2`,{ref:s,tabIndex:-1,className:`ui-empty-state-title`,children:t}),(0,M.jsxs)(`div`,{className:`ui-empty-state-body`,children:[(0,M.jsx)(`p`,{children:n}),r&&(0,M.jsxs)(`p`,{children:[`Tried `,(0,M.jsx)(`code`,{className:`live-empty-url`,children:r})]}),(0,M.jsx)(`p`,{children:`Every field and section can still be edited in Structure mode.`})]}),(0,M.jsxs)(`div`,{className:`ui-empty-state-action`,children:[i&&(0,M.jsx)(y,{icon:Le,onClick:i,children:`Reload the preview`}),(0,M.jsx)(y,{onClick:a,children:`Switch to Structure mode`})]})]})})}var ps=`The preview answered with an error — for example, your sign-in expired. Reload Studio and try again.`;function ms(e,t){let n=`The page preview did not load`;return t===404?{title:`The site has no page for this document`,detail:`${e} answered 404: the site’s page templates do not render this document.`}:t>=400&&t!==401&&t!==403?{title:n,detail:`${e} answered ${t}.`}:{title:n,detail:ps}}function hs(e){if(e.kind===`failed`&&e.why===`error`)return ms(e.path,e.status);let t=e.kind===`failed`?e.why:`unreadable`;if(t===`left`)return{title:`The preview left the page`,detail:`It went to a page Studio cannot read — another site, or the browser’s own error page.`};let n=`The page preview did not load`;return t===`timeout`?{title:n,detail:`The preview took too long to load.`}:{title:n,detail:`Studio cannot read the preview: it did not load, or it is not on this site’s origin.`}}function gs(e){return e.map(e=>({anchor:e,box:e.mark?io(e.mark.element):null}))}function _s(e,t,n){let r=t===`after`?e.top+e.height:e.top,i=Math.max(0,e.left),a=n.width>0?Math.min(e.left+e.width,n.width):e.left+e.width;return{top:r,left:i,width:Math.max(0,a-i)}}function vs({placed:e,layer:t}){let n=e.filter(e=>e.box!==null);return n.length===0?null:(0,M.jsx)(`div`,{className:`live-placeholder-markers`,"aria-hidden":`true`,children:n.map(({anchor:e,box:n})=>(0,M.jsx)(`div`,{className:`live-placeholder-marker`,"data-section":e.name,style:_s(n,e.side,t),children:(0,M.jsx)(`span`,{className:`live-placeholder-marker-tag`,children:`${e.name} · not written`})},e.name))})}function ys(e){return e.neighbour?`${e.side} ${e.neighbour}`:null}function bs({placed:e,readOnly:t,onAdd:n}){return e.length===0?null:(0,M.jsx)(`ul`,{className:`live-missing`,"aria-label":`Designed sections not written`,children:e.map(({anchor:e})=>(0,M.jsxs)(`li`,{className:`live-placeholder`,"data-section":e.name,children:[(0,M.jsxs)(`p`,{children:[e.name,` is in this page's section contract but hasn't been written. The page leaves it out.`,ys(e)&&(0,M.jsxs)(`span`,{className:`live-placeholder-at`,children:[` In the page: `,ys(e),`.`]})]}),(0,M.jsx)(y,{size:`sm`,icon:St,disabled:t,"aria-label":`Add section ${e.name}`,onClick:()=>n(e.name),children:`Add section`})]},e.name))})}var xs=5e3,Ss=50;function Cs(e,t){let n,r=null;q(()=>{let i=e.defaultView;i&&(r=new i.MutationObserver(()=>{n??=setTimeout(()=>{n=void 0,t()},Ss)}),r.observe(e.documentElement,{childList:!0,subtree:!0,attributes:!0,attributeFilter:[Aa,ja,Ma]}))});let i=setTimeout(()=>q(()=>r?.disconnect()),xs);return()=>{clearTimeout(i),n!==void 0&&clearTimeout(n),q(()=>r?.disconnect())}}function J(e,t,n,r={}){return q(()=>e?.addEventListener(t,n,r)),()=>q(()=>e?.removeEventListener(t,n,r))}function ws(e){let t=e;return t.detail>0?{x:t.clientX,y:t.clientY}:null}function Ts(e,t){let n=null,r=()=>e.stillThere();return{over:i=>{if(!r())return;let a=no(i.target,e.documentId);a!==n&&(n=a,e.events.current.onHover(a?t(a):null))},leave:()=>{n=null,e.events.current.onHover(null)},click:n=>{if(!r()||n.target?.closest?.(`.live-markdown-root`))return;let i=no(n.target,e.documentId),a=i?t(i):null;if(!a){e.events.current.onOutsideClick();return}n.preventDefault(),n.stopPropagation(),e.events.current.onPick(a,ws(n))},key:t=>{t.key===`Escape`&&e.events.current.onEscape()}}}function Es(e){let t=[],n=()=>{e.stillThere()&&(q(()=>{t=Qa(e.doc,e.documentId)}),e.onMarks(t),e.moved())},r=e=>t.find(t=>t.element===e)||(n(),t.find(t=>t.element===e)??null);n();let i=Ts(e,r),a=ns(()=>e.doc.defaultView),o=ns(()=>e.doc.documentElement),s=[Cs(e.doc,n),J(e.doc,`mouseover`,i.over),J(o,`mouseleave`,i.leave),J(e.doc,`click`,i.click,{capture:!0}),J(e.doc,`keydown`,i.key),J(e.doc,`scroll`,e.moved,{capture:!0,passive:!0}),J(a,`resize`,e.moved),J(window,`resize`,e.moved)];return{rescan:n,detach:()=>{for(let e of s)e()}}}var Ds=2e4,Os=500;function ks(e){let t=null;return{notify:()=>{t??=requestAnimationFrame(()=>{t=null,e()})},cancel:()=>{t!==null&&cancelAnimationFrame(t)}}}function As(e,t){(0,j.useEffect)(()=>{if(e===null)return;let n=setTimeout(t,Ds);return()=>clearTimeout(n)},[e,t])}var js={kind:`loading`};function Ms(e,t){let{src:n,path:r,reload:i}=e,[a,o]=(0,j.useState)({reload:i,state:js}),s=(0,j.useRef)(i);s.current=i;let c=a.reload===i?a.state:js,l=(0,j.useCallback)(e=>{o(t=>{let n=t.reload===s.current?t.state:js;return{reload:s.current,state:ss(n,e)}})},[]),u=(0,j.useCallback)(()=>l({kind:`timeout`}),[l]);return As(c.kind===`loading`?i:null,u),[c,l,(0,j.useCallback)(()=>l(os(t.current,n,r)),[l,t,n,r])]}function Ns(e,t){let{src:n,path:r,documentId:i,body:a,reload:o}=e,s=(0,j.useRef)(null),[c,l,u]=Ms(e,s),d=(0,j.useCallback)(()=>os(s.current,n,r),[n,r]),f=(0,j.useRef)([]),p=(0,j.useRef)(a);p.current=a;let m=(0,j.useRef)(t);m.current=Ps(t,()=>No(f.current,p.current));let h=Ls({state:c,documentId:i,events:m,look:d,see:l,raw:f});Fs(c,s,d,l);let g=(0,j.useMemo)(()=>No(h.marks,a),[h.marks,a]);return{src:n,reload:o,frameRef:s,state:c,onLoad:u,rescan:h.rescan,marks:g}}function Ps(e,t){let n=e=>t().find(t=>t.element===e.element)??e;return{onHover:t=>e.onHover(t&&n(t)),onPick:(t,r)=>e.onPick(n(t),r),onEscape:e.onEscape,onOutsideClick:e.onOutsideClick}}function Fs(e,t,n,r){let i=e.kind===`moved`;(0,j.useEffect)(()=>{if(!i)return;let e=()=>r(n()),a=setInterval(e,Os),o=J(ns(()=>t.current?.contentWindow),`popstate`,e);return()=>{clearInterval(a),o()}},[i,t,n,r])}function Is(e,t,n){return()=>{let r=t();return r.kind===`page`&&r.doc===e||(n(r),!1)}}function Ls(e){let{state:t,documentId:n,events:r,look:i,see:a,raw:o}=e,[s,c]=(0,j.useState)([]),[,l]=(0,j.useState)(0),u=(0,j.useRef)(()=>void 0);return(0,j.useEffect)(()=>{if(t.kind!==`ready`){o.current=[],c([]);return}let e=ks(()=>l(e=>e+1)),s=Is(t.doc,i,a),d=Es({doc:t.doc,documentId:n,events:r,onMarks:e=>{o.current=e,c(e)},moved:e.notify,stillThere:s});u.current=d.rescan;let f=setInterval(s,Os);return()=>{clearInterval(f),u.current=()=>void 0,d.detach(),e.cancel()}},[t,n,r,i,a,o]),{marks:s,rescan:(0,j.useCallback)(()=>u.current(),[])}}var Rs=20,zs=7;function Bs(e,t,n){return Math.max(t,Math.min(e,n))}function Vs(e,t){return e.left<t.left+t.width&&t.left<e.left+e.width&&e.top<t.top+t.height&&t.top<e.top+e.height}function Hs(e,t,n,r=null){let i=Bs(-e.top,0,Math.max(0,e.height-Rs)),a=e.top>=Rs?-20:i,o=e.top+e.height+Rs<=t.height?e.height:i,s=Math.min(n.length*zs+16,t.width),c=Bs(e.left,0,Math.max(0,t.width-s)),l=[a,i,o].find(t=>r===null||!Vs({top:e.top+t,left:c,width:s,height:Rs},r));return l===void 0?null:{top:l,left:c-e.left,maxWidth:Math.max(s,t.width-c)}}function Us(e,t){let n=t.width-16;return!e||n<=0?null:Math.min(Math.max(e.width,360),n)}function Ws(e,t,n,r=!1){let i=r?Us(e,t):null,a=t.height-16,o=Bs(e?.left??8,8,t.width-8-(i??n.width));if(a>0&&n.height>a)return{top:8,left:o,maxHeight:a,width:i};if(!e||a<=0)return{top:8,left:o,maxHeight:null,width:i};let s=t.height-8-n.height,c=e.top+e.height+8,l=e.top-8-n.height;return{top:Bs(c<=s?c:l>=8?l:c,8,s),left:o,maxHeight:null,width:i}}function Gs(e,t,n){let r=Math.max(0,t.width-16),i=r>0?Math.min(Math.max(e?.width??n.width,200),r):null,a=Ws(e,t,{...n,width:i??n.width});if(!e||t.height<=0)return{...a,width:i};let o=e.top+e.height+5,s=o+n.height<=t.height-8;return{...a,top:s?Math.max(8,o):a.top,width:i}}function Ks(e){let t=`live-outline`;return e===`hovered`?t:e===`selected`?`${t} ${t}--selected`:`${t} ${t}--selected ${t}--editing`}function qs({target:e,elements:t,designed:n,state:r,layer:i,avoid:a}){let o=t.map(io).filter(e=>e!==null),s=ao(e,n),c=Ks(r);return(0,M.jsx)(M.Fragment,{children:o.map((e,t)=>(0,M.jsx)(`div`,{className:c,style:{top:e.top,left:e.left,width:e.width,height:e.height},children:t===0&&r!==`editing`&&(0,M.jsx)(Js,{box:e,layer:i,text:s,avoid:a})},t))})}function Js(e){let t=Hs(e.box,e.layer,e.text,e.avoid);return t?(0,M.jsx)(`span`,{className:`live-tag`,title:e.text,style:t,children:e.text}):null}function Ys(e){if(e.kind===`lead`)return`Introduction`;if(e.kind===`section`)return`${e.heading} section`;if(e.name===`title`)return`Page title`;let t=e.name.replace(/[-_]+/g,` `);return t.charAt(0).toUpperCase()+t.slice(1)}function Xs(e){return e.kind===`field`?`Edit field ${e.name}`:e.kind===`lead`?`Edit the lead`:`Edit section ${e.heading}`}function Zs({props:e,id:t}){let{target:n,draft:r,schema:i,elements:a,onField:o,onPatched:s}=e;if(n.kind!==`field`)return null;let c=r.fields[n.name],l=typeof c==`string`?c:``,u=e=>{o(n.name,e),lo(a,e),s()};return co(n.name,i)?(0,M.jsx)(`textarea`,{id:t,className:`editor-control editor-control--area`,rows:3,value:l,onChange:e=>u(e.target.value)}):(0,M.jsx)(`input`,{id:t,className:`editor-control`,value:l,onChange:e=>u(e.target.value)})}function Qs(e,t){if(e.kind===`lead`)return Wa(t);let n=Fo(t,e);return n===null?null:Ua(t,n)}function $s(e){let[t,n]=(0,j.useState)({width:0,height:0}),[,r]=(0,j.useState)(0);return(0,j.useLayoutEffect)(()=>{let r=e.current;if(!r)return;let i=r.offsetHeight-r.clientHeight,a={width:r.offsetWidth,height:r.scrollHeight+i};(a.width!==t.width||a.height!==t.height)&&n(a)}),(0,j.useEffect)(()=>{let t=e.current;if(!t||typeof ResizeObserver>`u`)return;let n=new ResizeObserver(()=>r(e=>e+1));return n.observe(t),()=>n.disconnect()},[e]),t}function ec(e,t){let{elements:n,stage:r,onPlaced:i}=e,a=(0,j.useRef)(null),o=n[0],s=o?io(o):null,c={width:r?.clientWidth??0,height:r?.clientHeight??0},l=e.target.kind!==`field`,u=e.toolbar?Gs(s,c,t):Ws(s,c,t,l),d=s||!a.current?u:a.current;a.current=d;let f=d.maxHeight??t.height,p=d.width??t.width;return(0,j.useLayoutEffect)(()=>{i({top:d.top,left:d.left,width:p,height:f})},[i,d.top,d.left,p,f]),(0,j.useLayoutEffect)(()=>()=>i(null),[i]),d}function tc(e){let t=(0,j.useId)(),n=(0,j.useRef)(null),{target:r,onClose:i}=e;(0,j.useEffect)(()=>{n.current?.querySelector(`input, textarea, button`)?.focus()},[]);let a=ec(e,$s(n));function o(e){e.key===`Escape`&&(e.preventDefault(),i())}let s={top:a.top,left:a.left,width:a.width??void 0,maxHeight:a.maxHeight??void 0};return(0,M.jsxs)(`div`,{ref:n,className:`live-editor`,style:s,onKeyDown:o,children:[(0,M.jsx)(`label`,{htmlFor:t,className:`live-editor-label`,children:Xs(r)}),(0,M.jsx)(Zs,{props:e,id:t}),(0,M.jsxs)(`div`,{className:`live-editor-actions`,children:[(0,M.jsx)(`span`,{className:`side-note`,children:`Saved with the draft.`}),(0,M.jsx)(y,{size:`sm`,variant:`ghost`,onClick:i,children:`Done`})]})]})}function nc(e){let t=(0,j.useRef)(null),n={kind:`field`,name:e.name},r=ec({...e,target:n,elements:[e.element],toolbar:!0},$s(t)),i=(0,j.useRef)(e);i.current=e;let{name:a,element:o,multiline:s,point:c}=e,l=(0,j.useRef)(o.textContent??``);return(0,j.useEffect)(()=>Oo(o,{label:Xs({kind:`field`,name:a}),multiline:s,point:c,onText:e=>{let{elements:t,onField:n,onPatched:r}=i.current;n(a,e),lo(t.filter(e=>e!==o),e),r()},onClose:()=>i.current.onClose(),onDismiss:()=>{t.current?.contains(document.activeElement)||i.current.onDismiss()}}),[a,o,s,c]),(0,M.jsxs)(`fieldset`,{ref:t,className:`live-context`,"aria-label":`Editing ${Ys(n)}`,style:{top:r.top,left:r.left,width:r.width??void 0,maxHeight:r.maxHeight??void 0},onKeyDown:t=>{t.key===`Escape`&&(t.preventDefault(),e.onClose())},onBlur:t=>{if(t.currentTarget.contains(t.relatedTarget))return;let n=o.ownerDocument.defaultView?.frameElement;(t.relatedTarget!==n||o.ownerDocument.activeElement!==o)&&e.onDismiss()},children:[(0,M.jsxs)(`div`,{children:[(0,M.jsx)(`strong`,{children:Ys(n)}),(0,M.jsx)(`span`,{className:`side-note`,children:`Draft`})]}),(0,M.jsxs)(`div`,{className:`live-context-actions`,children:[(0,M.jsx)(b,{icon:Dt,label:`Cancel this element’s edit`,className:`live-context-cancel`,size:`sm`,onPointerDown:e=>e.preventDefault(),onClick:()=>{e.onField(a,l.current),lo(e.elements,l.current),e.onPatched(),e.onClose()}}),(0,M.jsx)(b,{icon:fe,label:`Done editing`,className:`live-context-done`,size:`sm`,onPointerDown:e=>e.preventDefault(),onClick:e.onClose})]})]})}var rc=(0,j.lazy)(()=>n(()=>import(`./live-markdown-editor-CTvxOTrh.js`).then(e=>({default:e.LiveMarkdownEditor})),__vite__mapDeps([31,1,0,3,4,32,33,6,7,8,9,10,11,12,13,14,34,28,35,36,37,26])));function ic(e){let{frame:t,body:n,designed:r,hovered:i,selected:a,placed:o,size:s,editor:c,inPlace:l}=e,u=(e,t,n)=>(0,M.jsx)(qs,{target:e,elements:t,designed:r,state:n,layer:s,avoid:c});return(0,M.jsxs)(`div`,{className:`live-layer`,"aria-hidden":`true`,children:[(0,M.jsx)(vs,{placed:o,layer:s}),i&&!(l&&a&&K(i.target)===K(a))&&u(i.target,[i.element],`hovered`),a&&u(a,Io(t.marks,a,n),l?`editing`:`selected`)]})}function ac(e){return{width:e?.clientWidth??0,height:e?.clientHeight??0}}function oc(e,t){return e===null||t===null?e===t:e.top===t.top&&e.left===t.left&&e.width===t.width&&e.height===t.height}function sc(){let[e,t]=(0,j.useState)(null);return[e,(0,j.useCallback)(e=>{t(t=>oc(t,e)?t:e)},[])]}function cc({props:e,frame:t,editing:n,target:r,stage:i,onPlaced:a}){let{draft:o,schema:s}=e,c=Io(t.marks,r,o.body),l=n.inPlace?.element,u=l&&c.includes(l)?[l,...c.filter(e=>e!==l)]:c,d={onField:n.onField,onPatched:t.rescan,onClose:n.close};if(r.kind===`field`&&n.inPlace){let{element:e,point:t}=n.inPlace,o=co(r.name,s),c=n.dismiss;return(0,M.jsx)(nc,{stage:i,onPlaced:a,...d,name:r.name,element:e,elements:u,multiline:o,point:t,onDismiss:c},K(r))}return r.kind===`field`?(0,M.jsx)(tc,{...d,target:r,elements:u,stage:i,schema:s,draft:o,onPlaced:a,onBody:n.onBody},K(r)):(0,M.jsx)(j.Suspense,{fallback:(0,M.jsx)(`span`,{className:`live-loading`,role:`status`,children:`Loading editor…`}),children:(0,M.jsx)(rc,{...d,target:r,elements:u,stage:i,schema:s,draft:o,onPlaced:a,onBody:n.onBody},K(r))})}function lc({props:e,frame:t,title:n,hovered:r,editing:i,placed:a}){let o=(0,j.useRef)(null),[s,c]=sc(),{draft:l,designed:u}=e,d=t.state.kind,f=d===`ready`||d===`loading`?i.editing:null,p={frame:t,body:l.body,designed:u,hovered:r,placed:a,editor:s,inPlace:f!==null&&(i.inPlace!==null||f.kind!==`field`)},m={ref:t.frameRef,title:n,src:t.src,onLoad:t.onLoad};return(0,M.jsxs)(`div`,{ref:o,className:`live-stage`,children:[(0,M.jsx)(`iframe`,{className:`live-frame`,...m},t.reload),d===`ready`&&(0,M.jsx)(ic,{...p,selected:i.selected,size:ac(o.current)}),f&&(0,M.jsx)(cc,{props:e,frame:t,editing:i,target:f,stage:o.current,onPlaced:c})]})}function uc(e,t,n){(0,j.useEffect)(()=>{n(e.kind===`ready`?oo(t):null)},[e,t,n]),(0,j.useEffect)(()=>()=>n(null),[n])}function dc(e,t,n){t.closeFirst();let r=za(e.draft.body,e.designed,n);e.onBody(r.body),e.onSelect({kind:`section`,heading:n,index:r.index},!0)}function fc(e,t){let{src:n,path:r,documentId:i,draft:a,reload:o}=e,[s,c]=(0,j.useState)(null),l=ts(e),u=Ns({src:n,path:r,documentId:i,body:a.body,reload:o},{onHover:c,onPick:(e,t)=>l.pick(e.target,u.frameRef.current,{element:e.element,point:t}),onEscape:l.dismiss,onOutsideClick:l.dismiss});(0,j.useEffect)(()=>{if(!l.editing)return;let e=e=>{let t=e.target;t instanceof Element&&(t.closest(`.live-editor, .live-context`)||t===u.frameRef.current||l.dismiss())};return document.addEventListener(`pointerdown`,e,!0),()=>document.removeEventListener(`pointerdown`,e,!0)},[l.editing,l.dismiss,u.frameRef]),uc(u.state,u.marks,e.onFound);let d=u.state.kind===`moved`||u.state.kind===`failed`,f=l.inPlace?.element,p=f!==void 0&&!u.marks.some(e=>e.element===f),{closeFirst:m}=l;return(0,j.useEffect)(()=>{(d||p)&&m()},[d,p,m]),us(t,u,l.editing!==null,e.focusRequested),{editing:l,frame:u,hovered:u.state.kind===`ready`&&s&&u.marks.some(e=>e.element===s.element)?s:null}}function pc(e){let{src:t,documentId:n,designed:r,draft:i,onReload:a,onStructure:o}=e,s=(0,j.useRef)(null),{editing:c,frame:l,hovered:u}=fc(e,s);if(l.state.kind===`failed`){let e=hs(l.state);return(0,M.jsx)(fs,{...e,tried:t,onReload:a,onStructure:o,announce:!0})}let d=gs(l.state.kind===`ready`?Ro(i.body,r,l.marks):[]),f=`Draft preview of ${n}`;return(0,M.jsxs)(`div`,{ref:s,className:`live-mode`,children:[(0,M.jsx)(wa,{frame:l,onReload:a}),(0,M.jsx)(`p`,{className:`live-notice side-note`,role:`status`,children:c.notice}),(0,M.jsx)(lc,{props:e,frame:l,title:f,editing:c,placed:d,hovered:u}),(0,M.jsx)(bs,{placed:d,readOnly:e.readOnly,onAdd:t=>dc(e,c,t)})]})}function mc(e){let[t,n]=(0,j.useState)(0),r=(0,j.useRef)(e),i=(0,j.useRef)(!1);return(0,j.useEffect)(()=>{r.current!==null&&e!==r.current&&n(e=>e+1),r.current=e},[e]),{reload:t,onReload:(0,j.useCallback)(()=>{i.current=!0,n(e=>e+1)},[]),focusRequested:i}}function hc(e){let t=mc(e.savedVersion),{preview:n,slug:r,onStructure:i}=e;if(n.src===null||r===null){let e=n.src===null?n.title:`The document has no page yet`,t=n.src===null?n.detail:`Save it first.`;return(0,M.jsx)(fs,{title:e,detail:t,onStructure:i})}return(0,M.jsx)(pc,{...e,...t,src:n.src,path:n.path,documentId:Za(e.collection,r)})}function gc(e,t){return{src:null,title:e,detail:t}}function _c(e){let{collection:t,slug:n,locale:r,defaultLocale:i,sitePreview:a,canEdit:o}=e;if(n===null)return gc(`The document has no page yet`,`Save it first.`);if(!a)return gc(`The site does not render drafts for editors`,`Live mode needs the site’s draft preview (sitePreview).`);if(!o)return gc(`Your role cannot open the draft preview.`,`The preview is for editors.`);if(r===null||r!==i)return gc(`The site’s preview has no locale`,`Live mode previews the site’s default-locale page; the site’s preview has no locale. Edit ${r??`this version`} in Structure mode.`);let s=sa({collection:t,slug:n,liveVersion:null,preview:!0,baseUrl:null}),c=t?xt(t,n):null;return s?.kind!==`preview`||c===null?gc(`This collection renders no pages`,`There is no page to show.`):{src:s.href,path:c}}function vc({ws:e,slot:t}){let[n,r]=(0,j.useState)([]),[i,a]=(0,j.useState)([]),[o,s]=(0,j.useState)(``),[c,l]=(0,j.useState)(``),[u,d]=(0,j.useState)(null),[f,p]=(0,j.useState)(!1),[m,h]=(0,j.useState)(null),g=e.document?.meta,_=e.schema.contract.metadata[t];if(!g||!_)return null;async function v(e){p(!0),h(null);try{await e()}catch(e){h(E(e,`Shared defaults could not be read`))}finally{p(!1)}}async function b(e){if(s(e),l(``),d(null),!e){a([]);return}let t=await Ze(e,{locale:g?.locale});a(t.items)}async function x(n){if(!g||e.draft.dirty)return;let r=await Ue(`/content/${encodeURIComponent(g.collection)}/${encodeURIComponent(g.slug)}/defaults`,{method:`POST`,body:JSON.stringify({sourceCollection:o,slots:[t],sourceSlug:c,locale:g.locale,apply:n,_version:u?.version??g.version,sourceVersion:u?.sourceVersion})});n?(d(null),await e.reloadDocument()):d(r)}return(0,M.jsxs)(`details`,{className:`metadata-defaults`,onToggle:e=>{e.currentTarget.open&&!n.length&&v(async()=>r(await ct()))},children:[(0,M.jsx)(`summary`,{children:`Copy from another page`}),(0,M.jsx)(`p`,{children:`Review details to copy from a shared document. Saved snapshots keep their copied values.`}),e.draft.dirty&&(0,M.jsx)(`p`,{children:`Save your draft before applying shared defaults.`}),(0,M.jsxs)(`fieldset`,{disabled:e.readOnly||f||e.draft.dirty,className:`metadata-defaults-fields`,children:[(0,M.jsxs)(`label`,{children:[`Source collection`,(0,M.jsxs)(`select`,{className:`editor-control`,value:o,onChange:e=>{v(()=>b(e.target.value))},children:[(0,M.jsx)(`option`,{value:``,children:`Choose collection`}),n.map(e=>(0,M.jsx)(`option`,{value:e.name,children:e.name},e.name))]})]}),(0,M.jsxs)(`label`,{children:[`Source document`,(0,M.jsxs)(`select`,{className:`editor-control`,value:c,onChange:e=>l(e.target.value),children:[(0,M.jsx)(`option`,{value:``,children:`Choose document`}),i.map(e=>(0,M.jsx)(`option`,{value:e.meta.slug,children:String(e.fields.title??e.meta.slug)},e.meta.slug))]})]}),(0,M.jsx)(y,{size:`sm`,disabled:!c,onClick:()=>{v(()=>x(!1))},children:`Review defaults`})]}),m&&(0,M.jsx)(`p`,{role:`alert`,children:m}),u&&(0,M.jsxs)(w,{title:`Review shared defaults`,onClose:()=>d(null),actions:(0,M.jsxs)(M.Fragment,{children:[(0,M.jsx)(y,{onClick:()=>d(null),children:`Cancel`}),(0,M.jsx)(y,{disabled:f||e.readOnly||e.draft.dirty||!u.paths.length,onClick:()=>{v(()=>x(!0))},children:`Apply to draft`})]}),children:[(0,M.jsx)(`p`,{children:u.paths.length?`${u.paths.length} ${u.paths.length===1?`value`:`values`} will be copied from snapshot v${u.sourceVersion}. Your authored overrides stay.`:`No missing or inherited values need updating.`}),m&&(0,M.jsx)(`p`,{role:`alert`,children:m}),(0,M.jsx)(U,{contract:{...e.schema.contract,metadata:{[t]:_}},metadata:u.metadata[t]?{[t]:u.metadata[t]}:{},fields:e.draft.draft.fields,readOnly:!0,errors:{},onMetadata:()=>{}})]})]})}function yc(e,t){return e===0?`missing`:e<t.minChars?`under`:e>t.maxChars?`over`:`within`}function bc(e,t){return e===0?`missing`:e>t?`over`:`within`}var xc={missing:`muted`,under:`ahead`,within:`live`,over:`danger`};function Sc(e,t,n){return{segments:[{value:e,tone:xc[t]}],max:Math.max(n,e)}}function Cc(e,t){switch(e){case`missing`:return`none`;case`under`:return`under the target`;case`over`:return t===`range`?`over the target`:`over the limit`;default:return t===`range`?`within the target`:`within the limit`}}function wc(e,t,n,r){let i=r.has(`meta-description`)?`meta-description`:null,a=[];if(e.source===null){let e=i??(r.has(`description`)?`description`:null);a.push({text:`No meta description: search engines pick text from the page.`,field:e})}if(e.source===`description`&&a.push(i?{text:`Search results show the description. Write a meta description of its own.`,field:i}:{text:`Search results show the description: this collection has no meta-description field.`,field:null}),t===`over`&&e.source){let t=`The meta description is ${e.text.length} characters; search results cut it near ${n.maxChars}.`;a.push({text:t,field:r.has(e.source)?e.source:null})}return a}function Tc(e){return e.kind===`range`?`target ${e.min}–${e.max}`:`limit ${e.max}`}function Ec({label:e,length:t,state:n,target:r,note:i}){let{segments:a,max:o}=Sc(t,n,r.max);return(0,M.jsxs)(`div`,{className:`side-length side-length--${n}`,"data-length-state":n,children:[(0,M.jsxs)(`div`,{className:`side-length-head`,children:[(0,M.jsx)(`span`,{className:`side-length-label`,children:e}),(0,M.jsxs)(`span`,{className:`side-length-figure`,children:[t,` chars · `,Tc(r)]})]}),(0,M.jsx)(Rt,{segments:a,max:o}),(0,M.jsx)(`span`,{className:`side-length-state`,children:Cc(n,r.kind)}),i&&(0,M.jsx)(`span`,{className:`side-length-note`,children:i})]})}function Y({title:e,summary:t,children:n}){let r=(0,j.useId)();return e===void 0?(0,M.jsxs)(`div`,{className:`side-card`,children:[t&&(0,M.jsx)(`div`,{className:`side-card-head`,children:t}),n]}):(0,M.jsxs)(`section`,{className:`side-card`,"aria-labelledby":r,children:[(0,M.jsxs)(`div`,{className:`side-card-head`,children:[(0,M.jsx)(`h3`,{id:r,className:`side-card-title`,children:e}),t]}),n]})}function X({label:e,children:t}){return(0,M.jsxs)(`div`,{className:`side-fact`,children:[(0,M.jsx)(`dt`,{children:e}),(0,M.jsx)(`dd`,{children:t})]})}function Z({children:e}){return(0,M.jsx)(`p`,{className:`side-note`,children:e})}function Dc(e){let[t,n]=(0,j.useState)({state:`loading`});return(0,j.useEffect)(()=>{let t=!0;return n({state:`loading`}),qe(e).then(e=>t&&n({state:`ready`,item:e})).catch(()=>t&&n({state:`missing`})),()=>{t=!1}},[e]),[t,e=>n({state:`ready`,item:e})]}function Oc({item:e,disabled:t,onReplaced:n}){let r=(0,j.useRef)(null),{busy:i,run:a}=ve(e,n);return(0,M.jsxs)(M.Fragment,{children:[(0,M.jsx)(`input`,{ref:r,type:`file`,accept:`image/*`,hidden:!0,onChange:e=>{let t=e.target.files?.[0];e.target.value=``,t&&a(t)}}),(0,M.jsx)(y,{size:`sm`,icon:ye,disabled:t||i,onClick:()=>r.current?.click(),children:i?`Replacing…`:`Replace`})]})}function kc({item:e,disabled:t,onSaved:n}){let r=(0,j.useId)(),[i,a]=(0,j.useState)(e.altText);(0,j.useEffect)(()=>a(e.altText),[e.altText]);let{busy:o,run:s}=me(e,n),c=o||i===e.altText;return(0,M.jsxs)(`div`,{className:`side-field`,children:[(0,M.jsx)(`label`,{htmlFor:r,className:`side-field-label`,children:`Alt text`}),(0,M.jsx)(`input`,{id:r,className:`editor-control`,value:i,disabled:t,"aria-describedby":`${r}-note`,onChange:e=>a(e.target.value)}),(0,M.jsx)(`p`,{id:`${r}-note`,className:`side-note`,children:`Saved on the media file at once, for every page that uses it — not in this draft.`}),(0,M.jsx)(Ac,{disabled:t,unchanged:c,busy:o,onSave:()=>void s(i)})]})}function Ac(e){return(0,M.jsx)(y,{size:`sm`,disabled:e.disabled,"aria-disabled":e.unchanged,onClick:e.unchanged?void 0:e.onSave,children:e.busy?`Saving…`:`Save alt text`})}function jc({id:e,readOnly:t}){return _(f(),`media`)?t?(0,M.jsx)(y,{size:`sm`,icon:ge,disabled:!0,children:`Crop & hotspot`}):(0,M.jsxs)(c,{to:et(e),className:v(`secondary`,`sm`),children:[(0,M.jsx)(ge,{className:`ui-button-icon`,"aria-hidden":`true`}),`Crop & hotspot`]}):null}function Mc({id:e,readOnly:t}){let[n,r]=Dc(e);if(n.state===`loading`)return(0,M.jsx)(Z,{children:`Reading the media file…`});if(n.state===`missing`)return(0,M.jsxs)(Z,{children:[`Media `,e,` was not found.`]});let{item:i}=n;return(0,M.jsxs)(`div`,{className:`side-media`,children:[(0,M.jsx)(`p`,{className:`side-media-name`,children:i.filename}),(0,M.jsxs)(`div`,{className:`side-actions`,children:[(0,M.jsx)(jc,{id:i.id,readOnly:t}),(0,M.jsx)(Oc,{item:i,disabled:t,onReplaced:r})]}),(0,M.jsx)(Z,{children:`Replacing keeps the id, so pages update without a content change.`}),(0,M.jsx)(kc,{item:i,disabled:t,onSaved:r},i.id)]})}function Nc(e){return Object.keys(e.schema.properties??{})}function Pc(e,t){return e.seoReadsFields?Fn(Nc(e.schema)).get(t)??`No SEO output`:`Nothing: SEO does not read this document`}function Fc(e,t,n){if(!t.fields.has(n))return`Not found marked by Live mode`;let r=so(n,e.schema,e.draft);return r===`media`?`Found by Live mode; media changes after Save`:e.readOnly?`Found by Live mode; read-only`:r===`other`?`Found by Live mode; not a text field: edit it in Structure mode`:`Found by Live mode: editable in place`}function Ic(e,t){return t===e?`Search results show this field.`:t===null?`Neither meta-description nor description is set.`:e===`description`?`The fallback: search results show meta-description while it is set.`:`Empty, so search results fall back to description.`}function Lc({doc:e,name:t,limits:n}){let{fields:r}=e.draft;if(t===`meta-description`||t===`description`){let e=Ee(r),{minChars:i,maxChars:a}=n.metaDescription;return(0,M.jsx)(Ec,{label:`Meta description, effective`,length:e.text.length,state:yc(e.text.length,n.metaDescription),target:{kind:`range`,min:i,max:a},note:Ic(t,e.source)})}if(I(Nc(e.schema)).title!==t)return null;let i=r[t],a=typeof i==`string`?i.length:0;return(0,M.jsx)(Ec,{label:`Title`,length:a,state:bc(a,n.title.maxChars),target:{kind:`limit`,max:n.title.maxChars}})}function Rc({doc:e,name:t}){let n=e.draft.fields[t],r=typeof n==`string`?n:``;return r?(0,M.jsx)(Mc,{id:r,readOnly:e.readOnly}):(0,M.jsx)(Z,{children:`No file chosen. Choose one in the form.`})}function zc({doc:e,name:t}){let n=(e.schema.schema.properties??{})[t],r=(e.schema.schema.required??[]).includes(t);return(0,M.jsxs)(Y,{summary:(0,M.jsx)(k,{children:r?`required`:`optional`}),children:[(0,M.jsxs)(`dl`,{className:`side-facts`,children:[(0,M.jsx)(X,{label:`Type`,children:n?(0,M.jsx)(`code`,{children:An(n,t)}):`Not in the schema (custom field)`}),(0,M.jsx)(X,{label:`Required`,children:r?`Yes`:`No`}),(0,M.jsx)(X,{label:`Read by`,children:Pc(e,t)}),e.live&&(0,M.jsx)(X,{label:`On the page`,children:Fc(e,e.live,t)})]}),e.seoReadsFields&&e.limits&&(0,M.jsx)(Lc,{doc:e,name:t,limits:e.limits}),n&&R(n,t)===`media`&&(0,M.jsx)(Rc,{doc:e,name:t})]})}function Bc({doc:e,onSelect:t}){let n=e.schema.schema.properties??{},r=Object.keys(n).filter(e=>!wn.has(e));return(0,M.jsxs)(Y,{title:`Fields`,children:[(0,M.jsx)(Z,{children:`The form is read-only. Choose a field to see what reads it.`}),(0,M.jsx)(`ul`,{className:`side-rows`,"aria-label":`Fields`,children:r.map(e=>(0,M.jsx)(`li`,{children:(0,M.jsxs)(`button`,{type:`button`,className:`side-row`,onClick:()=>t({kind:`field`,name:e}),children:[(0,M.jsx)(`span`,{className:`side-row-name`,children:e}),` `,(0,M.jsx)(`span`,{className:`side-row-state`,children:An(n[e]??{},e)})]})},e))})]})}var Vc=[];function Hc({found:e,onSelect:t}){return(0,M.jsx)(`li`,{children:(0,M.jsxs)(`button`,{type:`button`,className:`side-row`,onClick:()=>t({kind:`section`,...e}),children:[(0,M.jsx)(`span`,{className:`side-row-name`,children:e.heading}),` `,(0,M.jsxs)(`span`,{className:`side-row-state`,children:[(0,M.jsx)(D,{className:`side-row-icon side-row-icon--present`,"aria-hidden":`true`}),`present`]})]})})}function Uc({name:e,readOnly:t,onAdd:n}){return(0,M.jsx)(`li`,{children:(0,M.jsxs)(`button`,{type:`button`,className:`side-row side-row--missing`,disabled:t,onClick:()=>n(e),children:[(0,M.jsx)(`span`,{className:`side-row-name`,children:e}),` `,(0,M.jsxs)(`span`,{className:`side-row-state`,children:[(0,M.jsx)(St,{className:`side-row-icon`,"aria-hidden":`true`}),`Add section`]})]})})}function Wc({row:e,readOnly:t,onSelect:n,onAdd:r}){return e.found?(0,M.jsx)(Hc,{found:e.found,onSelect:n}):(0,M.jsx)(Uc,{name:e.name,readOnly:t,onAdd:r})}function Gc({name:e,state:t,onClick:n}){return(0,M.jsx)(`li`,{children:(0,M.jsxs)(`button`,{type:`button`,className:`side-row`,onClick:n,children:[(0,M.jsx)(`span`,{className:`side-row-name`,children:e}),` `,(0,M.jsx)(`span`,{className:`side-row-state`,children:t})]})})}function Kc({parts:e,readOnly:t,onSelect:n,onAdd:r}){return(0,M.jsxs)(`ul`,{className:`side-rows`,"aria-label":`Sections`,children:[e.lead!==``&&(0,M.jsx)(Gc,{name:`Lead`,state:`before first ##`,onClick:()=>n({kind:`lead`})}),e.designed.map(e=>(0,M.jsx)(Wc,{row:e,readOnly:t,onSelect:n,onAdd:r},e.name)),e.prose.map(e=>(0,M.jsx)(Gc,{name:e.heading,state:`prose`,onClick:()=>n({kind:`section`,...e})},`${e.index}-${e.heading}`))]})}function qc({doc:e,onSelect:t}){let n=e.info?.sections??Vc,{body:r}=e.draft,i=(0,j.useMemo)(()=>Pa(r,n),[r,n]);function a(i){let a=za(r,n,i);e.onBody(a.body),t({kind:`section`,heading:i,index:a.index})}let o=(0,M.jsx)(k,{tone:`accent`,children:`${i.present} / ${n.length} designed`});return(0,M.jsxs)(Y,{title:`Page & sections`,summary:o,children:[n.length===0&&(0,M.jsx)(Z,{children:`The page template designs no sections, so each renders as prose.`}),(0,M.jsx)(Kc,{parts:i,readOnly:e.readOnly,onSelect:t,onAdd:a})]})}function Jc(e,t){let{collection:n,slug:r,defaultLocale:i}=e;return ot(n,r,t===i?void 0:t)}function Yc(e,t,n){let[r,i]=(0,j.useState)(!1),[a,o]=(0,j.useState)(null),s=l(),c=T(),u=t.toUpperCase();async function d(){i(!0),o(null);try{await n(t),c({text:`${u} draft created from ${e.defaultLocale.toUpperCase()}.`}),s(Jc(e,t))}catch(e){o(E(e,`The ${u} draft could not be created`)),i(!1)}}return{busy:r,error:a,confirm:d}}function Xc({busy:e,confirmRef:t,onCancel:n,onConfirm:r}){return(0,M.jsxs)(M.Fragment,{children:[(0,M.jsx)(y,{onClick:e?void 0:n,"aria-disabled":e,children:`Cancel`}),(0,M.jsx)(y,{ref:t,variant:`primary`,onClick:e?void 0:r,"aria-disabled":e,children:e?`Creating…`:`Create draft`})]})}function Zc({locale:e,props:t,create:n,onClose:r}){let{busy:i,error:a,confirm:o}=Yc(t,e,n),s=(0,j.useRef)(null),c=e.toUpperCase(),l=(0,M.jsx)(Xc,{busy:i,confirmRef:s,onCancel:r,onConfirm:()=>void o()});return(0,M.jsxs)(w,{title:`Create the ${c} draft of ${t.slug}?`,onClose:i?()=>void 0:r,initialFocus:s,busy:i,actions:l,children:[(0,M.jsxs)(`p`,{children:[`Copies the `,t.defaultLocale.toUpperCase(),` version's fields and body into a new `,c,` `,`draft with its own history. Nothing is published.`]}),a&&(0,M.jsx)(`p`,{className:`editor-modal-error`,role:`alert`,children:a})]})}function Qc({locale:e,note:t}){let n=e.toUpperCase();return(0,M.jsxs)(`span`,{className:C(`neutral`,`editor-locale editor-locale--quiet`),title:t,"data-locale":e,children:[(0,M.jsx)(`span`,{"aria-hidden":`true`,children:n}),(0,M.jsxs)(`span`,{className:`visually-hidden`,children:[n,`: `,t]})]})}function $c({locale:e,onCreate:t}){let n=e.toUpperCase();return(0,M.jsxs)(`button`,{type:`button`,"data-locale":e,className:C(`neutral`,`editor-locale editor-locale--missing`),"aria-label":`Create ${n} draft`,onClick:t,children:[(0,M.jsx)(St,{className:`ui-chip-icon`,"aria-hidden":`true`}),n]})}function el({props:e,locale:t,state:n,onCreate:r}){let i=t.toUpperCase(),a=t===e.current;return!a&&n===void 0?(0,M.jsx)(Qc,{locale:t,note:`checking`}):!a&&n===`unknown`?(0,M.jsx)(Qc,{locale:t,note:`whether this version exists could not be checked`}):!a&&n===`missing`?e.canCreate?(0,M.jsx)($c,{locale:t,onCreate:r}):null:(0,M.jsx)(c,{to:Jc(e,t),className:C(a?`accent`:`neutral`,`editor-locale`),"aria-current":a?`true`:void 0,"aria-label":`${i} version`,"data-locale":t,children:i})}function tl(e,t){let[n,r]=(0,j.useState)(null);return(0,j.useEffect)(()=>{if(t!==null||n===null)return;r(null);let i=document.activeElement;if(i&&i!==document.body&&i.isConnected)return;let a=e.current?.querySelector(`[data-locale="${n}"]`);(a&&a.tabIndex>=0?a:e.current)?.focus()},[t,n,e]),r}function nl(e){let{collection:t,slug:n,locales:r,defaultLocale:i}=e,a=zt(t,n,r,i),[o,s]=(0,j.useState)(null),c=(0,j.useRef)(null),l=tl(c,o);if(r.length<2)return null;let u=e=>{l(e),s(null)};return(0,M.jsxs)(`div`,{ref:c,className:`editor-locales`,role:`group`,"aria-label":`Locales`,tabIndex:-1,children:[r.map(t=>(0,M.jsx)(el,{props:e,locale:t,state:a.states?.get(t),onCreate:()=>s(t)},t)),o&&(0,M.jsx)(Zc,{locale:o,props:e,create:a.create,onClose:()=>u(o)})]})}function rl({target:e,locale:t,current:n,status:r,versions:i,canCreate:a,onCreate:o}){let s=t.toUpperCase(),l=n?`exists`:i.states?.get(t);return(0,M.jsxs)(`li`,{className:`side-locale`,"data-locale":t,children:[l===`exists`?(0,M.jsx)(c,{to:Jc(e,t),"aria-current":n?`true`:void 0,children:s}):(0,M.jsx)(`span`,{className:`side-locale-name`,children:s}),(0,M.jsx)(il,{state:l,status:r}),l===`missing`&&a&&(0,M.jsx)(y,{size:`sm`,"aria-label":`Create draft in ${s}`,onClick:o,children:`Create draft`})]})}function il({state:e,status:t}){return e===`exists`&&t?(0,M.jsxs)(`span`,{className:`side-locale-state`,children:[(0,M.jsx)(At,{status:t,decorative:!0}),gt[t]]}):(0,M.jsx)(`span`,{className:`side-locale-state side-locale-state--quiet`,children:e===`missing`?`Missing`:e===`unknown`?`Could not be checked`:`Checking…`})}function al({meta:e,locales:t,versions:n,canCreate:r,onCreate:i}){let a={collection:e.collection,slug:e.slug,defaultLocale:t.defaultLocale};return(0,M.jsx)(`ul`,{className:`side-locales`,"aria-label":`Locales`,children:t.supportedLocales.map(t=>{let o=t===e.locale;return(0,M.jsx)(rl,{target:a,locale:t,current:o,status:o?rt(e):n.statuses?.get(t)??null,versions:n,canCreate:r,onCreate:()=>i(t)},t)})})}function ol({meta:e,locales:t,canCreate:n}){let{supportedLocales:r,defaultLocale:i}=t,a=zt(e.collection,e.slug,r,i),[o,s]=(0,j.useState)(null);return(0,M.jsxs)(M.Fragment,{children:[(0,M.jsx)(al,{meta:e,locales:t,versions:a,canCreate:n,onCreate:s}),o&&(0,M.jsx)(Zc,{locale:o,props:{collection:e.collection,slug:e.slug,defaultLocale:i},create:a.create,onClose:()=>s(null)})]})}function sl({meta:e}){let t=fa(e.collection,e.slug,e.locale);return t.state===`loading`?(0,M.jsx)(Z,{children:`Reading what publishing refreshes…`}):t.state===`error`?(0,M.jsx)(Z,{children:`What publishing refreshes could not be read.`}):(0,M.jsxs)(`div`,{className:`side-refreshes`,children:[(0,M.jsx)(`p`,{className:`side-subtitle`,children:`Publishing refreshes`}),(0,M.jsx)(pa,{impact:t.impact})]})}function cl({doc:e}){let{meta:t,locales:n}=e;return t?(0,M.jsxs)(Y,{title:`Reach`,children:[n?(0,M.jsx)(ol,{meta:t,locales:n,canCreate:e.canEdit}):(0,M.jsx)(Z,{children:`The site's locales could not be read.`}),e.info?.pages&&(0,M.jsx)(sl,{meta:t})]}):(0,M.jsx)(Y,{title:`Reach`,children:(0,M.jsx)(Z,{children:`Save the page first: its locale versions follow.`})})}var ll={document:{},site:{}};async function ul(e){try{return ui(await Li(e))}catch{return{}}}function dl(e,t){let[n,r]=(0,j.useState)(ll),i=Pr();return(0,j.useEffect)(()=>{let n=!0;return Promise.all([t===null?Promise.resolve({}):ul(`doc:${e}/${t}`),ul(`site`)]).then(([e,t])=>{n&&r({document:e,site:t})}),()=>{n=!1}},[e,t,i]),n}function fl(e){let{collection:t,slug:n,fields:r}=e,i=dl(t,n);return si({fields:r,slug:n??``,pageUrl:null,documentSeo:i.document,siteSeo:i.site,siteName:``}).social.image}function pl(e){let t=Cn(e.draft.metadata).description;return typeof t==`string`&&t.trim()?{text:t,source:`metadata`}:Ee(e.draft.fields)}function ml(e,t){let n=Cn(e.draft.metadata),r=n.headline??n.name;return typeof r==`string`&&r.trim()?r:L(I(t),`title`,e.draft.fields)}function hl(e){return[...new Set([...Nc(e.schema),...Object.keys(e.draft.fields)])]}function gl(e){let{meta:t,limits:n,label:r}=e,{minChars:i,maxChars:a}=n.metaDescription,o=t.source===`metadata`?`Your own search description`:t.source===`description`?`Falls back to description`:t.source===null?`Neither meta-description nor description is set`:`From meta-description`;return(0,M.jsx)(Ec,{label:r,length:t.text.length,state:yc(t.text.length,n.metaDescription),target:{kind:`range`,min:i,max:a},note:o})}function _l(e){let{title:t,limits:n,label:r}=e;return(0,M.jsx)(Ec,{label:r,length:t.length,state:bc(t.length,n.title.maxChars),target:{kind:`limit`,max:n.title.maxChars}})}function vl({doc:e}){let t=fl({collection:e.collection,slug:e.meta?.slug??null,fields:{...e.draft.fields,...Cn(e.draft.metadata)}});return(0,M.jsx)(X,{label:`Social image`,children:t?(0,M.jsxs)(M.Fragment,{children:[`Set `,(0,M.jsx)(`code`,{children:t})]}):`None`})}function yl({advice:e,readOnly:t,onEditField:n}){return e.length===0?null:(0,M.jsx)(`ul`,{className:`side-advice`,children:e.map(e=>(0,M.jsxs)(`li`,{children:[(0,M.jsx)(`span`,{children:e.text}),e.field&&!t&&(0,M.jsx)(`button`,{type:`button`,className:`side-link`,"aria-label":`Edit ${e.field}`,onClick:()=>e.field&&n(e.field),children:`Edit`})]},e.text))})}function bl({doc:e,limits:t,names:n,onEditField:r}){let i=pl(e),a=new Set(Nc(e.schema)),o=yc(i.text.length,t.metaDescription);return(0,M.jsxs)(M.Fragment,{children:[(0,M.jsx)(gl,{meta:i,limits:t,label:`Meta description`}),(0,M.jsx)(_l,{title:ml(e,n),limits:t,label:`Title`}),(0,M.jsx)(yl,{advice:wc(i,o,t.metaDescription,a),readOnly:e.readOnly,onEditField:r})]})}function xl(e,t){let n=e.draft.metadata.sharing?.image!==void 0;return{description:(0,M.jsx)(gl,{meta:pl(e),limits:t,label:`Length`}),title:(0,M.jsx)(_l,{title:ml(e,hl(e)),limits:t,label:`Length`}),image:n?void 0:(0,M.jsx)(`dl`,{className:`side-facts`,children:(0,M.jsx)(vl,{doc:e})})}}function Sl(e){let{doc:t,onEditField:n,renderFields:r}=e,i=_(f(),`seo`)&&(t.info?.pages??!0)?t.limits:null;if(r){let e=r(i?xl(t,i):{});if(e)return e}return i?(0,M.jsxs)(Y,{title:`Search and sharing`,children:[(0,M.jsx)(bl,{doc:t,limits:i,names:hl(t),onEditField:n}),(0,M.jsx)(`dl`,{className:`side-facts`,children:(0,M.jsx)(vl,{doc:t})})]}):null}var Cl=`Not in the contract. Rename it to a contract heading to get the designed layout, or keep it as prose.`;function wl({doc:e,heading:t}){let n=(0,j.useId)(),r=Ya(t),i=e.draft.fields[r],a=typeof i==`string`?i:``,o=e.limits?.metaDescription;return(0,M.jsxs)(`div`,{className:`side-field`,children:[(0,M.jsxs)(`div`,{className:`side-field-head`,children:[(0,M.jsx)(`label`,{htmlFor:n,className:`side-field-label`,children:(0,M.jsx)(`code`,{children:r})}),(0,M.jsx)(`span`,{className:`side-field-optional`,children:`optional`})]}),(0,M.jsx)(`textarea`,{id:n,className:`editor-control editor-control--area`,rows:3,value:a,disabled:e.readOnly,"aria-describedby":`${n}-note`,onChange:t=>e.onField(r,t.target.value||void 0)}),(0,M.jsx)(`p`,{id:`${n}-note`,className:`side-note`,children:`This section's own meta description, for a section with its own URL. Saved with the draft.`}),o&&a!==``&&(0,M.jsx)(Ec,{label:`Length`,length:a.length,state:yc(a.length,o),target:{kind:`range`,min:o.minChars,max:o.maxChars}})]})}function Tl({doc:e,heading:t,index:n}){let r=Ka(e.draft.body,t,n);if(!r)return(0,M.jsx)(Y,{children:(0,M.jsx)(Z,{children:`This section is no longer in the body.`})});let i=Na(t,e.info?.sections??[]);return(0,M.jsxs)(Y,{summary:(0,M.jsx)(k,{tone:i?`accent`:`neutral`,children:i?`designed`:`prose`}),children:[(0,M.jsxs)(`dl`,{className:`side-facts`,children:[(0,M.jsx)(X,{label:`Key`,children:(0,M.jsx)(`code`,{children:Xa(t)})}),(0,M.jsx)(X,{label:`Words`,children:Ja(r.section.markdown)})]}),!i&&(0,M.jsx)(Z,{children:Cl}),Object.hasOwn(e.schema.schema.properties??{},Ya(t))&&(0,M.jsx)(wl,{doc:e,heading:t})]})}function El({doc:e,heading:t}){let n=Na(t,e.info?.sections??[]);return(0,M.jsx)(Y,{summary:(0,M.jsx)(k,{tone:n?`accent`:`neutral`,children:n?`designed`:`prose`}),children:(0,M.jsxs)(`dl`,{className:`side-facts`,children:[(0,M.jsx)(X,{label:`Key`,children:(0,M.jsx)(`code`,{children:Xa(t)})}),(0,M.jsx)(X,{label:`On the page`,children:`This heading appears more than once in the body: edit it in Structure mode.`})]})})}function Dl({doc:e}){return(0,M.jsxs)(Y,{summary:(0,M.jsx)(k,{children:`before first ##`}),children:[(0,M.jsx)(`dl`,{className:`side-facts`,children:(0,M.jsx)(X,{label:`Words`,children:Ja(qa(e.draft.body))})}),(0,M.jsx)(Z,{children:`The markdown before the first ## heading.`})]})}function Ol(e){let{doc:t,control:n,onEditField:r,onOpenData:i}=e,{selection:a}=n,o=e=>n.select(e,!0),s=e.mode!==`structure`,c=e.mode!==`live`,l={contract:t.schema.contract,metadata:t.draft.metadata,fields:t.draft.fields,onOpenData:i?e.onOpenGraph??i:null,groupActions:e.groupActions,defaults:t.defaults,readOnly:t.readOnly,errors:t.fieldErrors,onMetadata:t.onMetadata};switch(a.kind){case`field`:return(0,M.jsx)(zc,{doc:t,name:a.name});case`section`:return a.ambiguous?(0,M.jsx)(El,{doc:t,heading:a.heading}):(0,M.jsx)(Tl,{doc:t,heading:a.heading,index:a.index});case`lead`:return(0,M.jsx)(Dl,{doc:t});default:return(0,M.jsxs)(M.Fragment,{children:[s&&(0,M.jsx)(U,{scope:`metadata`,...l,system:t.meta}),(0,M.jsx)(Sl,{doc:t,onEditField:r,renderFields:s?e=>(0,M.jsx)(U,{scope:`sharing`,checks:e,...l}):null}),t.readOnly&&t.meta&&(0,M.jsx)(Bc,{doc:t,onSelect:o}),c&&(0,M.jsx)(qc,{doc:t,onSelect:o}),c&&(0,M.jsx)(cl,{doc:t})]})}}function kl(e){let t=(0,j.useRef)(null);return(0,j.useEffect)(()=>{e>0&&t.current?.focus()},[e]),t}function Al(e){let[t,n]=(0,j.useState)(``),r=(0,j.useRef)(!0);return(0,j.useEffect)(()=>{if(r.current){r.current=!1;return}n(`Side panel: ${e}`)},[e]),t}function jl(e){let{control:t}=e,n=Uo(t.selection),r=kl(t.focusTick),i=Al(n),a=t.selection.kind!==`none`;function o(e){e.key===`Escape`&&!e.defaultPrevented&&a&&(e.preventDefault(),t.select(Bo,!0))}return(0,M.jsxs)(`aside`,{id:e.id,className:`side-panel`,"aria-label":`Side panel`,onKeyDown:o,children:[(0,M.jsxs)(`div`,{className:`side-panel-head`,children:[(0,M.jsx)(`h2`,{ref:r,tabIndex:-1,className:`side-panel-title`,children:n}),a&&(0,M.jsx)(y,{size:`sm`,variant:`ghost`,icon:ee,onClick:()=>t.select(Bo,!0),children:`Page overview`}),(0,M.jsx)(b,{id:`${e.id}-hide`,icon:Zt,label:`Hide side panel`,size:`sm`,"aria-expanded":`true`,"aria-controls":e.id,onClick:e.onCollapse})]}),(0,M.jsx)(`p`,{className:`visually-hidden`,role:`status`,children:i}),(0,M.jsx)(`div`,{className:`side-panel-body`,children:(0,M.jsx)(Ol,{...e})})]})}function Ml(){let[e,t]=(0,j.useState)(Bo),[n,r]=(0,j.useState)(0);return{selection:e,select:(0,j.useCallback)((e,n)=>{t(t=>Vo(t,e)?t:e),n&&r(e=>e+1)},[]),focusTick:n}}function Nl(e){return typeof e==`string`?e:JSON.stringify(e)}function Pl({props:e,name:t,value:n}){let r=`${e.idPrefix}-custom-${t}`;return(0,M.jsxs)(`div`,{className:`editor-field editor-custom-field`,children:[(0,M.jsxs)(`div`,{className:`editor-field-head`,children:[(0,M.jsx)(`label`,{className:`editor-field-label`,htmlFor:r,children:t}),(0,M.jsx)(`span`,{className:`editor-field-optional`,children:`custom`})]}),(0,M.jsxs)(`div`,{className:`editor-custom-line`,children:[(0,M.jsx)(`input`,{id:r,type:`text`,className:`editor-control`,value:Nl(n),onChange:n=>e.onChange(t,n.target.value)}),e.canPromote&&(0,M.jsx)(y,{size:`sm`,"aria-label":`Promote ${t} to a schema field`,onClick:()=>e.onPromote(t,n),children:`Promote`})]})]})}function Fl(e){let t=(0,j.useId)();return e.entries.length===0?null:(0,M.jsxs)(`section`,{className:`editor-custom-fields`,"aria-labelledby":t,children:[(0,M.jsx)(`h2`,{id:t,className:`editor-subtitle`,children:`Custom fields`}),(0,M.jsxs)(`p`,{className:`editor-note`,children:[`Not in the collection's schema.`,e.canPromote&&` Promote one to add it to the schema.`]}),e.entries.map(([t,n])=>(0,M.jsx)(Pl,{props:e,name:t,value:n},t))]})}function Il({pill:e,seoUse:t}){return(0,M.jsxs)(M.Fragment,{children:[(0,M.jsxs)(`span`,{className:C(`neutral`,`editor-field-pill`),children:[(0,M.jsx)(`span`,{className:`visually-hidden`,children:`type `}),e]}),t&&(0,M.jsxs)(`span`,{className:C(`accent`,`editor-field-pill`),children:[(0,M.jsx)(tn,{className:`ui-chip-icon`,"aria-hidden":`true`}),(0,M.jsx)(`span`,{className:`visually-hidden`,children:`used for search as `}),t]})]})}function Ll({id:e,labelId:t,name:n,required:r,pill:i,seoUse:a,isGroup:o}){return(0,M.jsxs)(`div`,{className:`editor-field-head`,children:[(0,M.jsxs)(o?`span`:`label`,{id:t,className:`editor-field-label`,...o?{}:{htmlFor:e},children:[n,r&&(0,M.jsx)(`span`,{className:`editor-field-required`,"aria-hidden":`true`,children:`*`})]}),!r&&(0,M.jsx)(`span`,{className:`editor-field-optional`,children:`optional`}),(0,M.jsx)(Il,{pill:i,seoUse:a})]})}function Rl(e,t,n){return[t?`${e}-help`:null,n?`${e}-error`:null].filter(Boolean).join(` `)||void 0}function zl({id:e,help:t,error:n}){return(0,M.jsxs)(M.Fragment,{children:[t&&(0,M.jsx)(`p`,{id:`${e}-help`,className:`editor-field-help`,children:t}),n&&(0,M.jsx)(`p`,{id:`${e}-error`,className:`editor-field-error`,children:n})]})}function Bl(e){if(e.property.type===`object`||e.property.type===`array`&&e.property.items?.type!==`string`)return(0,M.jsx)(H,{name:e.name,path:`fields.${e.name}`,property:e.property,value:e.value,required:e.required,errors:e.error?{[`fields.${e.name}`]:e.error}:{},onValue:t=>e.onChange(e.name,t)});let{idPrefix:t,name:n,property:r,value:i,required:a,seoUse:o,error:s,onChange:c}=e,l=R(r,n),u=cr[l],d=`${t}-${n}`,f=`${d}-label`,p=jn(r);return(0,M.jsxs)(`div`,{className:s?`editor-field editor-field--invalid`:`editor-field`,"data-field":n,children:[(0,M.jsx)(Ll,{id:d,labelId:f,name:n,required:a,pill:An(r,n),seoUse:o,isGroup:l===`media`}),(0,M.jsx)(u,{id:d,labelId:f,name:n,property:r,value:i,required:a,describedBy:Rl(d,p,s),invalid:s!==void 0,onChange:c}),(0,M.jsx)(zl,{id:d,help:p,error:s})]})}function Vl(e,t){let[n,r]=(0,j.useState)(``);return(0,j.useEffect)(()=>{if(!t)return;let n=!0;return Promise.resolve(Mt.parse(e)).then(e=>{n&&r(Nt.sanitize(e))}).catch(()=>{n&&r(``)}),()=>{n=!1}},[e,t]),n}function Hl(e){if(!e)return{};let t=t=>{let n=t.currentTarget;e(n.value,n.selectionStart)};return{onSelect:t,onClick:t,onFocus:t}}function Ul({view:e,own:t,label:n,onView:r}){let i=e===t;return(0,M.jsx)(`button`,{type:`button`,className:`editor-body-toggle`,"aria-pressed":i,onClick:()=>r(i?`write`:t),children:n})}function Wl({headingId:e,hintId:t,view:n,onView:r}){return(0,M.jsxs)(`div`,{className:`editor-body-head`,children:[(0,M.jsx)(`h2`,{id:e,className:`editor-body-title`,children:`Body`}),(0,M.jsxs)(`span`,{id:t,className:`editor-body-hint`,children:[`markdown · `,(0,M.jsx)(`code`,{children:`##`}),` headings become sections`]}),(0,M.jsxs)(`span`,{className:`editor-body-views`,children:[(0,M.jsx)(Ul,{view:n,own:`split`,label:`Split`,onView:r}),(0,M.jsx)(Ul,{view:n,own:`preview`,label:`Preview`,onView:r})]})]})}function Gl({html:e}){return(0,M.jsx)(`div`,{className:`editor-body-preview`,children:(0,M.jsx)(`div`,{dangerouslySetInnerHTML:{__html:e}})})}function Kl({headingId:e,hintId:t,props:n}){let{value:r,onChange:i,disabled:a,onCaret:o}=n;return(0,M.jsx)(`textarea`,{className:`editor-body-textarea`,"aria-labelledby":e,"aria-describedby":t,value:r,rows:20,spellCheck:!1,disabled:a,...Hl(o),onChange:e=>{i(e.target.value),o?.(e.target.value,e.target.selectionStart)}})}function ql(e){let[t,n]=(0,j.useState)(`write`),r=Vl(e.value,t!==`write`),i=(0,j.useId)(),a=(0,j.useId)();return(0,M.jsxs)(`section`,{className:`editor-body`,"aria-labelledby":i,children:[(0,M.jsx)(Wl,{headingId:i,hintId:a,view:t,onView:n}),(0,M.jsxs)(`div`,{className:t===`split`?`editor-body-panes editor-body-panes--split`:`editor-body-panes`,children:[t!==`preview`&&(0,M.jsx)(Kl,{headingId:i,hintId:a,props:e}),t!==`write`&&(0,M.jsx)(Gl,{html:r})]})]})}function Jl(e,t){if(!(e instanceof Element))return null;let n=e.closest(`[data-field]`)?.getAttribute(`data-field`)??null;return n===`slug`&&t?null:n}function Yl(e){let t=t=>{let n=Jl(t.target,e.newSlug);n&&e.onSelectField?.(n)};return{onFocus:t,onClick:t,onKeyUp:e=>{Wo(e.key)&&t(e)}}}var Xl={type:`string`,description:`Part of the page's address: lowercase words joined by hyphens, suggested from the title.`};function Zl({idPrefix:e,slug:t,error:n}){return(0,M.jsx)(Bl,{idPrefix:e,name:`slug`,property:Xl,value:t.value,required:!0,seoUse:null,error:n,onChange:(e,n)=>t.onChange(typeof n==`string`?n:``)})}function Ql(e){let{schema:t,kind:n,openedFields:r}=e;return(0,j.useMemo)(()=>{let e=Object.keys(t.schema.properties??{}).filter(e=>!wn.has(e));return n===`global`?e.filter(e=>r.includes(e)):e},[t,n,r])}function $l(e,t){return(0,j.useMemo)(()=>t?Fn(Object.keys(e.schema.properties??{})):new Map,[t,e])}function eu({props:e,idPrefix:t}){let{schema:n,draft:r,fieldErrors:i,onField:a}=e,o=Ql(e),s=$l(n,e.seoReadsFields),c=n.schema.properties??{},l=new Set(n.schema.required??[]);return o.map(e=>(0,M.jsx)(Bl,{idPrefix:t,name:e,property:c[e]??{},value:r.fields[e],required:l.has(e),seoUse:s.get(e)??null,error:i[e],onChange:a},e))}function tu(e){let{schema:t,draft:n,newSlug:r,readOnly:i}=e,a=(0,j.useId)(),o=t.schema.properties??{},s=Object.entries(n.fields).filter(([e])=>!(e in o)&&!wn.has(e));return(0,M.jsxs)(`div`,{className:`editor-structure`,children:[(0,M.jsxs)(`fieldset`,{className:`editor-structure-fields`,disabled:i,...Yl(e),children:[(0,M.jsx)(`legend`,{className:`visually-hidden`,children:`Fields`}),r&&(0,M.jsx)(Zl,{idPrefix:a,slug:r,error:e.fieldErrors.slug}),(0,M.jsx)(eu,{props:e,idPrefix:a}),(0,M.jsx)(Fl,{idPrefix:a,entries:s,onChange:e.onField,onPromote:(t,n)=>{e.onPromote(t,n).then(()=>{document.getElementById(`${a}-${t}`)?.focus()})},canPromote:e.canPromote})]}),t.contract.body===`none`&&n.body.length>0&&(0,M.jsxs)(`div`,{role:`alert`,children:[(0,M.jsx)(`p`,{children:`This content form has no text body. Remove the text before saving.`}),(0,M.jsx)(`button`,{type:`button`,disabled:i,onClick:()=>e.onBody(``),children:`Remove the text body`})]}),e.kind===`page`&&(t.contract.body!==`none`||n.body.length>0)&&(0,M.jsx)(ql,{value:n.body,onChange:e.onBody,disabled:i,onCaret:e.onCaret}),(0,M.jsx)(U,{contract:t.contract,metadata:n.metadata,fields:n.fields,defaults:e.defaults,groupActions:e.groupActions,onOpenData:e.onOpenData,readOnly:i,errors:e.fieldErrors,onMetadata:e.onMetadata})]})}var nu=`krantho-studio-panel`,ru={min:300,max:640,fallback:380};function iu(){let{collapsed:e,width:t}=dt(nu);return{collapsed:e===!0,width:kt(t,ru,ru.fallback)}}function au(){let[e,t]=ht(nu,iu),n=(0,j.useCallback)(e=>t(t=>({...t,...e})),[t]);return{...e,setCollapsed:(0,j.useCallback)(e=>n({collapsed:e}),[n]),setWidth:(0,j.useCallback)(e=>n({width:e}),[n])}}function ou(e){return e.readOnly?e.creating?`Creating the document…`:e.canEdit?`Read-only: ${e.facts.lockedBy??`Someone else`} is editing. Saving and publishing wait until they finish or the lock expires.`:`Read-only: your role can view documents but not edit them.`:null}function su(e){let t=document.activeElement;return!t||t===document.body||t.matches(`:disabled`)||!!e?.closest(`.editor-canvas`)?.contains(t)}function cu(e,t){let[n,r]=(0,j.useState)(!1),i=(0,j.useRef)(e);return(0,j.useEffect)(()=>{i.current&&!e&&r(!0),e&&r(!1),i.current=e},[e]),(0,j.useEffect)(()=>r(!1),[t]),n}function lu({ws:e}){let t=ou(e),n=cu(e.facts.lockedBy!==null,e.draft.draft),r=(0,j.useRef)(null),i=(0,j.useRef)(e.readOnly);(0,j.useEffect)(()=>{let t=e.readOnly!==i.current;i.current=e.readOnly,t&&!e.creating&&su(r.current)&&r.current?.focus()},[e.readOnly,e.creating]);let a=t??(n?`Editing is open again.`:null);return(0,M.jsxs)(`p`,{ref:r,role:`status`,tabIndex:-1,className:a?`editor-readonly`:`editor-readonly editor-readonly--empty`,children:[t&&(0,M.jsx)(pt,{className:`editor-notice-icon`,"aria-hidden":`true`}),n&&!t&&(0,M.jsx)(qt,{className:`editor-notice-icon`,"aria-hidden":`true`}),a]})}function uu(e){let{ws:t,source:n,collection:r,control:i,onMode:a,onFound:o}=e,s=f(),c=t.document?.meta,l=c?.slug??null,u=_c({collection:n.collection,slug:l,locale:c?.locale??null,defaultLocale:n.locales?.defaultLocale??null,sitePreview:_(s,`sitePreview`),canEdit:t.canEdit});return(0,M.jsx)(hc,{preview:u,collection:r,slug:l,schema:t.schema,draft:t.draft.draft,designed:n.collection?.sections??[],readOnly:t.readOnly,savedVersion:c?.version??null,selection:i.selection,onField:t.setField,onBody:t.draft.setBody,onSelect:i.select,onFound:o,onStructure:()=>a(`structure`)})}function du(e){let{ws:t,kind:n,mode:r,source:i,control:a}=e,{select:o}=a,s=f(),{document:c,draft:l}=t,u=i.collection?.pages??!1;return r===`live`?(0,M.jsx)(uu,{...e}):r===`data`?(0,M.jsx)(Qi,{ws:t,source:i,initialGraphOpen:e.initialGraphOpen}):r===`where`?(0,M.jsx)(xa,{ws:t}):(0,M.jsx)(tu,{kind:n,schema:t.schema,draft:l.draft,openedFields:t.openedFields,newSlug:c?null:t.newSlug,readOnly:t.readOnly,fieldErrors:t.actions.failure?.fieldErrors??{},seoReadsFields:n===`page`&&u&&_(s,`seo`),canPromote:t.isAdmin&&!t.readOnly,onField:t.setField,onBody:l.setBody,onMetadata:l.setMetadata,defaults:c?.defaults,groupActions:e=>(0,M.jsx)(vc,{ws:t,slot:e}),onOpenData:e.onOpenGraph,onPromote:t.promote,onSelectField:e=>o({kind:`field`,name:e}),onCaret:(e,t)=>o(Ho(e,t))})}function fu(e,t,n,r,i){return{collection:n,info:t.collection,schema:e.schema,onMetadata:e.draft.setMetadata,defaults:e.document?.defaults??[],fieldErrors:e.actions.failure?.fieldErrors??{},draft:e.draft.draft,meta:e.document?.meta??null,limits:t.site?.seo.limits??null,locales:t.locales,readOnly:e.readOnly,canEdit:e.canEdit,seoReadsFields:r,live:i,onField:e.setField,onBody:e.draft.setBody}}function pu(e,t){(e?.querySelector(`[data-field="${t.replace(/["\\]/g,`\\$&`)}"]`))?.querySelector(`input, textarea, select, button`)?.focus()}function mu(e){let{mode:t,onMode:n,ids:r,canvasRef:i}=e,a=(0,j.useRef)(null);(0,j.useEffect)(()=>{t===`structure`&&a.current!==null&&(pu(i.current,a.current),a.current=null)},[t,i]);let o=(0,j.useCallback)(e=>{if(t===`structure`){pu(i.current,e);return}a.current=e,n(`structure`)},[t,n,i]),s=(0,j.useCallback)(()=>{n(`data`),requestAnimationFrame(()=>document.getElementById(`${r}-mode-data`)?.focus())},[n,r]);return{editField:o,openData:t===`data`?null:s}}function hu(e){let{ws:t,ids:n,mode:r,showPanel:i,canvasRef:a}=e,o=Ml(),s=mu(e),[c,l]=(0,j.useState)(!1);(0,j.useEffect)(()=>{r!==`data`&&l(!1)},[r]);let u=()=>{l(!0),e.onMode(`data`)},[d,p]=(0,j.useState)(null),m=_(f(),`seo`)&&e.kind===`page`&&(e.source.collection?.pages??!1),h=r===`live`?d:null,g=fu(t,e.source,e.collection,m,h);function v(e){e.key!==`Escape`||e.defaultPrevented||e.currentTarget.contains(e.target)&&o.select(Bo)}let y=au(),x=`${n}-panel`;function ee(e){y.setCollapsed(e),requestAnimationFrame(()=>document.getElementById(`${x}-${e?`show`:`hide`}`)?.focus())}let te=[`editor-columns`];return i?y.collapsed&&te.push(`editor-columns--collapsed`):te.push(`editor-columns--single`),(0,M.jsxs)(`div`,{className:te.join(` `),style:{"--panel-width":`${y.width}px`},children:[(0,M.jsxs)(`div`,{ref:a,id:`${n}-canvas`,role:`tabpanel`,"aria-labelledby":`${n}-mode-${r}`,className:`editor-canvas`,tabIndex:-1,onKeyDown:v,children:[(0,M.jsx)(lu,{ws:t}),(0,M.jsx)(du,{...e,control:o,onFound:p,initialGraphOpen:c,onOpenGraph:u})]}),i&&y.collapsed&&(0,M.jsx)(b,{id:`${x}-show`,className:`editor-panel-show`,icon:$t,label:`Show side panel`,"aria-expanded":`false`,onClick:()=>ee(!1)}),i&&!y.collapsed&&(0,M.jsxs)(`div`,{className:`editor-side`,children:[(0,M.jsx)(Ot,{label:`Resize side panel`,value:y.width,min:ru.min,max:ru.max,grows:`left`,onChange:y.setWidth,onReset:()=>y.setWidth(ru.fallback),controls:x}),(0,M.jsx)(jl,{id:x,onCollapse:()=>ee(!0),doc:g,mode:r,control:o,onEditField:s.editField,onOpenData:s.openData,onOpenGraph:u,groupActions:e=>(0,M.jsx)(vc,{ws:t,slot:e})})]})]})}function gu(e){return JSON.stringify(e,(e,t)=>{if(typeof t!=`object`||!t||Array.isArray(t))return t;let n=Object.entries(t);return Object.fromEntries(n.sort(([e],[t])=>e.localeCompare(t)))})??`undefined`}function Q(e,t){return gu(e)===gu(t)}function _u(e,t){return e.body===t.body&&Q(e.fields,t.fields)&&Q(e.metadata,t.metadata)&&Q(e.defaults??[],t.defaults??[])}function vu(e,t,n){let r={},i=new Set([...Object.keys(n.fields),...Object.keys(e.fields)]);for(let a of i){let i=Q(e.fields[a],t.fields[a])?n.fields[a]:e.fields[a];i!==void 0&&(r[a]=i)}let a=e.body===t.body?n.body:e.body,o=yu(e.metadata,t.metadata,n.metadata),s=Q(e.defaults??[],t.defaults??[])?n.defaults:e.defaults;return{fields:r,body:a,metadata:o,...s?.length?{defaults:s}:{}}}function yu(e,t,n){let r={};for(let i of new Set([...Object.keys(n),...Object.keys(e)])){if(Q(e[i],t[i])){n[i]!==void 0&&(r[i]=n[i]);continue}if(!e[i])continue;let a={};for(let r of new Set([...Object.keys(n[i]??{}),...Object.keys(e[i]??{})])){let o=Q(e[i]?.[r],t[i]?.[r])?n[i]?.[r]:e[i]?.[r];o!==void 0&&(a[r]=o)}r[i]=a}return r}var bu=[`title`,`name`];function xu(e){return e.toLowerCase().replace(/[^a-z0-9]+/g,`-`).replace(/^-+|-+$/g,``)}function Su(e){return bu.includes(e)}function Cu(e,t,n){return`krantho-autosave-${e}-${t}-${n}`}function wu(e,t){let n=`krantho-autosave-new-${e}`;return t?`${n}-${t}`:n}function Tu(e){if(typeof e!=`object`||!e)return!1;let t=e;return typeof t.savedAt==`string`&&t.metadata!==null&&typeof t.metadata==`object`&&!Array.isArray(t.metadata)&&typeof t.body==`string`&&t.fields!==null&&typeof t.fields==`object`&&!Array.isArray(t.fields)}function Eu(e){try{let t=localStorage.getItem(e);if(!t)return null;let n=JSON.parse(t);return Tu(n)?n:null}catch{return null}}function Du(e,t,n={},r=new Date){try{let i={...t,...n,savedAt:r.toISOString()};return localStorage.setItem(e,JSON.stringify(i)),!0}catch{return!1}}function Ou(e){try{localStorage.removeItem(e)}catch{}}function ku(){let e=`krantho-autosave-probe`;try{return localStorage.setItem(e,`1`),localStorage.removeItem(e),!0}catch{return!1}}function Au(e,t,n){return!e||n&&typeof e.baseVersion!=`number`?!1:!_u(e,t)||!!e.slug}function ju(e,t){return e.baseVersion===void 0||t===null?null:e.baseVersion===t?`made on v${e.baseVersion}`:`made on v${e.baseVersion} — the document is now v${t}`}function Mu(e,t){let n=`Your changes to ${e} are not saved.`;return t===`kept`?`${n} They stay in this browser and are offered back when you open it again.`:t===`offer-pending`?`${n} They are not kept: changes from an earlier visit wait to be restored or discarded, and leaving loses what you typed since.`:`${n} This browser cannot keep them, so leaving loses them.`}function Nu({message:e,onStay:t,onLeave:n}){let r=(0,j.useRef)(null);return(0,M.jsx)(w,{title:`Leave without saving?`,onClose:t,initialFocus:r,actions:(0,M.jsxs)(M.Fragment,{children:[(0,M.jsx)(y,{ref:r,onClick:t,children:`Stay`}),(0,M.jsx)(y,{variant:`danger`,onClick:n,children:`Leave`})]}),children:(0,M.jsx)(`p`,{children:e})})}var Pu={unpublish:{title:e=>`Unpublish ${e}?`,verb:`Unpublish`,busy:`Unpublishing…`,says:`Visitors stop seeing it. The change is recorded as a new version, and publishing makes it live again.`,danger:!0},archive:{title:e=>`Archive ${e}?`,verb:`Archive`,busy:`Archiving…`,says:`Visitors stop seeing it and it is marked archived, recorded as a new version. Its versions stay.`,danger:!0},unarchive:{title:e=>`Restore ${e} to draft?`,verb:`Restore to draft`,busy:`Restoring…`,says:`It is no longer archived and becomes a draft again, recorded as a new version. Nothing is published.`,danger:!1}};function Fu(e){let{change:t,name:n,busy:r,onConfirm:i,onClose:a}=e,o=(0,j.useRef)(null),s=Pu[t],c=(0,M.jsxs)(M.Fragment,{children:[(0,M.jsx)(y,{ref:o,onClick:r?void 0:a,"aria-disabled":r,children:`Cancel`}),(0,M.jsx)(y,{variant:s.danger?`danger`:`primary`,onClick:r?void 0:i,"aria-disabled":r,children:r?s.busy:s.verb})]});return(0,M.jsx)(w,{title:s.title(n),onClose:r?()=>void 0:a,initialFocus:o,busy:r,actions:c,children:(0,M.jsx)(`p`,{children:s.says})})}function Iu({ws:e,hasPage:t,dialog:n,close:r}){let{document:i,actions:a,facts:o}=e;if(!i||!o.saved)return null;let s=a.busy===`publish`,c=e=>{a.changePublication(e).then(r)},{collection:l,slug:u,locale:d}=i.meta;if(n.kind===`status`){let{change:e}=n;return(0,M.jsx)(Fu,{change:e,name:u,busy:s,onConfirm:()=>c(e),onClose:r})}return(0,M.jsx)(ha,{collection:l,slug:u,locale:d,saved:o.saved,hasPage:t,busy:s,onConfirm:()=>c(`publish`),onClose:r})}function Lu({ws:e,hasPage:t,dialog:n,close:r}){let{blocker:i}=e.guard;return i.state===`blocked`?(0,M.jsx)(Nu,{message:Mu(e.document?.meta.slug??`the new document`,e.autosave.keeping),onStay:()=>i.reset(),onLeave:()=>i.proceed()}):n?(0,M.jsx)(Iu,{ws:e,hasPage:t,dialog:n,close:r}):null}var $=16;function Ru(e,t,n){return e<$?$-e:t>n-$?Math.max($-e,n-$-t):0}function zu(e,t){(0,j.useLayoutEffect)(()=>{let n=t.current;if(!e||!n)return;n.style.translate=``;let{left:r,right:i}=n.getBoundingClientRect(),a=Ru(r,i,window.innerWidth);a!==0&&(n.style.translate=`${a}px 0`)},[e,t])}function Bu(e,t,n){(0,j.useEffect)(()=>{if(!e)return;function r(e){t.current?.contains(e.target)||n()}return document.addEventListener(`pointerdown`,r),()=>document.removeEventListener(`pointerdown`,r)},[e,t,n])}function Vu(){let[e,t]=(0,j.useState)(!1),n=(0,j.useRef)(null),r=(0,j.useRef)(null);Bu(e,n,(0,j.useCallback)(()=>t(!1),[]));let i=(0,j.useCallback)(()=>{t(!1),r.current?.focus()},[]);function a(t){t.key===`Escape`&&e&&(t.stopPropagation(),i())}function o(e){n.current?.contains(e.relatedTarget)||t(!1)}return{open:e,toggle:()=>t(e=>!e),dismiss:i,wrapperRef:n,buttonRef:r,onKeyDown:a,onBlur:o}}function Hu({label:e,tone:t,icon:n,children:r}){let{open:i,toggle:a,dismiss:o,wrapperRef:s,buttonRef:c,onKeyDown:l,onBlur:u}=Vu(),d=(0,j.useId)(),f=(0,j.useRef)(null);return zu(i,f),(0,M.jsxs)(`div`,{ref:s,className:`editor-popover`,onKeyDown:l,onBlur:u,children:[(0,M.jsxs)(`button`,{ref:c,type:`button`,className:C(t,`editor-chip-button`),"aria-expanded":i,"aria-controls":d,onClick:a,children:[n&&(0,M.jsx)(n,{className:`ui-chip-icon`,"aria-hidden":`true`}),e,(0,M.jsx)(be,{className:`ui-chip-icon editor-chip-caret`,"aria-hidden":`true`})]}),(0,M.jsx)(`div`,{ref:f,id:d,className:`editor-popover-panel`,hidden:!i,children:typeof r==`function`?r(o):r})]})}var Uu={live:`success`,ahead:`warning`,draft:`neutral`};function Wu(e){let{modes:t,mode:n,onMode:r,tabId:i,panelId:a}=e,o=(0,j.useRef)(null);function s(e){let a={ArrowRight:1,ArrowLeft:-1}[e.key];if(a===void 0)return;e.preventDefault();let s=t.findIndex(e=>e.id===n),c=t[(s+a+t.length)%t.length];c&&(r(c.id),o.current?.querySelector(`#${CSS.escape(i(c.id))}`)?.focus())}return(0,M.jsx)(`div`,{ref:o,role:`tablist`,"aria-label":`Mode`,className:`editor-modes`,onKeyDown:s,children:t.map(e=>(0,M.jsx)(`button`,{id:i(e.id),type:`button`,role:`tab`,className:`editor-mode`,"aria-selected":e.id===n,"aria-controls":a,tabIndex:e.id===n?0:-1,onClick:()=>r(e.id),children:e.label},e.id))})}function Gu(e){return e.state===`held`?`You hold the edit lock`:e.state===`foreign`?`${e.holder} is editing`:e.state===`unavailable`?`Not locked: this store keeps no edit locks`:`Not locked`}function Ku({props:e,dismiss:t}){let{facts:n,record:r,onStatusChange:i}=e;if(!i)return null;let a=n.saved!==null&&n.saved.liveVersion!==null,o=r?.status===`archived`,s=ra(n),c=e=>()=>{t(),i(e)};return(0,M.jsxs)(`div`,{className:`editor-detail-actions`,children:[a&&(0,M.jsx)(A,{size:`sm`,reason:s,onClick:c(`unpublish`),children:`Unpublish`}),(0,M.jsx)(A,{size:`sm`,reason:s,onClick:c(o?`unarchive`:`archive`),children:o?`Restore to draft`:`Archive`}),s&&(0,M.jsx)(`p`,{className:`editor-detail-text`,children:s})]})}function qu({props:e,dismiss:t}){let{facts:n,record:r,lock:i}=e;return(0,M.jsxs)(M.Fragment,{children:[(0,M.jsxs)(`dl`,{className:`editor-detail`,children:[(0,M.jsx)(`dt`,{children:`Versions`}),(0,M.jsx)(`dd`,{children:ea(n.saved)}),(0,M.jsx)(`dt`,{children:`Edit lock`}),(0,M.jsx)(`dd`,{children:Gu(i)}),r&&(0,M.jsxs)(M.Fragment,{children:[(0,M.jsx)(`dt`,{children:`Last save`}),(0,M.jsxs)(`dd`,{children:[h(r.createdAt),r.changedBy&&` by ${O(r.changedBy)}`,r.status===`archived`&&` · archived`]})]})]}),(0,M.jsx)(Ku,{props:e,dismiss:t})]})}function Ju({lock:e}){return e.state===`foreign`?(0,M.jsx)(Hu,{label:`${e.holder} is editing`,tone:`warning`,icon:pt,children:(0,M.jsxs)(`p`,{className:`editor-detail-text`,children:[e.expiresAt&&`Their lock runs until ${h(e.expiresAt)}. `,`The editor is read-only until they finish or the lock expires; it opens for you then.`]})}):null}function Yu({link:e}){let t=e.kind===`preview`?`the saved draft`:`the live page`;return(0,M.jsxs)(`a`,{className:v(`ghost`,`md`,`editor-site-link`),href:e.href,target:`_blank`,rel:`noreferrer`,title:`Opens ${t} in a new tab`,children:[(0,M.jsx)(Te,{className:`ui-button-icon`,"aria-hidden":`true`}),`Open on site`,(0,M.jsxs)(`span`,{className:`visually-hidden`,children:[` (`,t,`, opens in a new tab)`]})]})}function Xu(e){let{facts:t,siteLink:n,onSave:r,onPublish:i}=e,a=$i(t.saved),o=ta(t),s=na(t);return(0,M.jsxs)(`div`,{className:`editor-header`,children:[(0,M.jsx)(Wu,{...e}),(0,M.jsx)(`span`,{className:`editor-header-spacer`}),(0,M.jsx)(Hu,{label:gt[a],tone:Uu[a],children:t=>(0,M.jsx)(qu,{props:e,dismiss:t})}),(0,M.jsx)(Ju,{lock:e.lock}),e.locales,n&&(0,M.jsx)(Yu,{link:n}),t.canEdit&&(0,M.jsxs)(M.Fragment,{children:[(0,M.jsx)(A,{reason:o,onClick:r,children:e.saving?`Saving…`:`Save draft`}),(0,M.jsx)(A,{reason:s,variant:`primary`,onClick:i,children:`Publish`})]})]})}function Zu(e,t){let n=e.savedAt?` from ${h(e.savedAt)}`:``,r=ju(e,t);return`${n}${r?`, ${r}`:``}`}function Qu({offer:e,currentVersion:t,onRestore:n,onDiscard:r}){return(0,M.jsxs)(`section`,{className:`editor-notice`,"aria-label":`Unsaved changes kept in this browser`,children:[(0,M.jsx)(ft,{className:`editor-notice-icon`,"aria-hidden":`true`}),(0,M.jsxs)(`p`,{className:`editor-notice-text`,children:[`Unsaved changes`,Zu(e,t),` are kept in this browser.`]}),(0,M.jsxs)(`span`,{className:`editor-notice-actions`,children:[(0,M.jsx)(y,{size:`sm`,variant:`primary`,onClick:n,children:`Restore`}),(0,M.jsx)(y,{size:`sm`,variant:`ghost`,onClick:r,children:`Discard`})]})]})}function $u(e,t){return e===`kept`?` They are also kept in this browser; reload to see v${t}.`:e===`offer-pending`?` They are not kept in this browser while earlier changes wait to be restored or discarded: reloading loses them.`:` This browser cannot keep them: reloading loses them.`}function ed({failure:e,keeping:t,onOverwrite:n}){let r=e.conflictWith;return(0,M.jsxs)(`div`,{className:`editor-notice editor-notice--error`,children:[(0,M.jsx)(He,{className:`editor-notice-icon`,"aria-hidden":`true`}),(0,M.jsxs)(`p`,{className:`editor-notice-text`,children:[e.message,r!==void 0&&$u(t,r)]}),r!==void 0&&(0,M.jsxs)(y,{size:`sm`,variant:`danger`,onClick:()=>n(r),children:[`Overwrite v`,r,` with my changes`]})]})}function td({slug:e,asked:t,editing:n}){return(0,M.jsxs)(`p`,{className:`editor-notice`,children:[(0,M.jsx)(_t,{className:`editor-notice-icon`,"aria-hidden":`true`}),(0,M.jsxs)(`span`,{className:`editor-notice-text`,children:[e,` has no `,t.toUpperCase(),` version yet. You are editing the `,n.toUpperCase(),` `,`version.`]})]})}function nd({workspace:e,onAnswered:t}){let{actions:n}=e;return(0,M.jsx)(`div`,{role:`alert`,className:`editor-alert-region`,children:n.failure&&(0,M.jsx)(ed,{failure:n.failure,keeping:e.autosave.keeping,onOverwrite:e=>{t(),n.save(e)}})})}function rd({workspace:e,missingLocale:t,onAnswered:n}){let{autosave:r,document:i}=e,a=e=>()=>{e(),n()};return(0,M.jsxs)(`div`,{className:`editor-notices`,children:[(0,M.jsx)(nd,{workspace:e,onAnswered:n}),r.offer&&(0,M.jsx)(Qu,{offer:r.offer,currentVersion:i?.meta.version??null,onRestore:a(e.restoreKept),onDiscard:a(r.discard)}),t&&i&&(0,M.jsx)(td,{slug:i.meta.slug,asked:t,editing:i.meta.locale})]})}var id={page:[{id:`live`,label:`Live`},{id:`structure`,label:`Structure`},{id:`data`,label:`Data`}],global:[{id:`fields`,label:`Fields`},{id:`where`,label:`Where it appears`}]},ad=`mode`;function od(e,t=!0){let n=id[e];return t?n:n.filter(e=>e.id!==`live`)}function sd(e,t,n={}){let r=od(t,n.hasPage??!0),i=r.find(t=>t.id===e);if(i)return i.id;let a=r[0]?.id??`structure`;return a===`live`&&n.isNew?`structure`:a}var cd=null;function ld(){return cd??=$e().catch(()=>(cd=null,null)),cd}async function ud(e){try{let[t,n,r,i,a]=await Promise.all([nt(e.collection),ct().catch(()=>[]),e.slug?S(e.collection,e.slug,e.locale):null,ld(),Qe().catch(()=>null)]);return{schema:t,collection:n.find(t=>t.name===e.collection)??null,document:r,site:i,locales:a}}catch(e){if(Ct(e))return null;throw e}}function dd(e){let{collection:t,slug:n,locale:r}=e,i=(0,j.useCallback)(()=>ud({collection:t,slug:n,locale:r}),[t,n,r]);return pe(i,`The document could not load`)}var fd=800;function pd(e,t,n){let{key:r,draft:i,dirty:a,context:o}=e,{baseVersion:s,slug:c}=o;(0,j.useEffect)(()=>{if(!r||t||n.forgotten)return;if(!a){Ou(r);return}let e=setTimeout(()=>Du(r,i,{baseVersion:s,slug:c}),fd);return()=>clearTimeout(e)},[r,i,a,s,c,t,n])}function md(e,t){(0,j.useEffect)(()=>{if(!e)return;let n=()=>{let{input:n,offer:r,forgotten:i}=t;n.dirty&&!r&&!i&&Du(e,n.draft,n.context)};return window.addEventListener(`pagehide`,n),()=>{window.removeEventListener(`pagehide`,n),n()}},[e,t])}function hd(e){let{key:t}=e,[n,r]=(0,j.useState)(()=>{let n=t?Eu(t):null;return Au(n,e.opened,e.context.baseVersion!==void 0)?n:null}),[i]=(0,j.useState)(ku),a=(0,j.useRef)({input:e,offer:n,forgotten:!1}).current;a.input=e,a.offer=n,pd(e,n,a),md(t,a);let o=(0,j.useCallback)(()=>(r(null),n),[n]),s=(0,j.useCallback)(()=>{t&&Ou(t),r(null)},[t]),c=(0,j.useCallback)(()=>{a.forgotten=!0,t&&Ou(t)},[t,a]);return{offer:n,keeping:n?`offer-pending`:t&&i?`kept`:`unavailable`,restore:o,discard:s,forget:c}}function gd(e){let t={};for(let[n,r]of Object.entries(e))r.default!==void 0&&(t[n]=r.default);return t}function _d(e,t){return e?{fields:e.fields,body:e.body,metadata:e.metadata,...e.defaults.length?{defaults:e.defaults}:{}}:{fields:t,body:``,metadata:{}}}function vd(e){let[t,n]=(0,j.useState)(e),[r,i]=(0,j.useState)(e),a=(0,j.useMemo)(()=>!_u(r,t),[r,t]),o=(0,j.useCallback)((e,t)=>{i(n=>{let r={...n.fields};return t===void 0?delete r[e]:r[e]=t,{...n,fields:r}})},[]),s=(0,j.useCallback)(e=>{i(t=>({...t,metadata:e}))},[]);return{draft:r,baseline:t,dirty:a,setField:o,setBody:(0,j.useCallback)(e=>{i(t=>({...t,body:e}))},[]),setMetadata:s,replace:i,reset:(0,j.useCallback)(e=>{n(e),i(e)},[]),rebase:(0,j.useCallback)((e,t)=>{n(e),i(n=>vu(n,t,e))},[])}}function yd(e){let[t,n]=(0,j.useState)(e.document),[r,i]=(0,j.useState)(e.document?.meta.version??null),a=(0,j.useMemo)(()=>gd(e.schema.schema.properties??{}),[e]),o=(0,j.useMemo)(()=>_d(e.document,a),[e,a]),s=vd(o),c=(0,j.useMemo)(()=>Object.keys(o.fields).filter(e=>o.fields[e]!==void 0),[o]),{rebase:l,reset:u}=s,d=(0,j.useCallback)((e,t)=>{n(e),i(e.meta.version),l(_d(e,a),t)},[l,a]),f=(0,j.useCallback)(e=>{n(e),i(e.meta.version),u(_d(e,a))},[u,a]);return{document:t,draft:s,opened:o,openedFields:c,baseVersion:r,restoredOn:(0,j.useCallback)(e=>{e!==void 0&&i(e)},[]),onSaved:d,onReplaced:f}}var bd=5e3,xd=6e4,Sd=3e4,Cd=5e3,wd=6e4;function Td(e){return e.locked?{state:`held`,expiresAt:e.expiresAt??null}:e.status===423&&e.lockedBy?{state:`foreign`,holder:O(e.lockedBy),expiresAt:e.expiresAt??null}:e.status===501?{state:`unavailable`}:null}function Ed(e){return Math.min(wd,Cd*2**Math.max(0,e-1))}function Dd(e,t=Date.now()){if(e.state===`foreign`)return Sd;if(e.state!==`held`)return null;if(!e.expiresAt)return xd;let n=new Date(e.expiresAt).getTime()-t;return Math.max(bd,Math.floor(n/2))}function Od(e,t){let{collection:n,slug:r,locale:i}=e,a=!0,o=!1,s=0,c=null,l=null,u=e=>(s=e?0:s+1,e?(o=e.state===`held`,a&&t(e),Dd(e)):Ed(s)),d=()=>{l=vt(n,r,i).then(e=>{l=null;let t=u(Td(e));a&&t!==null&&(c=setTimeout(d,t))})};return d(),()=>{a=!1,c&&clearTimeout(c);let e=()=>{o&&mt(n,r,i)};l?l.then(e):e()}}function kd(e){let[t,n]=(0,j.useState)({state:`none`}),r=e?.collection,i=e?.slug,a=e?.locale;return(0,j.useEffect)(()=>{if(!r||!i||!a)return;let e=Od({collection:r,slug:i,locale:a},n);return()=>{e(),n({state:`none`})}},[r,i,a]),t}var Ad=class extends Error{field;constructor(e,t){super(t),this.name=`FieldRefusal`,this.field=e}};function jd(e){let t={};if(!Array.isArray(e))return t;for(let n of e){if(typeof n!=`object`||!n)continue;let{field:e,message:r}=n;typeof e==`string`&&typeof r==`string`&&(t[e.startsWith(`fields.`)?e.slice(7):e]=r)}return t}function Md(e,t){return{message:`v${e} was saved after ${typeof t==`number`?`v${t}`:`the version you opened`}, the version your changes are based on. Nothing was saved; your changes are still in the form.`,fieldErrors:{},conflictWith:e}}function Nd(e,t){let{body:n}=e;if(e.status===409&&typeof n.currentVersion==`number`)return Md(n.currentVersion,n.yourVersion);if(e.status===423&&typeof n.lockedBy==`string`){let e=O(n.lockedBy);return{message:`${e} is editing this document.`,fieldErrors:{},lockedBy:e}}let r=jd(n.details);return Object.keys(r).length>0?{message:`Some fields are not valid. Fix the marked fields and save again.`,fieldErrors:r}:{message:e.message||t,fieldErrors:{}}}function Pd(e,t){return e instanceof Ad?{message:e.message,fieldErrors:{[e.field]:e.message}}:e instanceof Ge?Nd(e,t):{message:e instanceof Error?e.message:t,fieldErrors:{}}}var Fd={publish:`published`,unpublish:`draft`,archive:`archived`,unarchive:`draft`},Id={unpublish:e=>`Unpublished ${e}. Visitors no longer see it.`,archive:e=>`Archived ${e}. Visitors no longer see it.`,unarchive:e=>`${e} is a draft again. Nothing is live until you publish.`};async function Ld(e,t,n){try{let r=await S(e,t,n);return n===void 0||r.meta.locale===n}catch(e){if(e instanceof Ge&&e.status===404)return!1;throw e}}async function Rd(e){let{collection:t,draft:n,newLocale:r}=e,i=e.newSlug.trim();if(!i)throw new Ad(`slug`,`A new document needs a slug.`);if(await Ld(t,i,r))throw new Ad(`slug`,`${t} already has a document at "${i}". Choose another slug.`);let a=await tt(t,{slug:i,...n,locale:r});return e.onCreated(a.slug),ia(a)}async function zd(e,t){let{collection:n,saved:r,draft:i}=e;if(!r)return Rd(e);let{slug:a,locale:o}=r.meta,s=t??e.baseVersion??r.meta.version,c=await it(n,a,{...i,_version:s,locale:o});return e.onSaved(await Bd(e,r,c),i),ia(c)}async function Bd(e,t,n){let{slug:r,locale:i}=t.meta;try{return await S(e.collection,r,i)}catch{let r={...t.meta,version:n.version,liveVersion:n.liveVersion};return{...t,...e.draft,defaults:e.draft.defaults??t.defaults,meta:r}}}function Vd(e,t,n){return n===null||n===t?`Published ${e} · v${t} is live.`:`Published ${e} · v${t} is live, recorded as v${n}.`}async function Hd(e,t){let{collection:n,saved:r}=e;if(!r)throw Error(`Save the draft first.`);let{slug:i,locale:a,version:o}=r.meta,s=await lt(n,i,{status:Fd[t],locale:a});return e.onReplaced(await S(n,i,a)),t===`publish`?Vd(i,o,s.version):Id[t](i)}function Ud(e){let[t,n]=(0,j.useState)(null),[r,i]=(0,j.useState)(null),a=T(),o=Et(),s=(0,j.useRef)(!1);async function c(e,t,r){if(s.current)return!1;s.current=!0,n(e),i(null);let c;try{c=await t()}catch(e){return i(Pd(e,r)),!1}finally{s.current=!1,n(null)}return a({text:c}),o(),!0}return{busy:t,failure:r,save:async t=>{await c(`save`,()=>zd(e,t),`The draft could not be saved`)},changePublication:t=>c(`publish`,()=>Hd(e,t),`The change could not be made`)}}function Wd(e){let t=new URLSearchParams(e);return t.delete(ad),t.sort(),t.toString()}function Gd(e,t){return e.pathname!==t.pathname||Wd(e.search)!==Wd(t.search)}function Kd(e){let t=(0,j.useRef)(e);t.current=e;let n=(0,j.useRef)(!1),r=(0,j.useCallback)(({currentLocation:e,nextLocation:r})=>n.current||!t.current?!1:Gd(e,r),[]),i=s(r);return(0,j.useEffect)(()=>{if(!e)return;function t(e){e.preventDefault(),e.returnValue=``}return window.addEventListener(`beforeunload`,t),()=>window.removeEventListener(`beforeunload`,t)},[e]),{blocker:i,release:(0,j.useCallback)(()=>{n.current=!0},[])}}function qd(){let[e,t]=(0,j.useState)(``),[n,r]=(0,j.useState)(!1);return{value:e,onChange:(0,j.useCallback)(e=>{t(e),r(!0)},[]),suggestFrom:(0,j.useCallback)((e,r)=>{!n&&Su(e)&&typeof r==`string`&&t(xu(r))},[n])}}function Jd(e){return typeof e==`number`?`number`:typeof e==`boolean`?`boolean`:typeof e==`string`?/^\d{4}-\d{2}-\d{2}/.test(e)?`date`:/^https?:\/\//.test(e)?`url`:/^[^@\s]+@[^@\s]+\.[^@\s]+$/.test(e)?`email`:/^#[0-9a-f]{3,8}$/i.test(e)?`color`:`string`:`string`}function Yd(e,t){let[n,r]=(0,j.useState)(t),i=T();return[n,(0,j.useCallback)(async(t,n)=>{try{await ut(e,{name:t,type:Jd(n),required:!1}),r(await nt(e)),i({text:`${t} is now a field of the schema.`})}catch(e){i({text:E(e,`${t} could not be promoted`),tone:`error`})}},[e,i])]}function Xd(e,t){let{setField:n}=e,{suggestFrom:r}=t;return(0,j.useCallback)((e,t)=>{n(e,t),r(e,t)},[n,r])}function Zd(e,t){if(!t)return wu(e.collection,e.locale);let{slug:n,locale:r}=t.meta;return Cu(e.collection,n,r)}function Qd(e,t){return e.draft.dirty||e.document===null&&t.value.trim()!==``}function $d(e,t,n){let r=u().hasRole(`editor`),i=t.document?.meta,a=kd(r&&i?{collection:e.collection,slug:i.slug,locale:i.locale}:null),o=Qd(t,n);return{canEdit:r,lock:a,autosave:hd({key:Zd(e,t.document),draft:t.draft.draft,dirty:o,opened:t.opened,context:{baseVersion:t.baseVersion??void 0,slug:t.document?void 0:n.value}}),dirty:o,guard:Kd(o)}}function ef(e,t,n,r){let i=l(),{collection:a,locale:o}=e,{release:s}=r.guard,{forget:c}=r.autosave,u=(0,j.useCallback)(e=>{c(),s();let t=ot(a,e,o);i(`${t}${t.includes(`?`)?`&`:`?`}${ad}=structure`)},[c,s,i,a,o]);return Ud({collection:a,saved:t.document,baseVersion:t.baseVersion,newLocale:o,draft:t.draft.draft,newSlug:n.value,onSaved:t.onSaved,onReplaced:t.onReplaced,onCreated:u})}function tf(e,t){return e.state===`foreign`?e.holder:e.state===`held`?null:t.failure?.lockedBy??null}function nf(e,t,n,r,i){let a=e.document?.meta;return{saved:a?{version:a.version,liveVersion:a.liveVersion}:null,dirty:t,busy:n.busy!==null,canEdit:r,lockedBy:i,rebased:a!==void 0&&e.baseVersion!==a.version,conflict:n.failure?.conflictWith!==void 0}}function rf(e,t,n){let{replace:r}=e.draft,{restoredOn:i}=e,{onChange:a}=t,{restore:o}=n;return(0,j.useCallback)(()=>{let e=o();e&&(r({fields:e.fields,body:e.body,metadata:e.metadata,defaults:e.defaults}),i(e.baseVersion),e.slug&&a(e.slug))},[o,r,i,a])}function af(e,t){let{collection:n}=t,[r,i]=Yd(n,e.schema),a=yd(e),{document:o,draft:s,onReplaced:c}=a,l=qd(),{canEdit:d,lock:f,autosave:p,dirty:m,guard:h}=$d(t,a,l),g=ef(t,a,l,{guard:h,autosave:p}),_=tf(f,g),v=u().hasRole(`admin`),y=o===null&&g.busy===`save`,b=o?.meta,x=(0,j.useCallback)(async()=>{b&&c(await S(n,b.slug,b.locale))},[n,b,c]);return{prepareSnapshot:e=>s.replace(e),schema:r,document:o,draft:s,newSlug:l,lock:f,autosave:p,actions:g,guard:h,canEdit:d,isAdmin:v,creating:y,readOnly:!d||_!==null||y,facts:nf(a,m,g,d,_),baseVersion:a.baseVersion,openedFields:a.openedFields,setField:Xd(s,l),restoreKept:rf(a,l,p),promote:i,reloadDocument:x}}function of(e){(0,j.useEffect)(()=>{let t=document.activeElement;(!t||t===document.body)&&e.current?.focus()},[e])}function sf({ws:e,source:t}){let{locales:n}=t;return!e.document||!n||!at(n)?null:(0,M.jsx)(nl,{collection:e.document.meta.collection,slug:e.document.meta.slug,current:e.document.meta.locale,locales:n.supportedLocales,defaultLocale:n.defaultLocale,canCreate:e.canEdit})}function cf(e,{source:t,target:n}){let r=f(),i=n.collection===`globals`?`global`:`page`,a=e.document?.meta,o=a?sa({collection:t.collection,slug:a.slug,liveVersion:a.liveVersion,preview:e.canEdit&&_(r,`sitePreview`),baseUrl:t.site?.site.baseUrl??null}):null,s=t.collection?.pages??!1;return{kind:i,hasPage:s,modes:od(i,s),title:a?a.slug:`New ${m(n.collection)}`,siteLink:o,missingLocale:a&&n.locale&&n.locale!==a.locale?n.locale:null,showPanel:i===`page`}}function lf({ws:e,view:t,ids:n,mode:r,onMode:i,openDialog:a,source:o}){let s=e.document?.meta,c=s?{status:s.status,createdAt:s.createdAt,changedBy:s.changedBy}:null;return(0,M.jsx)(Xu,{modes:t.modes,mode:r,onMode:i,tabId:e=>`${n}-mode-${e}`,panelId:`${n}-canvas`,facts:e.facts,saving:e.actions.busy===`save`,record:c,lock:e.lock,locales:(0,M.jsx)(sf,{ws:e,source:o}),siteLink:t.siteLink,onSave:()=>void e.actions.save(),onPublish:()=>a({kind:`publish`}),onStatusChange:s&&!e.readOnly?e=>a({kind:`status`,change:e}):null})}function uf(e,t){let[n,r]=o();return[sd(n.get(ad),e,t),(0,j.useCallback)(e=>{r(t=>{let n=new URLSearchParams(t);return n.set(ad,e),n},{replace:!0})},[r])]}function df(e){let t=af(e.source,e.target),n=cf(t,e),r=e.target.slug===void 0,[i,a]=uf(n.kind,{isNew:r,hasPage:n.hasPage}),[o,s]=(0,j.useState)(null),c=(0,j.useId)(),l=(0,j.useRef)(null),u=(0,j.useRef)(null);of(l);let d=(0,j.useCallback)(()=>s(null),[]),f={...e,ws:t,view:n,ids:c,mode:i};return(0,M.jsxs)(`section`,{ref:l,className:`editor`,tabIndex:-1,"aria-labelledby":`${c}-title`,children:[(0,M.jsx)(`h1`,{id:`${c}-title`,className:`visually-hidden`,children:n.title}),(0,M.jsx)(lf,{...f,onMode:a,openDialog:s}),(0,M.jsx)(rd,{workspace:t,missingLocale:n.missingLocale,onAnswered:()=>u.current?.focus()}),n.kind===`page`&&i!==`data`&&t.document&&(0,M.jsx)(Or,{timeline:!0,collection:t.document.meta.collection,slug:t.document.meta.slug,locale:t.document.meta.locale,saved:{version:t.document.meta.version,liveVersion:t.document.meta.liveVersion},draft:t.draft.draft,unsaved:t.draft.dirty,canRestore:t.isAdmin&&!t.readOnly,onRestored:t.reloadDocument,onPrepare:t.prepareSnapshot}),(0,M.jsx)(hu,{ws:t,kind:n.kind,source:e.source,collection:e.target.collection,ids:c,mode:i,onMode:a,showPanel:n.showPanel,canvasRef:u}),(0,M.jsx)(Lu,{ws:t,hasPage:n.hasPage,dialog:o,close:d})]})}function ff(){return(0,M.jsxs)(`div`,{className:`editor`,"aria-busy":`true`,children:[(0,M.jsx)(`p`,{className:`visually-hidden`,role:`status`,children:`Loading the document…`}),(0,M.jsx)(`div`,{className:`editor-header editor-skeleton`,"aria-hidden":`true`}),(0,M.jsx)(`div`,{className:`editor-structure editor-skeleton editor-skeleton--canvas`,"aria-hidden":`true`})]})}function pf({target:e}){let{loaded:t,reload:n}=dd(e);return t.state===`loading`?(0,M.jsx)(ff,{}):t.state===`error`?(0,M.jsx)(It,{title:`The document could not load`,message:t.message,onRetry:n}):t.data?(0,M.jsx)(df,{source:t.data,target:e}):(0,M.jsx)(bt,{})}function mf({collection:e}){let t=a(),[n]=o(),r=e??t.collection,i=n.get(`locale`)??void 0;if(!r)return(0,M.jsx)(bt,{});let{slug:s}=t;return(0,M.jsx)(pf,{target:{collection:r,slug:s,locale:i}},`${r}/${s??``}/${i??``}`)}export{mf as EditorPage,ec as a,Vt as c,$s as i,Xs as n,fo as o,Qs as r,Ga as s,Ys as t};
@@ -0,0 +1 @@
1
+ .media-picker-layer{z-index:300;padding:var(--space-4);place-items:center;display:grid;position:fixed;inset:0}.media-picker-scrim{background:var(--color-overlay);animation:ui-fade-in var(--duration-base) var(--ease-out);position:absolute;inset:0}.media-picker{gap:var(--space-4);width:min(760px,100%);max-height:calc(100dvh - var(--space-6));padding:var(--space-5);background:var(--color-surface-raised);border:1px solid var(--color-border);border-radius:var(--radius-md);box-shadow:var(--shadow-lg);animation:ui-rise-in var(--duration-base) var(--ease-out);flex-direction:column;display:flex;position:relative;overflow-y:auto}.media-picker:focus{outline:none}.media-picker-title{font-size:var(--text-md);font-weight:600}.media-picker-grid{gap:var(--space-3);grid-template-columns:repeat(auto-fill,minmax(120px,1fr));list-style:none;display:grid}.media-picker-file{gap:var(--space-1);width:100%;padding:0 0 var(--space-2);background:var(--color-surface);border:1px solid var(--color-border);border-radius:var(--radius-sm);color:var(--color-text);font:inherit;text-align:start;cursor:pointer;flex-direction:column;display:flex;overflow:hidden}.media-picker-file:hover{border-color:var(--color-accent)}.media-picker-file:focus-visible{box-shadow:var(--shadow-focus);outline:none}.media-picker-file img{aspect-ratio:4/3;object-fit:cover;background:var(--color-bg-subtle);width:100%}.media-picker-name{padding:0 var(--space-2);font-size:var(--text-xs);text-overflow:ellipsis;white-space:nowrap;overflow:hidden}.media-picker-actions{justify-content:flex-end;display:flex}.editor-checkbox{width:18px;height:18px;accent-color:var(--color-accent)}.editor-color{align-items:center;gap:var(--space-2);display:inline-flex}.editor-color-swatch{background:var(--color-surface);border:1px solid var(--color-border-input);border-radius:var(--radius-sm);width:34px;height:34px;padding:2px}.editor-tags{gap:var(--space-2);flex-direction:column;width:100%;display:flex}.editor-tags-list{gap:var(--space-1);flex-wrap:wrap;list-style:none;display:flex}.editor-tag{align-items:center;gap:var(--space-1);height:26px;padding:0 2px 0 var(--space-2);background:var(--color-bg-subtle);border:1px solid var(--color-border);border-radius:var(--radius-full);font-size:var(--text-xs);display:inline-flex}.editor-tag-remove{border-radius:var(--radius-full);width:24px;height:24px;color:var(--color-text-muted);cursor:pointer;background:0 0;border:none;place-items:center;display:inline-grid}.editor-tag-remove:hover{background:var(--color-hover);color:var(--color-text)}.editor-tag-remove svg{width:12px;height:12px}.editor-media{align-items:center;gap:var(--space-3);width:100%;min-inline-size:0;padding:var(--space-2);border:1px solid var(--color-border);border-radius:var(--radius-sm);flex-wrap:wrap;margin:0;display:flex}.editor-media-thumb{object-fit:cover;background:var(--color-bg-subtle);border-radius:4px;flex-shrink:0;width:64px;height:48px}.editor-media-thumb--empty{color:var(--color-text-subtle);place-items:center;display:grid}.editor-media-thumb--empty svg{width:18px;height:18px}.editor-media-text{flex-direction:column;flex:1;gap:2px;min-width:160px;display:flex}.editor-media-name{overflow-wrap:anywhere;font-weight:550}.editor-media-meta{color:var(--color-text-muted);font-family:var(--font-mono);font-size:var(--text-xs)}.editor-media-alt{align-items:center;gap:var(--space-1);color:var(--color-live-ink);font-size:var(--text-xs);display:inline-flex}.editor-media-alt--missing{color:var(--color-ahead-ink)}.editor-media-alt svg{width:13px;height:13px}.editor-media-actions{gap:var(--space-1);display:flex}.editor-timestamp{align-items:baseline;gap:var(--space-2);flex-wrap:wrap;display:flex}.editor-timestamp-shown{color:var(--color-text-muted);font-size:var(--text-xs)}.editor-metadata{border:1px solid var(--color-border);border-radius:var(--radius-lg);padding:var(--space-4);background:var(--color-surface);min-width:0}.editor-metadata h3{font-size:var(--text-base);margin:0;font-weight:650}.metadata-intro{color:var(--color-text-muted);font-size:var(--text-sm);margin:var(--space-1) 0 var(--space-3)}.metadata-groups{border:0;min-width:0;margin:0;padding:0}.metadata-group{border-top:1px solid var(--color-border);padding:var(--space-3) 0}.metadata-group:last-child{padding-bottom:0}.metadata-group>summary,.metadata-advanced>summary,.metadata-defaults>summary{align-items:center;gap:var(--space-2);cursor:pointer;font-size:var(--text-sm);font-weight:600;list-style:none;display:flex}.metadata-group>summary::-webkit-details-marker{display:none}.metadata-advanced>summary::-webkit-details-marker{display:none}.metadata-defaults>summary::-webkit-details-marker{display:none}.metadata-group>summary:after,.metadata-advanced>summary:after,.metadata-defaults>summary:after{content:"";width:6px;height:6px;color:var(--color-text-muted);border-bottom:1.5px solid;border-right:1.5px solid;margin-left:auto;transform:rotate(-45deg)}.metadata-group[open]>summary:after,.metadata-advanced[open]>summary:after,.metadata-defaults[open]>summary:after{transform:rotate(45deg)}.metadata-property{gap:var(--space-1);margin:var(--space-3) 0;min-width:0;display:grid}.metadata-label-row{justify-content:space-between;align-items:center;gap:var(--space-2);min-height:24px;font-size:var(--text-sm);font-weight:500;display:flex}.metadata-label-row .ui-button{width:24px;min-height:24px;padding:4px}.metadata-label-row .ui-button.metadata-change{width:auto;padding:2px var(--space-2)}.metadata-property .editor-control{width:100%;min-width:0;max-width:none;font-size:var(--text-sm);padding:8px 10px}.metadata-property .editor-control--area{min-height:80px}.metadata-help,.metadata-source{font-size:var(--text-xs);color:var(--color-text-muted);margin:var(--space-1) 0 0;line-height:1.5}.metadata-source{color:var(--color-live-ink)}.metadata-default-label{font-size:var(--text-xs);color:var(--color-text-muted);font-weight:400}.metadata-search-value{margin-top:var(--space-3)}.metadata-sharing .editor-media{gap:var(--space-2);padding:var(--space-2)}.metadata-sharing .editor-media-thumb{width:44px;height:36px}.metadata-sharing .editor-media-text{min-width:0;font-size:var(--text-xs)}.metadata-sharing .editor-media .ui-button{font-size:var(--text-xs);min-height:28px}.metadata-sharing .editor-media-meta{display:none}.metadata-advanced{border-top:1px solid var(--color-border);padding-top:var(--space-3);margin-top:var(--space-3)}.metadata-advanced>summary{color:var(--color-text-muted);font-weight:500}.metadata-remove-group{color:var(--color-text-muted);font-size:var(--text-xs);margin-top:var(--space-2)}.metadata-defaults{margin-top:var(--space-3);padding-top:var(--space-3);border-top:1px solid var(--color-border)}.metadata-defaults>summary{color:var(--color-text-muted);font-weight:500;font-size:var(--text-xs)}.metadata-defaults>p{font-size:var(--text-xs);color:var(--color-text-muted);margin:var(--space-2) 0}.metadata-defaults-fields{gap:var(--space-2);margin:var(--space-2) 0 0;border:0;min-width:0;padding:0;display:grid}.metadata-defaults-fields label{gap:var(--space-1);font-size:var(--text-xs);display:grid}.metadata-defaults-fields .editor-control{width:100%;min-width:0;font-size:var(--text-sm)}.metadata-graph-link{gap:var(--space-2);font-size:var(--text-sm);display:grid}.metadata-graph-link>.ui-button{justify-self:start;padding-left:0}.metadata-object,.metadata-array{border:1px solid var(--color-border);border-radius:var(--radius-sm);padding:var(--space-3);margin:var(--space-3) 0;min-width:0}.metadata-array-item{border-bottom:1px solid var(--color-border);padding-bottom:var(--space-2)}.metadata-record{gap:var(--space-2);display:grid}.metadata-group--absent{justify-content:space-between;align-items:center;gap:var(--space-2);display:flex}.metadata-group-title{align-items:baseline;gap:var(--space-2);margin:0 0 var(--space-2);font-size:var(--text-sm);font-weight:600;display:flex}.metadata-key{font-family:var(--font-mono);font-size:var(--text-xs);color:var(--color-text-muted);font-weight:400}.metadata-system{margin:var(--space-3) 0 0;padding-top:var(--space-3);border-top:1px solid var(--color-border);color:var(--color-text-muted);font-size:var(--text-xs)}.metadata-group--bare{border-top:0;padding:0}.editor-metadata .side-facts{margin:var(--space-2) 0 0}.data-versions{flex-direction:column;list-style:none;display:flex}.data-version{align-items:center;gap:var(--space-2) var(--space-3);padding:var(--space-2) 0;border-top:1px solid var(--color-border);font-size:var(--text-sm);grid-template-columns:3.5em minmax(0,1fr) auto auto;display:grid}.data-version:first-child{border-top:none}.data-version-number{font-family:var(--font-mono);font-variant-numeric:tabular-nums;font-weight:600}.data-version-meta{gap:0 var(--space-3);min-width:0;color:var(--color-text-muted);font-size:var(--text-xs);overflow-wrap:anywhere;flex-wrap:wrap;display:flex}.data-version-meta time{font-family:var(--font-mono);font-variant-numeric:tabular-nums}.data-version-chips,.data-version-actions{gap:var(--space-1);display:flex}.data-version-actions{justify-content:flex-end}.data-diff{gap:var(--space-2);min-width:0;padding-top:var(--space-3);border-top:1px solid var(--color-border);flex-direction:column;display:flex}.data-diff-head{justify-content:space-between;align-items:center;gap:var(--space-2);flex-wrap:wrap;display:flex}.data-diff-title{font-family:var(--font-mono);font-size:var(--text-sm);font-weight:600}.data-diff-title:focus-visible{outline:2px solid var(--color-focus);outline-offset:2px;border-radius:2px}.data-diff-title:focus:not(:focus-visible){outline:none}.data-diff-controls{gap:var(--space-1);flex-wrap:wrap;display:flex}.data-diff-body{border:1px solid var(--color-border);border-radius:var(--radius-sm);max-height:520px;font-size:var(--text-xs);overflow:auto}@media (width<=640px){.data-version{grid-template-columns:3.5em minmax(0,1fr)}.data-version-chips,.data-version-actions{grid-column:2;justify-content:flex-start}}.snapshot-timeline{min-width:0;margin-bottom:var(--space-4);padding:4px var(--space-3);background:var(--color-surface);border:1px solid var(--color-border);border-radius:var(--radius-md)}.snapshot-heading,.snapshot-navigation,.snapshot-actions{align-items:center;gap:var(--space-2);display:flex}.snapshot-heading{flex-wrap:wrap;min-height:24px}.snapshot-heading small{color:var(--color-text-muted);font-weight:400}.snapshot-navigation{gap:var(--space-1)}.snapshot-disclosure{border:0;min-width:0;margin:0 0 0 auto;padding:0;position:relative}.snapshot-popover{z-index:20;gap:var(--space-2);width:min(360px,100vw - 48px);padding:var(--space-3);background:var(--color-surface);border:1px solid var(--color-border);border-radius:var(--radius-md);box-shadow:var(--shadow-md);font-size:var(--text-sm);flex-direction:column;display:flex;position:absolute;top:calc(100% + 4px);right:0}.snapshot-popover time,.snapshot-popover>span{color:var(--color-text-muted);font-size:var(--text-xs)}.snapshot-actions{flex-wrap:wrap}.snapshot-viewport{scrollbar-width:none;overscroll-behavior-x:contain;flex:1;min-width:0;overflow-x:auto}.snapshot-viewport::-webkit-scrollbar{display:none}.snapshot-ruler{height:44px;position:relative}.snapshot-ruler:before{content:"";background:var(--color-border-strong);height:2px;position:absolute;top:23px;left:0;right:0}.snapshot-markers{height:100%;margin:0;padding:0;list-style:none;display:flex}.snapshot-markers li{flex:1;min-width:104px}.snapshot-stop{width:100%;height:44px;color:var(--color-text-muted);cursor:pointer;background:0 0;border:0;flex-direction:column;justify-content:space-between;align-items:center;padding:0;font-size:11px;display:flex;position:relative}.snapshot-stop[aria-pressed=true]{color:var(--color-accent-ink);font-weight:600}.snapshot-stop:focus-visible{outline:2px solid var(--color-focus);outline-offset:-2px;border-radius:var(--radius-sm)}.snapshot-label{white-space:nowrap;align-items:baseline;gap:3px;display:flex}.snapshot-label>span{font-size:10px}.snapshot-live{color:var(--color-live-ink)}.snapshot-tick{background:var(--color-border-input);width:2px;height:12px;position:absolute;top:18px;left:calc(50% - 1px)}.snapshot-slider{appearance:none;top:14px;left:calc(var(--snapshot-edge) - 10px);width:calc(100% - var(--snapshot-edge) - var(--snapshot-edge) + 20px);cursor:ew-resize;background:0 0;height:20px;margin:0;position:absolute}.snapshot-slider::-webkit-slider-runnable-track{background:0 0;height:2px}.snapshot-slider::-moz-range-track{background:0 0;height:2px}.snapshot-slider::-webkit-slider-thumb{appearance:none;border:2px solid var(--color-accent-contrast);background:var(--color-accent);width:20px;height:20px;box-shadow:0 0 0 1px var(--color-accent);border-radius:3px;margin-top:-9px}.snapshot-slider::-moz-range-thumb{border:2px solid var(--color-accent-contrast);background:var(--color-accent);width:16px;height:16px;box-shadow:0 0 0 1px var(--color-accent);border-radius:3px}.snapshot-slider:focus-visible{outline:2px solid var(--color-focus);outline-offset:2px;border-radius:var(--radius-sm)}.snapshot-single{background:var(--color-accent);pointer-events:none;border-radius:3px;width:16px;height:16px;position:absolute;top:16px;left:calc(50% - 8px)}.snapshot-preview-note{color:var(--color-text-muted);margin-bottom:var(--space-3)}.snapshot-fields{margin:var(--space-3) 0}.snapshot-fields pre{font-size:var(--text-xs);overflow:auto}.snapshot-body{overflow-wrap:anywhere;line-height:1.6}.snapshot-body>*+*{margin-top:var(--space-3)}.snapshot-body table{border-collapse:collapse;display:block;overflow-x:auto}.snapshot-body th,.snapshot-body td{border:1px solid var(--color-border);padding:var(--space-2)}.editor-finding{align-items:flex-start;gap:var(--space-2);font-size:var(--text-xs);line-height:var(--leading-dense);display:flex}.editor-finding-icon{flex:none;width:14px;height:14px;margin-top:2px}.editor-finding--error .editor-finding-icon{color:var(--color-danger-strong)}.editor-finding--warning .editor-finding-icon{color:var(--color-ahead-ink)}.editor-finding--info .editor-finding-icon{color:var(--color-text-subtle)}.editor-finding-text{overflow-wrap:anywhere;min-width:0}.editor-finding-text code{font-family:var(--font-mono);font-size:.92em}.editor-finding-reader{font-weight:600}.editor-finding-source{margin-left:var(--space-1);color:var(--color-accent-ink);align-items:center;gap:2px;display:inline-flex}.editor-finding-source svg{width:10px;height:10px}.serp-preview{border:1px solid var(--color-border);border-radius:var(--radius-md);background:#fff;max-width:600px;padding:20px;font-family:Arial,sans-serif}.serp-preview p{margin:0}.serp-preview-url-row{align-items:center;gap:10px;margin-bottom:4px;display:flex}.serp-preview-favicon{background:#f1f3f4;border:1px solid #dadce0;border-radius:50%;flex-shrink:0;width:26px;height:26px}.serp-preview-url-group{flex-direction:column;display:flex}.serp-preview-site-name{color:#202124;font-size:14px;line-height:1.3}.serp-preview-breadcrumb{color:#4d5156;font-size:12px;line-height:1.3}.serp-preview-title{color:#1a0dab;text-overflow:ellipsis;white-space:nowrap;max-width:600px;margin-bottom:4px;font-size:20px;line-height:1.3;text-decoration:none;display:block;overflow:hidden}.serp-preview-description{color:#4d5156;-webkit-line-clamp:2;line-clamp:2;-webkit-box-orient:vertical;max-width:600px;margin:0;font-size:14px;line-height:1.58;display:-webkit-box;overflow:hidden}.social-previews{gap:var(--space-4);grid-template-columns:repeat(auto-fit,minmax(240px,1fr));display:grid}.social-preview{gap:var(--space-2);flex-direction:column;min-width:0;display:flex}.social-preview-label{color:var(--color-text-muted);font-family:var(--font-mono);font-size:var(--text-xs)}.social-card{background:var(--color-bg-subtle);border:1px solid var(--color-border);border-radius:var(--radius-md);flex-direction:column;display:flex;overflow:hidden}.social-card-image{aspect-ratio:1200/630;background:var(--color-surface);border-bottom:1px solid var(--color-border);justify-content:center;align-items:center;display:flex;overflow:hidden}.social-card-image img{object-fit:cover;width:100%;height:100%}.social-card-image--empty{gap:var(--space-1);color:var(--color-text-subtle);font-size:var(--text-xs);flex-direction:column}.social-card-image--empty svg{width:20px;height:20px}.social-card-text{min-width:0;padding:var(--space-3);flex-direction:column;gap:2px;display:flex}.social-card-site{color:var(--color-text-muted);font-size:var(--text-xs);text-transform:uppercase;letter-spacing:.04em}.social-card-title{font-size:var(--text-sm);-webkit-line-clamp:2;line-clamp:2;-webkit-box-orient:vertical;font-weight:650;display:-webkit-box;overflow:hidden}.social-card-description{color:var(--color-text-muted);font-size:var(--text-xs);-webkit-line-clamp:2;line-clamp:2;-webkit-box-orient:vertical;display:-webkit-box;overflow:hidden}.editor-structure{gap:var(--space-5);padding:var(--space-5);background:var(--color-surface);border:1px solid var(--color-border);border-radius:var(--radius-md);flex-direction:column;display:flex}.editor-structure-fields{gap:var(--space-5);border:none;flex-direction:column;min-inline-size:0;display:flex}.editor-field{align-items:flex-start;gap:var(--space-2);flex-direction:column;display:flex}.editor-field-head{align-items:center;gap:var(--space-1) var(--space-2);flex-wrap:wrap;display:flex}.editor-field-label{color:var(--color-text);font-family:var(--font-mono);font-size:var(--text-sm);font-weight:600}.editor-field-required{color:var(--color-danger-strong);margin-left:2px}.editor-field-optional{color:var(--color-text-subtle);font-size:var(--text-xs)}.ui-chip.editor-field-pill{font-family:var(--font-mono);font-weight:500}.editor-field-help{max-width:68ch;color:var(--color-text-muted);font-size:var(--text-xs)}.editor-field-error{color:var(--color-danger-strong);font-size:var(--text-xs);font-weight:550}.editor-control{width:100%;min-height:34px;padding:6px var(--space-3);background:var(--color-surface);border:1px solid var(--color-border-input);border-radius:var(--radius-sm);color:var(--color-text);font:inherit;font-size:var(--text-sm)}.editor-control:focus-visible{outline:2px solid var(--color-focus);outline-offset:1px}.editor-control--area{resize:vertical;min-height:80px;line-height:var(--leading-dense)}.editor-control--short{width:auto;min-width:220px;max-width:100%}.editor-field--invalid .editor-control{border-color:var(--color-danger)}.editor-structure :disabled{cursor:not-allowed;opacity:.7}.editor-field-counter{margin-top:calc(-1 * var(--space-1));color:var(--color-text-subtle);font-family:var(--font-mono);font-size:var(--text-xs);font-variant-numeric:tabular-nums;align-self:flex-end}.editor-custom-fields{gap:var(--space-3);padding-top:var(--space-4);border-top:1px solid var(--color-border);flex-direction:column;display:flex}.editor-subtitle{font-size:var(--text-base);font-weight:650}.editor-note{margin-top:calc(-1 * var(--space-2));color:var(--color-text-muted);font-size:var(--text-xs)}.editor-custom-line{gap:var(--space-2);width:100%;display:flex}.editor-body{gap:var(--space-2);padding-top:var(--space-4);border-top:1px solid var(--color-border);flex-direction:column;display:flex}.editor-body-head{align-items:baseline;gap:var(--space-1) var(--space-3);flex-wrap:wrap;display:flex}.editor-body-title{font-family:var(--font-text);font-size:var(--text-base);font-weight:650}.editor-body-hint{color:var(--color-text-muted);font-size:var(--text-xs);flex:1}.editor-body-hint code{color:var(--color-text)}.editor-body-views{gap:var(--space-1);margin-left:auto;display:inline-flex}.editor-body-panes{gap:var(--space-3);display:grid}@media (width>=900px){.editor-body-panes--split{grid-template-columns:minmax(0,1fr) minmax(0,1fr)}}.editor-body-toggle{height:28px;padding:0 var(--space-3);background:var(--color-surface);border:1px solid var(--color-border-strong);border-radius:var(--radius-sm);color:var(--color-text-muted);font:inherit;font-size:var(--text-xs);cursor:pointer;font-weight:550}.editor-body-toggle:hover{background:var(--color-hover);color:var(--color-text)}.editor-body-toggle[aria-pressed=true]{background:var(--color-accent-soft);border-color:var(--color-accent);color:var(--color-accent-ink)}.editor-body-textarea{width:100%;min-height:360px;padding:var(--space-3) var(--space-4);background:var(--color-code-bg);border:1px solid var(--color-border-input);border-radius:var(--radius-sm);color:var(--color-text);font-family:var(--font-mono);resize:vertical;tab-size:2;font-size:.8125rem;line-height:1.65}.editor-body-textarea:focus-visible{outline:2px solid var(--color-focus);outline-offset:1px}.editor-body-textarea:disabled{cursor:not-allowed;opacity:.7}.editor-body-preview{min-height:360px;padding:var(--space-4) var(--space-5);border:1px solid var(--color-border);border-radius:var(--radius-sm);line-height:var(--leading-body);overflow-wrap:anywhere}.editor-body-preview :is(h1,h2,h3,h4){margin:var(--space-4) 0 var(--space-2);font-family:var(--font-text);line-height:var(--leading-snug)}.editor-body-preview :is(p,ul,ol,pre,blockquote){margin-bottom:var(--space-3)}.editor-body-preview :is(ul,ol){padding-left:var(--space-5)}.editor-body-preview code{background:var(--color-code-bg);border-radius:4px;padding:1px 4px;font-size:.85em}.editor-body-preview pre{padding:var(--space-3);background:var(--color-code-bg);border:1px solid var(--color-code-border);border-radius:var(--radius-sm);overflow-x:auto}.editor-body-preview a{color:var(--color-accent-ink)}@media (width<=959.98px){.editor-structure{padding:var(--space-4)}}.data-mode{gap:var(--space-4);flex-direction:column;min-width:0;display:flex}.data-card{gap:var(--space-3);min-width:0;padding:var(--space-5);background:var(--color-surface);border:1px solid var(--color-border);border-radius:var(--radius-md);flex-direction:column;display:flex}.data-card-head{justify-content:space-between;align-items:center;gap:var(--space-2) var(--space-3);flex-wrap:wrap;display:flex}.data-card-title{font-family:var(--font-display);font-size:var(--text-md);font-weight:650;line-height:var(--leading-snug)}.data-card-aside{gap:var(--space-2);flex-wrap:wrap;display:flex}.data-card-lead{max-width:72ch;color:var(--color-text-muted);font-size:var(--text-sm);line-height:var(--leading-dense)}.data-note{color:var(--color-text-muted);font-size:var(--text-sm);line-height:var(--leading-dense)}.data-note--error{color:var(--color-danger-strong)}.data-mode code{font-family:var(--font-mono);font-size:.92em}.data-rich-list,.data-checks,.data-outcomes,.data-finding-list{gap:var(--space-1);flex-direction:column;list-style:none;display:flex}.data-rich{align-items:center;column-gap:var(--space-2);padding:var(--space-2) 0;border-top:1px solid var(--color-border);grid-template-columns:auto minmax(0,1fr) auto;grid-template-areas:"icon name chip""icon reader chip";display:grid}.data-rich:first-child{border-top:none}.data-rich-icon{width:16px;height:16px;color:var(--color-text-subtle);grid-area:icon}.data-rich-icon--eligible{color:var(--color-live)}.data-rich-name{font-size:var(--text-sm);grid-area:name;font-weight:600}.data-rich-reader{color:var(--color-text-muted);font-size:var(--text-xs);grid-area:reader}.data-rich .ui-chip{grid-area:chip}.data-findings{gap:var(--space-3);grid-template-columns:repeat(auto-fit,minmax(240px,1fr));display:grid}.data-finding-group{gap:var(--space-2);min-width:0;padding:var(--space-3);border:1px solid var(--color-border);border-radius:var(--radius-sm);flex-direction:column;display:flex}.data-finding-head{justify-content:space-between;align-items:center;gap:var(--space-2);display:flex}.data-finding-title{font-size:var(--text-sm);font-weight:650}.data-check,.data-outcome{align-items:flex-start;gap:var(--space-2);font-size:var(--text-xs);line-height:var(--leading-dense);display:flex}.data-check-icon,.data-outcome svg,.data-finding-clean svg{flex:none;width:14px;height:14px;margin-top:2px}.data-outcome--error svg{color:var(--color-danger-strong)}.data-check--open .data-check-icon{color:var(--color-ahead-ink)}.data-outcome--skipped svg{color:var(--color-text-subtle)}.data-finding-clean svg,.data-check-icon,.data-outcome--generated svg{color:var(--color-live)}.data-finding-clean{align-items:flex-start;gap:var(--space-2);color:var(--color-text-muted);font-size:var(--text-xs);display:flex}.data-check-label{min-width:10em;font-weight:550}.data-check-hint{color:var(--color-text-muted);font-family:var(--font-mono)}.data-fields{gap:var(--space-3);border:none;flex-direction:column;min-inline-size:0;display:flex}.data-image-field{border:none;min-inline-size:0}.data-image-field legend{margin-bottom:var(--space-1)}:is(.data-fields,.data-image-field):disabled :is(input,select,textarea,button){cursor:not-allowed;opacity:.7}.data-fields-legend{margin-bottom:var(--space-2);font-size:var(--text-sm);font-weight:650}.data-field{align-items:flex-start;gap:var(--space-1);flex-direction:column;display:flex}.data-field-label{font-family:var(--font-mono);font-size:var(--text-sm);font-weight:600}.data-field-help,.data-toggle-hint{color:var(--color-text-muted);font-size:var(--text-xs)}.data-toggle{align-items:center;gap:var(--space-2);font-size:var(--text-sm);grid-template-columns:auto auto 1fr;display:grid}.data-toggle input{width:16px;height:16px;accent-color:var(--color-accent)}.data-tag{width:fit-content;max-width:100%;padding:var(--space-1) var(--space-2);overflow-wrap:anywhere;background:var(--color-code-bg);border:1px solid var(--color-code-border);border-radius:var(--radius-sm);font-size:var(--text-xs)}.data-image-choice{align-items:center;gap:var(--space-2);flex-wrap:wrap;max-width:100%;display:flex}.data-image-value{overflow-wrap:anywhere;min-width:0;color:var(--color-text-muted);font-size:var(--text-xs)}.data-actions{gap:var(--space-2);flex-wrap:wrap;display:flex}@media (width<=640px){.data-card{padding:var(--space-4)}}.globals-banner{align-items:flex-start;gap:var(--space-2);max-width:80ch;padding:var(--space-3) var(--space-4);background:var(--color-accent-soft);border:1px solid var(--color-border);border-left:3px solid var(--color-accent);border-radius:var(--radius-md);color:var(--color-text);font-size:var(--text-sm);line-height:var(--leading-dense);display:flex}.globals-banner-icon{width:16px;height:16px;color:var(--color-accent-ink);flex-shrink:0;margin-top:2px}.globals-paths{gap:var(--space-1);padding-left:var(--space-5);flex-direction:column;display:flex}.globals-rule{max-width:72ch;font-size:var(--text-sm);line-height:var(--leading-dense)}.live-mode{gap:var(--space-3);flex-direction:column;display:flex}.live-toolbar{align-items:flex-end;gap:var(--space-2) var(--space-3);flex-wrap:wrap;display:flex}.live-stage{height:max(480px, calc(100vh - var(--topbar-height) - 220px));background:var(--color-surface);border:1px solid var(--color-border);border-radius:var(--radius-md);position:relative;overflow:hidden}.live-frame{border:0;width:100%;height:100%;display:block}.live-frame:focus-visible{outline:2px solid var(--color-focus);outline-offset:-2px}.live-layer{pointer-events:none;position:absolute;inset:0;overflow:hidden}.live-outline{border:2px solid var(--color-text);border-radius:var(--radius-sm);box-shadow:0 0 0 2px var(--color-surface);position:absolute}.live-outline--selected{box-shadow:0 0 0 3px var(--color-surface);border-width:3px}.live-outline--editing{border-color:var(--color-focus);box-shadow:0 0 0 3px var(--color-surface), 0 0 0 5px var(--color-text)}.live-tag{padding:1px var(--space-2);border-radius:var(--radius-sm);background:var(--color-text);box-shadow:0 0 0 1px var(--color-surface);color:var(--color-surface);font-family:var(--font-mono);font-size:var(--text-xs);text-overflow:ellipsis;white-space:nowrap;line-height:18px;position:absolute;overflow:hidden}.live-editor{z-index:1;gap:var(--space-2);width:min(360px, calc(100% - var(--space-4)));padding:var(--space-3);background:var(--color-surface-raised);border:1px solid var(--color-border-strong);border-radius:var(--radius-md);box-shadow:var(--shadow-lg);flex-direction:column;display:flex;position:absolute;overflow:auto}.live-editor-label{color:var(--color-text);font-family:var(--font-mono);font-size:var(--text-xs);font-weight:600}.live-editor-actions{justify-content:space-between;align-items:center;gap:var(--space-2);display:flex}.live-placeholder-marker{border-top:2px dashed var(--color-text);height:0;box-shadow:0 0 0 1px var(--color-surface);position:absolute}.live-placeholder-marker-tag{max-width:100%;padding:0 var(--space-1);border:1px dashed var(--color-text);border-radius:var(--radius-sm);color:var(--color-text);font-family:var(--font-mono);font-size:var(--text-xs);text-overflow:ellipsis;text-shadow:0 0 2px var(--color-surface), 0 0 2px var(--color-surface);white-space:nowrap;background:0 0;position:absolute;top:4px;left:0;overflow:hidden}.live-moved{color:var(--color-text-muted);font-size:var(--text-sm);align-items:center}.live-missing{gap:var(--space-2);flex-direction:column;list-style:none;display:flex}.live-placeholder{justify-content:space-between;align-items:center;gap:var(--space-2) var(--space-3);padding:var(--space-3) var(--space-4);border:1px dashed var(--color-border-input);border-radius:var(--radius-md);color:var(--color-text-muted);font-size:var(--text-sm);flex-wrap:wrap;display:flex}.live-empty{background:var(--color-surface);border:1px solid var(--color-border);border-radius:var(--radius-md)}.live-empty-url{font-family:var(--font-mono);word-break:break-all}@media (prefers-reduced-motion:no-preference){.live-outline{transition:border-width var(--duration-fast) var(--ease-out)}}.live-context{z-index:1;justify-content:space-between;align-items:center;gap:var(--space-3);min-width:0;max-width:calc(100% - var(--space-4));padding:var(--space-1) var(--space-2);background:var(--color-surface-raised);border:1px solid var(--color-border-strong);border-radius:0 0 var(--radius-md) var(--radius-md);box-shadow:var(--shadow-sm);font-size:var(--text-xs);margin:0;display:flex;position:absolute;overflow:auto}.live-context>div:not(.live-context-actions){flex-direction:column;display:flex}.live-context-actions{align-items:center;gap:var(--space-1);flex-shrink:0;display:flex}.live-context-cancel{color:var(--color-danger-strong)}.live-context-done{color:var(--color-accent)}.live-context--markdown{flex-wrap:wrap}.live-context--markdown>strong{flex:1}.live-context--markdown select{max-width:7rem;color:var(--color-text);background:var(--color-surface);border:1px solid var(--color-border);border-radius:var(--radius-sm);font:inherit}.live-loading{bottom:var(--space-2);left:var(--space-2);padding:var(--space-2);background:var(--color-surface-raised);position:absolute}.live-link-form{align-items:flex-end;gap:var(--space-2);flex-basis:100%;display:flex}.live-link-form label{flex-direction:column;flex:1;display:flex}.live-link-form input{width:100%;color:var(--color-text);background:var(--color-surface);border:1px solid var(--color-border-input);border-radius:var(--radius-sm);padding:var(--space-1)}.live-context [aria-pressed=true],.live-context [aria-pressed=true]:hover{background:var(--color-accent);color:var(--color-accent-contrast)}.live-context [aria-pressed=mixed],.live-context [aria-pressed=mixed]:hover{background:var(--color-hover);color:var(--color-text);box-shadow:inset 0 -2px var(--color-accent)}.live-context--markdown>.live-context-actions:last-child{order:1;margin-left:auto}.live-formatting{flex-basis:100%;order:2;justify-content:space-between}.live-link-form{order:3}.live-table-trigger{flex-shrink:0;order:1}.live-table-panel{border-top:1px solid var(--color-border);padding-top:var(--space-2);flex-basis:100%;order:3}.live-table-group{align-items:center;gap:var(--space-1);flex-wrap:wrap;display:flex}.live-table-group>strong{flex:1;min-width:6rem}.live-table-footer{justify-content:space-between;align-items:center;gap:var(--space-2);border-top:1px solid var(--color-border);margin-top:var(--space-2);padding-top:var(--space-2);display:flex}.live-table-panel,.live-table-group{border:0;min-width:0;margin:0;padding:0}.live-table-panel{border-top:1px solid var(--color-border);padding-top:var(--space-2)}.side-panel{gap:var(--space-3);flex-direction:column;min-width:0;display:flex}.side-panel-head{justify-content:space-between;align-items:center;gap:var(--space-2);min-height:32px;display:flex}.side-panel-title{overflow-wrap:anywhere;min-width:0;font-family:var(--font-display);font-size:var(--text-md);font-weight:650;line-height:var(--leading-snug)}.side-panel-title:focus:not(:focus-visible){outline:none}.side-panel-body{gap:var(--space-3);flex-direction:column;display:flex}.side-card{gap:var(--space-3);padding:var(--space-4);background:var(--color-surface);border:1px solid var(--color-border);border-radius:var(--radius-md);flex-direction:column;display:flex}.side-card-head{justify-content:space-between;align-items:center;gap:var(--space-2);display:flex}.side-card-title{font-size:var(--text-sm);font-weight:650;line-height:var(--leading-snug)}.side-note{color:var(--color-text-muted);font-size:var(--text-xs);line-height:var(--leading-dense)}.side-subtitle{color:var(--color-text-muted);font-size:var(--text-xs);font-weight:600}.side-facts{gap:var(--space-2);font-size:var(--text-xs);flex-direction:column;display:flex}.side-fact{gap:var(--space-2);grid-template-columns:9.5em minmax(0,1fr);align-items:baseline;display:grid}.side-fact dt{color:var(--color-text-muted)}.side-fact dd{overflow-wrap:anywhere;min-width:0;color:var(--color-text)}.side-panel code{font-family:var(--font-mono);font-size:.95em}.side-length{gap:var(--space-1);font-size:var(--text-xs);flex-direction:column;display:flex}.side-length-head{justify-content:space-between;gap:var(--space-2);display:flex}.side-length-label{font-weight:600}.side-length-figure{color:var(--color-text-muted);font-family:var(--font-mono);font-variant-numeric:tabular-nums}.side-length-state{font-weight:550}.side-length--within .side-length-state{color:var(--color-live-ink)}.side-length--under .side-length-state{color:var(--color-ahead-ink)}.side-length--over .side-length-state{color:var(--color-danger-strong)}.side-length--missing .side-length-state,.side-length-note{color:var(--color-text-muted)}.side-advice{gap:var(--space-2);padding:var(--space-2) var(--space-3);background:var(--color-ahead-soft);border-radius:var(--radius-sm);color:var(--color-ahead-ink);font-size:var(--text-xs);line-height:var(--leading-dense);flex-direction:column;list-style:none;display:flex}.side-advice li{justify-content:space-between;align-items:baseline;gap:var(--space-2);display:flex}.side-link{min-height:24px;padding:0 var(--space-1);color:inherit;font:inherit;text-underline-offset:2px;cursor:pointer;background:0 0;border:none;flex-shrink:0;font-weight:650;text-decoration:underline}.side-rows{gap:var(--space-1);flex-direction:column;list-style:none;display:flex}.side-row{justify-content:space-between;align-items:center;gap:var(--space-2);width:100%;min-height:32px;padding:var(--space-1) var(--space-2);border:1px solid var(--color-border);border-radius:var(--radius-sm);color:var(--color-text);font:inherit;font-size:var(--text-xs);text-align:left;cursor:pointer;background:0 0;display:flex}.side-row:hover{background:var(--color-hover)}.side-row--missing{border-style:dashed;border-color:var(--color-border-input);color:var(--color-text-muted)}.side-row:disabled{cursor:not-allowed;opacity:.7}.side-row-name{overflow-wrap:anywhere;min-width:0;font-weight:550}.side-row-state{align-items:center;gap:var(--space-1);color:var(--color-text-muted);flex-shrink:0;display:inline-flex}.side-row-icon{width:14px;height:14px}.side-row-icon--present{color:var(--color-live)}.side-locales{gap:var(--space-1);font-size:var(--text-xs);flex-direction:column;list-style:none;display:flex}.side-locale{align-items:center;gap:var(--space-2);grid-template-columns:3em minmax(0,1fr) auto;min-height:32px;display:grid}.side-locale a,.side-locale-name{font-family:var(--font-mono);font-weight:600}.side-locale a{color:var(--color-accent-ink)}.side-locale a[aria-current=true]{color:var(--color-text);text-decoration:none}.side-locale-state{align-items:center;gap:var(--space-2);display:inline-flex}.side-locale-state--quiet{color:var(--color-text-muted)}.side-refreshes{gap:var(--space-1);padding-top:var(--space-3);border-top:1px solid var(--color-border);font-size:var(--text-xs);flex-direction:column;display:flex}.side-refreshes .editor-impact{margin-top:0}.side-field{align-items:flex-start;gap:var(--space-2);flex-direction:column;display:flex}.side-field-head{align-items:baseline;gap:var(--space-2);display:flex}.side-field-label{font-size:var(--text-xs);overflow-wrap:anywhere;font-weight:600}.side-field-optional{color:var(--color-text-muted);font-size:var(--text-xs)}.side-field :disabled{cursor:not-allowed;opacity:.7}.side-media{gap:var(--space-3);padding-top:var(--space-3);border-top:1px solid var(--color-border);flex-direction:column;display:flex}.side-media-name{font-family:var(--font-mono);font-size:var(--text-xs);overflow-wrap:anywhere}.side-actions{gap:var(--space-2);flex-wrap:wrap;display:flex}.editor{flex-direction:column;display:flex}.editor:focus:not(:focus-visible),.editor-canvas:focus:not(:focus-visible){outline:none}.editor-header{align-items:center;gap:var(--space-2);min-height:52px;margin-bottom:var(--space-4);background:var(--color-surface);border:1px solid var(--color-border);border-radius:var(--radius-md);flex-wrap:wrap;padding:10px 20px;display:flex}.editor-header-spacer{min-width:var(--space-2);flex:1}.editor-modes{background:var(--color-bg-subtle);border:1px solid var(--color-border);border-radius:var(--radius-sm);padding:2px;display:inline-flex}.editor-mode{height:28px;padding:0 var(--space-3);color:var(--color-text-muted);font:inherit;font-size:var(--text-xs);cursor:pointer;background:0 0;border:none;border-radius:4px;font-weight:600}.editor-mode:hover{color:var(--color-text)}.editor-mode[aria-selected=true]{background:var(--color-surface);box-shadow:inset 0 -2px 0 var(--color-accent), inset 0 0 0 1px var(--color-border-strong);color:var(--color-text)}.ui-chip.editor-chip-button{height:28px;padding:0 var(--space-2);font:inherit;font-size:var(--text-xs);cursor:pointer;font-weight:550}.ui-chip.editor-chip-button:hover{border-color:var(--color-border-strong)}.editor-chip-caret{opacity:.75;margin-left:-2px}.editor-popover{position:relative}.editor-popover-panel{top:calc(100% + var(--space-1));z-index:200;width:max-content;max-width:min(320px, calc(100vw - 2 * var(--space-4)));padding:var(--space-3);background:var(--color-surface-raised);border:1px solid var(--color-border);border-radius:var(--radius-sm);box-shadow:var(--shadow-md);animation:ui-rise-in var(--duration-fast) var(--ease-out);position:absolute;right:0}.editor-detail{gap:var(--space-1) var(--space-3);font-size:var(--text-xs);grid-template-columns:auto 1fr;display:grid}.editor-detail dt{color:var(--color-text-muted)}.editor-detail dd{color:var(--color-text);font-family:var(--font-mono)}.editor-detail-text{font-size:var(--text-xs);line-height:var(--leading-dense)}.editor-detail-actions{gap:var(--space-2);margin-top:var(--space-3);padding-top:var(--space-3);border-top:1px solid var(--color-border);display:flex}.editor-locales{gap:var(--space-1);flex-wrap:wrap;display:inline-flex}.ui-chip.editor-locale{min-width:36px;height:28px;font:inherit;font-family:var(--font-mono);font-size:var(--text-xs);cursor:pointer;justify-content:center;font-weight:600;text-decoration:none}.editor-locale:hover{border-color:var(--color-border-strong);color:var(--color-text)}.editor-locale[aria-current=true]{border-color:var(--color-accent)}.editor-locale--missing{border-style:dashed;border-color:var(--color-border-input)}.ui-chip.editor-locale--quiet{cursor:default;color:var(--color-text-muted)}.editor-readonly{align-items:center;gap:var(--space-2);margin-bottom:var(--space-3);padding:var(--space-2) var(--space-3);background:var(--color-ahead-soft);border-radius:var(--radius-sm);color:var(--color-ahead-ink);font-size:var(--text-sm);display:flex}.editor-readonly--empty{margin:0;padding:0}.editor-notices{gap:var(--space-2);flex-direction:column;display:flex}.editor-notices:has(.editor-notice){margin-bottom:var(--space-4)}.editor-alert-region:empty{margin-bottom:calc(-1 * var(--space-2))}.editor-notice{align-items:center;gap:var(--space-2) var(--space-3);padding:var(--space-2) var(--space-3);background:var(--color-surface);border:1px solid var(--color-border);border-left:3px solid var(--color-accent);border-radius:var(--radius-sm);font-size:var(--text-sm);flex-wrap:wrap;display:flex}.editor-notice--error{border-left-color:var(--color-danger);background:var(--color-danger-soft)}.editor-notice-icon{width:16px;height:16px;color:var(--color-text-muted);flex-shrink:0}.editor-notice--error .editor-notice-icon{color:var(--color-danger-strong)}.editor-readonly .editor-notice-icon{color:var(--color-ahead-ink)}.editor-notice-text{flex:1;min-width:200px}.editor-notice-actions{gap:var(--space-1);display:inline-flex}.editor-columns{grid-template-columns:minmax(0, 1fr) var(--panel-width);align-items:start;gap:var(--space-4);display:grid}.editor-columns--single{grid-template-columns:minmax(0,1fr)}.editor-columns--collapsed{grid-template-columns:minmax(0,1fr) auto}.editor-side{min-width:0;position:relative}@media (width<=1099.98px){.editor-columns,.editor-columns--collapsed{grid-template-columns:minmax(0,1fr)}.editor-side .resize-handle{display:none}}.editor-impact{gap:var(--space-1);margin-top:var(--space-2);padding-left:var(--space-5);color:var(--color-text);flex-direction:column;display:flex}.editor-publish-findings{margin-top:var(--space-3)}.editor-findings{gap:var(--space-1);margin-top:var(--space-2);color:var(--color-text);flex-direction:column;list-style:none;display:flex}.editor-modal-error{margin-top:var(--space-3);color:var(--color-danger-strong)}.editor-skeleton{background:var(--color-bg-subtle)}.editor-skeleton--canvas{min-height:420px}
@@ -0,0 +1 @@
1
+ .ui-empty-state{align-items:center;gap:var(--space-2);padding:var(--space-6) var(--space-4);text-align:center;flex-direction:column;display:flex}.ui-empty-state-icon{width:40px;height:40px;margin-bottom:var(--space-1);border-radius:var(--radius-full);background:var(--color-live-soft);color:var(--color-live-ink);place-items:center;display:grid}.ui-empty-state-icon svg{width:20px;height:20px}.ui-empty-state-title{font-size:var(--text-base);font-weight:600}.ui-empty-state-body{max-width:44ch;color:var(--color-text-muted)}.ui-empty-state-action{margin-top:var(--space-2)}
@@ -0,0 +1 @@
1
+ import{a as e}from"./vendor-diff-Dm2YfgXt.js";var t=e();function n({icon:e,title:n,titleId:r,children:i,action:a}){return(0,t.jsxs)(`div`,{className:`ui-empty-state`,children:[(0,t.jsx)(`span`,{className:`ui-empty-state-icon`,"aria-hidden":`true`,children:(0,t.jsx)(e,{})}),(0,t.jsx)(`p`,{id:r,className:`ui-empty-state-title`,children:n}),i&&(0,t.jsx)(`div`,{className:`ui-empty-state-body`,children:i}),a&&(0,t.jsx)(`div`,{className:`ui-empty-state-action`,children:a})]})}export{n as t};
@@ -0,0 +1 @@
1
+ import{t as e}from"./createLucideIcon-D_HN41p3.js";var t={name:`download`,size:24,node:[[`path`,{d:`M12 15V3`,key:`m9g1x1`}],[`path`,{d:`M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4`,key:`ih7n3h`}],[`path`,{d:`m7 10 5 5 5-5`,key:`brsn70`}]]};t.node;var n=e(t);function r(e){return JSON.stringify(e,null,2)}function i(e){return`<script type="application/ld+json">\n${JSON.stringify(e,null,2)}\n<\/script>`}function a(e,t){return e&&t?`${e}-${t}.jsonld`:e?`${e}.jsonld`:`site.jsonld`}function o(e,t,n){let r=new Blob([e],{type:n}),i=URL.createObjectURL(r),a=document.createElement(`a`);a.href=i,a.download=t,a.click(),URL.revokeObjectURL(i)}export{n as a,a as i,r as n,i as r,o as t};
@@ -0,0 +1 @@
1
+ import{t as e}from"./createLucideIcon-D_HN41p3.js";var t={name:`external-link`,size:24,node:[[`path`,{d:`M15 3h6v6`,key:`1q9fwt`}],[`path`,{d:`M10 14 21 3`,key:`gplh6r`}],[`path`,{d:`M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6`,key:`a6xqqp`}]]};t.node;var n=e(t);export{n as t};
@@ -0,0 +1 @@
1
+ import{i as e}from"./rolldown-runtime-Dd_uD5pT.js";import{s as t}from"./vendor-diff-Dm2YfgXt.js";import{t as n}from"./createLucideIcon-D_HN41p3.js";import{r,v as i}from"./api-seo-2H6_VoWE.js";import{f as a}from"./index-DVe5jFLX.js";var o={name:`sparkles`,size:24,node:[[`path`,{d:`M11.017 2.814a1 1 0 0 1 1.966 0l1.051 5.558a2 2 0 0 0 1.594 1.594l5.558 1.051a1 1 0 0 1 0 1.966l-5.558 1.051a2 2 0 0 0-1.594 1.594l-1.051 5.558a1 1 0 0 1-1.966 0l-1.051-5.558a2 2 0 0 0-1.594-1.594l-5.558-1.051a1 1 0 0 1 0-1.966l5.558-1.051a2 2 0 0 0 1.594-1.594z`,key:`1s2grr`}],[`path`,{d:`M20 2v4`,key:`1rf3ol`}],[`path`,{d:`M22 4h-4`,key:`gwowj6`}],[`circle`,{cx:`4`,cy:`20`,r:`2`,key:`6kqj1y`}]],aliases:[`stars`]};o.node;var s=n(o),c=e(t(),1),l={"meta-descriptions":`Meta description`,archetype:`Schema.org properties`},u=500,d=e=>new Promise(t=>setTimeout(t,e));async function f(e,t,n){for(;;){let i=await r(e);if(!t())return null;if(n(i),i.status!==`running`)return i;await d(u)}}async function p(e,t,n,r=()=>void 0,a=!1){let o=await i({type:e,force:a,...t});if(!o.jobId)return{state:`empty`,message:o.message??`Nothing to enrich`};let s=await f(o.jobId,n,r);return s?{state:`finished`,status:s}:null}var m={steps:[`meta-descriptions`,`archetype`],force:!1},h={steps:[`meta-descriptions`],force:!1},g={steps:m.steps,force:!0};function _(e,t){return`step ${e.steps.indexOf(t)+1} of ${e.steps.length}`}var v={state:`idle`},y=new Set;function b(e){v=e;for(let e of y)e()}function x(e){return y.add(e),()=>{y.delete(e)}}var S=()=>v;async function C(e,t){let n=[];for(let r of t.steps){let i=e=>({state:`running`,plan:t,step:r,status:e,done:[...n]});b(i(null));let a=await p(r,e,()=>!0,e=>b(i(e)),t.force);if(!a)throw Error(`${r} stopped without an answer`);n.push(a.state===`empty`?{step:r,empty:a.message,status:null}:{step:r,empty:null,status:a.status})}return n}function w(e,t,n=m){return v.state!==`running`&&(C(e,n).then(e=>b({state:`done`,plan:n,reports:e}),e=>{let t=v.state===`running`?v.done:[];b({state:`failed`,plan:n,message:a(e,`Enrichment failed`),reports:t})}).finally(()=>t(v)),!0)}function T(){v.state!==`running`&&b({state:`idle`})}function E(){return(0,c.useSyncExternalStore)(x,S,S)}export{w as a,l as c,T as i,p as l,g as n,_ as o,h as r,E as s,m as t,s as u};
@@ -0,0 +1 @@
1
+ .ui-tabs{gap:var(--space-1);border-bottom:1px solid var(--color-border);scrollbar-width:thin;display:flex;overflow-x:auto}.ui-tab{min-height:40px;padding:0 var(--space-3);color:var(--color-text-muted);font:inherit;font-size:var(--text-sm);white-space:nowrap;cursor:pointer;background:0 0;border:none;border-bottom:2px solid #0000;flex-shrink:0;margin-bottom:-1px;font-weight:600}.ui-tab:hover{color:var(--color-text)}.ui-tab[aria-selected=true]{border-bottom-color:var(--color-accent);color:var(--color-text)}.fill-run-field{gap:var(--space-1);max-width:480px;font-size:var(--text-sm);flex-direction:column;font-weight:600;display:flex}.fill-run-select{min-height:36px;padding:var(--space-2) var(--space-3);border:1px solid var(--color-border-input);border-radius:var(--radius-sm);background:var(--color-surface);color:var(--color-text);font:inherit;font-weight:400}.fill-run-note{color:var(--color-text-muted);font-size:var(--text-sm);line-height:var(--leading-dense)}.fill-run-reports,.fill-run-items{gap:var(--space-1);padding-left:var(--space-4);font-size:var(--text-sm);flex-direction:column;display:flex}.fill-run-items{font-size:var(--text-xs)}.fill-run-usage{color:var(--color-text-muted)}.fill-run-disclosure summary{cursor:pointer;font-size:var(--text-sm);font-weight:600}.fill-run-disclosure[open] summary{margin-bottom:var(--space-2)}
@@ -0,0 +1 @@
1
+ import{i as e}from"./rolldown-runtime-Dd_uD5pT.js";import{a as t,s as n}from"./vendor-diff-Dm2YfgXt.js";import{u as r}from"./vendor-router-DjV3D6zM.js";import{t as i}from"./format-pPdsDgeS.js";import{c as a,o}from"./fill-job-D41ra-DR.js";var s=e(n(),1),c=t(),l={ArrowRight:1,ArrowLeft:-1};function u(e,t,n){if(e===`Home`)return 0;if(e===`End`)return n-1;let r=l[e];return r===void 0?null:(t+r+n)%n}function d({label:e,tabs:t,current:n,tabId:i,panelId:a}){let o=r(),l=(0,s.useRef)(null);function d(e,t){e.id!==n&&o(e.path),t&&l.current?.querySelector(`#${CSS.escape(i(e.id))}`)?.focus()}function f(e){let r=t.findIndex(e=>e.id===n),i=u(e.key,r,t.length),a=i===null?void 0:t[i];a&&(e.preventDefault(),d(a,!0))}return(0,c.jsx)(`div`,{ref:l,role:`tablist`,"aria-label":e,className:`ui-tabs`,onKeyDown:f,children:t.map(e=>(0,c.jsx)(`button`,{id:i(e.id),type:`button`,role:`tab`,className:`ui-tab`,"aria-selected":e.id===n,"aria-controls":a,tabIndex:e.id===n?0:-1,onClick:()=>d(e,!1),children:e.label},e.id))})}var f=``;function p(e){return e===f?{scope:`all`}:{scope:`collection`,collection:e}}function m({collections:e,value:t,disabled:n,onChange:r}){let a=(0,s.useId)();return(0,c.jsxs)(`div`,{className:`fill-run-field`,children:[(0,c.jsx)(`label`,{htmlFor:a,children:`Scope`}),(0,c.jsxs)(`select`,{id:a,className:`fill-run-select`,value:t.scope===`all`?f:t.collection,disabled:n,onChange:e=>r(p(e.target.value)),children:[(0,c.jsx)(`option`,{value:f,children:`The whole site`}),e.map(e=>(0,c.jsxs)(`option`,{value:e.name,children:[i(e.name),` only`]},e.name))]})]})}function h(e,t){return e?t===`loading`?`Reading the AI provider…`:t===`missing`?`No language model is set up.`:null:`Enrichment is run by an admin.`}function g(e){if(e.empty!==null)return e.empty;let t=e.status?.items??[],n=e=>t.filter(t=>t.status===e).length,r=n(`error`);return`${n(`complete`)} filled, ${n(`skipped`)} already set or skipped${r>0?`, ${r} failed`:``}`}function _(e){let t=e?.usage;return t?[t.inputTokens+t.outputTokens>0?`${t.inputTokens.toLocaleString(`en`)} tokens in, ${t.outputTokens.toLocaleString(`en`)} out`:``,t.model??``].filter(Boolean).join(` · `):``}function v(e){switch(e.state){case`running`:{let t=o(e.plan,e.step),n=`${t.charAt(0).toUpperCase()}${t.slice(1)}, ${a[e.step]}`,r=e.status?.progress;if(!r)return`${n}: starting…`;let i=r.completed+r.skipped+r.errors,s=r.current?`, now ${r.current}`:``;return`${n}: ${i} of ${r.total} documents${s}…`}case`done`:return`Finished. ${e.reports.map(e=>`${a[e.step]}: ${g(e)}`).join(`. `)}.`;case`failed`:return`Enrichment failed: ${e.message}`;default:return``}}function y({reports:e}){return(0,c.jsx)(`ul`,{className:`fill-run-reports`,children:e.map(e=>(0,c.jsxs)(`li`,{children:[(0,c.jsx)(`strong`,{children:a[e.step]}),` · `,g(e),_(e.status)!==``&&(0,c.jsxs)(`span`,{className:`fill-run-usage`,children:[` · `,_(e.status)]}),(e.status?.items.length??0)>0&&(0,c.jsxs)(`details`,{className:`fill-run-disclosure`,children:[(0,c.jsx)(`summary`,{children:`Each document`}),(0,c.jsx)(`ul`,{className:`fill-run-items`,children:e.status?.items.map(e=>(0,c.jsxs)(`li`,{children:[(0,c.jsxs)(`code`,{children:[e.collection,`/`,e.slug]}),` `,`· `,e.status,e.result||e.error?` · ${e.result??e.error}`:``]},`${e.collection}/${e.slug}`))})]})]},e.step))})}function b({run:e}){let t=e.state===`running`?e.done:e.state===`idle`?[]:e.reports;return(0,c.jsxs)(c.Fragment,{children:[(0,c.jsx)(`p`,{className:`fill-run-note`,role:`status`,children:v(e)}),t.length>0&&(0,c.jsx)(y,{reports:t})]})}export{d as i,m as n,h as r,b as t};