1var du=Object.defineProperty;var fu=(e,t,n)=>t in e?du(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var Tn=(e,t,n)=>fu(e,typeof t!="symbol"?t+"":t,n);import{r as m,p as Qn,j as s,G as re,ax as Ke,aF as ui,aG as Bt,aH as ci,aI as Ds,a5 as di,Q as $s,t as G,aJ as Bs,aK as fi,aL as pu,aM as hu,a3 as Vs,v as _t,a7 as Hs,aN as Us,c as mu,x as pi,y as gu,R as qs,P as je,ay as Vn,av as Zs,e as ut,k as tn,D as Mt,U as xu,ac as Nr,z as bu,H as yu,d as nn,a9 as wu,aO as po,u as ku}from"./index-d2-R7FBD.js";import{m as hi,a as Jn,i as vu,f as ju}from"./use-canvases-_e471iY6.js";import{r as mi,b as ae,f as Ot,g as rt,s as gi,h as er,v as Vt,j as tt,k as oe,l as Nt,m as xi,n as Nu,o as it,p as Iu,q as Dt,B as Br,S as Ks,t as tr,O as Su,w as xt,x as Ws,y as bi,z as Cu,C as Au,D as yi,E as Eu,F as cn,A as ho,e as Tu,G as dn,H as Pu,c as Gs,P as Mu,I as Ys,J as nr,K as Ht,L as Ru,N as Hn,M as Vr,Q as Xs,T as rr,U as Lu,V as Qs,W as Js,X as ea,u as Ou,Y as Fu,i as zu,Z as _u,_ as Du,$ as $u,a0 as Bu,a1 as mo,a2 as Pn,a3 as Vu,a4 as Hu,a as Uu}from"./pointer-menu-1rGXdvcm.js";import{u as qu,c as ta}from"./use-conversations-B5z7wN81.js";import{u as wi}from"./use-conversation-turn-C4qH3s9I.js";import{o as Zu}from"./opening-message-Y_vqyrCT.js";import{S as Ku}from"./ratios-D_tSy-Bg.js";import{a as ki,b as Wu,r as Gu}from"./canvas-surface-B7ifinzJ.js";import{o as na}from"./Image.es-iLbX9G8b.js";import{e as Yu}from"./Translate.es-CY2Kq9P9.js";import{e as vi}from"./Coins.es-BXaEIGuQ.js";import{r as Xu}from"./Prohibit.es-Cs4QqOmr.js";import{r as go}from"./Warning.es-DonNoxzG.js";import{a as fn}from"./authed-image-T5D9T06R.js";import{e as ra,u as Qu,a as Ju,c as ec,d as tc}from"./useCreations-C2g8phGM.js";import{t as nc}from"./Palette.es-ZN7Es3cu.js";import{r as rc}from"./ArrowUp.es-BLfEAAuj.js";import{u as ic,e as oc,o as pn}from"./use-auto-grow-textarea-D8fUZGFY.js";import{o as Un}from"./Sparkle.es-BK1GbsRr.js";import{c as rn}from"./CheckCircle.es-BkC1mPZv.js";import{o as ia}from"./computeCreditCost-CpNRJ7G1.js";import{a as oa}from"./useCredits-DAaFrndO.js";import{d as sa,u as aa}from"./useUploads-2VjKgnsP.js";import{R as sc}from"./uploads-DQbzSLms.js";import{e as ir}from"./FrameCorners.es-Bp7qoXBy.js";import{a as ac}from"./Hand.es-CKc6l18V.js";import{a as at,C as la}from"./canvas-control-pill--APR8UOd.js";import{e as lc}from"./Question.es-CZQswP5L.js";import{o as uc}from"./Cube.es-XkzoNJM7.js";import{o as cc}from"./User.es-D0WBsZ3N.js";import{e as dc}from"./Minus.es-t4NQILQ-.js";import{r as ua}from"./ArrowsClockwise.es-CgwW2O9B.js";import{e as fc}from"./DownloadSimple.es-sRPCbFEI.js";import"./ChatCircle.es-BMsjsXwc.js";import"./Export.es-BXT9KxXF.js";import"./Stack.es-BdGNsjGx.js";import"./VideoCamera.es-DZqHqxcG.js";import"./camera-motion-presets-DYJ4f25r.js";import"./ArrowRight.es-CDegyrZI.js";import"./LockSimpleOpen.es-kXNRuXJP.js";const pc=new Map([["bold",m.createElement(m.Fragment,null,m.createElement("path",{d:"M204,75.64V40a20,20,0,0,0-20-20H72A20,20,0,0,0,52,40V76a20.1,20.1,0,0,0,8,16l48,36L60,164a20.1,20.1,0,0,0-8,16v36a20,20,0,0,0,20,20H184a20,20,0,0,0,20-20V180.36a20.13,20.13,0,0,0-7.94-16L147.9,128l48.16-36.4A20.13,20.13,0,0,0,204,75.64ZM180,212H76V182l52-39,52,39.33Zm0-138.35L128,113,76,74V44H180Z"}))],["duotone",m.createElement(m.Fragment,null,m.createElement("path",{d:"M188.82,82,128,128,67.2,82.4A8,8,0,0,1,64,76V40a8,8,0,0,1,8-8H184a8,8,0,0,1,8,8V75.64A8,8,0,0,1,188.82,82ZM64,180v36a8,8,0,0,0,8,8H184a8,8,0,0,0,8-8V180.36a8,8,0,0,0-3.18-6.38L128,128,67.2,173.6A8,8,0,0,0,64,180Z",opacity:"0.2"}),m.createElement("path",{d:"M200,75.64V40a16,16,0,0,0-16-16H72A16,16,0,0,0,56,40V76a16.07,16.07,0,0,0,6.4,12.8L114.67,128,62.4,167.2A16.07,16.07,0,0,0,56,180v36a16,16,0,0,0,16,16H184a16,16,0,0,0,16-16V180.36a16.09,16.09,0,0,0-6.35-12.77L141.27,128l52.38-39.59A16.09,16.09,0,0,0,200,75.64ZM184,216H72V180l56-42,56,42.35Zm0-140.36L128,118,72,76V40H184Z"}))],["fill",m.createElement(m.Fragment,null,m.createElement("path",{d:"M200,75.64V40a16,16,0,0,0-16-16H72A16,16,0,0,0,56,40V76a16.08,16.08,0,0,0,6.41,12.8L114.67,128,62.4,167.2A16.07,16.07,0,0,0,56,
1180v36a16,16,0,0,0,16,16H184a16,16,0,0,0,16-16V180.36a16,16,0,0,0-6.36-12.77L141.26,128l52.38-39.59A16.05,16.05,0,0,0,200,75.64Z"}))],["light",m.createElement(m.Fragment,null,m.createElement("path",{d:"M198,75.64V40a14,14,0,0,0-14-14H72A14,14,0,0,0,58,40V76a14.06,14.06,0,0,0,5.6,11.2L118,128,63.6,168.8A14.06,14.06,0,0,0,58,180v36a14,14,0,0,0,14,14H184a14,14,0,0,0,14-14V180.36a14.08,14.08,0,0,0-5.56-11.17L138,128l54.49-41.19A14.08,14.08,0,0,0,198,75.64ZM186,180.36V216a2,2,0,0,1-2,2H72a2,2,0,0,1-2-2V180a2,2,0,0,1,.8-1.6L128,135.51l57.22,43.25A2,2,0,0,1,186,180.36Zm0-104.72a2,2,0,0,1-.79,1.6L128,120.49,70.8,77.6A2,2,0,0,1,70,76V40a2,2,0,0,1,2-2H184a2,2,0,0,1,2,2Z"}))],["regular",m.createElement(m.Fragment,null,m.createElement("path",{d:"M200,75.64V40a16,16,0,0,0-16-16H72A16,16,0,0,0,56,40V76a16.07,16.07,0,0,0,6.4,12.8L114.67,128,62.4,167.2A16.07,16.07,0,0,0,56,180v36a16,16,0,0,0,16,16H184a16,16,0,0,0,16-16V180.36a16.09,16.09,0,0,0-6.35-12.77L141.27,128l52.38-39.6A16.05,16.05,0,0,0,200,75.64ZM184,216H72V180l56-42,56,42.35Zm0-140.36L128,118,72,76V40H184Z"}))],["thin",m.createElement(m.Fragment,null,m.createElement("path",{d:"M196,75.64V40a12,12,0,0,0-12-12H72A12,12,0,0,0,60,40V76a12,12,0,0,0,4.8,9.6L121.33,128,64.8,170.4A12,12,0,0,0,60,180v36a12,12,0,0,0,12,12H184a12,12,0,0,0,12-12V180.36a12.05,12.05,0,0,0-4.76-9.57L134.63,128l56.61-42.79A12.05,12.05,0,0,0,196,75.64Zm-8,104.72V216a4,4,0,0,1-4,4H72a4,4,0,0,1-4-4V180a4,4,0,0,1,1.6-3.2L128,133l58.42,44.16A4,4,0,0,1,188,180.36Zm0-104.72a4,4,0,0,1-1.59,3.19L128,123,69.6,79.2A4,4,0,0,1,68,76V40a4,4,0,0,1,4-4H184a4,4,0,0,1,4,4Z"}))]]),hc=new Map([["bold",m.createElement(m.Fragment,null,m.createElement("path",{d:"M240.49,15.51a12,12,0,0,0-17,0L173.94,65.09l-2.54-2.55a36.05,36.05,0,0,0-50.91,0L100,83l-3.51-3.52a12,12,0,0,0-17,17L83,100,62.54,120.49a36,36,0,0,0,0,50.91l2.55,2.54L15.51,223.51a12,12,0,0,0,17,17l49.57-49.58,2.54,2.55a36.06,36.06,0,0,0,50.91,0L156,173l3.51,3.52a12,12,0,0,0,17-17L173,156l20.49-20.49a36,36,0,0,0,0-50.91l-2.55-2.54,49.58-49.57A12,12,0,0,0,240.49,15.51Zm-121.95,161a12,12,0,0,1-17,0L79.51,154.43a12,12,0,0,1,0-17L100,117l39,39Zm58-57.95h0L156,139l-39-39,20.49-20.49a12,12,0,0,1,17,0l22.06,22.06a12,12,0,0,1,0,17ZM85.27,33.37a12,12,0,0,1,21.46-10.74l8,16A12,12,0,1,1,93.27,49.37Zm-68,57.26a12,12,0,0,1,16.1-5.36l16,8a12,12,0,1,1-10.74,21.46l-16-8A12,12,0,0,1,17.27,90.63Zm221.46,74.74a12,12,0,0,1-16.1,5.36l-16-8a12,12,0,0,1,10.74-21.46l16,8A12,12,0,0,1,238.73,165.37Zm-68,57.26a12,12,0,1,1-21.46,10.74l-8-16a12,12,0,0,1,21.46-10.74Z"}))],["duotone",m.createElement(m.Fragment,null,m.createElement("path",{d:"M185,127,127,185a24,24,0,0,1-33.94,0L71,162.91A24,24,0,0,1,71,129L129,71a24,24,0,0,1,33.94,0L185,93.09A24,24,0,0,1,185,127Z",opacity:"0.2"}),m.createElement("path",{d:"M237.66,18.34a8,8,0,0,0-11.32,0l-52.4,52.41-5.37-5.38a32.05,32.05,0,0,0-45.26,0L100,88.69l-6.34-6.35A8,8,0,0,0,82.34,93.66L88.69,100,65.37,123.31a32,32,0,0,0,0,45.26l5.38,5.37-52.41,52.4a8,8,0,0,0,11.32,11.32l52.4-52.41,5.37,5.38a32.06,32.06,0,0,0,45.26,0L156,167.31l6.34,6.35a8,8,0,0,0,11.32-11.32L167.31,156l23.32-23.31a32,32,0,0,0,0-45.26l-5.38-5.37,52.41-52.4A8,8,0,0,0,237.66,18.34Zm-116.29,161a16,16,0,0,1-22.62,0L76.69,157.25a16,16,0,0,1,0-22.62L100,111.31,144.69,156Zm57.94-57.94h0L156,144.69,111.31,100l23.32-23.31a16,16,0,0,1,22.62,0l22.06,22a16,16,0,0,1,0,22.63ZM88.57,35A8,8,0,0,1,103.43,29l8,20A8,8,0,0,1,96.57,55ZM24.57,93A8,8,0,0,1,35,88.57l20,8A8,8,0,0,1,49,111.43l-20-8A8,8,0,0,1,24.57,93ZM231.43,163a8,8,0,0,1-10.4,4.46l-20-8A8,8,0,1,1,207,144.57l20,8A8,8,0,0,1,231.43,163Zm-64,58.06A8,8,0,0,1,152.57,227l-8-20A8,8,0,0,1,159.43,201Z"}))],["fill",m.createElement(m.Fragment,null,m.createElement("path",{d:"M88.57,35A8,8,0,0,1,103.43,29l8,20A8,8,0,0,1,96.57,55ZM29,103.43l20,8A8,8,0,1,0,55,96.57l-20-8A8,8,0,0,0,29,103.43ZM227,152.57l-20-8A8,8,0,1,0,201,159.43l20,8A8,8,0,0,0,227,152.57ZM159.43,201A8,8,0,0,0,144.57,207l8,20A8,8,0,1,0,167.43,221ZM237.91,18.52a8,8,0,0,0-11.5-.18L174,70.75l-5.38-5.38a32,32,0,0,0-45.28,0L106.14,82.54a4,4,0,0,0,0,5.66l61.7,61.66a4,4,0,0,0,5.66,0l16.74-16.74a32.76,32.76,0,0,0,9.81-22.52,31.82,31.82,0,0,0-9.37-23.17l-5.38-5.37,52.2-52.17A8.22,8.22,0,0,0,237.91,18.52ZM85.64,90.34a8,8,0,0,0-11.49.18,8.22,8.22,0,0,0,.41,11.37L80.67,108,65.34,123.31A31.82,31.82,0,0,0,56,
1146.47,32.75,32.75,0,0,0,65.77,169l5,4.94L18.49,226.13a8.21,8.21,0,0,0-.61,11.1,8,8,0,0,0,11.72.43L82,185.25l5.37,5.38a32.1,32.1,0,0,0,45.29,0L148,175.31l6.34,6.35a8,8,0,0,0,11.32-11.32Z"}))],["light",m.createElement(m.Fragment,null,m.createElement("path",{d:"M236.24,19.76a6,6,0,0,0-8.48,0L173.94,73.57l-6.79-6.78a30,30,0,0,0-42.42,0L100,91.51l-7.76-7.75a6,6,0,0,0-8.48,8.48L91.51,100,66.79,124.73a30,30,0,0,0,0,42.42l6.78,6.79L19.76,227.76a6,6,0,1,0,8.48,8.48l53.82-53.81,6.79,6.78a30,30,0,0,0,42.42,0L156,164.49l7.76,7.75a6,6,0,0,0,8.48-8.48L164.49,156l24.72-24.73a30,30,0,0,0,0-42.42l-6.78-6.79,53.81-53.82A6,6,0,0,0,236.24,19.76Zm-113.45,161a18,18,0,0,1-25.46,0L75.27,158.67a18,18,0,0,1,0-25.46L100,108.49,147.51,156Zm57.94-57.94L156,147.51,108.49,100l24.72-24.73a18,18,0,0,1,25.46,0l22.06,22.06a18,18,0,0,1,0,25.46ZM90.43,34.23a6,6,0,0,1,11.14-4.46l8,20a6,6,0,1,1-11.14,4.46Zm-64,59.54a6,6,0,0,1,7.8-3.34l20,8a6,6,0,1,1-4.46,11.14l-20-8A6,6,0,0,1,26.43,93.77Zm203.14,68.46a6,6,0,0,1-7.8,3.34l-20-8a6,6,0,0,1,4.46-11.14l20,8A6,6,0,0,1,229.57,162.23Zm-64,59.54a6,6,0,1,1-11.14,4.46l-8-20a6,6,0,0,1,11.14-4.46Z"}))],["regular",m.createElement(m.Fragment,null,m.createElement("path",{d:"M237.66,18.34a8,8,0,0,0-11.32,0l-52.4,52.41-5.37-5.38a32.05,32.05,0,0,0-45.26,0L100,88.69l-6.34-6.35A8,8,0,0,0,82.34,93.66L88.69,100,65.37,123.31a32,32,0,0,0,0,45.26l5.38,5.37-52.41,52.4a8,8,0,0,0,11.32,11.32l52.4-52.41,5.37,5.38a32,32,0,0,0,45.26,0L156,167.31l6.34,6.35a8,8,0,0,0,11.32-11.32L167.31,156l23.32-23.31a32,32,0,0,0,0-45.26l-5.38-5.37,52.41-52.4A8,8,0,0,0,237.66,18.34Zm-116.29,161a16,16,0,0,1-22.62,0L76.69,157.25a16,16,0,0,1,0-22.62L100,111.31,144.69,156Zm57.94-57.94L156,144.69,111.31,100l23.32-23.31a16,16,0,0,1,22.62,0l22.06,22A16,16,0,0,1,179.31,121.37ZM88.57,35A8,8,0,0,1,103.43,29l8,20A8,8,0,0,1,96.57,55ZM24.57,93A8,8,0,0,1,35,88.57l20,8A8,8,0,0,1,49,111.43l-20-8A8,8,0,0,1,24.57,93ZM231.43,163a8,8,0,0,1-10.4,4.46l-20-8A8,8,0,1,1,207,144.57l20,8A8,8,0,0,1,231.43,163Zm-64,58.06A8,8,0,0,1,152.57,227l-8-20A8,8,0,0,1,159.43,201Z"}))],["thin",m.createElement(m.Fragment,null,m.createElement("path",{d:"M234.83,21.17a4,4,0,0,0-5.66,0L173.94,76.4l-8.2-8.2a28,28,0,0,0-39.6,0L100,94.34l-9.17-9.17a4,4,0,0,0-5.66,5.66L94.34,100,68.2,126.14a28,28,0,0,0,0,39.6l8.2,8.2L21.17,229.17a4,4,0,0,0,5.66,5.66L82.06,179.6l8.2,8.2a28,28,0,0,0,39.6,0L156,161.66l9.17,9.17a4,4,0,0,0,5.66-5.66L161.66,156l26.14-26.14a28,28,0,0,0,0-39.6l-8.2-8.2,55.23-55.23A4,4,0,0,0,234.83,21.17Zm-110.63,161a20,20,0,0,1-28.28,0L73.86,160.08a20,20,0,0,1,0-28.28L100,105.66,150.34,156Zm57.94-57.94L156,150.34,105.66,100,131.8,73.86a20,20,0,0,1,28.28,0l22.06,22.06A20,20,0,0,1,182.14,124.2ZM92.29,33.49a4,4,0,1,1,7.42-3l8,20a4,4,0,0,1-2.22,5.2A3.91,3.91,0,0,1,104,56a4,4,0,0,1-3.71-2.51Zm-64,61a4,4,0,0,1,5.2-2.22l20,8A4,4,0,0,1,52,108a3.91,3.91,0,0,1-1.49-.29l-20-8A4,4,0,0,1,28.29,94.51Zm199.42,67A4,4,0,0,1,224,164a3.91,3.91,0,0,1-1.49-.29l-20-8a4,4,0,1,1,3-7.42l20,8A4,4,0,0,1,227.71,161.49Zm-64,61a4,4,0,0,1-2.22,5.2A3.91,3.91,0,0,1,160,228a4,4,0,0,1-3.71-2.51l-8-20a4,4,0,0,1,7.42-3Z"}))]]),mc=new Map([["bold",m.createElement(m.Fragment,null,m.createElement("path",{d:"M128,20A108,108,0,1,0,236,128,108.12,108.12,0,0,0,128,20Zm0,192a84,84,0,1,1,84-84A84.09,84.09,0,0,1,128,212Zm52-84a12,12,0,0,1-12,12H140v28a12,12,0,0,1-24,0V140H88a12,12,0,0,1,0-24h28V88a12,12,0,0,1,24,0v28h28A12,12,0,0,1,180,128Z"}))],["duotone",m.createElement(m.Fragment,null,m.createElement("path",{d:"M224,128a96,96,0,1,1-96-96A96,96,0,0,1,224,128Z",opacity:"0.2"}),m.createElement("path",{d:"M128,24A104,104,0,1,0,232,128,104.11,104.11,0,0,0,128,24Zm0,192a88,88,0,1,1,88-88A88.1,88.1,0,0,1,128,216Zm48-88a8,8,0,0,1-8,8H136v32a8,8,0,0,1-16,0V136H88a8,8,0,0,1,0-16h32V88a8,8,0,0,1,16,0v32h32A8,8,0,0,1,176,128Z"}))],["fill",m.createElement(m.Fragment,null,m.createElement("path",{d:"M128,24A104,104,0,1,0,232,128,104.13,104.13,0,0,0,128,24Zm40,112H136v32a8,8,0,0,1-16,0V136H88a8,8,0,0,1,0-16h32V88a8,8,0,0,1,16,0v32h32a8,8,0,0,1,0,16Z"}))],["light",m.createElement(m.Fragment,null,m.createElement("path",{d:"M128,26A102,102,0,1,0,230,128,102.12,102.12,0,0,0,128,26Zm0,192a90,90,0,1,1,90-90A90.1,90.1,0,0,1,128,218Zm46-90a6,6,0,0,1-6,6H134v34a6,6,0,0,1-12,0V134H88a6,6,0,0,1,0-12h34V88a6,6,0,0,1,12,0v34h34A6,6,0,0,1,174,128Z"}))],["regular",m.createElement(m.Fragment,null,m.createElement("path",{d:"M128,24A104,104,0,1,0,232,128,104.11,104.11,0,0,0,128,24Zm0,192a88,88,0,1,1,88-88A88.1,88.1,0,0,1,128,216Zm48-88a8,8,0,0,1-8,8H136v32a8,8,0,0,1-16,0V136H88a8,8,0,0,1,0-16h32V88a8,8,0,0,1,16,0v32h32A8,8,0,0,1,176,128Z"}))],["thin",m.createElement(m.Fragment,null,m.createElement("path",{d:"M128,28A100,100,0,1,0,228,128,100.11,100.11,0,0,0,128,28Zm0,192a92,92,0,1,1,92-92A92.1,92.1,0,0,1,128,220Zm44-92a4,4,0,0,1-4,4H132v36a4,4,0,0,1-8,0V132H88a4,4,0,0,1,0-8h36V88a4,4,0,0,1,8,0v36h36A4,4,0,0,1,172,128Z"}))]]),gc=new Map([["bold",m.createElement(m.Fragment,null,m.createElement("path",{d:"M156,40a12,12,0,0,1-12,12H112a12,12,0,0,1,0-24h32A12,12,0,0,1,156,40ZM144,204H112a12,12,0,0,0,0,24h32a12,12,0,0,0,0-24ZM208,28H184a12,12,0,0,0,0,24h20V72a12,12,0,0,0,24,0V48A20,20,0,0,0,208,28Zm8,72a12,12,0,0,0-12,12v32a12,12,0,0,0,24,0V112A12,12,0,0,0,216,100Zm0,72a12,12,0,0,0-12,12v20H184a12,12,0,0,0,0,24h24a20,20,0,0,0,20-20V184A12,12,0,0,0,216,172ZM40,156a12,12,0,0,0,12-12V112a12,12,0,0,0-24,0v32A12,12,0,0,0,40,156Zm32,48H52V184a12,12,0,0,0-24,0v24a20,20,0,0,0,20,20H72a12,12,0,0,0,0-24ZM72,28H48A20,20,0,0,0,28,48V72a12,12,0,0,0,24,0V52H72a12,12,0,0,0,0-24Z"}))],["duotone",m.createElement(m.Fragment,null,m.createElement("path",{d:"M216,40V216H40V40Z",opacity:"0.2"}),m.createElement("path",{d:"M152,40a8,8,0,0,1-8,8H112a8,8,0,0,1,0-16h32A8,8,0,0,1,152,40Zm-8,168H112a8,8,0,0,0,0,16h32a8,8,0,0,0,0-16ZM208,32H184a8,8,0,0,0,0,16h24V72a8,8,0,0,0,16,0V48A16,16,0,0,0,208,32Zm8,72a8,8,0,0,0-8,8v32a8,8,0,0,0,16,0V112A8,8,0,0,0,216,104Zm0,72a8,8,0,0,0-8,8v24H184a8,8,0,0,0,0,16h24a16,16,0,0,0,16-16V184A8,8,0,0,0,216,176ZM40,152a8,8,0,0,0,8-8V112a8,8,0,0,0-16,0v32A8,8,0,0,0,40,152Zm32,56H48V184a8,8,0,0,0-16,0v24a16,16,0,0,0,16,16H72a8,8,0,0,0,0-16ZM72,32H48A16,16,0,0,0,32,48V72a8,8,0,0,0,16,0V48H72a8,8,0,0,0,0-16Z"}))],["fill",m.createElement(m.Fragment,null,m.createElement("path",{d:"M208,32H48A16,16,0,0,0,32,48V208a16,16,0,0,0,16,16H208a16,16,0,0,0,16-16V48A16,16,0,0,0,208,32ZM104,200H72a16,16,0,0,1-16-16V152a8,8,0,0,1,16,0v32h32a8,8,0,0,1,0,16Zm0-128H72v32a8,8,0,0,1-16,0V72A16,16,0,0,1,72,56h32a8,8,0,0,1,0,16Zm96,112a16,16,0,0,1-16,16H152a8,8,0,0,1,0-16h32V152a8,8,0,0,1,16,0Zm0-80a8,8,0,0,1-16,0V72H152a8,8,0,0,1,0-16h32a16,16,0,0,1,16,16Z"}))],["light",m.createElement(m.Fragment,null,m.createElement("path",{d:"M150,40a6,6,0,0,1-6,6H112a6,6,0,0,1,0-12h32A6,6,0,0,1,150,40Zm-6,170H112a6,6,0,0,0,0,12h32a6,6,0,0,0,0-12ZM208,34H184a6,6,0,0,0,0,12h24a2,2,0,0,1,2,2V72a6,6,0,0,0,12,0V48A14,14,0,0,0,208,34Zm8,72a6,6,0,0,0-6,6v32a6,6,0,0,0,12,0V112A6,6,0,0,0,216,106Zm0,72a6,6,0,0,0-6,6v24a2,2,0,0,1-2,2H184a6,6,0,0,0,0,12h24a14,14,0,0,0,14-14V184A6,6,0,0,0,216,178ZM40,150a6,6,0,0,0,6-6V112a6,6,0,0,0-12,0v32A6,6,0,0,0,40,150Zm32,60H48a2,2,0,0,1-2-2V184a6,6,0,0,0-12,0v24a14,14,0,0,0,14,14H
172a6,6,0,0,0,0-12ZM72,34H48A14,14,0,0,0,34,48V72a6,6,0,0,0,12,0V48a2,2,0,0,1,2-2H72a6,6,0,0,0,0-12Z"}))],["regular",m.createElement(m.Fragment,null,m.createElement("path",{d:"M152,40a8,8,0,0,1-8,8H112a8,8,0,0,1,0-16h32A8,8,0,0,1,152,40Zm-8,168H112a8,8,0,0,0,0,16h32a8,8,0,0,0,0-16ZM208,32H184a8,8,0,0,0,0,16h24V72a8,8,0,0,0,16,0V48A16,16,0,0,0,208,32Zm8,72a8,8,0,0,0-8,8v32a8,8,0,0,0,16,0V112A8,8,0,0,0,216,104Zm0,72a8,8,0,0,0-8,8v24H184a8,8,0,0,0,0,16h24a16,16,0,0,0,16-16V184A8,8,0,0,0,216,176ZM40,152a8,8,0,0,0,8-8V112a8,8,0,0,0-16,0v32A8,8,0,0,0,40,152Zm32,56H48V184a8,8,0,0,0-16,0v24a16,16,0,0,0,16,16H72a8,8,0,0,0,0-16ZM72,32H48A16,16,0,0,0,32,48V72a8,8,0,0,0,16,0V48H72a8,8,0,0,0,0-16Z"}))],["thin",m.createElement(m.Fragment,null,m.createElement("path",{d:"M148,40a4,4,0,0,1-4,4H112a4,4,0,0,1,0-8h32A4,4,0,0,1,148,40Zm-4,172H112a4,4,0,0,0,0,8h32a4,4,0,0,0,0-8ZM208,36H184a4,4,0,0,0,0,8h24a4,4,0,0,1,4,4V72a4,4,0,0,0,8,0V48A12,12,0,0,0,208,36Zm8,72a4,4,0,0,0-4,4v32a4,4,0,0,0,8,0V112A4,4,0,0,0,216,108Zm0,72a4,4,0,0,0-4,4v24a4,4,0,0,1-4,4H184a4,4,0,0,0,0,8h24a12,12,0,0,0,12-12V184A4,4,0,0,0,216,180ZM40,148a4,4,0,0,0,4-4V112a4,4,0,0,0-8,0v32A4,4,0,0,0,40,148Zm32,64H48a4,4,0,0,1-4-4V184a4,4,0,0,0-8,0v24a12,12,0,0,0,12,12H72a4,4,0,0,0,0-8ZM72,36H48A12,12,0,0,0,36,48V72a4,4,0,0,0,8,0V48a4,4,0,0,1,4-4H72a4,4,0,0,0,0-8Z"}))]]),ca=m.forwardRef((e,t)=>m.createElement(Qn,{ref:t,...e,weights:pc}));ca.displayName="HourglassIcon";const ji=m.forwardRef((e,t)=>m.createElement(Qn,{ref:t,...e,weights:hc}));ji.displayName="PlugsConnectedIcon";const da=m.forwardRef((e,t)=>m.createElement(Qn,{ref:t,...e,weights:mc}));da.displayName="PlusCircleIcon";const fa=m.forwardRef((e,t)=>m.createElement(Qn,{ref:t,...e,weights:gc}));fa.displayName="SelectionIcon";function xc({open:e,onStay:t,onLeave:n,onSaveAndLeave:r,isSaving:i}){return s.jsx(re.Root,{open:e,onOpenChange:o=>{o||t()},children:s.jsxs(re.Content,{className:"max-w-md",children:[s.jsxs(re.Header,{children:[s.jsx(re.Title,{children:"Leave without marking this saved?"}),s.jsx(re.Description,{children:"Everything here is already stored, so leaving loses nothing. Marking it saved just records that you are done with it for now."})]}),s.jsxs(re.Actions,{children:[s.jsx(re.Cancel,{onClick:t,children:"Stay here"}),s.jsx(re.Action,{variant:"secondary",onClick:o=>{o.preventDefault(),n()},children:"Leave"}),s.jsx(re.Action,{variant:"default",disabled:i,onClick:o=>{o.preventDefault(),r()},children:i?"Savingâ¦":"Mark saved and leave"})]})]})})}const lt={all:["canvas-frames"],list:e=>[...lt.all,e]};function bc(e){const{canvasApi:t}=Ke(),{data:n,isLoading:r,isError:i}=ui({queryKey:lt.list(e??""),queryFn:async()=>(await t.listFrames(e)).frames,enabled:!!e,staleTime:0,refetchOnWindowFocus:!0});return{frames:n??yc,isLoading:r,isError:i}}const yc=[];function wc(){const{canvasApi:e}=Ke(),t=Bt();return ci({mutationFn:({canvasId:n,input:r})=>e.createFrame(n,r),onSuccess:(n,{canvasId:r})=>{t.invalidateQueries({queryKey:lt.list(r)}),hi(t,r)},onError:n=>mi(n,"frame")})}function kc(){const{canvasApi:e}=Ke(),t=Bt();return ci({mutationFn:({canvasId:n,frameId:r,patch:i})=>e.updateFrame(n,r,i),onSuccess:(n,{canvasId:r})=>hi(t,r),onMutate:async({canvasId:n,frameId:r,patch:i})=>{const o=lt.list(n);await t.cancelQueries({queryKey:o});const a=t.getQueryData(o);return t.setQueryData(o,l=>l==null?void 0:l.map(u=>u.id===r?{...u,...i}:u)),{previous:a}},onError:(n,{canvasId:r},i)=>{i!=null&&i.previous&&t.setQueryData(lt.list(r),i.previous),t.invalidateQueries({queryKey:lt.list(r)}),mi(n,"frame")}})}function vc(){const{canvasApi:e}=Ke(),t=Bt();return ci({mutationFn:({canvasId:n,frameId:r})=>e.deleteFrame(n,r),onSuccess:(n,{canvasId:r})=>hi(t,r),onMutate:async({canvasId:n,frameId:r})=>{const i=lt.list(n);await t.cancelQueries({queryKey:i});const o=t.getQueryData(i);return t.setQueryData(i,a=>a==null?void 0:a.filter(l=>l.id!==r)),{previous:o}},onError:(n,{canvasId:r},i)=>{i!=null&&i.previous&&t.setQueryData(lt.list(r),i.previous),mi(n,"frame")},onSettled:(n,r,{canvasId:i})=>{t.invalidateQueries({queryKey:lt.list(i)})}})}const on=48,jc="Frame",Nc=Ku;function Ic(e){if(!e)return null;const[t,n]=e.split(":"),r=Number(t),i=Number(n);return!Number.isFinite(r)||!Number.isFinite(i)||r<=0||i<=0?null:r/i}function Ni(e,t){const n=Ic(t);return n===null?null:Math.max(on,Math.round(e/n))}function Sc(e){const t=Math.round(e.right-e.left),n=Math.round(e.bottom-e.top);return t<on||n<on?null:{x:Math.round(e.left+t/2),y:Math.round(e.top+n/2),width:t,height:n}}function Cc(e,t,n,r){const i=e.x-e.width/2,o=e.y-e.height/2,a=i+e.width,l=o+e.height,u=t==="nw"||t==="sw"?a:i,c=t==="nw"||t==="ne"?l:o,f=(t==="nw"||t==="sw"?i:a)+n,p=(t==="nw"||t==="ne"?o:l)+r;let d=Math.max(on,Math.abs(f-u)),h=Math.max(on,Math.abs(p-c));const g=Ni(d,e.aspectRatio);g!==null&&(h=g);const x=f<u?u-d:u,C=p<c?c-h:c;return{x:Math.round(x+d/2),y:Math.round(C+h/2),width:Math.round(d),height:Math.round(h)}}function Ii(e){return e.name.trim()||jc}function Si(e){return`${Math.round(e.width)} à ${Math.round(e.height)}`}async function Ac(e,t){const n=await Promise.all(e.map(async o=>({id:o,creation:await t.get(o).catch(()=>null)}))),r=[],i=[];for(const{id:o,creation:a}of n)a!=null&&a.mediaUrl?r.push(a):i.push(o);return{usable:r,missingIds:i}}function Ec(){const{createApi:e,uploadApi:t,creationApi:n,canvasApi:r}
1=Ke(),i=Bt(),o=ae(c=>c.markBlocked),a=ae(c=>c.clearBlocked),l=ae(c=>c.markFailed),u=ae(c=>c.clearFailed);return m.useCallback(async c=>{var Z;const{canvasId:f,blockId:p,prompt:d,negativePrompt:h,label:g,modelId:x,variations:C,aspectRatio:v,intent:k,source:j,references:R,config:z}=c,N=(g??d).trim();if(a(p),u(p),k==="edit"&&!j)return l(p,{message:"Nothing was selected to edit. Pick a variant above, or start a new image instead.",refunded:!1}),null;const V=()=>i.invalidateQueries({queryKey:Ot.list(f)}),H=K=>r.updateBlock(f,p,{state:K}).then(V);await H("running");let E;try{const K=`create.${k}:${p}:${Date.now()}`;E=(k==="edit"?await e.edit({idempotencyKey:K,source:{kind:"image",...j},prompt:d,context:{canvasId:f,blockId:p}}):await e.still({idempotencyKey:K,prompt:d,...h!=null&&h.trim()?{negativePrompt:h.trim()}:{},modelId:x,variations:C,aspectRatio:v,references:R,context:{canvasId:f,blockId:p}})).job}catch(K){if(await H("placeholder"),K instanceof Ds){const ee=Pc(K);return ee?o(p,ee):l(p,{message:K.message,refunded:!1}),null}return l(p,{message:"The request did not reach the assistant. Please try again.",refunded:!1}),null}if(E.status!=="succeeded"||E.result.kind!=="outputs"&&E.result.kind!=="creations")return await H("placeholder"),l(p,{message:Tc((Z=E.error)==null?void 0:Z.code),refunded:E.cost.total===0}),E;const{usable:B,missingIds:A}=E.result.kind==="outputs"?{usable:E.result.outputs.map(K=>({url:K.url,name:N||"Still"})),missingIds:[]}:await Ac(E.result.creationIds,n).then(K=>({usable:K.usable.map(ee=>({url:ee.mediaUrl,name:ee.name})),missingIds:K.missingIds}));if(B.length===0)return await H("placeholder"),l(p,{message:"The output was made but could not be read back. Please try again.",refunded:!1}),E;A.length>0&&di.warning(A.length===1?"1 output could not be read back and is missing from this variant.":`${A.length} outputs could not be read back and are missing from this variant.`);const P=E.updatedAt,D={kind:k==="edit"?"derived":"generated",source:k==="edit"?"gooh-seedream-edit":x??"gooh-nano-pro",recordedAt:P},F=B.length===1?B[0]:null;return await r.appendVariant(f,p,{label:N.slice(0,60)||"Still",ratio:v??null,jobId:Mc(E.id),provenance:D,config:z??null,media:F?await bo(F,N):null,outputSet:F?null:{id:E.id,items:await Promise.all(B.map(async(K,ee)=>({id:`${E.id}-${ee+1}`,target:`Variation ${ee+1}`,provenance:D,media:await bo(K,N)})))}}),await H("complete"),await V(),E},[e,t,n,r,i,o,a,l,u])}function Tc(e){switch(e){case"provider_failed":case"provider_timeout":return"The model could not make this right now. Please try again in a moment.";case"invalid_input":return"The request was refused â try changing the prompt or the settings.";case"cancelled":return"This was cancelled before it finished.";default:return"This did not produce anything. Please try again."}}function Pc(e){const t=xo(e.details.required);return e.code==="spend_limit_exceeded"?{required:t??0,limit:xo(e.details.limit),kind:"ceiling"}:e.code==="insufficient_credits"?{required:t??0,limit:null,kind:"balance"}:null}function xo(e){return typeof e=="number"&&Number.isFinite(e)?e:null}function Mc(e){const t=e.indexOf("_");return t===-1?e:e.slice(t+1)}async function bo(e,t){const n=await Rc(e.url);return{src:e.url,...e.assetId?{assetId:e.assetId}:{},width:(n==null?void 0:n.width)??1600,height:(n==null?void 0:n.height)??900,alt:t||e.name}}function Rc(e){return new Promise(t=>{if(typeof Image>"u")return t(null);const n=new Image;n.onload=()=>t({width:n.naturalWidth,height:n.naturalHeight}),n.onerror=()=>t(null),n.src=e})}function Lc(){const{createApi:e,canvasApi:t}=Ke(),n=Bt(),r=ae(l=>l.markBlocked),i=ae(l=>l.clearBlocked),o=ae(l=>l.markFailed),a=ae(l=>l.clearFailed);return m.useCallback(async l=>{var H;const{canvasId:u,blockId:c,ratios:f,source:p,prompt:d,config:h}=l;i(c),a(c);const g=()=>n.invalidateQueries({queryKey:Ot.list(u)}),x=E=>t.updateBlock(u,c,{state:E}).then(g);if(f.length===0){o(c,{message:"No ratios were chosen, so there is nothing to refit to.",refunded:!1});return}if(!p){o(c,{message:"Nothing was selected to refit. Pick an output above first.",refunded:!1});return}await x("running");const C=Date.now(),v=await Promise.allSettled(f.map(E=>e.reshapeToRatio({idempotencyKey:`reshape.to-ratio:${c}:${E}:${C}`,source:{kind:"image",...p},aspectRatio:E,...d&&d.trim()?{prompt:d.trim()}:{},context:{canvasId:u,blockId:c}}).then(B=>({aspectRatio:E,job:B.job})))),k=[],j=[];let R=null,z=null;for(let E=0;E<v.length;E+=1){const B=v[E],A=f[E];if(B.status==="rejected"){j.push(A);const F=B.reason;F instanceof Ds?(R??(R=$c(F)),z??(z=F.message)):z??(z="The request did not reach the assistant. Please try again.");continue}const{job:P}=B.value,D=Oc(P);if(P.status!=="succeeded"||!D){j.push(A),z??(z=Dc((H=P.error)==null?void 0:H.code));continue}k.push({aspectRatio:A,job:P,url:D})}if(k.length===0){await x("placeholder"),R?r(c,R):o(c,{message:z??"This did not produce anything. Please try again.",refunded:!1});return}j.length>0&&di.warning(j.length===1?`${j[0]} could not be refitted. It is not in this set; the rest are.`:`${j.join(", ")} could not be refitted. They are not in this set; the rest are.`);const N=k[0],V=N.job.updatedAt;await t.appendVariant(u,c,{label:k.map(E=>E.aspectRatio).join(", ").slice(0,60),ratio:null,jobId:Fc(N.job.id),provenance:yo(V),config:h??null,media:null,outputSet:{i
1d:N.job.id,items:await Promise.all(k.map(async E=>({id:`${E.job.id}-1`,target:E.aspectRatio,provenance:yo(E.job.updatedAt),media:await zc(E.url,E.aspectRatio)})))}}),await x("complete"),await g()},[e,t,n,r,i,o,a])}function yo(e){return{kind:"derived",source:"gooh-nano-pro",recordedAt:e}}function Oc(e){var t;return e.result.kind!=="outputs"?null:((t=e.result.outputs[0])==null?void 0:t.url)??null}function Fc(e){const t=e.indexOf("_");return t===-1?e:e.slice(t+1)}async function zc(e,t){const n=await _c(e);return{src:e,width:(n==null?void 0:n.width)??1600,height:(n==null?void 0:n.height)??900,alt:`Refitted to ${t}`}}function _c(e){return new Promise(t=>{if(typeof Image>"u")return t(null);const n=new Image;n.onload=()=>t({width:n.naturalWidth,height:n.naturalHeight}),n.onerror=()=>t(null),n.src=e})}function Dc(e){switch(e){case"provider_failed":case"provider_timeout":return"The model could not refit this right now. Please try again in a moment.";case"invalid_input":return"The refit was refused â try a different ratio or a different source.";case"cancelled":return"This was cancelled before it finished.";default:return"This did not produce anything. Please try again."}}function $c(e){const t=wo(e.details.required);return e.code==="spend_limit_exceeded"?{required:t??0,limit:wo(e.details.limit),kind:"ceiling"}:e.code==="insufficient_credits"?{required:t??0,limit:null,kind:"balance"}:null}function wo(e){return typeof e=="number"&&Number.isFinite(e)?e:null}const Bc={all:["operation-capabilities"]},Vc=60*60*1e3;function hn(){const{createApi:e}=Ke(),{data:t,isLoading:n,isError:r}=ui({queryKey:Bc.all,queryFn:()=>e.capabilities(),staleTime:Vc});return{capabilities:t??null,capabilityFor:o=>!o||!t?null:t.groups.flatMap(a=>a.operations).find(a=>a.key===o)??null,isLoadingCapabilities:n,isCapabilitiesError:r}}function Ir(e,t){for(const n of t){const r=rt(e,n);if(!r)continue;const i=r.kind==="block"?gi(r.block):r.variant;if(!i)continue;const o=r.kind==="item"?r.item.media:er(i);if(o)return o.assetId?{assetId:o.assetId}:r.kind==="item"?{variantId:i.id,outputId:r.item.id}:{variantId:i.id}}}const Hc={"create.still":"image.generate","create.edit":"image.edit","animate.from-still":"video.generate"},pa={image:"image.generate",video:"video.generate"};function Uc(e){if(!e)return!1;const[t,n]=e.split(".");return!!n&&ma.has(t)}function Hr(e,t){if(!ha(e))return null;const n=t?Hc[t]??null:null,r=pa[e]??null,i=n!==null&&r!==null&&n.split(".")[0]===r.split(".")[0],o=t?i?n:null:r;return Uc(o)?o:null}function Sr(e){const t=ha(e.typeId)?Hr(e.typeId,e.operationKey):e.operationKey??null;if(!t)return{operationGroup:null,operationName:null};const n=t.indexOf(".");return n<=0||n===t.length-1?{operationGroup:null,operationName:null}:{operationGroup:t.slice(0,n),operationName:t.slice(n+1)}}function ha(e){return e in pa}function bt(e){return!e.operationGroup||!e.operationName?null:ma.has(e.operationGroup)?`${e.operationGroup}.${e.operationName}`:null}const ma=new Set(["image","video","text","motion"]),Ci={"asset-image":{key:null,wired:!0},"asset-video":{key:null,wired:!0},"asset-doc":{key:null,wired:!0},image:{key:"create.still",wired:!0},video:{key:"animate.from-still",wired:!0},document:{key:null,wired:!1,note:"No server route writes a document â plan and research are unbuilt operations. The block, the accept gate and promotion all work; only the producer is missing."},motion:{key:"animate.from-still",wired:!1,note:"Route exists (POST /animate/from-still); no client path yet."},compose:{key:"extract.layers",wired:!1,note:"Route exists (POST /extract/layers); no client path yet."},adapt:{key:"reshape.to-ratio",wired:!0},review:{key:null,wired:!1,note:"No server route at all â nothing defines what a review returns."},export:{key:null,wired:!1,note:"No server route at all â delivery packaging is post-MVP."}};function qn(e){return Ci[e]}function Ft(e){return Ci[e].wired}function Ai(e){return`${e} isnât available yet â nothing was run and nothing was charged.`}function qc(e,t){const n=r=>{if(r.role===null)return t.length+1;const i=t.indexOf(r.role);return i===-1?t.length:i};return[...e].map((r,i)=>({reference:r,index:i})).sort((r,i)=>n(r.reference)-n(i.reference)||r.index-i.index).map(r=>r.reference)}const Zc=["first","second","third","fourth","fifth","sixth","seventh","eighth"];function Cr(e){return Zc[e]??`${e+1}th`}function Kc(e){return e.length===1?e[0]:`${e.slice(0,-1).join(", ")}, and ${e.at(-1)}`}function Wc(e){if(e.length===0)return null;const t=[],n=[];if(e.forEach((r,i)=>{if(r.role===null){n.push(i);return}const o=(r.roleLabel??r.role).toLowerCase();t.push(`the ${Cr(i)} is the ${o}`)}),n.length===1)t.push(`the ${Cr(n[0])} is a general reference`);else if(n.length>1){const r=n.map(Cr);t.push(`the ${r.slice(0,-1).join(", ")} and ${r.at(-1)} are general references`)}return`Reference images follow in order: ${Kc(t)}.`}function ga(e){const t=e.trim();return t?`Avoid: ${t}`:null}function Gc(e){return[e.prompt.trim()||null,Wc(e.ordered),ga(e.negativePrompt)].filter(t=>t!==null&&t.length>0).join(` 2 3`)}function Ur(e,t){return t!=null&&t.config?{source:"variant",values:t.config}:e.config?{source:"block",values:e.config}:{source:"none",values:{}}}function xa(e){return e.operationName==="still"?"still":e.operationName==="edit"?"edit":null}const Yc=["gooh-nano-pro","gooh-nano-flash","gooh-flux"];function ba(e){var f;const t=((f=[e.prompt,e.brief].find(p=>typeof p=="string"&&p.trim().length>0))==null?void 0:f.trim())??"",n=typeof e.negativePrompt=="string"?e.negativePrompt.trim():"",r=[t||null,ga(n)].filter(p=>p!==null).join(` 4 5`),i=typeof e.model=="string"?e.model:void 0,o=Yc.includes(i??"")?i:void 0,a=typeof e.variations=="string"?e.variations:void 0,l=a===void 0?NaN:Number.parseInt(a,10),u=Number.isInteger(l)&&l>0?l:void 0,c=Vt(e.ratio)[0];return{prompt:r,label:t,...n?{negativePrompt:n}:{},...o?{modelId:o}:{},...u?{variations:u}:{},...c?{aspectRatio:c}:{}}}function Xc(e,t,n){return bt(e)!==null?null:Ci[e.typeId].wired?t.source==="none"?"Nothing was recorded about how this ran, so it cannot be repeated. Change a setting below to record one.":xa(e)===null?"This block does not front an operation, so there is nothing to run again.":null:`${n} canât run yet â nothing would be sent and nothing charged.`}function Qc({blocks:e,frames:t,openingId:n,runAgainRefusal:r,reformatRefusal:i,zRefusals:o}){const a=e.length+t.length;if(a===0)return[];const l=a===1&&e.length===1?e[0]:null,u=t.length===0,c=n!==null&&e.some(h=>h.id===n),f=e.some(h=>
5tt(h.state)),p=e.some(h=>h.position!==null),d=[];return l&&(d.push({id:"run-again",label:"Run again",group:"run",destructive:!1,refusal:r}),d.push({id:"reformat",label:"Reformat",group:"run",destructive:!1,refusal:i})),u&&d.push({id:"reset-position",label:e.length===1?"Reset position":`Reset ${e.length} positions`,group:"align",destructive:!1,refusal:p?null:e.length===1?"This block has not been moved.":"None of these have been moved."}),d.push({id:"bring-to-front",label:"Bring to front",group:"order",destructive:!1,refusal:(o==null?void 0:o.front)??null},{id:"bring-forward",label:"Bring forward",group:"order",destructive:!1,refusal:(o==null?void 0:o.forward)??null},{id:"send-backward",label:"Send backward",group:"order",destructive:!1,refusal:(o==null?void 0:o.backward)??null},{id:"send-to-back",label:"Send to back",group:"order",destructive:!1,refusal:(o==null?void 0:o.back)??null}),a>=2&&d.push({id:"align-left",label:"Align left",group:"align",destructive:!1,refusal:null},{id:"align-center-x",label:"Align centres",group:"align",destructive:!1,refusal:null},{id:"align-right",label:"Align right",group:"align",destructive:!1,refusal:null},{id:"align-top",label:"Align top",group:"align",destructive:!1,refusal:null},{id:"align-center-y",label:"Align middles",group:"align",destructive:!1,refusal:null},{id:"align-bottom",label:"Align bottom",group:"align",destructive:!1,refusal:null}),a>=3&&d.push({id:"distribute-horizontal",label:"Distribute across",group:"align",destructive:!1,refusal:null},{id:"distribute-vertical",label:"Distribute down",group:"align",destructive:!1,refusal:null}),c?d.push({id:"discard-run",label:"Discard this run",group:"destroy",destructive:!0,refusal:null}):d.push({id:"delete",label:Jc(e.length,t.length),group:"destroy",destructive:!0,refusal:f?a===1?"A step being worked cannot be discarded.":"One of these is being worked and cannot be discarded.":null}),d}function Jc(e,t){const n=e+t;return n===1?"Discard":t===0?`Discard ${n} blocks`:e===0?`Discard ${n} frames`:`Discard ${n} objects`}const Lt=new Set;function ya(e,t){return e.size===1&&e.has(t)?Lt:new Set([t])}function ed(e,t){const n=new Set(e);return n.delete(t)||n.add(t),n}function td(e,t,{additive:n}){if(!n)return new Set(t);const r=new Set(e);for(const i of t)r.add(i);return r}function nd(e,t){if(e.size===0)return e;const n=new Set(t.map(o=>o.id));let r=!1;const i=new Set;for(const o of e)n.has(o)?i.add(o):r=!0;return r?i:e}function rd(e,t){return e.has(t)?e:ya(e,t)}function ko(e,t){return t.filter(n=>e.has(n.id))}const Ei=e=>e.x-e.width/2,Ti=e=>e.x+e.width/2,Pi=e=>e.y-e.height/2,Mi=e=>e.y+e.height/2;function id(e){if(e.length===0)return null;const t=Math.min(...e.map(Ei)),n=Math.max(...e.map(Ti)),r=Math.min(...e.map(Pi)),i=Math.max(...e.map(Mi));return{id:"",x:(t+n)/2,y:(r+i)/2,width:n-t,height:i-r}}function od(e,t){const n=id(e);if(!n||e.length<2)return new Map;const r=new Map;for(const i of e){const o={x:i.x,y:i.y};switch(t){case"left":o.x=Ei(n)+i.width/2;break;case"center-x":o.x=n.x;break;case"right":o.x=Ti(n)-i.width/2;break;case"top":o.y=Pi(n)+i.height/2;break;case"center-y":o.y=n.y;break;case"bottom":o.y=Mi(n)-i.height/2;break}(o.x!==i.x||o.y!==i.y)&&r.set(i.id,wa(o))}return r}function sd(e,t){if(e.length<3)return new Map;const n=t==="horizontal",r=n?Ei:Pi,i=n?Ti:Mi,o=d=>n?d.width:d.height,a=[...e].sort((d,h)=>r(d)-r(h)),l=i(a[a.length-1])-r(a[0]),u=a.reduce((d,h)=>d+o(h),0),c=(l-u)/(a.length-1),f=new Map;let p=r(a[0]);for(const d of a){const h=p+o(d)/2,g=n?{x:h,y:d.y}:{x:d.x,y:h};(g.x!==d.x||g.y!==d.y)&&f.set(d.id,wa(g)),p+=o(d)+c}return f}function wa(e){return{x:Math.round(e.x),y:Math.round(e.y)}}const ad=8,vo=e=>({x:[e.x-e.width/2,e.x,e.x+e.width/2],y:[e.y-e.height/2,e.y,e.y+e.height/2]});function ld(e,t,n){const r=[];for(const c of t){if(c.id===e.id)continue;const f=vo(c),p=["start","center","end"];f.x.forEach((d,h)=>r.push({axis:"x",at:d,edge:p[h],from:c.y-c.height/2,to:c.y+c.height/2})),f.y.forEach((d,h)=>r.push({axis:"y",at:d,edge:p[h],from:c.x-c.width/2,to:c.x+c.width/2}))}const i=vo(e),o=[],a=c=>{const f=c==="x"?i.x:i.y;let p=null;for(const g of r)if(g.axis===c)for(let x=0;x<f.length;x+=1){const C=g.at-f[x];if(Math.abs(C)>n)continue;(p===null||Math.abs(C)<Math.abs(p.delta)||Math.abs(C)===Math.abs(p.delta)&&x<p.ownIndex)&&(p={delta:C,candidate:g,ownIndex:x})}if(p===null)return 0;
5const d=p,h=c==="x"?[e.y-e.height/2,e.y+e.height/2]:[e.x-e.width/2,e.x+e.width/2];return o.push({axis:c,at:d.candidate.at,from:Math.min(d.candidate.from,h[0]),to:Math.max(d.candidate.to,h[1])}),d.delta},l=a("x"),u=a("y");return{x:Math.round(e.x+l),y:Math.round(e.y+u),guides:o}}function qr(e){return[...e].sort((t,n)=>t.z-n.z||t.createdAt.localeCompare(n.createdAt))}function Mn(e,t,n){const r=qr(e),i=new Set(t),o=r.filter(x=>i.has(x.id)).map(x=>x.id),a=r.filter(x=>!i.has(x.id)).map(x=>x.id);if(o.length===0||a.length===0)return null;const l=r.map(x=>x.id),u=x=>l.indexOf(x);if(n==="front"){const x=[...a,...o];return So(l,x)?null:x}if(n==="back"){const x=[...o,...a];return So(l,x)?null:x}if(n==="forward"){const x=o[o.length-1],C=a.find(z=>u(z)>u(x));if(!C)return null;const v=a.filter(z=>z!==C),k=v.findIndex(z=>u(z)>u(C)),j=k===-1?v:v.slice(0,k),R=k===-1?[]:v.slice(k);return[...j,C,...o,...R]}const c=o[0],f=[...a].reverse().find(x=>u(x)<u(c));if(!f)return null;const p=a.filter(x=>x!==f),d=p.findIndex(x=>u(x)>u(f)),h=d===-1?p:p.slice(0,d),g=d===-1?[]:p.slice(d);return[...h,...o,f,...g]}function jo(e,t,n){const r=new Map(e.map(l=>[l.id,l])),i=t.filter(l=>n.includes(l));if(i.length===0)return new Map;const o=new Set(t.filter(l=>!n.includes(l))),a=new Map;for(const[l,u]of i.entries()){const c=t.indexOf(u),f=Io(t,o,c,-1),p=Io(t,o,c,1),d=f===null?null:r.get(f).z,h=p===null?null:r.get(p).z;if(d!==null&&h!==null){if(!(h>d))return No(t);a.set(u,d+(h-d)*(l+1)/(i.length+1));continue}if(d!==null){a.set(u,d+1+l);continue}if(h!==null){a.set(u,h-i.length+l);continue}return No(t)}return a}function No(e){return new Map(e.map((t,n)=>[t,n]))}function Io(e,t,n,r){for(let i=n+r;i>=0&&i<e.length;i+=r)if(t.has(e[i]))return e[i];return null}function So(e,t){return e.length===t.length&&e.every((n,r)=>n===t[r])}const ud={"create.edit":"image","extract.layers":"compose","reshape.to-ratio":"adapt","reshape.to-screen":"adapt","animate.from-still":"motion"};function cd(e){return e.source!=="none"}function dd(e){if(!e)return[];const t=[];for(const n of e.groups)for(const r of n.operations){if(!cd(r))continue;const i=ud[r.key];i&&t.push({key:r.key,label:r.label,typeId:i,refusal:Ft(i)?null:Ai(oe(i).label)})}return t}const fd=[{id:"describe",label:"Describe it",summary:"Say what you want. The block takes the detail.",icon:na},{id:"bring",label:"Upload an image",summary:"Start from a file you already have.",icon:$s}],pd=["gooh-seedance","gooh-motion-transfer"];function hd(e){return e&&pd.includes(e)?"video":"image"}function Co(e){var r;const t=e.type??"";if(t.startsWith("image/"))return"asset-image";if(t.startsWith("video/"))return"asset-video";const n=((r=(e.name??"").toLowerCase().match(/\.[a-z0-9]+$/))==null?void 0:r[0])??"";return[".png",".jpg",".jpeg",".webp",".gif",".avif",".svg"].includes(n)?"asset-image":[".mp4",".mov",".webm",".m4v"].includes(n)?"asset-video":"asset-doc"}const md="image/*,video/*,.pdf,.doc,.docx,.txt,.md";function Ao(e,t,n=[]){const r=`${e.label}.`,i=typeof t.prompt=="string"?t.prompt.trim():"",o=Nt(e).filter(l=>l.id!=="prompt").map(l=>{const u=xi(l,t[l.id]);return u?`${l.label}: ${u}`:null}).filter(l=>l!==null),a=n.length?`Source: ${n.join(", ")}`:null;return[r,i,[a,o.join(" · ")].filter(Boolean).join(" · ")||null].filter(l=>!!(l&&l.trim())).join(` 6 7`)}function or(e){const t=it(e),n=new Map(t.map(o=>[o.key,[]])),r=[];for(const o of e.inputs){const a=e.inputSlots[o],l=a===void 0?void 0:n.get(a);l?l.push(o):r.push(o)}const i=t.map(o=>({slot:o,citations:n.get(o.key)??[]}));return r.length>0&&i.push({slot:null,citations:r}),i}function ka(e,t){return!e.many&&t.length>0}function sn(e){return oe(e.typeId).produces}function sr(e,t){return e.accepts.some(n=>t.includes(n))}function gd({target:e,source:t,forcePicker:n}){if(e.id===t.id)return{outcome:"none"};if(tt(e.state))return{outcome:"none"};const r=it(e),i=sn(t),o=r.filter(c=>sr(c,i));if(o.length===0)return{outcome:"refuse",reason:xd(oe(e.typeId).label,r,t)};const a=or(e),l=c=>{var f;return((f=a.find(p=>{var d;return((d=p.slot)==null?void 0:d.key)===c.key}))==null?void 0:f.citations)??[]};if(n)return{outcome:"pick",slots:o};const u=o.find(c=>!ka(c,l(c)));return u?{outcome:"fill",slot:u}:{outcome:"pick",slots:o}}
7function xd(e,t,n){const r=Eo(t.flatMap(o=>o.accepts)),i=Eo(sn(n));return r===null?`${e} takes no inputs.`:i===null?`${e} takes ${r}. That block makes nothing to feed it.`:`${e} takes ${r}. That block makes ${i}.`}function Eo(e){const t=new Set,n=[];for(const r of e)t.has(r)||(t.add(r),n.push(Iu[r]));return n.length===0?null:n.length===1?n[0]:`${n.slice(0,-1).join(", ")} or ${n.at(-1)}`}function Zn(e,t,n){const r=new Map(e.map(o=>[o.key,0])),i={};for(const o of t){const a=n(o),l=e.find(u=>sr(u,a)&&(u.many||(r.get(u.key)??0)===0));l&&(i[o]=l.key,r.set(l.key,(r.get(l.key)??0)+1))}return i}function va(e,t,n){var u;const r=Nu(it(e),n);if(!r)throw new Error(`Block "${e.id}" (${e.typeId}) declares no slot "${n}" under the operation it is stamped with. A slot key is data â writing one the type does not declare would strand the edge on arrival.`);const i=new Set(e.inputs),o=((u=or(e).find(c=>{var f;return((f=c.slot)==null?void 0:f.key)===n}))==null?void 0:u.citations)??[],a=r.many?[]:o.filter(c=>c!==t),l=e.inputs.filter(c=>!a.includes(c));return i.has(t)||l.push(t),{inputs:l,inputSlots:Ri(e,l,{[t]:n})}}function bd(e,t){const{[t]:n,...r}=e.inputSlots;return{inputs:[...e.inputs],inputSlots:Ri(e,e.inputs,{},r)}}function yd(e,t){const n=e.inputs.filter(r=>r!==t);return{inputs:n,inputSlots:Ri(e,n,{})}}function Ri(e,t,n,r=e.inputSlots){const i=new Set(t),o={};for(const[a,l]of Object.entries({...r,...n}))i.has(a)&&(o[a]=l);return o}const ja={"asset-image":"bring","asset-video":"bring","asset-doc":"bring",image:"image",video:"video",document:null,motion:"motion",compose:null,adapt:"adapt",review:"review",export:"export"},Li={image:{studio:"new",studioOperation:null},video:{studio:"new",studioOperation:"video.generate"},enlarge:{studio:"new",studioOperation:"image.enlarge"},translate:{studio:"new",studioOperation:"text.translate"},compose:{studio:"new",studioOperation:"image.split-layers"},reformat:{studio:"new",studioOperation:"image.format"},adapt:{studio:"withheld",studioOperation:null},motion:{studio:"old",studioOperation:null},review:{studio:"old",studioOperation:null},export:{studio:"old",studioOperation:null},bring:{studio:"none",studioOperation:null}},Oi={image:"I",video:"V",bring:"U",enlarge:"",reformat:"",translate:"",motion:"M",compose:"C",adapt:"A",review:"R",export:"E"},Na=new Set(["bring"]),Dn={id:"create",label:"Generate",key:"create.still",panel:"still",studioOperation:"image.generate"},Xt={id:"edit",label:"Edit",key:"create.edit",panel:"edit",studioOperation:"image.edit"},wd={id:"reformat",label:"Reformat",key:"image.format",panel:"still",studioOperation:"image.format"},kd={id:"enlarge",label:"Enlarge",key:"image.enlarge",panel:"still",studioOperation:"image.enlarge"},vd={id:"split-layers",label:"Split layers",key:"image.split-layers",panel:"still",studioOperation:"image.split-layers",lands:"compose"},jd=[Dn,Xt,wd,kd,vd],Nd={image:jd};function Fi(e,t){return(t==null?void 0:t.key)??e.operationKey}function To(e){return Br.filter(t=>ja[t.id]===e).map(t=>t.id)}function Ia(e){return oe(e[0]).group==="bring"?"place":"create"}const Id={};function Po(e,t){const n=ja[e.id];if(n===null)return null;const r=Nd[n]??[];return{id:n,label:Id[n]??t,summary:e.summary,icon:e.icon,band:Ia([e.id]),lands:[e.id],picks:null,options:r,operationKey:r.length>0?null:qn(e.id).key,shortcut:Oi[n],inBar:Na.has(n),...Li[n],opening:e.group==="describe"}}const Sa=[{id:"translate",label:"Translate",summary:"Turn text into several languages at once.",icon:Yu,band:"create",lands:["document"],picks:null,options:[],operationKey:null,shortcut:Oi.translate,inBar:!1,...Li.translate,opening:!1}],St=[...Br.filter(e=>e.group==="describe").flatMap(e=>{const t=Po(e,e.shortLabel);return t?[t]:[]}),...fd.filter(e=>e.id==="bring").map(e=>({id:"bring",label:e.label,summary:e.summary,icon:e.icon,band:Ia(To("bring")),lands:To("bring"),picks:"file",options:[],operationKey:null,shortcut:Oi.bring,inBar:Na.has("bring"),...Li.bring,opening:!1})),...Br.filter(e=>e.group==="next").flatMap(e=>{const t=Po(e,e.label);return t?[t]:[]}),...Sa];function Sd(e){return St.flatMap(t=>{if(t.studio==="withheld")return[];if(t.studio==="none")return[t];if(t.studio==="old")return t.operationKey!==null?[t]:[];if(t.options.length>
70){const n=t.options.filter(r=>r.studioOperation!==null&&e(r.studioOperation));return n.length>0?[{...t,options:n}]:[]}return t.studioOperation!==null&&e(t.studioOperation)?[t]:[]})}const Cd=St.filter(e=>!Sa.includes(e)),Ad=St.filter(e=>e.inBar),Ed=St.filter(e=>e.opening),Td=["create","place"],Pd=new Map(St.flatMap(e=>e.options.map(t=>[t.key,t])));function Rn(e){var t;return e?((t=Pd.get(e))==null?void 0:t.panel)??"form":"form"}function Md(e){const t=St.find(n=>n.id===e);if(!t)throw new Error(`Unknown operation "${e}" â add it to OPERATIONS.`);return t}function Rd(e){const t=e.toUpperCase();return St.find(n=>n.shortcut===t)}function zi(e){return e.lands[0]}const Mo={citations:[],slots:{},filled:[]};function Kn(e,t,n){const r=Dt(e,t);if(r.length===0||n.length===0)return Mo;const i=new Map,o=[];for(const u of n){const c=sn(u);for(const f of u.variants)o.push(f.id),i.set(f.id,c)}if(o.length===0)return Mo;const a=Zn(r,o,u=>i.get(u)??[]),l=new Set(Object.values(a));return{citations:o.filter(u=>a[u]!==void 0),slots:a,filled:r.filter(u=>l.has(u.key))}}function Ca(e){const t=e.filled.map(n=>n.label);return t.length===0?null:t.length===1?`Pre-fills ${t[0]}.`:`Pre-fills ${t.slice(0,-1).join(", ")} and ${t.at(-1)}.`}const Ro=[{id:"image-video",steps:["image","video"],resolves:{0:"source"}}],Ld=new Map(Cd.flatMap(e=>e.lands.map(t=>[t,e.id])));function Od(e){const t=Ld.get(e);if(!t)throw new Error(`No operation offers block type "${e}" â see OFFERED_BY.`);return Md(t)}function Fd(e){return e.steps.map(t=>oe(t).shortLabel).join(", then ")}function zd(e){return`${e.steps.length} steps. The next one waits for your accept.`}function _d(e){const t=[];for(let n=0;n+1<e.steps.length;n+=1){const r=oe(e.steps[n]).produces,i=e.steps[n+1],o=Dt(i,Aa(i,n+1)),l=Zn(o,["probe"],()=>r).probe,u=o.filter(c=>sr(c,r));t.push({fromStep:n,toStep:n+1,slot:u.find(c=>c.key===l)??null,alsoAccepted:u.filter(c=>c.key!==l)})}return t}function Dd(e){const t=_d(e);return e.steps.map((n,r)=>{var i,o;return{step:r,type:n,slotKey:r===0?null:((o=(i=t[r-1])==null?void 0:i.slot)==null?void 0:o.key)??null,operationKey:Aa(n,r)}})}function Aa(e,t){return e==="image"&&t>0?Xt.key:qn(e).key}function ar(e,t){const n=[],r=it(e);for(const i of e.inputs){const o=rt(t,i);if((o==null?void 0:o.kind)!=="block"||o.block.id===e.id||gi(o.block))continue;const a=e.inputSlots[i];n.push({citation:i,upstream:o.block,slot:r.find(l=>l.key===a)??null})}return n}function $d(e,t){return ar(e,t).length>0}function Bd(e,t){const n=ar(e,t);if(n.length===0)return null;const r=n.map(o=>o.upstream.title||oe(o.upstream.typeId).label),i=r.length===1?r[0]:`${r.slice(0,-1).join(", ")} and ${r[r.length-1]}`;return n.length===1?`Waiting for you to accept a variant of ${i}.`:`Waiting for you to accept a variant of each of ${i}.`}function Vd(e,t){return t.filter(n=>{if(n.id===e.id)return!1;const r=ar(n,t);return r.length===0?!1:r.every(i=>i.upstream.id===e.id)})}function Hd(e,t){const n=[];for(const r of e.inputs){const i=rt(t,r);if((i==null?void 0:i.kind)!=="block")continue;const o=gi(i.block);o&&n.push({citation:r,variant:o,slotKey:e.inputSlots[r]})}return n}function Ud(e,t){const n=new Map(Hd(e,t).map(r=>[r.citation,r.variant]));return e.inputs.map(r=>{var i;return((i=n.get(r))==null?void 0:i.id)??r})}function qd({drag:e}){return s.jsxs("svg",{className:"pointer-events-none fixed inset-0 z-30 h-full w-full",children:[s.jsx("line",{x1:e.from.x,y1:e.from.y,x2:e.to.x,y2:e.to.y,className:"stroke-primary",strokeWidth:2,strokeDasharray:"6 4"}),s.jsx("circle",{cx:e.to.x,cy:e.to.y,r:4,className:"fill-primary"})]})}function Zd({pick:e,blocks:t,onPick:n,onDismiss:r}){const i=m.useRef(null);m.useEffect(()=>{const u=f=>{i.current&&!i.current.contains(f.target)&&r()},c=f=>{f.key==="Escape"&&r()};return document.addEventListener("pointerdown",u,!0),document.addEventListener("keydown",c),()=>{document.removeEventListener("pointerdown",u,!0),document.removeEventListener("keydown",c)}},[r]);const o=or(e.target),a=u=>{var c;return((c=o.find(f=>{var p;return((p=f.slot)==null?void 0:p.key)===u.key}))==null?void 0:c.citations)??[]},l=u=>{var c,f;for(const p of t)for(const d of p.variants){if(d.id===u)return p.title||d.label||u;if(((c=d.set)==null?void 0:c.id)===u)return p.title||u;const h=(f=d.set)==null?void 0:f.items.find(g=>g.id===u);if(h)return`${p.title} · ${h.target}`}return u};return s.jsxs("div",{ref:i,"data-slot":"connect-slot-picker",role:"menu",className:G("fixed z-40 flex min-w-44 max-w-64 flex-col gap-0.5 rounded-xl p-1.5","bg-surface-floating shadow-2xl ring-1 ring-border/70"),style:{left:Math.min(e.point.x,window.innerWidth-260),top:Math.min(e.point.y,window.innerHeight-40*e.slots.length-24)},children:[s.jsx("p",{className:"px-2 py-1 text-2xs font-semibold text-muted-foreground",children:"Which input?"}),e.slots.map(u=>{var p;const c=a(u),f=ka(u,c);return s.jsxs("button",{type:"button",role:"menuitem","data-slot-key":u.key,onClick:()=>n(u.key),className:G("flex flex-col items-start gap-0.5 rounded-lg px-2 py-1.5 text-left","transition-colors hover:bg-muted"),children:[s.jsx("span",{className:"text-xs font-semibold text-foreground",children:((p=it(e.target).find(d=>d.key===u.key))==null?void 0:p.label)??u.label}),f?s.jsxs("span",{className:"text-2xs text-destructive/80",children:["replaces ",l(c[0])]}
7):s.jsx("span",{className:"text-2xs text-muted-foreground/70",children:u.many&&c.length>0?`joins ${c.length} already there`:"empty"})]},u.key)})]})}const Wn=4,Zr=70,Lo=tr+Zr,Ea={x:0,y:0};function Kd(e){return e.request!==null?Su:Ks}function Ta(e,t,n){return(t==null?void 0:t[n])??e.get(n)??Ea}function Wd(e){const t=new Map,n=new Map,r=new Map;e.forEach((i,o)=>{r.set(i.id,o),t.set(i.id,new Set),n.set(i.id,[])});for(const i of e)for(const o of i.inputs){const a=rt(e,o);if(!a||a.block.id===i.id)continue;const l=n.get(a.block.id);l&&(t.get(i.id).add(a.block.id),l.includes(i.id)||l.push(i.id))}return{parents:t,children:n,index:r}}function Gd(e){const t=new Map,n=new Set,r=i=>{const o=t.get(i);if(o!==void 0)return o;if(n.has(i))return 1;n.add(i);const a=e.children.get(i)??[],l=a.length===0?1:1+Math.max(...a.map(r));return n.delete(i),t.set(i,l),l};for(const i of e.children.keys())r(i);return t}class Yd{constructor(){Tn(this,"taken",new Set);Tn(this,"perRow",new Map);Tn(this,"lastRow",-1)}get rowsUsed(){return this.lastRow+1}firstFit(t,n,r){for(let i=Math.max(0,n);;i++)for(let o=r;o<r+Wn;o++)if(this.fits(t,i,o))return{row:i,col:o}}fits(t,n,r){const i=new Map;for(const o of t){const a=n+o.drow;if(this.taken.has(`${a}:${r+o.dcol}`))return!1;i.set(a,(i.get(a)??0)+1)}return[...i].every(([o,a])=>(this.perRow.get(o)??0)+a<=Wn)}claim(t,n){this.taken.add(`${t}:${n}`),this.perRow.set(t,(this.perRow.get(t)??0)+1),this.lastRow=Math.max(this.lastRow,t)}}function Xd(e,t,n){var c;const r=new Map,i=new Yd,o=new Set,a=new Set,l=(f,p)=>(n.get(p)??0)-(n.get(f)??0)||t.index.get(f)-t.index.get(p),u=(f,p,d)=>{const h=[],g=[];let x=f;for(;x;){const k=x;h.push(k),o.add(k);const j=(t.children.get(k)??[]).filter(R=>!a.has(R)&&[...t.parents.get(R)??[]].every(z=>o.has(z))).sort(l);for(const R of j)a.add(R);x=j.shift();for(const R of j)g.push({head:R,from:k})}const C=h.map((k,j)=>({dcol:j%Wn,drow:Math.floor(j/Wn)})),v=i.firstFit(C,d,p);h.forEach((k,j)=>{const R={col:v.col+C[j].dcol,row:v.row+C[j].drow};r.set(k,R),i.claim(R.row,R.col)});for(const k of g){const j=r.get(k.from)??v;u(k.head,j.col,j.row+1)}};for(const f of e)a.has(f.id)||(((c=t.parents.get(f.id))==null?void 0:c.size)??0)>0||(a.add(f.id),u(f.id,0,i.rowsUsed));for(const f of e)o.has(f.id)||(a.add(f.id),u(f.id,0,i.rowsUsed));return r}function Qd(e,t){let n=0;for(const i of e.values())n=Math.max(n,i.row+1);const r=new Array(n).fill(Ks);for(const[i,o]of e)r[o.row]=Math.max(r[o.row],t(i));return r}function Jd(e){const t=new Map;if(e.length===0)return t;const n=Wd(e),r=Xd(e,n,Gd(n)),i=new Map(e.map(p=>[p.id,p])),o=Qd(r,p=>Kd(i.get(p))),a=[];let l=0;o.forEach((p,d)=>{a[d]=l,l+=p+Zr});const u=l-Zr;let c=0;for(const p of r.values())c=Math.max(c,p.col);const f=c*Lo/2;for(const[p,d]of r)t.set(p,{x:Math.round(d.col*Lo-f),y:Math.round(a[d.row]+o[d.row]/2-u/2)});return t}const ef=/\/(assets|uploads)\/[0-9a-f-]{36}\/content$/i;function tf(e,t){return e.assetId&&ef.test(e.src)?t(e.assetId):e.src}function mn(){const{uploadApi:e}=Ke();return m.useCallback(t=>tf(t,n=>e.contentUrl(n)),[e])}const Oo={width:tr,height:null};function Pa(e){const t=xt(e);if(!t||t.set)return Oo;const n=er(t);return!n||!(n.width>0)||!(n.height>0)?Oo:nf(n.width,n.height)}function nf(e,t){const n=tr/Math.max(e,t);return{width:Math.max(1,Math.round(e*n)),height:Math.max(1,Math.round(t*n))}}const an=10,kt=8;function rf(e,t){return{output:{x:e.x+t/2+an,y:e.y},input:{x:e.x-t/2-an,y:e.y}}}const of=4,sf=Hs({base:"group absolute select-none rounded-xl border transition-shadow",variants:{state:{placeholder:"border-dashed border-border bg-card/60 shadow-none",running:"border-primary/40 bg-card shadow-panel",complete:"border-border bg-card shadow-panel","needs-review":"border-warning-500/60 bg-card shadow-panel",locked:"border-border bg-muted/60 shadow-none ring-1 ring-border"}}}),af=Hs({base:"inline-flex shrink-0 items-center gap-1 rounded px-1.5 py-0.5 text-2xs font-bold leading-none",variants:{state:{placeholder:"bg-muted text-muted-foreground",running:"bg-primary/15 text-primary",complete:"bg-success/15 text-success","needs-review":"bg-warning-500/20 text-warning-700",locked:"bg-foreground
7/10 text-foreground/70"}}});function lf({intake:e}){return s.jsx("dl",{className:"grid grid-cols-[auto_1fr] items-baseline gap-x-2 gap-y-0.5 text-2xs",children:[["Client",e.clientName],["Brand",e.brandName],["Campaign",e.campaignName]].map(([t,n])=>s.jsxs(m.Fragment,{children:[s.jsx("dt",{className:"text-muted-foreground/70",children:t}),s.jsx("dd",{className:"min-w-0 truncate text-foreground",children:n??s.jsx("span",{className:"text-muted-foreground/60",children:"â"})})]},t))})}const uf=6;function cf({variant:e}){const t=mn(),n=e.set;if(!n||n.items.length===0)return null;const r=n.items.slice(0,uf),i=n.items.length-r.length;return s.jsxs("div",{"data-slot":"block-set",className:"grid grid-cols-2 gap-1 p-1",children:[r.map(o=>s.jsxs("figure",{"data-slot":"block-set-item",className:"min-w-0",children:[o.media?s.jsx(fn,{src:t(o.media),alt:o.media.alt,width:o.media.width,height:o.media.height,className:"h-16 w-full rounded object-cover",loading:"lazy",draggable:!1}):s.jsx("div",{className:"flex h-16 w-full items-center justify-center rounded bg-muted/60 text-2xs text-muted-foreground/70",children:"waiting"}),s.jsx("figcaption",{className:"mt-0.5 truncate text-2xs text-muted-foreground",children:o.target})]},o.id)),i>0&&s.jsxs("div",{"data-slot":"block-set-more",className:"flex h-16 items-center justify-center rounded bg-muted/40 text-2xs font-bold text-muted-foreground",children:["+",i," more"]})]})}function df({document:e,label:t}){const{words:n,lede:r}=yi(e),i=e.title.trim(),o=i&&i!==t.trim()?i:"";return s.jsxs("div",{"data-slot":"block-document",className:"flex flex-col gap-1.5 p-3",children:[s.jsxs("div",{className:"flex items-start gap-1.5",children:[s.jsx(Eu,{size:14,weight:"duotone",className:"mt-px shrink-0 text-muted-foreground"}),s.jsx("p",{className:"min-w-0 flex-1 text-2xs font-bold tabular-nums text-muted-foreground",children:n===1?"1 word":`${n.toLocaleString()} words`})]}),o&&s.jsx("p",{className:"line-clamp-2 text-xs font-bold leading-snug text-foreground",children:o}),r&&s.jsx("p",{className:"line-clamp-3 text-2xs leading-relaxed text-muted-foreground",children:r})]})}function ff(){return s.jsxs("div",{"data-slot":"block-output-deleted",className:"flex flex-col gap-1 px-3 py-4 text-center",children:[s.jsx("p",{className:"text-2xs font-medium text-foreground",children:"The accepted variant has been deleted"}),s.jsx("p",{className:"text-2xs leading-relaxed text-muted-foreground",children:"Put it back from the panel, accept another variant, or run this block again."})]})}function pf({block:e}){const t=mn(),n=oe(e.typeId).produces.includes("video"),{byVariant:r}=ra(e.canvasId),{representative:i}=Ws(e);if(!i)return null;const o=i.accepted?r.get(i.id):void 0;if(o!=null&&o.deletedAt)return s.jsx(ff,{});const a=i.set!==void 0,l=a?null:er(i)??null;return s.jsxs("div",{"data-slot":"block-outputs",className:"flex flex-col",children:[i.document&&s.jsx(df,{document:i.document,label:i.label}),a?s.jsx(cf,{variant:i}):n?l&&s.jsx("video",{"data-slot":"block-output",src:t(l),controls:!0,playsInline:!0,preload:"metadata",style:l.width>0&&l.height>0?{aspectRatio:`${l.width} / ${l.height}`}:{aspectRatio:"16 / 9"},className:"w-full bg-muted object-cover"}):l&&s.jsx(fn,{"data-slot":"block-output",src:t(l),alt:l.alt,width:l.width,height:l.height,style:l.width>0&&l.height>0?{aspectRatio:`${l.width} / ${l.height}`}:void 0,className:"w-full object-cover",loading:"lazy",draggable:!1})]})}function hf(e,t){var i;const n=t==null?void 0:t.label.trim();if(n)return n;const r=(i=e.request)==null?void 0:i.trim();return r||oe(e.typeId).label}function mf({block:e}){if(it(e).length===0)return null;const t=e.inputs.length>0;return s.jsx("span",{"data-slot":"block-input-port","data-port-key":"input","data-port-filled":t?"true":void 0,title:t?"What feeds this block":"Nothing feeds this block yet","aria-hidden":!0,className:G("pointer-events-none absolute top-1/2 -translate-x-1/2 -translate-y-1/2 rounded-full border",t?"border-primary bg-primary":"border-border bg-surface-floating"),style:{width:kt,height:kt,left:-an}})}function gf({block:e,autoPosition:t,waitingFor:n,selected:r,dragOffset:i,onSelect:o,onContextMenu:a,onDragStart:l,onDragMove:u,onDragEnd:c,onOpenPlan:f,onStartRun:p,onAddStep:d,onConnectStart:h,onConnectMove:g,onConnectEnd:x}){const C=Bs(),v=ae(I=>I.blockedBlocks[e.id]),k=ae(I=>I.failedBlocks[e.id]),[j,R]=m.useState(!1),z=m.useRef(null),N=e.position??t,V=i?{x:N.x+i.x,y:N.y+i.y}:N,H=tt(e.state),E=oe(e.typeId),B=m.useCallback(I=>{I.button===0&&(I.stopPropagation(),I.currentTarget.setPointerCapture(I.pointerId),z.current={px:I.clientX,py:I.clientY,moved:!1},R(!0))},[]),A=m.useCallback(I=>{const W=z.current;if(!W)return;const Y=I.clientX-W.px,he=I.clientY-W.py;if(!W.moved&&Math.hypot(Y,he)>of&&(W.moved=!0,l==null||l(e.id)),!W.moved||H)return;const{scale:ye}=fi(C);u==null||u(e.id,{x:Y/ye,y:he/ye})},[C,H,e.id,l,u]),P=m.useCallback(I=>{const W=z.current;W&&(z.current=null,R(!1),I.currentTarget.hasPointerCapture(I.pointerId)&&I.currentTarget.releasePointerCapture(I.pointerId),W.moved&&(c==null||c(e.id)),W.moved||o==null||o(e.id,{additive:I.shift
7Key||I.metaKey||I.ctrlKey}))},[e.id,c,o]),D=m.useRef(!1),F=m.useCallback(I=>{I.button===0&&(I.stopPropagation(),I.currentTarget.setPointerCapture(I.pointerId),D.current=!0,h==null||h(e.id,{x:I.clientX,y:I.clientY}))},[e.id,h]),Z=m.useCallback(I=>{D.current&&(g==null||g({x:I.clientX,y:I.clientY}))},[g]),K=m.useCallback(I=>{var he;if(!D.current)return;D.current=!1,I.currentTarget.hasPointerCapture(I.pointerId)&&I.currentTarget.releasePointerCapture(I.pointerId);const W=document.elementFromPoint(I.clientX,I.clientY),Y=((he=W==null?void 0:W.closest("[data-block-id]"))==null?void 0:he.dataset.blockId)??null;x==null||x({targetBlockId:Y===e.id?null:Y,forcePicker:I.altKey,point:{x:I.clientX,y:I.clientY}})},[e.id,x]),ee=j&&i!==null,{representative:ne,variantCount:ue}=Ws(e),Ne=pu(I=>hu(I.views,C).scale)>=Au,we=!Ft(e.typeId)&&bt(e)===null&&!ne,y=e.state==="placeholder"&&!ne?n??null:null,ge=e.request!==null,Ae=e.state==="placeholder"&&!ne&&!y&&!we&&!!p,pe=xt(e),Se=hf(e,ne),Ee=ne&&!ne.set&&ne.ratio&&ne.ratio!=="â"?ne.ratio:null,Ie=Pa(e);return s.jsxs("article",{[ki]:!0,"data-slot":"block","data-block-id":e.id,"data-block-state":e.state,"data-block-type":e.typeId,"data-selected":r?"true":void 0,"data-blocked":v?"true":void 0,"data-failed":k?"true":void 0,"aria-pressed":r,onPointerDown:B,onPointerMove:A,onPointerUp:P,onPointerCancel:P,onContextMenu:I=>{a&&(I.preventDefault(),I.stopPropagation(),a(e.id,{x:I.clientX,y:I.clientY}))},style:{width:Ie.width,...Ie.height===null?{}:{height:Ie.height},left:"50%",top:"50%",transform:`translate(-50%, -50%) translate(${V.x}px, ${V.y}px)`},className:G(sf({state:e.state}),ee?"cursor-grabbing ring-2 ring-primary transition-none":"",!ee&&r&&"ring-2 ring-primary",!ee&&H&&"cursor-not-allowed",!ee&&!H&&"cursor-grab hover:shadow-lg"),children:[s.jsx("div",{"data-slot":"block-chrome",className:"pointer-events-none absolute bottom-full left-0 right-0 mb-1 flex items-end gap-2",children:Ne?s.jsxs("div",{"data-slot":"block-label",className:"flex min-w-0 flex-1 items-baseline gap-1.5 text-2xs leading-none",children:[s.jsx("span",{className:G("min-w-0 truncate font-bold",r?"text-primary":"text-muted-foreground"),title:Se,children:Se}),ue>1&&s.jsxs("span",{"data-slot":"block-variant-count",title:`${ue} variants â the ${ne!=null&&ne.accepted?"accepted one":"latest"} is showing`,className:"shrink-0 tabular-nums text-muted-foreground/70",children:[ue," variants"]}),Ee&&s.jsx("span",{className:"shrink-0 tabular-nums text-muted-foreground/70",children:Ee})]}):s.jsx("span",{className:"min-w-0 flex-1"})}),ne&&e.state!=="complete"&&s.jsxs("span",{"data-slot":"block-state",className:G(af({state:e.state}),"absolute left-2 top-2 z-10 shadow-sm","bg-surface-floating ring-1 ring-border/60"),children:[H&&s.jsx(Vs,{size:10,weight:"fill"}),e.state==="needs-review"&&s.jsx(go,{size:10,weight:"fill"}),bi[e.state]]}),s.jsxs("div",{className:"flex flex-col overflow-hidden rounded-[calc(0.75rem-1px)]",children:[ne?s.jsx(pf,{block:e}):s.jsxs("div",{className:"flex flex-col gap-2 p-3",children:[ge&&e.intake&&s.jsx("div",{"data-slot":"block-intake",children:s.jsx(lf,{intake:e.intake})}),ge&&f&&e.plan&&s.jsx("div",{className:"border-t border-border pt-2",children:s.jsxs("button",{type:"button",onClick:f,onPointerDown:I=>I.stopPropagation(),"data-slot":"block-plan-open",className:G("flex w-full items-center gap-1.5 rounded-md border border-border px-2 py-1.5","text-2xs font-bold text-foreground transition-colors","hover:border-primary/40 hover:bg-muted","outline-none focus-visible:ring-2 focus-visible:ring-sidebar-ring"),children:[s.jsx(Cu,{size:13,weight:"duotone",className:"shrink-0 text-primary"}),e.plan.title,s.jsx("span",{className:"ml-auto text-muted-foreground",children:e.plan.approvedAt?"Approved":"Review"})]})}),y||we?s.jsxs("p",{"data-slot":y?"block-waiting":"block-unavailable",className:"flex items-start gap-1.5 text-2xs leading-relaxed text-muted-foreground",children:[y&&!we?s.jsx(ca,{size:13,className:"mt-px shrink-0"}):s.jsx(Xu,{size:13,className:"mt-px shrink-0"}),s.jsxs("span",{children:[y,y&&we?" ":null,we?Ai(E.label):null]})]}):s.jsx("p",{"data-slot":"block-empty",className:"text-2xs italic leading-relaxed text-muted-foreground
7/70",children:E.produces.length===0?"Leaves no variants behind":"No variants yet"}),Ae&&s.jsxs("button",{type:"button","data-slot":"block-start-run",onPointerDown:I=>I.stopPropagation(),onClick:I=>{I.stopPropagation(),p==null||p(e.id)},className:G("flex w-full items-center justify-center gap-1.5 rounded-md border border-dashed","border-border px-2 py-2 text-2xs font-medium text-muted-foreground","transition-colors hover:border-primary/50 hover:bg-muted hover:text-foreground","outline-none focus-visible:ring-2 focus-visible:ring-sidebar-ring"),children:[s.jsx(_t,{size:12,weight:"bold",className:"shrink-0"}),"Start now"]}),e.state==="running"&&s.jsx("div",{className:"h-1 overflow-hidden rounded-full bg-muted",children:s.jsx("div",{className:"h-full w-1/3 animate-pulse rounded-full bg-primary"})})]}),v&&s.jsxs("p",{"data-slot":"block-blocked","data-refusal":v.kind,className:"flex items-start gap-1.5 bg-warning-500/15 px-3 py-2 text-2xs leading-relaxed text-warning-700",children:[s.jsx(vi,{size:13,weight:"fill",className:"mt-px shrink-0"}),s.jsxs("span",{children:[s.jsx("span",{className:"font-bold",children:"Blocked â "}),v.kind==="ceiling"?s.jsxs(s.Fragment,{children:["this needs ",v.required," credits",v.limit!==null&&s.jsxs(s.Fragment,{children:[" and the limit is ",v.limit]}),". Ask for less: fewer variations, or a smaller batch."]}):s.jsxs(s.Fragment,{children:["this needs ",v.required," credits and your balance is lower. Nothing was charged."]})]})]}),k&&s.jsxs("p",{"data-slot":"block-failed",className:"flex items-start gap-1.5 bg-muted px-3 py-2 text-2xs leading-relaxed text-muted-foreground",children:[s.jsx(go,{size:13,weight:"fill",className:"mt-px shrink-0"}),s.jsxs("span",{children:[s.jsx("span",{className:"font-bold text-foreground",children:"Nothing came back â "}),k.message,k.refunded&&s.jsx(s.Fragment,{children:" Your tokens were returned."})]})]})]}),s.jsx(mf,{block:e}),!H&&E.produces.length>0&&pe&&s.jsxs(s.Fragment,{children:[s.jsx("button",{type:"button","data-slot":"block-connect-port","data-port-key":"output",disabled:!h,title:h?"Drag onto another block to feed it this output":"What this block outputs","aria-label":h?"Drag onto another block to feed it this output":"What this block outputs",onPointerDown:h?F:void 0,onPointerMove:h?Z:void 0,onPointerUp:h?K:void 0,onPointerCancel:h?K:void 0,className:G("absolute top-1/2 -translate-x-1/2 -translate-y-1/2 rounded-full","border border-primary bg-surface-floating transition-all duration-150",h?"cursor-crosshair hover:scale-150 hover:border-2 focus-visible:scale-150":"cursor-default","outline-none focus-visible:ring-2 focus-visible:ring-sidebar-ring"),style:{width:kt,height:kt,left:`calc(100% + ${an}px)`}}),d&&s.jsx("button",{type:"button","data-slot":"block-add",title:"Add a step from this output","aria-label":"Add a step from this output",onPointerDown:I=>I.stopPropagation(),onClick:I=>{I.stopPropagation();const W=I.currentTarget.getBoundingClientRect();d(e.id,{x:W.right,y:W.bottom})},className:G("absolute top-1/2 flex -translate-y-1/2 items-center justify-center rounded-full","border border-dashed border-primary/60 bg-surface-floating text-primary","transition-opacity duration-150 hover:border-solid hover:bg-primary/10","opacity-0 focus-visible:opacity-100 group-hover:opacity-100","outline-none focus-visible:ring-2 focus-visible:ring-sidebar-ring"),style:{width:kt*2,height:kt*2,left:`calc(100% + ${an*2+kt}px)`},children:s.jsx(_t,{size:10,weight:"bold"})})]})]})}const xf=18,bf=.4,yf=.22,wf=220;function kf(e,t){const n=xf+Math.abs(e)*bf+Math.abs(t)*yf;return Math.min(wf,n)}function vf(e,t){const n=kf(t.x-e.x,t.y-e.y);return{from:e,to:t,c1:{x:e.x+n,y:e.y},c2:{x:t.x-n,y:t.y},handle:n}}function Fo(e){const t=n=>`${zo(n.x)} ${zo(n.y)}`;return`M ${t(e.from)} C ${t(e.c1)} ${t(e.c2)} ${t(e.to)}`}function zo(e){return Math.round(e*100)/100}function jf(e,t){const n=Math.min(1,Math.max(0,t)),r=1-n,i=r*r*r,o=3*r*r*n,a=3*r*n*n,l=n*n*n;return{x:i*e.from.x+o*e.c1.x+a*e.c2.x+l*e.to.x,y:i*e.from.y+o*e.c1.y+a*e.c2.y+l*e.to.y}}const _o=2;function Nf(e,t){if(e.length===0)return t>1?`Ã${t}`:null;const n=e.slice(0,_o).join(" · "),r=e.length-_o;return r>0?`${n} +${r}`:n}function If(e){var n;const t=[];for(const r of e){const i=it(r),o=new Map;for(const a of r.inputs){const l=rt(e,a);if(!l||l.block.id===r.id)continue;const u=o.get(l.block.id)??{names:[],citations:0};u.citations+=1;const c=r.inputSlots[a],f=(n=i.find(d=>d.key===c))==null?void 0:n.label,p=l.kind==="item"?l.item.target:bt(r)!==null?"Input":f;p&&!u.names.includes(p)&&u.names.push(p),o.set(l.block.id,u)}for(const[a,{names:l,citations:u}]of o)t.push({key:`${a}->${r.id}`,fromId:a,toId:r.id,label:Nf(l,u)})}return t}function Sf({blocks:e,layout:t,onDisconnect:n}){const r={};for(const d of e)d.position&&(r[d.id]=d.position);const i=d=>Ta(t,r,d.id),o=m.useRef(null),[a,l]=m.useState({w:0,h:0});m.useEffect(()=>{const d=o.current;if(!d)return;const h=()=>{const x={w:d.clientWidth,h:d.clientHeight};l(C=>C.w===x.w&&C.h===x.h?C:x)};h();const g=new ResizeObserver(h);return g.observe(d),()=>g.disconnect()},[]);const[u,c]=m.useState({});m.useEffect(()=>{var C;const d=(C=o.current)==null?void 0:C.parentElement;if(!d)return;const h=[...d.querySelectorAll('[data-slot="block"][data-block-id]')],g=()=>{const v={};for(const k of h){const j=k.dataset.blockId;j&&(v[j]={w:k.offsetWidth,h:k.offsetHeight})}c(k=>{const j=Object.keys(v);return j.length===Object.keys(k).length&&j.every(z=>{var N,V;return((N=k[z])==null?void 0:N.w)===v[z].w&&((V=k[z])==null?void 0:V.h)===v[z].h})?k:v})};g();const x=new ResizeObserver(g);for(const v of h)x.observe(v);return()=>x.disconnect()},[e]);const f=If(e),p=new Map(e.map(d=>{const h=u[d.id],g=Pa(d);return[d.id,rf(i(d),(h==null?void 0:h.w)??g.width)]}));return s.jsxs("svg",{ref:o,"data-slot":"connectors","aria-hidden":!0,style:{position:"absolute",inset:0,width:"100%",height:"100%",overflow:"visible"}
7,className:"pointer-events-none text-muted-foreground/60",children:[s.jsx("defs",{children:s.jsx("marker",{id:"gooh-studio-arrow",viewBox:"0 0 8 8",refX:"7",refY:"4",markerWidth:"6",markerHeight:"6",orient:"auto-start-reverse",children:s.jsx("path",{d:"M 0 0 L 8 4 L 0 8 z",fill:"currentColor"})})}),s.jsx("g",{transform:`translate(${a.w/2}, ${a.h/2})`,children:f.map(d=>{const h=p.get(d.fromId),g=p.get(d.toId);if(!h||!g)return null;const x=vf(h.output,g.input),C=jf(x,.5);return s.jsxs("g",{"data-connector":d.key,className:"group/edge",children:[s.jsx("path",{d:Fo(x),fill:"none",stroke:"currentColor",strokeWidth:1.5,strokeLinecap:"round",markerEnd:"url(#gooh-studio-arrow)"}),d.label&&s.jsx("text",{x:C.x,y:C.y-4,textAnchor:"middle",className:"fill-current text-2xs font-bold",children:d.label}),s.jsx("path",{d:Fo(x),fill:"none",stroke:"transparent",strokeWidth:18,className:"cursor-pointer",onClick:()=>n==null?void 0:n(d.fromId,d.toId),children:s.jsx("title",{children:"Remove this connection"})}),n&&s.jsxs("g",{className:"cursor-pointer opacity-0 transition-opacity group-hover/edge:opacity-100",onClick:()=>n(d.fromId,d.toId),"data-slot":"edge-remove",children:[s.jsx("circle",{cx:C.x,cy:C.y+9,r:7,className:"fill-background stroke-current",strokeWidth:1}),s.jsx("path",{d:`M ${C.x-3} ${C.y+6} L ${C.x+3} ${C.y+12} M ${C.x+3} ${C.y+6} L ${C.x-3} ${C.y+12}`,stroke:"currentColor",strokeWidth:1.4,strokeLinecap:"round"}),s.jsx("title",{children:"Remove this connection"})]})]},d.key)})})]})}const Cf=4,Ln=10;function Af({frame:e,selected:t,dragOffset:n,onSelect:r,onContextMenu:i,onDragStart:o,onDragMove:a,onDragEnd:l,onCommit:u}){const c=Bs(),f=m.useRef(null),[p,d]=m.useState(null),h=p??{x:e.x+((n==null?void 0:n.x)??0),y:e.y+((n==null?void 0:n.y)??0),width:e.width,height:e.height},g=m.useCallback((k,j)=>{k.button===0&&(k.stopPropagation(),k.currentTarget.setPointerCapture(k.pointerId),f.current={px:k.clientX,py:k.clientY,corner:j,from:{x:e.x,y:e.y,width:e.width,height:e.height},moved:!1,latest:null})},[e.x,e.y,e.width,e.height]),x=m.useCallback(k=>{const j=f.current;if(!j)return;const R=k.clientX-j.px,z=k.clientY-j.py;if(!j.moved&&Math.hypot(R,z)>Cf&&(j.moved=!0),!j.moved)return;const{scale:N}=fi(c),V=j.corner?Cc({...j.from,aspectRatio:e.aspectRatio},j.corner,R/N,z/N):{...j.from,x:Math.round(j.from.x+R/N),y:Math.round(j.from.y+z/N)};j.latest=V,d(V)},[c,e.aspectRatio]),C=m.useCallback(k=>{const j=f.current;j&&(f.current=null,k.currentTarget.hasPointerCapture(k.pointerId)&&k.currentTarget.releasePointerCapture(k.pointerId),j.latest?u==null||u(e.id,j.latest):j.moved&&(l==null||l(e.id)),d(null),j.moved||r==null||r(e.id,{additive:k.shiftKey||k.metaKey||k.ctrlKey}))},[e.id,u,l,r]),v=k=>({onPointerDown:j=>g(j,k),onPointerMove:x,onPointerUp:C,onPointerCancel:C,onContextMenu:j=>{i&&(j.preventDefault(),j.stopPropagation(),i(e.id,{x:j.clientX,y:j.clientY}))}});return s.jsxs("div",{[ki]:!0,"data-slot":"frame","data-frame-id":e.id,"data-selected":t?"true":void 0,style:{width:h.width,height:h.height,left:"50%",top:"50%",transform:`translate(-50%, -50%) translate(${h.x}px, ${h.y}px)`},className:"pointer-events-none absolute",children:[s.jsx("div",{"aria-hidden":!0,className:G("absolute inset-0 rounded-lg border",t?"border-primary bg-primary/[0.04]":"border-border bg-foreground
7/[0.015]")}),s.jsxs("button",{type:"button",...v(null),"data-slot":"frame-label","aria-pressed":t,className:G("pointer-events-auto absolute bottom-full left-0 mb-1 flex max-w-full items-center gap-1.5","cursor-grab rounded px-1 text-2xs font-semibold outline-none","focus-visible:ring-2 focus-visible:ring-sidebar-ring",t?"text-primary":"text-muted-foreground hover:text-foreground"),children:[s.jsx("span",{className:"truncate",children:Ii(e)}),e.aspectRatio&&s.jsx("span",{className:"shrink-0 rounded bg-muted px-1 font-normal tabular-nums",children:e.aspectRatio}),(t||p)&&s.jsx("span",{className:"shrink-0 font-normal tabular-nums opacity-70",children:Si({...e,...h})})]}),[["top","left-0 right-0 top-0 cursor-grab",{height:Ln}],["bottom","left-0 right-0 bottom-0 cursor-grab",{height:Ln}],["left","top-0 bottom-0 left-0 cursor-grab",{width:Ln}],["right","top-0 bottom-0 right-0 cursor-grab",{width:Ln}]].map(([k,j,R])=>s.jsx("div",{...v(null),"data-slot":"frame-edge","data-edge":k,style:{...R,transform:"translate(0,0)"},className:G("pointer-events-auto absolute",j)},k)),t&&[["nw","-left-1 -top-1 cursor-nwse-resize"],["ne","-right-1 -top-1 cursor-nesw-resize"],["se","-right-1 -bottom-1 cursor-nwse-resize"],["sw","-left-1 -bottom-1 cursor-nesw-resize"]].map(([k,j])=>s.jsx("div",{...v(k),"data-slot":"frame-handle","data-corner":k,className:G("pointer-events-auto absolute size-2.5 rounded-sm border border-primary bg-background",j)},k))]})}function Ef({blocks:e,frames:t,layout:n,onApi:r,fitPadding:i,centrePadding:o,onBackgroundClick:a,onBackgroundContextMenu:l,onMarquee:u,selectedIds:c,onSelectObject:f,onObjectContextMenu:p,onFrameCommit:d,onDrawBox:h,onAddStep:g,dragOffsetFor:x,onObjectDragStart:C,onObjectDragMove:v,onObjectDragEnd:k,guides:j,onConnectStart:R,onConnectMove:z,onConnectEnd:N,onDisconnect:V,onStartRun:H,children:E}){var D;const B=ae(F=>F.openPanel),A=ae(F=>F.canvasTool),P=((D=cn(e))==null?void 0:D.id)??null;return s.jsxs(Wu,{className:"fixed inset-0 z-0",zoomOnWheel:!0,controls:!1,onApi:r,fitPadding:i,centrePadding:o,onBackgroundClick:a,onBackgroundContextMenu:l,dragOnSurface:A==="pan"?"pan":A==="frame"?"draw":"marquee",onMarquee:u,onDrawBox:h,children:[qr(t).map(F=>s.jsx(Af,{frame:F,selected:(c==null?void 0:c.has(F.id))??!1,dragOffset:(x==null?void 0:x(F.id))??null,onSelect:f,onContextMenu:p,onDragStart:C,onDragMove:v,onDragEnd:k,onCommit:d},F.id)),s.jsx(Tf,{guides:j??[]}),s.jsx(Sf,{blocks:e,layout:n,onDisconnect:V}),E,qr(e).map(F=>s.jsx(gf,{block:F,autoPosition:n.get(F.id)??Ea,onAddStep:g,waitingFor:Bd(F,e),selected:(c==null?void 0:c.has(F.id))??!1,dragOffset:(x==null?void 0:x(F.id))??null,onSelect:f,onContextMenu:p,onDragStart:C,onDragMove:v,onDragEnd:k,onConnectStart:R,onConnectMove:z,onConnectEnd:N,onOpenPlan:F.id===P?()=>B("plan"):void 0,onStartRun:H},F.id))]})}function Tf({guides:e}){const{scale:t}=Us();return e.length===0?null:s.jsx("svg",{"aria-hidden":!0,"data-slot":"canvas-guides",className:"pointer-events-none absolute left-1/2 top-1/2 overflow-visible",style:{width:0,height:0},children:e.map(n=>s.jsx("line",{"data-guide-axis":n.axis,x1:n.axis==="x"?n.at:n.from,y1:n.axis==="x"?n.from:n.at,x2:n.axis==="x"?n.at:n.to,y2:n.axis==="x"?n.to:n.at,className:"stroke-primary",strokeWidth:1/Math.max(t,.01),strokeDasharray:`${4/Math.max(t,.01)} ${3/Math.max(t,.01)}`},`${n.axis}-${n.at}`))})}function Pf({children:e}){const[t]=m.useState(()=>{const n=document.createElement("div");return n.setAttribute("data-slot","gooh-studio-ground"),n});return m.useEffect(()=>(document.body.insertBefore(t,document.body.firstChild),()=>t.remove()),[t]),mu.createPortal(e,t)}function Mf(){const e=ae(l=>l.canvasId),{canvas:t}=Jn(e??void 0),{brand:n}=pi((t==null?void 0:t.brandId)??void 0),{client:r}=gu((n==null?void 0:n.clientId)??void 0),{campaign:i}=qs((t==null?void 0:t.campaignId)??void 0),[o,a]=m.useState(!1);return e?t!=null&&t.brandId?s.jsxs("div",{className:"flex flex-col gap-3",children:[s.jsxs("div",{className:"rounded-lg border border-border bg-muted/30 p-3",children:[s.jsxs("p",{className:"flex items-center gap-1.5 text-2xs font-semibold text-muted-foreground",children:[s.jsx(Vs,{size:12,weight:"fill",className:"shrink-0"}),"Client"]}),s.jsx("p",{className:"mt-1 truncate text-sm font-bold text-foreground",children:(r==null?void 0:r.companyName)??"Loadingâ¦"}),s.jsx("p",{className:"mt-2 text-2xs leading-relaxed text-muted-foreground",children:"Permanent. A canvas belongs to one client for its whole life â start a new canvas to work for another."})]}),s.jsxs("div",{className:"rounded-lg border border-border p-3",children:[s.jsxs("p",{className:"flex items-center gap-1.5 text-2xs font-semibold text-muted-foreground",children:[s.jsx(nc,{size:12,weight:"duotone",className:"shrink-0"}),"Brand"]}),s.jsx("p",{className:"mt-1 truncate text-sm font-bold text-foreground",children:(n==null?void 0:n.name)??"Loadingâ¦"}),s.jsxs("p",{className:"mt-2 text-2xs leading-relaxed text-muted-foreground",children:["Not fixed â this canvas can move to another of ",(r==null?void 0:r.companyName)??"this client","'s brands at any time. Moving it clears the campaign."]})]}),s.jsxs("div",{className:"rounded-lg border border-border p-3",children:[s.jsx("p",{className:"text-2xs font-semibold text-muted-foreground",children:"Campaign"}),s.jsx("p",{className:"mt-1 truncate text-sm text-foreground",children:t.campaignId?(i==null?void 0:i.campaignName)??"Loadingâ¦":"None yet"}),s.jsx("p",{className:"mt-2 text-2xs leading-relaxed text-muted-foreground",children:"Not fixed â this canvas can move to another of this brand's campaigns at any time."})]}),s.jsx("button",{type:"button",onClick:()=>a(!0),"data-slot":"refile-canvas-from-panel",className:"rounded-md border border-border px-2 py-1.5 text-xs font-semibold text-foreground transition-colors hover:bg-muted",children:"Change"}),s.jsx("p",{className:"text-2xs leading-relaxed text-muted-foreground
7/80",children:"Palette, type and the brand check arrive with the brand kit."}),s.jsx(ho,{canvasId:e,currentBrandId:t.brandId,currentCampaignId:t.campaignId,open:o,onOpenChange:a})]}):s.jsxs("div",{className:"flex flex-col gap-3",children:[s.jsxs("div",{className:"rounded-lg border border-dashed border-border p-4 text-center",children:[s.jsx("p",{className:"text-xs font-semibold text-foreground",children:"No brand attached"}),s.jsx("p",{className:"mt-1 text-2xs leading-relaxed text-muted-foreground",children:"A canvas can be worked on without one. Attaching a brand files this work under that brand's guidelines, and decides the client â which cannot be changed afterwards."})]}),s.jsx("button",{type:"button",onClick:()=>a(!0),"data-slot":"attach-brand-from-panel",className:"rounded-md bg-foreground px-2 py-1.5 text-xs font-semibold text-background transition-opacity hover:opacity-90",children:"Attach brand"}),s.jsx(ho,{canvasId:e,open:o,onOpenChange:a})]}):s.jsx("div",{className:"flex h-full min-h-24 items-center justify-center rounded-lg border border-dashed border-border p-4 text-center",children:s.jsx("p",{className:"text-xs leading-relaxed text-muted-foreground",children:"Nothing has been made on this canvas yet. Add something, then attach it to a brand."})})}const Rf=[{label:"Talk through a brief",message:"I have a brief. Can we talk through it before anything gets made?"},{label:"Discuss first",message:"Before we make anything â help me work out what this should be."},{label:"Research",message:"Show me references, formats and what has run before for this kind of work."}],Ar=[{key:"create",label:"Create",hint:"Make something new on the canvas"},{key:"ask",label:"Ask",hint:"Question the run without changing it"}];function Lf({role:e,text:t}){return e==="user"?s.jsx("div",{"data-slot":"chat-turn","data-role":"user",className:"flex justify-end",children:s.jsx("p",{className:"max-w-[85%] rounded-2xl rounded-br-md bg-primary px-3 py-1.5 text-xs leading-relaxed text-primary-foreground",children:t})}):s.jsx("p",{"data-slot":"chat-turn","data-role":"assistant",className:"text-xs leading-relaxed text-foreground",children:t})}function Of(){return s.jsxs("p",{"data-slot":"chat-working",role:"status",className:"flex items-center gap-1.5 text-xs text-muted-foreground",children:[s.jsx(Un,{size:13,weight:"fill",className:"shrink-0 animate-pulse text-primary"}),"Workingâ¦"]})}function Ff({conversationId:e}){const[t,n]=m.useState(""),[r,i]=m.useState("create"),[o,a]=m.useState(!1),l=ic(t,120),{messages:u}=qu(e??void 0),{send:c,streamingText:f,isStreaming:p}=wi(e??void 0),d=[...u.map(k=>({role:k.role,text:k.body})),...p?[{role:"assistant",text:f}]:[]],h=p?"working":"idle",g=m.useRef(null);m.useEffect(()=>{var k;(k=g.current)==null||k.scrollIntoView({block:"end"})},[d.length,h]);const x=k=>{e&&c(k)},C=()=>{const k=t.trim();!k||!e||p||(c(k),n(""))},v=Ar.find(k=>k.key===r)??Ar[0];return s.jsxs("div",{className:"flex min-h-0 flex-1 flex-col",children:[d.length===0?s.jsxs("div",{className:"flex min-h-0 flex-1 flex-col items-center justify-center gap-2.5 px-6 text-center",children:[s.jsx("span",{"aria-hidden":"true",className:"flex size-9 items-center justify-center rounded-full bg-muted text-muted-foreground",children:s.jsx(Un,{size:18,weight:"duotone"})}),s.jsx("p",{className:"text-sm font-semibold text-foreground",children:"Start with an idea."}),s.jsx("div",{className:"flex flex-wrap items-center justify-center gap-1.5 pt-1",children:Rf.map(k=>s.jsx("button",{type:"button","data-chat-starter":k.label,onClick:()=>x(k.message),className:"rounded-full border border-border px-2.5 py-1 text-xs text-muted-foreground outline-none transition-colors hover:border-primary/40 hover:text-foreground focus-visible:ring-2 focus-visible:ring-sidebar-ring",children:k.label},k.label))})]}):s.jsxs("div",{className:"flex min-h-0 flex-1 flex-col gap-3 overflow-y-auto px-3 pb-2",children:[d.map((k,j)=>s.jsx(Lf,{role:k.role,text:k.text},j)),h==="working"&&s.jsx(Of,{}),s.jsx("div",{ref:g})]}),s.jsx("div",{className:"shrink-0 p-2.5 pt-0",children:s.jsxs("div",{className:"rounded-2xl bg-muted/60 p-2 transition-colors focus-within:bg-muted",children:[s.jsx("textarea",{ref:l,rows:1,value:t,onChange:k=>n(k.target.value),onKeyDown:k=>{k.key==="Enter"&&!k.shiftKey&&(k.preventDefault(),C())},placeholder:"What do you want to do?","aria-label":`${v.label} â message`,className:"w-full resize-none bg-transparent px-1 py-0.5 text-xs leading-5 text-foreground placeholder:text-muted-foreground focus-visible:outline-none"}),s.jsxs("div",{className:"mt-1 flex items-center gap-1",children:[s.jsxs(je.Root,{open:o,onOpenChange:a,children:[s.jsx(je.Anchor,{children:s.jsxs("button",{type:"button",onClick:()=>a(k=>!k),"aria-label":`Mode: ${v.label}`,className:"flex items-center gap-1 rounded-full px-2 py-1 text-2xs font-semibold text-foreground outline-none transition-colors hover:bg-background/70 focus-visible:ring-2 focus-visible:ring-sidebar-ring",children:[s.jsx(Un,{size:13,weight:"fill",className:"text-primary"}),v.label,s.jsx(Tu,{size:11,className:"text-muted-foreground"})]})}),s.jsx(je.Content,{side:"top",align:"start",className:"w-56",children:Ar.map(k=>s.jsx(je.Item,{onClick:()=>{i(k.key),a(!1)},className:"items-start gap-2 py-2",children:s.jsxs("span",{className:"min-w-0 flex-1 text-left",children:[s.jsx("span",{className:"block truncate font-semibold text-foreground",children:k.label}),s.jsx("span",{className:"block truncate text-2xs text-muted-foreground",children:k.hint})]})},k.key))})]}),s.jsx("button",{type:"button","aria-label":"Voice input",title:"Voice input",className:"ml-auto flex size-7 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-background/70 hover:text-foreground",children:s.jsx(oc,{size:15})}),s.jsx("button",{type:"button",onClick:C,disabled:!t.trim()||!e||p,"aria-label":"Send",title:"Send",className:G("flex size-7 items-center justify-center rounded-full transition-colors","bg-primary text-primary-foreground hover:bg-primary/90","disabled:cursor-not-allowed disabled:opacity-40"),children:s.jsx(rc,{size:14,weight:"bold"})})]})]})})]})}function zf(e,t){const n={};return(e[e.length-1]===""?[...e,""]:e).join((n.padRight?" ":"")+","+(n.padLeft===!1?"":" ")).trim()}const _f=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,Df=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,$f={};function Do(e,t){return($f.jsx?Df:_f).test(e)}const Bf=/[ \t\n\f\r]/g;function Vf(e){return typeof e=="object"?e.type==="text"?$o(e.value):!1:$o(e)}function $o(e){return e.replace(Bf,"")===""}class gn{constructor(t,n,r){this.normal=n,this.property=t,r&&(this.space=r)}}gn.prototype.normal={};gn.prototype.property={};gn.prototype.space=void 0;function Ma(e,t){const n={},r={};for(const i of e)Object.assign(n,i.property),Object.assign(r,i.normal);return new gn(n,r,t)}function Kr(e){return e.toLowerCase()}class ze{constructor(t,n){this.attribute=n,this.property=t}}ze.prototype.attribute="";ze.prototype.booleanish=!1;ze.prototype.boolean=!1;ze.prototype.commaOrSpaceSeparated=!1;ze.prototype.commaSeparated=!1;ze.prototype.defined=!1;ze.prototype.mustUseProperty=!1;ze.prototype.number=!1;ze.prototype.overloadedBoolean=!1;ze.prototype.property="";ze.prototype.spaceSeparated=!1;ze.prototype.space=void 0;let Hf=0;
vendor: 4,659 bytes, line 7
7const J=Ct(),ve=Ct(),Wr=Ct(),O=Ct(),me=Ct(),jt=Ct(),$e=Ct();function Ct(){return 2**++Hf}const Gr=Object.freeze(Object.defineProperty({__proto__:null,boolean:J,booleanish:ve,commaOrSpaceSeparated:$e,commaSeparated:jt,number:O,overloadedBoolean:Wr,spaceSeparated:me},Symbol.toStringTag,{value:"Module"})),Er=Object.keys(Gr);class _i extends ze{constructor(t,n,r,i){let o=-1;if(super(t,n),Bo(this,"space",i),typeof r=="number")for(;++o<Er.length;){const a=Er[o];Bo(this,Er[o],(r&Gr[a])===Gr[a])}}}_i.prototype.defined=!0;function Bo(e,t,n){n&&(e[t]=n)}function Ut(e){const t={},n={};for(const[r,i]of Object.entries(e.properties)){const o=new _i(r,e.transform(e.attributes||{},r),i,e.space);e.mustUseProperty&&e.mustUseProperty.includes(r)&&(o.mustUseProperty=!0),t[r]=o,n[Kr(r)]=r,n[Kr(o.attribute)]=r}return new gn(t,n,e.space)}const Ra=Ut({properties:{ariaActiveDescendant:null,ariaAtomic:ve,ariaAutoComplete:null,ariaBusy:ve,ariaChecked:ve,ariaColCount:O,ariaColIndex:O,ariaColSpan:O,ariaControls:me,ariaCurrent:null,ariaDescribedBy:me,ariaDetails:null,ariaDisabled:ve,ariaDropEffect:me,ariaErrorMessage:null,ariaExpanded:ve,ariaFlowTo:me,ariaGrabbed:ve,ariaHasPopup:null,ariaHidden:ve,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:me,ariaLevel:O,ariaLive:null,ariaModal:ve,ariaMultiLine:ve,ariaMultiSelectable:ve,ariaOrientation:null,ariaOwns:me,ariaPlaceholder:null,ariaPosInSet:O,ariaPressed:ve,ariaReadOnly:ve,ariaRelevant:null,ariaRequired:ve,ariaRoleDescription:me,ariaRowCount:O,ariaRowIndex:O,ariaRowSpan:O,ariaSelected:ve,ariaSetSize:O,ariaSort:null,ariaValueMax:O,ariaValueMin:O,ariaValueNow:O,ariaValueText:null,role:null},transform(e,t){return t==="role"?t:"aria-"+t.slice(4).toLowerCase()}});function La(e,t){return t in e?e[t]:t}function Oa(e,t){return La(e,t.toLowerCase())}const Uf=Ut({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:jt,acceptCharset:me,accessKey:me,action:null,allow:null,allowFullScreen:J,allowPaymentRequest:J,allowUserMedia:J,alpha:J,alt:null,as:null,async:J,autoCapitalize:null,autoComplete:me,autoFocus:J,autoPlay:J,blocking:me,capture:null,charSet:null,checked:J,cite:null,className:me,closedBy:null,colorSpace:null,cols:O,colSpan:O,command:null,commandFor:null,content:null,contentEditable:ve,controls:J,controlsList:me,coords:O|jt,crossOrigin:null,data:null,dateTime:null,decoding:null,default:J,defer:J,dir:null,dirName:null,disabled:J,download:Wr,draggable:ve,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:J,formTarget:null,headers:me,height:O,hidden:Wr,high:O,href:null,hrefLang:null,htmlFor:me,httpEquiv:me,id:null,imageSizes:null,imageSrcSet:null,inert:J,inputMode:null,integrity:null,is:null,isMap:J,itemId:null,itemProp:me,itemRef:me,itemScope:J,itemType:me,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:J,low:O,manifest:null,max:null,maxLength:O,media:null,method:null,min:null,minLength:O,multiple:J,muted:J,name:null,nonce:null,noModule:J,noValidate:J,onAbort:null,onAfterPrint:null,onAuxClick:null,onBeforeMatch:null,onBeforePrint:null,onBeforeToggle:null,onBeforeUnload:null,onBlur:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onContextLost:null,onContextMenu:null,onContextRestored:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnded:null,onError:null,onFocus:null,onFormData:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLanguageChange:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadEnd:null,onLoadStart:null,onMessage:null,onMessageError:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRejectionHandled:null,onReset:null,onResize:null,onScroll:null,onScrollEnd:null,onSecurityPolicyViolation:null,onSeeked:null,onSeeking:null,onSelect:null,onSlotChange:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnhandledRejection:null,onUnload:null,onVolumeChange:null,onWaiting:null,onWheel:null,open:J,optimum:O,pattern:null,ping:me,placeholder:null,playsInl
7ine:J,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:J,referrerPolicy:null,rel:me,required:J,reversed:J,rows:O,rowSpan:O,sandbox:me,scope:null,scoped:J,seamless:J,selected:J,shadowRootClonable:J,shadowRootCustomElementRegistry:J,shadowRootDelegatesFocus:J,shadowRootMode:null,shadowRootSerializable:J,shape:null,size:O,sizes:null,slot:null,span:O,spellCheck:ve,src:null,srcDoc:null,srcLang:null,srcSet:null,start:O,step:null,style:null,tabIndex:O,target:null,title:null,translate:null,type:null,typeMustMatch:J,useMap:null,value:ve,width:O,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:me,axis:null,background:null,bgColor:null,border:O,borderColor:null,bottomMargin:O,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:J,declare:J,event:null,face:null,frame:null,frameBorder:null,hSpace:O,leftMargin:O,link:null,longDesc:null,lowSrc:null,marginHeight:O,marginWidth:O,noResize:J,noHref:J,noShade:J,noWrap:J,object:null,profile:null,prompt:null,rev:null,rightMargin:O,rules:null,scheme:null,scrolling:ve,standby:null,summary:null,text:null,topMargin:O,valueType:null,version:null,vAlign:null,vLink:null,vSpace:O,allowTransparency:null,autoCorrect:null,autoSave:null,credentialless:J,disablePictureInPicture:J,disableRemotePlayback:J,exportParts:jt,part:me,prefix:null,property:null,results:O,security:null,unselectable:null},space:"html",transform:Oa}),qf=Ut({attributes:{accentHeight:"accent-height",alignmentBaseline:"alignment-baseline",arabicForm:"arabic-form",baselineShift:"baseline-shift",capHeight:"cap-height",className:"class",clipPath:"clip-path",clipRule:"clip-rule",colorInterpolation:"color-interpolation",colorInterpolationFilters:"color-interpolation-filters",colorProfile:"color-profile",colorRendering:"color-rendering",crossOrigin:"crossorigin",dataType:"datatype",dominantBaseline:"dominant-baseline",enableBackground:"enable-background",fillOpacity:"fill-opacity",fillRule:"fill-rule",floodColor:"flood-color",floodOpacity:"flood-opacity",fontFamily:"font-family",fontSize:"font-size",fontSizeAdjust:"font-size-adjust",fontStretch:"font-stretch",fontStyle:"font-style",fontVariant:"font-variant",fontWeight:"font-weight",glyphName:"glyph-name",glyphOrientationHorizontal:"glyph-orientation-horizontal",glyphOrientationVertical:"glyph-orientation-vertical",hrefLang:"hreflang",horizAdvX:"horiz-adv-x",horizOriginX:"horiz-origin-x",horizOriginY:"horiz-origin-y",imageRendering:"image-rendering",letterSpacing:"letter-spacing",lightingColor:"lighting-color",markerEnd:"marker-end",markerMid:"marker-mid",markerStart:"marker-start",maskType:"mask-type",navDown:"nav-down",navDownLeft:"nav-down-left",navDownRight:"nav-down-right",navLeft:"nav-left",navNext:"nav-next",navPrev:"nav-prev",navRight:"nav-right",navUp:"nav-up",navUpLeft:"nav
7-up-left",navUpRight:"nav-up-right",onAbort:"onabort",onActivate:"onactivate",onAfterPrint:"onafterprint",onBeforePrint:"onbeforeprint",onBegin:"onbegin",onCancel:"oncancel",onCanPlay:"oncanplay",onCanPlayThrough:"oncanplaythrough",onChange:"onchange",onClick:"onclick",onClose:"onclose",onCopy:"oncopy",onCueChange:"oncuechange",onCut:"oncut",onDblClick:"ondblclick",onDrag:"ondrag",onDragEnd:"ondragend",onDragEnter:"ondragenter",onDragExit:"ondragexit",onDragLeave:"ondragleave",onDragOver:"ondragover",onDragStart:"ondragstart",onDrop:"ondrop",onDurationChange:"ondurationchange",onEmptied:"onemptied",onEnd:"onend",onEnded:"onended",onError:"onerror",onFocus:"onfocus",onFocusIn:"onfocusin",onFocusOut:"onfocusout",onHashChange:"onhashchange",onInput:"oninput",onInvalid:"oninvalid",onKeyDown:"onkeydown",onKeyPress:"onkeypress",onKeyUp:"onkeyup",onLoad:"onload",onLoadedData:"onloadeddata",onLoadedMetadata:"onloadedmetadata",onLoadStart:"onloadstart",onMessage:"onmessage",onMouseDown:"onmousedown",onMouseEnter:"onmouseenter",onMouseLeave:"onmouseleave",onMouseMove:"onmousemove",onMouseOut:"onmouseout",onMouseOver:"onmouseover",onMouseUp:"onmouseup",onMouseWheel:"onmousewheel",onOffline:"onoffline",onOnline:"ononline",onPageHide:"onpagehide",onPageShow:"onpageshow",onPaste:"onpaste",onPause:"onpause",onPlay:"onplay",onPlaying:"onplaying",onPopState:"onpopstate",onProgress:"onprogress",onRateChange:"onratechange",onRepeat:"onrepeat",onReset:"onreset",onResize:"onresize",onScroll:"onscroll",onSeeked:"onseeked",onSeeking:"onseeking",onSelect:"onselect",onShow:"onshow",onStalled:"onstalled",onStorage:"onstorage",onSubmit:"onsubmit",onSuspend:"onsuspend",onTimeUpdate:"ontimeupdate",onToggle:"ontoggle",onUnload:"onunload",onVolumeChange:"onvolumechange",onWaiting:"onwaiting",onZoom:"onzoom",overlinePosition:"overline-position",overlineThickness:"overline-thickness",paintOrder:"paint-order",panose1:"panose-1",pointerEvents:"pointer-events",referrerPolicy:"referrerpolicy",renderingIntent:"rendering-intent",shapeRendering:"shape-rendering",stopColor:"stop-color",stopOpacity:"stop-opacity",strikethroughPosition:"strikethrough-position",strikethroughThickness:"strikethrough-thickness",strokeDashArray:"stroke-dasharray",strokeDashOffset:"stroke-dashoffset",strokeLineCap:"stroke-linecap",strokeLineJoin:"stroke-linejoin",strokeMiterLimit:"stroke-miterlimit",strokeOpacity:"stroke-opacity",strokeWidth:"stroke-width",tabIndex:"tabindex",textAnchor:"text-anchor",textDecoration:"text-decoration",textRendering:"text-rendering",transformOrigin:"transform-origin",typeOf:"typeof",underlinePosition:"underline-position",underlineThickness:"underline-thickness",unicodeBidi:"unicode-bidi",unicodeRange:"unicode-range",unitsPerEm:"units-per-em",vAlphabetic:"v-alphabetic",vHanging:"v-hanging",vIdeographic:"v-ideographic",vMathematical:"v-mathematical",vectorEffect:"vector-effect",vertAdvY:"vert-adv-y",vertOriginX:"vert-origin-x",vertOriginY:"vert-origin-y",wordSpacing:"word-spacing",writingMode:"writing-mode",xHeight:"x-height",playbackOrder:"playbackorder",timelineBegin:"timelinebegin"},properties:{about:$e,accentHeight:O,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:O,amplitude:O,arabicForm:null,ascent:O,attributeName:null,attributeType:null,azimuth:O,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:O,by:null,calcMode:null,capHeight:O,className:me,clip:null,clipPath:null,clipPathUnits:null,clipRule:null,color:null,colorInterpolation:null,colorInterpolationFilters:null,colorProfile:null,colorRendering:null,content:null,contentScriptType:null,contentStyleType:null,crossOrigin:null,cursor:null,cx:null,cy:null,d:null,dataType:null,defaultAction:null,descent:O,diffuseConstant:O,direction:null,display:null,dur:null,divisor:O,dominantBaseline:null,download:J,dx:null,dy:null,edgeMode:null,editable:null,elevation:O,enableBackground:null,end:null,event:null,exponent:O,externalResourcesRequired:null,fill:null,fillOpacity:O,fillRule:null,filter:null,filterRes:null,filterUnits:null,floodColor:null,floodOpacity:null,focusable:null,focusHighlight:null,fontFamily:null,fontSize:null,fontSizeAdjust:null,fontStretch:null,fontStyle:null,fontVariant:null,fontWeight:null,format:null,fr:null,from:null,fx:null,fy:null,g1:jt,g2:jt,glyphName:jt,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:O,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:O,horizOriginX:O,horizOriginY:O,id:null,ideographic:O,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:O,k:O,k1:O,k2:O,k3:O,k4:O,kernelMatrix:$e,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:O,local:null,markerEnd:null,markerMid:null,markerStart:null,markerHeight:null,markerUnits:null,markerWidth:null,mask:null,maskContentUnits:null,maskType:null,maskUnits:null,mathematical:null,max:null,media:null,mediaCharacterEncoding:null,mediaContentEncodings:null,mediaSize:O,mediaTime:null,method:null,min:null,mode:null,name:null,navDown:null,navDownLeft:null,navDownRight:null,navLeft:null,navNext:null,navPrev:null,navRight:null,navUp:null,navUpLeft:null,navUpRight:null,numOctaves:null,observer:null,offset:null,onAbort:null,onActivate:null,onAfterPrint:null,onBeforePrint:null,onBegin:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnd:null,onEnded:null,onError:null,onFocus:null,onFocusIn:null,onFocusOut:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadStart:null,onMessage:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onMouseWheel:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRepeat:null,onReset:null,onResize:null,onScroll:null,onSeeked:null,onSeeking:null,onSelect:null,onShow:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnload:null,onVolumeChange:null,onWaiting:null,on
vendor: 4,193 bytes, lines 7-8
7Zoom:null,opacity:null,operator:null,order:null,orient:null,orientation:null,origin:null,overflow:null,overlay:null,overlinePosition:O,overlineThickness:O,paintOrder:null,panose1:null,path:null,pathLength:O,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:me,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:O,pointsAtY:O,pointsAtZ:O,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:$e,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:$e,rev:$e,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:$e,requiredFeatures:$e,requiredFonts:$e,requiredFormats:$e,resource:null,restart:null,result:null,rotate:null,rx:null,ry:null,scale:null,seed:null,shapeRendering:null,side:null,slope:null,snapshotTime:null,specularConstant:O,specularExponent:O,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:O,strikethroughThickness:O,string:null,stroke:null,strokeDashArray:$e,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:O,strokeOpacity:O,strokeWidth:null,style:null,surfaceScale:O,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:$e,tabIndex:O,tableValues:null,target:null,targetX:O,targetY:O,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:$e,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:O,underlineThickness:O,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:O,values:null,vAlphabetic:O,vMathematical:O,vectorEffect:null,vHanging:O,vIdeographic:O,version:null,vertAdvY:O,vertOriginX:O,vertOriginY:O,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:O,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:"svg",transform:La}),Fa=Ut({properties:{xLinkActuate:null,xLinkArcRole:null,xLinkHref:null,xLinkRole:null,xLinkShow:null,xLinkTitle:null,xLinkType:null},space:"xlink",transform(e,t){return"xlink:"+t.slice(5).toLowerCase()}}),za=Ut({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:Oa}),_a=Ut({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform(e,t){return"xml:"+t.slice(3).toLowerCase()}}),Zf={classId:"classID",dataType:"datatype",itemId:"itemID",strokeDashArray:"strokeDasharray",strokeDashOffset:"strokeDashoffset",strokeLineCap:"strokeLinecap",strokeLineJoin:"strokeLinejoin",strokeMiterLimit:"strokeMiterlimit",typeOf:"typeof",xLinkActuate:"xlinkActuate",xLinkArcRole:"xlinkArcrole",xLinkHref:"xlinkHref",xLinkRole:"xlinkRole",xLinkShow:"xlinkShow",xLinkTitle:"xlinkTitle",xLinkType:"xlinkType",xmlnsXLink:"xmlnsXlink"},Kf=/[A-Z]/g,Vo=/-[a-z]/g,Wf=/^data[-\w.:]+$/i;function Gf(e,t){const n=Kr(t);let r=t,i=ze;if(n in e.normal)return e.property[e.normal[n]];if(n.length>4&&n.slice(0,4)==="data"&&Wf.test(t)){if(t.charAt(4)==="-"){const o=t.slice(5).replace(Vo,Xf);r="data"+o.charAt(0).toUpperCase()+o.slice(1)}else{const o=t.slice(4);if(!Vo.test(o)){let a=o.replace(Kf,Yf);a.charAt(0)!=="-"&&(a="-"+a),t="data"+a}}i=_i}return new i(r,t)}function Yf(e){return"-"+e.toLowerCase()}function Xf(e){return e.charAt(1).toUpperCase()}const Qf=Ma([Ra,Uf,Fa,za,_a],"html"),Di=Ma([Ra,qf,Fa,za,_a],"svg");function Jf(e){return e.join(" ").trim()}var $i={},Ho=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,ep=/\n/g,tp=/^\s*/,np=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,rp=/^:\s*/,ip=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,op=/^[;\s]*/,sp=/^\s+|\s+$/g,ap=` 8`,Uo="/",qo="*",vt="",lp="comment",up="declaration";function cp(e,t){if(typeof e!="string")throw new TypeError("First argument must be a string");if(!e)return[];t=t||{};var n=1,r=1;function i(g){var x=g.match(ep);x&&(n+=x.length);var C=g.lastIndexOf(ap);r=~C?g.length-C:r+g.length}function o(){var g={line:n,column:r};return function(x){return x.position=new a(g),c(),x}
vendor: 4,723 bytes, line 8
8}function a(g){this.start=g,this.end={line:n,column:r},this.source=t.source}a.prototype.content=e;function l(g){var x=new Error(t.source+":"+n+":"+r+": "+g);if(x.reason=g,x.filename=t.source,x.line=n,x.column=r,x.source=e,!t.silent)throw x}function u(g){var x=g.exec(e);if(x){var C=x[0];return i(C),e=e.slice(C.length),x}}function c(){u(tp)}function f(g){var x;for(g=g||[];x=p();)x!==!1&&g.push(x);return g}function p(){var g=o();if(!(Uo!=e.charAt(0)||qo!=e.charAt(1))){for(var x=2;vt!=e.charAt(x)&&(qo!=e.charAt(x)||Uo!=e.charAt(x+1));)++x;if(x+=2,vt===e.charAt(x-1))return l("End of comment missing");var C=e.slice(2,x-2);return r+=2,i(C),e=e.slice(x),r+=2,g({type:lp,comment:C})}}function d(){var g=o(),x=u(np);if(x){if(p(),!u(rp))return l("property missing ':'");var C=u(ip),v=g({type:up,property:Zo(x[0].replace(Ho,vt)),value:C?Zo(C[0].replace(Ho,vt)):vt});return u(op),v}}function h(){var g=[];f(g);for(var x;x=d();)x!==!1&&(g.push(x),f(g));return g}return c(),h()}function Zo(e){return e?e.replace(sp,vt):vt}var dp=cp,fp=Vn&&Vn.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty($i,"__esModule",{value:!0});$i.default=hp;const pp=fp(dp);function hp(e,t){let n=null;if(!e||typeof e!="string")return n;const r=(0,pp.default)(e),i=typeof t=="function";return r.forEach(o=>{if(o.type!=="declaration")return;const{property:a,value:l}=o;i?t(a,l,o):l&&(n=n||{},n[a]=l)}),n}var lr={};Object.defineProperty(lr,"__esModule",{value:!0});lr.camelCase=void 0;var mp=/^--[a-zA-Z0-9_-]+$/,gp=/-([a-z])/g,xp=/^[^-]+$/,bp=/^-(webkit|moz|ms|o|khtml)-/,yp=/^-(ms)-/,wp=function(e){return!e||xp.test(e)||mp.test(e)},kp=function(e,t){return t.toUpperCase()},Ko=function(e,t){return"".concat(t,"-")},vp=function(e,t){return t===void 0&&(t={}),wp(e)?e:(e=e.toLowerCase(),t.reactCompat?e=e.replace(yp,Ko):e=e.replace(bp,Ko),e.replace(gp,kp))};lr.camelCase=vp;var jp=Vn&&Vn.__importDefault||function(e){return e&&e.__esModule?e:{default:e}},Np=jp($i),Ip=lr;function Yr(e,t){var n={};return!e||typeof e!="string"||(0,Np.default)(e,function(r,i){r&&i&&(n[(0,Ip.camelCase)(r,t)]=i)}),n}Yr.default=Yr;var Sp=Yr;const Cp=Zs(Sp),Da=$a("end"),Bi=$a("start");function $a(e){return t;function t(n){const r=n&&n.position&&n.position[e]||{};if(typeof r.line=="number"&&r.line>0&&typeof r.column=="number"&&r.column>0)return{line:r.line,column:r.column,offset:typeof r.offset=="number"&&r.offset>-1?r.offset:void 0}}}function Ba(e){const t=Bi(e),n=Da(e);if(t&&n)return{start:t,end:n}}function Qt(e){return!e||typeof e!="object"?"":"position"in e||"type"in e?Wo(e.position):"start"in e||"end"in e?Wo(e):"line"in e||"column"in e?Xr(e):""}function Xr(e){return Go(e&&e.line)+":"+Go(e&&e.column)}function Wo(e){return Xr(e&&e.start)+"-"+Xr(e&&e.end)}function Go(e){return e&&typeof e=="number"?e:1}class Ce extends Error{constructor(t,n,r){super(),typeof n=="string"&&(r=n,n=void 0);let i="",o={},a=!1;if(n&&("line"in n&&"column"in n?o={place:n}:"start"in n&&"end"in n?o={place:n}:"type"in n?o={ancestors:[n],place:n.position}:o={...n}),typeof t=="string"?i=t:!o.cause&&t&&(a=!0,i=t.message,o.cause=t),!o.ruleId&&!o.source&&typeof r=="string"){const u=r.indexOf(":");u===-1?o.ruleId=r:(o.source=r.slice(0,u),o.ruleId=r.slice(u+1))}if(!o.place&&o.ancestors&&o.ancestors){const u=o.ancestors[o.ancestors.length-1];u&&(o.place=u.position)}const l=o.place&&"start"in o.place?o.place.start:o.place;this.ancestors=o.ancestors||void 0,this.cause=o.cause||void 0,this.column=l?l.column:void 0,this.fatal=void 0,this.file="",this.message=i,this.line=l?l.line:void 0,this.name=Qt(o.place)||"1:1",this.place=o.place||void 0,this.reason=this.message,this.ruleId=o.ruleId||void 0,this.source=o.source||void 0,this.stack=a&&o.cause&&typeof o.cause.stack=="string"?o.cause.stack:"",this.actual=void 0,this.expected=void 0,this.note=void 0,this.url=void 0}}Ce.prototype.file="";Ce.prototype.name="";Ce.prototype.reason="";Ce.prototype.message="";Ce.prototype.stack="";Ce.prototype.column=void 0;Ce.prototype.line=void 0;Ce.prototype.ancestors=void 0;Ce.prototype.cause=void 0;Ce.prototype.fatal=void 0;Ce.prototype.place=void 0;Ce.prototype.ruleId=void 0;Ce.prototype.source=void 0;const Vi={}.hasOwnProperty,Ap=new Map,Ep=/[A-Z]/g,Tp=new Set(["table","tbody","thead","tfoot","tr"]),Pp=new Set(["td","th"]),Va="https://github.com/syntax-tree/hast-util-to-jsx-runtime";function Mp(e,t){if(!t||t.Fragment===void 0)throw new TypeError("Expected `Fragment` in options");const n=t.filePath||void 0;let r;if(t.development){if(typeof t.jsxDEV!="function")throw new TypeError("Expected `jsxDEV` in options when `development: true`");r=$p(n,t.jsxDEV)}else{if(typeof t.jsx!="function")throw new TypeError("Expected `jsx` in production options");
vendor: 5,854 bytes, line 8
8if(typeof t.jsxs!="function")throw new TypeError("Expected `jsxs` in production options");r=Dp(n,t.jsx,t.jsxs)}const i={Fragment:t.Fragment,ancestors:[],components:t.components||{},create:r,elementAttributeNameCase:t.elementAttributeNameCase||"react",evaluater:t.createEvaluater?t.createEvaluater():void 0,filePath:n,ignoreInvalidStyle:t.ignoreInvalidStyle||!1,passKeys:t.passKeys!==!1,passNode:t.passNode||!1,schema:t.space==="svg"?Di:Qf,stylePropertyNameCase:t.stylePropertyNameCase||"dom",tableCellAlignToStyle:t.tableCellAlignToStyle!==!1},o=Ha(i,e,void 0);return o&&typeof o!="string"?o:i.create(e,i.Fragment,{children:o||void 0},void 0)}function Ha(e,t,n){if(t.type==="element")return Rp(e,t,n);if(t.type==="mdxFlowExpression"||t.type==="mdxTextExpression")return Lp(e,t);if(t.type==="mdxJsxFlowElement"||t.type==="mdxJsxTextElement")return Fp(e,t,n);if(t.type==="mdxjsEsm")return Op(e,t);if(t.type==="root")return zp(e,t,n);if(t.type==="text")return _p(e,t)}function Rp(e,t,n){const r=e.schema;let i=r;t.tagName.toLowerCase()==="svg"&&r.space==="html"&&(i=Di,e.schema=i),e.ancestors.push(t);const o=qa(e,t.tagName,!1),a=Bp(e,t);let l=Ui(e,t);return Tp.has(t.tagName)&&(l=l.filter(function(u){return typeof u=="string"?!Vf(u):!0})),Ua(e,a,o,t),Hi(a,l),e.ancestors.pop(),e.schema=r,e.create(t,o,a,n)}function Lp(e,t){if(t.data&&t.data.estree&&e.evaluater){const r=t.data.estree.body[0];return r.type,e.evaluater.evaluateExpression(r.expression)}ln(e,t.position)}function Op(e,t){if(t.data&&t.data.estree&&e.evaluater)return e.evaluater.evaluateProgram(t.data.estree);ln(e,t.position)}function Fp(e,t,n){const r=e.schema;let i=r;t.name==="svg"&&r.space==="html"&&(i=Di,e.schema=i),e.ancestors.push(t);const o=t.name===null?e.Fragment:qa(e,t.name,!0),a=Vp(e,t),l=Ui(e,t);return Ua(e,a,o,t),Hi(a,l),e.ancestors.pop(),e.schema=r,e.create(t,o,a,n)}function zp(e,t,n){const r={};return Hi(r,Ui(e,t)),e.create(t,e.Fragment,r,n)}function _p(e,t){return t.value}function Ua(e,t,n,r){typeof n!="string"&&n!==e.Fragment&&e.passNode&&(t.node=r)}function Hi(e,t){if(t.length>0){const n=t.length>1?t:t[0];n&&(e.children=n)}}function Dp(e,t,n){return r;function r(i,o,a,l){const c=Array.isArray(a.children)?n:t;return l?c(o,a,l):c(o,a)}}function $p(e,t){return n;function n(r,i,o,a){const l=Array.isArray(o.children),u=Bi(r);return t(i,o,a,l,{columnNumber:u?u.column-1:void 0,fileName:e,lineNumber:u?u.line:void 0},void 0)}}function Bp(e,t){const n={};let r,i;for(i in t.properties)if(i!=="children"&&Vi.call(t.properties,i)){const o=Hp(e,i,t.properties[i]);if(o){const[a,l]=o;e.tableCellAlignToStyle&&a==="align"&&typeof l=="string"&&Pp.has(t.tagName)?r=l:n[a]=l}}if(r){const o=n.style||(n.style={});o[e.stylePropertyNameCase==="css"?"text-align":"textAlign"]=r}return n}function Vp(e,t){const n={};for(const r of t.attributes)if(r.type==="mdxJsxExpressionAttribute")if(r.data&&r.data.estree&&e.evaluater){const o=r.data.estree.body[0];o.type;const a=o.expression;a.type;const l=a.properties[0];l.type,Object.assign(n,e.evaluater.evaluateExpression(l.argument))}else ln(e,t.position);else{const i=r.name;let o;if(r.value&&typeof r.value=="object")if(r.value.data&&r.value.data.estree&&e.evaluater){const l=r.value.data.estree.body[0];l.type,o=e.evaluater.evaluateExpression(l.expression)}else ln(e,t.position);else o=r.value===null?!0:r.value;n[i]=o}return n}function Ui(e,t){const n=[];let r=-1;const i=e.passKeys?new Map:Ap;for(;++r<t.children.length;){const o=t.children[r];let a;if(e.passKeys){const u=o.type==="element"?o.tagName:o.type==="mdxJsxFlowElement"||o.type==="mdxJsxTextElement"?o.name:void 0;if(u){const c=i.get(u)||0;a=u+"-"+c,i.set(u,c+1)}}const l=Ha(e,o,a);l!==void 0&&n.push(l)}return n}function Hp(e,t,n){const r=Gf(e.schema,t);if(!(n==null||typeof n=="number"&&Number.isNaN(n))){if(Array.isArray(n)&&(n=r.commaSeparated?zf(n):Jf(n)),r.property==="style"){let i=typeof n=="object"?n:Up(e,String(n));return e.stylePropertyNameCase==="css"&&(i=qp(i)),["style",i]}return[e.elementAttributeNameCase==="react"&&r.space?Zf[r.property]||r.property:r.attribute,n]}}function Up(e,t){try{return Cp(t,{reactCompat:!0})}catch(n){if(e.ignoreInvalidStyle)return{};const r=n,i=new Ce("Cannot parse `style` attribute",{ancestors:e.ancestors,cause:r,ruleId:"style",source:"hast-util-to-jsx-runtime"});throw i.file=e.filePath||void 0,i.url=Va+"#cannot-parse-style-attribute",i}}function qa(e,t,n){let r;if(!n)r={type:"Literal",value:t};else if(t.includes(".")){const i=t.split(".");let o=-1,a;for(;++o<i.length;){const l=Do(i[o])?{type:"Identifier",name:i[o]}:{type:"Literal",value:i[o]};a=a?{type:"MemberExpression",object:a,property:l,computed:!!(o&&l.type==="Literal"),optional:!1}:l}r=a}else r=Do(t)&&!/^[a-z]/.test(t)?{type:"Identifier",name:t}:{type:"Literal",value:t};if(r.type==="Literal"){const i=r.value;return Vi.call(e.components,i)?e.components[i]:i}if(e.evaluater)return e.evaluater.evaluateExpression(r);ln(e)}function ln(e,t){const n=new Ce("Cannot handle MDX estrees without `createEvaluater`",{ancestors:e.ancestors,place:t,ruleId:"mdx-estree",source:"hast-util-to-jsx-runtime"});throw n.file=e.filePath||void 0,n.url=Va+"#cannot-handle-mdx-estrees-without-createevaluater",n}function qp(e){const t={};let n;for(n in e)Vi.call(e,n)&&(t[Zp(n)]=e[n]);return t}function Zp(e){let t=e.replace(Ep,Kp);return t.slice(0,3)==="ms-"&&(t="-"+t),t}function Kp(e){return"-"+e.toLowerCase()}const Tr={action:["form"],cite:["blockquote","del","ins","q"],data:["object"],formAction:["button","input"],href:["a","area","base","link"],icon:["menuitem"],itemId:null,manifest:["html"],ping:["a","area"],poster:["video"],src:["audio","embed","iframe","img","input","script","source","track","video"]},Wp={};function Gp(e,t){const n=Wp,r=typeof n.includeImageAlt=="boolean"?n.includeImageAlt:!0,i=typeof n.includeHtml=="boolean"?n.includeHtml:!0;return Za(e,r,i)}
vendor: 13,398 bytes, line 8
8function Za(e,t,n){if(Yp(e)){if("value"in e)return e.type==="html"&&!n?"":e.value;if(t&&"alt"in e&&e.alt)return e.alt;if("children"in e)return Yo(e.children,t,n)}return Array.isArray(e)?Yo(e,t,n):""}function Yo(e,t,n){const r=[];let i=-1;for(;++i<e.length;)r[i]=Za(e[i],t,n);return r.join("")}function Yp(e){return!!(e&&typeof e=="object")}const Xo=document.createElement("i");function qi(e){const t="&"+e+";";Xo.innerHTML=t;const n=Xo.textContent;return n.charCodeAt(n.length-1)===59&&e!=="semi"||n===t?!1:n}function nt(e,t,n,r){const i=e.length;let o=0,a;if(t<0?t=-t>i?0:i+t:t=t>i?i:t,n=n>0?n:0,r.length<1e4)a=Array.from(r),a.unshift(t,n),e.splice(...a);else for(n&&e.splice(t,n);o<r.length;)a=r.slice(o,o+1e4),a.unshift(t,0),e.splice(...a),o+=1e4,t+=1e4}function qe(e,t){return e.length>0?(nt(e,e.length,0,t),e):t}const Qo={}.hasOwnProperty;function Xp(e){const t={};let n=-1;for(;++n<e.length;)Qp(t,e[n]);return t}function Qp(e,t){let n;for(n in t){const i=(Qo.call(e,n)?e[n]:void 0)||(e[n]={}),o=t[n];let a;if(o)for(a in o){Qo.call(i,a)||(i[a]=[]);const l=o[a];Jp(i[a],Array.isArray(l)?l:l?[l]:[])}}}function Jp(e,t){let n=-1;const r=[];for(;++n<t.length;)(t[n].add==="after"?e:r).push(t[n]);nt(e,0,0,r)}function Ka(e,t){const n=Number.parseInt(e,t);return n<9||n===11||n>13&&n<32||n>126&&n<160||n>55295&&n<57344||n>64975&&n<65008||(n&65535)===65535||(n&65535)===65534||n>1114111?"�":String.fromCodePoint(n)}function zt(e){return e.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}const et=yt(/[A-Za-z]/),Be=yt(/[\dA-Za-z]/),eh=yt(/[#-'*+\--9=?A-Z^-~]/);function Qr(e){return e!==null&&(e<32||e===127)}const Jr=yt(/\d/),th=yt(/[\dA-Fa-f]/),nh=yt(/[!-/:-@[-`{-~]/);function X(e){return e!==null&&e<-2}function Fe(e){return e!==null&&(e<0||e===32)}function le(e){return e===-2||e===-1||e===32}const rh=yt(new RegExp("\\p{P}|\\p{S}","u")),ih=yt(/\s/);function yt(e){return t;function t(n){return n!==null&&n>-1&&e.test(String.fromCharCode(n))}}function qt(e){const t=[];let n=-1,r=0,i=0;for(;++n<e.length;){const o=e.charCodeAt(n);let a="";if(o===37&&Be(e.charCodeAt(n+1))&&Be(e.charCodeAt(n+2)))i=2;else if(o<128)/[!#$&-;=?-Z_a-z~]/.test(String.fromCharCode(o))||(a=String.fromCharCode(o));else if(o>55295&&o<57344){const l=e.charCodeAt(n+1);o<56320&&l>56319&&l<57344?(a=String.fromCharCode(o,l),i=1):a="�"}else a=String.fromCharCode(o);a&&(t.push(e.slice(r,n),encodeURIComponent(a)),r=n+i+1,a=""),i&&(n+=i,i=0)}return t.join("")+e.slice(r)}function xe(e,t,n,r){const i=r?r-1:Number.POSITIVE_INFINITY;let o=0;return a;function a(u){return le(u)?(e.enter(n),l(u)):t(u)}function l(u){return le(u)&&o++<i?(e.consume(u),l):(e.exit(n),t(u))}}const oh={tokenize:sh};function sh(e){const t=e.attempt(this.parser.constructs.contentInitial,r,i);let n;return t;function r(l){if(l===null){e.consume(l);return}return e.enter("lineEnding"),e.consume(l),e.exit("lineEnding"),xe(e,t,"linePrefix")}function i(l){return e.enter("paragraph"),o(l)}function o(l){const u=e.enter("chunkText",{contentType:"text",previous:n});return n&&(n.next=u),n=u,a(l)}function a(l){if(l===null){e.exit("chunkText"),e.exit("paragraph"),e.consume(l);return}return X(l)?(e.consume(l),e.exit("chunkText"),o):(e.consume(l),a)}}const ah={tokenize:lh},Jo={tokenize:uh};function lh(e){const t=this,n=[];let r=0,i,o,a;return l;function l(j){if(r<n.length){const R=n[r];return t.containerState=R[1],e.attempt(R[0].continuation,u,c)(j)}return c(j)}function u(j){if(r++,t.containerState._closeFlow){t.containerState._closeFlow=void 0,i&&k();const R=t.events.length;let z=R,N;for(;z--;)if(t.events[z][0]==="exit"&&t.events[z][1].type==="chunkFlow"){N=t.events[z][1].end;break}v(r);let V=R;for(;V<t.events.length;)t.events[V][1].end={...N},V++;return nt(t.events,z+1,0,t.events.slice(R)),t.events.length=V,c(j)}return l(j)}function c(j){if(r===n.length){if(!i)return d(j);if(i.currentConstruct&&i.currentConstruct.concrete)return g(j);t.interrupt=!!(i.currentConstruct&&!i._gfmTableDynamicInterruptHack)}return t.containerState={},e.check(Jo,f,p)(j)}function f(j){return i&&k(),v(r),d(j)}function p(j){return t.parser.lazy[t.now().line]=r!==n.length,a=t.now().offset,g(j)}function d(j){return t.containerState={},e.attempt(Jo,h,g)(j)}function h(j){return r++,n.push([t.currentConstruct,t.containerState]),d(j)}function g(j){if(j===null){i&&k(),v(0),e.consume(j);return}return i=i||t.parser.flow(t.now()),e.enter("chunkFlow",{_tokenizer:i,contentType:"flow",previous:o}),x(j)}function x(j){if(j===null){C(e.exit("chunkFlow"),!0),v(0),e.consume(j);return}return X(j)?(e.consume(j),C(e.exit("chunkFlow")),r=0,t.interrupt=void 0,l):(e.consume(j),x)}function C(j,R){const z=t.sliceStream(j);if(R&&z.push(null),j.previous=o,o&&(o.next=j),o=j,i.defineSkip(j.start),i.write(z),t.parser.lazy[j.start.line]){let N=i.events.length;for(;N--;)if(i.events[N][1].start.offset<a&&(!i.events[N][1].end||i.events[N][1].end.offset>a))return;const V=t.events.length;let H=V,E,B;for(;H--;)if(t.events[H][0]==="exit"&&t.events[H][1].type==="chunkFlow"){if(E){B=t.events[H][1].end;break}E=!0}for(v(r),N=V;N<t.events.length;)t.events[N][1].end={...B},N++;nt(t.events,H+1,0,t.events.slice(V)),t.events.length=N}}function v(j){let R=n.length;for(;R-- >j;){const z=n[R];t.containerState=z[1],z[0].exit.call(t,e)}n.length=j}function k(){i.write([null]),o=void 0,i=void 0,t.containerState._closeFlow=void 0}}function uh(e,t,n){return xe(e,e.attempt(this.parser.constructs.document,t,n),"linePrefix",this.parser.constructs.disable.null.includes("codeIndented")?void 0:4)}function es(e){if(e===null||Fe(e)||ih(e))return 1;if(rh(e))return 2}function Zi(e,t,n){const r=[];let i=-1;for(;++i<e.length;){const o=e[i].resolveAll;o&&!r.includes(o)&&(t=o(t,n),r.push(o))}return t}const ei={name:"attention",resolveAll:ch,tokenize:dh};function ch(e,t){let n=-1,r,i,o,a,l,u,c,f;for(;++n<e.length;)if(e[n][0]==="enter"&&e[n][1].type==="attentionSequence"&&e[n][1]._close){for(r=n;r--;)if(e[r][0]==="exit"&&e[r][1].type==="attentionSequence"&&e[r][1]._open&&t.sliceSerialize(e[r][1]).charCodeAt(0)===t.sliceSerialize(e[n][1]).charCodeAt(0)){if((e[r][1]._close||e[n][1]._open)&&(e[n][1].end.offset-e[n][1].start.offset)%3&&!((e[r][1].end.offset-e[r][1].start.offset+e[n][1].end.offset-e[n][1].start.offset)%3))continue;u=e[r][1].end.offset-e[r][1].start.offset>1&&e[n][1].end.offset-e[n][1].start.offset>1?2:1;const p={...e[r][1].end},d={...e[n][1].start};ts(p,-u),ts(d,u),a={type:u>1?"strongSequence":"emphasisSequence",start:p,end:{...e[r][1].end}},l={type:u>1?"strongSequence":"emphasisSequence",start:{...e[n][1].start},end:d},o={type:u>1?"strongText":"emphasisText",start:{...e[r][1].end},end:{...e[n][1].start}},i={type:u>1?"strong":"emphasis",start:{...a.start},end:{...l.end}},e[r][1].end={...a.start},e[n][1].start={...l.end},c=[],e[r][1].end.offset-e[r][1].start.offset&&(c=qe(c,[["enter",e[r][1],t],["exit",e[r][1],t]])),c=qe(c,[["enter",i,t],["enter",a,t],["exit",a,t],["enter",o,t]]),c=qe(c,Zi(t.parser.constructs.insideSpan.null,e.slice(r+1,n),t)),c=qe(c,[["exit",o,t],["enter",l,t],["exit",l,t],["exit",i,t]]),e[n][1].end.offset-e[n][1].start.offset?(f=2,c=qe(c,[["enter",e[n][1],t],["exit",e[n][1],t]])):f=0,nt(e,r-1,n-r+3,c),n=r+c.length-f-2;break}}for(n=-1;++n<e.length;)e[n][1].type==="attentionSequence"&&(e[n][1].type="data");return e}function dh(e,t){const n=this.parser.constructs.attentionMarkers.null,r=this.previous,i=es(r);let o;return a;function a(u){return o=u,e.enter("attentionSequence"),l(u)}function l(u){if(u===o)return e.consume(u),l;const c=e.exit("attentionSequence"),f=es(u),p=!f||f===2&&i||n.includes(u),d=!i||i===2&&f||n.includes(r);return c._open=!!(o===42?p:p&&(i||!d)),c._close=!!(o===42?d:d&&(f||!p)),t(u)}}function ts(e,t){e.column+=t,e.offset+=t,e._bufferIndex+=t}const fh={name:"autolink",tokenize:ph};function ph(e,t,n){let r=0;return i;function i(h){return e.enter("autolink"),e.enter("autolinkMarker"),e.consume(h),e.exit("autolinkMarker"),e.enter("autolinkProtocol"),o}function o(h){return et(h)?(e.consume(h),a):h===64?n(h):c(h)}function a(h){return h===43||h===45||h===46||Be(h)?(r=1,l(h)):c(h)}function l(h){return h===58?(e.consume(h),r=0,u):(h===43||h===45||h===46||Be(h))&&r++<32?(e.consume(h),l):(r=0,c(h))}function u(h){return h===62?(e.exit("autolinkProtocol"),e.enter("autolinkMarker"),e.consume(h),e.exit("autolinkMarker"),e.exit("autolink"),t):h===null||h===32||h===60||Qr(h)?n(h):(e.consume(h),u)}function c(h){return h===64?(e.consume(h),f):eh(h)?(e.consume(h),c):n(h)}function f(h){return Be(h)?p(h):n(h)}function p(h){return h===46?(e.consume(h),r=0,f):h===62?(e.exit("autolinkProtocol").type="autolinkEmail",e.enter("autolinkMarker"),e.consume(h),e.exit("autolinkMarker"),e.exit("autolink"),t):d(h)}function d(h){if((h===45||Be(h))&&r++<63){const g=h===45?d:p;return e.consume(h),g}return n(h)}}const ur={partial:!0,tokenize:hh};function hh(e,t,n){return r;function r(o){return le(o)?xe(e,i,"linePrefix")(o):i(o)}function i(o){return o===null||X(o)?t(o):n(o)}}const Wa={continuation:{tokenize:gh},exit:xh,name:"blockQuote",tokenize:mh};function mh(e,t,n){const r=this;return i;function i(a){if(a===62){const l=r.containerState;return l.open||(e.enter("blockQuote",{_container:!0}),l.open=!0),e.enter("blockQuotePrefix"),e.enter("blockQuoteMarker"),e.consume(a),e.exit("blockQuoteMarker"),o}return n(a)}function o(a){return le(a)?(e.enter("blockQuotePrefixWhitespace"),e.consume(a),e.exit("blockQuotePrefixWhitespace"),e.exit("blockQuotePrefix"),t):(e.exit("blockQuotePrefix"),t(a))}}function gh(e,t,n){const r=this;return i;function i(a){return le(a)?xe(e,o,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(a):o(a)}function o(a){return e.attempt(Wa,t,n)(a)}}function xh(e){e.exit("blockQuote")}const Ga={name:"characterEscape",tokenize:bh};function bh(e,t,n){return r;function r(o){return e.enter("characterEscape"),e.enter("escapeMarker"),e.consume(o),e.exit("escapeMarker"),i}function i(o){return nh(o)?(e.enter("characterEscapeValue"),e.consume(o),e.exit("characterEscapeValue"),e.exit("characterEscape"),t):n(o)}}const Ya={name:"characterReference",tokenize:yh};function yh(e,t,n){const r=this;let i=0,o,a;return l;function l(p){return e.enter("characterReference"),e.enter("characterReferenceMarker"),e.consume(p),e.exit("characterReferenceMarker"),u}function u(p){return p===35?(e.enter("characterReferenceMarkerNumeric"),e.consume(p),e.exit("characterReferenceMarkerNumeric"),c):(e.enter("characterReferenceValue"),o=31,a=Be,f(p))}function c(p){return p===88||p===120?(e.enter("characterReferenceMarkerHexadecimal"),e.consume(p),e.exit("characterReferenceMarkerHexadecimal"),e.enter("characterReferenceValue"),o=6,a=th,f):(e.enter("characterReferenceValue"),o=7,a=Jr,f(p))}function f(p){if(p===59&&i){const d=e.exit("characterReferenceValue");return a===Be&&!qi(r.sliceSerialize(d))?n(p):(e.enter("characterReferenceMarker"),e.consume(p),e.exit("characterReferenceMarker"),e.exit("characterReference"),t)}return a(p)&&i++<o?(e.consume(p),f):n(p)}}const ns={partial:!0,tokenize:kh},rs={concrete:!0,name:"codeFenced",tokenize:wh};function wh(e,t,n){const r=this,i={partial:!0,tokenize:z};let o=0,a=0,l;return u;function u(N){return c(N)}function c(N){const V=r.events[r.events.length-1];return o=V&&V[1].type==="linePrefix"?V[2].sliceSerialize(V[1],!0).length:0,l=N,e.enter("codeFenced"),e.enter("codeFencedFence"),e.enter("codeFencedFenceSequence"),f(N)}function f(N){return N===l?(a++,e.consume(N),f):a<3?n(N):(e.exit("codeFencedFenceSequence"),le(N)?xe(e,p,"whitespace")(N):p(N))}function p(N){return N===null||X(N)?(e.exit("codeFencedFence"),r.interrupt?t(N):e.check(ns,x,R)(N)):(e.enter("codeFencedFenceInfo"),e.enter("chunkString",{contentType:"string"}),d(N))}function d(N){return N===null||X(N)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),p(N)):le(N)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),xe(e,h,"whitespace")(N)):N===96&&N===l?n(N):(e.consume(N),d)}function h(N){return N===null||X(N)?p(N):(e.enter("codeFencedFenceMeta"),e.enter("chunkString",{contentType:"string"}),g(N))}function g(N){return N===null||X(N)?(e.exit("chunkString"),e.exit("codeFencedFenceMeta"),p(N)):N===96&&N===l?n(N):(e.consume(N),g)}function x(N){return e.attempt(i,R,C)(N)}function C(N){return e.enter("lineEnding"),e.consume(N),e.exit("lineEnding"),v}function v(N){return o>0&&le(N)?xe(e,k,"linePrefix",o+1)(N):k(N)}function k(N){return N===null||X(N)?e.check(ns,x,R)(N):(e.enter("codeFlowValue"),j(N))}function j(N){return N===null||X(N)?(e.exit("codeFlowValue"),k(N)):(e.consume(N),j)}function R(N){return e.exit("codeFenced"),t(N)}function z(N,V,H){let E=0;return B;function B(Z){return N.enter("lineEnding"),N.consume(Z),N.exit("lineEnding"),A}function A(Z){return N.enter("codeFencedFence"),le(Z)?xe(N,P,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(Z):P(Z)}function P(Z){return Z===l?(N.enter("codeFencedFenceSequence"),D(Z)):H(Z)}function D(Z){return Z===l?(E++,N.consume(Z),D):E>=a?(N.exit("codeFencedFenceSequence"),le(Z)?xe(N,F,"whitespace")(Z):F(Z)):H(Z)}function F(Z){return Z===null||X(Z)?(N.exit("codeFencedFence"),V(Z)):H(Z)}}}function kh(e,t,n){const r=this;return i;function i(a){return a===null?n(a):(e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),o)}function o(a){return r.parser.lazy[r.now().line]?n(a):t(a)}}const Pr={name:"codeIndented",tokenize:jh},vh={partial:!0,tokenize:Nh};
vendor: 5,013 bytes, line 8
8function jh(e,t,n){const r=this;return i;function i(c){return e.enter("codeIndented"),xe(e,o,"linePrefix",5)(c)}function o(c){const f=r.events[r.events.length-1];return f&&f[1].type==="linePrefix"&&f[2].sliceSerialize(f[1],!0).length>=4?a(c):n(c)}function a(c){return c===null?u(c):X(c)?e.attempt(vh,a,u)(c):(e.enter("codeFlowValue"),l(c))}function l(c){return c===null||X(c)?(e.exit("codeFlowValue"),a(c)):(e.consume(c),l)}function u(c){return e.exit("codeIndented"),t(c)}}function Nh(e,t,n){const r=this;return i;function i(a){return r.parser.lazy[r.now().line]?n(a):X(a)?(e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),i):xe(e,o,"linePrefix",5)(a)}function o(a){const l=r.events[r.events.length-1];return l&&l[1].type==="linePrefix"&&l[2].sliceSerialize(l[1],!0).length>=4?t(a):X(a)?i(a):n(a)}}const Ih={name:"codeText",previous:Ch,resolve:Sh,tokenize:Ah};function Sh(e){let t=e.length-4,n=3,r,i;if((e[n][1].type==="lineEnding"||e[n][1].type==="space")&&(e[t][1].type==="lineEnding"||e[t][1].type==="space")){for(r=n;++r<t;)if(e[r][1].type==="codeTextData"){e[n][1].type="codeTextPadding",e[t][1].type="codeTextPadding",n+=2,t-=2;break}}for(r=n-1,t++;++r<=t;)i===void 0?r!==t&&e[r][1].type!=="lineEnding"&&(i=r):(r===t||e[r][1].type==="lineEnding")&&(e[i][1].type="codeTextData",r!==i+2&&(e[i][1].end=e[r-1][1].end,e.splice(i+2,r-i-2),t-=r-i-2,r=i+2),i=void 0);return e}function Ch(e){return e!==96||this.events[this.events.length-1][1].type==="characterEscape"}function Ah(e,t,n){let r=0,i,o;return a;function a(p){return e.enter("codeText"),e.enter("codeTextSequence"),l(p)}function l(p){return p===96?(e.consume(p),r++,l):(e.exit("codeTextSequence"),u(p))}function u(p){return p===null?n(p):p===32?(e.enter("space"),e.consume(p),e.exit("space"),u):p===96?(o=e.enter("codeTextSequence"),i=0,f(p)):X(p)?(e.enter("lineEnding"),e.consume(p),e.exit("lineEnding"),u):(e.enter("codeTextData"),c(p))}function c(p){return p===null||p===32||p===96||X(p)?(e.exit("codeTextData"),u(p)):(e.consume(p),c)}function f(p){return p===96?(e.consume(p),i++,f):i===r?(e.exit("codeTextSequence"),e.exit("codeText"),t(p)):(o.type="codeTextData",c(p))}}class Eh{constructor(t){this.left=t?[...t]:[],this.right=[]}get(t){if(t<0||t>=this.left.length+this.right.length)throw new RangeError("Cannot access index `"+t+"` in a splice buffer of size `"+(this.left.length+this.right.length)+"`");return t<this.left.length?this.left[t]:this.right[this.right.length-t+this.left.length-1]}get length(){return this.left.length+this.right.length}shift(){return this.setCursor(0),this.right.pop()}slice(t,n){const r=n??Number.POSITIVE_INFINITY;return r<this.left.length?this.left.slice(t,r):t>this.left.length?this.right.slice(this.right.length-r+this.left.length,this.right.length-t+this.left.length).reverse():this.left.slice(t).concat(this.right.slice(this.right.length-r+this.left.length).reverse())}splice(t,n,r){const i=n||0;this.setCursor(Math.trunc(t));const o=this.right.splice(this.right.length-i,Number.POSITIVE_INFINITY);return r&&Gt(this.left,r),o.reverse()}pop(){return this.setCursor(Number.POSITIVE_INFINITY),this.left.pop()}push(t){this.setCursor(Number.POSITIVE_INFINITY),this.left.push(t)}pushMany(t){this.setCursor(Number.POSITIVE_INFINITY),Gt(this.left,t)}unshift(t){this.setCursor(0),this.right.push(t)}unshiftMany(t){this.setCursor(0),Gt(this.right,t.reverse())}setCursor(t){if(!(t===this.left.length||t>this.left.length&&this.right.length===0||t<0&&this.left.length===0))if(t<this.left.length){const n=this.left.splice(t,Number.POSITIVE_INFINITY);Gt(this.right,n.reverse())}else{const n=this.right.splice(this.left.length+this.right.length-t,Number.POSITIVE_INFINITY);Gt(this.left,n.reverse())}}}function Gt(e,t){let n=0;if(t.length<1e4)e.push(...t);else for(;n<t.length;)e.push(...t.slice(n,n+1e4)),n+=1e4}function Xa(e){const t={};let n=-1,r,i,o,a,l,u,c;const f=new Eh(e);for(;++n<f.length;){for(;n in t;)n=t[n];if(r=f.get(n),n&&r[1].type==="chunkFlow"&&f.get(n-1)[1].type==="listItemPrefix"&&(u=r[1]._tokenizer.events,o=0,o<u.length&&u[o][1].type==="lineEndingBlank"&&(o+=2),o<u.length&&u[o][1].type==="content"))for(;++o<u.length&&u[o][1].type!=="content";)u[o][1].type==="chunkText"&&(u[o][1]._isInFirstContentOfListItem=!0,o++);if(r[0]==="enter")r[1].contentType&&(Object.assign(t,Th(f,n)),n=t[n],c=!0);else if(r[1]._container){for(o=n,i=void 0;o--;)if(a=f.get(o),a[1].type==="lineEnding"||a[1].type==="lineEndingBlank")a[0]==="enter"&&(i&&(f.get(i)[1].type="lineEndingBlank"),a[1].type="lineEnding",i=o);else if(!(a[1].type==="linePrefix"||a[1].type==="listItemIndent"))break;i&&(r[1].end={...f.get(i)[1].start},l=f.slice(i,n),l.unshift(r),f.splice(i,n-i+1,l))}}return nt(e,0,Number.POSITIVE_INFINITY,f.slice(0)),!c}function Th(e,t){const n=e.get(t)[1],r=e.get(t)[2];let i=t-1;const o=[];let a=n._tokenizer;a||(a=r.parser[n.contentType](n.start),n._contentTypeTextTrailing&&(a._contentTypeTextTrailing=!0));const l=a.events,u=[],c={};let f,p,d=-1,h=n,g=0,x=0;const C=[x];for(;h;){for(;e.get(++i)[1]!==h;);
vendor: 22,811 bytes, line 8
8o.push(i),h._tokenizer||(f=r.sliceStream(h),h.next||f.push(null),p&&a.defineSkip(h.start),h._isInFirstContentOfListItem&&(a._gfmTasklistFirstContentOfListItem=!0),a.write(f),h._isInFirstContentOfListItem&&(a._gfmTasklistFirstContentOfListItem=void 0)),p=h,h=h.next}for(h=n;++d<l.length;)l[d][0]==="exit"&&l[d-1][0]==="enter"&&l[d][1].type===l[d-1][1].type&&l[d][1].start.line!==l[d][1].end.line&&(x=d+1,C.push(x),h._tokenizer=void 0,h.previous=void 0,h=h.next);for(a.events=[],h?(h._tokenizer=void 0,h.previous=void 0):C.pop(),d=C.length;d--;){const v=l.slice(C[d],C[d+1]),k=o.pop();u.push([k,k+v.length-1]),e.splice(k,2,v)}for(u.reverse(),d=-1;++d<u.length;)c[g+u[d][0]]=g+u[d][1],g+=u[d][1]-u[d][0]-1;return c}const Ph={resolve:Rh,tokenize:Lh},Mh={partial:!0,tokenize:Oh};function Rh(e){return Xa(e),e}function Lh(e,t){let n;return r;function r(l){return e.enter("content"),n=e.enter("chunkContent",{contentType:"content"}),i(l)}function i(l){return l===null?o(l):X(l)?e.check(Mh,a,o)(l):(e.consume(l),i)}function o(l){return e.exit("chunkContent"),e.exit("content"),t(l)}function a(l){return e.consume(l),e.exit("chunkContent"),n.next=e.enter("chunkContent",{contentType:"content",previous:n}),n=n.next,i}}function Oh(e,t,n){const r=this;return i;function i(a){return e.exit("chunkContent"),e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),xe(e,o,"linePrefix")}function o(a){if(a===null||X(a))return n(a);const l=r.events[r.events.length-1];return!r.parser.constructs.disable.null.includes("codeIndented")&&l&&l[1].type==="linePrefix"&&l[2].sliceSerialize(l[1],!0).length>=4?t(a):e.interrupt(r.parser.constructs.flow,n,t)(a)}}function Qa(e,t,n,r,i,o,a,l,u){const c=u||Number.POSITIVE_INFINITY;let f=0;return p;function p(v){return v===60?(e.enter(r),e.enter(i),e.enter(o),e.consume(v),e.exit(o),d):v===null||v===32||v===41||Qr(v)?n(v):(e.enter(r),e.enter(a),e.enter(l),e.enter("chunkString",{contentType:"string"}),x(v))}function d(v){return v===62?(e.enter(o),e.consume(v),e.exit(o),e.exit(i),e.exit(r),t):(e.enter(l),e.enter("chunkString",{contentType:"string"}),h(v))}function h(v){return v===62?(e.exit("chunkString"),e.exit(l),d(v)):v===null||v===60||X(v)?n(v):(e.consume(v),v===92?g:h)}function g(v){return v===60||v===62||v===92?(e.consume(v),h):h(v)}function x(v){return!f&&(v===null||v===41||Fe(v))?(e.exit("chunkString"),e.exit(l),e.exit(a),e.exit(r),t(v)):f<c&&v===40?(e.consume(v),f++,x):v===41?(e.consume(v),f--,x):v===null||v===32||v===40||Qr(v)?n(v):(e.consume(v),v===92?C:x)}function C(v){return v===40||v===41||v===92?(e.consume(v),x):x(v)}}function Ja(e,t,n,r,i,o){const a=this;let l=0,u;return c;function c(h){return e.enter(r),e.enter(i),e.consume(h),e.exit(i),e.enter(o),f}function f(h){return l>999||h===null||h===91||h===93&&!u||h===94&&!l&&"_hiddenFootnoteSupport"in a.parser.constructs?n(h):h===93?(e.exit(o),e.enter(i),e.consume(h),e.exit(i),e.exit(r),t):X(h)?(e.enter("lineEnding"),e.consume(h),e.exit("lineEnding"),f):(e.enter("chunkString",{contentType:"string"}),p(h))}function p(h){return h===null||h===91||h===93||X(h)||l++>999?(e.exit("chunkString"),f(h)):(e.consume(h),u||(u=!le(h)),h===92?d:p)}function d(h){return h===91||h===92||h===93?(e.consume(h),l++,p):p(h)}}function el(e,t,n,r,i,o){let a;return l;function l(d){return d===34||d===39||d===40?(e.enter(r),e.enter(i),e.consume(d),e.exit(i),a=d===40?41:d,u):n(d)}function u(d){return d===a?(e.enter(i),e.consume(d),e.exit(i),e.exit(r),t):(e.enter(o),c(d))}function c(d){return d===a?(e.exit(o),u(a)):d===null?n(d):X(d)?(e.enter("lineEnding"),e.consume(d),e.exit("lineEnding"),xe(e,c,"linePrefix")):(e.enter("chunkString",{contentType:"string"}),f(d))}function f(d){return d===a||d===null||X(d)?(e.exit("chunkString"),c(d)):(e.consume(d),d===92?p:f)}function p(d){return d===a||d===92?(e.consume(d),f):f(d)}}function Jt(e,t){let n;return r;function r(i){return X(i)?(e.enter("lineEnding"),e.consume(i),e.exit("lineEnding"),n=!0,r):le(i)?xe(e,r,n?"linePrefix":"lineSuffix")(i):t(i)}}const Fh={name:"definition",tokenize:_h},zh={partial:!0,tokenize:Dh};function _h(e,t,n){const r=this;let i;return o;function o(h){return e.enter("definition"),a(h)}function a(h){return Ja.call(r,e,l,n,"definitionLabel","definitionLabelMarker","definitionLabelString")(h)}function l(h){return i=zt(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)),h===58?(e.enter("definitionMarker"),e.consume(h),e.exit("definitionMarker"),u):n(h)}function u(h){return Fe(h)?Jt(e,c)(h):c(h)}function c(h){return Qa(e,f,n,"definitionDestination","definitionDestinationLiteral","definitionDestinationLiteralMarker","definitionDestinationRaw","definitionDestinationString")(h)}function f(h){return e.attempt(zh,p,p)(h)}function p(h){return le(h)?xe(e,d,"whitespace")(h):d(h)}function d(h){return h===null||X(h)?(e.exit("definition"),r.parser.defined.push(i),t(h)):n(h)}}function Dh(e,t,n){return r;function r(l){return Fe(l)?Jt(e,i)(l):n(l)}function i(l){return el(e,o,n,"definitionTitle","definitionTitleMarker","definitionTitleString")(l)}function o(l){return le(l)?xe(e,a,"whitespace")(l):a(l)}function a(l){return l===null||X(l)?t(l):n(l)}}const $h={name:"hardBreakEscape",tokenize:Bh};function Bh(e,t,n){return r;function r(o){return e.enter("hardBreakEscape"),e.consume(o),i}function i(o){return X(o)?(e.exit("hardBreakEscape"),t(o)):n(o)}}const Vh={name:"headingAtx",resolve:Hh,tokenize:Uh};function Hh(e,t){let n=e.length-2,r=3,i,o;return e[r][1].type==="whitespace"&&(r+=2),n-2>r&&e[n][1].type==="whitespace"&&(n-=2),e[n][1].type==="atxHeadingSequence"&&(r===n-1||n-4>r&&e[n-2][1].type==="whitespace")&&(n-=r+1===n?2:4),n>r&&(i={type:"atxHeadingText",start:e[r][1].start,end:e[n][1].end},o={type:"chunkText",start:e[r][1].start,end:e[n][1].end,contentType:"text"},nt(e,r,n-r+1,[["enter",i,t],["enter",o,t],["exit",o,t],["exit",i,t]])),e}function Uh(e,t,n){let r=0;return i;function i(f){return e.enter("atxHeading"),o(f)}function o(f){return e.enter("atxHeadingSequence"),a(f)}function a(f){return f===35&&r++<6?(e.consume(f),a):f===null||Fe(f)?(e.exit("atxHeadingSequence"),l(f)):n(f)}function l(f){return f===35?(e.enter("atxHeadingSequence"),u(f)):f===null||X(f)?(e.exit("atxHeading"),t(f)):le(f)?xe(e,l,"whitespace")(f):(e.enter("atxHeadingText"),c(f))}function u(f){return f===35?(e.consume(f),u):(e.exit("atxHeadingSequence"),l(f))}function c(f){return f===null||f===35||Fe(f)?(e.exit("atxHeadingText"),l(f)):(e.consume(f),c)}}const qh=["address","article","aside","base","basefont","blockquote","body","caption","center","col","colgroup","dd","details","dialog","dir","div","dl","dt","fieldset","figcaption","figure","footer","form","frame","frameset","h1","h2","h3","h4","h5","h6","head","header","hr","html","iframe","legend","li","link","main","menu","menuitem","nav","noframes","ol","optgroup","option","p","param","search","section","summary","table","tbody","td","tfoot","th","thead","title","tr","track","ul"],is=["pre","script","style","textarea"],Zh={concrete:!0,name:"htmlFlow",resolveTo:Gh,tokenize:Yh},Kh={partial:!0,tokenize:Qh},Wh={partial:!0,tokenize:Xh};function Gh(e){let t=e.length;for(;t--&&!(e[t][0]==="enter"&&e[t][1].type==="htmlFlow"););return t>1&&e[t-2][1].type==="linePrefix"&&(e[t][1].start=e[t-2][1].start,e[t+1][1].start=e[t-2][1].start,e.splice(t-2,2)),e}function Yh(e,t,n){const r=this;let i,o,a,l,u;return c;function c(y){return f(y)}function f(y){return e.enter("htmlFlow"),e.enter("htmlFlowData"),e.consume(y),p}function p(y){return y===33?(e.consume(y),d):y===47?(e.consume(y),o=!0,x):y===63?(e.consume(y),i=3,r.interrupt?t:b):et(y)?(e.consume(y),a=String.fromCharCode(y),C):n(y)}function d(y){return y===45?(e.consume(y),i=2,h):y===91?(e.consume(y),i=5,l=0,g):et(y)?(e.consume(y),i=4,r.interrupt?t:b):n(y)}function h(y){return y===45?(e.consume(y),r.interrupt?t:b):n(y)}function g(y){const ge="CDATA[";return y===ge.charCodeAt(l++)?(e.consume(y),l===ge.length?r.interrupt?t:P:g):n(y)}function x(y){return et(y)?(e.consume(y),a=String.fromCharCode(y),C):n(y)}function C(y){if(y===null||y===47||y===62||Fe(y)){const ge=y===47,Ae=a.toLowerCase();return!ge&&!o&&is.includes(Ae)?(i=1,r.interrupt?t(y):P(y)):qh.includes(a.toLowerCase())?(i=6,ge?(e.consume(y),v):r.interrupt?t(y):P(y)):(i=7,r.interrupt&&!r.parser.lazy[r.now().line]?n(y):o?k(y):j(y))}return y===45||Be(y)?(e.consume(y),a+=String.fromCharCode(y),C):n(y)}function v(y){return y===62?(e.consume(y),r.interrupt?t:P):n(y)}function k(y){return le(y)?(e.consume(y),k):B(y)}function j(y){return y===47?(e.consume(y),B):y===58||y===95||et(y)?(e.consume(y),R):le(y)?(e.consume(y),j):B(y)}function R(y){return y===45||y===46||y===58||y===95||Be(y)?(e.consume(y),R):z(y)}function z(y){return y===61?(e.consume(y),N):le(y)?(e.consume(y),z):j(y)}function N(y){return y===null||y===60||y===61||y===62||y===96?n(y):y===34||y===39?(e.consume(y),u=y,V):le(y)?(e.consume(y),N):H(y)}function V(y){return y===u?(e.consume(y),u=null,E):y===null||X(y)?n(y):(e.consume(y),V)}function H(y){return y===null||y===34||y===39||y===47||y===60||y===61||y===62||y===96||Fe(y)?z(y):(e.consume(y),H)}function E(y){return y===47||y===62||le(y)?j(y):n(y)}function B(y){return y===62?(e.consume(y),A):n(y)}function A(y){return y===null||X(y)?P(y):le(y)?(e.consume(y),A):n(y)}function P(y){return y===45&&i===2?(e.consume(y),K):y===60&&i===1?(e.consume(y),ee):y===62&&i===4?(e.consume(y),Ne):y===63&&i===3?(e.consume(y),b):y===93&&i===5?(e.consume(y),ue):X(y)&&(i===6||i===7)?(e.exit("htmlFlowData"),e.check(Kh,we,D)(y)):y===null||X(y)?(e.exit("htmlFlowData"),D(y)):(e.consume(y),P)}function D(y){return e.check(Wh,F,we)(y)}function F(y){return e.enter("lineEnding"),e.consume(y),e.exit("lineEnding"),Z}function Z(y){return y===null||X(y)?D(y):(e.enter("htmlFlowData"),P(y))}function K(y){return y===45?(e.consume(y),b):P(y)}function ee(y){return y===47?(e.consume(y),a="",ne):P(y)}function ne(y){if(y===62){const ge=a.toLowerCase();return is.includes(ge)?(e.consume(y),Ne):P(y)}return et(y)&&a.length<8?(e.consume(y),a+=String.fromCharCode(y),ne):P(y)}function ue(y){return y===93?(e.consume(y),b):P(y)}function b(y){return y===62?(e.consume(y),Ne):y===45&&i===2?(e.consume(y),b):P(y)}function Ne(y){return y===null||X(y)?(e.exit("htmlFlowData"),we(y)):(e.consume(y),Ne)}function we(y){return e.exit("htmlFlow"),t(y)}}function Xh(e,t,n){const r=this;return i;function i(a){return X(a)?(e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),o):n(a)}function o(a){return r.parser.lazy[r.now().line]?n(a):t(a)}}function Qh(e,t,n){return r;function r(i){return e.enter("lineEnding"),e.consume(i),e.exit("lineEnding"),e.attempt(ur,t,n)}}const Jh={name:"htmlText",tokenize:em};function em(e,t,n){const r=this;let i,o,a;return l;function l(b){return e.enter("htmlText"),e.enter("htmlTextData"),e.consume(b),u}function u(b){return b===33?(e.consume(b),c):b===47?(e.consume(b),z):b===63?(e.consume(b),j):et(b)?(e.consume(b),H):n(b)}function c(b){return b===45?(e.consume(b),f):b===91?(e.consume(b),o=0,g):et(b)?(e.consume(b),k):n(b)}function f(b){return b===45?(e.consume(b),h):n(b)}function p(b){return b===null?n(b):b===45?(e.consume(b),d):X(b)?(a=p,ee(b)):(e.consume(b),p)}function d(b){return b===45?(e.consume(b),h):p(b)}function h(b){return b===62?K(b):b===45?d(b):p(b)}function g(b){const Ne="CDATA[";return b===Ne.charCodeAt(o++)?(e.consume(b),o===Ne.length?x:g):n(b)}function x(b){return b===null?n(b):b===93?(e.consume(b),C):X(b)?(a=x,ee(b)):(e.consume(b),x)}function C(b){return b===93?(e.consume(b),v):x(b)}function v(b){return b===62?K(b):b===93?(e.consume(b),v):x(b)}function k(b){return b===null||b===62?K(b):X(b)?(a=k,ee(b)):(e.consume(b),k)}function j(b){return b===null?n(b):b===63?(e.consume(b),R):X(b)?(a=j,ee(b)):(e.consume(b),j)}function R(b){return b===62?K(b):j(b)}function z(b){return et(b)?(e.consume(b),N):n(b)}function N(b){return b===45||Be(b)?(e.consume(b),N):V(b)}function V(b){return X(b)?(a=V,ee(b)):le(b)?(e.consume(b),V):K(b)}function H(b){return b===45||Be(b)?(e.consume(b),H):b===47||b===62||Fe(b)?E(b):n(b)}function E(b){return b===47?(e.consume(b),K):b===58||b===95||et(b)?(e.consume(b),B):X(b)?(a=E,ee(b)):le(b)?(e.consume(b),E):K(b)}function B(b){return b===45||b===46||b===58||b===95||Be(b)?(e.consume(b),B):A(b)}function A(b){return b===61?(e.consume(b),P):X(b)?(a=A,ee(b)):le(b)?(e.consume(b),A):E(b)}function P(b){return b===null||b===60||b===61||b===62||b===96?n(b):b===34||b===39?(e.consume(b),i=b,D):X(b)?(a=P,ee(b)):le(b)?(e.consume(b),P):(e.consume(b),F)}function D(b){return b===i?(e.consume(b),i=void 0,Z):b===null?n(b):X(b)?(a=D,ee(b)):(e.consume(b),D)}function F(b){return b===null||b===34||b===39||b===60||b===61||b===96?n(b):b===47||b===62||Fe(b)?E(b):(e.consume(b),F)}function Z(b){return b===47||b===62||Fe(b)?E(b):n(b)}function K(b){return b===62?(e.consume(b),e.exit("htmlTextData"),e.exit("htmlText"),t):n(b)}function ee(b){return e.exit("htmlTextData"),e.enter("lineEnding"),e.consume(b),e.exit("lineEnding"),ne}function ne(b){return le(b)?xe(e,ue,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(b):ue(b)}function ue(b){return e.enter("htmlTextData"),a(b)}}const Ki={name:"labelEnd",resolveAll:im,resolveTo:om,tokenize:sm},tm={tokenize:am},nm={tokenize:lm},rm={tokenize:um};function im(e){let t=-1;const n=[];for(;++t<e.length;){const r=e[t][1];if(n.push(e[t]),r.type==="labelImage"||r.type==="labelLink"||r.type==="labelEnd"){const i=r.type==="labelImage"?4:2;r.type="data",t+=i}}return e.length!==n.length&&nt(e,0,e.length,n),e}function om(e,t){let n=e.length,r=0,i,o,a,l;for(;n--;)if(i=e[n][1],o){if(i.type==="link"||i.type==="labelLink"&&i._inactive)break;e[n][0]==="enter"&&i.type==="labelLink"&&(i._inactive=!0)}else if(a){if(e[n][0]==="enter"&&(i.type==="labelImage"||i.type==="labelLink")&&!i._balanced&&(o=n,i.type!=="labelLink")){r=2;break}}else i.type==="labelEnd"&&(a=n);const u={type:e[o][1].type==="labelLink"?"link":"image",start:{...e[o][1].start},end:{...e[e.length-1][1].end}},c={type:"label",start:{...e[o][1].start},end:{...e[a][1].end}},f={type:"labelText",start:{...e[o+r+2][1].end},end:{...e[a-2][1].start}};return l=[["enter",u,t],["enter",c,t]],l=qe(l,e.slice(o+1,o+r+3)),l=qe(l,[["enter",f,t]]),l=qe(l,Zi(t.parser.constructs.insideSpan.null,e.slice(o+r+4,a-3),t)),l=qe(l,[["exit",f,t],e[a-2],e[a-1],["exit",c,t]]),l=qe(l,e.slice(a+1)),l=qe(l,[["exit",u,t]]),nt(e,o,e.length,l),e}function sm(e,t,n){const r=this;let i=r.events.length,o,a;for(;i--;)if((r.events[i][1].type==="labelImage"||r.events[i][1].type==="labelLink")&&!r.events[i][1]._balanced){o=r.events[i][1];break}return l;function l(d){return o?o._inactive?p(d):(a=r.parser.defined.includes(zt(r.sliceSerialize({start:o.end,end:r.now()}))),e.enter("labelEnd"),e.enter("labelMarker"),e.consume(d),e.exit("labelMarker"),e.exit("labelEnd"),u):n(d)}function u(d){return d===40?e.attempt(tm,f,a?f:p)(d):d===91?e.attempt(nm,f,a?c:p)(d):a?f(d):p(d)}function c(d){return e.attempt(rm,f,p)(d)}function f(d){return t(d)}function p(d){return o._balanced=!0,n(d)}}function am(e,t,n){return r;function r(p){return e.enter("resource"),e.enter("resourceMarker"),e.consume(p),e.exit("resourceMarker"),i}function i(p){return Fe(p)?Jt(e,o)(p):o(p)}function o(p){return p===41?f(p):Qa(e,a,l,"resourceDestination","resourceDestinationLiteral","resourceDestinationLiteralMarker","resourceDestinationRaw","resourceDestinationString",32)(p)}function a(p){return Fe(p)?Jt(e,u)(p):f(p)}function l(p){return n(p)}function u(p){return p===34||p===39||p===40?el(e,c,n,"resourceTitle","resourceTitleMarker","resourceTitleString")(p):f(p)}function c(p){return Fe(p)?Jt(e,f)(p):f(p)}function f(p){return p===41?(e.enter("resourceMarker"),e.consume(p),e.exit("resourceMarker"),e.exit("resource"),t):n(p)}}function lm(e,t,n){const r=this;return i;function i(l){return Ja.call(r,e,o,a,"reference","referenceMarker","referenceString")(l)}function o(l){return r.parser.defined.includes(zt(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)))?t(l):n(l)}function a(l){return n(l)}}function um(e,t,n){return r;function r(o){return e.enter("reference"),e.enter("referenceMarker"),e.consume(o),e.exit("referenceMarker"),i}function i(o){return o===93?(e.enter("referenceMarker"),e.consume(o),e.exit("referenceMarker"),e.exit("reference"),t):n(o)}}const cm={name:"labelStartImage",resolveAll:Ki.resolveAll,tokenize:dm};function dm(e,t,n){const r=this;return i;function i(l){return e.enter("labelImage"),e.enter("labelImageMarker"),e.consume(l),e.exit("labelImageMarker"),o}function o(l){return l===91?(e.enter("labelMarker"),e.consume(l),e.exit("labelMarker"),e.exit("labelImage"),a):n(l)}function a(l){return l===94&&"_hiddenFootnoteSupport"in r.parser.constructs?n(l):t(l)}}const fm={name:"labelStartLink",resolveAll:Ki.resolveAll,tokenize:pm};function pm(e,t,n){const r=this;return i;function i(a){return e.enter("labelLink"),e.enter("labelMarker"),e.consume(a),e.exit("labelMarker"),e.exit("labelLink"),o}function o(a){return a===94&&"_hiddenFootnoteSupport"in r.parser.constructs?n(a):t(a)}}const Mr={name:"lineEnding",tokenize:hm};function hm(e,t){return n;function n(r){return e.enter("lineEnding"),e.consume(r),e.exit("lineEnding"),xe(e,t,"linePrefix")}}const $n={name:"thematicBreak",tokenize:mm};function mm(e,t,n){let r=0,i;return o;function o(c){return e.enter("thematicBreak"),a(c)}function a(c){return i=c,l(c)}function l(c){return c===i?(e.enter("thematicBreakSequence"),u(c)):r>=3&&(c===null||X(c))?(e.exit("thematicBreak"),t(c)):n(c)}function u(c){return c===i?(e.consume(c),r++,u):(e.exit("thematicBreakSequence"),le(c)?xe(e,l,"whitespace")(c):l(c))}}const Oe={continuation:{tokenize:ym},exit:km,name:"list",tokenize:bm},gm={partial:!0,tokenize:vm},xm={partial:!0,tokenize:wm};function bm(e,t,n){const r=this,i=r.events[r.events.length-1];let o=i&&i[1].type==="linePrefix"?i[2].sliceSerialize(i[1],!0).length:0,a=0;return l;function l(h){const g=r.containerState.type||(h===42||h===43||h===45?"listUnordered":"listOrdered");if(g==="listUnordered"?!r.containerState.marker||h===r.containerState.marker:Jr(h)){if(r.containerState.type||(r.containerState.type=g,e.enter(g,{_container:!0})),g==="listUnordered")return e.enter("listItemPrefix"),h===42||h===45?e.check($n,n,c)(h):c(h);if(!r.interrupt||h===49)return e.enter("listItemPrefix"),e.enter("listItemValue"),u(h)}return n(h)}function u(h){return Jr(h)&&++a<10?(e.consume(h),u):(!r.interrupt||a<2)&&(r.containerState.marker?h===r.containerState.marker:h===41||h===46)?(e.exit("listItemValue"),c(h)):n(h)}function c(h){return e.enter("listItemMarker"),e.consume(h),e.exit("listItemMarker"),r.containerState.marker=r.containerState.marker||h,e.check(ur,r.interrupt?n:f,e.attempt(gm,d,p))}function f(h){return r.containerState.initialBlankLine=!0,o++,d(h)}function p(h){return le(h)?(e.enter("listItemPrefixWhitespace"),e.consume(h),e.exit("listItemPrefixWhitespace"),d):n(h)}function d(h){return r.containerState.size=o+r.sliceSerialize(e.exit("listItemPrefix"),!0).length,t(h)}}function ym(e,t,n){const r=this;return r.containerState._closeFlow=void 0,e.check(ur,i,o);function i(l){return r.containerState.furtherBlankLines=r.containerState.furtherBlankLines||r.containerState.initialBlankLine,xe(e,t,"listItemIndent",r.containerState.size+1)(l)}function o(l){return r.containerState.furtherBlankLines||!le(l)?(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,a(l)):(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,e.attempt(xm,t,a)(l))}function a(l){return r.containerState._closeFlow=!0,r.interrupt=void 0,xe(e,e.attempt(Oe,t,n),"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(l)}}function wm(e,t,n){const r=this;return xe(e,i,"listItemIndent",r.containerState.size+1);function i(o){const a=r.events[r.events.length-1];return a&&a[1].type==="listItemIndent"&&a[2].sliceSerialize(a[1],!0).length===r.containerState.size?t(o):n(o)}}function km(e){e.exit(this.containerState.type)}function vm(e,t,n){const r=this;return xe(e,i,"listItemPrefixWhitespace",r.parser.constructs.disable.null.includes("codeIndented")?void 0:5);function i(o){const a=r.events[r.events.length-1];return!le(o)&&a&&a[1].type==="listItemPrefixWhitespace"?t(o):n(o)}}const os={name:"setextUnderline",resolveTo:jm,tokenize:Nm};function jm(e,t){let n=e.length,r,i,o;for(;n--;)if(e[n][0]==="enter"){if(e[n][1].type==="content"){r=n;break}e[n][1].type==="paragraph"&&(i=n)}else e[n][1].type==="content"&&e.splice(n,1),!o&&e[n][1].type==="definition"&&(o=n);const a={type:"setextHeading",start:{...e[r][1].start},end:{...e[e.length-1][1].end}};return e[i][1].type="setextHeadingText",o?(e.splice(i,0,["enter",a,t]),e.splice(o+1,0,["exit",e[r][1],t]),e[r][1].end={...e[o][1].end}):e[r][1]=a,e.push(["exit",a,t]),e}function Nm(e,t,n){const r=this;let i;return o;function o(c){let f=r.events.length,p;for(;f--;)if(r.events[f][1].type!=="lineEnding"&&r.events[f][1].type!=="linePrefix"&&r.events[f][1].type!=="content"){p=r.events[f][1].type==="paragraph";break}return!r.parser.lazy[r.now().line]&&(r.interrupt||p)?(e.enter("setextHeadingLine"),i=c,a(c)):n(c)}function a(c){return e.enter("setextHeadingLineSequence"),l(c)}function l(c){return c===i?(e.consume(c),l):(e.exit("setextHeadingLineSequence"),le(c)?xe(e,u,"lineSuffix")(c):u(c))}function u(c){return c===null||X(c)?(e.exit("setextHeadingLine"),t(c)):n(c)}}const Im={tokenize:Sm};function Sm(e){const t=this,n=e.attempt(ur,r,e.attempt(this.parser.constructs.flowInitial,i,xe(e,e.attempt(this.parser.constructs.flow,i,e.attempt(Ph,i)),"linePrefix")));return n;function r(o){if(o===null){e.consume(o);return}return e.enter("lineEndingBlank"),e.consume(o),e.exit("lineEndingBlank"),t.currentConstruct=void 0,n}function i(o){if(o===null){e.consume(o);return}return e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),t.currentConstruct=void 0,n}}const Cm={resolveAll:nl()},Am=tl("string"),Em=tl("text");function tl(e){return{resolveAll:nl(e==="text"?Tm:void 0),tokenize:t};function t(n){const r=this,i=this.parser.constructs[e],o=n.attempt(i,a,l);return a;function a(f){return c(f)?o(f):l(f)}function l(f){if(f===null){n.consume(f);return}return n.enter("data"),n.consume(f),u}function u(f){return c(f)?(n.exit("data"),o(f)):(n.consume(f),u)}function c(f){if(f===null)return!0;const p=i[f];let d=-1;if(p)for(;++d<p.length;){const h=p[d];if(!h.previous||h.previous.call(r,r.previous))return!0}return!1}}}function nl(e){return t;function t(n,r){let i=-1,o;for(;++i<=n.length;)o===void 0?n[i]&&n[i][1].type==="data"&&(o=i,i++):(!n[i]||n[i][1].type!=="data")&&(i!==o+2&&(n[o][1].end=n[i-1][1].end,n.splice(o+2,i-o-2),i=o+2),o=void 0);return e?e(n,r):n}}function Tm(e,t){let n=0;for(;++n<=e.length;)if((n===e.length||e[n][1].type==="lineEnding")&&e[n-1][1].type==="data"){const r=e[n-1][1],i=t.sliceStream(r);let o=i.length,a=-1,l=0,u;
vendor: 4,651 bytes, lines 8-10
8for(;o--;){const c=i[o];if(typeof c=="string"){for(a=c.length;c.charCodeAt(a-1)===32;)l++,a--;if(a)break;a=-1}else if(c===-2)u=!0,l++;else if(c!==-1){o++;break}}if(t._contentTypeTextTrailing&&n===e.length&&(l=0),l){const c={type:n===e.length||u||l<2?"lineSuffix":"hardBreakTrailing",start:{_bufferIndex:o?a:r.start._bufferIndex+a,_index:r.start._index+o,line:r.end.line,column:r.end.column-l,offset:r.end.offset-l},end:{...r.end}};r.end={...c.start},r.start.offset===r.end.offset?Object.assign(r,c):(e.splice(n,0,["enter",c,t],["exit",c,t]),n+=2)}n++}return e}const Pm={42:Oe,43:Oe,45:Oe,48:Oe,49:Oe,50:Oe,51:Oe,52:Oe,53:Oe,54:Oe,55:Oe,56:Oe,57:Oe,62:Wa},Mm={91:Fh},Rm={[-2]:Pr,[-1]:Pr,32:Pr},Lm={35:Vh,42:$n,45:[os,$n],60:Zh,61:os,95:$n,96:rs,126:rs},Om={38:Ya,92:Ga},Fm={[-5]:Mr,[-4]:Mr,[-3]:Mr,33:cm,38:Ya,42:ei,60:[fh,Jh],91:fm,92:[$h,Ga],93:Ki,95:ei,96:Ih},zm={null:[ei,Cm]},_m={null:[42,95]},Dm={null:[]},$m=Object.freeze(Object.defineProperty({__proto__:null,attentionMarkers:_m,contentInitial:Mm,disable:Dm,document:Pm,flow:Lm,flowInitial:Rm,insideSpan:zm,string:Om,text:Fm},Symbol.toStringTag,{value:"Module"}));function Bm(e,t,n){let r={_bufferIndex:-1,_index:0,line:n&&n.line||1,column:n&&n.column||1,offset:n&&n.offset||0};const i={},o=[];let a=[],l=[];const u={attempt:V(z),check:V(N),consume:k,enter:j,exit:R,interrupt:V(N,{interrupt:!0})},c={code:null,containerState:{},defineSkip:x,events:[],now:g,parser:e,previous:null,sliceSerialize:d,sliceStream:h,write:p};let f=t.tokenize.call(c,u);return t.resolveAll&&o.push(t),c;function p(A){return a=qe(a,A),C(),a[a.length-1]!==null?[]:(H(t,0),c.events=Zi(o,c.events,c),c.events)}function d(A,P){return Hm(h(A),P)}function h(A){return Vm(a,A)}function g(){const{_bufferIndex:A,_index:P,line:D,column:F,offset:Z}=r;return{_bufferIndex:A,_index:P,line:D,column:F,offset:Z}}function x(A){i[A.line]=A.column,B()}function C(){let A;for(;r._index<a.length;){const P=a[r._index];if(typeof P=="string")for(A=r._index,r._bufferIndex<0&&(r._bufferIndex=0);r._index===A&&r._bufferIndex<P.length;)v(P.charCodeAt(r._bufferIndex));else v(P)}}function v(A){f=f(A)}function k(A){X(A)?(r.line++,r.column=1,r.offset+=A===-3?2:1,B()):A!==-1&&(r.column++,r.offset++),r._bufferIndex<0?r._index++:(r._bufferIndex++,r._bufferIndex===a[r._index].length&&(r._bufferIndex=-1,r._index++)),c.previous=A}function j(A,P){const D=P||{};return D.type=A,D.start=g(),c.events.push(["enter",D,c]),l.push(D),D}function R(A){const P=l.pop();return P.end=g(),c.events.push(["exit",P,c]),P}function z(A,P){H(A,P.from)}function N(A,P){P.restore()}function V(A,P){return D;function D(F,Z,K){let ee,ne,ue,b;return Array.isArray(F)?we(F):"tokenize"in F?we([F]):Ne(F);function Ne(pe){return Se;function Se(Ee){const Ie=Ee!==null&&pe[Ee],I=Ee!==null&&pe.null,W=[...Array.isArray(Ie)?Ie:Ie?[Ie]:[],...Array.isArray(I)?I:I?[I]:[]];return we(W)(Ee)}}function we(pe){return ee=pe,ne=0,pe.length===0?K:y(pe[ne])}function y(pe){return Se;function Se(Ee){return b=E(),ue=pe,pe.partial||(c.currentConstruct=pe),pe.name&&c.parser.constructs.disable.null.includes(pe.name)?Ae():pe.tokenize.call(P?Object.assign(Object.create(c),P):c,u,ge,Ae)(Ee)}}function ge(pe){return A(ue,b),Z}function Ae(pe){return b.restore(),++ne<ee.length?y(ee[ne]):K}}}function H(A,P){A.resolveAll&&!o.includes(A)&&o.push(A),A.resolve&&nt(c.events,P,c.events.length-P,A.resolve(c.events.slice(P),c)),A.resolveTo&&(c.events=A.resolveTo(c.events,c))}function E(){const A=g(),P=c.previous,D=c.currentConstruct,F=c.events.length,Z=Array.from(l);return{from:F,restore:K};function K(){r=A,c.previous=P,c.currentConstruct=D,c.events.length=F,l=Z,B()}}function B(){r.line in i&&r.column<2&&(r.column=i[r.line],r.offset+=i[r.line]-1)}}function Vm(e,t){const n=t.start._index,r=t.start._bufferIndex,i=t.end._index,o=t.end._bufferIndex;let a;if(n===i)a=[e[n].slice(r,o)];else{if(a=e.slice(n,i),r>-1){const l=a[0];typeof l=="string"?a[0]=l.slice(r):a.shift()}o>0&&a.push(e[i].slice(0,o))}return a}function Hm(e,t){let n=-1;const r=[];let i;for(;++n<e.length;){const o=e[n];let a;if(typeof o=="string")a=o;else switch(o){case-5:{a="\r";break}case-4:{a=` 9`;break}case-3:{a=`\r 10`;break}case-2:{a=t?" ":" ";break}case-1:{if(!t&&i)continue;a=" ";break}default:a=String.fromCharCode(o)}i=o===-2,r.push(a)}return r.join("")}function Um(e){const r={constructs:Xp([$m,...(e||{}).extensions||[]]),content:i(oh),defined:[],document:i(ah),flow:i(Im),lazy:{},string:i(Am),text:i(Em)};return r;function i(o){return a;function a(l){return Bm(r,o,l)}}}function qm(e){for(;!Xa(e););return e}const ss=/[\0\t\n\r]/g;function Zm(){let e=1,t="",n=!0,r;return i;function i(o,a,l){const u=[];let c,f,p,d,h;
vendor: 11,124 bytes, line 10
10for(o=t+(typeof o=="string"?o.toString():new TextDecoder(a||void 0).decode(o)),p=0,t="",n&&(o.charCodeAt(0)===65279&&p++,n=void 0);p<o.length;){if(ss.lastIndex=p,c=ss.exec(o),d=c&&c.index!==void 0?c.index:o.length,h=o.charCodeAt(d),!c){t=o.slice(p);break}if(h===10&&p===d&&r)u.push(-3),r=void 0;else switch(r&&(u.push(-5),r=void 0),p<d&&(u.push(o.slice(p,d)),e+=d-p),h){case 0:{u.push(65533),e++;break}case 9:{for(f=Math.ceil(e/4)*4,u.push(-2);e++<f;)u.push(-1);break}case 10:{u.push(-4),e=1;break}default:r=!0,e=1}p=d+1}return l&&(r&&u.push(-5),t&&u.push(t),u.push(null)),u}}const Km=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function Wm(e){return e.replace(Km,Gm)}function Gm(e,t,n){if(t)return t;if(n.charCodeAt(0)===35){const i=n.charCodeAt(1),o=i===120||i===88;return Ka(n.slice(o?2:1),o?16:10)}return qi(n)||e}const rl={}.hasOwnProperty;function Ym(e,t,n){return t&&typeof t=="object"&&(n=t,t=void 0),Xm(n)(qm(Um(n).document().write(Zm()(e,t,!0))))}function Xm(e){const t={transforms:[],canContainEols:["emphasis","fragment","heading","paragraph","strong"],enter:{autolink:o(Re),autolinkProtocol:E,autolinkEmail:E,atxHeading:o(Te),blockQuote:o(I),characterEscape:E,characterReference:E,codeFenced:o(W),codeFencedFenceInfo:a,codeFencedFenceMeta:a,codeIndented:o(W,a),codeText:o(Y,a),codeTextData:E,data:E,codeFlowValue:E,definition:o(he),definitionDestinationString:a,definitionLabelString:a,definitionTitleString:a,emphasis:o(ye),hardBreakEscape:o(Me),hardBreakTrailing:o(Me),htmlFlow:o(se,a),htmlFlowData:E,htmlText:o(se,a),htmlTextData:E,image:o(fe),label:a,link:o(Re),listItem:o(te),listItemValue:d,listOrdered:o(At,p),listUnordered:o(At),paragraph:o(Et),reference:y,referenceString:a,resourceDestinationString:a,resourceTitleString:a,setextHeading:o(Te),strong:o(yn),thematicBreak:o(Zt)},exit:{atxHeading:u(),atxHeadingSequence:z,autolink:u(),autolinkEmail:Ie,autolinkProtocol:Ee,blockQuote:u(),characterEscapeValue:B,characterReferenceMarkerHexadecimal:Ae,characterReferenceMarkerNumeric:Ae,characterReferenceValue:pe,characterReference:Se,codeFenced:u(C),codeFencedFence:x,codeFencedFenceInfo:h,codeFencedFenceMeta:g,codeFlowValue:B,codeIndented:u(v),codeText:u(Z),codeTextData:B,data:B,definition:u(),definitionDestinationString:R,definitionLabelString:k,definitionTitleString:j,emphasis:u(),hardBreakEscape:u(P),hardBreakTrailing:u(P),htmlFlow:u(D),htmlFlowData:B,htmlText:u(F),htmlTextData:B,image:u(ee),label:ue,labelText:ne,lineEnding:A,link:u(K),listItem:u(),listOrdered:u(),listUnordered:u(),paragraph:u(),referenceString:ge,resourceDestinationString:b,resourceTitleString:Ne,resource:we,setextHeading:u(H),setextHeadingLineSequence:V,setextHeadingText:N,strong:u(),thematicBreak:u()}};il(t,(e||{}).mdastExtensions||[]);const n={};return r;function r(T){let $={type:"root",children:[]};const Q={stack:[$],tokenStack:[],config:t,enter:l,exit:c,buffer:a,resume:f,data:n},ie=[];let ce=-1;for(;++ce<T.length;)if(T[ce][1].type==="listOrdered"||T[ce][1].type==="listUnordered")if(T[ce][0]==="enter")ie.push(ce);else{const _e=ie.pop();ce=i(T,_e,ce)}for(ce=-1;++ce<T.length;){const _e=t[T[ce][0]];rl.call(_e,T[ce][1].type)&&_e[T[ce][1].type].call(Object.assign({sliceSerialize:T[ce][2].sliceSerialize},Q),T[ce][1])}if(Q.tokenStack.length>0){const _e=Q.tokenStack[Q.tokenStack.length-1];(_e[1]||as).call(Q,void 0,_e[0])}for($.position={start:pt(T.length>0?T[0][1].start:{line:1,column:1,offset:0}),end:pt(T.length>0?T[T.length-2][1].end:{line:1,column:1,offset:0})},ce=-1;++ce<t.transforms.length;)$=t.transforms[ce]($)||$;return $}function i(T,$,Q){let ie=$-1,ce=-1,_e=!1,ot,We,ct,st;for(;++ie<=Q;){const Pe=T[ie];switch(Pe[1].type){case"listUnordered":case"listOrdered":case"blockQuote":{Pe[0]==="enter"?ce++:ce--,st=void 0;break}case"lineEndingBlank":{Pe[0]==="enter"&&(ot&&!st&&!ce&&!ct&&(ct=ie),st=void 0);break}case"linePrefix":case"listItemValue":case"listItemMarker":case"listItemPrefix":case"listItemPrefixWhitespace":break;default:st=void 0}if(!ce&&Pe[0]==="enter"&&Pe[1].type==="listItemPrefix"||ce===-1&&Pe[0]==="exit"&&(Pe[1].type==="listUnordered"||Pe[1].type==="listOrdered")){if(ot){let dt=ie;for(We=void 0;dt--;){const Ve=T[dt];if(Ve[1].type==="lineEnding"||Ve[1].type==="lineEndingBlank"){if(Ve[0]==="exit")continue;We&&(T[We][1].type="lineEndingBlank",_e=!0),Ve[1].type="lineEnding",We=dt}else if(!(Ve[1].type==="linePrefix"||Ve[1].type==="blockQuotePrefix"||Ve[1].type==="blockQuotePrefixWhitespace"||Ve[1].type==="blockQuoteMarker"||Ve[1].type==="listItemIndent"))break}ct&&(!We||ct<We)&&(ot._spread=!0),ot.end=Object.assign({},We?T[We][1].start:Pe[1].end),T.splice(We||ie,0,["exit",ot,Pe[2]]),ie++,Q++}if(Pe[1].type==="listItemPrefix"){const dt={type:"listItem",_spread:!1,start:Object.assign({},Pe[1].start),end:void 0};ot=dt,T.splice(ie,0,["enter",dt,Pe[2]]),ie++,Q++,ct=void 0,st=!0}}}return T[$][1]._spread=_e,Q}function o(T,$){return Q;function Q(ie){l.call(this,T(ie),ie),$&&$.call(this,ie)}}function a(){this.stack.push({type:"fragment",children:[]})}function l(T,$,Q){this.stack[this.stack.length-1].children.push(T),this.stack.push(T),this.tokenStack.push([$,Q||void 0]),T.position={start:pt($.start),end:void 0}}function u(T){return $;function $(Q){T&&T.call(this,Q),c.call(this,Q)}}function c(T,$){const Q=this.stack.pop(),ie=this.tokenStack.pop();if(ie)ie[0].type!==T.type&&($?$.call(this,T,ie[0]):(ie[1]||as).call(this,T,ie[0]));else throw new Error("Cannot close `"+T.type+"` ("+Qt({start:T.start,end:T.end})+"): itâs not open");Q.position.end=pt(T.end)}function f(){return Gp(this.stack.pop())}function p(){this.data.expectingFirstListItemValue=!0}function d(T){if(this.data.expectingFirstListItemValue){const $=this.stack[this.stack.length-2];$.start=Number.parseInt(this.sliceSerialize(T),10),this.data.expectingFirstListItemValue=void 0}}function h(){const T=this.resume(),$=this.stack[this.stack.length-1];$.lang=T}function g(){const T=this.resume(),$=this.stack[this.stack.length-1];$.meta=T}function x(){this.data.flowCodeInside||(this.buffer(),this.data.flowCodeInside=!0)}function C(){const T=this.resume(),$=this.stack[this.stack.length-1];$.value=T.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,""),this.data.flowCodeInside=void 0}function v(){const T=this.resume(),$=this.stack[this.stack.length-1];$.value=T.replace(/(\r?\n|\r)$/g,"")}function k(T){const $=this.resume(),Q=this.stack[this.stack.length-1];Q.label=$,Q.identifier=zt(this.sliceSerialize(T)).toLowerCase()}function j(){const T=this.resume(),$=this.stack[this.stack.length-1];$.title=T}function R(){const T=this.resume(),$=this.stack[this.stack.length-1];$.url=T}function z(T){const $=this.stack[this.stack.length-1];if(!$.depth){const Q=this.sliceSerialize(T).length;$.depth=Q}}function N(){this.data.setextHeadingSlurpLineEnding=!0}function V(T){const $=this.stack[this.stack.length-1];$.depth=this.sliceSerialize(T).codePointAt(0)===61?1:2}function H(){this.data.setextHeadingSlurpLineEnding=void 0}function E(T){const Q=this.stack[this.stack.length-1].children;let ie=Q[Q.length-1];(!ie||ie.type!=="text")&&(ie=mr(),ie.position={start:pt(T.start),end:void 0},Q.push(ie)),this.stack.push(ie)}function B(T){const $=this.stack.pop();$.value+=this.sliceSerialize(T),$.position.end=pt(T.end)}function A(T){const $=this.stack[this.stack.length-1];if(this.data.atHardBreak){const Q=$.children[$.children.length-1];Q.position.end=pt(T.end),this.data.atHardBreak=void 0;return}!this.data.setextHeadingSlurpLineEnding&&t.canContainEols.includes($.type)&&(E.call(this,T),B.call(this,T))}function P(){this.data.atHardBreak=!0}function D(){const T=this.resume(),$=this.stack[this.stack.length-1];$.value=T}function F(){const T=this.resume(),$=this.stack[this.stack.length-1];$.value=T}function Z(){const T=this.resume(),$=this.stack[this.stack.length-1];$.value=T}function K(){const T=this.stack[this.stack.length-1];if(this.data.inReference){const $=this.data.referenceType||"shortcut";T.type+="Reference",T.referenceType=$,delete T.url,delete T.title}else delete T.identifier,delete T.label;this.data.referenceType=void 0}function ee(){const T=this.stack[this.stack.length-1];if(this.data.inReference){const $=this.data.referenceType||"shortcut";T.type+="Reference",T.referenceType=$,delete T.url,delete T.title}else delete T.identifier,delete T.label;this.data.referenceType=void 0}function ne(T){const $=this.sliceSerialize(T),Q=this.stack[this.stack.length-2];Q.label=Wm($),Q.identifier=zt($).toLowerCase()}function ue(){const T=this.stack[this.stack.length-1],$=this.resume(),Q=this.stack[this.stack.length-1];if(this.data.inReference=!0,Q.type==="link"){const ie=T.children;Q.children=ie}else Q.alt=$}function b(){const T=this.resume(),$=this.stack[this.stack.length-1];$.url=T}function Ne(){const T=this.resume(),$=this.stack[this.stack.length-1];$.title=T}function we(){this.data.inReference=void 0}function y(){this.data.referenceType="collapsed"}function ge(T){const $=this.resume(),Q=this.stack[this.stack.length-1];Q.label=$,Q.identifier=zt(this.sliceSerialize(T)).toLowerCase(),this.data.referenceType="full"}function Ae(T){this.data.characterReferenceType=T.type}function pe(T){const $=this.sliceSerialize(T),Q=this.data.characterReferenceType;let ie;Q?(ie=Ka($,Q==="characterReferenceMarkerNumeric"?10:16),this.data.characterReferenceType=void 0):ie=qi($);const ce=this.stack[this.stack.length-1];ce.value+=ie}function Se(T){const $=this.stack.pop();$.position.end=pt(T.end)}function Ee(T){B.call(this,T);const $=this.stack[this.stack.length-1];$.url=this.sliceSerialize(T)}function Ie(T){B.call(this,T);const $=this.stack[this.stack.length-1];$.url="mailto:"+this.sliceSerialize(T)}function I(){return{type:"blockquote",children:[]}}function W(){return{type:"code",lang:null,meta:null,value:""}}function Y(){return{type:"inlineCode",value:""}}function he(){return{type:"definition",identifier:"",label:null,title:null,url:""}}function ye(){return{type:"emphasis",children:[]}}function Te(){return{type:"heading",depth:0,children:[]}}function Me(){return{type:"break"}}function se(){return{type:"html",value:""}}function fe(){return{type:"image",title:null,url:"",alt:null}}function Re(){return{type:"link",title:null,url:"",children:[]}}function At(T){return{type:"list",ordered:T.type==="listOrdered",start:null,spread:T._spread,children:[]}}function te(T){return{type:"listItem",spread:T._spread,checked:null,children:[]}}function Et(){return{type:"paragraph",children:[]}}function yn(){return{type:"strong",children:[]}}function mr(){return{type:"text",value:""}}function Zt(){return{type:"thematicBreak"}}}function pt(e){return{line:e.line,column:e.column,offset:e.offset}}function il(e,t){let n=-1;for(;++n<t.length;){const r=t[n];Array.isArray(r)?il(e,r):Qm(e,r)}}function Qm(e,t){let n;for(n in t)if(rl.call(t,n))switch(n){case"canContainEols":{const r=t[n];r&&e[n].push(...r);break}case"transforms":{const r=t[n];r&&e[n].push(...r);break}case"enter":case"exit":{const r=t[n];r&&Object.assign(e[n],r);break}}}function as(e,t){throw e?new Error("Cannot close `"+e.type+"` ("+Qt({start:e.start,end:e.end})+"): a different token (`"+t.type+"`, "+Qt({start:t.start,end:t.end}
vendor: 10,608 bytes, lines 10-14
10)+") is open"):new Error("Cannot close document, a token (`"+t.type+"`, "+Qt({start:t.start,end:t.end})+") is still open")}function Jm(e){const t=this;t.parser=n;function n(r){return Ym(r,{...t.data("settings"),...e,extensions:t.data("micromarkExtensions")||[],mdastExtensions:t.data("fromMarkdownExtensions")||[]})}}function eg(e,t){const n={type:"element",tagName:"blockquote",properties:{},children:e.wrap(e.all(t),!0)};return e.patch(t,n),e.applyData(t,n)}function tg(e,t){const n={type:"element",tagName:"br",properties:{},children:[]};return e.patch(t,n),[e.applyData(t,n),{type:"text",value:` 11`}]}function ng(e,t){const n=t.value?t.value+` 12`:"",r={},i=t.lang?t.lang.split(/\s+/):[];i.length>0&&(r.className=["language-"+i[0]]);let o={type:"element",tagName:"code",properties:r,children:[{type:"text",value:n}]};return t.meta&&(o.data={meta:t.meta}),e.patch(t,o),o=e.applyData(t,o),o={type:"element",tagName:"pre",properties:{},children:[o]},e.patch(t,o),o}function rg(e,t){const n={type:"element",tagName:"del",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function ig(e,t){const n={type:"element",tagName:"em",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function og(e,t){const n=typeof e.options.clobberPrefix=="string"?e.options.clobberPrefix:"user-content-",r=String(t.identifier).toUpperCase(),i=qt(r.toLowerCase()),o=e.footnoteOrder.indexOf(r);let a,l=e.footnoteCounts.get(r);l===void 0?(l=0,e.footnoteOrder.push(r),a=e.footnoteOrder.length):a=o+1,l+=1,e.footnoteCounts.set(r,l);const u={type:"element",tagName:"a",properties:{href:"#"+n+"fn-"+i,id:n+"fnref-"+i+(l>1?"-"+l:""),dataFootnoteRef:!0,ariaDescribedBy:["footnote-label"]},children:[{type:"text",value:String(a)}]};e.patch(t,u);const c={type:"element",tagName:"sup",properties:{},children:[u]};return e.patch(t,c),e.applyData(t,c)}function sg(e,t){const n={type:"element",tagName:"h"+t.depth,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function ag(e,t){if(e.options.allowDangerousHtml){const n={type:"raw",value:t.value};return e.patch(t,n),e.applyData(t,n)}}function ol(e,t){const n=t.referenceType;let r="]";if(n==="collapsed"?r+="[]":n==="full"&&(r+="["+(t.label||t.identifier)+"]"),t.type==="imageReference")return[{type:"text",value:"!["+t.alt+r}];const i=e.all(t),o=i[0];o&&o.type==="text"?o.value="["+o.value:i.unshift({type:"text",value:"["});const a=i[i.length-1];return a&&a.type==="text"?a.value+=r:i.push({type:"text",value:r}),i}function lg(e,t){const n=String(t.identifier).toUpperCase(),r=e.definitionById.get(n);if(!r)return ol(e,t);const i={src:qt(r.url||""),alt:t.alt};r.title!==null&&r.title!==void 0&&(i.title=r.title);const o={type:"element",tagName:"img",properties:i,children:[]};return e.patch(t,o),e.applyData(t,o)}function ug(e,t){const n={src:qt(t.url)};t.alt!==null&&t.alt!==void 0&&(n.alt=t.alt),t.title!==null&&t.title!==void 0&&(n.title=t.title);const r={type:"element",tagName:"img",properties:n,children:[]};return e.patch(t,r),e.applyData(t,r)}function cg(e,t){const n={type:"text",value:t.value.replace(/\r?\n|\r/g," ")};e.patch(t,n);const r={type:"element",tagName:"code",properties:{},children:[n]};return e.patch(t,r),e.applyData(t,r)}function dg(e,t){const n=String(t.identifier).toUpperCase(),r=e.definitionById.get(n);if(!r)return ol(e,t);const i={href:qt(r.url||"")};r.title!==null&&r.title!==void 0&&(i.title=r.title);const o={type:"element",tagName:"a",properties:i,children:e.all(t)};return e.patch(t,o),e.applyData(t,o)}function fg(e,t){const n={href:qt(t.url)};t.title!==null&&t.title!==void 0&&(n.title=t.title);const r={type:"element",tagName:"a",properties:n,children:e.all(t)};return e.patch(t,r),e.applyData(t,r)}function pg(e,t,n){const r=e.all(t),i=n?hg(n):sl(t),o={},a=[];if(typeof t.checked=="boolean"){const f=r[0];let p;f&&f.type==="element"&&f.tagName==="p"?p=f:(p={type:"element",tagName:"p",properties:{},children:[]},r.unshift(p)),p.children.length>0&&p.children.unshift({type:"text",value:" "}),p.children.unshift({type:"element",tagName:"input",properties:{type:"checkbox",checked:t.checked,disabled:!0},children:[]}),o.className=["task-list-item"]}let l=-1;for(;++l<r.length;){const f=r[l];(i||l!==0||f.type!=="element"||f.tagName!=="p")&&a.push({type:"text",value:` 13`}),f.type==="element"&&f.tagName==="p"&&!i?a.push(...f.children):a.push(f)}const u=r[r.length-1];u&&(i||u.type!=="element"||u.tagName!=="p")&&a.push({type:"text",value:` 14`});const c={type:"element",tagName:"li",properties:o,children:a};return e.patch(t,c),e.applyData(t,c)}function hg(e){let t=!1;if(e.type==="list"){t=e.spread||!1;const n=e.children;let r=-1;for(;!t&&++r<n.length;)t=sl(n[r])}return t}function sl(e){const t=e.spread;return t??e.children.length>1}function mg(e,t){const n={},r=e.all(t);let i=-1;for(typeof t.start=="number"&&t.start!==1&&(n.start=t.start);++i<r.length;){const a=r[i];if(a.type==="element"&&a.tagName==="li"&&a.properties&&Array.isArray(a.properties.className)&&a.properties.className.includes("task-list-item")){n.className=["contains-task-list"];break}}const o={type:"element",tagName:t.ordered?"ol":"ul",properties:n,children:e.wrap(r,!0)};return e.patch(t,o),e.applyData(t,o)}function gg(e,t){const n={type:"element",tagName:"p",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function xg(e,t){const n={type:"root",children:e.wrap(e.all(t))};return e.patch(t,n),e.applyData(t,n)}function bg(e,t){const n={type:"element",tagName:"strong",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function yg(e,t){const n=e.all(t),r=n.shift(),i=[];if(r){const a={type:"element",tagName:"thead",properties:{},children:e.wrap([r],!0)};e.patch(t.children[0],a),i.push(a)}if(n.length>0){const a={type:"element",tagName:"tbody",properties:{},children:e.wrap(n,!0)},l=Bi(t.children[1]),u=Da(t.children[t.children.length-1]);l&&u&&(a.position={start:l,end:u}),i.push(a)}const o={type:"element",tagName:"table",properties:{},children:e.wrap(i,!0)};return e.patch(t,o),e.applyData(t,o)}function wg(e,t,n){const r=n?n.children:void 0,o=(r?r.indexOf(t):1)===0?"th":"td",a=n&&n.type==="table"?n.align:void 0,l=a?a.length:t.children.length;let u=-1;const c=[];for(;++u<l;){const p=t.children[u],d={},h=a?a[u]:void 0;h&&(d.align=h);let g={type:"element",tagName:o,properties:d,children:[]};p&&(g.children=e.all(p),e.patch(p,g),g=e.applyData(p,g)),c.push(g)}const f={type:"element",tagName:"tr",properties:{},children:e.wrap(c,!0)};return e.patch(t,f),e.applyData(t,f)}function kg(e,t){const n={type:"element",tagName:"td",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}const ls=9,us=32;function vg(e){const t=String(e),n=/\r?\n|\r/g;let r=n.exec(t),i=0;const o=[];for(;r;)o.push(cs(t.slice(i,r.index),i>0,!0),r[0]),i=r.index+r[0].length,r=n.exec(t);return o.push(cs(t.slice(i),i>0,!1)),o.join("")}function cs(e,t,n){let r=0,i=e.length;if(t){let o=e.codePointAt(r);for(;o===ls||o===us;)r++,o=e.codePointAt(r)}if(n){let o=e.codePointAt(i-1);for(;o===ls||o===us;)i--,o=e.codePointAt(i-1)}return i>r?e.slice(r,i):""}function jg(e,t){const n={type:"text",value:vg(String(t.value))};return e.patch(t,n),e.applyData(t,n)}function Ng(e,t){const n={type:"element",tagName:"hr",properties:{},children:[]};return e.patch(t,n),e.applyData(t,n)}const Ig={blockquote:eg,break:tg,code:ng,delete:rg,emphasis:ig,footnoteReference:og,heading:sg,html:ag,imageReference:lg,image:ug,inlineCode:cg,linkReference:dg,link:fg,listItem:pg,list:mg,paragraph:gg,root:xg,strong:bg,table:yg,tableCell:kg,tableRow:wg,text:jg,thematicBreak:Ng,toml:On,yaml:On,definition:On,footnoteDefinition:On};function On(){}const al=-1,cr=0,en=1,Gn=2,Wi=3,Gi=4,Yi=5,Xi=6,ll=7,ul=8,ds=typeof self=="object"?self:globalThis,Sg=(e,t)=>{const n=(i,o)=>(e.set(o,i),i),r=i=>{if(e.has(i))return e.get(i);const[o,a]=t[i];switch(o){case cr:case al:return n(a,i);case en:{const l=n([],i);for(const u of a)l.push(r(u));return l}case Gn:{const l=n({},i);for(const[u,c]of a)l[r(u)]=r(c);return l}case Wi:return n(new Date(a),i);case Gi:{const{source:l,flags:u}=a;return n(new RegExp(l,u),i)}case Yi:{const l=n(new Map,i);for(const[u,c]of a)l.set(r(u),r(c));return l}case Xi:{const l=n(new Set,i);for(const u of a)l.add(r(u));return l}case ll:{const{name:l,message:u}=a;return n(new ds[l](u),i)}case ul:return n(BigInt(a),i);case"BigInt":return n(Object(BigInt(a)),i);case"ArrayBuffer":return n(new Uint8Array(a).buffer,a);case"DataView":{const{buffer:l}=new Uint8Array(a);return n(new DataView(l),a)}}return n(new ds[o](a),i)};return r},fs=e=>Sg(new Map,e)(0),Rt="",{toString:Cg}={},{keys:Ag}=Object,Yt=e=>{const t=typeof e;if(t!=="object"||!e)return[cr,t];const n=Cg.call(e).slice(8,-1);switch(n){case"Array":return[en,Rt];case"Object":return[Gn,Rt];case"Date":return[Wi,Rt];case"RegExp":return[Gi,Rt];case"Map":return[Yi,Rt];case"Set":return[Xi,Rt];case"DataView":return[en,n]}return n.includes("Array")?[en,n]:n.includes("Error")?[ll,n]:[Gn,n]},Fn=([e,t])=>e===cr&&(t==="function"||t==="symbol"),Eg=(e,t,n,r)=>{const i=(a,l)=>{const u=r.push(a)-1;return n.set(l,u),u},o=a=>{if(n.has(a))return n.get(a);let[l,u]=Yt(a);switch(l){case cr:{let f=a;switch(u){case"bigint":l=ul,f=a.toString();break;case"function":case"symbol":if(e)throw new TypeError("unable to serialize "+u);f=null;break;case"undefined":return i([al],a)}return i([l,f],a)}case en:{if(u){let d=a;return u==="DataView"?d=new Uint8Array(a.buffer):u==="ArrayBuffer"&&(d=new Uint8Array(a)),i([u,[...d]],a)}const f=[],p=i([l,f],a);for(const d of a)f.push(o(d));return p}case Gn:{if(u)switch(u){case"BigInt":return i([u,a.toString()],a);case"Boolean":case"Number":case"String":return i([u,a.valueOf()],a)}if(t&&"toJSON"in a)return o(a.toJSON());const f=[],p=i([l,f],a);for(const d of Ag(a))(e||!Fn(Yt(a[d])))&&f.push([o(d),o(a[d])]);return p}case Wi:return i([l,a.toISOString()],a);case Gi:{const{source:f,flags:p}=a;return i([l,{source:f,flags:p}],a)}case Yi:{const f=[],p=i([l,f],a);for(const[d,h]of a)(e||!(Fn(Yt(d))||Fn(Yt(h))))&&f.push([o(d),o(h)]);return p}case Xi:{const f=[],p=i([l,f],a);for(const d of a)(e||!Fn(Yt(d)))&&f.push(o(d));return p}}const{message:c}=a;return i([l,{name:u,message:c}],a)};return o},ps=(e,{json:t,lossy:n}={})=>{const r=[];return Eg(!(t||n),!!t,new Map,r)(e),r},un=typeof structuredClone=="function"?(e,t)=>t&&("json"in t||"lossy"in t)?fs(ps(e,t)):structuredClone(e):(e,t)=>fs(ps(e,t));function Tg(e,t){const n=[{type:"text",value:"â©"}];return t>1&&n.push({type:"element",tagName:"sup",properties:{},children:[{type:"text",value:String(t)}]}),n}function Pg(e,t){return"Back to reference "+(e+1)+(t>1?"-"+t:"")}
vendor: 8,921 bytes, lines 14-20
14function Mg(e){const t=typeof e.options.clobberPrefix=="string"?e.options.clobberPrefix:"user-content-",n=e.options.footnoteBackContent||Tg,r=e.options.footnoteBackLabel||Pg,i=e.options.footnoteLabel||"Footnotes",o=e.options.footnoteLabelTagName||"h2",a=e.options.footnoteLabelProperties||{className:["sr-only"]},l=[];let u=-1;for(;++u<e.footnoteOrder.length;){const c=e.footnoteById.get(e.footnoteOrder[u]);if(!c)continue;const f=e.all(c),p=String(c.identifier).toUpperCase(),d=qt(p.toLowerCase());let h=0;const g=[],x=e.footnoteCounts.get(p);for(;x!==void 0&&++h<=x;){g.length>0&&g.push({type:"text",value:" "});let k=typeof n=="string"?n:n(u,h);typeof k=="string"&&(k={type:"text",value:k}),g.push({type:"element",tagName:"a",properties:{href:"#"+t+"fnref-"+d+(h>1?"-"+h:""),dataFootnoteBackref:"",ariaLabel:typeof r=="string"?r:r(u,h),className:["data-footnote-backref"]},children:Array.isArray(k)?k:[k]})}const C=f[f.length-1];if(C&&C.type==="element"&&C.tagName==="p"){const k=C.children[C.children.length-1];k&&k.type==="text"?k.value+=" ":C.children.push({type:"text",value:" "}),C.children.push(...g)}else f.push(...g);const v={type:"element",tagName:"li",properties:{id:t+"fn-"+d},children:e.wrap(f,!0)};e.patch(c,v),l.push(v)}if(l.length!==0)return{type:"element",tagName:"section",properties:{dataFootnotes:!0,className:["footnotes"]},children:[{type:"element",tagName:o,properties:{...un(a),id:"footnote-label"},children:[{type:"text",value:i}]},{type:"text",value:` 15`},{type:"element",tagName:"ol",properties:{},children:e.wrap(l,!0)},{type:"text",value:` 16`}]}}const cl=function(e){if(e==null)return Fg;if(typeof e=="function")return dr(e);if(typeof e=="object")return Array.isArray(e)?Rg(e):Lg(e);if(typeof e=="string")return Og(e);throw new Error("Expected function, string, or object as test")};function Rg(e){const t=[];let n=-1;for(;++n<e.length;)t[n]=cl(e[n]);return dr(r);function r(...i){let o=-1;for(;++o<t.length;)if(t[o].apply(this,i))return!0;return!1}}function Lg(e){const t=e;return dr(n);function n(r){const i=r;let o;for(o in e)if(i[o]!==t[o])return!1;return!0}}function Og(e){return dr(t);function t(n){return n&&n.type===e}}function dr(e){return t;function t(n,r,i){return!!(zg(n)&&e.call(this,n,typeof r=="number"?r:void 0,i||void 0))}}function Fg(){return!0}function zg(e){return e!==null&&typeof e=="object"&&"type"in e}const dl=[],_g=!0,hs=!1,Dg="skip";function $g(e,t,n,r){let i;typeof t=="function"&&typeof n!="function"?(r=n,n=t):i=t;const o=cl(i),a=r?-1:1;l(e,void 0,[])();function l(u,c,f){const p=u&&typeof u=="object"?u:{};if(typeof p.type=="string"){const h=typeof p.tagName=="string"?p.tagName:typeof p.name=="string"?p.name:void 0;Object.defineProperty(d,"name",{value:"node ("+(u.type+(h?"<"+h+">":""))+")"})}return d;function d(){let h=dl,g,x,C;if((!t||o(u,c,f[f.length-1]||void 0))&&(h=Bg(n(u,f)),h[0]===hs))return h;if("children"in u&&u.children){const v=u;if(v.children&&h[0]!==Dg)for(x=(r?v.children.length:-1)+a,C=f.concat(v);x>-1&&x<v.children.length;){const k=v.children[x];if(g=l(k,x,C)(),g[0]===hs)return g;x=typeof g[1]=="number"?g[1]:x+a}}return h}}}function Bg(e){return Array.isArray(e)?e:typeof e=="number"?[_g,e]:e==null?dl:[e]}function fl(e,t,n,r){let i,o,a;typeof t=="function"&&typeof n!="function"?(o=void 0,a=t,i=n):(o=t,a=n,i=r),$g(e,o,l,i);function l(u,c){const f=c[c.length-1],p=f?f.children.indexOf(u):void 0;return a(u,p,f)}}const ti={}.hasOwnProperty,Vg={};function Hg(e,t){const n=t||Vg,r=new Map,i=new Map,o=new Map,a={...Ig,...n.handlers},l={all:c,applyData:qg,definitionById:r,footnoteById:i,footnoteCounts:o,footnoteOrder:[],handlers:a,one:u,options:n,patch:Ug,wrap:Kg};return fl(e,function(f){if(f.type==="definition"||f.type==="footnoteDefinition"){const p=f.type==="definition"?r:i,d=String(f.identifier).toUpperCase();p.has(d)||p.set(d,f)}}),l;function u(f,p){const d=f.type,h=l.handlers[d];if(ti.call(l.handlers,d)&&h)return h(l,f,p);if(l.options.passThrough&&l.options.passThrough.includes(d)){if("children"in f){const{children:x,...C}=f,v=un(C);return v.children=l.all(f),v}return un(f)}return(l.options.unknownHandler||Zg)(l,f,p)}function c(f){const p=[];if("children"in f){const d=f.children;let h=-1;for(;++h<d.length;){const g=l.one(d[h],f);if(g){if(h&&d[h-1].type==="break"&&(!Array.isArray(g)&&g.type==="text"&&(g.value=ms(g.value)),!Array.isArray(g)&&g.type==="element")){const x=g.children[0];x&&x.type==="text"&&(x.value=ms(x.value))}Array.isArray(g)?p.push(...g):p.push(g)}}}return p}}function Ug(e,t){e.position&&(t.position=Ba(e))}function qg(e,t){let n=t;if(e&&e.data){const r=e.data.hName,i=e.data.hChildren,o=e.data.hProperties;if(typeof r=="string")if(n.type==="element")n.tagName=r;else{const a="children"in n?n.children:[n];n={type:"element",tagName:r,properties:{},children:a}}n.type==="element"&&o&&Object.assign(n.properties,un(o)),"children"in n&&n.children&&i!==null&&i!==void 0&&(n.children=i)}return n}function Zg(e,t){const n=t.data||{},r="value"in t&&!(ti.call(n,"hProperties")||ti.call(n,"hChildren"))?{type:"text",value:t.value}:{type:"element",tagName:"div",properties:{},children:e.all(t)};return e.patch(t,r),e.applyData(t,r)}function Kg(e,t){const n=[];let r=-1;for(t&&n.push({type:"text",value:` 17`});++r<e.length;)r&&n.push({type:"text",value:` 18`}),n.push(e[r]);return t&&e.length>0&&n.push({type:"text",value:` 19`}),n}function ms(e){let t=0,n=e.charCodeAt(t);for(;n===9||n===32;)t++,n=e.charCodeAt(t);return e.slice(t)}function gs(e,t){const n=Hg(e,t),r=n.one(e,void 0),i=Mg(n),o=Array.isArray(r)?{type:"root",children:r}:r||{type:"root",children:[]};return i&&o.children.push({type:"text",value:` 20`},i),o}function Wg(e,t){return e&&"run"in e?async function(n,r){const i=gs(n,{file:r,...t});await e.run(i,r)}:function(n,r){return gs(n,{file:r,...e||t})}}function xs(e){if(e)throw e}var Bn=Object.prototype.hasOwnProperty,pl=Object.prototype.toString,bs=Object.defineProperty,ys=Object.getOwnPropertyDescriptor,ws=function(t){return typeof Array.isArray=="function"?Array.isArray(t):pl.call(t)==="[object Array]"},ks=function(t){if(!t||pl.call(t)!=="[object Object]")return!1;var n=Bn.call(t,"constructor"),r=t.constructor&&t.constructor.prototype&&Bn.call(t.constructor.prototype,"isPrototypeOf");if(t.constructor&&!n&&!r)return!1;var i;for(i in t);return typeof i>"u"||Bn.call(t,i)},vs=function(t,n){bs&&n.name==="__proto__"?bs(t,n.name,{enumerable:!0,configurable:!0,value:n.newValue,writable:!0}):t[n.name]=n.newValue},js=function(t,n){if(n==="__proto__")if(Bn.call(t,n)){if(ys)return ys(t,n).value}else return;return t[n]},Gg=function e(){var t,n,r,i,o,a,l=arguments[0],u=1,c=arguments.length,f=!1;for(typeof l=="boolean"&&(f=l,l=arguments[1]||{},u=2),(l==null||typeof l!="object"&&typeof l!="function")&&(l={});u<c;++u)if(t=arguments[u],t!=null)for(n in t)r=js(l,n),i=js(t,n),l!==i&&(f&&i&&(ks(i)||(o=ws(i)))?(o?(o=!1,a=r&&ws(r)?r:[]):a=r&&ks(r)?r:{},vs(l,{name:n,newValue:e(f,a,i)})):typeof i<"u"&&vs(l,{name:n,newValue:i}));return l};const Rr=Zs(Gg);function ni(e){if(typeof e!="object"||e===null)return!1;const t=Object.getPrototypeOf(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(Symbol.toStringTag in e)&&!(Symbol.iterator in e)}function Yg(){const e=[],t={run:n,use:r};return t;function n(...i){let o=-1;const a=i.pop();if(typeof a!="function")throw new TypeError("Expected function as last argument, not "+a);l(null,...i);function l(u,...c){const f=e[++o];let p=-1;if(u){a(u);return}for(;++p<i.length;)(c[p]===null||c[p]===void 0)&&(c[p]=i[p]);i=c,f?Xg(f,l)(...c):a(null,...c)}}function r(i){if(typeof i!="function")throw new TypeError("Expected `middelware` to be a function, not "+i);return e.push(i),t}}function Xg(e,t){let n;return r;function r(...a){const l=e.length>a.length;let u;l&&a.push(i);try{u=e.apply(this,a)}catch(c){const f=c;if(l&&n)throw f;return i(f)}l||(u&&u.then&&typeof u.then=="function"?u.then(o,i):u instanceof Error?i(u):o(u))}function i(a,...l){n||(n=!0,t(a,...l))}function o(a){i(null,a)}}const Je={basename:Qg,dirname:Jg,extname:ex,join:tx,sep:"/"};function Qg(e,t){if(t!==void 0&&typeof t!="string")throw new TypeError('"ext" argument must be a string');xn(e);let n=0,r=-1,i=e.length,o;if(t===void 0||t.length===0||t.length>e.length){for(;i--;)if(e.codePointAt(i)===47){if(o){n=i+1;break}}else r<0&&(o=!0,r=i+1);return r<0?"":e.slice(n,r)}if(t===e)return"";let a=-1,l=t.length-1;for(;i--;)if(e.codePointAt(i)===47){if(o){n=i+1;break}}else a<0&&(o=!0,a=i+1),l>-1&&(e.codePointAt(i)===t.codePointAt(l--)?l<0&&(r=i):(l=-1,r=a));return n===r?r=a:r<0&&(r=e.length),e.slice(n,r)}function Jg(e){if(xn(e),e.length===0)return".";let t=-1,n=e.length,r;for(;--n;)if(e.codePointAt(n)===47){if(r){t=n;break}}else r||(r=!0);return t<0?e.codePointAt(0)===47?"/":".":t===1&&e.codePointAt(0)===47?"//":e.slice(0,t)}function ex(e){xn(e);let t=e.length,n=-1,r=0,i=-1,o=0,a;for(;t--;){const l=e.codePointAt(t);if(l===47){if(a){r=t+1;break}continue}
vendor: 14,866 bytes, line 20
20n<0&&(a=!0,n=t+1),l===46?i<0?i=t:o!==1&&(o=1):i>-1&&(o=-1)}return i<0||n<0||o===0||o===1&&i===n-1&&i===r+1?"":e.slice(i,n)}function tx(...e){let t=-1,n;for(;++t<e.length;)xn(e[t]),e[t]&&(n=n===void 0?e[t]:n+"/"+e[t]);return n===void 0?".":nx(n)}function nx(e){xn(e);const t=e.codePointAt(0)===47;let n=rx(e,!t);return n.length===0&&!t&&(n="."),n.length>0&&e.codePointAt(e.length-1)===47&&(n+="/"),t?"/"+n:n}function rx(e,t){let n="",r=0,i=-1,o=0,a=-1,l,u;for(;++a<=e.length;){if(a<e.length)l=e.codePointAt(a);else{if(l===47)break;l=47}if(l===47){if(!(i===a-1||o===1))if(i!==a-1&&o===2){if(n.length<2||r!==2||n.codePointAt(n.length-1)!==46||n.codePointAt(n.length-2)!==46){if(n.length>2){if(u=n.lastIndexOf("/"),u!==n.length-1){u<0?(n="",r=0):(n=n.slice(0,u),r=n.length-1-n.lastIndexOf("/")),i=a,o=0;continue}}else if(n.length>0){n="",r=0,i=a,o=0;continue}}t&&(n=n.length>0?n+"/..":"..",r=2)}else n.length>0?n+="/"+e.slice(i+1,a):n=e.slice(i+1,a),r=a-i-1;i=a,o=0}else l===46&&o>-1?o++:o=-1}return n}function xn(e){if(typeof e!="string")throw new TypeError("Path must be a string. Received "+JSON.stringify(e))}const ix={cwd:ox};function ox(){return"/"}function ri(e){return!!(e!==null&&typeof e=="object"&&"href"in e&&e.href&&"protocol"in e&&e.protocol&&e.auth===void 0)}function sx(e){if(typeof e=="string")e=new URL(e);else if(!ri(e)){const t=new TypeError('The "path" argument must be of type string or an instance of URL. Received `'+e+"`");throw t.code="ERR_INVALID_ARG_TYPE",t}if(e.protocol!=="file:"){const t=new TypeError("The URL must be of scheme file");throw t.code="ERR_INVALID_URL_SCHEME",t}return ax(e)}function ax(e){if(e.hostname!==""){const r=new TypeError('File URL host must be "localhost" or empty on darwin');throw r.code="ERR_INVALID_FILE_URL_HOST",r}const t=e.pathname;let n=-1;for(;++n<t.length;)if(t.codePointAt(n)===37&&t.codePointAt(n+1)===50){const r=t.codePointAt(n+2);if(r===70||r===102){const i=new TypeError("File URL path must not include encoded / characters");throw i.code="ERR_INVALID_FILE_URL_PATH",i}}return decodeURIComponent(t)}const Lr=["history","path","basename","stem","extname","dirname"];class hl{constructor(t){let n;t?ri(t)?n={path:t}:typeof t=="string"||lx(t)?n={value:t}:n=t:n={},this.cwd="cwd"in n?"":ix.cwd(),this.data={},this.history=[],this.messages=[],this.value,this.map,this.result,this.stored;let r=-1;for(;++r<Lr.length;){const o=Lr[r];o in n&&n[o]!==void 0&&n[o]!==null&&(this[o]=o==="history"?[...n[o]]:n[o])}let i;for(i in n)Lr.includes(i)||(this[i]=n[i])}get basename(){return typeof this.path=="string"?Je.basename(this.path):void 0}set basename(t){Fr(t,"basename"),Or(t,"basename"),this.path=Je.join(this.dirname||"",t)}get dirname(){return typeof this.path=="string"?Je.dirname(this.path):void 0}set dirname(t){Ns(this.basename,"dirname"),this.path=Je.join(t||"",this.basename)}get extname(){return typeof this.path=="string"?Je.extname(this.path):void 0}set extname(t){if(Or(t,"extname"),Ns(this.dirname,"extname"),t){if(t.codePointAt(0)!==46)throw new Error("`extname` must start with `.`");if(t.includes(".",1))throw new Error("`extname` cannot contain multiple dots")}this.path=Je.join(this.dirname,this.stem+(t||""))}get path(){return this.history[this.history.length-1]}set path(t){ri(t)&&(t=sx(t)),Fr(t,"path"),this.path!==t&&this.history.push(t)}get stem(){return typeof this.path=="string"?Je.basename(this.path,this.extname):void 0}set stem(t){Fr(t,"stem"),Or(t,"stem"),this.path=Je.join(this.dirname||"",t+(this.extname||""))}fail(t,n,r){const i=this.message(t,n,r);throw i.fatal=!0,i}info(t,n,r){const i=this.message(t,n,r);return i.fatal=void 0,i}message(t,n,r){const i=new Ce(t,n,r);return this.path&&(i.name=this.path+":"+i.name,i.file=this.path),i.fatal=!1,this.messages.push(i),i}toString(t){return this.value===void 0?"":typeof this.value=="string"?this.value:new TextDecoder(t||void 0).decode(this.value)}}function Or(e,t){if(e&&e.includes(Je.sep))throw new Error("`"+t+"` cannot be a path: did not expect `"+Je.sep+"`")}function Fr(e,t){if(!e)throw new Error("`"+t+"` cannot be empty")}function Ns(e,t){if(!e)throw new Error("Setting `"+t+"` requires `path` to be set too")}function lx(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}const ux=function(e){const r=this.constructor.prototype,i=r[e],o=function(){return i.apply(o,arguments)};return Object.setPrototypeOf(o,r),o},cx={}.hasOwnProperty;class Qi extends ux{constructor(){super("copy"),this.Compiler=void 0,this.Parser=void 0,this.attachers=[],this.compiler=void 0,this.freezeIndex=-1,this.frozen=void 0,this.namespace={},this.parser=void 0,this.transformers=Yg()}copy(){const t=new Qi;let n=-1;for(;++n<this.attachers.length;){const r=this.attachers[n];t.use(...r)}return t.data(Rr(!0,{},this.namespace)),t}data(t,n){return typeof t=="string"?arguments.length===2?(Dr("data",this.frozen),this.namespace[t]=n,this):cx.call(this.namespace,t)&&this.namespace[t]||void 0:t?(Dr("data",this.frozen),this.namespace=t,this):this.namespace}freeze(){if(this.frozen)return this;const t=this;for(;++this.freezeIndex<this.attachers.length;){const[n,...r]=this.attachers[this.freezeIndex];if(r[0]===!1)continue;r[0]===!0&&(r[0]=void 0);const i=n.call(t,...r);typeof i=="function"&&this.transformers.use(i)}return this.frozen=!0,this.freezeIndex=Number.POSITIVE_INFINITY,this}parse(t){this.freeze();const n=zn(t),r=this.parser||this.Parser;return zr("parse",r),r(String(n),n)}process(t,n){const r=this;return this.freeze(),zr("process",this.parser||this.Parser),_r("process",this.compiler||this.Compiler),n?i(void 0,n):new Promise(i);function i(o,a){const l=zn(t),u=r.parse(l);r.run(u,l,function(f,p,d){if(f||!p||!d)return c(f);const h=p,g=r.stringify(h,d);px(g)?d.value=g:d.result=g,c(f,d)});function c(f,p){f||!p?a(f):o?o(p):n(void 0,p)}}}processSync(t){let n=!1,r;return this.freeze(),zr("processSync",this.parser||this.Parser),_r("processSync",this.compiler||this.Compiler),this.process(t,i),Ss("processSync","process",n),r;function i(o,a){n=!0,xs(o),r=a}}run(t,n,r){Is(t),this.freeze();const i=this.transformers;return!r&&typeof n=="function"&&(r=n,n=void 0),r?o(void 0,r):new Promise(o);function o(a,l){const u=zn(n);i.run(t,u,c);function c(f,p,d){const h=p||t;f?l(f):a?a(h):r(void 0,h,d)}}}runSync(t,n){let r=!1,i;return this.run(t,n,o),Ss("runSync","run",r),i;function o(a,l){xs(a),i=l,r=!0}}stringify(t,n){this.freeze();const r=zn(n),i=this.compiler||this.Compiler;return _r("stringify",i),Is(t),i(t,r)}use(t,...n){const r=this.attachers,i=this.namespace;if(Dr("use",this.frozen),t!=null)if(typeof t=="function")u(t,n);else if(typeof t=="object")Array.isArray(t)?l(t):a(t);else throw new TypeError("Expected usable value, not `"+t+"`");return this;function o(c){if(typeof c=="function")u(c,[]);else if(typeof c=="object")if(Array.isArray(c)){const[f,...p]=c;u(f,p)}else a(c);else throw new TypeError("Expected usable value, not `"+c+"`")}function a(c){if(!("plugins"in c)&&!("settings"in c))throw new Error("Expected usable value but received an empty preset, which is probably a mistake: presets typically come with `plugins` and sometimes with `settings`, but this has neither");l(c.plugins),c.settings&&(i.settings=Rr(!0,i.settings,c.settings))}function l(c){let f=-1;if(c!=null)if(Array.isArray(c))for(;++f<c.length;){const p=c[f];o(p)}else throw new TypeError("Expected a list of plugins, not `"+c+"`")}function u(c,f){let p=-1,d=-1;for(;++p<r.length;)if(r[p][0]===c){d=p;break}if(d===-1)r.push([c,...f]);else if(f.length>0){let[h,...g]=f;const x=r[d][1];ni(x)&&ni(h)&&(h=Rr(!0,x,h)),r[d]=[c,h,...g]}}}}const dx=new Qi().freeze();function zr(e,t){if(typeof t!="function")throw new TypeError("Cannot `"+e+"` without `parser`")}function _r(e,t){if(typeof t!="function")throw new TypeError("Cannot `"+e+"` without `compiler`")}function Dr(e,t){if(t)throw new Error("Cannot call `"+e+"` on a frozen processor.\nCreate a new processor first, by calling it: use `processor()` instead of `processor`.")}function Is(e){if(!ni(e)||typeof e.type!="string")throw new TypeError("Expected node, got `"+e+"`")}function Ss(e,t,n){if(!n)throw new Error("`"+e+"` finished async. Use `"+t+"` instead")}function zn(e){return fx(e)?e:new hl(e)}function fx(e){return!!(e&&typeof e=="object"&&"message"in e&&"messages"in e)}function px(e){return typeof e=="string"||hx(e)}function hx(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}const mx="https://github.com/remarkjs/react-markdown/blob/main/changelog.md",Cs=[],As={allowDangerousHtml:!0},gx=/^(https?|ircs?|mailto|xmpp)$/i,xx=[{from:"astPlugins",id:"remove-buggy-html-in-markdown-parser"},{from:"allowDangerousHtml",id:"remove-buggy-html-in-markdown-parser"},{from:"allowNode",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"allowElement"},{from:"allowedTypes",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"allowedElements"},{from:"className",id:"remove-classname"},{from:"disallowedTypes",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"disallowedElements"},{from:"escapeHtml",id:"remove-buggy-html-in-markdown-parser"},{from:"includeElementIndex",id:"#remove-includeelementindex"},{from:"includeNodeIndex",id:"change-includenodeindex-to-includeelementindex"},{from:"linkTarget",id:"remove-linktarget"},{from:"plugins",id:"change-plugins-to-remarkplugins",to:"remarkPlugins"},{from:"rawSourcePos",id:"#remove-rawsourcepos"},{from:"renderers",id:"change-renderers-to-components",to:"components"},{from:"source",id:"change-source-to-children",to:"children"},{from:"sourcePos",id:"#remove-sourcepos"},{from:"transformImageUri",id:"#add-urltransform",to:"urlTransform"},{from:"transformLinkUri",id:"#add-urltransform",to:"urlTransform"}];function ml(e){const t=bx(e),n=yx(e);return wx(t.runSync(t.parse(n),n),e)}function bx(e){const t=e.rehypePlugins||Cs,n=e.remarkPlugins||Cs,r=e.remarkRehypeOptions?{...e.remarkRehypeOptions,...As}:As;return dx().use(Jm).use(n).use(Wg,r).use(t)}function yx(e){const t=e.children||"",n=new hl;return typeof t=="string"&&(n.value=t),n}function wx(e,t){const n=t.allowedElements,r=t.allowElement,i=t.components,o=t.disallowedElements,a=t.skipHtml,l=t.unwrapDisallowed,u=t.urlTransform||kx;for(const f of xx)Object.hasOwn(t,f.from)&&(""+f.from+(f.to?"use `"+f.to+"` instead":"remove it")+mx+f.id,void 0);return fl(e,c),Mp(e,{Fragment:s.Fragment,components:i,ignoreInvalidStyle:!0,jsx:s.jsx,jsxs:s.jsxs,passKeys:!0,passNode:!0});function c(f,p,d){if(f.type==="raw"&&d&&typeof p=="number")return a?d.children.splice(p,1):d.children[p]={type:"text",value:f.value},p;if(f.type==="element"){let h;for(h in Tr)if(Object.hasOwn(Tr,h)&&Object.hasOwn(f.properties,h)){const g=f.properties[h],x=Tr[h];(x===null||x.includes(f.tagName))&&(f.properties[h]=u(String(g||""),h,f))}}if(f.type==="element"){let h=n?!n.includes(f.tagName):o?o.includes(f.tagName):!1;if(!h&&r&&typeof p=="number"&&(h=!r(f,p,d)),h&&d&&typeof p=="number")return l&&f.children?d.children.splice(p,1,...f.children):d.children.splice(p,1),p}}}function kx(e){const t=e.indexOf(":"),n=e.indexOf("?"),r=e.indexOf("#"),i=e.indexOf("/");return t===-1||i!==-1&&t>i||n!==-1&&t>n||r!==-1&&t>r||gx.test(e.slice(0,t))?e:""}const wt=["ariaDescribedBy","ariaLabel","ariaLabelledBy"],Es={ancestors:{tbody:["table"],td:["table"],th:["table"],thead:["table"],tfoot:["table"],tr:["table"]},attributes:{a:[...wt,"dataFootnoteBackref","dataFootnoteRef",["className","data-footnote-backref"],"href"],blockquote:["cite"],code:[["className",/^language-./]],del:["cite"],div:["itemScope","itemType"],dl:[...wt],h2:[["className","sr-only"]],img:[...wt,"longDesc","src"],input:[["disabled",!0],["type","checkbox"]],ins:["cite"],li:[["className","task-list-item"]],ol:[...wt,["className","contains-task-list"]],q:["cite"],section:["dataFootnotes",["className","footnotes"]],source:["srcSet"],summary:[...wt],table:[...wt],ul:[...wt,["className","contains-task-list"]],"*":["abbr","accept","acceptCharset","accessKey","action","align","alt","axis","border","cellPadding","cellSpacing","char","charOff","charSet","checked","clear","colSpan","color","cols","compact","coords","dateTime","dir","encType","frame","hSpace","headers","height","hrefLang","htmlFor","id","isMap","itemProp","label","lang","maxLength","media","method","multiple","name","noHref","noShade","noWrap","open","prompt","readOnly","rev","rowSpan","rows","rules","scope","selected","shape","size","span","start","summary","tabIndex","title","useMap","vAlign","value","width"]},clobber:["ariaDescribedBy","ariaLabelledBy","id","name"],clobberPrefix:"user-content-",protocols:{cite:["http","https"],href:["http","https","irc","ircs","mailto","xmpp"],longDesc:["http","https"],src:["http","https"]},required:{input:{disabled:!0,type:"checkbox"}},strip:["script"],tagNames:["a","b","blockquote","br","code","dd","del","details","div","dl","dt","em","h1","h2","h3","h4","h5","h6","hr","i","img","input","ins","kbd","li","ol","p","picture","pre","q","rp","rt","ruby","s","samp","section","source","span","strike","strong","sub","summary","sup","table","tbody","td","tfoot","th","thead","tr","tt","ul","var"]},ht={}.hasOwnProperty;function vx(e,t){let n={type:"root",children:[]};const r={schema:t?{...Es,...t}:Es,stack:[]},i=gl(r,e);return i&&(Array.isArray(i)?i.length===1?n=i[0]:n.children=i:n=i),n}function gl(e,t){if(t&&typeof t=="object"){const n=t;switch(typeof n.type=="string"?n.type:""){case"comment":return jx(e,n);case"doctype":return Nx(e,n);case"element":return Ix(e,n);case"root":return Sx(e,n);case"text":return Cx(e,n)}}}function jx(e,t){if(e.schema.allowComments){const n=typeof t.value=="string"?t.value:"",r=n.indexOf("-->"),o={type:"comment",value:r<0?n:n.slice(0,r)};return bn(o,t),o}}function Nx(e,t){if(e.schema.allowDoctypes){const n={type:"doctype"};return bn(n,t),n}}function Ix(e,t){const n=typeof t.tagName=="string"?t.tagName:"";e.stack.push(n);const r=xl(e,t.children),i=Ax(e,t.properties);e.stack.pop();let o=!1;if(n&&n!=="*"&&(!e.schema.tagNames||e.schema.tagNames.includes(n))&&(o=!0,e.schema.ancestors&&ht.call(e.schema.ancestors,n))){const l=e.schema.ancestors[n];let u=-1;for(o=!1;++u<l.length;)e.stack.includes(l[u])&&(o=!0)}if(!o)return e.schema.strip&&!e.schema.strip.includes(n)?r:void 0;const a={type:"element",tagName:n,properties:i,children:r};return bn(a,t),a}function Sx(e,t){const r={type:"root",children:xl(e,t.children)};return bn(r,t),r}function Cx(e,t){const r={type:"text",value:typeof t.value=="string"?t.value:""};return bn(r,t),r}function xl(e,t){const n=[];if(Array.isArray(t)){const r=t;let i=-1;for(;++i<r.length;){const o=gl(e,r[i]);o&&(Array.isArray(o)?n.push(...o):n.push(o))}}return n}function Ax(e,t){const n=e.stack[e.stack.length-1],r=e.schema.attributes,i=e.schema.required,o=r&&ht.call(r,n)?r[n]:void 0,a=r&&ht.call(r,"*")?r["*"]:void 0,l=t&&typeof t=="object"?t:{},u={};let c;for(c in l)if(ht.call(l,c)){const f=l[c];
20let p=Ts(e,Ps(o,c),c,f);p==null&&(p=Ts(e,Ps(a,c),c,f)),p!=null&&(u[c]=p)}if(i&&ht.call(i,n)){const f=i[n];for(c in f)ht.call(f,c)&&!ht.call(u,c)&&(u[c]=f[c])}return u}function Ts(e,t,n,r){return t?Array.isArray(r)?Ex(e,t,n,r):bl(e,t,n,r):void 0}function Ex(e,t,n,r){let i=-1;const o=[];for(;++i<r.length;){const a=bl(e,t,n,r[i]);(typeof a=="number"||typeof a=="string")&&o.push(a)}return o}function bl(e,t,n,r){if(!(typeof r!="boolean"&&typeof r!="number"&&typeof r!="string")&&Tx(e,n,r)){if(typeof t=="object"&&t.length>1){let i=!1,o=0;for(;++o<t.length;){const a=t[o];if(a&&typeof a=="object"&&"flags"in a){if(a.test(String(r))){i=!0;break}}else if(a===r){i=!0;break}}if(!i)return}return e.schema.clobber&&e.schema.clobberPrefix&&e.schema.clobber.includes(n)?e.schema.clobberPrefix+r:r}}function Tx(e,t,n){const r=e.schema.protocols&&ht.call(e.schema.protocols,t)?e.schema.protocols[t]:void 0;if(!r||r.length===0)return!0;const i=String(n),o=i.indexOf(":"),a=i.indexOf("?"),l=i.indexOf("#"),u=i.indexOf("/");if(o<0||u>-1&&o>u||a>-1&&o>a||l>-1&&o>l)return!0;let c=-1;for(;++c<r.length;){const f=r[c];if(o===f.length&&i.slice(0,f.length)===f)return!0}return!1}function bn(e,t){const n=Ba(t);t.data&&(e.data=un(t.data)),n&&(e.position=n)}function Ps(e,t){let n,r=-1;if(e)for(;++r<e.length;){const i=e[r],o=typeof i=="string"?i:i[0];if(o===t)return i;o==="data*"&&(n=i)}if(t.length>4&&t.slice(0,4).toLowerCase()==="data")return n}function yl(e){return function(t){return vx(t,e)}}function Px({blocks:e}){const t=cn(e),n=dn(),r=ae(i=>i.narrowSlot);return t!=null&&t.plan?t.plan.approvedAt?s.jsxs("p",{"data-slot":"plan-approved-note",className:"mt-3 flex items-center gap-1.5 border-t border-border pt-3 text-2xs font-semibold text-muted-foreground",children:[s.jsx(rn,{size:13,weight:"fill",className:"shrink-0 text-success"}),"Plan approved"]}):s.jsxs("div",{className:"mt-3 flex flex-col gap-2 border-t border-border pt-3",children:[s.jsxs("button",{type:"button","data-slot":"plan-approve",onClick:()=>{n.mutate({canvasId:t.canvasId,blockId:t.id,patch:{plan:{...t.plan,approvedAt:new Date().toISOString()}}}),r()},className:"flex w-full items-center justify-center gap-1.5 rounded-md bg-primary px-2 py-1.5 text-xs font-semibold text-primary-foreground transition-opacity hover:opacity-90",children:[s.jsx(rn,{size:14,weight:"fill"}),"Approve"]}),s.jsx("p",{className:"text-2xs leading-relaxed text-muted-foreground/70",children:"Nothing generates. Approving moves the run on and hands the width back to the canvas."})]}):null}function Mx({blocks:e}){const t=cn(e),n=(t==null?void 0:t.plan)??null;return n?s.jsxs("div",{"data-slot":"gooh-studio-plan-document",className:"flex flex-col gap-2 text-xs leading-relaxed text-foreground",children:[s.jsx(ml,{rehypePlugins:[yl],components:{h1:({children:r})=>s.jsx("h3",{className:"mt-3 text-lg font-semibold text-foreground",children:r}),h2:({children:r})=>s.jsx("h4",{className:"mt-3 text-xs font-semibold text-foreground",children:r}),h3:({children:r})=>s.jsx("h5",{className:"mt-2 text-xs font-medium text-muted-foreground",children:r}),p:({children:r})=>s.jsx("p",{className:"text-xs leading-relaxed",children:r}),ul:({children:r})=>s.jsx("ul",{className:"flex list-disc flex-col gap-1 pl-4 text-xs",children:r}),ol:({children:r})=>s.jsx("ol",{className:"flex list-decimal flex-col gap-1 pl-4 text-xs",children:r}),li:({children:r})=>s.jsx("li",{className:"leading-relaxed",children:r}),strong:({children:r})=>s.jsx("strong",{className:"font-semibold",children:r}),code:({children:r})=>s.jsx("code",{className:"rounded bg-muted px-1 py-0.5 font-mono text-2xs",children:r}),blockquote:({children:r})=>s.jsx("blockquote",{className:"border-l-2 border-border pl-2 text-2xs italic text-muted-foreground",children:r}),a:({children:r,href:i})=>s.jsx("a",{href:i,target:"_blank",rel:"noopener noreferrer",className:"text-primary underline",children:r})},children:n.markdown}),s.jsx(Px,{blocks:e})]}):s.jsx("p",{className:"text-xs leading-relaxed text-muted-foreground",children:t?"The plan is being written. It opens here as soon as it is ready.":"This run has not been started yet."})}function Ms({id:e,blocks:t,conversationId:n}){switch(e){case"chat":return s.jsx(Ff,{conversationId:n});case"plan":return s.jsx(Mx,{blocks:t});case"brand":return s.jsx(Mf,{})}}function wl({width:e,onResize:t,onDraggingChange:n,label:r="Resize the panel"}){const[i,o]=m.useState(!1),a=m.useRef(null),l=m.useCallback(p=>{o(p),n==null||n(p)},[n]),u=m.useCallback(p=>{p.preventDefault(),p.stopPropagation(),p.currentTarget.setPointerCapture(p.pointerId),a.current={startX:p.clientX,startWidth:e},l(!0)},[e,l]),c=m.useCallback(p=>{const d=a.current;d&&t(Pu(d.startWidth-(p.clientX-d.startX)))},[t]),f=m.useCallback(p=>{p.currentTarget.hasPointerCapture(p.pointerId)&&p.currentTarget.releasePointerCapture(p.pointerId),a.current=null,l(!1)},[l]);return s.jsx("div",{role:"separator","aria-orientation":"vertical","aria-label":r,"data-slot":"slot-resize-handle","data-dragging":i?"true":void 0,onPointerDown:u,onPointerMove:c,onPointerUp:f,onPointerCancel:f,className:"group absolute inset-y-0 -left-1.5 z-10 w-3 cursor-col-resize touch-none",children:s.jsx("span",{"aria-hidden":"true",className:G("absolute inset-y-3 left-1/2 w-px -translate-x-1/2 roun
20ded-full bg-border/0 transition-colors","group-hover:bg-border",i&&"bg-primary/60 group-hover:bg-primary/60")})})}function Rx({blocks:e,conversationId:t}){const n=Gs(),r=ae(p=>p.slotWidth),i=ae(p=>p.setSlotWidthByUser),o=ae(p=>p.closeChat),a=ae(p=>p.closePanel),[l,u]=m.useState(!1);if(!n)return null;const c=Mu[n],f=c.behaviour==="dismissible";return s.jsxs("section",{"data-slot":"gooh-studio-panel-slot","data-panel":c.id,"data-behaviour":c.behaviour,style:{width:r},className:G("pointer-events-auto relative flex min-h-0 shrink-0 flex-col overflow-hidden rounded-2xl bg-surface-floating","self-stretch",!l&&"transition-[width] duration-300 ease-out",f&&"z-20 shadow-2xl ring-1 ring-border",!f&&"shadow-panel"),children:[s.jsx(wl,{width:r,onResize:i,onDraggingChange:u}),s.jsxs("header",{className:"flex h-11 shrink-0 items-center gap-2 px-3",children:[s.jsx("h2",{className:"min-w-0 flex-1 truncate text-xs font-semibold text-foreground",children:c.title}),s.jsx("button",{type:"button",onClick:()=>c.behaviour==="persistent"?o():a(c.id),"data-slot":"gooh-studio-panel-close","aria-label":`Close ${c.title}`,title:`Close ${c.title}`,className:"flex size-6 shrink-0 items-center justify-center rounded-full text-muted-foreground outline-none transition-colors hover:bg-muted hover:text-foreground focus-visible:ring-2 focus-visible:ring-sidebar-ring",children:s.jsx(ut,{size:13,weight:"bold"})})]}),c.fills?s.jsx(Ms,{id:c.id,blocks:e,conversationId:t}):s.jsxs("div",{className:"min-h-0 flex-1 overflow-y-auto p-3",children:[c.blurb&&s.jsx("p",{className:"mb-2 text-2xs leading-relaxed text-muted-foreground/80",children:c.blurb}),s.jsx(Ms,{id:c.id,blocks:e,conversationId:t})]})]})}function Lx({blocks:e,open:t,onOpenChange:n}){const r=Ys(),i=()=>{e.forEach(o=>r.mutate({canvasId:o.canvasId,blockId:o.id})),n(!1)};return s.jsx(re.Root,{open:t,onOpenChange:n,children:s.jsxs(re.Content,{children:[s.jsxs(re.Header,{children:[s.jsx(re.Title,{children:"Discard this run?"}),s.jsx(re.Description,{children:e.length===1?"This removes the one block in this run, along with the request and the plan it carries.":`This removes all ${e.length} blocks in this run, along with the request and the plan the opening carries.`})]}),s.jsx("p",{className:"text-2xs leading-relaxed text-muted-foreground",children:"The canvas goes back to empty and you can start again. Nothing was generated, so nothing is lost that a re-run would not reproduce."}),s.jsxs(re.Actions,{children:[s.jsx(re.Cancel,{children:"Keep it"}),s.jsx(re.Action,{variant:"destructive",onClick:o=>{o.preventDefault(),i()},children:"Discard"})]})]})})}const Rs=["model","ratio","variations"];function Ze({label:e}){return s.jsx("span",{className:"text-2xs font-medium text-muted-foreground",children:e})}function $t({label:e,selected:t,onClick:n,title:r}){return s.jsx("button",{type:"button",onClick:n,"aria-pressed":t,title:r,"data-slot":"field-chip",className:G("rounded px-1.5 py-0.5 text-2xs font-medium transition-colors","outline-none focus-visible:ring-2 focus-visible:ring-sidebar-ring",t?"bg-foreground text-background":"bg-muted/50 text-muted-foreground hover:bg-muted hover:text-foreground"),children:e})}function Ox({field:e,value:t,onChange:n}){return s.jsxs("div",{className:"flex flex-col gap-1",children:[s.jsx(Ze,{label:e.label,hint:e.hint}),s.jsx("div",{className:"flex flex-wrap gap-1",children:e.choices.map(r=>s.jsx($t,{label:r,selected:r===t,onClick:()=>n(r)},r))})]})}function Fx({field:e,value:t,onChange:n}){const r=nr(e.catalogue),i=Vt(t),o=a=>{if(!e.multiple){n(a);return}n(i.includes(a)?i.filter(l=>l!==a):[...i,a])};return s.jsxs("div",{className:"flex flex-col gap-1",children:[s.jsx(Ze,{label:e.multiple?`${e.label} (any number)`:e.label,hint:e.hint}),s.jsx("div",{className:"flex flex-wrap gap-1",children:r.entries.map(a=>s.jsx($t,{label:a.name,title:a.description,selected:i.includes(a.id),onClick:()=>o(a.id)},a.id))})]})}function zx({field:e,value:t,onChange:n}){const r="w-full rounded-lg border border-border bg-background px-2 py-1.5 text-xs text-foreground placeholder:text-muted-foreground/60 outline-none focus-visible:ring-2 focus-visible:ring-sidebar-ring";return s.jsxs("div",{className:"flex flex-col gap-1",children:[s.jsx(Ze,{label:e.label,hint:e.hint}),e.multiline?s.jsx("textarea",{rows:3,value:t,onChange:i=>n(i.target.value),placeholder:e.placeholder,"aria-label":e.label,className:G(r,"resize-none leading-relaxed")}):s.jsx("input",{value:t,onChange:i=>n(i.target.value),placeholder:e.placeholder,"aria-label":e.label,className:r})]})}function kl({names:e,onRemove:t}){return e.length===0?null:s.jsx("ul",{className:"flex flex-col gap-0.5",children:e.map(n=>s.jsxs("li",{className:"flex items-center gap-1.5 rounded bg-muted/60 px-1.5 py-1 text-2xs",children:[s.jsx(pn,{size:11,className:"shrink-0 text-muted-foreground"}),s.jsx("span",{className:"min-w-0 flex-1 truncate text-foreground",children:n}),s.jsx("button",{type:"button",onClick:()=>t(n),"aria-label":`Remove ${n}`,className:"shrink-0 rounded text-muted-foreground transition-colors hover:text-foreground",children:s.jsx(ut,{size:11})})]},n))})}function _x({field:e,value:t,onChange:n}){const r=Vt(t);return s.jsxs("div",{className:"flex flex-col gap-1",children:[s.jsx(Ze,{label:e.label,hint:e.hint}),s.jsx(kl,{names:r,onRemove:i=>n(r.filter(o=>o!==i))}),s.jsxs("label",{className:G("flex cursor-pointer items-center justify-center gap-1.5 rounded-lg border border-dashed border-border","px-2 py-1.5 text-2xs font-semibold text-muted-foreground transition-colors","hover:border-primary/40 hover:bg-muted hover:text-foreground"),children:[s.jsx(pn,{size:12}),r.length?"Choose another":"Choose a file",s.jsx("input",{type:"file",accept:e.accept,multiple:e.multiple,className:"hidden",onChange:i=>{const o=Array.from(i.target.files??[]).map(a=>a.name);o.length!==0&&(n(e.multiple?[...new Set([...r,...o])]:o.slice(0,1)),i.target.value="")}})]})]})}function Dx({field:e,values:t,onChange:n}){const[r,i]=m.useState(null);return s.jsxs("div",{className:"flex flex-col gap-1",children:[s.jsx(Ze,{label:e.label,hint:e.hint}),s.jsx("div",{className:"flex flex-col gap-1 overflow-hidden rounded-lg border border-border",children:e.sections.map((o,a)=>{var p;const l=nr(o.catalogue),u=Vt(t[o.id])[0],c=((p=l.entries.find(d=>d.id===u))==null?void 0:p.name)??"â",f=r===o.id;return s.jsxs("div",{className:a>0?"border-t border-border":void 0,children:[s.jsxs("button",{type:"button",onClick:()=>i(f?null:o.id),"aria-expanded":f,"data-slot":"config-section","data-section":o.id,"data-open":f?"true":void 0,className:"flex w-full items-center gap-2 px-2 py-1.5 text-left transition-colors hover:bg-muted",children:[s.jsx("span",{className:"min-w-0 flex-1 truncate text-2xs font-semibold text-muted-foreground",children:o.label}),s.jsx("span",{className:"min-w-0 shrink truncate text-xs text-foreground",children:c}),s.jsx(tn,{size:11,className:G("shrink-0 text-muted-foreground transition-transform",f&&"rotate-180")}
20)]}),f&&s.jsx("div",{className:"flex flex-wrap gap-1 px-2 pb-2",children:l.entries.map(d=>s.jsx($t,{label:d.name,title:d.description,selected:d.id===u,onClick:()=>n(o.id,d.id)},d.id))})]},o.id)})})]})}function $x({models:e,value:t,onChange:n}){return s.jsxs("div",{className:"flex flex-col gap-1",children:[s.jsx(Ze,{label:"Model"}),s.jsx("select",{"aria-label":"Model","data-slot":"field-model",value:t,onChange:r=>n(r.target.value),className:G("w-full rounded-md border border-border bg-transparent px-1.5 py-1","text-2xs font-medium text-foreground","outline-none focus-visible:ring-2 focus-visible:ring-sidebar-ring"),children:e.map(r=>s.jsx("option",{value:r.id,className:"bg-popover text-foreground",children:`${Ht("model",r.id)} · ${r.price}`},r.id))})]})}function Bx(e){return!e||e.aspectRatio==="ignore"?null:e.aspectRatio==="refuse"?e.supportedRatios??[]:nr("ratio").entries.map(t=>t.id)}function fr(e,t){var r;const n=(t==null?void 0:t.models)??[];return typeof e.model=="string"&&n.some(i=>i.id===e.model)?e.model:((r=n[0])==null?void 0:r.id)??""}function It({type:e,values:t,onChange:n,capability:r,only:i}){const o=n,a=(r==null?void 0:r.models)??[],l=fr(t,r),u=a.find(d=>
20d.id===l),c=r?Bx(u):null,f=r==null?void 0:r.bounds.variations,p=(f==null?void 0:f.kind)==="values"?f.values:null;return s.jsx(s.Fragment,{children:e.fields.filter(d=>i===void 0?!0:i==="primary"?d.primary===!0:!d.primary).map(d=>{if(r&&d.id==="model")return a.length>0?s.jsx($x,{models:a,value:l,onChange:h=>o("model",h)},d.id):null;if(r&&d.id==="ratio")return!c||c.length===0?null:s.jsxs("div",{className:"flex flex-col gap-1",children:[s.jsx(Ze,{label:"Ratio"}),s.jsx("div",{className:"flex flex-wrap gap-1",children:c.map(h=>s.jsx($t,{label:h,selected:t.ratio===h,onClick:()=>o("ratio",h)},h))})]},d.id);if(r&&d.id==="variations")return!p||p.length===0?null:s.jsxs("div",{className:"flex flex-col gap-1",children:[s.jsx(Ze,{label:"Variations"}),s.jsx("div",{className:"flex flex-wrap gap-1",children:p.map(h=>s.jsx($t,{label:String(h),selected:t.variations===String(h),onClick:()=>o("variations",String(h))},h))})]},d.id);switch(d.kind){case"choice":return s.jsx(Ox,{field:d,value:typeof t[d.id]=="string"?t[d.id]:d.defaultChoice,onChange:h=>o(d.id,h)},d.id);case"catalogue":return s.jsx(Fx,{field:d,value:t[d.id],onChange:h=>o(d.id,h)},d.id);case"text":return s.jsx(zx,{field:d,value:typeof t[d.id]=="string"?t[d.id]:"",onChange:h=>o(d.id,h)},d.id);case"file":return s.jsx(_x,{field:d,value:t[d.id],onChange:h=>o(d.id,h)},d.id);case"sections":return s.jsx(Dx,{field:d,values:t,onChange:o},d.id)}})})}const Vx={all:["studio-offer"]};function pr(){const{studioApi:e}=Ke(),{data:t,isLoading:n,error:r}=ui({queryKey:Vx.all,queryFn:()=>e.offer(),staleTime:1/0,gcTime:1/0});return m.useMemo(()=>{const i=(t==null?void 0:t.operations)??[],o=(u,c)=>{var f;return(f=i.find(p=>p.id===u))==null?void 0:f.models.find(p=>p.id===c)},a=u=>i.find(c=>c.id===u);return{unavailable:!!r||!n&&t===void 0,offer:t??null,operations:i,operation:a,modelsFor:u=>{var c;return((c=a(u))==null?void 0:c.models)??[]},pairing:o,isLoading:n,error:r}},[t,n,r])}async function Hx(e){const t=await Ux(e);return t||(typeof Image>"u"?null:new Promise(n=>{const r=setTimeout(()=>n(null),vl),i=a=>{clearTimeout(r),n(a)},o=new Image;o.onload=()=>i({width:o.naturalWidth,height:o.naturalHeight}),o.onerror=()=>i(null),o.src=e}))}const vl=8e3;async function Ux(e){return typeof document>"u"?null:new Promise(t=>{const n=document.createElement("video"),r=setTimeout(()=>i(null),vl),i=o=>{clearTimeout(r),n.removeAttribute("src"),t(o)};n.preload="metadata",n.onloadedmetadata=()=>i(n.videoWidth>0?{width:n.videoWidth,height:n.videoHeight}:null),n.onerror=()=>i(null),n.src=e})}function qx(e){var n;const t=(n=e==null?void 0:e.body)==null?void 0:n.unsatisfied;return Array.isArray(t)?t.filter(r=>typeof r=="string"):[]}function Zx(e){var i,o,a,l;const t=e,n=(i=t==null?void 0:t.body)==null?void 0:i.kind,r=(a=(o=t==null?void 0:t.body)==null?void 0:o.projected)==null?void 0:a.credits;return n==="insufficient-credits"?"There are not enough credits on this account to start that run. Nothing was charged.":n==="acknowledgement-required"||n==="acknowledgement-stale"?typeof r=="number"?`That run costs ${r} credits and needs confirming before it can start. Nothing was charged.`:"That run needs confirming before it can start. Nothing was charged.":n==="not-offered"?"That operation is not available with the model it was asked for. Nothing was charged.":n==="debit-failed"?((l=t==null?void 0:t.body)==null?void 0:l.charged)==="no"?"The charge for that run did not go through, so it was not started. Nothing was charged.":"The charge for that run could not be completed, so it was not started. Whether it was charged is not yet established â check your balance before trying again.":n==="unpriced"?"That run has no price on this server, so it was not started. Nothing was charged.":(t==null?void 0:t.status)===404?"This operation is not available on the server this app is talking to. Nothing was charged â the request never reached a studio.":(t==null?void 0:t.status)===401?"Your session is no longer valid, so the run was not attempted. Nothing was charged.":"The run was refused before it started. Nothing was charged."}function jl(){const{studioApi:e,canvasApi:t}=Ke(),n=Bt(),r=ae(l=>l.markFailed),i=ae(l=>l.clearFailed),o=m.useCallback(l=>e.quote(l),[e]),a=m.useCallback(async l=>{var V,H;const{canvasId:u,blockId:c,request:f,label:p,config:d}=l;i(c);const h=async E=>{try{await t.updateBlock(u,c,{state:E})}catch{}};await h("running");let g;
20try{g=await e.run(f)}catch(E){await h("placeholder");const B=qx(E);r(c,{message:B.length?`That run needs ${B.length} more answer${B.length>1?"s":""} before it can start. Nothing was charged.`:Zx(E),refunded:!1});return}const x=g.results.filter(E=>E.status==="succeeded");if(x.length===0){await h("complete"),r(c,{message:`Nothing came back from this run, and it was charged. The full reason is on the run record â ask for run ${g.runId}.`,refunded:!1}),n.invalidateQueries({queryKey:Ot.list(u)});return}const C=new Date().toISOString(),v={kind:"generated",source:g.modelId,recordedAt:C},k=x.flatMap(E=>E.outputs.map(B=>({src:B,stampedWith:E.stampedWith,callId:E.callId??null}))),j=g.results.filter(E=>E.status==="failed").map(E=>E.stampedWith?String(E.stampedWith.value):null).filter(E=>E!==null),R=x.length===1?x[0].callId??null:null;if(k.length===0){await h("complete"),r(c,{message:"The run completed and no artefact was found where this model declares one. Nothing was saved, and the run was charged.",refunded:!1}),n.invalidateQueries({queryKey:Ot.list(u)});return}const z=k.length===1?k[0]:null,N=await Promise.all(k.map(E=>Hx(E.src)));try{await t.appendVariant(u,c,{label:p.slice(0,60)||"Run",ratio:l.ratio??null,studioCallId:R,provenance:v,config:d??null,media:z?{src:z.src,width:((V=N[0])==null?void 0:V.width)??0,height:((H=N[0])==null?void 0:H.height)??0,alt:p.slice(0,120)}:null,outputSet:z?null:{id:g.runId,...j.length?{missedTargets:j}:{},items:k.map((E,B)=>{var A,P;return{id:`${g.runId}-${B+1}`,...E.callId?{studioCallId:E.callId}:{},target:E.stampedWith?String(E.stampedWith.value):`Output ${B+1}`,provenance:v,media:{src:E.src,width:((A=N[B])==null?void 0:A.width)??0,height:((P=N[B])==null?void 0:P.height)??0,alt:p.slice(0,120)}}})}})}catch{await h("complete"),r(c,{message:`The run succeeded and was charged, but its ${k.length} output(s) could not be saved to this block. Do not run it again â that would charge a second time. The outputs are in the run record under ${g.runId}.`,refunded:!1}),n.invalidateQueries({queryKey:Ot.list(u)});return}if(await h("complete"),g.recordingFailure)r(c,{message:`The outputs are saved. Their cost was not recorded: ${g.recordingFailure}`,refunded:!1});else if(!g.allSucceeded){const E=g.results.filter(B=>B.status==="failed");r(c,{message:`${x.length} of ${g.results.length} succeeded. ${E.length} failed and were not charged for separately.`,refunded:!1})}n.invalidateQueries({queryKey:Ot.list(u)})},[e,t,n,r,i]);return{quote:o,run:a}}function mt(e){return e.arm==="upload"?`upload:${e.uploadId}`:`variant:${e.variantId}${e.outputId?`:${e.outputId}`:""}`}function Kx(e){return e.arm==="upload"?{assetId:e.uploadId}:{variantId:e.variantId,...e.outputId?{outputId:e.outputId}:{}}}function Wx(e,t){return e.arm!=="variant"?null:t.some(r=>r.variants.some(i=>i.id===e.variantId))?e.variantId:null}function Nl(e){if(!e.set)return e.media?{media:e.media}:null;const t=e.set.items.find(n=>n.media);return t!=null&&t.media?{media:t.media,outputId:t.id}:null}function Gx(e){return e.flatMap(t=>{if(tt(t.state))return[];if(!oe(t.typeId).produces.includes("image"))return[];const n=xt(t);if(!n)return[];const r=Nl(n);return r?[{arm:"variant",variantId:n.id,...r.outputId?{outputId:r.outputId}:{},src:r.media.src,name:t.title||n.label}]:[]})}function Yx(e,t){const n=rt(e,t);if(!n)return null;if(n.kind==="item")return n.item.media?{arm:"variant",variantId:n.variant.id,outputId:n.item.id,src:n.item.media.src,name:n.block.title||n.variant.label}:null;const r=n.kind==="block"?xt(n.block):n.variant;if(!r)return null;const i=Nl(r);return i?{arm:"variant",variantId:r.id,...i.outputId?{outputId:i.outputId}:{},src:i.media.src,name:n.block.title||r.label}:null}const gt={uploads:{id:"uploads",label:"Uploads",empty:"Nothing brought in yet. Attach a file from your computer below."},creations:{id:"creations",label:"Creations",empty:"Nothing promoted yet. Accept a variant on a canvas and it lands here."},brand:{id:"brand",label:"Brand assets",empty:"Nothing filed under this client yet."},canvas:{id:"canvas",label:"This canvas",empty:"Nothing made on this canvas yet."}};function Ji({open:e,onOpenChange:t,slotLabel:n,canvasId:r,blocks:i,onPick:o}){const{canvas:a}=Jn(r??void 0),{brand:l}=pi((a==null?void 0:a.brandId)??void 0),u=(l==null?void 0:l.clientId)??null,c=m.useMemo(()=>[gt.uploads,gt.creations,u?gt.brand:null,r?gt.canvas:null].filter(h=>h!==null),[u,r]),[f,p]=m.useState("uploads");m.useEffect(()=>{var h;c.some(g=>g.id===f)||p(((h=c[0])==null?void 0:h.id)??"uploads")},[c,f]);const d=h=>{o(h),t(!1)};return s.jsx(Mt.Root,{open:e,onOpenChange:t,children:s.jsxs(Mt.Content,{"data-slot":"image-picker",className:"flex max-h-[80vh] w-full max-w-3xl flex-col",children:[s.jsxs(Mt.Header,{children:[s.jsx(Mt.Title,{children:"Choose an image"}),s.jsxs(Mt.Description,{children:["It will be used as ",s.jsx("span",{className:"font-medium text-foreground",children:n}),"."]})]}),s.jsx(Mt.Close,{}),s.jsx("div",{"data-slot":"image-picker-tabs",role:"tablist","aria-label":"Where to choose from",className:"flex shrink-0 gap-1 border-b border-border px-5",children:c.map(h=>s.jsx("button",{type:"button",role:"tab","data-tab":h.id,"aria-selected":f===h.id,onClick:()=>p(h.id),className:G("-mb-px border-b-2 px-3 py-2 text-xs font-medium transition-colors","outline-none focus-visible:ring-2 focus-visible:ring-sidebar-ring",f===h.id?"border-foreground text-foreground":"border-transparent text-muted-foreground hover:text-foreground"),children:h.label},h.id))}),s.jsxs("div",{className:"min-h-0 flex-1 overflow-y-auto p-5",children:[f==="uploads"&&s.jsx(Xx,{canvasId:r,onPick:d}),f==="creations"&&s.jsx(Qx,{onPick:d}),f==="brand"&&u&&s.jsx(Jx,{clientId:u,onPick:d}),f==="canvas"&&s.jsx(e0,{blocks:i,onPick:d})]})]})})}function Xx({canvasId:e,onPick:t}){const{uploads:n,isLoadingUploads:r}=sa({kind:"upload",ownerOnly:!0,excludeSource:sc}),i=aa(),o=n.filter(a=>!a.brandId);return s.jsxs("div",{className:"flex flex-col gap-4",children:[s.jsx(t0,{canvasId:e,onPick:t}),s.jsx(hr,{loading:r,empty:gt.uploads.empty,items:o.map(a=>({picked:{arm:"upload",uploadId:a.id,src:i(a),name:a.name}})),onPick:t})]})}function Qx({onPick:e}){const{creations:t,isLoadingCreations:n}=Qu({kind:"image"}),r=Ju(),i=t.filter(o=>o.blockVariantId!==null);return s.jsx(hr,{loading:n,empty:gt.creations.empty,items:i.map(o=>({picked:{arm:"variant",variantId:o.blockVariantId,src:r(o),name:o.name}})),onPick:e})}function Jx({clientId:e,onPick:t}){const{uploads:n,isLoadingUploads:r}=sa({kind:"upload",clientId:e}),i=aa();return s.jsx(hr,{loading:r,empty:gt.brand.empty,items:n.map(o=>({picked:{arm:"upload",uploadId:o.id,src:i(o),name:o.name}})),onPick:t})}function e0({blocks:e,onPick:t}){const n=m.useMemo(()=>Gx(e),[e]);return s.jsx(hr,{loading:!1,empty:gt.canvas.empty,items:n.map(r=>({picked:r})),onPick:t})}function t0({canvasId:e,onPick:t}){const{uploadApi:n}=Ke(),r=m.useRef(null),[i,o]=m.useState(!1),[a,l]=m.useState(null),u=async c=>{o(!0),l(null);try{const f=await n.upload({file:c,...e?{canvasId:e}:{}});t({arm:"upload",uploadId:f.id,src:n.contentUrl(f.id),name:f.name})}catch{l("That file could not be uploaded. Nothing was attached â try again.")}finally{o(!1)}};return s.jsxs("div",{className:"flex flex-col gap-2",children:[s.jsxs("button",{type:"button","data-slot":"picker-attach",disabled:i,onClick:()=>{var c;return(c=r.current)==null?void 0:c.click()},className:G("flex items-center justify-center gap-2 rounded-lg border border-dashed border-border","px-3 py-2 text-xs font-medium text-muted-foreground transition-colors","hover:bg-muted hover:text-foreground","outline-none focus-visible:ring-2 focus-visible:ring-sidebar-ring","disabled:cursor-not-allowed disabled:opacity-50"),children:[s.jsx(pn,{size:14}),i?"Uploadingâ¦":"Attach from your computer"]}),s.jsx("input",{ref:r,type:"file",accept:"image/*",className:"hidden",onChange:c=>{var p;const f=(p=c.target.files)==null?void 0:p[0];c.target.value="",f&&u(f)}}),a&&s.jsxs("p",{"data-slot":"picker-attach-failure",role:"alert",className:"flex items-start gap-1.5 rounded-lg bg-destructive/10 px-2 py-1.5 text-2xs text-destructive",children:[s.jsx(xu,{size:13,className:"mt-px shrink-0"}),a]})]})}function hr({loading:e,empty:t,items:n,onPick:r}){return e?s.jsx("div",{className:"grid grid-cols-3 gap-3 sm:grid-cols-4",children:Array.from({length:8}).map((i,o)=>s.jsx("div",{className:"aspect-square animate-pulse rounded-xl bg-muted"},o))}):n.length===0?s.jsx("p",{className:"py-8 text-center text-xs italic text-muted-foreground",children:t}):s.jsx("div",{"data-slot":"picker-grid",className:"grid grid-cols-3 gap-3 sm:grid-cols-4",children:n.map(({picked:i})=>s.jsxs("button",{type:"button","data-slot":"picker-tile","data-arm":i.arm,title:i.name,onClick:()=>r(i),className:G("group relative overflow-hidden rounded-xl bg-muted text-left","outline-none ring-offset-2 ring-offset-card transition-shadow","hover:ring-2 hover:ring-border focus-visible:ring-2 focus-visible:ring-sidebar-ring"),children:[s.jsx(fn,{src:i.src,alt:i.name,className:"aspect-square w-full object-cover"}),s.jsx("span",{className:"pointer-events-none absolute inset-x-0 bottom-0 bg-gradient-to-t from-black/70 to-transparent px-1.5 pb-1 pt-4 text-3xs text-white",children:s.jsx("span",{className:"block truncate",children:i.name})})]},mt(i)))})}function n0(e){return e.label!==null&&e.wireRole!=="no-vendor"}const r0=4;function Yn(e){return e.rank??"advanced"}function Ls({slot:e,value:t,unsatisfied:n,autoFocus:r,onChange:i,onPick:o}){const a=e.label??"",l=n?"text-foreground":"text-muted-foreground";if(Yn(e)==="attachment")return s.jsx(i0,{slot:e,value:t,label:a,mark:l,wanting:!!n,onChange:i,onPick:o});if(e.wireRole==="repeat")return s.jsx(Os,{label:a,mark:l,options:["1","2","4"],value:t===void 0?null:String(t),onChange:c=>i(Number.parseInt(c,10))});if(e.type==="boolean")return s.jsx(s0,{label:a,mark:l,value:t===!0,onChange:i});const u=e.allowedValues;if(u&&u.length>0){const c=t===void 0?null:String(t);return u.length<=r0?s.jsx(Os,{label:a,mark:l,options:u,value:c,onChange:i}):s.jsx(o0,{label:a,mark:l,options:u,value:c,onChange:i})}if(e.type==="number"){const c=e.minimum!==void 0&&e.maximum!==void 0,f=[c?`${e.minimum}â${e.maximum}
20`:null,e.unit??null].filter(Boolean).join(" ");return s.jsxs("label",{className:"flex items-center gap-2",children:[s.jsx("span",{className:`text-2xs ${l}`,children:a}),s.jsx("input",{type:"number",className:"w-16 rounded-md border border-border bg-background px-2 py-1 text-xs",min:e.minimum,max:e.maximum,placeholder:c?String(e.minimum):void 0,value:t===void 0?"":String(t),onChange:p=>i(p.target.value===""?void 0:Number(p.target.value))}),f&&s.jsx("span",{className:"text-2xs text-muted-foreground",children:f})]})}return s.jsxs("div",{className:"flex flex-col gap-1",children:[s.jsx("span",{className:`text-2xs font-medium ${l}`,children:a}),s.jsx("textarea",{autoFocus:r,rows:Yn(e)==="primary"?4:2,maxLength:e.maxLength,className:"resize-none rounded-lg border border-border bg-background px-2.5 py-2 text-xs leading-relaxed outline-none focus-visible:border-foreground/40",value:t===void 0?"":String(t),onChange:c=>i(c.target.value||void 0)})]})}function i0({slot:e,value:t,label:n,mark:r,wanting:i,onChange:o,onPick:a}){const l=Array.isArray(t)?t:[],u=e.maxItems!==void 0&&l.length>=e.maxItems,c=e.minItems!==void 0&&e.minItems>0&&e.minItems===e.maxItems?`${e.minItems}`:e.minItems!==void 0&&e.minItems>0?`${e.minItems}+`:e.maxItems!==void 0?`up to ${e.maxItems}`:null;return s.jsxs("div",{className:"flex flex-col gap-1.5",children:[s.jsxs("span",{className:`text-2xs font-medium ${r}`,children:[n,c&&s.jsxs("span",{className:"ml-1 font-normal text-muted-foreground",children:["· ",c]})]}),s.jsxs("div",{className:"flex flex-wrap gap-1.5",children:[l.map((f,p)=>s.jsxs("div",{className:"group relative size-14 overflow-hidden rounded-md border border-border bg-muted",children:[f.src&&s.jsx(fn,{src:f.src,alt:"",className:"size-full object-cover"}),s.jsx("button",{type:"button","aria-label":"Remove",onClick:()=>o(l.filter((d,h)=>h!==p)),className:"absolute right-0.5 top-0.5 hidden rounded-full bg-background/90 p-0.5 group-hover:block",children:s.jsx(ut,{size:10,weight:"bold"})})]},p)),!u&&s.jsx("button",{type:"button","aria-label":`Add to ${n}`,onClick:a,className:`flex size-14 items-center justify-center rounded-md border border-dashed text-muted-foreground hover:border-foreground
20/40 hover:text-foreground ${i?"border-foreground/50":"border-border"}`,children:s.jsx(_t,{size:14,weight:"bold"})})]})]})}function Os({label:e,mark:t,options:n,value:r,onChange:i}){return s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:`shrink-0 text-2xs ${t}`,children:e}),s.jsx("div",{className:"flex overflow-hidden rounded-md border border-border",children:n.map(o=>s.jsx("button",{type:"button",onClick:()=>i(o),className:`px-2 py-0.5 text-2xs ${o===r?"bg-foreground text-background":"text-foreground hover:bg-muted"}`,children:o},o))})]})}function o0({label:e,mark:t,options:n,value:r,onChange:i}){const[o,a]=m.useState(!1);return s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:`shrink-0 text-2xs ${t}`,children:e}),s.jsxs(je.Root,{open:o,onOpenChange:a,children:[s.jsx(je.Trigger,{asChild:!0,children:s.jsxs("button",{type:"button",className:"flex items-center gap-1 rounded-md border border-border px-2 py-0.5 text-2xs text-foreground hover:bg-muted",children:[r??s.jsx("span",{className:"text-muted-foreground",children:"Choose"}),s.jsx(tn,{size:9,weight:"bold"})]})}),s.jsx(je.Content,{className:"max-h-56 w-28 overflow-y-auto p-1",align:"start",children:n.map(l=>s.jsx("button",{type:"button",onClick:()=>{i(l),a(!1)},className:`block w-full rounded px-2 py-1 text-left text-2xs ${l===r?"bg-muted font-medium":"hover:bg-muted"}`,children:l},l))})]})]})}function s0({label:e,mark:t,value:n,onChange:r}){return s.jsxs("button",{type:"button",role:"switch","aria-checked":n,onClick:()=>r(!n),className:`flex items-center gap-2 text-2xs ${t}`,children:[s.jsx("span",{className:`flex h-3.5 w-6 items-center rounded-full p-0.5 transition-colors ${n?"bg-foreground":"bg-border"}`,children:s.jsx("span",{className:`size-2.5 rounded-full bg-background transition-transform ${n?"translate-x-2.5":""}`})}),e]})}function a0(e){const t=e==null?void 0:e.body,n=t==null?void 0:t.unsatisfied;return Array.isArray(n)?n.filter(r=>typeof r=="string"):[]}function l0(e){return e!==null&&typeof e=="object"&&typeof e.key=="string"&&typeof e.value=="string"}function Il({operationId:e,canvasId:t,blocks:n,onRun:r,onCancel:i,seed:o}){const{modelsFor:a,operation:l,isLoading:u}=pr(),{quote:c}=jl(),f=m.useMemo(()=>a(e).filter(I=>I.id!==null),[a,e]),[p,d]=m.useState((o==null?void 0:o.modelId)??null),[h,g]=m.useState((o==null?void 0:o.mode)??null),[x,C]=m.useState(()=>(o==null?void 0:o.slots)??{}),[v,k]=m.useState(null),[j,R]=m.useState([]),[z,N]=m.useState(!1),[V,H]=m.useState(null),E=f.find(I=>I.id===p)??null,B=(o==null?void 0:o.references)??[];m.useEffect(()=>{if(B.length===0)return;const I=((E==null?void 0:E.slots)??[]).find(W=>Yn(W)==="attachment"&&(Array.isArray(W.type)?W.type:[W.type]).some(Y=>Y==="image"||Y==="video"));I&&C(W=>{const Y=W[I.input];return Array.isArray(Y)&&Y.length>0?W:{...W,[I.input]:B.map(he=>({key:he,value:he,src:he}))}})},[E,B.length]);const A=(E==null?void 0:E.modes)??null,P=m.useMemo(()=>{var he;const I=((E==null?void 0:E.slots)??[]).filter(n0);if(!A||!h)return I;const W=new Set(A.flatMap(ye=>ye.slots.map(Te=>Te.input))),Y=new Set(((he=A.find(ye=>ye.name===h))==null?void 0:he.slots.map(ye=>ye.input))??[]);return I.filter(ye=>!W.has(ye.input)||Y.has(ye.input))},[E,A,h]),D=m.useCallback(I=>P.filter(W=>Yn(W)===I),[P]),F=P.some(I=>I.required&&x[I.input]===void 0),Z=!!(A&&A.length>0&&!h),K=(A==null?void 0:A.find(I=>I.name===h))??null,ee=!!p&&!F&&!Z&&v!==null,ne=m.useCallback(()=>Object.fromEntries(Object.entries(x).map(([I,W])=>[I,Array.isArray(W)&&W.every(l0)?W.map(({value:Y,role:he})=>he===void 0?{value:Y}:{value:Y,role:he}):W])),[x]),ue=!!p&&!Z;m.useEffect(()=>{if(!ue){k(null),R([]);return}let I=!0;const W=setTimeout(()=>{c({operationId:e,modelId:p,slots:ne(),...h?{mode:h}:{}}).then(Y=>{I&&(k(Y),R([]))}).catch(Y=>{I&&(k(null),R(a0(Y)))})},350);return()=>{I=!1,clearTimeout(W)}
20},[ue,e,p,h,ne,c]);const b=(I,W)=>{k(null),C(Y=>({...Y,[I]:W}))},Ne=typeof x.prompt=="string"?x.prompt:"Run",we=()=>{var I;return s.jsx("div",{className:"flex flex-col gap-0.5 pb-0.5",children:s.jsx("span",{className:"text-xs font-semibold text-foreground",children:(I=l(e))==null?void 0:I.label})})};if(u)return s.jsx("div",{className:"h-24 animate-pulse rounded-lg bg-muted/60"});if(!p)return s.jsxs("div",{className:"flex max-h-[70vh] flex-col gap-2 overflow-y-auto",children:[s.jsx(we,{}),s.jsx("span",{className:"text-2xs font-medium text-muted-foreground",children:"Model"}),s.jsx("div",{className:"flex flex-col gap-1",children:f.map(I=>s.jsx("button",{type:"button",onClick:()=>d(I.id),className:"rounded-lg border border-border px-3 py-2 text-left text-xs text-foreground hover:border-foreground/40 hover:bg-muted",children:I.displayName},I.id))}),s.jsx("div",{className:"flex justify-end pt-1",children:s.jsx(Nr,{variant:"ghost",size:"sm",onClick:i,children:"Cancel"})})]});const y=D("primary"),ge=D("attachment"),Ae=D("chip"),pe=D("advanced"),Se=(I,W=!1)=>s.jsx(Ls,{slot:I,value:x[I.input],unsatisfied:j.includes(I.input),autoFocus:W,onChange:Y=>b(I.input,Y),onPick:()=>H({slot:I,label:I.label??""})},I.input),Ee=I=>{const W=((K==null?void 0:K.slots)??[]).filter(Y=>Y.input===I.input&&Y.role);return W.length<=1?[Se(I)]:W.map(Y=>{const he=Array.isArray(x[I.input])?x[I.input]:[],ye=he.filter(Te=>Te.role===Y.role);return s.jsx(Ls,{slot:{...I,label:Y.label??I.label,minItems:Y.min,maxItems:Y.max},value:ye,unsatisfied:j.includes(I.input)&&ye.length<Y.min,onChange:Te=>b(I.input,[...he.filter(Me=>Me.role!==Y.role),...Array.isArray(Te)?Te:[]]),onPick:()=>H({slot:I,role:Y.role,label:Y.label??I.label??""})},`${I.input}:${Y.role}`)})},Ie=(I,W,Y)=>{const he=Array.isArray(x[I.input])?x[I.input]:[],ye=((K==null?void 0:K.slots)??[]).find(se=>se.input===I.input&&se.role===Y),Te=(ye==null?void 0:ye.max)??I.maxItems,Me=Y===void 0?he:he.filter(se=>se.role===Y);Te!==void 0&&Me.length>=Te||he.some(se=>se.key===mt(W))||b(I.input,[...he,{key:mt(W),value:W.src,src:W.src,...Y?{role:Y}:{}}])};return s.jsxs("div",{className:"flex max-h-[70vh] flex-col gap-3 overflow-y-auto overflow-x-hidden",children:[s.jsx(we,{}),s.jsxs("button",{type:"button",onClick:()=>{d(null),g(null),k(null)},className:"flex items-center gap-1 self-start text-2xs text-muted-foreground hover:text-foreground",children:[(E==null?void 0:E.displayName)??p,s.jsx(tn,{size:9,weight:"bold"})]}),A&&A.length>0&&s.jsx("div",{className:"flex flex-wrap gap-1",children:A.map(I=>s.jsx("button",{type:"button",onClick:()=>g(I.name),className:`rounded-full border px-2 py-0.5 text-2xs ${I.name===h?"border-foreground bg-foreground text-background":"border-border text-foreground hover:bg-muted"}`,children:I.label},I.name))}),y.map(I=>Se(I,!0)),ge.length>0&&s.jsx("div",{className:"flex flex-col gap-2",children:ge.flatMap(I=>Ee(I))}),Ae.length>0&&s.jsx("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1.5",children:Ae.map(I=>Se(I))}),pe.length>0&&s.jsxs("div",{className:"flex flex-col gap-2",children:[s.jsxs("button",{type:"button",onClick:()=>N(I=>!I),className:"flex items-center gap-1 self-start text-2xs text-muted-foreground hover:text-foreground",children:["Advanced",s.jsx(tn,{size:9,weight:"bold",className:z?"rotate-180":""})]}),z&&s.jsx("div",{className:"flex flex-col gap-2",children:pe.map(I=>Se(I))})]}),V&&s.jsx(Ji,{open:!0,onOpenChange:I=>!I&&H(null),slotLabel:V.label,canvasId:t,blocks:n,onPick:I=>{Ie(V.slot,I,V.role),H(null)}}),s.jsxs("div",{className:"flex justify-end gap-2 pt-1",children:[s.jsx(Nr,{variant:"ghost",size:"sm",onClick:i,children:"Cancel"}),s.jsx(Nr,{size:"sm",disabled:!ee,onClick:()=>r({modelId:p,...h?{mode:h}:{},slots:ne(),...v!=null&&v.acknowledgementRequired?{acknowledgedCredits:v.acknowledgeCredits}:{},label:Ne}),children:v?`Create · ${v.projected.credits} credits`:"Create"})]})]})}function u0(e){const t=dn();return n=>t.mutate({canvasId:e.canvasId,blockId:e.id,patch:{inputs:n.inputs,inputSlots:n.inputSlots}})}function ii(e,t){if(!e)return t;const n=e.block.title||e.block.id,r=i=>i===n?n:`${n} · ${i}`;return e.kind==="item"?r(e.item.target):e.kind==="set"?`${n} · all outputs`:e.kind==="block"?`${n} · whatever it makes`:r(e.variant.label||"variant")}function c0(e){const t=e.accepts.length===1?Ru[e.accepts[0]]:null,n=e.label.toLowerCase();return t===null||e.many||n.includes(t)?`No ${n}.`:`No ${n} ${t}.`}function Sl({block:e,canvasBlocks:t}){const n=oe(e.typeId),r=it(e),i=or(e),o=u0(e),a=tt(e.state);return r.length===0&&e.inputs.length===0?s.jsxs("p",{className:"text-2xs leading-relaxed text-muted-foreground",children:[n.label," takes no input
20s â its content comes from the file it holds, not from anything else on the canvas."]}):s.jsx("div",{className:"flex flex-col gap-2",children:i.map(l=>{const u=l.slot;return s.jsxs("div",{"data-slot":"block-input-row","data-slot-key":u==null?void 0:u.key,className:"flex flex-col gap-1 rounded-lg border border-border/70 px-2 py-1.5",children:[s.jsxs("div",{className:"flex items-center gap-1.5",children:[s.jsx("span",{className:"min-w-0 flex-1 truncate text-2xs font-semibold text-foreground",children:u?u.label:"Not in a slot"}),(u==null?void 0:u.required)&&s.jsx("span",{className:"shrink-0 text-2xs text-muted-foreground/70",children:"required"}),(u==null?void 0:u.many)&&s.jsx("span",{className:"shrink-0 text-2xs text-muted-foreground/70",children:"any number"})]}),!u&&s.jsx("p",{className:"text-2xs leading-relaxed text-muted-foreground/70",children:"Cited by this block, with no slot recorded. Nothing guesses one â place it yourself, or take it off."}),l.citations.length===0?s.jsx("p",{className:"text-2xs text-muted-foreground/60",children:c0(u)}):l.citations.map(c=>{const f=rt(t,c),p=f?oe(f.block.typeId).produces:[],d=r.filter(h=>h.key!==(u==null?void 0:u.key)&&sr(h,p));return s.jsxs("div",{className:"flex items-center gap-1.5",children:[s.jsx(ji,{size:11,className:"shrink-0 text-muted-foreground/70"}),s.jsx("span",{className:"min-w-0 flex-1 truncate text-2xs text-foreground",title:ii(f,c),children:ii(f,c)}),!a&&(d.length>0||u)&&s.jsxs("select",{"aria-label":"Move this input",value:"",onChange:h=>{const g=h.target.value;g&&o(g==="__clear"?bd(e,c):va(e,c,g))},className:"shrink-0 rounded border border-border bg-transparent px-1 py-0.5 text-2xs text-muted-foreground",children:[s.jsx("option",{value:"",children:"Moveâ¦"}),d.map(h=>s.jsx("option",{value:h.key,children:h.label},h.key)),u&&s.jsx("option",{value:"__clear",children:"Out of any slot"})]}),!a&&s.jsx("button",{type:"button",title:"Take this input off the block","aria-label":"Take this input off the block",onClick:()=>o(yd(e,c)),className:G("shrink-0 rounded p-0.5 text-muted-foreground transition-colors","hover:bg-destructive/10 hover:text-destructive"),children:s.jsx(ut,{size:11})})]},c)})]},(u==null?void 0:u.key)??"__unassigned")})})}function Cl({block:e,canvasBlocks:t}){return e.inputs.length===0?null:s.jsx("div",{className:"flex flex-col gap-0.5","data-slot":"block-made-from",children:s.jsx("ul",{className:"flex list-none flex-col gap-0.5",children:e.inputs.map(n=>{const r=rt(t,n),i=e.inputSlots[n],o=it(e).find(l=>l.key===i),a=ii(r,n);return s.jsxs("li",{className:"flex items-center gap-1.5",children:[s.jsx(ji,{size:11,className:"shrink-0 text-muted-foreground/70"}),s.jsx("span",{className:"min-w-0 flex-1 truncate text-2xs text-foreground",title:a,children:a}),s.jsx("span",{className:"shrink-0 text-2xs text-muted-foreground/70",children:o?o.label:"no slot"})]},n)})})})}function d0(e,t){return e.inputs.flatMap(n=>{const r=rt(t,n);if(!r||r.kind==="block")return[];const i=r.kind==="item"?r.item.media:r.variant.media;return i!=null&&i.src?[i.src]:[]})}function f0({block:e,canvasBlocks:t,variant:n,open:r,onOpenChange:i,onConfirm:o,onStudioRun:a}){var N,V;const{pricing:l}=oa(),{capabilityFor:u}=hn(),c=dn(),f=oe(e.typeId),p=Ur(e,n),[d,h]=m.useState(p.values),g=m.useCallback((H,E)=>{h(B=>({...B,[H]:E}))},[]),x=Hn(e),C=u(x),v=fr(d,C),k=x&&v?ia(l,`${x}@${v}`):null,j=C!=null&&C.perVariation?ba(d).variations??1:1,R=k===null?null:k*j,z=bt(e);if(z!==null){const H=e.variants.some(A=>A.media||A.set||A.document),E=ar(e,t),B=E.length===0?null:E.map(A=>A.upstream.title||oe(A.upstream.typeId).label).join(" and ");return s.jsx(re.Root,{open:r,onOpenChange:i,children:s.jsxs(re.Content,{className:"max-w-md",children:[s.jsxs(re.Header,{children:[s.jsx(re.Title,{children:B?`Run ${B} first`:H?"Run this again?":`Start ${oe(e.typeId).label.toLowerCase()}`}),s.jsx(re.Description,{children:B?`This block takes what ${B} makes, so that has to run â and one of its results has to be accepted â before this can.`:H?"A re-run is a new run. It is priced fresh below, and the values you leave are the ones it will use.":"It is priced fresh below, and the values you leave are the ones it will use."})]}),s.jsx("div",{className:"flex max-h-[min(28rem,calc(100vh-14rem))] flex-col gap-3 overflow-y-auto px-5 pb-4",children:z&&!B&&s.jsx(Il,{operationId:z,canvasId:e.canvasId,blocks:t,seed:{modelId:((N=n==null?void 0:n.provenance)==null?void 0:N.source)??null,mode:((V=n==null?void 0:n.provenance)==null?void 0:V.mode)??null,slots:(n==null?void 0:n.config)??null,references:n!=null&&n.config?void 0:d0(e,t)},onCancel:()=>i(!1),onRun:A=>{a(A),i(!1)}},(n==null?void 0:n.id)??"block")})]})})}return s.jsx(re.Root,{open:r,onOpenChange:i,children:s.jsxs(re.Content,{className:"max-w-md",children:[s.jsxs(re.Header,{children:[s.jsx(re.Title,{children:"Run this again?"}),s.jsx(re.Description,{children:p.source==="variant"?s.jsx(s.Fragment,{children:"These are the settings the attempt you are looking at was recorded with. Change any of them and the price changes with it."}):s.jsx(s.Fragment,{children:"These are the block's current settings â no attempt is selected, so there is no snapshot to replay."})})]}),s.jsxs("div",{className:"flex max-h-[min(28rem,calc(100vh-14rem))] flex-col gap-3 overflow-y-auto px-5 pb-4",children:[f.fields.length>0&&s.jsx(It,{type:f,values:d,onChange:g,capability:C}),s.jsx(Sl,{block:e,canvasBlocks:t}),s.jsxs("div",{"data-slot":"run-again-cost",className:"flex items-center gap-2 rounded-lg border border-border bg-muted/30 p-3",children:[s.jsx(vi,{size:18,weight:"duotone",className:"shrink-0 text-muted-foreground"}),R===null?s.jsx("p",{className:"text-xs leading-relaxed text-muted-foreground",children:"The price for this run has not come back yet, so it cannot be quoted."}):s.jsxs("p",{className:"text-xs leading-relaxed text-foreground",children:[s.jsx("span",{className:"text-sm font-bold tabular-nums",children:R})," tokens ·"," ",s.jsxs("span",{className:"text-muted-foreground",children:[Ht("model",v),j>1&&` · ${j} variations at ${k} each`]})]})]}),s.jsxs("p",{className:"text-2xs leading-relaxed text-muted-foreground",children:["It adds a ",s.jsx("strong",{className:"text-foreground",children:"new variant"})," to this block. Nothing on the canvas moves, and the attempt it replays is kept beside the new one."]})]}),s.jsxs(re.Actions,{children:[s.jsx(re.Cancel,{children:"Cancel"}),s.jsx(re.Action,{variant:"default",disabled:R===null,onClick:H=>{H.preventDefault(),c.mutate({canvasId:e.canvasId,blockId:e.id,patch:{config:d}}),i(!1),o(d)},children:R===null?"Run again":`Run again â ${R} credits`})]})]})})}const Xn="reshape.to-ratio";function p0({open:e,onOpenChange:t,onConfirm:n}){var p;const{pricing:r}=oa(),{capabilityFor:i}=hn(),[o,a]=m.useState([]),l=i(Xn),u=((p=l==null?void 0:l.models[0])==null?void 0:p.id)??null,c=u?ia(r,`${Xn}@${u}`):null,f=c===null?null:c*o.length;return s.jsx(re.Root,{open:e,onOpenChange:t,children:s.jsxs(re.Content,{className:"max-w-md",children:[s.jsxs(re.Header,{children:[s.jsx(re.Title,{children:"Reformat this output?"}),s.jsx(re.Description,{children:o.length===0?"Pick the shapes it should be refitted to. Each shape is its own run.":`Refitted to ${h0(o)}. Each shape is its own run.`})]}),s.jsxs("div",{className:"flex flex-col gap-3 px-5 pb-4",children:[s.jsx("div",{className:"flex flex-wrap gap-1",role:"group","aria-label":"Ratios to reformat to",children:nr("ratio").entries.map(d=>{const h=o.includes(d.id);return s.jsx("button",{type:"button","aria-pressed":h,"data-slot":"reformat-ratio","data-ratio":d.id,onClick:()=>a(g=>g.includes(d.id)?g.filter(x=>x!==d.id):[...g,d.id]),className:G("rounded-md border px-2 py-1 text-xs font-medium tabular-nums transition-colors","outline-none focus-visible:ring-2 focus-visible:ring-sidebar-ring",h?"border-primary bg-primary/10 text-primary":"border-border text-muted-foreground hover:bg-muted hover:text-foreground"),children:d.name},d.id)})}),s.jsxs("div",{"data-slot":"reformat-cost",className:"flex items-center gap-2 rounded-lg border border-border bg-muted/30 p-3",children:[s.jsx(vi,{size:18,weight:"duotone",className:"shrink-0 text-muted-foreground"}),o.length===0?s.jsx("p",{className:"text-xs leading-relaxed text-muted-foreground",children:"Nothing picked yet, so there is nothing to price."}):f===null?s.jsx("p",{className:"text-xs leading-relaxed text-muted-foreground",children:"The price for a refit has not come back yet, so it cannot be quoted."}):s.jsxs("p",{className:"text-xs leading-relaxed text-foreground",children:[s.jsx("span",{className:"text-sm font-bold tabular-nums",children:f})," tokens ·"," ",s.jsxs("span",{className:"text-muted-foreground",children:[Ht("model",u??""),o.length>1&&` · ${o.length} shapes at ${c} each`]})]})]}),s.jsxs("p",{className:"text-2xs leading-relaxed text-muted-foreground",children:["It adds a ",s.jsx("strong",{className:"text-foreground",children:"new block"})," to the canvas, made from this output. Every shape is kept â there is nothing to pick between â and the block you are looking at is untouched."]})]}),s.jsxs(re.Actions,{children:[s.jsx(re.Cancel,{children:"Cancel"}),s.jsx(re.Action,{variant:"default",disabled:f===null||o.length===0,onClick:d=>{d.preventDefault(),t(!1),n(o)},children:f===null||o.length===0?"Reformat":`Reformat â ${f} credits`})]})]})})}function h0(e){return e.length===0?"no shapes":e.length===1?e[0]:`${e.slice(0,-1).join(", ")} and ${e.at(-1)}`}const eo=["flex min-h-7 w-full items-center gap-2.5 rounded-xl px-2.5 py-1.5 text-left transition-colors","outline-none hover:bg-muted focus-visible:ring-2 focus-visible:ring-sidebar-ring"].join(" ");function Al({selected:e,onRun:t,onRunFlow:n}){const{operations:r}
20=pr(),i=m.useMemo(()=>{const p=new Set(r.map(d=>d.id));return Sd(d=>p.has(d))},[r]),[o,a]=m.useState(null),[l,u]=m.useState("right"),c=m.useRef(null),f=m.useRef(null);return s.jsxs("div",{className:"flex flex-col",children:[Td.map((p,d)=>{const h=i.filter(g=>g.band===p);return h.length===0?null:s.jsxs("div",{"data-operation-band":p,children:[d>0&&s.jsx(Vr,{}),h.map(g=>{const x=g.options.length>0,C=x&&o===g.id,v=s.jsx(m0,{op:g,selected:e,side:l,hasFlyout:x,expanded:x?C:void 0,onPress:k=>{var j;if(x){u(Tl(k.currentTarget)),a(C?null:g.id);return}if(g.picks==="file"){f.current=g,(j=c.current)==null||j.click();return}t(g,null)}});return s.jsx("div",{children:x?s.jsx(Ml,{open:C,onOpenChange:k=>a(k?g.id:null),side:l,options:g.options,onPick:k=>{a(null),t(g,{pick:"operation",option:k})},children:v}):v},g.id)})]},p)}),Ro.length>0&&s.jsxs("div",{"data-operation-band":"flow",children:[s.jsx(Vr,{}),s.jsx(Xs,{children:"Flows"}),Ro.map(p=>s.jsx(b0,{flow:p,onPress:()=>n(p)},p.id))]}),s.jsx("input",{ref:c,type:"file",accept:md,className:"hidden",onChange:p=>{var g;const d=(g=p.target.files)==null?void 0:g[0];p.target.value="";const h=f.current;f.current=null,d&&h&&t(h,{pick:"file",file:d})}})]})}function m0({op:e,selected:t,side:n,hasFlyout:r,expanded:i,onPress:o}){const a=e.icon,l=Ca(Kn(zi(e),Fi(e,null),t));return s.jsxs("button",{type:"button",onClick:o,"aria-expanded":i,title:[e.label,l].filter(
20Boolean).join(" â "),"data-slot":"operation-item","data-operation":e.id,className:G(eo,i&&"bg-muted"),children:[s.jsx(a,{size:16,className:"shrink-0 text-muted-foreground"}),s.jsx("span",{className:"min-w-0 flex-1 truncate text-xs font-medium text-foreground",children:e.label}),s.jsx("span",{className:"shrink-0 text-2xs tabular-nums text-muted-foreground/80",children:e.shortcut}),r&&s.jsx(Pl,{side:n,open:i===!0})]})}const El="operation-flyout",g0=160,x0=12;function Tl(e){if(!e||typeof window>"u")return"right";const t=e.getBoundingClientRect();return window.innerWidth-t.right>=g0+x0?"right":"left"}function to(e){const t=e.detail.originalEvent.target;t instanceof Element&&t.closest(`[data-slot="${El}"]`)&&e.preventDefault()}function Pl({side:e,open:t}){return s.jsx(bu,{size:11,"aria-hidden":!0,className:G("shrink-0 text-muted-foreground transition-transform",(t?e:"right")==="left"&&"rotate-180")})}function Ml({open:e,onOpenChange:t,side:n,options:r,onPick:i,children:o}){return s.jsxs(je.Root,{open:e,onOpenChange:t,children:[s.jsx(je.Anchor,{children:o}),s.jsx(je.Content,{side:n,align:"start",sideOffset:2,"data-slot":El,className:"w-40 rounded-2xl p-1.5",onPointerDown:a=>a.stopPropagation(),children:r.map(a=>s.jsx("button",{type:"button",onClick:()=>i(a),"data-operation-option":a.id,className:G(eo,"text-xs"),children:s.jsx("span",{className:"min-w-0 flex-1 truncate text-foreground",children:a.label})},a.id))})]})}function b0({flow:e,onPress:t}){const n=e.steps[e.steps.length-1],r=Od(n).icon;return s.jsxs("button",{type:"button",onClick:t,"data-slot":"flow-item","data-flow":e.id,title:[e.steps.map(i=>oe(i).label).join(" â "),zd(e)].join(" â "),className:eo,children:[s.jsx(r,{size:16,className:"shrink-0 text-muted-foreground"}),s.jsx("span",{className:"min-w-0 flex-1 truncate text-xs font-medium text-foreground",children:Fd(e)})]})}const y0=["flex w-full items-center gap-2 rounded-xl px-2 py-1 text-left text-xs font-medium","text-foreground outline-none transition-colors hover:bg-muted","focus-visible:ring-2 focus-visible:ring-sidebar-ring","disabled:cursor-not-allowed disabled:text-muted-foreground/50 disabled:hover:bg-transparent"].join(" ");function w0({onRun:e}){const[t,n]=m.useState(!1),[r,i]=m.useState(null),[o,a]=m.useState("right"),l=()=>{n(!1),i(null)};return s.jsxs(je.Root,{open:t,onOpenChange:u=>{n(u),u||i(null)},children:[s.jsx(je.Anchor,{children:s.jsx(at,{label:"Create",active:t,onClick:()=>n(!t),children:s.jsx(Un,{size:17})})}),s.jsx(je.Content,{side:"top",align:"center",className:"w-44 rounded-2xl p-1.5",onInteractOutside:to,children:Ed.map(u=>{const c=u.lands[0],f=Ft(c),p=f&&u.options.length>0,d=p&&r===u.id,h=s.jsxs("button",{type:"button",disabled:!f,"data-slot":"create-kind","data-kind":c,"aria-expanded":p?d:void 0,title:f?u.label:qn(c).note??`${u.label} is not wired yet.`,onClick:g=>{if(p){a(Tl(g.currentTarget)),i(d?null:u.id);return}l(),e(u,null)},className:G(y0,d&&"bg-muted"),children:[s.jsx("span",{className:"min-w-0 flex-1 truncate",children:u.label}),!f&&s.jsx("span",{className:"ml-auto shrink-0 rounded-full bg-muted px-1.5 py-0.5 text-3xs font-semibold text-muted-foreground",children:"Soon"}),p&&s.jsx(Pl,{side:o,open:d})]});return s.jsx("div",{children:p?s.jsx(Ml,{open:d,onOpenChange:g=>i(g?u.id:null),side:o,options:u.options,onPick:g=>{l(),e(u,{pick:"operation",option:g})},children:h}):h},u.id)})})]})}const Rl="general",Ll=[{name:"character",icon:cc},{name:"object",icon:uc},{name:"background",icon:na}],k0=Ll.map(e=>e.name),oi=3;function v0({roles:e,candidates:t,chosen:n,onToggle:r}){return e.length===0?null:s.jsxs("div",{className:"flex flex-col gap-2",children:[s.jsx(Ze,{label:"References",hint:"Things to work from, without being the subject."}),t.length===0?s.jsx("p",{className:"text-2xs italic text-muted-foreground/70",children:"Nothing in this run to reference yet â bring an image in first."}):e.map(i=>{const o=n.filter(a=>a.role===i.name);return s.jsxs("div",{className:"flex flex-col gap-1",children:[s.jsxs("span",{className:"text-2xs font-medium text-muted-foreground",children:[i.label,i.max>1&&` (up to ${i.max})`,i.required&&" · required"]}),s.jsx("div",{className:"flex flex-wrap gap-1",children:t.map(a=>s.jsx($t,{label:a.variantLabel,title:a.blockTitle,selected:o.some(l=>l.assetId===a.assetId),onClick:()=>r(i.name,a.assetId,i.max)},`${i.name}:${a.assetId}`))})]},i.name)})]})}function no({entries:e,footnote:t}){return s.jsxs(je.Root,{children:[s.jsx(je.Trigger,{"aria-label":"What these do",title:"What these do",className:G("flex size-6 shrink-0 items-center justify-center rounded-md text-muted-foreground
20/70","outline-none transition-colors hover:bg-muted hover:text-foreground","focus-visible:ring-2 focus-visible:ring-sidebar-ring"),children:s.jsx(lc,{size:14})}),s.jsxs(je.Content,{side:"top",align:"end",className:"w-72 p-3",children:[s.jsx("dl",{className:"flex flex-col gap-2",children:e.map(n=>s.jsxs("div",{children:[s.jsx("dt",{className:"text-2xs font-medium text-foreground",children:n.label}),s.jsx("dd",{className:"text-2xs leading-relaxed text-muted-foreground",children:n.hint})]},n.label))}),s.jsx("p",{className:"mt-3 border-t border-border pt-2 text-2xs leading-relaxed text-muted-foreground",children:t})]})]})}const j0=3;function N0({trail:e,children:t}){const[n,r]=m.useState(!1),i=e.slice(0,j0),o=e.length-i.length;return s.jsxs("div",{className:"flex flex-col overflow-hidden rounded-lg border border-border",children:[s.jsxs("button",{type:"button",onClick:()=>r(!n),"aria-expanded":n,"data-slot":"config-advanced","data-open":n?"true":void 0,className:G("flex w-full items-center gap-2 px-2 py-1.5 text-left transition-colors hover:bg-muted","outline-none focus-visible:ring-2 focus-visible:ring-sidebar-ring",n&&"bg-muted"),children:[s.jsx("span",{className:"shrink-0 text-2xs font-medium text-muted-foreground",children:"Advanced"}),s.jsxs("span",{className:"min-w-0 flex-1 truncate text-right text-2xs text-foreground",children:[i.join(" · "),o>0&&` +${o}`]}),s.jsx(tn,{size:11,className:G("shrink-0 text-muted-foreground transition-transform",n&&"rotate-180")})]}),n&&s.jsx("div",{className:"flex flex-col gap-3 border-t border-border p-2",children:t})]})}function I0({arity:e,label:t,candidates:n,inputs:r,toggleInput:i,sourceFiles:o,setSourceFiles:a}){return s.jsxs("div",{className:"flex flex-col gap-2",children:[s.jsx(Ze,{label:t??`Source ${e==="many"?"(any number)":"(one)"}`}),n.length===0?s.jsx("p",{className:"text-2xs italic text-muted-foreground/70",children:"Nothing in this run yet â bring something in below, or leave it empty."}):s.jsx("div",{className:"flex max-h-32 flex-col gap-0.5 overflow-y-auto",children:n.map(({block:l,variant:u})=>s.jsxs("label",{className:"flex cursor-pointer items-center gap-2 rounded px-1 py-0.5 text-xs hover:bg-muted",children:[s.jsx("input",{type:"checkbox",checked:r.includes(u.id),onChange:()=>i(u.id),className:"size-3 shrink-0 accent-foreground"}),s.jsx("span",{className:"min-w-0 flex-1 truncate text-foreground",children:u.label}),s.jsx("span",{className:"shrink-0 text-2xs text-muted-foreground",children:l.title})]},u.id))}),s.jsx(kl,{names:o,onRemove:l=>a(u=>u.filter(c=>c!==l))}),s.jsxs("label",{className:G("flex cursor-pointer items-center justify-center gap-1.5 rounded-lg border border-dashed border-border","px-2 py-1.5 text-2xs font-medium text-muted-foreground transition-colors","hover:border-border hover:bg-muted hover:text-foreground"),children:[s.jsx(pn,{size:12}),"Bring in",s.jsx("input",{type:"file",accept:"image/*,video/*",multiple:e==="many",className:"hidden",onChange:l=>{const u=Array.from(l.target.files??[]).map(c=>c.name);u.length!==0&&(a(c=>e==="many"?[...new Set([...c,...u])]:u.slice(0,1)),l.target.value="")}})]})]})}function S0({label:e,picked:t,onOpenPicker:n,onClear:r}){return s.jsxs("div",{className:"flex flex-col gap-2","data-slot":"edit-source",children:[s.jsx(Ze,{label:e}),t?s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("div",{className:G(si,"size-16 shrink-0 bg-muted"),children:s.jsx(ai,{tile:{id:mt(t),src:t.src,name:t.name},onRemove:r,className:"size-full rounded-xl"})}),s.jsxs("div",{className:"flex min-w-0 flex-1 flex-col gap-1",children:[s.jsx("span",{className:"truncate text-2xs text-foreground",title:t.name,children:t.name}),s.jsx("button",{type:"button","data-slot":"edit-source-replace",onClick:n,className:G("self-start rounded-md px-1.5 py-0.5 text-2xs font-medium text-muted-foreground","transition-colors hover:bg-muted hover:text-foreground","outline-none focus-visible:ring-2 focus-visible:ring-sidebar-ring"),children:"Choose a different image"})]})]}):s.jsxs("button",{type:"button","data-slot":"edit-source-attach","aria-haspopup":"dialog",onClick:n,className:G("flex items-center justify-center gap-1.5 rounded-lg border border-dashed border-border","px-2 py-3 text-2xs font-medium text-muted-foreground transition-colors","hover:border-border hover:bg-muted hover:text-foreground","outline-none focus-visible:ring-2 focus-visible:ring-sidebar-ring"),children:[s.jsx(pn,{size:12}),"Choose an image"]})]})}function Ol(e,t){return Nt(e).some(n=>{if(n.kind==="text"&&n.required){const r=t[n.id];return typeof r!="string"||!r.trim()}return n.kind==="file"&&n.required?Vt(t[n.id]).length===0:!1})}function C0(e,t){const n=Nt(e).find(i=>i.primary),r=n?t[n.id]:void 0;return typeof r=="string"?r:""}
20function ro(e,t){return e?"Start the run":t!==void 0?"Run this step":"Add to canvas"}function io(e,t){return e?"Nothing generates. The request goes to the transcript and a plan follows on a timer.":t!==void 0?"Nothing generates. This runs the block already on the canvas.":"Nothing generates. The block lands empty and fills in on a timer."}function Fl(e,t){return[{label:e.label,hint:e.summary},...t,...Nt(e).flatMap(n=>n.hint?[{label:n.label,hint:n.hint}]:[])]}function A0({target:e,blocks:t,canvasId:n,capability:r,opensRun:i,onCancel:o,onSubmit:a}){var B;const l=e.type,[u,c]=m.useState(()=>({...rr(l),...e.seed})),[f,p]=m.useState([]),[d,h]=m.useState(void 0),g=(A,P)=>c(D=>({...D,[A]:P})),x=fr(u,r),C=(r==null?void 0:r.roles)??[],v=A=>({id:mt(A),src:A.src,name:A.name}),k=Ll.flatMap(A=>{const P=C.find(F=>F.name===A.name);if(!P)return[];const D=f.find(F=>F.role===A.name);return[{name:A.name,label:P.label,icon:A.icon,tile:D?v(D.picked):null}]}),j=f.filter(A=>A.role===null).map(A=>v(A.picked)),R=f.length>=oi,z=(A,P)=>p(D=>D.length>=oi||D.some(F=>mt(F.picked)===mt(P))?D:[...D,{picked:P,kind:"image",role:A}]),N=A=>p(P=>P.filter(D=>mt(D.picked)!==A)),V=qc(f.map(A=>{var P;return{ref:A.picked.arm==="upload"?{assetId:A.picked.uploadId}:{variantId:A.picked.variantId,...A.picked.outputId?{outputId:A.picked.outputId}:{}},kind:A.kind,role:A.role,roleLabel:A.role?((P=C.find(D=>D.name===A.role))==null?void 0:P.label)??null:null}}),k0),H=typeof u.negativePrompt=="string"?u.negativePrompt:"",E=Ol(l,u);return s.jsxs("section",{"data-slot":"gooh-studio-config-panel","data-config-type":l.id,"data-panel":"still","data-opens-run":i?"true":void 0,className:"pointer-events-auto flex max-h-[70vh] w-80 flex-col rounded-2xl bg-surface-floating shadow-2xl ring-1 ring-border",children:[s.jsxs("header",{className:"flex shrink-0 items-center gap-1 p-3 pb-2",children:[s.jsx("h2",{className:"min-w-0 flex-1 truncate text-xs font-semibold text-foreground",children:"Create image"}),s.jsx(no,{entries:Fl(l,[{label:"References",hint:"Things to work from, without being the subject."}]),footnote:io(i,e.blockId)}),s.jsx("button",{type:"button",onClick:o,"aria-label":"Cancel",title:"Cancel",className:"flex size-6 shrink-0 items-center justify-center rounded-md text-muted-foreground transition-colors hover:bg-muted hover:text-foreground",children:s.jsx(ut,{size:14})})]}),s.jsxs("div",{className:"flex min-h-0 flex-1 flex-col gap-3 overflow-y-auto px-3 pb-3",children:[C.length>0&&s.jsx(E0,{general:j,specific:k,atCap:R,attachedCount:f.length,onOpenPicker:h,onRemove:N}),d!==void 0&&s.jsx(Ji,{open:!0,onOpenChange:A=>!A&&h(void 0),slotLabel:d===null?"a general reference":((B=C.find(A=>A.name===d))==null?void 0:B.label)??"a reference",canvasId:n,blocks:t,onPick:A=>z(d,A)}),s.jsx(It,{type:l,values:u,onChange:g,capability:r,only:"primary"}),s.jsx(It,{type:l,values:u,onChange:g,capability:r,only:"advanced"})]}),s.jsx("div",{className:"shrink-0 p-3 pt-0",children:s.jsxs("div",{className:"flex gap-2",children:[s.jsx("button",{type:"button",onClick:o,className:"flex-1 rounded-md border border-border px-2 py-1.5 text-xs font-medium text-foreground transition-colors hover:bg-muted",children:"Cancel"}),s.jsx("button",{type:"button",disabled:E,"data-slot":"config-submit",onClick:()=>a({values:r?{...u,model:x}:u,inputs:[],references:V.map(A=>({...A.ref,kind:A.kind,role:A.role??Rl})),composedPrompt:Gc({prompt:typeof u.prompt=="string"?u.prompt:"",ordered:V,negativePrompt:H}),negativePrompt:H,sourceFiles:[]}),className:G("flex-1 rounded-md bg-foreground px-2 py-1.5 text-xs font-medium text-background transition-opacity","hover:opacity-90 disabled:cursor-not-allowed disabled:opacity-40"),children:ro(i,e.blockId)})]})})]})}const si="relative aspect-square rounded-xl overflow-hidden";function ai({tile:e,onRemove:t,className:n}){return s.jsxs("div",{"data-slot":"reference-attached","data-asset":e.id,className:G("group relative overflow-hidden rounded-lg bg-muted",n),children:[e.src?s.jsx("img",{src:e.src,alt:e.name,title:e.name,draggable:!1,className:"size-full object-cover"}):s.jsx("span",{className:"flex size-full items-center justify-center px-1 text-center text-3xs text-muted-foreground",children:e.name}),s.jsx("button",{type:"button","aria-label":`Remove ${e.name}`,title:"Remove",onClick:t,className:G("absolute right-0.5 top-0.5 flex size-4 items-center justify-center rounded-full","bg-black/55 text-white opacity-0 transition-opacity","group-hover:opacity-100 focus-visible:opacity-100","outline-none focus-visible:ring-2 focus-visible:ring-sidebar-ring"),children:s.jsx(ut,{size:9,weight:"bold"})})]})}function E0({general:e,specific:t,atCap:n,attachedCount:r,onOpenPicker:i,onRemove:o}){return s.jsxs("div",{className:"flex flex-col gap-1.5","data-slot":"reference-tiles",children:[s.jsxs("div",{className:"flex items-baseline gap-1.5",children:[s.jsx(Ze,{label:"References",hint:"Things to work from, without being the subject."}),s.jsxs("span",{className:"text-2xs tabular-nums text-muted-foreground
20/70",children:[r,"/",oi]})]}),s.jsxs("div",{className:"flex flex-col gap-1.5 rounded-2xl bg-muted/50 p-1.5",children:[s.jsxs("div",{"data-slot":"reference-general",className:"flex min-h-9 items-center gap-1.5 rounded-xl bg-muted/70 p-1",children:[e.map(a=>s.jsx(ai,{tile:a,onRemove:()=>o(a.id),className:"size-7 shrink-0"},a.id)),s.jsxs("button",{type:"button","data-slot":"reference-attach","data-role":Rl,"aria-label":"Attach a general reference",title:n?"Three references is the most this takes.":"Attach a general reference â no tag","aria-haspopup":"dialog",disabled:n,onClick:()=>i(null),className:G("flex min-w-0 flex-1 items-center gap-1.5 rounded-lg px-1.5 py-1 text-left","text-2xs font-medium text-muted-foreground transition-colors","hover:bg-surface-elevated hover:text-foreground","outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-sidebar-ring","disabled:cursor-not-allowed disabled:opacity-40 disabled:hover:bg-transparent"),children:[s.jsx(_t,{size:13,className:"shrink-0"}),s.jsx("span",{className:"truncate",children:"General"})]})]}),s.jsx("div",{className:"grid grid-cols-3 gap-1.5",children:t.map(a=>{const l=a.icon;return a.tile?s.jsxs("div",{className:G(si,"bg-muted"),children:[s.jsx(ai,{tile:a.tile,onRemove:()=>o(a.tile.id),className:"size-full rounded-xl"}),s.jsx("div",{className:"pointer-events-none absolute inset-x-0 bottom-0 h-1/2 rounded-b-xl bg-gradient-to-t from-black/70 to-transparent"}),s.jsx("span",{"data-slot":"reference-role","data-role":a.name,className:"pointer-events-none absolute inset-x-0 bottom-0 truncate px-1 pb-0.5 text-center text-3xs font-medium text-white",children:a.label})]},a.name):s.jsxs("button",{type:"button","data-slot":"reference-attach","data-role":a.name,"aria-label":`Attach ${a.label}`,title:n?"Three references is the most this takes.":`Attach ${a.label}`,"aria-haspopup":"dialog",disabled:n,onClick:()=>i(a.name),className:G(si,"flex flex-col items-center justify-center gap-0.5 bg-muted","text-muted-foreground transition-colors","hover:bg-surface-elevated hover:text-foreground","outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-sidebar-ring","disabled:cursor-not-allowed disabled:opacity-40 disabled:hover:bg-transparent"),children:[s.jsx(l,{size:15}),s.jsx("span",{className:"max-w-full truncate px-1 text-3xs font-medium",children:a.label})]},a.name)})})]})]})}function T0({target:e,blocks:t,canvasId:n,capability:r,opensRun:i,onCancel:o,onSubmit:a}){var j;const l=e.type,[u,c]=m.useState(()=>({...rr(l),...e.seed})),[f,p]=m.useState(()=>{var z;const R=(z=e.prefill)==null?void 0:z[0];return R?Yx(t,R):null}),[d,h]=m.useState(!1),g=(R,z)=>c(N=>({...N,[R]:z})),x=m.useMemo(()=>f?[Wx(f,t)].filter(R=>R!==null):[],[f,t]),C=(r==null?void 0:r.models[0])??null,v=((j=Dt(l.id,e.operationKey)[0])==null?void 0:j.label)??"Source image",k=f!==null;return s.jsxs("section",{"data-slot":"gooh-studio-config-panel","data-config-type":l.id,"data-panel":"edit","data-opens-run":i?"true":void 0,className:"pointer-events-auto flex max-h-[70vh] w-80 flex-col rounded-2xl bg-surface-floating shadow-2xl ring-1 ring-border",children:[s.jsxs("header",{className:"flex shrink-0 items-center gap-1 p-3 pb-2",children:[s.jsx("h2",{className:"min-w-0 flex-1 truncate text-xs font-semibold text-foreground",children:"Edit image"}),s.jsx(no,{entries:Fl(l,[{label:"Image",hint:"The one image this edits. Required â there is nothing to edit without it."}]),footnote:io(i,e.blockId)}),s.jsx("button",{type:"button",onClick:o,"aria-label":"Cancel",title:"Cancel",className:"flex size-6 shrink-0 items-center justify-center rounded-md text-muted-foreground transition-colors hover:bg-muted hover:text-foreground",children:s.jsx(ut,{size:14})})]}),s.jsxs("div",{className:"flex min-h-0 flex-1 flex-col gap-3 overflow-y-auto px-3 pb-3",children:[s.jsx(S0,{label:v,picked:f,onOpenPicker:()=>h(!0),onClear:()=>p(null)}),d&&s.jsx(Ji,{open:!0,onOpenChange:h,slotLabel:v,canvasId:n,blocks:t,onPick:p}),s.jsx(It,{type:l,values:u,onChange:g,capability:r,only:"primary"}),C&&s.jsxs("div",{className:"flex items-center gap-2 rounded-lg bg-muted/60 px-2 py-1.5",children:[s.jsx("span",{className:"min-w-0 flex-1 truncate text-2xs text-muted-foreground",children:Ht("model",C.id)}),s.jsx("span",{className:"shrink-0 text-2xs tabular-nums text-muted-foreground",children:C.price})]})]}),s.jsx("div",{className:"shrink-0 p-3 pt-0",children:s.jsxs("div",{className:"flex gap-2",children:[s.jsx("button",{type:"button",onClick:o,className:"flex-1 rounded-md border border-border px-2 py-1.5 text-xs font-medium text-foreground transition-colors hover:bg-muted",children:"Cancel"}),s.jsx("button",{type:"button",disabled:!k,"data-slot":"config-submit",title:k?void 0:"Attach the image to edit.",onClick:()=>a({values:C?{...u,model:C.id}
20:u,inputs:x,references:[],composedPrompt:typeof u.prompt=="string"?u.prompt:"",negativePrompt:"",source:f?Kx(f):void 0,sourceFiles:[]}),className:G("flex-1 rounded-md bg-foreground px-2 py-1.5 text-xs font-medium text-background transition-opacity","hover:opacity-90 disabled:cursor-not-allowed disabled:opacity-40"),children:ro(i,e.blockId)})]})})]})}function P0(e){return e.target.panel==="edit"?s.jsx(T0,{...e}):e.target.panel==="still"?s.jsx(A0,{...e}):s.jsx(M0,{...e})}function M0({target:e,blocks:t,capability:n,opensRun:r,onCancel:i,onSubmit:o}){const a=e.type,[l,u]=m.useState(()=>({...rr(a),...e.seed})),[c,f]=m.useState(()=>[...e.prefill??[]]),[p,d]=m.useState([]),[h,g]=m.useState([]),x=(P,D)=>u(F=>({...F,[P]:D})),C=fr(l,n),v=m.useMemo(()=>t.filter(P=>!tt(P.state)).flatMap(P=>P.variants.flatMap(D=>{const F=er(D);return F!=null&&F.assetId?[{blockTitle:P.title,variantLabel:D.label,assetId:F.assetId}]:[]})),[t]),k=(P,D,F)=>g(Z=>{if(Z.some(ue=>ue.role===P&&ue.assetId===D))return Z.filter(ue=>!(ue.role===P&&ue.assetId===D));const ee=Z.filter(ue=>ue.role===P),ne=ee.length>=F?[ee[0]]:[];return[...Z.filter(ue=>!ne.some(b=>b.role===ue.role&&b.assetId===ue.assetId)),{assetId:D,kind:"image",role:P}]}),j=m.useMemo(()=>t.filter(P=>!tt(P.state)).flatMap(P=>P.variants.map(D=>({block:P,variant:D}))),[t]),R=P=>f(D=>D.includes(P)?D.filter(F=>F!==P):[...D,P]),z=Ol(a,l),N=Lu(Dt(a.id,e.operationKey)),V=a.fields.length===0&&N==="none",H=a.fields.some(P=>!P.primary),E=m.useMemo(()=>{const P=n?{...l,model:C}:l,D=F=>{const Z=Rs.indexOf(F);return Z===-1?Rs.length:Z};return Nt(a).filter(F=>!F.primary).map((F,Z)=>({field:F,index:Z})).sort((F,Z)=>D(F.field.id)-D(Z.field.id)||F.index-Z.index).map(({field:F})=>xi(F,P[F.id])).filter(F=>F.length>0)},[a,l,n,C]),B=m.useMemo(()=>{const P=[{label:a.label,hint:a.summary}];N!=="none"&&P.push({label:"Source",hint:"What this is made from â what the run has already made first, or a file brought in from outside. Nothing is uploaded; the filename is recorded."}),n&&n.roles.length>0&&P.push({label:"References",hint:"Things to work from, without being the subject."});for(const D of Nt(a))D.hint&&P.push({label:D.label,hint:D.hint});return P},[a,N,n]),A=io(r,e.blockId);return s.jsxs("section",{"data-slot":"gooh-studio-config-panel","data-config-type":a.id,"data-opens-run":r?"true":void 0,className:"pointer-events-auto flex max-h-[70vh] w-80 flex-col rounded-2xl bg-surface-floating shadow-2xl ring-1 ring-border",children:[s.jsxs("header",{className:"flex shrink-0 items-center gap-1 p-3 pb-2",children:[s.jsx("h2",{className:"min-w-0 flex-1 truncate text-xs font-semibold text-foreground",children:r||e.blockId!==void 0?a.label:`New ${a.label}`}),s.jsx(no,{entries:B,footnote:A}),s.jsx("button",{type:"button",onClick:i,"aria-label":"Cancel",title:"Cancel",className:"flex size-6 shrink-0 items-center justify-center rounded-md text-muted-foreground transition-colors hover:bg-muted hover:text-foreground",children:s.jsx(ut,{size:14})})]}),s.jsxs("div",{className:"flex min-h-0 flex-1 flex-col gap-3 overflow-y-auto px-3 pb-3",children:[V&&s.jsx("p",{className:"rounded-lg bg-muted/60 px-2 py-1.5 text-2xs leading-relaxed text-muted-foreground",children:"Nothing to configure â this one goes straight to the conversation."}),s.jsx(It,{type:a,values:l,onChange:x,capability:n,only:"primary"}),N!=="none"&&s.jsx(I0,{arity:N,candidates:j,inputs:c,toggleInput:R,sourceFiles:p,setSourceFiles:d}),n&&s.jsx(v0,{roles:n.roles,candidates:v,chosen:h,onToggle:k}),H&&s.jsx(N0,{trail:E,children:s.jsx(It,{type:a,values:l,onChange:x,capability:n,only:"advanced"})})]}),s.jsx("div",{className:"shrink-0 p-3 pt-0",children:s.jsxs("div",{className:"flex gap-2",children:[s.jsx("button",{type:"button",onClick:i,className:"flex-1 rounded-md border border-border px-2 py-1.5 text-xs font-medium text-foreground transition-colors hover:bg-muted",children:"Cancel"}),s.jsx("button",{type:"button",disabled:z,"data-slot":"config-submit",onClick:()=>o({values:n?{...l,model:C}:l,inputs:c,references:h,composedPrompt:C0(a,l),negativePrompt:"",sourceFiles:p}),className:G("flex-1 rounded-md bg-foreground px-2 py-1.5 text-xs font-medium text-background transition-opacity","hover:opacity-90 disabled:cursor-not-allowed disabled:opacity-40"),children:ro(r,e.blockId)})]})})]})}function R0({blocks:e,canvasId:t,selected:n,configuring:r,onConfigure:i,onSubmit:o,onStudioRun:a,onRunOperation:l,onRunFlow:u}){var C;const[c,f]=m.useState(!1),{capabilityFor:p}=hn(),{modelsFor:d,unavailable:h}=pr(),g=(r==null?void 0:r.studioOperationId)??null,x=r&&g&&d(g).some(v=>v.id!==null)?{target:r,operationId:g}:null;return s.jsxs(s.Fragment,{children:[x&&s.jsx("div",{className:"pointer-events-none absolute bottom-full left-0 mb-2 flex justify-start",children:s.jsx("div",{className:"pointer-events-auto w-80 rounded-2xl border border-border bg-popover p-3 shadow-lg",children:s.jsx(Il,{operationId:x.operationId,canvasId:t,blocks:e,onCancel:()=>i(null),onRun:v=>a({operationId:x.operationId,typeId:x.target.type.id,typeLabel:x.target.type.label,...x.target.blockId!==void 0?{blockId:x.target.blockId}:{}},v)},`${x.target.type.id}:${x.target.operationKey??"-"}:${x.target.blockId??"-"}`)})}),r&&g&&!x&&h&&s.jsx("div",{className:"pointer-events-none absolute bottom-full left-0 mb-2 flex justify-start",children:s.jsx("div",{className:"pointer-events-auto w-80 rounded-2xl border border-border bg-popover p-3 text-2xs leading-relaxed text-muted-foreground shadow-lg",children:"The studio canât be reached, so nothing can run right now. Nothing was charged."})}),r&&r.studioOperationId===null&&s.jsx("div",{className:"pointer-events-none absolute bottom-full left-0 mb-2 flex justify-start",children:s.jsx(P0,{target:r,blocks:e,canvasId:t,capability:p(r.operationKey),opensRun:cn(e)===null,onCancel:()=>i(null),onSubmit:v=>o(r,v)},`${r.type.id}:${r.operationKey??"-"}:${r.blockId??"-"}:${r.fromBlockId??"-"}
20:${typeof((C=r.seed)==null?void 0:C.model)=="string"?r.seed.model:"-"}`)}),s.jsx("div",{className:"pointer-events-auto",children:s.jsxs(je.Root,{open:c,onOpenChange:f,children:[s.jsx(je.Anchor,{children:s.jsx(at,{label:"All operations",active:c||r!==null,onClick:()=>f(v=>!v),children:s.jsx(da,{size:18,weight:"bold"})})}),s.jsx(je.Content,{side:"top",align:"start",className:"w-64 rounded-2xl p-1.5",onInteractOutside:to,children:s.jsx(Al,{selected:n,onRun:(v,k)=>{f(!1),l(v,k)},onRunFlow:v=>{f(!1),u(v)}})})]})})]})}const $r="rounded-full bg-foreground text-background hover:bg-foreground hover:text-background";function Fs(){return s.jsx("span",{"aria-hidden":"true",className:"mx-1 h-5 w-px shrink-0 bg-border/70"})}function L0({blocks:e,canvasId:t,selected:n,configuring:r,onConfigure:i,onSubmit:o,onStudioRun:a,onRunOperation:l,onRunFlow:u}){const c=ae(p=>p.canvasTool),f=ae(p=>p.setCanvasTool);return s.jsxs(la,{"data-slot":"gooh-studio-bottom-rail",onPointerDown:p=>p.stopPropagation(),className:"pointer-events-auto relative flex-row gap-1.5 px-2.5",children:[s.jsx(at,{label:c==="pan"?"Pan â drag to move the canvas (current tool)":"Pan â drag to move the canvas",active:c==="pan",activeClassName:$r,onClick:()=>f("pan"),children:s.jsx(ac,{size:17,weight:"fill"})}),s.jsx(at,{label:c==="select"?"Select â drag to select (current tool)":"Select â drag to select",active:c==="select",activeClassName:$r,onClick:()=>f("select"),children:s.jsx(fa,{size:17,weight:"bold"})}),s.jsx(at,{label:c==="frame"?"Frame â drag to draw a frame (current tool)":"Frame â drag to draw a frame",active:c==="frame",activeClassName:$r,onClick:()=>f("frame"),children:s.jsx(ir,{size:17,weight:"bold"})}),s.jsx(Fs,{}),s.jsx(w0,{onRun:l}),s.jsx(Fs,{}),Ad.map(p=>s.jsx(O0,{op:p,selected:n,onRun:l},p.id)),s.jsx(R0,{blocks:e,canvasId:t,selected:n,configuring:r,onConfigure:i,onSubmit:o,onStudioRun:a,onRunOperation:l,onRunFlow:u})]})}function O0({op:e,selected:t,onRun:n}){const r=e.icon,i=Ca(Kn(zi(e),Fi(e,null),t));return s.jsx(at,{label:[`${e.label} (${e.shortcut})`,i].filter(Boolean).join(" â "),onClick:()=>n(e,null),children:s.jsx(r,{size:17})})}function F0({onFitView:e}){const{scale:t,setScale:n}=Us();return s.jsxs(la,{"data-slot":"gooh-studio-zoom",onPointerDown:r=>r.stopPropagation(),className:"pointer-events-auto flex-row items-center gap-1 p-1.5",children:[s.jsx(at,{label:"Zoom out",pop:!1,onClick:()=>n(r=>r/1.25),children:s.jsx(dc,{size:17,weight:"bold"})}),s.jsxs("span",{className:"min-w-10 select-none text-center text-2xs font-semibold tabular-nums text-muted-foreground",children:[Math.round(t*100),"%"]}),s.jsx(at,{label:"Zoom in",pop:!1,onClick:()=>n(r=>r*1.25),children:s.jsx(_t,{size:17,weight:"bold"})}),s.jsx(at,{label:"Tidy view â frame everything on the canvas",pop:!1,onClick:e,children:s.jsx(yu,{size:17,weight:"bold"})})]})}const z0={[ki]:!0},_0=-40;function D0({onOpenMenu:e}){return s.jsxs("button",{type:"button",...z0,"data-slot":"gooh-studio-start-here",onClick:t=>{const n=t.currentTarget.getBoundingClientRect();e({x:n.left,y:n.bottom})},style:{width:tr,transform:`translate(-50%, -50%) translate(0px, ${_0}px)`},className:G("absolute left-1/2 top-1/2 flex flex-col items-center justify-center gap-2 rounded-2xl","border border-dashed border-border bg-card/60 px-4 py-7","transition-colors hover:border-primary/40 hover:bg-muted","outline-none focus-visible:ring-2 focus-visible:ring-sidebar-ring"),children:[s.jsx("span",{className:"flex size-9 items-center justify-center rounded-xl bg-muted text-foreground/70",children:s.jsx(_t,{size:18})}),s.jsx("span",{className:"text-sm font-semibold text-foreground",children:"Start here"})]})}function $0({block:e,variant:t}){var f,p,d,h;const{pairing:n}=pr(),r=bt(e),i=((f=t.provenance)==null?void 0:f.source)??null,o=t.config??null;if(!r||!o)return null;const a=((p=n(r,i))==null?void 0:p.slots)??[],l=((d=t.provenance)==null?void 0:d.mode)??null,u=((h=t.provenance)==null?void 0:h.credits)??null,c=Object.entries(o).map(([g,x])=>{var C;return{input:g,label:((C=a.find(v=>v.input===g))==null?void 0:C.label)??null,value:x}});return s.jsxs("div",{"data-slot":"run-record",className:"flex flex-col gap-1.5",children:[s.jsx("span",{className:"text-2xs font-medium text-muted-foreground",children:"Made with"}),s.jsxs("dl",{className:"flex flex-col gap-0.5",children:[s.jsx(_n,{label:"Model",value:i??"â"}),l&&s.jsx(_n,{label:"Mode",value:B0(n(r,i),l)}),c.map(g=>s.jsx(_n,{label:g.label,value:V0(g.value)},g.input)),u!==null&&s.jsx(_n,{label:"Charged",value:`${u} credits`})]})]})}function _n({label:e,value:t}){return e?s.jsxs("div",{className:"flex items-baseline justify-between gap-3",children:[s.jsx("dt",{className:"shrink-0 text-2xs text-muted-foreground",children:e}),s.jsx("dd",{className:"truncate text-2xs text-foreground",title:t,children:t})]}):null}function B0(e,t){var n,r;return((r=(n=e==null?void 0:e.modes)==null?void 0:n.find(i=>i.name===t))==null?void 0:r.label)??t}function V0(e){if(Array.isArray(e))return e.length===1?"1 attached":`${e.length} attached`;if(typeof e=="boolean")return e?"Yes":"No";if(e==null)return"â";const t=String(e);return t.length>80?`${t.slice(0,80)}â¦`:t}function H0({block:e,operations:t,actions:n,armedDiscard:r,dependents:i,onStartFrom:o,onReUpload:a,onAction:l}){const u=oe(e.typeId),c=m.useRef(null),f=tt(e.state),p=n.filter(h=>h.group==="destroy"),d=U0(u.fields);return s.jsxs("div",{className:"shrink-0 border-t border-border","data-slot":"upload-actions",children:[s.jsxs("div",{className:"flex flex-col gap-0.5 p-2","data-upload-band":"create",children:[s.jsx("p",{className:"px-2 pb-0.5 text-2xs font-semibold text-muted-foreground",children:"New block"}),t.length===0?s.jsx("p",{className:"px-2 text-2xs leading-relaxed text-muted-foreground",children:"What can be made from a file has not come back yet."}):t.map(h=>s.jsx("button",{type:"button",disabled:h.refusal!==null||f,onClick:()=>o(h),"data-slot":"upload-start-from","data-operation":h.key,title:h.refusal??h.label,className:G("flex w-full items-center gap-2 rounded-lg px-2 py-1.5 text-left text-xs font-semibold transition-colors","text-foreground hover:bg-muted","outline-none focus-visible:ring-2 focus-visible:ring-sidebar-ring","disabled:cursor-not-allowed disabled:opacity-40 disabled:hover:bg-transparent"),children:h.label},h.key))]}),s.jsxs("div",{className:"flex flex-col gap-0.5 border-t border-border p-2","data-upload-band":"act",children:[s.jsx("p",{className:"px-2 pb-0.5 text-2xs font-semibold text-muted-foreground",children:"On this block"}),s.jsxs("button",{type:"button",disabled:f,onClick:()=>{var h;
20return(h=c.current)==null?void 0:h.click()},"data-slot":"upload-re-upload",title:"Bring in another file under this block",className:G("flex w-full items-center gap-2 rounded-lg px-2 py-1.5 text-left text-xs font-semibold transition-colors","text-foreground hover:bg-muted","outline-none focus-visible:ring-2 focus-visible:ring-sidebar-ring","disabled:cursor-not-allowed disabled:opacity-40 disabled:hover:bg-transparent"),children:[s.jsx($s,{size:14,className:"shrink-0"}),"Re-upload"]}),p.map(h=>s.jsxs("button",{type:"button",disabled:h.refusal!==null,onClick:()=>l(h.id),"data-slot":`block-action-${h.id}`,"data-armed":r?"true":void 0,className:G("flex w-full items-center gap-2 rounded-lg px-2 py-1.5 text-left text-xs font-semibold transition-colors","outline-none focus-visible:ring-2 focus-visible:ring-sidebar-ring","disabled:cursor-not-allowed disabled:opacity-40",r?"bg-destructive/10 text-destructive":"text-destructive hover:bg-destructive/10"),children:[s.jsx(nn,{size:14,weight:r?"fill":"regular",className:"shrink-0"}),r?`${h.label} anyway`:h.label]},h.id)),r&&i.length>0&&s.jsxs("p",{className:"px-2 pt-1 text-2xs leading-relaxed text-muted-foreground",children:[i.join(", ")," ",i.length===1?"was":"were"," made from this."," ",i.length===1?"It keeps":"They keep"," whatever"," ",i.length===1?"it has":"they have"," already produced."]}),p.map(h=>h.refusal?s.jsx("p",{className:"px-2 pt-1 text-2xs leading-relaxed text-muted-foreground",children:h.refusal},`${h.id}-refusal`):null)]}),s.jsx("input",{ref:c,type:"file",accept:d,className:"hidden",onChange:h=>{var x;const g=(x=h.target.files)==null?void 0:x[0];h.target.value="",g&&a(g)}})]})}function U0(e){const t=e.find(n=>n.kind==="file"&&"accept"in n);return t==null?void 0:t.accept}function oo({media:e,src:t,kind:n,className:r,fallbackRatio:i,...o}){const l=e.width>0&&e.height>0?{aspectRatio:`${e.width} / ${e.height}`}:i?{aspectRatio:i}:void 0;return n==="video"?s.jsx("video",{src:t,controls:!0,playsInline:!0,preload:"metadata",style:l,className:r,...o}):s.jsx(fn,{src:t,alt:e.alt,width:e.width,height:e.height,style:l,className:r,loading:"lazy",draggable:!1,...o})}function zl(e){return oe(e.typeId).produces.includes("video")?"video":"image"}const q0=[{id:"rerun",label:"Re-run this screen",icon:ua},{id:"download",label:"Download",icon:fc}];function Z0({target:e}){return s.jsx("div",{className:"mt-1 flex items-center gap-1",children:q0.map(({id:t,label:n,icon:r})=>s.jsx("button",{type:"button","aria-label":`${n} â ${e}`,title:`${n} (placeholder â nothing runs)`,className:"flex size-6 items-center justify-center rounded text-muted-foreground/70 transition-colors hover:bg-muted hover:text-foreground",children:s.jsx(r,{size:12})},t))})}const K0={h1:({children:e})=>s.jsx("h3",{className:"mt-3 text-lg font-semibold text-foreground",children:e}),h2:({children:e})=>s.jsx("h4",{className:"mt-3 text-xs font-semibold text-foreground",children:e}),h3:({children:e})=>s.jsx("h5",{className:"mt-2 text-xs font-medium text-muted-foreground",children:e}),p:({children:e})=>s.jsx("p",{className:"text-xs leading-relaxed",children:e}),ul:({children:e})=>s.jsx("ul",{className:"flex list-disc flex-col gap-1 pl-4 text-xs",children:e}),ol:({children:e})=>s.jsx("ol",{className:"flex list-decimal flex-col gap-1 pl-4 text-xs",children:e}),li:({children:e})=>s.jsx("li",{className:"leading-relaxed",children:e}),strong:({children:e})=>s.jsx("strong",{className:"font-semibold",children:e}),code:({children:e})=>s.jsx("code",{className:"rounded bg-muted px-1 py-0.5 font-mono text-2xs",children:e}),blockquote:({children:e})=>s.jsx("blockquote",{className:"border-l-2 border-border pl-2 text-2xs italic text-muted-foreground",children:e}),a:({children:e,href:t})=>s.jsx("a",{href:t,target:"_blank",rel:"noopener noreferrer",className:"text-primary underline",children:e})};function W0({headings:e}){return e.length===0?null:s.jsxs("div",{className:"flex flex-col gap-1 rounded-lg border border-border/70 px-2 py-2",children:[s.jsx("p",{className:"text-2xs font-semibold text-muted-foreground",children:e.length===1?"1 section":`${e.length} sections`}),s.jsx("ul",{className:"flex list-none flex-col gap-0.5",children:e.map((t,n)=>s.jsx("li",{style:{paddingLeft:`${Math.min(t.depth-1,3)*10}px`},className:"truncate text-2xs text-foreground",title:t.text,children:t.text},`${n}-${t.text}`))})]})}function G0({variant:e}){const t=e.document;if(!t)return null;const{words:n,headings:r}=yi(t);return s.jsxs("div",{"data-slot":"variant-document",className:"flex flex-col gap-2",children:[s.jsxs("div",{className:"flex flex-col gap-0.5",children:[s.jsx("p",{className:"text-xs font-semibold text-foreground",children:t.title||e.label||"Untitled document"}),s.jsxs("p",{className:"text-2xs tabular-nums text-muted-foreground
20/70",children:[n===1?"1 word":`${n.toLocaleString()} words`,` · ${t.format}`]})]}),s.jsx(W0,{headings:r}),s.jsx("div",{className:"flex flex-col gap-2 text-xs leading-relaxed text-foreground",children:s.jsx(ml,{rehypePlugins:[yl],components:K0,children:t.body})})]})}function Y0({variant:e,kind:t}){const n=mn(),r=e.set;return r?s.jsxs("div",{className:"flex flex-col gap-2",children:[s.jsx("p",{className:"text-xs font-semibold text-foreground",children:r.items.length===1?"1 output · kept":`${r.items.length} outputs · all kept`}),s.jsx("ul",{className:"grid list-none grid-cols-2 gap-1.5",children:r.items.map(i=>s.jsxs("li",{"data-slot":"set-item","data-target":i.target,className:"flex flex-col rounded-lg border border-border/70 px-2 py-1.5",children:[i.media&&s.jsx(oo,{media:i.media,src:n(i.media),kind:t,className:"mb-1 h-14 w-full rounded object-cover"}),s.jsx("span",{className:"truncate text-2xs font-semibold text-foreground",title:i.target,children:i.target}),i.provenance&&s.jsx("span",{className:"truncate text-2xs text-muted-foreground/70",children:Qs[i.provenance.kind]}),s.jsx(Z0,{target:i.target})]},i.id))})]}):null}function X0({variant:e,number:t,selected:n,onSelect:r,kind:i}){var u,c;const o=mn(),a=e.media??((c=(u=e.set)==null?void 0:u.items.find(f=>f.media))==null?void 0:c.media)??null,l=e.set?`Ã${e.set.items.length}`:e.document?`${yi(e.document).words.toLocaleString()}w`:null;return s.jsxs("button",{type:"button",role:"tab","aria-selected":n,"aria-label":`Variant ${t}${e.accepted?" â accepted":""}`,title:e.label,onClick:r,"data-slot":"variant-choice","data-variant-id":e.id,className:G("relative size-16 shrink-0 overflow-hidden rounded-lg border transition-colors","outline-none focus-visible:ring-2 focus-visible:ring-sidebar-ring",n?"border-primary ring-1 ring-primary":"border-border hover:border-primary/40"),children:[a?s.jsx(oo,{media:a,src:o(a),kind:i,className:"size-full object-cover"}):s.jsx("span",{className:"flex size-full items-center justify-center bg-muted/60","aria-hidden":!0}),s.jsx("span",{"aria-hidden":!0,className:"absolute left-1 top-1 rounded bg-foreground
20/70 px-1 text-2xs font-bold tabular-nums leading-tight text-background",children:t}),e.accepted&&s.jsx(rn,{size:14,weight:"fill","aria-hidden":!0,className:"absolute right-1 top-1 text-success drop-shadow"}),l&&s.jsx("span",{className:"absolute bottom-0 left-0 right-0 truncate bg-foreground/70 px-1 text-2xs font-semibold tabular-nums leading-tight text-background",children:l})]})}function Q0({variant:e,kind:t}){const n=mn();return e.document?s.jsx(G0,{variant:e}):e.set?s.jsx(Y0,{variant:e,kind:t}):e.media?s.jsx(oo,{media:e.media,src:n(e.media),kind:t,"data-slot":"variant-preview",className:"max-h-64 w-full rounded-lg object-contain",fallbackRatio:"16 / 9"}):s.jsx("p",{className:"text-xs leading-relaxed text-muted-foreground",children:"This attempt has nothing to show yet."})}function J0({variant:e}){const t=[];return e.provenance&&(t.push(Qs[e.provenance.kind]),t.push(Ht("model",e.provenance.source))),e.ratio&&e.ratio!=="â"&&t.push(e.ratio),e.provenance&&t.push(e.provenance.recordedAt.slice(0,10)),t.length===0?null:s.jsx("p",{"data-slot":"variant-meta",className:"text-2xs leading-relaxed tabular-nums text-muted-foreground",children:t.join(" · ")})}function e1({block:e,selected:t,onSelect:n}){return s.jsx("div",{className:"flex flex-wrap gap-1.5",role:"tablist","aria-label":"Variants",children:e.variants.map((r,i)=>s.jsx(X0,{variant:r,number:i+1,selected:r.id===t.id,onSelect:()=>n(r.id),kind:zl(e)},r.id))})}function t1({block:e,variant:t,onAccepted:n}){const r=Js();return t.accepted?s.jsxs("p",{className:"flex items-center gap-1.5 text-2xs font-semibold text-muted-foreground",children:[s.jsx(rn,{size:13,weight:"fill",className:"shrink-0 text-success"}),"This is the accepted variant"]}):s.jsxs("button",{type:"button","data-slot":"variant-accept",onClick:()=>{r.mutate({canvasId:e.canvasId,blockId:e.id,variantId:t.id}),n==null||n(e.id,t.id)},className:G("flex w-full items-center justify-center gap-1.5 rounded-md bg-primary px-2 py-1.5","text-xs font-semibold text-primary-foreground transition-opacity hover:opacity-90"),children:[s.jsx(rn,{size:14,weight:"fill"}),"Accept"]})}function n1({block:e,variant:t}){const{byVariant:n}=ra(e.canvasId),{updateCreation:r}=ec(),{deleteCreation:i}=tc(),o=Js(),a=n.get(t.id),[l,u]=m.useState(""),[c,f]=m.useState(!1);if(!a)return null;if(a.deletedAt)return s.jsxs("div",{"data-slot":"variant-creation-deleted",className:"flex items-center justify-between gap-2",children:[s.jsx("p",{className:"text-2xs leading-relaxed text-muted-foreground",children:"Deleted from the library."}),s.jsx("button",{type:"button","data-slot":"variant-creation-restore",onClick:()=>o.mutate({canvasId:e.canvasId,blockId:e.id,variantId:t.id}),className:"shrink-0 rounded-md border border-border px-1.5 py-0.5 text-2xs font-medium text-foreground transition-colors hover:bg-muted",children:"Put it back"})]});if(!a.isOwn)return s.jsxs("p",{className:"truncate text-2xs text-muted-foreground",title:a.name,children:["In the library as ",a.name]});const p=()=>{const d=l.trim();f(!1),d&&d!==a.name&&r({id:a.id,changes:{name:d}})};return s.jsxs("div",{"data-slot":"variant-creation",className:"flex items-center gap-1.5",children:[c?s.jsx("input",{autoFocus:!0,"data-slot":"variant-creation-name-input",value:l,onChange:d=>u(d.target.value),onBlur:p,onKeyDown:d=>{d.key==="Enter"&&p(),d.key==="Escape"&&f(!1)},className:"min-w-0 flex-1 rounded border border-border bg-background px-1 py-0.5 text-2xs text-foreground outline-none focus:ring-1 focus:ring-sidebar-ring"}):s.jsx("button",{type:"button","data-slot":"variant-creation-name",title:`Rename ${a.name}`,onClick:()=>{u(a.name),f(!0)},className:"min-w-0 flex-1 truncate rounded px-1 py-0.5 text-left text-2xs text-muted-foreground transition-colors hover:bg-muted hover:text-foreground",children:a.name}),s.jsx("button",{type:"button","data-slot":"variant-creation-delete","aria-label":`Delete ${a.name} from the library`,title:"Delete from the library",onClick:()=>i(a.id),className:"shrink-0 rounded p-0.5 text-muted-foreground transition-colors hover:bg-muted hover:text-destructive",children:s.jsx(nn,{size:12})})]})}function r1({blocks:e,canvasBlocks:t,frames:n,actions:r,dependents:i,armedDiscard:o,selectedVariantId:a,imageOperations:l,onSelectVariant:u,onVariantAccepted:c,onAction:f,onStartFrom:p,onReUpload:d,onFrameEdit:h,onClose:g}){const x=ae(H=>H.blockSlotWidth),C=ae(H=>H.setBlockSlotWidthByUser),[v,k]=m.useState(!1),j=e.length+n.length,R=j===1&&e.length===1?e[0]:null,z=j===1&&n.length===1?n[0]:null,N=R?oe(R.typeId):null,V=(N==null?void 0:N.group)==="bring";return s.jsxs("section",{"data-slot":"gooh-studio-block-slot","data-block-id":R==null?void 0:R.id,"data-selected-count":j,"data-single-kind":R?"block":z?"frame":void 0,style:{width:x},className:G("pointer-events-auto relative flex max-h-full min-h-0 flex-col overflow-hidden rounded-2xl bg-surface-floating","shadow-2xl ring-1 ring-border/70",!v&&"transition-[width] duration-300 ease-out"),onPointerDown:H=>H.stopPropagation(),children:[s.jsx(wl,{width:x,onResize:C,onDraggingChange:k,label:"Resize the block panel"}),s.jsxs("header",{className:"flex shrink-0 items-center gap-2 p-3 pb-2",children:[R&&N?s.jsxs(s.Fragment,{children:[s.jsx(N.icon,{size:15,className:"shrink-0 text-muted-foreground"}),s.jsx("h2",{className:"min-w-0 flex-1 truncate text-sm font-bold text-foreground",children:R.title}),R.state!=="complete"&&s.jsx("span",{className:"shrink-0 rounded bg-muted px-1.5 py-0.5 text-2xs font-semibold text-muted-foreground",children:bi[R.state]})]}):z?s.jsxs(s.Fragment,{children:[s.jsx(ir,{size:15,className:"shrink-0 text-muted-foreground"}),s.jsx("h2",{className:"min-w-0 flex-1 truncate text-sm font-bold text-foreground",children:Ii(z)})]}):s.jsx("h2",{className:"min-w-0 flex-1 truncate text-sm font-bold text-foreground",children:d1(e.length,n.length)}),s.jsx("button",{type:"button",onClick:g,"data-slot":"gooh-studio-block-close","aria-label":"Close",title:"Close",className:"flex size-6 shrink-0 items-center justify-center rounded-full text-muted-foreground outline-none transition-colors hover:bg-muted hover:text-foreground focus-visible:ring-2 focus-visible:ring-sidebar-ring",children:s.jsx(ut,{size:13,weight:"bold"})})]}),R&&tt(R.state)&&s.jsx("p",{className:"mx-3 mb-2 shrink-0 rounded-lg bg-muted/70 px-2 py-1.5 text-2xs leading-relaxed text-muted-foreground",children:"This step is being worked. You can look at it; it cannot be edited."}),R&&!V&&s.jsx(i1,{block:R,canvasBlocks:t,selectedVariantId:a,onSelectVariant:u,onVariantAccepted:c,onAction:f},R.id),z&&s.jsx(f1,{frame:z,onEdit:h}),!R&&!z&&s.jsx(l1,{blocks:e,frames:n}),R&&V?s.jsx(H0,{block:R,operations:l,actions:r,armedDiscard:o,dependents:i,onStartFrom:p,onReUpload:H=>d(R.id,H),onAction:f}):s.jsx(u1,{actions:r,dependents:i,armedDiscard:o,onAction:f})]})}function i1({block:e,canvasBlocks:t,selectedVariantId:n,onSelectVariant:r,onVariantAccepted:i,onAction:o}){const a=oe(e.typeId),{capabilityFor:l}=hn(),u=tt(e.state),c=e.variants.find(d=>d.id===n)??xt(e),f=l(Hn(e)),p=c!==null;return s.jsxs("div",{className:"flex min-h-0 grow flex-col gap-3 overflow-y-auto border-t border-border px-3 py-3",children:[c?s.jsxs(s.Fragment,{children:[s.jsx(Q0,{variant:c,kind:zl(e)}
20),s.jsx(J0,{variant:c}),s.jsx(e1,{block:e,selected:c,onSelect:r}),s.jsx(t1,{block:e,variant:c,onAccepted:i}),s.jsx(n1,{block:e,variant:c})]}):s.jsx("p",{className:"text-xs leading-relaxed text-muted-foreground",children:"Nothing produced yet. What this makes appears here as the block completes."}),p?s.jsx(o1,{type:a,block:e,canvasBlocks:t,variant:c}):s.jsx(s1,{block:e,canvasBlocks:t,capability:f,locked:u})]})}function o1({type:e,block:t,canvasBlocks:n,variant:r}){return s.jsxs("section",{className:"flex flex-col gap-2",children:[s.jsx(li,{children:"Inputs"}),s.jsx(Cl,{block:t,canvasBlocks:n}),s.jsx(_l,{type:e,block:t,values:r.config})]})}function s1({block:e,canvasBlocks:t,capability:n,locked:r}){const i=oe(e.typeId),o=dn(),[a,l]=m.useState(()=>e.config??rr(i)),u=m.useCallback(d=>{o.mutate({canvasId:e.canvasId,blockId:e.id,patch:{config:d}})},[e.canvasId,e.id,o]),c=new Set(i.fields.filter(d=>d.kind==="text").map(d=>d.id));if(r)return s.jsxs("section",{className:"flex flex-col gap-2",children:[s.jsx(li,{children:"Inputs"}),s.jsx(Cl,{block:e,canvasBlocks:t}),s.jsx(_l,{type:i,block:e,values:e.config})]});const f=xt(e),p=f?s.jsx($0,{block:e,variant:f}):null;return s.jsxs("section",{className:"flex flex-col gap-3",children:[s.jsx(li,{children:"Inputs"}),p??s.jsx(Sl,{block:e,canvasBlocks:t}),bt(e)!==null?null:i.fields.length===0?s.jsx("p",{className:"text-2xs leading-relaxed text-muted-foreground",children:"Nothing to configure â this type has no settings of its own."}):s.jsx("div",{className:"flex flex-col gap-3",onBlur:()=>u(a),children:s.jsx(It,{type:i,values:a,onChange:(d,h)=>{const g={...a,[d]:h};l(g),c.has(d)||u(g)},capability:n})})]})}function li({children:e}){return s.jsx("p",{className:"text-2xs font-semibold text-muted-foreground",children:e})}function _l({type:e,block:t,values:n}){return e.fields.length===0?s.jsx("p",{className:"text-2xs leading-relaxed text-muted-foreground",children:"This type has no settings of its own."}):n===null?s.jsx("p",{className:"text-2xs leading-relaxed text-muted-foreground",children:t.variants.length>0?"Nothing was recorded about what this attempt was sent with.":"Nothing is recorded on this block yet."}):s.jsx(a1,{type:e,values:n})}function a1({type:e,values:t}){const n=Nt(e),r=new Set(n.map(o=>o.id)),i=Object.keys(t).filter(o=>!r.has(o));return s.jsxs("dl",{className:"grid grid-cols-[auto_1fr] gap-x-3 gap-y-1",children:[n.map(o=>{const a=xi(o,t[o.id]);return s.jsxs("div",{"data-slot":"block-setting","data-field":o.id,className:"col-span-2 grid grid-cols-subgrid text-xs",children:[s.jsx("dt",{className:"truncate text-muted-foreground",children:o.label}),s.jsx("dd",{className:"min-w-0 truncate text-foreground",title:a||void 0,children:a||s.jsx("span",{className:"text-muted-foreground/60",children:"â"})})]},o.id)}),i.map(o=>{const a=t[o],l=Array.isArray(a)?a.join(", "):String(a??"");return s.jsxs("div",{"data-slot":"block-setting","data-field":o,"data-retired":"true",className:"col-span-2 grid grid-cols-subgrid text-xs",children:[s.jsx("dt",{className:"truncate font-mono text-muted-foreground/70",title:`${o} â no longer a field of this type`,children:o}),s.jsx("dd",{className:"min-w-0 truncate text-foreground",title:l||void 0,children:l||s.jsx("span",{className:"text-muted-foreground/60",children:"â"})})]},o)})]})}function l1({blocks:e,frames:t}){return s.jsx("div",{className:"min-h-0 grow overflow-y-auto border-t border-border px-3 py-2",children:s.jsxs("ul",{className:"flex flex-col gap-0.5",children:[t.map(n=>s.jsxs("li",{"data-slot":"selected-frame","data-frame-id":n.id,className:"flex items-center gap-2 rounded-lg px-1 py-1",children:[s.jsx(ir,{size:13,className:"shrink-0 text-muted-foreground"}),s.jsx("span",{className:"min-w-0 flex-1 truncate text-xs text-foreground",children:Ii(n)}),s.jsx("span",{className:"shrink-0 text-2xs tabular-nums text-muted-foreground/70",children:Si(n)})]},n.id)),e.map(n=>{const r=oe(n.typeId);return s.jsxs("li",{"data-slot":"selected-block","data-block-id":n.id,className:"flex items-center gap-2 rounded-lg px-1 py-1",children:[s.jsx(r.icon,{size:13,className:"shrink-0 text-muted-foreground"}),s.jsx("span",{className:"min-w-0 flex-1 truncate text-xs text-foreground",children:n.title}),n.state!=="complete"&&s.jsx("span",{className:"shrink-0 text-2xs text-muted-foreground
20/70",children:bi[n.state]})]},n.id)})]})})}function u1({actions:e,dependents:t,armedDiscard:n,onAction:r}){const i=e.filter(a=>a.group==="run"),o=e.filter(a=>a.group==="destroy");return s.jsxs("div",{className:"shrink-0 border-t border-border p-2",children:[i.map(a=>s.jsx(zs,{action:a,onAction:r},a.id)),o.map(a=>s.jsx(zs,{action:a,armed:n,onAction:r},a.id)),n&&t.length>0&&s.jsxs("p",{className:"px-2 pt-1 text-2xs leading-relaxed text-muted-foreground",children:[t.join(", ")," ",t.length===1?"was":"were"," made from"," ",t.length===1?"this":"these","."," ",t.length===1?"It keeps":"They keep"," whatever"," ",t.length===1?"it has":"they have"," already produced."]}),[...i,...o].map(a=>a.refusal?s.jsx("p",{className:"px-2 pt-1 text-2xs leading-relaxed text-muted-foreground",children:a.refusal},`${a.id}-refusal`):null)]})}const c1={"run-again":ua,reformat:ir,delete:nn,"discard-run":nn};function zs({action:e,armed:t=!1,onAction:n}){const r=e.refusal!==null,i=c1[e.id]??nn;return s.jsxs("button",{type:"button",disabled:r,onClick:()=>n(e.id),"data-slot":`block-action-${e.id}`,"data-armed":t?"true":void 0,className:G("flex w-full items-center gap-2 rounded-lg px-2 py-1.5 text-left text-xs font-semibold transition-colors","disabled:cursor-not-allowed disabled:opacity-40",e.destructive?t?"bg-destructive/10 text-destructive":"text-destructive hover:bg-destructive/10":"text-foreground hover:bg-muted"),children:[s.jsx(i,{size:14,weight:e.destructive&&t?"fill":"regular",className:"shrink-0"}),t&&e.destructive?`${e.label} anyway`:e.label]})}function d1(e,t){const n=e+t;return t===0?`${n} blocks selected`:e===0?`${n} frames selected`:`${n} objects selected`}function f1({frame:e,onEdit:t}){const[n,r]=m.useState(e.name),i=o=>{t(e.id,{aspectRatio:o})};return s.jsxs("div",{className:"flex min-h-0 grow flex-col gap-3 overflow-y-auto border-t border-border p-3",children:[s.jsxs("div",{className:"flex flex-col gap-1",children:[s.jsx("label",{htmlFor:`frame-name-${e.id}`,className:"text-xs font-semibold text-foreground",children:"Name"}),s.jsx("input",{id:`frame-name-${e.id}`,value:n,onChange:o=>r(o.target.value),onBlur:()=>{n!==e.name&&t(e.id,{name:n})},onKeyDown:o=>{o.key==="Enter"&&o.currentTarget.blur()},maxLength:120,placeholder:"Frame","data-slot":"frame-name",className:"w-full rounded-lg border border-border bg-background px-2 py-1.5 text-xs text-foreground outline-none placeholder:text-muted-foreground/60 focus-visible:ring-2 focus-visible:ring-sidebar-ring"})]}),s.jsxs("div",{className:"flex flex-col gap-1",children:[s.jsx("span",{className:"text-xs font-semibold text-foreground",children:"Size"}),s.jsx("p",{className:"text-xs tabular-nums text-foreground",children:Si(e)}),s.jsx("p",{className:"text-2xs leading-relaxed text-muted-foreground/70",children:"Drag a corner on the canvas to resize."})]}),s.jsxs("div",{className:"flex flex-col gap-1",children:[s.jsx("span",{className:"text-xs font-semibold text-foreground",children:"Screen ratio"}),s.jsx("p",{className:"text-2xs leading-relaxed text-muted-foreground/70",children:"Shapes the frame to a screen. It is a ratio, not a screen â nothing is linked."}),s.jsxs("div",{className:"mt-0.5 flex flex-wrap gap-1",children:[s.jsx(_s,{label:"None",selected:e.aspectRatio===null,onClick:()=>i(null)}),Nc.map(o=>s.jsx(_s,{label:o,selected:e.aspectRatio===o,onClick:()=>i(o)},o))]}),e.aspectRatio&&s.jsxs("p",{className:"mt-0.5 text-2xs leading-relaxed text-muted-foreground/70",children:["Height follows the width while this is set â ",e.aspectRatio," is"," ",Math.round(e.width)," Ã ",Ni(e.width,e.aspectRatio),"."]})]})]})}function _s({label:e,selected:t,onClick:n}){return s.jsx("button",{type:"button",onClick:n,"aria-pressed":t,"data-slot":"frame-ratio","data-ratio":e,className:G("rounded-md border px-2 py-1 text-xs font-medium tabular-nums transition-colors",t?"border-primary bg-primary/10 text-primary":"border-border text-muted-foreground hover:bg-muted hover:text-foreground"),children:e})}function p1({at:e,actions:t,subject:n,onAction:r,onClose:i}){const a=["run","order","align","destroy"].map(l=>t.filter(u=>u.group===l)).filter(l=>l.length>0);return s.jsxs(ea,{at:e,slot:"object-context-menu",onClose:i,children:[s.jsx(Xs,{children:n}),a.map((l,u)=>s.jsxs("div",{children:[u>0&&s.jsx(Vr,{}),l.map(c=>s.jsx(h1,{action:c,onAction:r},c.id))]},l[0].group))]})}function h1({action:e,onAction:t}){const n=e.refusal!==null;return s.jsx("button",{type:"button",disabled:n,title:e.refusal??void 0,onClick:()=>t(e.id),"data-slot":"object-context-item","data-action":e.id,className:G("flex w-full items-center rounded-lg px-2.5 py-1.5 text-left text-xs font-medium transition-colors","outline-none focus-visible:ring-2 focus-visible:ring-sidebar-ring","disabled:cursor-not-allowed disabled:opacity-40",e.destructive?"text-destructive hover:bg-destructive/10":"text-foreground hover:bg-muted"),children:e.label})}const m1=["gooh-nano-pro","gooh-nano-flash","gooh-flux"];function g1(e){return e==null||e===""?{}:m1.includes(e)?{modelId:e}:{refusal:`${Ht("model",String(e))} canât make a still â nothing was run and nothing was charged.`}}function x1(e){const t=typeof e=="string"?Number.parseInt(e,10):NaN;return Number.isInteger(t)&&t>0?t:void 0}const b1={"align-left":"left","align-center-x":"center-x","align-right":"right","align-top":"top","align-center-y":"center-y","align-bottom":"bottom"},y1={"distribute-horizontal":"horizontal","distribute-vertical":"vertical"};function w1(e,t){const n=e+t;return n===1?e===1?"This block":"This frame":t===0?`${n} blocks`:e===0?`${n} frames`:`${n} objects`}async function k1(e){if(typeof Image>"u"||typeof URL.createObjectURL!="function")return null;const t=URL.createObjectURL(e);try{return await new Promise(n=>{const r=new Image;r.onload=()=>
20n({width:r.naturalWidth,height:r.naturalHeight}),r.onerror=()=>n(null),r.src=t})}finally{URL.revokeObjectURL(t)}}function v1({conversationId:e,onConversationStarted:t,canvasId:n}){const r=n,{canvas:i}=Jn(n),{brand:o}=pi((i==null?void 0:i.brandId)??void 0),{campaign:a}=qs((i==null?void 0:i.campaignId)??void 0),l=m.useMemo(()=>({brandName:(o==null?void 0:o.name)??null,campaignName:(a==null?void 0:a.campaignName)??null}),[o==null?void 0:o.name,a==null?void 0:a.campaignName]),u=ae(w=>w.seedEntry);m.useEffect(()=>{u({mode:e?"agentic":"manual",canvasId:r,conversationId:e??null})},[]);const c=ae(w=>w.bindCanvas);m.useEffect(()=>{r&&c(r)},[r,c]);const f=ae(w=>w.openChat),{blocks:p}=Ou(r),d=m.useMemo(()=>Fu(p),[p]),{frames:h}=bc(r),g=wc(),x=kc(),C=vc(),v=m.useMemo(()=>{const w={};for(const S of d)S.position&&(w[S.id]=S.position);return w},[d]),k=m.useMemo(()=>Jd(d),[d]),j=m.useMemo(()=>cn(d),[d]),R=m.useMemo(()=>d.some(zu),[d]),z=ae(w=>w.honourTakeover);m.useEffect(()=>{R||z()},[R,z]);const[N,V]=m.useState(null),{uploadApi:H}=Ke(),E=ae(w=>w.markFailed),B=Ec(),A=Lc(),{capabilities:P}=hn(),D=m.useMemo(()=>dd(P),[P]),F=_u(),{run:Z}=jl(),K=dn(),ee=Ys(),ne=Du(),ue=$u(),b=ta(),[Ne,we]=m.useState(null),{send:y}=wi(Ne??void 0),ge=m.useCallback(async()=>r,[r]),Ae=m.useCallback(w=>{t(w)},[t]),pe=m.useCallback(async w=>{const{canvasId:S,blockId:M,typeId:L,values:_,prompt:U,composedPrompt:q,negativePrompt:de,inputs:ke,source:be,references:De,opensRun:Ue,message:Ge,operationKey:Pt}=w,Qe=be??Ir(d,ke);if(Ft(L)&&L==="image"){const ft=g1(_.model);"refusal"in ft?E(M,{message:ft.refusal,refunded:!1}):B({canvasId:S,blockId:M,prompt:q,label:U,negativePrompt:de,modelId:ft.modelId,variations:x1(_.variations),aspectRatio:typeof _.ratio=="string"?_.ratio:void 0,intent:Pt===Xt.key?"edit":"still",source:Qe,references:De,config:_})}if(Ft(L)&&L==="adapt"&&A({canvasId:S,blockId:M,ratios:Vt(_.ratios),source:Qe,prompt:typeof _.notes=="string"?_.notes:void 0,config:_}),!Ue)return;const{conversation:Le}=await b.mutateAsync(S);we(Le.id),Ae(Le.id),y(Ge),await K.mutateAsync({canvasId:S,blockId:M,patch:{intake:{clientName:null,brandName:l.brandName,campaignName:l.campaignName}}}),f()},[d,l,K,b,y,Ae,f,B,A,E]),Se=m.useCallback((w,S)=>{var En;const{type:M,fromBlockId:L}=w,{inputs:_,source:U,values:q,references:de,sourceFiles:ke,composedPrompt:be,negativePrompt:De}=S,Ue=j===null,Ge=((En=[q.prompt,q.brief].find(Wt=>typeof Wt=="string"&&Wt.trim().length>0))==null?void 0:En.trim())??"",Pt=L===void 0&&(M.id==="image"||M.id==="video")?hd(typeof q.model=="string"?q.model:void 0):M.id,Qe=oe(Pt),Le=w.operationKey,{operationGroup:ft,operationName:An}=Sr({typeId:M.id,operationKey:Le});(async()=>{const Wt=await ge(),{block:au}=await F.mutateAsync({canvasId:Wt,input:{typeId:Qe.id,title:Qe.label,inputs:[..._],inputSlots:Zn(Dt(Qe.id,Le),_,lu=>{const fo=d.find(uu=>uu.variants.some(cu=>cu.id===lu));return fo?sn(fo):[]}),request:Ue?Ge:null,operationGroup:ft,operationName:An,config:q}});await pe({canvasId:Wt,blockId:au.id,typeId:Qe.id,operationKey:Le,values:q,prompt:Ge,composedPrompt:be,negativePrompt:De,inputs:_,source:U,references:de,opensRun:Ue,message:Ao(M,q,ke)})})()},[d,j,ge,F,pe]),Ee=m.useCallback((w,S)=>{const M=d.find(U=>U.id===S);if(!M)return;const L=M.inputs.filter(U=>{const q=rt(d,U);return!q||q.block.id!==w});if(L.length===M.inputs.length)return;const _=Object.fromEntries(Object.entries(M.inputSlots).filter(([U])=>L.includes(U)));K.mutate({canvasId:M.canvasId,blockId:M.id,patch:{inputs:L,inputSlots:_}})},[d,K]),Ie=m.useCallback(async(w,S,M)=>{var L,_;await K.mutateAsync({canvasId:w,blockId:S,patch:{state:"running"}});try{const U=await H.upload({file:M,canvasId:w,blockId:S}),q=H.contentUrl(U.id),de=(L=U.contentType)!=null&&L.startsWith("image/")?await k1(M):null;await ue.mutateAsync({canvasId:w,blockId:S,input:{label:M.name,provenance:{kind:"uploaded",source:M.name,recordedAt:U.createdAt??new Date().toISOString()},media:de?{src:q,assetId:U.id,...de,alt:M.name}:null}}),await K.mutateAsync({canvasId:w,blockId:S,patch:{state:"complete"}})}catch{const U=((_=d.find(q=>q.id===S))==null?void 0:_.variants.length)??0;await K.mutateAsync({canvasId:w,blockId:S,patch:{state:U>0?"complete":"placeholder"}}),E(S,{message:"That file could not be uploaded. Please try again.",refunded:!1})}},[d,ue,K,H,E]),I=m.useCallback((w,S)=>{const M=d.find(_=>_.id===w);if(!M)return;const L=Co(S);
20if(L!==M.typeId){E(w,{message:`That is ${oe(L).shortLabel.toLowerCase()}, and this block holds ${oe(M.typeId).shortLabel.toLowerCase()}. Bring it in as its own block instead.`,refunded:!1});return}Ie(M.canvasId,w,S)},[d,Ie,E]),W=m.useCallback(w=>{const S=Co(w);(async()=>{const M=await ge(),{block:L}=await F.mutateAsync({canvasId:M,input:{typeId:S,title:w.name}});await Ie(M,L.id,w)})()},[ge,F,Ie]);m.useCallback(()=>{V({type:oe("image"),studioOperationId:Dn.studioOperation,operationKey:Dn.key,panel:Dn.panel})},[]);const Y=m.useCallback((w,S)=>{var Qe;const M=w.blockId;if(M===void 0)return;const L=d.find(Le=>Le.id===M);if(!L||$d(L,d))return;const{inputs:_,source:U,values:q,references:de,sourceFiles:ke,composedPrompt:be,negativePrompt:De}=S,Ue=oe(L.typeId),Ge=j===null,Pt=((Qe=[q.prompt,q.brief].find(Le=>typeof Le=="string"&&Le.trim().length>0))==null?void 0:Qe.trim())??"";(async()=>(await K.mutateAsync({canvasId:L.canvasId,blockId:L.id,patch:{config:q,inputs:[..._],inputSlots:Zn(it(L),_,Le=>{const ft=d.find(An=>An.id===Le||An.variants.some(En=>En.id===Le));return ft?sn(ft):[]}),...Ge?{request:Pt}:{}}}),await pe({canvasId:L.canvasId,blockId:L.id,typeId:L.typeId,operationKey:Hn(L),values:q,prompt:Pt,composedPrompt:be,negativePrompt:De,inputs:_,source:U,references:de,opensRun:Ge,message:Ao(Ue,q,ke)})))()}
20,[d,j,K,pe]),he=m.useCallback((w,S)=>{const{operationId:M}=w,[L,_]=M.split(".");(async()=>{const U=await ge();if(w.blockId!==void 0){await Z({canvasId:U,blockId:w.blockId,request:{operationId:M,modelId:S.modelId,slots:S.slots,...S.mode?{mode:S.mode}:{},...S.acknowledgedCredits!==void 0?{acknowledgedCredits:S.acknowledgedCredits}:{}},label:S.label,config:S.slots,ratio:typeof S.slots.ratio=="string"?S.slots.ratio:null});return}const{block:q}=await F.mutateAsync({canvasId:U,input:{typeId:w.typeId,title:w.typeLabel,inputs:[],request:S.label,operationGroup:L,operationName:_,config:S.slots}});await Z({canvasId:U,blockId:q.id,request:{operationId:M,modelId:S.modelId,slots:S.slots,...S.mode?{mode:S.mode}:{},...S.acknowledgedCredits!==void 0?{acknowledgedCredits:S.acknowledgedCredits}:{}},label:S.label,config:S.slots,ratio:typeof S.slots.ratio=="string"?S.slots.ratio:null})})(),V(null)},[ge,F,Z]),ye=m.useCallback((w,S)=>{w.blockId!==void 0?Y(w,S):Se(w,S),V(null)},[Se,Y]),[Te,Me]=m.useState(Lt),se=m.useMemo(()=>nd(Te,[...d,...h]),[Te,d,h]),fe=m.useMemo(()=>ko(se,d),[se,d]),Re=m.useMemo(()=>ko(se,h),[se,h]),At=fe.length+Re.length,te=At===1&&fe.length===1?fe[0]:null,Et=m.useCallback((w,S,M)=>{if((S==null?void 0:S.pick)==="file"){W(S.file);return}const L=(S==null?void 0:S.pick)==="operation"?S.option:null,_=(L==null?void 0:L.lands)??zi(w),U=M?d.find(be=>be.id===M):void 0,q=!L&&U&&_==="image",de=q?Xt.key:Fi(w,L),ke=q?Xt.studioOperation:(L==null?void 0:L.studioOperation)??w.studioOperation;V({type:oe(_),fromBlockId:M,studioOperationId:ke,operationKey:de,panel:(L==null?void 0:L.panel)??Rn(de),prefill:Kn(_,de,U?[U]:fe).citations})},[d,W,fe]),yn=m.useCallback(w=>{const S=Dd(w);(async()=>{var U;const M=await ge();let L=null,_=null;for(const q of S){const{operationGroup:de,operationName:ke}=Sr({typeId:q.type,operationKey:q.operationKey}),{block:be}=await F.mutateAsync({canvasId:M,input:{typeId:q.type,title:oe(q.type).label,...L&&q.slotKey?{inputs:[L],inputSlots:{[L]:q.slotKey}}:{},operationGroup:de,operationName:ke}});q.step===0&&(_=be.id),L=be.id}if(_){const q=((U=S[0])==null?void 0:U.operationKey)??null;V({type:oe(w.steps[0]),blockId:_,studioOperationId:Hr(w.steps[0],q),operationKey:q,panel:Rn(q)})}})()},[ge,F]),mr=m.useCallback((w,S)=>{const M=d.find(U=>U.id===w);if(!M)return;const L=Vd(M,d)[0];if(!L)return;const _=Hn(L);V({type:oe(L.typeId),blockId:L.id,studioOperationId:bt(L),operationKey:_,panel:Rn(_),prefill:Ud(L,d).map(U=>U===M.id?S:U)})},[d]);m.useEffect(()=>{const w=S=>{if(S.metaKey||S.ctrlKey||S.altKey||N!==null)return;const M=S.target;if(M!=null&&M.closest('input, textarea, select, [contenteditable="true"]')||document.querySelector('[role="dialog"], [role="alertdialog"]'))return;const L=Rd(S.key);L&&(S.preventDefault(),Et(L,null))};return window.addEventListener("keydown",w),()=>window.removeEventListener("keydown",w)},[N,Et]);const Zt=`gooh-studio:${r??"unsaved"}`,T=m.useCallback((w,{additive:S})=>{Me(M=>S?ed(M,w):ya(M,w))},[]),$=fe.length===1&&Re.length===0&&fe[0].variants.length===0&&fe[0].state==="placeholder",Q=m.useCallback(w=>{T(w,{additive:!1}),requestAnimationFrame(()=>wn(!0))},[T]),ie=m.useCallback((w,{additive:S})=>{const M=[];for(const L of document.querySelectorAll('[data-slot="block"], [data-slot="frame"]')){const _=L.dataset.blockId??L.dataset.frameId;if(!_)continue;const U=L.getBoundingClientRect();Gu(w,U)&&M.push(_)}Me(L=>td(L,M,{additive:S}))},[]),ce=m.useCallback(()=>{Me(Lt)},[]),_e=ae(w=>w.slotWidth),ot=Gs()!==null,We=ae(w=>w.blockSlotWidth),ct=Bu(_e,ot,se.size>0?We:null),st=m.useRef(null),Pe=m.useCallback(w=>{st.current=w},[]),dt=m.useCallback(()=>{var w;return(w=st.current)==null?void 0:w.fitView()},[]),Ve=m.useRef(null),[Ye,Dl]=m.useState({top:0,right:0,bottom:0,left:0});m.useEffect(()=>{const w=Ve.current;if(!w)return;const S=()=>{const L=w.getBoundingClientRect(),_={top:Math.round(L.top),right:Math.round(window.innerWidth-L.right),bottom:Math.round(window.innerHeight-L.bottom),left:Math.round(L.left)};Dl(U=>U.top===_.top&&U.right===_.right&&U.bottom===_.bottom&&U.left===_.left?U:_)};S();const M=new ResizeObserver(S);return M.observe(w),window.addEventListener("resize",S),()=>{M.disconnect(),window.removeEventListener("resize",S)}},[]);const $l=m.useMemo(()=>({top:Ye.top,right:Ye.right+ct,bottom:Ye.bottom+mo,left:Ye.left}),[Ye,ct]),Bl=m.useMemo(()=>({top:Ye.top,right:Ye.right,bottom:Ye.bottom,left:Ye.left}),[Ye]),gr=m.useMemo(()=>
20{if(fe.length===0)return[];const w=new Set(fe.map(M=>M.id)),S=new Set(fe.flatMap(M=>[M.id,...M.variants.map(L=>L.id)]));return d.filter(M=>!w.has(M.id)&&M.inputs.some(L=>S.has(L))).map(M=>M.title)},[d,fe]),[xr,so]=m.useState(null),[Vl,wn]=m.useState(!1),[Hl,br]=m.useState(!1);m.useEffect(()=>{so(null),wn(!1),br(!1)},[te==null?void 0:te.id]);const He=m.useMemo(()=>(te==null?void 0:te.variants.find(w=>w.id===xr))??(te?xt(te)??null:null),[te,xr]),[yr,ao]=m.useState(!1);m.useEffect(()=>{ao(!1)},[se]);const[Ul,lo]=m.useState(!1),uo=m.useMemo(()=>{const w=S=>{const M=fe.map(q=>q.id),L=Re.map(q=>q.id),_=M.length>0&&Mn(d,M,S)!==null,U=L.length>0&&Mn(h,L,S)!==null;return _||U?null:S==="front"||S==="forward"?"Already in front of everything in its class.":"Already behind everything in its class."};return{front:w("front"),forward:w("forward"),backward:w("backward"),back:w("back")}},[d,h,fe,Re]),kn=m.useMemo(()=>Qc({blocks:fe,frames:Re,openingId:(j==null?void 0:j.id)??null,runAgainRefusal:te?Xc(te,Ur(te,He),oe(te.typeId).label):null,reformatRefusal:te?He?Ft("adapt")?null:Ai(oe("adapt").label):"There is nothing to reformat yet â this block has not produced anything.":null,zRefusals:uo}),[fe,Re,j,te,He,uo]),vn=m.useRef([]),jn=m.useCallback(()=>{const w=st.current;if(!w)return;const S=[];for(const M of document.querySelectorAll('[data-slot="block"], [data-slot="frame"]')){const L=M.dataset.blockId??M.dataset.frameId;L&&S.push({id:L,...w.toCanvasRect(M.getBoundingClientRect())})}vn.current=S},[]),ql=m.useCallback(w=>{if(!te||!r)return;const S=bt(te);S&&Z({canvasId:r,blockId:te.id,request:{operationId:S,modelId:w.modelId,slots:w.slots,...w.mode?{mode:w.mode}:{},...w.acknowledgedCredits!==void 0?{acknowledgedCredits:w.acknowledgedCredits}:{}},label:w.label,config:w.slots,ratio:typeof w.slots.ratio=="string"?w.slots.ratio:null})},[te,r,Z]),Zl=m.useCallback(w=>{if(!te)return;const S={values:w},M=xa(te);!M||Ur(te,He).source==="none"||B({canvasId:te.canvasId,blockId:te.id,...ba(S.values),intent:M,source:Ir(d,te.inputs),config:S.values})},[d,B,He,te]),Kl=m.useCallback(w=>{if(!te||w.length===0)return;const S=He;if(!S)return;const M=oe("adapt"),L={ratios:[...w]};(async()=>{const{block:_}
20=await F.mutateAsync({canvasId:te.canvasId,input:{typeId:"adapt",title:M.label,inputs:[S.id],inputSlots:{[S.id]:Dt("adapt",Xn)[0].key},...Sr({typeId:"adapt",operationKey:Xn}),config:L}});await A({canvasId:te.canvasId,blockId:_.id,ratios:w,source:Ir(d,[S.id]),config:L})})()},[d,F,A,He,te]),Wl=m.useCallback(w=>{V({type:oe(w.typeId),studioOperationId:Hr(w.typeId,w.key),operationKey:w.key,panel:Rn(w.key),prefill:Kn(w.typeId,w.key,fe).citations})},[fe]),co=m.useCallback(w=>{const S=kn.find(_=>_.id===w);if(!S||S.refusal)return;if(w==="run-again"){if(!te)return;wn(!0);return}if(w==="reformat"){if(!te)return;br(!0);return}if(w==="bring-to-front"||w==="bring-forward"||w==="send-backward"||w==="send-to-back"){const _=w==="bring-to-front"?"front":w==="bring-forward"?"forward":w==="send-backward"?"backward":"back",U=fe.map(be=>be.id),q=U.length>0?Mn(d,U,_):null;if(q)for(const[be,De]of jo(d,q,U)){const Ue=d.find(Ge=>Ge.id===be);Ue&&K.mutate({canvasId:Ue.canvasId,blockId:be,patch:{z:De}})}const de=Re.map(be=>be.id),ke=de.length>0?Mn(h,de,_):null;if(ke)for(const[be,De]of jo(h,ke,de)){const Ue=h.find(Ge=>Ge.id===be);Ue&&x.mutate({canvasId:Ue.canvasId,frameId:be,patch:{z:De}})}return}const M=b1[w],L=y1[w];if(M||L){jn();const _=vn.current.filter(q=>se.has(q.id)),U=M?od(_,M):sd(_,L);for(const[q,de]of U){const ke=d.find(De=>De.id===q);if(ke){ne.mutate({canvasId:ke.canvasId,blockId:ke.id,position:de});continue}const be=h.find(De=>De.id===q);be&&x.mutate({canvasId:be.canvasId,frameId:be.id,patch:{x:de.x,y:de.y}})}return}if(w==="reset-position"){for(const _ of fe)_.position!==null&&ne.mutate({canvasId:_.canvasId,blockId:_.id,position:null});return}if(w==="discard-run"){Me(Lt),lo(!0);return}if(w==="delete"){if(gr.length>0&&!yr){ao(!0);return}const _=fe,U=Re;Me(Lt);for(const q of _)ee.mutate({canvasId:q.canvasId,blockId:q.id});for(const q of U)C.mutate({canvasId:q.canvasId,frameId:q.id})}},[kn,te,He,fe,Re,gr,yr,d,B,ne,ee,C,K,x,se,jn]),[Xe,Nn]=m.useState(null),Gl=m.useCallback(w=>{jn(),Nn({anchorId:w,offset:{x:0,y:0},guides:[]})},[jn]),Yl=m.useCallback((w,S)=>{const M=vn.current.find(ke=>ke.id===w);if(!M){Nn({anchorId:w,offset:S,guides:[]});return}const L={...M,x:M.x+S.x,y:M.y+S.y},_=se.has(w)?se:new Set([w]),U=vn.current.filter(ke=>!_.has(ke.id)),{scale:q}=fi(Zt),de=ld(L,U,ad/Math.max(q,.01));Nn({anchorId:w,offset:{x:de.x-M.x,y:de.y-M.y},guides:de.guides})},[se,Zt]),Xl=m.useCallback(w=>{const S=Xe;if(Nn(null),!S)return;const{offset:M}=S;if(M.x===0&&M.y===0)return;const L=se.has(w)?se:new Set([w]);for(const _ of d){if(!L.has(_.id))continue;const U=_.position??Ta(k,v,_.id);ne.mutate({canvasId:_.canvasId,blockId:_.id,position:{x:Math.round(U.x+M.x),y:Math.round(U.y+M.y)}})}for(const _ of h)L.has(_.id)&&x.mutate({canvasId:_.canvasId,frameId:_.id,patch:{x:Math.round(_.x+M.x),y:Math.round(_.y+M.y)}})},[Xe,se,d,h,k,v,ne,x]),Ql=m.useCallback(w=>Xe&&(se.has(Xe.anchorId)?se:new Set([Xe.anchorId])).has(w)?Xe.offset:null,[Xe,se]),[In,wr]=m.useState(null),[Sn,kr]=m.useState(null),vr=m.useCallback((w,S,M)=>{const L=va(w,S,M);K.mutate({canvasId:w.canvasId,blockId:w.id,patch:{inputs:L.inputs,inputSlots:L.inputSlots}})},[K]),Jl=m.useCallback((w,S)=>{wr({sourceId:w,from:S,to:S})},[]),eu=m.useCallback(w=>{wr(S=>S&&{...S,to:w})},[]),tu=m.useCallback(w=>{var q;const S=In;if(wr(null),!S||!w.targetBlockId)return;const M=d.find(de=>de.id===S.sourceId),L=d.find(de=>de.id===w.targetBlockId);if(!M||!L)return;const _=(q=xt(M))==null?void 0:q.id;if(!_)return;const U=gd({target:L,source:M,forcePicker:w.forcePicker});switch(U.outcome){case"fill":vr(L,_,U.slot.key);return;case"pick":kr({target:L,citation:_,slots:U.slots,point:w.point});return;case"refuse":di.warning(U.reason);return;case"none":return}},[In,d,vr]),nu=m.useCallback(w=>{const S=Sc(w);S&&g.mutate({canvasId:r,input:S})},[r,g]),ru=m.useCallback((w,S)=>{x.mutate({canvasId:r,frameId:w,patch:S})},[r,x]),iu=m.useCallback((w,S)=>{const M=h.find(_=>_.id===w);if(!M)return;const L=S.aspectRatio===void 0?null:Ni(M.width,S.aspectRatio);x.mutate({canvasId:r,frameId:w,patch:L===null?S:{...S,width:M.width,height:L}})},[r,h,x]),[Cn,jr]=m.useState(null),ou=m.useCallback((w,S)=>{const M=rd(se,w);Me(M),jr({at:S,forSelection:M})},[se]),su=Cn!==null&&Cn.forSelection===se,[Kt,Tt]=m.useState(null);return m.useEffect(()=>{if(se.size===0)return;const w=S=>{S.key==="Escape"&&Me(Lt)};return window.addEventListener("keydown",w),()=>window.removeEventListener("keydown",w)},[se.size]),s.jsx(wu,{value:Zt,children:s.jsxs("div",{"data-slot":"gooh-studio",ref:Ve,className:"relative h-full",children:[s.jsxs(Pf,{children:[s.jsx(Ef,{blocks:d,layout:k,onApi:Pe,fitPadding:$l,centrePadding:Bl,frames:h,onBackgroun
20dClick:ce,onMarquee:ie,onDrawBox:nu,selectedIds:se,onSelectObject:T,onObjectContextMenu:ou,onBackgroundContextMenu:Tt,onFrameCommit:ru,dragOffsetFor:Ql,onObjectDragStart:Gl,onObjectDragMove:Yl,onObjectDragEnd:Xl,onDisconnect:Ee,onStartRun:Q,onConnectStart:Jl,onConnectMove:eu,onConnectEnd:tu,guides:(Xe==null?void 0:Xe.guides)??[],onAddStep:(w,S)=>Tt({x:S.x,y:S.y,fromBlockId:w}),children:d.length===0&&s.jsx(D0,{onOpenMenu:Tt})}),In&&s.jsx(qd,{drag:In}),Sn&&s.jsx(Zd,{pick:Sn,blocks:d,onPick:w=>{vr(Sn.target,Sn.citation,w),kr(null)},onDismiss:()=>kr(null)})]}),s.jsx("div",{className:"pointer-events-none absolute bottom-0 left-0 right-0 z-30 flex justify-center",style:{padding:Pn*2},children:s.jsx(L0,{blocks:d,canvasId:r,selected:fe,configuring:N,onConfigure:V,onSubmit:ye,onStudioRun:he,onRunOperation:Et,onRunFlow:yn})}),s.jsx("div",{className:"pointer-events-none absolute bottom-0 right-0 z-30 flex justify-end",style:{padding:Pn*2},children:s.jsx(F0,{onFitView:dt})}),s.jsxs("div",{"data-slot":"gooh-studio-panels",className:"pointer-events-none absolute right-0 z-20 flex items-start justify-end",style:{top:Vu,bottom:mo,right:Pn,gap:Pn},children:[At>0&&!$&&s.jsx(r1,{blocks:fe,canvasBlocks:d,frames:Re,actions:kn,dependents:gr,armedDiscard:yr,selectedVariantId:xr,imageOperations:D,onSelectVariant:so,onVariantAccepted:mr,onAction:co,onStartFrom:Wl,onReUpload:I,onFrameEdit:iu,onClose:ce}),s.jsx(Rx,{blocks:d,conversationId:e??null})]}),su&&Cn&&At>0&&s.jsx(p1,{at:Cn.at,actions:kn,subject:w1(fe.length,Re.length),onAction:w=>{jr(null),co(w)},onClose:()=>jr(null)}),Kt&&s.jsx(ea,{at:Kt,slot:"operation-context-menu",className:"w-64",onClose:()=>Tt(null),onInteractOutside:to,children:s.jsx(Al,{selected:Kt.fromBlockId?d.filter(w=>w.id===Kt.fromBlockId):fe,onRunFlow:w=>{Tt(null),yn(w)},onRun:(w,S)=>{const M=Kt.fromBlockId;Tt(null),Et(w,S,M)}})}),s.jsx(Lx,{blocks:d,open:Ul,onOpenChange:lo}),te&&s.jsx(f0,{block:te,canvasBlocks:d,variant:He,open:Vl,onOpenChange:wn,onConfirm:Zl,onStudioRun:ql},(He==null?void 0:He.id)??"block"),te&&s.jsx(p0,{open:Hl,onOpenChange:br,onConfirm:Kl},te.id)]})})}function fb(){const{canvasId:e}=po.useParams(),{conversation:t}=po.useSearch(),n=ku(),r=m.useRef(void 0);r.current===void 0&&(r.current=Zu());const i=r.current,{canvas:o,isLoading:a,isError:l}=Jn(e),u=ta(),c=m.useRef(!1),f=m.useRef(null),{send:p}=wi(f.current??void 0);return m.useEffect(()=>{!i||t||c.current||!o||(c.current=!0,u.mutateAsync(o.id).then(({conversation:d})=>{f.current=d.id,n({to:"/canvas/$canvasId",params:{canvasId:o.id},search:{conversation:d.id},replace:!0})}).catch(()=>{c.current=!1}))},[i,t,o,u,n]),m.useEffect(()=>{!i||!t||f.current!==t||(f.current=null,p(i))},[i,t,p]),a?s.jsx("div",{className:"text-muted-foreground flex h-full items-center justify-center p-6 text-sm",role:"status","aria-live":"polite",children:"Opening canvasâ¦"}):l||!o?s.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-3 p-6 text-center",children:[s.jsx("p",{className:"text-foreground text-sm font-semibold",children:"Canvas not available"}),s.jsx("p",{className:"text-muted-foreground max-w-sm text-sm",children:"It may have been deleted, or it may not be shared with you."})]}):s.jsxs(s.Fragment,{children:[s.jsx(j1,{canvas:o}),s.jsx(N1,{canvasId:o.id,hasUnsavedChanges:o.hasUnsavedChanges}),s.jsx(v1,{canvasId:o.id,conversationId:t,onConversationStarted:d=>{n({to:"/canvas/$canvasId",params:{canvasId:o.id},search:{conversation:d},replace:!0})}})]})}function j1({canvas:e}){return vu(e),null}function N1({canvasId:e,hasUnsavedChanges:t}){const{blocked:n,proceed:r,stay:i}=Hu({canvasId:e,hasUnsavedChanges:t}),o=ju();return s.jsx(xc,{open:n,onStay:i,onLeave:r,isSaving:o.isPending,onSaveAndLeave:()=>{const a=Uu();o.mutate(e,{onSuccess:()=>r(),onError:()=>{a()}})}})}export{fb as component};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.