dsh-open-artifact 0.16.2 → 0.16.3

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 (109) hide show
  1. package/CHANGELOG.md +26 -0
  2. package/icon.svg +1 -1
  3. package/lib/client.js +2504 -2430
  4. package/lib/index.js +26 -8
  5. package/package.json +1 -1
  6. package/skills/open-artifact/SKILL.md +8 -5
  7. package/vendor/frame-host/client/comments.js +1 -1
  8. package/vendor/frame-host/frame-host.mjs +15 -2
  9. package/vendor/harnesses/antigravity.json +3 -0
  10. package/vendor/harnesses/chatgpt.json +3 -0
  11. package/vendor/harnesses/claude-code.json +3 -0
  12. package/vendor/harnesses/codex.json +3 -0
  13. package/vendor/harnesses/copilot.json +3 -0
  14. package/vendor/harnesses/cursor.json +3 -0
  15. package/vendor/harnesses/dsh.json +3 -0
  16. package/vendor/harnesses/zcode.json +3 -0
  17. package/vendor/home/assets/index-BMcfb5B7.css +1 -0
  18. package/vendor/home/assets/index-CxVzqoE0.js +43 -0
  19. package/vendor/home/index.html +2 -2
  20. package/vendor/open-artifact.mjs +1278 -456
  21. package/vendor/runtime.json +1 -1
  22. package/vendor/shell/assets/index-BMcfb5B7.css +1 -0
  23. package/vendor/{type-server/shell/assets/index-xloVcJb_.js → shell/assets/index-C_XsG-Qe.js} +1 -1
  24. package/vendor/shell/index.html +2 -2
  25. package/vendor/type-server/cli.mjs +16 -3
  26. package/vendor/type-server/editors/data/assets/{index-DcaVBiGm.js → index-CMhqwoHV.js} +1 -1
  27. package/vendor/type-server/editors/data/index.html +1 -1
  28. package/vendor/type-server/editors/design/assets/{index-B5Wv_tnf.js → index-DUW-k3ks.js} +1 -1
  29. package/vendor/type-server/editors/design/index.html +1 -1
  30. package/vendor/type-server/editors/design-system/assets/{index-BqDGbG4f.js → index-l9dVDF3y.js} +1 -1
  31. package/vendor/type-server/editors/design-system/index.html +1 -1
  32. package/vendor/type-server/editors/docs/assets/{abnfDiagram-WEYOIA3C-CDTl-yCx.js → abnfDiagram-WEYOIA3C-C7HiIlhQ.js} +1 -1
  33. package/vendor/type-server/editors/docs/assets/{architectureDiagram-ZHVYKT53-BOl_bS-V.js → architectureDiagram-ZHVYKT53-BNtmYbnl.js} +1 -1
  34. package/vendor/type-server/editors/docs/assets/{blockDiagram-RJAE7QA3-CkMxyQ6a.js → blockDiagram-RJAE7QA3-CmB3Jqrq.js} +1 -1
  35. package/vendor/type-server/editors/docs/assets/{c4Diagram-XDPPPE54-BLHAzoyQ.js → c4Diagram-XDPPPE54-BInEfPqU.js} +1 -1
  36. package/vendor/type-server/editors/docs/assets/channel-BT2p6jtG.js +1 -0
  37. package/vendor/type-server/editors/docs/assets/{chunk-2E7WHVMD-B2ZKLsyS.js → chunk-2E7WHVMD-DERsVzyR.js} +1 -1
  38. package/vendor/type-server/editors/docs/assets/{chunk-2Q5K7J3B-DkNtD1xL.js → chunk-2Q5K7J3B-C5h24pTP.js} +1 -1
  39. package/vendor/type-server/editors/docs/assets/{chunk-4EMNKR2T-C3xRZwqt.js → chunk-4EMNKR2T-CtlMesOe.js} +1 -1
  40. package/vendor/type-server/editors/docs/assets/{chunk-55XCU76K-DEOjkZqt.js → chunk-55XCU76K-BcHXSlto.js} +1 -1
  41. package/vendor/type-server/editors/docs/assets/{chunk-5VM5RSS4-DCKBSHxZ.js → chunk-5VM5RSS4-DnqXPWSg.js} +1 -1
  42. package/vendor/type-server/editors/docs/assets/{chunk-JWPE2WC7-DrvooUmN.js → chunk-JWPE2WC7-Bls1jQHy.js} +1 -1
  43. package/vendor/type-server/editors/docs/assets/{chunk-VQ5W62QI-DYMeK3pU.js → chunk-VQ5W62QI-B-9NPBBl.js} +1 -1
  44. package/vendor/type-server/editors/docs/assets/{chunk-XXDRQBXY-Cvl-anAV.js → chunk-XXDRQBXY-DqHJwIOI.js} +1 -1
  45. package/vendor/type-server/editors/docs/assets/{chunk-ZCHMQSOR-gWl3U20G.js → chunk-ZCHMQSOR-CO0N7boC.js} +2 -2
  46. package/vendor/type-server/editors/docs/assets/{classDiagram-v2-4MYWR3UA-On9X3_w5.js → classDiagram-v2-4MYWR3UA-Dm4tBHd-.js} +1 -1
  47. package/vendor/type-server/editors/docs/assets/{core-Cw4Llisp.js → core-CMnn1N7u.js} +1 -1
  48. package/vendor/type-server/editors/docs/assets/{cose-bilkent-JH36ORCC-B72D_yQn.js → cose-bilkent-JH36ORCC-DGyUtGAA.js} +1 -1
  49. package/vendor/type-server/editors/docs/assets/{cynefin-EF2NZ3EQ-B_v4ABxk.js → cynefin-EF2NZ3EQ-BdlZazYw.js} +1 -1
  50. package/vendor/type-server/editors/docs/assets/{cynefinDiagram-WF24UDRP-Bu9uLebD.js → cynefinDiagram-WF24UDRP-BjKufr-c.js} +1 -1
  51. package/vendor/type-server/editors/docs/assets/{dagre-NK4GIZVX-DOkgWNtI.js → dagre-NK4GIZVX-BZlO2--v.js} +1 -1
  52. package/vendor/type-server/editors/docs/assets/{diagram-CBK3MWTC-CgIhmBRJ.js → diagram-CBK3MWTC-3STWIa1n.js} +1 -1
  53. package/vendor/type-server/editors/docs/assets/{diagram-I5XIIV2D-HpeiOnYm.js → diagram-I5XIIV2D-BIiZBp1S.js} +1 -1
  54. package/vendor/type-server/editors/docs/assets/{diagram-ODIL2UCW-CWmar6iG.js → diagram-ODIL2UCW-Cxn7JmvU.js} +1 -1
  55. package/vendor/type-server/editors/docs/assets/{diagram-PFBEJUXE-CXcCGIYn.js → diagram-PFBEJUXE-D2k1jJ3f.js} +1 -1
  56. package/vendor/type-server/editors/docs/assets/{diagram-RJA3I4VV-jEFt8GAQ.js → diagram-RJA3I4VV-7ZRL3Uk6.js} +1 -1
  57. package/vendor/type-server/editors/docs/assets/{diagram-TYUNFSNR-Da-kw_Xm.js → diagram-TYUNFSNR-Jyx-ylJA.js} +1 -1
  58. package/vendor/type-server/editors/docs/assets/{ebnfDiagram-V4P3TTPT-BaZ03UMA.js → ebnfDiagram-V4P3TTPT-DGfWrKui.js} +1 -1
  59. package/vendor/type-server/editors/docs/assets/{elk-QONTBCTQ-Bri5BDi4.js → elk-QONTBCTQ-B7tKj3Ar.js} +1 -1
  60. package/vendor/type-server/editors/docs/assets/{erDiagram-KYQIGQAA-aju23vzr.js → erDiagram-KYQIGQAA-D06HHDAP.js} +1 -1
  61. package/vendor/type-server/editors/docs/assets/{flowDiagram-IUGLLWBU-DezRFFND.js → flowDiagram-IUGLLWBU-CZJZKHIM.js} +1 -1
  62. package/vendor/type-server/editors/docs/assets/{ganttDiagram-R7GPNTJY-DDDYA5M0.js → ganttDiagram-R7GPNTJY-BaBRsp-X.js} +1 -1
  63. package/vendor/type-server/editors/docs/assets/{gitGraphDiagram-PDYL7XHY-Brbvftki.js → gitGraphDiagram-PDYL7XHY-B2bt-1sQ.js} +1 -1
  64. package/vendor/type-server/editors/docs/assets/{index-rie6Fmea.js → index-YZPGEMCI.js} +3 -3
  65. package/vendor/type-server/editors/docs/assets/{infoDiagram-MVDRKAX5-Buk7jjzD.js → infoDiagram-MVDRKAX5-C1qijMFd.js} +1 -1
  66. package/vendor/type-server/editors/docs/assets/{ishikawaDiagram-HPEHV2GE-k1-dGoms.js → ishikawaDiagram-HPEHV2GE-C2fcPeVy.js} +1 -1
  67. package/vendor/type-server/editors/docs/assets/{journeyDiagram-BOSHW7O7-fuODgQ0y.js → journeyDiagram-BOSHW7O7-DAdGOjA_.js} +1 -1
  68. package/vendor/type-server/editors/docs/assets/{kanban-definition-FNSA4HC5-0EJOb8QO.js → kanban-definition-FNSA4HC5-Cjm2BYYa.js} +1 -1
  69. package/vendor/type-server/editors/docs/assets/{mermaid.core-rflC9T3b.js → mermaid.core-T4owCd57.js} +4 -4
  70. package/vendor/type-server/editors/docs/assets/{mindmap-definition-6OY57UG3-BA4jPnUz.js → mindmap-definition-6OY57UG3-DqNbrCsa.js} +1 -1
  71. package/vendor/type-server/editors/docs/assets/{pegDiagram-ECIUJNBX-D1mSs1Df.js → pegDiagram-ECIUJNBX-B8pnl9eq.js} +1 -1
  72. package/vendor/type-server/editors/docs/assets/{pieDiagram-GNMPY74T-DISpmq94.js → pieDiagram-GNMPY74T-CqN2ryDn.js} +1 -1
  73. package/vendor/type-server/editors/docs/assets/{quadrantDiagram-D57K4MC3-C_DveStJ.js → quadrantDiagram-D57K4MC3-D6ZHYaMj.js} +1 -1
  74. package/vendor/type-server/editors/docs/assets/{railroadDiagram-Y72NRBL7-XkLhMgFv.js → railroadDiagram-Y72NRBL7-DbFNy0DV.js} +1 -1
  75. package/vendor/type-server/editors/docs/assets/{requirementDiagram-EQYSW5RA-DKtU2dUB.js → requirementDiagram-EQYSW5RA-CBjn24a2.js} +1 -1
  76. package/vendor/type-server/editors/docs/assets/{sankeyDiagram-SY24JHO5-DXnpKoyA.js → sankeyDiagram-SY24JHO5-Be5yf8X0.js} +1 -1
  77. package/vendor/type-server/editors/docs/assets/{sequenceDiagram-BLEHNHQU-D3XryRDT.js → sequenceDiagram-BLEHNHQU-CM75oaFL.js} +1 -1
  78. package/vendor/type-server/editors/docs/assets/{sizeCapture-INFHLROL-Ce0anhUv.js → sizeCapture-INFHLROL-BS3ZKpfq.js} +1 -1
  79. package/vendor/type-server/editors/docs/assets/{stateDiagram-v2-A6IESKWZ-C_-4V6la.js → stateDiagram-v2-A6IESKWZ-DBao6lhy.js} +1 -1
  80. package/vendor/type-server/editors/docs/assets/{swimlanes-B3ENRKFQ-DsaAidHj.js → swimlanes-B3ENRKFQ-OBdPnY1S.js} +1 -1
  81. package/vendor/type-server/editors/docs/assets/swimlanesDiagram-AYQRV4AK-D73Zrbfj.js +8 -0
  82. package/vendor/type-server/editors/docs/assets/{timeline-definition-JXYKGLGB-DfKECQ2o.js → timeline-definition-JXYKGLGB-BqkDYP31.js} +1 -1
  83. package/vendor/type-server/editors/docs/assets/{usecaseDiagram-WPOLBNNX-Dc8tWzRe.js → usecaseDiagram-WPOLBNNX-0IvdCTW3.js} +1 -1
  84. package/vendor/type-server/editors/docs/assets/{vennDiagram-Q3Y3IDCW-tc61BjSp.js → vennDiagram-Q3Y3IDCW-Dt2rtwRE.js} +1 -1
  85. package/vendor/type-server/editors/docs/assets/{wardleyDiagram-IVAIDKWA-DyVqcsy4.js → wardleyDiagram-IVAIDKWA-G9f9s0F7.js} +1 -1
  86. package/vendor/type-server/editors/docs/assets/{xychartDiagram-4URNHDU4-B8VxiLaY.js → xychartDiagram-4URNHDU4-CaUTu_0n.js} +1 -1
  87. package/vendor/type-server/editors/docs/index.html +1 -1
  88. package/vendor/type-server/editors/motion/assets/{gif-jobs-DY7KR2r5.js → gif-jobs-C1zQj3s9.js} +1 -1
  89. package/vendor/type-server/editors/motion/assets/{index-DBRxctvJ.js → index-Cw_UcKR5.js} +3 -3
  90. package/vendor/type-server/editors/motion/assets/{src-CP9lpzx7.js → src-wn9P_DUt.js} +1 -1
  91. package/vendor/type-server/editors/motion/index.html +1 -1
  92. package/vendor/type-server/editors/sheets/assets/{index-B6FKM2kq.js → index-C3CIL5GM.js} +2 -2
  93. package/vendor/type-server/editors/sheets/assets/{workbook-worker-D4VqJhLz.js → workbook-worker-CbhVg0YQ.js} +1 -1
  94. package/vendor/type-server/editors/sheets/index.html +1 -1
  95. package/vendor/type-server/editors/slides/assets/{index-DI_AWWuc.js → index-fJEPQZQY.js} +2 -2
  96. package/vendor/type-server/editors/slides/assets/{src-CWCcr2Hw.js → src-mZdWgqty.js} +1 -1
  97. package/vendor/type-server/editors/slides/index.html +1 -1
  98. package/vendor/type-server/editors/whiteboard/assets/{drawing-look-worker-CS2Hv0Nf.js → drawing-look-worker-gMYrygDq.js} +2 -2
  99. package/vendor/type-server/editors/whiteboard/assets/{index-BkWtA61j.js → index-BtZ30wGI.js} +2 -2
  100. package/vendor/type-server/editors/whiteboard/index.html +1 -1
  101. package/vendor/type-server/shell/assets/index-BMcfb5B7.css +1 -0
  102. package/vendor/{shell/assets/index-xloVcJb_.js → type-server/shell/assets/index-C_XsG-Qe.js} +1 -1
  103. package/vendor/type-server/shell/index.html +2 -2
  104. package/vendor/home/assets/index-CQTGVxZi.js +0 -43
  105. package/vendor/home/assets/index-CkjifzaW.css +0 -1
  106. package/vendor/shell/assets/index-CkjifzaW.css +0 -1
  107. package/vendor/type-server/editors/docs/assets/channel-CR_04g-H.js +0 -1
  108. package/vendor/type-server/editors/docs/assets/swimlanesDiagram-AYQRV4AK-iNMg14LW.js +0 -8
  109. package/vendor/type-server/shell/assets/index-CkjifzaW.css +0 -1
@@ -11,7 +11,7 @@ Error generating stack: `+x.message+`
11
11
  `),i=fO(r,t.split(`
12
12
  `)),l=fO(r,n.split(`
13
13
  `));if(!i||!l)return null;const c=[];for(const h of i){const g=l.find(m=>gee(h,m,o));if(!g){c.push(h);continue}if(!(g.start===h.start&&g.end===h.end&&mee(g.lines,h.lines)))return null}c.push(...l),c.sort((h,g)=>h.start-g.start||h.end-g.end);const u=[];let f=0;for(const h of c)u.push(...r.slice(f,h.start),...h.lines),f=h.end;return u.push(...r.slice(f)),u.join(`
14
- `)}const bee="1.4.0";class Tu extends Error{code;paths;retryable;constructor(t,n,s,o){super(n),this.name="ArtifactError",this.code=t,s&&(this.paths=s),o&&(this.retryable=!0)}}function hO(e,t){if(!e||typeof e!="object")return!1;const n=e;return n.name!=="ArtifactError"||typeof n.code!="string"?!1:t===void 0||n.code===t}function xee(e){return e==="owner"||e==="editor"}const pO={defaultMs:12e4,maxMs:6e5};function vee(e,t={}){const n=t.timeoutMs??1e4,s=new Map;return Object.freeze({version:bee,use:r=>{const i=s.get(r);if(i)return i;const l=new Promise(c=>{const u=setTimeout(()=>c(null),n);Promise.resolve().then(()=>e.get(r)).then(f=>{clearTimeout(u),c(f?Object.freeze(f):null)},()=>{clearTimeout(u),c(null)})});return s.set(r,l),l}})}function wee(e,t){const n=globalThis.window?.openartifact;if(n)return n;const s=vee(e,t);return Object.defineProperty(window,"openartifact",{value:s,configurable:!1,enumerable:!0,writable:!1}),s}async function See(e){const t=globalThis.window?.openartifact;if(!t)return null;try{return await t.use(e)}catch{return null}}const Nt={session:"_api/session",files:"_api/files",file:"_api/file",publish:"_api/publish",assets:"_api/assets",events:"_api/events",agentSend:"_api/agent/send",presence:"_api/presence",peers:"_api/peers",downloads:"_api/downloads",roomEmit:"_api/room/emit",dbGet:"_api/db/get",dbList:"_api/db/list",dbWrite:"_api/db/write",comments:"_api/comments",commentsCreate:"_api/comments/create",commentsReply:"_api/comments/reply",commentsEdit:"_api/comments/edit",commentsReact:"_api/comments/react",commentsResolve:"_api/comments/resolve",commentsMove:"_api/comments/move",commentsRemove:"_api/comments/remove",commentsSend:"_api/comments/send",history:"_api/history",historyFiles:"_api/history/files",historyFile:"_api/history/file",historyDiff:"_api/history/diff",historyRestore:"_api/history/restore",historyDismiss:"_api/history/dismiss",systemCopy:"_api/design/system-copy",mcpTools:"_api/mcp/tools",mcpCall:"_api/mcp/call",dataRefresh:"_api/data/refresh"},zm={read:"_api/sheet/read",send:"_api/sheet/send",widget:"_api/sheet/widget",importFile:"_api/sheet/import"},kee="sheet",Eee="sheetWalkthrough",fa={session:"_api/doc/session",read:"_api/doc/read",call:"_api/doc/call",history:"_api/doc/history",version:"_api/doc/version",restore:"_api/doc/restore",importFile:"_api/doc/import",exportFile:"_api/doc/export"};function Cee(e,t,n){return t===401||t===403?"removed":t<200||t>=300||!n||n.id===e.id&&n.role===e.role?null:"changed"}async function Lw(e){let t={};try{t=await e.json()}catch{}const n=e.status===409?"conflict":e.status===403?"not_writer":e.status===404?"not_found":"unavailable";return new Tu(t.code??n,t.message??`HTTP ${e.status}`,t.paths,t.retryable===!0)}function Tee(){const e=new Uint8Array(8);return crypto.getRandomValues(e),Array.from(e,t=>t.toString(16).padStart(2,"0")).join("")}function WI(e={}){const t=new URL(e.base??"./",location.href),n=Tee(),s=($,D)=>{const z=new URL($,t);for(const[_,L]of Object.entries(D??{}))z.searchParams.set(_,L);return z.toString()},o=async($,D,z)=>{let _;try{_=await fetch(s($,z),D)}catch(L){throw new Tu("unavailable",L instanceof Error?L.message:String(L))}if(!_.ok)throw await Lw(_);return await _.json()},r=($,D)=>o($,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(D)}),i=new Map,l=($,D)=>{for(const z of i.get($)??[])z(D)},c=($,D)=>{let z=i.get($);return z||(z=new Set,i.set($,z),h?.addEventListener($,m)),z.add(D),S(),()=>z.delete(D)};let u=null,f=!1,h=null,g=null;const m=$=>{l($.type,JSON.parse($.data))},b=()=>{const $=new EventSource(s(Nt.events,{client:n}));h=$;for(const D of i.keys())$.addEventListener(D,m);$.onerror=()=>{M().then(D=>{D||$.readyState!==EventSource.CLOSED||h!==$||(h=null,g=setTimeout(()=>{g=null,S()},2e3))})}};let v=!1,w=!1;const E=$=>{v||(v=!0,g&&clearTimeout(g),g=null,h?.close(),h=null,u?.close(),u=null,e.onAccessChange?e.onAccessChange($):location.reload())},M=async()=>{if(v)return!0;if(!k||w)return!1;w=!0;try{const $=(await k.catch(()=>null))?.viewer;if(!$)return!1;let D;try{D=await fetch(s(Nt.session),{cache:"no-store"})}catch{return!1}const z=D.ok?(await D.json().catch(()=>null))?.viewer:null,_=Cee($,D.status,z);return _&&E(_),_!==null}finally{w=!1}};function S(){if(u||h||g||v)return;if(typeof WebSocket>"u")return b();const $=new URL(s(Nt.events,{client:n}));$.protocol=$.protocol==="https:"?"wss:":"ws:";const D=new WebSocket($);u=D,D.onopen=()=>{f=!0},D.onmessage=z=>{let _;try{_=JSON.parse(String(z.data))}catch{return}_.event&&l(_.event,_.data)},D.onclose=()=>{if(u===D&&(u=null),!v){if(!f)return b();M().then(z=>{z||u||h||g||(g=setTimeout(()=>{g=null,S()},2e3))})}}}let k=null;const R=()=>k??=o(Nt.session),N={async artifact(){const{artifact:$,stores:D}=await R();return{id:$.id,...D?.systemCopy?{systemCopy:(_,L)=>o(Nt.systemCopy,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({namespace:_,action:L})})}:{},title:async()=>(await o(Nt.session)).artifact.title,list:async()=>(await o(Nt.files)).files,readText:async _=>new TextDecoder().decode(await O(_)),readBytes:_=>O(_),publish:async _=>{const L={files:_,client:n};return o(Nt.publish,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(L)})},onChange:_=>c("files",_)}},async assets(){const{viewer:$}=await R();return xee($.role)?{upload:async(z,_)=>o(Nt.assets,{method:"POST",headers:{"content-type":z.type||"application/octet-stream"},body:z},_?.name?{name:_.name}:void 0)}:null},async user(){const{viewer:$}=await R();return{me:async()=>$}},async agent(){return{send:async(D,z)=>{const _={request:D,deliver:z?.deliver??"send"};return o(Nt.agentSend,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(_)})},status:async()=>(await o(Nt.session)).agent,onStatus:D=>c("agent",D)}},async room(){return{self:async()=>n,presence:async D=>{const z={client:n,patch:D};await o(Nt.presence,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(z)})},peers:async()=>(await o(Nt.peers)).peers,onPeers:D=>c("peers",D),emit:async(D,z)=>{const _={client:n,topic:D,data:z};await r(Nt.roomEmit,_)},onMessage:D=>c("room",D)}},async db(){const{stores:$}=await R();return $?.db?{get:async z=>(await o(Nt.dbGet,{cache:"no-store"},{path:z})).data,list:async z=>(await o(Nt.dbList,{cache:"no-store"},{collection:z})).documents,listing:async z=>{const{documents:_,epoch:L,seq:B}=await o(Nt.dbList,{cache:"no-store"},{collection:z});return typeof L=="string"&&typeof B=="number"?{documents:_,epoch:L,seq:B}:{documents:_}},write:async z=>{const _={writes:z,client:n},{epoch:L,seq:B,documents:U}=await r(Nt.dbWrite,_);return typeof L=="string"&&typeof B=="number"&&U!==void 0?{epoch:L,seq:B,documents:U}:void 0},onChange:z=>c("db",z)}:null},async comments(){const{stores:$}=await R();if(!$?.comments)return null;const D=async(_,L)=>(await r(_,L)).thread;return{list:async()=>(await o(Nt.comments,{cache:"no-store"})).threads,create:_=>D(Nt.commentsCreate,{input:_}),reply:(_,L,B)=>D(Nt.commentsReply,{threadId:_,text:L,...B?.to?.length?{to:B.to}:{}}),edit:(_,L,B,U)=>D(Nt.commentsEdit,{threadId:_,messageId:L,text:B,...U?.to?{to:U.to}:{}}),react:(_,L,B,U)=>D(Nt.commentsReact,{threadId:_,messageId:L,emoji:B,on:U}),setResolved:(_,L)=>D(Nt.commentsResolve,{threadId:_,resolved:L}),move:(_,L,B)=>D(Nt.commentsMove,{threadId:_,anchor:L,...B?{location:B}:{}}),remove:async(_,L)=>{await r(Nt.commentsRemove,{threadId:_,...L?{messageId:L}:{}})},sendToAgent:(_,L)=>D(Nt.commentsSend,{threadId:_,...L?.unasked?{unasked:!0}:{}}),onChange:_=>c("comments",_)}},async doc(){const{stores:$}=await R();return $?.doc?{session:()=>r(fa.session,{client:n}),read:z=>r(fa.read,{tab:z}),call:z=>r(fa.call,{...z,client:n}),history:z=>r(fa.history,{tab:z}),version:(z,_)=>r(fa.version,{tab:z,rev:_}),restore:z=>r(fa.restore,z),importFile:(z,_,L)=>o(fa.importFile,{method:"POST",headers:{"content-type":"application/octet-stream"},body:_},{name:z,...L?{tabName:L}:{}}),exportFile:async z=>{let _;try{_=await fetch(s(fa.exportFile,{format:z.format,...z.tab?{tab:z.tab}:{},...z.paper?{paper:z.paper}:{}}),{cache:"no-store"})}catch(I){throw new Tu("unavailable",I instanceof Error?I.message:String(I))}if(!_.ok)throw await Lw(_);const L=_.headers.get("content-disposition")??"",B=decodeURIComponent(/filename\*=UTF-8''([^;]+)/.exec(L)?.[1]??"")||`doc.${z.format==="markdown"?"md":z.format}`;let U=[];try{U=JSON.parse(decodeURIComponent(_.headers.get("x-doc-export-notes")??"%5B%5D"))}catch{}return{name:B,mime:_.headers.get("content-type")??"application/octet-stream",bytes:new Uint8Array(await _.arrayBuffer()),notes:U}},onFrame:z=>c("doc",z)}:null},async history(){const{stores:$}=await R();if(!$?.history)return null;const D=(_,L)=>({n:String(_),...L===void 0?{}:{path:L}});return{list:()=>o(Nt.history,{cache:"no-store"}),files:async _=>(await o(Nt.historyFiles,{cache:"no-store"},D(_))).files,read:async(_,L)=>new TextDecoder().decode(await A(Nt.historyFile,D(_,L))),readBytes:(_,L)=>A(Nt.historyFile,D(_,L)),diff:(_,L)=>o(Nt.historyDiff,{cache:"no-store"},D(_,L)),restore:(_,L)=>r(Nt.historyRestore,{n:_,...L?{paths:L}:{},client:n}),dismissNotice:async _=>{await r(Nt.historyDismiss,{id:_})},onChange:_=>c("history",_)}},async mcp(){const{viewer:$}=await R();return $.role!=="owner"?null:{callTool:async(z,_,L,B)=>{const U=B?.signal;U?.throwIfAborted();const I={server:z,tool:_,args:L,...B?.timeoutMs===void 0?{}:{timeoutMs:B.timeoutMs}};try{return await o(Nt.mcpCall,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(I),...U?{signal:U}:{}})}catch(F){throw U?.aborted?U.reason:F}},listTools:z=>o(Nt.mcpTools,{cache:"no-store"},z===void 0?void 0:{server:z})}},async sheet(){const{stores:$}=await R();if(!$?.sheet)return null;let D=Promise.resolve();return{read:_=>r(zm.read,_),send:_=>{const L=D.then(()=>r(zm.send,_));return D=L.catch(()=>{}),L},widget:_=>r(zm.widget,_),importFile:(_,L)=>o(zm.importFile,{method:"POST",headers:{"content-type":_.type||"application/octet-stream"},body:_},{name:L}),onFrame:_=>c(kee,_),onWalkthrough:_=>c(Eee,_)}},async downloads(){return{save:async({name:D,data:z})=>o(Nt.downloads,{method:"POST",headers:{"content-type":z.type||"application/octet-stream"},body:z},{name:D})}}};function O($){return A(Nt.file,{path:$})}async function A($,D){let z;try{z=await fetch(s($,D),{cache:"no-store"})}catch(_){throw new Tu("unavailable",_ instanceof Error?_.message:String(_))}if(!z.ok)throw await Lw(z);return new Uint8Array(await z.arrayBuffer())}return{get($){const D=N[$];return D?D():null}}}const Mee="[Artifact comment sent to agent]",Ree="[Artifact edit request sent to agent]",jee="[Artifact task finished]",Aee="[Open Artifact] ",Nee={id:"open_artifact_id"},GI=/^#slide-(?:~[A-Za-z0-9_-]{1,64}(?:\.only(?:\.[0-9]{1,4}\.[0-9]{1,4})?)?|[0-9]{1,4})$/,Oee="#view-inline",$ee=1,_ee=1,Lee=/^[a-z][a-z0-9]{0,23}$/,Dee="may not have run: the artifact was updated before this call was answered",zee=["quickstart","list","publish","read","open","call","adopt","delete","share"],Pee=["get","list","query","set","update","delete","str_replace","batch"],Iee=["read","reply","resolve","reopen","wait"],Bee=["share","export"],Fee={type:"object",properties:{action:{type:"string",enum:zee,description:"What to do: quickstart, list, publish, read, open, call, adopt, delete or share. Omitted: publish."},intent:{type:"string",description:"quickstart: what is being made (design, design-system, slides, whiteboard, document, data, sheets, motion, page, other), or a few words about it."},scope:{type:"string",enum:["types","mine","all"],description:"list: types (the installed types), mine (this session's and this workspace's artifacts; the default) or all (every artifact)."},type:{type:"string",description:"list: only artifacts of this type (an id, or open-artifact://type/<id>). quickstart: the type already chosen (an id), to get its create call and steps without matching."},query:{type:"string",description:"list: only artifacts whose title contains this text."},limit:{type:"integer",description:"list: how many to return (default 50, at most 200)."},cursor:{type:"string",description:"list: the next_cursor of the previous page."},type_url:{type:"string",description:"publish without url: the type to create from (open-artifact://type/<id>, from quickstart). read without url: the type to describe."},title:{type:"string",description:"publish without url: the new artifact's name. quickstart: the name it will have, to find similar ones."},folder:{type:"string",description:"publish without url, or adopt: where the artifact's folder goes (absolute, or relative to the workspace). Default <workspace>/artifacts/<slug>."},url:{type:"string",description:"An artifact: open-artifact://artifact/<id>, as publish returned it."},files:{type:"object",additionalProperties:!0,description:'publish with url: files to write under the artifact root, as {"rel/path": "text"} or {"rel/path": {"content": "...", "encoding": "base64"}}; null deletes.'},if_match:{type:"object",additionalProperties:!0,description:'publish with url: {"rel/path": sha256 | null | "*"}. Write only while the file still has the sha256 you read, does not exist (null), or anyway ("*"). One mismatch writes nothing and returns the current versions.'},check:{type:"boolean",description:"publish with url: run the type's check action after writing; its result comes back as check."},capabilities:{type:"object",additionalProperties:!0,description:'publish, page artifacts only: the runtime capabilities the page may use, as {"db": true, "assets": true, ...}. Omitted: kept; {}: none; otherwise the whole set. With url it may be given without files.'},open:{type:"string",enum:["after_first_write","now","never"],description:"publish without url: after_first_write (the default) opens the page in your app once your first write lands; now opens it at once; never leaves it closed. Where your app cannot show pages by itself the result says so: open view_url in your app's built-in browser, if you have one."},related:{type:"boolean",description:"quickstart: list existing artifacts the recommended type can build on, such as design systems (default true)."},path:{type:"string",description:"read: one file or folder under the root (omitted: the record and the file list)."},paths:{type:"array",items:{type:"string"},description:"read: several files under the root at once."},name:{type:"string",description:"call: the action's name (check, upload, ...; read with url lists them)."},args:{type:"object",additionalProperties:!0,description:"call: the action's arguments. upload: {file: absolute path, name?, group?}."},panel:{type:"string",enum:Bee,description:"open: also open the page's Share panel (share), for the person to share it on the network, or its Export tab (export), for them to download a file."},cloud:{type:"string",description:"share: publish the artifact to this cloud remote (its name, as `open-artifact remote list` shows it). It works only on a remote the person set up and let agents publish to (agentMayPublish); otherwise the person publishes it, from the Share panel or with `open-artifact publish <id> --remote <name>`."}}},Hee={type:"object",properties:{action:{type:"string",enum:Pee,description:"What to do: get, list, query, set, update, delete, str_replace or batch."},url:{type:"string",description:"The artifact (open-artifact://artifact/<id>)."},collection:{type:"string",description:"The collection: alone for list / query (query needs it), with doc_id for one document."},doc_id:{type:"string",description:"With collection: the document to get / set / update / delete / str_replace."},path:{type:"string",description:"collection/doc_id, instead of the two."},data:{type:"object",additionalProperties:!0,description:"set / update: the document's fields."},file_path:{type:"string",description:"set / update: a JSON file holding the fields, instead of data."},if_match:{description:'set / update / delete / str_replace: the sha256 get returned (write only if unchanged), null (only if it does not exist) or "*" (replace whatever is there).'},field:{type:"string",description:"str_replace: the text field, as a dot path (body, notes.text)."},old:{type:"string",description:"str_replace: the passage to replace; it must occur exactly once."},new:{type:"string",description:"str_replace: the passage that replaces it."},where:{type:"array",items:{type:"object",additionalProperties:!0},description:"query: [{field, op, value}], all must hold. op: ==, !=, <, <=, >, >=, in, not-in (up to 30 values), array-contains."},order_by:{type:"object",additionalProperties:!0,description:'query: {field, dir: "asc" | "desc"}.'},limit:{type:"integer",description:"list / query: how many documents (default 100, at most 1000)."},cursor:{type:"string",description:"list / query: the next_cursor of the previous page."},out_file:{type:"string",description:"get / list / query: write the result to this JSON file (absolute, or relative to the workspace) and return only its path and counts."},writes:{type:"array",items:{type:"object",additionalProperties:!0},description:"batch: [{op: set|update|delete|str_replace, path | collection+doc_id, data | file_path, if_match?, field?, old?, new?}], at most 500."}},required:["action","url"]},Uee={type:"object",properties:{action:{type:"string",enum:Iee,description:"What to do: read, reply, resolve, reopen or wait."},url:{type:"string",description:"The artifact (open-artifact://artifact/<id>). wait: optional."},thread_id:{type:"string",description:'reply / resolve / reopen: the thread (after ";thread=" in the message).'},text:{type:"string",description:"reply: the answer."},resolve:{type:"boolean",description:"reply: resolve the thread too."},all:{type:"boolean",description:"read: resolved threads too."},since:{type:"string",description:"read: only threads with a message at or after this time (ISO 8601)."},acknowledge_duplicate:{type:"boolean",description:"reply: send the same text as your last reply in this thread again, on purpose."},timeout_ms:{type:"number",description:"wait: how long (default 600000)."}},required:["action"]},mO={Artifact:Fee,ArtifactData:Hee,ArtifactComments:Uee},Vee={Artifact:["Make and change artifacts: typed folders of files that open as live pages the person can view, edit, comment on and export. Actions:","- quickstart {intent, type?}: call first for a new artifact; recommends a type (or takes the one given) and returns the call that creates it, the steps for this app and similar artifacts that already exist.",'- list {scope: "mine" | "all" | "types", type?, query?}: find existing artifacts, or the installed types.',"- publish {type_url, title, folder?, open?}: create an artifact; the result carries its root folder and the type's instructions. publish {url, files, if_match?, check?}: write files when you have no file tools of your own. A page artifact also takes capabilities (on create or write): the runtime capabilities its page may use.","- read {url, path? | paths?}: the artifact's record, files and actions, or some of its files with their sha256. read {type_url}: a type's instructions, before creating.",`- open {url, panel?}: show it to the person in the computer's browser (or the app, when it shows pages), once its content is written. When your app has a built-in browser, open view_url there instead. panel "share" or "export" opens its Share panel or Export tab for them.`,"- call {url, name, args?}: run one of the type's actions (check, upload, ...). A long one answers {task, pending: true}; its result comes later as a message.","- adopt {url | folder}: take over an artifact, or add an existing folder. Only when the person asks.","- share {url}: whether it is shared on the local network, and its links. Only the person changes that, in the page's Share panel.","- delete {url}: forget an artifact; its folder stays. Only when the person asks."].join(`
14
+ `)}const bee="1.4.0";class Tu extends Error{code;paths;retryable;constructor(t,n,s,o){super(n),this.name="ArtifactError",this.code=t,s&&(this.paths=s),o&&(this.retryable=!0)}}function hO(e,t){if(!e||typeof e!="object")return!1;const n=e;return n.name!=="ArtifactError"||typeof n.code!="string"?!1:t===void 0||n.code===t}function xee(e){return e==="owner"||e==="editor"}const pO={defaultMs:12e4,maxMs:6e5};function vee(e,t={}){const n=t.timeoutMs??1e4,s=new Map;return Object.freeze({version:bee,use:r=>{const i=s.get(r);if(i)return i;const l=new Promise(c=>{const u=setTimeout(()=>c(null),n);Promise.resolve().then(()=>e.get(r)).then(f=>{clearTimeout(u),c(f?Object.freeze(f):null)},()=>{clearTimeout(u),c(null)})});return s.set(r,l),l}})}function wee(e,t){const n=globalThis.window?.openartifact;if(n)return n;const s=vee(e,t);return Object.defineProperty(window,"openartifact",{value:s,configurable:!1,enumerable:!0,writable:!1}),s}async function See(e){const t=globalThis.window?.openartifact;if(!t)return null;try{return await t.use(e)}catch{return null}}const Nt={session:"_api/session",files:"_api/files",file:"_api/file",publish:"_api/publish",assets:"_api/assets",events:"_api/events",agentSend:"_api/agent/send",presence:"_api/presence",peers:"_api/peers",downloads:"_api/downloads",roomEmit:"_api/room/emit",dbGet:"_api/db/get",dbList:"_api/db/list",dbWrite:"_api/db/write",comments:"_api/comments",commentsCreate:"_api/comments/create",commentsReply:"_api/comments/reply",commentsEdit:"_api/comments/edit",commentsReact:"_api/comments/react",commentsResolve:"_api/comments/resolve",commentsMove:"_api/comments/move",commentsRemove:"_api/comments/remove",commentsSend:"_api/comments/send",history:"_api/history",historyFiles:"_api/history/files",historyFile:"_api/history/file",historyDiff:"_api/history/diff",historyRestore:"_api/history/restore",historyDismiss:"_api/history/dismiss",systemCopy:"_api/design/system-copy",mcpTools:"_api/mcp/tools",mcpCall:"_api/mcp/call",dataRefresh:"_api/data/refresh"},zm={read:"_api/sheet/read",send:"_api/sheet/send",widget:"_api/sheet/widget",importFile:"_api/sheet/import"},kee="sheet",Eee="sheetWalkthrough",fa={session:"_api/doc/session",read:"_api/doc/read",call:"_api/doc/call",history:"_api/doc/history",version:"_api/doc/version",restore:"_api/doc/restore",importFile:"_api/doc/import",exportFile:"_api/doc/export"};function Cee(e,t,n){return t===401||t===403?"removed":t<200||t>=300||!n||n.id===e.id&&n.role===e.role?null:"changed"}async function Lw(e){let t={};try{t=await e.json()}catch{}const n=e.status===409?"conflict":e.status===403?"not_writer":e.status===404?"not_found":"unavailable";return new Tu(t.code??n,t.message??`HTTP ${e.status}`,t.paths,t.retryable===!0)}function Tee(){const e=new Uint8Array(8);return crypto.getRandomValues(e),Array.from(e,t=>t.toString(16).padStart(2,"0")).join("")}function WI(e={}){const t=new URL(e.base??"./",location.href),n=Tee(),s=($,D)=>{const z=new URL($,t);for(const[_,L]of Object.entries(D??{}))z.searchParams.set(_,L);return z.toString()},o=async($,D,z)=>{let _;try{_=await fetch(s($,z),D)}catch(L){throw new Tu("unavailable",L instanceof Error?L.message:String(L))}if(!_.ok)throw await Lw(_);return await _.json()},r=($,D)=>o($,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(D)}),i=new Map,l=($,D)=>{for(const z of i.get($)??[])z(D)},c=($,D)=>{let z=i.get($);return z||(z=new Set,i.set($,z),h?.addEventListener($,m)),z.add(D),S(),()=>z.delete(D)};let u=null,f=!1,h=null,g=null;const m=$=>{l($.type,JSON.parse($.data))},b=()=>{const $=new EventSource(s(Nt.events,{client:n}));h=$;for(const D of i.keys())$.addEventListener(D,m);$.onerror=()=>{M().then(D=>{D||$.readyState!==EventSource.CLOSED||h!==$||(h=null,g=setTimeout(()=>{g=null,S()},2e3))})}};let v=!1,w=!1;const E=$=>{v||(v=!0,g&&clearTimeout(g),g=null,h?.close(),h=null,u?.close(),u=null,e.onAccessChange?e.onAccessChange($):location.reload())},M=async()=>{if(v)return!0;if(!k||w)return!1;w=!0;try{const $=(await k.catch(()=>null))?.viewer;if(!$)return!1;let D;try{D=await fetch(s(Nt.session),{cache:"no-store"})}catch{return!1}const z=D.ok?(await D.json().catch(()=>null))?.viewer:null,_=Cee($,D.status,z);return _&&E(_),_!==null}finally{w=!1}};function S(){if(u||h||g||v)return;if(typeof WebSocket>"u")return b();const $=new URL(s(Nt.events,{client:n}));$.protocol=$.protocol==="https:"?"wss:":"ws:";const D=new WebSocket($);u=D,D.onopen=()=>{f=!0},D.onmessage=z=>{let _;try{_=JSON.parse(String(z.data))}catch{return}_.event&&l(_.event,_.data)},D.onclose=()=>{if(u===D&&(u=null),!v){if(!f)return b();M().then(z=>{z||u||h||g||(g=setTimeout(()=>{g=null,S()},2e3))})}}}let k=null;const R=()=>k??=o(Nt.session),N={async artifact(){const{artifact:$,stores:D}=await R();return{id:$.id,...D?.systemCopy?{systemCopy:(_,L)=>o(Nt.systemCopy,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({namespace:_,action:L})})}:{},title:async()=>(await o(Nt.session)).artifact.title,list:async()=>(await o(Nt.files)).files,readText:async _=>new TextDecoder().decode(await O(_)),readBytes:_=>O(_),publish:async _=>{const L={files:_,client:n};return o(Nt.publish,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(L)})},onChange:_=>c("files",_)}},async assets(){const{viewer:$}=await R();return xee($.role)?{upload:async(z,_)=>o(Nt.assets,{method:"POST",headers:{"content-type":z.type||"application/octet-stream"},body:z},_?.name?{name:_.name}:void 0)}:null},async user(){const{viewer:$}=await R();return{me:async()=>$}},async agent(){return{send:async(D,z)=>{const _={request:D,deliver:z?.deliver??"send"};return o(Nt.agentSend,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(_)})},status:async()=>(await o(Nt.session)).agent,onStatus:D=>c("agent",D)}},async room(){return{self:async()=>n,presence:async D=>{const z={client:n,patch:D};await o(Nt.presence,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(z)})},peers:async()=>(await o(Nt.peers)).peers,onPeers:D=>c("peers",D),emit:async(D,z)=>{const _={client:n,topic:D,data:z};await r(Nt.roomEmit,_)},onMessage:D=>c("room",D)}},async db(){const{stores:$}=await R();return $?.db?{get:async z=>(await o(Nt.dbGet,{cache:"no-store"},{path:z})).data,list:async z=>(await o(Nt.dbList,{cache:"no-store"},{collection:z})).documents,listing:async z=>{const{documents:_,epoch:L,seq:B}=await o(Nt.dbList,{cache:"no-store"},{collection:z});return typeof L=="string"&&typeof B=="number"?{documents:_,epoch:L,seq:B}:{documents:_}},write:async z=>{const _={writes:z,client:n},{epoch:L,seq:B,documents:U}=await r(Nt.dbWrite,_);return typeof L=="string"&&typeof B=="number"&&U!==void 0?{epoch:L,seq:B,documents:U}:void 0},onChange:z=>c("db",z)}:null},async comments(){const{stores:$}=await R();if(!$?.comments)return null;const D=async(_,L)=>(await r(_,L)).thread;return{list:async()=>(await o(Nt.comments,{cache:"no-store"})).threads,create:_=>D(Nt.commentsCreate,{input:_}),reply:(_,L,B)=>D(Nt.commentsReply,{threadId:_,text:L,...B?.to?.length?{to:B.to}:{}}),edit:(_,L,B,U)=>D(Nt.commentsEdit,{threadId:_,messageId:L,text:B,...U?.to?{to:U.to}:{}}),react:(_,L,B,U)=>D(Nt.commentsReact,{threadId:_,messageId:L,emoji:B,on:U}),setResolved:(_,L)=>D(Nt.commentsResolve,{threadId:_,resolved:L}),move:(_,L,B)=>D(Nt.commentsMove,{threadId:_,anchor:L,...B?{location:B}:{}}),remove:async(_,L)=>{await r(Nt.commentsRemove,{threadId:_,...L?{messageId:L}:{}})},sendToAgent:(_,L)=>D(Nt.commentsSend,{threadId:_,...L?.unasked?{unasked:!0}:{}}),onChange:_=>c("comments",_)}},async doc(){const{stores:$}=await R();return $?.doc?{session:()=>r(fa.session,{client:n}),read:z=>r(fa.read,{tab:z}),call:z=>r(fa.call,{...z,client:n}),history:z=>r(fa.history,{tab:z}),version:(z,_)=>r(fa.version,{tab:z,rev:_}),restore:z=>r(fa.restore,z),importFile:(z,_,L)=>o(fa.importFile,{method:"POST",headers:{"content-type":"application/octet-stream"},body:_},{name:z,...L?{tabName:L}:{}}),exportFile:async z=>{let _;try{_=await fetch(s(fa.exportFile,{format:z.format,...z.tab?{tab:z.tab}:{},...z.paper?{paper:z.paper}:{}}),{cache:"no-store"})}catch(I){throw new Tu("unavailable",I instanceof Error?I.message:String(I))}if(!_.ok)throw await Lw(_);const L=_.headers.get("content-disposition")??"",B=decodeURIComponent(/filename\*=UTF-8''([^;]+)/.exec(L)?.[1]??"")||`doc.${z.format==="markdown"?"md":z.format}`;let U=[];try{U=JSON.parse(decodeURIComponent(_.headers.get("x-doc-export-notes")??"%5B%5D"))}catch{}return{name:B,mime:_.headers.get("content-type")??"application/octet-stream",bytes:new Uint8Array(await _.arrayBuffer()),notes:U}},onFrame:z=>c("doc",z)}:null},async history(){const{stores:$}=await R();if(!$?.history)return null;const D=(_,L)=>({n:String(_),...L===void 0?{}:{path:L}});return{list:()=>o(Nt.history,{cache:"no-store"}),files:async _=>(await o(Nt.historyFiles,{cache:"no-store"},D(_))).files,read:async(_,L)=>new TextDecoder().decode(await A(Nt.historyFile,D(_,L))),readBytes:(_,L)=>A(Nt.historyFile,D(_,L)),diff:(_,L)=>o(Nt.historyDiff,{cache:"no-store"},D(_,L)),restore:(_,L)=>r(Nt.historyRestore,{n:_,...L?{paths:L}:{},client:n}),dismissNotice:async _=>{await r(Nt.historyDismiss,{id:_})},onChange:_=>c("history",_)}},async mcp(){const{viewer:$}=await R();return $.role!=="owner"?null:{callTool:async(z,_,L,B)=>{const U=B?.signal;U?.throwIfAborted();const I={server:z,tool:_,args:L,...B?.timeoutMs===void 0?{}:{timeoutMs:B.timeoutMs}};try{return await o(Nt.mcpCall,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(I),...U?{signal:U}:{}})}catch(F){throw U?.aborted?U.reason:F}},listTools:z=>o(Nt.mcpTools,{cache:"no-store"},z===void 0?void 0:{server:z})}},async sheet(){const{stores:$}=await R();if(!$?.sheet)return null;let D=Promise.resolve();return{read:_=>r(zm.read,_),send:_=>{const L=D.then(()=>r(zm.send,_));return D=L.catch(()=>{}),L},widget:_=>r(zm.widget,_),importFile:(_,L)=>o(zm.importFile,{method:"POST",headers:{"content-type":_.type||"application/octet-stream"},body:_},{name:L}),onFrame:_=>c(kee,_),onWalkthrough:_=>c(Eee,_)}},async downloads(){return{save:async({name:D,data:z})=>o(Nt.downloads,{method:"POST",headers:{"content-type":z.type||"application/octet-stream"},body:z},{name:D})}}};function O($){return A(Nt.file,{path:$})}async function A($,D){let z;try{z=await fetch(s($,D),{cache:"no-store"})}catch(_){throw new Tu("unavailable",_ instanceof Error?_.message:String(_))}if(!z.ok)throw await Lw(z);return new Uint8Array(await z.arrayBuffer())}return{get($){const D=N[$];return D?D():null}}}const Mee="[Artifact comment sent to agent]",Ree="[Artifact edit request sent to agent]",jee="[Artifact task finished]",Aee="[Open Artifact] ",Nee={id:"open_artifact_id"},GI=/^#slide-(?:~[A-Za-z0-9_-]{1,64}(?:\.only(?:\.[0-9]{1,4}\.[0-9]{1,4})?)?|[0-9]{1,4})$/,Oee="#view-inline",$ee=1,_ee=1,Lee=/^[a-z][a-z0-9]{0,23}$/,Dee="may not have run: the artifact was updated before this call was answered",zee=["quickstart","list","publish","read","open","call","adopt","delete","share"],Pee=["get","list","query","set","update","delete","str_replace","batch"],Iee=["read","reply","resolve","reopen","wait"],Bee=["share","export"],Fee={type:"object",properties:{action:{type:"string",enum:zee,description:"What to do: quickstart, list, publish, read, open, call, adopt, delete or share. Omitted: publish."},intent:{type:"string",description:"quickstart: what is being made (design, design-system, slides, whiteboard, document, data, sheets, motion, page, other), or a few words about it."},scope:{type:"string",enum:["types","mine","all"],description:"list: types (the installed types), mine (this session's and this project's artifacts; the default) or all (every artifact)."},type:{type:"string",description:"list: only artifacts of this type (an id, or open-artifact://type/<id>). quickstart: the type already chosen (an id), to get its create call and steps without matching."},query:{type:"string",description:"list: only artifacts whose title contains this text."},limit:{type:"integer",description:"list: how many to return (default 50, at most 200)."},cursor:{type:"string",description:"list: the next_cursor of the previous page."},type_url:{type:"string",description:"publish without url: the type to create from (open-artifact://type/<id>, from quickstart). read without url: the type to describe."},title:{type:"string",description:"publish without url: the new artifact's name. quickstart: the name it will have, to find similar ones."},folder:{type:"string",description:"publish without url: the exact folder for the new artifact (absolute, or relative to the workspace), only when the person named one. Omitted: Open Artifact chooses the folder and its name. adopt: the folder to add."},location:{type:"string",enum:["home","workspace"],description:"publish without url: where the new artifact's folder goes when the person asked: workspace (in the project, under the working folder) or home (the person's Open Artifact folder). Omitted: what the person's settings say. The folder is named from the title either way."},url:{type:"string",description:"An artifact: open-artifact://artifact/<id>, as publish returned it."},files:{type:"object",additionalProperties:!0,description:'publish with url: files to write under the artifact root, as {"rel/path": "text"} or {"rel/path": {"content": "...", "encoding": "base64"}}; null deletes.'},if_match:{type:"object",additionalProperties:!0,description:'publish with url: {"rel/path": sha256 | null | "*"}. Write only while the file still has the sha256 you read, does not exist (null), or anyway ("*"). One mismatch writes nothing and returns the current versions.'},check:{type:"boolean",description:"publish with url: run the type's check action after writing; its result comes back as check."},capabilities:{type:"object",additionalProperties:!0,description:'publish, page artifacts only: the runtime capabilities the page may use, as {"db": true, "assets": true, ...}. Omitted: kept; {}: none; otherwise the whole set. With url it may be given without files.'},open:{type:"string",enum:["after_first_write","now","never"],description:"publish without url: after_first_write (the default) opens the page in your app once your first write lands; now opens it at once; never leaves it closed. Where your app cannot show pages by itself the result says so: open view_url in your app's built-in browser, if you have one."},related:{type:"boolean",description:"quickstart: list existing artifacts the recommended type can build on, such as design systems (default true)."},path:{type:"string",description:"read: one file or folder under the root (omitted: the record and the file list)."},paths:{type:"array",items:{type:"string"},description:"read: several files under the root at once."},name:{type:"string",description:"call: the action's name (check, upload, ...; read with url lists them)."},args:{type:"object",additionalProperties:!0,description:"call: the action's arguments. upload: {file: absolute path, name?, group?}."},panel:{type:"string",enum:Bee,description:"open: also open the page's Share panel (share), for the person to share it on the network, or its Export tab (export), for them to download a file."},cloud:{type:"string",description:"share: publish the artifact to this cloud remote (its name, as `open-artifact remote list` shows it). It works only on a remote the person set up and let agents publish to (agentMayPublish); otherwise the person publishes it, from the Share panel or with `open-artifact publish <id> --remote <name>`."}}},Hee={type:"object",properties:{action:{type:"string",enum:Pee,description:"What to do: get, list, query, set, update, delete, str_replace or batch."},url:{type:"string",description:"The artifact (open-artifact://artifact/<id>)."},collection:{type:"string",description:"The collection: alone for list / query (query needs it), with doc_id for one document."},doc_id:{type:"string",description:"With collection: the document to get / set / update / delete / str_replace."},path:{type:"string",description:"collection/doc_id, instead of the two."},data:{type:"object",additionalProperties:!0,description:"set / update: the document's fields."},file_path:{type:"string",description:"set / update: a JSON file holding the fields, instead of data."},if_match:{description:'set / update / delete / str_replace: the sha256 get returned (write only if unchanged), null (only if it does not exist) or "*" (replace whatever is there).'},field:{type:"string",description:"str_replace: the text field, as a dot path (body, notes.text)."},old:{type:"string",description:"str_replace: the passage to replace; it must occur exactly once."},new:{type:"string",description:"str_replace: the passage that replaces it."},where:{type:"array",items:{type:"object",additionalProperties:!0},description:"query: [{field, op, value}], all must hold. op: ==, !=, <, <=, >, >=, in, not-in (up to 30 values), array-contains."},order_by:{type:"object",additionalProperties:!0,description:'query: {field, dir: "asc" | "desc"}.'},limit:{type:"integer",description:"list / query: how many documents (default 100, at most 1000)."},cursor:{type:"string",description:"list / query: the next_cursor of the previous page."},out_file:{type:"string",description:"get / list / query: write the result to this JSON file (absolute, or relative to the workspace) and return only its path and counts."},writes:{type:"array",items:{type:"object",additionalProperties:!0},description:"batch: [{op: set|update|delete|str_replace, path | collection+doc_id, data | file_path, if_match?, field?, old?, new?}], at most 500."}},required:["action","url"]},Uee={type:"object",properties:{action:{type:"string",enum:Iee,description:"What to do: read, reply, resolve, reopen or wait."},url:{type:"string",description:"The artifact (open-artifact://artifact/<id>). wait: optional."},thread_id:{type:"string",description:'reply / resolve / reopen: the thread (after ";thread=" in the message).'},text:{type:"string",description:"reply: the answer."},resolve:{type:"boolean",description:"reply: resolve the thread too."},all:{type:"boolean",description:"read: resolved threads too."},since:{type:"string",description:"read: only threads with a message at or after this time (ISO 8601)."},acknowledge_duplicate:{type:"boolean",description:"reply: send the same text as your last reply in this thread again, on purpose."},timeout_ms:{type:"number",description:"wait: how long (default 600000)."}},required:["action"]},mO={Artifact:Fee,ArtifactData:Hee,ArtifactComments:Uee},Vee={Artifact:["Make and change artifacts: typed folders of files that open as live pages the person can view, edit, comment on and export. Actions:","- quickstart {intent, type?}: call first for a new artifact; recommends a type (or takes the one given) and returns the call that creates it, the steps for this app and similar artifacts that already exist.",'- list {scope: "mine" | "all" | "types", type?, query?}: find existing artifacts, or the installed types.',"- publish {type_url, title, folder?, open?}: create an artifact; the result carries its root folder and the type's instructions. publish {url, files, if_match?, check?}: write files when you have no file tools of your own. A page artifact also takes capabilities (on create or write): the runtime capabilities its page may use.","- read {url, path? | paths?}: the artifact's record, files and actions, or some of its files with their sha256. read {type_url}: a type's instructions, before creating.",`- open {url, panel?}: show it to the person in the computer's browser (or the app, when it shows pages), once its content is written. When your app has a built-in browser, open view_url there instead. panel "share" or "export" opens its Share panel or Export tab for them.`,"- call {url, name, args?}: run one of the type's actions (check, upload, ...). A long one answers {task, pending: true}; its result comes later as a message.","- adopt {url | folder}: take over an artifact, or add an existing folder. Only when the person asks.","- share {url}: whether it is shared on the local network, and its links. Only the person changes that, in the page's Share panel.","- delete {url}: forget an artifact; its folder stays. Only when the person asks."].join(`
15
15
  `),ArtifactData:'Read and write the document store of an artifact whose type keeps one (its instructions say so). get, list and query read documents with their sha256; set, update, delete, str_replace and batch write them. update merges fields, and {"__delete__": true} removes one; str_replace changes one passage of a long text field. Replacing or deleting an existing document needs if_match: the sha256 you read, or "*". Your writes show live on open pages.',ArtifactComments:`Comments the person leaves on their artifact's page, kept in the artifact's own folder on this computer (no outside service). read lists the threads; reply answers one (thread_id is after ";thread=" in the message), with resolve: true when it is done; resolve and reopen change a thread's state. A thread sent to you is the person asking for your answer in it, so replying there is what they asked for. Answer only threads sent to you, in one or two lines. wait blocks until the next message for this session: use it only when nothing else can wake you.`},gO={Artifact:{title:"Artifact",openWorldHint:!1},ArtifactData:{title:"Artifact data",openWorldHint:!1},ArtifactComments:{title:"Artifact comments",destructiveHint:!1,openWorldHint:!1}},qee={Artifact:{quickstart:"read",list:"read",read:"read",publish:"write",call:"write",open:"ui",delete:"remove",adopt:"remove",share:"person"},ArtifactData:{get:"read",list:"read",query:"read",set:"write",update:"write",str_replace:"write",batch:"write",delete:"write"},ArtifactComments:{read:"read",wait:"read",reply:"write",resolve:"write",reopen:"write"}},Wee={Artifact:["publish","open","call","share"],ArtifactData:["get","list","query","set","update","str_replace","batch","delete"],ArtifactComments:["read","reply","resolve","reopen"]};function Gee(e={any:!1,actions:!1}){return Object.keys(mO).map(t=>{const n=t==="Artifact"?e.any:e.actions;return{name:t,description:Vee[t],inputSchema:mO[t],annotations:n?{...gO[t],openWorldHint:!0}:gO[t],actions:qee[t],remoteActions:[...Wee[t]]}})}Gee();const Yee=300,Kee=12,yO=["Artifact","ArtifactData","ArtifactComments"];function Ra(e,t=Yee){const n=String(e??"").replace(/[<>]/g,"").replace(/\s+/g," ").trim();return n.length>t?`${n.slice(0,t-1).trimEnd()}…`:n}function Xee(e){const t=Ra(e,Number.MAX_SAFE_INTEGER),n=t.search(/[.!?。!?](\s|$)/);return n>=0?t.slice(0,n+1):t}function Zee(e){const t=Ra(e,24);return/^[a-z0-9]{1,5}$/i.test(t)?t.toUpperCase():t}const bO=e=>!e||/[.!?。!?…]$/.test(e)?e:`${e}.`;function Qee(e,t=!1){const n=Ra(e.title,80)||e.id;if(t)return`- ${e.id}: ${n}`;const s=Ra(e.when)||Ra(Xee(e.description)),o=(e.exports??[]).map(Zee).filter(Boolean),r=[bO(n),bO(s),o.length?`Exports: ${o.join(", ")}.`:""].filter(Boolean);return`- ${e.id}: ${r.join(" ")}`}const Jee="Open Artifact lets you make artifacts: typed folders of files (a slide deck, a design canvas, a whiteboard, a data dashboard, a spreadsheet, a doc, an animated motion piece, a free HTML page and more) that open as live pages the person can view, edit, comment on and export. You make and change them with the Artifact, ArtifactData and ArtifactComments tools.",ete=`<where_output_goes>
16
16
  Decide where your output will live before you make anything.
17
17
  - Something the person will read once and move on from (an answer, an explanation, a summary, a short report) goes in your reply, however long it is. A diagram or chart that explains your answer goes in the reply too, when you can show one there.
@@ -658,4 +658,4 @@ ${Rb()}`,m=X8(u,g,{width:Xe,height:ft,outerWidth:f,outerHeight:h}),b=await Z8(m,
658
658
  `});return}if(t2.has(c.tagName)){s(),o(c,$5(c,l)),s();return}o(c,$5(c,l))}})};o(e,{});let r=Ms(t);for(;r.length&&r[0].text.startsWith(`
659
659
  `);)r=Ms([{...r[0],text:r[0].text.slice(1)},...r.slice(1)]);for(;r.length&&r[r.length-1].text.endsWith(`
660
660
  `);){const i=r[r.length-1];r=Ms([...r.slice(0,-1),{...i,text:i.text.slice(0,-1)}])}return q0e(r)}function q0e(e){let t=e;for(ek(t)>ve.textChars&&(t=Tne(t,0,ve.textChars));i6(t)>ve.inlineMarks&&t.some(n=>n.marks);){const n=t.map(s=>!!s.marks).lastIndexOf(!0);t=Ms(t.map((s,o)=>o===n?{text:s.text}:s))}return t}function xH(e){const t=[...e.children].filter(n=>n.tagName==="LI").map(n=>{const s=bH(n);return s?{runs:Fl(n),level:s}:{runs:Fl(n)}});return t.length?t:[{runs:Fl(e)}]}function W0e(e,t){const n=[];let s=[];const o=()=>{if(s.length===0)return;const r=document.createElement("p");for(const l of s)r.appendChild(l.cloneNode(!0));const i=Fl(r);(i.length||n.length===0)&&n.push({kind:"text",tag:"p",style:{},runs:i}),s=[]};return e.childNodes.forEach(r=>{if(r instanceof HTMLElement&&(r.tagName==="UL"||r.tagName==="OL")){o(),n.push({kind:"list",tag:r.tagName==="UL"?"ul":"ol",style:{},items:xH(r)});return}if(r instanceof HTMLElement&&t2.has(r.tagName)){o();const i=/^H[1-3]$/.test(r.tagName)?r.tagName.toLowerCase():"p";n.push({kind:"text",tag:i,style:{},runs:Fl(r)});return}s.push(r)}),o(),n.map((r,i)=>{const l=t[i];return!l||l.kind!==r.kind?r:l.kind==="list"&&r.kind==="list"&&l.tag===r.tag?{...l,items:r.items}:{...r,style:l.style}})}let _u=null,Lu=null,Ml=null;function _5(e){Ml=e}function Ws(){return _u&&_u.isConnected?_u:null}function vH(){const e=Ws();if(e&&(e.focus({preventScroll:!0}),Lu)){const t=window.getSelection();t?.removeAllRanges(),t?.addRange(Lu)}}function G0e(){const e=Lu??(window.getSelection()?.rangeCount?window.getSelection().getRangeAt(0):null);return!e||e.collapsed}function K0(e,t){const n=Ws();n&&(vH(),document.execCommand("styleWithCSS",!1,e==="foreColor"?"true":"false"),document.execCommand(e,!1,t),n.dispatchEvent(new Event("input",{bubbles:!0})))}function Y0e(e){if(!Ws())return!1;try{return document.queryCommandState(e)}catch{return!1}}const X0="data-open-artifact-link-card";function K0e(){const e=document.querySelector(`[${X0}] button`);return e?.focus(),!!e}function X0e(e){return e instanceof Element&&!!e.closest(`[data-open-artifact-format-bar],[${X0}]`)}function Z0e(e,t,n){switch(e.kind){case"text":{const s=Fl(t);return Pw(s,e.runs)?null:{...e,runs:s}}case"list":{const s=xH(t);return s.length===e.items.length&&s.every((r,i)=>Pw(r.runs,e.items[i].runs)&&(r.level??0)===(e.items[i].level??0))?null:{...e,items:s}}case"textbox":{const s=W0e(t,e.blocks),o=JSON.stringify(e.blocks);return JSON.stringify(s)===o?null:{...e,blocks:s}}case"table":{if(!n)return null;const s=t.querySelector(`[data-open-artifact-cell="${n[0]}:${n[1]}"]`),o=e.rows[n[0]]?.cells[n[1]];if(!s||!o)return null;const r=Fl(s);return Pw(r,o.runs)?null:eoe(e,n[0],n[1],Ms(r))}default:return null}}function Q0e(e,t,n,s,o){Ga(e,"Edit text",r=>{let i=!1;const l=Bn(r,t,c=>{const u=Z0e(c,n,s);return u?(i=!0,u):c});return i?l:null},{coalesce:o})}function J0e(e,t){const n=window.getSelection();if(!n)return;let s=null;if(Ml){const r=document.caretPositionFromPoint?.(Ml.x,Ml.y);if(r&&e.contains(r.offsetNode))s=document.createRange(),s.setStart(r.offsetNode,r.offset);else{const i=document.caretRangeFromPoint?.(Ml.x,Ml.y);i&&e.contains(i.startContainer)&&(s=i)}Ml=null}s||(s=document.createRange(),s.selectNodeContents(e),t||s.collapse(!1)),n.removeAllRanges(),n.addRange(s)}function Ub(e,t,n,s){const{slideId:o,path:r,cell:i}=t,l=C.useRef(`text:${o}:${is(r)}:${i?.join(":")??""}:${Date.now()}`),c=C.useRef(null);C.useLayoutEffect(()=>{const u=e.current;if(!u)return;u.innerHTML=n(),_u=u,Lu=null,u.focus({preventScroll:!0}),J0e(u,s.placeholder);const f=()=>{c.current&&clearTimeout(c.current),c.current=null,Q0e(o,r,u,i,l.current)},h=()=>{c.current&&clearTimeout(c.current),c.current=setTimeout(f,400)},g=v=>{if(v.key==="Escape"){v.preventDefault(),v.stopPropagation(),f(),te.getState().endTextEdit();return}if(v.key==="Enter"&&(s.lineBreakOnEnter||v.shiftKey)&&!v.isComposing){v.preventDefault(),document.execCommand("insertLineBreak");return}if(v.key==="Tab"&&!v.shiftKey&&!v.isComposing&&t.node.kind!=="list"&&t.node.kind!=="table"){const w=window.getSelection()?.anchorNode?.parentElement?.closest("ul,ol");if(!(w&&u.contains(w))&&K0e()){v.preventDefault();return}}if(v.key==="Tab"&&!v.isComposing&&(t.node.kind==="list"||t.node.kind==="textbox")){const w=t.node.kind==="list"?u:window.getSelection()?.anchorNode?.parentElement?.closest("ul,ol");w&&u.contains(w)&&U0e(w,v.shiftKey?-1:1)&&(v.preventDefault(),h());return}if(v.key==="Tab"&&i&&t.node.kind==="table"){v.preventDefault(),f();const w=t.node,E=w.rows[0]?.cells.length??1,M=i[0]*E+i[1]+(v.shiftKey?-1:1),S=w.rows.length*E;if(M<0||M>=S){te.getState().endTextEdit();return}te.getState().startTextEdit({slideId:o,path:r,cell:[Math.floor(M/E),M%E]})}},m=v=>{v.preventDefault(),v.stopPropagation();const w=v.clipboardData?.getData("text/plain")??"";document.execCommand("insertText",!1,w)},b=v=>{const w=window.getSelection();w?.rangeCount&&u.contains(w.getRangeAt(0).startContainer)&&(Lu=w.getRangeAt(0).cloneRange()),!X0e(v.relatedTarget)&&f()};return u.addEventListener("input",h),u.addEventListener("keydown",g),u.addEventListener("paste",m),u.addEventListener("blur",b),document.execCommand("defaultParagraphSeparator",!1,"p"),()=>{u.removeEventListener("input",h),u.removeEventListener("keydown",g),u.removeEventListener("paste",m),u.removeEventListener("blur",b),f(),_u===u&&(_u=null),Lu=null}},[])}const Vb={contentEditable:!0,suppressContentEditableWarning:!0,spellCheck:!0,"data-open-artifact-editing":""};function eye(e){const{node:t,path:n}=e,s=C.useRef(null),o=ps();Ub(s,e,()=>Hb(t.runs),{lineBreakOnEnter:!0,placeholder:wH(t)===nC}),Ya(s,t.fit,[t]);const r=t.tag,i=Tn(t.style,{resolveUrl:o.resolveSrc});return p.jsx(r,{ref:s,className:"open-artifact-text","data-open-artifact-path":is(n),"data-open-artifact-kind":"text",style:i,...Vb})}function tye(e){const{node:t,path:n}=e,s=C.useRef(null),o=ps();Ub(s,e,()=>yH(t),{lineBreakOnEnter:!1,placeholder:!1}),Ya(s,t.fit,[t]);const r=t.tag;return p.jsx(r,{ref:s,className:"open-artifact-list","data-open-artifact-path":is(n),"data-open-artifact-kind":"list",style:jB(Tn(t.style,{resolveUrl:o.resolveSrc}),t.itemMargin),start:t.start,reversed:t.reversed,...Vb})}function nye(e){const{node:t,path:n}=e,s=C.useRef(null),o=ps(),r=t.blocks.length===1&&t.blocks[0].kind==="text"&&wH(t.blocks[0])===nC;Ub(s,e,()=>V0e(t.blocks),{lineBreakOnEnter:!1,placeholder:r}),Ya(s,t.fit,[t]);const i=Tn(t.style,{resolveUrl:o.resolveSrc});return t.indent!==void 0&&(i["--open-artifact-indent"]=`${t.indent}px`),p.jsx("div",{ref:s,className:"open-artifact-textbox","data-open-artifact-path":is(n),"data-open-artifact-kind":"textbox",style:i,...Vb})}function sye(e){const{node:t,cell:n}=e,s=C.useRef(null),o=t.rows[n[0]].cells[n[1]];Ub(s,e,()=>Hb(o.runs),{lineBreakOnEnter:!0,placeholder:!1});const r=o.tag;return p.jsx(r,{ref:s,"data-open-artifact-cell":`${n[0]}:${n[1]}`,style:Tn(o.style),...Vb})}function oye(e){const{node:t,path:n,cell:s}=e,o=C.useRef(null),r=ps();return Ya(o,t.fit,[t]),p.jsx("div",{ref:o,className:"open-artifact-tablebox","data-open-artifact-path":is(n),"data-open-artifact-kind":"table",style:Tn(t.style,{resolveUrl:r.resolveSrc}),children:p.jsx("table",{className:"open-artifact-table",children:p.jsx("tbody",{children:t.rows.map((i,l)=>p.jsx("tr",{style:Tn(i.style),children:i.cells.map((c,u)=>{if(s&&s[0]===l&&s[1]===u)return p.jsx(sye,{...e,node:t,cell:[l,u]},`edit-${l}-${u}`);const f=c.tag;return p.jsx(f,{"data-open-artifact-cell":`${l}:${u}`,style:Tn(c.style),children:p.jsx(Zu,{runs:c.runs,linkable:!1})},`view-${l}-${u}`)})},l))})})})}function wH(e){return e.runs.map(t=>t.text).join("")}function rye(e){switch(e.node.kind){case"text":return p.jsx(eye,{...e,node:e.node});case"list":return p.jsx(tye,{...e,node:e.node});case"textbox":return p.jsx(nye,{...e,node:e.node});case"table":return p.jsx(oye,{...e,node:e.node})}}function Fr({children:e,...t}){return p.jsx("svg",{viewBox:"0 0 16 16",width:"16",height:"16",fill:"none",stroke:"currentColor",strokeWidth:1,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,...t,children:e})}function SH(e){return p.jsxs(Fr,{...e,strokeWidth:1.2,children:[p.jsx("path",{d:"M1.5 7H6.5M4 7V13"}),p.jsx("path",{d:"M7.5 3.5H14.5M11 3.5V13"})]})}function iye(e){return p.jsxs(Fr,{...e,children:[p.jsx("path",{d:"M3.5 2.5V13.5M2 4L3.5 2.5L5 4M2 12L3.5 13.5L5 12"}),p.jsx("path",{d:"M7.5 4H14M7.5 8H14M7.5 12H14"})]})}function aye(e){return p.jsxs(Fr,{...e,children:[p.jsx("path",{d:"M2 2.5V13.5M14 2.5V13.5"}),p.jsx("path",{d:"M5.25 11.5L8 4.5L10.75 11.5M6.2 9H9.8"})]})}function lye(e){return p.jsx(Fr,{...e,children:p.jsx("path",{d:"M5.327 2.655H10.673M5.327 13.345H10.673M2.655 5.328V10.673M13.345 5.328V10.673"})})}function cye(e){return p.jsx(Fr,{...e,children:p.jsx("path",{d:"M2.739 5.826V4.739C2.739 3.634 3.634 2.739 4.739 2.739H5.826M10.174 2.739H11.261C12.366 2.739 13.261 3.634 13.261 4.739V5.826M13.261 10.174V11.261C13.261 12.366 12.366 13.261 11.261 13.261H10.174M5.826 13.261H4.739C3.634 13.261 2.739 12.366 2.739 11.261V10.174"})})}const uye={top:"M3 3H13",right:"M13 3V13",bottom:"M3 13H13",left:"M3 3V13"};function dye({side:e,...t}){return p.jsxs(Fr,{...t,children:[p.jsx("rect",{x:"3",y:"3",width:"10",height:"10",rx:"1",strokeOpacity:.3,strokeDasharray:"1.5 1.5"}),p.jsx("path",{d:uye[e],strokeWidth:1.5})]})}const fye={"top-left":0,"top-right":90,"bottom-right":180,"bottom-left":270};function hye({corner:e,...t}){return p.jsx(Fr,{...t,children:p.jsx("path",{d:"M3.5 12.5V8C3.5 5.515 5.515 3.5 8 3.5H12.5",transform:`rotate(${fye[e]} 8 8)`})})}function kH(e){return p.jsx(Fr,{...e,strokeWidth:1.5,children:p.jsx("path",{d:"M2 8H14"})})}function EH(e){return p.jsx(Fr,{...e,strokeWidth:1.5,children:p.jsx("path",{d:"M1.5 8H4.5M6.5 8H9.5M11.5 8H14.5"})})}function CH(e){return p.jsx(Fr,{...e,strokeWidth:1.5,children:p.jsx("path",{d:"M2 8H2.01M5 8H5.01M8 8H8.01M11 8H11.01M14 8H14.01"})})}function os({title:e,children:t,actions:n,collapsible:s=!1,defaultOpen:o=!s}){return s?p.jsxs(_Q,{defaultOpen:o,className:"border-t border-chrome-sep first:border-t-0",children:[p.jsxs(DQ,{className:"group flex min-h-10 w-full items-center gap-1 py-2 pl-4 pr-3 text-left outline-none focus-visible:bg-chrome-hover",children:[p.jsx("h3",{className:"min-w-0 flex-1 truncate text-[13px] font-[520] text-chrome-fg",children:e}),p.jsx(Fy,{className:"size-4 text-chrome-muted transition-transform group-data-[panel-open]:rotate-90",strokeWidth:1.5})]}),p.jsx(HQ,{className:"flex min-w-0 flex-col pb-2",children:t})]}):p.jsxs("section",{className:"flex min-w-0 shrink-0 flex-col border-t border-chrome-sep pb-2 first:border-t-0",children:[p.jsxs("header",{className:"flex min-h-10 items-center gap-1 py-2 pl-4 pr-3",children:[p.jsx("h3",{className:"min-w-0 flex-1 truncate text-[13px] font-[520] text-chrome-fg",children:e}),n?p.jsx("div",{className:"-my-1 flex items-center gap-0.5",children:n}):null]}),t?p.jsx("div",{className:"flex min-w-0 flex-col",children:t}):null]})}function Be({label:e,children:t,className:n,tip:s,onReset:o,resetLabel:r}){return e===void 0?p.jsx("div",{className:ze("flex min-h-8 min-w-0 flex-wrap items-center gap-1.5 px-4 py-px",n),children:t}):p.jsxs("div",{className:ze("group/row grid min-h-8 min-w-0 grid-cols-[72px_minmax(0,1fr)] items-center gap-x-2 py-px pl-4 pr-3",n),children:[p.jsxs("span",{className:"flex min-w-0 items-center gap-0.5",title:s,children:[p.jsx("span",{className:"truncate text-[12px] text-chrome-muted",children:e}),o?p.jsx("button",{type:"button","aria-label":r??`Reset ${typeof e=="string"?e:""}`.trim(),title:r??`Reset ${typeof e=="string"?e:""}`.trim(),onClick:o,className:"flex size-4 shrink-0 items-center justify-center rounded-[4px] text-chrome-muted opacity-0 outline-none hover:bg-chrome-hover hover:text-chrome-fg focus-visible:opacity-100 group-hover/row:opacity-100 group-focus-within/row:opacity-100",children:p.jsx(vi,{className:"size-3",strokeWidth:1.75})}):null]}),p.jsx("div",{className:"flex min-w-0 items-center gap-1.5",children:t})]})}function hi({children:e,className:t}){return p.jsx("p",{className:ze("px-4 py-1 text-[12px] leading-[1.45] text-chrome-muted",t),children:e})}const yd="h-6 min-w-0 rounded-[6px] bg-chrome-field text-[13px] text-chrome-fg outline-none shadow-[inset_0_0_0_1px_var(--chrome-field-ring)] transition-shadow hover:shadow-[inset_0_0_0_1px_var(--chrome-field-ring-strong)] focus-within:shadow-[inset_0_0_0_1px_var(--color-chrome-accent)] has-[:disabled]:opacity-50",TH=ze(yd,"w-full px-2 placeholder:text-chrome-muted focus:shadow-[inset_0_0_0_1px_var(--color-chrome-accent)]"),qb=C.forwardRef(function({className:t,...n},s){return p.jsx("input",{ref:s,className:ze(TH,t),...n})});function kT({value:e,onCommit:t,className:n,...s}){const[o,r]=C.useState(e);C.useEffect(()=>r(e),[e]);const i=()=>{o!==e&&t(o)};return p.jsx("input",{className:ze(TH,n),value:o,onChange:l=>r(l.target.value),onBlur:i,onKeyDown:l=>{l.key==="Enter"?(i(),l.currentTarget.blur()):l.key==="Escape"&&(r(e),l.currentTarget.blur())},...s})}function MH(e){return e&&/(^|\s)w-/.test(e)?"":"w-full"}const pye={useGrouping:!1,maximumFractionDigits:3};function kt({value:e,onChange:t,onCommit:n,label:s,unit:o,min:r,max:i,step:l=1,placeholder:c,className:u,steppers:f=!0,disabled:h,title:g,inherited:m=!1,...b}){const[v,w]=C.useState(null),E=C.useRef(null),M=C.useRef(null),S=Kce({value:e??Number.NaN,step:l,min:r,max:i,disabled:h,onScrub:k=>{E.current=k,w(k),t?.(k)},onScrubEnd:()=>{const k=E.current;E.current=null,w(null),k!==null&&k!==e&&n(k);const R=M.current;!R||k===null||k===e||(R.setAttribute(Dg,""),R.focus({preventScroll:!0}))}});return p.jsxs(HP,{value:v??e,min:r,max:i,step:l,disabled:h,title:g,onValueChange:k=>t?.(k),onValueCommitted:k=>n(k),format:pye,className:ze(yd,"group/num relative flex items-center",MH(u),u),children:[s!==void 0?p.jsx("span",{"data-scrub":"",onMouseDown:S,onPointerDown:Yce,className:ze("flex h-full shrink-0 cursor-ew-resize items-center text-[11px] text-chrome-muted [&>svg]:size-3.5",typeof s=="string"?"whitespace-nowrap pl-2 pr-1.5":"w-6 justify-center"),children:s}):null,p.jsx(VP,{ref:M,placeholder:c,"aria-label":b["aria-label"],onInput:k=>k.currentTarget.removeAttribute(Dg),onBlur:k=>k.currentTarget.removeAttribute(Dg),onKeyDown:k=>{if(k.key!=="Enter"||k.nativeEvent.isComposing)return;const R=k.currentTarget;R.blur(),R.focus()},className:ze("h-full w-full min-w-0 bg-transparent text-[13px] tabular-nums text-chrome-fg outline-none",m?"placeholder:text-chrome-secondary":"placeholder:text-chrome-muted",s===void 0&&"pl-2")}),o?p.jsx("span",{className:"shrink-0 pr-2 text-[12px] text-chrome-muted group-focus-within/num:hidden",children:o}):null,f?p.jsxs("span",{className:"hidden h-full shrink-0 flex-col justify-center pr-0.5 group-focus-within/num:flex [@media(pointer:coarse)]:!hidden",children:[p.jsx(fZ,{tabIndex:-1,"aria-label":"Increase",className:"flex h-2.5 w-4 items-center justify-center rounded-[3px] text-chrome-muted hover:bg-chrome-hover hover:text-chrome-fg",children:p.jsx(TD,{className:"size-3",strokeWidth:2})}),p.jsx(hZ,{tabIndex:-1,"aria-label":"Decrease",className:"flex h-2.5 w-4 items-center justify-center rounded-[3px] text-chrome-muted hover:bg-chrome-hover hover:text-chrome-fg",children:p.jsx(Go,{className:"size-3",strokeWidth:2})})]}):null]})}function Rs({value:e,options:t,onChange:n,placeholder:s="—",className:o,icon:r,valueStyle:i,disabled:l,title:c,inherited:u=!1,...f}){const h=t.find(g=>g.value===e);return p.jsxs(OZ,{value:e,disabled:l,onValueChange:g=>g!==null&&n(g),children:[p.jsxs(zZ,{"aria-label":f["aria-label"],title:c,className:ze(yd,"flex cursor-default items-center gap-1.5 pl-2 pr-[5px] text-left disabled:opacity-50",MH(o),o),children:[r?p.jsx("span",{className:"flex shrink-0 text-chrome-muted [&>svg]:size-3.5",children:r}):null,p.jsx("span",{className:ze("min-w-0 flex-1 truncate",!h&&(u?"text-chrome-secondary":"text-chrome-muted")),style:h?i??h.style:void 0,children:h?.label??s}),p.jsx(Go,{className:"size-4 shrink-0 text-chrome-muted",strokeWidth:1.5})]}),p.jsx(PZ,{children:p.jsx(BZ,{sideOffset:4,alignItemWithTrigger:!1,className:"z-[1000]",children:p.jsx(VZ,{className:"max-h-[min(420px,var(--available-height))] min-w-[var(--anchor-width)] overflow-auto rounded-[14px] bg-chrome p-1.5 text-[13px] text-chrome-fg shadow-chrome-popup outline-none",children:p.jsx(WZ,{children:t.map((g,m)=>{const b=g.group&&g.group!==t[m-1]?.group?g.group:null;return p.jsxs(C.Fragment,{children:[g.separated&&m>0?p.jsx("div",{role:"separator",className:"mx-2 my-1 h-px bg-chrome-sep"}):null,b?p.jsx("div",{className:"px-2 pb-1 pt-2 text-[11px] font-[520] text-chrome-muted first:pt-1",children:b}):null,p.jsxs(GZ,{value:g.value,disabled:g.disabled,title:g.disabled?g.reason:g.title,className:"flex min-h-7 cursor-default select-none items-center gap-2 rounded-[8px] py-0.5 pl-2 pr-2.5 outline-none data-[disabled]:opacity-40 data-[highlighted]:bg-chrome-hover",children:[p.jsx("span",{className:"flex size-4 shrink-0 items-center justify-center",children:p.jsx(YZ,{children:p.jsx(Pi,{className:"size-4 text-chrome-accent",strokeWidth:2.25})})}),g.icon?p.jsx("span",{className:"flex shrink-0 text-chrome-muted [&>svg]:size-4",children:g.icon}):null,p.jsx(XZ,{className:"min-w-0 flex-1 truncate",style:g.style,children:g.label}),g.hint?p.jsx("span",{className:"shrink-0 pl-3 text-[12px] tabular-nums text-chrome-muted",children:g.hint}):null]})]},g.value)})})})})})]})}function Ls({value:e,options:t,onChange:n,className:s,vertical:o=!1,...r}){return p.jsx(kI,{value:e===null?[]:[e],onValueChange:i=>{const l=i[0];l!==void 0&&n(l)},"aria-label":r["aria-label"],orientation:o?"vertical":"horizontal",className:ze("flex items-center gap-0.5 rounded-[6px] bg-chrome-field p-px",o?"w-6 flex-col":"h-6 w-full",s),children:t.map(i=>p.jsx(EI,{value:i.value,disabled:i.disabled,"aria-label":i.title,title:i.disabled?i.reason??i.title:i.title,className:"flex h-[22px] min-w-0 flex-1 items-center justify-center rounded-[5px] px-1 text-[12px] in-data-[orientation=vertical]:w-[22px] in-data-[orientation=vertical]:flex-none text-chrome-muted outline-none hover:text-chrome-fg focus-visible:outline-2 focus-visible:outline-chrome-accent data-[disabled]:opacity-35 data-[pressed]:bg-chrome data-[pressed]:text-chrome-fg data-[pressed]:shadow-[0_0_0_1px_rgb(0_0_0/0.06),0_1px_2px_rgb(0_0_0/0.08)] [&>svg]:size-4",children:i.icon??i.label},i.value))})}function aS({checked:e,onChange:t,disabled:n,...s}){return p.jsx(xI,{checked:e,disabled:n,onCheckedChange:o=>t(o),"aria-label":s["aria-label"],className:"relative inline-flex h-4 w-7 shrink-0 items-center rounded-full bg-chrome-selected p-0.5 transition-colors data-[checked]:bg-chrome-accent disabled:opacity-40",children:p.jsx(vI,{className:"size-3 rounded-full bg-white shadow transition-transform data-[checked]:translate-x-3"})})}function mye({checked:e,onChange:t,disabled:n,...s}){return p.jsx("button",{type:"button",role:"checkbox","aria-checked":e,"aria-label":s["aria-label"],disabled:n,onClick:()=>t(!e),className:ze("flex size-3.5 shrink-0 items-center justify-center rounded-[4px] outline-none focus-visible:outline-2 focus-visible:outline-offset-1 focus-visible:outline-chrome-accent disabled:opacity-40",e?"bg-chrome-accent text-white":"shadow-[inset_0_0_0_1px_var(--chrome-field-ring-strong)]"),children:e?p.jsx(Pi,{className:"size-3",strokeWidth:3}):null})}function gye({value:e,min:t,max:n,step:s=1,onChange:o,onCommit:r,disabled:i,...l}){return p.jsx(cI,{value:e,disabled:i,min:t,max:n,step:s,onValueChange:c=>o(Array.isArray(c)?c[0]??t:c),onValueCommitted:c=>r?.(Array.isArray(c)?c[0]??t:c),className:"flex h-6 w-full items-center px-1 data-[disabled]:opacity-40",children:p.jsx(fI,{className:"flex h-4 w-full items-center",children:p.jsxs(hI,{className:"h-[3px] w-full rounded-full bg-chrome-selected",children:[p.jsx(mI,{className:"rounded-full bg-chrome-accent"}),p.jsx(pI,{"aria-label":l["aria-label"],className:"size-3.5 rounded-full bg-white shadow-[0_0_0_1px_rgb(0_0_0/0.12),0_1px_3px_rgb(0_0_0/0.2)] outline-none focus-visible:outline-2 focus-visible:outline-chrome-accent"})]})})})}const Ps=C.forwardRef(function({label:t,icon:n,shortcut:s,active:o,size:r,noTooltip:i,reason:l,disabled:c,onClick:u,className:f,type:h="button",...g},m){const b=!!(c&&l),v=p.jsx("button",{ref:m,type:h,"aria-label":t,"aria-pressed":o===void 0?void 0:o,disabled:b?void 0:c,"aria-disabled":b?!0:void 0,onClick:b?w=>w.preventDefault():u,className:ze("inline-flex size-6 shrink-0 items-center justify-center rounded-[6px] text-chrome-secondary outline-none transition-colors hover:bg-chrome-hover hover:text-chrome-fg focus-visible:outline-2 focus-visible:outline-offset-[-2px] focus-visible:outline-chrome-accent disabled:pointer-events-none disabled:opacity-35 aria-disabled:cursor-default aria-disabled:opacity-35 aria-disabled:hover:bg-transparent [&>svg]:size-4",o&&"bg-chrome-selected text-chrome-fg hover:bg-chrome-selected",f),...g,children:n});return i?v:p.jsx(_n,{label:b?l:t,shortcut:b?void 0:s,side:"top",children:v})}),yye=["top","right","bottom","left"],bye=["top-left","top-right","bottom-right","bottom-left"],xye=["Top","Right","Bottom","Left"],vye=["Top left","Top right","Bottom right","Bottom left"],wye={sides:[0,1,2,3],corners:[0,1,3,2]},Sye="The values differ — make them equal to use one field";function Wb({label:e,kind:t,values:n,unit:s,min:o,max:r,step:i,placeholder:l="0",onCommit:c,toggleDisabledReason:u,onReset:f,disabled:h,title:g}){const m=n!==null&&n.some(R=>R!==n[0]),[b,v]=C.useState(m);C.useEffect(()=>{m&&v(!0)},[m]);const w=t==="sides"?"Per side":"Per corner",E=e.toLowerCase(),M=u??(b&&m?Sye:void 0),S=t==="sides"?xye:vye,k=n===null||m?null:n[0];return p.jsxs(p.Fragment,{children:[p.jsxs(Be,{label:e,tip:g,onReset:f,children:[p.jsx(kt,{"aria-label":e,value:k,placeholder:n===null?"Mixed":m?w:l,unit:s,min:o,max:r,step:i,disabled:h,onCommit:R=>R!==null&&c([R,R,R,R])}),p.jsx(Ps,{label:`${b?"Hide":"Edit"} ${E} per ${t==="sides"?"side":"corner"}`,icon:t==="sides"?p.jsx(lye,{}):p.jsx(cye,{}),active:b,disabled:h||M!==void 0,reason:M,onClick:()=>v(!b)})]}),b&&u===void 0?p.jsx("div",{className:"grid grid-cols-2 gap-2 py-px pl-[96px] pr-[42px]",children:wye[t].map(R=>p.jsx(kt,{"aria-label":`${e} ${S[R].toLowerCase()}`,title:S[R],label:t==="sides"?p.jsx(dye,{side:yye[R]}):p.jsx(hye,{corner:bye[R]}),value:n===null?null:n[R],placeholder:n===null?"Mixed":l,unit:s,min:o,max:r,step:i,steppers:!1,disabled:h,onCommit:N=>{const O=n?[...n]:[0,0,0,0];O[R]=N??0,c(O)}},R))}):null]})}function ET({title:e,text:t,swatch:n,children:s,disabled:o,open:r,onOpenChange:i}){const[l,c]=C.useState(!1),u=r??l,f=h=>{c(h),i?.(h)};return p.jsxs(Uy,{open:u,onOpenChange:f,children:[p.jsxs(Vy,{disabled:o,"aria-label":`${e}: ${t}`,className:ze(yd,"flex w-full min-w-0 cursor-default items-center gap-1.5 pr-2 text-left disabled:opacity-50 data-[popup-open]:shadow-[inset_0_0_0_1px_var(--color-chrome-accent)]",n!==void 0?"pl-1":"pl-2"),children:[n!==void 0?p.jsx("span",{className:"size-4 shrink-0 rounded-[4px] shadow-[inset_0_0_0_1px_rgb(0_0_0/0.1)]",style:{background:n?`linear-gradient(${n}, ${n}), ${L5}`:L5}}):null,p.jsx("span",{className:"min-w-0 flex-1 truncate tabular-nums",children:t})]}),p.jsx(qy,{children:p.jsx(Wy,{side:"left",align:"start",sideOffset:8,collisionPadding:8,className:"z-[1000]",children:p.jsxs(Gy,{className:"w-64 rounded-[14px] bg-chrome pb-2 text-chrome-fg shadow-chrome-popup outline-none origin-[var(--transform-origin)] transition-[opacity,transform] duration-100 data-[ending-style]:opacity-0 data-[starting-style]:scale-95 data-[starting-style]:opacity-0",children:[p.jsxs("div",{className:"flex h-11 items-center gap-2 pl-4 pr-2",children:[p.jsx(wX,{className:"min-w-0 flex-1 truncate text-[13px] font-[520]",children:e}),p.jsx(SX,{"aria-label":"Close",title:"Close",className:"flex size-7 shrink-0 items-center justify-center rounded-[8px] text-chrome-secondary outline-none hover:bg-chrome-hover hover:text-chrome-fg focus-visible:outline-2 focus-visible:outline-chrome-accent",children:p.jsx(zr,{className:"size-4",strokeWidth:1.5})})]}),p.jsx("div",{className:"flex flex-col",children:s})]})})})]})}const L5="repeating-conic-gradient(#ddd 0 25%, #fff 0 50%) 0 0 / 8px 8px",Hl=C.forwardRef(function({variant:t="secondary",size:n,icon:s,className:o,children:r,type:i="button",...l},c){return p.jsxs("button",{ref:c,type:i,className:ze("inline-flex h-7 shrink-0 items-center justify-center gap-1.5 rounded-[8px] px-2.5 text-[13px] font-control outline-none transition-colors focus-visible:outline-2 focus-visible:outline-offset-1 focus-visible:outline-chrome-accent disabled:pointer-events-none disabled:opacity-40 [&>svg]:size-3.5",t==="primary"&&"bg-chrome-accent text-white hover:brightness-110",t==="secondary"&&"text-chrome-fg shadow-[inset_0_0_0_1px_var(--chrome-field-ring-strong)] hover:bg-chrome-hover",t==="ghost"&&"text-chrome-fg hover:bg-chrome-hover",t==="danger"&&"text-danger hover:bg-danger/10",o),...l,children:[s,r]})}),RH=12,kye=.2,Eye=/#[0-9a-f]{3,8}\b|rgba?\([^)]*\)|hsla?\([^)]*\)/gi;function jH(e,t){if(e)for(const n of e.matchAll(Eye)){const s=Vn(n[0]);if(!s||s.a<kye)continue;const o=Ob(n[0]);t.set(o,(t.get(o)??0)+1)}}function Gg(e,t){for(const n of Object.values(e))jH(n,t)}function wf(e,t){for(const n of e)jH(n.marks?.color,t)}function Cye(e,t){if(Gg(e.style,t),e.kind==="text"&&wf(e.runs,t),e.kind==="list")for(const n of e.items)wf(n.runs,t);if(e.kind==="textbox")for(const n of e.blocks)if(n.kind==="text")wf(n.runs,t);else for(const s of n.items)wf(s.runs,t);if(e.kind==="table")for(const n of e.rows){Gg(n.style,t);for(const s of n.cells)Gg(s.style,t),wf(s.runs,t)}}function D5(e,t){const n=new Map;for(const s of e)Gg(s.style,n),dd(s,o=>Cye(o,n));return[...n.entries()].filter(([s])=>!t.has(s)).sort((s,o)=>o[1]-s[1]).slice(0,RH).map(([s])=>({label:s,value:s.toLowerCase()}))}function Hi(){const e=ie(s=>s.revision),t=te(s=>s.current),n=yc(s=>s.systems);return C.useMemo(()=>{const s=ie.getState().slides;if(n.length===0){const c=D5(Object.values(s).map(u=>u.slide),new Set);return c.length?[{choices:c}]:[]}const o=[],r=new Set(n.flatMap(c=>c.colors.map(u=>Ob(u.value)))),i=t?s[t]?.slide:void 0,l=i?D5([i],r):[];l.length&&o.push({title:"In this slide",choices:l});for(const c of n)c.colors.length&&o.push({title:c.title,choices:c.colors.map(u=>({label:u.name,value:u.value}))});return o},[e,t,n])}function Tye(e,t){if(!t)return null;for(const n of e)for(const s of n.choices)if(UC(s.value,t))return s;return null}function AH({info:e}){const t=e.ratio>=e.target;return p.jsxs("span",{className:"flex min-w-0 items-center gap-1.5",title:`${e.ratio.toFixed(1)}:1 on ${e.where}`,children:[p.jsx("span",{"aria-hidden":!0,className:"flex size-4 shrink-0 items-center justify-center rounded-[4px] shadow-[inset_0_0_0_1px_rgb(0_0_0/0.12)]",style:{background:e.ground,color:e.text},children:p.jsx(SH,{className:"size-3"})}),p.jsx("span",{className:ze("truncate text-[12px]",t?"text-chrome-fg":"text-warning"),children:t?"Good contrast":"Poor contrast"})]})}function Mye({info:e}){return e?p.jsx("div",{className:"flex h-6 items-center pl-[96px] pr-3",children:p.jsx(AH,{info:e})}):null}const n2="repeating-conic-gradient(#ddd 0 25%, #fff 0 50%) 0 0 / 8px 8px",Rye="linear-gradient(135deg, #ffffff 50%, #141413 50%)";function gh(e){const{value:t,mixed:n=!1,effective:s,emptyLabel:o="None",groups:r,preview:i,disabled:l,title:c}=e,[u,f]=C.useState(!1),h=t?Vn(t):null,g=Tye(r,t),m=n?"Mixed":i?i.label:t===null?o:g?.label??Ob(t),b=t??s??null,v=n?Rye:i?i.swatch:b?`linear-gradient(${b}, ${b}), ${n2}`:n2,w=!n&&!i&&h&&h.a<1?`${Math.round(h.a*100)}%`:null;return p.jsxs(Uy,{open:u,onOpenChange:f,children:[p.jsxs(Vy,{disabled:l,title:c,"aria-label":`${e["aria-label"]}: ${m}`,className:ze(yd,"flex w-full min-w-0 cursor-default items-center gap-1.5 pl-1 pr-2 text-left disabled:opacity-50 data-[popup-open]:shadow-[inset_0_0_0_1px_var(--color-chrome-accent)]"),children:[p.jsx("span",{className:"size-4 shrink-0 rounded-[4px] shadow-[inset_0_0_0_1px_rgb(0_0_0/0.1)]",style:{background:v}}),p.jsx("span",{className:"min-w-0 flex-1 truncate",children:m}),w?p.jsx("span",{className:"shrink-0 text-[12px] tabular-nums text-chrome-muted",children:w}):null]}),p.jsx(qy,{children:p.jsx(Wy,{side:"bottom",align:"end",sideOffset:4,collisionPadding:8,className:"z-[1000]",children:p.jsx(Gy,{className:"w-64 rounded-[14px] bg-chrome p-4 text-chrome-fg shadow-chrome-popup outline-none origin-[var(--transform-origin)] transition-[opacity,transform] duration-100 data-[ending-style]:opacity-0 data-[starting-style]:scale-95 data-[starting-style]:opacity-0",children:p.jsx(NH,{value:n||i?null:t,fallback:s??null,groups:r,allowNone:e.allowNone,opaque:e.opaque,contrast:e.contrast,kinds:e.kinds,onPick:E=>{e.onCommit(E),E===null&&f(!1)},onClose:()=>f(!1)})})})})]})}function ap({label:e,onReset:t,...n}){return p.jsxs(p.Fragment,{children:[p.jsx(Be,{label:e,onReset:t,children:p.jsx(gh,{...n})}),!n.mixed&&!n.preview?p.jsx(Mye,{info:n.contrast??null}):null]})}function NH({value:e,fallback:t,groups:n,allowNone:s,opaque:o,contrast:r,kinds:i,onPick:l,onClose:c}){const u=n.some(v=>v.choices.length>0)||!!s,f=!i||i.value==="color",[h,g]=C.useState(u&&f?"system":"custom"),m=p.jsx("button",{type:"button","aria-label":"Close",title:"Close",onClick:c,className:"ml-auto flex size-7 shrink-0 items-center justify-center rounded-[8px] text-chrome-secondary outline-none hover:bg-chrome-hover hover:text-chrome-fg focus-visible:outline-2 focus-visible:outline-chrome-accent",children:p.jsx(zr,{className:"size-4",strokeWidth:1.5})}),b=p.jsxs("div",{className:"flex flex-col gap-3",children:[i?p.jsxs("div",{className:"flex items-center gap-2",children:[p.jsx("span",{className:"w-10 shrink-0 text-[12px] text-chrome-muted",children:"Type"}),p.jsx(Ls,{"aria-label":"Fill type",value:i.value,options:i.options,onChange:i.onChange})]}):null,f?p.jsx(Oye,{value:e,fallback:t??null,opaque:o,contrast:r??null,onPick:l}):i?.content]});return u?p.jsxs(VQ,{value:h,onValueChange:v=>g(v),className:"flex flex-col gap-3",children:[p.jsxs("div",{className:"-mt-1 flex items-center gap-1",children:[p.jsx(XQ,{"aria-label":"Source",className:"flex items-center gap-1",children:["system","custom"].map(v=>p.jsx(WQ,{value:v,className:"h-7 rounded-[8px] px-2.5 text-[13px] text-chrome-secondary outline-none hover:bg-chrome-hover hover:text-chrome-fg data-[selected]:text-chrome-fg focus-visible:outline-2 focus-visible:outline-chrome-accent data-[selected]:bg-chrome-selected",children:v==="system"?"Theme":"Custom"},v))}),m]}),p.jsx(QN,{value:"system",className:"outline-none",children:p.jsx(jye,{value:e,groups:n,allowNone:s,onPick:l})}),p.jsx(QN,{value:"custom",className:"outline-none",children:b})]}):p.jsxs("div",{className:"flex flex-col gap-3",children:[p.jsxs("div",{className:"-mt-1 flex items-center",children:[p.jsx("span",{className:"text-[13px] font-[520]",children:"Color"}),m]}),b]})}function jye({value:e,groups:t,allowNone:n,onPick:s}){const[o,r]=C.useState(""),l=t.reduce((g,m)=>g+m.choices.length,0)>RH||t.some(g=>g.title),c=o.trim().toLowerCase(),u=t.map(g=>({...g,choices:c?g.choices.filter(m=>m.label.toLowerCase().includes(c)||Ob(m.value).toLowerCase().includes(c)):g.choices})).filter(g=>g.choices.length>0),f=g=>{const m=[...g.currentTarget.querySelectorAll("button[data-color-row]")],b=m.indexOf(document.activeElement),v=g.key==="ArrowDown"?b+1:g.key==="ArrowUp"?b-1:g.key==="Home"?0:g.key==="End"?m.length-1:null;v!==null&&(g.preventDefault(),m[Math.max(0,Math.min(m.length-1,v))]?.focus())},h=(g,m,b,v,w)=>p.jsxs("button",{type:"button","data-color-row":!0,"aria-pressed":v,onClick:w,className:ze("flex h-8 w-full items-center gap-2.5 rounded-[8px] px-2 text-left text-[13px] outline-none hover:bg-chrome-hover focus-visible:bg-chrome-hover",v&&"bg-chrome-hover"),children:[b,p.jsx("span",{className:"min-w-0 flex-1 truncate",children:m}),v?p.jsx(Pi,{className:"size-4 shrink-0 text-chrome-accent",strokeWidth:2.25}):null]},g);return p.jsxs("div",{className:"-mx-2 flex flex-col gap-1",children:[l?p.jsx("div",{className:"px-2 pb-1",children:p.jsx(qb,{"aria-label":"Search colors",placeholder:"Search colors",value:o,onChange:g=>r(g.target.value)})}):null,p.jsxs("div",{className:"max-h-72 overflow-y-auto",onKeyDown:f,children:[n&&!c?h("none","None",p.jsx("span",{className:"size-4 shrink-0 rounded-[4px] border border-dashed border-chrome-muted"}),e===null,()=>s(null)):null,u.map((g,m)=>p.jsxs("div",{children:[g.title?p.jsx("div",{className:"px-2 pb-1 pt-2 text-[11px] font-[520] text-chrome-muted",children:g.title}):null,g.choices.map(b=>h(`${g.title??""}:${b.label}:${b.value}`,b.label,p.jsx("span",{className:"size-4 shrink-0 rounded-[4px] shadow-[inset_0_0_0_1px_rgb(0_0_0/0.12)]",style:{background:b.value}}),UC(b.value,e),()=>s(b.value)))]},g.title??m)),c&&u.length===0?p.jsx("p",{className:"px-2 py-2 text-[12px] text-chrome-muted",children:"No matches"}):null]})]})}const Aye={r:0,g:0,b:0,a:1};function Nye(e){const t=C.useRef(null),n=C.useRef(null),s=C.useRef(e);return s.current=e,C.useEffect(()=>()=>{n.current!==null&&cancelAnimationFrame(n.current)},[]),o=>{t.current={value:o},n.current===null&&(n.current=requestAnimationFrame(()=>{n.current=null,t.current&&s.current(t.current.value)}))}}function Oye({value:e,fallback:t,opaque:n,contrast:s,onPick:o}){const[r,i]=C.useState(()=>rg(Vn(e??t??"")??Aye)),l=Nye(o);C.useEffect(()=>{const m=e?Vn(e):null;m&&!UC($l(Bg(r)),e)&&i(rg(m,r.h))},[e]);const c=m=>{const b=n?{...m,a:1}:m;i(b),l($l(Bg(b)))},u=Bg({...r,a:1}),f=$l(u),h=f.toUpperCase(),g=typeof window<"u"&&"EyeDropper"in window;return p.jsxs("div",{className:"flex flex-col gap-3",children:[p.jsx($ye,{hsva:r,onChange:c}),p.jsx(z5,{label:"Hue",value:r.h/360,background:"linear-gradient(to right, #f00, #ff0, #0f0, #0ff, #00f, #f0f, #f00)",thumb:`hsl(${r.h} 100% 50%)`,valueText:`${Math.round(r.h)}°`,onChange:m=>c({...r,h:m*360})}),n?null:p.jsx(z5,{label:"Opacity",value:r.a,background:`linear-gradient(to right, transparent, ${f}), ${n2}`,thumb:$l({...u,a:r.a}),valueText:`${Math.round(r.a*100)}%`,onChange:m=>c({...r,a:Math.round(m*100)/100})}),p.jsxs("div",{className:"flex items-center gap-1.5",children:[g?p.jsx("button",{type:"button","aria-label":"Pick color from screen",title:"Pick color from screen",className:"flex size-6 shrink-0 items-center justify-center rounded-[6px] text-chrome-secondary outline-none hover:bg-chrome-hover hover:text-chrome-fg focus-visible:outline-2 focus-visible:outline-chrome-accent",onClick:()=>{const m=window.EyeDropper;new m().open().then(b=>{const v=Vn(b.sRGBHex);v&&c(rg({...v,a:r.a},r.h))}).catch(()=>{})},children:p.jsx(EK,{className:"size-4",strokeWidth:1.5})}):null,p.jsx(kT,{"aria-label":"Hex color",value:h,className:"min-w-0 flex-1 font-mono text-[12px] uppercase",onCommit:m=>{const b=m.trim(),v=Vn(/^[0-9a-f]{3,8}$/i.test(b)?`#${b}`:b);v&&c(rg({...v,a:n?1:v.a<1?v.a:r.a},r.h))}}),n?null:p.jsx(kt,{"aria-label":"Opacity percent",className:"w-[64px] shrink-0",value:Math.round(r.a*100),unit:"%",min:0,max:100,steppers:!1,onCommit:m=>m!==null&&c({...r,a:Math.max(0,Math.min(100,m))/100})})]}),s?p.jsxs("div",{className:"flex flex-col gap-2",children:[p.jsx(AH,{info:s}),s.ratio<s.target&&s.fix?p.jsx(Hl,{size:"sm",className:"self-start",onClick:()=>s.fix&&o(s.fix),children:"Use a readable shade"}):null]}):null]})}function OH(e,t){const n=t.getBoundingClientRect();return{x:Math.max(0,Math.min(1,(e.clientX-n.left)/Math.max(1,n.width))),y:Math.max(0,Math.min(1,(e.clientY-n.top)/Math.max(1,n.height)))}}function $H(e){return e.shiftKey?.1:.01}function $ye({hsva:e,onChange:t}){const n=o=>{const{x:r,y:i}=OH(o,o.currentTarget);t({...e,s:r,v:1-i})},s=o=>{const r=$H(o),i=o.key==="ArrowLeft"?{s:e.s-r}:o.key==="ArrowRight"?{s:e.s+r}:o.key==="ArrowUp"?{v:e.v+r}:o.key==="ArrowDown"?{v:e.v-r}:null;i&&(o.preventDefault(),t({...e,s:Math.max(0,Math.min(1,i.s??e.s)),v:Math.max(0,Math.min(1,i.v??e.v))}))};return p.jsx("div",{role:"slider",tabIndex:0,"aria-label":"Saturation and brightness","aria-valuetext":`Saturation ${Math.round(e.s*100)}%, brightness ${Math.round(e.v*100)}%`,className:"relative aspect-[3/2] w-full cursor-crosshair touch-none rounded-[8px] outline-none focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-chrome-accent",style:{background:`linear-gradient(to top, #000, transparent), linear-gradient(to right, #fff, transparent), hsl(${e.h} 100% 50%)`},onPointerDown:o=>{o.currentTarget.setPointerCapture(o.pointerId),n(o)},onPointerMove:o=>{o.currentTarget.hasPointerCapture(o.pointerId)&&n(o)},onKeyDown:s,children:p.jsx("span",{className:"pointer-events-none absolute size-3.5 -translate-x-1/2 -translate-y-1/2 rounded-full border-2 border-white shadow-[0_0_0_1px_rgb(0_0_0/0.25),0_1px_3px_rgb(0_0_0/0.3)]",style:{left:`${e.s*100}%`,top:`${(1-e.v)*100}%`,background:$l(Bg({...e,a:1}))}})})}function z5({label:e,value:t,background:n,thumb:s,valueText:o,onChange:r}){const i=c=>r(OH(c,c.currentTarget).x),l=c=>{const u=$H(c),f=c.key==="ArrowLeft"||c.key==="ArrowDown"?t-u:c.key==="ArrowRight"||c.key==="ArrowUp"?t+u:c.key==="PageDown"?t-.1:c.key==="PageUp"?t+.1:c.key==="Home"?0:c.key==="End"?1:null;f!==null&&(c.preventDefault(),r(Math.max(0,Math.min(1,f))))};return p.jsx("div",{role:"slider",tabIndex:0,"aria-label":e,"aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":Math.round(t*100),"aria-valuetext":o,className:"relative h-3 w-full cursor-pointer touch-none rounded-full shadow-[inset_0_0_0_1px_rgb(0_0_0/0.08)] outline-none focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-chrome-accent",style:{background:n,backgroundSize:n.includes("conic")?"auto, 8px 8px":void 0},onPointerDown:c=>{c.currentTarget.setPointerCapture(c.pointerId),i(c)},onPointerMove:c=>{c.currentTarget.hasPointerCapture(c.pointerId)&&i(c)},onKeyDown:l,children:p.jsx("span",{className:"pointer-events-none absolute top-1/2 size-3.5 -translate-x-1/2 -translate-y-1/2 rounded-full border-2 border-white shadow-[0_0_0_1px_rgb(0_0_0/0.25),0_1px_3px_rgb(0_0_0/0.3)]",style:{left:`${t*100}%`,background:s}})})}function _ye(e){if(!e)return"section";switch(e.kind){case"text":return"text";case"list":return"list";case"textbox":return"textbox";case"box":return"div";case"image":return"img";case"table":return"table";case"svg":return"svg";case"shape":return"shape";case"icon":return"icon";case"connector":return"connector";case"embed":return"embed";case"rule":return"hr"}}function Lye(e,t,n){const s=t.length?We(e,t)??null:null,o=s?s.style:e.style,r=t.length>1?fb(e,t)?.style:e.style,i=s?Xt(s):!1,l=o.display==="grid"?"grid":o.display==="none"?"none":"flex";return{element:_ye(s),...s?.kind==="shape"?{shape:s.shape}:{},pinned:i,flowChild:!!s&&!i,gridChild:!!s&&!i&&r?.display==="grid",display:l,direction:o["flex-direction"]??"column",faces:n}}function _H(e,t,n,s,o){const r=s.trim();if(r==="")return{ok:!0,patch:{[n]:void 0}};const i=rh(n,r,Lye(e,t,o));if(!i.ok)return{ok:!1,reason:i.noop?`${n} has no effect here`:i.reason};const l={};for(const[c,u]of i.set)l[c]=u;return n==="border"&&(l["border-top"]=void 0,l["border-right"]=void 0,l["border-bottom"]=void 0,l["border-left"]=void 0),{ok:!0,patch:l,...i.warning||i.note?{note:i.warning??i.note}:{}}}function Ut(e,t){const n=e.nodes.length?e.nodes.map(o=>o.style[t]):[e.slide.style[t]],s=n[0];return{value:s,mixed:n.some(o=>o!==s)}}function ic(e){if(e==="0")return 0;const t=e?/^(-?[\d.]+)px$/.exec(e):null;return t?Number(t[1]):null}function Dye(){const e=ie(t=>t.index.faces);return C.useMemo(()=>new Set(Object.values(e).map(t=>t.family.toLowerCase())),[e])}function zye(){return new Set(Er(ie.getState().index).map(e=>e.toLowerCase()))}function dt(e,t,n,s=t,o){const r=zye(),i=[];for(const l of e.paths){const c=_H(e.slide,l,t,n,r);if(!c.ok)return Ke.add({title:`Can't set ${t}`,description:c.reason}),!1;c.note&&Ke.add({title:c.note}),i.push([l,c.patch])}return LH(s,i,o)}function So(e,t,n,s){return LH(t,e.paths.map(o=>[o,typeof n=="function"?n(o.length?We(e.slide,o)??null:null):n]),s)}function LH(e,t,n){return jn(e,s=>{let o=s;for(const[r,i]of t)r.length&&!We(o,r)||(o=Pa(o,r,i));return o},n?{coalesce:n}:{})}const DH=`A presentation carries up to ${ve.faces} typefaces, and every one is in use`;function Pye(){const e=new Set,t=n=>{for(const s of qa(n??""))e.add(s.toLowerCase())};for(const n of Object.values(ie.getState().slides))t(n.slide.style["font-family"]),dd(n.slide,s=>t(s.style["font-family"]));return e}function zH(e,t){const n=Object.entries(e);if(n.some(([,o])=>o.family.toLowerCase()===t.family.toLowerCase()))return e;let s=n;if(s.length>=ve.faces){const o=Pye();if(s=n.filter(([,r])=>o.has(r.family.toLowerCase())),s.length>=ve.faces)return null}return{...Object.fromEntries(s),[W6(t.family)]:t}}function Iye(){return zH(ie.getState().index.faces,{family:"\0"})!==null}function P5(e,t,n){const s=ie.getState(),o=n?zH(s.index.faces,n):s.index.faces;if(!o)return Ke.add({title:`Can't add ${n.family}`,description:DH}),!1;if(o===s.index.faces)return dt(e,"font-family",t,"Font");const r=te.getState().current,i=Lr(r);if(!r||!i)return!1;const l=new Set(Object.values(o).map(u=>u.family.toLowerCase()));let c=i.slide;for(const u of e.paths){const f=_H(c,u,"font-family",t,l);if(!f.ok)return Ke.add({title:"Can't set font-family",description:f.reason}),!1;u.length&&!We(c,u)||(c=Pa(c,u,f.patch))}return s.apply("Font",{slides:{[r]:c},index:{...s.index,faces:o}},{focus:r}),!0}function CT({target:e,property:t,label:n,placeholder:s,className:o}){const r=Ut(e,t);return p.jsx(kT,{"aria-label":n??t,className:ze("min-w-0 flex-1 font-mono text-xs",o),value:r.mixed?"":r.value??"",placeholder:r.mixed?"Mixed":s??"—",onCommit:i=>dt(e,t,i,n??t)})}function Bye(e){return{fontWeight:e["font-weight"],textTransform:e["text-transform"],fontFamily:e["font-family"],fontStyle:e["font-style"]}}function PH(e){const t=yc(u=>u.systems),n=Dye(),s=C.useMemo(()=>{const u=ck.map(h=>{const g=C0[h];return{value:h,label:Eoe[h],hint:String(g.fontSize),style:{fontWeight:g.fontWeight,textTransform:g.uppercase?"uppercase":void 0},...t.length?{group:"Built-in"}:{}}});return[...t.flatMap(h=>h.styles.map(g=>({value:g.id,label:`${g.group?`${g.group} / `:""}${g.name}`,hint:g.declarations["font-size"]?.replace(/px$/,""),group:h.title,style:Bye(g.declarations)}))),...u]},[t]),r=(e===null?[]:Array.isArray(e)?e:[e]).map(u=>Toe(u.tag,u.style)??jue(t,u.tag,u.style)?.id??null),i=r.some(u=>u!==r[0]),l=i?null:r[0]??null;return{options:s,value:l,mixed:i,apply:u=>{const f=Aue(u);if(f){const g=Mue(f,n);ao("Text style",m=>m.kind==="text"?XO(m,f.tag,g):m);return}if(!ck.includes(u))return;const h=u;ao("Text style",g=>g.kind==="text"?XO(g,C0[h].tag,mu(h)):g)}}}const IH={r:255,g:255,b:255,a:1},Fye={r:0,g:0,b:0,a:1};function Hye(e){if(!e)return null;const t=ud(e);if(!t.ok)return null;if(t.value.gradient||t.value.image)return"unknown";const n=t.value.color?Vn(t.value.color):null;return n&&n.a>0?n:null}function BH(e,t,n){const s=[{style:e.style,where:"the slide background"}],o=n?t.length:t.length-1;for(let l=1;l<=o;l++){const c=We(e,t.slice(0,l));c&&s.push({style:c.style,where:l===t.length?"its fill":"the group fill"})}let r=IH,i="white";for(const l of s){const c=Hye(l.style.background);if(c==="unknown")return null;c&&(r=rb(c,r),i=l.where)}return{color:r,where:i}}function TT(e,t){const n=BH(e,t,!0)?.color??IH;let s=Fye;const o=[e.style];for(let r=1;r<=t.length;r++){const i=We(e,t.slice(0,r));i&&o.push(i.style)}for(const r of o){const i=r.color?Vn(r.color):null;i&&(s=i)}return{text:rb(s,n),background:n}}function FH(e,t){if(e.nodes.length!==1)return null;const n=e.paths[0],s=e.nodes[0];if(s.style["background-clip"]==="text"||s.kind==="text"&&s.runs.some(g=>g.marks?.color))return null;const o=BH(e.slide,n,s.kind!=="icon");if(!o)return null;const r=t.color?Vn(t.color):TT(e.slide,n).text;if(!r)return null;const i=rb(r,o.color),l=t.size??ic(s.style["font-size"])??0,c=t.weight??Number(s.style["font-weight"]??400),u=l>=32||l>=24&&c>=700,f=t.kind==="icon"||u?3:4.5,h=ib(i,o.color);return{ratio:h,target:f,text:pr(i),ground:pr(o.color),where:o.where,fix:h>=f?null:JB(i,o.color,f)}}const s2="image/png,image/jpeg,image/gif,image/webp,image/svg+xml",Uye="video/mp4,video/quicktime,video/webm,.mov";function Vye(e,t,n,s){jn(t,o=>Bn(o,e,r=>r.kind==="image"?n(r):r),s?{coalesce:s}:{})}function lS(e,t,n){ao(e,s=>s.kind==="image"?t(s):s,n?{coalesce:n}:void 0)}function qye(e){return!!(e.src||e.video)}function Wye(e){return Vu(ji(e,null),void 0)}function HH({label:e,text:t,thumb:n,empty:s=!1,reason:o,tip:r,onPress:i,removeLabel:l,onRemove:c}){const u=o!==void 0;return p.jsxs(Be,{label:e,children:[p.jsxs("button",{type:"button","aria-label":s?`${e}: none`:`${e}: ${t}`,title:o??(s?void 0:r),"aria-disabled":u||void 0,onClick:u?void 0:i,className:ze("flex h-7 min-w-0 flex-1 items-center gap-2 rounded-[6px] bg-chrome-field px-1.5 text-left text-[13px] text-chrome-fg outline-none hover:bg-chrome-hover focus-visible:ring-1 focus-visible:ring-chrome-accent",u&&"cursor-default text-chrome-muted hover:bg-chrome-field",s&&"text-chrome-muted"),children:[!s&&n!==void 0?p.jsx("span",{className:"size-[18px] shrink-0 overflow-hidden rounded-[4px] border border-chrome-sep bg-chrome",children:n?p.jsx("img",{alt:"",src:n,className:"size-full object-cover"}):null}):null,p.jsx("span",{className:"min-w-0 flex-1 truncate",children:t})]}),s?p.jsx(Ps,{label:"Upload image…",icon:p.jsx(IK,{className:"size-3.5"}),disabled:u,reason:o,onClick:i}):c?p.jsx(Ps,{label:l??"Remove",icon:p.jsx(Ii,{className:"size-3.5"}),onClick:c}):null]})}function Gye(e){return/^[^\s/\\]+\.(png|jpe?g|gif|webp|svg|mp4|mov|webm)$/i.test(e.trim())}function Yye(e){const t=e.alt?.trim()??"";if(Gye(t))return t;if(e.video?.link)return`${Pf[e.video.link.provider]} video`;if(e.video)return"Uploaded video";const n=e.src&&!e.src.startsWith("/_blob/")?e.src.split("/").pop():void 0;if(n)return decodeURIComponent(n);const s=/\.([a-z0-9]+)$/i.exec(e.src??"")?.[1];return s?`${s.toUpperCase()} image`:"Image"}const Kye="A selected SVG image can't be cropped to fill its frame.";function Xye({target:e}){if(e.nodes.length===0||!e.nodes.every(b=>b.kind==="image"))return null;const t=e.nodes,n=t.length===1,s=t[0],o=e.paths[0],r=n?s.video:void 0,i=!t.some(qye),l=t.some(b=>/\.svg($|\?)/i.test(b.src??"")),c=t.map(b=>b.style["object-fit"]==="contain"?"contain":"cover"),u=c.every(b=>b===c[0])?c[0]:null,f=t.map(b=>b.alt??""),h=f.every(b=>b===f[0]),g=(b,v)=>{gd(b,!1).then(w=>{w[0]&&v(w[0])})},m=()=>{r?.link?Nr.getState().open("videoLink"):g(r?`${Uye},${s2}`:s2,b=>{_0(o,b)})};return p.jsxs(os,{title:r?"Video":"Image",children:[p.jsx(HH,{label:r?"Video":"Image",text:n?i?"Add image…":Yye(s):"Mixed",thumb:r||!s.src?void 0:Ds(s.src),empty:i,reason:n?void 0:"Select one image to replace it",tip:r?.link?"Change video link":r?"Replace the video…":"Replace the image…",onPress:m,removeLabel:r?"Remove video":"Remove image",onRemove:()=>lS(r?"Remove video":"Remove image",Wye)}),r?p.jsx(Zye,{node:s,path:o,video:r}):null,r?.link&&!s.src?null:p.jsx(Be,{label:"Fit",children:p.jsx(Ls,{"aria-label":"Image fit",value:u,options:[{value:"cover",label:"Cover",...l?{disabled:!0,reason:Kye}:{}},{value:"contain",label:"Contain"}],onChange:b=>lS("Image fit",v=>b==="cover"&&/\.svg($|\?)/i.test(v.src??"")?v:ioe(b==="contain"?fd(v,void 0):v,b))})}),r?p.jsx(Qye,{path:o,video:r}):null,p.jsx(Be,{label:"Alt text",children:p.jsx(qb,{"aria-label":"Alt text",className:"min-w-0 flex-1",maxLength:ve.alt,value:h?f[0]:"",placeholder:h?"":"Mixed",onChange:b=>{const v=b.target.value;lS("Alt text",w=>Vu(w,w.src,v),"alt-text")}})})]})}function Zye({node:e,path:t,video:n}){const s=n.still==="custom",o=s?"Custom cover image":e.src?n.link?`${Pf[n.link.provider]} thumbnail`:"Video frame":"None";return p.jsx(HH,{label:"Cover image",text:o,thumb:e.src?Ds(e.src):"",tip:"Set cover image",onPress:()=>{gd(s2,!1).then(r=>{r[0]&&Gae(t,r[0])})},removeLabel:"Reset cover image",onRemove:s?()=>{n.link?Kae(t):Yae(t)}:void 0})}function Qye({path:e,video:t}){const n=(o,r,i)=>Vye(e,o,l=>ji(l,r),i),s=!!t.startOnClick;return p.jsxs(p.Fragment,{children:[p.jsx(Be,{label:"Autoplay",tip:"Automatically starts the video when it appears in a presentation.",children:p.jsx(aS,{"aria-label":"Autoplay",checked:!s,onChange:o=>n("Video autoplay",o?{startOnClick:void 0}:{startOnClick:!0,delay:void 0})})}),p.jsx(Be,{label:"Delay",children:p.jsx(kt,{"aria-label":"Delay",value:s?null:t.delay??0,unit:"s",min:0,max:60,step:.5,disabled:s,title:s?"A video that starts on a click has no delay.":"Seconds to wait after the slide appears before the video starts.",onCommit:o=>n("Video delay",{delay:o?Math.min(60,o):void 0},"video-delay")})}),t.src?p.jsxs(p.Fragment,{children:[p.jsx(Be,{label:"Loop",children:p.jsx(aS,{"aria-label":"Loop",checked:t.loop!==!1,onChange:o=>n("Video loop",{loop:o?void 0:!1})})}),p.jsx(Be,{label:"Sound",children:p.jsx(aS,{"aria-label":"Sound",checked:!!t.sound,onChange:o=>n("Video sound",{sound:o||void 0})})})]}):null,t.link&&a6(t.link.provider)?p.jsx(Be,{label:"Start at",tip:"Seconds into the video where it starts playing.",children:p.jsx(kt,{"aria-label":"Start at",value:t.link.start??0,unit:"s",min:0,max:86400,onCommit:o=>n("Video start time",{link:{...t.link,start:o?Math.round(o):void 0}})})}):null]})}function xu(e,t,n){jn(t,s=>Bn(s,e,o=>o.kind==="table"?n(o):o))}function Jye(e,t,n){return{...e,rows:e.rows.map((s,o)=>o===0?{...s,cells:s.cells.map((r,i)=>{if(i!==t)return r;const l={...r.style};return n===null?delete l.width:l.width=`${n}%`,{...r,style:l}})}:s)}}function ebe({target:e}){const t=e.nodes.length===1&&e.nodes[0].kind==="table"?e.nodes[0]:null;if(!t)return null;const n=e.paths[0],s=t.rows.length,o=Us(t),r=Array.from({length:o},(i,l)=>{const c=t.rows[0]?.cells[l]?.style.width,u=c?/^([\d.]+)%$/.exec(c):null;return{value:u?Number(u[1]):null,placeholder:c&&!u?c:"auto"}});return p.jsxs(os,{title:"Table",children:[p.jsx(Be,{label:"Columns",children:p.jsx(kt,{"aria-label":"Columns",value:o,min:1,max:ve.tableColumns,onCommit:i=>i&&i!==o&&xu(n,"Table columns",l=>E0(l,s,i))})}),p.jsx(Be,{label:"Rows",children:p.jsx(kt,{"aria-label":"Rows",value:s,min:1,max:ve.tableRows,onCommit:i=>i&&i!==s&&xu(n,"Table rows",l=>E0(l,i,o))})}),p.jsxs("div",{className:"flex flex-col gap-1 py-1 pl-4 pr-3",children:[p.jsx("div",{className:"text-[12px] text-chrome-muted",children:"Column widths"}),p.jsx("div",{className:"grid grid-cols-2 gap-2",children:r.map((i,l)=>p.jsx(kt,{"aria-label":`Column ${l+1} width`,label:`Col ${l+1}`,value:i.value,placeholder:i.placeholder,min:1,max:100,steppers:!1,className:"[&_input]:placeholder:text-chrome-fg",onCommit:c=>xu(n,"Column width",u=>Jye(u,l,c))},l))})]}),p.jsx(Be,{label:"Header row",children:p.jsx(mye,{"aria-label":"Header row",checked:ooe(t),onChange:i=>xu(n,i?"Add header row":"Remove header row",l=>soe(l,i))})})]})}function tbe({target:e}){return e.nodes.length!==1||e.nodes[0].kind!=="embed"?null:p.jsx(os,{title:"Embed",children:p.jsx(hi,{children:"This embed’s content is written by the agent — ask the agent in chat to change it."})})}const nbe={tl:{label:"Down-right",Icon:DY},tr:{label:"Down-left",Icon:LY},bl:{label:"Up-right",Icon:IY},br:{label:"Up-left",Icon:PY}},I5=[{value:"none",label:"None"},{value:"open",label:"Open"},{value:"filled",label:"Filled"}],sbe=[{value:"straight",label:"Straight"},{value:"elbow",label:"Elbow"},{value:"hv",label:"Bend: across, then down"},{value:"vh",label:"Bend: down, then across"}];function vg(e,t,n){const s=e.map(o=>o[t]??n);return s.every(o=>o===s[0])?s[0]:null}function cS(e,t){ao(e,n=>n.kind==="connector"?{...n,...t}:n)}function obe({target:e}){const t=Hi();if(e.nodes.length===0||!e.nodes.every(u=>u.kind==="connector"))return null;const n=e.nodes,s=n.every(u=>!u.points),o=Ut(e,"border-style"),r=Ut(e,"border-width"),i=Ut(e,"color"),l=o.mixed?null:o.value==="dashed"?"dashed":"solid",c=u=>{dt(e,"border-style",u==="dashed"?"dashed":"","Line style")};return p.jsxs(p.Fragment,{children:[p.jsxs(os,{title:"Connector",children:[s?p.jsx(Be,{label:"Direction",children:p.jsx(Ls,{"aria-label":"Direction",value:vg(n,"from","tl"),options:s6.map(u=>{const{label:f,Icon:h}=nbe[u];return{value:u,title:f,label:p.jsx(h,{className:"size-4",strokeWidth:1.5})}}),onChange:u=>ao("Connector direction",f=>{if(f.kind!=="connector")return f;const{from:h,...g}=f;return u==="tl"?g:{...g,from:u}})})}):null,p.jsx(Be,{label:"Start",children:p.jsx(Ls,{"aria-label":"Start",value:vg(n,"headStart","none"),options:I5,onChange:u=>cS("Arrowhead",{headStart:u})})}),p.jsx(Be,{label:"End",children:p.jsx(Ls,{"aria-label":"End",value:vg(n,"headEnd","none"),options:I5,onChange:u=>cS("Arrowhead",{headEnd:u})})}),p.jsx(Be,{label:"Route",children:p.jsx(Rs,{"aria-label":"Route",value:vg(n,"route","straight"),placeholder:"Mixed",options:sbe,onChange:u=>cS("Connector route",{route:u})})}),p.jsx(Be,{label:"Style",children:p.jsx(Ls,{"aria-label":"Style",value:l,options:[{value:"solid",label:"Solid"},{value:"dashed",label:"Dashed"}],onChange:c})})]}),p.jsxs(os,{title:"Appearance",children:[p.jsx(Be,{label:"Line",children:p.jsx(Ls,{"aria-label":"Line",value:l,options:[{value:"none",title:"None",label:p.jsx(pD,{className:"size-3.5",strokeWidth:1.5}),disabled:!0,reason:"A line always draws"},{value:"solid",title:"Solid",label:p.jsx(kH,{})},{value:"dashed",title:"Dashed",label:p.jsx(EH,{})},{value:"dotted",title:"Dotted",label:p.jsx(CH,{}),disabled:!0,reason:"A line is solid or dashed"}],onChange:c})}),p.jsx(ap,{label:"Color","aria-label":"Line color",value:i.mixed?null:i.value??null,mixed:i.mixed,effective:pr(TT(e.slide,e.paths[0]).text),emptyLabel:"Theme default",groups:t,onReset:i.value?()=>dt(e,"color","","Line color"):void 0,onCommit:u=>dt(e,"color",u??"","Line color","line-color")}),p.jsx(Be,{label:"Width",children:p.jsx(kt,{"aria-label":"Line width",value:r.mixed?null:Number.parseFloat(r.value??"")||null,placeholder:r.mixed?"Mixed":"2",unit:"px",min:1,max:32,onCommit:u=>dt(e,"border-width",u?`${u}px`:"","Line width","line-width")})})]})]})}function rbe({target:e}){const t=Hi(),n=l=>l.kind==="rule"||l.kind==="shape"&&l.shape==="line";if(e.nodes.length===0||!e.nodes.every(n))return null;const s=Ut(e,"border"),o=s.value&&!s.mixed?If(s.value,32):null,r=o?.ok?o.value:{width:2,style:"solid",color:"#141413"},i=(l,c)=>{dt(e,"border",Bf({...r,...l,style:"solid"}),c,"line")};return p.jsxs(os,{title:"Line",children:[p.jsx(Be,{label:"Thickness",children:p.jsx(kt,{"aria-label":"Thickness",value:s.mixed?null:r.width,placeholder:"Mixed",unit:"px",min:1,max:32,onCommit:l=>i({width:l??2},"Line thickness")})}),p.jsx(ap,{label:"Color","aria-label":"Line color",value:s.mixed?null:r.color,mixed:s.mixed,groups:t,onCommit:l=>l&&i({color:l},"Line color")})]})}function ibe(e){const t=e.replace(/([a-z])([A-Z])/g,"$1 $2").toLowerCase();return t[0].toUpperCase()+t.slice(1)}function abe({target:e}){const t=Hi();if(e.nodes.length===0||!e.nodes.every(l=>l.kind==="icon"))return null;const n=e.nodes.map(l=>l.kind==="icon"?l.name:null),s=n.every(l=>l===n[0])?n[0]:null,o=Ut(e,"color"),r=o.mixed?null:o.value??null,i=pr(TT(e.slide,e.paths[0]).text);return p.jsxs(os,{title:"Icon",children:[p.jsx(Be,{label:"Glyph",children:p.jsx(Rs,{"aria-label":"Glyph",value:s,placeholder:"Mixed",options:o6.map(l=>{const c=LB[l];return{value:l,label:ibe(l),icon:p.jsx(c,{size:14,strokeWidth:1.75})}}),onChange:l=>ao("Icon",c=>c.kind==="icon"?{...c,name:l}:c)})}),p.jsx(ap,{label:"Color","aria-label":"Icon color",value:r,mixed:o.mixed,effective:i,emptyLabel:"Theme default",groups:t,contrast:o.mixed?null:FH(e,{kind:"icon",color:r??i}),onReset:r?()=>dt(e,"color","","Icon color"):void 0,onCommit:l=>dt(e,"color",l??"","Icon color","icon-color")})]})}const lbe=40,cbe=36,B5=16,Mr={className:"size-4",strokeWidth:1.75},F5=[["left","Align left",TE],["center","Center",sP],["right","Align right",rP],["justify","Justify",aP]],ube=[[["left","Align left",f0],["center","Align horizontal centers",B3],["right","Align right",V3]],[["top","Align top",X3],["middle","Align vertical centers",P3],["bottom","Align bottom",H3]]];function dbe(e){return Va(e)||e.kind==="table"}function MT(){return!!Ws()&&!G0e()}function Du(){setTimeout(()=>{Ws()&&vH()},0)}function fbe(e){const t=e.target;Ws()&&!t.closest("input, textarea, [contenteditable]")&&e.preventDefault()}function hbe(){const[,e]=C.useState(0);C.useEffect(()=>{const t=()=>e(n=>n+1);return document.addEventListener("selectionchange",t),()=>document.removeEventListener("selectionchange",t)},[])}function pbe(e,t){return e===t?!0:!e||!t?!1:e.left===t.left&&e.right===t.right&&e.top===t.top&&e.bottom===t.bottom&&e.band.left===t.band.left&&e.band.right===t.band.right&&e.band.top===t.band.top&&e.band.bottom===t.band.bottom}function mbe(e){const t=document.querySelector("[data-open-artifact-stage]");if(!t)return null;const n=Ws(),s=n?[n]:e.map(u=>t.querySelector(`[data-open-artifact-path="${u.join(".")}"]`)).filter(u=>u!==null);if(s.length===0)return null;let o=1/0,r=-1/0,i=1/0,l=-1/0;for(const u of s){const f=u.getBoundingClientRect();o=Math.min(o,f.left),r=Math.max(r,f.right),i=Math.min(i,f.top),l=Math.max(l,f.bottom)}const c=t.getBoundingClientRect();return{left:Math.round(o),right:Math.round(r),top:Math.round(i),bottom:Math.round(l),band:{left:Math.round(c.left),right:Math.round(c.right),top:Math.round(c.top+Q0+J0),bottom:Math.round(c.bottom-J0-Q0)}}}function gbe(e){const[t,n]=C.useState(null),s=e?e.map(o=>o.join(".")).join(","):null;return C.useLayoutEffect(()=>{if(!e){n(null);return}let o=0;const r=()=>{const i=mbe(e);n(l=>pbe(l,i)?l:i),o=requestAnimationFrame(r)};return r(),()=>cancelAnimationFrame(o)},[s]),t}function ybe(){const e=window.getSelection();if(!Ws()||!e?.rangeCount)return null;const t=e.getRangeAt(0).getClientRects(),n=t.length?t[t.length-1]:e.getRangeAt(0).getBoundingClientRect();return n.height?{top:n.top,bottom:n.bottom}:null}function bbe(){const{slide:e,paths:t,nodes:n,readOnly:s}=Ib(),o=te(S=>S.textEdit),r=te(S=>S.tool),i=te(S=>S.cropping),l=xt(S=>!!(S.move||S.draft||S.marquee||S.draw)),c=te(S=>S.showProperties),u=!s&&gn()&&!c&&n.length>0&&n.every(dbe)&&r==="select"&&!i&&!l,f=gbe(u?t:null),h=C.useRef(null),[g,m]=C.useState(0);if(C.useLayoutEffect(()=>{h.current&&m(h.current.offsetWidth)}),!u||!f||!e)return null;const{band:b}=f;if(f.bottom<b.top||f.top>b.bottom)return null;const v=F0e(f.left,g,b.left,b.right),w=(f.left+f.right)/2,E=!o&&n.length===1&&w>=v-B5&&w<=v+g+B5?cbe:0,{top:M}=B0e({selTop:f.top-E,selBottom:f.bottom,menuH:lbe,bandTop:b.top,bandBottom:b.bottom,caret:ybe});return p.jsx("div",{ref:h,"data-open-artifact-format-bar":!0,className:"pointer-events-none fixed z-30 flex",style:{left:v,top:M,maxWidth:b.right-b.left-16},children:n.length===1&&n[0].kind==="table"&&!o?p.jsx(Sbe,{table:n[0],path:t[0]}):p.jsx(xbe,{nodes:n})})}function xbe({nodes:e}){hbe();const t=te(m=>m.textEdit!==null),n=e.length===1?e[0]:null,s=n?.kind==="text"?n:null,o=PH(s),r=e[0],i=r.style["text-align"]??"left",l=e.every(m=>(m.style["text-align"]??"left")===i),c=F5.find(([m])=>m===i)?.[2]??TE,u=n?.kind==="list"?n.tag:null,f=m=>{MT()?K0(m==="b"?"bold":m==="i"?"italic":"underline"):ao(m==="b"?"Bold":m==="i"?"Italic":"Underline",b=>Yse(b,m))},h=m=>t&&Ws()?Y0e(m==="b"?"bold":m==="i"?"italic":"underline"):e.every(b=>B6(b,m)),g=m=>{ao("List",b=>b.kind==="text"||b.kind==="list"?F6(b,m):b),Du()};return p.jsxs(Br,{role:"toolbar","aria-label":"Text format",className:"h-10 min-w-0 gap-0.5 overflow-x-auto px-1 [scrollbar-width:none]",onMouseDown:fbe,children:[s?p.jsxs(p.Fragment,{children:[p.jsx(wo,{tip:{label:"Text style"},trigger:p.jsxs(Ht,{"aria-label":"Text style",className:"max-w-[148px] gap-0.5 pl-2 pr-1",children:[p.jsx("span",{className:"min-w-0 truncate",children:o.options.find(m=>m.value===o.value)?.label??"Custom"}),p.jsx(Go,{className:"size-4 shrink-0 text-chrome-muted",strokeWidth:1.5})]}),children:o.options.map(m=>p.jsx(It,{checked:m.value===o.value,onSelect:()=>{o.apply(m.value),Du()},children:m.label},m.value))}),p.jsx($r,{})]}):null,p.jsx(Ebe,{value:r.style.color??null}),p.jsx(_n,{label:"Bold",shortcut:`${ot}B`,children:p.jsx(Ht,{square:!0,"aria-label":"Bold",pressed:h("b"),onClick:()=>f("b"),children:p.jsx(bK,{...Mr})})}),p.jsx(_n,{label:"Italic",shortcut:`${ot}I`,children:p.jsx(Ht,{square:!0,"aria-label":"Italic",pressed:h("i"),onClick:()=>f("i"),children:p.jsx(mK,{...Mr})})}),p.jsx(_n,{label:"Underline",shortcut:`${ot}U`,children:p.jsx(Ht,{square:!0,"aria-label":"Underline",pressed:h("u"),onClick:()=>f("u"),children:p.jsx(mP,{...Mr})})}),p.jsx(Cbe,{node:n}),p.jsx($r,{}),p.jsx(wo,{tip:{label:"Alignment"},trigger:p.jsxs(Ht,{"aria-label":"Alignment",className:"gap-0 pl-1.5 pr-0.5",children:[p.jsx(c,{...Mr}),p.jsx(Go,{className:"size-3.5 text-chrome-muted",strokeWidth:1.5})]}),children:F5.map(([m,b,v])=>p.jsx(It,{checked:l&&i===m,icon:p.jsx(v,{className:"size-4"}),onSelect:()=>{uB("Align",{"text-align":m==="left"?void 0:m}),Du()},children:b},m))}),e.length>1?p.jsx(kbe,{nodes:e}):null,n&&(n.kind==="text"||n.kind==="list")?p.jsxs(wo,{tip:{label:"List"},trigger:p.jsxs(Ht,{"aria-label":"List",pressed:u!==null,className:"gap-0 pl-1.5 pr-0.5",children:[u==="ol"?p.jsx(ON,{...Mr}):p.jsx($N,{...Mr}),p.jsx(Go,{className:"size-3.5 text-chrome-muted",strokeWidth:1.5})]}),children:[p.jsx(It,{checked:u===null,onSelect:()=>g(null),children:"No list"}),p.jsx(It,{checked:u==="ul",icon:p.jsx($N,{className:"size-4"}),onSelect:()=>g("ul"),children:"Bulleted list"}),p.jsx(It,{checked:u==="ol",icon:p.jsx(ON,{className:"size-4"}),onSelect:()=>g("ol"),children:"Numbered list"})]}):null,p.jsx($r,{}),p.jsx(UH,{})]})}function UH(){return p.jsx(_n,{label:"Open the Properties panel",shortcut:`${ot}\\`,children:p.jsx(Ht,{square:!0,"aria-label":"Properties",onClick:()=>te.getState().toggle("showProperties",!0),children:p.jsx(wE,{...Mr})})})}function vbe(){return p.jsx("svg",{viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:1.25,strokeLinecap:"round","aria-hidden":"true",children:p.jsx("path",{d:"M3.865 4H12.135M3.865 8H12.135M3.865 12H12.135"})})}function wbe(){return p.jsx("svg",{viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:1.25,strokeLinecap:"round","aria-hidden":"true",children:p.jsx("path",{d:"M4 3.865V12.135M8 3.865V12.135M12 3.865V12.135"})})}function Sbe({table:e,path:t}){const n=e.rows.length,s=Us(e);return p.jsxs(Br,{role:"toolbar","aria-label":"Table",className:"h-10 min-w-0 gap-1 overflow-x-auto px-1 [scrollbar-width:none]",children:[p.jsx(kt,{"aria-label":"Rows",title:"Rows. Fewer rows drop the bottom rows’ text (undoable)",label:p.jsx(vbe,{}),value:n,min:1,max:ve.tableRows,className:"w-[76px] shrink-0",onCommit:o=>o&&o!==n&&xu(t,"Table rows",r=>E0(r,o,Us(r)))}),p.jsx(kt,{"aria-label":"Columns",title:"Columns. Fewer columns drop the rightmost columns’ text (undoable)",label:p.jsx(wbe,{}),value:s,min:1,max:ve.tableColumns,className:"w-[76px] shrink-0",onCommit:o=>o&&o!==s&&xu(t,"Table columns",r=>E0(r,r.rows.length,o))}),p.jsx($r,{}),p.jsx(UH,{})]})}function kbe({nodes:e}){const t=Dae(e);return t?p.jsx(_n,{label:`Align items. ${t}`,children:p.jsx(Ht,{square:!0,"aria-label":"Align items",disabled:!0,children:p.jsx(f0,{...Mr})})}):p.jsx(wo,{tip:{label:"Align items"},trigger:p.jsxs(Ht,{"aria-label":"Align items",className:"gap-0 pl-1.5 pr-0.5",children:[p.jsx(f0,{...Mr}),p.jsx(Go,{className:"size-3.5 text-chrome-muted",strokeWidth:1.5})]}),children:ube.map((n,s)=>[s>0?p.jsx(rc,{},`sep${s}`):null,...n.map(([o,r,i])=>p.jsx(It,{icon:p.jsx(i,{className:"size-4"}),shortcut:`${KI}${N0[o]}`,onSelect:()=>MC(o),children:r},o))])})}function Ebe({value:e}){const t=Hi(),[n,s]=C.useState(!1);return p.jsx(LP,{open:n,side:"bottom",align:"start",onOpenChange:o=>{s(o),o||Du()},trigger:p.jsxs(Ht,{square:!0,"aria-label":"Text color",title:"Text color",className:"flex-col gap-0",children:[p.jsx("span",{className:"text-[14px] font-semibold leading-none",children:"A"}),p.jsx("span",{className:"mt-0.5 h-[3px] w-4 rounded-full shadow-[inset_0_0_0_1px_rgb(0_0_0/0.12)]",style:{background:e??"currentColor"}})]}),children:p.jsx("div",{"data-open-artifact-format-bar":!0,className:"w-60",children:p.jsx(NH,{value:e,groups:t,onClose:()=>{s(!1),Du()},onPick:o=>{o&&(MT()?(K0("foreColor",o),s(!1)):uB("Text color",{color:o},{coalesce:"text-color"}))}})})})}function Cbe({node:e}){const[t,n]=C.useState(!1),s=e?Kse(e):void 0,[o,r]=C.useState(s??""),i=oh(o.trim()),l=()=>{const u=o.trim();oh(u)&&(MT()?K0("createLink",u):ao("Link",f=>rk(f,"href",u)),n(!1))},c=()=>{Ws()?K0("unlink"):ao("Remove link",u=>rk(u,"href",void 0)),n(!1)};return p.jsx(LP,{open:t,side:"bottom",align:"start",onOpenChange:u=>{n(u),u?r(s??""):Du()},trigger:p.jsx(Ht,{square:!0,"aria-label":"Link",title:`Link (${ot}K)`,pressed:!!s,children:p.jsx(vK,{...Mr})}),children:p.jsxs("div",{"data-open-artifact-format-bar":!0,className:"flex w-72 flex-col gap-2",children:[p.jsx(qb,{autoFocus:!0,"aria-label":"Link address",placeholder:"https://",value:o,onChange:u=>r(u.target.value),onKeyDown:u=>{u.key==="Enter"&&(u.preventDefault(),l())}}),o.trim()&&!i?p.jsx("p",{className:"text-[12px] text-danger",children:"Links must start with http:// or https://"}):null,p.jsxs("div",{className:"flex justify-end gap-1",children:[s?p.jsx(Hl,{size:"sm",variant:"ghost",icon:p.jsx(xP,{className:"size-3.5"}),onClick:c,children:"Remove"}):null,p.jsx(Hl,{size:"sm",variant:"primary",disabled:!i,onClick:l,children:"Apply"})]})]})})}function Tbe(e){const t=e.trim();if(!t)return null;const n=/^[a-z][a-z0-9+.-]*:/i.test(t)?t:`https://${t}`;return oh(n)?n:null}function Mbe(){const e=Ws(),t=document.getSelection()?.anchorNode??null,s=(t instanceof Element?t:t?.parentElement)?.closest("a");return s&&e?.contains(s)?s:null}function Rbe(e){const t=Ws();if(!t||(t.focus({preventScroll:!0}),!e.isConnected))return;const n=document.createRange();n.selectNodeContents(e),n.collapse(!1);const s=window.getSelection();s?.removeAllRanges(),s?.addRange(n)}function H5(e,t,n){const s=Ws();if(!s||!e.isConnected)return;s.focus({preventScroll:!0});const o=document.createRange();o.selectNodeContents(e);const r=window.getSelection();r?.removeAllRanges(),r?.addRange(o),document.execCommand("styleWithCSS",!1,"false"),document.execCommand(t,!1,n),r?.collapseToEnd()}async function jbe(e){try{await Ute(e,io()?.shell),Ke.add({title:"Copied link"})}catch{Ke.add({title:"Could not copy link",description:e})}}function Abe(){const e=te(i=>i.textEdit!==null),[t,n]=C.useState(null),[s,o]=C.useState(0);if(C.useEffect(()=>{if(!e){n(null);return}const i=()=>{document.activeElement?.closest(`[${X0}]`)||n(Mbe())};return i(),document.addEventListener("selectionchange",i),()=>document.removeEventListener("selectionchange",i)},[e]),!t||!t.isConnected||!Ws())return null;const r=t.getAttribute("href")??"";return Wn.createPortal(p.jsx("div",{[X0]:"",onBlur:i=>{const l=i.relatedTarget;l instanceof Node&&(i.currentTarget.contains(l)||Ws()?.contains(l))||l instanceof Element&&l.closest("[data-open-artifact-format-bar]")||te.getState().endTextEdit()},children:p.jsx(KJ,{link:t,target:r,href:t.href,normalize:Tbe,invalidMessage:"Links must start with http:// or https://",className:"z-[1000]",onCopy:i=>{jbe(i)},onEdit:i=>(H5(t,"createLink",i),o(l=>l+1),!0),onRemove:()=>H5(t,"unlink"),onReturn:()=>Rbe(t)},`${r}:${s}`)}),document.body)}const Z0={className:"size-5",strokeWidth:1.5},Vo={className:"size-4",strokeWidth:1.5},VH=[["rect","Rectangle",p.jsx(OK,{...Vo},"r"),"R"],["rounded","Rounded rectangle",p.jsx(CK,{...Vo},"rr"),`${tb}R`],["ellipse","Ellipse",p.jsx(WY,{...Vo},"e"),"O"],["diamond","Diamond (decision)",p.jsx(tK,{...Vo},"d"),"D"]],qH=[["line","Line",p.jsx(Ii,{...Vo},"l"),"L"],["connector","Connector",p.jsx(NK,{...Vo},"c"),`${tb}L`]],Nbe=[...VH,...qH],Obe=[["arrow-right","Arrow right",p.jsx(Nm,{...Vo},"ar")],["arrow-left","Arrow left",p.jsx(Nm,{...Vo,className:"size-4 rotate-180"},"al")],["arrow-up","Arrow up",p.jsx(Nm,{...Vo,className:"size-4 -rotate-90"},"au")],["arrow-down","Arrow down",p.jsx(Nm,{...Vo,className:"size-4 rotate-90"},"ad")]];function $be(){gd(Xae,!0).then(e=>{e.length&&jC(e)})}function _be(){const e=te(n=>n.tool),t=Nbe.find(([n])=>n===e);return p.jsxs(wo,{side:"top",align:"center",tip:{label:t?t[1]:"Shapes",side:"top"},trigger:p.jsxs(Ht,{size:"lg",pressed:!!t,"aria-label":"Shapes",className:"gap-0 pl-1.5 pr-0.5",children:[t?p.jsx("span",{className:"flex size-5 items-center justify-center [&>svg]:size-5",children:t[2]}):p.jsx(jK,{...Z0}),p.jsx(Go,{className:"size-3.5 text-chrome-muted",strokeWidth:1.5})]}),children:[VH.map(([n,s,o,r])=>p.jsx(It,{icon:o,shortcut:r,onSelect:()=>te.getState().setTool(n),children:s},n)),Obe.map(([n,s,o])=>p.jsx(It,{icon:o,onSelect:()=>mB(n),children:s},n)),p.jsx(rc,{}),qH.map(([n,s,o,r])=>p.jsx(It,{icon:o,shortcut:r,onSelect:()=>te.getState().setTool(n),children:s},n))]})}function Lbe(){return p.jsxs(wo,{side:"top",align:"center",tip:{label:"Image or video",side:"top"},trigger:p.jsx(Ht,{size:"lg",square:!0,"aria-label":"Image or video",children:p.jsx(h0,{...Z0})}),children:[p.jsx(It,{icon:p.jsx(h0,{...Vo}),onSelect:$be,children:"Image or video from this computer…"}),p.jsx(It,{icon:p.jsx(iK,{...Vo}),onSelect:()=>Nr.getState().open("videoLink"),children:"Video link…"})]})}function Dbe(){const e=Rt(h=>h.status.name),t=Rt(h=>h.status.busy),n=te(h=>h.selection.length),[s,o]=C.useState(""),[r,i]=C.useState(!1),[l,c]=C.useState(!1),u=async()=>{const h=s.trim();if(!(!h||r)){i(!0);try{await v8(h)&&o("")}finally{i(!1)}}},f=l||s.length>0;return p.jsxs("form",{className:ze("flex h-8 shrink-0 items-center gap-1 rounded-[8px] bg-chrome-field pl-2.5 pr-1 transition-[width] duration-150",f?"w-64":"w-[100px]"),onSubmit:h=>{h.preventDefault(),u()},children:[t?p.jsx(p0,{className:"size-4 shrink-0 animate-spin text-chrome-muted","aria-label":`${e} is working`}):null,p.jsx("input",{value:s,"aria-label":`Ask ${e}`,maxLength:4e3,placeholder:f?n?`Ask ${e} about the selection…`:`Ask ${e} to change this slide…`:`Ask ${e}`,className:"h-full min-w-0 flex-1 bg-transparent text-[14px] text-chrome-fg outline-none placeholder:text-chrome-muted",onFocus:()=>c(!0),onBlur:()=>c(!1),onChange:h=>o(h.target.value),onKeyDown:h=>{h.key==="Escape"&&(h.preventDefault(),h.currentTarget.blur())}}),f?p.jsx("button",{type:"submit","aria-label":"Send",disabled:!s.trim()||r,className:"flex size-6 shrink-0 items-center justify-center rounded-full bg-chrome-fg text-chrome outline-none disabled:opacity-30",children:r?p.jsx(p0,{className:"size-3.5 animate-spin"}):p.jsx(bE,{className:"size-3.5",strokeWidth:2})}):null]})}function zbe({editing:e,ask:t}){const n=te(r=>r.tool),s=te.getState;if(!e&&!t)return null;const o=r=>{if(r0(r)||r.metaKey||r.ctrlKey||r.altKey||Mte(r.target)||document.querySelector('[role="menu"], [role="listbox"]'))return;const i=[...r.currentTarget.querySelectorAll("button:not([disabled])")].filter(f=>!f.closest("form")),l=document.activeElement,c=l instanceof HTMLButtonElement?i.indexOf(l):-1,u=Rte(r.key,c,i.length);u!==null&&(r.preventDefault(),i[u]?.focus())};return p.jsxs(Br,{role:"toolbar","aria-label":e?"Insert":"Ask",className:"max-w-full gap-1 p-1",onKeyDown:o,children:[e?p.jsxs(p.Fragment,{children:[p.jsx(_n,{label:"Text",shortcut:"T",side:"top",children:p.jsx(Ht,{size:"lg",square:!0,pressed:n==="text","aria-label":"Text",onClick:()=>s().setTool(n==="text"?"select":"text"),children:p.jsx(hP,{...Z0})})}),p.jsx(Lbe,{}),p.jsx(_n,{label:"Table",side:"top",children:p.jsx(Ht,{size:"lg",square:!0,"aria-label":"Table",onClick:()=>Nr.getState().open("table"),children:p.jsx(DK,{...Z0})})}),p.jsx(_be,{})]}):null,t?p.jsxs(p.Fragment,{children:[e?p.jsx($r,{className:"mx-0"}):null,p.jsx(Dbe,{})]}):null]})}function U5({peer:e,ring:t}){return p.jsx("span",{className:ze("flex size-6 shrink-0 items-center justify-center rounded-full text-[11px] font-semibold text-white ring-2 ring-chrome",t&&"outline-2 outline-offset-1 outline-chrome-accent"),style:{background:e.color},"aria-hidden":!0,children:e.kind==="agent"?p.jsx(Dh,{className:"size-3"}):e.name.slice(0,1).toUpperCase()})}function Pbe({peers:e,following:t,leading:n,followers:s,agent:o,onFollow:r,onLead:i,onFollowAgent:l}){const c=e.filter(f=>f.kind==="person");if(e.length===0&&!o)return null;const u=e.slice(0,3);return p.jsx(Br,{className:"pointer-events-auto flex items-center p-1",children:p.jsxs(wo,{align:"end",tip:{label:s?`${s} following you`:"People here"},trigger:p.jsxs(Ht,{size:"lg","aria-label":"People here and following",className:"gap-1.5 px-1.5",children:[u.length?p.jsx("span",{className:"flex -space-x-1.5",children:u.map(f=>p.jsx(U5,{peer:f,ring:f.id===t},f.id))}):p.jsx(SE,{className:"size-5",strokeWidth:1.5}),e.length>3?p.jsxs("span",{className:"text-xs text-chrome-muted",children:["+",e.length-3]}):null,n||s?p.jsxs("span",{className:ze("flex items-center gap-1 rounded-full px-1.5 text-[11px] tabular-nums",n?"bg-chrome-pressed text-chrome-pressed-fg":"text-chrome-muted"),children:[p.jsx(_N,{className:"size-3","aria-hidden":!0}),s]}):null]}),children:[p.jsx(It,{checked:n,icon:p.jsx(_N,{className:"size-4",strokeWidth:1.5}),description:n?s?`${s} ${s===1?"person is":"people are"} following you`:"No one is following yet":"Everyone here sees what you are looking at",onSelect:()=>i(!n),disabled:c.length===0&&!n,children:"Follow me"}),o?p.jsxs(It,{checked:o.following,icon:p.jsx(Dh,{className:"size-4",strokeWidth:1.5}),description:"Your view follows what it changes",onSelect:()=>l(!o.following),children:["Follow ",o.name]}):null,c.length?p.jsxs(p.Fragment,{children:[p.jsx(rc,{}),p.jsx(pH,{children:"People here"}),c.map(f=>p.jsx(It,{checked:t===f.id,icon:p.jsx(U5,{peer:f}),description:f.where,onSelect:()=>r(t===f.id?null:f.id),children:t===f.id?`Following ${f.name}`:`Follow ${f.name}`},f.id))]}):null]})})}function Ibe({name:e,leading:t,followers:n,onStop:s}){return!e&&!t?null:p.jsx("div",{className:"pointer-events-none absolute inset-x-0 top-[60px] z-20 flex justify-center",children:p.jsxs("div",{role:"status",className:"pointer-events-auto flex items-center gap-2 rounded-full bg-chrome-accent py-1 pl-3 pr-1 text-xs font-medium text-white shadow-chrome",children:[p.jsx("span",{children:e?`Following ${e}`:`Others follow you · ${n} following`}),p.jsx("span",{className:"text-white/70",children:e?"Esc to stop":""}),p.jsx("button",{type:"button","aria-label":e?"Stop following":"Stop leading",className:"flex size-5 items-center justify-center rounded-full hover:bg-white/20",onClick:s,children:p.jsx(zr,{className:"size-3.5"})})]})})}function Bbe({cursors:e,peers:t}){return e.length===0?null:p.jsx("div",{className:"pointer-events-none absolute inset-0 z-10","aria-hidden":!0,children:e.map(({peerId:n,x:s,y:o})=>{const r=t.find(l=>l.id===n);if(!r)return null;const i=r.color;return p.jsxs("div",{className:"absolute transition-[left,top] duration-75 ease-linear",style:{left:`${s*100}%`,top:`${o*100}%`},children:[p.jsx(SK,{className:"size-4 -translate-x-[3px] -translate-y-[2px] drop-shadow",style:{color:i,fill:i},strokeWidth:1.5}),p.jsx("span",{className:"absolute left-3 top-3 whitespace-nowrap rounded px-1 py-px text-[10px] font-medium text-white",style:{background:i},children:r.name})]},n)})})}function Fbe(e){const t=e.state?.slideIndex?`On slide ${e.state.slideIndex}`:void 0,n={id:e.id,name:e.name,kind:e.kind,color:e.color};return t?{...n,where:t}:n}function WH(){const e=Ai(t=>t.peers);return C.useMemo(()=>e.map(Fbe),[e])}function Hbe(){const e=WH(),{following:t,leading:n,followers:s,status:o}=Rt(bb(l=>({following:l.following,leading:l.leading,followers:l.followers,status:l.status}))),r=e.find(l=>l.kind==="agent"),i=t===Ia||r!==void 0&&t===r.id;return p.jsx(Pbe,{peers:e,following:t,leading:n,followers:s,agent:o.available?{name:o.name,following:i}:null,onFollow:l=>Rt.getState().follow(l),onLead:l=>Rt.getState().setLeading(l),onFollowAgent:l=>l?Rre():Rt.getState().follow(null)})}function Ube(){const e=Ai(o=>o.peers),t=Rt(o=>Mre(o,e)),n=Rt(o=>o.leading),s=Rt(o=>o.followers);return p.jsx(Ibe,{name:t,leading:n,followers:s,onStop:()=>t?Rt.getState().follow(null):Rt.getState().setLeading(!1)})}function Vbe({id:e}){const t=uu(o=>o.cursors),n=WH(),s=C.useMemo(()=>Object.entries(t).filter(([,o])=>o.slideId===e).map(([o,r])=>({peerId:o,x:r.x,y:r.y})),[t,e]);return p.jsx(Bbe,{cursors:s,peers:n})}const Q0=12,J0=40,qbe=Q0+J0+8,Wbe=8+J0+Q0;function Gbe({onStage:e,startCard:t}){const n=ie(r=>r.readOnly),s=Rt(r=>r.status.available),o=!n&&gn();return p.jsxs(p.Fragment,{children:[t?p.jsx("div",{className:"pointer-events-none absolute left-3 top-3 z-10 flex",children:p.jsx(N0e,{})}):null,p.jsxs("div",{className:"pointer-events-none absolute right-3 top-3 z-10 flex gap-2",children:[p.jsx(Hbe,{}),p.jsx(I0e,{onStage:e})]}),p.jsx(Ube,{}),e?p.jsxs(p.Fragment,{children:[p.jsx("div",{className:"pointer-events-none absolute inset-x-0 bottom-3 z-10 flex justify-center px-3",children:p.jsx(zbe,{editing:o,ask:s&&!n})}),p.jsx(bbe,{}),p.jsx(Abe,{})]}):null]})}function V5(e,t,n){if(n.x!==void 0&&n.y!==void 0)return{x:n.x,y:n.y};const s=lC(t,n),o=s&&We(t,s)?zs(e.root,s):null;if(o){const r=Xo(e.root,o,e.scale);return{x:r.x+r.w,y:r.y}}return{x:Xe-48,y:48}}function Ybe(e){const t=e.root.getBoundingClientRect(),n=e.root.closest("[data-open-artifact-stage]")?.getBoundingClientRect();return n?{width:n.right-t.left,height:n.bottom-t.top}:{width:t.width,height:t.height}}function Kbe({ctx:e,slide:t}){const n=Ts(m=>m.threads),s=Ts(m=>m.draft),o=xt(m=>m.layoutTick),r=Rt(m=>m.status),[i,l]=C.useState(()=>({points:new Map,viewport:{width:0,height:0}}));C.useLayoutEffect(()=>{const m=new Map;for(const b of n){const v=k8(b);v.slide===e.slideId&&m.set(v,V5(e,t,v))}s?.slide===e.slideId&&m.set(s,V5(e,t,s)),l({points:m,viewport:Ybe(e)})},[e,t,n,s,o]);const c=C.useCallback(m=>{const b=m.slide===e.slideId?i.points.get(m):void 0;return b?{world:b,state:"ok"}:null},[e.slideId,i]),u=C.useCallback(m=>{const b=e.root.getBoundingClientRect(),v=Af(e,t,b.left+m.x*e.scale,b.top+m.y*e.scale,[]);return uh(t,v,m)},[e,t]),f=C.useMemo(()=>({x:0,y:0,zoom:e.scale}),[e.scale]),h=(m,b)=>{const v=(M,S)=>Math.max(0,Math.min(S,M)),w=v(Math.min(m.x,b.x),Xe),E=v(Math.min(m.y,b.y),ft);return uh(t,null,{x:w,y:E},{w:v(Math.max(m.x,b.x),Xe)-w,h:v(Math.max(m.y,b.y),ft)-E})},g=m=>{if(m.x!==void 0&&m.y!==void 0&&m.w!==void 0&&m.h!==void 0)return{x:m.x,y:m.y,w:m.w,h:m.h,area:!0};const b=lC(t,m),v=b&&zs(e.root,b);return v?Xo(e.root,v,e.scale):null};return p.jsxs("div",{"data-open-artifact-comment-ui":!0,className:"contents",children:[p.jsx("div",{className:"pointer-events-auto contents",children:p.jsx(n0e,{comments:Ql,enabled:!0,camera:()=>f,anchorAt:u,areaAnchor:h})}),p.jsx(l0e,{comments:Ql,camera:f,viewport:i.viewport,place:c,highlight:g,anchorAt:u,agent:{available:r.available,name:r.name,wakesIdle:r.wakesIdle},piles:!1})]})}function q5(e,t,n){const s=[];for(const o of n){const r=We(t,o),i=zs(e.root,o);!r||!i||s.push({key:is(o),path:o,box:PC(e.root,i,e.scale,Ri(r))})}return s}function Xbe(e,t){const n=xt(o=>o.relayout),s=t.map(is).join(",");C.useLayoutEffect(()=>{if(typeof ResizeObserver>"u")return;const o=new ResizeObserver(()=>n());o.observe(e.root);for(const r of s?s.split(","):[]){const i=zs(e.root,r);i&&o.observe(i)}return()=>o.disconnect()},[e.root,s,n])}function Zbe({ctx:e,slide:t,children:n}){const s=te(D=>D.selection),o=te(D=>D.textEdit),r=te(D=>D.cropping),i=xt(D=>D.hover),l=xt(D=>D.move),c=xt(D=>D.guides),u=xt(D=>D.marquee),f=xt(D=>D.draw),h=xt(D=>D.layoutTick),g=xt(D=>!!(D.draft||D.move)),m=Ts(D=>D.on),b=Ts(D=>D.draft!==null||D.active!==null),[v,w]=C.useState([]),[E,M]=C.useState(null),S=Xa(e),k=e.scale;Xbe(e,s),C.useLayoutEffect(()=>{w(q5(e,t,s));const D=i&&(m||!s.some(z=>_s(z,i)));M(D?q5(e,t,[i])[0]??null:null)},[e,t,s,i,h,o,m]);const R=D=>l&&l.keys.includes(D.key)?{...D.box,x:D.box.x+l.dx,y:D.box.y+l.dy}:D.box,N=v.length===1?v[0]:null,O=N?We(t,N.path):void 0,A=!!(N&&O&&S&&!o&&!r&&!l),$=v.length>1?HB(v.map(R)):null;return p.jsxs("div",{className:"pointer-events-none absolute inset-0 overflow-visible","data-open-artifact-overlay":!0,children:[E&&!g&&!m?p.jsx(Yg,{box:E.box,scale:k,className:"border border-accent/60"}):null,E&&m&&!b?p.jsx(Yg,{box:E.box,scale:k,className:"rounded-[2px] border-2 border-warning/80"}):null,v.map(D=>p.jsxs(Yg,{box:R(D),scale:k,className:ze("border-accent",v.length>1?"border":"border-[1.5px]",o&&"border-dashed"),children:[A&&N===D&&O&&O.kind!=="connector"?p.jsx(Qbe,{ctx:e,path:D.path}):null,A&&N===D&&O?.kind==="table"?p.jsx(Jbe,{table:O,path:D.path}):null]},D.key)),A&&N&&O?.kind==="connector"&&O.points?p.jsx(exe,{ctx:e,slide:t,path:N.path}):null,$?p.jsx("div",{className:"absolute border border-dashed border-accent/70",style:{left:$.x*k-4,top:$.y*k-4,width:$.w*k+8,height:$.h*k+8}}):null,p.jsx(nxe,{ctx:e,slide:t}),c?p.jsxs(p.Fragment,{children:[c.x.map(D=>p.jsx("div",{className:"absolute top-0 h-full w-px bg-danger",style:{left:D*k}},`x${D}`)),c.y.map(D=>p.jsx("div",{className:"absolute left-0 h-px w-full bg-danger",style:{top:D*k}},`y${D}`))]}):null,u?p.jsx("div",{className:"absolute border border-accent bg-accent/10",style:{left:u.x*k,top:u.y*k,width:u.w*k,height:u.h*k}}):null,f?p.jsx(txe,{scale:k}):null,r&&S?p.jsx(oxe,{ctx:e,slide:t,path:r}):null,n]})}function Yg({box:e,scale:t,className:n,children:s}){return p.jsx("div",{className:ze("absolute",n),style:{left:e.x*t,top:e.y*t,width:e.w*t,height:e.h*t,transform:e.rotation?`rotate(${e.rotation}deg)`:void 0},children:s})}function Qbe({ctx:e,path:t}){return p.jsxs(p.Fragment,{children:[yce.map(n=>p.jsx("div",{role:"presentation",className:"pointer-events-auto absolute size-2.5 rounded-[2px] border border-accent bg-surface shadow-sm",style:{left:`calc(${(n.hx+1)/2*100}% - 5px)`,top:`calc(${(n.hy+1)/2*100}% - 5px)`,cursor:n.cursor},onPointerDown:s=>{s.button===0&&(s.stopPropagation(),s.preventDefault(),Nce(e,s,t,n))}},n.id)),p.jsx("div",{className:"absolute left-1/2 top-0 h-5 w-px -translate-y-full bg-accent"}),p.jsx("div",{role:"presentation",title:"Rotate (Shift snaps to 15°)",className:"pointer-events-auto absolute left-1/2 top-0 flex size-4 -translate-x-1/2 -translate-y-[calc(100%+18px)] cursor-grab items-center justify-center rounded-full border border-accent bg-surface text-accent shadow-sm",onPointerDown:n=>{n.button===0&&(n.stopPropagation(),n.preventDefault(),Oce(e,n,t))},children:p.jsx(CE,{className:"size-2.5"})})]})}function Jbe({table:e,path:t}){const n=[{what:"column",label:"Add a column",style:{left:"calc(100% + 14px)",top:"50%",transform:"translateY(-50%)"}},{what:"row",label:"Add a row",style:{top:"calc(100% + 14px)",left:"50%",transform:"translateX(-50%)"}}];return p.jsx(p.Fragment,{children:n.map(({what:s,label:o,style:r})=>{const i=O0(e,s);return p.jsx(m3,{label:i??o,children:p.jsx("button",{type:"button",tabIndex:-1,"data-open-artifact-table-add":s,"aria-label":o,"aria-disabled":i!==null,className:ze("pointer-events-auto absolute flex size-5 items-center justify-center rounded-full border border-accent bg-surface text-accent shadow-sm",i?"cursor-not-allowed opacity-50":"hover:bg-accent hover:text-accent-fg"),style:r,onPointerDown:l=>l.stopPropagation(),onMouseDown:l=>l.preventDefault(),onDoubleClick:l=>l.stopPropagation(),onClick:l=>{l.stopPropagation(),i||ir(t,s==="row"?"addRow":"addColumn")},children:p.jsx(fs,{className:"size-3",strokeWidth:2})})},s)})})}function exe({ctx:e,slide:t,path:n}){const s=We(t,n);if(s?.kind!=="connector")return null;const o=Qu(e.root,t,n,e.scale),r=DC(s,o.w,o.h);return r?p.jsx(p.Fragment,{children:r.map((i,l)=>p.jsx("div",{role:"presentation",title:l===0?"Start":"End",className:"pointer-events-auto absolute size-3 cursor-move rounded-full border-2 border-accent bg-surface shadow-sm",style:{left:(o.x+i.x)*e.scale-6,top:(o.y+i.y)*e.scale-6},onPointerDown:c=>{c.button===0&&(c.stopPropagation(),c.preventDefault(),$ce(e,c,n,l))}},l))}):null}function txe({scale:e}){const t=xt(s=>s.draw);if(!t)return null;if(t.tool==="line"||t.tool==="connector")return p.jsx("svg",{className:"absolute inset-0 size-full overflow-visible",children:p.jsx("line",{x1:t.from.x*e,y1:t.from.y*e,x2:t.to.x*e,y2:t.to.y*e,stroke:"var(--color-accent)",strokeWidth:2,strokeDasharray:"6 4"})});const n=z0(t.from,t.to);return p.jsx("div",{className:ze("absolute border-2 border-dashed border-accent bg-accent/5",t.tool==="ellipse"&&"rounded-full",t.tool==="rounded"&&"rounded-xl"),style:{left:n.x*e,top:n.y*e,width:n.w*e,height:n.h*e}})}function nxe({ctx:e,slide:t}){const n=Kh().get(e.slideId),s=xt(l=>l.layoutTick),[o,r]=C.useState([]),i=C.useMemo(()=>(n??[]).flatMap(l=>(l.state?.selected??[]).flatMap(c=>{const u=A6(t,c);return u?[{peer:l,path:u.path}]:[]})),[n,t]);return C.useLayoutEffect(()=>{r(i.flatMap(({peer:l,path:c})=>{const u=We(t,c),f=zs(e.root,c);return!u||!f?[]:[{id:`${l.id}:${is(c)}`,name:l.name,agent:l.kind==="agent",box:PC(e.root,f,e.scale,Ri(u))}]}))},[e,t,i,s]),p.jsx(p.Fragment,{children:o.map(l=>p.jsx(Yg,{box:l.box,scale:e.scale,className:ze("border-2",l.agent?"border-accent/70":"border-success/80"),children:p.jsx("span",{className:ze("absolute -top-5 left-0 rounded px-1 text-[10px] font-medium leading-4 text-white",l.agent?"bg-accent":"bg-success"),children:l.name})},l.id))})}const sxe={n:"ns-resize",s:"ns-resize",e:"ew-resize",w:"ew-resize",ne:"nesw-resize",sw:"nesw-resize",nw:"nwse-resize",se:"nwse-resize"},W5={n:"top edge",s:"bottom edge",e:"right edge",w:"left edge",ne:"top right",nw:"top left",se:"bottom right",sw:"bottom left"};function oxe({ctx:e,slide:t,path:n}){const s=We(t,n),o=xt(w=>w.layoutTick),r=xt(w=>w.relayout),[i,l]=C.useState(null),[c,u]=C.useState(null);if(C.useLayoutEffect(()=>{if(s?.kind!=="image")return;const w=GB(e,n,s);if(l(w),!w){const E=zs(e.root,n)?.querySelector("img");E&&!E.complete&&E.addEventListener("load",r,{once:!0})}},[e,s,n,o,r]),s?.kind!=="image"||!s.src)return null;const f=e.scale,h=()=>te.getState().setCropping(null);if(!i)return null;const{frame:g,picture:m}=i,b=c??tp(s).zoom,v=YB(s);return p.jsxs(p.Fragment,{children:[p.jsx("img",{src:Ds(s.src),alt:"",draggable:!1,className:"absolute max-w-none opacity-35",style:{left:m.x*f,top:m.y*f,width:m.w*f,height:m.h*f}}),p.jsx("div",{role:"presentation",title:"Drag to move the picture; drag a side to crop",className:"pointer-events-auto absolute cursor-move outline outline-2 outline-accent",style:{left:g.x*f,top:g.y*f,width:g.w*f,height:g.h*f},onPointerDown:w=>{w.button===0&&(w.stopPropagation(),w.preventDefault(),Pce(e,w,n))},onDoubleClick:w=>{w.stopPropagation(),h()},onWheel:w=>{w.stopPropagation();const E=Math.min(Math.max(5,b),Math.max(1,b*Math.exp(-w.deltaY*.002)));j_(e.slideId,n,E)}}),v?vce.map(w=>{const E=v[w],M=w.includes("w")?0:w.includes("e")?1:.5,S=w.includes("n")?0:w.includes("s")?1:.5,k=w.length===2;return p.jsx("div",{role:"presentation","aria-label":`Crop handle, ${W5[w]}`,title:E??`Crop from the ${W5[w]}`,className:ze("pointer-events-auto absolute -translate-x-1/2 -translate-y-1/2 border border-accent bg-surface shadow-sm",k?"size-3":w==="n"||w==="s"?"h-1.5 w-6 rounded-full":"h-6 w-1.5 rounded-full",E&&"opacity-40"),style:{left:(g.x+g.w*M)*f,top:(g.y+g.h*S)*f,cursor:E?"not-allowed":sxe[w]},onPointerDown:R=>{R.button===0&&(R.stopPropagation(),R.preventDefault(),E||Bce(e,R,n,w))}},w)}):null,p.jsxs("div",{className:"pointer-events-auto absolute flex w-72 items-center gap-2 rounded-control border border-line bg-surface px-2 py-1 shadow-popup",style:{left:g.x*f+g.w*f/2-144,top:(g.y+g.h)*f+12},onPointerDown:w=>w.stopPropagation(),children:[p.jsx("span",{className:"text-xs text-fg-muted",children:"Zoom"}),p.jsx("div",{className:"min-w-0 flex-1",children:p.jsx(EQ,{"aria-label":"Crop zoom",value:b,min:1,max:Math.max(5,b),step:.05,onChange:w=>{u(w),j_(e.slideId,n,w)},onCommit:()=>u(null)})}),p.jsx(bt,{size:"sm",variant:"ghost",icon:p.jsx(vi,{className:"size-3.5"}),onClick:()=>Hce(e.slideId,n),"aria-label":"Reset crop"}),p.jsx(bt,{size:"sm",variant:"primary",icon:p.jsx(Pi,{className:"size-3.5"}),onClick:h,children:"Done"})]})]})}const G5=ot==="⌘"?"⌥":"Alt+",rxe=ot==="⌘"?"⇧":"Shift+";function Y5(e){document.execCommand(e)||Ke.add({title:`Use ${ot}${e==="copy"?"C":"X"} to ${e}`})}function ixe(){const e=te.getState(),t=es(),n=Lr(e.current)!==null,s=Qo();if(!t||!e.current)return null;if(s.length===0)return p.jsxs(p.Fragment,{children:[n?p.jsx(pt,{icon:p.jsx(VS,{className:"size-4"}),shortcut:`${ot}V`,disabled:!Ek(),onSelect:()=>kk(),children:"Paste"}):null,p.jsx(pt,{shortcut:`${ot}A`,onSelect:aB,children:"Select all"}),Ku()?p.jsx(pt,{icon:p.jsx(Da,{className:"size-4"}),onSelect:()=>S$(uh(t,null)),children:"Comment on slide"}):null,p.jsx(Al,{}),p.jsx(Fb,{ids:[e.current]})]});const o=s.length===1?s[0]:null,r=o?We(t,o):void 0,i=r?.kind==="box"&&r.group;return p.jsxs(p.Fragment,{children:[n?p.jsx(pt,{icon:p.jsx(Fz,{className:"size-4"}),shortcut:`${ot}X`,onSelect:()=>Y5("cut"),children:"Cut"}):null,p.jsx(pt,{icon:p.jsx(vE,{className:"size-4"}),shortcut:`${ot}C`,onSelect:()=>Y5("copy"),children:"Copy"}),n?p.jsxs(p.Fragment,{children:[p.jsx(pt,{icon:p.jsx(VS,{className:"size-4"}),shortcut:`${ot}V`,disabled:!Ek(),onSelect:()=>kk(),children:"Paste"}),p.jsx(pt,{shortcut:`${ot}D`,onSelect:cB,children:"Duplicate"}),p.jsx(pt,{icon:p.jsx(Hy,{className:"size-4"}),shortcut:"⌫",danger:!0,onSelect:TC,children:"Delete"}),p.jsx(Al,{}),r&&Va(r)?p.jsx(pt,{icon:p.jsx(hP,{className:"size-4"}),shortcut:"↵",onSelect:lB,children:"Edit text"}):null,r?.kind==="image"&&r.src?p.jsx(pt,{icon:p.jsx(JY,{className:"size-4"}),onSelect:()=>{Ri(r)?Ke.add({title:"Straighten the picture to crop it"}):te.getState().setCropping(o)},children:"Crop"}):null,r?.kind==="image"&&o?p.jsx(pt,{icon:p.jsx(hK,{className:"size-4"}),onSelect:()=>{gd("image/png,image/jpeg,image/gif,image/webp,image/svg+xml",!1).then(l=>{l[0]&&_0(o,l[0])})},children:"Replace picture…"}):null,r?.kind==="table"&&o?p.jsx(axe,{table:r,path:o}):null,p.jsx(pt,{icon:p.jsx(UY,{className:"size-4"}),shortcut:"]",onSelect:()=>gu("front"),children:"Bring to front"}),p.jsx(pt,{shortcut:`${ot}]`,onSelect:()=>gu("forward"),children:"Bring forward"}),p.jsx(pt,{shortcut:`${ot}[`,onSelect:()=>gu("backward"),children:"Send backward"}),p.jsx(pt,{icon:p.jsx(TK,{className:"size-4"}),shortcut:"[",onSelect:()=>gu("back"),children:"Send to back"}),p.jsx(Al,{}),s.length>1?p.jsx(pt,{icon:p.jsx(cK,{className:"size-4"}),shortcut:`${ot}G`,onSelect:dB,children:"Group"}):null,i?p.jsx(pt,{icon:p.jsx(PK,{className:"size-4"}),shortcut:`${rxe}${ot}G`,onSelect:fB,children:"Ungroup"}):null,p.jsx(pt,{icon:p.jsx(Tz,{className:"size-4"}),shortcut:`${G5}${ot}C`,onSelect:hB,children:"Copy style"}),p.jsx(pt,{shortcut:`${G5}${ot}V`,disabled:!e.styleClipboard,onSelect:pB,children:"Paste style"})]}):null,Ku()&&o?p.jsxs(p.Fragment,{children:[p.jsx(Al,{}),p.jsx(pt,{icon:p.jsx(Da,{className:"size-4"}),onSelect:()=>S$(uh(t,o)),children:"Comment"})]}):null]})}function axe({table:e,path:t}){const[n]=C.useState(()=>{const{textEdit:c,current:u}=te.getState();return bae(u??"",t,e,c?.cell&&_s(c.path,t)?c.cell:void 0)}),s=n.cell??null,o=O0(e,"row"),r=O0(e,"column"),i=vk(e,"row"),l=vk(e,"column");return p.jsxs(p.Fragment,{children:[s?p.jsxs(p.Fragment,{children:[p.jsx(pt,{disabled:o!==null,onSelect:()=>ir(n.path,"addRow",s[0],n),children:"Insert row above"}),p.jsx(pt,{disabled:o!==null,onSelect:()=>ir(n.path,"addRow",s[0]+1,n),children:"Insert row below"}),p.jsx(pt,{disabled:r!==null,onSelect:()=>ir(n.path,"addColumn",s[1],n),children:"Insert column left"}),p.jsx(pt,{disabled:r!==null,onSelect:()=>ir(n.path,"addColumn",s[1]+1,n),children:"Insert column right"}),p.jsx(pt,{disabled:i!==null,onSelect:()=>ir(n.path,"removeRow",s[0],n),children:"Delete row"}),p.jsx(pt,{disabled:l!==null,onSelect:()=>ir(n.path,"removeColumn",s[1],n),children:"Delete column"})]}):p.jsxs(p.Fragment,{children:[p.jsx(pt,{disabled:o!==null,onSelect:()=>ir(n.path,"addRow",void 0,n),children:"Add a row"}),p.jsx(pt,{disabled:r!==null,onSelect:()=>ir(n.path,"addColumn",void 0,n),children:"Add a column"}),p.jsx(pt,{disabled:i!==null,onSelect:()=>ir(n.path,"removeRow",void 0,n),children:"Remove the last row"}),p.jsx(pt,{disabled:l!==null,onSelect:()=>ir(n.path,"removeColumn",void 0,n),children:"Remove the last column"})]}),p.jsx(Al,{})]})}const uS=24,K5=qbe,X5=Wbe+24,Z5=72;function lxe(e){return Va(e)||e.kind==="table"}function GH(){const e=te(z=>z.current),t=ie(z=>e?z.slides[e]:void 0),n=xt(z=>z.draft),s=te(M0),o=te(z=>z.textEdit),r=te(z=>z.tool),i=Ts(z=>z.on),l=te(z=>z.showNotes),c=C.useRef(null),u=C.useRef(null),[f,h]=C.useState(null),g=mc(c),m=C.useRef(0),b=ie(z=>z.index.size);C.useEffect(()=>{if(!g||g.w<=0||g.h<=0)return;const z=g.h-K5-X5-(l?Z5:0);te.getState().setFitScale(Math.max(.05,Math.min((g.w-uS*2)/Xe,z/ft)))},[g,l,b]),C.useLayoutEffect(()=>{h(u.current)}),C.useEffect(()=>()=>xt.getState().set({draft:null,move:null,guides:null,marquee:null,draw:null,hover:null}),[e]),C.useEffect(()=>{const z=c.current;if(!z)return;const _=L=>{if(!(L.ctrlKey||L.metaKey))return;L.preventDefault();const B=te.getState();B.setZoom(M0(B)*Math.exp(-L.deltaY*.01))};return z.addEventListener("wheel",_,{passive:!1}),()=>z.removeEventListener("wheel",_)},[]);const v=n&&n.slideId===e?n.slide:t?.slide,w=C.useMemo(()=>f&&e?{root:f,scale:s,slideId:e}:null,[f,s,e]),E=C.useMemo(()=>{const z=o&&o.slideId===e?o:null;return{mode:"edit",resolveSrc:Ds,override:z?(_,L)=>_s(L,z.path)&&lxe(_)?p.jsx(rye,{node:_,path:L,slideId:z.slideId,cell:z.cell},is(L)):void 0:void 0}},[o,e]);if(cxe(f,e,v),!e||!t||!v)return p.jsx("div",{className:"absolute inset-0 bg-stage"});const M=z=>{if(!w)return;const _=z.target;if(_.closest("[data-open-artifact-overlay] .pointer-events-auto, [data-open-artifact-comment-ui], [data-open-artifact-notes]"))return;EB("stage");const L=te.getState(),B=ie.getState().slides[w.slideId]?.slide;if(!B)return;if(z.button===2){const V=Af(w,B,z.clientX,z.clientY,L.selection);V&&!L.selection.some(W=>_s(W,V)||jr(W,V))&&L.select([V]),!V&&L.selection.length&&L.select([]);return}if(z.button!==0||_.closest("[data-open-artifact-editing]"))return;const U=document.activeElement;if(U&&U!==document.body&&!w.root.contains(U)&&U.blur?.(),z.preventDefault(),L.textEdit&&L.endTextEdit(),L.cropping&&L.setCropping(null),Ts.getState().on)return;if(L.tool!=="select"){Dce(w,z,L.tool);return}const I=Af(w,B,z.clientX,z.clientY,L.selection);if(!I){_ce(w,z,z.shiftKey);return}const F=L.selection.some(V=>_s(V,I));if(z.shiftKey||z.metaKey||z.ctrlKey){if(F){L.select(L.selection.filter(V=>!_s(V,I)));return}L.select([...L.selection,I])}else F||L.select([I]);Tce(w,z,te.getState().selection)},S=z=>{if(!w||Ts.getState().on)return;const _=z.target;if(_.closest("[data-open-artifact-editing], [data-open-artifact-overlay] .pointer-events-auto, [data-open-artifact-comment-ui], [data-open-artifact-notes]"))return;const L=te.getState(),B=ie.getState().slides[w.slideId]?.slide;if(!B||L.tool!=="select")return;const U=L.selection[0],I=Ece(w,B,z.clientX,z.clientY);if(!I)return;const F=U?We(B,U):void 0;if(U&&F?.kind==="box"&&jr(U,I)){L.select([I]);return}const V=U&&(_s(U,I)||jr(U,I))?U:I,W=We(B,V);if(!(!W||!Lr(w.slideId)))if(Va(W))_5({x:z.clientX,y:z.clientY}),L.startTextEdit({slideId:w.slideId,path:V});else if(W.kind==="table"){const K=_.closest("[data-open-artifact-cell]")?.getAttribute("data-open-artifact-cell")?.split(":").map(Number);_5({x:z.clientX,y:z.clientY}),L.startTextEdit({slideId:w.slideId,path:V,cell:K&&K.length===2?[K[0],K[1]]:[0,0]})}else W.kind==="image"?W.src?Ri(W)?Ke.add({title:"Straighten the picture to crop it"}):(L.select([V]),L.setCropping(V)):gd("image/png,image/jpeg,image/gif,image/webp,image/svg+xml",!1).then(K=>{K[0]&&_0(V,K[0])}):W.kind==="box"&&W.children.length&&L.select([I])},k=z=>{const _=Ts.getState().on;if(!w||z.buttons||!_&&te.getState().tool!=="select")return;const L=z.clientX,B=z.clientY;cancelAnimationFrame(m.current),m.current=requestAnimationFrame(()=>{const U=ie.getState().slides[w.slideId]?.slide,I=U?Af(w,U,L,B,_?[]:te.getState().selection):null,F=xt.getState().hover;!(F&&I&&_s(F,I))&&F!==I&&xt.getState().set({hover:I})})},R=z=>{!z.dataTransfer.types.includes("Files")||!gn()||!Lr(e)||(z.preventDefault(),z.dataTransfer.dropEffect="copy")},N=z=>{if(!w||!z.dataTransfer.files.length)return;z.preventDefault();const _=Array.from(z.dataTransfer.files).filter(bB);if(_.length===0){Ke.add({title:"Only pictures and video clips can be dropped here"});return}const L=ie.getState().slides[w.slideId]?.slide,B=L?Af(w,L,z.clientX,z.clientY,[]):null,U=L&&B?We(L,B):void 0;if(B&&U?.kind==="image"&&_.length===1&&_[0].type.startsWith("image/")){_0(B,_[0]);return}const I=tc(w.root,z.clientX,z.clientY,w.scale);jC(_,{x:Math.min(Xe,Math.max(0,I.x)),y:Math.min(ft,Math.max(0,I.y))})},O=Xe*s,A=ft*s,$=Math.min(320,(g?.w??0)-24),D=i?dH:r!=="select"?"crosshair":void 0;return p.jsx(Bb,{menu:i?null:p.jsx(ixe,{}),className:"absolute inset-0",children:p.jsx("div",{ref:c,"data-open-artifact-stage":!0,className:"absolute inset-0 overflow-auto bg-stage outline-none",style:{cursor:D},onPointerDown:M,onPointerMove:k,onPointerLeave:()=>xt.getState().set({hover:null}),onDoubleClick:S,onDragOver:R,onDrop:N,children:p.jsx("div",{className:"flex min-h-full min-w-full flex-col items-center justify-center",style:{paddingTop:K5,paddingBottom:X5+(l?Z5:0),paddingLeft:uS,paddingRight:uS,width:"max-content",height:"max-content"},children:p.jsxs("div",{className:"relative shrink-0 shadow-[0_0_0_1px_rgb(0_0_0/0.06),0_1px_3px_rgb(0_0_0/0.08)]",style:{width:O,height:A},children:[p.jsx("div",{className:"absolute left-0 top-0 origin-top-left",style:{width:Xe,height:ft,transform:`scale(${s})`},children:p.jsx(Ka,{slide:v,options:E,rootRef:u})}),w?p.jsx(Zbe,{ctx:w,slide:v,children:p.jsx(Kbe,{ctx:w,slide:v})}):null,v.hidden?p.jsxs("div",{className:"pointer-events-none absolute left-2 top-2 flex items-center gap-1 rounded-full bg-chrome/90 px-2 py-0.5 text-[11px] text-chrome-secondary shadow-chrome",children:[p.jsx(Lh,{className:"size-3"})," Skipped when presenting"]}):null,l?p.jsx("div",{"data-open-artifact-notes":!0,className:"absolute left-0 top-full",style:{width:O},onContextMenu:z=>z.stopPropagation(),children:p.jsx("div",{className:"mt-2",style:{width:Math.min(720,Math.max(O,$)),marginLeft:Math.min(0,(O-$)/2)},children:p.jsx(ST,{slideId:e,autoGrow:!0,className:"-mx-1.5 -my-0.5 block w-[calc(100%+12px)] resize-none overflow-hidden rounded-[6px] bg-transparent px-1.5 py-0.5 text-[13px] leading-[18px] text-chrome-secondary outline-none placeholder:text-chrome-muted hover:bg-chrome-hover focus:bg-chrome focus:text-chrome-fg focus:shadow-[0_0_0_1px_var(--color-chrome-accent)]"},e)})}):null]})})})})}function cxe(e,t,n){const s=te(i=>i.findOpen),o=Ea(i=>i.query),r=Ea(i=>i.matches[i.index]);C.useEffect(()=>{if(!e||!s||!o.trim())return;const i=r&&r.slideId===t?{pathKey:is(r.path),occurrence:r.occurrence}:void 0,l=requestAnimationFrame(()=>rle(e,o,i));return()=>cancelAnimationFrame(l)},[e,s,o,r,t,n])}const uxe=64;function dxe(){const e=Rt(t=>t.status);return p.jsx(Yge,{comments:Ql,agent:{available:e.available,name:e.name,wakesIdle:e.wakesIdle},top:uxe,hint:"Press C, then click the slide where you want to comment."})}const YH="#ffffff",fxe=/#[0-9a-fA-F]{3,8}\b|(?:rgba?|hsla?)\([^()]*\)|\b[a-zA-Z]+\b/g;function zu(e,t){const n=e.split(/(url\([^)]*\))/i);let s=!1;const o=n.map((r,i)=>i%2===1?r:r.replace(fxe,l=>{if(/^[a-z]+$/i.test(l)&&!Object.hasOwn(ob,l.toLowerCase()))return l;const c=VC(l);if(!c)return l;const u=t(c,l);return u===void 0||u===l?l:(s=!0,u)}));return s?o.join(""):e}function hxe(e){if(!e)return null;let t=null;return zu(e,n=>{t??=n}),t}const KH=["border","border-top","border-right","border-bottom","border-left","text-decoration","-webkit-text-stroke"],pxe=/((?:fill|stroke|stop-color|flood-color|lighting-color|color)\s*(?:=\s*["']?|:\s*))(#[0-9a-fA-F]{3,8}\b|(?:rgba?|hsla?)\([^()]*\)|[a-zA-Z]+)/g;function mxe(e,t,n){let s=!1;const o=e.replace(pxe,(r,i,l)=>{if(/^[a-z]+$/i.test(l)&&!Object.hasOwn(ob,l.toLowerCase()))return r;const c=VC(l);if(!c)return r;const u=n({prop:"fill",value:c,on:t},l);return u===void 0||u===l?r:(s=!0,i+u)});return s?o:e}function yh(e,t,n,s){let o=e;const r=(c,u)=>{u!==e[c]&&(o===e&&(o={...e}),o[c]=u)};let i=t;const l=e.background;if(l){const c=e["background-clip"]==="text",u=hxe(l);r("background",zu(l,(f,h)=>s.visit({prop:c?"text":n,value:f,on:t},h))),!c&&u&&/^(#|rgb|hsl|[a-z])/i.test(l.trim())&&(i=u)}e.color&&r("color",zu(e.color,(c,u)=>s.visit({prop:"text",value:c,on:i},u)));for(const c of KH){const u=e[c];u&&r(c,zu(u,(f,h)=>s.visit({prop:"line",value:f,on:i},h)))}return{style:o,ground:i}}function o2(e,t,n){let s=e;return e.forEach((o,r)=>{const i=o.marks?.color;if(!i)return;const l=zu(i,(c,u)=>n.visit({prop:"text",value:c,on:t},u));l!==i&&(s===e&&(s=[...e]),s[r]={...o,marks:{...o.marks,color:l}})}),s}function gxe(e,t,n){let s=e;return e.forEach((o,r)=>{const i=yh(o.style,t,"fill",n);let l=o.cells;o.cells.forEach((c,u)=>{const f=yh(c.style,i.ground,"fill",n),h=o2(c.runs,f.ground,n);f.style===c.style&&h===c.runs||(l===o.cells&&(l=[...o.cells]),l[u]={...c,style:f.style,runs:h})}),!(i.style===o.style&&l===o.cells)&&(s===e&&(s=[...e]),s[r]={...o,style:i.style,cells:l})}),s}function r2(e,t,n){const{style:s,ground:o}=e.kind==="connector"?yxe(e.style,t,n):yh(e.style,t,"fill",n);let r=s===e.style?e:{...e,style:s};const i=l=>{r={...r,...l}};switch(e.kind){case"text":{const l=o2(e.runs,o,n);l!==e.runs&&i({runs:l});break}case"list":{let l=e.items;e.items.forEach((c,u)=>{const f=o2(c.runs,o,n);f!==c.runs&&(l===e.items&&(l=[...e.items]),l[u]={...c,runs:f})}),l!==e.items&&i({items:l});break}case"textbox":{let l=e.blocks;e.blocks.forEach((c,u)=>{const f=r2(c,o,n);f!==c&&(l===e.blocks&&(l=[...e.blocks]),l[u]=f)}),l!==e.blocks&&i({blocks:l});break}case"box":{let l=e.children;e.children.forEach((c,u)=>{const f=r2(c,o,n);f!==c&&(l===e.children&&(l=[...e.children]),l[u]=f)}),l!==e.children&&i({children:l});break}case"table":{const l=gxe(e.rows,o,n);l!==e.rows&&i({rows:l});break}case"svg":{const l=mxe(e.markup,o,n.visit);l!==e.markup&&i({markup:l});break}}return r}function yxe(e,t,n){const s=e.color,o=yh({...e,color:void 0},t,"fill",n),r=s?zu(s,(c,u)=>n.visit({prop:"line",value:c,on:t},u)):void 0;if(!(o.style.background!==e.background||r!==s||KH.some(c=>o.style[c]!==e[c])))return{style:e,ground:o.ground};const l={...o.style};return r!==void 0?l.color=r:delete l.color,{style:l,ground:o.ground}}function RT(e,t){const n={visit:t},{style:s,ground:o}=yh(e.style,YH,"ground",n);let r=e.children;return e.children.forEach((i,l)=>{const c=r2(i,o,n);c!==i&&(r===e.children&&(r=[...e.children]),r[l]=c)}),s===e.style&&r===e.children?e:{...e,style:s,children:r}}function bxe(e){const t=[];return RT(e,n=>{t.push(n)}),t}const ey=512;function XH(e){return`${e.prop}|${e.value}|${e.on}`}const Pu=e=>e==="ground"||e==="fill";function xxe(e){const t=new Map;for(const n of e){const s=XH(n),o=t.get(s);o?o.count++:t.set(s,{...n,key:s,count:1})}return[...t.values()]}function vxe(e){const t=new Map;for(const o of e){const r=o.prop==="ground"?o.value:o.on;t.set(r,(t.get(r)??0)+o.count)}const n=[...new Set(e.filter(o=>o.prop==="ground").map(o=>o.value))];if(!n.length)return YH;const s=o=>(t.get(o)??0)*(Rr(o)?.5:1);return n.sort((o,r)=>s(r)-s(o)||(o<r?-1:1))[0]}function Q5(e){const t=new Map;for(const n of e)t.set(n.value,(t.get(n.value)??0)+n.count);return[...t].sort((n,s)=>s[1]-n[1]||(n[0]<s[0]?-1:1)).map(([n])=>n)}function wxe(e,t,n){const s=B0(t),o=n?.themes.find(A=>A.dark===s)??n?.themes[0],r=WC(o,"accent"),i=new Map,l=new Map,c=new Map;for(const A of e)Rr(A.value)&&!L_(A.value)&&c.set(A.value,(c.get(A.value)??0)+A.count*(Pu(A.prop)?3:1));const u=[...c].sort((A,$)=>$[1]-A[1]).map(([A])=>A),f=u.find(A=>A===r)??u[0],h=(A,$)=>$!==void 0&&yue(A,$)<24,g=u.filter(A=>!h(A,f)&&!Uf(A)),m=new Set(g.map(A=>Math.round(F0(A)/30)%12)).size<=1,b=A=>h(A,f)||m&&g.some($=>A===$||h(A,$)),v=A=>{const $=A.value;return $===t?"background":Rr($)?b($)?ks($,t)<1.3&&qC($)<.09?"accent-soft":"accent":Uf($)??"other":B0($)!==s&&ks($,t)>=4.5?"inverse":A.prop==="ground"||ks($,A.on)<1.25?"surface":"border"},w=e.filter(A=>Pu(A.prop)).sort((A,$)=>A.prop===$.prop?0:A.prop==="ground"?-1:1);for(const A of w){const $=v(A);i.set(A.key,$),(!l.has(A.value)||A.prop==="ground")&&l.set(A.value,$)}const E=A=>l.get(A.on)??(A.on===t?"background":"surface"),M=e.filter(A=>A.prop==="text"&&!Rr(A.value)),S=A=>{const $=M.filter(D=>A(E(D)));return Q5($.filter(D=>ks(D.value,D.on)>=7))[0]??Q5($)[0]},k=S(A=>A!=="accent"&&A!=="inverse"&&A!=="other"&&!J5(A)),R=S(A=>A==="inverse"),N=(A,$)=>$===void 0||ks(A.value,A.on)>=.8*ks($,A.on),O=A=>{const $=A.value,D=E(A);return A.prop==="text"&&ks($,A.on)<1.5?"other":D==="accent"?"on-accent":D==="other"||J5(D)?"other":Rr($)&&!L_($)?b($)?D==="inverse"?"inverse-accent":"accent":Uf($)??"other":D==="inverse"?N(A,R)?"on-inverse":"on-inverse-muted":A.prop==="line"?ks($,A.on)>=7?"text":"border":N(A,k)?"text":"muted"};for(const A of e)Pu(A.prop)||i.set(A.key,O(A));return i}const J5=e=>e==="success"||e==="warning"||e==="danger"||e==="info";function i2(e){const t=e.replace(/-\d+$/,"");return Dk.includes(t)?t:"other"}function Sxe(e,t){const n=new Map;for(const u of e){const f=`${t.get(u.key)??"other"} ${u.value}`;n.set(f,[...n.get(f)??[],u])}const s=(u,f)=>f.reduce((h,g)=>h+g.count*(u==="accent"&&Pu(g.prop)?3:1),0),o=new Map,r=new Map,i=[],l=[...n].sort((u,f)=>{const h=u[0].split(" ")[0],g=f[0].split(" ")[0];return s(g,f[1])-s(h,u[1])||(u[0]<f[0]?-1:1)});for(const[u,f]of l){const h=u.split(" ")[0],g=(o.get(h)??0)+1;o.set(h,g);const m=g===1?h:`${h}-${g}`;i.push({id:m,role:h,value:f[0].value,count:f.reduce((b,v)=>b+v.count,0)});for(const b of f)r.set(b.key,m)}const c=new Map;for(const u of e)Pu(u.prop)&&!c.has(u.value)&&c.set(u.value,r.get(u.key));for(const u of i){const f=new Map;for(const g of e){if(r.get(g.key)!==u.id||Pu(g.prop))continue;const m=c.get(g.on);m&&f.set(m,(f.get(m)??0)+g.count)}const h=[...f].sort((g,m)=>m[1]-g[1])[0];h&&(u.on=h[0])}return i.sort((u,f)=>Dk.indexOf(u.role)-Dk.indexOf(f.role)||u.id.length-f.id.length||(u.id<f.id?-1:1)),{slots:i,assign:r}}function ZH(e){return e.kind==="text"?e.tag!=="p"||parseFloat(e.style["font-size"]??"")>=56:e.kind==="textbox"?e.blocks[0]?.kind==="text"&&e.blocks[0].tag!=="p":!1}function fi(e){return e?(qa(e)[0]??"").toLowerCase():""}function kxe(e,t){const n=(s,o)=>{for(const r of s){const i=r.style["font-family"],l=i?fi(i):o;r.kind==="box"?n(r.children,l):(r.kind==="text"||r.kind==="textbox"||r.kind==="list"||r.kind==="table")&&t(r,l,ZH(r))}};n(e.children,fi(e.style["font-family"]))}function Exe(e){const t=new Map,n=new Map;for(const r of e)kxe(r,(i,l,c)=>{const u=c?t:n;u.set(l,(u.get(l)??0)+1)});const s=r=>[...r].sort((i,l)=>l[1]-i[1])[0]?.[0],o=s(n)??s(t)??"";return{heading:s(t)??o,body:o}}function QH(e,t){const n=xxe(e.flatMap(l=>bxe(l))),s=vxe(n),o=new Set(n.map(l=>l.value)).size,{slots:r,assign:i}=o>ey?{slots:[],assign:new Map}:Sxe(n,wxe(n,s,t));return{ground:s,dark:B0(s),slots:r,assign:i,uses:n,distinct:o,over:o>ey,...Exe(e)}}const Na="",JH=2,Iu=e=>typeof e=="object"&&e!==null&&!Array.isArray(e);function e4(e){if(!Iu(e)||typeof e.look!="string"||!Iu(e.colors))return null;const t={};for(const[s,o]of Object.entries(e.colors))typeof o=="string"&&/^#[0-9a-f]{6}$/.test(o)&&(t[s]=o);const n={look:e.look,colors:t};return typeof e.title=="string"&&(n.title=e.title),typeof e.heading=="string"&&(n.heading=e.heading),typeof e.body=="string"&&(n.body=e.body),Iu(e.on)&&(n.on=Object.fromEntries(Object.entries(e.on).filter(s=>typeof s[1]=="string"))),n}function jT(e){const t=e.style;if(!Iu(t)||!Iu(t.theme))return null;const n=e4(t.theme.original);if(!n)return null;const s=Array.isArray(t.theme.recent)?t.theme.recent.map(e4).filter(o=>o!==null).slice(0,JH):[];return{original:n,recent:s}}function Cxe(e,t){const n=Iu(e.style)?e.style:{};return{...e,style:{...n,theme:t}}}function t4(e){return e?.recent[0]?.look??Na}function Txe(e,t,n){const s=e?.recent??[],o=[n,...s.filter(r=>r.look!==n.look)].slice(0,JH);return{original:e?.original??t,recent:o}}function Mxe(e,t){const n=new Set([e.original,...e.recent].flatMap(r=>Object.values(r.colors)));let s=0,o=0;for(const r of t)o+=r.count,n.has(r.value)&&(s+=r.count);return o?s/o:1}function Rxe(e,t,n){const s={},o={};for(const r of e)s[r.id]=r.value,r.on&&(o[r.id]=r.on);return{look:Na,title:"Original look",colors:s,on:o,...t!==void 0?{heading:t}:{},...n!==void 0?{body:n}:{}}}function jxe(e){return Object.entries(e.colors).map(([t,n])=>({id:t,value:n,...e.on?.[t]?{on:e.on[t]}:{}}))}const Axe={text:4.5,"on-accent":4.5,"on-inverse":4.5,muted:3,"on-inverse-muted":3,"inverse-accent":3,accent:3,success:3,warning:3,danger:3,info:3},Nxe=(e,t)=>[...t].sort((n,s)=>ks(s,e)-ks(n,e))[0];function Oxe(e,t){const n=(h,g=0)=>WC(t,h,g),s=n("background")??(t.dark?"#121212":"#ffffff"),o=n("text")??D_(t.dark?"#f2f2f2":"#1a1a1a",s,7),r=t.colors.filter(h=>h.role==="other"&&Rr(h.value)).map(h=>h.value),i=[...t.colors.filter(h=>h.role==="accent").sort((h,g)=>h.rank-g.rank).map(h=>h.value),...r],l=i[0]??o,c=n("inverse")??o,u=n("on-inverse")??s,f={};for(const h of e){const g=i2(h.id),m=Number(/-(\d+)$/.exec(h.id)?.[1]??1);let b;switch(g){case"background":b=m===1?s:n("surface",m-2)??ru(s,o,.04*(m-1));break;case"surface":b=n("surface",m-1)??ru(s,o,.05*m);break;case"text":b=n("text",m-1)??o;break;case"muted":b=n("muted",m-1)??n("muted")??ru(o,s,.4);break;case"border":b=n("border",m-1)??n("border")??ru(s,o,.18);break;case"accent":b=i[m-1]??(m===1?l:Rr(h.value)?h.value:l);break;case"accent-soft":b=n("accent-soft",m-1)??ru(s,l,.14);break;case"on-accent":b=n("on-accent")??Nxe(l,[s,o,"#ffffff","#000000"]);break;case"inverse":b=c;break;case"on-inverse":b=u;break;case"on-inverse-muted":b=ru(u,c,.35);break;case"inverse-accent":b=ks(l,c)>=3?l:u;break;case"success":case"warning":case"danger":case"info":b=n(g)??h.value;break;default:b=h.value}f[h.id]=b}for(const h of e){const g=Axe[i2(h.id)],m=h.on?f[h.on]:void 0;g&&m&&f[h.id]&&(f[h.id]=D_(f[h.id],m,g))}return f}const $xe=new Set(["background","surface","accent","accent-soft","inverse","border","success","warning","danger","info","other"]),_xe=new Set(["text","muted","border","accent","on-accent","on-inverse","on-inverse-muted","inverse-accent","success","warning","danger","info","other"]),Lxe=(e,t)=>(e==="ground"||e==="fill"?$xe:_xe).has(t);function e9(e,t,n){for(let s=0;s<t.length;s++){const o=t[s],r=Object.entries(o.colors).filter(([i,l])=>l===e.value&&Lxe(e.prop,i2(i)));if(r.length){if(r.length>1&&n){const i=new Set(Object.entries(o.colors).filter(([,c])=>c===e.on).map(([c])=>c)),l=r.find(([c])=>n[c]!==void 0&&i.has(n[c]));if(l)return{slot:l[0],look:s}}return{slot:r[0][0],look:s}}}return null}function Dxe(e,t){return RT(e,(n,s)=>{const o=t.assign?.get(XH(n))??e9(n,t.from,t.on)?.slot;if(!o)return;const r=t.to[o];if(!(!r||r===n.value))return bue(r,s)})}function zxe(e,t,n){let s=0;const o=t[0];return o?(RT(e,r=>{const i=e9(r,t,n);i&&i.look>0&&o.colors[i.slot]&&o.colors[i.slot]!==r.value&&s++}),s):0}const n4=e=>e.kind==="text"||e.kind==="textbox"||e.kind==="list"||e.kind==="table";function s4(e,t){if((e["font-family"]??void 0)===(t||void 0))return e;const n={...e};return t?n["font-family"]=t:delete n["font-family"],n}function Pxe(e,t){const{heading:n,body:s}=t;if(!n&&!s)return e;const o=u=>s&&fi(u)===s.from&&(u||s.from==="")?s.to||void 0:u,r=(u,f,h)=>{let g=null;return u.forEach((m,b)=>{const v=m.style["font-family"],w=v??f,E=n4(m)&&ZH(m);let M=v;v&&!E&&(M=o(v));const S=M??h;if(n4(m)){const R=E?n&&fi(w)===n.from?n.to||void 0:w:s&&fi(w)===s.from?s.to||void 0:w;fi(S)!==fi(R)&&(R||!h)&&(M=R)}let k=m;if(M!==v&&(k={...m,style:s4(m.style,M)}),m.kind==="box"){const R=r(m.children,w,M??h);R!==m.children&&(k={...k,children:R})}k!==m&&(g??=[...u],g[b]=k)}),g??u},i=e.style["font-family"],l=s&&fi(i)===s.from?s.to||void 0:i,c=r(e.children,i,l);return l===i&&c===e.children?e:{...e,style:l===i?e.style:s4(e.style,l),children:c}}function o4(e,t){if(!t)return"";let n="";const s=r=>{!n&&fi(r["font-family"])===t&&(n=r["font-family"])},o=r=>{for(const i of r)s(i.style),i.kind==="box"&&o(i.children)};for(const r of e)if(s(r.style),o(r.children),n)break;return n||Uh([t])}function r4(e){const t=new Set,n=o=>{for(const r of qa(o??""))t.add(r.toLowerCase())},s=o=>{for(const r of o)if(n(r.style["font-family"]),r.kind==="box"&&s(r.children),r.kind==="table")for(const i of r.rows)for(const l of i.cells)n(l.style["font-family"])};for(const o of e)n(o.style["font-family"]),s(o.children);return t}function i4(e,t,n,s){const o={},r=new Set;for(const[i,l]of Object.entries(e))n.has(l.family.toLowerCase())&&(o[i]=l,r.add(l.family.toLowerCase()));for(const[i,l]of t)r.has(l.family.toLowerCase())||(o[i]=l,r.add(l.family.toLowerCase()));return Object.keys(o).length>s?null:o}function Ixe(e,t){if(!e)return"";const n=lb(e,t);return n.ok?n.value:e}const ty=[{family:"Arial",generic:"sans-serif"},{family:"Georgia",generic:"serif"},{family:"Times New Roman",generic:"serif"},{family:"Courier New",generic:"monospace"},{family:"Verdana",generic:"sans-serif"},{family:"Tahoma",generic:"sans-serif"},{family:"Trebuchet MS",generic:"sans-serif"}],Gb=[{family:"Inter",generic:"sans-serif",wght:[100,900],italic:!0},{family:"Roboto",generic:"sans-serif",weights:[400,500,700],wght:[100,900],italic:!0},{family:"Open Sans",generic:"sans-serif",wght:[300,800],italic:!0},{family:"Lato",generic:"sans-serif",weights:[400,700],statics:[100,300,400,700,900],italic:!0},{family:"Montserrat",generic:"sans-serif",wght:[100,900],italic:!0},{family:"Poppins",generic:"sans-serif",statics:[100,200,300,400,500,600,700,800,900],italic:!0},{family:"Raleway",generic:"sans-serif",wght:[100,900],italic:!0},{family:"Nunito",generic:"sans-serif",wght:[200,1e3],italic:!0},{family:"Playfair Display",generic:"serif",wght:[400,900],italic:!0},{family:"Merriweather",generic:"serif",weights:[400,700],wght:[300,900],italic:!0},{family:"Work Sans",generic:"sans-serif",wght:[100,900],italic:!0},{family:"DM Sans",generic:"sans-serif",wght:[100,1e3],italic:!0},{family:"Manrope",generic:"sans-serif",wght:[200,800],italic:!1},{family:"Space Grotesk",generic:"sans-serif",wght:[300,700],italic:!1},{family:"Lora",generic:"serif",wght:[400,700],italic:!0},{family:"Bebas Neue",generic:"sans-serif",statics:[400],italic:!1},{family:"Caveat",generic:"sans-serif",wght:[400,700],italic:!1}],a2=[{key:"sans-serif",label:"Sans-serif",css:"sans-serif"},{key:"serif",label:"Serif",css:"serif"},{key:"monospace",label:"Monospace",css:"monospace"},{key:"helvetica",label:"Helvetica",css:Uh(["Helvetica","Arial","sans-serif"])}],bh=e=>e.trim().toLowerCase();function ed(e){return Gb.find(t=>bh(t.family)===bh(e))}function Yb(e){return ty.find(t=>bh(t.family)===bh(e))}function t9(e){return`https://fonts.googleapis.com/css2?family=${e.family.replace(/ +/g,"+")}:wght@${(e.weights??[400,500,600,700]).join(";")}&display=swap`}function n9(e){return{family:e.family,href:t9(e)}}function wg(e,t=Yb(e)?.generic??ed(e)?.generic??"sans-serif"){return Uh([e,t])}function xh(e){return e?qa(e)[0]??null:null}function Bxe(e=document){for(const t of Gb){const n=t9(t);if(e.head.querySelector(`link[href="${CSS.escape(n)}"]`))continue;const s=e.createElement("link");s.rel="stylesheet",s.href=n,e.head.appendChild(s)}}const a4=[100,200,300,400,500,600,700,800,900],Fxe={100:"Thin",200:"Extra light",300:"Light",400:"Regular",500:"Medium",600:"Semibold",700:"Bold",800:"Extra bold",900:"Black"};function td(e){return Math.min(900,Math.max(100,Math.round(e/100)*100))}function l4({weight:e,italic:t}){const n=Fxe[td(e)]??String(e);return t?td(e)===400?"Italic":`${n} italic`:n}function c4({weight:e,italic:t}){return`${td(e)}${t?"i":""}`}function Hxe(e){const t=/^(\d{3})(i?)$/.exec(e);return t?{weight:Number(t[1]),italic:t[2]==="i"}:null}const dS=(e,t)=>e.flatMap(n=>t?[{weight:n,italic:!1},{weight:n,italic:!0}]:[{weight:n,italic:!1}]);function Uxe(e){const t=e?ed(e):void 0;if(t){const s=t.wght?a4.filter(o=>o>=t.wght[0]&&o<=t.wght[1]):[...t.statics??[400]];return dS(s,t.italic)}const n=e?bh(e):"";return Yb(n)||n==="helvetica"||n==="helvetica neue"?dS([400,700],!0):dS(a4,!0)}function Vxe(e,t){const n=Uxe(e);return t&&!n.some(s=>s.weight===td(t.weight)&&s.italic===t.italic)&&n.push({weight:td(t.weight),italic:t.italic}),n.sort((s,o)=>s.weight-o.weight||Number(s.italic)-Number(o.italic))}const qxe=(e,t)=>`${e}/${t}`;function s9(e){const t=e.indexOf("/");return t<0?{namespace:e,theme:""}:{namespace:e.slice(0,t),theme:e.slice(t+1)}}function Wxe(e){const t=n=>WC(e,n);return[t("background")??"#ffffff",t("text")??"#1a1a1a",t("accent")??t("text")??"#1a1a1a",t("surface")??t("background")??"#ffffff",t("muted")??"#777777"]}function Gxe(e,t){const n=[t];for(const s of e){const o=s.look.themes;for(const r of o)n.push({id:qxe(s.namespace,r.id),title:s.title,...o.length>1?{subtitle:r.name}:{},swatches:Wxe(r),...s.look.heading?{heading:s.look.heading.family}:{},...s.look.body?{body:s.look.body.family}:{}})}return n}function o9(e){return e.subtitle?`${e.title} · ${e.subtitle}`:e.title}function AT(){const e=ie.getState();return mn(e).map(t=>({id:t,entry:e.slides[t]})).filter(t=>!!(t.entry&&!t.entry.held)).map(({id:t,entry:n})=>({id:t,slide:n.slide}))}function r9(e,t,n){let s=t;const o=t4(s),r=o?n.find(c=>c.namespace===s9(o).namespace):void 0,i=QH(e.map(c=>c.slide),r?.look);s&&Mxe(s,i.uses)<.5&&(s=null);const l=[];if(s?.recent[0]){const c=[s.recent[0],...s.recent.slice(1),s.original];for(const{id:u,slide:f}of e)zxe(f,c,s.original.on)>0&&l.push(u)}return{analysis:i,memory:s,current:s?t4(s):Na,strays:l}}const i9=/^(sans-serif|serif|monospace|system-ui|cursive|fantasy|ui-sans-serif|ui-serif|ui-monospace)$/i;function Yxe(e,t,n){if(!e||i9.test(e)||Yb(e))return"builtin";const s=e.toLowerCase(),o=Object.values(t).find(i=>i.family.toLowerCase()===s);if(o)return o;for(const i of n)for(const l of[i.look.heading,i.look.body]){if(!l?.files?.length||l.family.toLowerCase()!==s)continue;const c=l.files.find(u=>u.weight==="400"&&u.style==="normal")??l.files.find(u=>u.style==="normal")??l.files[0];return{family:l.family,src:`${loe}${i.namespace}/${c.file}`}}const r=ed(e);return r?n9(r):null}function Kxe(e,t){const n=t?qa(t).at(-1)?.toLowerCase():void 0;return n==="serif"||n==="monospace"||n==="sans-serif"?n:Yb(e)?.generic??ed(e)?.generic??"sans-serif"}function a9(e,t){return e?i9.test(e)?e.toLowerCase():Uh([e,Kxe(e,t)]):""}function Xxe(e,t){const n=[],s=new Set,o=(r,i)=>{!r||s.has(r.toLowerCase())||(s.add(r.toLowerCase()),n.push({family:r,group:i}))};for(const r of Object.values(e))o(r.family,"In this deck");for(const r of t)o(r.look.heading?.family,r.title),o(r.look.body?.family,r.title);for(const r of[...ty,...Gb].sort((i,l)=>i.family.localeCompare(l.family)))o(r.family,"More fonts");return n}function l9(e,t,n,s){const o={wanted:[],missing:[]};for(const r of["heading","body"]){const i=t[r];if(i===void 0)continue;const l=qa(i)[0]??"";if((l.toLowerCase()||"")===e[r])continue;const c=Yxe(l,n,s);if(c===null){o.missing.push(l);continue}c!=="builtin"&&o.wanted.push([W6(c.family),c]),o[r]={from:e[r],to:i}}return o}function NT(e,t,n){const s=ie.getState(),o=c=>{const u={},f=[],h=new Set([...Object.values(s.index.faces),...n.wanted.map(([,v])=>v)].map(v=>v.family.toLowerCase())),g=v=>v?{...v,to:Ixe(v.to,h)}:void 0,m=c?g(n.heading):void 0,b=c?g(n.body):void 0;for(const{id:v,slide:w}of e){let E=t?Dxe(w,t):w;E=Pxe(E,{heading:m,body:b}),E!==w&&(u[v]=E),f.push(E)}for(const v of Object.values(s.slides))v.held&&f.push(v.slide);return{slides:u,all:f}};let r=o(!0),i=i4(s.index.faces,n.wanted,r4(r.all),ve.faces),l=!1;return i||(l=!0,r=o(!1),i=i4(s.index.faces,[],r4(r.all),ve.faces)??s.index.faces),{slides:r.slides,faces:i,fontsDropped:l}}function l2(e,t){t?Ke.add({title:"Fonts unchanged",description:`A presentation carries up to ${ve.faces} typefaces, and the new ones would not fit.`}):e.missing.length&&Ke.add({title:"Some fonts were kept",description:`${e.missing.join(", ")} can't be carried by this deck, so the current fonts stay.`})}function Zxe(e,t){const{namespace:n,theme:s}=s9(e),o=t.find(i=>i.namespace===n),r=o?.look.themes.find(i=>i.id===s)??(s===""?o?.look.themes[0]:void 0);return o&&r?{system:o,theme:r}:null}const u4=e=>e?a9(e.family,e.stack):void 0;function Qxe(e){const t=ie.getState();if(t.readOnly||t.status!=="ready")return!1;const n=yc.getState().systems,s=AT(),o=r9(s,jT(t.index),n),{analysis:r}=o;let i=o.memory;if(!i&&r.over)return Ke.add({title:"This deck can't be restyled automatically",description:`It uses ${r.distinct} colors (at most ${ey}). Ask the agent to redo its look instead.`}),!1;const l=s.map(k=>k.slide),c=i?.original??Rxe(r.slots,o4(l,r.heading),o4(l,r.body)),u=i?[...i.recent,i.original]:[c];let f,h,g;if(e===Na){if(!i)return!1;f=c.colors,h={heading:c.heading,body:c.body},g="Original look"}else{const k=Zxe(e,n);if(!k)return!1;f=Oxe(i?jxe(c):r.slots,k.theme),h={heading:u4(k.system.look.heading),body:u4(k.system.look.body)},g=o9({title:k.system.title,...k.system.look.themes.length>1?{subtitle:k.theme.name}:{}})}const m=l9(r,h,t.index.faces,n),b={from:u,to:f,...c.on?{on:c.on}:{},...i?{}:{assign:r.assign}},v=NT(s,b,m),w={look:e,title:g,colors:f,...h.heading!==void 0?{heading:h.heading}:{},...h.body!==void 0?{body:h.body}:{}},{on:E,...M}=c;i=Txe(i,c,e===Na?M:w);const S=Cxe({...t.index,faces:v.faces??t.index.faces},i);return t.apply(`Theme: ${g}`,{slides:v.slides,index:S}),l2(m,v.fontsDropped),!0}function Jxe(){const e=ie.getState();if(e.readOnly)return;const t=jT(e.index),n=t?.recent[0];if(!t||!n)return;const s=[n,...t.recent.slice(1),t.original],o=NT(AT(),{from:s,to:n.colors,...t.original.on?{on:t.original.on}:{}},{wanted:[]});Object.keys(o.slides).length&&e.apply(`Theme: ${n.title??"look"} on all slides`,{slides:o.slides})}function d4(e,t){const n=ie.getState();if(n.readOnly)return;const s=yc.getState().systems,o=AT(),r=QH(o.map(f=>f.slide)),i=a9(t),l=l9(r,{[e]:i},n.index.faces,s);if(!l.heading&&!l.body){l2(l,!1);return}const c=NT(o,null,l),u=c.faces&&c.faces!==n.index.faces?{...n.index,faces:c.faces}:void 0;n.apply(e==="heading"?"Heading font":"Body font",{slides:c.slides,...u?{index:u}:{}}),l2(l,c.fontsDropped)}function eve({colors:e,className:t}){return p.jsx("span",{className:ze("flex shrink-0 overflow-hidden rounded-[4px] shadow-[0_0_0_1px_var(--chrome-line)]",t),"aria-hidden":!0,children:e.map((n,s)=>p.jsx("span",{className:"h-full w-3",style:{background:n}},s))})}function tve({option:e,current:t,onPick:n,tabStop:s}){const[o,r,i]=e.swatches,l=[e.heading,e.body].filter((c,u,f)=>!!c&&f.indexOf(c)===u).join(" · ");return p.jsxs("button",{type:"button",role:"option","aria-selected":t,"data-look":e.id,tabIndex:s?0:-1,onClick:n,className:ze("flex w-full min-w-0 items-center gap-2.5 rounded-[8px] p-1.5 text-left outline-none hover:bg-chrome-hover focus-visible:shadow-[inset_0_0_0_1px_var(--color-chrome-accent)]",t&&"bg-chrome-hover"),children:[p.jsxs("span",{className:"relative flex h-9 w-16 shrink-0 flex-col justify-center gap-1 overflow-hidden rounded-[4px] px-1.5 shadow-[0_0_0_1px_var(--chrome-line)]",style:{background:o},"aria-hidden":!0,children:[p.jsx("span",{className:"h-1.5 w-8 rounded-full",style:{background:r}}),p.jsx("span",{className:"h-1 w-10 rounded-full opacity-60",style:{background:r}}),p.jsx("span",{className:"absolute bottom-1 right-1.5 size-2.5 rounded-full",style:{background:i}})]}),p.jsxs("span",{className:"flex min-w-0 flex-1 flex-col",children:[p.jsx("span",{className:"truncate text-[13px] text-chrome-fg",children:e.title}),e.subtitle||l?p.jsx("span",{className:"truncate text-[11px] text-chrome-muted",children:[e.subtitle,l].filter(Boolean).join(" — ")}):null]}),t?p.jsx(Pi,{className:"size-4 shrink-0 text-chrome-accent",strokeWidth:2}):null]})}const fS="\0default";function nve(){const e=ie($=>$.slides),t=ie($=>$.index),n=ie($=>$.readOnly),s=yc($=>$.systems),o=Rt($=>$.status),r=C.useRef(null),i=C.useMemo(()=>mn({index:t,slides:e}).map($=>({id:$,entry:e[$]})).filter($=>!!($.entry&&!$.entry.held)).map(({id:$,entry:D})=>({id:$,slide:D.slide})),[t,e]),l=C.useMemo(()=>jT(t),[t]),c=C.useMemo(()=>r9(i,l,s),[i,l,s]),{analysis:u,memory:f,current:h,strays:g}=c,m=C.useMemo(()=>{const $=f?.original.colors??Object.fromEntries(u.slots.map(z=>[z.id,z.value])),D=(...z)=>z.map(_=>$[_]).find(Boolean)??"#ffffff";return{id:Na,title:"Original look",subtitle:"How the deck looked before",swatches:[D("background","surface"),D("text","muted","on-inverse"),D("accent","text"),D("surface","background"),D("muted","text")]}},[f,u]),b=C.useMemo(()=>Gxe(s,m),[s,m]),v=$=>{const D=b.find(z=>z.id===$);return D?o9(D):f?.recent.find(z=>z.look===$)?.title??"an earlier look"},w=$=>{n||$!==h&&($===Na&&!f||Qxe($))},E=$=>{if(!["ArrowDown","ArrowUp","Home","End"].includes($.key))return;const D=[...r.current?.querySelectorAll("[data-look]")??[]],z=D.indexOf(document.activeElement),_=$.key==="Home"?0:$.key==="End"?D.length-1:Math.max(0,Math.min(D.length-1,(z<0?0:z)+($.key==="ArrowDown"?1:-1))),L=D[_];L&&($.preventDefault(),L.focus(),w(L.dataset.look??""))},M=C.useMemo(()=>Xxe(t.faces,s),[t.faces,s]),S=C.useMemo(()=>[{value:fS,label:"Default (system font)",group:"Default"},...M.map($=>({value:$.family.toLowerCase(),label:$.family,group:$.group,style:{fontFamily:`"${$.family}"`}}))],[M]),k=$=>$===""?fS:$,R=$=>$&&!S.some(D=>D.value===$)?[{value:$,label:$,group:"In this deck",style:{fontFamily:`"${$}"`}},...S]:S,N=$=>$===fS?"":M.find(D=>D.family.toLowerCase()===$)?.family??$,O=f?.recent.slice(1).filter($=>$.look!==h)??[],A=n;return p.jsxs("div",{className:"flex min-w-0 flex-col",children:[p.jsxs(os,{title:"Look",children:[s.length===0?p.jsxs(p.Fragment,{children:[p.jsx(hi,{children:"Install a design system in this deck to restyle every slide from its colors and fonts."}),o.available&&!n?p.jsx("div",{className:"px-4 py-1",children:p.jsxs(Hl,{variant:"secondary",icon:p.jsx(bD,{}),onClick:()=>{v8("Install a design system in this deck (copy it under project/ds/ and list it in deck.json designSystems) so I can restyle the slides from the Theme panel.")},children:["Ask ",o.name," to add one"]})}):null]}):null,!f&&u.over?p.jsxs(hi,{children:["This deck uses ",u.distinct," colors (at most ",ey," can be restyled automatically). Ask ",o.name," to redo its look instead."]}):null,p.jsxs("div",{ref:r,role:"listbox","aria-label":"Looks","aria-disabled":A||void 0,onKeyDown:E,className:ze("flex flex-col gap-0.5 px-2.5",A&&"pointer-events-none opacity-50"),children:[b.filter($=>$.id!==Na||f).map($=>p.jsx(tve,{option:$,current:$.id===h,tabStop:$.id===h||!f&&$===b[1],onPick:()=>w($.id)},$.id||"original")),!f&&s.length>0?p.jsx(hi,{className:"px-1.5",children:"The deck wears its own look. Pick one to restyle every slide; Original look brings it back."}):null]}),O.length?p.jsx(Be,{label:"Recent",children:O.map($=>p.jsxs(Hl,{variant:"ghost",className:"min-w-0 truncate px-1.5",disabled:A,onClick:()=>w($.look),title:`Switch back to ${v($.look)}`,children:[p.jsx(eve,{className:"h-3",colors:[$.colors.background,$.colors.text,$.colors.accent].filter(D=>!!D)}),p.jsx("span",{className:"truncate",children:v($.look)})]},$.look||"original"))}):null,g.length&&f?.recent[0]?p.jsxs("div",{className:"mx-4 mt-1 flex flex-col gap-1.5 rounded-[8px] bg-chrome-field p-2.5",children:[p.jsxs("span",{className:"text-[12px] leading-[1.45] text-chrome-fg",children:[g.length===1?"1 slide still uses":`${g.length} slides still use`," colors from an earlier look. Make ",g.length===1?"it":"them"," ",v(h)," too?"]}),p.jsx(Hl,{variant:"secondary",icon:p.jsx(Tz,{}),disabled:A,onClick:Jxe,className:"self-start",children:"Apply to all slides"})]}):null]}),p.jsxs(os,{title:"Fonts",children:[p.jsx(Be,{label:"Headings",tip:"The typeface of every heading in the deck",children:p.jsx(Rs,{"aria-label":"Heading font",value:k(u.heading),options:R(u.heading),disabled:A,onChange:$=>d4("heading",N($))})}),p.jsx(Be,{label:"Body",tip:"The typeface of body text across the deck",children:p.jsx(Rs,{"aria-label":"Body font",value:k(u.body),options:R(u.body),disabled:A,onChange:$=>d4("body",N($))})}),p.jsx(hi,{children:"A presentation carries up to four typefaces; changing a font is one undo step."})]}),u.slots.length?p.jsxs(os,{title:"Palette",collapsible:!0,children:[p.jsx("div",{className:"flex flex-col gap-0.5 px-4",children:u.slots.slice(0,24).map($=>p.jsxs("div",{className:"flex min-h-6 items-center gap-2 text-[12px]",children:[p.jsx("span",{className:"size-4 shrink-0 rounded-[4px] shadow-[0_0_0_1px_var(--chrome-line)]",style:{background:$.value},"aria-hidden":!0}),p.jsxs("span",{className:"min-w-0 flex-1 truncate text-chrome-fg",children:[xue[$.role],/-\d+$/.test($.id)?` ${$.id.split("-").at(-1)}`:""]}),p.jsx("span",{className:"font-mono text-[11px] text-chrome-muted",children:$.value})]},$.id))}),p.jsx(hi,{children:"How the deck’s colors were read. A look maps each role to the design system’s matching color."})]}):null]})}function OT({title:e,children:t}){return p.jsxs("div",{className:"flex min-w-0 flex-col",children:[p.jsx("div",{className:"px-4 pb-1 pt-2 text-[12px] font-[520] text-chrome-secondary",children:e}),t]})}function sve({target:e}){return p.jsxs(os,{title:"Advanced",collapsible:!0,children:[p.jsx(ove,{target:e}),p.jsx(lve,{target:e}),p.jsx(dve,{target:e})]})}const f4=[{value:"auto",label:"Auto"},{value:"start",label:"Start"},{value:"center",label:"Center"},{value:"end",label:"End"},{value:"stretch",label:"Stretch"}];function c9(e){const t=e.style.flex?.trim();if(t==="none")return{grow:0,shrink:0,basis:"auto"};if(t==="auto")return{grow:1,shrink:1,basis:"auto"};if(t){const[n,s,o]=t.split(/\s+/),r=s!==void 0&&/^[\d.]+$/.test(s);return{grow:Number(n)||0,shrink:r?Number(s):1,basis:(r?o:s)??"0%"}}return{grow:Number(e.style["flex-grow"]??0),shrink:Number(e.style["flex-shrink"]??1),basis:e.style["flex-basis"]??"auto"}}function hS(e,t,n){So(e,t,s=>{if(!s)return{};const o=n(c9(s));return{flex:o.grow===0&&o.shrink===1&&o.basis==="auto"?void 0:`${o.grow} ${o.shrink} ${o.basis}`,"flex-grow":void 0,"flex-shrink":void 0,"flex-basis":void 0}})}function ove({target:e}){if(e.nodes.length===0||e.nodes.some(f=>Xt(f)||f.kind==="connector"))return null;const t=e.nodes[0],n=e.paths[0],o=((n.length>1?fb(e.slide,n)?.style:e.slide.style)??{}).display==="grid",r=Ut(e,"align-self"),i=Ut(e,"justify-self"),l=c9(t),c=/^([\d.]+)px$/.exec(l.basis),u=f=>f.mixed?null:f.value?.replace(/^flex-/,"")??"auto";return p.jsxs(OT,{title:"Sizing",children:[p.jsx(Be,{label:"Align self",children:p.jsx(Rs,{"aria-label":"Align self",value:u(r),placeholder:"Mixed",options:f4.map(f=>({...f})),onChange:f=>dt(e,"align-self",f==="auto"?"":f,"Align self")})}),o?p.jsx(Be,{label:"Justify self",children:p.jsx(Rs,{"aria-label":"Justify self",value:u(i),placeholder:"Mixed",options:f4.map(f=>({...f})),onChange:f=>dt(e,"justify-self",f==="auto"?"":f,"Justify self")})}):p.jsxs(p.Fragment,{children:[p.jsx(Be,{label:"Grow",tip:"How much of the group's spare room this child takes",children:p.jsx(kt,{"aria-label":"Grow",value:l.grow,min:0,max:1e3,onCommit:f=>hS(e,"Grow",h=>({...h,grow:f??0}))})}),p.jsx(Be,{label:"Shrink",tip:"How much this child gives up when the group runs out of room",children:p.jsx(kt,{"aria-label":"Shrink",value:l.shrink,min:0,max:1e3,onCommit:f=>hS(e,"Shrink",h=>({...h,shrink:f??1}))})}),p.jsx(Be,{label:"Basis",tip:"The size this child starts from before growing or shrinking",children:p.jsx(kt,{"aria-label":"Basis",value:c?Number(c[1]):null,placeholder:l.basis==="0%"?"0":"Auto",unit:"px",min:0,max:4096,step:8,onCommit:f=>hS(e,"Basis",h=>({...h,basis:f===null?"auto":`${f}px`}))})})]}),p.jsx(Be,{label:"Aspect",children:p.jsx(CT,{target:e,property:"aspect-ratio",label:"Aspect ratio",placeholder:"Auto"})})]})}const c2={blur:"Blur",brightness:"Brightness",contrast:"Contrast",saturate:"Saturate",grayscale:"Grayscale",sepia:"Sepia",invert:"Invert","hue-rotate":"Hue"},h4={blur:0,brightness:1,contrast:1,saturate:1,grayscale:0,sepia:0,invert:0,"hue-rotate":0},u9=Object.keys(Xl);function u2(e,t){return Xl[e].unit===""?Math.round(t*100):t}function d9(e){const t=Xl[e].unit;return t===""?"%":t==="deg"?"°":t}function rve(e){const t=u9.filter(n=>e[n]!==void 0).map(n=>`${c2[n]} ${u2(n,e[n])}${d9(n)}`);return t.length?t.join(" · "):"None"}const ive=[{value:"default",label:"Default"},{value:"normal",label:"Normal"},{value:"multiply",label:"Multiply"},{value:"screen",label:"Screen"},{value:"overlay",label:"Overlay"},{value:"darken",label:"Darken"},{value:"lighten",label:"Lighten"}],ave=new Set(["box","text","list","textbox","image","shape"]);function lve({target:e}){if(e.nodes.length===0)return null;const t=e.nodes.every(o=>ave.has(o.kind)&&o.kind!=="rule"),n=e.nodes.every(o=>o.kind!=="connector"&&o.kind!=="shape");if(!t&&!n)return null;const s=Ut(e,"mix-blend-mode");return p.jsxs(OT,{title:"Effects",children:[t?p.jsx(p4,{target:e,property:"filter",label:"Filter"}):null,t?p.jsx(p4,{target:e,property:"backdrop-filter",label:"Backdrop"}):null,n?p.jsx(uve,{target:e}):null,t?p.jsx(Be,{label:"Blend",children:p.jsx(Rs,{"aria-label":"Blend mode",value:s.mixed?null:s.value??"default",placeholder:"Mixed",options:ive.map(o=>({...o})),onChange:o=>dt(e,"mix-blend-mode",o==="default"?"":o,"Blend mode")})}):null]})}function p4({target:e,property:t,label:n}){const s=Ut(e,t),o=s.value&&!s.mixed?UE(s.value):null,r=o?.ok?o.value:{},i=t==="filter"?"Filter":"Background filter",l=(c,u)=>{const f={...r},h=u===null?null:Xl[c].unit===""?u/100:u;h===null||h===h4[c]?delete f[c]:f[c]=h,dt(e,t,VE(f),i,`${t}-${c}`)};return p.jsx(Be,{label:n,onReset:s.value?()=>dt(e,t,"",i):void 0,resetLabel:`Remove ${i.toLowerCase()}`,children:p.jsx(ET,{title:i,text:s.mixed?"Mixed":rve(r),children:u9.map(c=>{const u=Xl[c],f=u.unit===""?100:1;return p.jsx(Be,{label:c2[c],children:p.jsx(kt,{"aria-label":`${i} ${c2[c].toLowerCase()}`,value:r[c]===void 0?null:u2(c,r[c]),placeholder:String(u2(c,h4[c])),unit:d9(c),min:u.min*f,max:u.max*f,step:c==="blur"?.5:1,onCommit:h=>l(c,h)})},c)})})})}function cve(e){const t=[];return(e.translateX!==void 0||e.translateY!==void 0)&&t.push(`Move ${e.translateX??0}, ${e.translateY??0}`),e.scale!==void 0&&t.push(`Scale ${Math.round(e.scale*100)}%`),e.rotate!==void 0&&t.push(`Rotate ${e.rotate}°`),(e.skewX!==void 0||e.skewY!==void 0)&&t.push(`Skew ${e.skewX??0}°, ${e.skewY??0}°`),t.length?t.join(" · "):"None"}function uve({target:e}){const t=Ut(e,"transform"),n=t.value&&!t.mixed?m6(t.value):null,s=n?.ok?n.value:{},o=i=>{const l={...s,...i};for(const c of Object.keys(l)){const u=c==="scale"?1:0;(l[c]===void 0||l[c]===u)&&delete l[c]}dt(e,"transform",sk(l),"Transform","transform")},r=i=>typeof i=="number"?i:null;return p.jsx(Be,{label:"Transform",onReset:t.value?()=>dt(e,"transform","","Transform"):void 0,resetLabel:"Remove transform",children:p.jsxs(ET,{title:"Transform",text:t.mixed?"Mixed":cve(s),children:[p.jsxs(Be,{label:"Move",children:[p.jsx(kt,{"aria-label":"Move x",label:"X",value:r(s.translateX),placeholder:s.translateX==="-50%"?"−50%":"0",steppers:!1,min:-4e3,max:4e3,onCommit:i=>o({translateX:i??0})}),p.jsx(kt,{"aria-label":"Move y",label:"Y",value:r(s.translateY),placeholder:s.translateY==="-50%"?"−50%":"0",steppers:!1,min:-4e3,max:4e3,onCommit:i=>o({translateY:i??0})})]}),p.jsx(Be,{label:"Scale",children:p.jsx(kt,{"aria-label":"Scale",value:s.scale===void 0?null:Math.round(s.scale*100),placeholder:"100",unit:"%",min:50,max:200,onCommit:i=>o({scale:(i??100)/100})})}),p.jsx(Be,{label:"Rotate",children:p.jsx(kt,{"aria-label":"Rotate",value:s.rotate??null,placeholder:"0",unit:"°",min:-360,max:360,onCommit:i=>o({rotate:i??0})})}),p.jsxs(Be,{label:"Skew",children:[p.jsx(kt,{"aria-label":"Skew x",label:"X",value:s.skewX??null,placeholder:"0",unit:"°",steppers:!1,min:-60,max:60,onCommit:i=>o({skewX:i??0})}),p.jsx(kt,{"aria-label":"Skew y",label:"Y",value:s.skewY??null,placeholder:"0",unit:"°",steppers:!1,min:-60,max:60,onCommit:i=>o({skewY:i??0})})]})]})})}function dve({target:e}){const[t,n]=C.useState(null),s=C.useMemo(()=>{const r=e.nodes.length?e.nodes.map(l=>l.style):[e.slide.style],i=new Set;for(const l of r)for(const c of Object.keys(l))i.add(c);return w0.filter(l=>i.has(l))},[e]),o=w0.filter(r=>!s.includes(r));return p.jsxs(OT,{title:"CSS",children:[s.length===0?p.jsx("p",{className:"px-4 text-[12px] text-chrome-muted",children:"No declarations."}):null,p.jsx("div",{className:"flex flex-col gap-1 px-4",children:s.map(r=>p.jsxs("div",{className:"flex min-w-0 items-center gap-1",children:[p.jsx("span",{className:"w-28 shrink-0 truncate font-mono text-[11px] text-chrome-muted",title:r,children:r}),p.jsx(CT,{target:e,property:r}),p.jsx(Ps,{label:`Remove ${r}`,icon:p.jsx(zr,{className:"size-3"}),onClick:()=>dt(e,r,"",`Remove ${r}`)})]},r))}),p.jsxs("div",{className:"flex min-w-0 items-center gap-1 px-4 pt-2",children:[p.jsx("div",{className:"w-28 shrink-0",children:p.jsx(Rs,{"aria-label":"Property to add",value:t,placeholder:"Add…",options:o.map(r=>({value:r,label:r})),onChange:n})}),t?p.jsx(kT,{autoFocus:!0,"aria-label":`${t} value`,className:"min-w-0 flex-1 font-mono text-xs",value:"",placeholder:"value",onCommit:r=>{r.trim()&&dt(e,t,r,t)&&n(null)}}):p.jsx(fs,{className:"size-3.5 text-chrome-muted"})]})]})}function fve({target:e}){const t=e.nodes.length===1?e.nodes[0]:null,n=e.paths[0],s=t?Co(t):null,o=i=>{s&&jn("Move",l=>ah(l,n,{...s,...i}))},r=[["left","Align left",f0],["center","Align centers",B3],["right","Align right",V3],["top","Align top",X3],["middle","Align middles",P3],["bottom","Align bottom",H3]].map(([i,l,c])=>p.jsx(Ps,{size:"sm",label:`${e.nodes.length>1?l:`${l} to slide`} (${KI}${N0[i]})`,icon:p.jsx(c,{className:"size-3.5"}),onClick:()=>MC(i)},i));return p.jsxs(os,{title:"Size",children:[s&&t?p.jsxs(p.Fragment,{children:[p.jsx(Be,{label:"Width",children:p.jsx(kt,{"aria-label":"Width",value:s.w,min:1,unit:"px",onCommit:i=>i!==null&&o({w:i})})}),p.jsx(Be,{label:"Height",children:p.jsx(kt,{"aria-label":"Height",value:s.h,min:1,unit:"px",onCommit:i=>i!==null&&o({h:i})})}),p.jsxs(Be,{label:"Position",children:[p.jsx(kt,{"aria-label":"X",label:"X",value:s.x,onCommit:i=>i!==null&&o({x:i})}),p.jsx(kt,{"aria-label":"Y",label:"Y",value:s.y,onCommit:i=>i!==null&&o({y:i})})]}),p.jsx(Be,{label:"Rotation",children:p.jsx(kt,{"aria-label":"Rotation",value:Ri(t),unit:"°",min:-180,max:180,onCommit:i=>jn("Rotate",l=>P6(l,n,i??0))})})]}):null,p.jsx(Be,{label:"Align",children:p.jsx("div",{className:"flex flex-wrap items-center gap-0.5",children:r})})]})}function pS(e,t){const n=(t.length>1?fb(e,t)?.style:e.style)??{};return{kind:n.display==="grid"?"grid":"stack",row:n["flex-direction"]==="row"||n["flex-direction"]==="row-reverse",alignItems:n["align-items"]??"stretch"}}function f9(e,t){return e.kind==="stack"&&e.row===(t==="w")}function h9(e,t){return e.kind==="grid"&&t==="w"?"justify-self":"align-self"}function m4(e,t,n){const s=e.style[n==="w"?"width":"height"];if(s&&s!=="auto"&&s!=="100%")return"fixed";if(s==="100%")return"fill";if(f9(t,n)){const r=e.style.flex??"";return/^[1-9]/.test(r)||Number(e.style["flex-grow"]??0)>0?"fill":"hug"}const o=e.style[h9(t,n)];return o?o==="stretch"?"fill":"hug":t.alignItems==="stretch"||t.alignItems==="normal"?"fill":"hug"}function hve(e,t,n,s,o){const r=n==="w"?"width":"height";if(f9(t,n))return s==="fill"?{[r]:void 0,flex:"1","flex-grow":void 0,"flex-basis":void 0}:s==="fixed"?{[r]:`${Math.round(o)}px`,flex:"none","flex-grow":void 0}:{[r]:void 0,flex:void 0,"flex-grow":void 0,"flex-basis":void 0};const i=h9(t,n);return s==="fill"?{[r]:void 0,[i]:"stretch"}:s==="fixed"?{[r]:`${Math.round(o)}px`,[i]:e.style[i]==="stretch"?void 0:e.style[i]}:{[r]:void 0,[i]:"start"}}function g4(e){const t=e?/span\s+(\d+)/.exec(e):null;return t?Number(t[1]):1}function p9(e){return document.querySelector(`[data-open-artifact-stage] [data-open-artifact-path="${e.join(".")}"]`)}function m9(e){if(e instanceof HTMLElement)return{w:e.offsetWidth,h:e.offsetHeight};const t=e.getBoundingClientRect();let n=e.parentElement;for(;n&&n.offsetWidth===0;)n=n.parentElement;const s=n&&n.getBoundingClientRect().width/n.offsetWidth||1;return{w:Math.round(t.width/s),h:Math.round(t.height/s)}}function pve(e){const t=p9(e);return t?m9(t):{w:240,h:120}}function mve(e){const t=e?e.join("."):null,n=ie(i=>i.revision),s=te(i=>i.textEdit!==null),[o,r]=C.useState(null);return C.useEffect(()=>{if(t===null)return;let i=null;const l=requestAnimationFrame(()=>{const c=p9(t.split(".").map(Number));if(!c)return r(null);const u=()=>{const{w:f,h}=m9(c);f===0&&h===0||r(g=>g&&g.w===f&&g.h===h?g:{w:f,h})};u(),i=new ResizeObserver(u),i.observe(c)});return()=>{cancelAnimationFrame(l),i?.disconnect()}},[t,n,s]),o}const gve=e=>`${e}: Hug sizes to the content, Fixed is an exact size, Fill takes the space the group gives it.`,y4=[{key:"min-width",label:"Min width"},{key:"max-width",label:"Max width"},{key:"min-height",label:"Min height"},{key:"max-height",label:"Max height"}];function yve({target:e}){const t=e.paths.map(m=>m.join(".")).join("|"),[n,s]=C.useState(new Set);C.useEffect(()=>s(new Set),[t]);const o=mve(e.nodes.length===1?e.paths[0]:null);if(e.nodes.length===0)return null;if(e.nodes.every(m=>Xt(m)&&m.kind!=="connector"))return p.jsx(fve,{target:e});if(e.nodes.some(m=>Xt(m)))return null;const r=e.paths[0],i=e.nodes[0],l=pS(e.slide,r),c=m=>n.has(m)||e.nodes.some(b=>b.style[m]!==void 0),u=(m,b,v)=>{jn("Size",w=>{let E=w;for(const M of e.paths){const S=We(E,M);if(!S)continue;const k=pve(M),R=hve(S,pS(E,M),m,b,v??(m==="w"?k.w:k.h));E=Bn(E,M,N=>({...N,style:wve(N.style,R)}))}return E})},f=m=>{const b=m4(i,l,m),v=m==="w"?"width":"height",w=m==="w"?"Width":"Height",M=(b==="fixed"?ic(i.style[v]):null)??(o?Math.round(m==="w"?o.w:o.h):null);return p.jsxs(Be,{label:w,tip:gve(w),children:[p.jsx(kt,{"aria-label":w,value:e.nodes.length===1?M:null,placeholder:e.nodes.length===1?"Auto":"Mixed",min:1,max:4096,step:8,onCommit:S=>S!==null&&u(m,"fixed",S)}),p.jsx(Rs,{"aria-label":`${w} sizing`,className:"w-[76px] shrink-0",value:e.nodes.every((S,k)=>m4(S,pS(e.slide,e.paths[k]),m)===b)?b:null,placeholder:"Mixed",options:[{value:"hug",label:"Hug"},{value:"fixed",label:"Fixed"},{value:"fill",label:"Fill"}],onChange:S=>u(m,S)})]})},h=p.jsx(wo,{align:"end",tip:{label:"Add to Size"},trigger:p.jsx("button",{type:"button","aria-label":"Add to Size",className:"flex size-6 items-center justify-center rounded-[6px] text-chrome-secondary outline-none hover:bg-chrome-hover hover:text-chrome-fg focus-visible:ring-2 focus-visible:ring-chrome-accent",children:p.jsx(fs,{className:"size-4",strokeWidth:1.5})}),children:y4.map(({key:m,label:b})=>p.jsx(It,{disabled:c(m),onSelect:()=>s(new Set([...n,m])),children:b},m))}),g=l.kind==="grid"?vve(e.slide,r):0;return p.jsxs(os,{title:"Size",actions:h,children:[f("w"),f("h"),y4.filter(({key:m})=>c(m)).map(({key:m,label:b})=>{const v=Ut(e,m);return p.jsx(Be,{label:b,onReset:()=>{dt(e,m,"",b);const w=new Set(n);w.delete(m),s(w)},resetLabel:`Remove ${b.toLowerCase()}`,children:p.jsx(kt,{"aria-label":b,value:v.mixed?null:ic(v.value),placeholder:v.mixed?"Mixed":m.startsWith("min")?"0":"—",unit:"px",min:m.startsWith("min")?0:1,max:4096,step:8,onCommit:w=>dt(e,m,w===null?"":`${w}px`,b)})},m)}),l.kind==="grid"?p.jsxs(p.Fragment,{children:[p.jsx(Be,{label:"Column span",tip:"Grid cells this child spans across (row-major auto-flow).",children:p.jsx(kt,{"aria-label":"Column span",value:g4(i.style["grid-column"]),placeholder:"1",min:1,max:Math.max(1,g),onCommit:m=>dt(e,"grid-column",!m||m<=1?"":`span ${Math.round(m)}`,"Column span")})}),p.jsx(Be,{label:"Row span",children:p.jsx(kt,{"aria-label":"Row span",value:g4(i.style["grid-row"]),placeholder:"1",min:1,max:12,onCommit:m=>dt(e,"grid-row",!m||m<=1?"":`span ${Math.round(m)}`,"Row span")})})]}):null,p.jsx(xve,{target:e})]})}function bve(e){const t=(e??"").trim().split(/\s+/).filter(Boolean);if(t.length===0)return[0,0,0,0];const[n,s=n,o=n,r=s]=t.map(i=>i==="auto"?"auto":ic(i)??0);return[n,s,o,r]}const Sg=e=>e==="auto"?0:e;function xve({target:e}){const t=Ut(e,"margin"),n=t.mixed?null:bve(t.value),s=n?[Sg(n[0]),Sg(n[1]),Sg(n[2]),Sg(n[3])]:null,o=r=>{const i=r.map((l,c)=>n?.[c]==="auto"&&l===s?.[c]?"auto":`${l}px`);dt(e,"margin",i.every(l=>l==="0px")?"":i.join(" "),"Margin","margin")};return p.jsx(Wb,{label:"Margin",kind:"sides",values:s,unit:"px",min:-1920,max:1920,title:"Space outside the element, between it and its neighbours.",onCommit:o,onReset:t.value&&!t.mixed?()=>dt(e,"margin","","Margin"):void 0})}function vve(e,t){const n=(t.length>1?fb(e,t)?.style:e.style)??{},s=n["grid-template-columns"]?qE(n["grid-template-columns"]):null;return s?.ok?s.value.length:12}function wve(e,t){const n={...e};for(const[s,o]of Object.entries(t))o===void 0?delete n[s]:n[s]=o;return n}const b4=[{value:"stretch",label:"Stretch"},{value:"start",label:"Start"},{value:"center",label:"Center"},{value:"end",label:"End"}];function d2(e){switch(e){case"start":case"flex-start":return"start";case"center":return"center";case"end":case"flex-end":return"end";default:return null}}function Sve(e){return e.unit==="fr"?{unit:"px",value:240}:e.unit==="px"?{unit:"auto"}:{unit:"fr",value:1}}function kve(e){return e.unit==="auto"?"Auto":`${e.value}${e.unit}`}const f2={justify:{start:jY,center:MY,end:RY},align:{start:$Y,center:NY,end:OY}},Eve={justify:f2.align,align:f2.justify};function Cve({target:e}){const t=e.nodes.length===1?e.nodes[0]:null,n=e.nodes.length===0;if(!n&&e.nodes.every(r=>r.kind==="text"||r.kind==="list"||r.kind==="textbox"))return p.jsx(os,{title:"Layout",children:p.jsx(x4,{target:e})});if(!n&&t?.kind!=="box"||t?.kind==="box"&&t.group)return null;const s=n?e.slide.style:t.style,o=s.display==="grid"?"grid":s.position==="relative"?"layered":"stack";return p.jsxs(os,{title:"Layout",children:[p.jsx(Be,{children:p.jsx(Ls,{"aria-label":"Layout",value:o,options:[{value:"stack",label:"Stack",title:"Children follow one another"},{value:"grid",label:"Grid",title:"Children fill a grid of columns"},...n?[]:[{value:"layered",label:"Layered",title:"Children are placed freely on top of each other"}]],onChange:r=>Tve(e,s,o,r,n)})}),o==="stack"?p.jsx(Mve,{target:e,style:s}):null,o==="grid"?p.jsx(Rve,{target:e,style:s}):null,o==="layered"?p.jsx(hi,{children:"Children are placed freely. Drag them on the slide to arrange them."}):null,o!=="layered"?p.jsx(Be,{label:"Gap",children:p.jsx(kt,{"aria-label":"Gap",value:Ut(e,"gap").mixed?null:ic(s.gap?.split(/\s+/)[0])??0,placeholder:"Mixed",min:0,max:512,onCommit:r=>dt(e,"gap",r?`${r}px`:"","Gap","gap")})}):null,p.jsx(x4,{target:e})]})}function Tve(e,t,n,s,o){s!==n&&(s==="grid"?So(e,"Grid layout",{display:"grid","grid-template-columns":WE([{unit:"fr",value:1},{unit:"fr",value:1}]),"flex-direction":void 0,"flex-wrap":void 0,"justify-content":void 0,position:o||t.position==="relative"?void 0:t.position}):s==="stack"?So(e,"Stack layout",{display:void 0,"grid-template-columns":void 0,"grid-template-rows":void 0,"justify-items":void 0,position:t.position==="relative"?void 0:t.position}):So(e,"Layered layout",{position:"relative",display:void 0,"grid-template-columns":void 0,"grid-template-rows":void 0}))}function Mve({target:e,style:t}){const n=t["flex-direction"]==="row"||t["flex-direction"]==="row-reverse",s=t["flex-wrap"]==="wrap",o=t["justify-content"]==="space-between",r=t["justify-content"]?d2(t["justify-content"]):"start",i=d2(t["align-items"]),l=n?f2:Eve,c=(f,h)=>["start","center","end"].map(g=>{const m=l[f][g];return{value:g,label:`${h} ${g}`,title:`${h} ${g}`,icon:p.jsx(m,{strokeWidth:1.5}),disabled:f==="justify"&&o,reason:"Distribute decides this axis"}}),u=n?AY:_Y;return p.jsxs(p.Fragment,{children:[p.jsxs(Be,{label:"Direction",children:[p.jsx(Ls,{"aria-label":"Direction",value:n?"h":"v",options:[{value:"h",label:"Horizontal",title:"Horizontal",icon:p.jsx(zY,{strokeWidth:1.5})},{value:"v",label:"Vertical",title:"Vertical",icon:p.jsx(rD,{strokeWidth:1.5})}],onChange:f=>So(e,"Direction",f==="h"?{"flex-direction":"row"}:{"flex-direction":void 0,"flex-wrap":void 0})}),p.jsx(Ps,{label:s?"Children wrap onto more rows — click for one row":"Wrap children onto more rows",icon:p.jsx(QY,{strokeWidth:1.5}),active:s,disabled:!n,reason:n?void 0:"Wrap applies to a horizontal stack",onClick:()=>dt(e,"flex-wrap",s?"":"wrap","Wrap")})]}),p.jsxs(Be,{label:"Align",onReset:t["justify-content"]||t["align-items"]?()=>So(e,"Align",{"justify-content":void 0,"align-items":void 0}):void 0,children:[p.jsxs("div",{className:ze("flex min-w-0 flex-1 gap-2",n?"items-center":"items-start"),children:[p.jsx(Ls,{"aria-label":"Justify",vertical:!n,className:n?"min-w-0 flex-1":void 0,value:r,options:c("justify","Justify"),onChange:f=>dt(e,"justify-content",f==="start"?"":f,"Justify")}),p.jsx(Ls,{"aria-label":"Align",vertical:!n,className:n?"min-w-0 flex-1":void 0,value:i,options:c("align","Align"),onChange:f=>dt(e,"align-items",f,"Align")})]}),p.jsx(Ps,{label:o?"Distribute: space between — click to pack":"Distribute (space between); needs main-axis room to show",icon:p.jsx(u,{strokeWidth:1.5}),active:o,onClick:()=>dt(e,"justify-content",o?"":"space-between","Distribute")})]})]})}function Rve({target:e,style:t}){const n=t["grid-template-columns"]?qE(t["grid-template-columns"]):null,s=n?.ok?n.value:[],o=r=>{r.length>0&&dt(e,"grid-template-columns",WE(r),"Grid columns")};return p.jsxs(p.Fragment,{children:[p.jsx(Be,{label:"Columns",children:p.jsxs("div",{className:"flex min-w-0 flex-1 flex-wrap items-center gap-1",children:[s.map((r,i)=>p.jsx("button",{type:"button",title:"Click to switch between a share, a fixed 240px and the content's size",className:"h-6 rounded-[6px] bg-chrome-field px-1.5 text-[12px] tabular-nums text-chrome-fg shadow-[inset_0_0_0_1px_var(--chrome-field-ring)] hover:shadow-[inset_0_0_0_1px_var(--chrome-field-ring-strong)]",onClick:()=>o(s.map((l,c)=>c===i?Sve(l):l)),children:kve(r)},i)),p.jsx(Ps,{label:"Add column",icon:p.jsx(fs,{strokeWidth:1.5}),disabled:s.length>=12,reason:s.length>=12?"12 columns at most":void 0,onClick:()=>o([...s,{unit:"fr",value:1}])}),p.jsx(Ps,{label:"Remove column",icon:p.jsx(Ii,{strokeWidth:1.5}),disabled:s.length<=1,reason:s.length<=1?"A grid keeps one column":void 0,onClick:()=>o(s.slice(0,-1))})]})}),p.jsx(Be,{label:"Rows",children:p.jsx(CT,{target:e,property:"grid-template-rows",label:"Grid rows",placeholder:"auto"})}),p.jsxs(Be,{label:"Align",children:[p.jsx(Rs,{"aria-label":"Justify items",value:t["justify-items"]??"stretch",options:b4.map(r=>({...r})),onChange:r=>dt(e,"justify-items",r==="stretch"?"":r,"Align columns")}),p.jsx(Rs,{"aria-label":"Align items",value:d2(t["align-items"])??"stretch",options:b4.map(r=>({...r})),onChange:r=>dt(e,"align-items",r==="stretch"?"":r,"Align rows")})]})]})}function x4({target:e}){const t=Ut(e,"padding"),n=s=>{const o=s.every(r=>r===s[0]);dt(e,"padding",o?s[0]?`${s[0]}px`:"":s.map(r=>`${r}px`).join(" "),"Padding","padding")};return p.jsx(Wb,{label:"Padding",kind:"sides",values:t.mixed?null:zne(t.value),unit:"px",min:0,max:1920,onCommit:n,onReset:t.value&&!t.mixed?()=>dt(e,"padding","","Padding"):void 0})}function g9(e){const t={color:"Color",gradient:"Gradient",image:"Image"};return e.map(n=>({value:n,label:t[n]}))}function y9(e){return e?.image?"image":e?.gradient?"gradient":"color"}function h2(e){return e?e.image?{swatch:`url("${e.image.url}") center / cover`,label:"Image"}:e.gradient?{swatch:Hh({gradient:e.gradient}),label:e.gradient.type==="radial"?"Radial":"Linear"}:null:null}function jve(e,t,n){const s=Vn(e)??{r:20,g:20,b:19},o=Vn(t)??s;return $l({r:Math.round(s.r+(o.r-s.r)*n),g:Math.round(s.g+(o.g-s.g)*n),b:Math.round(s.b+(o.b-s.b)*n),a:1})}function b9(e){const t=e&&Vn(e)?$l({...Vn(e),a:1}):"#141413";return{type:"linear",angle:90,stops:[{color:t,positions:[]},{color:jve(t,"#d97757",.6),positions:[]}]}}function Ave({image:e,onImage:t}){const[n,s]=C.useState(!1),o=()=>{gd("image/png,image/jpeg,image/webp,image/gif",!1).then(async r=>{const i=r[0];if(i){s(!0);try{const l=await Jh(i);t({url:l.src,size:e?.size??"cover"})}catch(l){Ke.add({title:"Couldn't add the image",description:l instanceof Error?l.message:String(l)})}finally{s(!1)}}})};return p.jsxs("div",{className:"flex flex-col gap-2",children:[p.jsxs("div",{className:"flex min-h-7 items-center gap-2",children:[p.jsx("span",{className:"w-12 shrink-0 text-[12px] text-chrome-muted",children:"Image"}),e?p.jsx("span",{className:"size-6 shrink-0 rounded-[4px] bg-cover bg-center shadow-[inset_0_0_0_1px_rgb(0_0_0/0.1)]",style:{backgroundImage:`url("${e.url}")`}}):null,p.jsx(Hl,{size:"sm",className:"min-w-0 flex-1",disabled:n,onClick:o,children:n?"Uploading…":e?"Replace…":"Choose image…"})]}),p.jsxs("div",{className:"flex min-h-7 items-center gap-2",children:[p.jsx("span",{className:"w-12 shrink-0 text-[12px] text-chrome-muted",children:"Size"}),p.jsx(Ls,{"aria-label":"Image size",value:e?.size??"cover",options:[{value:"cover",label:"Cover"},{value:"contain",label:"Contain"}],onChange:r=>e&&t({...e,size:r})})]})]})}const mS=8,gS=2,Nve="repeating-conic-gradient(#ddd 0 25%, #fff 0 50%) 0 0 / 8px 8px";function x9(e,t){const n=e.stops[t]?.positions[0],s=n?/^(-?[\d.]+)%$/.exec(n):null;return s?Number(s[1]):Math.round(t/Math.max(1,e.stops.length-1)*100)}function v9(e){return{...e,stops:e.stops.map((t,n)=>({...t,positions:[`${x9(e,n)}%`]}))}}function yS(e,t,n){const s=v9(e);return{...s,stops:s.stops.map((o,r)=>r===t?{...o,positions:[`${Math.round(Math.max(0,Math.min(100,n)))}%`]}:o)}}function v4({label:e,children:t}){return p.jsxs("div",{className:"flex min-h-7 items-center gap-2",children:[p.jsx("span",{className:"w-12 shrink-0 text-[12px] text-chrome-muted",children:e}),p.jsx("div",{className:"flex min-w-0 flex-1 items-center gap-1.5",children:t})]})}function w9({gradient:e,onChange:t,linearOnly:n=!1}){const s=Hi(),[o,r]=C.useState(0),i=C.useRef(null),l=e.type==="radial",c=e.stops.map((v,w)=>x9(e,w)),u=[...e.stops.map((v,w)=>({stop:v,at:c[w]}))].sort((v,w)=>v.at-w.at),f=Hh({gradient:{type:"linear",angle:90,stops:u.map(({stop:v,at:w})=>({...v,positions:[`${w}%`]}))}}),h=v=>{const w=i.current?.getBoundingClientRect();return w?(v.clientX-w.left-12)/Math.max(1,w.width-24)*100:0},g=v=>w=>{const E=w.shiftKey?10:1,M=w.key==="ArrowLeft"||w.key==="ArrowDown"?-E:w.key==="ArrowRight"||w.key==="ArrowUp"?E:0;M&&(w.preventDefault(),t(yS(e,v,c[v]+M)))},m=()=>{const v=c[o]??50,w=c.filter(M=>M>v).sort((M,S)=>M-S)[0]??Math.min(100,v+20),E=v9(e);E.stops.push({color:e.stops[o]?.color??"#ffffff",positions:[`${Math.round((v+w)/2)}%`]}),t(E),r(E.stops.length-1)},b=v=>{t({...e,stops:e.stops.filter((w,E)=>E!==v)}),r(Math.max(0,Math.min(o,e.stops.length-2)))};return p.jsxs("div",{className:"flex flex-col gap-2",children:[p.jsxs(v4,{label:"Style",children:[p.jsx(Rs,{"aria-label":"Gradient style",value:l?"radial":"linear",options:[{value:"linear",label:"Linear"},{value:"radial",label:"Radial",disabled:n,reason:"Linear gradients only here."}],onChange:v=>t(v==="radial"?{type:v,shape:"ellipse",stops:e.stops}:{type:v,angle:e.angle??180,stops:e.stops})}),p.jsx(kt,{"aria-label":"Angle",className:"w-[76px] shrink-0",label:p.jsx(CE,{}),value:l?null:e.angle??180,placeholder:l?"–":"180",unit:"°",min:0,max:360,steppers:!1,disabled:l,title:l?"A radial gradient has no angle.":void 0,onCommit:v=>t({...e,angle:v??180})})]}),p.jsxs("div",{ref:i,className:"relative my-1 h-8 rounded-[6px] shadow-[inset_0_0_0_1px_rgb(0_0_0/0.08)]",style:{background:Nve},children:[p.jsx("div",{className:"absolute inset-0 rounded-[6px]",style:{background:f}}),p.jsx("div",{className:"absolute inset-y-0 left-3 right-3",children:e.stops.map((v,w)=>p.jsx("button",{type:"button",role:"slider","aria-label":`Stop ${w+1} position`,"aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":Math.round(c[w]),className:ze("absolute top-1/2 size-4 -translate-x-1/2 -translate-y-1/2 cursor-default touch-none rounded-full border-2 border-white shadow-[0_0_0_1px_rgb(0_0_0/0.25)] outline-none focus-visible:ring-2 focus-visible:ring-chrome-accent",w===o&&"z-[1] outline-2 outline-offset-1 outline-chrome-fg"),style:{left:`${c[w]}%`,background:v.color},onPointerDown:E=>{E.currentTarget.setPointerCapture(E.pointerId),r(w)},onPointerMove:E=>{E.currentTarget.hasPointerCapture(E.pointerId)&&t(yS(e,w,h(E)))},onKeyDown:g(w)},w))})]}),p.jsxs(v4,{label:"Stops",children:[p.jsx("span",{className:"flex-1"}),p.jsx(Ps,{size:"sm",label:"Add stop",icon:p.jsx(fs,{className:"size-4",strokeWidth:1.5}),disabled:e.stops.length>=mS,title:e.stops.length>=mS?`${mS} stops at most.`:void 0,onClick:m})]}),p.jsx("div",{role:"list","aria-label":"Stops",className:"flex flex-col gap-1.5",children:e.stops.map((v,w)=>p.jsxs("div",{role:"listitem",className:ze("flex min-w-0 items-center gap-1.5 rounded-[8px]",w===o&&"bg-chrome-hover"),onFocus:()=>r(w),children:[p.jsx(kt,{"aria-label":`Stop ${w+1} position`,className:"w-[60px] shrink-0",value:Math.round(c[w]),unit:"%",min:0,max:100,steppers:!1,onCommit:E=>t(yS(e,w,E??c[w]))}),p.jsx("div",{className:"min-w-0 flex-1",children:p.jsx(gh,{"aria-label":`Stop ${w+1} color`,value:v.color,groups:s,onCommit:E=>E&&t({...e,stops:e.stops.map((M,S)=>S===w?{...M,color:E}:M)})})}),p.jsx(Ps,{size:"sm",label:`Remove stop ${w+1}`,icon:p.jsx(Ii,{className:"size-4",strokeWidth:1.5}),disabled:e.stops.length<=gS,title:e.stops.length<=gS?`A gradient needs ${gS} color stops.`:void 0,onClick:()=>b(w)})]},w))})]})}const Ove="A selected object’s opacity is set by an animation. Ask the agent to change the animation.",$ve="Add a border first",_ve="A shape draws one stroke all round",w4="A line is solid (a connector can dash)",S4="Not on diamond or arrow shapes",Lve="Inner shadow needs a fill or border on this text",bS=`At most ${ve.shadows} per element`,_f="#141413",p2=e=>e.kind==="rule"||e.kind==="shape"&&e.shape==="line",k4=e=>e.kind==="shape"||e.kind==="rule",Dve=e=>e.kind==="shape"&&(e.shape==="diamond"||e.shape.startsWith("arrow-"));function zve({target:e,label:t="Fill",gradients:n=!1,removable:s=!0}){const o=Hi(),r=Ut(e,"background"),i=r.value?ud(r.value):null,l=i?.ok?i.value:null,c=Ut(e,"background-clip").value==="text",u=y9(l),f=l?.color&&l.color!=="transparent"?l.color:null,h=!r.mixed&&!!(f||l?.gradient||l?.image),g=e.nodes.length>0&&e.nodes.every(w=>w.kind==="shape"&&!w.style.border),m=(w,E=t)=>{dt(e,"background",w?Hh(w):"",E,"fill")};if(c)return p.jsx(Be,{label:t,children:p.jsx(gh,{"aria-label":t,value:null,groups:o,preview:h2(l)??{swatch:f??"transparent",label:"Text fill"},disabled:!0,title:"This fill paints the letters — change it under Text › Color",onCommit:()=>{}})});const v=n||u==="gradient"?["color","gradient"]:[];return p.jsxs(Be,{label:t,children:[p.jsx(gh,{"aria-label":t,value:r.mixed?null:f,mixed:r.mixed,allowNone:!g,groups:o,preview:h2(l),onCommit:w=>m(w?{color:w}:null),kinds:v.length>1&&!r.mixed?{value:u,options:g9(v),onChange:w=>{w==="gradient"&&u!=="gradient"?m({gradient:b9(f)},"Gradient"):w==="color"&&u==="gradient"&&m({color:l?.gradient?.stops[0]?.color??_f})},content:l?.gradient?p.jsx(w9,{gradient:l.gradient,onChange:w=>m({gradient:w},"Gradient")}):null}:void 0}),s&&h?p.jsx(Ps,{label:t==="Background"?"Remove background":`Remove ${t.toLowerCase()}`,icon:p.jsx(Ii,{}),disabled:g,reason:g?$ve:void 0,onClick:()=>m(null)}):null]})}function Pve({target:e,lockedReason:t}){const n=Ut(e,"opacity"),[s,o]=C.useState(null),r=s??Math.round((n.value===void 0?1:Number(n.value))*100),i=l=>{dt(e,"opacity",l>=100?"":String(Math.max(0,l)/100),"Opacity","opacity")};return p.jsxs(Be,{label:"Opacity",tip:t,children:[p.jsx(kt,{"aria-label":"Opacity",className:"w-[72px] shrink-0",value:n.mixed?null:r,placeholder:"Mixed",unit:"%",min:0,max:100,disabled:!!t,title:t,onCommit:l=>l!==null&&i(l)}),p.jsx(gye,{"aria-label":"Opacity slider",value:r,min:0,max:100,disabled:!!t,onChange:l=>{o(l),i(l)},onCommit:l=>{o(null),i(l)}})]})}function Ive(e){const t=(e??"0").trim().split(/\s+/).map(i=>Number.parseFloat(i)||0),[n=0,s=n,o=n,r=s]=t;return[n,s,o,r]}function Bve({target:e}){const t=Ut(e,"border-radius"),n=(t.value??"").includes("%"),s=n?"%":"px",o=r=>{const i=r.every(l=>l===r[0])?r[0]?`${r[0]}${s}`:"":r.map(l=>`${l}${s}`).join(" ");dt(e,"border-radius",i,"Corner radius","radius")};return p.jsx(Wb,{label:"Radius",kind:"corners",values:t.mixed?null:Ive(t.value),unit:s,min:0,max:n?50:256,onCommit:o,onReset:t.value&&!t.mixed?()=>dt(e,"border-radius","","Corner radius"):void 0})}const S9=["border-top","border-right","border-bottom","border-left"];function E4(e){const t=l=>{const c=l?If(l,32):null;return c?.ok?c.value:null},n=t(e.border),s=S9.map(l=>t(e[l])??n),o=s.map(l=>l&&l.style!=="none"?l.width:0),r=s.find(l=>l&&l.style!=="none"&&l.width>0);if(!r)return null;const i=r.style==="dashed"||r.style==="dotted"?r.style:"solid";return{widths:o,style:i,color:r.color}}function Fve(e,t){const n={border:void 0,"border-top":void 0,"border-right":void 0,"border-bottom":void 0,"border-left":void 0};if(!e||e.widths.every(o=>o<=0))return n;const s=o=>Bf({width:o,style:e.style,color:e.color});return t||e.widths.every(o=>o===e.widths[0])?(n.border=s(Math.max(...e.widths)),n):(S9.forEach((o,r)=>{e.widths[r]>0&&(n[o]=s(e.widths[r]))}),n)}function xS(e){const t=e[0];return e.every(n=>JSON.stringify(n)===JSON.stringify(t))?t??null:null}function Hve({target:e}){const t=Hi(),s=(e.nodes.length?e.nodes.map(b=>b.style):[e.slide.style]).map(E4),o=e.nodes.length>0&&e.nodes.some(k4),r=e.nodes.length>0&&e.nodes.every(p2),i=b=>b?.style??"none",l=xS(s.map(i)),c=xS(s.map(b=>b?.color??null)),u=xS(s.map(b=>b?.widths??null)),f=s.some(Boolean),h=(b,v,w)=>{So(e,b,E=>Fve(v(E4(E?.style??e.slide.style)),E?k4(E):!1),w)},g=b=>{b==="none"?h("Remove border",()=>null):h("Border style",v=>({widths:v?.widths??[1,1,1,1],style:b,color:v?.color??_f}))},m=o?32:16;return p.jsxs(p.Fragment,{children:[p.jsx(Be,{label:"Border",onReset:f?()=>g("none"):void 0,resetLabel:"Remove border",children:p.jsx(Ls,{"aria-label":"Border",value:l,options:[{value:"none",label:"None",title:"No border",icon:p.jsx(pD,{strokeWidth:1.5})},{value:"solid",label:"Solid",title:"Solid",icon:p.jsx(kH,{})},{value:"dashed",label:"Dashed",title:"Dashed",icon:p.jsx(EH,{}),disabled:r,reason:w4},{value:"dotted",label:"Dotted",title:"Dotted",icon:p.jsx(CH,{}),disabled:r,reason:w4}],onChange:g})}),f?p.jsxs(p.Fragment,{children:[p.jsx(ap,{label:"Color","aria-label":"Border color",value:c,mixed:c===null,groups:t,onCommit:b=>b&&h("Border color",v=>v&&{...v,color:b},"border-color"),onReset:c&&c.toLowerCase()!==_f?()=>h("Border color",b=>b&&{...b,color:_f}):void 0}),p.jsx(Wb,{label:"Width",kind:"sides",values:u,unit:"px",min:0,max:m,toggleDisabledReason:o?_ve:void 0,onCommit:b=>h("Border width",v=>v?b.every(w=>w<=0)?{...v,widths:[1,1,1,1]}:{...v,widths:b}:{widths:b,style:"solid",color:_f},"border-width")})]}):null]})}function k9({target:e,fill:t=!0,fillLabel:n="Fill",gradients:s=!1,opacity:o=!0,radius:r=!0,border:i=!0,buildControlled:l=!1}){return!t&&!o&&!r&&!i?null:p.jsxs(os,{title:"Appearance",children:[t?p.jsx(zve,{target:e,label:n,gradients:s,removable:e.nodes.length>0}):null,o?p.jsx(Pve,{target:e,lockedReason:l?Ove:void 0}):null,r?p.jsx(Bve,{target:e}):null,i?p.jsx(Hve,{target:e}):null]})}const Uve={inset:!1,x:0,y:2,blur:8,spread:0,color:"#00000033"},Vve={inset:!0,x:0,y:1,blur:2,spread:0,color:"#00000033"},qve={inset:!1,x:0,y:1,blur:3,spread:0,color:"#00000033"},C4=4,vS=e=>String(Math.round(e*100)/100);function Wve(e){return`${vS(e.x)}, ${vS(e.y)} · ${vS(e.blur)}px`}function T4(e,t){const n=Ut(e,t),s=n.value&&!n.mixed?tk(n.value,t==="text-shadow"):null;return s?.ok?s.value:[]}function M4(e,t){const n=Ut(e,t),s=n.value&&!n.mixed?UE(n.value):null;return s?.ok?s.value:{}}function Gve(e){if(e.length===0)return null;const t=new Set(["box","text","list","textbox","image","table","icon","shape"]),n=new Set(["box","text","list","textbox","image","shape"]),s=e.every(i=>t.has(i.kind)&&!p2(i)),o=e.every(i=>n.has(i.kind)&&!p2(i));if(!s&&!o)return null;const r=e.some(Dve);return{box:s?r?S4:"":null,text:e.every(Va),filter:o,backdrop:r?S4:""}}function Yve({target:e}){const t=Gve(e.nodes);return t?p.jsx(Kve,{target:e,support:t}):null}function Kve({target:e,support:t}){const n=t.box!==null?T4(e,"box-shadow"):[],s=t.text?T4(e,"text-shadow"):[],o=t.filter?M4(e,"filter"):{},r=t.filter?M4(e,"backdrop-filter"):{},[i,l]=C.useState(null),c=(E,M,S)=>{dt(e,E,M.length?nk(M,E==="text-shadow"):"",S,E)},u=(E,M,S)=>{const R={...E==="filter"?o:r};M===null?delete R.blur:R.blur=M,dt(e,E,VE(R),S,E)},f=t.text&&e.nodes.every(E=>E.style.background||E.style.border),h=E=>E.length>=ve.shadows,g=t.text?s:n,m=t.text?h(s)?bS:"":t.box===null?null:t.box||(h(n)?bS:""),b=t.box===null?null:t.box||(t.text&&!f?Lve:h(n)?bS:""),v=p.jsxs(wo,{align:"end",tip:{label:"Add to Effects"},trigger:p.jsx("button",{type:"button","aria-label":"Add to Effects",className:"flex size-6 items-center justify-center rounded-[6px] text-chrome-secondary outline-none hover:bg-chrome-hover hover:text-chrome-fg focus-visible:ring-2 focus-visible:ring-chrome-accent",children:p.jsx(fs,{className:"size-4",strokeWidth:1.5})}),children:[m!==null?p.jsx(It,{disabled:m!=="",title:m||void 0,onSelect:()=>{t.text?c("text-shadow",[...s,qve],"Drop shadow"):c("box-shadow",[...n,Uve],"Drop shadow"),l(`${t.text?"text":"box"}-${g.length}`)},children:"Drop shadow"}):null,b!==null?p.jsx(It,{disabled:b!=="",title:b||void 0,onSelect:()=>{c("box-shadow",[...n,Vve],"Inner shadow"),l(`box-${n.length}`)},children:"Inner shadow"}):null,t.filter?p.jsxs(p.Fragment,{children:[p.jsx(It,{disabled:o.blur!==void 0,onSelect:()=>u("filter",C4,"Layer blur"),children:"Layer blur"}),p.jsx(It,{disabled:r.blur!==void 0||t.backdrop!=="",title:t.backdrop||void 0,onSelect:()=>u("backdrop-filter",C4,"Background blur"),children:"Background blur"})]}):null]}),w=(E,M)=>M.map((S,k)=>{const R=`${E==="text-shadow"?"text":"box"}-${k}`,N=E==="text-shadow"?"Drop shadow":S.inset?"Inner shadow":t.text?"Box shadow":"Drop shadow",O=A=>A?M.map(($,D)=>D===k?A:$):M.filter(($,D)=>D!==k);return p.jsxs(Be,{label:N,children:[p.jsx(Xve,{title:N,shadow:S,spread:E==="box-shadow",open:i===R,onOpenChange:A=>l(A?R:null),onChange:A=>c(E,O(A),N)}),p.jsx(Ps,{label:`Remove ${N.toLowerCase()}`,icon:p.jsx(Ii,{}),onClick:()=>c(E,O(null),`Remove ${N.toLowerCase()}`)})]},R)});return p.jsxs(os,{title:"Effects",actions:v,children:[t.text?w("text-shadow",s):null,t.box!==null?w("box-shadow",n):null,o.blur!==void 0?p.jsx(R4,{label:"Layer blur",value:o.blur,onCommit:E=>u("filter",E,"Layer blur")}):null,r.blur!==void 0?p.jsx(R4,{label:"Background blur",value:r.blur,onCommit:E=>u("backdrop-filter",E,"Background blur")}):null]})}function R4({label:e,value:t,onCommit:n}){return p.jsxs(Be,{label:e,children:[p.jsx(kt,{"aria-label":e,value:t,placeholder:"0",unit:"px",min:0,max:20,step:.5,onCommit:s=>s!==null&&n(s)}),p.jsx(Ps,{label:`Remove ${e.toLowerCase()}`,icon:p.jsx(Ii,{}),onClick:()=>n(null)})]})}function Xve({title:e,shadow:t,spread:n,open:s,onOpenChange:o,onChange:r}){const i=Hi(),l=c=>r({...t,...c});return p.jsxs(ET,{title:e,text:Wve(t),swatch:t.color,open:s,onOpenChange:o,children:[p.jsxs(Be,{label:"Offset",children:[p.jsx(kt,{"aria-label":"Horizontal offset",label:"X",value:t.x,min:-64,max:64,steppers:!1,onCommit:c=>c!==null&&l({x:c})}),p.jsx(kt,{"aria-label":"Vertical offset",label:"Y",value:t.y,min:-64,max:64,steppers:!1,onCommit:c=>c!==null&&l({y:c})})]}),p.jsx(Be,{label:"Blur",children:p.jsx(kt,{"aria-label":"Blur",value:t.blur,unit:"px",min:0,max:n?160:64,onCommit:c=>c!==null&&l({blur:c})})}),n?p.jsx(Be,{label:"Spread",children:p.jsx(kt,{"aria-label":"Spread",value:t.spread,unit:"px",min:-32,max:32,onCommit:c=>c!==null&&l({spread:c})})}):null,p.jsx(Be,{label:"Color",children:p.jsx(gh,{"aria-label":"Shadow color",value:t.color,groups:i,onCommit:c=>c&&l({color:c})})})]})}function Zve(e){return document.querySelector(`[data-open-artifact-stage] [data-open-artifact-path="${is(e)}"]`)}const wS=(e,t)=>Math.round(e*10**t)/10**t;function Qve(e){const t=getComputedStyle(e),n=Number.parseFloat(t.fontSize)||16,s=Number.parseFloat(t.lineHeight),o=Number.parseFloat(t.letterSpacing),r=t.textAlign==="start"?"left":t.textAlign==="end"?"right":t.textAlign;return{family:xh(t.fontFamily),weight:td(Number(t.fontWeight)||400),italic:t.fontStyle==="italic"||t.fontStyle.startsWith("oblique"),size:wS(n,1),lineHeight:Number.isFinite(s)?wS(s/n,2):null,letterSpacing:Number.isFinite(o)?wS(o,1):0,color:t.color,align:r}}const j4=(e,t)=>JSON.stringify(e)===JSON.stringify(t);function Jve(e){const t=ie(i=>i.revision),n=te(i=>i.textEdit!==null),s=e.map(is).join("|"),[o,r]=C.useState(null);return C.useLayoutEffect(()=>{const i=()=>{const u=e.map(Zve).map(g=>g?Qve(g):null),f=u[0],h=f&&u.every(g=>g&&j4(g,f))?f:null;r(g=>g&&h&&j4(g,h)?g:h)};i();const l=requestAnimationFrame(i),c=window.setTimeout(i,250);return()=>{cancelAnimationFrame(l),window.clearTimeout(c)}},[s,t,n]),o}const ewe=[["left","Left",TE],["center","Center",sP],["right","Right",rP],["justify","Justify",aP]],twe=[{value:"none",label:"None"},{value:"uppercase",label:"Uppercase"},{value:"lowercase",label:"Lowercase"},{value:"capitalize",label:"Capitalize"}],nwe=[{value:"shrink",label:"Shrink text to fit"},{value:"none",label:"Don’t resize text"},{value:"grow",label:"Grow box to fit text"}],A4="What happens when the text outgrows its box: shrink the text, leave it as it is, or grow the box.";function swe(e){return Va(e)||e.kind==="table"}function owe(e){return e?e==="bold"?700:e==="normal"?400:/^\d{3}$/.test(e)?Number(e):null:null}function rwe({target:e}){const t=e.nodes.length===0,n=!t&&e.nodes.every(L=>L.kind==="text"),s=PH(n?e.nodes:null),o=Jve(t?[]:e.paths),r=e.paths.map(L=>L.join(".")).join("|"),[i,l]=C.useState(new Set);if(C.useEffect(()=>l(new Set),[r]),!t&&!e.nodes.every(swe))return null;const c=Ut(e,"font-size"),u=Ut(e,"line-height"),f=Ut(e,"letter-spacing"),h=Ut(e,"text-transform"),g=Ut(e,"text-decoration"),m=Ut(e,"text-align"),b=g.mixed?null:/line-through/.test(g.value??"")?"line-through":/underline/.test(g.value??"")?"underline":null,v=!t&&e.nodes.every(L=>L.kind==="text"||L.kind==="list"),w=v?e.nodes.every(L=>L.kind==="list"&&L.tag==="ul")?"ul":e.nodes.every(L=>L.kind==="list"&&L.tag==="ol")?"ol":e.nodes.every(L=>L.kind==="text")?"none":null:null,E=!t,M=e.nodes.map(L=>L.fit??"shrink"),S=M.every(L=>L===M[0])?M[0]??"shrink":null,k=!t&&(i.has("emphasis")||g.mixed||b!==null),R=v&&(i.has("list")||e.nodes.some(L=>L.kind==="list")),N=i.has("case")||h.mixed||!!(h.value&&h.value!=="none"),O=L=>l(new Set([...i,L])),A=e.nodes.length,$=A>1?`${A} Text`:"Text",D=p.jsxs(wo,{align:"end",tip:{label:"Add to Text"},trigger:p.jsx("button",{type:"button","aria-label":"Add to Text",className:"flex size-6 items-center justify-center rounded-[6px] text-chrome-secondary outline-none hover:bg-chrome-hover hover:text-chrome-fg focus-visible:ring-2 focus-visible:ring-chrome-accent",children:p.jsx(fs,{className:"size-4",strokeWidth:1.5})}),children:[t?null:p.jsx(It,{disabled:k,onSelect:()=>O("emphasis"),children:"Emphasis"}),v?p.jsx(It,{disabled:R,onSelect:()=>O("list"),children:"List"}):null,p.jsx(It,{disabled:N,onSelect:()=>O("case"),children:"Case"})]}),z=!!(u.value||f.value),_=f.mixed||!f.value?null:f.value.endsWith("em")?Math.round(Number.parseFloat(f.value)*(o?.size??16)*10)/10:ic(f.value);return p.jsxs(os,{title:$,actions:D,children:[n?p.jsx(Be,{label:"Text style",children:p.jsx(Rs,{"aria-label":"Text style",icon:p.jsx(SH,{}),value:s.value,placeholder:s.mixed?"Mixed":"Custom",options:s.options.map(L=>({value:L.value,label:L.label,hint:L.hint,group:L.group,style:L.style})),valueStyle:{},onChange:s.apply})}):null,p.jsx(awe,{target:e,resolved:o,isSlide:t}),p.jsx(lwe,{target:e,resolved:o}),p.jsx(Be,{label:"Size",onReset:c.value&&!c.mixed?()=>dt(e,"font-size","","Font size"):void 0,children:p.jsx(kt,{"aria-label":"Font size",value:c.mixed?null:ic(c.value),unit:"px",min:8,max:400,placeholder:c.mixed?"Mixed":o?String(o.size):"Auto",inherited:!c.mixed,onCommit:L=>dt(e,"font-size",L===null?"":`${L}px`,"Font size")})}),p.jsx(Be,{label:"Spacing",tip:"Line height · Letter spacing",resetLabel:"Reset Spacing",onReset:z?()=>So(e,"Spacing",{"line-height":void 0,"letter-spacing":void 0}):void 0,children:p.jsxs("div",{className:"grid min-w-0 flex-1 grid-cols-2 gap-1.5",children:[p.jsx(kt,{"aria-label":"Line height",title:"Line height",label:p.jsx(iye,{}),value:u.mixed||!u.value?null:Number.parseFloat(u.value),step:.05,min:.5,max:4,steppers:!1,placeholder:u.mixed?"Mixed":o?.lineHeight!=null?String(o.lineHeight):"Auto",inherited:!u.mixed,onCommit:L=>dt(e,"line-height",L===null?"":String(L),"Line height")}),p.jsx(kt,{"aria-label":"Letter spacing",title:"Letter spacing (px)",label:p.jsx(aye,{}),value:_,step:.5,min:-24,max:32,steppers:!1,placeholder:f.mixed?"Mixed":String(o?.letterSpacing??0),inherited:!f.mixed,onCommit:L=>dt(e,"letter-spacing",L===null||L===0?"":`${L}px`,"Letter spacing")})]})}),p.jsx(dwe,{target:e,resolved:o}),k?p.jsxs(Be,{label:"Emphasis",onReset:b?()=>dt(e,"text-decoration","","Emphasis"):void 0,children:[p.jsx(Ps,{label:"Underline",icon:p.jsx(mP,{}),active:b==="underline",onClick:()=>dt(e,"text-decoration",b==="underline"?"":"underline","Underline")}),p.jsx(Ps,{label:"Strikethrough",icon:p.jsx(LK,{}),active:b==="line-through",onClick:()=>dt(e,"text-decoration",b==="line-through"?"":"line-through","Strikethrough")})]}):null,R?p.jsx(Be,{label:"List",children:p.jsx(Ls,{"aria-label":"List",value:w,options:[{value:"none",label:"None"},{value:"ul",label:"Bulleted"},{value:"ol",label:"Numbered"}],onChange:L=>ao("List",B=>B.kind==="text"||B.kind==="list"?F6(B,L==="none"?null:L):B)})}):null,p.jsx(Be,{label:"Align",onReset:m.value&&!m.mixed?()=>dt(e,"text-align","","Align"):void 0,children:p.jsx(Ls,{"aria-label":"Text alignment",value:m.mixed?null:m.value??o?.align??"left",options:ewe.map(([L,B,U])=>({value:L,title:B,label:p.jsx(U,{className:"size-4",strokeWidth:1.5})})),onChange:L=>dt(e,"text-align",L,"Align")})}),N?p.jsx(Be,{label:"Case",onReset:h.value&&!h.mixed?()=>dt(e,"text-transform","","Text case"):void 0,children:p.jsx(Rs,{"aria-label":"Text case",value:h.mixed?null:h.value??"none",placeholder:"Mixed",options:twe,onChange:L=>dt(e,"text-transform",L==="none"?"":L,"Text case")})}):null,E?p.jsx(Be,{label:"Resize",tip:A4,children:p.jsx(Rs,{"aria-label":"Resize",title:A4,value:S,placeholder:"Mixed",options:nwe,onChange:L=>ao("Resize",B=>{const{fit:U,...I}=B;return L==="shrink"?I:{...I,fit:L}})})}):null]})}function iwe(e){if(!e)return"";const t=xh(e);if(!t)return"";const n=t.toLowerCase(),s=a2.find(o=>o.key===n);return s?s.key:`face:${n}`}function awe({target:e,resolved:t,isSlide:n}){const s=ie(M=>M.index.faces),[o,r]=C.useState(!1),[i,l]=C.useState(""),c=Ut(e,"font-family"),u=c.mixed?null:iwe(c.value),f=C.useMemo(()=>Iye(),[s,o]),h=C.useMemo(()=>{const M=Object.values(s).map(A=>A.family),S=new Set(M.map(A=>A.toLowerCase())),k=[{key:"",label:n?"System font":"Style default",css:""}];for(const A of M)k.push({key:`face:${A.toLowerCase()}`,label:A,css:wg(A),preview:wg(A)});const R=c.mixed?null:xh(c.value);R&&!(A=>S.has(A.toLowerCase())||a2.some($=>$.key===A.toLowerCase())||!!ed(A)||ty.some($=>$.family.toLowerCase()===A.toLowerCase()))(R)&&k.push({key:`face:${R.toLowerCase()}`,label:R,css:c.value,preview:c.value});for(const A of a2)k.push({key:A.key,label:A.label,css:A.css,preview:A.css});const O=[...ty.map(A=>({family:A.family,google:!1})),...Gb.map(A=>({family:A.family,google:!0}))].filter(A=>!S.has(A.family.toLowerCase())).sort((A,$)=>A.family.localeCompare($.family));for(const A of O)k.push({key:`face:${A.family.toLowerCase()}`,label:A.family,css:wg(A.family),preview:wg(A.family),google:A.google,disabled:A.google&&!f});return k},[s,c.value,c.mixed,n,f]),g=i.trim().toLowerCase(),m=g?h.filter(M=>M.label.toLowerCase().includes(g)):h,b=h.find(M=>M.key===u),v=t?.family&&!/^(?:system-ui|-apple-system|blinkmacsystemfont)$/i.test(t.family)?t.family:"System font",w=c.mixed?"Mixed":u?b?.label??xh(c.value)??"":t?v:n?"System font":"Style default",E=M=>{if(r(!1),l(""),M.google){const S=ed(M.label);P5(e,M.css,n9(S))}else P5(e,M.css,null)};return p.jsx(Be,{label:"Font",onReset:c.value&&!c.mixed?()=>dt(e,"font-family","","Font"):void 0,children:p.jsxs(Uy,{open:o,onOpenChange:M=>{r(M),M?Bxe():l("")},children:[p.jsxs(Vy,{"aria-label":`Font: ${w}`,className:ze(yd,"flex w-full min-w-0 cursor-default items-center gap-1.5 pl-2 pr-[5px] text-left data-[popup-open]:shadow-[inset_0_0_0_1px_var(--color-chrome-accent)]"),children:[p.jsx("span",{className:ze("min-w-0 flex-1 truncate",c.mixed?"text-chrome-muted":!u&&"text-chrome-secondary"),children:w}),p.jsx(Go,{className:"size-4 shrink-0 text-chrome-muted",strokeWidth:1.5})]}),p.jsx(qy,{children:p.jsx(Wy,{side:"bottom",align:"end",sideOffset:4,collisionPadding:8,className:"z-[1000]",children:p.jsxs(Gy,{className:"flex w-64 flex-col overflow-hidden rounded-[14px] bg-chrome text-chrome-fg shadow-chrome-popup outline-none",children:[p.jsx("div",{className:"p-2 pb-1",children:p.jsx(qb,{autoFocus:!0,"aria-label":"Search fonts",placeholder:"Search fonts",value:i,onChange:M=>l(M.target.value)})}),p.jsxs("div",{role:"listbox","aria-label":"Fonts",className:"max-h-80 overflow-y-auto p-1.5 pt-1",children:[m.map(M=>p.jsxs("button",{type:"button",role:"option","aria-selected":M.key===u,disabled:M.disabled,title:M.disabled?DH:void 0,onClick:()=>E(M),className:"flex h-7 w-full cursor-default items-center gap-2 rounded-[8px] pl-2 pr-2.5 text-left text-[13px] outline-none hover:bg-chrome-hover focus-visible:bg-chrome-hover disabled:opacity-40",children:[p.jsx("span",{className:"flex size-4 shrink-0 items-center justify-center",children:M.key===u?p.jsx(Pi,{className:"size-4 text-chrome-accent",strokeWidth:2.25}):null}),p.jsx("span",{className:"min-w-0 flex-1 truncate",style:M.preview?{fontFamily:M.preview}:void 0,children:M.label})]},M.key||"default")),m.length===0?p.jsx("p",{className:"px-2 py-2 text-[12px] text-chrome-muted",children:"No matches"}):null]})]})})})]})})}function lwe({target:e,resolved:t}){const n=Ut(e,"font-family"),s=Ut(e,"font-weight"),o=Ut(e,"font-style"),r=s.mixed||o.mixed,i=s.value!==void 0||o.value!==void 0,l=t?{weight:t.weight,italic:t.italic}:null,c=i?{weight:owe(s.value)??l?.weight??400,italic:o.value==="italic"}:null,u=(n.mixed?null:xh(n.value))??t?.family??null,f=Vxe(u,c??l).map(h=>({value:c4(h),label:l4(h)}));return p.jsx(Be,{label:"Weight",onReset:i&&!r?()=>So(e,"Font weight",{"font-weight":void 0,"font-style":void 0}):void 0,children:p.jsx(Rs,{"aria-label":"Weight",value:r||!c?null:c4(c),placeholder:r?"Mixed":l?l4(l):"Regular",inherited:!r,options:f,onChange:h=>{const g=Hxe(h);g&&So(e,"Font weight",{"font-weight":String(g.weight),"font-style":g.italic?"italic":void 0})}})})}const cwe={"background-clip":"text","-webkit-text-fill-color":"transparent"},N4={background:void 0,"background-clip":void 0,"-webkit-text-fill-color":void 0},uwe="repeating-conic-gradient(#ddd 0 25%, #fff 0 50%) 0 0 / 8px 8px";function dwe({target:e,resolved:t}){const n=Hi(),s=Ut(e,"color"),o=Ut(e,"background"),r=Ut(e,"background-clip"),i=e.nodes.length>0&&e.nodes.every(k=>Va(k)),l=!r.mixed&&r.value==="text",c=l&&!o.mixed&&o.value?ud(o.value):null,u=c?.ok?c.value:null,f=l?y9(u):"color",[h,g]=C.useState(null),m=h??f;C.useEffect(()=>g(null),[f]);const b=(k,R,N)=>{So(e,R,{background:Hh(k),...cwe},N)},v=k=>{k==="color"?(g(null),l&&So(e,"Text fill",N4)):k==="gradient"?(g(null),b({gradient:u?.gradient??b9(s.value??t?.color)},"Gradient text")):g("image")},w=m==="gradient"&&u?.gradient?p.jsx(w9,{gradient:u.gradient,onChange:k=>b({gradient:k},"Text gradient","text-gradient")}):m==="image"?p.jsx(Ave,{image:u?.image??null,onImage:k=>b({image:k},"Picture text")}):null,E=m==="color"?null:h2(u)??{swatch:uwe,label:m==="image"?"Image":"Linear"},M=s.mixed?null:s.value??null,S=m==="color"&&!s.mixed?FH(e,{kind:"text",color:M??t?.color??null,...t?{size:t.size,weight:t.weight}:{}}):null;return p.jsx(ap,{label:"Color","aria-label":"Text color",value:M,mixed:s.mixed,effective:t?.color??null,emptyLabel:"Theme default",groups:n,preview:E,contrast:S,onReset:M?()=>dt(e,"color","","Text color"):void 0,onCommit:k=>{g(null),So(e,"Text color",{color:k??void 0,...l?N4:{}},"text-color")},...i?{kinds:{value:m,options:g9(["color","gradient","image"]),onChange:k=>v(k),content:w}}:{}})}const m2="open-artifact-slides:properties-width",ny=304,E9=285;function C9(){return Math.min(560,window.innerWidth-120)}function Kg(e){return Math.round(Math.max(E9,Math.min(C9(),e)))}function fwe(){try{const e=Number(localStorage.getItem(m2));return e?Kg(e):ny}catch{return ny}}function hwe(e){try{e===ny?localStorage.removeItem(m2):localStorage.setItem(m2,String(e))}catch{}}function pwe(){const[e,t]=C.useState(fwe),n=C.useRef(null);C.useEffect(()=>{const u=()=>t(f=>Kg(f));return window.addEventListener("resize",u),()=>window.removeEventListener("resize",u)},[]);const s=u=>{const f=Kg(u);t(f),hwe(f)},o=u=>{u.button===0&&(u.preventDefault(),u.currentTarget.setPointerCapture(u.pointerId),n.current={x:u.clientX,width:e})},r=u=>{n.current&&t(Kg(n.current.width+n.current.x-u.clientX))},i=u=>{n.current&&(s(n.current.width+n.current.x-u.clientX),n.current=null)},l=u=>{const f=u.shiftKey?48:16;if(u.key==="ArrowLeft")s(e+f);else if(u.key==="ArrowRight")s(e-f);else return;u.preventDefault()},c=p.jsx("div",{role:"separator","aria-orientation":"vertical","aria-label":"Resize the properties panel","aria-valuenow":e,"aria-valuemin":E9,"aria-valuemax":C9(),tabIndex:0,title:"Drag to resize. Double-click to reset.",onPointerDown:o,onPointerMove:r,onPointerUp:i,onPointerCancel:i,onDoubleClick:()=>s(ny),onKeyDown:l,className:"group absolute inset-y-0 -left-1 z-10 flex w-2 cursor-col-resize justify-center outline-none",children:p.jsx("span",{className:"h-full w-px bg-transparent transition-colors group-hover:bg-chrome-accent group-focus-visible:bg-chrome-accent group-active:bg-chrome-accent"})});return{width:e,handle:c}}const mwe={none:"None",fade:"Fade",push:"Push",magic:"Magic move"},O4="How this slide leaves for the next one in Present",gwe="Magic move animates elements this slide shares with the next one into their new place. Duplicate the slide, then move or resize — duplicates keep the element identity that pairs them up.",T9="open-artifact-slides:properties-tab";function ywe(){try{return localStorage.getItem(T9)==="theme"?"theme":"properties"}catch{return"properties"}}function bwe(){const[e,t]=C.useState(ywe);return[e,s=>{t(s);try{localStorage.setItem(T9,s)}catch{}}]}function xwe(){const{slide:e,slideId:t,readOnly:n,paths:s,nodes:o}=Ib(),{width:r,handle:i}=pwe(),[l,c]=bwe(),u=C.useMemo(()=>e?{slide:e,paths:o.length?s:[[]],nodes:o}:null,[e,s,o]);let f=null;return n?f=p.jsx(hi,{className:"py-4",children:"This presentation is read-only here, so its properties can’t be edited."}):e&&u&&t&&(f=o.length===0?p.jsx(vwe,{target:u}):p.jsxs(p.Fragment,{children:[p.jsx(wwe,{target:u,nodes:o}),p.jsx(sve,{target:u})]})),p.jsxs("aside",{"data-open-artifact-properties":!0,"aria-label":"Properties",style:{width:r},className:"relative flex h-full shrink-0 flex-col border-l border-chrome-sep bg-chrome text-chrome-fg",children:[i,p.jsx("div",{className:"shrink-0 border-b border-chrome-sep px-3 py-2",children:p.jsx(Ls,{"aria-label":"Panel",value:l,options:[{value:"properties",label:"Properties"},{value:"theme",label:"Theme"}],onChange:c})}),p.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto overflow-x-hidden overscroll-contain pb-1",children:l==="theme"?p.jsx(nve,{}):f})]})}function vwe({target:e}){const{slide:t}=e;return p.jsxs(p.Fragment,{children:[p.jsx(os,{title:"Slide",children:p.jsx(Be,{label:"Transition",tip:O4,children:p.jsx(Rs,{"aria-label":"Transition",title:O4,value:t.transition??"none",options:["none",...PE].map(n=>({value:n,label:mwe[n]})),onChange:n=>jn("Transition",s=>Gse(s,n==="none"?void 0:n))})})}),p.jsx(k9,{target:e,fillLabel:"Background",opacity:!1,radius:!1,border:!1}),p.jsx(hi,{className:"pt-3",children:gwe})]})}function wwe({target:e,nodes:t}){const n=new Set(t.map(c=>c.kind)),s=n.size===1?[...n][0]:null,o=t.every(c=>c.kind==="rule"||c.kind==="shape"&&c.shape==="line"),r=t.every(Va),i=t.some(c=>c.kind==="shape"),l=s==="connector"?null:p.jsx(k9,{target:e,fill:!o,gradients:!i&&s!=="icon",radius:!o&&s!=="icon"&&s!=="svg"&&!t.some(c=>c.kind==="shape"&&c.shape!=="rect"&&c.shape!=="rounded"),border:!o&&s!=="svg"&&s!=="embed",buildControlled:t.some(c=>c.buildIn||c.buildOut)});return p.jsxs(p.Fragment,{children:[p.jsx(yve,{target:e}),p.jsx(Cve,{target:e}),p.jsx(Xye,{target:e}),p.jsx(abe,{target:e}),p.jsx(obe,{target:e}),p.jsx(rbe,{target:e}),p.jsx(ebe,{target:e}),p.jsx(tbe,{target:e}),r?null:l,p.jsx(rwe,{target:e}),r?l:null,p.jsx(Yve,{target:e})]})}const Swe="open-artifact-slides-speaker",M9="open-artifact-speaker-root",R9='style, link[rel="stylesheet"]';function kwe(){const e=window.open("",Swe,"popup,width=1100,height=720");if(!e)return null;const t=e.document;t.title="Speaker notes",t.head.replaceChildren(),t.body.replaceChildren();const n=t.createElement("meta");n.setAttribute("charset","utf-8"),t.head.appendChild(n);for(const r of document.head.querySelectorAll(R9))t.head.appendChild(t.importNode(r,!0));jb(t);const s=document.documentElement.getAttribute("data-theme");s?t.documentElement.setAttribute("data-theme",s):t.documentElement.removeAttribute("data-theme"),t.body.className="m-0 bg-canvas text-fg antialiased";const o=t.createElement("div");return o.id=M9,o.className="h-screen",t.body.appendChild(o),e}function Ewe(e){const t=Math.max(0,Math.floor(e/1e3)),n=Math.floor(t/3600),s=Math.floor(t%3600/60),o=String(t%60).padStart(2,"0");return n?`${n}:${String(s).padStart(2,"0")}:${o}`:`${s}:${o}`}function SS({slide:e,done:t,width:n}){const s=C.useMemo(()=>ec(e),[e]),o=C.useMemo(()=>AC(e,s,t,!1),[e,s,t]),r=C.useMemo(()=>({mode:"thumb",resolveSrc:Ds,builds:o}),[o]),i=n/Xe;return p.jsx("div",{className:"relative overflow-hidden rounded-md bg-white ring-1 ring-line",style:{width:n,height:ft*i},children:p.jsx("div",{className:"pointer-events-none absolute left-0 top-0 origin-top-left",style:{width:Xe,height:ft,transform:`scale(${i})`},children:p.jsx(Ka,{slide:e,options:r})})})}function Cwe({popup:e,onClosed:t,...n}){const s=e.document.getElementById(M9),o=ie(r=>r.index.faces);return C.useEffect(()=>{np(o,Ds,e.document)},[o,e]),C.useEffect(()=>{const r=new MutationObserver(i=>{for(const l of i)for(const c of l.addedNodes)c instanceof Element&&c.matches(R9)&&!c.hasAttribute("data-open-artifact-face")&&e.document.head.appendChild(e.document.importNode(c,!0))});return r.observe(document.head,{childList:!0}),()=>r.disconnect()},[e]),C.useEffect(()=>{const r=setInterval(()=>{e.closed&&t()},500);return()=>clearInterval(r)},[e,t]),s?Wn.createPortal(p.jsx(Twe,{popup:e,...n}),s):null}function Twe({popup:e,position:t,index:n,count:s,steps:o,nextId:r,clock:i,onClock:l,onNext:c,onPrevious:u}){const f=ie(A=>A.slides[t.id]?.slide),h=ie(A=>r?A.slides[r]?.slide:void 0),[g,m]=C.useState(Date.now()),[b,v]=C.useState(e.innerWidth),[w,E]=C.useState(20);if(C.useEffect(()=>{const A=setInterval(()=>m(Date.now()),500),$=()=>v(e.innerWidth);return e.addEventListener("resize",$),()=>{clearInterval(A),e.removeEventListener("resize",$)}},[e]),!f)return null;const M=i.pausedAt!==null,S=(i.pausedAt??g)-i.startedAt,k=t.done<o,R=k?`Next: build ${t.done+1} of ${o}`:h?`Next: slide ${n+2}`:"End of presentation",N=Math.max(240,Math.floor(b*.56)-32),O=Math.max(160,b-N-72);return p.jsxs("div",{className:"flex h-full flex-col gap-3 p-4",children:[p.jsxs("header",{className:"flex items-center gap-3",children:[p.jsxs("span",{className:"text-sm font-medium tabular-nums",children:["Slide ",n+1," of ",s]}),p.jsx("span",{className:"flex-1"}),p.jsx("span",{className:ze("font-mono text-2xl tabular-nums",M&&"text-fg-muted"),"aria-label":"Elapsed time",children:Ewe(S)}),p.jsx(Cs,{noTooltip:!0,label:M?"Resume timer":"Pause timer",icon:M?p.jsx(sh,{className:"size-4"}):p.jsx(kK,{className:"size-4"}),onClick:()=>l(M?{startedAt:i.startedAt+(Date.now()-i.pausedAt),pausedAt:null}:{startedAt:i.startedAt,pausedAt:Date.now()})}),p.jsx(Cs,{noTooltip:!0,label:"Reset timer",icon:p.jsx(vi,{className:"size-4"}),onClick:()=>l({startedAt:Date.now(),pausedAt:M?Date.now():null})})]}),p.jsxs("div",{className:"flex min-h-0 flex-1 gap-6",children:[p.jsxs("div",{className:"flex min-w-0 flex-col gap-3",style:{width:N},children:[p.jsx(SS,{slide:f,done:t.done,width:N}),p.jsxs("div",{className:"flex min-h-0 flex-1 flex-col rounded-md border border-line bg-surface",children:[p.jsxs("div",{className:"flex items-center gap-1 border-b border-line px-3 py-1 text-xs text-fg-muted",children:[p.jsx("span",{className:"flex-1",children:"Speaker notes"}),p.jsx(bt,{size:"sm",variant:"ghost","aria-label":"Smaller notes",onClick:()=>E(A=>Math.max(12,A-2)),children:"A−"}),p.jsx(bt,{size:"sm",variant:"ghost","aria-label":"Larger notes",onClick:()=>E(A=>Math.min(48,A+2)),children:"A+"})]}),p.jsx("div",{className:"min-h-0 flex-1",style:{fontSize:w},children:p.jsx(ST,{slideId:t.id,className:"h-full w-full resize-none bg-transparent px-3 py-2 leading-relaxed text-fg outline-none placeholder:text-fg-subtle [font-size:inherit]"},t.id)})]})]}),p.jsxs("div",{className:"flex min-w-0 flex-col gap-2",style:{width:O},children:[p.jsx("div",{className:"text-xs font-medium text-fg-muted",children:R}),k?p.jsx(SS,{slide:f,done:t.done+1,width:O}):h?p.jsx(SS,{slide:h,done:0,width:O}):p.jsx("div",{className:"flex items-center justify-center rounded-md border border-dashed border-line text-xs text-fg-subtle",style:{width:O,height:O*9/16},children:"End of presentation"}),p.jsxs("div",{className:"mt-2 flex gap-2",children:[p.jsx(bt,{icon:p.jsx(xE,{className:"size-4"}),disabled:n===0&&t.done===0,onClick:u,children:"Previous"}),p.jsxs(bt,{variant:"primary",disabled:!k&&!h,onClick:c,children:["Next",p.jsx(Fy,{className:"size-4"})]})]})]})]})]})}const kg="cubic-bezier(0.33, 0.01, 0.2, 1)";function g2(){return typeof matchMedia<"u"&&matchMedia("(prefers-reduced-motion: reduce)").matches}function Mwe(e,t,n){const s=n>0?e.transition:t.transition;return s&&PE.includes(s)?s:null}function $4(e){const t=new Map;return e.slide.children.forEach((n,s)=>{if(!n.id)return;const o=e.root.querySelector(`[data-open-artifact-path="${s}"]`);o&&t.set(n.id,o)}),t}const _4=e=>({x:e.left+e.width/2,y:e.top+e.height/2});function Rwe(e,t,n,s,o){const r=RB[e],i=[];if(e==="push")i.push(t.root.animate([{transform:"translateX(0)"},{transform:`translateX(${-s*Xe}px)`}],{duration:r,easing:kg,fill:"forwards"}),n.root.animate([{transform:`translateX(${s*Xe}px)`},{transform:"translateX(0)"}],{duration:r,easing:kg}));else if(e==="magic"){const u=$4(t);for(const[f,h]of $4(n)){const g=u.get(f);if(!g)continue;const m=g.getBoundingClientRect(),b=h.getBoundingClientRect();if(!m.width||!m.height||!b.width||!b.height)continue;const v=_4(m),w=_4(b),E=(v.x-w.x)/o,M=(v.y-w.y)/o,S=m.width/b.width,k=m.height/b.height;i.push(h.animate([{translate:`${E}px ${M}px`,scale:`${S} ${k}`},{translate:"0px 0px",scale:"1 1"}],{duration:r,easing:kg}),g.animate([{translate:"0px 0px",scale:"1 1"},{translate:`${-E}px ${-M}px`,scale:`${1/S} ${1/k}`}],{duration:r,easing:kg,fill:"forwards"}))}i.push(n.root.animate([{opacity:0},{opacity:1}],{duration:r,easing:"ease"}))}else i.push(n.root.animate([{opacity:0},{opacity:1}],{duration:r,easing:"ease"}));const l=()=>{for(const u of i)try{u.finish()}catch{}};return{done:Promise.all(i.map(u=>u.finished.catch(()=>{}))).then(()=>{for(const u of i)u.cancel()}),finish:l}}const L4="open-artifact-deck-motion";let kS;function jwe(){const e=f8()?.sheet.motion??[];if(kS?.rules!==e){kS={rules:e,read:$B(e)};let t=document.getElementById(L4);t||(t=document.createElement("style"),t.id=L4,document.head.append(t)),t.textContent=e.join(`
661
- `)}return kS.read}function D4(e,t){const n=new Map,s=e.querySelector("[data-open-artifact-slide]");s&&n.set(0,{element:s});const o=(r,i)=>{r.forEach((l,c)=>{const u=[...i,c];if(l.origin!==void 0){const h=e.querySelector(`[data-open-artifact-path="${u.join(".")}"]`);h&&n.set(l.origin,{element:h,node:l})}const f=l.children;Array.isArray(f)&&o(f,u)})};return o(t.children,[]),n}function Awe(e,t,n,s){const o=t.motion;C.useLayoutEffect(()=>{const i=e.current;if(!s||!o||!i||g2())return;const l=jwe(),c=D4(i,t),u=[];let f="";const h=`open-artifact-start-${Math.random().toString(36).slice(2,8)}`,g=new Set([...Object.keys(o.elements),...Object.keys(o.starting)].map(Number));for(const b of g){const v=c.get(b);if(!v||v.node?.buildIn||v.node?.buildOut)continue;const w=o.elements[b]??{},{animation:E,keyframes:M,count:S}=_B(w,o.starting[b],l,`${h}-${b}`);if(!E)continue;f+=M;const k=v.element;k.style.animation=E;const R=S?xle(k,S):void 0;u.push(()=>{k.style.animation="",R?.()})}let m;return f&&(m=document.createElement("style"),m.textContent=f,document.head.append(m)),()=>{for(const b of u)b();m?.remove()}},[e,t,o,s]);const r=C.useMemo(()=>[...n].sort((i,l)=>i-l).join(","),[n]);C.useLayoutEffect(()=>{const i=e.current;if(!i||!o?.fragments.length)return;const l=D4(i,t),c=g2()?"":`opacity ${dh}ms ease`;for(const u of o.fragments){const f=l.get(u.origin)?.element;f&&(f.style.transition=c,f.style.opacity=n.has(u.origin)?"0":"")}},[e,t,o,r])}function Nwe(e){return e.parent!==e&&e.location.hash===Oee}function Owe(e,t){const n=e.filter(s=>!t(s));return n.length>0?n:[...e]}function $we(e,t,n){return t&&e.includes(t)?t:e.length===0?null:e[Math.min(Math.max(n,0),e.length-1)]}function j9(e,t,n){const s=`${e+1} / ${t}`,o=`Slide ${e+1} of ${t}`;return{counter:s,announcement:n?`${o}: ${n}`:o}}const _we=3e3;function z4({slide:e,done:t,animate:n,scale:s,rootRef:o,startedClips:r,onStartClip:i,className:l,motion:c=!1}){const u=C.useMemo(()=>ec(e),[e]),f=C.useMemo(()=>AC(e,u,t,n),[e,u,t,n]),h=C.useMemo(()=>ile(e,u,t),[e,u,t]),g=C.useMemo(()=>({mode:"present",resolveSrc:Ds,builds:f,startedClips:r,onStartClip:i}),[f,r,i]),m=C.useRef(null);return Awe(m,e,h,c),p.jsx("div",{ref:m,className:ze("absolute left-1/2 top-1/2",l),style:{width:Xe*s,height:ft*s,translate:"-50% -50%"},children:p.jsx("div",{className:"origin-top-left overflow-hidden",style:{width:Xe,height:ft,transform:`scale(${s})`},children:p.jsx(Ka,{slide:e,options:g,rootRef:o})})})}function Lwe(){const e=te(s=>s.presenting),t=te(s=>s.presentRun);if(!e)return null;const n=e.only===!0;return p.jsx(zwe,{start:e.start,speaker:e.speaker&&!n,only:n},t)}function P4(e){const t=ie.getState().slides[e]?.slide;return t?ec(t).length:0}function Dwe(e){const t=e.style.background;return t&&!t.includes("url(")?t:void 0}function zwe({start:e,speaker:t,only:n}){const s=ie(bb(()=>mi())),[o,r]=C.useState(()=>({id:e,done:n?P4(e):0,animate:!1})),i=Math.max(0,s.indexOf(o.id)),l=ie(Y=>Y.slides[o.id]?.slide),c=C.useMemo(()=>l?ec(l):[],[l]),[u,f]=C.useState(null),[h,g]=C.useState(()=>new Set),[m,b]=C.useState(!0),[v,w]=C.useState(!1),[E,M]=C.useState(!1),[S,k]=C.useState(null),[R,N]=C.useState(()=>({startedAt:Date.now(),pausedAt:null})),O=C.useRef(null),A=C.useRef(null),$=C.useRef(null),D=C.useRef(null),z=C.useRef(null),[_,L]=C.useState({w:window.innerWidth,h:window.innerHeight}),B=t&&E,U=B?_.h*.72:_.h,I=Math.min(_.w/Xe,U/ft);C.useEffect(()=>{xk(o.id,n?{position:i+1,count:s.length}:void 0)},[o.id,n,i,s.length]),C.useEffect(()=>{if(s.length===0){te.getState().present(null);return}if(!s.includes(o.id)){const Y=s[Math.min(i,s.length-1)];r({id:Y,done:n?P4(Y):0,animate:!1})}},[s,o.id,i,n]);const F=C.useCallback((Y,se,le={})=>{const re=mi()[Y];if(!re||re===o.id)return;D.current?.();const he=ie.getState(),Se=he.slides[o.id]?.slide,Oe=he.slides[re]?.slide;if(!Oe)return;const Ie=le.allDone?ec(Oe).length:0,Ne=!le.cut&&Se&&!g2()?Mwe(Se,Oe,se):null;f(Ne&&Se?{slide:Se,done:o.done,direction:se,kind:Ne}:null),g(new Set),r({id:re,done:Ie,animate:!1})},[o]),V=C.useCallback(()=>{if(u){D.current?.();return}if(n){i<s.length-1&&F(i+1,1,{allDone:!0});return}if(o.done<c.length){r(Y=>({...Y,done:Y.done+1,animate:!0}));return}i<s.length-1&&F(i+1,1)},[u,n,o.done,c.length,i,s.length,F]),W=C.useCallback(()=>{if(u&&D.current?.(),n){i>0&&F(i-1,-1,{allDone:!0});return}if(o.done>0){r(Y=>({...Y,done:Y.done-1,animate:!1}));return}i>0&&F(i-1,-1,{allDone:!0})},[u,n,o.done,i,F]),K=C.useCallback(()=>{const Y=o.id;document.fullscreenElement&&document.exitFullscreen().catch(()=>{}),te.getState().present(null),te.getState().showSlide(Y),xk(Y)},[o.id]);C.useEffect(()=>{if(u||!c[o.done]?.auto)return;const se=setTimeout(()=>r(le=>le.id===o.id?{...le,done:le.done+1,animate:!0}:le),o.done===0?0:dh);return()=>clearTimeout(se)},[u,c,o.id,o.done]),C.useLayoutEffect(()=>{if(!u||!$.current||!A.current||!l)return;const Y=Rwe(u.kind,{slide:u.slide,root:$.current},{slide:l,root:A.current},u.direction,I);let se=!0;return D.current=Y.finish,Y.done.then(()=>{se&&(D.current=null,f(null))}),()=>{se=!1}},[u]);const H=C.useRef({text:"",timer:null}),G=C.useCallback(Y=>{if(Y.target?.closest('textarea, input, [contenteditable="true"]')||Y.metaKey||Y.ctrlKey||Y.altKey)return;const le=Y.key;if(/^[0-9]$/.test(le)){const me=H.current;me.text=(me.text+le).slice(-3),me.timer&&clearTimeout(me.timer),me.timer=setTimeout(()=>{const re=Number(me.text);me.text="",re>=1&&re<=mi().length&&F(re-1,re-1>=i?1:-1,{cut:!0,allDone:n})},500);return}switch(le){case"ArrowRight":case"ArrowDown":case"PageDown":case" ":case"Enter":case"n":Y.preventDefault(),V();return;case"ArrowLeft":case"ArrowUp":case"PageUp":case"Backspace":case"p":Y.preventDefault(),W();return;case"Home":Y.preventDefault(),F(0,-1,{cut:!0,allDone:n});return;case"End":Y.preventDefault(),F(mi().length-1,1,{cut:!0,allDone:!0});return;case"f":case"F":if(n)return;Y.preventDefault(),I4(O.current);return;case"Escape":Y.preventDefault(),K();return}},[V,W,F,K,i,n]);C.useEffect(()=>(window.addEventListener("keydown",G),S?.addEventListener("keydown",G),()=>{window.removeEventListener("keydown",G),S?.removeEventListener("keydown",G)}),[G,S]),C.useEffect(()=>{const Y=()=>L({w:window.innerWidth,h:window.innerHeight}),se=()=>w(!!document.fullscreenElement);return window.addEventListener("resize",Y),document.addEventListener("fullscreenchange",se),!n&&O.current?.requestFullscreen&&!document.fullscreenElement&&O.current.requestFullscreen().catch(()=>{}),()=>{window.removeEventListener("resize",Y),document.removeEventListener("fullscreenchange",se)}},[n]);const X=C.useRef(null),Z=C.useCallback(()=>{b(!0),X.current&&clearTimeout(X.current),X.current=setTimeout(()=>b(!1),_we)},[]);C.useEffect(()=>(Z(),()=>{X.current&&clearTimeout(X.current)}),[Z]);const Q=C.useCallback(()=>{if(S&&!S.closed){S.focus();return}const Y=kwe();if(!Y){M(!0),Ke.add({title:"The speaker window was blocked",description:"Speaker notes show under the slide instead. Allow pop-ups for this site to open them in their own window."});return}M(!1),k(Y)},[S]);C.useEffect(()=>{t&&Q()},[]),C.useEffect(()=>()=>S?.close(),[S]);const ne=C.useCallback(Y=>g(se=>new Set([...se,Y])),[]);if(!l)return null;const J=s[i+1]??null;return p.jsxs("div",{ref:O,role:n?"group":"dialog","aria-modal":n?void 0:!0,"aria-label":n?j9(i,s.length,Mi(l)).announcement:"Presentation",tabIndex:n?0:void 0,"data-presenter-only":n?"":void 0,className:ze("fixed inset-0 z-[2000] select-none overflow-hidden",n?"outline-none focus-visible:outline-2 focus-visible:-outline-offset-4 focus-visible:outline-accent":"bg-black",!m&&!n&&"cursor-none"),style:n?{background:Dwe(l)??"#000"}:void 0,onPointerMove:n?void 0:Z,onPointerDown:Y=>{z.current={x:Y.clientX,y:Y.clientY}},onPointerUp:Y=>{const se=z.current;if(z.current=null,!se)return;const le=Y.clientX-se.x;Y.pointerType!=="mouse"&&Math.abs(le)>50&&Math.abs(le)>Math.abs(Y.clientY-se.y)&&(le<0?V():W())},onClick:Y=>{Y.target.closest("a, button, video, iframe, [data-presenter-controls], [data-presenter-notes]")||Y.detail>1||V()},onContextMenu:Y=>{Y.preventDefault(),W()},children:[p.jsxs("div",{className:"absolute inset-x-0 top-0",style:{height:U},children:[u?p.jsx(z4,{slide:u.slide,done:u.done,animate:!1,scale:I,rootRef:$,className:"z-[1]"}):null,p.jsx(z4,{slide:l,done:o.done,animate:o.animate,scale:I,rootRef:A,startedClips:h,onStartClip:ne,className:"z-[2]",motion:!0},o.id)]}),B?p.jsxs("div",{"data-presenter-notes":!0,className:"absolute inset-x-0 bottom-0 flex flex-col border-t border-white/15 bg-neutral-950 text-white",style:{height:_.h-U},children:[p.jsxs("div",{className:"px-4 pt-2 text-[11px] uppercase tracking-wide text-white/50",children:["Speaker notes · Slide ",i+1," of ",s.length]}),p.jsx(ST,{slideId:o.id,className:"h-full w-full resize-none bg-transparent px-4 py-2 text-lg leading-relaxed text-white outline-none placeholder:text-white/40"},o.id)]}):null,n?null:p.jsxs("div",{"data-presenter-controls":!0,className:ze("absolute bottom-4 left-1/2 flex -translate-x-1/2 items-center gap-1 rounded-full bg-neutral-900/85 px-2 py-1 text-white shadow-lg backdrop-blur transition-opacity duration-300",m?"opacity-100":"pointer-events-none opacity-0"),style:B?{bottom:_.h-U+16}:void 0,children:[p.jsx(Cs,{label:"Previous",shortcut:"←",icon:p.jsx(xE,{className:"size-4"}),className:"text-white hover:bg-white/15 hover:text-white",disabled:i===0&&o.done===0,onClick:W}),p.jsxs("span",{className:"min-w-16 text-center text-xs tabular-nums text-white/80",children:[i+1," / ",s.length]}),p.jsx(Cs,{label:"Next",shortcut:"→",icon:p.jsx(Fy,{className:"size-4"}),className:"text-white hover:bg-white/15 hover:text-white",disabled:i===s.length-1&&o.done>=c.length,onClick:V}),p.jsx("span",{className:"mx-1 h-4 w-px bg-white/20"}),p.jsx(Cs,{label:"Speaker notes",icon:p.jsx(_K,{className:"size-4"}),className:"text-white hover:bg-white/15 hover:text-white",onClick:Q}),p.jsx(Cs,{label:v?"Exit full screen":"Full screen",shortcut:"F",icon:v?p.jsx(wK,{className:"size-4"}):p.jsx(kE,{className:"size-4"}),className:"text-white hover:bg-white/15 hover:text-white",onClick:()=>I4(O.current)}),p.jsx(Cs,{label:"Stop presenting",shortcut:"Esc",icon:p.jsx(zr,{className:"size-4"}),className:"text-white hover:bg-white/15 hover:text-white",onClick:K})]}),S?p.jsx(Cwe,{popup:S,position:o,index:i,count:s.length,steps:c.length,nextId:J,clock:R,onClock:N,onNext:V,onPrevious:W,onClosed:()=>k(null)}):null]})}function I4(e){document.fullscreenElement?document.exitFullscreen().catch(()=>{}):e?.requestFullscreen?.().catch(()=>{})}const wi=hs()(()=>({drag:null})),Pwe=5;function Iwe(e,t){const n=[...e.querySelectorAll("[data-section-row]")];let s=n.length;for(const o of n){const r=o.getBoundingClientRect();if(t<r.top+r.height/2){s=Number(o.dataset.sectionRow);break}}return s}function Bwe(e,t){if(e.button!==0||!gn())return;const n=e.currentTarget.closest("[data-section-rows]");if(!n)return;const s=[...n.querySelectorAll("[data-section-row]")].map(m=>m.dataset.sectionKey||null),o=e.clientX,r=e.clientY;let i=!1;const l=()=>{const m=te.getState().sectionSelection,b=m.includes(t)?m:[t];return s.filter(v=>v!==null&&b.includes(v))},c=m=>{if(!i){if(Math.hypot(m.clientX-o,m.clientY-r)<Pwe)return;i=!0,document.body.style.cursor="grabbing"}wi.setState({drag:{keys:l(),gap:Iwe(n,m.clientY)}});const b=n.closest("[data-section-scroll]");if(b){const v=b.getBoundingClientRect();m.clientY<v.top+32?b.scrollBy(0,-12):m.clientY>v.bottom-32&&b.scrollBy(0,12)}},u=m=>{window.removeEventListener("pointermove",c),window.removeEventListener("pointerup",f),window.removeEventListener("pointercancel",h),window.removeEventListener("keydown",g,!0),document.body.style.cursor="";const b=wi.getState().drag;if(wi.setState({drag:null}),!i){m&&te.getState().sectionSelection.length>1&&te.getState().selectSections([t]);return}m&&b&&b.gap!==null&&b.keys.length&&Aae(b.keys,b.gap)},f=()=>u(!0),h=()=>u(!1),g=m=>{m.key!=="Escape"||!i||(m.preventDefault(),m.stopPropagation(),u(!1))};window.addEventListener("pointermove",c),window.addEventListener("pointerup",f),window.addEventListener("pointercancel",h),window.addEventListener("keydown",g,!0)}const A9=C.memo(function({id:t,index:n,comments:s,peers:o,dragging:r,dropBefore:i,dropAfter:l,onPointerDown:c,onOpen:u,width:f}){const h=ie(E=>E.slides[t]),g=te(E=>E.current===t),m=te(E=>E.slideSelection.includes(t)),b=IF(t);if(!h)return null;const v=h.held??(h.conflict?"Changed elsewhere at the same time":null),w=Mi(h.slide);return p.jsxs(Bb,{menu:p.jsx(Fb,{ids:te.getState().slideSelection.includes(t)?Ko():[t]}),onOpen:()=>{te.getState().slideSelection.includes(t)||te.getState().showSlide(t)},className:"relative shrink-0 outline-none",style:f?{width:f}:void 0,children:[i?p.jsx("span",{"aria-hidden":!0,className:"absolute -left-[13px] inset-y-0 w-1 rounded bg-accent"}):null,l?p.jsx("span",{"aria-hidden":!0,className:"absolute -right-[13px] inset-y-0 w-1 rounded bg-accent"}):null,p.jsxs("div",{"data-slide-index":n,"data-slide-id":t,role:"option","aria-selected":m||g,"aria-label":`Slide ${n+1}${w?`: ${w}`:""}`,onPointerDown:E=>c(E,t),onDoubleClick:()=>u(t),className:ze("group cursor-default",r&&"opacity-40",b&&"oa-arrive"),children:[p.jsxs("div",{className:ze("relative overflow-hidden rounded-md ring-1 ring-line transition-shadow",m||g?"ring-2 ring-accent":"group-hover:ring-line-strong",h.slide.hidden&&"opacity-50"),children:[p.jsx(oc,{slide:h.slide,virtual:!0}),p.jsxs("div",{className:"pointer-events-none absolute bottom-1.5 right-1.5 flex items-center gap-1",children:[p.jsx(wT,{peers:o}),s?p.jsxs("span",{className:"flex items-center gap-0.5 rounded-full bg-surface px-1.5 text-[10px] text-fg shadow-popup",children:[p.jsx(Da,{className:"size-2.5"}),s]}):null]})]}),p.jsxs("div",{className:"flex items-center gap-1.5 pt-1.5 text-[11px] text-fg-muted",children:[p.jsx("span",{className:ze("tabular-nums",(m||g)&&"font-semibold text-fg"),children:n+1}),p.jsx("span",{className:"min-w-0 flex-1 truncate",children:w}),h.slide.hidden?p.jsx(Lh,{className:"size-3 shrink-0","aria-label":"Skipped"}):null,v?p.jsx(xo,{className:"size-3 shrink-0 text-warning","aria-label":v}):null]})]})]})});function $T({section:e,n:t,ids:n,previousGap:s,nextGap:o,className:r}){const i=e?.key??"-",l=te(b=>b.editingSection===i),c=te(b=>b.sectionSelection.includes(i)),u=ie(b=>!b.readOnly&&!b.indexError)&&gn(),f=e?.description??"",h=`Section ${t+1}`,g=u&&(e!==null||n.length>0),m=b=>{te.getState().setEditingSection(null);const v=eC(b);v!==f&&(e?Rae(e.key,v):n[0]&&jae(n[0],v))};return p.jsxs("div",{"data-section-label":i,className:ze("group/label flex min-w-0 items-start gap-2 rounded-md px-1.5 py-1",c&&"bg-accent-soft",e&&u&&"cursor-grab",r),onPointerDown:b=>{const v=b.target;if(b.button!==0||v.closest("textarea")||v.closest("button")&&!v.closest("[data-section-describe]"))return;const w=te.getState(),E=b.metaKey||b.ctrlKey||b.shiftKey;E?w.selectSections(c?w.sectionSelection.filter(M=>M!==i):[...w.sectionSelection,i]):(!c||!e||!u)&&w.selectSections([i]),w.selectSlides([...n]),e&&u&&!E&&Bwe(b,e.key)},children:[p.jsxs("div",{className:"min-w-0 flex-1",children:[p.jsx("div",{className:"text-[11px] font-semibold uppercase tracking-wide text-fg-muted",children:h}),l?p.jsx(Fwe,{initial:f,onCommit:m,onCancel:()=>te.getState().setEditingSection(null)}):p.jsx("button",{type:"button","data-section-describe":!0,disabled:!g,"aria-label":f||(g?`${h}, Describe this section`:h),className:ze("block max-w-full truncate text-left text-sm",f?"text-fg":"text-fg-subtle",g&&"hover:text-fg"),onClick:()=>g&&te.getState().setEditingSection(i),children:f||(g?"Describe this section":"")})]}),u&&e?p.jsxs(RP,{trigger:p.jsx(Cs,{size:"sm",noTooltip:!0,label:`Actions for ${h}`,icon:p.jsx(wE,{className:"size-3.5"}),className:"opacity-0 group-hover/label:opacity-100 focus-visible:opacity-100 pointer-coarse:opacity-100"}),align:"end",children:[p.jsxs(pt,{onSelect:()=>te.getState().setEditingSection(i),children:["Describe ",h]}),p.jsx(pt,{disabled:s===null,onSelect:()=>s!==null&&f_(e.key,s),children:"Move section earlier"}),p.jsx(pt,{disabled:o===null,onSelect:()=>o!==null&&f_(e.key,o),children:"Move section later"}),p.jsx(pt,{icon:p.jsx(fs,{className:"size-4"}),disabled:n.length===0,onSelect:()=>{Ba("blank",n.at(-1)??null)},children:"Add a slide to this section"}),p.jsx(pt,{icon:p.jsx(Hy,{className:"size-4"}),danger:!0,onSelect:()=>Mae(e.key),children:"Remove section"})]}):null]})}function Fwe({initial:e,onCommit:t,onCancel:n}){const[s,o]=C.useState(e),r=C.useRef(null),i=C.useRef(!1);return C.useEffect(()=>{r.current?.focus(),r.current?.select()},[]),p.jsx("textarea",{ref:r,rows:2,value:s,maxLength:ve.sectionDescription,placeholder:"Describe this section","aria-label":"Section description",className:"mt-0.5 block w-full resize-none rounded border border-accent bg-canvas px-1.5 py-1 text-sm text-fg outline-none",onChange:l=>o(l.target.value.replace(/\n/g," ")),onBlur:()=>{i.current||(i.current=!0,t(s))},onKeyDown:l=>{l.stopPropagation(),l.key==="Enter"?(l.preventDefault(),i.current=!0,t(s)):l.key==="Escape"&&(l.preventDefault(),i.current=!0,n())}})}function _T({gap:e,after:t,className:n}){return gn()?p.jsxs(RP,{trigger:p.jsx("button",{type:"button","aria-label":"Add a slide or section here",className:ze("flex size-6 items-center justify-center rounded-full border border-line bg-surface text-fg-muted opacity-0 shadow-popup transition-opacity hover:text-fg focus-visible:opacity-100 group-hover/gap:opacity-100 pointer-coarse:opacity-100",n),children:p.jsx(fs,{className:"size-3.5"})}),align:"center",children:[p.jsx(pt,{icon:p.jsx(fs,{className:"size-4"}),onSelect:()=>{Ba("blank",t)},children:"New slide here"}),p.jsx(pt,{icon:p.jsx(qS,{className:"size-4"}),onSelect:()=>Tae(e),children:"New section here"})]}):null}const Es=480,nd=28,bo=48,dr=96,lr=320;function Hwe(e,t,n){const s=Es*n/t,o=s+nd,r=[],i=new Map,l=[];let c=0;e.forEach((f,h)=>{const g=h*(o+dr);l.push({row:h,section:f.section,key:f.section?.key??null,top:g,first:c,ids:f.ids,empty:f.ids.length===0?{x:lr,y:g,w:Es,h:s}:null}),f.ids.forEach((m,b)=>{const v={id:m,index:c++,row:h,x:lr+b*(Es+bo),y:g,w:Es,h:s};r.push(v),i.set(m,v)})});const u=Math.max(1,...e.map(f=>f.ids.length));return{tiles:r,byId:i,rows:l,slideH:s,tileH:o,width:lr+u*Es+(u-1)*bo,height:Math.max(1,e.length)*(o+dr)-dr}}const y2=(e,t,n)=>t>=e.x&&t<e.x+e.w&&n>=e.y&&n<e.y+e.h;function Uwe(e,t){const n=e.tileH+dr,s=Math.floor((t+dr/2)/n);return e.rows[Math.min(e.rows.length-1,Math.max(0,s))]}function B4(e,t,n){const s=Uwe(e,n);if(!s||!s.ids.length)return null;const o=Math.floor((t-lr)/(Es+bo)),r=s.ids[o],i=r===void 0?void 0:e.byId.get(r);return i?y2(i,t,n)?{tile:i,caption:!1}:y2({x:i.x,y:i.y+i.h,w:i.w,h:nd},t,n)?{tile:i,caption:!0}:null:null}function Vwe(e,t,n){for(const s of e.rows)if(s.empty&&s.key&&y2(s.empty,t,n))return s.key;return null}function qwe(e,t,n){let s=null,o=1/0;for(const r of e.tiles){const i=r.y+e.tileH,l=t<r.x?r.x-t:t>r.x+r.w?t-r.x-r.w:0,u=(n<r.y?r.y-n:n>i?n-i:0)*4+l;u<o&&(s=r,o=u)}return s?s.index+(t>s.x+s.w/2?1:0):0}function Wwe(e,t){const n=[],s=e.tiles[t],o=e.tiles[t-1];return s&&n.push({x:s.x-bo/2-2,y:s.y,w:4,h:e.tileH}),o&&(!s||s.row!==o.row)&&n.push({x:o.x+o.w+bo/2-2,y:o.y,w:4,h:e.tileH}),n}function b2(e,t){const n=[];for(const s of e.tiles)s.x<t.x+t.w&&s.x+s.w>t.x&&s.y<t.y+t.h&&s.y+e.tileH>t.y&&n.push(s);return n}function Gwe(e,t){return{x:e.x-e.w*t,y:e.y-e.h*t,w:e.w*(1+t*2),h:e.h*(1+t*2)}}const Sf=32,Ywe=1,Kwe=2,Xwe=3,Zwe=0,Qwe=1,Jwe=2,e1e=1,t1e=2,n1e=4,s1e=8,o1e=16,r1e=32,i1e=64,a1e=128,l1e=256,c1e=512,u1e=1024,d1e=2048,f1e=4096,h1e=8192,p1e=2,N9=0,Xf=1,F4=2,x2=3,O9=4,wSe={minZoom:1,maxZoom:2,snap:3,snapDistance:4,dragThreshold:5,hitTolerance:6,handleSize:7,settleMs:8,cameraEventMs:9,wheelZoom:10,selection:11,marquee:12,fadeMs:13,dragEvents:14,grid:15,gridSpacing:16,textureBudget:17,zoomSpeed:18,wheelZoomMax:19,gridMajor:20,gridFadeStart:21,gridFadeEnd:22},SSe={background:30,grid:31,selection:32,handle:33,guide:34,marquee:35,hover:36},kSe=1,ESe=2,CSe=4,TSe=8,MSe=1,RSe=2,jSe=3,ASe={select:0,pan:1,none:2},NSe={mouse:0,pen:1,touch:2},OSe=["default","grab","grabbing","move","ns-resize","ew-resize","nwse-resize","nesw-resize","crosshair"],$Se=1,_Se=2,LSe=4,m1e={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074},g1e=/^[-+]?(?:\d+\.?\d*|\.\d+)(?:e[-+]?\d+)?/;function Kb(e){const t=g1e.exec(e);if(!t)return null;const n=e.slice(t[0].length);return/^(%|deg|rad|grad|turn)?$/.test(n)?{v:parseFloat(t[0]),unit:n}:null}function y1e(e){const t=e.includes(","),[n,s,o]=t?[e,void 0,void 0]:e.split("/");if(o!==void 0)return null;const r=n.split(t?",":/\s+/).map(c=>c.trim()).filter(Boolean);if(t?r.length!==3&&r.length!==4:r.length!==3)return null;const i=t?r[3]:s?.trim();if(i==="")return null;const l=c=>c==="none"?"0":c;return[l(r[0]),l(r[1]),l(r[2]),i===void 0?void 0:l(i)]}function b1e(e){if(e===void 0)return 1;const t=Kb(e);return!t||t.unit&&t.unit!=="%"?NaN:t.unit==="%"?t.v/100:t.v}function x1e(e){const t=Kb(e);if(!t)return NaN;switch(t.unit){case"":case"deg":return t.v;case"rad":return t.v*180/Math.PI;case"grad":return t.v*.9;case"turn":return t.v*360;default:return NaN}}function H4(e){const t=Kb(e);return t?t.unit==="%"||t.unit===""?t.v/100:NaN:NaN}function U4(e,t,n,s){const o=(r,i)=>Math.round(Math.min(Math.max(r,0),i));return(o(e,255)<<24|o(t,255)<<16|o(n,255)<<8|o(s*255,255))>>>0}function v1e(e,t,n){const s=(e%360+360)%360,o=l=>(l+s/30)%12,r=t*Math.min(n,1-n),i=l=>n-r*Math.max(-1,Math.min(o(l)-3,9-o(l),1));return[i(0)*255,i(8)*255,i(4)*255]}function du(e,t=0){if(e==null)return t;if(typeof e=="number")return e>>>0;const n=e.trim().toLowerCase();if(n==="transparent"||n==="none")return 0;const s=m1e[n];if(s!==void 0)return(s<<8|255)>>>0;if(n.startsWith("#")){const l=n.slice(1);if(/^[0-9a-f]+$/.test(l)){if(l.length===3||l.length===4){const c=[...l].map(u=>u+u).join("");return parseInt(l.length===3?c+"ff":c,16)>>>0}if(l.length===6)return parseInt(l+"ff",16)>>>0;if(l.length===8)return parseInt(l,16)>>>0}}const o=/^(rgba?|hsla?)\(\s*([^()]*)\)$/.exec(n),r=o?y1e(o[2]):null;if(o&&r){const[l,c,u,f]=r,h=b1e(f);if(o[1].startsWith("rgb")){const g=b=>{const v=Kb(b);return v?v.unit==="%"?v.v/100*255:v.unit===""?v.v:NaN:NaN},m=[g(l),g(c),g(u)];if([...m,h].every(Number.isFinite))return U4(m[0],m[1],m[2],h)}else{const g=x1e(l),m=Math.min(Math.max(H4(c),0),1),b=Math.min(Math.max(H4(u),0),1);if([g,m,b,h].every(Number.isFinite)){const[v,w,E]=v1e(g,m,b);return U4(v,w,E,h)}}}const i=w1e(n);if(i!==null)return i;throw new TypeError(`canvas-engine: unsupported colour ${JSON.stringify(e)}`)}let Po;const Eg=new Map;function w1e(e){const t=Eg.get(e);if(t!==void 0)return t;Po===void 0&&(Po=typeof OffscreenCanvas<"u"?new OffscreenCanvas(1,1).getContext("2d",{willReadFrequently:!0}):typeof document<"u"?document.createElement("canvas").getContext("2d",{willReadFrequently:!0}):null);let n=null;if(Po){Po.fillStyle="#000",Po.fillStyle=e;const s=Po.fillStyle;if(Po.fillStyle="#fff",Po.fillStyle=e,s===Po.fillStyle){Po.clearRect(0,0,1,1),Po.fillRect(0,0,1,1);const[o,r,i,l]=Po.getImageData(0,0,1,1).data;n=l===0?0:(o<<24|r<<16|i<<8|l)>>>0}}return Eg.size>512&&Eg.clear(),Eg.set(e,n),n}function S1e(e){let t=0;return e.visible!==!1&&(t|=e1e),e.hittable!==!1&&(t|=t1e),e.selectable!==!1&&(t|=n1e),e.movable!==!1&&(t|=s1e),e.resizable!==!1&&(t|=o1e),e.snap!==!1&&(t|=r1e),e.lockAspect&&(t|=i1e),e.hitStrokeOnly&&(t|=a1e),e.screenStroke&&(t|=l1e),e.hover===!1&&(t|=c1e),e.selectionOutline===!1&&(t|=u1e),e.handles==="corners"?t|=d1e:e.handles==="width"&&(t|=f1e),e.blend==="multiply"&&(t|=h1e),t}function k1e(e){const t=/([MmLlHhVvCcSsQqTtAaZz])|([-+]?(?:\d+\.?\d*|\.\d+)(?:[eE][-+]?\d+)?)/g,n=[];let s;for(;s=t.exec(e);)n.push(s[1]?{cmd:!0,raw:s[1]}:{cmd:!1,raw:s[2]});return n}function E1e(e,t,n,s,o,r,i,l,c,u){if(s===0||o===0){e.push(Xf,c,u);return}if(t===c&&n===u)return;s=Math.abs(s),o=Math.abs(o);const f=r*Math.PI/180,h=Math.cos(f),g=Math.sin(f),m=(t-c)/2,b=(n-u)/2,v=h*m+g*b,w=-g*m+h*b,E=v*v/(s*s)+w*w/(o*o);if(E>1){const V=Math.sqrt(E);s*=V,o*=V}const M=s*s*o*o-s*s*w*w-o*o*v*v,S=s*s*w*w+o*o*v*v;let k=Math.sqrt(Math.max(0,M/S));i===l&&(k=-k);const R=k*s*w/o,N=-k*o*v/s,O=h*R-g*N+(t+c)/2,A=g*R+h*N+(n+u)/2,$=(V,W,K,H)=>Math.atan2(V*H-W*K,V*K+W*H),D=$(1,0,(v-R)/s,(w-N)/o);let z=$((v-R)/s,(w-N)/o,(-v-R)/s,(-w-N)/o);!l&&z>0&&(z-=2*Math.PI),l&&z<0&&(z+=2*Math.PI);const _=Math.max(1,Math.ceil(Math.abs(z)/(Math.PI/2))),L=z/_,B=4/3*Math.tan(L/4);let U=D;const I=V=>{const W=s*Math.cos(V),K=o*Math.sin(V);return[O+h*W-g*K,A+g*W+h*K]},F=V=>{const W=-s*Math.sin(V),K=o*Math.cos(V);return[h*W-g*K,g*W+h*K]};for(let V=0;V<_;V++){const W=U+L,[K,H]=I(U),[G,X]=I(W),[Z,Q]=F(U),[ne,J]=F(W);e.push(x2,K+B*Z,H+B*Q,G-B*ne,X-B*J,V===_-1?c:G,V===_-1?u:X),U=W}}function C1e(e){const t=[],n=k1e(e);let s=0,o="",r=0,i=0,l=0,c=0,u=0,f=0,h="";const g=()=>{const b=n[s];if(!b||b.cmd)throw new SyntaxError(`canvas-engine: bad path data near token ${s} in ${JSON.stringify(e.slice(0,80))}`);return s++,parseFloat(b.raw)},m=()=>{const b=n[s];if(!b||b.cmd||b.raw[0]!=="0"&&b.raw[0]!=="1")throw new SyntaxError(`canvas-engine: bad arc flag near token ${s}`);return b.raw.length>1?n[s]={cmd:!1,raw:b.raw.slice(1)}:s++,b.raw[0]==="1"};for(;s<n.length;){const b=n[s];if(b.cmd)o=b.raw,s++;else if(!o)throw new SyntaxError("canvas-engine: path data must start with a command");const v=o===o.toLowerCase(),w=v?r:0,E=v?i:0;switch(o.toUpperCase()){case"M":{r=w+g(),i=E+g(),l=r,c=i,t.push(N9,r,i),o=v?"l":"L",h="M";break}case"L":r=w+g(),i=E+g(),t.push(Xf,r,i),h="L";break;case"H":r=w+g(),t.push(Xf,r,i),h="L";break;case"V":i=E+g(),t.push(Xf,r,i),h="L";break;case"C":{const M=w+g(),S=E+g();u=w+g(),f=E+g(),r=w+g(),i=E+g(),t.push(x2,M,S,u,f,r,i),h="C";break}case"S":{const M=h==="C"?2*r-u:r,S=h==="C"?2*i-f:i;u=w+g(),f=E+g(),r=w+g(),i=E+g(),t.push(x2,M,S,u,f,r,i),h="C";break}case"Q":u=w+g(),f=E+g(),r=w+g(),i=E+g(),t.push(F4,u,f,r,i),h="Q";break;case"T":u=h==="Q"?2*r-u:r,f=h==="Q"?2*i-f:i,r=w+g(),i=E+g(),t.push(F4,u,f,r,i),h="Q";break;case"A":{const M=g(),S=g(),k=g(),R=m(),N=m(),O=w+g(),A=E+g();E1e(t,r,i,M,S,k,R,N,O,A),r=O,i=A,h="A";break}case"Z":if(t.push(O9),r=l,i=c,h="Z",n[s]&&!n[s].cmd)throw new SyntaxError("canvas-engine: numbers after Z in path data");break;default:throw new SyntaxError(`canvas-engine: unknown path command ${o}`)}}return t}function T1e(e,t=!1){const n=[];for(let s=0;s+1<e.length;s+=2)n.push(s===0?N9:Xf,e[s],e[s+1]);return t&&n.length&&n.push(O9),n}class V4{#e=new Map;#t=[];#i=[];#o=[];get size(){return this.#e.size}get(t){return this.#e.get(t)}ensure(t){let n=this.#e.get(t);return n===void 0&&(n=this.#i.pop()??this.#t.length,this.#e.set(t,n),this.#t[n]=t),n}id(t){return this.#t[t]}ids(t){const n=[];for(let s=0;s<t.length;s++){const o=this.#t[t[s]];o!==void 0&&n.push(o)}return n}release(t){const n=this.#e.get(t);if(n!==void 0)return this.#e.delete(t),this.#t[n]=void 0,this.#o.push(n),n}clear(){for(const t of this.#e.values())this.#o.push(t);this.#e.clear(),this.#t.fill(void 0)}flush(){this.#i.push(...this.#o),this.#o.length=0}}const M1e={butt:0,round:1,square:2},R1e={miter:0,round:1,bevel:2};class DSe{items=new V4;textures=new V4;#e=new Map;#t(t){const n=this.#e.get(t.id),s=t.closed??!1;if(n&&n.d===t.d&&n.points===t.points&&n.closed===s)return n.cmds;const o=t.d!==void 0?C1e(t.d):t.points?T1e(t.points,s):[];return this.#e.set(t.id,{d:t.d,points:t.points,closed:s,cmds:o}),o}encode(t){const n=t.upsert??[],s=t.remove??[],o=(t.clear?1:0)+s.length+n.length,r=new Float64Array(o*Sf),i=[];let l=0,c=0;t.clear&&(r[0]=Xwe,this.items.clear(),this.#e.clear(),c=1);for(const h of s){const g=this.items.release(h);if(this.#e.delete(h),g===void 0)continue;const m=c*Sf;r[m]=Kwe,r[m+1]=g,c++}for(const h of n){const g=c*Sf;switch(c++,r[g]=Ywe,r[g+1]=this.items.ensure(h.id),r[g+3]=h.layer??0,r[g+4]=h.z??0,r[g+5]=h.x,r[g+6]=h.y,r[g+7]=h.w,r[g+8]=h.h,r[g+9]=h.rotation??0,r[g+10]=S1e(h),r[g+11]=h.opacity??1,r[g+22]=-1,h.kind){case"hole":r[g+2]=Qwe,r[g+15]=h.radius??0;break;case"path":{r[g+2]=Jwe,r[g+12]=du(h.fill),r[g+13]=du(h.stroke),r[g+14]=h.strokeWidth??1,r[g+16]=h.dash?.[0]??0,r[g+17]=h.dash?.[1]??0;const m=this.#t(h);r[g+23]=l,r[g+24]=m.length,i.push(m),l+=m.length;const b=h.cuts?.slice(0,p1e)??[];if(b.length){const v=b.flatMap(w=>[w.x,w.y,w.w,w.h]);i.push(v),l+=v.length,r[g+31]=b.length}r[g+25]=h.viewBox?.[0]??0,r[g+26]=h.viewBox?.[1]??0,r[g+27]=M1e[h.cap??"butt"],r[g+28]=R1e[h.join??"miter"],r[g+29]=h.miterLimit??4,r[g+30]=h.fillRule==="evenodd"?1:0;break}default:r[g+2]=Zwe,r[g+12]=du(h.fill),r[g+13]=du(h.stroke),r[g+14]=h.strokeWidth??(h.stroke!==void 0?1:0),r[g+15]=h.radius??0,r[g+16]=h.dash?.[0]??0,r[g+17]=h.dash?.[1]??0,h.shadow&&(r[g+18]=du(h.shadow.color),r[g+19]=h.shadow.blur,r[g+20]=h.shadow.dx??0,r[g+21]=h.shadow.dy??0),h.texture!==void 0&&(r[g+22]=this.textures.ensure(h.texture))}}const u=new Float32Array(l);let f=0;for(const h of i)u.set(h,f),f+=h.length;return this.items.flush(),{ops:c*Sf===r.length?r:r.subarray(0,c*Sf),paths:u,records:c}}}const j1e=(()=>{try{return new URLSearchParams(location.search).get("open_artifact_engine")==="off"}catch{return!1}})(),A1e=.05,N1e=2,O1e=48,$1e=12,_1e=48,L1e=1.25,ES=160,D1e=6,z1e=6,P1e=500;let CS=null;function q4(){const e=ie.getState(),t=mn(e),n=ds($n(Yh({sections:e.index.sections}),t),t),s=`${Xe}:${JSON.stringify(n)}`;return{layout:Hwe(n,Xe,ft),key:s}}function $9(e){try{return du(e),e}catch{return null}}function W4(){const e=getComputedStyle(document.documentElement),t=(n,s)=>$9(e.getPropertyValue(n).trim())??s;return{accent:t("--open-artifact-accent","#2563eb"),accentSoft:t("--open-artifact-accent-soft","rgba(37, 99, 235, 0.12)"),line:t("--open-artifact-line","rgba(0, 0, 0, 0.1)"),lineStrong:t("--open-artifact-line-strong","rgba(0, 0, 0, 0.2)")}}async function I1e(e,t){const n=Array.from(e.querySelectorAll("img"),s=>s.decode().catch(()=>{}));await Promise.race([Promise.all(n),new Promise(s=>setTimeout(s,t))])}const G4=()=>new Promise(e=>requestAnimationFrame(()=>e())),TS=(e,t)=>`${e}|${t.key}`;class B1e{store;#e=null;#t=null;#i=!1;#o=[];#x;#r={x:0,y:0,zoom:1};#m=!1;#c=new Set;#T=new Set;#a=new Map;#f=new Set;#l=new Map;#u=new Map;#d=new Map;#g=[];#y=new Set;#h=new Map;#v=new Set;#w=new Set;#S=new Set;#b={accent:"#2563eb",accentSoft:"rgba(37, 99, 235, 0.12)",line:"rgba(0, 0, 0, 0.1)",lineStrong:"rgba(0, 0, 0, 0.2)"};#k=new Map;#p=null;#M=!1;#n=null;constructor(){const{layout:t,key:n}=q4();this.#x=n,this.store=FI()(()=>({layout:t,view:null,zoom:1,hover:null,live:[],drag:null,menu:null}))}async start(t,n){const{CanvasEngine:s}=await BI(async()=>{const{CanvasEngine:i}=await import("./src-CWCcr2Hw.js");return{CanvasEngine:i}},[],import.meta.url);if(this.#i)return;this.#b=W4();const o=await s.create(n,{selection:"controlled",snap:!1,grid:"none",minZoom:A1e,maxZoom:N1e,cameraEventMs:0,dragEvents:!0,dragThreshold:5,zoomSpeed:.01,wheelZoomMax:1/0,theme:this.#j()});if(this.#i){o.destroy();return}this.#e=o,this.#t=n;const r=(i,l)=>{this.#o.push(o.on(i,l))};r("camera",i=>this.#B(i)),r("moving",({moving:i})=>{i&&(this.#m=!0,this.#s())}),r("holes",({holes:i})=>this.#W(i)),r("textureNeeded",({keys:i})=>this.#q(i)),r("hover",({id:i})=>this.store.setState({hover:i})),r("gesture",i=>this.#X(i)),r("dragging",i=>this.#Z(i)),r("dblclick",({id:i,world:l})=>{const c=this.#I(i,l);c&&te.getState().editOnCanvas(c)}),r("contextmenu",({id:i,world:l,event:c})=>{const u=this.#I(i,l);if(!u){c?.stopPropagation();return}te.getState().slideSelection.includes(u)||te.getState().showSlide(u),this.store.setState({menu:u})}),r("commit",i=>{i.op==="select"?this.#M&&this.#J(i.ids):i.op==="move"&&this.#Q()}),this.#G(t,n),this.#V(),this.#O(),this.#s(),CS?o.setCamera(CS):this.fit(0),globalThis.__openArtifactCanvasEngine=()=>this.#ee()}destroy(){if(this.#i)return;this.#i=!0;for(const n of this.#o)n();this.#o.length=0,this.#e?.destroy(),this.#e=null,this.#n&&(te.getState().setDropGap(null),Wf([]));const t=globalThis;delete t.__openArtifactCanvasEngine}fit(t=300){const{layout:n}=this.store.getState();this.#e?.glideTo({x:0,y:0,w:n.width,h:n.height},{duration:t,padding:O1e,maxZoom:1})}zoomBy(t){this.#e?.zoomAt(t)}attachWorld(t){return this.#w.add(t),t.style.transform=this.#R(),()=>this.#w.delete(t)}attachZoomReadout(t){return this.#S.add(t),t.textContent=`${Math.round(this.#r.zoom*100)}%`,()=>this.#S.delete(t)}#R(){const{x:t,y:n,zoom:s}=this.#r;return`translate(${-t*s}px, ${-n*s}px) scale(${s})`}#B(t){this.#r={x:t.x,y:t.y,zoom:t.zoom},CS=this.#r;const n=this.#R();for(const o of this.#w)o.style.transform=n;const s=`${Math.round(t.zoom*100)}%`;for(const o of this.#S)o.textContent=s;LF(),t.settled&&(this.#m=!1,this.#E())}#E(){const t=this.#e;if(!t)return;const{layout:n}=this.store.getState(),s=t.viewport();this.#c=new Set(b2(n,s).map(i=>i.id));const o=this.#F(s),r=this.store.getState().live;this.#T=new Set(o),this.store.setState({view:s,zoom:this.#r.zoom,live:o.length===r.length&&o.every((i,l)=>r[l]===i)?r:o});for(const[i,l]of this.#h)this.#f.has(i)||this.#P(i,l);for(const i of this.#c){const l=this.#l.get(i);l&&this.#d.get(l)===1&&this.#N()&&this.#L(l)}this.#s()}#F(t){const{layout:n}=this.store.getState(),s=Es*this.#r.zoom,o=s*(devicePixelRatio||1),r=Xe*$F*L1e,i=t.x+t.w/2,l=t.y+t.h/2,c=s<_1e?[]:b2(n,t).filter(f=>!this.#C(f.id)||o>r).map(f=>({id:f.id,d:Math.hypot(f.x+f.w/2-i,f.y+f.h/2-l)})).sort((f,h)=>f.d-h.d).slice(0,$1e).map(f=>f.id),u=te.getState().current;return u&&this.#c.has(u)&&!c.includes(u)&&c.push(u),c}#s(){const t=this.#e;if(!t||this.#n)return;const{layout:n}=this.store.getState(),s=ie.getState(),o=gn(),r=new Set(wi.getState().drag?.keys??[]),i=[],l=new Set;let c=!1;for(const f of n.tiles){const h=s.slides[f.id]?.slide;if(!h)continue;const g=n.rows[f.row]?.key,m=this.#v.has(f.id)&&this.#T.has(f.id)&&!(this.#m&&this.#C(f.id)),b={id:f.id,x:f.x,y:f.y,w:f.w,h:f.h,radius:z1e,movable:o,resizable:!1,snap:!1},v=m?{...b,kind:"hole"}:{...b,kind:"image",fill:this.#H(h),stroke:this.#b.line,strokeWidth:1,screenStroke:!0,texture:this.#l.get(f.id),opacity:(h.hidden?.5:1)*(g&&r.has(g)?.4:1)};l.add(f.id),m?this.#f.add(f.id):this.#f.delete(f.id);const w=JSON.stringify(v);this.#a.get(f.id)!==w&&(this.#a.has(f.id)||(c=!0),this.#a.set(f.id,w),i.push(v))}const u=[...this.#a.keys()].filter(f=>!l.has(f));for(const f of u)this.#a.delete(f),this.#f.delete(f);(i.length||u.length)&&t.applyPatch({upsert:i,remove:u}),c&&this.#A()}#H(t){const n=t.style.background;if(!n||/url\(|gradient/i.test(n))return"#ffffff";let s=this.#k.get(n);return s===void 0&&(s=$9(n)??"#ffffff",this.#k.set(n,s)),s}#j(){const t=this.#b;return{background:"transparent",grid:"transparent",selection:t.accent,handle:t.accent,guide:t.accent,marquee:t.accentSoft,hover:t.lineStrong}}#A(){const t=te.getState(),n=new Set(t.slideSelection);t.current&&n.add(t.current),this.#e?.setSelection([...n].filter(s=>this.#a.has(s)))}#U(){const{layout:t,key:n}=q4();n!==this.#x?(this.#x=n,this.store.setState({layout:t}),this.#E()):this.#s()}#V(){const t=r=>{this.#o.push(r)};t(ie.subscribe((r,i)=>{(r.index!==i.index||r.slides!==i.slides||r.status!==i.status||r.readOnly!==i.readOnly)&&this.#U()})),t(te.subscribe((r,i)=>{(r.slideSelection!==i.slideSelection||r.current!==i.current)&&this.#A(),r.current!==i.current&&!this.#m&&this.#E()})),t(wi.subscribe(()=>this.#s())),t(Hs.subscribe((r,i)=>{r.snapshots!==i.snapshots&&this.#O()})),t(ape({ids:()=>this.store.getState().layout.byId.keys(),visible:()=>this.#c}));const n=()=>{this.#b=W4(),this.#k.clear(),this.#e?.setOptions({theme:this.#j()}),this.#a.clear(),this.#s()},s=matchMedia("(prefers-color-scheme: dark)");s.addEventListener("change",n),t(()=>s.removeEventListener("change",n));const o=new MutationObserver(n);o.observe(document.documentElement,{attributes:!0,attributeFilter:["data-theme"]}),t(()=>o.disconnect())}#C(t){const n=this.#l.get(t);return n!==void 0&&this.#d.has(n)}#N(){return Es*this.#r.zoom*(devicePixelRatio||1)>ES}#O(){const{snapshots:t}=Hs.getState(),n=new Set([...this.#l.keys(),...Object.keys(t)]);let s=!1;for(const o of n){const r=t[o],i=r?TS(o,r):void 0,l=this.#l.get(o);i===l||i&&this.#u.has(i)||(i&&l&&this.#c.has(o)?(this.#u.set(i,o),this.#z(i).finally(()=>{this.#$(o,i)&&this.#s()})):s=this.#$(o,i)||s)}s&&this.#s()}#$(t,n){if(this.#i)return!1;const s=Hs.getState().snapshots[t];if(n&&(!s||TS(t,s)!==n))return this.#_(n),!1;const o=this.#l.get(t);return n?(this.#l.set(t,n),this.#u.set(n,t)):this.#l.delete(t),o&&o!==n&&this.#_(o),!0}#_(t){this.#u.delete(t),this.#d.delete(t),this.#e?.removeTexture(t)}#q(t){for(const n of t)this.#d.delete(n),this.#u.has(n)&&this.#L(n)}#L(t){!this.#y.has(t)&&!this.#g.includes(t)&&this.#g.push(t),this.#D()}#D(){for(;this.#y.size<D1e&&this.#g.length;){const t=this.#g.shift();this.#y.add(t),this.#z(t).finally(()=>{this.#y.delete(t),this.#D()})}}async#z(t){const n=this.#u.get(t),s=n?Hs.getState().snapshots[n]:void 0;if(!n||!s||TS(n,s)!==t)return;const o=this.#N(),{layout:r}=this.store.getState(),i=[];try{const l={premultiplyAlpha:"premultiply"};if(i.push(await createImageBitmap(s.blob,{...l,resizeWidth:ES,resizeHeight:Math.round(ES*r.slideH/Es),resizeQuality:"medium"})),o&&i.push(await createImageBitmap(s.blob,l)),!this.#e||this.#u.get(t)!==n)return;this.#e.setTexture(t,i)&&this.#d.set(t,o?2:1)}catch{}finally{for(const l of i)l.close()}}attachLive(t,n){this.#h.set(t,n),this.#P(t,n);let s=!0;return(async()=>(await G4(),await G4(),await I1e(n,P1e),!(!s||this.#h.get(t)!==n)&&(this.#v.add(t),this.#s())))(),()=>{s=!1,this.#h.get(t)===n&&(this.#h.delete(t),this.#v.delete(t),this.#s())}}#P(t,n){const s=this.store.getState().layout.byId.get(t);if(!s)return;const{x:o,y:r,zoom:i}=this.#r;n.style.transform=`matrix(${i}, 0, 0, ${i}, ${(s.x-o)*i}, ${(s.y-r)*i})`,n.style.visibility="hidden"}#W(t){const n=new Map(t.map(s=>[s.id,s]));for(const[s,o]of this.#h){const r=n.get(s);r?(o.style.transform=r.transform,o.style.visibility="visible"):o.style.visibility="hidden"}}hitAt(t,n){if(!this.#e||!this.#t)return null;const s=this.#t.getBoundingClientRect(),o=this.#e.screenToWorld({x:t-s.left,y:n-s.top});return B4(this.store.getState().layout,o.x,o.y)}#G(t,n){const s=(o,r,i=!1)=>{t.addEventListener(o,r,i),this.#o.push(()=>t.removeEventListener(o,r,i))};s("pointerdown",o=>this.#Y(o,n),!0),s("wheel",o=>{o.target===n||o.target instanceof Element&&o.target.closest("textarea")||(o.preventDefault(),n.dispatchEvent(new WheelEvent("wheel",o)))},!1),s("contextmenu",o=>{o.target!==n&&o.stopPropagation()},!0)}#I(t,n){return t??B4(this.store.getState().layout,n.x,n.y)?.tile.id??null}#Y(t,n){const s=this.#e;if(t.button!==0||!s||t.target!==n)return;const o=this.hitAt(t.clientX,t.clientY);if(!o){!t.shiftKey&&!t.metaKey&&!t.ctrlKey&&this.#K(t,s);return}const r=o.tile.id,i=te.getState().slideSelection.includes(r),l=gH(r,t);(!l||o.caption)&&t.stopPropagation();const c=n.getBoundingClientRect(),u={id:r,world:s.screenToWorld({x:t.clientX-c.left,y:t.clientY-c.top}),moved:!1};this.#p=u;const f=h=>{window.removeEventListener("pointerup",f,!0),window.removeEventListener("pointercancel",f,!0),this.#p===u&&(this.#p=null),h.type==="pointerup"&&l&&!u.moved&&i&&te.getState().slideSelection.length>1&&te.getState().selectSlides([r])};window.addEventListener("pointerup",f,!0),window.addEventListener("pointercancel",f,!0)}#K(t,n){n.setTool("pan");const s=t.clientX,o=t.clientY;let r=!1;const i=c=>{Math.hypot(c.clientX-s,c.clientY-o)>=3&&(r=!0)},l=c=>{if(window.removeEventListener("pointermove",i),window.removeEventListener("pointerup",l),window.removeEventListener("pointercancel",l),this.#e?.setTool("select"),r||c.type!=="pointerup")return;const u=te.getState();u.selectSections([]),u.selectSlides(u.current?[u.current]:[])};window.addEventListener("pointermove",i),window.addEventListener("pointerup",l),window.addEventListener("pointercancel",l)}#X(t){if(t.kind==="marquee"&&(this.#M=t.phase==="start"),t.kind!=="move")return;if(t.phase==="start"){this.#p&&(this.#p.moved=!0);return}const n=this.#n;if(this.#n=null,te.getState().setDropGap(null),Wf([]),this.store.setState({drag:null}),n)for(const s of n.ids)this.#a.delete(s);this.#s()}#Z({ids:t,dx:n,dy:s}){const{layout:o}=this.store.getState();if(!this.#n){const u=mn(ie.getState()),f=this.#p,h=o.byId.get(t[0]??"");this.#n={ids:u.filter(g=>t.includes(g)),origin:f?f.world:{x:h?.x??0,y:h?.y??0}},Wf(this.#n.ids)}const r=this.#n.origin.x+n,i=this.#n.origin.y+s,l=Vwe(o,r,i);te.getState().setDropGap(l?null:qwe(o,r,i));const c=this.store.getState().drag;(!c||c.section!==l)&&this.store.setState({drag:{ids:this.#n.ids,section:l}})}#Q(){const t=this.#n;if(!t)return;const n=this.store.getState().drag?.section??null,s=te.getState().dropGap;n?rB(t.ids,n,0):s!==null&&EC(t.ids,s)}#J(t){const n=te.getState(),s=mn(ie.getState()).filter(o=>t.includes(o));if(n.selectSections([]),!s.length){n.selectSlides(n.current?[n.current]:[]);return}(!n.current||!s.includes(n.current))&&n.showSlide(s[0],{keepSelection:!0}),te.getState().selectSlides(s)}#ee(){let t=0;for(const o of this.#c)(this.#C(o)||this.#f.has(o))&&t++;const{layout:n,live:s}=this.store.getState();return{tiles:n.tiles.length,visible:this.#c.size,visibleShown:t,live:s.length,holes:this.#f.size,textures:this.#d.size,large:[...this.#d.values()].filter(o=>o===2).length,camera:this.#r,moving:this.#m,engine:this.#e?.stats()??null}}}const F1e=.25,H1e=.5;function U1e({onFail:e}){const t=C.useRef(null),n=C.useRef(null),[s,o]=C.useState(null),r=C.useRef(e);return r.current=e,C.useEffect(()=>{const i=new B1e;return o(i),i.start(t.current,n.current).catch(l=>{i.destroy(),r.current(l)}),()=>i.destroy()},[]),p.jsx(Bb,{menu:s?p.jsx(V1e,{board:s}):p.jsx(p.Fragment,{}),className:"relative flex min-h-0 flex-1 bg-stage outline-none",children:p.jsxs("div",{ref:t,role:"listbox","aria-label":"Canvas","aria-multiselectable":!0,"data-open-artifact-canvas-engine":!0,className:"relative min-h-0 flex-1 touch-none overflow-hidden",children:[s?p.jsx(q1e,{board:s}):null,p.jsx("canvas",{ref:n,className:"absolute inset-0 size-full"}),s?p.jsx(G1e,{board:s}):null,s?p.jsx(Z1e,{board:s}):null]})})}function V1e({board:e}){const t=cr(e.store,n=>n.menu);return t?p.jsx(Fb,{ids:te.getState().slideSelection.includes(t)?Ko():[t]}):null}function q1e({board:e}){const t=cr(e.store,n=>n.live);return p.jsx("div",{"aria-hidden":!0,className:"pointer-events-none absolute inset-0 overflow-hidden",children:t.map(n=>p.jsx(W1e,{board:e,id:n},n))})}const W1e=C.memo(function({board:t,id:n}){const s=C.useRef(null),o=ie(c=>c.slides[n]?.slide),r=cr(t.store,c=>c.layout.slideH),i=cr(t.store,c=>c.layout.rows[c.layout.byId.get(n)?.row??-1]?.key??null),l=wi(c=>i!==null&&(c.drag?.keys.includes(i)??!1));return C.useLayoutEffect(()=>t.attachLive(n,s.current),[t,n]),p.jsx("div",{ref:s,className:"absolute left-0 top-0 origin-top-left overflow-hidden rounded-md",style:{width:Es,height:r,visibility:"hidden",opacity:(o?.hidden?.5:1)*(l?.4:1)},children:o?p.jsx(oc,{slide:o}):null})});function G1e({board:e}){const t=C.useRef(null),n=cr(e.store,m=>m.layout),s=cr(e.store,m=>m.view),o=cr(e.store,m=>m.zoom),r=cr(e.store,m=>m.drag),i=te(m=>m.dropGap),l=wi(m=>m.drag),c=ie(m=>!m.readOnly)&&gn();C.useLayoutEffect(()=>e.attachWorld(t.current),[e]);const u=s?Gwe(s,H1e):null,f=u?n.rows.filter(m=>m.top<u.y+u.h&&m.top+n.tileH>u.y):[],h=u&&o>=F1e?b2(n,u):[],g=Math.min(4,Math.max(1,.6/o));return p.jsx("div",{className:"pointer-events-none absolute inset-0 overflow-hidden",children:p.jsxs("div",{ref:t,"data-section-rows":!0,className:"absolute left-0 top-0 origin-top-left",style:{width:n.width,height:n.height},children:[n.rows.map(m=>p.jsx("div",{"data-section-row":m.row,"data-section-key":m.key??"","aria-hidden":!0,className:"absolute left-0",style:{top:m.top,width:1,height:n.tileH}},m.key??"-")),l&&l.gap!==null?p.jsx("div",{"aria-hidden":!0,className:"absolute left-0 h-1 rounded bg-accent",style:{top:l.gap*(n.tileH+dr)-dr/2,width:n.width}}):null,f.map(m=>p.jsx("div",{className:ze("pointer-events-auto absolute",m.key&&l?.keys.includes(m.key)&&"opacity-40"),style:{left:0,top:m.top,width:lr-bo},children:p.jsx("div",{className:"origin-top-left",style:{transform:`scale(${g})`,width:(lr-bo)/g},children:p.jsx($T,{section:m.section,n:m.row,ids:m.ids,previousGap:m.row>0?m.row-1:null,nextGap:m.row<n.rows.length-1?m.row+2:null})})},m.key??"-")),n.rows.map(m=>m.empty&&m.key?p.jsx("div",{"data-empty-section":m.key,className:ze("absolute flex items-center justify-center rounded-lg border-2 border-dashed border-line text-lg text-fg-subtle",r?.section===m.key&&"border-accent bg-accent-soft text-accent"),style:{left:m.empty.x,top:m.empty.y,width:m.empty.w,height:m.empty.h},children:"An empty section. Drop slides here."},m.key):null),r&&!r.section&&i!==null?Wwe(n,i).map((m,b)=>p.jsx("span",{"aria-hidden":!0,className:"absolute rounded bg-accent",style:{left:m.x,top:m.y,width:m.w,height:m.h}},b)):null,h.length?p.jsx(Y1e,{tiles:h,slideH:n.slideH,dragging:r?.ids??null}):null,c&&!r?p.jsx(X1e,{board:e}):null]})})}function Y1e({tiles:e,slideH:t,dragging:n}){const s=xb(),o=Kh();return e.map(r=>p.jsx(K1e,{tile:r,slideH:t,comments:s.get(r.id)??0,peers:o.get(r.id),dragging:n?.includes(r.id)??!1},r.id))}const K1e=C.memo(function({tile:t,slideH:n,comments:s,peers:o,dragging:r}){const i=ie(h=>h.slides[t.id]),l=te(h=>h.current===t.id),c=te(h=>h.slideSelection.includes(t.id));if(!i)return null;const u=i.held??(i.conflict?"Changed elsewhere at the same time":null),f=Mi(i.slide);return p.jsxs("div",{"data-slide-index":t.index,"data-slide-id":t.id,role:"option","aria-selected":c||l,"aria-label":`Slide ${t.index+1}${f?`: ${f}`:""}`,className:ze("absolute",r&&"opacity-40"),style:{left:t.x,top:t.y,width:t.w,height:n+nd},children:[p.jsxs("div",{className:"absolute right-1.5 flex items-center gap-1",style:{top:n-6,transform:"translateY(-100%)"},children:[p.jsx(wT,{peers:o}),s?p.jsxs("span",{className:"flex items-center gap-0.5 rounded-full bg-surface px-1.5 text-[10px] text-fg shadow-popup",children:[p.jsx(Da,{className:"size-2.5"}),s]}):null]}),p.jsxs("div",{className:"absolute inset-x-0 flex items-center gap-1.5 pt-1.5 text-[11px] text-fg-muted",style:{top:n},children:[p.jsx("span",{className:ze("tabular-nums",(c||l)&&"font-semibold text-fg"),children:t.index+1}),p.jsx("span",{className:"min-w-0 flex-1 truncate",children:f}),i.slide.hidden?p.jsx(Lh,{className:"size-3 shrink-0","aria-label":"Skipped"}):null,u?p.jsx(xo,{className:"size-3 shrink-0 text-warning","aria-label":u}):null]})]})});function X1e({board:e}){const t=cr(e.store,r=>r.hover),n=cr(e.store,r=>r.layout),s=C.useRef(null);t&&n.byId.has(t)&&(s.current=t);const o=s.current?n.byId.get(s.current):void 0;return o?p.jsx("div",{className:ze("group/gap pointer-events-none absolute flex items-center justify-center [&_button]:pointer-events-auto",t===o.id&&"[&_button]:opacity-100"),style:{left:o.x+o.w,top:o.y,width:bo,height:o.h},children:p.jsx(_T,{gap:o.index+1,after:o.id})}):null}function Z1e({board:e}){const t=C.useRef(null);return C.useLayoutEffect(()=>e.attachZoomReadout(t.current),[e]),p.jsxs(Br,{"data-canvas-controls":!0,className:"absolute bottom-3 right-3 h-9 px-1 py-px",onPointerDown:n=>n.stopPropagation(),children:[p.jsx(_n,{label:"Zoom out",children:p.jsx(Ht,{square:!0,"aria-label":"Zoom out",onClick:()=>e.zoomBy(1/1.25),children:p.jsx(Ii,{className:"size-4",strokeWidth:1.5})})}),p.jsx("span",{ref:t,className:"min-w-11 text-center text-[13px] tabular-nums text-chrome-secondary"}),p.jsx(_n,{label:"Zoom in",children:p.jsx(Ht,{square:!0,"aria-label":"Zoom in",onClick:()=>e.zoomBy(1.25),children:p.jsx(fs,{className:"size-4",strokeWidth:1.5})})}),p.jsx($r,{}),p.jsxs(Ht,{className:"pl-1.5 pr-2",onClick:()=>e.fit(),children:[p.jsx(kE,{className:"size-4",strokeWidth:1.5}),"Fit all slides"]})]})}const Q1e=()=>Es*ft/Xe+nd,MS=48,J1e=.05,eSe=2;let Y4=null;const _9=e=>Math.min(eSe,Math.max(J1e,e));function tSe(e,t,n,s){const o=_9(Math.min((n-MS*2)/e,(s-MS*2)/t,1));return{scale:o,x:(n-e*o)/2,y:Math.max(MS,(s-t*o)/2)}}function nSe(e){te.getState().editOnCanvas(e)}function sSe(){return te(t=>t.canvasEdit)?p.jsx(aSe,{}):p.jsx(oSe,{})}let RS=!1;function oSe(){const e=pd().length===0,[,t]=C.useState(RS);return j1e||RS||e?p.jsx(rSe,{}):p.jsx(U1e,{onFail:n=>{console.warn("Canvas engine unavailable; drawing the canvas with the DOM.",n),RS=!0,t(!0)}})}function rSe(){const{order:e,groups:t}=E8(),n=xb(),s=Kh(),o=te(D=>D.dropGap),r=ie(D=>!D.readOnly)&&gn(),i=C.useRef(null),l=mc(i),{drag:c,onPointerDown:u}=vT(i,"grid"),f=wi(D=>D.drag),h=new Set(c?.ids??[]);ie(D=>D.index.size);const g=Q1e(),m=Math.max(1,...t.map(D=>D.ids.length)),b=lr+m*Es+(m-1)*bo,v=Math.max(1,t.length)*(g+dr)-dr,[w,E]=C.useState(Y4),M=C.useRef(w);M.current=w;const S=C.useCallback(D=>{M.current=D,Y4=D,E(D),LF()},[]),k=C.useCallback(()=>{l&&S(tSe(b,v,l.w,l.h))},[l,b,v,S]);C.useLayoutEffect(()=>{!M.current&&l&&k()},[l,k]);const R=C.useCallback((D,z,_)=>{const L=M.current;if(!L)return;const B=_9(L.scale*D),U=B/L.scale;S({scale:B,x:z-(z-L.x)*U,y:_-(_-L.y)*U})},[S]);C.useEffect(()=>{const D=i.current;if(!D)return;const z=_=>{_.preventDefault();const L=M.current;if(!L)return;const B=D.getBoundingClientRect();if(_.ctrlKey||_.metaKey)R(Math.exp(-_.deltaY*.01),_.clientX-B.left,_.clientY-B.top);else{const U=_.shiftKey&&_.deltaX===0?_.deltaY:_.deltaX,I=_.shiftKey&&_.deltaX===0?0:_.deltaY;S({...L,x:L.x-U,y:L.y-I})}};return D.addEventListener("wheel",z,{passive:!1}),()=>D.removeEventListener("wheel",z)},[R,S]);const N=()=>({x:(l?.w??0)/2,y:(l?.h??0)/2}),O=D=>{if(D.button!==0&&D.button!==1||D.target.closest("[data-slide-index], [data-section-label], [data-empty-section], button, textarea, [data-canvas-controls]"))return;const _=M.current;if(!_)return;D.preventDefault();const L=D.clientX,B=D.clientY;let U=!1;const I=V=>{!U&&Math.hypot(V.clientX-L,V.clientY-B)<3||(U=!0,S({..._,x:_.x+V.clientX-L,y:_.y+V.clientY-B}))},F=()=>{if(window.removeEventListener("pointermove",I),window.removeEventListener("pointerup",F),!U){const V=te.getState();V.selectSections([]),V.selectSlides(V.current?[V.current]:[])}};window.addEventListener("pointermove",I),window.addEventListener("pointerup",F)};let A=0;const $=t.map(D=>{const z=A;return A+=D.ids.length,z});return p.jsxs("div",{ref:i,role:"listbox","aria-label":"Canvas","aria-multiselectable":!0,"data-open-artifact-thumbs":!0,className:ze("relative min-h-0 flex-1 touch-none overflow-hidden bg-stage",!c&&"cursor-grab active:cursor-grabbing"),onPointerDown:O,children:[e.length===0?p.jsxs("div",{className:"absolute inset-0 flex flex-col items-center justify-center gap-3 text-sm text-chrome-muted",children:[p.jsx("p",{children:"No slides yet."}),r?p.jsx(bt,{variant:"primary",icon:p.jsx(fs,{className:"size-4"}),onClick:()=>Ba("blank",null),children:"Add slide"}):null]}):w?p.jsx("div",{"data-section-rows":!0,className:"absolute left-0 top-0 origin-top-left",style:{width:b,height:v,transform:`translate(${w.x}px, ${w.y}px) scale(${w.scale})`},children:t.map((D,z)=>{const _=z*(g+dr),L=$[z];return p.jsxs("section",{"aria-label":D.section?.description||`Section ${z+1}`,className:ze(D.section&&f?.keys.includes(D.section.key)&&"opacity-40"),children:[p.jsx("div",{"data-section-row":z,"data-section-key":D.section?.key??"","aria-hidden":!0,className:"pointer-events-none absolute left-0",style:{top:_,width:1,height:g}}),f?.gap===z?p.jsx("div",{"aria-hidden":!0,className:"pointer-events-none absolute left-0 h-1 rounded bg-accent",style:{top:_-dr/2,width:b}}):null,p.jsx("div",{className:"absolute",style:{left:0,top:_,width:lr-bo},children:p.jsx("div",{className:"origin-top-left",style:{transform:`scale(${Math.min(4,Math.max(1,.6/w.scale))})`,width:(lr-bo)/Math.min(4,Math.max(1,.6/w.scale))},children:p.jsx($T,{section:D.section,n:z,ids:D.ids,previousGap:z>0?z-1:null,nextGap:z<t.length-1?z+2:null})})}),D.ids.length===0?p.jsx("div",{"data-empty-section":D.section?.key,className:ze("absolute flex items-center justify-center rounded-lg border-2 border-dashed border-line text-lg text-fg-subtle",c?.section===D.section?.key&&"border-accent bg-accent-soft text-accent"),style:{left:lr,top:_,width:Es,height:g-nd},children:"An empty section. Drop slides here."}):D.ids.map((B,U)=>{const I=L+U;return p.jsxs("div",{className:"group/gap absolute",style:{left:lr+U*(Es+bo),top:_,width:Es},children:[p.jsx(A9,{id:B,index:I,width:Es,comments:n.get(B)??0,peers:s.get(B),dragging:h.has(B),dropBefore:c!==null&&o===I,dropAfter:c!==null&&U===D.ids.length-1&&o===I+1,onPointerDown:u,onOpen:nSe}),r&&!c?p.jsx("div",{className:"absolute top-0 z-10 flex items-center justify-center",style:{left:Es,width:bo,height:g-nd},children:p.jsx(_T,{gap:I+1,after:B})}):null]},B)})]},D.section?.key??"-")})}):null,p.jsxs(Br,{"data-canvas-controls":!0,className:"absolute bottom-3 right-3 h-9 px-1 py-px",onPointerDown:D=>D.stopPropagation(),children:[p.jsx(_n,{label:"Zoom out",children:p.jsx(Ht,{square:!0,"aria-label":"Zoom out",onClick:()=>R(1/1.25,N().x,N().y),children:p.jsx(Ii,{className:"size-4",strokeWidth:1.5})})}),p.jsx("span",{className:"min-w-11 text-center text-[13px] tabular-nums text-chrome-secondary",children:w?`${Math.round(w.scale*100)}%`:""}),p.jsx(_n,{label:"Zoom in",children:p.jsx(Ht,{square:!0,"aria-label":"Zoom in",onClick:()=>R(1.25,N().x,N().y),children:p.jsx(fs,{className:"size-4",strokeWidth:1.5})})}),p.jsx($r,{}),p.jsxs(Ht,{className:"pl-1.5 pr-2",onClick:k,children:[p.jsx(kE,{className:"size-4",strokeWidth:1.5}),"Fit all slides"]})]})]})}const K4=2;function iSe({id:e,n:t}){const n=ie(s=>s.slides[e]?.slide);return n?p.jsxs("button",{type:"button","aria-label":`Edit slide ${t}`,className:"group w-full text-left",onClick:()=>te.getState().showSlide(e),children:[p.jsx("div",{className:"overflow-hidden rounded-[6px] opacity-60 shadow-[0_0_0_1px_var(--chrome-line)] transition group-hover:opacity-100",children:p.jsx(oc,{slide:n})}),p.jsxs("div",{className:"truncate pt-1 text-[11px] text-chrome-muted",children:[p.jsx("span",{className:"tabular-nums",children:t})," ",Mi(n)]})]}):null}function aSe(){const e=pd(),t=te(i=>i.current),n=t?e.indexOf(t):-1;if(C.useEffect(()=>{n<0&&te.getState().editOnCanvas(null)},[n]),n<0)return null;const s=e.slice(Math.max(0,n-K4),n),o=e.slice(n+1,n+1+K4),r=(i,l)=>p.jsx("div",{className:"flex w-40 shrink-0 flex-col justify-center gap-4 overflow-hidden px-3 pb-14 pt-14 max-md:hidden",children:i.map((c,u)=>p.jsx(iSe,{id:c,n:l+u+1},c))});return p.jsxs("div",{className:"relative flex min-h-0 flex-1 bg-stage",children:[r(s,n-s.length),p.jsxs("div",{className:"relative min-w-0 flex-1",children:[p.jsx(GH,{}),p.jsx("div",{className:"pointer-events-none absolute inset-x-0 top-3 z-10 flex justify-center",children:p.jsxs(Br,{className:"h-9 px-1 py-px",children:[p.jsx(_n,{label:"Back to canvas",shortcut:"Esc",children:p.jsxs(Ht,{className:"pl-1.5 pr-2",onClick:()=>te.getState().editOnCanvas(null),children:[p.jsx(aD,{className:"size-4",strokeWidth:1.5}),"Canvas"]})}),p.jsx($r,{}),p.jsxs("span",{className:"px-2 text-[13px] tabular-nums text-chrome-secondary",children:["Slide ",n+1," of ",e.length]})]})})]}),r(o,n+1)]})}const X4=220,iu=24,jS=32;function lSe(e){const t=te.getState();t.setMode("edit"),t.showSlide(e)}function cSe(){const{order:e,groups:t}=E8(),n=xb(),s=Kh(),o=te(k=>k.dropGap),r=te(k=>k.current),i=ie(k=>!k.readOnly)&&gn(),l=On(k=>k.writing),c=C.useRef(null),u=mc(c),{drag:f,onPointerDown:h}=vT(c,"grid"),g=wi(k=>k.drag),m=new Set(f?.ids??[]),b=u?Math.max(1,Math.floor((u.w-jS*2+iu)/(X4+iu))):4,v=u?Math.floor((u.w-jS*2-iu*(b-1))/b):X4,[w,E]=C.useState(!1);if(C.useLayoutEffect(()=>{w||!u||!r||(c.current?.querySelector(`[data-slide-id="${CSS.escape(r)}"]`)?.scrollIntoView({block:"center"}),E(!0))},[w,u,r]),e.length===0)return l?p.jsx(PF,{}):p.jsxs("div",{className:"flex flex-1 flex-col items-center justify-center gap-3 bg-stage text-sm text-chrome-muted",children:[p.jsx("p",{children:"No slides yet."}),i?p.jsx(bt,{variant:"primary",icon:p.jsx(fs,{className:"size-4"}),onClick:()=>Ba("blank",null),children:"Add slide"}):null]});let M=0;const S=t.map(k=>{const R=M;return M+=k.ids.length,R});return p.jsxs("div",{ref:c,role:"listbox","aria-label":"Slides","aria-multiselectable":!0,"data-open-artifact-grid-columns":b,"data-section-rows":!0,"data-section-scroll":!0,"data-open-artifact-thumbs":!0,className:"min-h-0 flex-1 overflow-y-auto bg-stage pb-6 pt-[60px]",style:{paddingInline:jS},onPointerMove:k=>{const R=k.target instanceof Element?k.target.closest("[data-slide-id]"):null,N=R?.dataset.slideId;if(!R||!N)return B1(null);const O=R.getBoundingClientRect();B1({slideId:N,x:(k.clientX-O.left)/Math.max(1,O.width),y:(k.clientY-O.top)/Math.max(1,O.height)})},onPointerLeave:()=>B1(null),onPointerDown:k=>{if(k.target===k.currentTarget){const R=te.getState();R.selectSections([]),R.selectSlides(R.current?[R.current]:[])}},children:[t.map((k,R)=>{const N=S[R],O=R>0?R-1:null,A=R<t.length-1?R+2:null,$=k.section!==null||t.length>1||i,D=!!(k.section&&g?.keys.includes(k.section.key));return p.jsxs("section",{"data-section-row":R,"data-section-key":k.section?.key??"",className:ze("relative mb-8",D&&"opacity-40"),"aria-label":k.section?.description||`Section ${R+1}`,children:[g?.gap===R?p.jsx(Z4,{}):null,$?p.jsx($T,{section:k.section,n:R,ids:k.ids,previousGap:O,nextGap:A,className:"mb-3 max-w-2xl"}):null,k.ids.length===0?p.jsx("div",{"data-empty-section":k.section?.key,className:ze("flex h-24 items-center justify-center rounded-md border border-dashed border-line text-xs text-fg-subtle",f?.section===k.section?.key&&"border-accent bg-accent-soft text-accent"),children:"An empty section. Drop slides here."}):p.jsx("div",{className:"grid",style:{gridTemplateColumns:`repeat(${b}, ${v}px)`,columnGap:iu,rowGap:iu},children:k.ids.map((z,_)=>{const L=N+_,B=L===e.length-1;return p.jsxs("div",{className:"group/gap relative",children:[p.jsx(A9,{id:z,index:L,comments:n.get(z)??0,peers:s.get(z),dragging:m.has(z),dropBefore:f!==null&&o===L,dropAfter:f!==null&&B&&o===e.length,onPointerDown:h,onOpen:lSe}),p.jsx(Vbe,{id:z}),i&&!f?p.jsx("div",{className:"absolute -right-[18px] top-0 z-10 flex w-3 items-center justify-center",style:{height:v*9/16},children:p.jsx(_T,{gap:L+1,after:z})}):null]},z)})})]},k.section?.key??"-")}),p.jsx(wpe,{first:e.length,columns:b,tile:v,gap:iu}),g?.gap===t.length?p.jsx("div",{className:"relative h-0",children:p.jsx(Z4,{})}):null,i?p.jsx(bt,{variant:"ghost",icon:p.jsx(fs,{className:"size-4"}),onClick:()=>Ba("blank",e.at(-1)??null),children:"Add slide"}):null]})}function Z4(){return p.jsx("div",{className:"pointer-events-none absolute -top-4 left-0 right-0 h-0.5 rounded bg-accent","aria-hidden":!0})}async function uSe(){try{await m8()}catch(n){ie.getState().fail(n instanceof Error?n.message:String(n));return}await tF();const e=ie.getState();if(e.status!=="ready")return;te.getState().showSlide(gae()),yae(),Nre(),uue();const t=io()?.room;t&&pue(t,{ids:()=>Ai.getState().peers.map(n=>n.id),subscribe:n=>Ai.subscribe((s,o)=>{s.peers!==o.peers&&n()})}),_he(),Ore(),Bue(),Oue(),e.readOnly||Vg.getState().set(Lue()),document.title=e.title||"Slides"}let Q4=!1;function dSe(){const e=ie(s=>!s.readOnly)&&gn(),t=Rt(s=>s.status);return On(s=>s.writing)?p.jsx(PF,{}):p.jsxs(Gl,{icon:p.jsx(_z,{className:"size-6"}),title:"This presentation has no slides yet",children:[p.jsx("p",{children:e?t.available?`Add one, or ask ${t.name} to add some.`:"Add one to get started.":"Slides will show here once they are added."}),e?p.jsx(bt,{className:"mt-2",variant:"primary",icon:p.jsx(fs,{className:"size-4"}),onClick:()=>Ba("blank",null),children:"Add slide"}):null]})}function fSe(){const e=ie(b=>b.status),t=ie(b=>b.error),n=ie(b=>b.title),s=ie(b=>b.index.faces),o=pd(),r=te(b=>b.mode),i=te(b=>b.canvasEdit),l=te(b=>b.current),c=te(b=>b.showRail),u=te(b=>b.showProperties);C.useEffect(()=>{Q4||(Q4=!0,uSe());const b=Jce(),v=Jae(),w=Jte(window);return()=>{b(),v(),w()}},[]),C.useEffect(()=>{n&&(document.title=n)},[n]),C.useEffect(()=>{e==="ready"&&np(s,Ds)},[e,s]);const f=C.useRef(0);if(C.useEffect(()=>{if(e!=="ready")return;const b=l?o.indexOf(l):-1;if(b>=0){f.current=b;return}const v=o[Math.min(f.current,o.length-1)]??null;v!==l&&te.getState().showSlide(v)},[e,o,l]),e==="loading")return p.jsx("div",{className:"flex h-full items-center justify-center bg-canvas",children:p.jsx(p0,{className:"size-5 animate-spin text-fg-subtle","aria-label":"Loading"})});if(e==="error")return p.jsx("div",{className:"h-full bg-canvas",children:p.jsx(Gl,{icon:p.jsx(xo,{className:"size-6"}),title:"This presentation could not be opened",children:t})});const h=r==="edit"||i,g=o.length===0,m=r==="edit"&&c&&!g;return p.jsx(II,{fallback:p.jsx(DF,{}),children:p.jsx(y0e,{children:p.jsxs("div",{className:"flex h-full bg-stage text-fg",children:[m?p.jsx(L0e,{}):null,p.jsxs("div",{className:"flex min-w-0 flex-1 flex-col",children:[p.jsx(bpe,{}),p.jsxs("main",{className:"relative flex min-h-0 min-w-0 flex-1",children:[r==="edit"?g?p.jsx(dSe,{}):p.jsx(GH,{}):r==="grid"?p.jsx(cSe,{}):p.jsx(sSe,{}),p.jsx(Gbe,{onStage:h&&!g,startCard:!m}),p.jsx(E0e,{}),p.jsx(Spe,{}),p.jsx(kpe,{})]})]}),h&&u&&!g?p.jsx(xwe,{}):null,p.jsx(dxe,{}),p.jsx(Epe,{}),p.jsx(Hue,{}),p.jsx(Lwe,{})]})})})}const Ll=hs()(e=>({current:null,show(t){e({current:t})}}));function v2(){const e=ie.getState();return Owe(mn(e),t=>!!e.slides[t]?.slide.hidden)}function hSe(e){const t=ie.getState().slides[e]?.slide;return t?Mi(t):void 0}async function pSe(){try{await m8()}catch(o){ie.getState().fail(o instanceof Error?o.message:String(o));return}await tF({readOnly:!0});const e=ie.getState();if(e.status!=="ready")return;document.title=e.title||"Slides",Ll.getState().show(v2()[0]??null);const n=io()?.shell;if(!n)return;n.onFilesChanged(()=>!0),n.onCommand(o=>{if(o.cmd!=="goto_slide")return;const r=kC(o.hash);r&&v2().includes(r)&&Ll.getState().show(r)});const s=o=>{o&&n.currentSlide(SC(o))};s(Ll.getState().current),Ll.subscribe((o,r)=>{o.current!==r.current&&s(o.current)})}let J4=!1;function mSe({slide:e,scale:t}){const n=C.useMemo(()=>{const l=ec(e);return AC(e,l,l.length,!1)},[e]),[s,o]=C.useState(()=>new Set),r=C.useCallback(l=>o(c=>new Set(c).add(l)),[]),i=C.useMemo(()=>({mode:"present",resolveSrc:Ds,builds:n,startedClips:s,onStartClip:r}),[n,s,r]);return p.jsx("div",{className:"absolute left-1/2 top-1/2 overflow-hidden",style:{width:Xe*t,height:ft*t,translate:"-50% -50%"},children:p.jsx("div",{className:"origin-top-left",style:{width:Xe,height:ft,transform:`scale(${t})`},children:p.jsx(Ka,{slide:e,options:i})})})}function gSe({index:e,count:t,title:n,go:s}){const{counter:o,announcement:r}=j9(e,t,n),i=l=>{if(!(l.altKey||l.ctrlKey||l.metaKey)){if(l.key==="ArrowLeft"&&e>0)s(e-1);else if(l.key==="ArrowRight"&&e<t-1)s(e+1);else return;l.preventDefault()}};return p.jsxs("nav",{"aria-label":"Slides",className:"flex h-11 shrink-0 items-center justify-center gap-2 border-t border-chrome-sep bg-chrome text-chrome-fg",onKeyDown:i,children:[p.jsx(Cs,{label:"Previous slide",icon:p.jsx(xE,{className:"size-4"}),disabled:e===0,onClick:()=>s(e-1)}),p.jsx("span",{className:"min-w-14 text-center text-xs tabular-nums text-chrome-muted","aria-hidden":"true",children:o}),p.jsx(Cs,{label:"Next slide",icon:p.jsx(Fy,{className:"size-4"}),disabled:e>=t-1,onClick:()=>s(e+1)}),p.jsx("span",{className:"sr-only",role:"status","aria-live":"polite",children:r})]})}function ySe(){const e=ie(m=>m.status),t=ie(m=>m.error),n=ie(m=>m.index.faces),s=ie(bb(()=>v2())),o=Ll(m=>m.current),r=ie(m=>o?m.slides[o]?.slide:void 0),i=ie(m=>o?m.slides[o]?.held:void 0),l=C.useRef(null),c=mc(l),u=C.useRef(0);C.useEffect(()=>{J4||(J4=!0,pSe())},[]),C.useEffect(()=>{e==="ready"&&np(n,Ds)},[e,n]),C.useEffect(()=>{if(e!=="ready")return;const m=$we(s,o,u.current);m!==o?Ll.getState().show(m):o&&(u.current=s.indexOf(o))},[e,s,o]);const f=C.useCallback(m=>{const b=s[m];b&&Ll.getState().show(b)},[s]);if(e==="loading")return p.jsx("div",{className:"flex h-full items-center justify-center bg-canvas",children:p.jsx(p0,{className:"size-5 animate-spin text-fg-subtle","aria-label":"Loading"})});if(e==="error")return p.jsx("div",{className:"h-full bg-canvas",children:p.jsx(Gl,{icon:p.jsx(xo,{className:"size-6"}),title:"This presentation could not be opened",children:t})});if(s.length===0)return p.jsx("div",{className:"h-full bg-canvas",children:p.jsx(Gl,{icon:p.jsx(_z,{className:"size-6"}),title:"This presentation has no slides yet",children:p.jsx("p",{children:"Slides will show here once they are added."})})});const h=o?Math.max(0,s.indexOf(o)):0,g=c?Math.min(c.w/Xe,c.h/ft):0;return p.jsx(II,{fallback:p.jsx(DF,{viewing:!0}),children:p.jsxs("div",{"data-open-artifact-inline-view":"",className:"flex h-full flex-col bg-stage",children:[p.jsx("div",{ref:l,className:"relative min-h-0 flex-1 overflow-hidden","data-open-artifact-slide":o??void 0,children:r&&g>0?p.jsx(mSe,{slide:r,scale:g},r.id):null}),i?p.jsxs("p",{role:"note",className:"flex shrink-0 items-center gap-1.5 border-t border-chrome-sep bg-chrome px-3 py-1.5 text-xs text-chrome-muted",children:[p.jsx(xo,{className:"size-3.5 shrink-0"}),"This slide's file has errors, so it may not show as written: ",i]}):null,s.length>1?p.jsx(gSe,{index:h,count:s.length,title:o?hSe(o):void 0,go:f}):null]})})}S2.createRoot(document.getElementById("root")).render(p.jsx(C.StrictMode,{children:p.jsxs(kG,{children:[Nwe(window)?p.jsx(ySe,{}):p.jsx(fSe,{}),p.jsx(kJ,{})]})}));export{OSe as C,LSe as F,V4 as I,MSe as K,TSe as M,wSe as O,DSe as P,ASe as T,$Se as a,_Se as b,RSe as c,jSe as d,NSe as e,SSe as f,CSe as g,ESe as h,kSe as i,p1e as j,C1e as k,T1e as l,du as p,xSe as s,vSe as v,bSe as w};
661
+ `)}return kS.read}function D4(e,t){const n=new Map,s=e.querySelector("[data-open-artifact-slide]");s&&n.set(0,{element:s});const o=(r,i)=>{r.forEach((l,c)=>{const u=[...i,c];if(l.origin!==void 0){const h=e.querySelector(`[data-open-artifact-path="${u.join(".")}"]`);h&&n.set(l.origin,{element:h,node:l})}const f=l.children;Array.isArray(f)&&o(f,u)})};return o(t.children,[]),n}function Awe(e,t,n,s){const o=t.motion;C.useLayoutEffect(()=>{const i=e.current;if(!s||!o||!i||g2())return;const l=jwe(),c=D4(i,t),u=[];let f="";const h=`open-artifact-start-${Math.random().toString(36).slice(2,8)}`,g=new Set([...Object.keys(o.elements),...Object.keys(o.starting)].map(Number));for(const b of g){const v=c.get(b);if(!v||v.node?.buildIn||v.node?.buildOut)continue;const w=o.elements[b]??{},{animation:E,keyframes:M,count:S}=_B(w,o.starting[b],l,`${h}-${b}`);if(!E)continue;f+=M;const k=v.element;k.style.animation=E;const R=S?xle(k,S):void 0;u.push(()=>{k.style.animation="",R?.()})}let m;return f&&(m=document.createElement("style"),m.textContent=f,document.head.append(m)),()=>{for(const b of u)b();m?.remove()}},[e,t,o,s]);const r=C.useMemo(()=>[...n].sort((i,l)=>i-l).join(","),[n]);C.useLayoutEffect(()=>{const i=e.current;if(!i||!o?.fragments.length)return;const l=D4(i,t),c=g2()?"":`opacity ${dh}ms ease`;for(const u of o.fragments){const f=l.get(u.origin)?.element;f&&(f.style.transition=c,f.style.opacity=n.has(u.origin)?"0":"")}},[e,t,o,r])}function Nwe(e){return e.parent!==e&&e.location.hash===Oee}function Owe(e,t){const n=e.filter(s=>!t(s));return n.length>0?n:[...e]}function $we(e,t,n){return t&&e.includes(t)?t:e.length===0?null:e[Math.min(Math.max(n,0),e.length-1)]}function j9(e,t,n){const s=`${e+1} / ${t}`,o=`Slide ${e+1} of ${t}`;return{counter:s,announcement:n?`${o}: ${n}`:o}}const _we=3e3;function z4({slide:e,done:t,animate:n,scale:s,rootRef:o,startedClips:r,onStartClip:i,className:l,motion:c=!1}){const u=C.useMemo(()=>ec(e),[e]),f=C.useMemo(()=>AC(e,u,t,n),[e,u,t,n]),h=C.useMemo(()=>ile(e,u,t),[e,u,t]),g=C.useMemo(()=>({mode:"present",resolveSrc:Ds,builds:f,startedClips:r,onStartClip:i}),[f,r,i]),m=C.useRef(null);return Awe(m,e,h,c),p.jsx("div",{ref:m,className:ze("absolute left-1/2 top-1/2",l),style:{width:Xe*s,height:ft*s,translate:"-50% -50%"},children:p.jsx("div",{className:"origin-top-left overflow-hidden",style:{width:Xe,height:ft,transform:`scale(${s})`},children:p.jsx(Ka,{slide:e,options:g,rootRef:o})})})}function Lwe(){const e=te(s=>s.presenting),t=te(s=>s.presentRun);if(!e)return null;const n=e.only===!0;return p.jsx(zwe,{start:e.start,speaker:e.speaker&&!n,only:n},t)}function P4(e){const t=ie.getState().slides[e]?.slide;return t?ec(t).length:0}function Dwe(e){const t=e.style.background;return t&&!t.includes("url(")?t:void 0}function zwe({start:e,speaker:t,only:n}){const s=ie(bb(()=>mi())),[o,r]=C.useState(()=>({id:e,done:n?P4(e):0,animate:!1})),i=Math.max(0,s.indexOf(o.id)),l=ie(Y=>Y.slides[o.id]?.slide),c=C.useMemo(()=>l?ec(l):[],[l]),[u,f]=C.useState(null),[h,g]=C.useState(()=>new Set),[m,b]=C.useState(!0),[v,w]=C.useState(!1),[E,M]=C.useState(!1),[S,k]=C.useState(null),[R,N]=C.useState(()=>({startedAt:Date.now(),pausedAt:null})),O=C.useRef(null),A=C.useRef(null),$=C.useRef(null),D=C.useRef(null),z=C.useRef(null),[_,L]=C.useState({w:window.innerWidth,h:window.innerHeight}),B=t&&E,U=B?_.h*.72:_.h,I=Math.min(_.w/Xe,U/ft);C.useEffect(()=>{xk(o.id,n?{position:i+1,count:s.length}:void 0)},[o.id,n,i,s.length]),C.useEffect(()=>{if(s.length===0){te.getState().present(null);return}if(!s.includes(o.id)){const Y=s[Math.min(i,s.length-1)];r({id:Y,done:n?P4(Y):0,animate:!1})}},[s,o.id,i,n]);const F=C.useCallback((Y,se,le={})=>{const re=mi()[Y];if(!re||re===o.id)return;D.current?.();const he=ie.getState(),Se=he.slides[o.id]?.slide,Oe=he.slides[re]?.slide;if(!Oe)return;const Ie=le.allDone?ec(Oe).length:0,Ne=!le.cut&&Se&&!g2()?Mwe(Se,Oe,se):null;f(Ne&&Se?{slide:Se,done:o.done,direction:se,kind:Ne}:null),g(new Set),r({id:re,done:Ie,animate:!1})},[o]),V=C.useCallback(()=>{if(u){D.current?.();return}if(n){i<s.length-1&&F(i+1,1,{allDone:!0});return}if(o.done<c.length){r(Y=>({...Y,done:Y.done+1,animate:!0}));return}i<s.length-1&&F(i+1,1)},[u,n,o.done,c.length,i,s.length,F]),W=C.useCallback(()=>{if(u&&D.current?.(),n){i>0&&F(i-1,-1,{allDone:!0});return}if(o.done>0){r(Y=>({...Y,done:Y.done-1,animate:!1}));return}i>0&&F(i-1,-1,{allDone:!0})},[u,n,o.done,i,F]),K=C.useCallback(()=>{const Y=o.id;document.fullscreenElement&&document.exitFullscreen().catch(()=>{}),te.getState().present(null),te.getState().showSlide(Y),xk(Y)},[o.id]);C.useEffect(()=>{if(u||!c[o.done]?.auto)return;const se=setTimeout(()=>r(le=>le.id===o.id?{...le,done:le.done+1,animate:!0}:le),o.done===0?0:dh);return()=>clearTimeout(se)},[u,c,o.id,o.done]),C.useLayoutEffect(()=>{if(!u||!$.current||!A.current||!l)return;const Y=Rwe(u.kind,{slide:u.slide,root:$.current},{slide:l,root:A.current},u.direction,I);let se=!0;return D.current=Y.finish,Y.done.then(()=>{se&&(D.current=null,f(null))}),()=>{se=!1}},[u]);const H=C.useRef({text:"",timer:null}),G=C.useCallback(Y=>{if(Y.target?.closest('textarea, input, [contenteditable="true"]')||Y.metaKey||Y.ctrlKey||Y.altKey)return;const le=Y.key;if(/^[0-9]$/.test(le)){const me=H.current;me.text=(me.text+le).slice(-3),me.timer&&clearTimeout(me.timer),me.timer=setTimeout(()=>{const re=Number(me.text);me.text="",re>=1&&re<=mi().length&&F(re-1,re-1>=i?1:-1,{cut:!0,allDone:n})},500);return}switch(le){case"ArrowRight":case"ArrowDown":case"PageDown":case" ":case"Enter":case"n":Y.preventDefault(),V();return;case"ArrowLeft":case"ArrowUp":case"PageUp":case"Backspace":case"p":Y.preventDefault(),W();return;case"Home":Y.preventDefault(),F(0,-1,{cut:!0,allDone:n});return;case"End":Y.preventDefault(),F(mi().length-1,1,{cut:!0,allDone:!0});return;case"f":case"F":if(n)return;Y.preventDefault(),I4(O.current);return;case"Escape":Y.preventDefault(),K();return}},[V,W,F,K,i,n]);C.useEffect(()=>(window.addEventListener("keydown",G),S?.addEventListener("keydown",G),()=>{window.removeEventListener("keydown",G),S?.removeEventListener("keydown",G)}),[G,S]),C.useEffect(()=>{const Y=()=>L({w:window.innerWidth,h:window.innerHeight}),se=()=>w(!!document.fullscreenElement);return window.addEventListener("resize",Y),document.addEventListener("fullscreenchange",se),!n&&O.current?.requestFullscreen&&!document.fullscreenElement&&O.current.requestFullscreen().catch(()=>{}),()=>{window.removeEventListener("resize",Y),document.removeEventListener("fullscreenchange",se)}},[n]);const X=C.useRef(null),Z=C.useCallback(()=>{b(!0),X.current&&clearTimeout(X.current),X.current=setTimeout(()=>b(!1),_we)},[]);C.useEffect(()=>(Z(),()=>{X.current&&clearTimeout(X.current)}),[Z]);const Q=C.useCallback(()=>{if(S&&!S.closed){S.focus();return}const Y=kwe();if(!Y){M(!0),Ke.add({title:"The speaker window was blocked",description:"Speaker notes show under the slide instead. Allow pop-ups for this site to open them in their own window."});return}M(!1),k(Y)},[S]);C.useEffect(()=>{t&&Q()},[]),C.useEffect(()=>()=>S?.close(),[S]);const ne=C.useCallback(Y=>g(se=>new Set([...se,Y])),[]);if(!l)return null;const J=s[i+1]??null;return p.jsxs("div",{ref:O,role:n?"group":"dialog","aria-modal":n?void 0:!0,"aria-label":n?j9(i,s.length,Mi(l)).announcement:"Presentation",tabIndex:n?0:void 0,"data-presenter-only":n?"":void 0,className:ze("fixed inset-0 z-[2000] select-none overflow-hidden",n?"outline-none focus-visible:outline-2 focus-visible:-outline-offset-4 focus-visible:outline-accent":"bg-black",!m&&!n&&"cursor-none"),style:n?{background:Dwe(l)??"#000"}:void 0,onPointerMove:n?void 0:Z,onPointerDown:Y=>{z.current={x:Y.clientX,y:Y.clientY}},onPointerUp:Y=>{const se=z.current;if(z.current=null,!se)return;const le=Y.clientX-se.x;Y.pointerType!=="mouse"&&Math.abs(le)>50&&Math.abs(le)>Math.abs(Y.clientY-se.y)&&(le<0?V():W())},onClick:Y=>{Y.target.closest("a, button, video, iframe, [data-presenter-controls], [data-presenter-notes]")||Y.detail>1||V()},onContextMenu:Y=>{Y.preventDefault(),W()},children:[p.jsxs("div",{className:"absolute inset-x-0 top-0",style:{height:U},children:[u?p.jsx(z4,{slide:u.slide,done:u.done,animate:!1,scale:I,rootRef:$,className:"z-[1]"}):null,p.jsx(z4,{slide:l,done:o.done,animate:o.animate,scale:I,rootRef:A,startedClips:h,onStartClip:ne,className:"z-[2]",motion:!0},o.id)]}),B?p.jsxs("div",{"data-presenter-notes":!0,className:"absolute inset-x-0 bottom-0 flex flex-col border-t border-white/15 bg-neutral-950 text-white",style:{height:_.h-U},children:[p.jsxs("div",{className:"px-4 pt-2 text-[11px] uppercase tracking-wide text-white/50",children:["Speaker notes · Slide ",i+1," of ",s.length]}),p.jsx(ST,{slideId:o.id,className:"h-full w-full resize-none bg-transparent px-4 py-2 text-lg leading-relaxed text-white outline-none placeholder:text-white/40"},o.id)]}):null,n?null:p.jsxs("div",{"data-presenter-controls":!0,className:ze("absolute bottom-4 left-1/2 flex -translate-x-1/2 items-center gap-1 rounded-full bg-neutral-900/85 px-2 py-1 text-white shadow-lg backdrop-blur transition-opacity duration-300",m?"opacity-100":"pointer-events-none opacity-0"),style:B?{bottom:_.h-U+16}:void 0,children:[p.jsx(Cs,{label:"Previous",shortcut:"←",icon:p.jsx(xE,{className:"size-4"}),className:"text-white hover:bg-white/15 hover:text-white",disabled:i===0&&o.done===0,onClick:W}),p.jsxs("span",{className:"min-w-16 text-center text-xs tabular-nums text-white/80",children:[i+1," / ",s.length]}),p.jsx(Cs,{label:"Next",shortcut:"→",icon:p.jsx(Fy,{className:"size-4"}),className:"text-white hover:bg-white/15 hover:text-white",disabled:i===s.length-1&&o.done>=c.length,onClick:V}),p.jsx("span",{className:"mx-1 h-4 w-px bg-white/20"}),p.jsx(Cs,{label:"Speaker notes",icon:p.jsx(_K,{className:"size-4"}),className:"text-white hover:bg-white/15 hover:text-white",onClick:Q}),p.jsx(Cs,{label:v?"Exit full screen":"Full screen",shortcut:"F",icon:v?p.jsx(wK,{className:"size-4"}):p.jsx(kE,{className:"size-4"}),className:"text-white hover:bg-white/15 hover:text-white",onClick:()=>I4(O.current)}),p.jsx(Cs,{label:"Stop presenting",shortcut:"Esc",icon:p.jsx(zr,{className:"size-4"}),className:"text-white hover:bg-white/15 hover:text-white",onClick:K})]}),S?p.jsx(Cwe,{popup:S,position:o,index:i,count:s.length,steps:c.length,nextId:J,clock:R,onClock:N,onNext:V,onPrevious:W,onClosed:()=>k(null)}):null]})}function I4(e){document.fullscreenElement?document.exitFullscreen().catch(()=>{}):e?.requestFullscreen?.().catch(()=>{})}const wi=hs()(()=>({drag:null})),Pwe=5;function Iwe(e,t){const n=[...e.querySelectorAll("[data-section-row]")];let s=n.length;for(const o of n){const r=o.getBoundingClientRect();if(t<r.top+r.height/2){s=Number(o.dataset.sectionRow);break}}return s}function Bwe(e,t){if(e.button!==0||!gn())return;const n=e.currentTarget.closest("[data-section-rows]");if(!n)return;const s=[...n.querySelectorAll("[data-section-row]")].map(m=>m.dataset.sectionKey||null),o=e.clientX,r=e.clientY;let i=!1;const l=()=>{const m=te.getState().sectionSelection,b=m.includes(t)?m:[t];return s.filter(v=>v!==null&&b.includes(v))},c=m=>{if(!i){if(Math.hypot(m.clientX-o,m.clientY-r)<Pwe)return;i=!0,document.body.style.cursor="grabbing"}wi.setState({drag:{keys:l(),gap:Iwe(n,m.clientY)}});const b=n.closest("[data-section-scroll]");if(b){const v=b.getBoundingClientRect();m.clientY<v.top+32?b.scrollBy(0,-12):m.clientY>v.bottom-32&&b.scrollBy(0,12)}},u=m=>{window.removeEventListener("pointermove",c),window.removeEventListener("pointerup",f),window.removeEventListener("pointercancel",h),window.removeEventListener("keydown",g,!0),document.body.style.cursor="";const b=wi.getState().drag;if(wi.setState({drag:null}),!i){m&&te.getState().sectionSelection.length>1&&te.getState().selectSections([t]);return}m&&b&&b.gap!==null&&b.keys.length&&Aae(b.keys,b.gap)},f=()=>u(!0),h=()=>u(!1),g=m=>{m.key!=="Escape"||!i||(m.preventDefault(),m.stopPropagation(),u(!1))};window.addEventListener("pointermove",c),window.addEventListener("pointerup",f),window.addEventListener("pointercancel",h),window.addEventListener("keydown",g,!0)}const A9=C.memo(function({id:t,index:n,comments:s,peers:o,dragging:r,dropBefore:i,dropAfter:l,onPointerDown:c,onOpen:u,width:f}){const h=ie(E=>E.slides[t]),g=te(E=>E.current===t),m=te(E=>E.slideSelection.includes(t)),b=IF(t);if(!h)return null;const v=h.held??(h.conflict?"Changed elsewhere at the same time":null),w=Mi(h.slide);return p.jsxs(Bb,{menu:p.jsx(Fb,{ids:te.getState().slideSelection.includes(t)?Ko():[t]}),onOpen:()=>{te.getState().slideSelection.includes(t)||te.getState().showSlide(t)},className:"relative shrink-0 outline-none",style:f?{width:f}:void 0,children:[i?p.jsx("span",{"aria-hidden":!0,className:"absolute -left-[13px] inset-y-0 w-1 rounded bg-accent"}):null,l?p.jsx("span",{"aria-hidden":!0,className:"absolute -right-[13px] inset-y-0 w-1 rounded bg-accent"}):null,p.jsxs("div",{"data-slide-index":n,"data-slide-id":t,role:"option","aria-selected":m||g,"aria-label":`Slide ${n+1}${w?`: ${w}`:""}`,onPointerDown:E=>c(E,t),onDoubleClick:()=>u(t),className:ze("group cursor-default",r&&"opacity-40",b&&"oa-arrive"),children:[p.jsxs("div",{className:ze("relative overflow-hidden rounded-md ring-1 ring-line transition-shadow",m||g?"ring-2 ring-accent":"group-hover:ring-line-strong",h.slide.hidden&&"opacity-50"),children:[p.jsx(oc,{slide:h.slide,virtual:!0}),p.jsxs("div",{className:"pointer-events-none absolute bottom-1.5 right-1.5 flex items-center gap-1",children:[p.jsx(wT,{peers:o}),s?p.jsxs("span",{className:"flex items-center gap-0.5 rounded-full bg-surface px-1.5 text-[10px] text-fg shadow-popup",children:[p.jsx(Da,{className:"size-2.5"}),s]}):null]})]}),p.jsxs("div",{className:"flex items-center gap-1.5 pt-1.5 text-[11px] text-fg-muted",children:[p.jsx("span",{className:ze("tabular-nums",(m||g)&&"font-semibold text-fg"),children:n+1}),p.jsx("span",{className:"min-w-0 flex-1 truncate",children:w}),h.slide.hidden?p.jsx(Lh,{className:"size-3 shrink-0","aria-label":"Skipped"}):null,v?p.jsx(xo,{className:"size-3 shrink-0 text-warning","aria-label":v}):null]})]})]})});function $T({section:e,n:t,ids:n,previousGap:s,nextGap:o,className:r}){const i=e?.key??"-",l=te(b=>b.editingSection===i),c=te(b=>b.sectionSelection.includes(i)),u=ie(b=>!b.readOnly&&!b.indexError)&&gn(),f=e?.description??"",h=`Section ${t+1}`,g=u&&(e!==null||n.length>0),m=b=>{te.getState().setEditingSection(null);const v=eC(b);v!==f&&(e?Rae(e.key,v):n[0]&&jae(n[0],v))};return p.jsxs("div",{"data-section-label":i,className:ze("group/label flex min-w-0 items-start gap-2 rounded-md px-1.5 py-1",c&&"bg-accent-soft",e&&u&&"cursor-grab",r),onPointerDown:b=>{const v=b.target;if(b.button!==0||v.closest("textarea")||v.closest("button")&&!v.closest("[data-section-describe]"))return;const w=te.getState(),E=b.metaKey||b.ctrlKey||b.shiftKey;E?w.selectSections(c?w.sectionSelection.filter(M=>M!==i):[...w.sectionSelection,i]):(!c||!e||!u)&&w.selectSections([i]),w.selectSlides([...n]),e&&u&&!E&&Bwe(b,e.key)},children:[p.jsxs("div",{className:"min-w-0 flex-1",children:[p.jsx("div",{className:"text-[11px] font-semibold uppercase tracking-wide text-fg-muted",children:h}),l?p.jsx(Fwe,{initial:f,onCommit:m,onCancel:()=>te.getState().setEditingSection(null)}):p.jsx("button",{type:"button","data-section-describe":!0,disabled:!g,"aria-label":f||(g?`${h}, Describe this section`:h),className:ze("block max-w-full truncate text-left text-sm",f?"text-fg":"text-fg-subtle",g&&"hover:text-fg"),onClick:()=>g&&te.getState().setEditingSection(i),children:f||(g?"Describe this section":"")})]}),u&&e?p.jsxs(RP,{trigger:p.jsx(Cs,{size:"sm",noTooltip:!0,label:`Actions for ${h}`,icon:p.jsx(wE,{className:"size-3.5"}),className:"opacity-0 group-hover/label:opacity-100 focus-visible:opacity-100 pointer-coarse:opacity-100"}),align:"end",children:[p.jsxs(pt,{onSelect:()=>te.getState().setEditingSection(i),children:["Describe ",h]}),p.jsx(pt,{disabled:s===null,onSelect:()=>s!==null&&f_(e.key,s),children:"Move section earlier"}),p.jsx(pt,{disabled:o===null,onSelect:()=>o!==null&&f_(e.key,o),children:"Move section later"}),p.jsx(pt,{icon:p.jsx(fs,{className:"size-4"}),disabled:n.length===0,onSelect:()=>{Ba("blank",n.at(-1)??null)},children:"Add a slide to this section"}),p.jsx(pt,{icon:p.jsx(Hy,{className:"size-4"}),danger:!0,onSelect:()=>Mae(e.key),children:"Remove section"})]}):null]})}function Fwe({initial:e,onCommit:t,onCancel:n}){const[s,o]=C.useState(e),r=C.useRef(null),i=C.useRef(!1);return C.useEffect(()=>{r.current?.focus(),r.current?.select()},[]),p.jsx("textarea",{ref:r,rows:2,value:s,maxLength:ve.sectionDescription,placeholder:"Describe this section","aria-label":"Section description",className:"mt-0.5 block w-full resize-none rounded border border-accent bg-canvas px-1.5 py-1 text-sm text-fg outline-none",onChange:l=>o(l.target.value.replace(/\n/g," ")),onBlur:()=>{i.current||(i.current=!0,t(s))},onKeyDown:l=>{l.stopPropagation(),l.key==="Enter"?(l.preventDefault(),i.current=!0,t(s)):l.key==="Escape"&&(l.preventDefault(),i.current=!0,n())}})}function _T({gap:e,after:t,className:n}){return gn()?p.jsxs(RP,{trigger:p.jsx("button",{type:"button","aria-label":"Add a slide or section here",className:ze("flex size-6 items-center justify-center rounded-full border border-line bg-surface text-fg-muted opacity-0 shadow-popup transition-opacity hover:text-fg focus-visible:opacity-100 group-hover/gap:opacity-100 pointer-coarse:opacity-100",n),children:p.jsx(fs,{className:"size-3.5"})}),align:"center",children:[p.jsx(pt,{icon:p.jsx(fs,{className:"size-4"}),onSelect:()=>{Ba("blank",t)},children:"New slide here"}),p.jsx(pt,{icon:p.jsx(qS,{className:"size-4"}),onSelect:()=>Tae(e),children:"New section here"})]}):null}const Es=480,nd=28,bo=48,dr=96,lr=320;function Hwe(e,t,n){const s=Es*n/t,o=s+nd,r=[],i=new Map,l=[];let c=0;e.forEach((f,h)=>{const g=h*(o+dr);l.push({row:h,section:f.section,key:f.section?.key??null,top:g,first:c,ids:f.ids,empty:f.ids.length===0?{x:lr,y:g,w:Es,h:s}:null}),f.ids.forEach((m,b)=>{const v={id:m,index:c++,row:h,x:lr+b*(Es+bo),y:g,w:Es,h:s};r.push(v),i.set(m,v)})});const u=Math.max(1,...e.map(f=>f.ids.length));return{tiles:r,byId:i,rows:l,slideH:s,tileH:o,width:lr+u*Es+(u-1)*bo,height:Math.max(1,e.length)*(o+dr)-dr}}const y2=(e,t,n)=>t>=e.x&&t<e.x+e.w&&n>=e.y&&n<e.y+e.h;function Uwe(e,t){const n=e.tileH+dr,s=Math.floor((t+dr/2)/n);return e.rows[Math.min(e.rows.length-1,Math.max(0,s))]}function B4(e,t,n){const s=Uwe(e,n);if(!s||!s.ids.length)return null;const o=Math.floor((t-lr)/(Es+bo)),r=s.ids[o],i=r===void 0?void 0:e.byId.get(r);return i?y2(i,t,n)?{tile:i,caption:!1}:y2({x:i.x,y:i.y+i.h,w:i.w,h:nd},t,n)?{tile:i,caption:!0}:null:null}function Vwe(e,t,n){for(const s of e.rows)if(s.empty&&s.key&&y2(s.empty,t,n))return s.key;return null}function qwe(e,t,n){let s=null,o=1/0;for(const r of e.tiles){const i=r.y+e.tileH,l=t<r.x?r.x-t:t>r.x+r.w?t-r.x-r.w:0,u=(n<r.y?r.y-n:n>i?n-i:0)*4+l;u<o&&(s=r,o=u)}return s?s.index+(t>s.x+s.w/2?1:0):0}function Wwe(e,t){const n=[],s=e.tiles[t],o=e.tiles[t-1];return s&&n.push({x:s.x-bo/2-2,y:s.y,w:4,h:e.tileH}),o&&(!s||s.row!==o.row)&&n.push({x:o.x+o.w+bo/2-2,y:o.y,w:4,h:e.tileH}),n}function b2(e,t){const n=[];for(const s of e.tiles)s.x<t.x+t.w&&s.x+s.w>t.x&&s.y<t.y+t.h&&s.y+e.tileH>t.y&&n.push(s);return n}function Gwe(e,t){return{x:e.x-e.w*t,y:e.y-e.h*t,w:e.w*(1+t*2),h:e.h*(1+t*2)}}const Sf=32,Ywe=1,Kwe=2,Xwe=3,Zwe=0,Qwe=1,Jwe=2,e1e=1,t1e=2,n1e=4,s1e=8,o1e=16,r1e=32,i1e=64,a1e=128,l1e=256,c1e=512,u1e=1024,d1e=2048,f1e=4096,h1e=8192,p1e=2,N9=0,Xf=1,F4=2,x2=3,O9=4,wSe={minZoom:1,maxZoom:2,snap:3,snapDistance:4,dragThreshold:5,hitTolerance:6,handleSize:7,settleMs:8,cameraEventMs:9,wheelZoom:10,selection:11,marquee:12,fadeMs:13,dragEvents:14,grid:15,gridSpacing:16,textureBudget:17,zoomSpeed:18,wheelZoomMax:19,gridMajor:20,gridFadeStart:21,gridFadeEnd:22},SSe={background:30,grid:31,selection:32,handle:33,guide:34,marquee:35,hover:36},kSe=1,ESe=2,CSe=4,TSe=8,MSe=1,RSe=2,jSe=3,ASe={select:0,pan:1,none:2},NSe={mouse:0,pen:1,touch:2},OSe=["default","grab","grabbing","move","ns-resize","ew-resize","nwse-resize","nesw-resize","crosshair"],$Se=1,_Se=2,LSe=4,m1e={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074},g1e=/^[-+]?(?:\d+\.?\d*|\.\d+)(?:e[-+]?\d+)?/;function Kb(e){const t=g1e.exec(e);if(!t)return null;const n=e.slice(t[0].length);return/^(%|deg|rad|grad|turn)?$/.test(n)?{v:parseFloat(t[0]),unit:n}:null}function y1e(e){const t=e.includes(","),[n,s,o]=t?[e,void 0,void 0]:e.split("/");if(o!==void 0)return null;const r=n.split(t?",":/\s+/).map(c=>c.trim()).filter(Boolean);if(t?r.length!==3&&r.length!==4:r.length!==3)return null;const i=t?r[3]:s?.trim();if(i==="")return null;const l=c=>c==="none"?"0":c;return[l(r[0]),l(r[1]),l(r[2]),i===void 0?void 0:l(i)]}function b1e(e){if(e===void 0)return 1;const t=Kb(e);return!t||t.unit&&t.unit!=="%"?NaN:t.unit==="%"?t.v/100:t.v}function x1e(e){const t=Kb(e);if(!t)return NaN;switch(t.unit){case"":case"deg":return t.v;case"rad":return t.v*180/Math.PI;case"grad":return t.v*.9;case"turn":return t.v*360;default:return NaN}}function H4(e){const t=Kb(e);return t?t.unit==="%"||t.unit===""?t.v/100:NaN:NaN}function U4(e,t,n,s){const o=(r,i)=>Math.round(Math.min(Math.max(r,0),i));return(o(e,255)<<24|o(t,255)<<16|o(n,255)<<8|o(s*255,255))>>>0}function v1e(e,t,n){const s=(e%360+360)%360,o=l=>(l+s/30)%12,r=t*Math.min(n,1-n),i=l=>n-r*Math.max(-1,Math.min(o(l)-3,9-o(l),1));return[i(0)*255,i(8)*255,i(4)*255]}function du(e,t=0){if(e==null)return t;if(typeof e=="number")return e>>>0;const n=e.trim().toLowerCase();if(n==="transparent"||n==="none")return 0;const s=m1e[n];if(s!==void 0)return(s<<8|255)>>>0;if(n.startsWith("#")){const l=n.slice(1);if(/^[0-9a-f]+$/.test(l)){if(l.length===3||l.length===4){const c=[...l].map(u=>u+u).join("");return parseInt(l.length===3?c+"ff":c,16)>>>0}if(l.length===6)return parseInt(l+"ff",16)>>>0;if(l.length===8)return parseInt(l,16)>>>0}}const o=/^(rgba?|hsla?)\(\s*([^()]*)\)$/.exec(n),r=o?y1e(o[2]):null;if(o&&r){const[l,c,u,f]=r,h=b1e(f);if(o[1].startsWith("rgb")){const g=b=>{const v=Kb(b);return v?v.unit==="%"?v.v/100*255:v.unit===""?v.v:NaN:NaN},m=[g(l),g(c),g(u)];if([...m,h].every(Number.isFinite))return U4(m[0],m[1],m[2],h)}else{const g=x1e(l),m=Math.min(Math.max(H4(c),0),1),b=Math.min(Math.max(H4(u),0),1);if([g,m,b,h].every(Number.isFinite)){const[v,w,E]=v1e(g,m,b);return U4(v,w,E,h)}}}const i=w1e(n);if(i!==null)return i;throw new TypeError(`canvas-engine: unsupported colour ${JSON.stringify(e)}`)}let Po;const Eg=new Map;function w1e(e){const t=Eg.get(e);if(t!==void 0)return t;Po===void 0&&(Po=typeof OffscreenCanvas<"u"?new OffscreenCanvas(1,1).getContext("2d",{willReadFrequently:!0}):typeof document<"u"?document.createElement("canvas").getContext("2d",{willReadFrequently:!0}):null);let n=null;if(Po){Po.fillStyle="#000",Po.fillStyle=e;const s=Po.fillStyle;if(Po.fillStyle="#fff",Po.fillStyle=e,s===Po.fillStyle){Po.clearRect(0,0,1,1),Po.fillRect(0,0,1,1);const[o,r,i,l]=Po.getImageData(0,0,1,1).data;n=l===0?0:(o<<24|r<<16|i<<8|l)>>>0}}return Eg.size>512&&Eg.clear(),Eg.set(e,n),n}function S1e(e){let t=0;return e.visible!==!1&&(t|=e1e),e.hittable!==!1&&(t|=t1e),e.selectable!==!1&&(t|=n1e),e.movable!==!1&&(t|=s1e),e.resizable!==!1&&(t|=o1e),e.snap!==!1&&(t|=r1e),e.lockAspect&&(t|=i1e),e.hitStrokeOnly&&(t|=a1e),e.screenStroke&&(t|=l1e),e.hover===!1&&(t|=c1e),e.selectionOutline===!1&&(t|=u1e),e.handles==="corners"?t|=d1e:e.handles==="width"&&(t|=f1e),e.blend==="multiply"&&(t|=h1e),t}function k1e(e){const t=/([MmLlHhVvCcSsQqTtAaZz])|([-+]?(?:\d+\.?\d*|\.\d+)(?:[eE][-+]?\d+)?)/g,n=[];let s;for(;s=t.exec(e);)n.push(s[1]?{cmd:!0,raw:s[1]}:{cmd:!1,raw:s[2]});return n}function E1e(e,t,n,s,o,r,i,l,c,u){if(s===0||o===0){e.push(Xf,c,u);return}if(t===c&&n===u)return;s=Math.abs(s),o=Math.abs(o);const f=r*Math.PI/180,h=Math.cos(f),g=Math.sin(f),m=(t-c)/2,b=(n-u)/2,v=h*m+g*b,w=-g*m+h*b,E=v*v/(s*s)+w*w/(o*o);if(E>1){const V=Math.sqrt(E);s*=V,o*=V}const M=s*s*o*o-s*s*w*w-o*o*v*v,S=s*s*w*w+o*o*v*v;let k=Math.sqrt(Math.max(0,M/S));i===l&&(k=-k);const R=k*s*w/o,N=-k*o*v/s,O=h*R-g*N+(t+c)/2,A=g*R+h*N+(n+u)/2,$=(V,W,K,H)=>Math.atan2(V*H-W*K,V*K+W*H),D=$(1,0,(v-R)/s,(w-N)/o);let z=$((v-R)/s,(w-N)/o,(-v-R)/s,(-w-N)/o);!l&&z>0&&(z-=2*Math.PI),l&&z<0&&(z+=2*Math.PI);const _=Math.max(1,Math.ceil(Math.abs(z)/(Math.PI/2))),L=z/_,B=4/3*Math.tan(L/4);let U=D;const I=V=>{const W=s*Math.cos(V),K=o*Math.sin(V);return[O+h*W-g*K,A+g*W+h*K]},F=V=>{const W=-s*Math.sin(V),K=o*Math.cos(V);return[h*W-g*K,g*W+h*K]};for(let V=0;V<_;V++){const W=U+L,[K,H]=I(U),[G,X]=I(W),[Z,Q]=F(U),[ne,J]=F(W);e.push(x2,K+B*Z,H+B*Q,G-B*ne,X-B*J,V===_-1?c:G,V===_-1?u:X),U=W}}function C1e(e){const t=[],n=k1e(e);let s=0,o="",r=0,i=0,l=0,c=0,u=0,f=0,h="";const g=()=>{const b=n[s];if(!b||b.cmd)throw new SyntaxError(`canvas-engine: bad path data near token ${s} in ${JSON.stringify(e.slice(0,80))}`);return s++,parseFloat(b.raw)},m=()=>{const b=n[s];if(!b||b.cmd||b.raw[0]!=="0"&&b.raw[0]!=="1")throw new SyntaxError(`canvas-engine: bad arc flag near token ${s}`);return b.raw.length>1?n[s]={cmd:!1,raw:b.raw.slice(1)}:s++,b.raw[0]==="1"};for(;s<n.length;){const b=n[s];if(b.cmd)o=b.raw,s++;else if(!o)throw new SyntaxError("canvas-engine: path data must start with a command");const v=o===o.toLowerCase(),w=v?r:0,E=v?i:0;switch(o.toUpperCase()){case"M":{r=w+g(),i=E+g(),l=r,c=i,t.push(N9,r,i),o=v?"l":"L",h="M";break}case"L":r=w+g(),i=E+g(),t.push(Xf,r,i),h="L";break;case"H":r=w+g(),t.push(Xf,r,i),h="L";break;case"V":i=E+g(),t.push(Xf,r,i),h="L";break;case"C":{const M=w+g(),S=E+g();u=w+g(),f=E+g(),r=w+g(),i=E+g(),t.push(x2,M,S,u,f,r,i),h="C";break}case"S":{const M=h==="C"?2*r-u:r,S=h==="C"?2*i-f:i;u=w+g(),f=E+g(),r=w+g(),i=E+g(),t.push(x2,M,S,u,f,r,i),h="C";break}case"Q":u=w+g(),f=E+g(),r=w+g(),i=E+g(),t.push(F4,u,f,r,i),h="Q";break;case"T":u=h==="Q"?2*r-u:r,f=h==="Q"?2*i-f:i,r=w+g(),i=E+g(),t.push(F4,u,f,r,i),h="Q";break;case"A":{const M=g(),S=g(),k=g(),R=m(),N=m(),O=w+g(),A=E+g();E1e(t,r,i,M,S,k,R,N,O,A),r=O,i=A,h="A";break}case"Z":if(t.push(O9),r=l,i=c,h="Z",n[s]&&!n[s].cmd)throw new SyntaxError("canvas-engine: numbers after Z in path data");break;default:throw new SyntaxError(`canvas-engine: unknown path command ${o}`)}}return t}function T1e(e,t=!1){const n=[];for(let s=0;s+1<e.length;s+=2)n.push(s===0?N9:Xf,e[s],e[s+1]);return t&&n.length&&n.push(O9),n}class V4{#e=new Map;#t=[];#i=[];#o=[];get size(){return this.#e.size}get(t){return this.#e.get(t)}ensure(t){let n=this.#e.get(t);return n===void 0&&(n=this.#i.pop()??this.#t.length,this.#e.set(t,n),this.#t[n]=t),n}id(t){return this.#t[t]}ids(t){const n=[];for(let s=0;s<t.length;s++){const o=this.#t[t[s]];o!==void 0&&n.push(o)}return n}release(t){const n=this.#e.get(t);if(n!==void 0)return this.#e.delete(t),this.#t[n]=void 0,this.#o.push(n),n}clear(){for(const t of this.#e.values())this.#o.push(t);this.#e.clear(),this.#t.fill(void 0)}flush(){this.#i.push(...this.#o),this.#o.length=0}}const M1e={butt:0,round:1,square:2},R1e={miter:0,round:1,bevel:2};class DSe{items=new V4;textures=new V4;#e=new Map;#t(t){const n=this.#e.get(t.id),s=t.closed??!1;if(n&&n.d===t.d&&n.points===t.points&&n.closed===s)return n.cmds;const o=t.d!==void 0?C1e(t.d):t.points?T1e(t.points,s):[];return this.#e.set(t.id,{d:t.d,points:t.points,closed:s,cmds:o}),o}encode(t){const n=t.upsert??[],s=t.remove??[],o=(t.clear?1:0)+s.length+n.length,r=new Float64Array(o*Sf),i=[];let l=0,c=0;t.clear&&(r[0]=Xwe,this.items.clear(),this.#e.clear(),c=1);for(const h of s){const g=this.items.release(h);if(this.#e.delete(h),g===void 0)continue;const m=c*Sf;r[m]=Kwe,r[m+1]=g,c++}for(const h of n){const g=c*Sf;switch(c++,r[g]=Ywe,r[g+1]=this.items.ensure(h.id),r[g+3]=h.layer??0,r[g+4]=h.z??0,r[g+5]=h.x,r[g+6]=h.y,r[g+7]=h.w,r[g+8]=h.h,r[g+9]=h.rotation??0,r[g+10]=S1e(h),r[g+11]=h.opacity??1,r[g+22]=-1,h.kind){case"hole":r[g+2]=Qwe,r[g+15]=h.radius??0;break;case"path":{r[g+2]=Jwe,r[g+12]=du(h.fill),r[g+13]=du(h.stroke),r[g+14]=h.strokeWidth??1,r[g+16]=h.dash?.[0]??0,r[g+17]=h.dash?.[1]??0;const m=this.#t(h);r[g+23]=l,r[g+24]=m.length,i.push(m),l+=m.length;const b=h.cuts?.slice(0,p1e)??[];if(b.length){const v=b.flatMap(w=>[w.x,w.y,w.w,w.h]);i.push(v),l+=v.length,r[g+31]=b.length}r[g+25]=h.viewBox?.[0]??0,r[g+26]=h.viewBox?.[1]??0,r[g+27]=M1e[h.cap??"butt"],r[g+28]=R1e[h.join??"miter"],r[g+29]=h.miterLimit??4,r[g+30]=h.fillRule==="evenodd"?1:0;break}default:r[g+2]=Zwe,r[g+12]=du(h.fill),r[g+13]=du(h.stroke),r[g+14]=h.strokeWidth??(h.stroke!==void 0?1:0),r[g+15]=h.radius??0,r[g+16]=h.dash?.[0]??0,r[g+17]=h.dash?.[1]??0,h.shadow&&(r[g+18]=du(h.shadow.color),r[g+19]=h.shadow.blur,r[g+20]=h.shadow.dx??0,r[g+21]=h.shadow.dy??0),h.texture!==void 0&&(r[g+22]=this.textures.ensure(h.texture))}}const u=new Float32Array(l);let f=0;for(const h of i)u.set(h,f),f+=h.length;return this.items.flush(),{ops:c*Sf===r.length?r:r.subarray(0,c*Sf),paths:u,records:c}}}const j1e=(()=>{try{return new URLSearchParams(location.search).get("open_artifact_engine")==="off"}catch{return!1}})(),A1e=.05,N1e=2,O1e=48,$1e=12,_1e=48,L1e=1.25,ES=160,D1e=6,z1e=6,P1e=500;let CS=null;function q4(){const e=ie.getState(),t=mn(e),n=ds($n(Yh({sections:e.index.sections}),t),t),s=`${Xe}:${JSON.stringify(n)}`;return{layout:Hwe(n,Xe,ft),key:s}}function $9(e){try{return du(e),e}catch{return null}}function W4(){const e=getComputedStyle(document.documentElement),t=(n,s)=>$9(e.getPropertyValue(n).trim())??s;return{accent:t("--open-artifact-accent","#2563eb"),accentSoft:t("--open-artifact-accent-soft","rgba(37, 99, 235, 0.12)"),line:t("--open-artifact-line","rgba(0, 0, 0, 0.1)"),lineStrong:t("--open-artifact-line-strong","rgba(0, 0, 0, 0.2)")}}async function I1e(e,t){const n=Array.from(e.querySelectorAll("img"),s=>s.decode().catch(()=>{}));await Promise.race([Promise.all(n),new Promise(s=>setTimeout(s,t))])}const G4=()=>new Promise(e=>requestAnimationFrame(()=>e())),TS=(e,t)=>`${e}|${t.key}`;class B1e{store;#e=null;#t=null;#i=!1;#o=[];#x;#r={x:0,y:0,zoom:1};#m=!1;#c=new Set;#T=new Set;#a=new Map;#f=new Set;#l=new Map;#u=new Map;#d=new Map;#g=[];#y=new Set;#h=new Map;#v=new Set;#w=new Set;#S=new Set;#b={accent:"#2563eb",accentSoft:"rgba(37, 99, 235, 0.12)",line:"rgba(0, 0, 0, 0.1)",lineStrong:"rgba(0, 0, 0, 0.2)"};#k=new Map;#p=null;#M=!1;#n=null;constructor(){const{layout:t,key:n}=q4();this.#x=n,this.store=FI()(()=>({layout:t,view:null,zoom:1,hover:null,live:[],drag:null,menu:null}))}async start(t,n){const{CanvasEngine:s}=await BI(async()=>{const{CanvasEngine:i}=await import("./src-mZdWgqty.js");return{CanvasEngine:i}},[],import.meta.url);if(this.#i)return;this.#b=W4();const o=await s.create(n,{selection:"controlled",snap:!1,grid:"none",minZoom:A1e,maxZoom:N1e,cameraEventMs:0,dragEvents:!0,dragThreshold:5,zoomSpeed:.01,wheelZoomMax:1/0,theme:this.#j()});if(this.#i){o.destroy();return}this.#e=o,this.#t=n;const r=(i,l)=>{this.#o.push(o.on(i,l))};r("camera",i=>this.#B(i)),r("moving",({moving:i})=>{i&&(this.#m=!0,this.#s())}),r("holes",({holes:i})=>this.#W(i)),r("textureNeeded",({keys:i})=>this.#q(i)),r("hover",({id:i})=>this.store.setState({hover:i})),r("gesture",i=>this.#X(i)),r("dragging",i=>this.#Z(i)),r("dblclick",({id:i,world:l})=>{const c=this.#I(i,l);c&&te.getState().editOnCanvas(c)}),r("contextmenu",({id:i,world:l,event:c})=>{const u=this.#I(i,l);if(!u){c?.stopPropagation();return}te.getState().slideSelection.includes(u)||te.getState().showSlide(u),this.store.setState({menu:u})}),r("commit",i=>{i.op==="select"?this.#M&&this.#J(i.ids):i.op==="move"&&this.#Q()}),this.#G(t,n),this.#V(),this.#O(),this.#s(),CS?o.setCamera(CS):this.fit(0),globalThis.__openArtifactCanvasEngine=()=>this.#ee()}destroy(){if(this.#i)return;this.#i=!0;for(const n of this.#o)n();this.#o.length=0,this.#e?.destroy(),this.#e=null,this.#n&&(te.getState().setDropGap(null),Wf([]));const t=globalThis;delete t.__openArtifactCanvasEngine}fit(t=300){const{layout:n}=this.store.getState();this.#e?.glideTo({x:0,y:0,w:n.width,h:n.height},{duration:t,padding:O1e,maxZoom:1})}zoomBy(t){this.#e?.zoomAt(t)}attachWorld(t){return this.#w.add(t),t.style.transform=this.#R(),()=>this.#w.delete(t)}attachZoomReadout(t){return this.#S.add(t),t.textContent=`${Math.round(this.#r.zoom*100)}%`,()=>this.#S.delete(t)}#R(){const{x:t,y:n,zoom:s}=this.#r;return`translate(${-t*s}px, ${-n*s}px) scale(${s})`}#B(t){this.#r={x:t.x,y:t.y,zoom:t.zoom},CS=this.#r;const n=this.#R();for(const o of this.#w)o.style.transform=n;const s=`${Math.round(t.zoom*100)}%`;for(const o of this.#S)o.textContent=s;LF(),t.settled&&(this.#m=!1,this.#E())}#E(){const t=this.#e;if(!t)return;const{layout:n}=this.store.getState(),s=t.viewport();this.#c=new Set(b2(n,s).map(i=>i.id));const o=this.#F(s),r=this.store.getState().live;this.#T=new Set(o),this.store.setState({view:s,zoom:this.#r.zoom,live:o.length===r.length&&o.every((i,l)=>r[l]===i)?r:o});for(const[i,l]of this.#h)this.#f.has(i)||this.#P(i,l);for(const i of this.#c){const l=this.#l.get(i);l&&this.#d.get(l)===1&&this.#N()&&this.#L(l)}this.#s()}#F(t){const{layout:n}=this.store.getState(),s=Es*this.#r.zoom,o=s*(devicePixelRatio||1),r=Xe*$F*L1e,i=t.x+t.w/2,l=t.y+t.h/2,c=s<_1e?[]:b2(n,t).filter(f=>!this.#C(f.id)||o>r).map(f=>({id:f.id,d:Math.hypot(f.x+f.w/2-i,f.y+f.h/2-l)})).sort((f,h)=>f.d-h.d).slice(0,$1e).map(f=>f.id),u=te.getState().current;return u&&this.#c.has(u)&&!c.includes(u)&&c.push(u),c}#s(){const t=this.#e;if(!t||this.#n)return;const{layout:n}=this.store.getState(),s=ie.getState(),o=gn(),r=new Set(wi.getState().drag?.keys??[]),i=[],l=new Set;let c=!1;for(const f of n.tiles){const h=s.slides[f.id]?.slide;if(!h)continue;const g=n.rows[f.row]?.key,m=this.#v.has(f.id)&&this.#T.has(f.id)&&!(this.#m&&this.#C(f.id)),b={id:f.id,x:f.x,y:f.y,w:f.w,h:f.h,radius:z1e,movable:o,resizable:!1,snap:!1},v=m?{...b,kind:"hole"}:{...b,kind:"image",fill:this.#H(h),stroke:this.#b.line,strokeWidth:1,screenStroke:!0,texture:this.#l.get(f.id),opacity:(h.hidden?.5:1)*(g&&r.has(g)?.4:1)};l.add(f.id),m?this.#f.add(f.id):this.#f.delete(f.id);const w=JSON.stringify(v);this.#a.get(f.id)!==w&&(this.#a.has(f.id)||(c=!0),this.#a.set(f.id,w),i.push(v))}const u=[...this.#a.keys()].filter(f=>!l.has(f));for(const f of u)this.#a.delete(f),this.#f.delete(f);(i.length||u.length)&&t.applyPatch({upsert:i,remove:u}),c&&this.#A()}#H(t){const n=t.style.background;if(!n||/url\(|gradient/i.test(n))return"#ffffff";let s=this.#k.get(n);return s===void 0&&(s=$9(n)??"#ffffff",this.#k.set(n,s)),s}#j(){const t=this.#b;return{background:"transparent",grid:"transparent",selection:t.accent,handle:t.accent,guide:t.accent,marquee:t.accentSoft,hover:t.lineStrong}}#A(){const t=te.getState(),n=new Set(t.slideSelection);t.current&&n.add(t.current),this.#e?.setSelection([...n].filter(s=>this.#a.has(s)))}#U(){const{layout:t,key:n}=q4();n!==this.#x?(this.#x=n,this.store.setState({layout:t}),this.#E()):this.#s()}#V(){const t=r=>{this.#o.push(r)};t(ie.subscribe((r,i)=>{(r.index!==i.index||r.slides!==i.slides||r.status!==i.status||r.readOnly!==i.readOnly)&&this.#U()})),t(te.subscribe((r,i)=>{(r.slideSelection!==i.slideSelection||r.current!==i.current)&&this.#A(),r.current!==i.current&&!this.#m&&this.#E()})),t(wi.subscribe(()=>this.#s())),t(Hs.subscribe((r,i)=>{r.snapshots!==i.snapshots&&this.#O()})),t(ape({ids:()=>this.store.getState().layout.byId.keys(),visible:()=>this.#c}));const n=()=>{this.#b=W4(),this.#k.clear(),this.#e?.setOptions({theme:this.#j()}),this.#a.clear(),this.#s()},s=matchMedia("(prefers-color-scheme: dark)");s.addEventListener("change",n),t(()=>s.removeEventListener("change",n));const o=new MutationObserver(n);o.observe(document.documentElement,{attributes:!0,attributeFilter:["data-theme"]}),t(()=>o.disconnect())}#C(t){const n=this.#l.get(t);return n!==void 0&&this.#d.has(n)}#N(){return Es*this.#r.zoom*(devicePixelRatio||1)>ES}#O(){const{snapshots:t}=Hs.getState(),n=new Set([...this.#l.keys(),...Object.keys(t)]);let s=!1;for(const o of n){const r=t[o],i=r?TS(o,r):void 0,l=this.#l.get(o);i===l||i&&this.#u.has(i)||(i&&l&&this.#c.has(o)?(this.#u.set(i,o),this.#z(i).finally(()=>{this.#$(o,i)&&this.#s()})):s=this.#$(o,i)||s)}s&&this.#s()}#$(t,n){if(this.#i)return!1;const s=Hs.getState().snapshots[t];if(n&&(!s||TS(t,s)!==n))return this.#_(n),!1;const o=this.#l.get(t);return n?(this.#l.set(t,n),this.#u.set(n,t)):this.#l.delete(t),o&&o!==n&&this.#_(o),!0}#_(t){this.#u.delete(t),this.#d.delete(t),this.#e?.removeTexture(t)}#q(t){for(const n of t)this.#d.delete(n),this.#u.has(n)&&this.#L(n)}#L(t){!this.#y.has(t)&&!this.#g.includes(t)&&this.#g.push(t),this.#D()}#D(){for(;this.#y.size<D1e&&this.#g.length;){const t=this.#g.shift();this.#y.add(t),this.#z(t).finally(()=>{this.#y.delete(t),this.#D()})}}async#z(t){const n=this.#u.get(t),s=n?Hs.getState().snapshots[n]:void 0;if(!n||!s||TS(n,s)!==t)return;const o=this.#N(),{layout:r}=this.store.getState(),i=[];try{const l={premultiplyAlpha:"premultiply"};if(i.push(await createImageBitmap(s.blob,{...l,resizeWidth:ES,resizeHeight:Math.round(ES*r.slideH/Es),resizeQuality:"medium"})),o&&i.push(await createImageBitmap(s.blob,l)),!this.#e||this.#u.get(t)!==n)return;this.#e.setTexture(t,i)&&this.#d.set(t,o?2:1)}catch{}finally{for(const l of i)l.close()}}attachLive(t,n){this.#h.set(t,n),this.#P(t,n);let s=!0;return(async()=>(await G4(),await G4(),await I1e(n,P1e),!(!s||this.#h.get(t)!==n)&&(this.#v.add(t),this.#s())))(),()=>{s=!1,this.#h.get(t)===n&&(this.#h.delete(t),this.#v.delete(t),this.#s())}}#P(t,n){const s=this.store.getState().layout.byId.get(t);if(!s)return;const{x:o,y:r,zoom:i}=this.#r;n.style.transform=`matrix(${i}, 0, 0, ${i}, ${(s.x-o)*i}, ${(s.y-r)*i})`,n.style.visibility="hidden"}#W(t){const n=new Map(t.map(s=>[s.id,s]));for(const[s,o]of this.#h){const r=n.get(s);r?(o.style.transform=r.transform,o.style.visibility="visible"):o.style.visibility="hidden"}}hitAt(t,n){if(!this.#e||!this.#t)return null;const s=this.#t.getBoundingClientRect(),o=this.#e.screenToWorld({x:t-s.left,y:n-s.top});return B4(this.store.getState().layout,o.x,o.y)}#G(t,n){const s=(o,r,i=!1)=>{t.addEventListener(o,r,i),this.#o.push(()=>t.removeEventListener(o,r,i))};s("pointerdown",o=>this.#Y(o,n),!0),s("wheel",o=>{o.target===n||o.target instanceof Element&&o.target.closest("textarea")||(o.preventDefault(),n.dispatchEvent(new WheelEvent("wheel",o)))},!1),s("contextmenu",o=>{o.target!==n&&o.stopPropagation()},!0)}#I(t,n){return t??B4(this.store.getState().layout,n.x,n.y)?.tile.id??null}#Y(t,n){const s=this.#e;if(t.button!==0||!s||t.target!==n)return;const o=this.hitAt(t.clientX,t.clientY);if(!o){!t.shiftKey&&!t.metaKey&&!t.ctrlKey&&this.#K(t,s);return}const r=o.tile.id,i=te.getState().slideSelection.includes(r),l=gH(r,t);(!l||o.caption)&&t.stopPropagation();const c=n.getBoundingClientRect(),u={id:r,world:s.screenToWorld({x:t.clientX-c.left,y:t.clientY-c.top}),moved:!1};this.#p=u;const f=h=>{window.removeEventListener("pointerup",f,!0),window.removeEventListener("pointercancel",f,!0),this.#p===u&&(this.#p=null),h.type==="pointerup"&&l&&!u.moved&&i&&te.getState().slideSelection.length>1&&te.getState().selectSlides([r])};window.addEventListener("pointerup",f,!0),window.addEventListener("pointercancel",f,!0)}#K(t,n){n.setTool("pan");const s=t.clientX,o=t.clientY;let r=!1;const i=c=>{Math.hypot(c.clientX-s,c.clientY-o)>=3&&(r=!0)},l=c=>{if(window.removeEventListener("pointermove",i),window.removeEventListener("pointerup",l),window.removeEventListener("pointercancel",l),this.#e?.setTool("select"),r||c.type!=="pointerup")return;const u=te.getState();u.selectSections([]),u.selectSlides(u.current?[u.current]:[])};window.addEventListener("pointermove",i),window.addEventListener("pointerup",l),window.addEventListener("pointercancel",l)}#X(t){if(t.kind==="marquee"&&(this.#M=t.phase==="start"),t.kind!=="move")return;if(t.phase==="start"){this.#p&&(this.#p.moved=!0);return}const n=this.#n;if(this.#n=null,te.getState().setDropGap(null),Wf([]),this.store.setState({drag:null}),n)for(const s of n.ids)this.#a.delete(s);this.#s()}#Z({ids:t,dx:n,dy:s}){const{layout:o}=this.store.getState();if(!this.#n){const u=mn(ie.getState()),f=this.#p,h=o.byId.get(t[0]??"");this.#n={ids:u.filter(g=>t.includes(g)),origin:f?f.world:{x:h?.x??0,y:h?.y??0}},Wf(this.#n.ids)}const r=this.#n.origin.x+n,i=this.#n.origin.y+s,l=Vwe(o,r,i);te.getState().setDropGap(l?null:qwe(o,r,i));const c=this.store.getState().drag;(!c||c.section!==l)&&this.store.setState({drag:{ids:this.#n.ids,section:l}})}#Q(){const t=this.#n;if(!t)return;const n=this.store.getState().drag?.section??null,s=te.getState().dropGap;n?rB(t.ids,n,0):s!==null&&EC(t.ids,s)}#J(t){const n=te.getState(),s=mn(ie.getState()).filter(o=>t.includes(o));if(n.selectSections([]),!s.length){n.selectSlides(n.current?[n.current]:[]);return}(!n.current||!s.includes(n.current))&&n.showSlide(s[0],{keepSelection:!0}),te.getState().selectSlides(s)}#ee(){let t=0;for(const o of this.#c)(this.#C(o)||this.#f.has(o))&&t++;const{layout:n,live:s}=this.store.getState();return{tiles:n.tiles.length,visible:this.#c.size,visibleShown:t,live:s.length,holes:this.#f.size,textures:this.#d.size,large:[...this.#d.values()].filter(o=>o===2).length,camera:this.#r,moving:this.#m,engine:this.#e?.stats()??null}}}const F1e=.25,H1e=.5;function U1e({onFail:e}){const t=C.useRef(null),n=C.useRef(null),[s,o]=C.useState(null),r=C.useRef(e);return r.current=e,C.useEffect(()=>{const i=new B1e;return o(i),i.start(t.current,n.current).catch(l=>{i.destroy(),r.current(l)}),()=>i.destroy()},[]),p.jsx(Bb,{menu:s?p.jsx(V1e,{board:s}):p.jsx(p.Fragment,{}),className:"relative flex min-h-0 flex-1 bg-stage outline-none",children:p.jsxs("div",{ref:t,role:"listbox","aria-label":"Canvas","aria-multiselectable":!0,"data-open-artifact-canvas-engine":!0,className:"relative min-h-0 flex-1 touch-none overflow-hidden",children:[s?p.jsx(q1e,{board:s}):null,p.jsx("canvas",{ref:n,className:"absolute inset-0 size-full"}),s?p.jsx(G1e,{board:s}):null,s?p.jsx(Z1e,{board:s}):null]})})}function V1e({board:e}){const t=cr(e.store,n=>n.menu);return t?p.jsx(Fb,{ids:te.getState().slideSelection.includes(t)?Ko():[t]}):null}function q1e({board:e}){const t=cr(e.store,n=>n.live);return p.jsx("div",{"aria-hidden":!0,className:"pointer-events-none absolute inset-0 overflow-hidden",children:t.map(n=>p.jsx(W1e,{board:e,id:n},n))})}const W1e=C.memo(function({board:t,id:n}){const s=C.useRef(null),o=ie(c=>c.slides[n]?.slide),r=cr(t.store,c=>c.layout.slideH),i=cr(t.store,c=>c.layout.rows[c.layout.byId.get(n)?.row??-1]?.key??null),l=wi(c=>i!==null&&(c.drag?.keys.includes(i)??!1));return C.useLayoutEffect(()=>t.attachLive(n,s.current),[t,n]),p.jsx("div",{ref:s,className:"absolute left-0 top-0 origin-top-left overflow-hidden rounded-md",style:{width:Es,height:r,visibility:"hidden",opacity:(o?.hidden?.5:1)*(l?.4:1)},children:o?p.jsx(oc,{slide:o}):null})});function G1e({board:e}){const t=C.useRef(null),n=cr(e.store,m=>m.layout),s=cr(e.store,m=>m.view),o=cr(e.store,m=>m.zoom),r=cr(e.store,m=>m.drag),i=te(m=>m.dropGap),l=wi(m=>m.drag),c=ie(m=>!m.readOnly)&&gn();C.useLayoutEffect(()=>e.attachWorld(t.current),[e]);const u=s?Gwe(s,H1e):null,f=u?n.rows.filter(m=>m.top<u.y+u.h&&m.top+n.tileH>u.y):[],h=u&&o>=F1e?b2(n,u):[],g=Math.min(4,Math.max(1,.6/o));return p.jsx("div",{className:"pointer-events-none absolute inset-0 overflow-hidden",children:p.jsxs("div",{ref:t,"data-section-rows":!0,className:"absolute left-0 top-0 origin-top-left",style:{width:n.width,height:n.height},children:[n.rows.map(m=>p.jsx("div",{"data-section-row":m.row,"data-section-key":m.key??"","aria-hidden":!0,className:"absolute left-0",style:{top:m.top,width:1,height:n.tileH}},m.key??"-")),l&&l.gap!==null?p.jsx("div",{"aria-hidden":!0,className:"absolute left-0 h-1 rounded bg-accent",style:{top:l.gap*(n.tileH+dr)-dr/2,width:n.width}}):null,f.map(m=>p.jsx("div",{className:ze("pointer-events-auto absolute",m.key&&l?.keys.includes(m.key)&&"opacity-40"),style:{left:0,top:m.top,width:lr-bo},children:p.jsx("div",{className:"origin-top-left",style:{transform:`scale(${g})`,width:(lr-bo)/g},children:p.jsx($T,{section:m.section,n:m.row,ids:m.ids,previousGap:m.row>0?m.row-1:null,nextGap:m.row<n.rows.length-1?m.row+2:null})})},m.key??"-")),n.rows.map(m=>m.empty&&m.key?p.jsx("div",{"data-empty-section":m.key,className:ze("absolute flex items-center justify-center rounded-lg border-2 border-dashed border-line text-lg text-fg-subtle",r?.section===m.key&&"border-accent bg-accent-soft text-accent"),style:{left:m.empty.x,top:m.empty.y,width:m.empty.w,height:m.empty.h},children:"An empty section. Drop slides here."},m.key):null),r&&!r.section&&i!==null?Wwe(n,i).map((m,b)=>p.jsx("span",{"aria-hidden":!0,className:"absolute rounded bg-accent",style:{left:m.x,top:m.y,width:m.w,height:m.h}},b)):null,h.length?p.jsx(Y1e,{tiles:h,slideH:n.slideH,dragging:r?.ids??null}):null,c&&!r?p.jsx(X1e,{board:e}):null]})})}function Y1e({tiles:e,slideH:t,dragging:n}){const s=xb(),o=Kh();return e.map(r=>p.jsx(K1e,{tile:r,slideH:t,comments:s.get(r.id)??0,peers:o.get(r.id),dragging:n?.includes(r.id)??!1},r.id))}const K1e=C.memo(function({tile:t,slideH:n,comments:s,peers:o,dragging:r}){const i=ie(h=>h.slides[t.id]),l=te(h=>h.current===t.id),c=te(h=>h.slideSelection.includes(t.id));if(!i)return null;const u=i.held??(i.conflict?"Changed elsewhere at the same time":null),f=Mi(i.slide);return p.jsxs("div",{"data-slide-index":t.index,"data-slide-id":t.id,role:"option","aria-selected":c||l,"aria-label":`Slide ${t.index+1}${f?`: ${f}`:""}`,className:ze("absolute",r&&"opacity-40"),style:{left:t.x,top:t.y,width:t.w,height:n+nd},children:[p.jsxs("div",{className:"absolute right-1.5 flex items-center gap-1",style:{top:n-6,transform:"translateY(-100%)"},children:[p.jsx(wT,{peers:o}),s?p.jsxs("span",{className:"flex items-center gap-0.5 rounded-full bg-surface px-1.5 text-[10px] text-fg shadow-popup",children:[p.jsx(Da,{className:"size-2.5"}),s]}):null]}),p.jsxs("div",{className:"absolute inset-x-0 flex items-center gap-1.5 pt-1.5 text-[11px] text-fg-muted",style:{top:n},children:[p.jsx("span",{className:ze("tabular-nums",(c||l)&&"font-semibold text-fg"),children:t.index+1}),p.jsx("span",{className:"min-w-0 flex-1 truncate",children:f}),i.slide.hidden?p.jsx(Lh,{className:"size-3 shrink-0","aria-label":"Skipped"}):null,u?p.jsx(xo,{className:"size-3 shrink-0 text-warning","aria-label":u}):null]})]})});function X1e({board:e}){const t=cr(e.store,r=>r.hover),n=cr(e.store,r=>r.layout),s=C.useRef(null);t&&n.byId.has(t)&&(s.current=t);const o=s.current?n.byId.get(s.current):void 0;return o?p.jsx("div",{className:ze("group/gap pointer-events-none absolute flex items-center justify-center [&_button]:pointer-events-auto",t===o.id&&"[&_button]:opacity-100"),style:{left:o.x+o.w,top:o.y,width:bo,height:o.h},children:p.jsx(_T,{gap:o.index+1,after:o.id})}):null}function Z1e({board:e}){const t=C.useRef(null);return C.useLayoutEffect(()=>e.attachZoomReadout(t.current),[e]),p.jsxs(Br,{"data-canvas-controls":!0,className:"absolute bottom-3 right-3 h-9 px-1 py-px",onPointerDown:n=>n.stopPropagation(),children:[p.jsx(_n,{label:"Zoom out",children:p.jsx(Ht,{square:!0,"aria-label":"Zoom out",onClick:()=>e.zoomBy(1/1.25),children:p.jsx(Ii,{className:"size-4",strokeWidth:1.5})})}),p.jsx("span",{ref:t,className:"min-w-11 text-center text-[13px] tabular-nums text-chrome-secondary"}),p.jsx(_n,{label:"Zoom in",children:p.jsx(Ht,{square:!0,"aria-label":"Zoom in",onClick:()=>e.zoomBy(1.25),children:p.jsx(fs,{className:"size-4",strokeWidth:1.5})})}),p.jsx($r,{}),p.jsxs(Ht,{className:"pl-1.5 pr-2",onClick:()=>e.fit(),children:[p.jsx(kE,{className:"size-4",strokeWidth:1.5}),"Fit all slides"]})]})}const Q1e=()=>Es*ft/Xe+nd,MS=48,J1e=.05,eSe=2;let Y4=null;const _9=e=>Math.min(eSe,Math.max(J1e,e));function tSe(e,t,n,s){const o=_9(Math.min((n-MS*2)/e,(s-MS*2)/t,1));return{scale:o,x:(n-e*o)/2,y:Math.max(MS,(s-t*o)/2)}}function nSe(e){te.getState().editOnCanvas(e)}function sSe(){return te(t=>t.canvasEdit)?p.jsx(aSe,{}):p.jsx(oSe,{})}let RS=!1;function oSe(){const e=pd().length===0,[,t]=C.useState(RS);return j1e||RS||e?p.jsx(rSe,{}):p.jsx(U1e,{onFail:n=>{console.warn("Canvas engine unavailable; drawing the canvas with the DOM.",n),RS=!0,t(!0)}})}function rSe(){const{order:e,groups:t}=E8(),n=xb(),s=Kh(),o=te(D=>D.dropGap),r=ie(D=>!D.readOnly)&&gn(),i=C.useRef(null),l=mc(i),{drag:c,onPointerDown:u}=vT(i,"grid"),f=wi(D=>D.drag),h=new Set(c?.ids??[]);ie(D=>D.index.size);const g=Q1e(),m=Math.max(1,...t.map(D=>D.ids.length)),b=lr+m*Es+(m-1)*bo,v=Math.max(1,t.length)*(g+dr)-dr,[w,E]=C.useState(Y4),M=C.useRef(w);M.current=w;const S=C.useCallback(D=>{M.current=D,Y4=D,E(D),LF()},[]),k=C.useCallback(()=>{l&&S(tSe(b,v,l.w,l.h))},[l,b,v,S]);C.useLayoutEffect(()=>{!M.current&&l&&k()},[l,k]);const R=C.useCallback((D,z,_)=>{const L=M.current;if(!L)return;const B=_9(L.scale*D),U=B/L.scale;S({scale:B,x:z-(z-L.x)*U,y:_-(_-L.y)*U})},[S]);C.useEffect(()=>{const D=i.current;if(!D)return;const z=_=>{_.preventDefault();const L=M.current;if(!L)return;const B=D.getBoundingClientRect();if(_.ctrlKey||_.metaKey)R(Math.exp(-_.deltaY*.01),_.clientX-B.left,_.clientY-B.top);else{const U=_.shiftKey&&_.deltaX===0?_.deltaY:_.deltaX,I=_.shiftKey&&_.deltaX===0?0:_.deltaY;S({...L,x:L.x-U,y:L.y-I})}};return D.addEventListener("wheel",z,{passive:!1}),()=>D.removeEventListener("wheel",z)},[R,S]);const N=()=>({x:(l?.w??0)/2,y:(l?.h??0)/2}),O=D=>{if(D.button!==0&&D.button!==1||D.target.closest("[data-slide-index], [data-section-label], [data-empty-section], button, textarea, [data-canvas-controls]"))return;const _=M.current;if(!_)return;D.preventDefault();const L=D.clientX,B=D.clientY;let U=!1;const I=V=>{!U&&Math.hypot(V.clientX-L,V.clientY-B)<3||(U=!0,S({..._,x:_.x+V.clientX-L,y:_.y+V.clientY-B}))},F=()=>{if(window.removeEventListener("pointermove",I),window.removeEventListener("pointerup",F),!U){const V=te.getState();V.selectSections([]),V.selectSlides(V.current?[V.current]:[])}};window.addEventListener("pointermove",I),window.addEventListener("pointerup",F)};let A=0;const $=t.map(D=>{const z=A;return A+=D.ids.length,z});return p.jsxs("div",{ref:i,role:"listbox","aria-label":"Canvas","aria-multiselectable":!0,"data-open-artifact-thumbs":!0,className:ze("relative min-h-0 flex-1 touch-none overflow-hidden bg-stage",!c&&"cursor-grab active:cursor-grabbing"),onPointerDown:O,children:[e.length===0?p.jsxs("div",{className:"absolute inset-0 flex flex-col items-center justify-center gap-3 text-sm text-chrome-muted",children:[p.jsx("p",{children:"No slides yet."}),r?p.jsx(bt,{variant:"primary",icon:p.jsx(fs,{className:"size-4"}),onClick:()=>Ba("blank",null),children:"Add slide"}):null]}):w?p.jsx("div",{"data-section-rows":!0,className:"absolute left-0 top-0 origin-top-left",style:{width:b,height:v,transform:`translate(${w.x}px, ${w.y}px) scale(${w.scale})`},children:t.map((D,z)=>{const _=z*(g+dr),L=$[z];return p.jsxs("section",{"aria-label":D.section?.description||`Section ${z+1}`,className:ze(D.section&&f?.keys.includes(D.section.key)&&"opacity-40"),children:[p.jsx("div",{"data-section-row":z,"data-section-key":D.section?.key??"","aria-hidden":!0,className:"pointer-events-none absolute left-0",style:{top:_,width:1,height:g}}),f?.gap===z?p.jsx("div",{"aria-hidden":!0,className:"pointer-events-none absolute left-0 h-1 rounded bg-accent",style:{top:_-dr/2,width:b}}):null,p.jsx("div",{className:"absolute",style:{left:0,top:_,width:lr-bo},children:p.jsx("div",{className:"origin-top-left",style:{transform:`scale(${Math.min(4,Math.max(1,.6/w.scale))})`,width:(lr-bo)/Math.min(4,Math.max(1,.6/w.scale))},children:p.jsx($T,{section:D.section,n:z,ids:D.ids,previousGap:z>0?z-1:null,nextGap:z<t.length-1?z+2:null})})}),D.ids.length===0?p.jsx("div",{"data-empty-section":D.section?.key,className:ze("absolute flex items-center justify-center rounded-lg border-2 border-dashed border-line text-lg text-fg-subtle",c?.section===D.section?.key&&"border-accent bg-accent-soft text-accent"),style:{left:lr,top:_,width:Es,height:g-nd},children:"An empty section. Drop slides here."}):D.ids.map((B,U)=>{const I=L+U;return p.jsxs("div",{className:"group/gap absolute",style:{left:lr+U*(Es+bo),top:_,width:Es},children:[p.jsx(A9,{id:B,index:I,width:Es,comments:n.get(B)??0,peers:s.get(B),dragging:h.has(B),dropBefore:c!==null&&o===I,dropAfter:c!==null&&U===D.ids.length-1&&o===I+1,onPointerDown:u,onOpen:nSe}),r&&!c?p.jsx("div",{className:"absolute top-0 z-10 flex items-center justify-center",style:{left:Es,width:bo,height:g-nd},children:p.jsx(_T,{gap:I+1,after:B})}):null]},B)})]},D.section?.key??"-")})}):null,p.jsxs(Br,{"data-canvas-controls":!0,className:"absolute bottom-3 right-3 h-9 px-1 py-px",onPointerDown:D=>D.stopPropagation(),children:[p.jsx(_n,{label:"Zoom out",children:p.jsx(Ht,{square:!0,"aria-label":"Zoom out",onClick:()=>R(1/1.25,N().x,N().y),children:p.jsx(Ii,{className:"size-4",strokeWidth:1.5})})}),p.jsx("span",{className:"min-w-11 text-center text-[13px] tabular-nums text-chrome-secondary",children:w?`${Math.round(w.scale*100)}%`:""}),p.jsx(_n,{label:"Zoom in",children:p.jsx(Ht,{square:!0,"aria-label":"Zoom in",onClick:()=>R(1.25,N().x,N().y),children:p.jsx(fs,{className:"size-4",strokeWidth:1.5})})}),p.jsx($r,{}),p.jsxs(Ht,{className:"pl-1.5 pr-2",onClick:k,children:[p.jsx(kE,{className:"size-4",strokeWidth:1.5}),"Fit all slides"]})]})]})}const K4=2;function iSe({id:e,n:t}){const n=ie(s=>s.slides[e]?.slide);return n?p.jsxs("button",{type:"button","aria-label":`Edit slide ${t}`,className:"group w-full text-left",onClick:()=>te.getState().showSlide(e),children:[p.jsx("div",{className:"overflow-hidden rounded-[6px] opacity-60 shadow-[0_0_0_1px_var(--chrome-line)] transition group-hover:opacity-100",children:p.jsx(oc,{slide:n})}),p.jsxs("div",{className:"truncate pt-1 text-[11px] text-chrome-muted",children:[p.jsx("span",{className:"tabular-nums",children:t})," ",Mi(n)]})]}):null}function aSe(){const e=pd(),t=te(i=>i.current),n=t?e.indexOf(t):-1;if(C.useEffect(()=>{n<0&&te.getState().editOnCanvas(null)},[n]),n<0)return null;const s=e.slice(Math.max(0,n-K4),n),o=e.slice(n+1,n+1+K4),r=(i,l)=>p.jsx("div",{className:"flex w-40 shrink-0 flex-col justify-center gap-4 overflow-hidden px-3 pb-14 pt-14 max-md:hidden",children:i.map((c,u)=>p.jsx(iSe,{id:c,n:l+u+1},c))});return p.jsxs("div",{className:"relative flex min-h-0 flex-1 bg-stage",children:[r(s,n-s.length),p.jsxs("div",{className:"relative min-w-0 flex-1",children:[p.jsx(GH,{}),p.jsx("div",{className:"pointer-events-none absolute inset-x-0 top-3 z-10 flex justify-center",children:p.jsxs(Br,{className:"h-9 px-1 py-px",children:[p.jsx(_n,{label:"Back to canvas",shortcut:"Esc",children:p.jsxs(Ht,{className:"pl-1.5 pr-2",onClick:()=>te.getState().editOnCanvas(null),children:[p.jsx(aD,{className:"size-4",strokeWidth:1.5}),"Canvas"]})}),p.jsx($r,{}),p.jsxs("span",{className:"px-2 text-[13px] tabular-nums text-chrome-secondary",children:["Slide ",n+1," of ",e.length]})]})})]}),r(o,n+1)]})}const X4=220,iu=24,jS=32;function lSe(e){const t=te.getState();t.setMode("edit"),t.showSlide(e)}function cSe(){const{order:e,groups:t}=E8(),n=xb(),s=Kh(),o=te(k=>k.dropGap),r=te(k=>k.current),i=ie(k=>!k.readOnly)&&gn(),l=On(k=>k.writing),c=C.useRef(null),u=mc(c),{drag:f,onPointerDown:h}=vT(c,"grid"),g=wi(k=>k.drag),m=new Set(f?.ids??[]),b=u?Math.max(1,Math.floor((u.w-jS*2+iu)/(X4+iu))):4,v=u?Math.floor((u.w-jS*2-iu*(b-1))/b):X4,[w,E]=C.useState(!1);if(C.useLayoutEffect(()=>{w||!u||!r||(c.current?.querySelector(`[data-slide-id="${CSS.escape(r)}"]`)?.scrollIntoView({block:"center"}),E(!0))},[w,u,r]),e.length===0)return l?p.jsx(PF,{}):p.jsxs("div",{className:"flex flex-1 flex-col items-center justify-center gap-3 bg-stage text-sm text-chrome-muted",children:[p.jsx("p",{children:"No slides yet."}),i?p.jsx(bt,{variant:"primary",icon:p.jsx(fs,{className:"size-4"}),onClick:()=>Ba("blank",null),children:"Add slide"}):null]});let M=0;const S=t.map(k=>{const R=M;return M+=k.ids.length,R});return p.jsxs("div",{ref:c,role:"listbox","aria-label":"Slides","aria-multiselectable":!0,"data-open-artifact-grid-columns":b,"data-section-rows":!0,"data-section-scroll":!0,"data-open-artifact-thumbs":!0,className:"min-h-0 flex-1 overflow-y-auto bg-stage pb-6 pt-[60px]",style:{paddingInline:jS},onPointerMove:k=>{const R=k.target instanceof Element?k.target.closest("[data-slide-id]"):null,N=R?.dataset.slideId;if(!R||!N)return B1(null);const O=R.getBoundingClientRect();B1({slideId:N,x:(k.clientX-O.left)/Math.max(1,O.width),y:(k.clientY-O.top)/Math.max(1,O.height)})},onPointerLeave:()=>B1(null),onPointerDown:k=>{if(k.target===k.currentTarget){const R=te.getState();R.selectSections([]),R.selectSlides(R.current?[R.current]:[])}},children:[t.map((k,R)=>{const N=S[R],O=R>0?R-1:null,A=R<t.length-1?R+2:null,$=k.section!==null||t.length>1||i,D=!!(k.section&&g?.keys.includes(k.section.key));return p.jsxs("section",{"data-section-row":R,"data-section-key":k.section?.key??"",className:ze("relative mb-8",D&&"opacity-40"),"aria-label":k.section?.description||`Section ${R+1}`,children:[g?.gap===R?p.jsx(Z4,{}):null,$?p.jsx($T,{section:k.section,n:R,ids:k.ids,previousGap:O,nextGap:A,className:"mb-3 max-w-2xl"}):null,k.ids.length===0?p.jsx("div",{"data-empty-section":k.section?.key,className:ze("flex h-24 items-center justify-center rounded-md border border-dashed border-line text-xs text-fg-subtle",f?.section===k.section?.key&&"border-accent bg-accent-soft text-accent"),children:"An empty section. Drop slides here."}):p.jsx("div",{className:"grid",style:{gridTemplateColumns:`repeat(${b}, ${v}px)`,columnGap:iu,rowGap:iu},children:k.ids.map((z,_)=>{const L=N+_,B=L===e.length-1;return p.jsxs("div",{className:"group/gap relative",children:[p.jsx(A9,{id:z,index:L,comments:n.get(z)??0,peers:s.get(z),dragging:m.has(z),dropBefore:f!==null&&o===L,dropAfter:f!==null&&B&&o===e.length,onPointerDown:h,onOpen:lSe}),p.jsx(Vbe,{id:z}),i&&!f?p.jsx("div",{className:"absolute -right-[18px] top-0 z-10 flex w-3 items-center justify-center",style:{height:v*9/16},children:p.jsx(_T,{gap:L+1,after:z})}):null]},z)})})]},k.section?.key??"-")}),p.jsx(wpe,{first:e.length,columns:b,tile:v,gap:iu}),g?.gap===t.length?p.jsx("div",{className:"relative h-0",children:p.jsx(Z4,{})}):null,i?p.jsx(bt,{variant:"ghost",icon:p.jsx(fs,{className:"size-4"}),onClick:()=>Ba("blank",e.at(-1)??null),children:"Add slide"}):null]})}function Z4(){return p.jsx("div",{className:"pointer-events-none absolute -top-4 left-0 right-0 h-0.5 rounded bg-accent","aria-hidden":!0})}async function uSe(){try{await m8()}catch(n){ie.getState().fail(n instanceof Error?n.message:String(n));return}await tF();const e=ie.getState();if(e.status!=="ready")return;te.getState().showSlide(gae()),yae(),Nre(),uue();const t=io()?.room;t&&pue(t,{ids:()=>Ai.getState().peers.map(n=>n.id),subscribe:n=>Ai.subscribe((s,o)=>{s.peers!==o.peers&&n()})}),_he(),Ore(),Bue(),Oue(),e.readOnly||Vg.getState().set(Lue()),document.title=e.title||"Slides"}let Q4=!1;function dSe(){const e=ie(s=>!s.readOnly)&&gn(),t=Rt(s=>s.status);return On(s=>s.writing)?p.jsx(PF,{}):p.jsxs(Gl,{icon:p.jsx(_z,{className:"size-6"}),title:"This presentation has no slides yet",children:[p.jsx("p",{children:e?t.available?`Add one, or ask ${t.name} to add some.`:"Add one to get started.":"Slides will show here once they are added."}),e?p.jsx(bt,{className:"mt-2",variant:"primary",icon:p.jsx(fs,{className:"size-4"}),onClick:()=>Ba("blank",null),children:"Add slide"}):null]})}function fSe(){const e=ie(b=>b.status),t=ie(b=>b.error),n=ie(b=>b.title),s=ie(b=>b.index.faces),o=pd(),r=te(b=>b.mode),i=te(b=>b.canvasEdit),l=te(b=>b.current),c=te(b=>b.showRail),u=te(b=>b.showProperties);C.useEffect(()=>{Q4||(Q4=!0,uSe());const b=Jce(),v=Jae(),w=Jte(window);return()=>{b(),v(),w()}},[]),C.useEffect(()=>{n&&(document.title=n)},[n]),C.useEffect(()=>{e==="ready"&&np(s,Ds)},[e,s]);const f=C.useRef(0);if(C.useEffect(()=>{if(e!=="ready")return;const b=l?o.indexOf(l):-1;if(b>=0){f.current=b;return}const v=o[Math.min(f.current,o.length-1)]??null;v!==l&&te.getState().showSlide(v)},[e,o,l]),e==="loading")return p.jsx("div",{className:"flex h-full items-center justify-center bg-canvas",children:p.jsx(p0,{className:"size-5 animate-spin text-fg-subtle","aria-label":"Loading"})});if(e==="error")return p.jsx("div",{className:"h-full bg-canvas",children:p.jsx(Gl,{icon:p.jsx(xo,{className:"size-6"}),title:"This presentation could not be opened",children:t})});const h=r==="edit"||i,g=o.length===0,m=r==="edit"&&c&&!g;return p.jsx(II,{fallback:p.jsx(DF,{}),children:p.jsx(y0e,{children:p.jsxs("div",{className:"flex h-full bg-stage text-fg",children:[m?p.jsx(L0e,{}):null,p.jsxs("div",{className:"flex min-w-0 flex-1 flex-col",children:[p.jsx(bpe,{}),p.jsxs("main",{className:"relative flex min-h-0 min-w-0 flex-1",children:[r==="edit"?g?p.jsx(dSe,{}):p.jsx(GH,{}):r==="grid"?p.jsx(cSe,{}):p.jsx(sSe,{}),p.jsx(Gbe,{onStage:h&&!g,startCard:!m}),p.jsx(E0e,{}),p.jsx(Spe,{}),p.jsx(kpe,{})]})]}),h&&u&&!g?p.jsx(xwe,{}):null,p.jsx(dxe,{}),p.jsx(Epe,{}),p.jsx(Hue,{}),p.jsx(Lwe,{})]})})})}const Ll=hs()(e=>({current:null,show(t){e({current:t})}}));function v2(){const e=ie.getState();return Owe(mn(e),t=>!!e.slides[t]?.slide.hidden)}function hSe(e){const t=ie.getState().slides[e]?.slide;return t?Mi(t):void 0}async function pSe(){try{await m8()}catch(o){ie.getState().fail(o instanceof Error?o.message:String(o));return}await tF({readOnly:!0});const e=ie.getState();if(e.status!=="ready")return;document.title=e.title||"Slides",Ll.getState().show(v2()[0]??null);const n=io()?.shell;if(!n)return;n.onFilesChanged(()=>!0),n.onCommand(o=>{if(o.cmd!=="goto_slide")return;const r=kC(o.hash);r&&v2().includes(r)&&Ll.getState().show(r)});const s=o=>{o&&n.currentSlide(SC(o))};s(Ll.getState().current),Ll.subscribe((o,r)=>{o.current!==r.current&&s(o.current)})}let J4=!1;function mSe({slide:e,scale:t}){const n=C.useMemo(()=>{const l=ec(e);return AC(e,l,l.length,!1)},[e]),[s,o]=C.useState(()=>new Set),r=C.useCallback(l=>o(c=>new Set(c).add(l)),[]),i=C.useMemo(()=>({mode:"present",resolveSrc:Ds,builds:n,startedClips:s,onStartClip:r}),[n,s,r]);return p.jsx("div",{className:"absolute left-1/2 top-1/2 overflow-hidden",style:{width:Xe*t,height:ft*t,translate:"-50% -50%"},children:p.jsx("div",{className:"origin-top-left",style:{width:Xe,height:ft,transform:`scale(${t})`},children:p.jsx(Ka,{slide:e,options:i})})})}function gSe({index:e,count:t,title:n,go:s}){const{counter:o,announcement:r}=j9(e,t,n),i=l=>{if(!(l.altKey||l.ctrlKey||l.metaKey)){if(l.key==="ArrowLeft"&&e>0)s(e-1);else if(l.key==="ArrowRight"&&e<t-1)s(e+1);else return;l.preventDefault()}};return p.jsxs("nav",{"aria-label":"Slides",className:"flex h-11 shrink-0 items-center justify-center gap-2 border-t border-chrome-sep bg-chrome text-chrome-fg",onKeyDown:i,children:[p.jsx(Cs,{label:"Previous slide",icon:p.jsx(xE,{className:"size-4"}),disabled:e===0,onClick:()=>s(e-1)}),p.jsx("span",{className:"min-w-14 text-center text-xs tabular-nums text-chrome-muted","aria-hidden":"true",children:o}),p.jsx(Cs,{label:"Next slide",icon:p.jsx(Fy,{className:"size-4"}),disabled:e>=t-1,onClick:()=>s(e+1)}),p.jsx("span",{className:"sr-only",role:"status","aria-live":"polite",children:r})]})}function ySe(){const e=ie(m=>m.status),t=ie(m=>m.error),n=ie(m=>m.index.faces),s=ie(bb(()=>v2())),o=Ll(m=>m.current),r=ie(m=>o?m.slides[o]?.slide:void 0),i=ie(m=>o?m.slides[o]?.held:void 0),l=C.useRef(null),c=mc(l),u=C.useRef(0);C.useEffect(()=>{J4||(J4=!0,pSe())},[]),C.useEffect(()=>{e==="ready"&&np(n,Ds)},[e,n]),C.useEffect(()=>{if(e!=="ready")return;const m=$we(s,o,u.current);m!==o?Ll.getState().show(m):o&&(u.current=s.indexOf(o))},[e,s,o]);const f=C.useCallback(m=>{const b=s[m];b&&Ll.getState().show(b)},[s]);if(e==="loading")return p.jsx("div",{className:"flex h-full items-center justify-center bg-canvas",children:p.jsx(p0,{className:"size-5 animate-spin text-fg-subtle","aria-label":"Loading"})});if(e==="error")return p.jsx("div",{className:"h-full bg-canvas",children:p.jsx(Gl,{icon:p.jsx(xo,{className:"size-6"}),title:"This presentation could not be opened",children:t})});if(s.length===0)return p.jsx("div",{className:"h-full bg-canvas",children:p.jsx(Gl,{icon:p.jsx(_z,{className:"size-6"}),title:"This presentation has no slides yet",children:p.jsx("p",{children:"Slides will show here once they are added."})})});const h=o?Math.max(0,s.indexOf(o)):0,g=c?Math.min(c.w/Xe,c.h/ft):0;return p.jsx(II,{fallback:p.jsx(DF,{viewing:!0}),children:p.jsxs("div",{"data-open-artifact-inline-view":"",className:"flex h-full flex-col bg-stage",children:[p.jsx("div",{ref:l,className:"relative min-h-0 flex-1 overflow-hidden","data-open-artifact-slide":o??void 0,children:r&&g>0?p.jsx(mSe,{slide:r,scale:g},r.id):null}),i?p.jsxs("p",{role:"note",className:"flex shrink-0 items-center gap-1.5 border-t border-chrome-sep bg-chrome px-3 py-1.5 text-xs text-chrome-muted",children:[p.jsx(xo,{className:"size-3.5 shrink-0"}),"This slide's file has errors, so it may not show as written: ",i]}):null,s.length>1?p.jsx(gSe,{index:h,count:s.length,title:o?hSe(o):void 0,go:f}):null]})})}S2.createRoot(document.getElementById("root")).render(p.jsx(C.StrictMode,{children:p.jsxs(kG,{children:[Nwe(window)?p.jsx(ySe,{}):p.jsx(fSe,{}),p.jsx(kJ,{})]})}));export{OSe as C,LSe as F,V4 as I,MSe as K,TSe as M,wSe as O,DSe as P,ASe as T,$Se as a,_Se as b,RSe as c,jSe as d,NSe as e,SSe as f,CSe as g,ESe as h,kSe as i,p1e as j,C1e as k,T1e as l,du as p,xSe as s,vSe as v,bSe as w};