@manifest-editor/exhibition-preset 2.0.3-next.0.f58cbd8 → 2.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -1,2 +1,2 @@
1
- var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},s=(n,r,a)=>(a=n==null?{}:e(i(n)),o(r||!n||!n.__esModule?t(a,`default`,{value:n,enumerable:!0}):a,n));let c=require(`@manifest-editor/manifest-preset`);c=s(c);let l=require(`@manifest-editor/shell`),u=require(`@manifest-editor/editors`),d=require(`react-iiif-vault`),f=require(`zustand`),p=require(`react/jsx-runtime`),m=require(`react`);m=s(m);let h=require(`@manifest-editor/components`),g=require(`exhibition-viewer`),_=require(`exhibition-viewer/library`),v=require(`react-aria-components`),y=require(`tailwind-merge`),b=require(`@manifest-editor/manifest-preset/components`),x=require(`@dnd-kit/core`),S=require(`@dnd-kit/modifiers`),C=require(`@dnd-kit/sortable`),w=require(`@dnd-kit/utilities`),T=require(`tiny-invariant`);T=s(T);let E=require(`@manifest-editor/creator-api`),D=require(`@manifest-editor/creators`),O=require(`@iiif/parser`),k=require(`@iiif/helpers`),A=require(`@iiif/parser/image-3`),j=require(`@iiif/helpers/vault/actions`);const M={id:`@exhibition/tour-step-annotations`,label:`Tour steps`,render:()=>(0,p.jsx)(N,{})},ee={border:`2px solid rgba(255, 255, 255, 0.3)`,":hover":{borderColor:`#4B67E1`,backgroundColor:`rgba(255, 255, 255, 0.2)`}};function N(){let e=(0,d.useCanvas)(),t=(0,f.useStore)((0,l.useAtlasStore)(),e=>e.tool.enabled),{rightPanel:n}=(0,l.useLayoutState)(),r=n.current===`@manifest-editor/editor`&&n.state?.currentTab?.startsWith(`@exhibition/tour-steps`),i=e?.annotations[0];return!r||!e||t||!i?null:(0,p.jsx)(p.Fragment,{children:(0,p.jsx)(d.AnnotationPageContext,{annotationPage:i.id,children:(0,p.jsx)(u.ViewerAnnotationPage,{showAnnotationNumber:!0,style:ee})})})}const P=`https://exhibitionviewer.org/iiif/theme-service`,te={en:[`Exhibition viewer theme`]},ne={fontSans:`"Tahoma", "Fira Sans", sans-serif`,fontMono:`"Fira Mono", monospace`,titleTransform:`uppercase`},F={backgroundPrimary:`#e5e7eb`,backgroundSecondary:`#fff`,backgroundOverlay:`rgba(0, 0, 0, 0.3)`,textPrimary:`#fff`,textSecondary:`#000`,imageCaption:`#fff`,annotationSelected:`#facc15`,controlBar:`#6d6e70`,controlBarBorder:`#5a5b5d`,controlHover:`rgba(0, 0, 0, 0.1)`,progressBar:`#fff`,closeBackground:`#000`,closeBackgroundHover:`#373737`,closeText:`#fff`,titleCard:`#facc15`,titleCardText:`#000`,infoBlock:`#000`,infoBlockText:`#fff`,viewerBackground:`#373737`},I={...F,backgroundPrimary:`#fff`,backgroundSecondary:`#fff`,textPrimary:`#000`,textSecondary:`#000`,imageCaption:`#000`,annotationSelected:`#303f9f`,controlBar:`#f9f9f9`,controlBarBorder:`#000`,closeBackground:`#fff`,closeBackgroundHover:`#eee`,closeText:`#000`,progressBar:`#000000`,titleCard:`#fff`,titleCardText:`#000`,infoBlock:`#fff`,infoBlockText:`#000`,viewerBackground:`#e9e9e9`},L={titleBackground:`#fff`,titleColor:`#444`,annotationBackground:`#fff`,annotationColor:`#333`,annotationRadius:`0px`,annotationMaxWidth:`30em`,infoBlockBackground:`#fff`,infoBlockColor:`#444`},re={cutCorners:!0,fullTitleBar:!0,fullWidthGrid:!1,hideTableOfContents:!1,disablePresentation:!1,hideTitle:!1,hideTitleCard:!1,alternativeImageMode:!0,transitionScale:!1,imageInfoIcon:!1,coverImages:!1},R={cutCorners:!1,isFloating:!1,floatingPosition:`bottom-left`},ie={alternativeImageMode:!0,transitionScale:!1,imageInfoIcon:!1,coverImages:!1},ae={version:1,preset:`delft`,shared:ne,delft:{tokens:F,exhibition:re,presentation:R,slideshow:ie},scroll:{tokens:L,options:{showTableOfContents:!1,titleBlock:{fullHeight:!0}}}},oe={delft:ae,minimal:{...ae,preset:`minimal`,shared:{...ne,titleTransform:`none`},delft:{...ae.delft,tokens:I}},gallery:{version:1,preset:`gallery`,shared:{fontSans:`"Gill Sans", "Trebuchet MS", sans-serif`,fontMono:`"Courier Prime", "Courier New", monospace`,titleTransform:`capitalize`},delft:{tokens:{...F,backgroundPrimary:`#f3ecdf`,backgroundSecondary:`#fff8ee`,backgroundOverlay:`rgba(20, 26, 32, 0.45)`,textPrimary:`#fff8ee`,textSecondary:`#2b2118`,imageCaption:`#f8efe1`,annotationSelected:`#f08c2e`,controlBar:`#1f3a5f`,controlBarBorder:`#162b47`,controlHover:`rgba(255, 255, 255, 0.14)`,progressBar:`#f4a261`,closeBackground:`#1f3a5f`,closeBackgroundHover:`#335c8a`,closeText:`#fff8ee`,titleCard:`#c7522a`,titleCardText:`#fff8ee`,infoBlock:`#22313f`,infoBlockText:`#f8efe1`,viewerBackground:`#30414d`},exhibition:{...re,cutCorners:!1,fullTitleBar:!0,fullWidthGrid:!0,alternativeImageMode:!1,transitionScale:!0,imageInfoIcon:!0,coverImages:!0},presentation:{...R,isFloating:!0,floatingPosition:`bottom-right`},slideshow:{...ie,alternativeImageMode:!1,transitionScale:!0,imageInfoIcon:!0,coverImages:!0}},scroll:{tokens:{...L,titleBackground:`#f8efe1`,titleColor:`#2a2119`,annotationBackground:`#22313f`,annotationColor:`#f8efe1`,annotationRadius:`18px`,annotationMaxWidth:`34em`,infoBlockBackground:`#fff8ee`,infoBlockColor:`#2a2119`},options:{showTableOfContents:!0,titleBlock:{fullHeight:!1}}}}};function se(e){return JSON.parse(JSON.stringify(e))}function ce(e){return!!e&&typeof e==`object`&&!Array.isArray(e)}function le(e,t){if(!t)return se(e);let n=se(e);for(let[e,r]of Object.entries(t)){if(r===void 0)continue;let t=n[e];if(ce(t)&&ce(r)){n[e]=le(t,r);continue}n[e]=r}return n}function ue(e){return typeof e==`string`&&e in oe}function de(e=`delft`){return se(oe[e]||ae)}function fe(e){let t=ue(e?.preset)?e.preset:`delft`,n=le(de(t),e||{});return n.version=1,n.preset=t,n}function pe(e){return`${e}#exhibition-viewer-theme`}function me(e,t){return{id:pe(e),type:`Service`,profile:P,label:te,theme:fe(t)}}function he(e){if(!e?.length)return null;let t=e.findIndex(e=>e?.profile===P||e?.theme);return t===-1?null:{index:t,service:e[t]}}function ge(e){return he(e)?.service?.theme}function _e(e,t){let n=[...e||[]],r=he(n);return r?t?(n[r.index]=t,n):(n.splice(r.index,1),n):(t&&n.push(t),n)}function ve(e){return{"--f-font":e.shared.fontSans,"--f-mono-font":e.shared.fontMono,"--delft-title-transform":e.shared.titleTransform,"--delft-bg-primary":e.delft.tokens.backgroundPrimary,"--delft-bg-secondary":e.delft.tokens.backgroundSecondary,"--delft-bg-overlay":e.delft.tokens.backgroundOverlay,"--delft-text-primary":e.delft.tokens.textPrimary,"--delft-text-secondary":e.delft.tokens.textSecondary,"--delft-image-caption":e.delft.tokens.imageCaption,"--delft-annotation-selected":e.delft.tokens.annotationSelected,"--delft-control-bar":e.delft.tokens.controlBar,"--delft-control-bar-border":e.delft.tokens.controlBarBorder,"--delft-control-hover":e.delft.tokens.controlHover,"--delft-progress-bar":e.delft.tokens.progressBar,"--delft-close-background":e.delft.tokens.closeBackground,"--delft-close-background-hover":e.delft.tokens.closeBackgroundHover,"--delft-close-text":e.delft.tokens.closeText,"--delft-title-card":e.delft.tokens.titleCard,"--delft-title-card-text":e.delft.tokens.titleCardText,"--delft-info-block":e.delft.tokens.infoBlock,"--delft-info-block-text":e.delft.tokens.infoBlockText,"--delft-viewer-background":e.delft.tokens.viewerBackground,"--exv-scroll-title-background":e.scroll.tokens.titleBackground,"--exv-scroll-title-color":e.scroll.tokens.titleColor,"--exv-scroll-annotation-background":e.scroll.tokens.annotationBackground,"--exv-scroll-annotation-color":e.scroll.tokens.annotationColor,"--exv-scroll-annotation-radius":e.scroll.tokens.annotationRadius,"--exv-scroll-annotation-max-width":e.scroll.tokens.annotationMaxWidth,"--exv-scroll-info-block-background":e.scroll.tokens.infoBlockBackground,"--exv-scroll-info-block-color":e.scroll.tokens.infoBlockColor}}const ye={id:`@exhibitions/center-panel`,label:`Exhibition editor`,icon:null,render:()=>(0,p.jsx)(be,{}),options:{minWidth:350,maxWidth:350}};function be(){let e=(0,d.useManifest)(),t=(0,d.useVault)(),[n,r]=(0,m.useState)(.8),i=(0,m.useRef)(null),{edit:a,leftPanel:o}=(0,l.useLayoutActions)(),s=(0,m.useMemo)(()=>e?fe(ge(e.service||e.services)):null,[e]),c=(0,m.useMemo)(()=>({localeStringEditor:e=>(0,p.jsxs)(`span`,{className:`inline-flex items-center hover:ring-4 hover:ring-me-primary-500`,children:[e.original,(0,p.jsx)(v.Button,{className:`py-1 px-2 inline-block`,onPress:()=>a(e.resource),children:(0,p.jsx)(h.EditTextIcon,{className:`text-xl`})})]}),canvasPreviewEditor:e=>(0,p.jsxs)(`div`,{className:`w-full h-full flex-1 flex relative`,children:[e.original,(0,p.jsx)(`button`,{onClick:t=>{t.preventDefault(),t.stopPropagation(),a(e.resource),o.open({id:`canvas-listing`})},className:`absolute top-5 right-5 bg-white text-black p-2 rounded z-40`,children:`EDIT`})]})}),[]);return(0,m.useEffect)(()=>{for(let n of e?.items||[]){let e=t.get(n);e&&!Array.isArray(e.items)&&t.modifyEntityField(e,`items`,[]);for(let n of[...e?.items||[],...e?.annotations||[]]){let e=t.get(n);e&&!Array.isArray(e.items)&&t.modifyEntityField(e,`items`,[])}}},[e,t]),(0,m.useLayoutEffect)(()=>{if(i.current){let e=i.current.offsetWidth/1200;r(Math.max(1,e))}},[]),e?(0,p.jsx)(`div`,{ref:i,className:`overflow-y-auto delft-exhibition exhibition-viewer`,style:s?ve(s):void 0,children:(0,p.jsx)(_.EditorHooksProvider,{hooks:c,children:(0,p.jsx)(g.DelftExhibition,{skipLoadManifest:!0,customVault:t,manifest:e.id,options:{...s?.delft.exhibition||{},disablePresentation:!0,hideTableOfContents:!0,hideTitle:!0}},n)})}):null}function xe(e,t){let n=new URLSearchParams;switch(Ce(n,`manifest`,t.manifest),Ce(n,`canvas`,t.canvas),e){case`delft`:case`exhibition`:{let e=t;z(n,`cut-corners`,e.cutCorners),z(n,`full-title-bar`,e.fullTitleBar);break}case`minimal`:{let e=t;n.set(`minimal`,`true`),z(n,`cut-corners`,e.cutCorners),z(n,`full-title-bar`,e.fullTitleBar);break}case`presentation`:{let e=t;n.set(`type`,`presentation`),z(n,`cut-corners`,e.cutCorners),z(n,`floating`,e.floating??e.isFloating),Ce(n,`floating-position`,e.floatingPosition);break}case`scroll`:{let e=t;n.set(`type`,`scroll`),we(n,`minimal`,e.minimal),we(n,`manifest-editor-preview`,e.manifestEditorPreview),Ce(n,`manifest-editor-preview-origin`,e.manifestEditorPreviewOrigin);break}case`slideshow`:{let e=t;n.set(`type`,`slideshow`),we(n,`minimal`,e.minimal),z(n,`floating`,e.floating),Ce(n,`floating-position`,e.floatingPosition);break}}return n}function Se(e,t){let n=xe(e,t||{}),r=window.localStorage.getItem(`exhibition-viewer-preview-url`)||process.env.NEXT_PUBLIC_EXHIBITION_VIEWER_URL||(window.location.hostname===`localhost`||window.location.hostname===`127.0.0.1`?`http://localhost:5174/preview/${e}?${n?.toString()}`:`https://preview.exhibitionviewer.org/preview/${e}?${n?.toString()}`),i=new URL(r);return i.searchParams.set(`manifest-editor-preview`,`true`),i.searchParams.set(`manifest-editor-preview-origin`,window.location.origin),i}function Ce(e,t,n){n&&e.set(t,n)}function z(e,t,n){typeof n==`boolean`&&e.set(t,String(n))}function we(e,t,n){n&&e.set(t,`true`)}const Te=`manifest-editor:iframe-preview:connect`,Ee=`manifest-editor:iframe-preview:ready`,De=`manifest-editor:iframe-preview:selection`,Oe=1024,ke=440,Ae=.5;function je({preset:e,presetOptions:t,focusSelectedCanvas:n=!0}){let r=(0,d.useVault)(),i=(0,l.useAppResource)(),a=(0,d.useManifest)(),o=(0,u.useInStack)(`Canvas`),s=(0,m.useRef)(null),c=(0,m.useRef)(null),f=(0,m.useRef)(null),h=(0,m.useRef)(i),g=(0,m.useRef)(null),[_,v]=(0,m.useState)(`waiting`),[b,x]=(0,m.useState)(0),[S,C]=(0,m.useState)(!1),[w,T]=(0,m.useState)(!1),E=n&&(o?.resource.source.id||a?.items?.[0]?.id)||null,D=(0,m.useMemo)(()=>Se(e,t).toString(),[e,t]),O=(0,m.useMemo)(()=>new URL(D).origin,[D]),k=S?Ae:1,A=w?440:b?Math.round(b/k):0,j=A>0&&A<=Oe;h.current=i,g.current=E;let M=(0,m.useCallback)(()=>{let e=s.current;if(!e?.contentWindow)return;f.current?.(),v(`waiting`);let t=new MessageChannel;f.current=(0,l.createIframeVaultBridge)(r,t.port1);try{e.contentWindow.postMessage({_type:`manifest-editor:iframe-preview:connect`,resource:h.current,canvasId:g.current},O,[t.port2]),v(`connected`)}catch{f.current?.(),f.current=null,v(`error`)}},[O,r]);(0,m.useEffect)(()=>{function e(e){e.origin===O&&e.source===s.current?.contentWindow&&e.data?._type===`manifest-editor:iframe-preview:ready`&&M()}return window.addEventListener(`message`,e),()=>{window.removeEventListener(`message`,e),f.current?.(),f.current=null}},[M,O]),(0,m.useEffect)(()=>{let e=s.current?.contentWindow;!e||_!==`connected`||e.postMessage({_type:`manifest-editor:iframe-preview:selection`,resource:i,canvasId:E},O)},[_,i.id,i.type,E,O]),(0,m.useEffect)(()=>{let e=c.current;if(!e)return;let t=()=>{x(e.getBoundingClientRect().width)};t();let n=new ResizeObserver(t);return n.observe(e),()=>n.disconnect()},[]),(0,m.useEffect)(()=>{if(b){if(b>Oe){C(!1);return}T(!1)}},[b]);let ee=(0,m.useCallback)(e=>{C(e),e&&T(!1)},[]),N=(0,m.useCallback)(e=>{T(e),e&&C(!1)},[]);return(0,p.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col bg-zinc-950`,children:[_===`connected`?null:(0,p.jsx)(`div`,{className:`border-b border-zinc-800 bg-zinc-900 px-3 py-2 text-sm text-zinc-300`,children:_===`error`?`Preview connection failed.`:`Connecting to local exhibition viewer...`}),(0,p.jsx)(Me,{iframeViewportWidth:A,isMobileViewport:j,showScaleOption:b>0&&b<=Oe,showMobileWidthOption:b>Oe,useScaledPreview:S,useMobileWidthPreview:w,onUseScaledPreviewChange:ee,onUseMobileWidthPreviewChange:N}),(0,p.jsx)(`div`,{ref:c,className:(0,y.twMerge)(`flex min-h-0 flex-1 overflow-hidden bg-white`,S?`justify-start`:`justify-center`),children:(0,p.jsx)(`iframe`,{ref:s,src:D,title:`Exhibition preview`,className:(0,y.twMerge)(`block h-full shrink-0 border-0 bg-white`,w?`shadow-2xl shadow-black/40`:``),style:{width:w?440:S?`${100/Ae}%`:`100%`,maxWidth:w?`100%`:void 0,height:S?`${100/Ae}%`:`100%`,transform:S?`scale(${Ae})`:void 0,transformOrigin:`top left`},onLoad:()=>v(`waiting`)})})]})}function Me({iframeViewportWidth:e,isMobileViewport:t,showScaleOption:n,showMobileWidthOption:r,useScaledPreview:i,useMobileWidthPreview:a,onUseScaledPreviewChange:o,onUseMobileWidthPreviewChange:s}){return e?(0,p.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3 border-b border-zinc-800/80 bg-zinc-900 px-3 py-2 text-xs text-zinc-200`,children:[(0,p.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,p.jsx)(`span`,{className:(0,y.twMerge)(`shrink-0 rounded-full px-2 py-1 font-semibold ring-1 ring-inset`,t?`bg-amber-300/90 text-amber-950 ring-amber-200/50`:`bg-emerald-300/90 text-emerald-950 ring-emerald-200/50`),children:t?`Mobile view`:`Desktop view`}),(0,p.jsxs)(`span`,{className:`truncate text-zinc-400`,children:[`Iframe viewport: `,e,`px. Mobile starts at`,` `,Oe,`px and below.`]})]}),n?(0,p.jsx)(Ne,{label:`50% scale`,checked:i,onChange:o}):null,r?(0,p.jsx)(Ne,{label:`Mobile width`,checked:a,onChange:s}):null]}):null}function Ne({label:e,checked:t,onChange:n}){return(0,p.jsxs)(`label`,{className:`flex shrink-0 cursor-pointer items-center gap-2 rounded-md border border-zinc-800 bg-zinc-950/70 px-2.5 py-1.5 font-semibold text-zinc-200 shadow-sm shadow-black/20 transition-colors hover:border-zinc-700 hover:bg-zinc-950`,children:[(0,p.jsx)(`span`,{children:e}),(0,p.jsx)(`input`,{type:`checkbox`,className:`peer sr-only`,checked:t,onChange:e=>n(e.currentTarget.checked)}),(0,p.jsx)(`span`,{className:`relative h-5 w-9 rounded-full bg-zinc-700/80 transition-colors after:absolute after:left-0.5 after:top-0.5 after:h-4 after:w-4 after:rounded-full after:bg-zinc-100 after:shadow after:shadow-black/20 after:transition-transform peer-checked:bg-me-primary-500 peer-checked:after:translate-x-4`})]})}const Pe=`@exhibitions/remote-preview-panel`,Fe=`exhibition`,Ie=`exhibition-preview-preset`,Le=[{value:`exhibition`,label:`Full page`},{value:`scroll`,label:`Scroll`},{value:`slideshow`,label:`Slideshow`}];function Re(){let[e,t]=(0,l.useLocalStorage)(`exhibition-preview-preset`,Fe),{centerPanel:n}=(0,l.useLayoutState)(),{centerPanel:r}=(0,l.useLayoutActions)();return[e||Fe,(0,m.useCallback)(e=>{t(e),n.current===Pe&&r.open({id:Pe,state:{preset:e}})},[n.current,r,t])]}function ze(e){return(0,p.jsxs)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,width:`1em`,height:`1em`,viewBox:`0 0 24 24`,fill:`currentColor`,...e,children:[(0,p.jsx)(`title`,{children:`Preview`}),(0,p.jsx)(`path`,{d:`M12 5c5 0 9.27 3.11 11 7-1.73 3.89-6 7-11 7s-9.27-3.11-11-7c1.73-3.89 6-7 11-7Zm0 2c-3.72 0-7.04 2.01-8.74 5C4.96 14.99 8.28 17 12 17s7.04-2.01 8.74-5C19.04 9.01 15.72 7 12 7Zm0 2.5A2.5 2.5 0 1 1 12 14a2.5 2.5 0 0 1 0-5Z`})]})}const Be=Fe,Ve={id:Pe,label:`Exhibition preview`,icon:(0,p.jsx)(ze,{}),defaultState:{},render:e=>(0,p.jsx)(He,{state:e}),options:{minWidth:350}};function He({state:e}){let[t]=Re();return(0,p.jsx)(je,{preset:e.preset||t||Be,focusSelectedCanvas:!1})}function Ue({children:e}){let t=(0,d.useManifest)(),{edit:n}=(0,l.useLayoutActions)();return(0,p.jsxs)(`div`,{className:`grid auto-rows-auto grid-cols-12 content-center justify-center gap-2 p-2`,children:[(0,p.jsx)(`div`,{className:`col-span-12 row-span-2 text-black flex flex-col items-center justify-center`,children:(0,p.jsx)(v.Button,{onPress:()=>t&&n(t),className:`col-span-4 row-span-4 text-md text-left text-black hover:bg-slate-100 w-full flex items-center justify-center`,children:(0,p.jsx)(d.LocaleString,{className:`block w-full text-left`,children:t?.label})})}),e]})}const We={"h-1":`lg:min-h-[100px] row-span-1`,"h-2":`lg:min-h-[200px] row-span-2`,"h-3":`lg:min-h-[300px] row-span-3`,"h-4":`lg:min-h-[400px] row-span-4`,"h-5":`lg:min-h-[500px] row-span-5`,"h-6":`lg:min-h-[600px] row-span-6`,"h-7":`lg:min-h-[700px] row-span-7`,"h-8":`lg:min-h-[800px] row-span-8`,"h-9":`lg:min-h-[900px] row-span-9`,"h-10":`lg:min-h-[1000px] row-span-10`,"h-11":`lg:min-h-[1100px] row-span-11`,"h-12":`lg:min-h-[1200px] row-span-12`},Ge={"h-1":`lg:min-h-[25px] row-span-1`,"h-2":`lg:min-h-[50px] row-span-2`,"h-3":`lg:min-h-[75px] row-span-3`,"h-4":`lg:min-h-[100px] row-span-4`,"h-5":`lg:min-h-[125px] row-span-5`,"h-6":`lg:min-h-[150px] row-span-6`,"h-7":`lg:min-h-[175px] row-span-7`,"h-8":`lg:min-h-[200px] row-span-8`,"h-9":`lg:min-h-[225px] row-span-9`,"h-10":`lg:min-h-[250px] row-span-10`,"h-11":`lg:min-h-[275px] row-span-11`,"h-12":`lg:min-h-[300px] row-span-12`},Ke={"w-1":`col-span-1`,"w-2":`col-span-2`,"w-3":`col-span-3`,"w-4":`col-span-4`,"w-5":`col-span-5`,"w-6":`col-span-6`,"w-7":`col-span-7`,"w-8":`col-span-8`,"w-9":`col-span-9`,"w-10":`col-span-10`,"w-11":`col-span-11`,"w-12":`col-span-12`};function qe(e){let{isLeft:t,isRight:n,isBottom:r}=Ye(e),i=e?.find(e=>e.includes(`h-`)),a=e?.find(e=>e.includes(`w-`));if(!i||!a)return{h:0,w:0,ratio:1};let o={h:Number.parseInt(i.split(`-`)[1]),w:Number.parseInt(a.split(`-`)[1]),ratio:1};return(t||n)&&(o.w*=2/3),r&&(o.h*=2/3),o.h&&o.w&&(o.ratio=o.w/o.h),o}function Je(e,t=!1,n=!0){(!e||e.length===0)&&(e=[`h-8`,`w-8`,`image`]);let r=e.find(e=>e.includes(`h-`)),i=e.find(e=>e.includes(`w-`)),a=[];return t&&r===`h-4`&&(r=`h-8`),a.push(n?Ge[r]:We[r]),a.push(Ke[i]),a.join(` `)}function Ye(e){let t=e?.includes(`right`),n=e?.includes(`left`),r=e?.includes(`bottom`),i=e?.includes(`top`),a=e?.includes(`image`)||!n&&!t&&!r&&!i;return{isRight:t,isLeft:n,isBottom:r,isTop:i,isInfo:e?.includes(`info`),isImage:a}}function B(e,t){return t.get(e)?.type===`Canvas`}function Xe(e,t){let n=e.source?.id,r=e.source?.type;if(!n||!r)return!1;try{return(t.get({id:n,type:r})?.behavior||[]).includes(`info`)}catch{return!1}}function Ze(e,t){let n=e.source?.id,r=e.source?.type;if(!n||!r)return!1;try{let e=t.get({id:n,type:r}),i=Array.isArray(e?.items)?e.items:[];for(let e of i){let n=t.get(e,{skipSelfReturn:!1}),r=Array.isArray(n?.items)?n.items:[];for(let e of r){let n=t.get(e,{skipSelfReturn:!1}),r=Array.isArray(n?.body)?n.body[0]:n?.body,i=r?.id&&t.get(r,{skipSelfReturn:!1})||r,a=i?.type===`SpecificResource`?i.source:i,o=Array.isArray(a?.service)?a.service:a?.service?[a.service]:[];if(a?.type===`Video`||o.some(e=>e?.profile===`https://www.youtube.com`))return!0}}}catch{return!1}return!1}function Qe(e){if(!e)return!1;let t=e.behavior||[];if(t.includes(`image`)||t.includes(`info`))return!0;for(let e of t)if(e.startsWith(`w-`)||e.startsWith(`h-`))return!0;return!1}const V=(0,f.create)(e=>({selectedAnnotationId:null,repositioningAnnotationId:null,selectedTextRegion:null,repositioningTextRegion:null,selectedTourStepId:null,repositioningTourStepId:null,selectAnnotation:t=>e({selectedAnnotationId:t,repositioningAnnotationId:null,selectedTextRegion:null,repositioningTextRegion:null}),startRepositioning:t=>e({selectedAnnotationId:t,repositioningAnnotationId:t,selectedTextRegion:null,repositioningTextRegion:null}),stopRepositioning:()=>e({repositioningAnnotationId:null}),selectTextRegion:t=>e({selectedAnnotationId:null,repositioningAnnotationId:null,selectedTextRegion:t,repositioningTextRegion:null}),startTextRepositioning:t=>e({selectedAnnotationId:null,repositioningAnnotationId:null,selectedTextRegion:t,repositioningTextRegion:t}),stopTextRepositioning:()=>e({repositioningTextRegion:null}),selectTourStep:t=>e({selectedTourStepId:t,repositioningTourStepId:null}),startTourStepRepositioning:t=>e({selectedTourStepId:t,repositioningTourStepId:t}),stopTourStepRepositioning:()=>e({repositioningTourStepId:null}),clear:()=>e({selectedAnnotationId:null,repositioningAnnotationId:null,selectedTextRegion:null,repositioningTextRegion:null,selectedTourStepId:null,repositioningTourStepId:null})})),H=(0,f.create)(e=>({requestedTab:null,showTourSteps:!1,requestTab:t=>e({requestedTab:t}),clearRequestedTab:()=>e({requestedTab:null}),setShowTourSteps:t=>e({showTourSteps:t})}));function $e(e){let t=Number(e?.width)||1920,n=Number(e?.height)||1080,r=ut(e);return r.content?r.content:{x:Math.round(t*.1),y:Math.round(n*.1),width:Math.round(t*.8),height:Math.round(n*.8)}}function et(e,t){return{type:`SpecificResource`,source:{id:e.id,type:`Canvas`},selector:{type:`FragmentSelector`,value:`xywh=${Math.round(t.x)},${Math.round(t.y)},${Math.round(t.width)},${Math.round(t.height)}`}}}function tt(e){return et(e,$e(e))}function U(e,t){return it(e,t?.items||[]).filter(e=>(Array.isArray(e?.motivation)?e.motivation:[e?.motivation]).includes(`painting`))}function nt(e,t){return it(e,t?.annotations||[])}function rt(e,t){return!t||(Array.isArray(t?.behavior)?t.behavior:[]).includes(`info`)?!1:!U(e,t).some(t=>{let n=ft(e,t);return!!(vt(n)||yt(n))})}function it(e,t){let n=[];for(let r of t){let t=e.get(r,{skipSelfReturn:!1});for(let r of t?.items||[]){let t=e.get(r,{skipSelfReturn:!1});t&&n.push(t)}}return n}function at(e,t){return U(e,t).map(n=>{let r=ft(e,n);return{annotation:n,box:ot(n,t),html:gt(r),imageUrl:ht(e,r),videoUrl:vt(r),youtubeId:yt(r)}})}function ot(e,t){let n=Number(t?.width)||1920,r=Number(t?.height)||1080,i=e?.target;if(typeof i==`string`&&i.includes(`#xywh=`)){let e=pt(i.split(`#xywh=`)[1]);if(e)return e}let a=i?.selector,o=Array.isArray(a)?a.find(e=>e?.spatial||e?.points):a;if(o?.spatial)return o.spatial;if(Array.isArray(o?.points)){let e=o.points.filter(e=>Array.isArray(e)&&Number.isFinite(e[0])&&Number.isFinite(e[1]));if(e.length){let t=e.map(e=>e[0]),n=e.map(e=>e[1]),r=Math.min(...t),i=Math.min(...n);return{x:r,y:i,width:Math.max(1,Math.max(...t)-r),height:Math.max(1,Math.max(...n)-i)}}}let s=Array.isArray(a)?a.find(e=>e?.value?.startsWith?.(`xywh=`))?.value:a?.value;if(typeof s==`string`&&s.includes(`xywh=`)){let e=pt(s.split(`xywh=`)[1]);if(e)return e}return{x:0,y:0,width:n,height:r}}function st(e,t,n,r){e.modifyEntityField({id:n,type:`Annotation`},`target`,et(t,dt(t,r)))}function ct(e,t,n){let r=dt(t,n),i=Array.isArray(t?.behavior)?t.behavior:[];e.modifyEntityField(t,`behavior`,i.filter(e=>!e.startsWith(`text-xywh=`)).concat(`text-xywh=${Math.round(r.x)},${Math.round(r.y)},${Math.round(r.width)},${Math.round(r.height)}`))}function lt(e,t){if(t)for(let n of U(e,t)){let r=n?.target;(r?.type===`SpecificResource`&&r?.source?.type===`Canvas`&&!r.selector||r?.type===`Canvas`||r===t.id)&&st(e,t,n.id,ut(t).content||$e(t))}}function ut(e){let t=Number(e?.width)||1920,n=Number(e?.height)||1080,r=Array.isArray(e?.behavior)?e.behavior:[],i=mt(r);return r.includes(`right`)?{content:{x:0,y:0,width:Math.round(t*2/3),height:n},text:i||{x:Math.round(t*2/3),y:0,width:Math.round(t/3),height:n}}:r.includes(`left`)?{content:{x:Math.round(t/3),y:0,width:Math.round(t*2/3),height:n},text:i||{x:0,y:0,width:Math.round(t/3),height:n}}:r.includes(`bottom`)?{content:{x:0,y:0,width:t,height:Math.round(n*2/3)},text:i||{x:0,y:Math.round(n*2/3),width:t,height:Math.round(n/3)}}:r.includes(`top`)?{content:{x:0,y:Math.round(n/3),width:t,height:Math.round(n*2/3)},text:i||{x:0,y:0,width:t,height:Math.round(n/3)}}:r.includes(`info`)?{content:null,text:i||{x:0,y:0,width:t,height:n}}:r.includes(`image`)?{content:{x:0,y:0,width:t,height:n},text:i}:{content:null,text:i}}function dt(e,t){let n=Number(e?.width)||1920,r=Number(e?.height)||1080,i=Math.max(1,Math.min(t.width,n)),a=Math.max(1,Math.min(t.height,r)),o=Math.max(0,Math.min(t.x,n-i)),s=Math.max(0,Math.min(t.y,r-a));return{x:Math.round(o),y:Math.round(s),width:Math.round(i),height:Math.round(a)}}function ft(e,t){let n=Array.isArray(t?.body)?t.body[0]:t?.body,r=n?e.get(n,{skipSelfReturn:!1}):null;return r?.type===`SpecificResource`?r.source:r||n||null}function pt(e){let t=e?e.split(/[,&]/).slice(0,4).map(Number):[];if(t.length===4&&t.every(e=>Number.isFinite(e))){let[e,n,r,i]=t;return{x:e,y:n,width:r,height:i}}return null}function mt(e){let t=e.find(e=>e.startsWith(`text-xywh=`))?.replace(`text-xywh=`,``);return pt(t)}function ht(e,t){let n=_t(e,t);if(n?.type===`Choice`){let t=Array.isArray(n.items)?n.items:[];for(let n of t){let t=ht(e,n);if(t)return t}}if(n?.type===`Canvas`){let t=e.get({id:n.id,type:`Canvas`},{skipSelfReturn:!1})||n,r=Array.isArray(t.thumbnail)?t.thumbnail[0]:t.thumbnail;if(r?.id)return r.id;for(let n of U(e,t)){let t=ht(e,ft(e,n));if(t)return t}}let r=Array.isArray(n?.service)?n.service[0]:n?.service,i=r?.id||r?.[`@id`];return i?`${i.replace(/\/$/,``)}/full/1000,/0/default.jpg`:n?.type===`Image`&&n.id?n.id:null}function gt(e){let t=e?.type===`SpecificResource`?e.source:e;return t?.type===`Text`||t?.type===`TextualBody`||t?.format===`text/html`||t?.format===`text/plain`?t.value||``:null}function _t(e,t){return t?.type===`SpecificResource`?_t(e,t.source):t?.id&&t?.type===`ContentResource`?e.get({id:t.id,type:`ContentResource`},{skipSelfReturn:!1})||t:t?.id&&!t.items&&!t.value&&!t.service&&!t.format&&!t.width&&!t.height&&e.get(t,{skipSelfReturn:!1})||t}function vt(e){let t=e?.type===`SpecificResource`?e.source:e;return t?.type===`Video`&&!yt(t)?t.id:null}function yt(e){let t=e?.type===`SpecificResource`?e.source:e,n=((t?.service||[]).find(e=>e?.profile===`https://www.youtube.com`)?.id||t?.id||``).match(/^.*(?:(?:youtu\.be\/|v\/|vi\/|u\/\w\/|embed\/|shorts\/)|(?:(?:watch)?\?vi?=|&vi?=))([^#&?]*).*/);return n?n[1]:null}const bt=`editorial-text`;function xt({className:e,editable:t=!1,mode:n=`edit`,showTourSteps:r=!1}){let i=(0,d.useCanvas)(),a=(0,d.useVault)(),o=(0,u.useInStack)(`Annotation`),s=(0,m.useRef)(null),c=H(e=>e.requestTab),{selectedAnnotationId:l,repositioningAnnotationId:f,selectedTextRegion:h,repositioningTextRegion:g,selectedTourStepId:_,repositioningTourStepId:v,selectAnnotation:b,startRepositioning:x,selectTextRegion:S,selectTourStep:C}=V();(0,m.useEffect)(()=>{lt(a,i)},[i?.id,a]);let w=(0,d.useVaultSelector)((e,t)=>i?at(t,i):[],[i?.id,i?.items?.[0]?.id]),T=(0,d.useVaultSelector)((e,t)=>i?nt(t,i):[],[i?.id,i?.annotations?.[0]?.id]);if(!i)return null;let E=Number(i.width)||1920,D=Number(i.height)||1080,O=ut(i),k=Array.isArray(i.behavior)?i.behavior:[],A=o?.resource.source.id,j=n===`edit`&&r,M=n===`edit`&&!r;return(0,p.jsxs)(`div`,{ref:s,className:(0,y.twMerge)(`relative h-full w-full overflow-hidden`,n===`edit`&&`bg-white`,e),style:{aspectRatio:`${E} / ${D}`},children:[w.length?w.map(e=>{let r=A===e.annotation.id,o=r||l===e.annotation.id,u=f===e.annotation.id;return(0,p.jsxs)(`div`,{className:(0,y.twMerge)(`absolute overflow-hidden`,M&&o&&`ring-4 ring-me-primary-500 ring-offset-2 ring-offset-white`,(u||r)&&M&&`cursor-move select-none touch-none`),style:{left:`${e.box.x/E*100}%`,top:`${e.box.y/D*100}%`,width:`${e.box.width/E*100}%`,height:`${e.box.height/D*100}%`},onPointerDown:M&&(u||r)?t=>Tt({event:t,mode:`move`,canvas:i,annotation:e.annotation,vault:a,startBox:e.box,stage:s.current}):M&&t?t=>{b(e.annotation.id),x(e.annotation.id),c(`content`),Tt({event:t,mode:`move`,canvas:i,annotation:e.annotation,vault:a,startBox:e.box,stage:s.current})}:void 0,children:[(0,p.jsx)(wt,{layer:e,mode:n,cover:k.includes(`cover`)}),M&&(u||r)?(0,p.jsx)(`div`,{className:`absolute bottom-0 right-0 h-4 w-4 cursor-se-resize rounded-tl bg-me-primary-500`,onPointerDown:t=>{t.stopPropagation(),Tt({event:t,mode:`resize`,canvas:i,annotation:e.annotation,vault:a,startBox:e.box,stage:s.current})}}):null]},e.annotation.id)}):(0,p.jsx)(`div`,{className:(0,y.twMerge)(`flex h-full w-full items-center justify-center text-sm font-semibold`,n===`preview`?`text-white/40`:`bg-white text-slate-400`),children:n===`preview`?`This slide has no content yet`:`Empty slide`}),O.text?(0,p.jsx)(Ct,{canvas:i,box:O.text,editable:t&&M,mode:n,repositioning:g===bt,selected:h===bt,stage:s,onSelect:()=>{S(bt),c(`content`)}}):null,j?T.map((e,t)=>(0,p.jsx)(St,{annotation:e,canvas:i,index:t,selected:_===e.id,repositioning:v===e.id,onSelect:()=>{C(e.id)}},e.id)):null]})}function St({annotation:e,canvas:t,index:n,selected:r,repositioning:i,onSelect:a}){let o=ot(e,t),s=Number(t.width)||1920,c=Number(t.height)||1080,l=`#6d5aa8`;return(0,p.jsx)(`div`,{className:(0,y.twMerge)(`absolute select-none border-2 border-me-primary-500 bg-me-primary-500/10 touch-none`,r?`z-40`:`z-30`,`cursor-pointer`,r?`border-4`:`ring-2 ring-white`),style:{left:`${o.x/s*100}%`,top:`${o.y/c*100}%`,width:`${o.width/s*100}%`,height:`${o.height/c*100}%`,...r?{backgroundColor:`rgba(109, 90, 168, 0.2)`,borderColor:l,boxShadow:`0 0 0 4px rgba(109, 90, 168, 0.22), 0 0 0 8px rgba(109, 90, 168, 0.14)`}:{}},onPointerDown:e=>{e.stopPropagation(),a()},children:(0,p.jsxs)(`span`,{className:(0,y.twMerge)(`absolute left-1 top-1 rounded px-1.5 py-0.5 text-xs font-semibold text-white`,!r&&`bg-me-primary-500`),style:r?{backgroundColor:l}:void 0,children:[`Step `,n+1]})})}function Ct({canvas:e,box:t,editable:n,mode:r,onSelect:i,repositioning:a,selected:o,stage:s}){let c=Number(e.width)||1920,l=Number(e.height)||1080,u=(0,d.useVault)();return(0,p.jsxs)(`div`,{className:(0,y.twMerge)(`absolute flex flex-col overflow-hidden bg-black text-white`,r===`preview`?`font-mono`:`p-[3%]`,n&&o&&`ring-4 ring-me-primary-500 ring-offset-2`,n&&a&&`cursor-move select-none touch-none`),style:{left:`${t.x/c*100}%`,top:`${t.y/l*100}%`,width:`${t.width/c*100}%`,height:`${t.height/l*100}%`,...r===`preview`?{containerType:`inline-size`,padding:`3% 4%`}:{}},onPointerDown:n?n=>{i(),a&&Et({event:n,mode:`move`,canvas:e,vault:u,startBox:t,stage:s.current})}:void 0,children:[r===`edit`?(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(`div`,{className:`block cursor-text text-xl font-semibold uppercase leading-tight outline-none focus:ring-2 focus:ring-white/70`,contentEditable:!0,suppressContentEditableWarning:!0,onBlur:t=>u.modifyEntityField(e,`label`,{en:[t.currentTarget.textContent||``]}),children:Dt(e.label)||`Untitled`}),(0,p.jsx)(`div`,{className:`mt-4 block min-h-0 cursor-text overflow-y-auto whitespace-pre-wrap text-sm leading-relaxed opacity-90 outline-none focus:ring-2 focus:ring-white/70`,contentEditable:!0,suppressContentEditableWarning:!0,onBlur:t=>u.modifyEntityField(e,`summary`,{en:[t.currentTarget.textContent||``]}),children:Dt(e.summary)||`Add editorial text`})]}):(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(d.LocaleString,{className:`block font-semibold uppercase leading-tight`,style:{fontSize:`clamp(13px, 5cqw, 26px)`},children:e.label}),(0,p.jsx)(d.LocaleString,{className:`block min-h-0 overflow-y-auto whitespace-pre-wrap opacity-90 leading-[1.45]`,style:{fontSize:`clamp(11px, 3.5cqw, 18px)`,marginTop:`5%`,paddingRight:`2%`},children:e.summary})]}),n&&a?(0,p.jsx)(`div`,{className:`absolute bottom-0 right-0 h-4 w-4 cursor-se-resize rounded-tl bg-me-primary-500`,onPointerDown:n=>{n.stopPropagation(),Et({event:n,mode:`resize`,canvas:e,vault:u,startBox:t,stage:s.current})}}):null]})}function wt({layer:e,mode:t,cover:n}){return e.imageUrl?(0,p.jsx)(`img`,{src:e.imageUrl,alt:``,className:(0,y.twMerge)(`h-full w-full`,n?`object-cover`:`object-contain`)}):e.html===null?e.youtubeId?(0,p.jsx)(`iframe`,{className:`h-full w-full border-0`,title:`YouTube slide content`,src:`https://www.youtube.com/embed/${e.youtubeId}?modestbranding=1&rel=0`,allow:`accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture`,allowFullScreen:!0}):e.videoUrl?(0,p.jsx)(`video`,{className:`h-full w-full bg-black object-contain`,controls:!0,children:(0,p.jsx)(`source`,{src:e.videoUrl})}):(0,p.jsx)(`div`,{className:`flex h-full w-full items-center justify-center rounded bg-slate-100 text-sm font-semibold text-slate-500`,children:`Media`}):e.html?(0,p.jsx)(`div`,{className:`h-full w-full overflow-hidden bg-white p-4 text-slate-900`,dangerouslySetInnerHTML:{__html:e.html}}):t===`preview`?null:(0,p.jsx)(`div`,{className:`h-full w-full overflow-hidden bg-white p-4 text-slate-900`,children:(0,p.jsx)(`div`,{className:`flex h-full items-center justify-center rounded border border-dashed border-slate-300 text-sm font-semibold text-slate-400`,children:`Empty text`})})}function Tt({event:e,mode:t,canvas:n,annotation:r,vault:i,startBox:a,stage:o}){if(!o)return;e.preventDefault();let s=o.getBoundingClientRect(),c=(Number(n?.width)||1920)/s.width,l=(Number(n?.height)||1080)/s.height,u=e.clientX,d=e.clientY,f=e=>{let o=(e.clientX-u)*c,s=(e.clientY-d)*l,f=t===`move`?{...a,x:a.x+o,y:a.y+s}:{...a,width:a.width+o,height:a.height+s};st(i,n,r.id,f)},p=()=>{window.removeEventListener(`pointermove`,f),window.removeEventListener(`pointerup`,p),window.removeEventListener(`pointercancel`,p)};window.addEventListener(`pointermove`,f),window.addEventListener(`pointerup`,p),window.addEventListener(`pointercancel`,p)}function Et({event:e,mode:t,canvas:n,vault:r,startBox:i,stage:a}){if(!a)return;e.preventDefault(),e.stopPropagation();let o=a.getBoundingClientRect(),s=(Number(n?.width)||1920)/o.width,c=(Number(n?.height)||1080)/o.height,l=e.clientX,u=e.clientY,d=e=>{let a=(e.clientX-l)*s,o=(e.clientY-u)*c;ct(r,n,t===`move`?{...i,x:i.x+a,y:i.y+o}:{...i,width:i.width+a,height:i.height+o})},f=()=>{window.removeEventListener(`pointermove`,d),window.removeEventListener(`pointerup`,f),window.removeEventListener(`pointercancel`,f)};window.addEventListener(`pointermove`,d),window.addEventListener(`pointerup`,f),window.addEventListener(`pointercancel`,f)}function Dt(e){if(!e)return``;if(typeof e==`string`)return e;if(Array.isArray(e))return e.filter(Boolean).join(` `);let t=Object.values(e)[0];return Array.isArray(t)?t.filter(Boolean).join(` `):typeof t==`string`?t:``}const Ot=(0,m.forwardRef)(function({isFirst:e,item:t,children:n,...r},i){let a=(0,d.useCanvas)(),[o]=(0,d.useRenderingStrategy)(),s=a?.behavior||[],c=(0,u.useInStack)(`Canvas`),l=Je(a?.behavior,e),{isBottom:f,isImage:m,isInfo:g,isLeft:_}=Ye(a?.behavior),v=c?.resource.source?.id===a?.id,b=s.includes(`w-12`)&&s.includes(`h-8`),x=null;return x=b?(0,p.jsx)(xt,{className:`pointer-events-none h-full w-full`,mode:`preview`}):g?(0,p.jsx)(`div`,{className:`bg-black w-full h-full text-white max-h-40`,children:(0,p.jsx)(`div`,{className:`p-1.5 text-[4px]`,children:o.type===`textual-content`?(0,p.jsx)(d.LocaleString,{enableDangerouslySetInnerHTML:!0,children:o.items[0]?.text}):null})}):(0,p.jsxs)(`div`,{className:(0,y.twMerge)(`flex h-full max-h-full min-h-0`,_?`flex-row-reverse`:f?`flex-col`:`flex-row`),children:[(0,p.jsx)(`div`,{className:`flex-1 overflow-hidden relative justify-self-stretch`,children:(0,p.jsx)(`div`,{className:`absolute inset-0 w-full h-full`,children:(0,p.jsx)(h.LazyThumbnail,{cover:s.includes(`cover`),fade:!1})})}),m?null:(0,p.jsx)(`div`,{className:`${f?`min-h-3 w-full`:`w-1/3`} flex-shrink-0 self-stretch p-2 text-white bg-black rounded`,children:(0,p.jsxs)(`div`,{className:`p-1.5 text-[4px]`,children:[(0,p.jsx)(d.LocaleString,{className:`block mb-1 text-[5px]`,children:a?.label}),(0,p.jsx)(d.LocaleString,{children:a?.summary})]})})]}),(0,p.jsxs)(`div`,{ref:i,className:(0,y.twMerge)(l,`bg-me-gray-700 overflow-hidden hover:ring-2 ring-me-primary-500 relative`,v?`ring-2 ring-me-primary-500`:``),...r,children:[x,n]})});function kt(){let{open:e}=(0,l.useLayoutActions)(),{structural:t,technical:n}=(0,l.useManifestEditor)(),[,r]=(0,l.useCreator)({id:n.id.get(),type:`Manifest`},`items`,`Canvas`);return(0,p.jsx)(Ue,{children:t.items.get().map((t,n)=>(0,p.jsx)(d.CanvasContext,{canvas:t.id,children:(0,p.jsx)(Ot,{isFirst:n===0,item:t,onClick:()=>{e({id:`current-canvas`}),r.edit(t,n)}})},n))})}function At(e){return(0,p.jsxs)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 24 24`,height:`1em`,width:`1em`,...e,children:[(0,p.jsx)(`title`,{children:`Rearrange`}),(0,p.jsx)(`path`,{fill:`none`,d:`M0 0h24v24H0z`}),(0,p.jsx)(`path`,{d:`M20 9H4v2h16V9zM4 15h16v-2H4v2z`,fill:`currentColor`})]})}function jt({isFirst:e,onClick:t,item:n,actions:r}){let{attributes:i,listeners:a,setNodeRef:o,transform:s,transition:c}=(0,C.useSortable)({id:n.id,transition:{duration:150,easing:`cubic-bezier(0.25, 1, 0.5, 1)`}});return(0,p.jsx)(Ot,{ref:o,style:{transform:w.CSS.Translate.toString(s),transition:c},...i,...a,onClick:t,isFirst:e,item:n,children:(0,p.jsxs)(`div`,{className:`absolute top-0.5 right-0.5 flex gap-0.5 items-stretch`,children:[r?.length?(0,p.jsx)(u.AppDropdown,{as:v.Button,className:`bg-white p-1 text-2xl hover:text-me-500 aria-expanded:text-me-600 aria-expanded:bg-me-200 hover:bg-me-100 rounded-sm`,"aria-label":`Action menu`,items:r,children:(0,p.jsx)(h.MoreMenu,{})}):null,(0,p.jsx)(`div`,{className:`bg-white text-2xl h-8 flex items-center p-1 hover:text-me-500 hover:bg-me-100 rounded-sm`,children:(0,p.jsx)(At,{"aria-label":`Reorder item`})})]})})}function Mt(){let e=(0,d.useManifest)(),{structural:t,technical:n}=(0,l.useManifestEditor)(),r=(0,l.useEditingStack)(),i=(0,u.useInStack)(`Canvas`),a=t.items.get(),{open:o}=(0,l.useLayoutActions)(),s=(0,x.useSensors)((0,x.useSensor)(x.PointerSensor,{activationConstraint:{distance:5}}),(0,x.useSensor)(x.KeyboardSensor,{coordinateGetter:C.sortableKeyboardCoordinates})),[,c]=(0,l.useCreator)({id:n.id.get(),type:`Manifest`},`items`,`Canvas`),f=(0,m.useCallback)(e=>{let{active:n,over:r}=e;r&&n.id!==r.id&&t.items.reorder(a.findIndex(e=>e.id===n.id),a.findIndex(e=>e.id===r.id))},[a,t.items]),h=i?.resource.source.id,g=h?a.findIndex(e=>e.id===h):-1,_=g&&g>0?Number(g-1):0;function v(){r.close();let n=t.items.getWithoutTracking();n&&n.length>0?c.edit(n[_]):c.edit(e)}let y=(0,m.useMemo)(()=>(0,u.createAppActions)(t.items,v),[t.items,v]);return(0,p.jsx)(Ue,{children:(0,p.jsx)(x.DndContext,{sensors:s,collisionDetection:x.closestCenter,onDragEnd:f,modifiers:[S.restrictToParentElement],children:(0,p.jsx)(C.SortableContext,{items:a,strategy:C.rectSortingStrategy,children:a.map((t,n)=>t?(0,p.jsx)(d.CanvasContext,{canvas:t.id,children:(0,p.jsx)(jt,{item:t,isFirst:n===0,onClick:()=>{o({id:`current-canvas`}),c.edit(t,n)},actions:y(t,n,e)},t.id)},t.id):null)})})})}const Nt=Ft({label:`Exhibition grid`,creatorFilter:`exhibition-slide`}),Pt=Ft({label:`Slideshow`,creatorFilter:`exhibition-slideshow-slide`});function Ft({label:e,creatorFilter:t}){return{id:`canvas-listing`,label:e,icon:(0,p.jsx)(Lt,{}),render:()=>(0,p.jsx)(It,{creatorFilter:t}),options:{minWidth:350,maxWidth:350}}}function It({creatorFilter:e}){let{structural:t,technical:n}=(0,l.useManifestEditor)(),r={id:n.id.get(),type:`Manifest`},i=t.items.get()||[],a=(0,u.useInStack)(`Canvas`)?.resource.source.id,o=a?i.findIndex(e=>e.id===a):-1,s=o>=0?o+1:void 0,[c,d]=(0,l.useCreator)(r,`items`,`Canvas`,void 0,{isPainting:!0}),[f,m]=(0,u.useToggleList)();return(0,p.jsxs)(h.Sidebar,{children:[(0,p.jsx)(h.SidebarHeader,{title:`Exhibition`,actions:[{icon:f.list?(0,p.jsx)(b.CanvasListingIcon,{className:`text-2xl`}):(0,p.jsx)(Lt,{}),title:f.list?`List view`:`Grid view`,onClick:()=>m(`list`)},{icon:(0,p.jsx)(Rt,{}),title:`Edit slides`,toggled:f.editing,onClick:()=>m(`editing`)},{icon:(0,p.jsx)(zt,{}),title:`Add new slide`,disabled:!c,onClick:()=>d.createFiltered(e,s)}]}),(0,p.jsx)(h.SidebarContent,{children:f.list?(0,p.jsx)(b.CanvasListView,{isEditing:f.editing}):f.editing?(0,p.jsx)(Mt,{}):(0,p.jsx)(kt,{})})]})}function Lt(){return(0,p.jsxs)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,width:`24`,height:`24`,fill:`currentColor`,viewBox:`0 -960 960 960`,children:[(0,p.jsx)(`title`,{children:`Exhibition grid`}),(0,p.jsx)(`path`,{d:`M600-160v-280h280v280H600ZM440-520v-280h440v280H440ZM80-160v-280h440v280H80Zm0-360v-280h280v280H80Zm440-80h280v-120H520v120ZM160-240h280v-120H160v120Zm520 0h120v-120H680v120ZM160-600h120v-120H160v120Zm360 0Zm-80 240Zm240 0ZM280-600Z`})]})}function Rt(){return(0,p.jsxs)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,height:`24`,viewBox:`0 0 24 24`,width:`24`,children:[(0,p.jsx)(`title`,{children:`Edit slides`}),(0,p.jsx)(`path`,{d:`M0 0h24v24H0V0z`,fill:`none`}),(0,p.jsx)(`path`,{d:`M14.06 9.02l.92.92L5.92 19H5v-.92l9.06-9.06M17.66 3c-.25 0-.51.1-.7.29l-1.83 1.83 3.75 3.75 1.83-1.83c.39-.39.39-1.02 0-1.41l-2.34-2.34c-.2-.2-.45-.29-.71-.29zm-3.6 3.19L3 17.25V21h3.75L17.81 9.94l-3.75-3.75z`})]})}function zt(){return(0,p.jsxs)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,width:`24`,height:`24`,fill:`currentColor`,viewBox:`0 -960 960 960`,children:[(0,p.jsx)(`title`,{children:`Add new slide`}),(0,p.jsx)(`path`,{d:`M160-240v-480 480Zm80-80v-200h360v200H240Zm-80 160q-33 0-56.5-23.5T80-240v-480q0-33 23.5-56.5T160-800h640q33 0 56.5 23.5T880-720v240h-80v-240H160v480h360v80H160Zm500-320v-100H360v-60h360v160h-60Zm60 400v-120H600v-80h120v-120h80v120h120v80H800v120h-80Z`})]})}const Bt={id:`@exhibitions/overview-panel`,label:`Preview`,icon:(0,p.jsx)(ze,{}),render:()=>(0,p.jsx)(Vt,{})};function Vt(){return(0,d.useManifest)()?(0,p.jsx)(`div`,{children:`Coming soon.`}):null}const Ht={id:`@exhibitions/theme-panel`,label:`Theme`,icon:(0,p.jsx)(Zt,{}),render:()=>(0,p.jsx)(Xt,{}),options:{minWidth:360,maxWidth:440}};function W({title:e,description:t,children:n}){return(0,p.jsxs)(`section`,{className:`mb-5 border-b border-slate-200 pb-5 last:mb-0 last:border-b-0`,children:[(0,p.jsxs)(`div`,{className:`mb-3`,children:[(0,p.jsx)(`h3`,{className:`text-sm font-semibold`,children:e}),t?(0,p.jsx)(`p`,{className:`mt-1 text-xs text-slate-500`,children:t}):null]}),n?(0,p.jsx)(`div`,{className:`space-y-3`,children:n}):null]})}function Ut({label:e,value:t,onChange:n,options:r}){return(0,p.jsxs)(`div`,{children:[(0,p.jsx)(`div`,{className:`mb-2 text-xs font-medium text-slate-500`,children:e}),(0,p.jsx)(`div`,{className:`flex flex-wrap gap-1 rounded-md border border-slate-200 bg-slate-100 p-1`,children:r.map(e=>{let r=e.value===t;return(0,p.jsx)(v.Button,{className:[`rounded px-2 py-1.5 text-sm transition-colors`,r?`bg-white font-semibold text-slate-950 shadow-sm`:`text-slate-600 hover:bg-white/70 hover:text-slate-900`].join(` `),"aria-pressed":r,onPress:()=>n(e.value),children:e.label},e.value)})})]})}function G({label:e,checked:t,onChange:n}){return(0,p.jsxs)(`label`,{className:`flex items-center gap-3 text-sm`,children:[(0,p.jsx)(`input`,{type:`checkbox`,checked:t,onChange:e=>n(e.target.checked)}),(0,p.jsx)(`span`,{children:e})]})}function K({label:e,value:t,onChange:n}){return(0,p.jsxs)(`div`,{className:`grid grid-cols-[minmax(0,1fr)_auto] items-center gap-3`,children:[(0,p.jsx)(`label`,{className:`text-sm`,children:e}),(0,p.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,p.jsx)(`input`,{className:`h-9 w-12 shrink-0 cursor-pointer rounded border border-slate-300 bg-white p-1`,type:`color`,value:Kt(t),onChange:e=>n(e.target.value)}),(0,p.jsx)(u.Input,{value:t,onChange:e=>n(e.target.value)})]})]})}function Wt({label:e,value:t,onChange:n}){return(0,p.jsxs)(u.InputContainer,{$wide:!0,children:[(0,p.jsx)(u.InputLabel,{children:e}),(0,p.jsx)(u.Input,{value:t,onChange:e=>n(e.target.value)})]})}function Gt({label:e,value:t,onChange:n,options:r}){return(0,p.jsxs)(u.InputContainer,{$wide:!0,children:[(0,p.jsx)(u.InputLabel,{children:e}),(0,p.jsx)(`select`,{className:`w-full rounded border border-slate-300 bg-slate-50 px-3 py-2 text-sm`,value:t,onChange:e=>n(e.target.value),children:r.map(e=>(0,p.jsx)(`option`,{value:e.value,children:e.label},e.value))})]})}function Kt(e){let t=e.trim();if(/^#[0-9a-fA-F]{6}$/.test(t))return t;if(/^#[0-9a-fA-F]{3}$/.test(t)){let[e,n,r]=t.slice(1);return`#${e}${e}${n}${n}${r}${r}`}return`#ffffff`}function qt(e){return JSON.parse(JSON.stringify(e))}function Jt(e,t,n){let r=qt(e),i=r;for(let e of t.slice(0,-1)){var a;(a=i)[e]||(a[e]={}),i=i[e]}let o=t[t.length-1];return o&&(i[o]=n),r}function Yt(e,t){let n=qt(e);for(let e of t){let t=n;for(let n of e.path.slice(0,-1)){var r;(r=t)[n]||(r[n]={}),t=t[n]}let i=e.path[e.path.length-1];i&&(t[i]=e.value)}return n}function Xt(){let e=(0,d.useManifest)(),t=(0,d.useVault)(),[n,r]=(0,m.useState)(`simple`),{centerPanel:i}=(0,l.useLayoutState)(),{centerPanel:a}=(0,l.useLayoutActions)(),[o,s]=Re(),c=e?.service||[],u=e?.services||[],f=(i.current===Ve.id?i.state:null)?.preset||o||Be,g=(0,m.useMemo)(()=>{let e=he(c);if(e)return{service:e.service};let t=he(u);return t?{service:t.service}:null},[c,u]),_=(0,m.useMemo)(()=>g?fe(g.service.theme):null,[g])||de(`delft`);if(!e)return null;let y=n=>{let r=_e(c,n?me(e.id,n):null),i=_e(u,null),a={id:e.id,type:`Manifest`};t.batch(t=>{t.modifyEntityField(a,`service`,r),(e.services||i.length!==u.length)&&t.modifyEntityField(a,`services`,i)})},b=(e,t)=>{y(Jt(_,e,t))},x=e=>{y(Yt(_,e))};return(0,p.jsx)(h.Sidebar,{children:(0,p.jsxs)(h.SidebarContent,{padding:!0,children:[(0,p.jsx)(W,{title:`Preview`,description:`Switch the live preview route without changing the saved manifest theme.`,children:(0,p.jsx)(Ut,{label:`Preview preset`,value:f,onChange:e=>{s(e),a.open({id:Ve.id,state:{preset:e}})},options:Le})}),(0,p.jsxs)(W,{title:`Manifest Theme`,description:`Store exhibition styling and viewer defaults in a custom IIIF service on the Manifest.`,children:[(0,p.jsx)(G,{label:`Enable manifest theme`,checked:!!g,onChange:e=>{if(!e){y(null);return}y(de(`delft`))}}),(0,p.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,p.jsx)(v.Button,{className:`rounded border border-slate-300 px-3 py-2 text-sm hover:bg-slate-50 disabled:cursor-not-allowed disabled:opacity-50`,onPress:()=>{y(de(_.preset))},isDisabled:!g,children:`Reset to preset`}),(0,p.jsx)(v.Button,{className:`rounded border border-slate-300 px-3 py-2 text-sm hover:bg-slate-50 disabled:cursor-not-allowed disabled:opacity-50`,onPress:()=>y(null),isDisabled:!g,children:`Remove theme service`})]}),(0,p.jsx)(Ut,{label:`Preset`,value:_.preset,onChange:e=>{y(de(e))},options:[{label:`Delft`,value:`delft`},{label:`Gallery`,value:`gallery`},{label:`Minimal`,value:`minimal`}]})]}),(0,p.jsx)(W,{title:`Theme Options`,children:(0,p.jsx)(Ut,{label:`Editing mode`,value:n,onChange:r,options:[{label:`Simple`,value:`simple`},{label:`Advanced`,value:`advanced`}]})}),n===`simple`?(0,p.jsxs)(W,{title:`Simple Colors`,description:`Apply broad colours across the exhibition, scrolling, presentation, and slideshow views.`,children:[(0,p.jsx)(K,{label:`Base colour`,value:_.delft.tokens.backgroundSecondary,onChange:e=>{x([{path:[`delft`,`tokens`,`backgroundPrimary`],value:e},{path:[`delft`,`tokens`,`backgroundSecondary`],value:e},{path:[`delft`,`tokens`,`controlBar`],value:e},{path:[`delft`,`tokens`,`closeBackground`],value:e},{path:[`delft`,`tokens`,`titleCard`],value:e},{path:[`delft`,`tokens`,`infoBlock`],value:e},{path:[`delft`,`tokens`,`viewerBackground`],value:e},{path:[`scroll`,`tokens`,`titleBackground`],value:e},{path:[`scroll`,`tokens`,`annotationBackground`],value:e},{path:[`scroll`,`tokens`,`infoBlockBackground`],value:e}])}}),(0,p.jsx)(K,{label:`Text colour`,value:_.delft.tokens.textSecondary,onChange:e=>{x([{path:[`delft`,`tokens`,`textPrimary`],value:e},{path:[`delft`,`tokens`,`textSecondary`],value:e},{path:[`delft`,`tokens`,`imageCaption`],value:e},{path:[`delft`,`tokens`,`closeText`],value:e},{path:[`delft`,`tokens`,`titleCardText`],value:e},{path:[`delft`,`tokens`,`infoBlockText`],value:e},{path:[`scroll`,`tokens`,`titleColor`],value:e},{path:[`scroll`,`tokens`,`annotationColor`],value:e},{path:[`scroll`,`tokens`,`infoBlockColor`],value:e}])}})]}):(0,p.jsxs)(p.Fragment,{children:[(0,p.jsxs)(W,{title:`Typography`,children:[(0,p.jsx)(Wt,{label:`Sans font stack`,value:_.shared.fontSans,onChange:e=>b([`shared`,`fontSans`],e)}),(0,p.jsx)(Wt,{label:`Mono font stack`,value:_.shared.fontMono,onChange:e=>b([`shared`,`fontMono`],e)}),(0,p.jsx)(Gt,{label:`Title transform`,value:_.shared.titleTransform,onChange:e=>b([`shared`,`titleTransform`],e),options:[{label:`Uppercase`,value:`uppercase`},{label:`None`,value:`none`},{label:`Capitalize`,value:`capitalize`}]})]}),(0,p.jsxs)(W,{title:`Delft Colors`,children:[(0,p.jsx)(K,{label:`Background`,value:_.delft.tokens.backgroundPrimary,onChange:e=>b([`delft`,`tokens`,`backgroundPrimary`],e)}),(0,p.jsx)(K,{label:`Secondary background`,value:_.delft.tokens.backgroundSecondary,onChange:e=>b([`delft`,`tokens`,`backgroundSecondary`],e)}),(0,p.jsx)(K,{label:`Primary text`,value:_.delft.tokens.textPrimary,onChange:e=>b([`delft`,`tokens`,`textPrimary`],e)}),(0,p.jsx)(K,{label:`Secondary text`,value:_.delft.tokens.textSecondary,onChange:e=>b([`delft`,`tokens`,`textSecondary`],e)}),(0,p.jsx)(K,{label:`Title card`,value:_.delft.tokens.titleCard,onChange:e=>b([`delft`,`tokens`,`titleCard`],e)}),(0,p.jsx)(K,{label:`Title card text`,value:_.delft.tokens.titleCardText,onChange:e=>b([`delft`,`tokens`,`titleCardText`],e)}),(0,p.jsx)(K,{label:`Info block`,value:_.delft.tokens.infoBlock,onChange:e=>b([`delft`,`tokens`,`infoBlock`],e)}),(0,p.jsx)(K,{label:`Info block text`,value:_.delft.tokens.infoBlockText,onChange:e=>b([`delft`,`tokens`,`infoBlockText`],e)}),(0,p.jsx)(K,{label:`Control bar`,value:_.delft.tokens.controlBar,onChange:e=>b([`delft`,`tokens`,`controlBar`],e)}),(0,p.jsx)(K,{label:`Viewer background`,value:_.delft.tokens.viewerBackground,onChange:e=>b([`delft`,`tokens`,`viewerBackground`],e)})]}),(0,p.jsxs)(W,{title:`Scroll Colors`,children:[(0,p.jsx)(K,{label:`Title background`,value:_.scroll.tokens.titleBackground,onChange:e=>b([`scroll`,`tokens`,`titleBackground`],e)}),(0,p.jsx)(K,{label:`Title text`,value:_.scroll.tokens.titleColor,onChange:e=>b([`scroll`,`tokens`,`titleColor`],e)}),(0,p.jsx)(K,{label:`Annotation background`,value:_.scroll.tokens.annotationBackground,onChange:e=>b([`scroll`,`tokens`,`annotationBackground`],e)}),(0,p.jsx)(K,{label:`Annotation text`,value:_.scroll.tokens.annotationColor,onChange:e=>b([`scroll`,`tokens`,`annotationColor`],e)}),(0,p.jsx)(K,{label:`Info block background`,value:_.scroll.tokens.infoBlockBackground,onChange:e=>b([`scroll`,`tokens`,`infoBlockBackground`],e)}),(0,p.jsx)(K,{label:`Info block text`,value:_.scroll.tokens.infoBlockColor,onChange:e=>b([`scroll`,`tokens`,`infoBlockColor`],e)})]}),(0,p.jsxs)(W,{title:`Exhibition Defaults`,children:[(0,p.jsx)(G,{label:`Cut corners`,checked:_.delft.exhibition.cutCorners,onChange:e=>b([`delft`,`exhibition`,`cutCorners`],e)}),(0,p.jsx)(G,{label:`Full title bar`,checked:_.delft.exhibition.fullTitleBar,onChange:e=>b([`delft`,`exhibition`,`fullTitleBar`],e)}),(0,p.jsx)(G,{label:`Full width grid`,checked:_.delft.exhibition.fullWidthGrid,onChange:e=>b([`delft`,`exhibition`,`fullWidthGrid`],e)}),(0,p.jsx)(G,{label:`Hide table of contents`,checked:_.delft.exhibition.hideTableOfContents,onChange:e=>b([`delft`,`exhibition`,`hideTableOfContents`],e)}),(0,p.jsx)(G,{label:`Disable presentation mode`,checked:_.delft.exhibition.disablePresentation,onChange:e=>b([`delft`,`exhibition`,`disablePresentation`],e)}),(0,p.jsx)(G,{label:`Hide title card`,checked:_.delft.exhibition.hideTitleCard,onChange:e=>b([`delft`,`exhibition`,`hideTitleCard`],e)}),(0,p.jsx)(G,{label:`Alternative image mode`,checked:_.delft.exhibition.alternativeImageMode,onChange:e=>b([`delft`,`exhibition`,`alternativeImageMode`],e)}),(0,p.jsx)(G,{label:`Transition scale`,checked:_.delft.exhibition.transitionScale,onChange:e=>b([`delft`,`exhibition`,`transitionScale`],e)}),(0,p.jsx)(G,{label:`Image info icon`,checked:_.delft.exhibition.imageInfoIcon,onChange:e=>b([`delft`,`exhibition`,`imageInfoIcon`],e)}),(0,p.jsx)(G,{label:`Cover images`,checked:_.delft.exhibition.coverImages,onChange:e=>b([`delft`,`exhibition`,`coverImages`],e)})]}),(0,p.jsxs)(W,{title:`Presentation Defaults`,children:[(0,p.jsx)(G,{label:`Cut corners`,checked:_.delft.presentation.cutCorners,onChange:e=>b([`delft`,`presentation`,`cutCorners`],e)}),(0,p.jsx)(G,{label:`Floating caption panels`,checked:_.delft.presentation.isFloating,onChange:e=>b([`delft`,`presentation`,`isFloating`],e)}),(0,p.jsx)(Gt,{label:`Floating position`,value:_.delft.presentation.floatingPosition,onChange:e=>b([`delft`,`presentation`,`floatingPosition`],e),options:[{label:`Top left`,value:`top-left`},{label:`Top right`,value:`top-right`},{label:`Bottom left`,value:`bottom-left`},{label:`Bottom right`,value:`bottom-right`}]})]}),(0,p.jsxs)(W,{title:`Slideshow Defaults`,children:[(0,p.jsx)(G,{label:`Alternative image mode`,checked:_.delft.slideshow.alternativeImageMode,onChange:e=>b([`delft`,`slideshow`,`alternativeImageMode`],e)}),(0,p.jsx)(G,{label:`Transition scale`,checked:_.delft.slideshow.transitionScale,onChange:e=>b([`delft`,`slideshow`,`transitionScale`],e)}),(0,p.jsx)(G,{label:`Image info icon`,checked:_.delft.slideshow.imageInfoIcon,onChange:e=>b([`delft`,`slideshow`,`imageInfoIcon`],e)}),(0,p.jsx)(G,{label:`Cover images`,checked:_.delft.slideshow.coverImages,onChange:e=>b([`delft`,`slideshow`,`coverImages`],e)})]}),(0,p.jsxs)(W,{title:`Scroll Defaults`,children:[(0,p.jsx)(G,{label:`Show table of contents`,checked:_.scroll.options.showTableOfContents,onChange:e=>b([`scroll`,`options`,`showTableOfContents`],e)}),(0,p.jsx)(G,{label:`Full-height title block`,checked:_.scroll.options.titleBlock.fullHeight,onChange:e=>b([`scroll`,`options`,`titleBlock`,`fullHeight`],e)})]})]})]})})}function Zt(){return(0,p.jsxs)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,width:`24`,height:`24`,fill:`currentColor`,viewBox:`0 -960 960 960`,children:[(0,p.jsx)(`title`,{children:`Theme`}),(0,p.jsx)(`path`,{d:`M480-80q-83 0-156-31.5T197-197q-54-54-85.5-127T80-480q0-83 32.5-156T201-763q56-54 131-85.5T492-880q79 0 147 27t120 74q52 47 81.5 110T870-533q0 93-56 147t-145 54h-72q-18 0-28 10t-10 25q0 15 12 31.5t12 39.5q0 55-29 100.5T480-80ZM280-480q25 0 42.5-17.5T340-540q0-25-17.5-42.5T280-600q-25 0-42.5 17.5T220-540q0 25 17.5 42.5T280-480Zm120-160q25 0 42.5-17.5T460-700q0-25-17.5-42.5T400-760q-25 0-42.5 17.5T340-700q0 25 17.5 42.5T400-640Zm160 0q25 0 42.5-17.5T620-700q0-25-17.5-42.5T560-760q-25 0-42.5 17.5T500-700q0 25 17.5 42.5T560-640Zm120 160q25 0 42.5-17.5T740-540q0-25-17.5-42.5T680-600q-25 0-42.5 17.5T620-540q0 25 17.5 42.5T680-480Z`})]})}const Qt=`left-panel-manifest`;function $t(e){return e===`left-panel-manifest`||e===Nt.id}const en={id:`exhibition-background-task`,label:`Query string`,render:()=>(0,p.jsx)(tn,{})};function tn(){let e=(0,d.useManifest)(),{leftPanel:t,rightPanel:n}=(0,l.useLayoutState)(),{edit:r,centerPanel:i,rightPanel:a}=(0,l.useLayoutActions)(),[o,s]=(0,m.useState)(!1),c=(0,m.useRef)(null),u=(0,m.useRef)(null);return(0,m.useEffect)(()=>{let l=e?.id||null,d=c.current!==t.current,f=u.current!==l,p=c.current;if(c.current=t.current,u.current=l,!(!e||!d&&!f)){if(t.current===Bt.id){r(e),i.open({id:ye.id}),s(!1);return}if(t.current===Ht.id){r(e),n.open?(a.close(),s(!0)):s(!1),i.open({id:Ve.id});return}!n.open&&n.current&&$t(t.current)&&(p===null||p===Ht.id&&o)&&(a.open(),s(!1))}},[i,r,t.current,e?.id,n.current,n.open,a,o]),null}const nn={id:`image-block-editor`,label:`Image Block Editor`,component:e=>(0,p.jsx)(rn,{strategy:e}),supports:{strategy:(e,t,n)=>{if(e.type!==`images`)return!1;let r=n.get(t.resource);if(r.type!==`Canvas`)return!1;let i=r.behavior||[],a=!1;for(let e of i)(e.startsWith(`w-`)||e.startsWith(`h-`)||e===`image`)&&(a=!0);return a}}};function rn({strategy:e}){let[t,n]=(0,l.useLocalStorage)(`exhibition-preview-mode`),[r,i]=Re(),a=(0,u.useInStack)(`Canvas`);return a?(0,p.jsx)(d.CanvasContext,{canvas:a.resource.source?.id,children:(0,p.jsx)(an,{isPreview:!!t,previewPreset:r,onModeChange:n,onPreviewPresetChange:i})}):null}function an({isPreview:e,previewPreset:t,onModeChange:n,onPreviewPresetChange:r}){return(0,p.jsxs)(`div`,{className:`relative z-0 flex h-full min-h-0 w-full min-w-0 max-w-full flex-col overflow-hidden bg-white`,children:[(0,p.jsxs)(`div`,{className:`exhibition-slideshow-current-toolbar flex items-center gap-3 border-b border-slate-200 bg-white px-4 py-3 shadow-sm`,children:[(0,p.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,p.jsx)(d.LocaleString,{className:`block truncate text-sm font-semibold text-slate-800`,children:(0,d.useCanvas)()?.label})}),(0,p.jsxs)(`div`,{className:`flex items-center gap-2`,children:[e?(0,p.jsx)(`select`,{className:`rounded-md border border-slate-200 bg-white px-2 py-2 text-xs font-semibold text-slate-700 shadow-sm`,value:t,onChange:e=>r(e.target.value),children:Le.map(e=>(0,p.jsx)(`option`,{value:e.value,children:e.label},e.value))}):null,(0,p.jsxs)(`div`,{className:`flex shrink-0 overflow-hidden rounded-md border border-slate-200 bg-slate-50 text-xs font-semibold`,children:[(0,p.jsx)(on,{selected:!e,onPress:()=>n(!1),children:`Edit`}),(0,p.jsx)(on,{selected:e,onPress:()=>n(!0),children:`Preview`})]})]})]}),e?(0,p.jsx)(`div`,{className:`min-h-0 flex-1`,children:(0,p.jsx)(je,{preset:t})}):(0,p.jsx)(`div`,{className:`flex min-h-0 flex-1`,children:(0,p.jsx)(u.CanvasPanelEditor,{asFallback:!0})})]})}function on({children:e,selected:t,onPress:n}){return(0,p.jsx)(v.Button,{className:(0,y.twMerge)(`px-3 py-2 text-xs font-semibold transition`,t?`bg-white text-slate-900 shadow-sm`:`text-slate-500 hover:text-slate-700`),onPress:n,children:e})}const sn={id:`info-block-editor`,label:`info Block Editor`,component:e=>(0,p.jsx)(dn,{strategy:e}),supports:{strategy:(e,t,n)=>e.type===`textual-content`}};function cn(e){if(e===`@none`||e===`none`)return null;try{let t=new Intl.DisplayNames([e],{type:`language`});return e===`cy`?{key:e,language:e,label:`Cymraeg`}:{key:e,language:e,label:t.of(e)}}catch{return{key:e,language:e,label:e}}}function ln({selectedLanguage:e,languages:t,availableLanguages:n,onSelectLanguage:r,onAddLanguage:i}){let[a,o]=(0,m.useState)(!1),s=(0,m.useRef)(null);(0,m.useEffect)(()=>{if(!a)return;let e=e=>{s.current&&!s.current.contains(e.target)&&o(!1)};return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[a]);let c=n.filter(e=>!t.includes(e));return(0,p.jsxs)(`div`,{ref:s,className:`relative`,children:[(0,p.jsxs)(`button`,{type:`button`,className:`flex items-center gap-1 rounded-md border border-slate-200 bg-white px-3 py-2 text-xs font-semibold text-slate-700 shadow-sm transition hover:bg-slate-50`,onClick:()=>o(e=>!e),children:[(0,p.jsx)(`span`,{className:``,children:cn(e)?.label||e}),(0,p.jsx)(`svg`,{className:`h-3 w-3 text-slate-400`,viewBox:`0 0 12 12`,fill:`none`,stroke:`currentColor`,strokeWidth:2,children:(0,p.jsx)(`path`,{d:`M2 4l4 4 4-4`})})]}),a&&(0,p.jsxs)(`div`,{className:`absolute right-0 top-full z-50 mt-1 min-w-[14rem] rounded-md border border-slate-200 bg-white py-1 shadow-lg`,children:[t.length>0&&(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(`div`,{className:`px-3 py-1 text-[10px] font-semibold uppercase tracking-wider text-slate-400`,children:`Language`}),t.map(t=>{let n=cn(t);return(0,p.jsxs)(`button`,{type:`button`,className:(0,y.twMerge)(`flex w-full items-center gap-2 px-3 py-1.5 text-xs hover:bg-slate-50`,t===e?`font-semibold text-slate-900`:`text-slate-600`),onClick:()=>{r(t),o(!1)},children:[t===e?(0,p.jsx)(`svg`,{className:`h-3 w-3 shrink-0 text-slate-500`,viewBox:`0 0 12 12`,fill:`currentColor`,children:(0,p.jsx)(`path`,{d:`M2 6l3 3 5-5`,stroke:`currentColor`,strokeWidth:2,fill:`none`})}):(0,p.jsx)(`div`,{className:`h-3 w-3 shrink-0 text-slate-500`}),(0,p.jsx)(`span`,{className:t===e?``:`ml-5`,children:n?.label||t})]},t)})]}),c.length>0&&(0,p.jsxs)(p.Fragment,{children:[t.length>0&&(0,p.jsx)(`div`,{className:`my-1 border-t border-slate-100`}),(0,p.jsx)(`div`,{className:`px-3 py-1 text-[10px] font-semibold uppercase tracking-wider text-slate-400`,children:`Add language`}),c.map(e=>{let t=cn(e);return(0,p.jsxs)(`button`,{type:`button`,className:`flex w-full items-center gap-2 px-3 py-1.5 text-xs text-slate-600 hover:bg-slate-50`,onClick:()=>{i(e),o(!1)},children:[(0,p.jsx)(`svg`,{className:`h-3 w-3 shrink-0 text-slate-400`,viewBox:`0 0 12 12`,fill:`none`,stroke:`currentColor`,strokeWidth:2,children:(0,p.jsx)(`path`,{d:`M6 2v8M2 6h8`})}),t?.label||e]},e)})]}),c.length===0&&t.length===0&&(0,p.jsx)(`div`,{className:`px-3 py-2 text-xs text-slate-400`,children:`No languages available`})]})]})}function un(e,t){if(!e)return[];let n=e.items||[],r=new Set;for(let e of n){let n=q(e,t);if(!n)continue;let i=Sn(n.body);for(let e of i){let n=q(e,t);n?.language&&r.add(n.language)}}return Array.from(r)}function dn({strategy:e}){let t=(0,d.useCanvas)(),n=(0,d.useVault)(),r=t?.behavior||[],i=qe(r),a=!!(i.h&&i.w),{isBottom:o,isLeft:s,isRight:c}=Ye(r),u=a&&i.w<=6,f=(0,d.useVaultSelector)((e,n)=>t?.items[0]?n.get(t.items[0]):null),h=(0,d.useVaultSelector)((e,n)=>t?.annotations[0]?n.get(t?.annotations[0]):null),{i18n:{availableLanguages:g,defaultLanguage:_}}=(0,l.useConfig)(),[v,b]=(0,l.useLocalStorage)(`exhibition-info-block-mode`,`edit`),[x,S]=Re(),C=(0,m.useMemo)(()=>{let e=un(f,n),t=un(h,n),r=new Set([...e,...t]);return r.size===0&&r.add(_||`en`),Array.from(r)},[f,h,n,_]),[w,T]=(0,l.useLocalStorage)(`exhibition-info-block-language`,_||`en`),E=C.includes(w)?w:C[0]||_||`en`,D=e=>{T(e)},O=u?`28rem`:void 0;return(0,p.jsxs)(`div`,{className:`relative z-0 flex h-full min-h-0 w-full min-w-0 max-w-full flex-col overflow-hidden bg-white`,children:[(0,p.jsxs)(`div`,{className:`exhibition-slideshow-current-toolbar flex items-center gap-3 border-b border-slate-200 bg-white px-4 py-3 shadow-sm`,children:[(0,p.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,p.jsx)(d.LocaleString,{className:`block truncate text-sm font-semibold text-slate-800`,children:t?.label})}),(0,p.jsxs)(`div`,{className:`flex items-center gap-2`,children:[v===`edit`&&(0,p.jsx)(ln,{selectedLanguage:E,languages:C,availableLanguages:g,onSelectLanguage:T,onAddLanguage:D}),v===`preview`?(0,p.jsx)(`select`,{className:`rounded-md border border-slate-200 bg-white px-2 py-2 text-xs font-semibold text-slate-700 shadow-sm`,value:x,onChange:e=>S(e.target.value),children:Le.map(e=>(0,p.jsx)(`option`,{value:e.value,children:e.label},e.value))}):null,(0,p.jsxs)(`div`,{className:`flex shrink-0 overflow-hidden rounded-md border border-slate-200 bg-slate-50 text-xs font-semibold`,children:[(0,p.jsx)(fn,{selected:v===`edit`,onPress:()=>b(`edit`),children:`Edit`}),(0,p.jsx)(fn,{selected:v===`preview`,onPress:()=>b(`preview`),children:`Preview`})]})]})]}),v===`preview`?(0,p.jsx)(`div`,{className:`min-h-0 flex-1`,children:(0,p.jsx)(je,{preset:x})}):(0,p.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-x-hidden overflow-y-auto`,children:[(0,p.jsx)(pn,{annotationPage:f,compact:u,editorMaxWidth:O,fallbackText:e.items[0]?.text,heading:`Short summary`,panelClassName:(0,y.twMerge)(`border-b border-gray-100`,u?`p-3`:`p-5`,a&&(s||c)?`max-w-xl`:``,a&&o?`max-w-4xl`:``),parentProperty:`items`,selectedLanguage:E,onLanguageAdded:D}),(0,p.jsx)(pn,{annotationPage:h,compact:u,heading:`Long summary`,panelClassName:(0,y.twMerge)(u?`p-3`:`p-5`),parentProperty:`annotations`,selectedLanguage:E,onLanguageAdded:D})]})]})}function fn({children:e,selected:t,onPress:n}){return(0,p.jsx)(v.Button,{className:(0,y.twMerge)(`px-3 py-2 text-xs font-semibold transition`,t?`bg-white text-slate-900 shadow-sm`:`text-slate-500 hover:text-slate-700`),onPress:n,children:e})}function pn({annotationPage:e,compact:t,editorMaxWidth:n,fallbackText:r,heading:i,panelClassName:a,parentProperty:o,selectedLanguage:s,onLanguageAdded:c}){let u=(0,d.useCanvas)(),f=(0,l.useInlineCreator)(),g=(0,d.useVault)(),{i18n:{defaultLanguage:_}}=(0,l.useConfig)(),v=e||null,b=v?.items||[],x=gn(b,g),S=()=>{u&&f.create(`@manifest-editor/empty-annotation-page`,{label:{en:[i]}},{target:{id:u.id,type:`Canvas`},targetType:`AnnotationPage`,parent:{property:o,resource:{id:u.id,type:`Canvas`}}})},C=()=>{if(u){if(!v){S();return}f.create(`@manifest-editor/html-annotation`,{label:{en:[i]},body:{[s||_||`en`]:[``]},motivation:o===`annotations`?`tagging`:`painting`},{target:{id:u.id,type:`Canvas`},targetType:`Annotation`,parent:{property:`items`,resource:{id:v.id,type:`AnnotationPage`}},initialData:{}})}},w=()=>{if(!v){C(),c(s);return}let e=!1;for(let t of b){let n=q(t,g);if(!n)continue;let r=Sn(n.body);if(r.some(e=>q(e,g)?.language===s))continue;let i=r[0],a=i?q(i,g):null,o=`${n.id}-body-${s}-${Date.now()}`;g.batch(()=>{g.dispatch({type:`entities/update`,payload:{type:`ContentResource`,id:o,language:s,value:``,format:a?.format||`text/html`,motivation:a?.motivation}}),g.modifyEntityField({id:n.id,type:`Annotation`},`body`,[...r,{id:o,type:`ContentResource`}])}),e=!0}e||C(),c(s)},T=(0,m.useMemo)(()=>{if(!v)return!1;for(let e of b){let t=q(e,g);if(!t)continue;let n=Sn(t.body);for(let e of n)if(q(e,g)?.language===s)return!0}return!1},[v,b,g,s]);return(0,p.jsxs)(`section`,{className:(0,y.twMerge)(`min-w-0 max-w-full`,a),children:[(0,p.jsxs)(`div`,{className:(0,y.twMerge)(`flex items-center justify-between gap-3`,x.length?`mb-3`:`mb-0`),children:[(0,p.jsx)(`h2`,{className:(0,y.twMerge)(`font-semibold tracking-tight text-gray-700`,t?`text-xs uppercase`:`text-sm uppercase tracking-wide`),children:i}),!T&&(0,p.jsx)(h.ActionButton,{primary:!0,onPress:w,children:v?`Add text`:`Add`})]}),!v&&r?(0,p.jsx)(`div`,{className:`mt-2 text-sm text-gray-600`,children:(0,p.jsx)(d.LocaleString,{enableDangerouslySetInnerHTML:!0,children:r})}):null,x.length?(0,p.jsx)(`div`,{className:`min-w-0 max-w-full`,children:x.map(({item:e,index:r})=>(0,p.jsx)(d.AnnotationContext,{annotation:e.id,children:(0,p.jsx)(mn,{compact:t,editorMaxWidth:n,pageItems:b,pageRef:{id:v.id,type:`AnnotationPage`},selectedLanguage:s,onRemoveAnnotation:()=>{g.modifyEntityField({id:v.id,type:`AnnotationPage`},`items`,b.filter((e,t)=>t!==r))}})},e.id+r))}):v&&T?(0,p.jsx)(`div`,{className:(0,y.twMerge)(`mt-2 text-sm text-gray-400 italic`,``),children:`No text added yet.`}):null]})}function mn({compact:e,editorMaxWidth:t,onRemoveAnnotation:n,pageItems:r,pageRef:i,selectedLanguage:a}){let o=(0,d.useAnnotation)(),s=(0,d.useVault)(),c=o?.body||[],u=(0,l.useGenericEditor)(o);if(!o)return null;let f=c.map((e,t)=>({item:e,index:t})).filter(({item:e})=>q(e,s)?.language===a),h=f.length>0?f:[],g=(0,m.useCallback)(e=>{let t=vn(c,s,e);t.length!==c.length&&s.modifyEntityField({id:o.id,type:`Annotation`},`body`,t);let n=_n(r,s,o.id);n.length!==r.length&&s.modifyEntityField(i,`items`,n)},[o.id,i.id,r,s]);return h.length?(0,p.jsx)(`div`,{className:`min-w-0 max-w-full overflow-hidden`,children:h.map(({item:n,index:r})=>(0,p.jsx)(hn,{resourceId:n.id,onRemove:()=>u.annotation.body.deleteAtIndex(r),onUpdate:()=>g(n.id),compact:e,editorMaxWidth:t},n.id||r))}):null}function hn({compact:e,editorMaxWidth:t,resourceId:n,onRemove:r,onUpdate:i}){let a=(0,l.useGenericEditor)((0,m.useMemo)(()=>({id:n,type:`ContentResource`}),[n])),{i18n:{advancedLanguageMode:o,availableLanguages:s,defaultLanguage:c}}=(0,l.useConfig)(),{language:d,value:f}=a.descriptive,h=d.get(),g=Array.isArray(h)?h[0]||c||`en`:h||c||`en`;return(0,m.useEffect)(()=>{let e=Array.isArray(d.get())?d.get()[0]:d.get();!o&&e!==g&&d.set(g)},[o,g]),(0,p.jsx)(`div`,{className:`min-w-0 max-w-full overflow-hidden`,style:t?{maxWidth:t}:void 0,children:(0,p.jsx)(u.TiptapRichTextLanguageField,{language:g,languages:s,value:f.get()||``,onUpdate:e=>{f.set(e),i()},onUpdateLanguage:o?e=>d.set(e):void 0,onRemove:o?r:void 0})})}function gn(e,t){let n=e.map((e,t)=>({item:e,index:t})),r=n.filter(({item:e})=>!yn(e,t));return r.length?r:n.slice(0,1)}function _n(e,t,n){let r=e.filter(e=>e?.id===n||!yn(e,t));return r.length?r:e.slice(0,1)}function vn(e,t,n){let r=e.filter(e=>e?.id===n||!bn(e,t));return r.length?r:e.slice(0,1)}function yn(e,t){let n=Sn(q(e,t)?.body);return n.length?n.every(e=>bn(e,t)):!0}function bn(e,t){let n=q(e,t);return n?xn(n.value||``):!0}function xn(e){let t=String(e||``);return/<img\b/i.test(t)?!1:t.replace(/<[^>]*>/g,``).replace(/&nbsp;/gi,` `).replace(/\s+/g,``).trim()===``}function q(e,t){return!e?.id||e.value||e.items||e.body?e:t.get(e,{skipSelfReturn:!1})||e}function Sn(e){return Array.isArray(e)?e:e==null?[]:[e]}const Cn={id:`youtube-main-editor`,label:`YouTube main editor`,component:e=>e.type===`media`?(0,p.jsx)(wn,{strategy:e,video:e.media}):null,supports:{strategy:(e,t,n)=>(console.log(e),!(e.type!==`media`||e.media.type!==`VideoYouTube`))}};function wn({strategy:e,video:t}){let{edit:n}=(0,l.useLayoutActions)(),r=(0,d.useCanvas)(),i=(0,d.useVaultSelector)((e,t)=>t.get(r?.items[0]).items[0]);(0,T.default)(r&&i);let a=(0,m.useRef)(null),o=(0,l.useGenericEditor)(i),s=t,c=(r.width||1)/(r.height||1);return`${s.youTubeId}`,(0,p.jsxs)(`div`,{className:`overflow-y-auto`,children:[(0,p.jsx)(`div`,{className:`p-8`,children:(0,p.jsx)(`div`,{className:`bg-black z-20 flex p-8 rounded-lg max-w-full max-h-[70vh] mx-auto`,style:{aspectRatio:c},children:(0,p.jsx)(`iframe`,{title:`YouTube video`,className:`border-none w-full h-full object-contain`,ref:a,src:`https://www.youtube.com/embed/${s.youTubeId}?enablejsapi=1&origin=${window.location.host}&modestbranding=1&rel=0`,referrerPolicy:`no-referrer compute-pressure`,sandbox:`allow-scripts allow-same-origin allow-presentation`})})}),(0,p.jsxs)(`div`,{className:`bg-white shadow w-full p-8 flex gap-8`,children:[(0,p.jsx)(`div`,{children:(0,p.jsx)(`div`,{className:`w-64 bg-black flex-shrink-0 flex items-center justify-center rounded overflow-clip`,style:{aspectRatio:c},children:r.thumbnail?.length?(0,p.jsx)(h.LazyThumbnail,{cover:!0}):(0,p.jsx)(`div`,{className:`text-white/50 text-center py-16`,children:`No thumbnail`})})}),(0,p.jsxs)(`div`,{className:`flex-1`,children:[(0,p.jsx)(d.LocaleString,{as:`h3`,className:`text-2xl font-bold mt-4`,defaultText:(0,p.jsx)(`span`,{className:`text-black/30`,children:`No Label`}),children:o.descriptive.label.get()}),(0,p.jsx)(d.LocaleString,{as:`p`,className:`mt-2 mb-8`,defaultText:(0,p.jsx)(`span`,{className:`text-black/30`,children:`No summary`}),children:o.descriptive.summary.get()}),(0,p.jsx)(h.ActionButton,{onPress:()=>n(o.ref()),children:`Edit properties`})]})]})]})}const Tn=(0,E.defineCreator)({...D.iiifBrowserCreator,id:`@exhibitions/browser-creator`,create:En,tags:[`image`,`exhibition-slide`],label:`IIIF Browser`,summary:`Browse IIIF Resources`,resourceType:`Canvas`,resourceFields:[`id`,`language`,`type`,`format`,`value`],additionalTypes:[],supports:{onlyPainting:!0,parentTypes:[`Manifest`],parentFields:[`items`],parentFieldMap:{Manifest:[`items`]}}});async function En(e,t){let n=t.generateId(`canvas`),r=t.generateId(`annotation-page`,{id:n,type:`Canvas`}),i={width:0,height:0},a=await(0,E.creatorHelper)(t,{id:r,type:`AnnotationPage`},`items`,`@manifest-editor/iiif-browser-creator`)({...e,trackSize({width:e,height:t}){i.height=t,i.width=e}},{targetType:`Annotation`,target:{id:n,type:`Canvas`}});return await(0,E.creatorHelper)(t,`Manifest`,`items`,`@exhibitions/image-slide-creator`)({canvasId:n,width:i.width,height:i.height,type:`default`,items:a})}const Dn=(0,E.defineCreator)({...D.imageServiceCreator,id:`@exhibitions/image-service-creator`,create:On,tags:[`image`,`exhibition-slide`],label:`IIIF Image`,summary:`IIIF Image service`,resourceType:`Canvas`,supports:{parentTypes:[`Manifest`],parentFields:[`items`]}});async function On(e,t){let n=t.generateId(`canvas`);t.generateId(`annotation-page`,{id:n,type:`Canvas`});let r=await(0,E.creatorHelper)(t,{id:t.generateId(`annotation`),type:`Annotation`},`body`,`@manifest-editor/image-service-creator`)(e,{target:{id:n,type:`Canvas`}}),{width:i,height:a}=r.get(),o=t.embed({id:t.generateId(`annotation`),type:`Annotation`,motivation:`painting`,body:[r],target:{type:`SpecificResource`,source:{id:n,type:`Canvas`}}});return await(0,E.creatorHelper)(t,`Manifest`,`items`,`@exhibitions/image-slide-creator`)({canvasId:n,width:i,height:a,type:`default`,items:[o]})}const J=(0,E.defineCreator)({id:`@exhibitions/image-slide-creator`,create:Y,label:`Empty slide`,summary:`An empty image slide.`,icon:(0,p.jsx)(h.EmptyCanvasIcon,{}),tags:[`exhibition-slide`],resourceType:`Canvas`,resourceFields:[`id`,`type`,`label`,`height`,`width`,`items`],supports:{parentTypes:[`Manifest`],parentFields:[`items`]}}),kn=(0,E.defineCreator)({...J,id:`@exhibitions/image-slide-creator-left`,label:`Image (Left)`,summary:`An image with text on the left.`,icon:(0,p.jsx)(`div`,{children:`IMAGE (LEFT)`}),create:(e,t)=>Y({...e,type:`left`},t)}),An=(0,E.defineCreator)({...J,id:`@exhibitions/image-slide-creator-right`,label:`Image (Right)`,summary:`An image with text on the right.`,icon:(0,p.jsx)(`div`,{children:`IMAGE (RIGHT)`}),create:(e,t)=>Y({...e,type:`right`},t)}),jn=(0,E.defineCreator)({...J,id:`@exhibitions/image-slide-creator-bottom`,label:`Image (Bottom)`,summary:`An image with text at the bottom.`,icon:(0,p.jsx)(`div`,{children:`IMAGE (BOTTOM)`}),create:(e,t)=>Y({...e,type:`bottom`},t)}),Mn=(0,E.defineCreator)({...J,id:`@exhibitions/slideshow-image-only-creator`,label:`Image only`,summary:`A slideshow slide focused on an image.`,tags:[`exhibition-slideshow-slide`],create:(e,t)=>Y({...e,behavior:[`w-12`,`h-8`,`image`],height:e.height||1080,width:e.width||1920,type:`default`},t)}),Nn=(0,E.defineCreator)({...J,id:`@exhibitions/slideshow-image-text-creator`,label:`Image with text`,summary:`A slideshow slide with image and text.`,tags:[`exhibition-slideshow-slide`],create:(e,t)=>Y({...e,behavior:[`w-12`,`h-8`,`right`],height:e.height||1080,width:e.width||1920,type:`right`},t)}),Pn=(0,E.defineCreator)({...J,id:`@exhibitions/scroll-compact-deck-creator`,label:`Compact image deck`,summary:`A scrolling section with compact annotation-led image slides.`,tags:[`exhibition-scroll-section`,`exhibition-slide`],create:(e,t)=>Y({...e,behavior:[`w-12`,`h-8`,`compact-deck`],height:e.height||1080,width:e.width||1920,type:`default`},t)});function Y(e,t){let n=e.canvasId||t.generateId(`Canvas`),r=t.generateId(`AnnotationPage`,{id:n,type:`Canvas`}),i=t.generateId(`AnnotationPage`,{id:n,type:`Canvas`}),a=[],o=6e3;if(e.behavior)a.push(...e.behavior);else if(e.width&&e.height){let t=e.type??`default`,n=t===`left`||t===`right`,r=t===`bottom`,i=e.width/e.height,o=n?12*(2/3):12,s=r?3/2:1,c=Math.max(1,Math.min(12,Math.round(o/i*s)));a.push(`w-12`,`h-${c}`)}else a.push(`w-12`,`h-4`);if(!e.behavior)switch(e.type){case`left`:a.push(`left`),o*=2/3;break;case`right`:a.push(`right`),o*=2/3;break;case`bottom`:a.push(`bottom`);break}return e.items?.length||a.push(`multi-image`),t.embed({...O.emptyCanvas,id:n,behavior:a,label:e.label||{en:[`Untitled`]},height:e.height||4e3,duration:e.duration,width:e.width||o,items:[t.embed({...O.emptyAnnotationPage,id:r,type:`AnnotationPage`,items:e.items?e.items:[]})],annotations:[t.embed({...O.emptyAnnotationPage,id:i,type:`AnnotationPage`,items:[]})]})}const Fn=(0,E.defineCreator)({...D.imageUrlCreator,id:`@exhibitions/image-url-creator`,create:In,tags:[`exhibition-slide`],label:`Image`,summary:`Image from URL`,resourceType:`Canvas`,supports:{parentTypes:[`Manifest`],parentFields:[`items`]}});async function In(e,t){let n=t.generateId(`canvas`);t.generateId(`annotation-page`,{id:n,type:`Canvas`});let r=t.generateId(`annotation`),i=await(0,E.creatorHelper)(t,{id:r,type:`Annotation`},`body`,`@manifest-editor/image-url-creator`)(e,{target:{id:n,type:`Canvas`},targetType:`Annotation`}),{width:a,height:o}=i.get(),s=t.embed({id:r,type:`Annotation`,motivation:`painting`,body:[i],target:{type:`SpecificResource`,source:{id:n,type:`Canvas`}}});return await(0,E.creatorHelper)(t,`Manifest`,`items`,`@exhibitions/image-slide-creator`)({canvasId:n,width:a,height:o,type:`default`,items:[s]})}const Ln=(0,E.defineCreator)({id:`@exhibitions/info-box-creator`,create:zn,label:`Info box`,summary:`A text panel for an exhibition`,icon:(0,p.jsxs)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,width:`1em`,height:`1em`,viewBox:`0 0 24 24`,children:[(0,p.jsx)(`title`,{children:`Info box`}),(0,p.jsx)(`path`,{fill:`currentColor`,d:`M11 17h2v-6h-2zm1-8q.425 0 .713-.288T13 8t-.288-.712T12 7t-.712.288T11 8t.288.713T12 9m0 13q-2.075 0-3.9-.788t-3.175-2.137T2.788 15.9T2 12t.788-3.9t2.137-3.175T8.1 2.788T12 2t3.9.788t3.175 2.137T21.213 8.1T22 12t-.788 3.9t-2.137 3.175t-3.175 2.138T12 22`})]}),tags:[`exhibition-slide`],resourceType:`Canvas`,resourceFields:[`id`,`type`,`label`,`height`,`width`,`items`],supports:{parentTypes:[`Manifest`],parentFields:[`items`]}}),Rn=(0,E.defineCreator)({...Ln,id:`@exhibitions/slideshow-long-editorial-creator`,label:`Long editorial`,summary:`A text-led slideshow slide.`,tags:[`exhibition-slideshow-slide`],create:(e,t)=>zn({...e,behavior:[`w-12`,`h-8`,`info`],height:e.height||1080,width:e.width||1920},t)});async function zn(e,t){let n=t.generateId(`canvas`),r=t.generateId(`annotation-page`,{id:n,type:`Canvas`}),i=t.generateId(`annotation-page`,{id:n,type:`Canvas`}),a={...O.emptyAnnotation,id:t.generateId(`annotation`,{id:n,type:`Canvas`}),type:`Annotation`},o=[await t.create(`@manifest-editor/html-body-creator`,{language:`en`,body:``},{parent:{resource:a,property:`body`}})],s=t.embed({...a,motivation:`painting`,body:o,target:{type:`SpecificResource`,source:{id:n,type:`Canvas`}}}),c=t.generateId(`annotation`,{id:n,type:`Canvas`}),l=t.embed({id:c,type:`Annotation`,motivation:`tagging`,body:[await t.create(`@manifest-editor/html-body-creator`,{language:`en`,body:``},{parent:{resource:{id:c,type:`Annotation`},property:`body`}})],target:{type:`SpecificResource`,source:{id:n,type:`Canvas`}}}),u=t.embed({id:r,type:`AnnotationPage`,items:[s]}),d=t.embed({id:i,type:`AnnotationPage`,items:[l]});return t.embed({...O.emptyCanvas,id:n,type:`Canvas`,behavior:e.behavior||[`w-4`,`h-4`,`info`],label:e.label||void 0,height:e.height||1e3,width:e.width||1e3,items:[u],annotations:[d]})}const Bn=(0,E.defineCreator)({...D.videoAnnotation,id:`@exhibitions/video-creator`,create:Hn,tags:[`video`,`exhibition-slide`],label:`Video`,summary:`A video for an exhibition`,resourceType:`Canvas`,resourceFields:[`id`,`type`,`label`,`height`,`width`,`items`],supports:{parentTypes:[`Manifest`],parentFields:[`items`]}}),Vn=(0,E.defineCreator)({...Bn,id:`@exhibitions/slideshow-video-creator`,label:`Video`,summary:`A video slide for a slideshow exhibition.`,tags:[`exhibition-slideshow-slide`],create:(e,t)=>Hn({...e,behavior:[`w-12`,`h-8`,`image`],height:e.height||1080,slideType:`default`,width:e.width||1920},t)});async function Hn(e,t){let n=t.generateId(`canvas`),r=t.generateId(`annotation-page`,{id:n,type:`Canvas`}),i=await t.create(`@manifest-editor/video-annotation`,e,{target:{id:n,type:`Canvas`},targetType:`Annotation`,parent:{resource:{id:r,type:`AnnotationPage`},property:`items`}});return t.embed({id:r,type:`AnnotationPage`,items:[i]}),await(0,E.creatorHelper)(t,`Manifest`,`items`,`@exhibitions/image-slide-creator`)({canvasId:n,behavior:e.behavior,height:e.height||1080,width:e.width||1920,duration:e.duration,type:e.slideType||`bottom`,items:[i]})}const Un=(0,E.defineCreator)({...D.youTubeBodyCreator,id:`@exhibitions/youtube-creator`,create:Gn,tags:[`video`,`exhibition-slide`],label:`YouTube`,summary:`A YouTube for an exhibition`}),Wn=(0,E.defineCreator)({...Un,id:`@exhibitions/slideshow-youtube-creator`,label:`YouTube`,summary:`A YouTube slide for a slideshow exhibition.`,tags:[`exhibition-slideshow-slide`]});async function Gn(e,t){let n=(0,u.getYouTubeId)(e.youtubeUrl),r=t.generateId(`canvas`),i=t.generateId(`annotation-page`,{id:r,type:`Canvas`}),a=await t.create(`@manifest-editor/youtube`,e,{target:{id:r,type:`Canvas`},targetType:`Annotation`,parent:{resource:{id:i,type:`AnnotationPage`},property:`items`}}),o=t.embed({id:i,type:`AnnotationPage`,items:[a]}),s=t.embed({id:`https://img.youtube.com/vi/${n}/maxresdefault.jpg`,type:`Image`,format:`image/jpeg`,width:640,height:360});return t.embed({...O.emptyCanvas,id:r,type:`Canvas`,behavior:[`w-12`,`h-8`],label:e.label||{en:[`Untitled YouTube Video`]},height:e.height||1080,width:e.width||1920,thumbnail:[s],items:[o]})}function Kn(){let e=(0,l.useEditor)(),t=()=>{let t=e.technical.width.get(),n=e.technical.height.get(),r=e.descriptive.summary,i=e.technical.behavior.get();i.push(`w-12`);let a=Math.max(1,Math.min(12,Math.round(t/n*12)));i.push(`h-${a}`),(0,k.getValue)(r.get())||r.set({en:[`Summary of image`]}),e.technical.behavior.set(i)};return(0,p.jsxs)(`div`,{className:`flex flex-col items-center gap-4 border-me-100 border-2 p-4 rounded`,children:[`This canvas was not created in the exhibition editor. Do you want to apply default settings?`,(0,p.jsx)(h.ActionButton,{onPress:()=>t(),children:`Apply defaults`})]})}function qn(){let e=(0,d.useCanvas)();(0,T.default)(e);let t=e.width&&e.height?e.width/e.height:0,n=qe(e.behavior||[]);return Math.abs(t-n.ratio)<.01?null:(0,p.jsxs)(`div`,{className:`exhibition-aspect-warning p-2 rounded bg-me-100`,children:[(0,p.jsx)(`div`,{className:`font-semibold text-me-700`,children:`Aspect ratio warning`}),(0,p.jsxs)(`div`,{className:`text-sm text-black/60`,children:[`The aspect ratio of this canvas is `,t.toFixed(2),` but the target aspect ratio is `,n.ratio.toFixed(2),`. Some parts of this image may be cropped.`,(0,p.jsx)(`div`,{className:`relative h-32 w-full mt-2`,children:(0,p.jsx)(`div`,{className:`bg-[red] left-0 top-0 z-2 opacity-50 max-w-32 max-h-32`,style:{aspectRatio:t.toFixed(2)},children:(0,p.jsx)(`div`,{className:`asbolute bg-[white] left-0 top-0 z-1 opacity-50 max-w-32 max-h-32`,style:{aspectRatio:n.ratio}})})})]})]})}function Jn(){let e=(0,d.useCanvas)(),t=(0,l.useEditingResource)(),n=(0,l.useInlineCreator)(),[r,i]=(0,l.useCreator)(t?.resource.source,`thumbnail`,`ContentResource`),{descriptive:a}=(0,l.useEditor)(),{thumbnail:o}=a,s=o.get()||[],c=(0,d.useVault)(),f=(0,m.useMemo)(()=>e?Zn(c,e):[],[e,c]);return!e||!t?null:!s.length&&f.length?(0,p.jsx)(Yn,{candidates:f,canCreateThumbnail:r,onCreateThumbnail:()=>i.create(),onAddThumbnail:({service:t,width:r,height:i})=>n.create(`@manifest-editor/thumbnail-image`,{service:t,width:r,height:i},Xn(e))}):(0,p.jsx)(u.LinkingPropertyList,{containerId:o.containerId(),label:`Thumbnail`,property:`thumbnail`,items:s,singleMode:!0,reorder:e=>o.reorder(e.startIndex,e.endIndex),createActions:(0,u.createAppActions)(o),creationType:`ContentResource`,emptyLabel:`No thumbnail`,parent:t.resource})}function Yn({candidates:e,canCreateThumbnail:t,onCreateThumbnail:n,onAddThumbnail:r}){let[i,a]=(0,m.useState)(null),[o,s]=(0,m.useState)(``),[c,l]=(0,m.useState)({}),d=e.find(e=>e.id===i)||e[0],f=d?c[d.id]:void 0,g=d?f===null?null:f||d.service:null,_=g?rr(g):[],v=ar(_,350),y=_.find(e=>ir(e)===o)||v,b=g&&y?or(g,y):null,x=d&&!d.service.sizes?.length&&!(d.id in c);return(0,m.useEffect)(()=>{!i&&e[0]&&a(e[0].id)},[e,i]),(0,m.useEffect)(()=>{let t=e.filter(e=>{let t=e.service;return!t.sizes?.length&&tr(t)&&!(e.id in c)});for(let e of t){let t=tr(e.service);t&&fetch(nr(t)).then(e=>e.ok?e.json():null).then(t=>{l(n=>({...n,[e.id]:t?{...e.service,...t}:null}))}).catch(()=>{l(t=>({...t,[e.id]:null}))})}},[e,c]),(0,m.useEffect)(()=>{v&&!_.some(e=>ir(e)===o)&&s(ir(v))},[v,o,_]),(0,p.jsx)(u.InputContainer,{$wide:!0,children:(0,p.jsxs)(`div`,{className:`rounded-md border border-[#dcd5ce] bg-[#f8f6f3] p-4`,children:[(0,p.jsx)(`div`,{className:`text-sm font-semibold text-[#25211f]`,children:`Thumbnail`}),(0,p.jsx)(`div`,{className:`mt-1 text-sm text-[#6a625c]`,children:`Use an image service from this canvas to add a thumbnail.`}),e.length>1?(0,p.jsxs)(`div`,{className:`mt-3`,children:[(0,p.jsx)(`label`,{className:`text-xs font-semibold uppercase text-[#6a625c]`,htmlFor:`thumbnail-source-image`,children:`Image`}),(0,p.jsx)(`select`,{id:`thumbnail-source-image`,className:`mt-1 w-full rounded-md border border-[#dcd5ce] bg-white px-3 py-2 text-sm`,value:d?.id||``,onChange:e=>{a(e.currentTarget.value),s(``)},children:e.map(e=>(0,p.jsx)(`option`,{value:e.id,children:e.label},e.id))})]}):null,_.length?(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(`div`,{className:`mt-3 flex flex-wrap gap-2`,children:_.map(e=>{let t=ir(e),n=y?t===ir(y):!1;return(0,p.jsxs)(`button`,{type:`button`,className:`rounded-md border px-2 py-1 text-xs font-semibold`,style:{backgroundColor:n?`#b84c74`:`#ffffff`,borderColor:n?`#b84c74`:`#dcd5ce`,color:n?`#ffffff`:`#332f2c`},onClick:()=>s(t),children:[e.width,`x`,e.height]},t)})}),b?(0,p.jsx)(`div`,{className:`mt-3 overflow-hidden rounded-md border border-[#dcd5ce] bg-white`,children:(0,p.jsx)(`img`,{src:b,alt:``,className:`max-h-40 w-full object-contain`})}):null,(0,p.jsx)(`button`,{type:`button`,className:`mt-3 rounded-md px-3 py-2 text-sm font-semibold shadow-sm`,style:{backgroundColor:`#b84c74`,border:`1px solid #a13e63`,color:`#ffffff`},disabled:!b||!y,onClick:()=>{!g||!y||r({service:g,width:y.width,height:y.height})},children:`Add thumbnail from image`})]}):x?(0,p.jsx)(`div`,{className:`mt-3 text-sm text-[#6a625c]`,children:`Finding available sizes...`}):(0,p.jsx)(`div`,{className:`mt-3 text-sm text-[#6a625c]`,children:`No fixed thumbnail sizes were found for this image service.`}),t?(0,p.jsx)(`div`,{className:`mt-4 border-t border-[#dcd5ce] pt-3`,children:(0,p.jsxs)(h.ActionButton,{onPress:n,children:[(0,p.jsx)(h.AddIcon,{}),` Create thumbnail`]})}):null]})})}function Xn(e){return{parent:{property:`thumbnail`,resource:{id:e.id,type:`Canvas`}}}}function Zn(e,t){let n=[],r=new Set;return U(e,t).forEach((t,i)=>{Qn(e,ft(e,t)).forEach((e,a)=>{let o=er(e),s=o?tr(o):``;!o||!s||r.has(s)||(r.add(s),n.push({id:`${t.id||i}-${e.id||s}-${a}`,label:sr(e.label)||sr(t.label)||`Image ${n.length+1}`,imageId:e.id,service:o}))})}),n}function Qn(e,t){let n=$n(e,t);return n?n.type===`Choice`&&Array.isArray(n.items)?n.items.flatMap(t=>Qn(e,t)):n.type===`SpecificResource`?Qn(e,n.source):n.type===`Canvas`?U(e,n).flatMap(t=>Qn(e,ft(e,t))):er(n)?[n]:[]:[]}function $n(e,t){return t?t.id&&!t.service&&!t.items&&!t.value&&e.get(t,{skipSelfReturn:!1})||t:null}function er(e){return(Array.isArray(e?.service)?e.service:e?.service?[e.service]:[]).find(e=>{let t=Array.isArray(e.profile)?e.profile.join(` `):e.profile||``;return(e.type||e[`@type`]||``).includes(`ImageService`)||t.includes(`level`)||t.includes(`iiif.io/api/image`)})||null}function tr(e){return(e.id||e[`@id`]||``).replace(/\/info\.json$/,``)}function nr(e){return e.endsWith(`/info.json`)?e:`${e.replace(/\/$/,``)}/info.json`}function rr(e){let t=Array.isArray(e.sizes)?e.sizes.filter(e=>Number(e.width)&&Number(e.height)).map(e=>({width:Number(e.width),height:Number(e.height)})):[];if(t.length)return t.sort((e,t)=>e.width-t.width).slice(0,8);let n=Number(e.width),r=Number(e.height);return!n||!r?[]:[256,512,1024].filter(e=>e<n).map(e=>({width:e,height:Math.round(r/n*e)})).concat([{width:n,height:r}]).slice(0,4)}function ir(e){return`${e.width},${e.height||``}`}function ar(e,t){return e.reduce((e,n)=>e?Math.hypot(n.width-t,n.height-t)<Math.hypot(e.width-t,e.height-t)?n:e:n,void 0)}function or(e,t){let n={...e};n[`@id`]&&(n.id=n[`@id`]),n[`@type`]&&(n.type=n[`@type`]);let r=(0,A.createImageServiceRequest)(n);return(0,A.imageServiceRequestToString)({identifier:r.identifier,server:r.server,scheme:r.scheme,type:`image`,size:{max:!1,confined:!1,upscaled:!1,width:t.width,height:t.height},format:`jpg`,region:{full:!0},rotation:{angle:0},quality:`default`,prefix:r.prefix,originalPath:r.originalPath})}function sr(e){return e?typeof e==`string`?e:Array.isArray(e)?e.filter(Boolean).join(` `):typeof e==`object`?Object.values(e).flatMap(e=>Array.isArray(e)?e:[e]).filter(e=>typeof e==`string`).join(` `):``:``}const cr=new Set([`left`,`right`,`bottom`,`top`,`image`]),lr=[{value:`image`,label:`Image only`},{value:`right`,label:`Image + text right`},{value:`left`,label:`Image + text left`},{value:`bottom`,label:`Image + text bottom`}],X={primary:`var(--exhibition-primary, #b84c74)`,fieldBorder:`var(--exhibition-field-border, #dcd5ce)`,fieldBackground:`var(--exhibition-field-bg, #f8f6f3)`,text:`var(--exhibition-text, #25211f)`,muted:`var(--exhibition-muted, #6a625c)`,buttonBackground:`var(--exhibition-button-bg, #ffffff)`,buttonText:`var(--exhibition-button-text, #ffffff)`,inactiveButtonText:`var(--exhibition-inactive-button-text, #332f2c)`},ur=[{value:12,label:`Full width`},{value:8,label:`2/3 width`},{value:6,label:`Half width`},{value:4,label:`1/3 width`}],dr=new Set([`float-top-left`,`float-top-right`,`float-bottom-left`,`float-bottom-right`]),fr=`exhibition-layout-panel-mode`,pr={component:()=>(0,p.jsx)(vr,{}),supports:{edit:!0,resourceTypes:[`Canvas`],properties:[`behavior`],custom:({resource:e},t)=>B(e,t)?!Xe(e,t):!1},id:`slide-behaviors`,label:`Layout`,tabs:{showTitle:!0}},mr=[{id:`layout`,type:`choice`,label:{en:[`Layout`]},initialOpen:!0,items:[{label:{en:[`Text on left`]},value:`left`},{label:{en:[`Text on right`]},value:`right`},{label:{en:[`Text on bottom`]},value:`bottom`},{label:{en:[`Text on top`]},value:`top`},{label:{en:[`Only image`]},value:`image`}]},{id:`floating`,type:`choice`,label:{en:[`Floating`]},initialOpen:!1,addNone:!0,groupBehavior:`floating`,items:[{label:{en:[`Float top left`]},value:`float-top-left`},{label:{en:[`Float top right`]},value:`float-top-right`},{label:{en:[`Float bottom left`]},value:`float-bottom-left`},{label:{en:[`Float bottom right`]},value:`float-bottom-right`}]},{id:`size`,component:(e,t)=>(0,p.jsx)(_r,{behaviors:e,setBehaviors:t}),label:{en:[`Size`]},type:`custom`,initialOpen:!0,supports:e=>e.startsWith(`w-`)||e.startsWith(`h-`)}];function hr(e){let t=0,n=0;for(let r of e)r.startsWith(`w-`)&&(t=Number.parseInt(r.slice(2))),r.startsWith(`h-`)&&(n=Number.parseInt(r.slice(2)));return{width:t,height:n}}function gr(e){return e.filter(e=>!cr.has(e)&&!e.startsWith(`w-`)&&!e.startsWith(`h-`)&&!dr.has(e)&&e!==`cover`)}function _r({behaviors:e,setBehaviors:t}){let{width:n,height:r}=hr(e),[i,a]=(0,m.useState)({x:-1,y:-1}),o=(n,r)=>{let i=e.filter(e=>!e.startsWith(`w-`)&&!e.startsWith(`h-`));i.push(`w-${n}`),i.push(`h-${r}`),t(i)};return(0,p.jsx)(`div`,{className:`grid grid-cols-12 grid-rows-12 gap-1`,onMouseLeave:()=>a({x:-1,y:-1}),children:Array.from({length:144},(e,t)=>{let s=t%12,c=Math.floor(t/12),l=i.x>=s&&i.y>=c,u=s<n&&c<r,d=l&&u,f=`bg-gray-200`;return l&&(f=`bg-me-200`),u&&(f=`bg-me-500`),d&&(f=`bg-me-400`),(0,p.jsx)(`div`,{className:`flex aspect-square rounded cursor-se-resize items-center justify-center ${f}`,onClick:()=>o(s+1,c+1),onMouseUp:()=>o(s+1,c+1),onMouseEnter:()=>a({x:s,y:c})},t)})})}function vr(){let[e,t]=(0,l.useLocalStorage)(`exhibition-layout-panel-mode`,`simple`);return(0,p.jsx)(h.Sidebar,{children:(0,p.jsxs)(h.SidebarContent,{className:`bg-white px-6 pt-5 pb-20`,children:[(0,p.jsx)(`div`,{className:`mb-6 flex justify-center`,children:(0,p.jsx)(Dr,{value:e,onChange:t})}),(0,p.jsx)(yr,{mode:e})]})})}function yr({mode:e=`advanced`,layoutContext:t=`default`}){let n=(0,u.useInStack)(`Canvas`),r=(0,l.useEditor)(),{width:i,height:a}=r.technical;return!n||r.technical.type!==`Canvas`?(0,p.jsx)(`div`,{className:`p-4`,children:`Please select canvas`}):e===`simple`?(0,p.jsx)(br,{behavior:r.technical.behavior.get()||[],layoutContext:t,canvasWidth:i.get()||0,canvasHeight:a.get()||0,onChange:e=>{r.technical.behavior.set(e)}}):(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(`div`,{className:`px-2`,children:(0,p.jsxs)(u.InputContainer,{$wide:!0,children:[(0,p.jsx)(u.DimensionsTriplet,{widthId:i.containerId(),width:i.get()||0,changeWidth:e=>i.set(e),heightId:a.containerId(),height:a.get()||0,changeHeight:e=>a.set(e)}),(0,p.jsx)(`div`,{children:(0,p.jsx)(qn,{})})]})}),(0,p.jsx)(u.BehaviorEditor,{behavior:r.technical.behavior.get()||[],onChange:e=>{r.technical.behavior.set(e)},configs:mr}),(0,p.jsx)(Jn,{})]})}function br({behavior:e,layoutContext:t,canvasWidth:n,canvasHeight:r,onChange:i}){let[a,o]=(0,m.useState)(Or(e)),[s,c]=(0,m.useState)(t===`slideshow`?12:Ar(e)),[l,u]=(0,m.useState)(jr(e)),[f,h]=(0,m.useState)(e.includes(`cover`)),g=H(e=>e.requestTab),_=(0,d.useCanvas)(),v=(0,d.useVault)(),y=(0,d.useManifest)(),b=t===`slideshow`?12:s,x=Nr({canvasWidth:n,canvasHeight:r,layoutPreset:a,displayWidth:b}),S=t===`default`&&y?.items&&_?Ir(_.id,y.items,v):null,C=o=>{let c=o.layoutPreset??a;i(Mr({behavior:e,layoutPreset:c,displayWidth:t===`slideshow`?12:o.displayWidth??s,canvasWidth:n,canvasHeight:r,floating:o.floating??l,cover:o.cover??f})),_&&Rr(v,_,c)};return(0,p.jsxs)(`div`,{className:`flex flex-col gap-7`,children:[(0,p.jsx)(xr,{layoutPreset:a,cover:f,floating:l,width:b,height:x,onTextClick:()=>g(`summary`)}),(0,p.jsxs)(Z,{children:[(0,p.jsx)(Q,{children:`Layout preset`}),(0,p.jsx)(`div`,{className:`mt-3 grid grid-cols-2 gap-3`,children:lr.map(e=>(0,p.jsx)(Sr,{preset:e.value,label:e.label,selected:a===e.value,onClick:()=>{o(e.value),C({layoutPreset:e.value})}},e.value))})]}),t===`default`?(0,p.jsxs)(Z,{children:[(0,p.jsx)(Q,{children:`Width`}),(0,p.jsx)(`div`,{className:`mt-3 grid grid-cols-2 gap-3`,children:ur.map(e=>(0,p.jsx)(Tr,{selected:s===e.value,onClick:()=>{c(e.value),C({displayWidth:e.value})},children:e.label},e.value))})]}):null,S?(0,p.jsxs)(Z,{children:[(0,p.jsxs)(Q,{children:[`Fit alongside `,S.neighbour,` slide`]}),(0,p.jsx)(`div`,{className:`mt-3`,children:(0,p.jsxs)(Tr,{selected:s===S.width,onClick:()=>{c(S.width),C({displayWidth:S.width})},children:[`w-`,S.width,` — fills remaining space`]})})]}):null,(0,p.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,p.jsx)(Er,{checked:l,label:`Floating`,onChange:e=>{u(e),C({floating:e})}}),(0,p.jsx)(Er,{checked:f,label:`Image cover`,onChange:e=>{h(e),C({cover:e})}})]})]})}function xr({layoutPreset:e,cover:t,floating:n,width:r,height:i,onTextClick:a}){let o=e===`bottom`,s=e===`image`,c=e===`left`;return(0,p.jsxs)(`div`,{children:[(0,p.jsxs)(`div`,{className:`relative mx-auto overflow-hidden rounded-md border bg-[#f8f6f3] shadow-sm`,style:{width:`${Math.max(33,Math.round(r/12*100))}%`,aspectRatio:`${r} / ${i}`,borderColor:X.fieldBorder},children:[(0,p.jsxs)(`div`,{className:(0,y.twMerge)(`flex h-full w-full min-h-0`,c?`flex-row-reverse`:o?`flex-col`:`flex-row`),children:[(0,p.jsx)(`div`,{className:`relative min-h-0 flex-1 overflow-hidden bg-white`,children:(0,p.jsx)(`div`,{className:`absolute inset-0`,children:(0,p.jsx)(h.LazyThumbnail,{cover:t,fade:!1})})}),s?null:(0,p.jsx)(`button`,{type:`button`,className:(0,y.twMerge)(`flex-shrink-0 border-0 bg-[#25211f] p-3 text-left text-white transition-colors hover:bg-[#332f2c] focus:outline-none focus:ring-2 focus:ring-me-primary-500 focus:ring-offset-2`,o?`h-1/3 w-full`:`h-full w-1/3`),onClick:a,children:(0,p.jsx)(wr,{tone:`light`})})]}),n?(0,p.jsx)(`div`,{className:`absolute right-2 top-2 h-7 w-10 rounded bg-white/90 shadow ring-1 ring-black/10`}):null]}),(0,p.jsxs)(`div`,{className:`mt-2 text-center text-xs`,style:{color:X.muted},children:[`w-`,r,` h-`,i]})]})}function Sr({preset:e,label:t,selected:n,onClick:r}){return(0,p.jsxs)(`button`,{type:`button`,className:`flex min-h-[112px] flex-col items-center justify-center gap-3 rounded-md border px-3 py-4 text-center text-sm font-semibold transition-colors`,style:{backgroundColor:n?X.primary:X.buttonText,borderColor:n?X.primary:X.fieldBorder,color:n?X.buttonText:X.inactiveButtonText},onClick:r,children:[(0,p.jsx)(Cr,{preset:e,selected:n}),(0,p.jsx)(`span`,{className:`leading-tight`,children:t})]})}function Cr({preset:e,selected:t}){let n=e===`image`,r=e===`bottom`,i=e===`left`,a=t?`bg-white/80`:`bg-[#25211f]`,o=t?`bg-white/25 ring-white/70`:`bg-[#f8f6f3] ring-[#dcd5ce]`;return(0,p.jsxs)(`span`,{className:(0,y.twMerge)(`flex h-12 w-16 gap-1 overflow-hidden rounded border p-1`,t?`border-white/70 bg-white/15`:`border-[#dcd5ce] bg-white`,i?`flex-row-reverse`:r?`flex-col`:`flex-row`),"aria-hidden":`true`,children:[(0,p.jsx)(`span`,{className:(0,y.twMerge)(`flex-1 rounded-sm ring-1`,o)}),n?null:(0,p.jsx)(`span`,{className:(0,y.twMerge)(`flex flex-shrink-0 flex-col justify-center gap-0.5 rounded-sm px-0.5`,a,r?`h-3 w-full`:`h-full w-4`),children:(0,p.jsx)(wr,{compact:!0,tone:t?`dark`:`light`})})]})}function wr({compact:e=!1,tone:t=`light`}){let n=t===`light`?`bg-white/70`:`bg-[#8b3f61]/70`;return(0,p.jsxs)(`span`,{className:(0,y.twMerge)(`block space-y-1.5`,e?`space-y-0.5`:`mt-1`),"aria-hidden":`true`,children:[(0,p.jsx)(`span`,{className:(0,y.twMerge)(`block rounded`,n,e?`h-0.5 w-full`:`h-1.5 w-3/4`)}),(0,p.jsx)(`span`,{className:(0,y.twMerge)(`block rounded`,n,e?`h-0.5 w-4/5`:`h-1.5 w-full`)}),(0,p.jsx)(`span`,{className:(0,y.twMerge)(`block rounded`,n,e?`h-0.5 w-2/3`:`h-1.5 w-2/3`)})]})}function Tr({selected:e,onClick:t,children:n}){return(0,p.jsx)(`button`,{type:`button`,className:`min-h-11 rounded-md border px-3 py-2 text-sm font-semibold transition-colors`,style:{backgroundColor:e?X.primary:X.buttonText,borderColor:e?X.primary:X.fieldBorder,color:e?X.buttonText:X.inactiveButtonText},onClick:t,children:n})}function Er({checked:e,label:t,onChange:n}){return(0,p.jsxs)(`label`,{className:`flex items-center justify-between rounded-md border px-4 py-3 text-sm font-semibold`,style:{backgroundColor:X.fieldBackground,borderColor:X.fieldBorder,color:X.text},children:[t,(0,p.jsx)(`input`,{type:`checkbox`,className:`h-4 w-4 accent-me-primary-500`,checked:e,onChange:e=>n(e.currentTarget.checked)})]})}function Dr({value:e,onChange:t}){return(0,p.jsx)(`div`,{className:`grid w-full max-w-[240px] grid-cols-2 rounded-full bg-[#f5eaf0] p-1`,children:[`simple`,`advanced`].map(n=>{let r=e===n;return(0,p.jsx)(v.Button,{className:`border-none rounded-full bg-transparent px-4 py-2 text-sm font-semibold capitalize transition-colors`,style:{backgroundColor:r?X.primary:`transparent`,color:r?`#ffffff`:`#8b3f61`,boxShadow:r?`0 1px 3px rgba(15, 23, 42, 0.18)`:`none`},onPress:()=>t(n),children:n},n)})})}function Z({children:e}){return(0,p.jsx)(`div`,{children:e})}function Q({children:e}){return(0,p.jsx)(`div`,{className:`text-sm font-semibold`,style:{color:X.muted},children:e})}function Or(e){return e.includes(`image`)?`image`:e.includes(`left`)?`left`:e.includes(`bottom`)?`bottom`:e.includes(`right`)?`right`:`image`}function kr(e,t,n){let r=e.filter(e=>!cr.has(e));if(n?.width&&n?.height){let{width:i}=hr(e),a=i?i<=4?4:i<=6?6:i<=8?8:12:12,o=Nr({canvasWidth:n.width,canvasHeight:n.height,layoutPreset:t,displayWidth:a}),s=r.filter(e=>!e.startsWith(`h-`));return s.push(`h-${o}`),s.push(t),s}return[...r,t]}function Ar(e){let{width:t}=hr(e);return t?t<=4?4:t<=6?6:t<=8?8:12:12}function jr(e){return e.some(e=>dr.has(e))}function Mr({behavior:e,layoutPreset:t,displayWidth:n,canvasWidth:r,canvasHeight:i,floating:a,cover:o}){let s=gr(e),c=Nr({canvasWidth:r,canvasHeight:i,layoutPreset:t,displayWidth:n});return s.push(t,`w-${n}`,`h-${c}`),a&&s.push(`float-top-right`),o&&s.push(`cover`),s}function Nr({canvasWidth:e,canvasHeight:t,layoutPreset:n,displayWidth:r}){let i=e&&t?e/t:1.5,a=n===`left`||n===`right`?r*(2/3):r,o=n===`bottom`?3/2:1,s=Math.round(a/i*o);return Math.max(1,Math.min(12,s))}const Pr=[{value:4,label:`1/3 width`},{value:6,label:`Half width`},{value:8,label:`2/3 width`},{value:12,label:`Full width`}];function Fr(e){let{width:t}=hr(e);return t}function Ir(e,t,n){let r=t.findIndex(t=>t.id===e);if(r===-1)return null;let i=e=>{if(!e)return 0;try{return Fr(n.get(e)?.behavior||[])}catch{return 0}},a=i(t[r-1]),o=i(t[r+1]);if(a>0&&a<12){let e=12-a;if(e>=4)return{width:e,neighbour:`previous`}}if(o>0&&o<12){let e=12-o;if(e>=4)return{width:e,neighbour:`next`}}return null}const Lr=new Set([`left`,`right`,`bottom`]);function Rr(e,t,n){Lr.has(n)&&((0,u.getInternationalStringText)(t.label)||e.modifyEntityField(t,`label`,{en:[`Untitled`]}),(0,u.getInternationalStringText)(t.summary)||e.modifyEntityField(t,`summary`,{en:[`Add a description for this slide.`]}))}const zr=new Set([`a`,`blockquote`,`br`,`code`,`em`,`h1`,`h2`,`h3`,`hr`,`i`,`img`,`li`,`ol`,`p`,`pre`,`s`,`span`,`strong`,`u`,`ul`]),Br={a:new Set([`href`,`rel`,`target`,`title`]),img:new Set([`alt`,`loading`,`src`,`title`])};function Vr(e){let t=Kr(e),n={};for(let[e,r]of Object.entries(t)){let t=r.filter(e=>typeof e==`string`).map(e=>qr(e)?Wr(e):Jr(e)).filter(Boolean).join(``);t&&(n[e]=[t])}return n}function Hr(e){let t={};for(let[n,r]of Object.entries(e||{})){let e=(r||[]).filter(e=>typeof e==`string`).map(e=>qr(e)?Wr(e):Jr(e)).filter(Boolean).join(``);e&&(t[n]=[e])}return t}function Ur(e){return Object.values(Vr(e)).flatMap(e=>Array.isArray(e)?e:[e]).filter(e=>typeof e==`string`).join(``)}function Wr(e){if(typeof document>`u`)return Xr(e);let t=document.createElement(`template`);return t.innerHTML=e||``,Gr(t.content),t.innerHTML}function Gr(e){for(let t of Array.from(e.childNodes)){if(t.nodeType===Node.ELEMENT_NODE){let e=t,n=e.tagName.toLowerCase();if(!zr.has(n)){e.replaceWith(...Array.from(e.childNodes));continue}for(let t of Array.from(e.attributes)){let r=t.name.toLowerCase(),i=Br[n]?.has(r)||!1,a=(r===`href`||r===`src`)&&/^(javascript|data):/i.test(t.value.trim());(!i||a)&&e.removeAttribute(t.name)}n===`a`&&e.getAttribute(`target`)===`_blank`&&e.setAttribute(`rel`,`noopener noreferrer`)}Gr(t)}}function Kr(e){if(!e)return{};if(typeof e==`string`)return{none:[e]};if(Array.isArray(e))return{none:e.filter(e=>typeof e==`string`)};if(typeof e==`object`){let t={};for(let[n,r]of Object.entries(e))t[n]=(Array.isArray(r)?r:[r]).filter(e=>typeof e==`string`);return t}return{}}function qr(e){return e.trimStart().startsWith(`<`)}function Jr(e){return e.replace(/\r\n?/g,`
2
- `).split(/\n+/).map(e=>e.trim()).filter(Boolean).map(e=>`<p>${Yr(e)}</p>`).join(``)}function Yr(e){return e.replace(/&/g,`&amp;`).replace(/</g,`&lt;`).replace(/>/g,`&gt;`).replace(/"/g,`&quot;`).replace(/'/g,`&#39;`)}function Xr(e){return(e||``).replace(/<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi,``).replace(/<style\b[^<]*(?:(?!<\/style>)<[^<]*)*<\/style>/gi,``).replace(/\s+on[a-z]+\s*=\s*(?:"[^"]*"|'[^']*'|[^\s>]+)/gi,``).replace(/\s+(href|src)\s*=\s*(["'])\s*(?:javascript|data):[^"']*\2/gi,``)}const Zr={id:`@exhibition/right-panel-editor`,supports:{edit:!0,properties:[`label`,`summary`],resourceTypes:[`Canvas`],custom:({resource:e},t)=>B(e,t)?!Xe(e,t):!1},label:`Exhibition`,component:()=>(0,p.jsx)(Qr,{})};function Qr(){return(0,p.jsx)(h.Sidebar,{children:(0,p.jsx)(h.SidebarContent,{padding:!0,children:(0,p.jsx)($r,{})})})}function $r(){let e=(0,d.useCanvas)(),t=(0,d.useVault)(),n=(0,l.useEditingResource)(),{structural:r,technical:i}=(0,l.useEditor)(),{items:a}=r,o=i.behavior.get()||[],s=a.get()[0],c=Qe(e),f=o.includes(`info`),m=rt(t,e);return!e||!s||!n?(0,p.jsx)(`div`,{className:`p-8`,children:`Canvas, page, or resource not found`}):f?(0,p.jsxs)(l.ResourceEditingProvider,{resource:e,children:[c?null:(0,p.jsx)(Kn,{}),(0,p.jsx)(ei,{canvas:e}),m?(0,p.jsx)(ti,{canvas:e}):null]}):(0,p.jsxs)(l.ResourceEditingProvider,{resource:e,children:[c?null:(0,p.jsx)(Kn,{}),(0,p.jsx)(ei,{canvas:e}),(0,p.jsx)(u.InputContainer,{$wide:!0,children:(0,p.jsxs)(`div`,{children:[(0,p.jsx)(`div`,{className:`exhibition-workbench-muted mb-3 text-sm font-semibold`,children:`Layout preset`}),(0,p.jsx)(`div`,{className:`grid grid-cols-2 gap-3`,children:lr.map(n=>(0,p.jsx)(Sr,{preset:n.value,label:n.label,selected:Or(o)===n.value,onClick:()=>{i.behavior.set(kr(o,n.value,e?{width:e.width,height:e.height}:void 0)),e&&Rr(t,e,n.value)}},n.value))}),(0,p.jsx)(ni,{canvas:e,tabId:`slide-behaviors`,label:`Edit layout options`})]})}),m?(0,p.jsx)(ti,{canvas:e}):null,(0,p.jsx)(d.AnnotationPageContext,{annotationPage:s.id,children:(0,p.jsx)(u.PaintingAnnotationList,{createFilter:`image`})})]})}function ei({canvas:e}){let{edit:t}=(0,l.useLayoutActions)(),n=(0,m.useRef)(null),[r,i]=(0,m.useState)(!1),[a,o]=(0,m.useState)(!1),s=ri(e.label)||`Untitled`,c=Ur(e.summary);return(0,m.useEffect)(()=>{let e=n.current;if(!e){o(!1);return}o(e.scrollHeight>e.clientHeight+1)},[c,r]),(0,p.jsx)(u.InputContainer,{$wide:!0,children:(0,p.jsxs)(`div`,{className:`rounded-md border border-[#dcd5ce] bg-[#f8f6f3] p-4`,children:[(0,p.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,p.jsxs)(`div`,{className:`min-w-0`,children:[(0,p.jsx)(`div`,{className:`text-xs font-semibold uppercase text-[#6a625c]`,children:`Label`}),(0,p.jsx)(`div`,{className:`mt-1 break-words text-base font-semibold text-[#25211f]`,children:s})]}),(0,p.jsx)(`button`,{type:`button`,className:`flex-shrink-0 rounded-md px-3 py-2 text-sm font-semibold shadow-sm`,style:{backgroundColor:`#b84c74`,border:`1px solid #a13e63`,color:`#ffffff`},onClick:()=>{t({id:e.id,type:`Canvas`},void 0,{selectedTab:`@exhibition/summary-editor`,forceOpen:!0})},children:`Edit`})]}),(0,p.jsxs)(`div`,{className:`mt-5`,children:[(0,p.jsx)(`div`,{className:`text-xs font-semibold uppercase text-[#6a625c]`,children:`Summary`}),(0,p.jsx)(`div`,{ref:n,className:[`mt-2 whitespace-pre-wrap break-words text-sm leading-relaxed text-[#332f2c]`,r?``:`max-h-32 overflow-hidden`].join(` `),children:c?(0,p.jsx)(`div`,{className:`prose prose-sm max-w-none prose-p:my-2 prose-headings:my-2 prose-ul:my-2 prose-ol:my-2`,dangerouslySetInnerHTML:{__html:c}}):(0,p.jsx)(`span`,{className:`text-[#6a625c]`,children:`No summary added.`})}),a||r?(0,p.jsx)(`button`,{type:`button`,className:`mt-2 text-sm font-semibold text-[#b84c74]`,onClick:()=>i(e=>!e),children:r?`Read less`:`Read more`}):null]})]})})}function ti({canvas:e}){let t=(0,d.useVault)(),n=e.annotations?.[0],r=n?t.get(n,{skipSelfReturn:!1}):null,i=Array.isArray(r?.items)?r.items.length:0,a=i===0?`There are no tour steps yet.`:`${i} tour step${i===1?``:`s`} on this canvas.`;return(0,p.jsx)(u.InputContainer,{$wide:!0,children:(0,p.jsxs)(`div`,{className:`rounded-md border border-[#dcd5ce] bg-white p-4`,children:[(0,p.jsx)(`div`,{className:`text-sm font-semibold text-[#25211f]`,children:`Tour steps`}),(0,p.jsx)(`div`,{className:`mt-1 text-sm text-[#6a625c]`,children:a}),(0,p.jsx)(ni,{canvas:e,tabId:`@exhibition/tour-steps`,label:i===0?`Open Tour steps tab to add one`:`Open Tour steps tab`})]})})}function ni({canvas:e,tabId:t,label:n}){let{edit:r}=(0,l.useLayoutActions)();return(0,p.jsxs)(`button`,{type:`button`,onClick:()=>r({id:e.id,type:`Canvas`},void 0,{selectedTab:t,forceOpen:!0}),className:`flex gap-2 items-center justify-between mt-3 text-me-primary-600 bg-gray-50 py-2 px-4 rounded-full hover:bg-gray-100`,children:[(0,p.jsx)(`span`,{className:`text-left text-sm font-semibold`,children:n}),(0,p.jsx)(h.ArrowRightIcon,{})]})}function ri(e){return e?typeof e==`string`?e:Array.isArray(e)?e.filter(Boolean).join(` `):typeof e==`object`?Object.values(e).flatMap(e=>Array.isArray(e)?e:[e]).filter(e=>typeof e==`string`).join(` `):``:``}const ii={id:`@exhibition/summary-editor`,supports:{edit:!0,properties:[`summary`],resourceTypes:[`Canvas`],custom:({resource:e},t)=>B(e,t)?!Xe(e,t):!1},label:`Summary`,component:()=>(0,p.jsx)(ai,{})};function ai(){return(0,p.jsx)(h.Sidebar,{children:(0,p.jsx)(h.SidebarContent,{padding:!0,children:(0,p.jsx)(oi,{})})})}function oi(){let e=(0,d.useCanvas)();return e?(0,p.jsxs)(l.ResourceEditingProvider,{resource:e,children:[(0,p.jsx)(u.LanguageMapEditor,{dispatchType:`label`}),(0,p.jsx)(si,{canvas:e})]}):null}function si({canvas:e}){let t=(0,d.useVault)(),n=(0,m.useMemo)(()=>Vr(e.summary),[e.summary]);return(0,p.jsx)(u.TiptapLanguageFieldEditor,{label:`summary`,metadataKey:`summary`,fields:n,onSave:n=>{t.modifyEntityField(e,`summary`,Hr(n.toInternationalString()))}},e.id)}function ci(e){return(0,p.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,width:`1em`,height:`1em`,viewBox:`0 0 24 24`,...e,children:(0,p.jsx)(`path`,{fill:`currentColor`,d:`M9 16.17L4.83 12l-1.42 1.41L9 19L21 7l-1.41-1.41z`})})}const li=`<h2>New step</h2><p>Description</p>`;function ui(){let{saveAnnotation:e}=(0,d.useCurrentAnnotationActions)(),[t,n]=(0,d.useCurrentAnnotationMetadata)(),{editorFeatureFlags:r}=(0,l.useConfig)(),{annotationPopups:i}=r;return i?(0,p.jsxs)(`div`,{className:`bg-white shadow-md rounded-lg`,children:[(0,p.jsx)(`div`,{className:`prose-headings:mt-1 overflow-y-auto rounded prose-headings:mb-1 prose-sm focus-within:ring-1 focus-within:ring-me-primary-500`,children:(0,p.jsx)(h.HTMLEditor,{className:`border-none`,value:t.bodyValue||li,onChange:e=>n({bodyValue:e})})}),(0,p.jsxs)(`div`,{className:`flex gap-2 p-3`,children:[(0,p.jsxs)(h.ActionButton,{primary:!0,onPress:()=>e(),children:[(0,p.jsx)(ci,{}),` Finish editing`]}),(0,p.jsx)(u.AnnotationPopUpSwitcherButton,{})]})]}):(0,p.jsxs)(`div`,{className:`flex gap-2`,children:[(0,p.jsxs)(h.ActionButton,{primary:!0,onPress:()=>e(),children:[(0,p.jsx)(ci,{}),` Finish editing`]}),(0,p.jsx)(u.AnnotationPopUpSwitcherButton,{})]})}function di(){let e=(0,f.useStore)((0,l.useAtlasStore)(),e=>e.polygon),[t,n]=(0,d.useCurrentAnnotationMetadata)(),{editorFeatureFlags:r}=(0,l.useConfig)(),{annotationPopups:i}=r,{cancelRequest:a,saveAnnotation:o}=(0,d.useCurrentAnnotationActions)();return(0,p.jsxs)(`div`,{className:`border border-gray-300 hover:border-me-500 shadow-sm rounded bg-white relative`,children:[(0,p.jsxs)(`div`,{className:`bg-me-primary-500 text-white p-2 m-1 rounded flex gap-2`,children:[(0,p.jsx)(h.TargetIcon,{}),`Draw a box on the canvas`]}),i?(0,p.jsx)(`div`,{className:`relative p-3 line-clamp-3 prose-p:text-slate-600`,children:(0,p.jsx)(`div`,{className:`prose-headings:mt-1 prose-headings:mb-1 prose-sm`,children:(0,p.jsx)(`div`,{dangerouslySetInnerHTML:{__html:t.bodyValue||li}})})}):(0,p.jsx)(h.HTMLEditor,{className:`border-none`,value:t.bodyValue||li,onChange:e=>n({bodyValue:e})}),(0,p.jsxs)(`div`,{className:`flex gap-2 p-3`,children:[(0,p.jsxs)(h.ActionButton,{isDisabled:e?.points.length===0,onPress:()=>o(),children:[(0,p.jsx)(ci,{}),` Finish editing`]}),(0,p.jsxs)(h.ActionButton,{className:`gap-2 flex`,onPress:()=>a(),children:[(0,p.jsx)(h.DeleteIcon,{}),` Delete`]}),(0,p.jsx)(u.AnnotationPopUpSwitcherButton,{})]})]})}function fi(){let{editorFeatureFlags:e}=(0,l.useConfig)(),{annotationPopups:t}=e,n=(0,l.useSaveConfig)();return(0,p.jsx)(h.ActionButton,{className:`ml-auto`,onPress:()=>n({editorFeatureFlags:{...e,annotationPopups:!t}}),children:t?(0,p.jsx)(h.AnnotationPopInIcon,{}):(0,p.jsx)(h.AnnotationPopOutIcon,{})})}function pi({highlightProps:e,useSlideshowWorkbench:t=!1}){let n=(0,m.useContext)(l.ResourceEditingReactContext),r=(0,d.useAnnotation)(),{editorFeatureFlags:i}=(0,l.useConfig)(),{annotationPopups:a}=i,o=V(e=>e.startTourStepRepositioning),s=H(e=>e.requestTab),c=H(e=>e.setShowTourSteps),{isPending:f,cancelRequest:g,busy:_,requestAnnotationFromTarget:v,deleteAnnotation:y}=(0,u.useAnnotationEditor)({annotationPopup:(0,p.jsx)(d.AnnotationContext,{annotation:r.id,children:(0,p.jsx)(l.ResourceEditingReactContext.Provider,{value:n,children:(0,p.jsx)(mi,{})})})}),[b,x]=(0,m.useState)(!1),S=()=>!t||!r?.id?!1:(c(!0),o(r.id),s(`tour`),!0);return(0,m.useEffect)(()=>{b&&!f&&x(!0)},[f,b]),(0,p.jsxs)(`div`,{...e,className:`exhibition-tour-step-card border border-gray-300 hover:border-me-500 shadow-sm rounded bg-white relative`,onClick:S,children:[(0,p.jsx)(`div`,{className:`relative`,children:b&&!a?(0,p.jsx)(u.HTMLAnnotationEditor,{className:`border-none`}):(0,p.jsx)(h.HTMLAnnotationBodyRender,{className:`exhibition-tour-step-body px-3 pt-3 line-clamp-3 prose-p:text-slate-600`,locale:`en`})}),(0,p.jsxs)(`div`,{className:`flex gap-2 p-2`,children:[b&&f?(0,p.jsxs)(p.Fragment,{children:[(0,p.jsxs)(h.ActionButton,{primary:!0,onPress:()=>{x(!1),g()},children:[(0,p.jsx)(ci,{}),` Finish editing`]}),(0,p.jsx)(u.AnnotationPopUpSwitcherButton,{})]}):(0,p.jsxs)(h.ActionButton,{isDisabled:_,onPress:()=>{t&&r?.id&&(c(!0),o(r.id),s(`tour`)),x(!0),v().then(()=>{x(!1)})},children:[(0,p.jsx)(h.EditTextIcon,{}),` Edit`]}),(0,p.jsxs)(h.ActionButton,{className:`gap-2 flex`,onPress:()=>y(),children:[(0,p.jsx)(h.DeleteIcon,{}),` Delete`]})]}),(0,p.jsx)(`div`,{className:`absolute -bottom-5 left-5 h-5 border-l-2 border-gray-300 w-0`})]})}function mi(){let{editorFeatureFlags:e}=(0,l.useConfig)(),{annotationPopups:t}=e,{saveAnnotation:n}=(0,d.useCurrentAnnotationActions)();return t?(0,p.jsxs)(`div`,{className:`bg-white shadow-md rounded-lg relative max-h-[50vh] overflow-y-auto`,children:[(0,p.jsx)(`div`,{className:`prose-headings:mt-1 rounded prose-headings:mb-1 prose-sm focus-within:ring-1 focus-within:ring-me-primary-500`,children:(0,p.jsx)(u.HTMLAnnotationEditor,{className:`border-none`})}),(0,p.jsxs)(`div`,{className:`flex gap-2 p-2 sticky bottom-0 z-50 bg-white`,children:[(0,p.jsxs)(h.ActionButton,{primary:!0,onPress:()=>{n()},children:[(0,p.jsx)(ci,{}),` Finish editing`]}),(0,p.jsx)(fi,{})]})]}):(0,p.jsxs)(`div`,{className:`flex gap-2`,children:[(0,p.jsxs)(h.ActionButton,{primary:!0,onPress:()=>n(),children:[(0,p.jsx)(ci,{}),` Finish editing`]}),(0,p.jsx)(u.AnnotationPopUpSwitcherButton,{})]})}function hi({originalAnnotationId:e,highlightProps:t,useSlideshowWorkbench:n=!1}){let r=(0,l.useGenericEditor)((0,d.useAnnotationPage)()),i=(0,d.useAnnotation)(),a=(0,d.useCanvas)(),o=(0,d.useVault)(),{edit:s}=(0,l.useLayoutActions)(),[c,f]=(0,m.useState)(!1),g=V(e=>e.startTourStepRepositioning),_=H(e=>e.requestTab),v=H(e=>e.setShowTourSteps),y=a?.items?.[0],b=y?.id&&i?.id?(o.get(y)?.items||[]).findIndex(e=>e.id===i.id):-1,x=()=>{if(e&&confirm(`Are you sure you want to delete this annotation?`)){let t=r.structural.items.getWithoutTracking().findIndex(t=>t.id===e);r.structural.items.deleteAtIndex(t)}},S=()=>!n||!e?!1:(v(!0),g(e),_(`tour`),!0);return(0,p.jsxs)(`div`,{...t,className:`exhibition-tour-step-card border border-gray-300 hover:border-me-500 shadow-sm rounded bg-white relative`,onClick:S,children:[(0,p.jsx)(`div`,{className:`flex gap-2 mb-2 p-3`,children:(0,p.jsx)(`div`,{className:`flex-1 min-w-0`,children:c?(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(`h3`,{className:`text-lg font-semibold border-b pt-1 pb-2 mb-2`,children:`Edit step`}),(0,p.jsx)(u.LanguageMapEditor,{dispatchType:`label`}),(0,p.jsx)(u.LanguageMapEditor,{dispatchType:`summary`})]}):(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(d.LocaleString,{as:`div`,defaultText:(0,p.jsx)(`span`,{className:`opacity-50`,children:`Untitled`}),className:`whitespace-nowrap overflow-ellipsis w-full overflow-x-hidden`,children:i?.label}),(0,p.jsx)(d.LocaleString,{className:`exhibition-tour-step-body text-gray-500 text-sm bg-white line-clamp-2`,as:`div`,children:i?.summary})]})})}),(0,p.jsxs)(`div`,{className:`flex gap-2 p-2`,children:[c?(0,p.jsxs)(h.ActionButton,{onPress:()=>f(!1),children:[(0,p.jsx)(ci,{}),` Finish editing`]}):(0,p.jsxs)(h.ActionButton,{onPress:()=>f(!0),children:[(0,p.jsx)(h.EditTextIcon,{}),` Edit body`]}),(0,p.jsx)(h.ActionButton,{onPress:()=>{S()||i&&s({id:i.id,type:`Annotation`},y?{parent:y,property:`items`,index:b}:void 0,{forceOpen:!0})},children:`Edit annotation`}),(0,p.jsxs)(h.ActionButton,{className:`gap-2 flex`,onPress:()=>x(),children:[(0,p.jsx)(h.DeleteIcon,{}),` Delete`]})]}),(0,p.jsx)(`div`,{className:`absolute -bottom-5 left-5 h-5 border-l-2 border-gray-300 w-0`})]})}function gi({useSlideshowWorkbench:e=!1}){let[t,{annotationTarget:n,highlightProps:r}]=(0,u.useAnnotationInfo)(),i=(0,m.useMemo)(()=>n?{id:n,type:`Annotation`}:{id:t?.id,type:`Annotation`},[t?.id,n]);return n?(0,p.jsx)(l.ResourceEditingProvider,{resource:i,children:(0,p.jsx)(d.AnnotationContext,{annotation:n,children:(0,p.jsx)(hi,{originalAnnotationId:t?.id,highlightProps:r,useSlideshowWorkbench:e})})}):(0,p.jsx)(l.ResourceEditingProvider,{resource:i,children:(0,p.jsx)(pi,{highlightProps:r,useSlideshowWorkbench:e})})}function _i({reorderable:e=!1,useSlideshowWorkbench:t=!1}){let n=(0,d.useAnnotationPage)(),r=(0,l.useGenericEditor)(n);return n?e?(0,p.jsx)(p.Fragment,{children:(0,p.jsx)(u.ReorderList,{id:n.id,marginBottom:`0.5em`,items:n.items||[],inlineHandle:!1,reorder:({startIndex:e,endIndex:t})=>r.structural.items.reorder(e,t),renderItem:(e,n)=>(0,p.jsx)(d.AnnotationContext,{annotation:e.id,children:(0,p.jsx)(gi,{useSlideshowWorkbench:t})})})}):(0,p.jsx)(p.Fragment,{children:n.items.map(e=>(0,p.jsx)(d.AnnotationContext,{annotation:e.id,children:(0,p.jsx)(gi,{useSlideshowWorkbench:t})},e.id))}):null}const vi={id:`@exhibition/tour-steps`,supports:{edit:!0,properties:[`annotations`],resourceTypes:[`Canvas`],custom:({resource:e},t)=>B(e,t)?!Xe(e,t)&&!Ze(e,t):!1},label:`Tour steps`,component:()=>(0,p.jsx)(yi,{})};function yi({mode:e=`advanced`}){let t=(0,d.useCanvas)(),n=t?.annotations[0],r=t?.items[0];return!n||!t||!r?(0,p.jsx)(bi,{}):(0,p.jsx)(h.Sidebar,{children:(0,p.jsx)(h.SidebarContent,{padding:!0,children:(0,p.jsx)(xi,{mode:e})})})}function bi(){let e=(0,d.useCanvas)(),t=(0,l.useInlineCreator)(),n=()=>{e&&t.create(`@manifest-editor/empty-annotation-page`,{label:{en:[`Tour steps`]}},{target:{id:e.id,type:`Canvas`},targetType:`AnnotationPage`,parent:{property:`annotations`,resource:{id:e.id,type:`Canvas`}}})};return(0,p.jsxs)(`div`,{className:`flex flex-col items-center justify-center p-4`,children:[(0,p.jsx)(`div`,{className:`p-4 opacity-50 text-center`,children:`This image does not yet have a tour.`}),(0,p.jsx)(v.Button,{className:`border w-full disabled:opacity-50 border-gray-300 hover:border-me-500 hover:bg-me-50 cursor-pointer shadow-sm rounded p-4 bg-white relative text-black/40 hover:text-me-500`,onPress:()=>n(),children:`Create Tour`})]})}function xi({mode:e,useSlideshowWorkbench:t=!1}){let n=(0,d.useCanvas)(),r=n?.annotations?.[0],i=n?.items?.[0],[a,o]=(0,m.useState)(!1),s=H(e=>e.setShowTourSteps),c=V(e=>e.stopRepositioning),f=V(e=>e.stopTextRepositioning);(0,m.useEffect)(()=>{s(!0),c(),f()},[s,c,f]);let{requestTourStep:g,isPending:_,busy:y}=Si({onBeforeRequest:t?()=>{s(!0),c(),f()}:void 0});if(!n)return null;if(!r)return(0,p.jsx)(bi,{});let b=e===`advanced`&&!!i;return(0,p.jsxs)(p.Fragment,{children:[(0,p.jsxs)(`div`,{className:`flex gap-4 border-b pt-4 pb-2 mb-2`,children:[(0,p.jsx)(`h2`,{className:`text-lg font-semibold flex-1`,children:`Tour steps`}),e===`advanced`?(0,p.jsx)(h.ActionButton,{onPress:()=>o(e=>!e),children:a?`Done`:`Reorder`}):null]}),(0,p.jsx)(l.ResourceEditingProvider,{resource:n,children:(0,p.jsxs)(d.AnnotationPageContext,{annotationPage:r.id,children:[(0,p.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,p.jsx)(_i,{reorderable:e===`advanced`?a:!1,useSlideshowWorkbench:t}),y?null:_?(0,p.jsx)(di,{}):(0,p.jsx)(v.Button,{onPress:g,className:`border disabled:opacity-50 border-gray-300 hover:border-me-500 hover:bg-me-50 cursor-pointer shadow-sm rounded p-4 bg-white relative text-black/40 hover:text-me-500`,children:`+ Add new step`})]}),b&&i?(0,p.jsx)(p.Fragment,{children:(0,p.jsx)(u.PromptToAddPaintingAnnotations,{title:(0,p.jsx)(`h3`,{className:`text-md border-b pt-4 pb-2 mb-2`,children:`Available tour steps from images`}),painting:i,page:r,canvasId:n.id})}):null]})})]})}function Si({onBeforeRequest:e}={}){let t=(0,d.useCanvas)(),n=t?.annotations?.[0],r=(0,l.useInlineCreator)(),{requestAnnotation:i,isPending:a,busy:o}=(0,d.useRequestAnnotation)({onSuccess:e=>{let i=e.metadata.bodyValue||``;!e.cancelled&&e.target&&t&&n&&r.create(`@manifest-editor/html-annotation`,{label:{en:[`Tour step`]},body:{en:[i||`<h2>New step</h2><p>Description</p>`]},motivation:`tagging`},{target:{id:t.id,type:`Canvas`},targetType:`Annotation`,parent:{property:`items`,resource:{id:n.id,type:`AnnotationPage`}},initialData:{selector:e}})}});return{requestTourStep:()=>{e?.(),i({type:`box`,annotationPopup:(0,p.jsx)(ui,{})})},isPending:a,busy:o,canRequestTourStep:!!(t&&n)}}const Ci=`exhibition-info-box-mode`,wi={id:`@exhibition/info-box-editor`,supports:{edit:!0,properties:[`label`,`behavior`],resourceTypes:[`Canvas`],custom:({resource:e},t)=>B(e,t)?Xe(e,t):!1},label:`Text box`,component:()=>(0,p.jsx)(Ti,{})};function Ti(){let[e,t]=(0,l.useLocalStorage)(`exhibition-info-box-mode`,`simple`),n=(0,d.useCanvas)(),r=(0,d.useVault)(),i=(0,d.useManifest)(),a=(0,l.useEditor)();if(!n||a.technical.type!==`Canvas`)return null;let o=a.technical.behavior.get()||[],s=Fr(o)||12,c=e=>{let t=o.filter(e=>!e.startsWith(`w-`)&&!e.startsWith(`h-`)),n=o.find(e=>e.startsWith(`h-`));t.push(`w-${e}`),n||t.push(`h-4`),a.technical.behavior.set(t)},f=i?.items&&n?Ir(n.id,i.items,r):null;return(0,p.jsx)(h.Sidebar,{children:(0,p.jsxs)(h.SidebarContent,{className:`bg-white px-6 pt-5 pb-20`,children:[(0,p.jsx)(`div`,{className:`flex justify-center`,children:(0,p.jsx)(Dr,{value:e,onChange:t})}),(0,p.jsxs)(`div`,{className:`mt-8 flex flex-col gap-7`,children:[(0,p.jsx)(l.ResourceEditingProvider,{resource:n,children:e===`simple`?(0,p.jsxs)(Z,{children:[(0,p.jsx)(Q,{children:`Title`}),(0,p.jsx)(`div`,{className:`mt-2`,children:(0,p.jsx)(u.LanguageMapEditor,{dispatchType:`label`,disableMultiline:!0,disallowHTML:!0})})]}):(0,p.jsxs)(Z,{children:[(0,p.jsx)(Q,{children:`Label & summary`}),(0,p.jsxs)(`div`,{className:`mt-2 flex flex-col gap-3`,children:[(0,p.jsx)(u.LanguageMapEditor,{dispatchType:`label`,disableMultiline:!0,disallowHTML:!0}),(0,p.jsx)(u.LanguageMapEditor,{dispatchType:`summary`})]})]})}),e===`simple`?(0,p.jsxs)(p.Fragment,{children:[(0,p.jsxs)(Z,{children:[(0,p.jsx)(Q,{children:`Width`}),(0,p.jsx)(`div`,{className:`mt-3 grid grid-cols-2 gap-3`,children:Pr.map(e=>(0,p.jsx)(Tr,{selected:s===e.value,onClick:()=>c(e.value),children:e.label},e.value))})]}),f?(0,p.jsxs)(Z,{children:[(0,p.jsxs)(Q,{children:[`Fit alongside `,f.neighbour,` slide`]}),(0,p.jsx)(`div`,{className:`mt-3`,children:(0,p.jsxs)(Tr,{selected:s===f.width,onClick:()=>c(f.width),children:[`w-`,f.width,` — fills remaining space`]})})]}):null,(0,p.jsxs)(`div`,{className:`text-center text-xs`,style:{color:X.muted},children:[`w-`,s]})]}):(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(`div`,{className:`px-2`,children:(0,p.jsx)(u.InputContainer,{$wide:!0,children:(0,p.jsx)(u.DimensionsTriplet,{widthId:a.technical.width.containerId(),width:a.technical.width.get()||0,changeWidth:e=>a.technical.width.set(e),heightId:a.technical.height.containerId(),height:a.technical.height.get()||0,changeHeight:e=>a.technical.height.set(e)})})}),(0,p.jsx)(u.BehaviorEditor,{behavior:o,onChange:e=>a.technical.behavior.set(e),configs:[{id:`size`,component:(e,t)=>(0,p.jsx)(_r,{behaviors:e,setBehaviors:t}),label:{en:[`Size`]},type:`custom`,initialOpen:!0,supports:e=>e.startsWith(`w-`)||e.startsWith(`h-`)}]})]})]})]})})}const Ei=`editorial-text`;function Di(){let e=(0,d.useCanvas)(),t=e?.items?.[0]?{id:e.items[0].id,type:`AnnotationPage`}:void 0,[,n]=(0,l.useCreator)(t,`items`,`Annotation`,e?{id:e.id,type:`Canvas`}:void 0,{isPainting:!0}),{selectedAnnotationId:r,repositioningAnnotationId:i,selectedTextRegion:a,repositioningTextRegion:o,selectAnnotation:s,startRepositioning:c,stopRepositioning:u,selectTextRegion:f,startTextRepositioning:m,stopTextRepositioning:h}=V(),g=H(e=>e.setShowTourSteps),_=(0,d.useVaultSelector)((t,n)=>e?at(n,e):[],[e?.id,t?.id]),v=ut(e).text,y=_.length||v;return!e||!t?(0,p.jsxs)(`div`,{children:[(0,p.jsx)(Ii,{children:`Content on this slide`}),(0,p.jsx)(`p`,{className:`exhibition-workbench-muted mt-2 text-sm leading-relaxed`,children:`This slide does not have a content layer yet.`})]}):(0,p.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,p.jsxs)(`div`,{children:[(0,p.jsx)(Ii,{children:`Content on this slide`}),(0,p.jsx)(`p`,{className:`exhibition-workbench-muted mt-2 text-sm leading-relaxed`,children:`Select a painting annotation to highlight it in the workbench. Use the centre panel to add, position, and edit slide content.`})]}),y?(0,p.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[v?(0,p.jsx)(ki,{box:v,selected:a===Ei,repositioning:o===Ei,onSelect:()=>{g(!1),f(Ei)},onReposition:()=>{g(!1),m(Ei)},onStopReposition:h}):null,_.map((e,t)=>(0,p.jsx)(Oi,{layer:e,index:t,selected:r===e.annotation.id,repositioning:i===e.annotation.id,onSelect:()=>{g(!1),s(e.annotation.id)},onReposition:()=>{g(!1),c(e.annotation.id)},onStopReposition:u,onAdvancedEdit:()=>n.edit({id:e.annotation.id,type:`Annotation`},t)},e.annotation.id))]}):(0,p.jsx)(`div`,{className:`exhibition-slideshow-content-empty rounded-lg border border-dashed border-slate-200 bg-slate-50 p-4 text-sm`,children:`No painting annotations on this slide yet.`})]})}function Oi({layer:e,index:t,selected:n,repositioning:r,onSelect:i,onReposition:a,onStopReposition:o,onAdvancedEdit:s}){let c=(0,d.useVault)(),l=(0,u.useAnnotationThumbnail)({annotationId:e.annotation.id,options:{maxWidth:96,maxHeight:96}}),f=Pi(e.annotation,c),m=ji(e,f),h=Mi(e,f,t),g=Ni(e,f,m);return(0,p.jsxs)(`div`,{className:[`exhibition-slideshow-content-item rounded-lg border bg-white p-3 transition`,n?`exhibition-slideshow-content-item-selected border-me-primary-500 bg-me-primary-50 ring-2 ring-me-primary-100`:`border-slate-200`].join(` `),children:[(0,p.jsxs)(v.Button,{className:`flex w-full items-center gap-3 border-none bg-transparent p-0 text-left`,onPress:i,children:[(0,p.jsx)(Ai,{thumbnailUrl:l?.id,type:m}),(0,p.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,p.jsx)(`span`,{className:`block text-[11px] font-semibold uppercase tracking-wide text-me-primary-500`,children:m}),(0,p.jsx)(`span`,{className:`mt-0.5 block truncate text-sm font-semibold`,children:h}),(0,p.jsx)(`span`,{className:`exhibition-workbench-muted mt-0.5 block truncate text-xs`,children:g})]})]}),(0,p.jsxs)(`div`,{className:`mt-3 flex items-center justify-between gap-3`,children:[(0,p.jsx)(`span`,{className:`exhibition-workbench-muted text-xs`,children:r?`Drag or resize in the workbench`:n?`Selected in workbench`:`Click to select on slide`}),(0,p.jsxs)(`div`,{className:`flex gap-2`,children:[(0,p.jsx)(v.Button,{className:`rounded-md border border-me-primary-200 bg-me-primary-50 px-3 py-1.5 text-xs font-semibold text-me-primary-600 transition hover:bg-me-primary-100`,onPress:r?o:a,children:r?`Done moving`:`Reposition`}),(0,p.jsx)(v.Button,{className:`rounded-md border border-slate-200 bg-white px-3 py-1.5 text-xs font-semibold text-slate-700 transition hover:bg-slate-50`,onPress:s,children:`Advanced edit`})]})]})]})}function ki({box:e,selected:t,repositioning:n,onSelect:r,onReposition:i,onStopReposition:a}){return(0,p.jsxs)(`div`,{className:[`exhibition-slideshow-content-item rounded-lg border bg-white p-3 transition`,t?`exhibition-slideshow-content-item-selected border-me-primary-500 bg-me-primary-50 ring-2 ring-me-primary-100`:`border-slate-200`].join(` `),children:[(0,p.jsxs)(v.Button,{className:`flex w-full items-center gap-3 border-none bg-transparent p-0 text-left`,onPress:r,children:[(0,p.jsx)(Ai,{type:`Text`}),(0,p.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,p.jsx)(`span`,{className:`block text-[11px] font-semibold uppercase tracking-wide text-me-primary-500`,children:`Editorial text`}),(0,p.jsx)(`span`,{className:`mt-0.5 block truncate text-sm font-semibold`,children:`Slide label and summary`}),(0,p.jsxs)(`span`,{className:`exhibition-workbench-muted mt-0.5 block truncate text-xs`,children:[`Position `,Math.round(e.x),`, `,Math.round(e.y),` ·`,` `,Math.round(e.width),` x `,Math.round(e.height)]})]})]}),(0,p.jsxs)(`div`,{className:`mt-3 flex items-center justify-between gap-3`,children:[(0,p.jsx)(`span`,{className:`exhibition-workbench-muted text-xs`,children:n?`Drag or resize in the workbench`:t?`Selected in workbench`:`Click to select on slide`}),(0,p.jsx)(v.Button,{className:`rounded-md border border-me-primary-200 bg-me-primary-50 px-3 py-1.5 text-xs font-semibold text-me-primary-600 transition hover:bg-me-primary-100`,onPress:n?a:i,children:n?`Done moving`:`Reposition`})]})]})}function Ai({thumbnailUrl:e,type:t}){return(0,p.jsx)(`div`,{className:`flex h-16 w-16 shrink-0 items-center justify-center overflow-hidden rounded-md bg-[#f8f6f3] text-xs font-semibold text-black/60 ring-1 ring-slate-200`,children:e?(0,p.jsx)(`img`,{alt:``,className:`h-full w-full object-cover`,src:e}):(0,p.jsx)(`span`,{children:t})})}function ji(e,t){return e.imageUrl?`Image`:e.youtubeId?`YouTube`:e.videoUrl?`Video`:e.html===null?t?.type===`Canvas`?`Canvas`:t?.type?String(t.type):`Media`:`Text`}function Mi(e,t,n){let r=(0,u.getInternationalStringText)(t?.label,``),i=(0,u.getInternationalStringText)(e.annotation.label,``),a=e.html?Fi(e.html).slice(0,80):``;return r||i||a||`${ji(e,t)} layer ${n+1}`}function Ni(e,t,n){let r=`${Math.round(e.box.x)}, ${Math.round(e.box.y)} · ${Math.round(e.box.width)} x ${Math.round(e.box.height)}`;return[t?.format||t?.profile||t?.type||`${n} painting annotation`,`Position ${r}`].filter(Boolean).join(` · `)}function Pi(e,t){return(0,u.resolveContentResource)(t,Array.isArray(e?.body)?e.body[0]:e?.body)}function Fi(e){return e.replace(/<br\s*\/?>/gi,` `).replace(/<\/p>/gi,` `).replace(/<[^>]+>/g,` `).replace(/\s+/g,` `).trim()}function Ii({children:e}){return(0,p.jsx)(`div`,{className:`exhibition-workbench-muted text-sm font-semibold`,children:e})}const Li=[{id:`layout`,label:`Layout`},{id:`summary`,label:`Summary`},{id:`tour`,label:`Tour steps`}],Ri=[{id:`layout`,label:`Layout`},{id:`content`,label:`Content`},{id:`summary`,label:`Summary`},{id:`tour`,label:`Tour steps`}],zi=[{value:`simple`,label:`Simple`},{value:`advanced`,label:`Advanced`}],Bi=`exhibition-right-panel-mode`,Vi={track:`#f5eaf0`,active:`#b84c74`,inactiveText:`#8b3f61`,activeText:`#ffffff`,activeShadow:`0 1px 3px rgba(15, 23, 42, 0.18)`},Hi={id:`@exhibition/workbench-editor`,supports:{edit:!0,properties:[`label`,`summary`,`behavior`,`annotations`],resourceTypes:[`Canvas`],custom:({resource:e},t)=>B(e,t)?Xe(e,t):!1},label:`Canvas`,component:()=>(0,p.jsx)(Wi,{})},Ui={...Hi,id:`@exhibition/slideshow-workbench-editor`,supports:{...Hi.supports,custom:({resource:e},t)=>B(e,t)},component:()=>(0,p.jsx)(Wi,{preset:`slideshow`})};function Wi({preset:e=`default`}){let[t,n]=(0,l.useLocalStorage)(`exhibition-right-panel-mode`,`simple`),r=(0,d.useCanvas)(),i=(0,d.useVault)(),a=!!r?.behavior?.includes(`info`),o=rt(i,r),s=(0,m.useMemo)(()=>(e===`slideshow`?Ri:Li).filter(e=>e.id!==`tour`||o),[e,o]),[c,u]=(0,m.useState)(`layout`),f=H(e=>e.requestedTab),g=H(e=>e.clearRequestedTab),_=H(e=>e.setShowTourSteps);(0,m.useEffect)(()=>{f&&s.some(e=>e.id===f)&&(u(f),_(f===`tour`),g())},[g,f,_,s]),(0,m.useEffect)(()=>{c===`tour`&&!o&&(u(`layout`),_(!1))},[c,_,o]);let v=e=>{u(e),_(e===`tour`)};return a?(0,p.jsx)(Ti,{}):(0,p.jsx)(h.Sidebar,{children:(0,p.jsxs)(h.SidebarContent,{className:`bg-white px-6 pt-5 pb-20`,children:[(0,p.jsx)(`div`,{className:`flex justify-center`,children:(0,p.jsx)(Gi,{value:t,options:zi,onChange:n})}),(0,p.jsx)(`div`,{className:[`mt-5 grid border-b border-[#e4ddd6]`,s.length===4?`grid-cols-4`:`grid-cols-3`].join(` `),children:s.map(e=>(0,p.jsx)(`button`,{type:`button`,className:[`exhibition-workbench-tab`,`-mb-px border-b-[3px] border-transparent px-1 pb-3 text-center text-sm font-semibold`,c===e.id?`border-me-primary-500 text-me-primary-500`:`exhibition-workbench-muted`].join(` `),onClick:()=>v(e.id),children:e.label},e.id))}),(0,p.jsxs)(`div`,{className:`mt-8 px-4`,children:[c===`layout`?(0,p.jsx)(yr,{mode:t,layoutContext:e===`slideshow`?`slideshow`:`default`}):null,c===`content`?(0,p.jsx)(Di,{}):null,c===`summary`?t===`simple`?(0,p.jsx)(Ki,{}):(0,p.jsx)(oi,{}):null,c===`tour`?(0,p.jsx)(xi,{mode:t,useSlideshowWorkbench:e===`slideshow`}):null]})]})})}function Gi({value:e,options:t,onChange:n}){return(0,p.jsx)(`div`,{className:`grid w-full max-w-[240px] grid-cols-2 rounded-full p-1`,style:{backgroundColor:Vi.track},children:t.map(t=>{let r=e===t.value;return(0,p.jsx)(v.Button,{className:`border-none rounded-full bg-transparent px-4 py-2 text-sm font-semibold transition-colors`,style:{backgroundColor:r?Vi.active:`transparent`,color:r?Vi.activeText:Vi.inactiveText,boxShadow:r?Vi.activeShadow:`none`},onPress:()=>n(t.value),children:t.label},t.value)})})}function Ki(){let e=(0,d.useCanvas)();return e?(0,p.jsx)(l.ResourceEditingProvider,{resource:e,children:(0,p.jsxs)(`div`,{className:`flex flex-col gap-7`,children:[(0,p.jsxs)(`div`,{children:[(0,p.jsx)(qi,{children:`Slide title`}),(0,p.jsx)(`div`,{className:`mt-2`,children:(0,p.jsx)(u.LanguageMapEditor,{dispatchType:`label`,disableMultiline:!0,disallowHTML:!0})})]}),(0,p.jsxs)(`div`,{children:[(0,p.jsx)(qi,{children:`Slide summary`}),(0,p.jsx)(`div`,{className:`mt-2`,children:(0,p.jsx)(u.LanguageMapEditor,{dispatchType:`summary`})})]})]})}):null}function qi({children:e}){return(0,p.jsx)(`div`,{className:`exhibition-workbench-muted text-sm font-semibold`,children:e})}const Ji=e=>(0,p.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,width:`1em`,height:`1em`,viewBox:`0 0 15 15`,...e,children:(0,p.jsx)(`path`,{fill:`currentColor`,d:`M4.5 1a2.5 2.5 0 0 0-2.45 2H0v1h2.05a2.5 2.5 0 0 0 4.9 0H15V3H6.95A2.5 2.5 0 0 0 4.5 1m6 8a2.5 2.5 0 0 0-2.45 2H0v1h8.05a2.5 2.5 0 0 0 4.9 0H15v-1h-2.05a2.5 2.5 0 0 0-2.45-2`})});var Yi=Ji;const Xi=(0,l.extendApp)((0,l.mapApp)(c),{id:`exhibition-scrolling-editor`,title:`Exhibition Editor (scrolling)`,project:!0,projectType:`Manifest`},{config:{editorConfig:{}},leftPanels:[],centerPanels:[],annotations:[],background:[],canvasEditors:[],editors:[wi,Hi,Zr,pr,ii,vi],creators:[Ln,Un,Dn,Tn,J,Fn,Bn]}),Zi={id:`slideshow-canvas-editor`,label:`Slideshow canvas editor`,component:()=>(0,p.jsx)(Qi,{}),supports:{strategy:(e,t,n)=>{let r=n.get(t.resource);return r?.type===`Canvas`&&Qe(r)}}};function Qi(){let e=(0,d.useCanvas)(),t=(0,d.useManifest)(),{edit:n}=(0,l.useLayoutActions)(),{rightPanel:r}=(0,l.useLayoutState)(),i=(0,d.useCurrentAnnotationRequest)(),a=(0,u.useAnnotationEditing)(e=>e.annotationId),[o,s]=(0,m.useState)(1),c=t?.items?.findIndex(t=>t.id===e?.id),f=typeof c==`number`?t?.items?.[c-1]:void 0,h=typeof c==`number`?t?.items?.[c+1]:void 0;return e?i||a||r.current===`@manifest-editor/editor`&&r.state?.currentTab?.startsWith(`@exhibition/tour-steps`)?(0,p.jsx)(u.CanvasPanelEditor,{asFallback:!0}):(0,p.jsxs)(`div`,{className:`exhibition-slideshow-current-canvas flex h-full min-h-0 flex-col bg-slate-100`,children:[(0,p.jsxs)(`div`,{className:`exhibition-slideshow-current-toolbar flex items-center gap-3 border-b border-slate-200 bg-white px-4 py-3 shadow-sm`,children:[(0,p.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,p.jsx)(d.LocaleString,{className:`block truncate text-sm font-semibold text-slate-800`,children:e.label})}),(0,p.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,p.jsx)($i,{onPress:()=>s(1),children:`Home`}),(0,p.jsx)($i,{onPress:()=>s(e=>Math.max(.25,e-.25)),children:`-`}),(0,p.jsx)($i,{onPress:()=>s(e=>Math.min(3,e+.25)),children:`+`}),(0,p.jsx)($i,{isDisabled:!f,onPress:()=>f&&n({id:f.id,type:`Canvas`},void 0,{forceOpen:!1}),children:`Previous`}),(0,p.jsx)($i,{isDisabled:!h,onPress:()=>h&&n({id:h.id,type:`Canvas`},void 0,{forceOpen:!1}),children:`Next`})]})]}),(0,p.jsx)(`div`,{className:`exhibition-slideshow-current-viewport min-h-0 flex-1 overflow-auto p-8`,children:(0,p.jsx)(`div`,{className:`exhibition-slideshow-current-preview mx-auto origin-top overflow-hidden rounded-md bg-white shadow-xl ring-1 ring-black/10`,style:{width:`min(100%, 1200px)`,aspectRatio:`${e.width||1920} / ${e.height||1080}`,transform:`scale(${o})`,transformOrigin:`top center`},children:(0,p.jsx)(d.CanvasContext,{canvas:e.id,children:(0,p.jsx)(xt,{})})})})]}):null}function $i({children:e,isDisabled:t,onPress:n}){return(0,p.jsx)(v.Button,{className:`exhibition-slideshow-current-control rounded-md border border-slate-200 bg-white px-3 py-2 text-sm font-semibold text-slate-700 shadow-sm transition hover:bg-slate-50 disabled:cursor-not-allowed disabled:opacity-40`,isDisabled:t,onPress:n,children:e})}const ea=e=>(0,p.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,width:`1em`,height:`1em`,viewBox:`0 0 48 48`,...e,children:(0,p.jsxs)(`g`,{fill:`none`,stroke:`#000`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:4,children:[(0,p.jsx)(`path`,{d:`m20 8 4-4m0 0 4 4m-4-4v12M20 40l4 4m0 0 4-4m-4 4V32M40 20l4 4m0 0-4 4m4-4H32M8 20l-4 4m0 0 4 4m-4-4h12`}),(0,p.jsx)(`circle`,{cx:24,cy:24,r:2})]})});var ta=ea;const na=e=>(0,p.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,width:`1em`,height:`1em`,viewBox:`0 0 24 24`,...e,children:(0,p.jsx)(`path`,{fill:`currentColor`,d:`M20 22H4q-.825 0-1.413-.588T2 20V8q0-.825.588-1.413T4 6h5.975v2H4v12h16v-3.975h2V20q0 .825-.588 1.413T20 22ZM4 20V8v8.025-.675V20Zm13-5.975-1.55-3.475L11.975 9l3.475-1.55L17 4l1.55 3.45L22 9l-3.45 1.55L17 14.025Z`})});var ra=na;const ia={skipEditingOnCreate:!0},aa=`<h2>New step</h2><p>Description</p>`,oa={id:`@exhibitions/slideshow-center-panel`,label:`Slideshow workbench`,icon:(0,p.jsx)(ra,{}),render:()=>(0,p.jsx)(sa,{})};function sa(){let{structural:e,technical:t}=(0,l.useManifestEditor)(),n=e.items.get(),r={id:t.id.get(),type:`Manifest`},i=(0,d.useVault)(),[,a]=(0,l.useCreator)(r,`items`,`Canvas`,void 0,{isPainting:!0}),o=(0,u.useInStack)(`Canvas`),{edit:s}=(0,l.useLayoutActions)(),c=V(e=>e.clear),f=o?.resource.source.id||n[0]?.id,g=f?n.findIndex(e=>e.id===f):-1,_=g>=0?g:0,v=g>=0?n[g]:n[0]||null;(0,m.useEffect)(()=>{for(let e of n)lt(i,i.get(e))},[n,i]);let y=()=>{a.createFiltered(`exhibition-slideshow-slide`,n.length?_+1:void 0)},b=(e,t,n=!1)=>{s({id:e.id,type:`Canvas`},{parent:r,property:`items`,index:t},{forceOpen:n})},x=(e,t)=>{c(),b(e,t)},S=t=>{if(!n[t]||!confirm(`Are you sure you want to delete this slide?`))return;let r=n[t+1]||n[t-1]||null,i=n[t+1]?t:t-1;c(),e.items.deleteAtIndex(t),r&&b(r,Math.max(0,i))},C=_>0?n[_-1]:void 0,w=_<n.length-1?n[_+1]:void 0;return n.length?(0,p.jsx)(ca,{children:(0,p.jsxs)(`div`,{className:`exhibition-slideshow-main flex min-h-full flex-col gap-6 pb-12 pt-16`,children:[(0,p.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3 px-8`,style:{paddingInlineStart:`calc(2rem + var(--manifest-editor-layout-left-sidebar-small, 0px))`,paddingInlineEnd:`calc(2rem + var(--manifest-editor-layout-right-sidebar-small, 0px))`},children:[(0,p.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,p.jsx)(`p`,{className:`text-sm font-semibold uppercase tracking-wider text-me-primary-500`,children:`Slideshow workbench`}),(0,p.jsx)(`h2`,{className:`exhibition-slideshow-heading truncate text-2xl font-bold text-slate-900`,children:v?(0,p.jsx)(d.CanvasContext,{canvas:v.id,children:(0,p.jsx)(la,{})}):`Slides`}),(0,p.jsxs)(`p`,{className:`exhibition-slideshow-muted mt-1 text-sm font-semibold text-slate-500`,children:[`Slide `,_+1,` of `,n.length]})]}),(0,p.jsx)(ua,{current:_+1,total:n.length,onPrevious:C?()=>x(C,_-1):void 0,onNext:w?()=>x(w,_+1):void 0}),(0,p.jsx)(`div`,{children:(0,p.jsx)(h.ActionButton,{primary:!0,onPress:y,children:`Add new slide`})})]}),(0,p.jsxs)(`div`,{className:`flex flex-1 flex-col gap-5 px-8`,style:{paddingInlineStart:`calc(1.5rem + var(--manifest-editor-layout-left-sidebar-small, 0px))`,paddingInlineEnd:`calc(1.5rem + var(--manifest-editor-layout-right-sidebar-small, 0px))`},children:[(0,p.jsx)(`div`,{className:`exhibition-slideshow-preview-frame flex items-center justify-center overflow-hidden rounded-lg bg-slate-100`,children:v?(0,p.jsx)(d.CanvasContext,{canvas:v.id,children:(0,p.jsx)(fa,{})}):null}),(0,p.jsxs)(`aside`,{className:`exhibition-slideshow-slide-strip overflow-hidden rounded-lg border border-slate-200 bg-white p-4`,children:[(0,p.jsx)(`div`,{className:`exhibition-slideshow-heading mb-3 text-sm font-semibold text-slate-700`,children:`Slides`}),(0,p.jsx)(`div`,{className:`flex gap-3 overflow-x-auto pb-2`,children:n.map((e,t)=>(0,p.jsx)(d.CanvasContext,{canvas:e.id,children:(0,p.jsx)(Oa,{index:t,selected:v?.id===e.id,onPress:()=>x(e,t),onDelete:()=>S(t)})},e.id))})]})]})]})}):(0,p.jsx)(ca,{children:(0,p.jsx)(`div`,{className:`flex min-h-full items-center justify-center px-24 py-12`,children:(0,p.jsxs)(`div`,{className:`w-full max-w-4xl`,children:[(0,p.jsx)(`p`,{className:`text-sm font-semibold uppercase tracking-wider text-me-primary-500`,children:`Slideshow exhibition`}),(0,p.jsx)(`h2`,{className:`mt-2 text-3xl font-bold text-slate-900`,children:`Create your first slideshow slide`}),(0,p.jsx)(`p`,{className:`mt-3 max-w-2xl text-sm text-slate-600`,children:`Add a new slide and choose one of the supported slideshow slide types. You can add images, text, media, and tour steps after the slide is created.`}),(0,p.jsx)(`div`,{className:`mt-8`,children:(0,p.jsx)(h.ActionButton,{primary:!0,large:!0,onPress:y,children:`Add new slide`})})]})})})}function ca({children:e}){return(0,p.jsx)(h.SidebarContent,{className:`exhibition-slideshow-workbench h-full overflow-x-hidden overflow-y-auto bg-[#f8f6f3]`,children:e})}function la(){return(0,p.jsx)(p.Fragment,{children:Ea((0,d.useCanvas)()?.label,`Untitled slide`)||`Untitled slide`})}function ua({current:e,total:t,onPrevious:n,onNext:r}){return(0,p.jsxs)(`div`,{className:`exhibition-slideshow-navigation flex items-stretch overflow-hidden rounded-lg border border-slate-200 bg-white text-sm text-slate-800 shadow-sm`,children:[(0,p.jsx)(v.Button,{className:`border-none bg-white px-5 py-3 font-semibold transition hover:bg-slate-50 disabled:cursor-not-allowed disabled:text-slate-300`,isDisabled:!n,onPress:n,children:`Previous`}),(0,p.jsxs)(`span`,{className:`exhibition-slideshow-navigation-current flex min-w-[96px] items-center justify-center border-x border-slate-200 bg-slate-50 px-4 font-bold text-slate-900`,children:[e,` of `,t]}),(0,p.jsx)(v.Button,{className:`border-none bg-white px-5 py-3 font-semibold transition hover:bg-slate-50 disabled:cursor-not-allowed disabled:text-slate-300`,isDisabled:!r,onPress:r,children:`Next`})]})}function da({current:e,total:t,onPrevious:n,onNext:r}){return(0,p.jsxs)(`div`,{className:`exhibition-slideshow-navigation flex items-stretch overflow-hidden rounded-md border border-slate-200 bg-white text-xs text-slate-800 shadow-sm`,children:[(0,p.jsx)(v.Button,{className:`border-none bg-white px-3 py-2 font-semibold transition hover:bg-slate-50 disabled:cursor-not-allowed disabled:text-slate-300`,isDisabled:!n,onPress:n,children:`Previous step`}),(0,p.jsx)(`span`,{className:`exhibition-slideshow-navigation-current flex min-w-[84px] items-center justify-center border-x border-slate-200 bg-slate-50 px-3 font-bold text-slate-900`,children:t?`${e} of ${t}`:`0 of 0`}),(0,p.jsx)(v.Button,{className:`border-none bg-white px-3 py-2 font-semibold transition hover:bg-slate-50 disabled:cursor-not-allowed disabled:text-slate-300`,isDisabled:!r,onPress:r,children:`Next step`})]})}function fa(){let e=(0,d.useCanvas)(),t=(0,d.useVault)(),n=(0,l.useInlineCreator)(),[r,i]=(0,m.useState)(`edit`),[a,o]=(0,m.useState)(null),[s,c]=(0,m.useState)(`box`),u=(0,m.useRef)(null),f=(0,m.useRef)(null),h=e?.annotations?.[0]?.id,g=e?.items?.[0]?{id:e.items[0].id,type:`AnnotationPage`}:void 0,[,_]=(0,l.useCreator)(g,`items`,`Annotation`,e?tt(e):void 0,{isPainting:!0}),{selectedAnnotationId:b,repositioningAnnotationId:x,selectedTextRegion:S,repositioningTextRegion:C,selectedTourStepId:w,selectAnnotation:T,startRepositioning:E,stopRepositioning:D,startTextRepositioning:O,stopTextRepositioning:k,selectTourStep:A,stopTourStepRepositioning:j}=V(),M=H(e=>e.requestTab),ee=H(e=>e.showTourSteps),N=H(e=>e.setShowTourSteps),P=(0,d.useVaultSelector)((t,n)=>e?U(n,e):[],[e?.id,g?.id]),te=P.find(e=>e.id===b),ne=S===`editorial-text`?ut(e).text:null,F=(0,d.useVaultSelector)((t,n)=>e?nt(n,e):[],[e?.id,h]),I=F.find(e=>e.id===w)||F[0],L=I?Math.max(0,F.findIndex(e=>e.id===I.id)):-1,re=rt(t,e),R=ee&&re,ie=e=>{let t=F[e];t?.id&&A(t.id)};(0,m.useEffect)(()=>{u.current=null,f.current=null,o(null),c(`box`)},[e?.id]),(0,m.useEffect)(()=>{!re&&ee&&(N(!1),j(),o(null))},[N,ee,j,re]),(0,m.useEffect)(()=>{R&&i(`edit`)},[R]),(0,m.useEffect)(()=>{if(u.current===null){u.current=P.length;return}let e=P[P.length-1];P.length>u.current&&e?.id&&(T(e.id),M(`content`),N(!1)),u.current=P.length},[P,M,T,N]),(0,m.useEffect)(()=>{if(f.current===null){f.current=F.length;return}let e=F[F.length-1];F.length>f.current&&e?.id&&(A(e.id),D(),k(),N(!0)),f.current=F.length},[A,N,D,k,F]);let ae=()=>{let e=!ee;N(e),e?(D(),k(),I?.id&&A(I.id)):j()},oe=()=>{e&&n.create(`@manifest-editor/empty-annotation-page`,{label:{en:[`Tour steps`]}},{target:{id:e.id,type:`Canvas`},targetType:`AnnotationPage`,parent:{property:`annotations`,resource:{id:e.id,type:`Canvas`}}})},se=()=>{!e||!h||(N(!0),D(),k(),c(`box`),o({type:`add`}))},ce=()=>{I?.id&&(N(!0),D(),k(),c(`box`),o({type:`edit`,annotationId:I.id}))};return(0,p.jsxs)(`div`,{className:`exhibition-slideshow-preview-card group relative flex max-h-full flex-col overflow-hidden rounded-md bg-white shadow-xl ring-1 ring-black/10`,style:{width:`100%`,height:`min(68vh, 760px)`,minHeight:420},children:[(0,p.jsxs)(`div`,{className:`exhibition-slideshow-toolbar flex flex-wrap items-center justify-between gap-3 border-b border-slate-200 bg-white px-4 py-3`,children:[(0,p.jsx)(`span`,{className:`exhibition-slideshow-muted text-xs font-semibold text-slate-500`,children:r===`edit`?`Click content to edit or reposition it`:`Slideshow layout preview (approximate)`}),(0,p.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[r===`edit`?(0,p.jsxs)(p.Fragment,{children:[re?(0,p.jsx)(v.Button,{className:(0,y.twMerge)(`rounded-md border px-3 py-2 text-xs font-semibold shadow-sm transition`,R?`border-me-primary-500 bg-me-primary-50 text-me-primary-600`:`border-slate-200 bg-white text-slate-700 hover:border-me-primary-300`),onPress:ae,children:R?`Hide tour steps`:`Show tour steps`}):null,R?(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(da,{current:L+1,total:F.length,onPrevious:L>0?()=>ie(L-1):void 0,onNext:L>=0&&L<F.length-1?()=>ie(L+1):void 0}),h?(0,p.jsx)(v.Button,{className:`rounded-md bg-me-primary-500 px-3 py-2 text-xs font-semibold text-white shadow-sm transition hover:bg-me-primary-600`,onPress:se,children:`Add tour step`}):(0,p.jsx)(v.Button,{className:`rounded-md bg-me-primary-500 px-3 py-2 text-xs font-semibold text-white shadow-sm transition hover:bg-me-primary-600`,onPress:oe,children:`Create tour`})]}):(0,p.jsx)(v.Button,{className:`rounded-md bg-me-primary-500 px-3 py-2 text-xs font-semibold text-white shadow-sm transition hover:bg-me-primary-600`,onPress:()=>{N(!1),j(),_.create(void 0,ia)},children:`Add content`})]}):null,(0,p.jsxs)(`div`,{className:`flex shrink-0 overflow-hidden rounded-md border border-slate-200 bg-slate-50 text-xs font-semibold`,children:[(0,p.jsx)(Da,{selected:r===`edit`,onPress:()=>i(`edit`),children:`Edit`}),(0,p.jsx)(Da,{selected:r===`preview`,onPress:()=>i(`preview`),children:`Preview`})]})]})]}),(0,p.jsxs)(`div`,{className:`relative min-h-0 flex-1 bg-black`,children:[(0,p.jsx)(xt,{editable:r===`edit`,mode:r,showTourSteps:R}),a&&e&&h?(0,p.jsx)(ba,{annotationPageId:h,canvas:e,mode:a,selectedTool:s,setSelectedTool:c,vault:t,onCancel:()=>o(null),onComplete:e=>{e&&A(e),N(!0),o(null)}}):null,!a&&r===`edit`&&!R&&te&&e?(0,p.jsx)(ga,{annotation:te,canvas:e,isRepositioning:x===te.id,onStartReposition:()=>E(te.id),onStopReposition:D,vault:t}):null,!a&&r===`edit`&&!R&&ne&&e?(0,p.jsx)(ga,{canvas:e,currentBox:ne,isRepositioning:C===S,label:`Editorial text`,onStartReposition:()=>O(`editorial-text`),onStopReposition:k,setBox:n=>ct(t,e,n),vault:t}):null,!a&&r===`edit`&&R&&e?I?(0,p.jsx)(ga,{annotation:I,canvas:e,isRepositioning:!1,label:`Selected tour step target`,onStopReposition:j,showBoxFields:!0,showRepositionButton:!1,vault:t,children:h?(0,p.jsx)(pa,{annotationPageId:h,canvas:e,onAddTourStep:se,onEditTarget:ce,selectedTourStepId:I?.id}):null}):(0,p.jsx)(ha,{label:`Tour steps`,children:h?(0,p.jsx)(pa,{annotationPageId:h,canvas:e,onAddTourStep:se,onEditTarget:ce,selectedTourStepId:I?.id}):(0,p.jsx)(ma,{onCreate:oe})}):null]})]})}function pa({annotationPageId:e,canvas:t,onAddTourStep:n,onEditTarget:r,selectedTourStepId:i}){return(0,p.jsx)(l.ResourceEditingProvider,{resource:t,children:(0,p.jsx)(d.AnnotationPageContext,{annotationPage:e,children:(0,p.jsxs)(`div`,{className:`space-y-3 text-slate-800`,children:[(0,p.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,p.jsx)(`h3`,{className:`text-sm font-semibold text-slate-800`,children:`Tour steps`}),(0,p.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[i?(0,p.jsx)($,{label:`Edit target`,onPress:r}):null,(0,p.jsx)($,{primary:!0,label:`Add step`,onPress:n})]})]}),(0,p.jsx)(`p`,{className:`text-xs text-slate-500`,children:`Select a step below. Use the quick box controls here, or edit the target with the Atlas drawing tools.`}),(0,p.jsx)(`div`,{className:`max-h-72 overflow-y-auto pr-1`,children:(0,p.jsx)(_i,{reorderable:!1,useSlideshowWorkbench:!0})})]})})})}function ma({onCreate:e}){return(0,p.jsxs)(`div`,{className:`space-y-3 text-slate-800`,children:[(0,p.jsx)(`p`,{className:`text-xs text-slate-600`,children:`This slide does not have a tour annotation page yet.`}),(0,p.jsx)($,{primary:!0,label:`Create tour`,onPress:e})]})}function ha({children:e,label:t}){return(0,p.jsxs)(`div`,{className:`absolute bottom-4 left-4 z-40 max-w-[min(34rem,calc(100%-2rem))] rounded-lg bg-white/95 p-3 text-xs shadow-lg ring-1 ring-black/10`,children:[(0,p.jsx)(`div`,{className:`mb-2 font-semibold text-slate-700`,children:t}),e]})}function ga({annotation:e,canvas:t,children:n,currentBox:r,isRepositioning:i,label:a=`Selected content`,onStartReposition:o,onStopReposition:s,setBox:c,vault:l,hidePositionControls:u=!1,showBoxFields:d=!1,showRepositionButton:f=!0}){let h=(0,m.useRef)(null),g=(0,m.useRef)(null),[_,v]=(0,m.useState)(null),b=Number(t?.width)||1920,x=Number(t?.height)||1080,S=r||ot(e,t),C=c||(n=>st(l,t,e.id,n)),w=Math.round(b/2),T=Math.round(x/2),E=e=>{let t=h.current,n=t?.offsetParent,r=t?.getBoundingClientRect(),i=n?.getBoundingClientRect();!t||!r||!i||(e.currentTarget.setPointerCapture(e.pointerId),g.current={pointerId:e.pointerId,startX:e.clientX,startY:e.clientY,panelX:r.left-i.left,panelY:r.top-i.top,maxX:Math.max(16,i.width-r.width-16),maxY:Math.max(16,i.height-r.height-16)})},D=e=>{let t=g.current;!t||t.pointerId!==e.pointerId||v({x:Math.min(t.maxX,Math.max(16,t.panelX+e.clientX-t.startX)),y:Math.min(t.maxY,Math.max(16,t.panelY+e.clientY-t.startY))})},O=e=>{g.current?.pointerId===e.pointerId&&(g.current=null,e.currentTarget.hasPointerCapture(e.pointerId)&&e.currentTarget.releasePointerCapture(e.pointerId))};return(0,p.jsx)(`div`,{ref:h,className:(0,y.twMerge)(`absolute z-40 w-[min(30rem,calc(100%-2rem))] rounded-lg bg-white/95 p-3 text-xs shadow-lg ring-1 ring-black/10`,_?null:`bottom-4 left-4`),style:_?{left:_.x,top:_.y}:void 0,children:(0,p.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,p.jsxs)(`div`,{className:`min-w-[280px]`,children:[(0,p.jsxs)(`div`,{className:`mb-2 flex items-center justify-between gap-3`,children:[(0,p.jsx)(`span`,{className:`font-semibold text-slate-700`,children:a}),(0,p.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,p.jsx)(`button`,{className:`cursor-move rounded border border-slate-200 bg-white px-2 py-1 text-[11px] font-semibold text-slate-600 transition hover:border-me-primary-300 hover:text-me-primary-600`,type:`button`,onPointerDown:E,onPointerMove:D,onPointerUp:O,onPointerCancel:O,children:(0,p.jsx)(ta,{})}),(0,p.jsxs)(`span`,{className:`text-slate-400`,children:[Math.round(S.width),` x `,Math.round(S.height)]})]})]}),u?null:(0,p.jsxs)(`div`,{className:`space-y-2`,children:[(0,p.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[f&&o?(0,p.jsx)($,{onPress:o,label:`Reposition`,primary:!0}):null,i&&s?(0,p.jsx)($,{onPress:s,label:`Stop moving`}):null,(0,p.jsx)($,{onPress:()=>C({x:0,y:0,width:b,height:x}),label:`Fill`}),(0,p.jsx)($,{onPress:()=>C({x:Math.round(b*.1),y:Math.round(x*.1),width:Math.round(b*.8),height:Math.round(x*.8)}),label:`Centre`}),(0,p.jsx)($,{onPress:()=>C({x:0,y:0,width:w,height:x}),label:`Left`}),(0,p.jsx)($,{onPress:()=>C({x:w,y:0,width:w,height:x}),label:`Right`}),(0,p.jsx)($,{onPress:()=>C({x:0,y:0,width:b,height:T}),label:`Top`}),(0,p.jsx)($,{onPress:()=>C({x:0,y:T,width:b,height:T}),label:`Bottom`})]}),d?(0,p.jsx)(_a,{box:S,onChange:C}):null]})]}),n?(0,p.jsx)(`div`,{className:`w-full border-t border-slate-200 pt-3`,children:n}):null]})})}function _a({box:e,onChange:t}){let n=(n,r)=>{let i=Number(r);Number.isFinite(i)&&t({...e,[n]:Math.round(i)})};return(0,p.jsxs)(`div`,{className:`grid grid-cols-4 gap-2 pt-1`,children:[(0,p.jsx)(va,{label:`X`,value:e.x,onChange:e=>n(`x`,e)}),(0,p.jsx)(va,{label:`Y`,value:e.y,onChange:e=>n(`y`,e)}),(0,p.jsx)(va,{label:`W`,value:e.width,onChange:e=>n(`width`,e)}),(0,p.jsx)(va,{label:`H`,value:e.height,onChange:e=>n(`height`,e)})]})}function va({label:e,value:t,onChange:n}){return(0,p.jsxs)(`label`,{className:`block text-[11px] font-semibold text-slate-500`,children:[e,(0,p.jsx)(`input`,{className:`mt-1 w-full rounded border border-slate-200 bg-white px-1.5 py-1 text-xs text-slate-900 outline-none focus:border-me-primary-400 focus:ring-1 focus:ring-me-primary-100`,type:`number`,value:Math.round(t),onChange:e=>n(e.target.value)})]})}function ya(e,t,n,r){let i=`${n}/tour-step/${Date.now()}-${Math.random().toString(36).slice(2,8)}`,a=`${i}/body/en`,o=e.get?.({id:n,type:`AnnotationPage`})||{},s=Array.isArray(o?.items)?o.items:[],c=()=>{e.dispatch((0,j.importEntities)({entities:{ContentResource:{[a]:{id:a,type:`TextualBody`,language:`en`,format:`text/html`,value:`<h2>New step</h2><p>Description</p>`}},Annotation:{[i]:{id:i,type:`Annotation`,motivation:`tagging`,label:{en:[`New step`]},body:[{id:a,type:`ContentResource`}],target:r}}}})),e.dispatch((0,j.addMappings)({mapping:{[a]:`ContentResource`,[i]:`Annotation`}})),e.modifyEntityField({id:n,type:`AnnotationPage`},`items`,[...s,{id:i,type:`Annotation`}])};return e.batch?e.batch(c):c(),i}function ba({annotationPageId:e,canvas:t,mode:n,selectedTool:r,setSelectedTool:i,vault:a,onCancel:o,onComplete:s}){let c=(0,m.useRef)(null),[l,u]=(0,m.useState)(null),[d,f]=(0,m.useState)(null),[h,g]=(0,m.useState)([]),_=Number(t?.width)||1920,v=Number(t?.height)||1080,y=e=>{let t=c.current;if(!t)return{x:0,y:0};let n=t.createSVGPoint();n.x=e.clientX,n.y=e.clientY;let r=t.getScreenCTM()?.inverse(),i=r?n.matrixTransform(r):n;return{x:Ta(Math.round(i.x),0,_),y:Ta(Math.round(i.y),0,v)}},b=e=>{if(e.preventDefault(),r===`polygon`){let t=y(e);g(e=>[...e,t]);return}u(y(e)),f(null)},x=e=>{if(!l||r===`polygon`)return;let t=y(e);r===`box`&&f({type:`box`,x:Math.min(l.x,t.x),y:Math.min(l.y,t.y),width:Math.abs(t.x-l.x),height:Math.abs(t.y-l.y)}),r===`circle`&&f({type:`circle`,cx:l.x,cy:l.y,r:Math.round(Math.sqrt((t.x-l.x)**2+(t.y-l.y)**2))}),r===`line`&&f({type:`line`,x1:l.x,y1:l.y,x2:t.x,y2:t.y})},S=()=>{u(null)},C=r===`polygon`&&h.length?{type:`polygon`,points:h}:d,w=()=>{u(null),f(null),g([])};return(0,p.jsxs)(`div`,{className:`absolute inset-0 z-30`,children:[(0,p.jsxs)(`svg`,{ref:c,className:`absolute inset-0 h-full w-full cursor-crosshair touch-none`,preserveAspectRatio:`xMidYMid meet`,viewBox:`0 0 ${_} ${v}`,onPointerDown:b,onPointerMove:x,onPointerUp:S,onPointerCancel:S,children:[(0,p.jsx)(`rect`,{x:0,y:0,width:_,height:v,fill:`transparent`}),C?(0,p.jsx)(Sa,{shape:C}):null,h.map((e,t)=>(0,p.jsx)(`circle`,{cx:e.x,cy:e.y,r:8,fill:`white`,stroke:`#be4778`,strokeWidth:4},`${e.x}-${e.y}-${t}`))]}),(0,p.jsxs)(`div`,{className:`absolute left-4 top-4 z-40 flex flex-wrap items-center gap-2 rounded-lg bg-white/95 p-2 text-xs shadow-lg ring-1 ring-black/10`,children:[(0,p.jsx)(`span`,{className:`mr-2 font-semibold text-slate-700`,children:n.type===`add`?`Draw new tour step`:`Edit target`}),(0,p.jsx)(xa,{active:r===`box`,label:`Box`,onPress:()=>{w(),i(`box`)}}),(0,p.jsx)(xa,{active:r===`circle`,label:`Circle`,onPress:()=>{w(),i(`circle`)}}),(0,p.jsx)(xa,{active:r===`line`,label:`Line`,onPress:()=>{w(),i(`line`)}}),(0,p.jsx)(xa,{active:r===`polygon`,label:`Polygon`,onPress:()=>{w(),i(`polygon`)}}),(0,p.jsx)($,{primary:!0,label:n.type===`add`?`Create step`:`Save target`,onPress:()=>{if(!C)return;let r=Ca(t.id,C);if(n.type===`edit`){a.modifyEntityField({id:n.annotationId,type:`Annotation`},`target`,r),s(n.annotationId);return}s(ya(a,t,e,r))}}),(0,p.jsx)($,{label:`Clear`,onPress:w}),(0,p.jsx)($,{label:`Cancel`,onPress:o})]})]})}function xa({active:e,label:t,onPress:n}){return(0,p.jsx)(v.Button,{className:(0,y.twMerge)(`rounded-md border px-2.5 py-1.5 font-semibold transition`,e?`border-me-primary-500 bg-me-primary-500 text-white`:`border-slate-200 bg-white text-slate-700 hover:border-me-primary-300 hover:bg-me-primary-50`),onPress:n,children:t})}function Sa({shape:e}){let t={fill:`rgba(190, 71, 120, 0.18)`,stroke:`#be4778`,strokeWidth:6,vectorEffect:`non-scaling-stroke`};return e.type===`box`?(0,p.jsx)(`rect`,{...t,x:e.x,y:e.y,width:e.width,height:e.height}):e.type===`circle`?(0,p.jsx)(`circle`,{...t,cx:e.cx,cy:e.cy,r:e.r}):e.type===`line`?(0,p.jsx)(`line`,{x1:e.x1,y1:e.y1,x2:e.x2,y2:e.y2,stroke:`#be4778`,strokeWidth:6,vectorEffect:`non-scaling-stroke`}):(0,p.jsx)(`polygon`,{...t,points:e.points.map(e=>`${e.x},${e.y}`).join(` `)})}function Ca(e,t){return t.type===`box`?`${e}#xywh=${Math.round(t.x)},${Math.round(t.y)},${Math.round(t.width)},${Math.round(t.height)}`:{source:e,selector:{type:`SvgSelector`,value:wa(t)}}}function wa(e){return e.type===`circle`?`<svg xmlns="http://www.w3.org/2000/svg"><circle cx="${Math.round(e.cx)}" cy="${Math.round(e.cy)}" r="${Math.round(e.r)}" /></svg>`:e.type===`line`?`<svg xmlns="http://www.w3.org/2000/svg"><line x1="${Math.round(e.x1)}" y1="${Math.round(e.y1)}" x2="${Math.round(e.x2)}" y2="${Math.round(e.y2)}" /></svg>`:`<svg xmlns="http://www.w3.org/2000/svg"><polygon points="${e.points.map(e=>`${Math.round(e.x)},${Math.round(e.y)}`).join(` `)}" /></svg>`}function Ta(e,t,n){return Math.min(n,Math.max(t,e))}function Ea(e,t=``){if(!e)return t;if(typeof e==`string`)return e;let n=e.en||e.none||Object.values(e).flat();return Array.isArray(n)&&n.length?String(n[0]):t}function $({label:e,onPress:t,primary:n}){return(0,p.jsx)(v.Button,{className:(0,y.twMerge)(`rounded-md border px-2.5 py-1.5 font-semibold transition`,n?`border-me-primary-500 bg-me-primary-500 text-white hover:bg-me-primary-600`:`border-slate-200 bg-white text-slate-700 hover:border-me-primary-300 hover:bg-me-primary-50`),onPress:t,children:e})}function Da({children:e,selected:t,onPress:n}){return(0,p.jsx)(v.Button,{className:(0,y.twMerge)(`border-none px-3 py-2 transition`,t?`bg-me-primary-500 text-white`:`bg-transparent text-slate-600 hover:bg-white`),onPress:n,children:e})}function Oa({index:e,selected:t,onPress:n,onDelete:r}){let i=(0,d.useCanvas)();return(0,p.jsxs)(`div`,{className:(0,y.twMerge)(`exhibition-slideshow-slide-card relative w-44 shrink-0 rounded-md border bg-white p-2 text-left transition`,t?`border-me-primary-500 ring-2 ring-me-primary-200`:`border-slate-200 hover:border-me-primary-300`),children:[(0,p.jsxs)(v.Button,{className:`block w-full border-none bg-transparent p-0 text-left`,onPress:n,children:[(0,p.jsx)(`div`,{className:`aspect-video overflow-hidden rounded`,style:{backgroundColor:`#0e0d12`},children:(0,p.jsx)(xt,{className:`pointer-events-none h-full w-full`,mode:`preview`})}),(0,p.jsxs)(`div`,{className:`mt-2 flex items-center gap-2 pr-7`,children:[(0,p.jsx)(`span`,{className:`flex h-6 w-6 shrink-0 items-center justify-center rounded bg-slate-100 text-xs font-semibold text-slate-600`,children:e+1}),(0,p.jsx)(d.LocaleString,{className:`min-w-0 truncate text-sm font-medium text-slate-800`,children:i?.label})]})]}),(0,p.jsx)(v.Button,{className:`absolute bottom-2 right-2 flex items-center gap-1 rounded border border-me-primary-100 bg-white px-2 py-1 text-xs font-semibold text-me-primary-500 shadow-sm transition hover:bg-me-primary-50`,"aria-label":`Delete slide ${e+1}`,onPress:r,children:`Delete`})]})}const ka=(0,l.extendApp)((0,l.mapApp)(c),{id:`exhibition-slideshow-editor`,title:`Exhibition Editor (slideshow)`,project:!0,projectType:`Manifest`},{config:{editorConfig:{Canvas:{singleTab:`@exhibition/slideshow-workbench-editor`,hideTabs:[`@manifest-editor/overview`,`@manifest-editor/technical-properties`,`@manifest-editor/linking-properties`,`@manifest-editor/nav-place-editor`,`@manifest-editor/canvas-structural`,`@manifest-editor/descriptive-properties`,`@manifest-editor/overview-canvas-editor`,`@manifest-editor/metadata`]}}},leftPanels:[Pt],centerPanels:[oa],annotations:[M],leftPanelIds:[`left-panel-manifest`],background:[en],canvasEditors:[Zi],editors:[Ui,wi,Zr,pr,ii,vi],creators:[Mn,Nn,Vn,Wn,Rn]}),Aa=(0,l.extendApp)((0,l.mapApp)(c),{id:`exhibition-editor`,title:`Exhibition Editor`,project:!0,projectType:`Manifest`},{config:{editorConfig:{Canvas:{hideTabs:[`@manifest-editor/overview`,`@manifest-editor/technical-properties`,`@manifest-editor/linking-properties`,`@manifest-editor/nav-place-editor`,`@manifest-editor/canvas-structural`,`@manifest-editor/descriptive-properties`,`@manifest-editor/overview-canvas-editor`,`@manifest-editor/metadata`]}}},leftPanels:[Nt,Ht],centerPanels:[ye,Ve],annotations:[M],leftPanelIds:[`left-panel-manifest`],background:[en],canvasEditors:[nn,Cn,sn],editors:[wi,Hi,Zr,pr,ii,vi],creators:[Ln,Un,Dn,Tn,J,Fn,Bn]});exports.PresetIcon=Yi,exports.exhibitionEditorPreset=Aa,exports.exhibitionEditorScrollingPreset=Xi,exports.exhibitionEditorSlideshowPreset=ka;
1
+ var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},s=(n,r,a)=>(a=n==null?{}:e(i(n)),o(r||!n||!n.__esModule?t(a,`default`,{value:n,enumerable:!0}):a,n));let c=require(`@manifest-editor/manifest-preset`);c=s(c);let l=require(`@manifest-editor/shell`),u=require(`@manifest-editor/editors`),d=require(`react-iiif-vault`),f=require(`zustand`),p=require(`react/jsx-runtime`),m=require(`react`);m=s(m);let h=require(`@manifest-editor/components`),g=require(`exhibition-viewer`),_=require(`exhibition-viewer/library`),v=require(`react-aria-components`),y=require(`tailwind-merge`),b=require(`@manifest-editor/manifest-preset/components`),x=require(`@dnd-kit/core`),S=require(`@dnd-kit/modifiers`),C=require(`@dnd-kit/sortable`),w=require(`@dnd-kit/utilities`),T=require(`tiny-invariant`);T=s(T);let E=require(`@manifest-editor/creator-api`),D=require(`@manifest-editor/creators`),O=require(`@iiif/parser`),k=require(`@iiif/helpers`),A=require(`@iiif/parser/image-3`),j=require(`@iiif/helpers/vault/actions`);const M={id:`@exhibition/tour-step-annotations`,label:`Tour steps`,render:()=>(0,p.jsx)(ee,{})},N={border:`2px solid rgba(255, 255, 255, 0.3)`,":hover":{borderColor:`#4B67E1`,backgroundColor:`rgba(255, 255, 255, 0.2)`}};function ee(){let e=(0,d.useCanvas)(),t=(0,f.useStore)((0,l.useAtlasStore)(),e=>e.tool.enabled),{rightPanel:n}=(0,l.useLayoutState)(),r=n.current===`@manifest-editor/editor`&&n.state?.currentTab?.startsWith(`@exhibition/tour-steps`),i=e?.annotations[0];return!r||!e||t||!i?null:(0,p.jsx)(p.Fragment,{children:(0,p.jsx)(d.AnnotationPageContext,{annotationPage:i.id,children:(0,p.jsx)(u.ViewerAnnotationPage,{showAnnotationNumber:!0,style:N})})})}const te=`https://exhibitionviewer.org/iiif/theme-service`,P={en:[`Exhibition viewer theme`]},F={fontSans:`"Tahoma", "Fira Sans", sans-serif`,fontMono:`"Fira Mono", monospace`,titleTransform:`uppercase`},I={backgroundPrimary:`#e5e7eb`,backgroundSecondary:`#fff`,backgroundOverlay:`rgba(0, 0, 0, 0.3)`,textPrimary:`#fff`,textSecondary:`#000`,imageCaption:`#fff`,annotationSelected:`#facc15`,controlBar:`#6d6e70`,controlBarBorder:`#5a5b5d`,controlHover:`rgba(0, 0, 0, 0.1)`,progressBar:`#fff`,closeBackground:`#000`,closeBackgroundHover:`#373737`,closeText:`#fff`,titleCard:`#facc15`,titleCardText:`#000`,infoBlock:`#000`,infoBlockText:`#fff`,viewerBackground:`#373737`},ne={...I,backgroundPrimary:`#fff`,backgroundSecondary:`#fff`,textPrimary:`#000`,textSecondary:`#000`,imageCaption:`#000`,annotationSelected:`#303f9f`,controlBar:`#f9f9f9`,controlBarBorder:`#000`,closeBackground:`#fff`,closeBackgroundHover:`#eee`,closeText:`#000`,progressBar:`#000000`,titleCard:`#fff`,titleCardText:`#000`,infoBlock:`#fff`,infoBlockText:`#000`,viewerBackground:`#e9e9e9`},L={titleBackground:`#fff`,titleColor:`#444`,annotationBackground:`#fff`,annotationColor:`#333`,annotationRadius:`0px`,annotationMaxWidth:`30em`,infoBlockBackground:`#fff`,infoBlockColor:`#444`},R={cutCorners:!0,fullTitleBar:!0,fullWidthGrid:!1,hideTableOfContents:!1,disablePresentation:!1,hideTitle:!1,hideTitleCard:!1,alternativeImageMode:!0,transitionScale:!1,imageInfoIcon:!1,coverImages:!1},z={cutCorners:!1,isFloating:!1,floatingPosition:`bottom-left`},re={alternativeImageMode:!0,transitionScale:!1,imageInfoIcon:!1,coverImages:!1},B={version:1,preset:`delft`,shared:F,delft:{tokens:I,exhibition:R,presentation:z,slideshow:re},scroll:{tokens:L,options:{showTableOfContents:!1,titleBlock:{fullHeight:!0}}}},ie={delft:B,minimal:{...B,preset:`minimal`,shared:{...F,titleTransform:`none`},delft:{...B.delft,tokens:ne}},gallery:{version:1,preset:`gallery`,shared:{fontSans:`"Gill Sans", "Trebuchet MS", sans-serif`,fontMono:`"Courier Prime", "Courier New", monospace`,titleTransform:`capitalize`},delft:{tokens:{...I,backgroundPrimary:`#f3ecdf`,backgroundSecondary:`#fff8ee`,backgroundOverlay:`rgba(20, 26, 32, 0.45)`,textPrimary:`#fff8ee`,textSecondary:`#2b2118`,imageCaption:`#f8efe1`,annotationSelected:`#f08c2e`,controlBar:`#1f3a5f`,controlBarBorder:`#162b47`,controlHover:`rgba(255, 255, 255, 0.14)`,progressBar:`#f4a261`,closeBackground:`#1f3a5f`,closeBackgroundHover:`#335c8a`,closeText:`#fff8ee`,titleCard:`#c7522a`,titleCardText:`#fff8ee`,infoBlock:`#22313f`,infoBlockText:`#f8efe1`,viewerBackground:`#30414d`},exhibition:{...R,cutCorners:!1,fullTitleBar:!0,fullWidthGrid:!0,alternativeImageMode:!1,transitionScale:!0,imageInfoIcon:!0,coverImages:!0},presentation:{...z,isFloating:!0,floatingPosition:`bottom-right`},slideshow:{...re,alternativeImageMode:!1,transitionScale:!0,imageInfoIcon:!0,coverImages:!0}},scroll:{tokens:{...L,titleBackground:`#f8efe1`,titleColor:`#2a2119`,annotationBackground:`#22313f`,annotationColor:`#f8efe1`,annotationRadius:`18px`,annotationMaxWidth:`34em`,infoBlockBackground:`#fff8ee`,infoBlockColor:`#2a2119`},options:{showTableOfContents:!0,titleBlock:{fullHeight:!1}}}}};function ae(e){return JSON.parse(JSON.stringify(e))}function oe(e){return!!e&&typeof e==`object`&&!Array.isArray(e)}function se(e,t){if(!t)return ae(e);let n=ae(e);for(let[e,r]of Object.entries(t)){if(r===void 0)continue;let t=n[e];if(oe(t)&&oe(r)){n[e]=se(t,r);continue}n[e]=r}return n}function ce(e){return typeof e==`string`&&e in ie}function le(e=`delft`){return ae(ie[e]||B)}function ue(e){let t=ce(e?.preset)?e.preset:`delft`,n=se(le(t),e||{});return n.version=1,n.preset=t,n}function de(e){return`${e}#exhibition-viewer-theme`}function fe(e,t){return{id:de(e),type:`Service`,profile:te,label:P,theme:ue(t)}}function pe(e){if(!e?.length)return null;let t=e.findIndex(e=>e?.profile===te||e?.theme);return t===-1?null:{index:t,service:e[t]}}function me(e){return pe(e)?.service?.theme}function he(e,t){let n=[...e||[]],r=pe(n);return r?t?(n[r.index]=t,n):(n.splice(r.index,1),n):(t&&n.push(t),n)}function ge(e){return{"--f-font":e.shared.fontSans,"--f-mono-font":e.shared.fontMono,"--delft-title-transform":e.shared.titleTransform,"--delft-bg-primary":e.delft.tokens.backgroundPrimary,"--delft-bg-secondary":e.delft.tokens.backgroundSecondary,"--delft-bg-overlay":e.delft.tokens.backgroundOverlay,"--delft-text-primary":e.delft.tokens.textPrimary,"--delft-text-secondary":e.delft.tokens.textSecondary,"--delft-image-caption":e.delft.tokens.imageCaption,"--delft-annotation-selected":e.delft.tokens.annotationSelected,"--delft-control-bar":e.delft.tokens.controlBar,"--delft-control-bar-border":e.delft.tokens.controlBarBorder,"--delft-control-hover":e.delft.tokens.controlHover,"--delft-progress-bar":e.delft.tokens.progressBar,"--delft-close-background":e.delft.tokens.closeBackground,"--delft-close-background-hover":e.delft.tokens.closeBackgroundHover,"--delft-close-text":e.delft.tokens.closeText,"--delft-title-card":e.delft.tokens.titleCard,"--delft-title-card-text":e.delft.tokens.titleCardText,"--delft-info-block":e.delft.tokens.infoBlock,"--delft-info-block-text":e.delft.tokens.infoBlockText,"--delft-viewer-background":e.delft.tokens.viewerBackground,"--exv-scroll-title-background":e.scroll.tokens.titleBackground,"--exv-scroll-title-color":e.scroll.tokens.titleColor,"--exv-scroll-annotation-background":e.scroll.tokens.annotationBackground,"--exv-scroll-annotation-color":e.scroll.tokens.annotationColor,"--exv-scroll-annotation-radius":e.scroll.tokens.annotationRadius,"--exv-scroll-annotation-max-width":e.scroll.tokens.annotationMaxWidth,"--exv-scroll-info-block-background":e.scroll.tokens.infoBlockBackground,"--exv-scroll-info-block-color":e.scroll.tokens.infoBlockColor}}const _e={id:`@exhibitions/center-panel`,label:`Exhibition editor`,icon:null,render:()=>(0,p.jsx)(ve,{}),options:{minWidth:350,maxWidth:350}};function ve(){let e=(0,d.useManifest)(),t=(0,d.useVault)(),[n,r]=(0,m.useState)(.8),i=(0,m.useRef)(null),{edit:a,leftPanel:o}=(0,l.useLayoutActions)(),s=(0,m.useMemo)(()=>e?ue(me(e.service||e.services)):null,[e]),c=(0,m.useMemo)(()=>({localeStringEditor:e=>(0,p.jsxs)(`span`,{className:`inline-flex items-center hover:ring-4 hover:ring-me-primary-500`,children:[e.original,(0,p.jsx)(v.Button,{className:`py-1 px-2 inline-block`,onPress:()=>a(e.resource),children:(0,p.jsx)(h.EditTextIcon,{className:`text-xl`})})]}),canvasPreviewEditor:e=>(0,p.jsxs)(`div`,{className:`w-full h-full flex-1 flex relative`,children:[e.original,(0,p.jsx)(`button`,{onClick:t=>{t.preventDefault(),t.stopPropagation(),a(e.resource),o.open({id:`canvas-listing`})},className:`absolute top-5 right-5 bg-white text-black p-2 rounded z-40`,children:`EDIT`})]})}),[]);return(0,m.useEffect)(()=>{for(let n of e?.items||[]){let e=t.get(n);e&&!Array.isArray(e.items)&&t.modifyEntityField(e,`items`,[]);for(let n of[...e?.items||[],...e?.annotations||[]]){let e=t.get(n);e&&!Array.isArray(e.items)&&t.modifyEntityField(e,`items`,[])}}},[e,t]),(0,m.useLayoutEffect)(()=>{if(i.current){let e=i.current.offsetWidth/1200;r(Math.max(1,e))}},[]),e?(0,p.jsx)(`div`,{ref:i,className:`overflow-y-auto delft-exhibition exhibition-viewer`,style:s?ge(s):void 0,children:(0,p.jsx)(_.EditorHooksProvider,{hooks:c,children:(0,p.jsx)(g.DelftExhibition,{skipLoadManifest:!0,customVault:t,manifest:e.id,options:{...s?.delft.exhibition||{},disablePresentation:!0,hideTableOfContents:!0,hideTitle:!0}},n)})}):null}function ye(e,t){let n=new URLSearchParams;switch(xe(n,`manifest`,t.manifest),xe(n,`canvas`,t.canvas),e){case`delft`:case`exhibition`:{let e=t;V(n,`cut-corners`,e.cutCorners),V(n,`full-title-bar`,e.fullTitleBar);break}case`minimal`:{let e=t;n.set(`minimal`,`true`),V(n,`cut-corners`,e.cutCorners),V(n,`full-title-bar`,e.fullTitleBar);break}case`presentation`:{let e=t;n.set(`type`,`presentation`),V(n,`cut-corners`,e.cutCorners),V(n,`floating`,e.floating??e.isFloating),xe(n,`floating-position`,e.floatingPosition);break}case`scroll`:{let e=t;n.set(`type`,`scroll`),Se(n,`minimal`,e.minimal),Se(n,`manifest-editor-preview`,e.manifestEditorPreview),xe(n,`manifest-editor-preview-origin`,e.manifestEditorPreviewOrigin);break}case`slideshow`:{let e=t;n.set(`type`,`slideshow`),Se(n,`minimal`,e.minimal),V(n,`floating`,e.floating),xe(n,`floating-position`,e.floatingPosition);break}}return n}function be(e,t){let n=ye(e,t||{}),r=window.localStorage.getItem(`exhibition-viewer-preview-url`)||process.env.NEXT_PUBLIC_EXHIBITION_VIEWER_URL||(window.location.hostname===`localhost`||window.location.hostname===`127.0.0.1`?`http://localhost:5174/preview/${e}?${n?.toString()}`:`https://preview.exhibitionviewer.org/preview/${e}?${n?.toString()}`),i=new URL(r);return i.searchParams.set(`manifest-editor-preview`,`true`),i.searchParams.set(`manifest-editor-preview-origin`,window.location.origin),i}function xe(e,t,n){n&&e.set(t,n)}function V(e,t,n){typeof n==`boolean`&&e.set(t,String(n))}function Se(e,t,n){n&&e.set(t,`true`)}const Ce=`manifest-editor:iframe-preview:connect`,we=`manifest-editor:iframe-preview:ready`,Te=`manifest-editor:iframe-preview:selection`,Ee=1024,De=440,Oe=.5;function ke({preset:e,presetOptions:t,focusSelectedCanvas:n=!0}){let r=(0,d.useVault)(),i=(0,l.useAppResource)(),a=(0,d.useManifest)(),o=(0,u.useInStack)(`Canvas`),s=(0,m.useRef)(null),c=(0,m.useRef)(null),f=(0,m.useRef)(null),h=(0,m.useRef)(i),g=(0,m.useRef)(null),[_,v]=(0,m.useState)(`waiting`),[b,x]=(0,m.useState)(0),[S,C]=(0,m.useState)(!1),[w,T]=(0,m.useState)(!1),E=n&&(o?.resource.source.id||a?.items?.[0]?.id)||null,D=(0,m.useMemo)(()=>be(e,t).toString(),[e,t]),O=(0,m.useMemo)(()=>new URL(D).origin,[D]),k=S?Oe:1,A=w?440:b?Math.round(b/k):0,j=A>0&&A<=Ee;h.current=i,g.current=E;let M=(0,m.useCallback)(()=>{let e=s.current;if(!e?.contentWindow)return;f.current?.(),v(`waiting`);let t=new MessageChannel;f.current=(0,l.createIframeVaultBridge)(r,t.port1);try{e.contentWindow.postMessage({_type:`manifest-editor:iframe-preview:connect`,resource:h.current,canvasId:g.current},O,[t.port2]),v(`connected`)}catch{f.current?.(),f.current=null,v(`error`)}},[O,r]);(0,m.useEffect)(()=>{function e(e){e.origin===O&&e.source===s.current?.contentWindow&&e.data?._type===`manifest-editor:iframe-preview:ready`&&M()}return window.addEventListener(`message`,e),()=>{window.removeEventListener(`message`,e),f.current?.(),f.current=null}},[M,O]),(0,m.useEffect)(()=>{let e=s.current?.contentWindow;!e||_!==`connected`||e.postMessage({_type:`manifest-editor:iframe-preview:selection`,resource:i,canvasId:E},O)},[_,i.id,i.type,E,O]),(0,m.useEffect)(()=>{let e=c.current;if(!e)return;let t=()=>{x(e.getBoundingClientRect().width)};t();let n=new ResizeObserver(t);return n.observe(e),()=>n.disconnect()},[]),(0,m.useEffect)(()=>{if(b){if(b>Ee){C(!1);return}T(!1)}},[b]);let N=(0,m.useCallback)(e=>{C(e),e&&T(!1)},[]),ee=(0,m.useCallback)(e=>{T(e),e&&C(!1)},[]);return(0,p.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col bg-zinc-950`,children:[_===`connected`?null:(0,p.jsx)(`div`,{className:`border-b border-zinc-800 bg-zinc-900 px-3 py-2 text-sm text-zinc-300`,children:_===`error`?`Preview connection failed.`:`Connecting to local exhibition viewer...`}),(0,p.jsx)(Ae,{iframeViewportWidth:A,isMobileViewport:j,showScaleOption:b>0&&b<=Ee,showMobileWidthOption:b>Ee,useScaledPreview:S,useMobileWidthPreview:w,onUseScaledPreviewChange:N,onUseMobileWidthPreviewChange:ee}),(0,p.jsx)(`div`,{ref:c,className:(0,y.twMerge)(`flex min-h-0 flex-1 overflow-hidden bg-white`,S?`justify-start`:`justify-center`),children:(0,p.jsx)(`iframe`,{ref:s,src:D,title:`Exhibition preview`,className:(0,y.twMerge)(`block h-full shrink-0 border-0 bg-white`,w?`shadow-2xl shadow-black/40`:``),style:{width:w?440:S?`${100/Oe}%`:`100%`,maxWidth:w?`100%`:void 0,height:S?`${100/Oe}%`:`100%`,transform:S?`scale(${Oe})`:void 0,transformOrigin:`top left`},onLoad:()=>v(`waiting`)})})]})}function Ae({iframeViewportWidth:e,isMobileViewport:t,showScaleOption:n,showMobileWidthOption:r,useScaledPreview:i,useMobileWidthPreview:a,onUseScaledPreviewChange:o,onUseMobileWidthPreviewChange:s}){return e?(0,p.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3 border-b border-zinc-800/80 bg-zinc-900 px-3 py-2 text-xs text-zinc-200`,children:[(0,p.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,p.jsx)(`span`,{className:(0,y.twMerge)(`shrink-0 rounded-full px-2 py-1 font-semibold ring-1 ring-inset`,t?`bg-amber-300/90 text-amber-950 ring-amber-200/50`:`bg-emerald-300/90 text-emerald-950 ring-emerald-200/50`),children:t?`Mobile view`:`Desktop view`}),(0,p.jsxs)(`span`,{className:`truncate text-zinc-400`,children:[`Iframe viewport: `,e,`px. Mobile starts at`,` `,Ee,`px and below.`]})]}),n?(0,p.jsx)(je,{label:`50% scale`,checked:i,onChange:o}):null,r?(0,p.jsx)(je,{label:`Mobile width`,checked:a,onChange:s}):null]}):null}function je({label:e,checked:t,onChange:n}){return(0,p.jsxs)(`label`,{className:`flex shrink-0 cursor-pointer items-center gap-2 rounded-md border border-zinc-800 bg-zinc-950/70 px-2.5 py-1.5 font-semibold text-zinc-200 shadow-sm shadow-black/20 transition-colors hover:border-zinc-700 hover:bg-zinc-950`,children:[(0,p.jsx)(`span`,{children:e}),(0,p.jsx)(`input`,{type:`checkbox`,className:`peer sr-only`,checked:t,onChange:e=>n(e.currentTarget.checked)}),(0,p.jsx)(`span`,{className:`relative h-5 w-9 rounded-full bg-zinc-700/80 transition-colors after:absolute after:left-0.5 after:top-0.5 after:h-4 after:w-4 after:rounded-full after:bg-zinc-100 after:shadow after:shadow-black/20 after:transition-transform peer-checked:bg-me-primary-500 peer-checked:after:translate-x-4`})]})}const Me=`@exhibitions/remote-preview-panel`,Ne=`exhibition`,Pe=`exhibition-preview-preset`,Fe=[{value:`exhibition`,label:`Full page`},{value:`scroll`,label:`Scroll`},{value:`slideshow`,label:`Slideshow`}];function Ie(){let[e,t]=(0,l.useLocalStorage)(`exhibition-preview-preset`,Ne),{centerPanel:n}=(0,l.useLayoutState)(),{centerPanel:r}=(0,l.useLayoutActions)();return[e||Ne,(0,m.useCallback)(e=>{t(e),n.current===Me&&r.open({id:Me,state:{preset:e}})},[n.current,r,t])]}function Le(e){return(0,p.jsxs)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,width:`1em`,height:`1em`,viewBox:`0 0 24 24`,fill:`currentColor`,...e,children:[(0,p.jsx)(`title`,{children:`Preview`}),(0,p.jsx)(`path`,{d:`M12 5c5 0 9.27 3.11 11 7-1.73 3.89-6 7-11 7s-9.27-3.11-11-7c1.73-3.89 6-7 11-7Zm0 2c-3.72 0-7.04 2.01-8.74 5C4.96 14.99 8.28 17 12 17s7.04-2.01 8.74-5C19.04 9.01 15.72 7 12 7Zm0 2.5A2.5 2.5 0 1 1 12 14a2.5 2.5 0 0 1 0-5Z`})]})}const Re=Ne,ze={id:Me,label:`Exhibition preview`,icon:(0,p.jsx)(Le,{}),defaultState:{},render:e=>(0,p.jsx)(Be,{state:e}),options:{minWidth:350}};function Be({state:e}){let[t]=Ie();return(0,p.jsx)(ke,{preset:e.preset||t||Re,focusSelectedCanvas:!1})}function Ve({children:e}){let t=(0,d.useManifest)(),{edit:n}=(0,l.useLayoutActions)();return(0,p.jsxs)(`div`,{className:`grid auto-rows-auto grid-cols-12 content-center justify-center gap-2 p-2`,children:[(0,p.jsx)(`div`,{className:`col-span-12 row-span-2 text-black flex flex-col items-center justify-center`,children:(0,p.jsx)(v.Button,{onPress:()=>t&&n(t),className:`col-span-4 row-span-4 text-md text-left text-black hover:bg-slate-100 w-full flex items-center justify-center`,children:(0,p.jsx)(d.LocaleString,{className:`block w-full text-left`,children:t?.label})})}),e]})}const He={"h-1":`lg:min-h-[100px] row-span-1`,"h-2":`lg:min-h-[200px] row-span-2`,"h-3":`lg:min-h-[300px] row-span-3`,"h-4":`lg:min-h-[400px] row-span-4`,"h-5":`lg:min-h-[500px] row-span-5`,"h-6":`lg:min-h-[600px] row-span-6`,"h-7":`lg:min-h-[700px] row-span-7`,"h-8":`lg:min-h-[800px] row-span-8`,"h-9":`lg:min-h-[900px] row-span-9`,"h-10":`lg:min-h-[1000px] row-span-10`,"h-11":`lg:min-h-[1100px] row-span-11`,"h-12":`lg:min-h-[1200px] row-span-12`},Ue={"h-1":`lg:min-h-[25px] row-span-1`,"h-2":`lg:min-h-[50px] row-span-2`,"h-3":`lg:min-h-[75px] row-span-3`,"h-4":`lg:min-h-[100px] row-span-4`,"h-5":`lg:min-h-[125px] row-span-5`,"h-6":`lg:min-h-[150px] row-span-6`,"h-7":`lg:min-h-[175px] row-span-7`,"h-8":`lg:min-h-[200px] row-span-8`,"h-9":`lg:min-h-[225px] row-span-9`,"h-10":`lg:min-h-[250px] row-span-10`,"h-11":`lg:min-h-[275px] row-span-11`,"h-12":`lg:min-h-[300px] row-span-12`},We={"w-1":`col-span-1`,"w-2":`col-span-2`,"w-3":`col-span-3`,"w-4":`col-span-4`,"w-5":`col-span-5`,"w-6":`col-span-6`,"w-7":`col-span-7`,"w-8":`col-span-8`,"w-9":`col-span-9`,"w-10":`col-span-10`,"w-11":`col-span-11`,"w-12":`col-span-12`};function Ge(e){let{isLeft:t,isRight:n,isBottom:r}=qe(e),i=e?.find(e=>e.includes(`h-`)),a=e?.find(e=>e.includes(`w-`));if(!i||!a)return{h:0,w:0,ratio:1};let o={h:Number.parseInt(i.split(`-`)[1]),w:Number.parseInt(a.split(`-`)[1]),ratio:1};return(t||n)&&(o.w*=2/3),r&&(o.h*=2/3),o.h&&o.w&&(o.ratio=o.w/o.h),o}function Ke(e,t=!1,n=!0){(!e||e.length===0)&&(e=[`h-8`,`w-8`,`image`]);let r=e.find(e=>e.includes(`h-`)),i=e.find(e=>e.includes(`w-`)),a=[];return t&&r===`h-4`&&(r=`h-8`),a.push(n?Ue[r]:He[r]),a.push(We[i]),a.join(` `)}function qe(e){let t=e?.includes(`right`),n=e?.includes(`left`),r=e?.includes(`bottom`),i=e?.includes(`top`),a=e?.includes(`image`)||!n&&!t&&!r&&!i;return{isRight:t,isLeft:n,isBottom:r,isTop:i,isInfo:e?.includes(`info`),isImage:a}}function H(e,t){return t.get(e)?.type===`Canvas`}function Je(e,t){let n=e.source?.id,r=e.source?.type;if(!n||!r)return!1;try{return(t.get({id:n,type:r})?.behavior||[]).includes(`info`)}catch{return!1}}function Ye(e,t){let n=e.source?.id,r=e.source?.type;if(!n||!r)return!1;try{let e=t.get({id:n,type:r}),i=Array.isArray(e?.items)?e.items:[];for(let e of i){let n=t.get(e,{skipSelfReturn:!1}),r=Array.isArray(n?.items)?n.items:[];for(let e of r){let n=t.get(e,{skipSelfReturn:!1}),r=Array.isArray(n?.body)?n.body[0]:n?.body,i=r?.id&&t.get(r,{skipSelfReturn:!1})||r,a=i?.type===`SpecificResource`?i.source:i,o=Array.isArray(a?.service)?a.service:a?.service?[a.service]:[];if(a?.type===`Video`||o.some(e=>e?.profile===`https://www.youtube.com`))return!0}}}catch{return!1}return!1}function Xe(e){if(!e)return!1;let t=e.behavior||[];if(t.includes(`image`)||t.includes(`info`))return!0;for(let e of t)if(e.startsWith(`w-`)||e.startsWith(`h-`))return!0;return!1}const U=(0,f.create)(e=>({selectedAnnotationId:null,repositioningAnnotationId:null,selectedTextRegion:null,repositioningTextRegion:null,selectedTourStepId:null,repositioningTourStepId:null,selectAnnotation:t=>e({selectedAnnotationId:t,repositioningAnnotationId:null,selectedTextRegion:null,repositioningTextRegion:null}),startRepositioning:t=>e({selectedAnnotationId:t,repositioningAnnotationId:t,selectedTextRegion:null,repositioningTextRegion:null}),stopRepositioning:()=>e({repositioningAnnotationId:null}),selectTextRegion:t=>e({selectedAnnotationId:null,repositioningAnnotationId:null,selectedTextRegion:t,repositioningTextRegion:null}),startTextRepositioning:t=>e({selectedAnnotationId:null,repositioningAnnotationId:null,selectedTextRegion:t,repositioningTextRegion:t}),stopTextRepositioning:()=>e({repositioningTextRegion:null}),selectTourStep:t=>e({selectedTourStepId:t,repositioningTourStepId:null}),startTourStepRepositioning:t=>e({selectedTourStepId:t,repositioningTourStepId:t}),stopTourStepRepositioning:()=>e({repositioningTourStepId:null}),clear:()=>e({selectedAnnotationId:null,repositioningAnnotationId:null,selectedTextRegion:null,repositioningTextRegion:null,selectedTourStepId:null,repositioningTourStepId:null})})),W=(0,f.create)(e=>({requestedTab:null,showTourSteps:!1,centerPanelMode:`preview`,requestTab:t=>e({requestedTab:t}),clearRequestedTab:()=>e({requestedTab:null}),setShowTourSteps:t=>e({showTourSteps:t}),setCenterPanelMode:t=>e({centerPanelMode:t})}));function Ze(e){let t=Number(e?.width)||1920,n=Number(e?.height)||1080,r=ct(e);return r.content?r.content:{x:Math.round(t*.1),y:Math.round(n*.1),width:Math.round(t*.8),height:Math.round(n*.8)}}function Qe(e,t){return{type:`SpecificResource`,source:{id:e.id,type:`Canvas`},selector:{type:`FragmentSelector`,value:`xywh=${Math.round(t.x)},${Math.round(t.y)},${Math.round(t.width)},${Math.round(t.height)}`}}}function $e(e){return Qe(e,Ze(e))}function G(e,t){return nt(e,t?.items||[]).filter(e=>(Array.isArray(e?.motivation)?e.motivation:[e?.motivation]).includes(`painting`))}function et(e,t){return nt(e,t?.annotations||[])}function tt(e,t){return!t||(Array.isArray(t?.behavior)?t.behavior:[]).includes(`info`)?!1:!G(e,t).some(t=>{let n=ut(e,t);return!!(gt(n)||_t(n))})}function nt(e,t){let n=[];for(let r of t){let t=e.get(r,{skipSelfReturn:!1});for(let r of t?.items||[]){let t=e.get(r,{skipSelfReturn:!1});t&&n.push(t)}}return n}function rt(e,t){return G(e,t).map(n=>{let r=ut(e,n);return{annotation:n,box:it(n,t),html:mt(r),imageUrl:pt(e,r),videoUrl:gt(r),youtubeId:_t(r)}})}function it(e,t){let n=Number(t?.width)||1920,r=Number(t?.height)||1080,i=e?.target;if(typeof i==`string`&&i.includes(`#xywh=`)){let e=dt(i.split(`#xywh=`)[1]);if(e)return e}let a=i?.selector,o=Array.isArray(a)?a.find(e=>e?.spatial||e?.points):a;if(o?.spatial)return o.spatial;if(Array.isArray(o?.points)){let e=o.points.filter(e=>Array.isArray(e)&&Number.isFinite(e[0])&&Number.isFinite(e[1]));if(e.length){let t=e.map(e=>e[0]),n=e.map(e=>e[1]),r=Math.min(...t),i=Math.min(...n);return{x:r,y:i,width:Math.max(1,Math.max(...t)-r),height:Math.max(1,Math.max(...n)-i)}}}let s=Array.isArray(a)?a.find(e=>e?.value?.startsWith?.(`xywh=`))?.value:a?.value;if(typeof s==`string`&&s.includes(`xywh=`)){let e=dt(s.split(`xywh=`)[1]);if(e)return e}return{x:0,y:0,width:n,height:r}}function at(e,t,n,r){e.modifyEntityField({id:n,type:`Annotation`},`target`,Qe(t,lt(t,r)))}function ot(e,t,n){let r=lt(t,n),i=Array.isArray(t?.behavior)?t.behavior:[];e.modifyEntityField(t,`behavior`,i.filter(e=>!e.startsWith(`text-xywh=`)).concat(`text-xywh=${Math.round(r.x)},${Math.round(r.y)},${Math.round(r.width)},${Math.round(r.height)}`))}function st(e,t){if(t)for(let n of G(e,t)){let r=n?.target;(r?.type===`SpecificResource`&&r?.source?.type===`Canvas`&&!r.selector||r?.type===`Canvas`||r===t.id)&&at(e,t,n.id,ct(t).content||Ze(t))}}function ct(e){let t=Number(e?.width)||1920,n=Number(e?.height)||1080,r=Array.isArray(e?.behavior)?e.behavior:[],i=ft(r);return r.includes(`right`)?{content:{x:0,y:0,width:Math.round(t*2/3),height:n},text:i||{x:Math.round(t*2/3),y:0,width:Math.round(t/3),height:n}}:r.includes(`left`)?{content:{x:Math.round(t/3),y:0,width:Math.round(t*2/3),height:n},text:i||{x:0,y:0,width:Math.round(t/3),height:n}}:r.includes(`bottom`)?{content:{x:0,y:0,width:t,height:Math.round(n*2/3)},text:i||{x:0,y:Math.round(n*2/3),width:t,height:Math.round(n/3)}}:r.includes(`top`)?{content:{x:0,y:Math.round(n/3),width:t,height:Math.round(n*2/3)},text:i||{x:0,y:0,width:t,height:Math.round(n/3)}}:r.includes(`info`)?{content:null,text:i||{x:0,y:0,width:t,height:n}}:r.includes(`image`)?{content:{x:0,y:0,width:t,height:n},text:i}:{content:null,text:i}}function lt(e,t){let n=Number(e?.width)||1920,r=Number(e?.height)||1080,i=Math.max(1,Math.min(t.width,n)),a=Math.max(1,Math.min(t.height,r)),o=Math.max(0,Math.min(t.x,n-i)),s=Math.max(0,Math.min(t.y,r-a));return{x:Math.round(o),y:Math.round(s),width:Math.round(i),height:Math.round(a)}}function ut(e,t){let n=Array.isArray(t?.body)?t.body[0]:t?.body,r=n?e.get(n,{skipSelfReturn:!1}):null;return r?.type===`SpecificResource`?r.source:r||n||null}function dt(e){let t=e?e.split(/[,&]/).slice(0,4).map(Number):[];if(t.length===4&&t.every(e=>Number.isFinite(e))){let[e,n,r,i]=t;return{x:e,y:n,width:r,height:i}}return null}function ft(e){let t=e.find(e=>e.startsWith(`text-xywh=`))?.replace(`text-xywh=`,``);return dt(t)}function pt(e,t){let n=ht(e,t);if(n?.type===`Choice`){let t=Array.isArray(n.items)?n.items:[];for(let n of t){let t=pt(e,n);if(t)return t}}if(n?.type===`Canvas`){let t=e.get({id:n.id,type:`Canvas`},{skipSelfReturn:!1})||n,r=Array.isArray(t.thumbnail)?t.thumbnail[0]:t.thumbnail;if(r?.id)return r.id;for(let n of G(e,t)){let t=pt(e,ut(e,n));if(t)return t}}let r=Array.isArray(n?.service)?n.service[0]:n?.service,i=r?.id||r?.[`@id`];return i?`${i.replace(/\/$/,``)}/full/1000,/0/default.jpg`:n?.type===`Image`&&n.id?n.id:null}function mt(e){let t=e?.type===`SpecificResource`?e.source:e;return t?.type===`Text`||t?.type===`TextualBody`||t?.format===`text/html`||t?.format===`text/plain`?t.value||``:null}function ht(e,t){return t?.type===`SpecificResource`?ht(e,t.source):t?.id&&t?.type===`ContentResource`?e.get({id:t.id,type:`ContentResource`},{skipSelfReturn:!1})||t:t?.id&&!t.items&&!t.value&&!t.service&&!t.format&&!t.width&&!t.height&&e.get(t,{skipSelfReturn:!1})||t}function gt(e){let t=e?.type===`SpecificResource`?e.source:e;return t?.type===`Video`&&!_t(t)?t.id:null}function _t(e){let t=e?.type===`SpecificResource`?e.source:e,n=((t?.service||[]).find(e=>e?.profile===`https://www.youtube.com`)?.id||t?.id||``).match(/^.*(?:(?:youtu\.be\/|v\/|vi\/|u\/\w\/|embed\/|shorts\/)|(?:(?:watch)?\?vi?=|&vi?=))([^#&?]*).*/);return n?n[1]:null}const vt=`editorial-text`;function yt({className:e,editable:t=!1,mode:n=`edit`,showTourSteps:r=!1}){let i=(0,d.useCanvas)(),a=(0,d.useVault)(),o=(0,u.useInStack)(`Annotation`),s=(0,m.useRef)(null),c=W(e=>e.requestTab),{selectedAnnotationId:l,repositioningAnnotationId:f,selectedTextRegion:h,repositioningTextRegion:g,selectedTourStepId:_,repositioningTourStepId:v,selectAnnotation:b,startRepositioning:x,selectTextRegion:S,selectTourStep:C}=U();(0,m.useEffect)(()=>{st(a,i)},[i?.id,a]);let w=(0,d.useVaultSelector)((e,t)=>i?rt(t,i):[],[i?.id,i?.items?.[0]?.id]),T=(0,d.useVaultSelector)((e,t)=>i?et(t,i):[],[i?.id,i?.annotations?.[0]?.id]);if(!i)return null;let E=Number(i.width)||1920,D=Number(i.height)||1080,O=ct(i),k=Array.isArray(i.behavior)?i.behavior:[],A=o?.resource.source.id,j=n===`edit`&&r,M=n===`edit`&&!r;return(0,p.jsxs)(`div`,{ref:s,className:(0,y.twMerge)(`relative h-full w-full overflow-hidden`,n===`edit`&&`bg-white`,e),style:{aspectRatio:`${E} / ${D}`},children:[w.length?w.map(e=>{let r=A===e.annotation.id,o=r||l===e.annotation.id,u=f===e.annotation.id;return(0,p.jsxs)(`div`,{className:(0,y.twMerge)(`absolute overflow-hidden`,M&&o&&`ring-4 ring-me-primary-500 ring-offset-2 ring-offset-white`,(u||r)&&M&&`cursor-move select-none touch-none`),style:{left:`${e.box.x/E*100}%`,top:`${e.box.y/D*100}%`,width:`${e.box.width/E*100}%`,height:`${e.box.height/D*100}%`},onPointerDown:M&&(u||r)?t=>Ct({event:t,mode:`move`,canvas:i,annotation:e.annotation,vault:a,startBox:e.box,stage:s.current}):M&&t?t=>{b(e.annotation.id),x(e.annotation.id),c(`content`),Ct({event:t,mode:`move`,canvas:i,annotation:e.annotation,vault:a,startBox:e.box,stage:s.current})}:void 0,children:[(0,p.jsx)(St,{layer:e,mode:n,cover:k.includes(`cover`)}),M&&(u||r)?(0,p.jsx)(`div`,{className:`absolute bottom-0 right-0 h-4 w-4 cursor-se-resize rounded-tl bg-me-primary-500`,onPointerDown:t=>{t.stopPropagation(),Ct({event:t,mode:`resize`,canvas:i,annotation:e.annotation,vault:a,startBox:e.box,stage:s.current})}}):null]},e.annotation.id)}):(0,p.jsx)(`div`,{className:(0,y.twMerge)(`flex h-full w-full items-center justify-center text-sm font-semibold`,n===`preview`?`text-white/40`:`bg-white text-slate-400`),children:n===`preview`?`This slide has no content yet`:`Empty slide`}),O.text?(0,p.jsx)(xt,{canvas:i,box:O.text,editable:t&&M,mode:n,repositioning:g===vt,selected:h===vt,stage:s,onSelect:()=>{S(vt),c(`content`)}}):null,j?T.map((e,t)=>(0,p.jsx)(bt,{annotation:e,canvas:i,index:t,selected:_===e.id,repositioning:v===e.id,onSelect:()=>{C(e.id)}},e.id)):null]})}function bt({annotation:e,canvas:t,index:n,selected:r,repositioning:i,onSelect:a}){let o=it(e,t),s=Number(t.width)||1920,c=Number(t.height)||1080,l=`#6d5aa8`;return(0,p.jsx)(`div`,{className:(0,y.twMerge)(`absolute select-none border-2 border-me-primary-500 bg-me-primary-500/10 touch-none`,r?`z-40`:`z-30`,`cursor-pointer`,r?`border-4`:`ring-2 ring-white`),style:{left:`${o.x/s*100}%`,top:`${o.y/c*100}%`,width:`${o.width/s*100}%`,height:`${o.height/c*100}%`,...r?{backgroundColor:`rgba(109, 90, 168, 0.2)`,borderColor:l,boxShadow:`0 0 0 4px rgba(109, 90, 168, 0.22), 0 0 0 8px rgba(109, 90, 168, 0.14)`}:{}},onPointerDown:e=>{e.stopPropagation(),a()},children:(0,p.jsxs)(`span`,{className:(0,y.twMerge)(`absolute left-1 top-1 rounded px-1.5 py-0.5 text-xs font-semibold text-white`,!r&&`bg-me-primary-500`),style:r?{backgroundColor:l}:void 0,children:[`Step `,n+1]})})}function xt({canvas:e,box:t,editable:n,mode:r,onSelect:i,repositioning:a,selected:o,stage:s}){let c=Number(e.width)||1920,l=Number(e.height)||1080,u=(0,d.useVault)();return(0,p.jsxs)(`div`,{className:(0,y.twMerge)(`absolute flex flex-col overflow-hidden bg-black text-white`,r===`preview`?`font-mono`:`p-[3%]`,n&&o&&`ring-4 ring-me-primary-500 ring-offset-2`,n&&a&&`cursor-move select-none touch-none`),style:{left:`${t.x/c*100}%`,top:`${t.y/l*100}%`,width:`${t.width/c*100}%`,height:`${t.height/l*100}%`,...r===`preview`?{containerType:`inline-size`,padding:`3% 4%`}:{}},onPointerDown:n?n=>{i(),a&&wt({event:n,mode:`move`,canvas:e,vault:u,startBox:t,stage:s.current})}:void 0,children:[r===`edit`?(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(`div`,{className:`block cursor-text text-xl font-semibold uppercase leading-tight outline-none focus:ring-2 focus:ring-white/70`,contentEditable:!0,suppressContentEditableWarning:!0,onBlur:t=>u.modifyEntityField(e,`label`,{en:[t.currentTarget.textContent||``]}),children:Tt(e.label)||`Untitled`}),(0,p.jsx)(`div`,{className:`mt-4 block min-h-0 cursor-text overflow-y-auto whitespace-pre-wrap text-sm leading-relaxed opacity-90 outline-none focus:ring-2 focus:ring-white/70`,contentEditable:!0,suppressContentEditableWarning:!0,onBlur:t=>u.modifyEntityField(e,`summary`,{en:[t.currentTarget.textContent||``]}),children:Tt(e.summary)||`Add editorial text`})]}):(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(d.LocaleString,{className:`block font-semibold uppercase leading-tight`,style:{fontSize:`clamp(13px, 5cqw, 26px)`},children:e.label}),(0,p.jsx)(d.LocaleString,{className:`block min-h-0 overflow-y-auto whitespace-pre-wrap opacity-90 leading-[1.45]`,style:{fontSize:`clamp(11px, 3.5cqw, 18px)`,marginTop:`5%`,paddingRight:`2%`},children:e.summary})]}),n&&a?(0,p.jsx)(`div`,{className:`absolute bottom-0 right-0 h-4 w-4 cursor-se-resize rounded-tl bg-me-primary-500`,onPointerDown:n=>{n.stopPropagation(),wt({event:n,mode:`resize`,canvas:e,vault:u,startBox:t,stage:s.current})}}):null]})}function St({layer:e,mode:t,cover:n}){return e.imageUrl?(0,p.jsx)(`img`,{src:e.imageUrl,alt:``,className:(0,y.twMerge)(`h-full w-full`,n?`object-cover`:`object-contain`)}):e.html===null?e.youtubeId?(0,p.jsx)(`iframe`,{className:`h-full w-full border-0`,title:`YouTube slide content`,src:`https://www.youtube.com/embed/${e.youtubeId}?modestbranding=1&rel=0`,allow:`accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture`,allowFullScreen:!0}):e.videoUrl?(0,p.jsx)(`video`,{className:`h-full w-full bg-black object-contain`,controls:!0,children:(0,p.jsx)(`source`,{src:e.videoUrl})}):(0,p.jsx)(`div`,{className:`flex h-full w-full items-center justify-center rounded bg-slate-100 text-sm font-semibold text-slate-500`,children:`Media`}):e.html?(0,p.jsx)(`div`,{className:`h-full w-full overflow-hidden bg-white p-4 text-slate-900`,dangerouslySetInnerHTML:{__html:e.html}}):t===`preview`?null:(0,p.jsx)(`div`,{className:`h-full w-full overflow-hidden bg-white p-4 text-slate-900`,children:(0,p.jsx)(`div`,{className:`flex h-full items-center justify-center rounded border border-dashed border-slate-300 text-sm font-semibold text-slate-400`,children:`Empty text`})})}function Ct({event:e,mode:t,canvas:n,annotation:r,vault:i,startBox:a,stage:o}){if(!o)return;e.preventDefault();let s=o.getBoundingClientRect(),c=(Number(n?.width)||1920)/s.width,l=(Number(n?.height)||1080)/s.height,u=e.clientX,d=e.clientY,f=e=>{let o=(e.clientX-u)*c,s=(e.clientY-d)*l,f=t===`move`?{...a,x:a.x+o,y:a.y+s}:{...a,width:a.width+o,height:a.height+s};at(i,n,r.id,f)},p=()=>{window.removeEventListener(`pointermove`,f),window.removeEventListener(`pointerup`,p),window.removeEventListener(`pointercancel`,p)};window.addEventListener(`pointermove`,f),window.addEventListener(`pointerup`,p),window.addEventListener(`pointercancel`,p)}function wt({event:e,mode:t,canvas:n,vault:r,startBox:i,stage:a}){if(!a)return;e.preventDefault(),e.stopPropagation();let o=a.getBoundingClientRect(),s=(Number(n?.width)||1920)/o.width,c=(Number(n?.height)||1080)/o.height,l=e.clientX,u=e.clientY,d=e=>{let a=(e.clientX-l)*s,o=(e.clientY-u)*c;ot(r,n,t===`move`?{...i,x:i.x+a,y:i.y+o}:{...i,width:i.width+a,height:i.height+o})},f=()=>{window.removeEventListener(`pointermove`,d),window.removeEventListener(`pointerup`,f),window.removeEventListener(`pointercancel`,f)};window.addEventListener(`pointermove`,d),window.addEventListener(`pointerup`,f),window.addEventListener(`pointercancel`,f)}function Tt(e){if(!e)return``;if(typeof e==`string`)return e;if(Array.isArray(e))return e.filter(Boolean).join(` `);let t=Object.values(e)[0];return Array.isArray(t)?t.filter(Boolean).join(` `):typeof t==`string`?t:``}const Et=(0,m.forwardRef)(function({isFirst:e,item:t,children:n,...r},i){let a=(0,d.useCanvas)(),[o]=(0,d.useRenderingStrategy)(),s=a?.behavior||[],c=(0,u.useInStack)(`Canvas`),l=Ke(a?.behavior,e),{isBottom:f,isImage:m,isInfo:g,isLeft:_}=qe(a?.behavior),v=c?.resource.source?.id===a?.id,b=s.includes(`w-12`)&&s.includes(`h-8`),x=null;return x=b?(0,p.jsx)(yt,{className:`pointer-events-none h-full w-full`,mode:`preview`}):g?(0,p.jsx)(`div`,{className:`bg-black w-full h-full text-white max-h-40`,children:(0,p.jsx)(`div`,{className:`p-1.5 text-[4px]`,children:o.type===`textual-content`?(0,p.jsx)(d.LocaleString,{enableDangerouslySetInnerHTML:!0,children:o.items[0]?.text}):null})}):(0,p.jsxs)(`div`,{className:(0,y.twMerge)(`flex h-full max-h-full min-h-0`,_?`flex-row-reverse`:f?`flex-col`:`flex-row`),children:[(0,p.jsx)(`div`,{className:`flex-1 overflow-hidden relative justify-self-stretch`,children:(0,p.jsx)(`div`,{className:`absolute inset-0 w-full h-full`,children:(0,p.jsx)(h.LazyThumbnail,{cover:s.includes(`cover`),fade:!1})})}),m?null:(0,p.jsx)(`div`,{className:`${f?`min-h-3 w-full`:`w-1/3`} flex-shrink-0 self-stretch p-2 text-white bg-black rounded`,children:(0,p.jsxs)(`div`,{className:`p-1.5 text-[4px]`,children:[(0,p.jsx)(d.LocaleString,{className:`block mb-1 text-[5px]`,children:a?.label}),(0,p.jsx)(d.LocaleString,{children:a?.summary})]})})]}),(0,p.jsxs)(`div`,{ref:i,className:(0,y.twMerge)(l,`bg-me-gray-700 overflow-hidden hover:ring-2 ring-me-primary-500 relative`,v?`ring-2 ring-me-primary-500`:``),...r,children:[x,n]})});function Dt(){let{open:e}=(0,l.useLayoutActions)(),{structural:t,technical:n}=(0,l.useManifestEditor)(),[,r]=(0,l.useCreator)({id:n.id.get(),type:`Manifest`},`items`,`Canvas`);return(0,p.jsx)(Ve,{children:t.items.get().map((t,n)=>(0,p.jsx)(d.CanvasContext,{canvas:t.id,children:(0,p.jsx)(Et,{isFirst:n===0,item:t,onClick:()=>{e({id:`current-canvas`}),r.edit(t,n)}})},n))})}function Ot(e){return(0,p.jsxs)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 24 24`,height:`1em`,width:`1em`,...e,children:[(0,p.jsx)(`title`,{children:`Rearrange`}),(0,p.jsx)(`path`,{fill:`none`,d:`M0 0h24v24H0z`}),(0,p.jsx)(`path`,{d:`M20 9H4v2h16V9zM4 15h16v-2H4v2z`,fill:`currentColor`})]})}function kt({isFirst:e,onClick:t,item:n,actions:r}){let{attributes:i,listeners:a,setNodeRef:o,transform:s,transition:c}=(0,C.useSortable)({id:n.id,transition:{duration:150,easing:`cubic-bezier(0.25, 1, 0.5, 1)`}});return(0,p.jsx)(Et,{ref:o,style:{transform:w.CSS.Translate.toString(s),transition:c},...i,...a,onClick:t,isFirst:e,item:n,children:(0,p.jsxs)(`div`,{className:`absolute top-0.5 right-0.5 flex gap-0.5 items-stretch`,children:[r?.length?(0,p.jsx)(u.AppDropdown,{as:v.Button,className:`bg-white p-1 text-2xl hover:text-me-500 aria-expanded:text-me-600 aria-expanded:bg-me-200 hover:bg-me-100 rounded-sm`,"aria-label":`Action menu`,items:r,children:(0,p.jsx)(h.MoreMenu,{})}):null,(0,p.jsx)(`div`,{className:`bg-white text-2xl h-8 flex items-center p-1 hover:text-me-500 hover:bg-me-100 rounded-sm`,children:(0,p.jsx)(Ot,{"aria-label":`Reorder item`})})]})})}function At(){let e=(0,d.useManifest)(),{structural:t,technical:n}=(0,l.useManifestEditor)(),r=(0,l.useEditingStack)(),i=(0,u.useInStack)(`Canvas`),a=t.items.get(),{open:o}=(0,l.useLayoutActions)(),s=(0,x.useSensors)((0,x.useSensor)(x.PointerSensor,{activationConstraint:{distance:5}}),(0,x.useSensor)(x.KeyboardSensor,{coordinateGetter:C.sortableKeyboardCoordinates})),[,c]=(0,l.useCreator)({id:n.id.get(),type:`Manifest`},`items`,`Canvas`),f=(0,m.useCallback)(e=>{let{active:n,over:r}=e;r&&n.id!==r.id&&t.items.reorder(a.findIndex(e=>e.id===n.id),a.findIndex(e=>e.id===r.id))},[a,t.items]),h=i?.resource.source.id,g=h?a.findIndex(e=>e.id===h):-1,_=g&&g>0?Number(g-1):0;function v(){r.close();let n=t.items.getWithoutTracking();n&&n.length>0?c.edit(n[_]):c.edit(e)}let y=(0,m.useMemo)(()=>(0,u.createAppActions)(t.items,v),[t.items,v]);return(0,p.jsx)(Ve,{children:(0,p.jsx)(x.DndContext,{sensors:s,collisionDetection:x.closestCenter,onDragEnd:f,modifiers:[S.restrictToParentElement],children:(0,p.jsx)(C.SortableContext,{items:a,strategy:C.rectSortingStrategy,children:a.map((t,n)=>t?(0,p.jsx)(d.CanvasContext,{canvas:t.id,children:(0,p.jsx)(kt,{item:t,isFirst:n===0,onClick:()=>{o({id:`current-canvas`}),c.edit(t,n)},actions:y(t,n,e)},t.id)},t.id):null)})})})}const jt=Nt({label:`Exhibition grid`,creatorFilter:`exhibition-slide`}),Mt=Nt({label:`Slideshow`,creatorFilter:`exhibition-slideshow-slide`});function Nt({label:e,creatorFilter:t}){return{id:`canvas-listing`,label:e,icon:(0,p.jsx)(Ft,{}),render:()=>(0,p.jsx)(Pt,{creatorFilter:t}),options:{minWidth:350,maxWidth:350}}}function Pt({creatorFilter:e}){let{structural:t,technical:n}=(0,l.useManifestEditor)(),r={id:n.id.get(),type:`Manifest`},i=t.items.get()||[],a=(0,u.useInStack)(`Canvas`)?.resource.source.id,o=a?i.findIndex(e=>e.id===a):-1,s=o>=0?o+1:void 0,[c,d]=(0,l.useCreator)(r,`items`,`Canvas`,void 0,{isPainting:!0}),[f,m]=(0,u.useToggleList)();return(0,p.jsxs)(h.Sidebar,{children:[(0,p.jsx)(h.SidebarHeader,{title:`Exhibition`,actions:[{icon:f.list?(0,p.jsx)(b.CanvasListingIcon,{className:`text-2xl`}):(0,p.jsx)(Ft,{}),title:f.list?`List view`:`Grid view`,onClick:()=>m(`list`)},{icon:(0,p.jsx)(It,{}),title:`Edit slides`,toggled:f.editing,onClick:()=>m(`editing`)},{icon:(0,p.jsx)(Lt,{}),title:`Add new slide`,disabled:!c,onClick:()=>d.createFiltered(e,s)}]}),(0,p.jsx)(h.SidebarContent,{children:f.list?(0,p.jsx)(b.CanvasListView,{isEditing:f.editing}):f.editing?(0,p.jsx)(At,{}):(0,p.jsx)(Dt,{})})]})}function Ft(){return(0,p.jsxs)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,width:`24`,height:`24`,fill:`currentColor`,viewBox:`0 -960 960 960`,children:[(0,p.jsx)(`title`,{children:`Exhibition grid`}),(0,p.jsx)(`path`,{d:`M600-160v-280h280v280H600ZM440-520v-280h440v280H440ZM80-160v-280h440v280H80Zm0-360v-280h280v280H80Zm440-80h280v-120H520v120ZM160-240h280v-120H160v120Zm520 0h120v-120H680v120ZM160-600h120v-120H160v120Zm360 0Zm-80 240Zm240 0ZM280-600Z`})]})}function It(){return(0,p.jsxs)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,height:`24`,viewBox:`0 0 24 24`,width:`24`,children:[(0,p.jsx)(`title`,{children:`Edit slides`}),(0,p.jsx)(`path`,{d:`M0 0h24v24H0V0z`,fill:`none`}),(0,p.jsx)(`path`,{d:`M14.06 9.02l.92.92L5.92 19H5v-.92l9.06-9.06M17.66 3c-.25 0-.51.1-.7.29l-1.83 1.83 3.75 3.75 1.83-1.83c.39-.39.39-1.02 0-1.41l-2.34-2.34c-.2-.2-.45-.29-.71-.29zm-3.6 3.19L3 17.25V21h3.75L17.81 9.94l-3.75-3.75z`})]})}function Lt(){return(0,p.jsxs)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,width:`24`,height:`24`,fill:`currentColor`,viewBox:`0 -960 960 960`,children:[(0,p.jsx)(`title`,{children:`Add new slide`}),(0,p.jsx)(`path`,{d:`M160-240v-480 480Zm80-80v-200h360v200H240Zm-80 160q-33 0-56.5-23.5T80-240v-480q0-33 23.5-56.5T160-800h640q33 0 56.5 23.5T880-720v240h-80v-240H160v480h360v80H160Zm500-320v-100H360v-60h360v160h-60Zm60 400v-120H600v-80h120v-120h80v120h120v80H800v120h-80Z`})]})}const Rt={id:`@exhibitions/overview-panel`,label:`Preview`,icon:(0,p.jsx)(Le,{}),render:()=>(0,p.jsx)(zt,{})};function zt(){return(0,d.useManifest)()?(0,p.jsx)(`div`,{children:`Coming soon.`}):null}const Bt={id:`@exhibitions/theme-panel`,label:`Theme`,icon:(0,p.jsx)(Yt,{}),render:()=>(0,p.jsx)(Jt,{}),options:{minWidth:360,maxWidth:440}};function K({title:e,description:t,children:n}){return(0,p.jsxs)(`section`,{className:`mb-5 border-b border-slate-200 pb-5 last:mb-0 last:border-b-0`,children:[(0,p.jsxs)(`div`,{className:`mb-3`,children:[(0,p.jsx)(`h3`,{className:`text-sm font-semibold`,children:e}),t?(0,p.jsx)(`p`,{className:`mt-1 text-xs text-slate-500`,children:t}):null]}),n?(0,p.jsx)(`div`,{className:`space-y-3`,children:n}):null]})}function Vt({label:e,value:t,onChange:n,options:r}){return(0,p.jsxs)(`div`,{children:[(0,p.jsx)(`div`,{className:`mb-2 text-xs font-medium text-slate-500`,children:e}),(0,p.jsx)(`div`,{className:`flex flex-wrap gap-1 rounded-md border border-slate-200 bg-slate-100 p-1`,children:r.map(e=>{let r=e.value===t;return(0,p.jsx)(v.Button,{className:[`rounded px-2 py-1.5 text-sm transition-colors`,r?`bg-white font-semibold text-slate-950 shadow-sm`:`text-slate-600 hover:bg-white/70 hover:text-slate-900`].join(` `),"aria-pressed":r,onPress:()=>n(e.value),children:e.label},e.value)})})]})}function q({label:e,checked:t,onChange:n}){return(0,p.jsxs)(`label`,{className:`flex items-center gap-3 text-sm`,children:[(0,p.jsx)(`input`,{type:`checkbox`,checked:t,onChange:e=>n(e.target.checked)}),(0,p.jsx)(`span`,{children:e})]})}function J({label:e,value:t,onChange:n}){return(0,p.jsxs)(`div`,{className:`grid grid-cols-[minmax(0,1fr)_auto] items-center gap-3`,children:[(0,p.jsx)(`label`,{className:`text-sm`,children:e}),(0,p.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,p.jsx)(`input`,{className:`h-9 w-12 shrink-0 cursor-pointer rounded border border-slate-300 bg-white p-1`,type:`color`,value:Wt(t),onChange:e=>n(e.target.value)}),(0,p.jsx)(u.Input,{value:t,onChange:e=>n(e.target.value)})]})]})}function Ht({label:e,value:t,onChange:n}){return(0,p.jsxs)(u.InputContainer,{$wide:!0,children:[(0,p.jsx)(u.InputLabel,{children:e}),(0,p.jsx)(u.Input,{value:t,onChange:e=>n(e.target.value)})]})}function Ut({label:e,value:t,onChange:n,options:r}){return(0,p.jsxs)(u.InputContainer,{$wide:!0,children:[(0,p.jsx)(u.InputLabel,{children:e}),(0,p.jsx)(`select`,{className:`w-full rounded border border-slate-300 bg-slate-50 px-3 py-2 text-sm`,value:t,onChange:e=>n(e.target.value),children:r.map(e=>(0,p.jsx)(`option`,{value:e.value,children:e.label},e.value))})]})}function Wt(e){let t=e.trim();if(/^#[0-9a-fA-F]{6}$/.test(t))return t;if(/^#[0-9a-fA-F]{3}$/.test(t)){let[e,n,r]=t.slice(1);return`#${e}${e}${n}${n}${r}${r}`}return`#ffffff`}function Gt(e){return JSON.parse(JSON.stringify(e))}function Kt(e,t,n){let r=Gt(e),i=r;for(let e of t.slice(0,-1)){var a;(a=i)[e]||(a[e]={}),i=i[e]}let o=t[t.length-1];return o&&(i[o]=n),r}function qt(e,t){let n=Gt(e);for(let e of t){let t=n;for(let n of e.path.slice(0,-1)){var r;(r=t)[n]||(r[n]={}),t=t[n]}let i=e.path[e.path.length-1];i&&(t[i]=e.value)}return n}function Jt(){let e=(0,d.useManifest)(),t=(0,d.useVault)(),[n,r]=(0,m.useState)(`simple`),{centerPanel:i}=(0,l.useLayoutState)(),{centerPanel:a}=(0,l.useLayoutActions)(),[o,s]=Ie(),c=e?.service||[],u=e?.services||[],f=(i.current===ze.id?i.state:null)?.preset||o||Re,g=(0,m.useMemo)(()=>{let e=pe(c);if(e)return{service:e.service};let t=pe(u);return t?{service:t.service}:null},[c,u]),_=(0,m.useMemo)(()=>g?ue(g.service.theme):null,[g])||le(`delft`);if(!e)return null;let y=n=>{let r=he(c,n?fe(e.id,n):null),i=he(u,null),a={id:e.id,type:`Manifest`};t.batch(t=>{t.modifyEntityField(a,`service`,r),(e.services||i.length!==u.length)&&t.modifyEntityField(a,`services`,i)})},b=(e,t)=>{y(Kt(_,e,t))},x=e=>{y(qt(_,e))};return(0,p.jsx)(h.Sidebar,{children:(0,p.jsxs)(h.SidebarContent,{padding:!0,children:[(0,p.jsx)(K,{title:`Preview`,description:`Switch the live preview route without changing the saved manifest theme.`,children:(0,p.jsx)(Vt,{label:`Preview preset`,value:f,onChange:e=>{s(e),a.open({id:ze.id,state:{preset:e}})},options:Fe})}),(0,p.jsxs)(K,{title:`Manifest Theme`,description:`Store exhibition styling and viewer defaults in a custom IIIF service on the Manifest.`,children:[(0,p.jsx)(q,{label:`Enable manifest theme`,checked:!!g,onChange:e=>{if(!e){y(null);return}y(le(`delft`))}}),(0,p.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,p.jsx)(v.Button,{className:`rounded border border-slate-300 px-3 py-2 text-sm hover:bg-slate-50 disabled:cursor-not-allowed disabled:opacity-50`,onPress:()=>{y(le(_.preset))},isDisabled:!g,children:`Reset to preset`}),(0,p.jsx)(v.Button,{className:`rounded border border-slate-300 px-3 py-2 text-sm hover:bg-slate-50 disabled:cursor-not-allowed disabled:opacity-50`,onPress:()=>y(null),isDisabled:!g,children:`Remove theme service`})]}),(0,p.jsx)(Vt,{label:`Preset`,value:_.preset,onChange:e=>{y(le(e))},options:[{label:`Delft`,value:`delft`},{label:`Gallery`,value:`gallery`},{label:`Minimal`,value:`minimal`}]})]}),(0,p.jsx)(K,{title:`Theme Options`,children:(0,p.jsx)(Vt,{label:`Editing mode`,value:n,onChange:r,options:[{label:`Simple`,value:`simple`},{label:`Advanced`,value:`advanced`}]})}),n===`simple`?(0,p.jsxs)(K,{title:`Simple Colors`,description:`Apply broad colours across the exhibition, scrolling, presentation, and slideshow views.`,children:[(0,p.jsx)(J,{label:`Base colour`,value:_.delft.tokens.backgroundSecondary,onChange:e=>{x([{path:[`delft`,`tokens`,`backgroundPrimary`],value:e},{path:[`delft`,`tokens`,`backgroundSecondary`],value:e},{path:[`delft`,`tokens`,`controlBar`],value:e},{path:[`delft`,`tokens`,`closeBackground`],value:e},{path:[`delft`,`tokens`,`titleCard`],value:e},{path:[`delft`,`tokens`,`infoBlock`],value:e},{path:[`delft`,`tokens`,`viewerBackground`],value:e},{path:[`scroll`,`tokens`,`titleBackground`],value:e},{path:[`scroll`,`tokens`,`annotationBackground`],value:e},{path:[`scroll`,`tokens`,`infoBlockBackground`],value:e}])}}),(0,p.jsx)(J,{label:`Text colour`,value:_.delft.tokens.textSecondary,onChange:e=>{x([{path:[`delft`,`tokens`,`textPrimary`],value:e},{path:[`delft`,`tokens`,`textSecondary`],value:e},{path:[`delft`,`tokens`,`imageCaption`],value:e},{path:[`delft`,`tokens`,`closeText`],value:e},{path:[`delft`,`tokens`,`titleCardText`],value:e},{path:[`delft`,`tokens`,`infoBlockText`],value:e},{path:[`scroll`,`tokens`,`titleColor`],value:e},{path:[`scroll`,`tokens`,`annotationColor`],value:e},{path:[`scroll`,`tokens`,`infoBlockColor`],value:e}])}})]}):(0,p.jsxs)(p.Fragment,{children:[(0,p.jsxs)(K,{title:`Typography`,children:[(0,p.jsx)(Ht,{label:`Sans font stack`,value:_.shared.fontSans,onChange:e=>b([`shared`,`fontSans`],e)}),(0,p.jsx)(Ht,{label:`Mono font stack`,value:_.shared.fontMono,onChange:e=>b([`shared`,`fontMono`],e)}),(0,p.jsx)(Ut,{label:`Title transform`,value:_.shared.titleTransform,onChange:e=>b([`shared`,`titleTransform`],e),options:[{label:`Uppercase`,value:`uppercase`},{label:`None`,value:`none`},{label:`Capitalize`,value:`capitalize`}]})]}),(0,p.jsxs)(K,{title:`Delft Colors`,children:[(0,p.jsx)(J,{label:`Background`,value:_.delft.tokens.backgroundPrimary,onChange:e=>b([`delft`,`tokens`,`backgroundPrimary`],e)}),(0,p.jsx)(J,{label:`Secondary background`,value:_.delft.tokens.backgroundSecondary,onChange:e=>b([`delft`,`tokens`,`backgroundSecondary`],e)}),(0,p.jsx)(J,{label:`Primary text`,value:_.delft.tokens.textPrimary,onChange:e=>b([`delft`,`tokens`,`textPrimary`],e)}),(0,p.jsx)(J,{label:`Secondary text`,value:_.delft.tokens.textSecondary,onChange:e=>b([`delft`,`tokens`,`textSecondary`],e)}),(0,p.jsx)(J,{label:`Title card`,value:_.delft.tokens.titleCard,onChange:e=>b([`delft`,`tokens`,`titleCard`],e)}),(0,p.jsx)(J,{label:`Title card text`,value:_.delft.tokens.titleCardText,onChange:e=>b([`delft`,`tokens`,`titleCardText`],e)}),(0,p.jsx)(J,{label:`Info block`,value:_.delft.tokens.infoBlock,onChange:e=>b([`delft`,`tokens`,`infoBlock`],e)}),(0,p.jsx)(J,{label:`Info block text`,value:_.delft.tokens.infoBlockText,onChange:e=>b([`delft`,`tokens`,`infoBlockText`],e)}),(0,p.jsx)(J,{label:`Control bar`,value:_.delft.tokens.controlBar,onChange:e=>b([`delft`,`tokens`,`controlBar`],e)}),(0,p.jsx)(J,{label:`Viewer background`,value:_.delft.tokens.viewerBackground,onChange:e=>b([`delft`,`tokens`,`viewerBackground`],e)})]}),(0,p.jsxs)(K,{title:`Scroll Colors`,children:[(0,p.jsx)(J,{label:`Title background`,value:_.scroll.tokens.titleBackground,onChange:e=>b([`scroll`,`tokens`,`titleBackground`],e)}),(0,p.jsx)(J,{label:`Title text`,value:_.scroll.tokens.titleColor,onChange:e=>b([`scroll`,`tokens`,`titleColor`],e)}),(0,p.jsx)(J,{label:`Annotation background`,value:_.scroll.tokens.annotationBackground,onChange:e=>b([`scroll`,`tokens`,`annotationBackground`],e)}),(0,p.jsx)(J,{label:`Annotation text`,value:_.scroll.tokens.annotationColor,onChange:e=>b([`scroll`,`tokens`,`annotationColor`],e)}),(0,p.jsx)(J,{label:`Info block background`,value:_.scroll.tokens.infoBlockBackground,onChange:e=>b([`scroll`,`tokens`,`infoBlockBackground`],e)}),(0,p.jsx)(J,{label:`Info block text`,value:_.scroll.tokens.infoBlockColor,onChange:e=>b([`scroll`,`tokens`,`infoBlockColor`],e)})]}),(0,p.jsxs)(K,{title:`Exhibition Defaults`,children:[(0,p.jsx)(q,{label:`Cut corners`,checked:_.delft.exhibition.cutCorners,onChange:e=>b([`delft`,`exhibition`,`cutCorners`],e)}),(0,p.jsx)(q,{label:`Full title bar`,checked:_.delft.exhibition.fullTitleBar,onChange:e=>b([`delft`,`exhibition`,`fullTitleBar`],e)}),(0,p.jsx)(q,{label:`Full width grid`,checked:_.delft.exhibition.fullWidthGrid,onChange:e=>b([`delft`,`exhibition`,`fullWidthGrid`],e)}),(0,p.jsx)(q,{label:`Hide table of contents`,checked:_.delft.exhibition.hideTableOfContents,onChange:e=>b([`delft`,`exhibition`,`hideTableOfContents`],e)}),(0,p.jsx)(q,{label:`Disable presentation mode`,checked:_.delft.exhibition.disablePresentation,onChange:e=>b([`delft`,`exhibition`,`disablePresentation`],e)}),(0,p.jsx)(q,{label:`Hide title card`,checked:_.delft.exhibition.hideTitleCard,onChange:e=>b([`delft`,`exhibition`,`hideTitleCard`],e)}),(0,p.jsx)(q,{label:`Alternative image mode`,checked:_.delft.exhibition.alternativeImageMode,onChange:e=>b([`delft`,`exhibition`,`alternativeImageMode`],e)}),(0,p.jsx)(q,{label:`Transition scale`,checked:_.delft.exhibition.transitionScale,onChange:e=>b([`delft`,`exhibition`,`transitionScale`],e)}),(0,p.jsx)(q,{label:`Image info icon`,checked:_.delft.exhibition.imageInfoIcon,onChange:e=>b([`delft`,`exhibition`,`imageInfoIcon`],e)}),(0,p.jsx)(q,{label:`Cover images`,checked:_.delft.exhibition.coverImages,onChange:e=>b([`delft`,`exhibition`,`coverImages`],e)})]}),(0,p.jsxs)(K,{title:`Presentation Defaults`,children:[(0,p.jsx)(q,{label:`Cut corners`,checked:_.delft.presentation.cutCorners,onChange:e=>b([`delft`,`presentation`,`cutCorners`],e)}),(0,p.jsx)(q,{label:`Floating caption panels`,checked:_.delft.presentation.isFloating,onChange:e=>b([`delft`,`presentation`,`isFloating`],e)}),(0,p.jsx)(Ut,{label:`Floating position`,value:_.delft.presentation.floatingPosition,onChange:e=>b([`delft`,`presentation`,`floatingPosition`],e),options:[{label:`Top left`,value:`top-left`},{label:`Top right`,value:`top-right`},{label:`Bottom left`,value:`bottom-left`},{label:`Bottom right`,value:`bottom-right`}]})]}),(0,p.jsxs)(K,{title:`Slideshow Defaults`,children:[(0,p.jsx)(q,{label:`Alternative image mode`,checked:_.delft.slideshow.alternativeImageMode,onChange:e=>b([`delft`,`slideshow`,`alternativeImageMode`],e)}),(0,p.jsx)(q,{label:`Transition scale`,checked:_.delft.slideshow.transitionScale,onChange:e=>b([`delft`,`slideshow`,`transitionScale`],e)}),(0,p.jsx)(q,{label:`Image info icon`,checked:_.delft.slideshow.imageInfoIcon,onChange:e=>b([`delft`,`slideshow`,`imageInfoIcon`],e)}),(0,p.jsx)(q,{label:`Cover images`,checked:_.delft.slideshow.coverImages,onChange:e=>b([`delft`,`slideshow`,`coverImages`],e)})]}),(0,p.jsxs)(K,{title:`Scroll Defaults`,children:[(0,p.jsx)(q,{label:`Show table of contents`,checked:_.scroll.options.showTableOfContents,onChange:e=>b([`scroll`,`options`,`showTableOfContents`],e)}),(0,p.jsx)(q,{label:`Full-height title block`,checked:_.scroll.options.titleBlock.fullHeight,onChange:e=>b([`scroll`,`options`,`titleBlock`,`fullHeight`],e)})]})]})]})})}function Yt(){return(0,p.jsxs)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,width:`24`,height:`24`,fill:`currentColor`,viewBox:`0 -960 960 960`,children:[(0,p.jsx)(`title`,{children:`Theme`}),(0,p.jsx)(`path`,{d:`M480-80q-83 0-156-31.5T197-197q-54-54-85.5-127T80-480q0-83 32.5-156T201-763q56-54 131-85.5T492-880q79 0 147 27t120 74q52 47 81.5 110T870-533q0 93-56 147t-145 54h-72q-18 0-28 10t-10 25q0 15 12 31.5t12 39.5q0 55-29 100.5T480-80ZM280-480q25 0 42.5-17.5T340-540q0-25-17.5-42.5T280-600q-25 0-42.5 17.5T220-540q0 25 17.5 42.5T280-480Zm120-160q25 0 42.5-17.5T460-700q0-25-17.5-42.5T400-760q-25 0-42.5 17.5T340-700q0 25 17.5 42.5T400-640Zm160 0q25 0 42.5-17.5T620-700q0-25-17.5-42.5T560-760q-25 0-42.5 17.5T500-700q0 25 17.5 42.5T560-640Zm120 160q25 0 42.5-17.5T740-540q0-25-17.5-42.5T680-600q-25 0-42.5 17.5T620-540q0 25 17.5 42.5T680-480Z`})]})}const Xt=`left-panel-manifest`;function Zt(e){return e===`left-panel-manifest`||e===jt.id}const Qt={id:`exhibition-background-task`,label:`Query string`,render:()=>(0,p.jsx)($t,{})};function $t(){let e=(0,d.useManifest)(),{leftPanel:t,rightPanel:n}=(0,l.useLayoutState)(),{edit:r,centerPanel:i,rightPanel:a}=(0,l.useLayoutActions)(),[o,s]=(0,m.useState)(!1),c=(0,m.useRef)(null),u=(0,m.useRef)(null);return(0,m.useEffect)(()=>{let l=e?.id||null,d=c.current!==t.current,f=u.current!==l,p=c.current;if(c.current=t.current,u.current=l,!(!e||!d&&!f)){if(t.current===Rt.id){r(e),i.open({id:_e.id}),s(!1);return}if(t.current===Bt.id){r(e),n.open?(a.close(),s(!0)):s(!1),i.open({id:ze.id});return}!n.open&&n.current&&Zt(t.current)&&(p===null||p===Bt.id&&o)&&(a.open(),s(!1))}},[i,r,t.current,e?.id,n.current,n.open,a,o]),null}const en={id:`image-block-editor`,label:`Image Block Editor`,component:e=>(0,p.jsx)(tn,{strategy:e}),supports:{strategy:(e,t,n)=>{if(e.type!==`images`)return!1;let r=n.get(t.resource);if(r.type!==`Canvas`)return!1;let i=r.behavior||[],a=!1;for(let e of i)(e.startsWith(`w-`)||e.startsWith(`h-`)||e===`image`)&&(a=!0);return a}}};function tn({strategy:e}){let[t,n]=(0,l.useLocalStorage)(`exhibition-preview-mode`),[r,i]=Ie(),a=(0,u.useInStack)(`Canvas`);return a?(0,p.jsx)(d.CanvasContext,{canvas:a.resource.source?.id,children:(0,p.jsx)(nn,{isPreview:!!t,previewPreset:r,onModeChange:n,onPreviewPresetChange:i})}):null}function nn({isPreview:e,previewPreset:t,onModeChange:n,onPreviewPresetChange:r}){return(0,p.jsxs)(`div`,{className:`relative z-0 flex h-full min-h-0 w-full min-w-0 max-w-full flex-col overflow-hidden bg-white`,children:[(0,p.jsxs)(`div`,{className:`exhibition-slideshow-current-toolbar flex items-center gap-3 border-b border-slate-200 bg-white px-4 py-3 shadow-sm`,children:[(0,p.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,p.jsx)(d.LocaleString,{className:`block truncate text-sm font-semibold text-slate-800`,children:(0,d.useCanvas)()?.label})}),(0,p.jsxs)(`div`,{className:`flex items-center gap-2`,children:[e?(0,p.jsx)(`select`,{className:`rounded-md border border-slate-200 bg-white px-2 py-2 text-xs font-semibold text-slate-700 shadow-sm`,value:t,onChange:e=>r(e.target.value),children:Fe.map(e=>(0,p.jsx)(`option`,{value:e.value,children:e.label},e.value))}):null,(0,p.jsxs)(`div`,{className:`flex shrink-0 overflow-hidden rounded-md border border-slate-200 bg-slate-50 text-xs font-semibold`,children:[(0,p.jsx)(rn,{selected:!e,onPress:()=>n(!1),children:`Edit`}),(0,p.jsx)(rn,{selected:e,onPress:()=>n(!0),children:`Preview`})]})]})]}),e?(0,p.jsx)(`div`,{className:`min-h-0 flex-1`,children:(0,p.jsx)(ke,{preset:t})}):(0,p.jsx)(`div`,{className:`flex min-h-0 flex-1`,children:(0,p.jsx)(u.CanvasPanelEditor,{asFallback:!0})})]})}function rn({children:e,selected:t,onPress:n}){return(0,p.jsx)(v.Button,{className:(0,y.twMerge)(`px-3 py-2 text-xs font-semibold transition`,t?`bg-white text-slate-900 shadow-sm`:`text-slate-500 hover:text-slate-700`),onPress:n,children:e})}const an={id:`info-block-editor`,label:`info Block Editor`,component:e=>(0,p.jsx)(ln,{strategy:e}),supports:{strategy:(e,t,n)=>e.type===`textual-content`}};function on(e){if(e===`@none`||e===`none`)return null;try{let t=new Intl.DisplayNames([e],{type:`language`});return e===`cy`?{key:e,language:e,label:`Cymraeg`}:{key:e,language:e,label:t.of(e)}}catch{return{key:e,language:e,label:e}}}function sn({selectedLanguage:e,languages:t,availableLanguages:n,onSelectLanguage:r,onAddLanguage:i}){let[a,o]=(0,m.useState)(!1),s=(0,m.useRef)(null);(0,m.useEffect)(()=>{if(!a)return;let e=e=>{s.current&&!s.current.contains(e.target)&&o(!1)};return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[a]);let c=n.filter(e=>!t.includes(e));return(0,p.jsxs)(`div`,{ref:s,className:`relative`,children:[(0,p.jsxs)(`button`,{type:`button`,className:`flex items-center gap-1 rounded-md border border-slate-200 bg-white px-3 py-2 text-xs font-semibold text-slate-700 shadow-sm transition hover:bg-slate-50`,onClick:()=>o(e=>!e),children:[(0,p.jsx)(`span`,{className:``,children:on(e)?.label||e}),(0,p.jsx)(`svg`,{className:`h-3 w-3 text-slate-400`,viewBox:`0 0 12 12`,fill:`none`,stroke:`currentColor`,strokeWidth:2,children:(0,p.jsx)(`path`,{d:`M2 4l4 4 4-4`})})]}),a&&(0,p.jsxs)(`div`,{className:`absolute right-0 top-full z-50 mt-1 min-w-[14rem] rounded-md border border-slate-200 bg-white py-1 shadow-lg`,children:[t.length>0&&(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(`div`,{className:`px-3 py-1 text-[10px] font-semibold uppercase tracking-wider text-slate-400`,children:`Language`}),t.map(t=>{let n=on(t);return(0,p.jsxs)(`button`,{type:`button`,className:(0,y.twMerge)(`flex w-full items-center gap-2 px-3 py-1.5 text-xs hover:bg-slate-50`,t===e?`font-semibold text-slate-900`:`text-slate-600`),onClick:()=>{r(t),o(!1)},children:[t===e?(0,p.jsx)(`svg`,{className:`h-3 w-3 shrink-0 text-slate-500`,viewBox:`0 0 12 12`,fill:`currentColor`,children:(0,p.jsx)(`path`,{d:`M2 6l3 3 5-5`,stroke:`currentColor`,strokeWidth:2,fill:`none`})}):(0,p.jsx)(`div`,{className:`h-3 w-3 shrink-0 text-slate-500`}),(0,p.jsx)(`span`,{className:t===e?``:`ml-5`,children:n?.label||t})]},t)})]}),c.length>0&&(0,p.jsxs)(p.Fragment,{children:[t.length>0&&(0,p.jsx)(`div`,{className:`my-1 border-t border-slate-100`}),(0,p.jsx)(`div`,{className:`px-3 py-1 text-[10px] font-semibold uppercase tracking-wider text-slate-400`,children:`Add language`}),c.map(e=>{let t=on(e);return(0,p.jsxs)(`button`,{type:`button`,className:`flex w-full items-center gap-2 px-3 py-1.5 text-xs text-slate-600 hover:bg-slate-50`,onClick:()=>{i(e),o(!1)},children:[(0,p.jsx)(`svg`,{className:`h-3 w-3 shrink-0 text-slate-400`,viewBox:`0 0 12 12`,fill:`none`,stroke:`currentColor`,strokeWidth:2,children:(0,p.jsx)(`path`,{d:`M6 2v8M2 6h8`})}),t?.label||e]},e)})]}),c.length===0&&t.length===0&&(0,p.jsx)(`div`,{className:`px-3 py-2 text-xs text-slate-400`,children:`No languages available`})]})]})}function cn(e,t){if(!e)return[];let n=e.items||[],r=new Set;for(let e of n){let n=Y(e,t);if(!n)continue;let i=bn(n.body);for(let e of i){let n=Y(e,t);n?.language&&r.add(n.language)}}return Array.from(r)}function ln({strategy:e}){let t=(0,d.useCanvas)(),n=(0,d.useVault)(),r=t?.behavior||[],i=Ge(r),a=!!(i.h&&i.w),{isBottom:o,isLeft:s,isRight:c}=qe(r),u=a&&i.w<=6,f=(0,d.useVaultSelector)((e,n)=>t?.items[0]?n.get(t.items[0]):null),h=(0,d.useVaultSelector)((e,n)=>t?.annotations[0]?n.get(t?.annotations[0]):null),{i18n:{availableLanguages:g,defaultLanguage:_}}=(0,l.useConfig)(),[v,b]=(0,l.useLocalStorage)(`exhibition-info-block-mode`,`edit`),[x,S]=Ie(),C=(0,m.useMemo)(()=>{let e=cn(f,n),t=cn(h,n),r=new Set([...e,...t]);return r.size===0&&r.add(_||`en`),Array.from(r)},[f,h,n,_]),[w,T]=(0,l.useLocalStorage)(`exhibition-info-block-language`,_||`en`),E=C.includes(w)?w:C[0]||_||`en`,D=e=>{T(e)},O=u?`28rem`:void 0;return(0,p.jsxs)(`div`,{className:`relative z-0 flex h-full min-h-0 w-full min-w-0 max-w-full flex-col overflow-hidden bg-white`,children:[(0,p.jsxs)(`div`,{className:`exhibition-slideshow-current-toolbar flex items-center gap-3 border-b border-slate-200 bg-white px-4 py-3 shadow-sm`,children:[(0,p.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,p.jsx)(d.LocaleString,{className:`block truncate text-sm font-semibold text-slate-800`,children:t?.label})}),(0,p.jsxs)(`div`,{className:`flex items-center gap-2`,children:[v===`edit`&&(0,p.jsx)(sn,{selectedLanguage:E,languages:C,availableLanguages:g,onSelectLanguage:T,onAddLanguage:D}),v===`preview`?(0,p.jsx)(`select`,{className:`rounded-md border border-slate-200 bg-white px-2 py-2 text-xs font-semibold text-slate-700 shadow-sm`,value:x,onChange:e=>S(e.target.value),children:Fe.map(e=>(0,p.jsx)(`option`,{value:e.value,children:e.label},e.value))}):null,(0,p.jsxs)(`div`,{className:`flex shrink-0 overflow-hidden rounded-md border border-slate-200 bg-slate-50 text-xs font-semibold`,children:[(0,p.jsx)(un,{selected:v===`edit`,onPress:()=>b(`edit`),children:`Edit`}),(0,p.jsx)(un,{selected:v===`preview`,onPress:()=>b(`preview`),children:`Preview`})]})]})]}),v===`preview`?(0,p.jsx)(`div`,{className:`min-h-0 flex-1`,children:(0,p.jsx)(ke,{preset:x})}):(0,p.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-x-hidden overflow-y-auto`,children:[(0,p.jsx)(dn,{annotationPage:f,compact:u,editorMaxWidth:O,fallbackText:e.items[0]?.text,heading:`Short summary`,panelClassName:(0,y.twMerge)(`border-b border-gray-100`,u?`p-3`:`p-5`,a&&(s||c)?`max-w-xl`:``,a&&o?`max-w-4xl`:``),parentProperty:`items`,selectedLanguage:E,onLanguageAdded:D}),(0,p.jsx)(dn,{annotationPage:h,compact:u,heading:`Long summary`,panelClassName:(0,y.twMerge)(u?`p-3`:`p-5`),parentProperty:`annotations`,selectedLanguage:E,onLanguageAdded:D})]})]})}function un({children:e,selected:t,onPress:n}){return(0,p.jsx)(v.Button,{className:(0,y.twMerge)(`px-3 py-2 text-xs font-semibold transition`,t?`bg-white text-slate-900 shadow-sm`:`text-slate-500 hover:text-slate-700`),onPress:n,children:e})}function dn({annotationPage:e,compact:t,editorMaxWidth:n,fallbackText:r,heading:i,panelClassName:a,parentProperty:o,selectedLanguage:s,onLanguageAdded:c}){let u=(0,d.useCanvas)(),f=(0,l.useInlineCreator)(),g=(0,d.useVault)(),{i18n:{defaultLanguage:_}}=(0,l.useConfig)(),v=e||null,b=v?.items||[],x=mn(b,g),S=()=>{u&&f.create(`@manifest-editor/empty-annotation-page`,{label:{en:[i]}},{target:{id:u.id,type:`Canvas`},targetType:`AnnotationPage`,parent:{property:o,resource:{id:u.id,type:`Canvas`}}})},C=()=>{if(u){if(!v){S();return}f.create(`@manifest-editor/html-annotation`,{label:{en:[i]},body:{[s||_||`en`]:[``]},motivation:o===`annotations`?`tagging`:`painting`},{target:{id:u.id,type:`Canvas`},targetType:`Annotation`,parent:{property:`items`,resource:{id:v.id,type:`AnnotationPage`}},initialData:{}})}},w=()=>{if(!v){C(),c(s);return}let e=!1;for(let t of b){let n=Y(t,g);if(!n)continue;let r=bn(n.body);if(r.some(e=>Y(e,g)?.language===s))continue;let i=r[0],a=i?Y(i,g):null,o=`${n.id}-body-${s}-${Date.now()}`;g.batch(()=>{g.dispatch({type:`entities/update`,payload:{type:`ContentResource`,id:o,language:s,value:``,format:a?.format||`text/html`,motivation:a?.motivation}}),g.modifyEntityField({id:n.id,type:`Annotation`},`body`,[...r,{id:o,type:`ContentResource`}])}),e=!0}e||C(),c(s)},T=(0,m.useMemo)(()=>{if(!v)return!1;for(let e of b){let t=Y(e,g);if(!t)continue;let n=bn(t.body);for(let e of n)if(Y(e,g)?.language===s)return!0}return!1},[v,b,g,s]);return(0,p.jsxs)(`section`,{className:(0,y.twMerge)(`min-w-0 max-w-full`,a),children:[(0,p.jsxs)(`div`,{className:(0,y.twMerge)(`flex items-center justify-between gap-3`,x.length?`mb-3`:`mb-0`),children:[(0,p.jsx)(`h2`,{className:(0,y.twMerge)(`font-semibold tracking-tight text-gray-700`,t?`text-xs uppercase`:`text-sm uppercase tracking-wide`),children:i}),!T&&(0,p.jsx)(h.ActionButton,{primary:!0,onPress:w,children:v?`Add text`:`Add`})]}),!v&&r?(0,p.jsx)(`div`,{className:`mt-2 text-sm text-gray-600`,children:(0,p.jsx)(d.LocaleString,{enableDangerouslySetInnerHTML:!0,children:r})}):null,x.length?(0,p.jsx)(`div`,{className:`min-w-0 max-w-full`,children:x.map(({item:e,index:r})=>(0,p.jsx)(d.AnnotationContext,{annotation:e.id,children:(0,p.jsx)(fn,{compact:t,editorMaxWidth:n,pageItems:b,pageRef:{id:v.id,type:`AnnotationPage`},selectedLanguage:s,onRemoveAnnotation:()=>{g.modifyEntityField({id:v.id,type:`AnnotationPage`},`items`,b.filter((e,t)=>t!==r))}})},e.id+r))}):v&&T?(0,p.jsx)(`div`,{className:(0,y.twMerge)(`mt-2 text-sm text-gray-400 italic`,``),children:`No text added yet.`}):null]})}function fn({compact:e,editorMaxWidth:t,onRemoveAnnotation:n,pageItems:r,pageRef:i,selectedLanguage:a}){let o=(0,d.useAnnotation)(),s=(0,d.useVault)(),c=o?.body||[],u=(0,l.useGenericEditor)(o);if(!o)return null;let f=c.map((e,t)=>({item:e,index:t})).filter(({item:e})=>Y(e,s)?.language===a),h=f.length>0?f:[],g=(0,m.useCallback)(e=>{let t=gn(c,s,e);t.length!==c.length&&s.modifyEntityField({id:o.id,type:`Annotation`},`body`,t);let n=hn(r,s,o.id);n.length!==r.length&&s.modifyEntityField(i,`items`,n)},[o.id,i.id,r,s]);return h.length?(0,p.jsx)(`div`,{className:`min-w-0 max-w-full overflow-hidden`,children:h.map(({item:n,index:r})=>(0,p.jsx)(pn,{resourceId:n.id,onRemove:()=>u.annotation.body.deleteAtIndex(r),onUpdate:()=>g(n.id),compact:e,editorMaxWidth:t},n.id||r))}):null}function pn({compact:e,editorMaxWidth:t,resourceId:n,onRemove:r,onUpdate:i}){let a=(0,l.useGenericEditor)((0,m.useMemo)(()=>({id:n,type:`ContentResource`}),[n])),{i18n:{advancedLanguageMode:o,availableLanguages:s,defaultLanguage:c}}=(0,l.useConfig)(),{language:d,value:f}=a.descriptive,h=d.get(),g=Array.isArray(h)?h[0]||c||`en`:h||c||`en`;return(0,m.useEffect)(()=>{let e=Array.isArray(d.get())?d.get()[0]:d.get();!o&&e!==g&&d.set(g)},[o,g]),(0,p.jsx)(`div`,{className:`min-w-0 max-w-full overflow-hidden`,style:t?{maxWidth:t}:void 0,children:(0,p.jsx)(u.TiptapRichTextLanguageField,{language:g,languages:s,value:f.get()||``,onUpdate:e=>{f.set(e),i()},onUpdateLanguage:o?e=>d.set(e):void 0,onRemove:o?r:void 0})})}function mn(e,t){let n=e.map((e,t)=>({item:e,index:t})),r=n.filter(({item:e})=>!_n(e,t));return r.length?r:n.slice(0,1)}function hn(e,t,n){let r=e.filter(e=>e?.id===n||!_n(e,t));return r.length?r:e.slice(0,1)}function gn(e,t,n){let r=e.filter(e=>e?.id===n||!vn(e,t));return r.length?r:e.slice(0,1)}function _n(e,t){let n=bn(Y(e,t)?.body);return n.length?n.every(e=>vn(e,t)):!0}function vn(e,t){let n=Y(e,t);return n?yn(n.value||``):!0}function yn(e){let t=String(e||``);return/<img\b/i.test(t)?!1:t.replace(/<[^>]*>/g,``).replace(/&nbsp;/gi,` `).replace(/\s+/g,``).trim()===``}function Y(e,t){return!e?.id||e.value||e.items||e.body?e:t.get(e,{skipSelfReturn:!1})||e}function bn(e){return Array.isArray(e)?e:e==null?[]:[e]}const xn={id:`youtube-main-editor`,label:`YouTube main editor`,component:e=>e.type===`media`?(0,p.jsx)(Sn,{strategy:e,video:e.media}):null,supports:{strategy:(e,t,n)=>(console.log(e),!(e.type!==`media`||e.media.type!==`VideoYouTube`))}};function Sn({strategy:e,video:t}){let{edit:n}=(0,l.useLayoutActions)(),r=(0,d.useCanvas)(),i=(0,d.useVaultSelector)((e,t)=>t.get(r?.items[0]).items[0]);(0,T.default)(r&&i);let a=(0,m.useRef)(null),o=(0,l.useGenericEditor)(i),s=t,c=(r.width||1)/(r.height||1);return`${s.youTubeId}`,(0,p.jsxs)(`div`,{className:`overflow-y-auto`,children:[(0,p.jsx)(`div`,{className:`p-8`,children:(0,p.jsx)(`div`,{className:`bg-black z-20 flex p-8 rounded-lg max-w-full max-h-[70vh] mx-auto`,style:{aspectRatio:c},children:(0,p.jsx)(`iframe`,{title:`YouTube video`,className:`border-none w-full h-full object-contain`,ref:a,src:`https://www.youtube.com/embed/${s.youTubeId}?enablejsapi=1&origin=${window.location.host}&modestbranding=1&rel=0`,referrerPolicy:`no-referrer compute-pressure`,sandbox:`allow-scripts allow-same-origin allow-presentation`})})}),(0,p.jsxs)(`div`,{className:`bg-white shadow w-full p-8 flex gap-8`,children:[(0,p.jsx)(`div`,{children:(0,p.jsx)(`div`,{className:`w-64 bg-black flex-shrink-0 flex items-center justify-center rounded overflow-clip`,style:{aspectRatio:c},children:r.thumbnail?.length?(0,p.jsx)(h.LazyThumbnail,{cover:!0}):(0,p.jsx)(`div`,{className:`text-white/50 text-center py-16`,children:`No thumbnail`})})}),(0,p.jsxs)(`div`,{className:`flex-1`,children:[(0,p.jsx)(d.LocaleString,{as:`h3`,className:`text-2xl font-bold mt-4`,defaultText:(0,p.jsx)(`span`,{className:`text-black/30`,children:`No Label`}),children:o.descriptive.label.get()}),(0,p.jsx)(d.LocaleString,{as:`p`,className:`mt-2 mb-8`,defaultText:(0,p.jsx)(`span`,{className:`text-black/30`,children:`No summary`}),children:o.descriptive.summary.get()}),(0,p.jsx)(h.ActionButton,{onPress:()=>n(o.ref()),children:`Edit properties`})]})]})]})}const Cn=(0,E.defineCreator)({...D.iiifBrowserCreator,id:`@exhibitions/browser-creator`,create:wn,tags:[`image`,`exhibition-slide`],label:`IIIF Browser`,summary:`Browse IIIF Resources`,resourceType:`Canvas`,resourceFields:[`id`,`language`,`type`,`format`,`value`],additionalTypes:[],supports:{onlyPainting:!0,parentTypes:[`Manifest`],parentFields:[`items`],parentFieldMap:{Manifest:[`items`]}}});async function wn(e,t){let n=t.generateId(`canvas`),r=t.generateId(`annotation-page`,{id:n,type:`Canvas`}),i={width:0,height:0},a=await(0,E.creatorHelper)(t,{id:r,type:`AnnotationPage`},`items`,`@manifest-editor/iiif-browser-creator`)({...e,trackSize({width:e,height:t}){i.height=t,i.width=e}},{targetType:`Annotation`,target:{id:n,type:`Canvas`}});return await(0,E.creatorHelper)(t,`Manifest`,`items`,`@exhibitions/image-slide-creator`)({canvasId:n,width:i.width,height:i.height,type:`default`,items:a})}const Tn=(0,E.defineCreator)({...D.imageServiceCreator,id:`@exhibitions/image-service-creator`,create:En,tags:[`image`,`exhibition-slide`],label:`IIIF Image`,summary:`IIIF Image service`,resourceType:`Canvas`,supports:{parentTypes:[`Manifest`],parentFields:[`items`]}});async function En(e,t){let n=t.generateId(`canvas`);t.generateId(`annotation-page`,{id:n,type:`Canvas`});let r=await(0,E.creatorHelper)(t,{id:t.generateId(`annotation`),type:`Annotation`},`body`,`@manifest-editor/image-service-creator`)(e,{target:{id:n,type:`Canvas`}}),{width:i,height:a}=r.get(),o=t.embed({id:t.generateId(`annotation`),type:`Annotation`,motivation:`painting`,body:[r],target:{type:`SpecificResource`,source:{id:n,type:`Canvas`}}});return await(0,E.creatorHelper)(t,`Manifest`,`items`,`@exhibitions/image-slide-creator`)({canvasId:n,width:i,height:a,type:`default`,items:[o]})}const X=(0,E.defineCreator)({id:`@exhibitions/image-slide-creator`,create:Nn,label:`Empty slide`,summary:`An empty image slide.`,icon:(0,p.jsx)(h.EmptyCanvasIcon,{}),tags:[`exhibition-slide`],resourceType:`Canvas`,resourceFields:[`id`,`type`,`label`,`height`,`width`,`items`],supports:{parentTypes:[`Manifest`],parentFields:[`items`]}}),Dn=(0,E.defineCreator)({...X,id:`@exhibitions/image-slide-creator-left`,label:`Image (Left)`,summary:`An image with text on the left.`,icon:(0,p.jsx)(`div`,{children:`IMAGE (LEFT)`}),create:(e,t)=>Nn({...e,type:`left`},t)}),On=(0,E.defineCreator)({...X,id:`@exhibitions/image-slide-creator-right`,label:`Image (Right)`,summary:`An image with text on the right.`,icon:(0,p.jsx)(`div`,{children:`IMAGE (RIGHT)`}),create:(e,t)=>Nn({...e,type:`right`},t)}),kn=(0,E.defineCreator)({...X,id:`@exhibitions/image-slide-creator-bottom`,label:`Image (Bottom)`,summary:`An image with text at the bottom.`,icon:(0,p.jsx)(`div`,{children:`IMAGE (BOTTOM)`}),create:(e,t)=>Nn({...e,type:`bottom`},t)}),An=(0,E.defineCreator)({...X,id:`@exhibitions/slideshow-image-only-creator`,label:`Image only`,summary:`A slideshow slide focused on an image.`,tags:[`exhibition-slideshow-slide`],create:(e,t)=>Nn({...e,behavior:[`w-12`,`h-8`,`image`],height:e.height||1080,width:e.width||1920,type:`default`},t)}),jn=(0,E.defineCreator)({...X,id:`@exhibitions/slideshow-image-text-creator`,label:`Image with text`,summary:`A slideshow slide with image and text.`,tags:[`exhibition-slideshow-slide`],create:(e,t)=>Nn({...e,behavior:[`w-12`,`h-8`,`right`],height:e.height||1080,width:e.width||1920,type:`right`},t)}),Mn=(0,E.defineCreator)({...X,id:`@exhibitions/scroll-compact-deck-creator`,label:`Compact image deck`,summary:`A scrolling section with compact annotation-led image slides.`,tags:[`exhibition-scroll-section`,`exhibition-slide`],create:(e,t)=>Nn({...e,behavior:[`w-12`,`h-8`,`compact-deck`],height:e.height||1080,width:e.width||1920,type:`default`},t)});function Nn(e,t){let n=e.canvasId||t.generateId(`Canvas`),r=t.generateId(`AnnotationPage`,{id:n,type:`Canvas`}),i=t.generateId(`AnnotationPage`,{id:n,type:`Canvas`}),a=[],o=6e3;if(e.behavior)a.push(...e.behavior);else if(e.width&&e.height){let t=e.type??`default`,n=t===`left`||t===`right`,r=t===`bottom`,i=e.width/e.height,o=n?12*(2/3):12,s=r?3/2:1,c=Math.max(1,Math.min(12,Math.round(o/i*s)));a.push(`w-12`,`h-${c}`)}else a.push(`w-12`,`h-4`);if(!e.behavior)switch(e.type){case`left`:a.push(`left`),o*=2/3;break;case`right`:a.push(`right`),o*=2/3;break;case`bottom`:a.push(`bottom`);break}return e.items?.length||a.push(`multi-image`),t.embed({...O.emptyCanvas,id:n,behavior:a,label:e.label||{en:[`Untitled`]},height:e.height||4e3,duration:e.duration,width:e.width||o,items:[t.embed({...O.emptyAnnotationPage,id:r,type:`AnnotationPage`,items:e.items?e.items:[]})],annotations:[t.embed({...O.emptyAnnotationPage,id:i,type:`AnnotationPage`,items:[]})]})}const Pn=(0,E.defineCreator)({...D.imageUrlCreator,id:`@exhibitions/image-url-creator`,create:Fn,tags:[`exhibition-slide`],label:`Image`,summary:`Image from URL`,resourceType:`Canvas`,supports:{parentTypes:[`Manifest`],parentFields:[`items`]}});async function Fn(e,t){let n=t.generateId(`canvas`);t.generateId(`annotation-page`,{id:n,type:`Canvas`});let r=t.generateId(`annotation`),i=await(0,E.creatorHelper)(t,{id:r,type:`Annotation`},`body`,`@manifest-editor/image-url-creator`)(e,{target:{id:n,type:`Canvas`},targetType:`Annotation`}),{width:a,height:o}=i.get(),s=t.embed({id:r,type:`Annotation`,motivation:`painting`,body:[i],target:{type:`SpecificResource`,source:{id:n,type:`Canvas`}}});return await(0,E.creatorHelper)(t,`Manifest`,`items`,`@exhibitions/image-slide-creator`)({canvasId:n,width:a,height:o,type:`default`,items:[s]})}const In=(0,E.defineCreator)({id:`@exhibitions/info-box-creator`,create:Rn,label:`Info box`,summary:`A text panel for an exhibition`,icon:(0,p.jsxs)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,width:`1em`,height:`1em`,viewBox:`0 0 24 24`,children:[(0,p.jsx)(`title`,{children:`Info box`}),(0,p.jsx)(`path`,{fill:`currentColor`,d:`M11 17h2v-6h-2zm1-8q.425 0 .713-.288T13 8t-.288-.712T12 7t-.712.288T11 8t.288.713T12 9m0 13q-2.075 0-3.9-.788t-3.175-2.137T2.788 15.9T2 12t.788-3.9t2.137-3.175T8.1 2.788T12 2t3.9.788t3.175 2.137T21.213 8.1T22 12t-.788 3.9t-2.137 3.175t-3.175 2.138T12 22`})]}),tags:[`exhibition-slide`],resourceType:`Canvas`,resourceFields:[`id`,`type`,`label`,`height`,`width`,`items`],supports:{parentTypes:[`Manifest`],parentFields:[`items`]}}),Ln=(0,E.defineCreator)({...In,id:`@exhibitions/slideshow-long-editorial-creator`,label:`Long editorial`,summary:`A text-led slideshow slide.`,tags:[`exhibition-slideshow-slide`],create:(e,t)=>Rn({...e,behavior:[`w-12`,`h-8`,`info`],height:e.height||1080,width:e.width||1920},t)});async function Rn(e,t){let n=t.generateId(`canvas`),r=t.generateId(`annotation-page`,{id:n,type:`Canvas`}),i=t.generateId(`annotation-page`,{id:n,type:`Canvas`}),a={...O.emptyAnnotation,id:t.generateId(`annotation`,{id:n,type:`Canvas`}),type:`Annotation`},o=[await t.create(`@manifest-editor/html-body-creator`,{language:`en`,body:``},{parent:{resource:a,property:`body`}})],s=t.embed({...a,motivation:`painting`,body:o,target:{type:`SpecificResource`,source:{id:n,type:`Canvas`}}}),c=t.generateId(`annotation`,{id:n,type:`Canvas`}),l=t.embed({id:c,type:`Annotation`,motivation:`tagging`,body:[await t.create(`@manifest-editor/html-body-creator`,{language:`en`,body:``},{parent:{resource:{id:c,type:`Annotation`},property:`body`}})],target:{type:`SpecificResource`,source:{id:n,type:`Canvas`}}}),u=t.embed({id:r,type:`AnnotationPage`,items:[s]}),d=t.embed({id:i,type:`AnnotationPage`,items:[l]});return t.embed({...O.emptyCanvas,id:n,type:`Canvas`,behavior:e.behavior||[`w-4`,`h-4`,`info`],label:e.label||void 0,height:e.height||1e3,width:e.width||1e3,items:[u],annotations:[d]})}const zn=(0,E.defineCreator)({...D.videoAnnotation,id:`@exhibitions/video-creator`,create:Vn,tags:[`video`,`exhibition-slide`],label:`Video`,summary:`A video for an exhibition`,resourceType:`Canvas`,resourceFields:[`id`,`type`,`label`,`height`,`width`,`items`],supports:{parentTypes:[`Manifest`],parentFields:[`items`]}}),Bn=(0,E.defineCreator)({...zn,id:`@exhibitions/slideshow-video-creator`,label:`Video`,summary:`A video slide for a slideshow exhibition.`,tags:[`exhibition-slideshow-slide`],create:(e,t)=>Vn({...e,behavior:[`w-12`,`h-8`,`image`],height:e.height||1080,slideType:`default`,width:e.width||1920},t)});async function Vn(e,t){let n=t.generateId(`canvas`),r=t.generateId(`annotation-page`,{id:n,type:`Canvas`}),i=await t.create(`@manifest-editor/video-annotation`,e,{target:{id:n,type:`Canvas`},targetType:`Annotation`,parent:{resource:{id:r,type:`AnnotationPage`},property:`items`}});return t.embed({id:r,type:`AnnotationPage`,items:[i]}),await(0,E.creatorHelper)(t,`Manifest`,`items`,`@exhibitions/image-slide-creator`)({canvasId:n,behavior:e.behavior,height:e.height||1080,width:e.width||1920,duration:e.duration,type:e.slideType||`bottom`,items:[i]})}const Hn=(0,E.defineCreator)({...D.youTubeBodyCreator,id:`@exhibitions/youtube-creator`,create:Wn,tags:[`video`,`exhibition-slide`],label:`YouTube`,summary:`A YouTube for an exhibition`}),Un=(0,E.defineCreator)({...Hn,id:`@exhibitions/slideshow-youtube-creator`,label:`YouTube`,summary:`A YouTube slide for a slideshow exhibition.`,tags:[`exhibition-slideshow-slide`]});async function Wn(e,t){let n=(0,u.getYouTubeId)(e.youtubeUrl),r=t.generateId(`canvas`),i=t.generateId(`annotation-page`,{id:r,type:`Canvas`}),a=await t.create(`@manifest-editor/youtube`,e,{target:{id:r,type:`Canvas`},targetType:`Annotation`,parent:{resource:{id:i,type:`AnnotationPage`},property:`items`}}),o=t.embed({id:i,type:`AnnotationPage`,items:[a]}),s=t.embed({id:`https://img.youtube.com/vi/${n}/maxresdefault.jpg`,type:`Image`,format:`image/jpeg`,width:640,height:360});return t.embed({...O.emptyCanvas,id:r,type:`Canvas`,behavior:[`w-12`,`h-8`],label:e.label||{en:[`Untitled YouTube Video`]},height:e.height||1080,width:e.width||1920,thumbnail:[s],items:[o]})}function Gn(){let e=(0,l.useEditor)(),t=()=>{let t=e.technical.width.get(),n=e.technical.height.get(),r=e.descriptive.summary,i=e.technical.behavior.get();i.push(`w-12`);let a=Math.max(1,Math.min(12,Math.round(t/n*12)));i.push(`h-${a}`),(0,k.getValue)(r.get())||r.set({en:[`Summary of image`]}),e.technical.behavior.set(i)};return(0,p.jsxs)(`div`,{className:`flex flex-col items-center gap-4 border-me-100 border-2 p-4 rounded`,children:[`This canvas was not created in the exhibition editor. Do you want to apply default settings?`,(0,p.jsx)(h.ActionButton,{onPress:()=>t(),children:`Apply defaults`})]})}function Kn(){let e=(0,d.useCanvas)();(0,T.default)(e);let t=e.width&&e.height?e.width/e.height:0,n=Ge(e.behavior||[]);return Math.abs(t-n.ratio)<.01?null:(0,p.jsxs)(`div`,{className:`exhibition-aspect-warning p-2 rounded bg-me-100`,children:[(0,p.jsx)(`div`,{className:`font-semibold text-me-700`,children:`Aspect ratio warning`}),(0,p.jsxs)(`div`,{className:`text-sm text-black/60`,children:[`The aspect ratio of this canvas is `,t.toFixed(2),` but the target aspect ratio is `,n.ratio.toFixed(2),`. Some parts of this image may be cropped.`,(0,p.jsx)(`div`,{className:`relative h-32 w-full mt-2`,children:(0,p.jsx)(`div`,{className:`bg-[red] left-0 top-0 z-2 opacity-50 max-w-32 max-h-32`,style:{aspectRatio:t.toFixed(2)},children:(0,p.jsx)(`div`,{className:`asbolute bg-[white] left-0 top-0 z-1 opacity-50 max-w-32 max-h-32`,style:{aspectRatio:n.ratio}})})})]})]})}function qn(){let e=(0,d.useCanvas)(),t=(0,l.useEditingResource)(),n=(0,l.useInlineCreator)(),[r,i]=(0,l.useCreator)(t?.resource.source,`thumbnail`,`ContentResource`),{descriptive:a}=(0,l.useEditor)(),{thumbnail:o}=a,s=o.get()||[],c=(0,d.useVault)(),f=(0,m.useMemo)(()=>e?Xn(c,e):[],[e,c]);return!e||!t?null:!s.length&&f.length?(0,p.jsx)(Jn,{candidates:f,canCreateThumbnail:r,onCreateThumbnail:()=>i.create(),onAddThumbnail:({service:t,width:r,height:i})=>n.create(`@manifest-editor/thumbnail-image`,{service:t,width:r,height:i},Yn(e))}):(0,p.jsx)(u.LinkingPropertyList,{containerId:o.containerId(),label:`Thumbnail`,property:`thumbnail`,items:s,singleMode:!0,reorder:e=>o.reorder(e.startIndex,e.endIndex),createActions:(0,u.createAppActions)(o),creationType:`ContentResource`,emptyLabel:`No thumbnail`,parent:t.resource})}function Jn({candidates:e,canCreateThumbnail:t,onCreateThumbnail:n,onAddThumbnail:r}){let[i,a]=(0,m.useState)(null),[o,s]=(0,m.useState)(``),[c,l]=(0,m.useState)({}),d=e.find(e=>e.id===i)||e[0],f=d?c[d.id]:void 0,g=d?f===null?null:f||d.service:null,_=g?nr(g):[],v=ir(_,350),y=_.find(e=>rr(e)===o)||v,b=g&&y?ar(g,y):null,x=d&&!d.service.sizes?.length&&!(d.id in c);return(0,m.useEffect)(()=>{!i&&e[0]&&a(e[0].id)},[e,i]),(0,m.useEffect)(()=>{let t=e.filter(e=>{let t=e.service;return!t.sizes?.length&&er(t)&&!(e.id in c)});for(let e of t){let t=er(e.service);t&&fetch(tr(t)).then(e=>e.ok?e.json():null).then(t=>{l(n=>({...n,[e.id]:t?{...e.service,...t}:null}))}).catch(()=>{l(t=>({...t,[e.id]:null}))})}},[e,c]),(0,m.useEffect)(()=>{v&&!_.some(e=>rr(e)===o)&&s(rr(v))},[v,o,_]),(0,p.jsx)(u.InputContainer,{$wide:!0,children:(0,p.jsxs)(`div`,{className:`rounded-md border border-[#dcd5ce] bg-[#f8f6f3] p-4`,children:[(0,p.jsx)(`div`,{className:`text-sm font-semibold text-[#25211f]`,children:`Thumbnail`}),(0,p.jsx)(`div`,{className:`mt-1 text-sm text-[#6a625c]`,children:`Use an image service from this canvas to add a thumbnail.`}),e.length>1?(0,p.jsxs)(`div`,{className:`mt-3`,children:[(0,p.jsx)(`label`,{className:`text-xs font-semibold uppercase text-[#6a625c]`,htmlFor:`thumbnail-source-image`,children:`Image`}),(0,p.jsx)(`select`,{id:`thumbnail-source-image`,className:`mt-1 w-full rounded-md border border-[#dcd5ce] bg-white px-3 py-2 text-sm`,value:d?.id||``,onChange:e=>{a(e.currentTarget.value),s(``)},children:e.map(e=>(0,p.jsx)(`option`,{value:e.id,children:e.label},e.id))})]}):null,_.length?(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(`div`,{className:`mt-3 flex flex-wrap gap-2`,children:_.map(e=>{let t=rr(e),n=y?t===rr(y):!1;return(0,p.jsxs)(`button`,{type:`button`,className:`rounded-md border px-2 py-1 text-xs font-semibold`,style:{backgroundColor:n?`#b84c74`:`#ffffff`,borderColor:n?`#b84c74`:`#dcd5ce`,color:n?`#ffffff`:`#332f2c`},onClick:()=>s(t),children:[e.width,`x`,e.height]},t)})}),b?(0,p.jsx)(`div`,{className:`mt-3 overflow-hidden rounded-md border border-[#dcd5ce] bg-white`,children:(0,p.jsx)(`img`,{src:b,alt:``,className:`max-h-40 w-full object-contain`})}):null,(0,p.jsx)(`button`,{type:`button`,className:`mt-3 rounded-md px-3 py-2 text-sm font-semibold shadow-sm`,style:{backgroundColor:`#b84c74`,border:`1px solid #a13e63`,color:`#ffffff`},disabled:!b||!y,onClick:()=>{!g||!y||r({service:g,width:y.width,height:y.height})},children:`Add thumbnail from image`})]}):x?(0,p.jsx)(`div`,{className:`mt-3 text-sm text-[#6a625c]`,children:`Finding available sizes...`}):(0,p.jsx)(`div`,{className:`mt-3 text-sm text-[#6a625c]`,children:`No fixed thumbnail sizes were found for this image service.`}),t?(0,p.jsx)(`div`,{className:`mt-4 border-t border-[#dcd5ce] pt-3`,children:(0,p.jsxs)(h.ActionButton,{onPress:n,children:[(0,p.jsx)(h.AddIcon,{}),` Create thumbnail`]})}):null]})})}function Yn(e){return{parent:{property:`thumbnail`,resource:{id:e.id,type:`Canvas`}}}}function Xn(e,t){let n=[],r=new Set;return G(e,t).forEach((t,i)=>{Zn(e,ut(e,t)).forEach((e,a)=>{let o=$n(e),s=o?er(o):``;!o||!s||r.has(s)||(r.add(s),n.push({id:`${t.id||i}-${e.id||s}-${a}`,label:or(e.label)||or(t.label)||`Image ${n.length+1}`,imageId:e.id,service:o}))})}),n}function Zn(e,t){let n=Qn(e,t);return n?n.type===`Choice`&&Array.isArray(n.items)?n.items.flatMap(t=>Zn(e,t)):n.type===`SpecificResource`?Zn(e,n.source):n.type===`Canvas`?G(e,n).flatMap(t=>Zn(e,ut(e,t))):$n(n)?[n]:[]:[]}function Qn(e,t){return t?t.id&&!t.service&&!t.items&&!t.value&&e.get(t,{skipSelfReturn:!1})||t:null}function $n(e){return(Array.isArray(e?.service)?e.service:e?.service?[e.service]:[]).find(e=>{let t=Array.isArray(e.profile)?e.profile.join(` `):e.profile||``;return(e.type||e[`@type`]||``).includes(`ImageService`)||t.includes(`level`)||t.includes(`iiif.io/api/image`)})||null}function er(e){return(e.id||e[`@id`]||``).replace(/\/info\.json$/,``)}function tr(e){return e.endsWith(`/info.json`)?e:`${e.replace(/\/$/,``)}/info.json`}function nr(e){let t=Array.isArray(e.sizes)?e.sizes.filter(e=>Number(e.width)&&Number(e.height)).map(e=>({width:Number(e.width),height:Number(e.height)})):[];if(t.length)return t.sort((e,t)=>e.width-t.width).slice(0,8);let n=Number(e.width),r=Number(e.height);return!n||!r?[]:[256,512,1024].filter(e=>e<n).map(e=>({width:e,height:Math.round(r/n*e)})).concat([{width:n,height:r}]).slice(0,4)}function rr(e){return`${e.width},${e.height||``}`}function ir(e,t){return e.reduce((e,n)=>e?Math.hypot(n.width-t,n.height-t)<Math.hypot(e.width-t,e.height-t)?n:e:n,void 0)}function ar(e,t){let n={...e};n[`@id`]&&(n.id=n[`@id`]),n[`@type`]&&(n.type=n[`@type`]);let r=(0,A.createImageServiceRequest)(n);return(0,A.imageServiceRequestToString)({identifier:r.identifier,server:r.server,scheme:r.scheme,type:`image`,size:{max:!1,confined:!1,upscaled:!1,width:t.width,height:t.height},format:`jpg`,region:{full:!0},rotation:{angle:0},quality:`default`,prefix:r.prefix,originalPath:r.originalPath})}function or(e){return e?typeof e==`string`?e:Array.isArray(e)?e.filter(Boolean).join(` `):typeof e==`object`?Object.values(e).flatMap(e=>Array.isArray(e)?e:[e]).filter(e=>typeof e==`string`).join(` `):``:``}const sr=new Set([`left`,`right`,`bottom`,`top`,`image`]),cr=[{value:`image`,label:`Image only`},{value:`right`,label:`Image + text right`},{value:`left`,label:`Image + text left`},{value:`bottom`,label:`Image + text bottom`}],Z={primary:`var(--exhibition-primary, #b84c74)`,fieldBorder:`var(--exhibition-field-border, #dcd5ce)`,fieldBackground:`var(--exhibition-field-bg, #f8f6f3)`,text:`var(--exhibition-text, #25211f)`,muted:`var(--exhibition-muted, #6a625c)`,buttonBackground:`var(--exhibition-button-bg, #ffffff)`,buttonText:`var(--exhibition-button-text, #ffffff)`,inactiveButtonText:`var(--exhibition-inactive-button-text, #332f2c)`},lr=[{value:12,label:`Full width`},{value:8,label:`2/3 width`},{value:6,label:`Half width`},{value:4,label:`1/3 width`}],ur=new Set([`float-top-left`,`float-top-right`,`float-bottom-left`,`float-bottom-right`]),dr=`exhibition-layout-panel-mode`,fr={component:()=>(0,p.jsx)(_r,{}),supports:{edit:!0,resourceTypes:[`Canvas`],properties:[`behavior`],custom:({resource:e},t)=>H(e,t)?!Je(e,t):!1},id:`slide-behaviors`,label:`Layout`,tabs:{showTitle:!0}},pr=[{id:`layout`,type:`choice`,label:{en:[`Layout`]},initialOpen:!0,items:[{label:{en:[`Text on left`]},value:`left`},{label:{en:[`Text on right`]},value:`right`},{label:{en:[`Text on bottom`]},value:`bottom`},{label:{en:[`Text on top`]},value:`top`},{label:{en:[`Only image`]},value:`image`}]},{id:`floating`,type:`choice`,label:{en:[`Floating`]},initialOpen:!1,addNone:!0,groupBehavior:`floating`,items:[{label:{en:[`Float top left`]},value:`float-top-left`},{label:{en:[`Float top right`]},value:`float-top-right`},{label:{en:[`Float bottom left`]},value:`float-bottom-left`},{label:{en:[`Float bottom right`]},value:`float-bottom-right`}]},{id:`size`,component:(e,t)=>(0,p.jsx)(gr,{behaviors:e,setBehaviors:t}),label:{en:[`Size`]},type:`custom`,initialOpen:!0,supports:e=>e.startsWith(`w-`)||e.startsWith(`h-`)}];function mr(e){let t=0,n=0;for(let r of e)r.startsWith(`w-`)&&(t=Number.parseInt(r.slice(2))),r.startsWith(`h-`)&&(n=Number.parseInt(r.slice(2)));return{width:t,height:n}}function hr(e){return e.filter(e=>!sr.has(e)&&!e.startsWith(`w-`)&&!e.startsWith(`h-`)&&!ur.has(e)&&e!==`cover`)}function gr({behaviors:e,setBehaviors:t}){let{width:n,height:r}=mr(e),[i,a]=(0,m.useState)({x:-1,y:-1}),o=(n,r)=>{let i=e.filter(e=>!e.startsWith(`w-`)&&!e.startsWith(`h-`));i.push(`w-${n}`),i.push(`h-${r}`),t(i)};return(0,p.jsx)(`div`,{className:`grid grid-cols-12 grid-rows-12 gap-1`,onMouseLeave:()=>a({x:-1,y:-1}),children:Array.from({length:144},(e,t)=>{let s=t%12,c=Math.floor(t/12),l=i.x>=s&&i.y>=c,u=s<n&&c<r,d=l&&u,f=`bg-gray-200`;return l&&(f=`bg-me-200`),u&&(f=`bg-me-500`),d&&(f=`bg-me-400`),(0,p.jsx)(`div`,{className:`flex aspect-square rounded cursor-se-resize items-center justify-center ${f}`,onClick:()=>o(s+1,c+1),onMouseUp:()=>o(s+1,c+1),onMouseEnter:()=>a({x:s,y:c})},t)})})}function _r(){let[e,t]=(0,l.useLocalStorage)(`exhibition-layout-panel-mode`,`simple`);return(0,p.jsx)(h.Sidebar,{children:(0,p.jsxs)(h.SidebarContent,{className:`bg-white px-6 pt-5 pb-20`,children:[(0,p.jsx)(`div`,{className:`mb-6 flex justify-center`,children:(0,p.jsx)(Er,{value:e,onChange:t})}),(0,p.jsx)(vr,{mode:e})]})})}function vr({mode:e=`advanced`,layoutContext:t=`default`}){let n=(0,u.useInStack)(`Canvas`),r=(0,l.useEditor)(),{width:i,height:a}=r.technical;return!n||r.technical.type!==`Canvas`?(0,p.jsx)(`div`,{className:`p-4`,children:`Please select canvas`}):e===`simple`?(0,p.jsx)(yr,{behavior:r.technical.behavior.get()||[],layoutContext:t,canvasWidth:i.get()||0,canvasHeight:a.get()||0,onChange:e=>{r.technical.behavior.set(e)}}):(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(`div`,{className:`px-2`,children:(0,p.jsxs)(u.InputContainer,{$wide:!0,children:[(0,p.jsx)(u.DimensionsTriplet,{widthId:i.containerId(),width:i.get()||0,changeWidth:e=>i.set(e),heightId:a.containerId(),height:a.get()||0,changeHeight:e=>a.set(e)}),(0,p.jsx)(`div`,{children:(0,p.jsx)(Kn,{})})]})}),(0,p.jsx)(u.BehaviorEditor,{behavior:r.technical.behavior.get()||[],onChange:e=>{r.technical.behavior.set(e)},configs:pr}),(0,p.jsx)(qn,{})]})}function yr({behavior:e,layoutContext:t,canvasWidth:n,canvasHeight:r,onChange:i}){let[a,o]=(0,m.useState)(Or(e)),[s,c]=(0,m.useState)(t===`slideshow`?12:Ar(e)),[l,u]=(0,m.useState)(jr(e)),[f,h]=(0,m.useState)(e.includes(`cover`)),g=W(e=>e.requestTab),_=(0,d.useCanvas)(),v=(0,d.useVault)(),y=(0,d.useManifest)(),b=t===`slideshow`?12:s,x=Nr({canvasWidth:n,canvasHeight:r,layoutPreset:a,displayWidth:b}),S=t===`default`&&y?.items&&_?Ir(_.id,y.items,v):null,C=o=>{let c=o.layoutPreset??a;i(Mr({behavior:e,layoutPreset:c,displayWidth:t===`slideshow`?12:o.displayWidth??s,canvasWidth:n,canvasHeight:r,floating:o.floating??l,cover:o.cover??f})),_&&Rr(v,_,c)};return(0,p.jsxs)(`div`,{className:`flex flex-col gap-7`,children:[(0,p.jsx)(br,{layoutPreset:a,cover:f,floating:l,width:b,height:x,onTextClick:()=>g(`summary`)}),(0,p.jsxs)(Dr,{children:[(0,p.jsx)(Q,{children:`Layout preset`}),(0,p.jsx)(`div`,{className:`mt-3 grid grid-cols-2 gap-3`,children:cr.map(e=>(0,p.jsx)(xr,{preset:e.value,label:e.label,selected:a===e.value,onClick:()=>{o(e.value),C({layoutPreset:e.value})}},e.value))})]}),t===`default`?(0,p.jsxs)(Dr,{children:[(0,p.jsx)(Q,{children:`Width`}),(0,p.jsx)(`div`,{className:`mt-3 grid grid-cols-2 gap-3`,children:lr.map(e=>(0,p.jsx)(wr,{selected:s===e.value,onClick:()=>{c(e.value),C({displayWidth:e.value})},children:e.label},e.value))})]}):null,S?(0,p.jsxs)(Dr,{children:[(0,p.jsxs)(Q,{children:[`Fit alongside `,S.neighbour,` slide`]}),(0,p.jsx)(`div`,{className:`mt-3`,children:(0,p.jsxs)(wr,{selected:s===S.width,onClick:()=>{c(S.width),C({displayWidth:S.width})},children:[`w-`,S.width,` — fills remaining space`]})})]}):null,(0,p.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,p.jsx)(Tr,{checked:l,label:`Floating`,onChange:e=>{u(e),C({floating:e})}}),(0,p.jsx)(Tr,{checked:f,label:`Image cover`,onChange:e=>{h(e),C({cover:e})}})]})]})}function br({layoutPreset:e,cover:t,floating:n,width:r,height:i,onTextClick:a}){let o=e===`bottom`,s=e===`image`,c=e===`left`;return(0,p.jsxs)(`div`,{children:[(0,p.jsxs)(`div`,{className:`relative mx-auto overflow-hidden rounded-md border bg-[#f8f6f3] shadow-sm`,style:{width:`${Math.max(33,Math.round(r/12*100))}%`,aspectRatio:`${r} / ${i}`,borderColor:Z.fieldBorder},children:[(0,p.jsxs)(`div`,{className:(0,y.twMerge)(`flex h-full w-full min-h-0`,c?`flex-row-reverse`:o?`flex-col`:`flex-row`),children:[(0,p.jsx)(`div`,{className:`relative min-h-0 flex-1 overflow-hidden bg-white`,children:(0,p.jsx)(`div`,{className:`absolute inset-0`,children:(0,p.jsx)(h.LazyThumbnail,{cover:t,fade:!1})})}),s?null:(0,p.jsx)(`button`,{type:`button`,className:(0,y.twMerge)(`flex-shrink-0 border-0 bg-[#25211f] p-3 text-left text-white transition-colors hover:bg-[#332f2c] focus:outline-none focus:ring-2 focus:ring-me-primary-500 focus:ring-offset-2`,o?`h-1/3 w-full`:`h-full w-1/3`),onClick:a,children:(0,p.jsx)(Cr,{tone:`light`})})]}),n?(0,p.jsx)(`div`,{className:`absolute right-2 top-2 h-7 w-10 rounded bg-white/90 shadow ring-1 ring-black/10`}):null]}),(0,p.jsxs)(`div`,{className:`mt-2 text-center text-xs`,style:{color:Z.muted},children:[`w-`,r,` h-`,i]})]})}function xr({preset:e,label:t,selected:n,onClick:r}){return(0,p.jsxs)(`button`,{type:`button`,className:`flex min-h-[112px] flex-col items-center justify-center gap-3 rounded-md border px-3 py-4 text-center text-sm font-semibold transition-colors`,style:{backgroundColor:n?Z.primary:Z.buttonText,borderColor:n?Z.primary:Z.fieldBorder,color:n?Z.buttonText:Z.inactiveButtonText},onClick:r,children:[(0,p.jsx)(Sr,{preset:e,selected:n}),(0,p.jsx)(`span`,{className:`leading-tight`,children:t})]})}function Sr({preset:e,selected:t}){let n=e===`image`,r=e===`bottom`,i=e===`left`,a=t?`bg-white/80`:`bg-[#25211f]`,o=t?`bg-white/25 ring-white/70`:`bg-[#f8f6f3] ring-[#dcd5ce]`;return(0,p.jsxs)(`span`,{className:(0,y.twMerge)(`flex h-12 w-16 gap-1 overflow-hidden rounded border p-1`,t?`border-white/70 bg-white/15`:`border-[#dcd5ce] bg-white`,i?`flex-row-reverse`:r?`flex-col`:`flex-row`),"aria-hidden":`true`,children:[(0,p.jsx)(`span`,{className:(0,y.twMerge)(`flex-1 rounded-sm ring-1`,o)}),n?null:(0,p.jsx)(`span`,{className:(0,y.twMerge)(`flex flex-shrink-0 flex-col justify-center gap-0.5 rounded-sm px-0.5`,a,r?`h-3 w-full`:`h-full w-4`),children:(0,p.jsx)(Cr,{compact:!0,tone:t?`dark`:`light`})})]})}function Cr({compact:e=!1,tone:t=`light`}){let n=t===`light`?`bg-white/70`:`bg-[#8b3f61]/70`;return(0,p.jsxs)(`span`,{className:(0,y.twMerge)(`block space-y-1.5`,e?`space-y-0.5`:`mt-1`),"aria-hidden":`true`,children:[(0,p.jsx)(`span`,{className:(0,y.twMerge)(`block rounded`,n,e?`h-0.5 w-full`:`h-1.5 w-3/4`)}),(0,p.jsx)(`span`,{className:(0,y.twMerge)(`block rounded`,n,e?`h-0.5 w-4/5`:`h-1.5 w-full`)}),(0,p.jsx)(`span`,{className:(0,y.twMerge)(`block rounded`,n,e?`h-0.5 w-2/3`:`h-1.5 w-2/3`)})]})}function wr({selected:e,onClick:t,children:n}){return(0,p.jsx)(`button`,{type:`button`,className:`min-h-11 rounded-md border px-3 py-2 text-sm font-semibold transition-colors`,style:{backgroundColor:e?Z.primary:Z.buttonText,borderColor:e?Z.primary:Z.fieldBorder,color:e?Z.buttonText:Z.inactiveButtonText},onClick:t,children:n})}function Tr({checked:e,label:t,onChange:n}){return(0,p.jsxs)(`label`,{className:`flex items-center justify-between rounded-md border px-4 py-3 text-sm font-semibold`,style:{backgroundColor:Z.fieldBackground,borderColor:Z.fieldBorder,color:Z.text},children:[t,(0,p.jsx)(`input`,{type:`checkbox`,className:`h-4 w-4 accent-me-primary-500`,checked:e,onChange:e=>n(e.currentTarget.checked)})]})}function Er({value:e,onChange:t}){return(0,p.jsx)(`div`,{className:`grid w-full max-w-[240px] grid-cols-2 rounded-full bg-[#f5eaf0] p-1`,children:[`simple`,`advanced`].map(n=>{let r=e===n;return(0,p.jsx)(v.Button,{className:`border-none rounded-full bg-transparent px-4 py-2 text-sm font-semibold capitalize transition-colors`,style:{backgroundColor:r?Z.primary:`transparent`,color:r?`#ffffff`:`#8b3f61`,boxShadow:r?`0 1px 3px rgba(15, 23, 42, 0.18)`:`none`},onPress:()=>t(n),children:n},n)})})}function Dr({children:e}){return(0,p.jsx)(`div`,{children:e})}function Q({children:e}){return(0,p.jsx)(`div`,{className:`text-sm font-semibold`,style:{color:Z.muted},children:e})}function Or(e){return e.includes(`image`)?`image`:e.includes(`left`)?`left`:e.includes(`bottom`)?`bottom`:e.includes(`right`)?`right`:`image`}function kr(e,t,n){let r=e.filter(e=>!sr.has(e));if(n?.width&&n?.height){let{width:i}=mr(e),a=i?i<=4?4:i<=6?6:i<=8?8:12:12,o=Nr({canvasWidth:n.width,canvasHeight:n.height,layoutPreset:t,displayWidth:a}),s=r.filter(e=>!e.startsWith(`h-`));return s.push(`h-${o}`),s.push(t),s}return[...r,t]}function Ar(e){let{width:t}=mr(e);return t?t<=4?4:t<=6?6:t<=8?8:12:12}function jr(e){return e.some(e=>ur.has(e))}function Mr({behavior:e,layoutPreset:t,displayWidth:n,canvasWidth:r,canvasHeight:i,floating:a,cover:o}){let s=hr(e),c=Nr({canvasWidth:r,canvasHeight:i,layoutPreset:t,displayWidth:n});return s.push(t,`w-${n}`,`h-${c}`),a&&s.push(`float-top-right`),o&&s.push(`cover`),s}function Nr({canvasWidth:e,canvasHeight:t,layoutPreset:n,displayWidth:r}){let i=e&&t?e/t:1.5,a=n===`left`||n===`right`?r*(2/3):r,o=n===`bottom`?3/2:1,s=Math.round(a/i*o);return Math.max(1,Math.min(12,s))}const Pr=[{value:4,label:`1/3 width`},{value:6,label:`Half width`},{value:8,label:`2/3 width`},{value:12,label:`Full width`}];function Fr(e){let{width:t}=mr(e);return t}function Ir(e,t,n){let r=t.findIndex(t=>t.id===e);if(r===-1)return null;let i=e=>{if(!e)return 0;try{return Fr(n.get(e)?.behavior||[])}catch{return 0}},a=i(t[r-1]),o=i(t[r+1]);if(a>0&&a<12){let e=12-a;if(e>=4)return{width:e,neighbour:`previous`}}if(o>0&&o<12){let e=12-o;if(e>=4)return{width:e,neighbour:`next`}}return null}const Lr=new Set([`left`,`right`,`bottom`]);function Rr(e,t,n){Lr.has(n)&&((0,u.getInternationalStringText)(t.label)||e.modifyEntityField(t,`label`,{en:[`Untitled`]}),(0,u.getInternationalStringText)(t.summary)||e.modifyEntityField(t,`summary`,{en:[`Add a description for this slide.`]}))}const zr=new Set([`a`,`blockquote`,`br`,`code`,`em`,`h1`,`h2`,`h3`,`hr`,`i`,`img`,`li`,`ol`,`p`,`pre`,`s`,`span`,`strong`,`u`,`ul`]),Br={a:new Set([`href`,`rel`,`target`,`title`]),img:new Set([`alt`,`loading`,`src`,`title`])};function Vr(e){let t=Kr(e),n={};for(let[e,r]of Object.entries(t)){let t=r.filter(e=>typeof e==`string`).map(e=>qr(e)?Wr(e):Jr(e)).filter(Boolean).join(``);t&&(n[e]=[t])}return n}function Hr(e){let t={};for(let[n,r]of Object.entries(e||{})){let e=(r||[]).filter(e=>typeof e==`string`).map(e=>qr(e)?Wr(e):Jr(e)).filter(Boolean).join(``);e&&(t[n]=[e])}return t}function Ur(e){return Object.values(Vr(e)).flatMap(e=>Array.isArray(e)?e:[e]).filter(e=>typeof e==`string`).join(``)}function Wr(e){if(typeof document>`u`)return Xr(e);let t=document.createElement(`template`);return t.innerHTML=e||``,Gr(t.content),t.innerHTML}function Gr(e){for(let t of Array.from(e.childNodes)){if(t.nodeType===Node.ELEMENT_NODE){let e=t,n=e.tagName.toLowerCase();if(!zr.has(n)){e.replaceWith(...Array.from(e.childNodes));continue}for(let t of Array.from(e.attributes)){let r=t.name.toLowerCase(),i=Br[n]?.has(r)||!1,a=(r===`href`||r===`src`)&&/^(javascript|data):/i.test(t.value.trim());(!i||a)&&e.removeAttribute(t.name)}n===`a`&&e.getAttribute(`target`)===`_blank`&&e.setAttribute(`rel`,`noopener noreferrer`)}Gr(t)}}function Kr(e){if(!e)return{};if(typeof e==`string`)return{none:[e]};if(Array.isArray(e))return{none:e.filter(e=>typeof e==`string`)};if(typeof e==`object`){let t={};for(let[n,r]of Object.entries(e))t[n]=(Array.isArray(r)?r:[r]).filter(e=>typeof e==`string`);return t}return{}}function qr(e){return e.trimStart().startsWith(`<`)}function Jr(e){return e.replace(/\r\n?/g,`
2
+ `).split(/\n+/).map(e=>e.trim()).filter(Boolean).map(e=>`<p>${Yr(e)}</p>`).join(``)}function Yr(e){return e.replace(/&/g,`&amp;`).replace(/</g,`&lt;`).replace(/>/g,`&gt;`).replace(/"/g,`&quot;`).replace(/'/g,`&#39;`)}function Xr(e){return(e||``).replace(/<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi,``).replace(/<style\b[^<]*(?:(?!<\/style>)<[^<]*)*<\/style>/gi,``).replace(/\s+on[a-z]+\s*=\s*(?:"[^"]*"|'[^']*'|[^\s>]+)/gi,``).replace(/\s+(href|src)\s*=\s*(["'])\s*(?:javascript|data):[^"']*\2/gi,``)}const Zr={id:`@exhibition/right-panel-editor`,supports:{edit:!0,properties:[`label`,`summary`],resourceTypes:[`Canvas`],custom:({resource:e},t)=>H(e,t)?!Je(e,t):!1},label:`Exhibition`,component:()=>(0,p.jsx)(Qr,{})};function Qr(){return(0,p.jsx)(h.Sidebar,{children:(0,p.jsx)(h.SidebarContent,{padding:!0,children:(0,p.jsx)($r,{})})})}function $r(){let e=(0,d.useCanvas)(),t=(0,d.useVault)(),n=(0,l.useEditingResource)(),{structural:r,technical:i}=(0,l.useEditor)(),{items:a}=r,o=i.behavior.get()||[],s=a.get()[0],c=Xe(e),f=o.includes(`info`),m=tt(t,e);return!e||!s||!n?(0,p.jsx)(`div`,{className:`p-8`,children:`Canvas, page, or resource not found`}):f?(0,p.jsxs)(l.ResourceEditingProvider,{resource:e,children:[c?null:(0,p.jsx)(Gn,{}),(0,p.jsx)(ei,{canvas:e}),m?(0,p.jsx)(ti,{canvas:e}):null]}):(0,p.jsxs)(l.ResourceEditingProvider,{resource:e,children:[c?null:(0,p.jsx)(Gn,{}),(0,p.jsx)(ei,{canvas:e}),(0,p.jsx)(u.InputContainer,{$wide:!0,children:(0,p.jsxs)(`div`,{children:[(0,p.jsx)(`div`,{className:`exhibition-workbench-muted mb-3 text-sm font-semibold`,children:`Layout preset`}),(0,p.jsx)(`div`,{className:`grid grid-cols-2 gap-3`,children:cr.map(n=>(0,p.jsx)(xr,{preset:n.value,label:n.label,selected:Or(o)===n.value,onClick:()=>{i.behavior.set(kr(o,n.value,e?{width:e.width,height:e.height}:void 0)),e&&Rr(t,e,n.value)}},n.value))}),(0,p.jsx)(ni,{canvas:e,tabId:`slide-behaviors`,label:`Edit layout options`})]})}),m?(0,p.jsx)(ti,{canvas:e}):null,(0,p.jsx)(d.AnnotationPageContext,{annotationPage:s.id,children:(0,p.jsx)(u.PaintingAnnotationList,{createFilter:`image`})})]})}function ei({canvas:e}){let{edit:t}=(0,l.useLayoutActions)(),n=(0,m.useRef)(null),[r,i]=(0,m.useState)(!1),[a,o]=(0,m.useState)(!1),s=ri(e.label)||`Untitled`,c=Ur(e.summary);return(0,m.useEffect)(()=>{let e=n.current;if(!e){o(!1);return}o(e.scrollHeight>e.clientHeight+1)},[c,r]),(0,p.jsx)(u.InputContainer,{$wide:!0,children:(0,p.jsxs)(`div`,{className:`rounded-md border border-[#dcd5ce] bg-[#f8f6f3] p-4`,children:[(0,p.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,p.jsxs)(`div`,{className:`min-w-0`,children:[(0,p.jsx)(`div`,{className:`text-xs font-semibold uppercase text-[#6a625c]`,children:`Label`}),(0,p.jsx)(`div`,{className:`mt-1 break-words text-base font-semibold text-[#25211f]`,children:s})]}),(0,p.jsx)(`button`,{type:`button`,className:`flex-shrink-0 rounded-md px-3 py-2 text-sm font-semibold shadow-sm`,style:{backgroundColor:`#b84c74`,border:`1px solid #a13e63`,color:`#ffffff`},onClick:()=>{t({id:e.id,type:`Canvas`},void 0,{selectedTab:`@exhibition/summary-editor`,forceOpen:!0})},children:`Edit`})]}),(0,p.jsxs)(`div`,{className:`mt-5`,children:[(0,p.jsx)(`div`,{className:`text-xs font-semibold uppercase text-[#6a625c]`,children:`Summary`}),(0,p.jsx)(`div`,{ref:n,className:[`mt-2 whitespace-pre-wrap break-words text-sm leading-relaxed text-[#332f2c]`,r?``:`max-h-32 overflow-hidden`].join(` `),children:c?(0,p.jsx)(`div`,{className:`prose prose-sm max-w-none prose-p:my-2 prose-headings:my-2 prose-ul:my-2 prose-ol:my-2`,dangerouslySetInnerHTML:{__html:c}}):(0,p.jsx)(`span`,{className:`text-[#6a625c]`,children:`No summary added.`})}),a||r?(0,p.jsx)(`button`,{type:`button`,className:`mt-2 text-sm font-semibold text-[#b84c74]`,onClick:()=>i(e=>!e),children:r?`Read less`:`Read more`}):null]})]})})}function ti({canvas:e}){let t=(0,d.useVault)(),n=e.annotations?.[0],r=n?t.get(n,{skipSelfReturn:!1}):null,i=Array.isArray(r?.items)?r.items.length:0,a=i===0?`There are no tour steps yet.`:`${i} tour step${i===1?``:`s`} on this canvas.`;return(0,p.jsx)(u.InputContainer,{$wide:!0,children:(0,p.jsxs)(`div`,{className:`rounded-md border border-[#dcd5ce] bg-white p-4`,children:[(0,p.jsx)(`div`,{className:`text-sm font-semibold text-[#25211f]`,children:`Tour steps`}),(0,p.jsx)(`div`,{className:`mt-1 text-sm text-[#6a625c]`,children:a}),(0,p.jsx)(ni,{canvas:e,tabId:`@exhibition/tour-steps`,label:i===0?`Open Tour steps tab to add one`:`Open Tour steps tab`})]})})}function ni({canvas:e,tabId:t,label:n}){let{edit:r}=(0,l.useLayoutActions)();return(0,p.jsxs)(`button`,{type:`button`,onClick:()=>r({id:e.id,type:`Canvas`},void 0,{selectedTab:t,forceOpen:!0}),className:`flex gap-2 items-center justify-between mt-3 text-me-primary-600 bg-gray-50 py-2 px-4 rounded-full hover:bg-gray-100`,children:[(0,p.jsx)(`span`,{className:`text-left text-sm font-semibold`,children:n}),(0,p.jsx)(h.ArrowRightIcon,{})]})}function ri(e){return e?typeof e==`string`?e:Array.isArray(e)?e.filter(Boolean).join(` `):typeof e==`object`?Object.values(e).flatMap(e=>Array.isArray(e)?e:[e]).filter(e=>typeof e==`string`).join(` `):``:``}const ii={id:`@exhibition/summary-editor`,supports:{edit:!0,properties:[`summary`],resourceTypes:[`Canvas`],custom:({resource:e},t)=>H(e,t)?!Je(e,t):!1},label:`Summary`,component:()=>(0,p.jsx)(ai,{})};function ai(){return(0,p.jsx)(h.Sidebar,{children:(0,p.jsx)(h.SidebarContent,{padding:!0,children:(0,p.jsx)(oi,{})})})}function oi(){let e=(0,d.useCanvas)();return e?(0,p.jsxs)(l.ResourceEditingProvider,{resource:e,children:[(0,p.jsx)(u.LanguageMapEditor,{dispatchType:`label`}),(0,p.jsx)(si,{canvas:e})]}):null}function si({canvas:e}){let t=(0,d.useVault)(),n=(0,m.useMemo)(()=>Vr(e.summary),[e.summary]);return(0,p.jsx)(u.TiptapLanguageFieldEditor,{label:`summary`,metadataKey:`summary`,fields:n,onSave:n=>{t.modifyEntityField(e,`summary`,Hr(n.toInternationalString()))}},e.id)}function ci(e){return(0,p.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,width:`1em`,height:`1em`,viewBox:`0 0 24 24`,...e,children:(0,p.jsx)(`path`,{fill:`currentColor`,d:`M9 16.17L4.83 12l-1.42 1.41L9 19L21 7l-1.41-1.41z`})})}const li=`<h2>New step</h2><p>Description</p>`;function ui(){let{saveAnnotation:e}=(0,d.useCurrentAnnotationActions)(),[t,n]=(0,d.useCurrentAnnotationMetadata)(),{editorFeatureFlags:r}=(0,l.useConfig)(),{annotationPopups:i}=r;return i?(0,p.jsxs)(`div`,{className:`bg-white shadow-md rounded-lg`,children:[(0,p.jsx)(`div`,{className:`prose-headings:mt-1 overflow-y-auto rounded prose-headings:mb-1 prose-sm focus-within:ring-1 focus-within:ring-me-primary-500`,children:(0,p.jsx)(h.HTMLEditor,{className:`border-none`,value:t.bodyValue||li,onChange:e=>n({bodyValue:e})})}),(0,p.jsxs)(`div`,{className:`flex gap-2 p-3`,children:[(0,p.jsxs)(h.ActionButton,{primary:!0,onPress:()=>e(),children:[(0,p.jsx)(ci,{}),` Finish editing`]}),(0,p.jsx)(u.AnnotationPopUpSwitcherButton,{})]})]}):(0,p.jsxs)(`div`,{className:`flex gap-2`,children:[(0,p.jsxs)(h.ActionButton,{primary:!0,onPress:()=>e(),children:[(0,p.jsx)(ci,{}),` Finish editing`]}),(0,p.jsx)(u.AnnotationPopUpSwitcherButton,{})]})}function di(){let e=(0,f.useStore)((0,l.useAtlasStore)(),e=>e.polygon),[t,n]=(0,d.useCurrentAnnotationMetadata)(),{editorFeatureFlags:r}=(0,l.useConfig)(),{annotationPopups:i}=r,{cancelRequest:a,saveAnnotation:o}=(0,d.useCurrentAnnotationActions)();return(0,p.jsxs)(`div`,{className:`border border-gray-300 hover:border-me-500 shadow-sm rounded bg-white relative`,children:[(0,p.jsxs)(`div`,{className:`bg-me-primary-500 text-white p-2 m-1 rounded flex gap-2`,children:[(0,p.jsx)(h.TargetIcon,{}),`Draw a box on the canvas`]}),i?(0,p.jsx)(`div`,{className:`relative p-3 line-clamp-3 prose-p:text-slate-600`,children:(0,p.jsx)(`div`,{className:`prose-headings:mt-1 prose-headings:mb-1 prose-sm`,children:(0,p.jsx)(`div`,{dangerouslySetInnerHTML:{__html:t.bodyValue||li}})})}):(0,p.jsx)(h.HTMLEditor,{className:`border-none`,value:t.bodyValue||li,onChange:e=>n({bodyValue:e})}),(0,p.jsxs)(`div`,{className:`flex gap-2 p-3`,children:[(0,p.jsxs)(h.ActionButton,{isDisabled:e?.points.length===0,onPress:()=>o(),children:[(0,p.jsx)(ci,{}),` Finish editing`]}),(0,p.jsxs)(h.ActionButton,{className:`gap-2 flex`,onPress:()=>a(),children:[(0,p.jsx)(h.DeleteIcon,{}),` Delete`]}),(0,p.jsx)(u.AnnotationPopUpSwitcherButton,{})]})]})}function fi(){let{editorFeatureFlags:e}=(0,l.useConfig)(),{annotationPopups:t}=e,n=(0,l.useSaveConfig)();return(0,p.jsx)(h.ActionButton,{className:`ml-auto`,onPress:()=>n({editorFeatureFlags:{...e,annotationPopups:!t}}),children:t?(0,p.jsx)(h.AnnotationPopInIcon,{}):(0,p.jsx)(h.AnnotationPopOutIcon,{})})}function pi({highlightProps:e,useSlideshowWorkbench:t=!1}){let n=(0,m.useContext)(l.ResourceEditingReactContext),r=(0,d.useAnnotation)(),{editorFeatureFlags:i}=(0,l.useConfig)(),{annotationPopups:a}=i,o=U(e=>e.startTourStepRepositioning),s=W(e=>e.requestTab),c=W(e=>e.setShowTourSteps),{isPending:f,cancelRequest:g,busy:_,requestAnnotationFromTarget:v,deleteAnnotation:y}=(0,u.useAnnotationEditor)({annotationPopup:(0,p.jsx)(d.AnnotationContext,{annotation:r.id,children:(0,p.jsx)(l.ResourceEditingReactContext.Provider,{value:n,children:(0,p.jsx)(mi,{})})})}),[b,x]=(0,m.useState)(!1),S=()=>!t||!r?.id?!1:(c(!0),o(r.id),s(`tour`),!0);return(0,m.useEffect)(()=>{b&&!f&&x(!0)},[f,b]),(0,p.jsxs)(`div`,{...e,className:`exhibition-tour-step-card border border-gray-300 hover:border-me-500 shadow-sm rounded bg-white relative`,onClick:S,children:[(0,p.jsx)(`div`,{className:`relative`,children:b&&!a?(0,p.jsx)(u.HTMLAnnotationEditor,{className:`border-none`}):(0,p.jsx)(h.HTMLAnnotationBodyRender,{className:`exhibition-tour-step-body px-3 pt-3 line-clamp-3 prose-p:text-slate-600`,locale:`en`})}),(0,p.jsxs)(`div`,{className:`flex gap-2 p-2`,children:[b&&f?(0,p.jsxs)(p.Fragment,{children:[(0,p.jsxs)(h.ActionButton,{primary:!0,onPress:()=>{x(!1),g()},children:[(0,p.jsx)(ci,{}),` Finish editing`]}),(0,p.jsx)(u.AnnotationPopUpSwitcherButton,{})]}):(0,p.jsxs)(h.ActionButton,{isDisabled:_,onPress:()=>{t&&r?.id&&(c(!0),o(r.id),s(`tour`)),x(!0),v().then(()=>{x(!1)})},children:[(0,p.jsx)(h.EditTextIcon,{}),` Edit`]}),(0,p.jsxs)(h.ActionButton,{className:`gap-2 flex`,onPress:()=>y(),children:[(0,p.jsx)(h.DeleteIcon,{}),` Delete`]})]}),(0,p.jsx)(`div`,{className:`absolute -bottom-5 left-5 h-5 border-l-2 border-gray-300 w-0`})]})}function mi(){let{editorFeatureFlags:e}=(0,l.useConfig)(),{annotationPopups:t}=e,{saveAnnotation:n}=(0,d.useCurrentAnnotationActions)();return t?(0,p.jsxs)(`div`,{className:`bg-white shadow-md rounded-lg relative max-h-[50vh] overflow-y-auto`,children:[(0,p.jsx)(`div`,{className:`prose-headings:mt-1 rounded prose-headings:mb-1 prose-sm focus-within:ring-1 focus-within:ring-me-primary-500`,children:(0,p.jsx)(u.HTMLAnnotationEditor,{className:`border-none`})}),(0,p.jsxs)(`div`,{className:`flex gap-2 p-2 sticky bottom-0 z-50 bg-white`,children:[(0,p.jsxs)(h.ActionButton,{primary:!0,onPress:()=>{n()},children:[(0,p.jsx)(ci,{}),` Finish editing`]}),(0,p.jsx)(fi,{})]})]}):(0,p.jsxs)(`div`,{className:`flex gap-2`,children:[(0,p.jsxs)(h.ActionButton,{primary:!0,onPress:()=>n(),children:[(0,p.jsx)(ci,{}),` Finish editing`]}),(0,p.jsx)(u.AnnotationPopUpSwitcherButton,{})]})}function hi({originalAnnotationId:e,highlightProps:t,useSlideshowWorkbench:n=!1}){let r=(0,l.useGenericEditor)((0,d.useAnnotationPage)()),i=(0,d.useAnnotation)(),a=(0,d.useCanvas)(),o=(0,d.useVault)(),{edit:s}=(0,l.useLayoutActions)(),[c,f]=(0,m.useState)(!1),g=U(e=>e.startTourStepRepositioning),_=W(e=>e.requestTab),v=W(e=>e.setShowTourSteps),y=a?.items?.[0],b=y?.id&&i?.id?(o.get(y)?.items||[]).findIndex(e=>e.id===i.id):-1,x=()=>{if(e&&confirm(`Are you sure you want to delete this annotation?`)){let t=r.structural.items.getWithoutTracking().findIndex(t=>t.id===e);r.structural.items.deleteAtIndex(t)}},S=()=>!n||!e?!1:(v(!0),g(e),_(`tour`),!0);return(0,p.jsxs)(`div`,{...t,className:`exhibition-tour-step-card border border-gray-300 hover:border-me-500 shadow-sm rounded bg-white relative`,onClick:S,children:[(0,p.jsx)(`div`,{className:`flex gap-2 mb-2 p-3`,children:(0,p.jsx)(`div`,{className:`flex-1 min-w-0`,children:c?(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(`h3`,{className:`text-lg font-semibold border-b pt-1 pb-2 mb-2`,children:`Edit step`}),(0,p.jsx)(u.LanguageMapEditor,{dispatchType:`label`}),(0,p.jsx)(u.LanguageMapEditor,{dispatchType:`summary`})]}):(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(d.LocaleString,{as:`div`,defaultText:(0,p.jsx)(`span`,{className:`opacity-50`,children:`Untitled`}),className:`whitespace-nowrap overflow-ellipsis w-full overflow-x-hidden`,children:i?.label}),(0,p.jsx)(d.LocaleString,{className:`exhibition-tour-step-body text-gray-500 text-sm bg-white line-clamp-2`,as:`div`,children:i?.summary})]})})}),(0,p.jsxs)(`div`,{className:`flex gap-2 p-2`,children:[c?(0,p.jsxs)(h.ActionButton,{onPress:()=>f(!1),children:[(0,p.jsx)(ci,{}),` Finish editing`]}):(0,p.jsxs)(h.ActionButton,{onPress:()=>f(!0),children:[(0,p.jsx)(h.EditTextIcon,{}),` Edit body`]}),(0,p.jsx)(h.ActionButton,{onPress:()=>{S()||i&&s({id:i.id,type:`Annotation`},y?{parent:y,property:`items`,index:b}:void 0,{forceOpen:!0})},children:`Edit annotation`}),(0,p.jsxs)(h.ActionButton,{className:`gap-2 flex`,onPress:()=>x(),children:[(0,p.jsx)(h.DeleteIcon,{}),` Delete`]})]}),(0,p.jsx)(`div`,{className:`absolute -bottom-5 left-5 h-5 border-l-2 border-gray-300 w-0`})]})}function gi({useSlideshowWorkbench:e=!1}){let[t,{annotationTarget:n,highlightProps:r}]=(0,u.useAnnotationInfo)(),i=(0,m.useMemo)(()=>n?{id:n,type:`Annotation`}:{id:t?.id,type:`Annotation`},[t?.id,n]);return n?(0,p.jsx)(l.ResourceEditingProvider,{resource:i,children:(0,p.jsx)(d.AnnotationContext,{annotation:n,children:(0,p.jsx)(hi,{originalAnnotationId:t?.id,highlightProps:r,useSlideshowWorkbench:e})})}):(0,p.jsx)(l.ResourceEditingProvider,{resource:i,children:(0,p.jsx)(pi,{highlightProps:r,useSlideshowWorkbench:e})})}function _i({reorderable:e=!1,useSlideshowWorkbench:t=!1}){let n=(0,d.useAnnotationPage)(),r=(0,l.useGenericEditor)(n);return n?e?(0,p.jsx)(p.Fragment,{children:(0,p.jsx)(u.ReorderList,{id:n.id,marginBottom:`0.5em`,items:n.items||[],inlineHandle:!1,reorder:({startIndex:e,endIndex:t})=>r.structural.items.reorder(e,t),renderItem:(e,n)=>(0,p.jsx)(d.AnnotationContext,{annotation:e.id,children:(0,p.jsx)(gi,{useSlideshowWorkbench:t})})})}):(0,p.jsx)(p.Fragment,{children:n.items.map(e=>(0,p.jsx)(d.AnnotationContext,{annotation:e.id,children:(0,p.jsx)(gi,{useSlideshowWorkbench:t})},e.id))}):null}const vi={id:`@exhibition/tour-steps`,supports:{edit:!0,properties:[`annotations`],resourceTypes:[`Canvas`],custom:({resource:e},t)=>H(e,t)?!Je(e,t)&&!Ye(e,t):!1},label:`Tour steps`,component:()=>(0,p.jsx)(yi,{})};function yi({mode:e=`advanced`}){let t=(0,d.useCanvas)(),n=t?.annotations[0],r=t?.items[0];return!n||!t||!r?(0,p.jsx)(bi,{}):(0,p.jsx)(h.Sidebar,{children:(0,p.jsx)(h.SidebarContent,{padding:!0,children:(0,p.jsx)(xi,{mode:e})})})}function bi(){let e=(0,d.useCanvas)(),t=(0,l.useInlineCreator)(),n=()=>{e&&t.create(`@manifest-editor/empty-annotation-page`,{label:{en:[`Tour steps`]}},{target:{id:e.id,type:`Canvas`},targetType:`AnnotationPage`,parent:{property:`annotations`,resource:{id:e.id,type:`Canvas`}}})};return(0,p.jsxs)(`div`,{className:`flex flex-col items-center justify-center p-4`,children:[(0,p.jsx)(`div`,{className:`p-4 opacity-50 text-center`,children:`This image does not yet have a tour.`}),(0,p.jsx)(v.Button,{className:`border w-full disabled:opacity-50 border-gray-300 hover:border-me-500 hover:bg-me-50 cursor-pointer shadow-sm rounded p-4 bg-white relative text-black/40 hover:text-me-500`,onPress:()=>n(),children:`Create Tour`})]})}function xi({mode:e,useSlideshowWorkbench:t=!1}){let n=(0,d.useCanvas)(),r=n?.annotations?.[0],i=n?.items?.[0],[a,o]=(0,m.useState)(!1),s=W(e=>e.setShowTourSteps),c=U(e=>e.stopRepositioning),f=U(e=>e.stopTextRepositioning);(0,m.useEffect)(()=>{s(!0),c(),f()},[s,c,f]);let{requestTourStep:g,isPending:_,busy:y}=Si({onBeforeRequest:t?()=>{s(!0),c(),f()}:void 0});if(!n)return null;if(!r)return(0,p.jsx)(bi,{});let b=e===`advanced`&&!!i;return(0,p.jsxs)(p.Fragment,{children:[(0,p.jsxs)(`div`,{className:`flex gap-4 border-b pt-4 pb-2 mb-2`,children:[(0,p.jsx)(`h2`,{className:`text-lg font-semibold flex-1`,children:`Tour steps`}),e===`advanced`?(0,p.jsx)(h.ActionButton,{onPress:()=>o(e=>!e),children:a?`Done`:`Reorder`}):null]}),(0,p.jsx)(l.ResourceEditingProvider,{resource:n,children:(0,p.jsxs)(d.AnnotationPageContext,{annotationPage:r.id,children:[(0,p.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,p.jsx)(_i,{reorderable:e===`advanced`?a:!1,useSlideshowWorkbench:t}),y?null:_?(0,p.jsx)(di,{}):(0,p.jsx)(v.Button,{onPress:g,className:`border disabled:opacity-50 border-gray-300 hover:border-me-500 hover:bg-me-50 cursor-pointer shadow-sm rounded p-4 bg-white relative text-black/40 hover:text-me-500`,children:`+ Add new step`})]}),b&&i?(0,p.jsx)(p.Fragment,{children:(0,p.jsx)(u.PromptToAddPaintingAnnotations,{title:(0,p.jsx)(`h3`,{className:`text-md border-b pt-4 pb-2 mb-2`,children:`Available tour steps from images`}),painting:i,page:r,canvasId:n.id})}):null]})})]})}function Si({onBeforeRequest:e}={}){let t=(0,d.useCanvas)(),n=t?.annotations?.[0],r=(0,l.useInlineCreator)(),{requestAnnotation:i,isPending:a,busy:o}=(0,d.useRequestAnnotation)({onSuccess:e=>{let i=e.metadata.bodyValue||``;!e.cancelled&&e.target&&t&&n&&r.create(`@manifest-editor/html-annotation`,{label:{en:[`Tour step`]},body:{en:[i||`<h2>New step</h2><p>Description</p>`]},motivation:`tagging`},{target:{id:t.id,type:`Canvas`},targetType:`Annotation`,parent:{property:`items`,resource:{id:n.id,type:`AnnotationPage`}},initialData:{selector:e}})}});return{requestTourStep:()=>{e?.(),i({type:`box`,annotationPopup:(0,p.jsx)(ui,{})})},isPending:a,busy:o,canRequestTourStep:!!(t&&n)}}const Ci=`exhibition-info-box-mode`,wi={id:`@exhibition/info-box-editor`,supports:{edit:!0,properties:[`label`,`behavior`],resourceTypes:[`Canvas`],custom:({resource:e},t)=>H(e,t)?Je(e,t):!1},label:`Text box`,component:()=>(0,p.jsx)(Ti,{})};function Ti(){let[e,t]=(0,l.useLocalStorage)(`exhibition-info-box-mode`,`simple`),n=(0,d.useCanvas)(),r=(0,d.useVault)(),i=(0,d.useManifest)(),a=(0,l.useEditor)();if(!n||a.technical.type!==`Canvas`)return null;let o=a.technical.behavior.get()||[],s=Fr(o)||12,c=e=>{let t=o.filter(e=>!e.startsWith(`w-`)&&!e.startsWith(`h-`)),n=o.find(e=>e.startsWith(`h-`));t.push(`w-${e}`),n||t.push(`h-4`),a.technical.behavior.set(t)},f=i?.items&&n?Ir(n.id,i.items,r):null;return(0,p.jsx)(h.Sidebar,{children:(0,p.jsxs)(h.SidebarContent,{className:`bg-white px-6 pt-5 pb-20`,children:[(0,p.jsx)(`div`,{className:`flex justify-center`,children:(0,p.jsx)(Er,{value:e,onChange:t})}),(0,p.jsxs)(`div`,{className:`mt-8 flex flex-col gap-7`,children:[(0,p.jsx)(l.ResourceEditingProvider,{resource:n,children:e===`simple`?(0,p.jsxs)(Dr,{children:[(0,p.jsx)(Q,{children:`Title`}),(0,p.jsx)(`div`,{className:`mt-2`,children:(0,p.jsx)(u.LanguageMapEditor,{dispatchType:`label`,disableMultiline:!0,disallowHTML:!0})})]}):(0,p.jsxs)(Dr,{children:[(0,p.jsx)(Q,{children:`Label & summary`}),(0,p.jsxs)(`div`,{className:`mt-2 flex flex-col gap-3`,children:[(0,p.jsx)(u.LanguageMapEditor,{dispatchType:`label`,disableMultiline:!0,disallowHTML:!0}),(0,p.jsx)(u.LanguageMapEditor,{dispatchType:`summary`})]})]})}),e===`simple`?(0,p.jsxs)(p.Fragment,{children:[(0,p.jsxs)(Dr,{children:[(0,p.jsx)(Q,{children:`Width`}),(0,p.jsx)(`div`,{className:`mt-3 grid grid-cols-2 gap-3`,children:Pr.map(e=>(0,p.jsx)(wr,{selected:s===e.value,onClick:()=>c(e.value),children:e.label},e.value))})]}),f?(0,p.jsxs)(Dr,{children:[(0,p.jsxs)(Q,{children:[`Fit alongside `,f.neighbour,` slide`]}),(0,p.jsx)(`div`,{className:`mt-3`,children:(0,p.jsxs)(wr,{selected:s===f.width,onClick:()=>c(f.width),children:[`w-`,f.width,` — fills remaining space`]})})]}):null,(0,p.jsxs)(`div`,{className:`text-center text-xs`,style:{color:Z.muted},children:[`w-`,s]})]}):(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(`div`,{className:`px-2`,children:(0,p.jsx)(u.InputContainer,{$wide:!0,children:(0,p.jsx)(u.DimensionsTriplet,{widthId:a.technical.width.containerId(),width:a.technical.width.get()||0,changeWidth:e=>a.technical.width.set(e),heightId:a.technical.height.containerId(),height:a.technical.height.get()||0,changeHeight:e=>a.technical.height.set(e)})})}),(0,p.jsx)(u.BehaviorEditor,{behavior:o,onChange:e=>a.technical.behavior.set(e),configs:[{id:`size`,component:(e,t)=>(0,p.jsx)(gr,{behaviors:e,setBehaviors:t}),label:{en:[`Size`]},type:`custom`,initialOpen:!0,supports:e=>e.startsWith(`w-`)||e.startsWith(`h-`)}]})]})]})]})})}const Ei=`editorial-text`;function Di(){let e=(0,d.useCanvas)(),t=e?.items?.[0]?{id:e.items[0].id,type:`AnnotationPage`}:void 0,[,n]=(0,l.useCreator)(t,`items`,`Annotation`,e?{id:e.id,type:`Canvas`}:void 0,{isPainting:!0}),{selectedAnnotationId:r,repositioningAnnotationId:i,selectedTextRegion:a,repositioningTextRegion:o,selectAnnotation:s,startRepositioning:c,stopRepositioning:u,selectTextRegion:f,startTextRepositioning:m,stopTextRepositioning:h}=U(),g=W(e=>e.setShowTourSteps),_=(0,d.useVaultSelector)((t,n)=>e?rt(n,e):[],[e?.id,t?.id]),v=ct(e).text,y=_.length||v;return!e||!t?(0,p.jsxs)(`div`,{children:[(0,p.jsx)(Ii,{children:`Content on this slide`}),(0,p.jsx)(`p`,{className:`exhibition-workbench-muted mt-2 text-sm leading-relaxed`,children:`This slide does not have a content layer yet.`})]}):(0,p.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,p.jsxs)(`div`,{children:[(0,p.jsx)(Ii,{children:`Content on this slide`}),(0,p.jsx)(`p`,{className:`exhibition-workbench-muted mt-2 text-sm leading-relaxed`,children:`Select a painting annotation to highlight it in the workbench. Use the centre panel to add, position, and edit slide content.`})]}),y?(0,p.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[v?(0,p.jsx)(ki,{box:v,selected:a===Ei,repositioning:o===Ei,onSelect:()=>{g(!1),f(Ei)},onReposition:()=>{g(!1),m(Ei)},onStopReposition:h}):null,_.map((e,t)=>(0,p.jsx)(Oi,{layer:e,index:t,selected:r===e.annotation.id,repositioning:i===e.annotation.id,onSelect:()=>{g(!1),s(e.annotation.id)},onReposition:()=>{g(!1),c(e.annotation.id)},onStopReposition:u,onAdvancedEdit:()=>n.edit({id:e.annotation.id,type:`Annotation`},t)},e.annotation.id))]}):(0,p.jsx)(`div`,{className:`exhibition-slideshow-content-empty rounded-lg border border-dashed border-slate-200 bg-slate-50 p-4 text-sm`,children:`No painting annotations on this slide yet.`})]})}function Oi({layer:e,index:t,selected:n,repositioning:r,onSelect:i,onReposition:a,onStopReposition:o,onAdvancedEdit:s}){let c=(0,d.useVault)(),l=(0,u.useAnnotationThumbnail)({annotationId:e.annotation.id,options:{maxWidth:96,maxHeight:96}}),f=Pi(e.annotation,c),m=ji(e,f),h=Mi(e,f,t),g=Ni(e,f,m);return(0,p.jsxs)(`div`,{className:[`exhibition-slideshow-content-item rounded-lg border bg-white p-3 transition`,n?`exhibition-slideshow-content-item-selected border-me-primary-500 bg-me-primary-50 ring-2 ring-me-primary-100`:`border-slate-200`].join(` `),children:[(0,p.jsxs)(v.Button,{className:`flex w-full items-center gap-3 border-none bg-transparent p-0 text-left`,onPress:i,children:[(0,p.jsx)(Ai,{thumbnailUrl:l?.id,type:m}),(0,p.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,p.jsx)(`span`,{className:`block text-[11px] font-semibold uppercase tracking-wide text-me-primary-500`,children:m}),(0,p.jsx)(`span`,{className:`mt-0.5 block truncate text-sm font-semibold`,children:h}),(0,p.jsx)(`span`,{className:`exhibition-workbench-muted mt-0.5 block truncate text-xs`,children:g})]})]}),(0,p.jsxs)(`div`,{className:`mt-3 flex items-center justify-between gap-3`,children:[(0,p.jsx)(`span`,{className:`exhibition-workbench-muted text-xs`,children:r?`Drag or resize in the workbench`:n?`Selected in workbench`:`Click to select on slide`}),(0,p.jsxs)(`div`,{className:`flex gap-2`,children:[(0,p.jsx)(v.Button,{className:`rounded-md border border-me-primary-200 bg-me-primary-50 px-3 py-1.5 text-xs font-semibold text-me-primary-600 transition hover:bg-me-primary-100`,onPress:r?o:a,children:r?`Done moving`:`Reposition`}),(0,p.jsx)(v.Button,{className:`rounded-md border border-slate-200 bg-white px-3 py-1.5 text-xs font-semibold text-slate-700 transition hover:bg-slate-50`,onPress:s,children:`Advanced edit`})]})]})]})}function ki({box:e,selected:t,repositioning:n,onSelect:r,onReposition:i,onStopReposition:a}){return(0,p.jsxs)(`div`,{className:[`exhibition-slideshow-content-item rounded-lg border bg-white p-3 transition`,t?`exhibition-slideshow-content-item-selected border-me-primary-500 bg-me-primary-50 ring-2 ring-me-primary-100`:`border-slate-200`].join(` `),children:[(0,p.jsxs)(v.Button,{className:`flex w-full items-center gap-3 border-none bg-transparent p-0 text-left`,onPress:r,children:[(0,p.jsx)(Ai,{type:`Text`}),(0,p.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,p.jsx)(`span`,{className:`block text-[11px] font-semibold uppercase tracking-wide text-me-primary-500`,children:`Editorial text`}),(0,p.jsx)(`span`,{className:`mt-0.5 block truncate text-sm font-semibold`,children:`Slide label and summary`}),(0,p.jsxs)(`span`,{className:`exhibition-workbench-muted mt-0.5 block truncate text-xs`,children:[`Position `,Math.round(e.x),`, `,Math.round(e.y),` ·`,` `,Math.round(e.width),` x `,Math.round(e.height)]})]})]}),(0,p.jsxs)(`div`,{className:`mt-3 flex items-center justify-between gap-3`,children:[(0,p.jsx)(`span`,{className:`exhibition-workbench-muted text-xs`,children:n?`Drag or resize in the workbench`:t?`Selected in workbench`:`Click to select on slide`}),(0,p.jsx)(v.Button,{className:`rounded-md border border-me-primary-200 bg-me-primary-50 px-3 py-1.5 text-xs font-semibold text-me-primary-600 transition hover:bg-me-primary-100`,onPress:n?a:i,children:n?`Done moving`:`Reposition`})]})]})}function Ai({thumbnailUrl:e,type:t}){return(0,p.jsx)(`div`,{className:`flex h-16 w-16 shrink-0 items-center justify-center overflow-hidden rounded-md bg-[#f8f6f3] text-xs font-semibold text-black/60 ring-1 ring-slate-200`,children:e?(0,p.jsx)(`img`,{alt:``,className:`h-full w-full object-cover`,src:e}):(0,p.jsx)(`span`,{children:t})})}function ji(e,t){return e.imageUrl?`Image`:e.youtubeId?`YouTube`:e.videoUrl?`Video`:e.html===null?t?.type===`Canvas`?`Canvas`:t?.type?String(t.type):`Media`:`Text`}function Mi(e,t,n){let r=(0,u.getInternationalStringText)(t?.label,``),i=(0,u.getInternationalStringText)(e.annotation.label,``),a=e.html?Fi(e.html).slice(0,80):``;return r||i||a||`${ji(e,t)} layer ${n+1}`}function Ni(e,t,n){let r=`${Math.round(e.box.x)}, ${Math.round(e.box.y)} · ${Math.round(e.box.width)} x ${Math.round(e.box.height)}`;return[t?.format||t?.profile||t?.type||`${n} painting annotation`,`Position ${r}`].filter(Boolean).join(` · `)}function Pi(e,t){return(0,u.resolveContentResource)(t,Array.isArray(e?.body)?e.body[0]:e?.body)}function Fi(e){return e.replace(/<br\s*\/?>/gi,` `).replace(/<\/p>/gi,` `).replace(/<[^>]+>/g,` `).replace(/\s+/g,` `).trim()}function Ii({children:e}){return(0,p.jsx)(`div`,{className:`exhibition-workbench-muted text-sm font-semibold`,children:e})}const Li=[{id:`layout`,label:`Layout`},{id:`summary`,label:`Summary`},{id:`tour`,label:`Tour steps`}],Ri=[{id:`layout`,label:`Layout`},{id:`content`,label:`Content`},{id:`summary`,label:`Summary`},{id:`tour`,label:`Tour steps`}],zi=[{value:`simple`,label:`Simple`},{value:`advanced`,label:`Advanced`}],Bi=`exhibition-right-panel-mode`,Vi={track:`#f5eaf0`,active:`#b84c74`,inactiveText:`#8b3f61`,activeText:`#ffffff`,activeShadow:`0 1px 3px rgba(15, 23, 42, 0.18)`},Hi={id:`@exhibition/workbench-editor`,supports:{edit:!0,properties:[`label`,`summary`,`behavior`,`annotations`],resourceTypes:[`Canvas`],custom:({resource:e},t)=>H(e,t)?Je(e,t):!1},label:`Canvas`,component:()=>(0,p.jsx)(Wi,{})},Ui={...Hi,id:`@exhibition/slideshow-workbench-editor`,supports:{...Hi.supports,custom:({resource:e},t)=>H(e,t)},component:()=>(0,p.jsx)(Wi,{preset:`slideshow`})};function Wi({preset:e=`default`}){let[t,n]=(0,l.useLocalStorage)(`exhibition-right-panel-mode`,`simple`),r=(0,d.useCanvas)(),i=(0,d.useVault)(),a=!!r?.behavior?.includes(`info`),o=tt(i,r),s=(0,m.useMemo)(()=>(e===`slideshow`?Ri:Li).filter(e=>e.id!==`tour`||o),[e,o]),[c,u]=(0,m.useState)(`layout`),f=W(e=>e.requestedTab),g=W(e=>e.clearRequestedTab),_=W(e=>e.setShowTourSteps),v=W(e=>e.setCenterPanelMode);(0,m.useEffect)(()=>{c===`tour`?v(`edit`):c===`layout`&&v(`preview`)},[]),(0,m.useEffect)(()=>{if(f&&s.some(e=>e.id===f)){let e=f;u(e),_(e===`tour`),e===`tour`?v(`edit`):e===`layout`&&v(`preview`),g()}},[g,f,v,_,s]),(0,m.useEffect)(()=>{c===`tour`&&!o&&(u(`layout`),_(!1))},[c,_,o]);let y=e=>{u(e),_(e===`tour`),e===`tour`?v(`edit`):e===`layout`&&v(`preview`)};return a?(0,p.jsx)(Ti,{}):(0,p.jsx)(h.Sidebar,{children:(0,p.jsxs)(h.SidebarContent,{className:`bg-white px-6 pt-5 pb-20`,children:[(0,p.jsx)(`div`,{className:`flex justify-center`,children:(0,p.jsx)(Gi,{value:t,options:zi,onChange:n})}),(0,p.jsx)(`div`,{className:[`mt-5 grid border-b border-[#e4ddd6]`,s.length===4?`grid-cols-4`:`grid-cols-3`].join(` `),children:s.map(e=>(0,p.jsx)(`button`,{type:`button`,className:[`exhibition-workbench-tab`,`-mb-px border-b-[3px] border-transparent px-1 pb-3 text-center text-sm font-semibold`,c===e.id?`border-me-primary-500 text-me-primary-500`:`exhibition-workbench-muted`].join(` `),onClick:()=>y(e.id),children:e.label},e.id))}),(0,p.jsxs)(`div`,{className:`mt-8 px-4`,children:[c===`layout`?(0,p.jsx)(vr,{mode:t,layoutContext:e===`slideshow`?`slideshow`:`default`}):null,c===`content`?(0,p.jsx)(Di,{}):null,c===`summary`?t===`simple`?(0,p.jsx)(Ki,{}):(0,p.jsx)(oi,{}):null,c===`tour`?(0,p.jsx)(xi,{mode:t,useSlideshowWorkbench:e===`slideshow`}):null]})]})})}function Gi({value:e,options:t,onChange:n}){return(0,p.jsx)(`div`,{className:`grid w-full max-w-[240px] grid-cols-2 rounded-full p-1`,style:{backgroundColor:Vi.track},children:t.map(t=>{let r=e===t.value;return(0,p.jsx)(v.Button,{className:`border-none rounded-full bg-transparent px-4 py-2 text-sm font-semibold transition-colors`,style:{backgroundColor:r?Vi.active:`transparent`,color:r?Vi.activeText:Vi.inactiveText,boxShadow:r?Vi.activeShadow:`none`},onPress:()=>n(t.value),children:t.label},t.value)})})}function Ki(){let e=(0,d.useCanvas)();return e?(0,p.jsx)(l.ResourceEditingProvider,{resource:e,children:(0,p.jsxs)(`div`,{className:`flex flex-col gap-7`,children:[(0,p.jsxs)(`div`,{children:[(0,p.jsx)(qi,{children:`Slide title`}),(0,p.jsx)(`div`,{className:`mt-2`,children:(0,p.jsx)(u.LanguageMapEditor,{dispatchType:`label`,disableMultiline:!0,disallowHTML:!0})})]}),(0,p.jsxs)(`div`,{children:[(0,p.jsx)(qi,{children:`Slide summary`}),(0,p.jsx)(`div`,{className:`mt-2`,children:(0,p.jsx)(u.LanguageMapEditor,{dispatchType:`summary`})})]})]})}):null}function qi({children:e}){return(0,p.jsx)(`div`,{className:`exhibition-workbench-muted text-sm font-semibold`,children:e})}const Ji=e=>(0,p.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,width:`1em`,height:`1em`,viewBox:`0 0 15 15`,...e,children:(0,p.jsx)(`path`,{fill:`currentColor`,d:`M4.5 1a2.5 2.5 0 0 0-2.45 2H0v1h2.05a2.5 2.5 0 0 0 4.9 0H15V3H6.95A2.5 2.5 0 0 0 4.5 1m6 8a2.5 2.5 0 0 0-2.45 2H0v1h8.05a2.5 2.5 0 0 0 4.9 0H15v-1h-2.05a2.5 2.5 0 0 0-2.45-2`})});var Yi=Ji;const Xi=(0,l.extendApp)((0,l.mapApp)(c),{id:`exhibition-scrolling-editor`,title:`Exhibition Editor (scrolling)`,project:!0,projectType:`Manifest`},{config:{editorConfig:{}},leftPanels:[],centerPanels:[],annotations:[],background:[],canvasEditors:[],editors:[wi,Hi,Zr,fr,ii,vi],creators:[In,Hn,Tn,Cn,X,Pn,zn]}),Zi={id:`slideshow-canvas-editor`,label:`Slideshow canvas editor`,component:()=>(0,p.jsx)(Qi,{}),supports:{strategy:(e,t,n)=>{let r=n.get(t.resource);return r?.type===`Canvas`&&Xe(r)}}};function Qi(){let e=(0,d.useCanvas)(),t=(0,d.useManifest)(),{edit:n}=(0,l.useLayoutActions)(),{rightPanel:r}=(0,l.useLayoutState)(),i=W(e=>e.centerPanelMode),a=(0,d.useCurrentAnnotationRequest)(),o=(0,u.useAnnotationEditing)(e=>e.annotationId),[s,c]=(0,m.useState)(1),f=t?.items?.findIndex(t=>t.id===e?.id),h=typeof f==`number`?t?.items?.[f-1]:void 0,g=typeof f==`number`?t?.items?.[f+1]:void 0;return e?a||o||i===`edit`||r.current===`@manifest-editor/editor`&&r.state?.currentTab?.startsWith(`@exhibition/tour-steps`)?(0,p.jsx)(u.CanvasPanelEditor,{asFallback:!0}):(0,p.jsxs)(`div`,{className:`exhibition-slideshow-current-canvas flex h-full min-h-0 flex-col bg-slate-100`,children:[(0,p.jsxs)(`div`,{className:`exhibition-slideshow-current-toolbar flex items-center gap-3 border-b border-slate-200 bg-white px-4 py-3 shadow-sm`,children:[(0,p.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,p.jsx)(d.LocaleString,{className:`block truncate text-sm font-semibold text-slate-800`,children:e.label})}),(0,p.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,p.jsx)($i,{onPress:()=>c(1),children:`Home`}),(0,p.jsx)($i,{onPress:()=>c(e=>Math.max(.25,e-.25)),children:`-`}),(0,p.jsx)($i,{onPress:()=>c(e=>Math.min(3,e+.25)),children:`+`}),(0,p.jsx)($i,{isDisabled:!h,onPress:()=>h&&n({id:h.id,type:`Canvas`},void 0,{forceOpen:!1}),children:`Previous`}),(0,p.jsx)($i,{isDisabled:!g,onPress:()=>g&&n({id:g.id,type:`Canvas`},void 0,{forceOpen:!1}),children:`Next`})]})]}),(0,p.jsx)(`div`,{className:`exhibition-slideshow-current-viewport min-h-0 flex-1 overflow-auto p-8`,children:(0,p.jsx)(`div`,{className:`exhibition-slideshow-current-preview mx-auto origin-top overflow-hidden rounded-md bg-white shadow-xl ring-1 ring-black/10`,style:{width:`min(100%, 1200px)`,aspectRatio:`${e.width||1920} / ${e.height||1080}`,transform:`scale(${s})`,transformOrigin:`top center`},children:(0,p.jsx)(d.CanvasContext,{canvas:e.id,children:(0,p.jsx)(yt,{})})})})]}):null}function $i({children:e,isDisabled:t,onPress:n}){return(0,p.jsx)(v.Button,{className:`exhibition-slideshow-current-control rounded-md border border-slate-200 bg-white px-3 py-2 text-sm font-semibold text-slate-700 shadow-sm transition hover:bg-slate-50 disabled:cursor-not-allowed disabled:opacity-40`,isDisabled:t,onPress:n,children:e})}const ea=e=>(0,p.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,width:`1em`,height:`1em`,viewBox:`0 0 48 48`,...e,children:(0,p.jsxs)(`g`,{fill:`none`,stroke:`#000`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:4,children:[(0,p.jsx)(`path`,{d:`m20 8 4-4m0 0 4 4m-4-4v12M20 40l4 4m0 0 4-4m-4 4V32M40 20l4 4m0 0-4 4m4-4H32M8 20l-4 4m0 0 4 4m-4-4h12`}),(0,p.jsx)(`circle`,{cx:24,cy:24,r:2})]})});var ta=ea;const na=e=>(0,p.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,width:`1em`,height:`1em`,viewBox:`0 0 24 24`,...e,children:(0,p.jsx)(`path`,{fill:`currentColor`,d:`M20 22H4q-.825 0-1.413-.588T2 20V8q0-.825.588-1.413T4 6h5.975v2H4v12h16v-3.975h2V20q0 .825-.588 1.413T20 22ZM4 20V8v8.025-.675V20Zm13-5.975-1.55-3.475L11.975 9l3.475-1.55L17 4l1.55 3.45L22 9l-3.45 1.55L17 14.025Z`})});var ra=na;const ia={skipEditingOnCreate:!0},aa=`<h2>New step</h2><p>Description</p>`,oa={id:`@exhibitions/slideshow-center-panel`,label:`Slideshow workbench`,icon:(0,p.jsx)(ra,{}),render:()=>(0,p.jsx)(sa,{})};function sa(){let{structural:e,technical:t}=(0,l.useManifestEditor)(),n=e.items.get(),r={id:t.id.get(),type:`Manifest`},i=(0,d.useVault)(),[,a]=(0,l.useCreator)(r,`items`,`Canvas`,void 0,{isPainting:!0}),o=(0,u.useInStack)(`Canvas`),{edit:s}=(0,l.useLayoutActions)(),c=U(e=>e.clear),f=o?.resource.source.id||n[0]?.id,g=f?n.findIndex(e=>e.id===f):-1,_=g>=0?g:0,v=g>=0?n[g]:n[0]||null;(0,m.useEffect)(()=>{for(let e of n)st(i,i.get(e))},[n,i]);let y=()=>{a.createFiltered(`exhibition-slideshow-slide`,n.length?_+1:void 0)},b=(e,t,n=!1)=>{s({id:e.id,type:`Canvas`},{parent:r,property:`items`,index:t},{forceOpen:n})},x=(e,t)=>{c(),b(e,t)},S=t=>{if(!n[t]||!confirm(`Are you sure you want to delete this slide?`))return;let r=n[t+1]||n[t-1]||null,i=n[t+1]?t:t-1;c(),e.items.deleteAtIndex(t),r&&b(r,Math.max(0,i))},C=_>0?n[_-1]:void 0,w=_<n.length-1?n[_+1]:void 0;return n.length?(0,p.jsx)(ca,{children:(0,p.jsxs)(`div`,{className:`exhibition-slideshow-main flex min-h-full flex-col gap-6 pb-12 pt-16`,children:[(0,p.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3 px-8`,style:{paddingInlineStart:`calc(2rem + var(--manifest-editor-layout-left-sidebar-small, 0px))`,paddingInlineEnd:`calc(2rem + var(--manifest-editor-layout-right-sidebar-small, 0px))`},children:[(0,p.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,p.jsx)(`p`,{className:`text-sm font-semibold uppercase tracking-wider text-me-primary-500`,children:`Slideshow workbench`}),(0,p.jsx)(`h2`,{className:`exhibition-slideshow-heading truncate text-2xl font-bold text-slate-900`,children:v?(0,p.jsx)(d.CanvasContext,{canvas:v.id,children:(0,p.jsx)(la,{})}):`Slides`}),(0,p.jsxs)(`p`,{className:`exhibition-slideshow-muted mt-1 text-sm font-semibold text-slate-500`,children:[`Slide `,_+1,` of `,n.length]})]}),(0,p.jsx)(ua,{current:_+1,total:n.length,onPrevious:C?()=>x(C,_-1):void 0,onNext:w?()=>x(w,_+1):void 0}),(0,p.jsx)(`div`,{children:(0,p.jsx)(h.ActionButton,{primary:!0,onPress:y,children:`Add new slide`})})]}),(0,p.jsxs)(`div`,{className:`flex flex-1 flex-col gap-5 px-8`,style:{paddingInlineStart:`calc(1.5rem + var(--manifest-editor-layout-left-sidebar-small, 0px))`,paddingInlineEnd:`calc(1.5rem + var(--manifest-editor-layout-right-sidebar-small, 0px))`},children:[(0,p.jsx)(`div`,{className:`exhibition-slideshow-preview-frame flex items-center justify-center overflow-hidden rounded-lg bg-slate-100`,children:v?(0,p.jsx)(d.CanvasContext,{canvas:v.id,children:(0,p.jsx)(fa,{})}):null}),(0,p.jsxs)(`aside`,{className:`exhibition-slideshow-slide-strip overflow-hidden rounded-lg border border-slate-200 bg-white p-4`,children:[(0,p.jsx)(`div`,{className:`exhibition-slideshow-heading mb-3 text-sm font-semibold text-slate-700`,children:`Slides`}),(0,p.jsx)(`div`,{className:`flex gap-3 overflow-x-auto pb-2`,children:n.map((e,t)=>(0,p.jsx)(d.CanvasContext,{canvas:e.id,children:(0,p.jsx)(Oa,{index:t,selected:v?.id===e.id,onPress:()=>x(e,t),onDelete:()=>S(t)})},e.id))})]})]})]})}):(0,p.jsx)(ca,{children:(0,p.jsx)(`div`,{className:`flex min-h-full items-center justify-center px-24 py-12`,children:(0,p.jsxs)(`div`,{className:`w-full max-w-4xl`,children:[(0,p.jsx)(`p`,{className:`text-sm font-semibold uppercase tracking-wider text-me-primary-500`,children:`Slideshow exhibition`}),(0,p.jsx)(`h2`,{className:`mt-2 text-3xl font-bold text-slate-900`,children:`Create your first slideshow slide`}),(0,p.jsx)(`p`,{className:`mt-3 max-w-2xl text-sm text-slate-600`,children:`Add a new slide and choose one of the supported slideshow slide types. You can add images, text, media, and tour steps after the slide is created.`}),(0,p.jsx)(`div`,{className:`mt-8`,children:(0,p.jsx)(h.ActionButton,{primary:!0,large:!0,onPress:y,children:`Add new slide`})})]})})})}function ca({children:e}){return(0,p.jsx)(h.SidebarContent,{className:`exhibition-slideshow-workbench h-full overflow-x-hidden overflow-y-auto bg-[#f8f6f3]`,children:e})}function la(){return(0,p.jsx)(p.Fragment,{children:Ea((0,d.useCanvas)()?.label,`Untitled slide`)||`Untitled slide`})}function ua({current:e,total:t,onPrevious:n,onNext:r}){return(0,p.jsxs)(`div`,{className:`exhibition-slideshow-navigation flex items-stretch overflow-hidden rounded-lg border border-slate-200 bg-white text-sm text-slate-800 shadow-sm`,children:[(0,p.jsx)(v.Button,{className:`border-none bg-white px-5 py-3 font-semibold transition hover:bg-slate-50 disabled:cursor-not-allowed disabled:text-slate-300`,isDisabled:!n,onPress:n,children:`Previous`}),(0,p.jsxs)(`span`,{className:`exhibition-slideshow-navigation-current flex min-w-[96px] items-center justify-center border-x border-slate-200 bg-slate-50 px-4 font-bold text-slate-900`,children:[e,` of `,t]}),(0,p.jsx)(v.Button,{className:`border-none bg-white px-5 py-3 font-semibold transition hover:bg-slate-50 disabled:cursor-not-allowed disabled:text-slate-300`,isDisabled:!r,onPress:r,children:`Next`})]})}function da({current:e,total:t,onPrevious:n,onNext:r}){return(0,p.jsxs)(`div`,{className:`exhibition-slideshow-navigation flex items-stretch overflow-hidden rounded-md border border-slate-200 bg-white text-xs text-slate-800 shadow-sm`,children:[(0,p.jsx)(v.Button,{className:`border-none bg-white px-3 py-2 font-semibold transition hover:bg-slate-50 disabled:cursor-not-allowed disabled:text-slate-300`,isDisabled:!n,onPress:n,children:`Previous step`}),(0,p.jsx)(`span`,{className:`exhibition-slideshow-navigation-current flex min-w-[84px] items-center justify-center border-x border-slate-200 bg-slate-50 px-3 font-bold text-slate-900`,children:t?`${e} of ${t}`:`0 of 0`}),(0,p.jsx)(v.Button,{className:`border-none bg-white px-3 py-2 font-semibold transition hover:bg-slate-50 disabled:cursor-not-allowed disabled:text-slate-300`,isDisabled:!r,onPress:r,children:`Next step`})]})}function fa(){let e=(0,d.useCanvas)(),t=(0,d.useVault)(),n=(0,l.useInlineCreator)(),r=W(e=>e.centerPanelMode),i=W(e=>e.setCenterPanelMode),a=r,o=i,[s,c]=(0,m.useState)(null),[u,f]=(0,m.useState)(`box`),h=(0,m.useRef)(null),g=(0,m.useRef)(null),_=e?.annotations?.[0]?.id,b=e?.items?.[0]?{id:e.items[0].id,type:`AnnotationPage`}:void 0,[,x]=(0,l.useCreator)(b,`items`,`Annotation`,e?$e(e):void 0,{isPainting:!0}),{selectedAnnotationId:S,repositioningAnnotationId:C,selectedTextRegion:w,repositioningTextRegion:T,selectedTourStepId:E,selectAnnotation:D,startRepositioning:O,stopRepositioning:k,startTextRepositioning:A,stopTextRepositioning:j,selectTourStep:M,stopTourStepRepositioning:N}=U(),ee=W(e=>e.requestTab),te=W(e=>e.showTourSteps),P=W(e=>e.setShowTourSteps),F=(0,d.useVaultSelector)((t,n)=>e?G(n,e):[],[e?.id,b?.id]),I=F.find(e=>e.id===S),ne=w===`editorial-text`?ct(e).text:null,L=(0,d.useVaultSelector)((t,n)=>e?et(n,e):[],[e?.id,_]),R=L.find(e=>e.id===E)||L[0],z=R?Math.max(0,L.findIndex(e=>e.id===R.id)):-1,re=tt(t,e),B=te&&re,ie=e=>{let t=L[e];t?.id&&M(t.id)};(0,m.useEffect)(()=>{h.current=null,g.current=null,c(null),f(`box`)},[e?.id]),(0,m.useEffect)(()=>{!re&&te&&(P(!1),N(),c(null))},[P,te,N,re]),(0,m.useEffect)(()=>{B&&o(`edit`)},[B]),(0,m.useEffect)(()=>{if(h.current===null){h.current=F.length;return}let e=F[F.length-1];F.length>h.current&&e?.id&&(D(e.id),ee(`content`),P(!1)),h.current=F.length},[F,ee,D,P]),(0,m.useEffect)(()=>{if(g.current===null){g.current=L.length;return}let e=L[L.length-1];L.length>g.current&&e?.id&&(M(e.id),k(),j(),P(!0)),g.current=L.length},[M,P,k,j,L]);let ae=()=>{let e=!te;P(e),e?(k(),j(),R?.id&&M(R.id)):N()},oe=()=>{e&&n.create(`@manifest-editor/empty-annotation-page`,{label:{en:[`Tour steps`]}},{target:{id:e.id,type:`Canvas`},targetType:`AnnotationPage`,parent:{property:`annotations`,resource:{id:e.id,type:`Canvas`}}})},se=()=>{!e||!_||(P(!0),k(),j(),f(`box`),c({type:`add`}))},ce=()=>{R?.id&&(P(!0),k(),j(),f(`box`),c({type:`edit`,annotationId:R.id}))};return(0,p.jsxs)(`div`,{className:`exhibition-slideshow-preview-card group relative flex max-h-full flex-col overflow-hidden rounded-md bg-white shadow-xl ring-1 ring-black/10`,style:{width:`100%`,height:`min(68vh, 760px)`,minHeight:420},children:[(0,p.jsxs)(`div`,{className:`exhibition-slideshow-toolbar flex flex-wrap items-center justify-between gap-3 border-b border-slate-200 bg-white px-4 py-3`,children:[(0,p.jsx)(`span`,{className:`exhibition-slideshow-muted text-xs font-semibold text-slate-500`,children:a===`edit`?`Click content to edit or reposition it`:`Slideshow layout preview (approximate)`}),(0,p.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[a===`edit`?(0,p.jsxs)(p.Fragment,{children:[re?(0,p.jsx)(v.Button,{className:(0,y.twMerge)(`rounded-md border px-3 py-2 text-xs font-semibold shadow-sm transition`,B?`border-me-primary-500 bg-me-primary-50 text-me-primary-600`:`border-slate-200 bg-white text-slate-700 hover:border-me-primary-300`),onPress:ae,children:B?`Hide tour steps`:`Show tour steps`}):null,B?(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(da,{current:z+1,total:L.length,onPrevious:z>0?()=>ie(z-1):void 0,onNext:z>=0&&z<L.length-1?()=>ie(z+1):void 0}),_?(0,p.jsx)(v.Button,{className:`rounded-md bg-me-primary-500 px-3 py-2 text-xs font-semibold text-white shadow-sm transition hover:bg-me-primary-600`,onPress:se,children:`Add tour step`}):(0,p.jsx)(v.Button,{className:`rounded-md bg-me-primary-500 px-3 py-2 text-xs font-semibold text-white shadow-sm transition hover:bg-me-primary-600`,onPress:oe,children:`Create tour`})]}):(0,p.jsx)(v.Button,{className:`rounded-md bg-me-primary-500 px-3 py-2 text-xs font-semibold text-white shadow-sm transition hover:bg-me-primary-600`,onPress:()=>{P(!1),N(),x.create(void 0,ia)},children:`Add content`})]}):null,(0,p.jsxs)(`div`,{className:`flex shrink-0 overflow-hidden rounded-md border border-slate-200 bg-slate-50 text-xs font-semibold`,children:[(0,p.jsx)(Da,{selected:a===`edit`,onPress:()=>o(`edit`),children:`Edit`}),(0,p.jsx)(Da,{selected:a===`preview`,onPress:()=>o(`preview`),children:`Preview`})]})]})]}),(0,p.jsxs)(`div`,{className:`relative min-h-0 flex-1 bg-black`,children:[(0,p.jsx)(yt,{editable:a===`edit`,mode:a,showTourSteps:B}),s&&e&&_?(0,p.jsx)(ba,{annotationPageId:_,canvas:e,mode:s,selectedTool:u,setSelectedTool:f,vault:t,onCancel:()=>c(null),onComplete:e=>{e&&M(e),P(!0),c(null)}}):null,!s&&a===`edit`&&!B&&I&&e?(0,p.jsx)(ga,{annotation:I,canvas:e,isRepositioning:C===I.id,onStartReposition:()=>O(I.id),onStopReposition:k,vault:t}):null,!s&&a===`edit`&&!B&&ne&&e?(0,p.jsx)(ga,{canvas:e,currentBox:ne,isRepositioning:T===w,label:`Editorial text`,onStartReposition:()=>A(`editorial-text`),onStopReposition:j,setBox:n=>ot(t,e,n),vault:t}):null,!s&&a===`edit`&&B&&e?R?(0,p.jsx)(ga,{annotation:R,canvas:e,isRepositioning:!1,label:`Selected tour step target`,onStopReposition:N,showBoxFields:!0,showRepositionButton:!1,vault:t,children:_?(0,p.jsx)(pa,{annotationPageId:_,canvas:e,onAddTourStep:se,onEditTarget:ce,selectedTourStepId:R?.id}):null}):(0,p.jsx)(ha,{label:`Tour steps`,children:_?(0,p.jsx)(pa,{annotationPageId:_,canvas:e,onAddTourStep:se,onEditTarget:ce,selectedTourStepId:R?.id}):(0,p.jsx)(ma,{onCreate:oe})}):null]})]})}function pa({annotationPageId:e,canvas:t,onAddTourStep:n,onEditTarget:r,selectedTourStepId:i}){return(0,p.jsx)(l.ResourceEditingProvider,{resource:t,children:(0,p.jsx)(d.AnnotationPageContext,{annotationPage:e,children:(0,p.jsxs)(`div`,{className:`space-y-3 text-slate-800`,children:[(0,p.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,p.jsx)(`h3`,{className:`text-sm font-semibold text-slate-800`,children:`Tour steps`}),(0,p.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[i?(0,p.jsx)($,{label:`Edit target`,onPress:r}):null,(0,p.jsx)($,{primary:!0,label:`Add step`,onPress:n})]})]}),(0,p.jsx)(`p`,{className:`text-xs text-slate-500`,children:`Select a step below. Use the quick box controls here, or edit the target with the Atlas drawing tools.`}),(0,p.jsx)(`div`,{className:`max-h-72 overflow-y-auto pr-1`,children:(0,p.jsx)(_i,{reorderable:!1,useSlideshowWorkbench:!0})})]})})})}function ma({onCreate:e}){return(0,p.jsxs)(`div`,{className:`space-y-3 text-slate-800`,children:[(0,p.jsx)(`p`,{className:`text-xs text-slate-600`,children:`This slide does not have a tour annotation page yet.`}),(0,p.jsx)($,{primary:!0,label:`Create tour`,onPress:e})]})}function ha({children:e,label:t}){return(0,p.jsxs)(`div`,{className:`absolute bottom-4 left-4 z-40 max-w-[min(34rem,calc(100%-2rem))] rounded-lg bg-white/95 p-3 text-xs shadow-lg ring-1 ring-black/10`,children:[(0,p.jsx)(`div`,{className:`mb-2 font-semibold text-slate-700`,children:t}),e]})}function ga({annotation:e,canvas:t,children:n,currentBox:r,isRepositioning:i,label:a=`Selected content`,onStartReposition:o,onStopReposition:s,setBox:c,vault:l,hidePositionControls:u=!1,showBoxFields:d=!1,showRepositionButton:f=!0}){let h=(0,m.useRef)(null),g=(0,m.useRef)(null),[_,v]=(0,m.useState)(null),b=Number(t?.width)||1920,x=Number(t?.height)||1080,S=r||it(e,t),C=c||(n=>at(l,t,e.id,n)),w=Math.round(b/2),T=Math.round(x/2),E=e=>{let t=h.current,n=t?.offsetParent,r=t?.getBoundingClientRect(),i=n?.getBoundingClientRect();!t||!r||!i||(e.currentTarget.setPointerCapture(e.pointerId),g.current={pointerId:e.pointerId,startX:e.clientX,startY:e.clientY,panelX:r.left-i.left,panelY:r.top-i.top,maxX:Math.max(16,i.width-r.width-16),maxY:Math.max(16,i.height-r.height-16)})},D=e=>{let t=g.current;!t||t.pointerId!==e.pointerId||v({x:Math.min(t.maxX,Math.max(16,t.panelX+e.clientX-t.startX)),y:Math.min(t.maxY,Math.max(16,t.panelY+e.clientY-t.startY))})},O=e=>{g.current?.pointerId===e.pointerId&&(g.current=null,e.currentTarget.hasPointerCapture(e.pointerId)&&e.currentTarget.releasePointerCapture(e.pointerId))};return(0,p.jsx)(`div`,{ref:h,className:(0,y.twMerge)(`absolute z-40 w-[min(30rem,calc(100%-2rem))] rounded-lg bg-white/95 p-3 text-xs shadow-lg ring-1 ring-black/10`,_?null:`bottom-4 left-4`),style:_?{left:_.x,top:_.y}:void 0,children:(0,p.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,p.jsxs)(`div`,{className:`min-w-[280px]`,children:[(0,p.jsxs)(`div`,{className:`mb-2 flex items-center justify-between gap-3`,children:[(0,p.jsx)(`span`,{className:`font-semibold text-slate-700`,children:a}),(0,p.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,p.jsx)(`button`,{className:`cursor-move rounded border border-slate-200 bg-white px-2 py-1 text-[11px] font-semibold text-slate-600 transition hover:border-me-primary-300 hover:text-me-primary-600`,type:`button`,onPointerDown:E,onPointerMove:D,onPointerUp:O,onPointerCancel:O,children:(0,p.jsx)(ta,{})}),(0,p.jsxs)(`span`,{className:`text-slate-400`,children:[Math.round(S.width),` x `,Math.round(S.height)]})]})]}),u?null:(0,p.jsxs)(`div`,{className:`space-y-2`,children:[(0,p.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[f&&o?(0,p.jsx)($,{onPress:o,label:`Reposition`,primary:!0}):null,i&&s?(0,p.jsx)($,{onPress:s,label:`Stop moving`}):null,(0,p.jsx)($,{onPress:()=>C({x:0,y:0,width:b,height:x}),label:`Fill`}),(0,p.jsx)($,{onPress:()=>C({x:Math.round(b*.1),y:Math.round(x*.1),width:Math.round(b*.8),height:Math.round(x*.8)}),label:`Centre`}),(0,p.jsx)($,{onPress:()=>C({x:0,y:0,width:w,height:x}),label:`Left`}),(0,p.jsx)($,{onPress:()=>C({x:w,y:0,width:w,height:x}),label:`Right`}),(0,p.jsx)($,{onPress:()=>C({x:0,y:0,width:b,height:T}),label:`Top`}),(0,p.jsx)($,{onPress:()=>C({x:0,y:T,width:b,height:T}),label:`Bottom`})]}),d?(0,p.jsx)(_a,{box:S,onChange:C}):null]})]}),n?(0,p.jsx)(`div`,{className:`w-full border-t border-slate-200 pt-3`,children:n}):null]})})}function _a({box:e,onChange:t}){let n=(n,r)=>{let i=Number(r);Number.isFinite(i)&&t({...e,[n]:Math.round(i)})};return(0,p.jsxs)(`div`,{className:`grid grid-cols-4 gap-2 pt-1`,children:[(0,p.jsx)(va,{label:`X`,value:e.x,onChange:e=>n(`x`,e)}),(0,p.jsx)(va,{label:`Y`,value:e.y,onChange:e=>n(`y`,e)}),(0,p.jsx)(va,{label:`W`,value:e.width,onChange:e=>n(`width`,e)}),(0,p.jsx)(va,{label:`H`,value:e.height,onChange:e=>n(`height`,e)})]})}function va({label:e,value:t,onChange:n}){return(0,p.jsxs)(`label`,{className:`block text-[11px] font-semibold text-slate-500`,children:[e,(0,p.jsx)(`input`,{className:`mt-1 w-full rounded border border-slate-200 bg-white px-1.5 py-1 text-xs text-slate-900 outline-none focus:border-me-primary-400 focus:ring-1 focus:ring-me-primary-100`,type:`number`,value:Math.round(t),onChange:e=>n(e.target.value)})]})}function ya(e,t,n,r){let i=`${n}/tour-step/${Date.now()}-${Math.random().toString(36).slice(2,8)}`,a=`${i}/body/en`,o=e.get?.({id:n,type:`AnnotationPage`})||{},s=Array.isArray(o?.items)?o.items:[],c=()=>{e.dispatch((0,j.importEntities)({entities:{ContentResource:{[a]:{id:a,type:`TextualBody`,language:`en`,format:`text/html`,value:`<h2>New step</h2><p>Description</p>`}},Annotation:{[i]:{id:i,type:`Annotation`,motivation:`tagging`,label:{en:[`New step`]},body:[{id:a,type:`ContentResource`}],target:r}}}})),e.dispatch((0,j.addMappings)({mapping:{[a]:`ContentResource`,[i]:`Annotation`}})),e.modifyEntityField({id:n,type:`AnnotationPage`},`items`,[...s,{id:i,type:`Annotation`}])};return e.batch?e.batch(c):c(),i}function ba({annotationPageId:e,canvas:t,mode:n,selectedTool:r,setSelectedTool:i,vault:a,onCancel:o,onComplete:s}){let c=(0,m.useRef)(null),[l,u]=(0,m.useState)(null),[d,f]=(0,m.useState)(null),[h,g]=(0,m.useState)([]),_=Number(t?.width)||1920,v=Number(t?.height)||1080,y=e=>{let t=c.current;if(!t)return{x:0,y:0};let n=t.createSVGPoint();n.x=e.clientX,n.y=e.clientY;let r=t.getScreenCTM()?.inverse(),i=r?n.matrixTransform(r):n;return{x:Ta(Math.round(i.x),0,_),y:Ta(Math.round(i.y),0,v)}},b=e=>{if(e.preventDefault(),r===`polygon`){let t=y(e);g(e=>[...e,t]);return}u(y(e)),f(null)},x=e=>{if(!l||r===`polygon`)return;let t=y(e);r===`box`&&f({type:`box`,x:Math.min(l.x,t.x),y:Math.min(l.y,t.y),width:Math.abs(t.x-l.x),height:Math.abs(t.y-l.y)}),r===`circle`&&f({type:`circle`,cx:l.x,cy:l.y,r:Math.round(Math.sqrt((t.x-l.x)**2+(t.y-l.y)**2))}),r===`line`&&f({type:`line`,x1:l.x,y1:l.y,x2:t.x,y2:t.y})},S=()=>{u(null)},C=r===`polygon`&&h.length?{type:`polygon`,points:h}:d,w=()=>{u(null),f(null),g([])};return(0,p.jsxs)(`div`,{className:`absolute inset-0 z-30`,children:[(0,p.jsxs)(`svg`,{ref:c,className:`absolute inset-0 h-full w-full cursor-crosshair touch-none`,preserveAspectRatio:`xMidYMid meet`,viewBox:`0 0 ${_} ${v}`,onPointerDown:b,onPointerMove:x,onPointerUp:S,onPointerCancel:S,children:[(0,p.jsx)(`rect`,{x:0,y:0,width:_,height:v,fill:`transparent`}),C?(0,p.jsx)(Sa,{shape:C}):null,h.map((e,t)=>(0,p.jsx)(`circle`,{cx:e.x,cy:e.y,r:8,fill:`white`,stroke:`#be4778`,strokeWidth:4},`${e.x}-${e.y}-${t}`))]}),(0,p.jsxs)(`div`,{className:`absolute left-4 top-4 z-40 flex flex-wrap items-center gap-2 rounded-lg bg-white/95 p-2 text-xs shadow-lg ring-1 ring-black/10`,children:[(0,p.jsx)(`span`,{className:`mr-2 font-semibold text-slate-700`,children:n.type===`add`?`Draw new tour step`:`Edit target`}),(0,p.jsx)(xa,{active:r===`box`,label:`Box`,onPress:()=>{w(),i(`box`)}}),(0,p.jsx)(xa,{active:r===`circle`,label:`Circle`,onPress:()=>{w(),i(`circle`)}}),(0,p.jsx)(xa,{active:r===`line`,label:`Line`,onPress:()=>{w(),i(`line`)}}),(0,p.jsx)(xa,{active:r===`polygon`,label:`Polygon`,onPress:()=>{w(),i(`polygon`)}}),(0,p.jsx)($,{primary:!0,label:n.type===`add`?`Create step`:`Save target`,onPress:()=>{if(!C)return;let r=Ca(t.id,C);if(n.type===`edit`){a.modifyEntityField({id:n.annotationId,type:`Annotation`},`target`,r),s(n.annotationId);return}s(ya(a,t,e,r))}}),(0,p.jsx)($,{label:`Clear`,onPress:w}),(0,p.jsx)($,{label:`Cancel`,onPress:o})]})]})}function xa({active:e,label:t,onPress:n}){return(0,p.jsx)(v.Button,{className:(0,y.twMerge)(`rounded-md border px-2.5 py-1.5 font-semibold transition`,e?`border-me-primary-500 bg-me-primary-500 text-white`:`border-slate-200 bg-white text-slate-700 hover:border-me-primary-300 hover:bg-me-primary-50`),onPress:n,children:t})}function Sa({shape:e}){let t={fill:`rgba(190, 71, 120, 0.18)`,stroke:`#be4778`,strokeWidth:6,vectorEffect:`non-scaling-stroke`};return e.type===`box`?(0,p.jsx)(`rect`,{...t,x:e.x,y:e.y,width:e.width,height:e.height}):e.type===`circle`?(0,p.jsx)(`circle`,{...t,cx:e.cx,cy:e.cy,r:e.r}):e.type===`line`?(0,p.jsx)(`line`,{x1:e.x1,y1:e.y1,x2:e.x2,y2:e.y2,stroke:`#be4778`,strokeWidth:6,vectorEffect:`non-scaling-stroke`}):(0,p.jsx)(`polygon`,{...t,points:e.points.map(e=>`${e.x},${e.y}`).join(` `)})}function Ca(e,t){return t.type===`box`?`${e}#xywh=${Math.round(t.x)},${Math.round(t.y)},${Math.round(t.width)},${Math.round(t.height)}`:{source:e,selector:{type:`SvgSelector`,value:wa(t)}}}function wa(e){return e.type===`circle`?`<svg xmlns="http://www.w3.org/2000/svg"><circle cx="${Math.round(e.cx)}" cy="${Math.round(e.cy)}" r="${Math.round(e.r)}" /></svg>`:e.type===`line`?`<svg xmlns="http://www.w3.org/2000/svg"><line x1="${Math.round(e.x1)}" y1="${Math.round(e.y1)}" x2="${Math.round(e.x2)}" y2="${Math.round(e.y2)}" /></svg>`:`<svg xmlns="http://www.w3.org/2000/svg"><polygon points="${e.points.map(e=>`${Math.round(e.x)},${Math.round(e.y)}`).join(` `)}" /></svg>`}function Ta(e,t,n){return Math.min(n,Math.max(t,e))}function Ea(e,t=``){if(!e)return t;if(typeof e==`string`)return e;let n=e.en||e.none||Object.values(e).flat();return Array.isArray(n)&&n.length?String(n[0]):t}function $({label:e,onPress:t,primary:n}){return(0,p.jsx)(v.Button,{className:(0,y.twMerge)(`rounded-md border px-2.5 py-1.5 font-semibold transition`,n?`border-me-primary-500 bg-me-primary-500 text-white hover:bg-me-primary-600`:`border-slate-200 bg-white text-slate-700 hover:border-me-primary-300 hover:bg-me-primary-50`),onPress:t,children:e})}function Da({children:e,selected:t,onPress:n}){return(0,p.jsx)(v.Button,{className:(0,y.twMerge)(`border-none px-3 py-2 transition`,t?`bg-me-primary-500 text-white`:`bg-transparent text-slate-600 hover:bg-white`),onPress:n,children:e})}function Oa({index:e,selected:t,onPress:n,onDelete:r}){let i=(0,d.useCanvas)();return(0,p.jsxs)(`div`,{className:(0,y.twMerge)(`exhibition-slideshow-slide-card relative w-44 shrink-0 rounded-md border bg-white p-2 text-left transition`,t?`border-me-primary-500 ring-2 ring-me-primary-200`:`border-slate-200 hover:border-me-primary-300`),children:[(0,p.jsxs)(v.Button,{className:`block w-full border-none bg-transparent p-0 text-left`,onPress:n,children:[(0,p.jsx)(`div`,{className:`aspect-video overflow-hidden rounded`,style:{backgroundColor:`#0e0d12`},children:(0,p.jsx)(yt,{className:`pointer-events-none h-full w-full`,mode:`preview`})}),(0,p.jsxs)(`div`,{className:`mt-2 flex items-center gap-2 pr-7`,children:[(0,p.jsx)(`span`,{className:`flex h-6 w-6 shrink-0 items-center justify-center rounded bg-slate-100 text-xs font-semibold text-slate-600`,children:e+1}),(0,p.jsx)(d.LocaleString,{className:`min-w-0 truncate text-sm font-medium text-slate-800`,children:i?.label})]})]}),(0,p.jsx)(v.Button,{className:`absolute bottom-2 right-2 flex items-center gap-1 rounded border border-me-primary-100 bg-white px-2 py-1 text-xs font-semibold text-me-primary-500 shadow-sm transition hover:bg-me-primary-50`,"aria-label":`Delete slide ${e+1}`,onPress:r,children:`Delete`})]})}const ka=(0,l.extendApp)((0,l.mapApp)(c),{id:`exhibition-slideshow-editor`,title:`Exhibition Editor (slideshow)`,project:!0,projectType:`Manifest`},{config:{editorConfig:{Canvas:{singleTab:`@exhibition/slideshow-workbench-editor`,hideTabs:[`@manifest-editor/overview`,`@manifest-editor/technical-properties`,`@manifest-editor/linking-properties`,`@manifest-editor/nav-place-editor`,`@manifest-editor/canvas-structural`,`@manifest-editor/descriptive-properties`,`@manifest-editor/overview-canvas-editor`,`@manifest-editor/metadata`]}}},leftPanels:[Mt],centerPanels:[oa],annotations:[M],leftPanelIds:[`left-panel-manifest`],background:[Qt],canvasEditors:[Zi],editors:[Ui,wi,Zr,fr,ii,vi],creators:[An,jn,Bn,Un,Ln]}),Aa=(0,l.extendApp)((0,l.mapApp)(c),{id:`exhibition-editor`,title:`Exhibition Editor`,project:!0,projectType:`Manifest`},{config:{editorConfig:{Canvas:{hideTabs:[`@manifest-editor/overview`,`@manifest-editor/technical-properties`,`@manifest-editor/linking-properties`,`@manifest-editor/nav-place-editor`,`@manifest-editor/canvas-structural`,`@manifest-editor/descriptive-properties`,`@manifest-editor/overview-canvas-editor`,`@manifest-editor/metadata`]}}},leftPanels:[jt,Bt],centerPanels:[_e,ze],annotations:[M],leftPanelIds:[`left-panel-manifest`],background:[Qt],canvasEditors:[en,xn,an],editors:[wi,Hi,Zr,fr,ii,vi],creators:[In,Hn,Tn,Cn,X,Pn,zn]});exports.PresetIcon=Yi,exports.exhibitionEditorPreset=Aa,exports.exhibitionEditorScrollingPreset=Xi,exports.exhibitionEditorSlideshowPreset=ka;