@manifest-editor/exhibition-preset 2.1.0 → 2.2.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 +3 -2
- package/dist/index.cjs.map +1 -0
- package/dist/index.css +0 -3
- package/dist/index.d.cts +81 -8
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.ts +81 -8
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/package.json +22 -22
- package/dist/index.css.map +0 -1
package/dist/index.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import*as e from"@manifest-editor/manifest-preset";import{ResourceEditingProvider as t,ResourceEditingReactContext as n,createIframeVaultBridge as r,extendApp as i,mapApp as a,useAppResource as o,useAtlasStore as s,useConfig as c,useCreator as l,useEditingResource as u,useEditingStack as d,useEditor as f,useGenericEditor as p,useInlineCreator as m,useLayoutActions as h,useLayoutState as g,useLocalStorage as _,useManifestEditor as v,useSaveConfig as y}from"@manifest-editor/shell";import{AnnotationPopUpSwitcherButton as b,AppDropdown as x,BehaviorEditor as S,CanvasPanelEditor as C,DimensionsTriplet as w,HTMLAnnotationEditor as T,Input as ee,InputContainer as E,InputLabel as te,LanguageMapEditor as D,LinkingPropertyList as ne,PaintingAnnotationList as re,PromptToAddPaintingAnnotations as O,ReorderList as ie,TiptapLanguageFieldEditor as ae,TiptapRichTextLanguageField as oe,ViewerAnnotationPage as k,createAppActions as A,getInternationalStringText as j,getYouTubeId as se,resolveContentResource as M,useAnnotationEditing as ce,useAnnotationEditor as le,useAnnotationInfo as ue,useAnnotationThumbnail as de,useInStack as fe,useToggleList as pe}from"@manifest-editor/editors";import{AnnotationContext as me,AnnotationPageContext as he,CanvasContext as ge,LocaleString as N,useAnnotation as _e,useAnnotationPage as ve,useCanvas as P,useCurrentAnnotationActions as ye,useCurrentAnnotationMetadata as be,useCurrentAnnotationRequest as xe,useManifest as F,useRenderingStrategy as Se,useRequestAnnotation as Ce,useVault as I,useVaultSelector as we}from"react-iiif-vault";import{create as Te,useStore as Ee}from"zustand";import{Fragment as L,jsx as R,jsxs as z}from"react/jsx-runtime";import{forwardRef as De,useCallback as Oe,useContext as ke,useEffect as B,useLayoutEffect as Ae,useMemo as V,useRef as H,useState as U}from"react";import{ActionButton as W,AddIcon as je,AnnotationPopInIcon as Me,AnnotationPopOutIcon as Ne,ArrowRightIcon as Pe,DeleteIcon as Fe,EditTextIcon as Ie,EmptyCanvasIcon as Le,HTMLAnnotationBodyRender as Re,HTMLEditor as ze,LazyThumbnail as Be,MoreMenu as Ve,Sidebar as He,SidebarContent as Ue,SidebarHeader as We,TargetIcon as Ge}from"@manifest-editor/components";import{DelftExhibition as Ke}from"exhibition-viewer";import{EditorHooksProvider as qe}from"exhibition-viewer/library";import{Button as G}from"react-aria-components";import{twMerge as K}from"tailwind-merge";import{CanvasListView as Je,CanvasListingIcon as Ye}from"@manifest-editor/manifest-preset/components";import{DndContext as Xe,KeyboardSensor as Ze,PointerSensor as Qe,closestCenter as $e,useSensor as et,useSensors as tt}from"@dnd-kit/core";import{restrictToParentElement as nt}from"@dnd-kit/modifiers";import{SortableContext as rt,rectSortingStrategy as it,sortableKeyboardCoordinates as at,useSortable as ot}from"@dnd-kit/sortable";import{CSS as st}from"@dnd-kit/utilities";import ct from"tiny-invariant";import{creatorHelper as lt,defineCreator as q}from"@manifest-editor/creator-api";import{iiifBrowserCreator as ut,imageServiceCreator as dt,imageUrlCreator as ft,videoAnnotation as pt,youTubeBodyCreator as mt}from"@manifest-editor/creators";import{emptyAnnotation as ht,emptyAnnotationPage as gt,emptyCanvas as _t}from"@iiif/parser";import{getValue as vt}from"@iiif/helpers";import{createImageServiceRequest as yt,imageServiceRequestToString as bt}from"@iiif/parser/image-3";import{addMappings as xt,importEntities as St}from"@iiif/helpers/vault/actions";const Ct={id:`@exhibition/tour-step-annotations`,label:`Tour steps`,render:()=>R(Tt,{})},wt={border:`2px solid rgba(255, 255, 255, 0.3)`,":hover":{borderColor:`#4B67E1`,backgroundColor:`rgba(255, 255, 255, 0.2)`}};function Tt(){let e=P(),t=Ee(s(),e=>e.tool.enabled),{rightPanel:n}=g(),r=n.current===`@manifest-editor/editor`&&n.state?.currentTab?.startsWith(`@exhibition/tour-steps`),i=e?.annotations[0];return!r||!e||t||!i?null:R(L,{children:R(he,{annotationPage:i.id,children:R(k,{showAnnotationNumber:!0,style:wt})})})}const Et=`https://exhibitionviewer.org/iiif/theme-service`,Dt={en:[`Exhibition viewer theme`]},Ot={fontSans:`"Tahoma", "Fira Sans", sans-serif`,fontMono:`"Fira Mono", monospace`,titleTransform:`uppercase`},kt={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`},At={...kt,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`},jt={titleBackground:`#fff`,titleColor:`#444`,annotationBackground:`#fff`,annotationColor:`#333`,annotationRadius:`0px`,annotationMaxWidth:`30em`,infoBlockBackground:`#fff`,infoBlockColor:`#444`},Mt={cutCorners:!0,fullTitleBar:!0,fullWidthGrid:!1,hideTableOfContents:!1,disablePresentation:!1,hideTitle:!1,hideTitleCard:!1,alternativeImageMode:!0,transitionScale:!1,imageInfoIcon:!1,coverImages:!1},Nt={cutCorners:!1,isFloating:!1,floatingPosition:`bottom-left`},Pt={alternativeImageMode:!0,transitionScale:!1,imageInfoIcon:!1,coverImages:!1},Ft={version:1,preset:`delft`,shared:Ot,delft:{tokens:kt,exhibition:Mt,presentation:Nt,slideshow:Pt},scroll:{tokens:jt,options:{showTableOfContents:!1,titleBlock:{fullHeight:!0}}}},It={delft:Ft,minimal:{...Ft,preset:`minimal`,shared:{...Ot,titleTransform:`none`},delft:{...Ft.delft,tokens:At}},gallery:{version:1,preset:`gallery`,shared:{fontSans:`"Gill Sans", "Trebuchet MS", sans-serif`,fontMono:`"Courier Prime", "Courier New", monospace`,titleTransform:`capitalize`},delft:{tokens:{...kt,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:{...Mt,cutCorners:!1,fullTitleBar:!0,fullWidthGrid:!0,alternativeImageMode:!1,transitionScale:!0,imageInfoIcon:!0,coverImages:!0},presentation:{...Nt,isFloating:!0,floatingPosition:`bottom-right`},slideshow:{...Pt,alternativeImageMode:!1,transitionScale:!0,imageInfoIcon:!0,coverImages:!0}},scroll:{tokens:{...jt,titleBackground:`#f8efe1`,titleColor:`#2a2119`,annotationBackground:`#22313f`,annotationColor:`#f8efe1`,annotationRadius:`18px`,annotationMaxWidth:`34em`,infoBlockBackground:`#fff8ee`,infoBlockColor:`#2a2119`},options:{showTableOfContents:!0,titleBlock:{fullHeight:!1}}}}};function Lt(e){return JSON.parse(JSON.stringify(e))}function Rt(e){return!!e&&typeof e==`object`&&!Array.isArray(e)}function zt(e,t){if(!t)return Lt(e);let n=Lt(e);for(let[e,r]of Object.entries(t)){if(r===void 0)continue;let t=n[e];if(Rt(t)&&Rt(r)){n[e]=zt(t,r);continue}n[e]=r}return n}function Bt(e){return typeof e==`string`&&e in It}function Vt(e=`delft`){return Lt(It[e]||Ft)}function Ht(e){let t=Bt(e?.preset)?e.preset:`delft`,n=zt(Vt(t),e||{});return n.version=1,n.preset=t,n}function Ut(e){return`${e}#exhibition-viewer-theme`}function Wt(e,t){return{id:Ut(e),type:`Service`,profile:Et,label:Dt,theme:Ht(t)}}function Gt(e){if(!e?.length)return null;let t=e.findIndex(e=>e?.profile===Et||e?.theme);return t===-1?null:{index:t,service:e[t]}}function Kt(e){return Gt(e)?.service?.theme}function qt(e,t){let n=[...e||[]],r=Gt(n);return r?t?(n[r.index]=t,n):(n.splice(r.index,1),n):(t&&n.push(t),n)}function Jt(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 Yt={id:`@exhibitions/center-panel`,label:`Exhibition editor`,icon:null,render:()=>R(Xt,{}),options:{minWidth:350,maxWidth:350}};function Xt(){let e=F(),t=I(),[n,r]=U(.8),i=H(null),{edit:a,leftPanel:o}=h(),s=V(()=>e?Ht(Kt(e.service||e.services)):null,[e]),c=V(()=>({localeStringEditor:e=>z(`span`,{className:`inline-flex items-center hover:ring-4 hover:ring-me-primary-500`,children:[e.original,R(G,{className:`py-1 px-2 inline-block`,onPress:()=>a(e.resource),children:R(Ie,{className:`text-xl`})})]}),canvasPreviewEditor:e=>z(`div`,{className:`w-full h-full flex-1 flex relative`,children:[e.original,R(`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 B(()=>{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]),Ae(()=>{if(i.current){let e=i.current.offsetWidth/1200;r(Math.max(1,e))}},[]),e?R(`div`,{ref:i,className:`overflow-y-auto delft-exhibition exhibition-viewer`,style:s?Jt(s):void 0,children:R(qe,{hooks:c,children:R(Ke,{skipLoadManifest:!0,customVault:t,manifest:e.id,options:{...s?.delft.exhibition||{},disablePresentation:!0,hideTableOfContents:!0,hideTitle:!0}},n)})}):null}function Zt(e,t){let n=new URLSearchParams;switch($t(n,`manifest`,t.manifest),$t(n,`canvas`,t.canvas),e){case`delft`:case`exhibition`:{let e=t;en(n,`cut-corners`,e.cutCorners),en(n,`full-title-bar`,e.fullTitleBar);break}case`minimal`:{let e=t;n.set(`minimal`,`true`),en(n,`cut-corners`,e.cutCorners),en(n,`full-title-bar`,e.fullTitleBar);break}case`presentation`:{let e=t;n.set(`type`,`presentation`),en(n,`cut-corners`,e.cutCorners),en(n,`floating`,e.floating??e.isFloating),$t(n,`floating-position`,e.floatingPosition);break}case`scroll`:{let e=t;n.set(`type`,`scroll`),tn(n,`minimal`,e.minimal),tn(n,`manifest-editor-preview`,e.manifestEditorPreview),$t(n,`manifest-editor-preview-origin`,e.manifestEditorPreviewOrigin);break}case`slideshow`:{let e=t;n.set(`type`,`slideshow`),tn(n,`minimal`,e.minimal),en(n,`floating`,e.floating),$t(n,`floating-position`,e.floatingPosition);break}}return n}function Qt(e,t){let n=Zt(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 $t(e,t,n){n&&e.set(t,n)}function en(e,t,n){typeof n==`boolean`&&e.set(t,String(n))}function tn(e,t,n){n&&e.set(t,`true`)}const nn=1024,rn=.5;function an({preset:e,presetOptions:t,focusSelectedCanvas:n=!0}){let i=I(),a=o(),s=F(),c=fe(`Canvas`),l=H(null),u=H(null),d=H(null),f=H(a),p=H(null),[m,h]=U(`waiting`),[g,_]=U(0),[v,y]=U(!1),[b,x]=U(!1),S=n&&(c?.resource.source.id||s?.items?.[0]?.id)||null,C=V(()=>Qt(e,t).toString(),[e,t]),w=V(()=>new URL(C).origin,[C]),T=v?rn:1,ee=b?440:g?Math.round(g/T):0,E=ee>0&&ee<=nn;f.current=a,p.current=S;let te=Oe(()=>{let e=l.current;if(!e?.contentWindow)return;d.current?.(),h(`waiting`);let t=new MessageChannel;d.current=r(i,t.port1);try{e.contentWindow.postMessage({_type:`manifest-editor:iframe-preview:connect`,resource:f.current,canvasId:p.current},w,[t.port2]),h(`connected`)}catch{d.current?.(),d.current=null,h(`error`)}},[w,i]);B(()=>{function e(e){e.origin===w&&e.source===l.current?.contentWindow&&e.data?._type===`manifest-editor:iframe-preview:ready`&&te()}return window.addEventListener(`message`,e),()=>{window.removeEventListener(`message`,e),d.current?.(),d.current=null}},[te,w]),B(()=>{let e=l.current?.contentWindow;!e||m!==`connected`||e.postMessage({_type:`manifest-editor:iframe-preview:selection`,resource:a,canvasId:S},w)},[m,a.id,a.type,S,w]),B(()=>{let e=u.current;if(!e)return;let t=()=>{_(e.getBoundingClientRect().width)};t();let n=new ResizeObserver(t);return n.observe(e),()=>n.disconnect()},[]),B(()=>{if(g){if(g>nn){y(!1);return}x(!1)}},[g]);let D=Oe(e=>{y(e),e&&x(!1)},[]),ne=Oe(e=>{x(e),e&&y(!1)},[]);return z(`div`,{className:`flex h-full min-h-0 flex-col bg-zinc-950`,children:[m===`connected`?null:R(`div`,{className:`border-b border-zinc-800 bg-zinc-900 px-3 py-2 text-sm text-zinc-300`,children:m===`error`?`Preview connection failed.`:`Connecting to local exhibition viewer...`}),R(on,{iframeViewportWidth:ee,isMobileViewport:E,showScaleOption:g>0&&g<=nn,showMobileWidthOption:g>nn,useScaledPreview:v,useMobileWidthPreview:b,onUseScaledPreviewChange:D,onUseMobileWidthPreviewChange:ne}),R(`div`,{ref:u,className:K(`flex min-h-0 flex-1 overflow-hidden bg-white`,v?`justify-start`:`justify-center`),children:R(`iframe`,{ref:l,src:C,title:`Exhibition preview`,className:K(`block h-full shrink-0 border-0 bg-white`,b?`shadow-2xl shadow-black/40`:``),style:{width:b?440:v?`${100/rn}%`:`100%`,maxWidth:b?`100%`:void 0,height:v?`${100/rn}%`:`100%`,transform:v?`scale(${rn})`:void 0,transformOrigin:`top left`},onLoad:()=>h(`waiting`)})})]})}function on({iframeViewportWidth:e,isMobileViewport:t,showScaleOption:n,showMobileWidthOption:r,useScaledPreview:i,useMobileWidthPreview:a,onUseScaledPreviewChange:o,onUseMobileWidthPreviewChange:s}){return e?z(`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:[z(`div`,{className:`flex min-w-0 items-center gap-2`,children:[R(`span`,{className:K(`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`}),z(`span`,{className:`truncate text-zinc-400`,children:[`Iframe viewport: `,e,`px. Mobile starts at`,` `,nn,`px and below.`]})]}),n?R(sn,{label:`50% scale`,checked:i,onChange:o}):null,r?R(sn,{label:`Mobile width`,checked:a,onChange:s}):null]}):null}function sn({label:e,checked:t,onChange:n}){return z(`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:[R(`span`,{children:e}),R(`input`,{type:`checkbox`,className:`peer sr-only`,checked:t,onChange:e=>n(e.currentTarget.checked)}),R(`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 cn=`@exhibitions/remote-preview-panel`,ln=`exhibition`,un=[{value:`exhibition`,label:`Full page`},{value:`scroll`,label:`Scroll`},{value:`slideshow`,label:`Slideshow`}];function dn(){let[e,t]=_(`exhibition-preview-preset`,ln),{centerPanel:n}=g(),{centerPanel:r}=h();return[e||ln,Oe(e=>{t(e),n.current===cn&&r.open({id:cn,state:{preset:e}})},[n.current,r,t])]}function fn(e){return z(`svg`,{xmlns:`http://www.w3.org/2000/svg`,width:`1em`,height:`1em`,viewBox:`0 0 24 24`,fill:`currentColor`,...e,children:[R(`title`,{children:`Preview`}),R(`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 pn=ln,mn={id:cn,label:`Exhibition preview`,icon:R(fn,{}),defaultState:{},render:e=>R(hn,{state:e}),options:{minWidth:350}};function hn({state:e}){let[t]=dn();return R(an,{preset:e.preset||t||pn,focusSelectedCanvas:!1})}function gn({children:e}){let t=F(),{edit:n}=h();return z(`div`,{className:`grid auto-rows-auto grid-cols-12 content-center justify-center gap-2 p-2`,children:[R(`div`,{className:`col-span-12 row-span-2 text-black flex flex-col items-center justify-center`,children:R(G,{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:R(N,{className:`block w-full text-left`,children:t?.label})})}),e]})}const _n={"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`},vn={"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`},yn={"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 bn(e){let{isLeft:t,isRight:n,isBottom:r}=Sn(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 xn(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?vn[r]:_n[r]),a.push(yn[i]),a.join(` `)}function Sn(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 Cn(e,t){return t.get(e)?.type===`Canvas`}function wn(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 Tn(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 En(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 Dn=Te(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})})),J=Te(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 On(e){let t=Number(e?.width)||1920,n=Number(e?.height)||1080,r=Bn(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 kn(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 An(e){return kn(e,On(e))}function jn(e,t){return Pn(e,t?.items||[]).filter(e=>(Array.isArray(e?.motivation)?e.motivation:[e?.motivation]).includes(`painting`))}function Mn(e,t){return Pn(e,t?.annotations||[])}function Nn(e,t){return!t||(Array.isArray(t?.behavior)?t.behavior:[]).includes(`info`)?!1:!jn(e,t).some(t=>{let n=Hn(e,t);return!!(Jn(n)||Yn(n))})}function Pn(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 Fn(e,t){return jn(e,t).map(n=>{let r=Hn(e,n);return{annotation:n,box:In(n,t),html:Kn(r),imageUrl:Gn(e,r),videoUrl:Jn(r),youtubeId:Yn(r)}})}function In(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=Un(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=Un(s.split(`xywh=`)[1]);if(e)return e}return{x:0,y:0,width:n,height:r}}function Ln(e,t,n,r){e.modifyEntityField({id:n,type:`Annotation`},`target`,kn(t,Vn(t,r)))}function Rn(e,t,n){let r=Vn(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 zn(e,t){if(t)for(let n of jn(e,t)){let r=n?.target;(r?.type===`SpecificResource`&&r?.source?.type===`Canvas`&&!r.selector||r?.type===`Canvas`||r===t.id)&&Ln(e,t,n.id,Bn(t).content||On(t))}}function Bn(e){let t=Number(e?.width)||1920,n=Number(e?.height)||1080,r=Array.isArray(e?.behavior)?e.behavior:[],i=Wn(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 Vn(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 Hn(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 Un(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 Wn(e){let t=e.find(e=>e.startsWith(`text-xywh=`))?.replace(`text-xywh=`,``);return Un(t)}function Gn(e,t){let n=qn(e,t);if(n?.type===`Choice`){let t=Array.isArray(n.items)?n.items:[];for(let n of t){let t=Gn(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 jn(e,t)){let t=Gn(e,Hn(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 Kn(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 qn(e,t){return t?.type===`SpecificResource`?qn(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 Jn(e){let t=e?.type===`SpecificResource`?e.source:e;return t?.type===`Video`&&!Yn(t)?t.id:null}function Yn(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 Xn=`editorial-text`;function Zn({className:e,editable:t=!1,mode:n=`edit`,showTourSteps:r=!1}){let i=P(),a=I(),o=fe(`Annotation`),s=H(null),c=J(e=>e.requestTab),{selectedAnnotationId:l,repositioningAnnotationId:u,selectedTextRegion:d,repositioningTextRegion:f,selectedTourStepId:p,repositioningTourStepId:m,selectAnnotation:h,startRepositioning:g,selectTextRegion:_,selectTourStep:v}=Dn();B(()=>{zn(a,i)},[i?.id,a]);let y=we((e,t)=>i?Fn(t,i):[],[i?.id,i?.items?.[0]?.id]),b=we((e,t)=>i?Mn(t,i):[],[i?.id,i?.annotations?.[0]?.id]);if(!i)return null;let x=Number(i.width)||1920,S=Number(i.height)||1080,C=Bn(i),w=Array.isArray(i.behavior)?i.behavior:[],T=o?.resource.source.id,ee=n===`edit`&&r,E=n===`edit`&&!r;return z(`div`,{ref:s,className:K(`relative h-full w-full overflow-hidden`,n===`edit`&&`bg-white`,e),style:{aspectRatio:`${x} / ${S}`},children:[y.length?y.map(e=>{let r=T===e.annotation.id,o=r||l===e.annotation.id,d=u===e.annotation.id;return z(`div`,{className:K(`absolute overflow-hidden`,E&&o&&`ring-4 ring-me-primary-500 ring-offset-2 ring-offset-white`,(d||r)&&E&&`cursor-move select-none touch-none`),style:{left:`${e.box.x/x*100}%`,top:`${e.box.y/S*100}%`,width:`${e.box.width/x*100}%`,height:`${e.box.height/S*100}%`},onPointerDown:E&&(d||r)?t=>tr({event:t,mode:`move`,canvas:i,annotation:e.annotation,vault:a,startBox:e.box,stage:s.current}):E&&t?t=>{h(e.annotation.id),g(e.annotation.id),c(`content`),tr({event:t,mode:`move`,canvas:i,annotation:e.annotation,vault:a,startBox:e.box,stage:s.current})}:void 0,children:[R(er,{layer:e,mode:n,cover:w.includes(`cover`)}),E&&(d||r)?R(`div`,{className:`absolute bottom-0 right-0 h-4 w-4 cursor-se-resize rounded-tl bg-me-primary-500`,onPointerDown:t=>{t.stopPropagation(),tr({event:t,mode:`resize`,canvas:i,annotation:e.annotation,vault:a,startBox:e.box,stage:s.current})}}):null]},e.annotation.id)}):R(`div`,{className:K(`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`}),C.text?R($n,{canvas:i,box:C.text,editable:t&&E,mode:n,repositioning:f===Xn,selected:d===Xn,stage:s,onSelect:()=>{_(Xn),c(`content`)}}):null,ee?b.map((e,t)=>R(Qn,{annotation:e,canvas:i,index:t,selected:p===e.id,repositioning:m===e.id,onSelect:()=>{v(e.id)}},e.id)):null]})}function Qn({annotation:e,canvas:t,index:n,selected:r,repositioning:i,onSelect:a}){let o=In(e,t),s=Number(t.width)||1920,c=Number(t.height)||1080,l=`#6d5aa8`;return R(`div`,{className:K(`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:z(`span`,{className:K(`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 $n({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=I();return z(`div`,{className:K(`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&&nr({event:n,mode:`move`,canvas:e,vault:u,startBox:t,stage:s.current})}:void 0,children:[r===`edit`?z(L,{children:[R(`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:rr(e.label)||`Untitled`}),R(`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:rr(e.summary)||`Add editorial text`})]}):z(L,{children:[R(N,{className:`block font-semibold uppercase leading-tight`,style:{fontSize:`clamp(13px, 5cqw, 26px)`},children:e.label}),R(N,{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?R(`div`,{className:`absolute bottom-0 right-0 h-4 w-4 cursor-se-resize rounded-tl bg-me-primary-500`,onPointerDown:n=>{n.stopPropagation(),nr({event:n,mode:`resize`,canvas:e,vault:u,startBox:t,stage:s.current})}}):null]})}function er({layer:e,mode:t,cover:n}){return e.imageUrl?R(`img`,{src:e.imageUrl,alt:``,className:K(`h-full w-full`,n?`object-cover`:`object-contain`)}):e.html===null?e.youtubeId?R(`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?R(`video`,{className:`h-full w-full bg-black object-contain`,controls:!0,children:R(`source`,{src:e.videoUrl})}):R(`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?R(`div`,{className:`h-full w-full overflow-hidden bg-white p-4 text-slate-900`,dangerouslySetInnerHTML:{__html:e.html}}):t===`preview`?null:R(`div`,{className:`h-full w-full overflow-hidden bg-white p-4 text-slate-900`,children:R(`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 tr({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};Ln(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 nr({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;Rn(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 rr(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 ir=De(function({isFirst:e,item:t,children:n,...r},i){let a=P(),[o]=Se(),s=a?.behavior||[],c=fe(`Canvas`),l=xn(a?.behavior,e),{isBottom:u,isImage:d,isInfo:f,isLeft:p}=Sn(a?.behavior),m=c?.resource.source?.id===a?.id,h=s.includes(`w-12`)&&s.includes(`h-8`),g=null;return g=h?R(Zn,{className:`pointer-events-none h-full w-full`,mode:`preview`}):f?R(`div`,{className:`bg-black w-full h-full text-white max-h-40`,children:R(`div`,{className:`p-1.5 text-[4px]`,children:o.type===`textual-content`?R(N,{enableDangerouslySetInnerHTML:!0,children:o.items[0]?.text}):null})}):z(`div`,{className:K(`flex h-full max-h-full min-h-0`,p?`flex-row-reverse`:u?`flex-col`:`flex-row`),children:[R(`div`,{className:`flex-1 overflow-hidden relative justify-self-stretch`,children:R(`div`,{className:`absolute inset-0 w-full h-full`,children:R(Be,{cover:s.includes(`cover`),fade:!1})})}),d?null:R(`div`,{className:`${u?`min-h-3 w-full`:`w-1/3`} flex-shrink-0 self-stretch p-2 text-white bg-black rounded`,children:z(`div`,{className:`p-1.5 text-[4px]`,children:[R(N,{className:`block mb-1 text-[5px]`,children:a?.label}),R(N,{children:a?.summary})]})})]}),z(`div`,{ref:i,className:K(l,`bg-me-gray-700 overflow-hidden hover:ring-2 ring-me-primary-500 relative`,m?`ring-2 ring-me-primary-500`:``),...r,children:[g,n]})});function ar(){let{open:e}=h(),{structural:t,technical:n}=v(),[,r]=l({id:n.id.get(),type:`Manifest`},`items`,`Canvas`);return R(gn,{children:t.items.get().map((t,n)=>R(ge,{canvas:t.id,children:R(ir,{isFirst:n===0,item:t,onClick:()=>{e({id:`current-canvas`}),r.edit(t,n)}})},n))})}function or(e){return z(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 24 24`,height:`1em`,width:`1em`,...e,children:[R(`title`,{children:`Rearrange`}),R(`path`,{fill:`none`,d:`M0 0h24v24H0z`}),R(`path`,{d:`M20 9H4v2h16V9zM4 15h16v-2H4v2z`,fill:`currentColor`})]})}function sr({isFirst:e,onClick:t,item:n,actions:r}){let{attributes:i,listeners:a,setNodeRef:o,transform:s,transition:c}=ot({id:n.id,transition:{duration:150,easing:`cubic-bezier(0.25, 1, 0.5, 1)`}});return R(ir,{ref:o,style:{transform:st.Translate.toString(s),transition:c},...i,...a,onClick:t,isFirst:e,item:n,children:z(`div`,{className:`absolute top-0.5 right-0.5 flex gap-0.5 items-stretch`,children:[r?.length?R(x,{as:G,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:R(Ve,{})}):null,R(`div`,{className:`bg-white text-2xl h-8 flex items-center p-1 hover:text-me-500 hover:bg-me-100 rounded-sm`,children:R(or,{"aria-label":`Reorder item`})})]})})}function cr(){let e=F(),{structural:t,technical:n}=v(),r=d(),i=fe(`Canvas`),a=t.items.get(),{open:o}=h(),s=tt(et(Qe,{activationConstraint:{distance:5}}),et(Ze,{coordinateGetter:at})),[,c]=l({id:n.id.get(),type:`Manifest`},`items`,`Canvas`),u=Oe(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]),f=i?.resource.source.id,p=f?a.findIndex(e=>e.id===f):-1,m=p&&p>0?Number(p-1):0;function g(){r.close();let n=t.items.getWithoutTracking();n&&n.length>0?c.edit(n[m]):c.edit(e)}let _=V(()=>A(t.items,g),[t.items,g]);return R(gn,{children:R(Xe,{sensors:s,collisionDetection:$e,onDragEnd:u,modifiers:[nt],children:R(rt,{items:a,strategy:it,children:a.map((t,n)=>t?R(ge,{canvas:t.id,children:R(sr,{item:t,isFirst:n===0,onClick:()=>{o({id:`current-canvas`}),c.edit(t,n)},actions:_(t,n,e)},t.id)},t.id):null)})})})}const lr=dr({label:`Exhibition grid`,creatorFilter:`exhibition-slide`}),ur=dr({label:`Slideshow`,creatorFilter:`exhibition-slideshow-slide`});function dr({label:e,creatorFilter:t}){return{id:`canvas-listing`,label:e,icon:R(pr,{}),render:()=>R(fr,{creatorFilter:t}),options:{minWidth:350,maxWidth:350}}}function fr({creatorFilter:e}){let{structural:t,technical:n}=v(),r={id:n.id.get(),type:`Manifest`},i=t.items.get()||[],a=fe(`Canvas`)?.resource.source.id,o=a?i.findIndex(e=>e.id===a):-1,s=o>=0?o+1:void 0,[c,u]=l(r,`items`,`Canvas`,void 0,{isPainting:!0}),[d,f]=pe();return z(He,{children:[R(We,{title:`Exhibition`,actions:[{icon:d.list?R(Ye,{className:`text-2xl`}):R(pr,{}),title:d.list?`List view`:`Grid view`,onClick:()=>f(`list`)},{icon:R(mr,{}),title:`Edit slides`,toggled:d.editing,onClick:()=>f(`editing`)},{icon:R(hr,{}),title:`Add new slide`,disabled:!c,onClick:()=>u.createFiltered(e,s)}]}),R(Ue,{children:d.list?R(Je,{isEditing:d.editing}):d.editing?R(cr,{}):R(ar,{})})]})}function pr(){return z(`svg`,{xmlns:`http://www.w3.org/2000/svg`,width:`24`,height:`24`,fill:`currentColor`,viewBox:`0 -960 960 960`,children:[R(`title`,{children:`Exhibition grid`}),R(`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 mr(){return z(`svg`,{xmlns:`http://www.w3.org/2000/svg`,height:`24`,viewBox:`0 0 24 24`,width:`24`,children:[R(`title`,{children:`Edit slides`}),R(`path`,{d:`M0 0h24v24H0V0z`,fill:`none`}),R(`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 hr(){return z(`svg`,{xmlns:`http://www.w3.org/2000/svg`,width:`24`,height:`24`,fill:`currentColor`,viewBox:`0 -960 960 960`,children:[R(`title`,{children:`Add new slide`}),R(`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 gr={id:`@exhibitions/overview-panel`,label:`Preview`,icon:R(fn,{}),render:()=>R(_r,{})};function _r(){return F()?R(`div`,{children:`Coming soon.`}):null}const vr={id:`@exhibitions/theme-panel`,label:`Theme`,icon:R(Dr,{}),render:()=>R(Er,{}),options:{minWidth:360,maxWidth:440}};function Y({title:e,description:t,children:n}){return z(`section`,{className:`mb-5 border-b border-slate-200 pb-5 last:mb-0 last:border-b-0`,children:[z(`div`,{className:`mb-3`,children:[R(`h3`,{className:`text-sm font-semibold`,children:e}),t?R(`p`,{className:`mt-1 text-xs text-slate-500`,children:t}):null]}),n?R(`div`,{className:`space-y-3`,children:n}):null]})}function yr({label:e,value:t,onChange:n,options:r}){return z(`div`,{children:[R(`div`,{className:`mb-2 text-xs font-medium text-slate-500`,children:e}),R(`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 R(G,{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 X({label:e,checked:t,onChange:n}){return z(`label`,{className:`flex items-center gap-3 text-sm`,children:[R(`input`,{type:`checkbox`,checked:t,onChange:e=>n(e.target.checked)}),R(`span`,{children:e})]})}function Z({label:e,value:t,onChange:n}){return z(`div`,{className:`grid grid-cols-[minmax(0,1fr)_auto] items-center gap-3`,children:[R(`label`,{className:`text-sm`,children:e}),z(`div`,{className:`flex min-w-0 items-center gap-2`,children:[R(`input`,{className:`h-9 w-12 shrink-0 cursor-pointer rounded border border-slate-300 bg-white p-1`,type:`color`,value:Sr(t),onChange:e=>n(e.target.value)}),R(ee,{value:t,onChange:e=>n(e.target.value)})]})]})}function br({label:e,value:t,onChange:n}){return z(E,{$wide:!0,children:[R(te,{children:e}),R(ee,{value:t,onChange:e=>n(e.target.value)})]})}function xr({label:e,value:t,onChange:n,options:r}){return z(E,{$wide:!0,children:[R(te,{children:e}),R(`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=>R(`option`,{value:e.value,children:e.label},e.value))})]})}function Sr(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 Cr(e){return JSON.parse(JSON.stringify(e))}function wr(e,t,n){let r=Cr(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 Tr(e,t){let n=Cr(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 Er(){let e=F(),t=I(),[n,r]=U(`simple`),{centerPanel:i}=g(),{centerPanel:a}=h(),[o,s]=dn(),c=e?.service||[],l=e?.services||[],u=(i.current===mn.id?i.state:null)?.preset||o||pn,d=V(()=>{let e=Gt(c);if(e)return{service:e.service};let t=Gt(l);return t?{service:t.service}:null},[c,l]),f=V(()=>d?Ht(d.service.theme):null,[d])||Vt(`delft`);if(!e)return null;let p=n=>{let r=qt(c,n?Wt(e.id,n):null),i=qt(l,null),a={id:e.id,type:`Manifest`};t.batch(t=>{t.modifyEntityField(a,`service`,r),(e.services||i.length!==l.length)&&t.modifyEntityField(a,`services`,i)})},m=(e,t)=>{p(wr(f,e,t))},_=e=>{p(Tr(f,e))};return R(He,{children:z(Ue,{padding:!0,children:[R(Y,{title:`Preview`,description:`Switch the live preview route without changing the saved manifest theme.`,children:R(yr,{label:`Preview preset`,value:u,onChange:e=>{s(e),a.open({id:mn.id,state:{preset:e}})},options:un})}),z(Y,{title:`Manifest Theme`,description:`Store exhibition styling and viewer defaults in a custom IIIF service on the Manifest.`,children:[R(X,{label:`Enable manifest theme`,checked:!!d,onChange:e=>{if(!e){p(null);return}p(Vt(`delft`))}}),z(`div`,{className:`flex flex-wrap gap-2`,children:[R(G,{className:`rounded border border-slate-300 px-3 py-2 text-sm hover:bg-slate-50 disabled:cursor-not-allowed disabled:opacity-50`,onPress:()=>{p(Vt(f.preset))},isDisabled:!d,children:`Reset to preset`}),R(G,{className:`rounded border border-slate-300 px-3 py-2 text-sm hover:bg-slate-50 disabled:cursor-not-allowed disabled:opacity-50`,onPress:()=>p(null),isDisabled:!d,children:`Remove theme service`})]}),R(yr,{label:`Preset`,value:f.preset,onChange:e=>{p(Vt(e))},options:[{label:`Delft`,value:`delft`},{label:`Gallery`,value:`gallery`},{label:`Minimal`,value:`minimal`}]})]}),R(Y,{title:`Theme Options`,children:R(yr,{label:`Editing mode`,value:n,onChange:r,options:[{label:`Simple`,value:`simple`},{label:`Advanced`,value:`advanced`}]})}),n===`simple`?z(Y,{title:`Simple Colors`,description:`Apply broad colours across the exhibition, scrolling, presentation, and slideshow views.`,children:[R(Z,{label:`Base colour`,value:f.delft.tokens.backgroundSecondary,onChange:e=>{_([{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}])}}),R(Z,{label:`Text colour`,value:f.delft.tokens.textSecondary,onChange:e=>{_([{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}])}})]}):z(L,{children:[z(Y,{title:`Typography`,children:[R(br,{label:`Sans font stack`,value:f.shared.fontSans,onChange:e=>m([`shared`,`fontSans`],e)}),R(br,{label:`Mono font stack`,value:f.shared.fontMono,onChange:e=>m([`shared`,`fontMono`],e)}),R(xr,{label:`Title transform`,value:f.shared.titleTransform,onChange:e=>m([`shared`,`titleTransform`],e),options:[{label:`Uppercase`,value:`uppercase`},{label:`None`,value:`none`},{label:`Capitalize`,value:`capitalize`}]})]}),z(Y,{title:`Delft Colors`,children:[R(Z,{label:`Background`,value:f.delft.tokens.backgroundPrimary,onChange:e=>m([`delft`,`tokens`,`backgroundPrimary`],e)}),R(Z,{label:`Secondary background`,value:f.delft.tokens.backgroundSecondary,onChange:e=>m([`delft`,`tokens`,`backgroundSecondary`],e)}),R(Z,{label:`Primary text`,value:f.delft.tokens.textPrimary,onChange:e=>m([`delft`,`tokens`,`textPrimary`],e)}),R(Z,{label:`Secondary text`,value:f.delft.tokens.textSecondary,onChange:e=>m([`delft`,`tokens`,`textSecondary`],e)}),R(Z,{label:`Title card`,value:f.delft.tokens.titleCard,onChange:e=>m([`delft`,`tokens`,`titleCard`],e)}),R(Z,{label:`Title card text`,value:f.delft.tokens.titleCardText,onChange:e=>m([`delft`,`tokens`,`titleCardText`],e)}),R(Z,{label:`Info block`,value:f.delft.tokens.infoBlock,onChange:e=>m([`delft`,`tokens`,`infoBlock`],e)}),R(Z,{label:`Info block text`,value:f.delft.tokens.infoBlockText,onChange:e=>m([`delft`,`tokens`,`infoBlockText`],e)}),R(Z,{label:`Control bar`,value:f.delft.tokens.controlBar,onChange:e=>m([`delft`,`tokens`,`controlBar`],e)}),R(Z,{label:`Viewer background`,value:f.delft.tokens.viewerBackground,onChange:e=>m([`delft`,`tokens`,`viewerBackground`],e)})]}),z(Y,{title:`Scroll Colors`,children:[R(Z,{label:`Title background`,value:f.scroll.tokens.titleBackground,onChange:e=>m([`scroll`,`tokens`,`titleBackground`],e)}),R(Z,{label:`Title text`,value:f.scroll.tokens.titleColor,onChange:e=>m([`scroll`,`tokens`,`titleColor`],e)}),R(Z,{label:`Annotation background`,value:f.scroll.tokens.annotationBackground,onChange:e=>m([`scroll`,`tokens`,`annotationBackground`],e)}),R(Z,{label:`Annotation text`,value:f.scroll.tokens.annotationColor,onChange:e=>m([`scroll`,`tokens`,`annotationColor`],e)}),R(Z,{label:`Info block background`,value:f.scroll.tokens.infoBlockBackground,onChange:e=>m([`scroll`,`tokens`,`infoBlockBackground`],e)}),R(Z,{label:`Info block text`,value:f.scroll.tokens.infoBlockColor,onChange:e=>m([`scroll`,`tokens`,`infoBlockColor`],e)})]}),z(Y,{title:`Exhibition Defaults`,children:[R(X,{label:`Cut corners`,checked:f.delft.exhibition.cutCorners,onChange:e=>m([`delft`,`exhibition`,`cutCorners`],e)}),R(X,{label:`Full title bar`,checked:f.delft.exhibition.fullTitleBar,onChange:e=>m([`delft`,`exhibition`,`fullTitleBar`],e)}),R(X,{label:`Full width grid`,checked:f.delft.exhibition.fullWidthGrid,onChange:e=>m([`delft`,`exhibition`,`fullWidthGrid`],e)}),R(X,{label:`Hide table of contents`,checked:f.delft.exhibition.hideTableOfContents,onChange:e=>m([`delft`,`exhibition`,`hideTableOfContents`],e)}),R(X,{label:`Disable presentation mode`,checked:f.delft.exhibition.disablePresentation,onChange:e=>m([`delft`,`exhibition`,`disablePresentation`],e)}),R(X,{label:`Hide title card`,checked:f.delft.exhibition.hideTitleCard,onChange:e=>m([`delft`,`exhibition`,`hideTitleCard`],e)}),R(X,{label:`Alternative image mode`,checked:f.delft.exhibition.alternativeImageMode,onChange:e=>m([`delft`,`exhibition`,`alternativeImageMode`],e)}),R(X,{label:`Transition scale`,checked:f.delft.exhibition.transitionScale,onChange:e=>m([`delft`,`exhibition`,`transitionScale`],e)}),R(X,{label:`Image info icon`,checked:f.delft.exhibition.imageInfoIcon,onChange:e=>m([`delft`,`exhibition`,`imageInfoIcon`],e)}),R(X,{label:`Cover images`,checked:f.delft.exhibition.coverImages,onChange:e=>m([`delft`,`exhibition`,`coverImages`],e)})]}),z(Y,{title:`Presentation Defaults`,children:[R(X,{label:`Cut corners`,checked:f.delft.presentation.cutCorners,onChange:e=>m([`delft`,`presentation`,`cutCorners`],e)}),R(X,{label:`Floating caption panels`,checked:f.delft.presentation.isFloating,onChange:e=>m([`delft`,`presentation`,`isFloating`],e)}),R(xr,{label:`Floating position`,value:f.delft.presentation.floatingPosition,onChange:e=>m([`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`}]})]}),z(Y,{title:`Slideshow Defaults`,children:[R(X,{label:`Alternative image mode`,checked:f.delft.slideshow.alternativeImageMode,onChange:e=>m([`delft`,`slideshow`,`alternativeImageMode`],e)}),R(X,{label:`Transition scale`,checked:f.delft.slideshow.transitionScale,onChange:e=>m([`delft`,`slideshow`,`transitionScale`],e)}),R(X,{label:`Image info icon`,checked:f.delft.slideshow.imageInfoIcon,onChange:e=>m([`delft`,`slideshow`,`imageInfoIcon`],e)}),R(X,{label:`Cover images`,checked:f.delft.slideshow.coverImages,onChange:e=>m([`delft`,`slideshow`,`coverImages`],e)})]}),z(Y,{title:`Scroll Defaults`,children:[R(X,{label:`Show table of contents`,checked:f.scroll.options.showTableOfContents,onChange:e=>m([`scroll`,`options`,`showTableOfContents`],e)}),R(X,{label:`Full-height title block`,checked:f.scroll.options.titleBlock.fullHeight,onChange:e=>m([`scroll`,`options`,`titleBlock`,`fullHeight`],e)})]})]})]})})}function Dr(){return z(`svg`,{xmlns:`http://www.w3.org/2000/svg`,width:`24`,height:`24`,fill:`currentColor`,viewBox:`0 -960 960 960`,children:[R(`title`,{children:`Theme`}),R(`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`})]})}function Or(e){return e===`left-panel-manifest`||e===lr.id}const kr={id:`exhibition-background-task`,label:`Query string`,render:()=>R(Ar,{})};function Ar(){let e=F(),{leftPanel:t,rightPanel:n}=g(),{edit:r,centerPanel:i,rightPanel:a}=h(),[o,s]=U(!1),c=H(null),l=H(null);return B(()=>{let u=e?.id||null,d=c.current!==t.current,f=l.current!==u,p=c.current;if(c.current=t.current,l.current=u,!(!e||!d&&!f)){if(t.current===gr.id){r(e),i.open({id:Yt.id}),s(!1);return}if(t.current===vr.id){r(e),n.open?(a.close(),s(!0)):s(!1),i.open({id:mn.id});return}!n.open&&n.current&&Or(t.current)&&(p===null||p===vr.id&&o)&&(a.open(),s(!1))}},[i,r,t.current,e?.id,n.current,n.open,a,o]),null}const jr={id:`image-block-editor`,label:`Image Block Editor`,component:e=>R(Mr,{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 Mr({strategy:e}){let[t,n]=_(`exhibition-preview-mode`),[r,i]=dn(),a=fe(`Canvas`);return a?R(ge,{canvas:a.resource.source?.id,children:R(Nr,{isPreview:!!t,previewPreset:r,onModeChange:n,onPreviewPresetChange:i})}):null}function Nr({isPreview:e,previewPreset:t,onModeChange:n,onPreviewPresetChange:r}){return z(`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:[z(`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:[R(`div`,{className:`min-w-0 flex-1`,children:R(N,{className:`block truncate text-sm font-semibold text-slate-800`,children:P()?.label})}),z(`div`,{className:`flex items-center gap-2`,children:[e?R(`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:un.map(e=>R(`option`,{value:e.value,children:e.label},e.value))}):null,z(`div`,{className:`flex shrink-0 overflow-hidden rounded-md border border-slate-200 bg-slate-50 text-xs font-semibold`,children:[R(Pr,{selected:!e,onPress:()=>n(!1),children:`Edit`}),R(Pr,{selected:e,onPress:()=>n(!0),children:`Preview`})]})]})]}),e?R(`div`,{className:`min-h-0 flex-1`,children:R(an,{preset:t})}):R(`div`,{className:`flex min-h-0 flex-1`,children:R(C,{asFallback:!0})})]})}function Pr({children:e,selected:t,onPress:n}){return R(G,{className:K(`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 Fr={id:`info-block-editor`,label:`info Block Editor`,component:e=>R(zr,{strategy:e}),supports:{strategy:(e,t,n)=>e.type===`textual-content`}};function Ir(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 Lr({selectedLanguage:e,languages:t,availableLanguages:n,onSelectLanguage:r,onAddLanguage:i}){let[a,o]=U(!1),s=H(null);B(()=>{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 z(`div`,{ref:s,className:`relative`,children:[z(`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:[R(`span`,{className:``,children:Ir(e)?.label||e}),R(`svg`,{className:`h-3 w-3 text-slate-400`,viewBox:`0 0 12 12`,fill:`none`,stroke:`currentColor`,strokeWidth:2,children:R(`path`,{d:`M2 4l4 4 4-4`})})]}),a&&z(`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&&z(L,{children:[R(`div`,{className:`px-3 py-1 text-[10px] font-semibold uppercase tracking-wider text-slate-400`,children:`Language`}),t.map(t=>{let n=Ir(t);return z(`button`,{type:`button`,className:K(`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?R(`svg`,{className:`h-3 w-3 shrink-0 text-slate-500`,viewBox:`0 0 12 12`,fill:`currentColor`,children:R(`path`,{d:`M2 6l3 3 5-5`,stroke:`currentColor`,strokeWidth:2,fill:`none`})}):R(`div`,{className:`h-3 w-3 shrink-0 text-slate-500`}),R(`span`,{className:t===e?``:`ml-5`,children:n?.label||t})]},t)})]}),c.length>0&&z(L,{children:[t.length>0&&R(`div`,{className:`my-1 border-t border-slate-100`}),R(`div`,{className:`px-3 py-1 text-[10px] font-semibold uppercase tracking-wider text-slate-400`,children:`Add language`}),c.map(e=>{let t=Ir(e);return z(`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:[R(`svg`,{className:`h-3 w-3 shrink-0 text-slate-400`,viewBox:`0 0 12 12`,fill:`none`,stroke:`currentColor`,strokeWidth:2,children:R(`path`,{d:`M6 2v8M2 6h8`})}),t?.label||e]},e)})]}),c.length===0&&t.length===0&&R(`div`,{className:`px-3 py-2 text-xs text-slate-400`,children:`No languages available`})]})]})}function Rr(e,t){if(!e)return[];let n=e.items||[],r=new Set;for(let e of n){let n=Xr(e,t);if(!n)continue;let i=Zr(n.body);for(let e of i){let n=Xr(e,t);n?.language&&r.add(n.language)}}return Array.from(r)}function zr({strategy:e}){let t=P(),n=I(),r=t?.behavior||[],i=bn(r),a=!!(i.h&&i.w),{isBottom:o,isLeft:s,isRight:l}=Sn(r),u=a&&i.w<=6,d=we((e,n)=>t?.items[0]?n.get(t.items[0]):null),f=we((e,n)=>t?.annotations[0]?n.get(t?.annotations[0]):null),{i18n:{availableLanguages:p,defaultLanguage:m}}=c(),[h,g]=_(`exhibition-info-block-mode`,`edit`),[v,y]=dn(),b=V(()=>{let e=Rr(d,n),t=Rr(f,n),r=new Set([...e,...t]);return r.size===0&&r.add(m||`en`),Array.from(r)},[d,f,n,m]),[x,S]=_(`exhibition-info-block-language`,m||`en`),C=b.includes(x)?x:b[0]||m||`en`,w=e=>{S(e)},T=u?`28rem`:void 0;return z(`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:[z(`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:[R(`div`,{className:`min-w-0 flex-1`,children:R(N,{className:`block truncate text-sm font-semibold text-slate-800`,children:t?.label})}),z(`div`,{className:`flex items-center gap-2`,children:[h===`edit`&&R(Lr,{selectedLanguage:C,languages:b,availableLanguages:p,onSelectLanguage:S,onAddLanguage:w}),h===`preview`?R(`select`,{className:`rounded-md border border-slate-200 bg-white px-2 py-2 text-xs font-semibold text-slate-700 shadow-sm`,value:v,onChange:e=>y(e.target.value),children:un.map(e=>R(`option`,{value:e.value,children:e.label},e.value))}):null,z(`div`,{className:`flex shrink-0 overflow-hidden rounded-md border border-slate-200 bg-slate-50 text-xs font-semibold`,children:[R(Br,{selected:h===`edit`,onPress:()=>g(`edit`),children:`Edit`}),R(Br,{selected:h===`preview`,onPress:()=>g(`preview`),children:`Preview`})]})]})]}),h===`preview`?R(`div`,{className:`min-h-0 flex-1`,children:R(an,{preset:v})}):z(`div`,{className:`min-h-0 flex-1 overflow-x-hidden overflow-y-auto`,children:[R(Vr,{annotationPage:d,compact:u,editorMaxWidth:T,fallbackText:e.items[0]?.text,heading:`Short summary`,panelClassName:K(`border-b border-gray-100`,u?`p-3`:`p-5`,a&&(s||l)?`max-w-xl`:``,a&&o?`max-w-4xl`:``),parentProperty:`items`,selectedLanguage:C,onLanguageAdded:w}),R(Vr,{annotationPage:f,compact:u,heading:`Long summary`,panelClassName:K(u?`p-3`:`p-5`),parentProperty:`annotations`,selectedLanguage:C,onLanguageAdded:w})]})]})}function Br({children:e,selected:t,onPress:n}){return R(G,{className:K(`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 Vr({annotationPage:e,compact:t,editorMaxWidth:n,fallbackText:r,heading:i,panelClassName:a,parentProperty:o,selectedLanguage:s,onLanguageAdded:l}){let u=P(),d=m(),f=I(),{i18n:{defaultLanguage:p}}=c(),h=e||null,g=h?.items||[],_=Wr(g,f),v=()=>{u&&d.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`}}})},y=()=>{if(u){if(!h){v();return}d.create(`@manifest-editor/html-annotation`,{label:{en:[i]},body:{[s||p||`en`]:[``]},motivation:o===`annotations`?`tagging`:`painting`},{target:{id:u.id,type:`Canvas`},targetType:`Annotation`,parent:{property:`items`,resource:{id:h.id,type:`AnnotationPage`}},initialData:{}})}},b=()=>{if(!h){y(),l(s);return}let e=!1;for(let t of g){let n=Xr(t,f);if(!n)continue;let r=Zr(n.body);if(r.some(e=>Xr(e,f)?.language===s))continue;let i=r[0],a=i?Xr(i,f):null,o=`${n.id}-body-${s}-${Date.now()}`;f.batch(()=>{f.dispatch({type:`entities/update`,payload:{type:`ContentResource`,id:o,language:s,value:``,format:a?.format||`text/html`,motivation:a?.motivation}}),f.modifyEntityField({id:n.id,type:`Annotation`},`body`,[...r,{id:o,type:`ContentResource`}])}),e=!0}e||y(),l(s)},x=V(()=>{if(!h)return!1;for(let e of g){let t=Xr(e,f);if(!t)continue;let n=Zr(t.body);for(let e of n)if(Xr(e,f)?.language===s)return!0}return!1},[h,g,f,s]);return z(`section`,{className:K(`min-w-0 max-w-full`,a),children:[z(`div`,{className:K(`flex items-center justify-between gap-3`,_.length?`mb-3`:`mb-0`),children:[R(`h2`,{className:K(`font-semibold tracking-tight text-gray-700`,t?`text-xs uppercase`:`text-sm uppercase tracking-wide`),children:i}),!x&&R(W,{primary:!0,onPress:b,children:h?`Add text`:`Add`})]}),!h&&r?R(`div`,{className:`mt-2 text-sm text-gray-600`,children:R(N,{enableDangerouslySetInnerHTML:!0,children:r})}):null,_.length?R(`div`,{className:`min-w-0 max-w-full`,children:_.map(({item:e,index:r})=>R(me,{annotation:e.id,children:R(Hr,{compact:t,editorMaxWidth:n,pageItems:g,pageRef:{id:h.id,type:`AnnotationPage`},selectedLanguage:s,onRemoveAnnotation:()=>{f.modifyEntityField({id:h.id,type:`AnnotationPage`},`items`,g.filter((e,t)=>t!==r))}})},e.id+r))}):h&&x?R(`div`,{className:K(`mt-2 text-sm text-gray-400 italic`,``),children:`No text added yet.`}):null]})}function Hr({compact:e,editorMaxWidth:t,onRemoveAnnotation:n,pageItems:r,pageRef:i,selectedLanguage:a}){let o=_e(),s=I(),c=o?.body||[],l=p(o);if(!o)return null;let u=c.map((e,t)=>({item:e,index:t})).filter(({item:e})=>Xr(e,s)?.language===a),d=u.length>0?u:[],f=Oe(e=>{let t=Kr(c,s,e);t.length!==c.length&&s.modifyEntityField({id:o.id,type:`Annotation`},`body`,t);let n=Gr(r,s,o.id);n.length!==r.length&&s.modifyEntityField(i,`items`,n)},[o.id,i.id,r,s]);return d.length?R(`div`,{className:`min-w-0 max-w-full overflow-hidden`,children:d.map(({item:n,index:r})=>R(Ur,{resourceId:n.id,onRemove:()=>l.annotation.body.deleteAtIndex(r),onUpdate:()=>f(n.id),compact:e,editorMaxWidth:t},n.id||r))}):null}function Ur({compact:e,editorMaxWidth:t,resourceId:n,onRemove:r,onUpdate:i}){let a=p(V(()=>({id:n,type:`ContentResource`}),[n])),{i18n:{advancedLanguageMode:o,availableLanguages:s,defaultLanguage:l}}=c(),{language:u,value:d}=a.descriptive,f=u.get(),m=Array.isArray(f)?f[0]||l||`en`:f||l||`en`;return B(()=>{let e=Array.isArray(u.get())?u.get()[0]:u.get();!o&&e!==m&&u.set(m)},[o,m]),R(`div`,{className:`min-w-0 max-w-full overflow-hidden`,style:t?{maxWidth:t}:void 0,children:R(oe,{language:m,languages:s,value:d.get()||``,onUpdate:e=>{d.set(e),i()},onUpdateLanguage:o?e=>u.set(e):void 0,onRemove:o?r:void 0})})}function Wr(e,t){let n=e.map((e,t)=>({item:e,index:t})),r=n.filter(({item:e})=>!qr(e,t));return r.length?r:n.slice(0,1)}function Gr(e,t,n){let r=e.filter(e=>e?.id===n||!qr(e,t));return r.length?r:e.slice(0,1)}function Kr(e,t,n){let r=e.filter(e=>e?.id===n||!Jr(e,t));return r.length?r:e.slice(0,1)}function qr(e,t){let n=Zr(Xr(e,t)?.body);return n.length?n.every(e=>Jr(e,t)):!0}function Jr(e,t){let n=Xr(e,t);return n?Yr(n.value||``):!0}function Yr(e){let t=String(e||``);return/<img\b/i.test(t)?!1:t.replace(/<[^>]*>/g,``).replace(/ /gi,` `).replace(/\s+/g,``).trim()===``}function Xr(e,t){return!e?.id||e.value||e.items||e.body?e:t.get(e,{skipSelfReturn:!1})||e}function Zr(e){return Array.isArray(e)?e:e==null?[]:[e]}const Qr={id:`youtube-main-editor`,label:`YouTube main editor`,component:e=>e.type===`media`?R($r,{strategy:e,video:e.media}):null,supports:{strategy:(e,t,n)=>(console.log(e),!(e.type!==`media`||e.media.type!==`VideoYouTube`))}};function $r({strategy:e,video:t}){let{edit:n}=h(),r=P(),i=we((e,t)=>t.get(r?.items[0]).items[0]);ct(r&&i);let a=H(null),o=p(i),s=t,c=(r.width||1)/(r.height||1);return`${s.youTubeId}`,z(`div`,{className:`overflow-y-auto`,children:[R(`div`,{className:`p-8`,children:R(`div`,{className:`bg-black z-20 flex p-8 rounded-lg max-w-full max-h-[70vh] mx-auto`,style:{aspectRatio:c},children:R(`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`})})}),z(`div`,{className:`bg-white shadow w-full p-8 flex gap-8`,children:[R(`div`,{children:R(`div`,{className:`w-64 bg-black flex-shrink-0 flex items-center justify-center rounded overflow-clip`,style:{aspectRatio:c},children:r.thumbnail?.length?R(Be,{cover:!0}):R(`div`,{className:`text-white/50 text-center py-16`,children:`No thumbnail`})})}),z(`div`,{className:`flex-1`,children:[R(N,{as:`h3`,className:`text-2xl font-bold mt-4`,defaultText:R(`span`,{className:`text-black/30`,children:`No Label`}),children:o.descriptive.label.get()}),R(N,{as:`p`,className:`mt-2 mb-8`,defaultText:R(`span`,{className:`text-black/30`,children:`No summary`}),children:o.descriptive.summary.get()}),R(W,{onPress:()=>n(o.ref()),children:`Edit properties`})]})]})]})}const ei=q({...ut,id:`@exhibitions/browser-creator`,create:ti,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 ti(e,t){let n=t.generateId(`canvas`),r=t.generateId(`annotation-page`,{id:n,type:`Canvas`}),i={width:0,height:0},a=await lt(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 lt(t,`Manifest`,`items`,`@exhibitions/image-slide-creator`)({canvasId:n,width:i.width,height:i.height,type:`default`,items:a})}const ni=q({...dt,id:`@exhibitions/image-service-creator`,create:ri,tags:[`image`,`exhibition-slide`],label:`IIIF Image`,summary:`IIIF Image service`,resourceType:`Canvas`,supports:{parentTypes:[`Manifest`],parentFields:[`items`]}});async function ri(e,t){let n=t.generateId(`canvas`);t.generateId(`annotation-page`,{id:n,type:`Canvas`});let r=await lt(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 lt(t,`Manifest`,`items`,`@exhibitions/image-slide-creator`)({canvasId:n,width:i,height:a,type:`default`,items:[o]})}const ii=q({id:`@exhibitions/image-slide-creator`,create:si,label:`Empty slide`,summary:`An empty image slide.`,icon:R(Le,{}),tags:[`exhibition-slide`],resourceType:`Canvas`,resourceFields:[`id`,`type`,`label`,`height`,`width`,`items`],supports:{parentTypes:[`Manifest`],parentFields:[`items`]}});q({...ii,id:`@exhibitions/image-slide-creator-left`,label:`Image (Left)`,summary:`An image with text on the left.`,icon:R(`div`,{children:`IMAGE (LEFT)`}),create:(e,t)=>si({...e,type:`left`},t)}),q({...ii,id:`@exhibitions/image-slide-creator-right`,label:`Image (Right)`,summary:`An image with text on the right.`,icon:R(`div`,{children:`IMAGE (RIGHT)`}),create:(e,t)=>si({...e,type:`right`},t)}),q({...ii,id:`@exhibitions/image-slide-creator-bottom`,label:`Image (Bottom)`,summary:`An image with text at the bottom.`,icon:R(`div`,{children:`IMAGE (BOTTOM)`}),create:(e,t)=>si({...e,type:`bottom`},t)});const ai=q({...ii,id:`@exhibitions/slideshow-image-only-creator`,label:`Image only`,summary:`A slideshow slide focused on an image.`,tags:[`exhibition-slideshow-slide`],create:(e,t)=>si({...e,behavior:[`w-12`,`h-8`,`image`],height:e.height||1080,width:e.width||1920,type:`default`},t)}),oi=q({...ii,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)=>si({...e,behavior:[`w-12`,`h-8`,`right`],height:e.height||1080,width:e.width||1920,type:`right`},t)});q({...ii,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)=>si({...e,behavior:[`w-12`,`h-8`,`compact-deck`],height:e.height||1080,width:e.width||1920,type:`default`},t)});function si(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({..._t,id:n,behavior:a,label:e.label||{en:[`Untitled`]},height:e.height||4e3,duration:e.duration,width:e.width||o,items:[t.embed({...gt,id:r,type:`AnnotationPage`,items:e.items?e.items:[]})],annotations:[t.embed({...gt,id:i,type:`AnnotationPage`,items:[]})]})}const ci=q({...ft,id:`@exhibitions/image-url-creator`,create:li,tags:[`exhibition-slide`],label:`Image`,summary:`Image from URL`,resourceType:`Canvas`,supports:{parentTypes:[`Manifest`],parentFields:[`items`]}});async function li(e,t){let n=t.generateId(`canvas`);t.generateId(`annotation-page`,{id:n,type:`Canvas`});let r=t.generateId(`annotation`),i=await lt(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 lt(t,`Manifest`,`items`,`@exhibitions/image-slide-creator`)({canvasId:n,width:a,height:o,type:`default`,items:[s]})}const ui=q({id:`@exhibitions/info-box-creator`,create:fi,label:`Info box`,summary:`A text panel for an exhibition`,icon:z(`svg`,{xmlns:`http://www.w3.org/2000/svg`,width:`1em`,height:`1em`,viewBox:`0 0 24 24`,children:[R(`title`,{children:`Info box`}),R(`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`]}}),di=q({...ui,id:`@exhibitions/slideshow-long-editorial-creator`,label:`Long editorial`,summary:`A text-led slideshow slide.`,tags:[`exhibition-slideshow-slide`],create:(e,t)=>fi({...e,behavior:[`w-12`,`h-8`,`info`],height:e.height||1080,width:e.width||1920},t)});async function fi(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={...ht,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({..._t,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 pi=q({...pt,id:`@exhibitions/video-creator`,create:hi,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`]}}),mi=q({...pi,id:`@exhibitions/slideshow-video-creator`,label:`Video`,summary:`A video slide for a slideshow exhibition.`,tags:[`exhibition-slideshow-slide`],create:(e,t)=>hi({...e,behavior:[`w-12`,`h-8`,`image`],height:e.height||1080,slideType:`default`,width:e.width||1920},t)});async function hi(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 lt(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 gi=q({...mt,id:`@exhibitions/youtube-creator`,create:vi,tags:[`video`,`exhibition-slide`],label:`YouTube`,summary:`A YouTube for an exhibition`}),_i=q({...gi,id:`@exhibitions/slideshow-youtube-creator`,label:`YouTube`,summary:`A YouTube slide for a slideshow exhibition.`,tags:[`exhibition-slideshow-slide`]});async function vi(e,t){let n=se(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({..._t,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 yi(){let e=f(),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}`),vt(r.get())||r.set({en:[`Summary of image`]}),e.technical.behavior.set(i)};return z(`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?`,R(W,{onPress:()=>t(),children:`Apply defaults`})]})}function bi(){let e=P();ct(e);let t=e.width&&e.height?e.width/e.height:0,n=bn(e.behavior||[]);return Math.abs(t-n.ratio)<.01?null:z(`div`,{className:`exhibition-aspect-warning p-2 rounded bg-me-100`,children:[R(`div`,{className:`font-semibold text-me-700`,children:`Aspect ratio warning`}),z(`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.`,R(`div`,{className:`relative h-32 w-full mt-2`,children:R(`div`,{className:`bg-[red] left-0 top-0 z-2 opacity-50 max-w-32 max-h-32`,style:{aspectRatio:t.toFixed(2)},children:R(`div`,{className:`asbolute bg-[white] left-0 top-0 z-1 opacity-50 max-w-32 max-h-32`,style:{aspectRatio:n.ratio}})})})]})]})}function xi(){let e=P(),t=u(),n=m(),[r,i]=l(t?.resource.source,`thumbnail`,`ContentResource`),{descriptive:a}=f(),{thumbnail:o}=a,s=o.get()||[],c=I(),d=V(()=>e?wi(c,e):[],[e,c]);return!e||!t?null:!s.length&&d.length?R(Si,{candidates:d,canCreateThumbnail:r,onCreateThumbnail:()=>i.create(),onAddThumbnail:({service:t,width:r,height:i})=>n.create(`@manifest-editor/thumbnail-image`,{service:t,width:r,height:i},Ci(e))}):R(ne,{containerId:o.containerId(),label:`Thumbnail`,property:`thumbnail`,items:s,singleMode:!0,reorder:e=>o.reorder(e.startIndex,e.endIndex),createActions:A(o),creationType:`ContentResource`,emptyLabel:`No thumbnail`,parent:t.resource})}function Si({candidates:e,canCreateThumbnail:t,onCreateThumbnail:n,onAddThumbnail:r}){let[i,a]=U(null),[o,s]=U(``),[c,l]=U({}),u=e.find(e=>e.id===i)||e[0],d=u?c[u.id]:void 0,f=u?d===null?null:d||u.service:null,p=f?Ai(f):[],m=Mi(p,350),h=p.find(e=>ji(e)===o)||m,g=f&&h?Ni(f,h):null,_=u&&!u.service.sizes?.length&&!(u.id in c);return B(()=>{!i&&e[0]&&a(e[0].id)},[e,i]),B(()=>{let t=e.filter(e=>{let t=e.service;return!t.sizes?.length&&Oi(t)&&!(e.id in c)});for(let e of t){let t=Oi(e.service);t&&fetch(ki(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]),B(()=>{m&&!p.some(e=>ji(e)===o)&&s(ji(m))},[m,o,p]),R(E,{$wide:!0,children:z(`div`,{className:`rounded-md border border-[#dcd5ce] bg-[#f8f6f3] p-4`,children:[R(`div`,{className:`text-sm font-semibold text-[#25211f]`,children:`Thumbnail`}),R(`div`,{className:`mt-1 text-sm text-[#6a625c]`,children:`Use an image service from this canvas to add a thumbnail.`}),e.length>1?z(`div`,{className:`mt-3`,children:[R(`label`,{className:`text-xs font-semibold uppercase text-[#6a625c]`,htmlFor:`thumbnail-source-image`,children:`Image`}),R(`select`,{id:`thumbnail-source-image`,className:`mt-1 w-full rounded-md border border-[#dcd5ce] bg-white px-3 py-2 text-sm`,value:u?.id||``,onChange:e=>{a(e.currentTarget.value),s(``)},children:e.map(e=>R(`option`,{value:e.id,children:e.label},e.id))})]}):null,p.length?z(L,{children:[R(`div`,{className:`mt-3 flex flex-wrap gap-2`,children:p.map(e=>{let t=ji(e),n=h?t===ji(h):!1;return z(`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)})}),g?R(`div`,{className:`mt-3 overflow-hidden rounded-md border border-[#dcd5ce] bg-white`,children:R(`img`,{src:g,alt:``,className:`max-h-40 w-full object-contain`})}):null,R(`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:!g||!h,onClick:()=>{!f||!h||r({service:f,width:h.width,height:h.height})},children:`Add thumbnail from image`})]}):_?R(`div`,{className:`mt-3 text-sm text-[#6a625c]`,children:`Finding available sizes...`}):R(`div`,{className:`mt-3 text-sm text-[#6a625c]`,children:`No fixed thumbnail sizes were found for this image service.`}),t?R(`div`,{className:`mt-4 border-t border-[#dcd5ce] pt-3`,children:z(W,{onPress:n,children:[R(je,{}),` Create thumbnail`]})}):null]})})}function Ci(e){return{parent:{property:`thumbnail`,resource:{id:e.id,type:`Canvas`}}}}function wi(e,t){let n=[],r=new Set;return jn(e,t).forEach((t,i)=>{Ti(e,Hn(e,t)).forEach((e,a)=>{let o=Di(e),s=o?Oi(o):``;!o||!s||r.has(s)||(r.add(s),n.push({id:`${t.id||i}-${e.id||s}-${a}`,label:Pi(e.label)||Pi(t.label)||`Image ${n.length+1}`,imageId:e.id,service:o}))})}),n}function Ti(e,t){let n=Ei(e,t);return n?n.type===`Choice`&&Array.isArray(n.items)?n.items.flatMap(t=>Ti(e,t)):n.type===`SpecificResource`?Ti(e,n.source):n.type===`Canvas`?jn(e,n).flatMap(t=>Ti(e,Hn(e,t))):Di(n)?[n]:[]:[]}function Ei(e,t){return t?t.id&&!t.service&&!t.items&&!t.value&&e.get(t,{skipSelfReturn:!1})||t:null}function Di(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 Oi(e){return(e.id||e[`@id`]||``).replace(/\/info\.json$/,``)}function ki(e){return e.endsWith(`/info.json`)?e:`${e.replace(/\/$/,``)}/info.json`}function Ai(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 ji(e){return`${e.width},${e.height||``}`}function Mi(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 Ni(e,t){let n={...e};n[`@id`]&&(n.id=n[`@id`]),n[`@type`]&&(n.type=n[`@type`]);let r=yt(n);return bt({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 Pi(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 Fi=new Set([`left`,`right`,`bottom`,`top`,`image`]),Ii=[{value:`image`,label:`Image only`},{value:`right`,label:`Image + text right`},{value:`left`,label:`Image + text left`},{value:`bottom`,label:`Image + text bottom`}],Q={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)`},Li=[{value:12,label:`Full width`},{value:8,label:`2/3 width`},{value:6,label:`Half width`},{value:4,label:`1/3 width`}],Ri=new Set([`float-top-left`,`float-top-right`,`float-bottom-left`,`float-bottom-right`]),zi={component:()=>R(Wi,{}),supports:{edit:!0,resourceTypes:[`Canvas`],properties:[`behavior`],custom:({resource:e},t)=>Cn(e,t)?!wn(e,t):!1},id:`slide-behaviors`,label:`Layout`,tabs:{showTitle:!0}},Bi=[{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)=>R(Ui,{behaviors:e,setBehaviors:t}),label:{en:[`Size`]},type:`custom`,initialOpen:!0,supports:e=>e.startsWith(`w-`)||e.startsWith(`h-`)}];function Vi(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 Hi(e){return e.filter(e=>!Fi.has(e)&&!e.startsWith(`w-`)&&!e.startsWith(`h-`)&&!Ri.has(e)&&e!==`cover`)}function Ui({behaviors:e,setBehaviors:t}){let{width:n,height:r}=Vi(e),[i,a]=U({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 R(`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`),R(`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 Wi(){let[e,t]=_(`exhibition-layout-panel-mode`,`simple`);return R(He,{children:z(Ue,{className:`bg-white px-6 pt-5 pb-20`,children:[R(`div`,{className:`mb-6 flex justify-center`,children:R($i,{value:e,onChange:t})}),R(Gi,{mode:e})]})})}function Gi({mode:e=`advanced`,layoutContext:t=`default`}){let n=fe(`Canvas`),r=f(),{width:i,height:a}=r.technical;return!n||r.technical.type!==`Canvas`?R(`div`,{className:`p-4`,children:`Please select canvas`}):e===`simple`?R(Ki,{behavior:r.technical.behavior.get()||[],layoutContext:t,canvasWidth:i.get()||0,canvasHeight:a.get()||0,onChange:e=>{r.technical.behavior.set(e)}}):z(L,{children:[R(`div`,{className:`px-2`,children:z(E,{$wide:!0,children:[R(w,{widthId:i.containerId(),width:i.get()||0,changeWidth:e=>i.set(e),heightId:a.containerId(),height:a.get()||0,changeHeight:e=>a.set(e)}),R(`div`,{children:R(bi,{})})]})}),R(S,{behavior:r.technical.behavior.get()||[],onChange:e=>{r.technical.behavior.set(e)},configs:Bi}),R(xi,{})]})}function Ki({behavior:e,layoutContext:t,canvasWidth:n,canvasHeight:r,onChange:i}){let[a,o]=U(na(e)),[s,c]=U(t===`slideshow`?12:ia(e)),[l,u]=U(aa(e)),[d,f]=U(e.includes(`cover`)),p=J(e=>e.requestTab),m=P(),h=I(),g=F(),_=t===`slideshow`?12:s,v=sa({canvasWidth:n,canvasHeight:r,layoutPreset:a,displayWidth:_}),y=t===`default`&&g?.items&&m?ua(m.id,g.items,h):null,b=o=>{let c=o.layoutPreset??a;i(oa({behavior:e,layoutPreset:c,displayWidth:t===`slideshow`?12:o.displayWidth??s,canvasWidth:n,canvasHeight:r,floating:o.floating??l,cover:o.cover??d})),m&&fa(h,m,c)};return z(`div`,{className:`flex flex-col gap-7`,children:[R(qi,{layoutPreset:a,cover:d,floating:l,width:_,height:v,onTextClick:()=>p(`summary`)}),z(ea,{children:[R(ta,{children:`Layout preset`}),R(`div`,{className:`mt-3 grid grid-cols-2 gap-3`,children:Ii.map(e=>R(Ji,{preset:e.value,label:e.label,selected:a===e.value,onClick:()=>{o(e.value),b({layoutPreset:e.value})}},e.value))})]}),t===`default`?z(ea,{children:[R(ta,{children:`Width`}),R(`div`,{className:`mt-3 grid grid-cols-2 gap-3`,children:Li.map(e=>R(Zi,{selected:s===e.value,onClick:()=>{c(e.value),b({displayWidth:e.value})},children:e.label},e.value))})]}):null,y?z(ea,{children:[z(ta,{children:[`Fit alongside `,y.neighbour,` slide`]}),R(`div`,{className:`mt-3`,children:z(Zi,{selected:s===y.width,onClick:()=>{c(y.width),b({displayWidth:y.width})},children:[`w-`,y.width,` — fills remaining space`]})})]}):null,z(`div`,{className:`flex flex-col gap-3`,children:[R(Qi,{checked:l,label:`Floating`,onChange:e=>{u(e),b({floating:e})}}),R(Qi,{checked:d,label:`Image cover`,onChange:e=>{f(e),b({cover:e})}})]})]})}function qi({layoutPreset:e,cover:t,floating:n,width:r,height:i,onTextClick:a}){let o=e===`bottom`,s=e===`image`,c=e===`left`;return z(`div`,{children:[z(`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:Q.fieldBorder},children:[z(`div`,{className:K(`flex h-full w-full min-h-0`,c?`flex-row-reverse`:o?`flex-col`:`flex-row`),children:[R(`div`,{className:`relative min-h-0 flex-1 overflow-hidden bg-white`,children:R(`div`,{className:`absolute inset-0`,children:R(Be,{cover:t,fade:!1})})}),s?null:R(`button`,{type:`button`,className:K(`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:R(Xi,{tone:`light`})})]}),n?R(`div`,{className:`absolute right-2 top-2 h-7 w-10 rounded bg-white/90 shadow ring-1 ring-black/10`}):null]}),z(`div`,{className:`mt-2 text-center text-xs`,style:{color:Q.muted},children:[`w-`,r,` h-`,i]})]})}function Ji({preset:e,label:t,selected:n,onClick:r}){return z(`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?Q.primary:Q.buttonText,borderColor:n?Q.primary:Q.fieldBorder,color:n?Q.buttonText:Q.inactiveButtonText},onClick:r,children:[R(Yi,{preset:e,selected:n}),R(`span`,{className:`leading-tight`,children:t})]})}function Yi({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 z(`span`,{className:K(`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:[R(`span`,{className:K(`flex-1 rounded-sm ring-1`,o)}),n?null:R(`span`,{className:K(`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:R(Xi,{compact:!0,tone:t?`dark`:`light`})})]})}function Xi({compact:e=!1,tone:t=`light`}){let n=t===`light`?`bg-white/70`:`bg-[#8b3f61]/70`;return z(`span`,{className:K(`block space-y-1.5`,e?`space-y-0.5`:`mt-1`),"aria-hidden":`true`,children:[R(`span`,{className:K(`block rounded`,n,e?`h-0.5 w-full`:`h-1.5 w-3/4`)}),R(`span`,{className:K(`block rounded`,n,e?`h-0.5 w-4/5`:`h-1.5 w-full`)}),R(`span`,{className:K(`block rounded`,n,e?`h-0.5 w-2/3`:`h-1.5 w-2/3`)})]})}function Zi({selected:e,onClick:t,children:n}){return R(`button`,{type:`button`,className:`min-h-11 rounded-md border px-3 py-2 text-sm font-semibold transition-colors`,style:{backgroundColor:e?Q.primary:Q.buttonText,borderColor:e?Q.primary:Q.fieldBorder,color:e?Q.buttonText:Q.inactiveButtonText},onClick:t,children:n})}function Qi({checked:e,label:t,onChange:n}){return z(`label`,{className:`flex items-center justify-between rounded-md border px-4 py-3 text-sm font-semibold`,style:{backgroundColor:Q.fieldBackground,borderColor:Q.fieldBorder,color:Q.text},children:[t,R(`input`,{type:`checkbox`,className:`h-4 w-4 accent-me-primary-500`,checked:e,onChange:e=>n(e.currentTarget.checked)})]})}function $i({value:e,onChange:t}){return R(`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 R(G,{className:`border-none rounded-full bg-transparent px-4 py-2 text-sm font-semibold capitalize transition-colors`,style:{backgroundColor:r?Q.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 ea({children:e}){return R(`div`,{children:e})}function ta({children:e}){return R(`div`,{className:`text-sm font-semibold`,style:{color:Q.muted},children:e})}function na(e){return e.includes(`image`)?`image`:e.includes(`left`)?`left`:e.includes(`bottom`)?`bottom`:e.includes(`right`)?`right`:`image`}function ra(e,t,n){let r=e.filter(e=>!Fi.has(e));if(n?.width&&n?.height){let{width:i}=Vi(e),a=i?i<=4?4:i<=6?6:i<=8?8:12:12,o=sa({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 ia(e){let{width:t}=Vi(e);return t?t<=4?4:t<=6?6:t<=8?8:12:12}function aa(e){return e.some(e=>Ri.has(e))}function oa({behavior:e,layoutPreset:t,displayWidth:n,canvasWidth:r,canvasHeight:i,floating:a,cover:o}){let s=Hi(e),c=sa({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 sa({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 ca=[{value:4,label:`1/3 width`},{value:6,label:`Half width`},{value:8,label:`2/3 width`},{value:12,label:`Full width`}];function la(e){let{width:t}=Vi(e);return t}function ua(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 la(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 da=new Set([`left`,`right`,`bottom`]);function fa(e,t,n){da.has(n)&&(j(t.label)||e.modifyEntityField(t,`label`,{en:[`Untitled`]}),j(t.summary)||e.modifyEntityField(t,`summary`,{en:[`Add a description for this slide.`]}))}const pa=new Set([`a`,`blockquote`,`br`,`code`,`em`,`h1`,`h2`,`h3`,`hr`,`i`,`img`,`li`,`ol`,`p`,`pre`,`s`,`span`,`strong`,`u`,`ul`]),ma={a:new Set([`href`,`rel`,`target`,`title`]),img:new Set([`alt`,`loading`,`src`,`title`])};function ha(e){let t=ba(e),n={};for(let[e,r]of Object.entries(t)){let t=r.filter(e=>typeof e==`string`).map(e=>xa(e)?va(e):Sa(e)).filter(Boolean).join(``);t&&(n[e]=[t])}return n}function ga(e){let t={};for(let[n,r]of Object.entries(e||{})){let e=(r||[]).filter(e=>typeof e==`string`).map(e=>xa(e)?va(e):Sa(e)).filter(Boolean).join(``);e&&(t[n]=[e])}return t}function _a(e){return Object.values(ha(e)).flatMap(e=>Array.isArray(e)?e:[e]).filter(e=>typeof e==`string`).join(``)}function va(e){if(typeof document>`u`)return wa(e);let t=document.createElement(`template`);return t.innerHTML=e||``,ya(t.content),t.innerHTML}function ya(e){for(let t of Array.from(e.childNodes)){if(t.nodeType===Node.ELEMENT_NODE){let e=t,n=e.tagName.toLowerCase();if(!pa.has(n)){e.replaceWith(...Array.from(e.childNodes));continue}for(let t of Array.from(e.attributes)){let r=t.name.toLowerCase(),i=ma[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`)}ya(t)}}function ba(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 xa(e){return e.trimStart().startsWith(`<`)}function Sa(e){return e.replace(/\r\n?/g,`
|
|
2
|
-
`).split(/\n+/).map(e=>e.trim()).filter(Boolean).map(e=>`<p>${Ca(e)}</p>`).join(``)}function Ca(e){return e.replace(/&/g,`&`).replace(/</g,`<`).replace(/>/g,`>`).replace(/"/g,`"`).replace(/'/g,`'`)}function wa(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 Ta={id:`@exhibition/right-panel-editor`,supports:{edit:!0,properties:[`label`,`summary`],resourceTypes:[`Canvas`],custom:({resource:e},t)=>Cn(e,t)?!wn(e,t):!1},label:`Exhibition`,component:()=>R(Ea,{})};function Ea(){return R(He,{children:R(Ue,{padding:!0,children:R(Da,{})})})}function Da(){let e=P(),n=I(),r=u(),{structural:i,technical:a}=f(),{items:o}=i,s=a.behavior.get()||[],c=o.get()[0],l=En(e),d=s.includes(`info`),p=Nn(n,e);return!e||!c||!r?R(`div`,{className:`p-8`,children:`Canvas, page, or resource not found`}):d?z(t,{resource:e,children:[l?null:R(yi,{}),R(Oa,{canvas:e}),p?R(ka,{canvas:e}):null]}):z(t,{resource:e,children:[l?null:R(yi,{}),R(Oa,{canvas:e}),R(E,{$wide:!0,children:z(`div`,{children:[R(`div`,{className:`exhibition-workbench-muted mb-3 text-sm font-semibold`,children:`Layout preset`}),R(`div`,{className:`grid grid-cols-2 gap-3`,children:Ii.map(t=>R(Ji,{preset:t.value,label:t.label,selected:na(s)===t.value,onClick:()=>{a.behavior.set(ra(s,t.value,e?{width:e.width,height:e.height}:void 0)),e&&fa(n,e,t.value)}},t.value))}),R(Aa,{canvas:e,tabId:`slide-behaviors`,label:`Edit layout options`})]})}),p?R(ka,{canvas:e}):null,R(he,{annotationPage:c.id,children:R(re,{createFilter:`image`})})]})}function Oa({canvas:e}){let{edit:t}=h(),n=H(null),[r,i]=U(!1),[a,o]=U(!1),s=ja(e.label)||`Untitled`,c=_a(e.summary);return B(()=>{let e=n.current;if(!e){o(!1);return}o(e.scrollHeight>e.clientHeight+1)},[c,r]),R(E,{$wide:!0,children:z(`div`,{className:`rounded-md border border-[#dcd5ce] bg-[#f8f6f3] p-4`,children:[z(`div`,{className:`flex items-start justify-between gap-3`,children:[z(`div`,{className:`min-w-0`,children:[R(`div`,{className:`text-xs font-semibold uppercase text-[#6a625c]`,children:`Label`}),R(`div`,{className:`mt-1 break-words text-base font-semibold text-[#25211f]`,children:s})]}),R(`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`})]}),z(`div`,{className:`mt-5`,children:[R(`div`,{className:`text-xs font-semibold uppercase text-[#6a625c]`,children:`Summary`}),R(`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?R(`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}}):R(`span`,{className:`text-[#6a625c]`,children:`No summary added.`})}),a||r?R(`button`,{type:`button`,className:`mt-2 text-sm font-semibold text-[#b84c74]`,onClick:()=>i(e=>!e),children:r?`Read less`:`Read more`}):null]})]})})}function ka({canvas:e}){let t=I(),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 R(E,{$wide:!0,children:z(`div`,{className:`rounded-md border border-[#dcd5ce] bg-white p-4`,children:[R(`div`,{className:`text-sm font-semibold text-[#25211f]`,children:`Tour steps`}),R(`div`,{className:`mt-1 text-sm text-[#6a625c]`,children:a}),R(Aa,{canvas:e,tabId:`@exhibition/tour-steps`,label:i===0?`Open Tour steps tab to add one`:`Open Tour steps tab`})]})})}function Aa({canvas:e,tabId:t,label:n}){let{edit:r}=h();return z(`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:[R(`span`,{className:`text-left text-sm font-semibold`,children:n}),R(Pe,{})]})}function ja(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 Ma={id:`@exhibition/summary-editor`,supports:{edit:!0,properties:[`summary`],resourceTypes:[`Canvas`],custom:({resource:e},t)=>Cn(e,t)?!wn(e,t):!1},label:`Summary`,component:()=>R(Na,{})};function Na(){return R(He,{children:R(Ue,{padding:!0,children:R(Pa,{})})})}function Pa(){let e=P();return e?z(t,{resource:e,children:[R(D,{dispatchType:`label`}),R(Fa,{canvas:e})]}):null}function Fa({canvas:e}){let t=I();return R(ae,{label:`summary`,metadataKey:`summary`,fields:V(()=>ha(e.summary),[e.summary]),onSave:n=>{t.modifyEntityField(e,`summary`,ga(n.toInternationalString()))}},e.id)}function Ia(e){return R(`svg`,{xmlns:`http://www.w3.org/2000/svg`,width:`1em`,height:`1em`,viewBox:`0 0 24 24`,...e,children:R(`path`,{fill:`currentColor`,d:`M9 16.17L4.83 12l-1.42 1.41L9 19L21 7l-1.41-1.41z`})})}const La=`<h2>New step</h2><p>Description</p>`;function Ra(){let{saveAnnotation:e}=ye(),[t,n]=be(),{editorFeatureFlags:r}=c(),{annotationPopups:i}=r;return i?z(`div`,{className:`bg-white shadow-md rounded-lg`,children:[R(`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:R(ze,{className:`border-none`,value:t.bodyValue||La,onChange:e=>n({bodyValue:e})})}),z(`div`,{className:`flex gap-2 p-3`,children:[z(W,{primary:!0,onPress:()=>e(),children:[R(Ia,{}),` Finish editing`]}),R(b,{})]})]}):z(`div`,{className:`flex gap-2`,children:[z(W,{primary:!0,onPress:()=>e(),children:[R(Ia,{}),` Finish editing`]}),R(b,{})]})}function za(){let e=Ee(s(),e=>e.polygon),[t,n]=be(),{editorFeatureFlags:r}=c(),{annotationPopups:i}=r,{cancelRequest:a,saveAnnotation:o}=ye();return z(`div`,{className:`border border-gray-300 hover:border-me-500 shadow-sm rounded bg-white relative`,children:[z(`div`,{className:`bg-me-primary-500 text-white p-2 m-1 rounded flex gap-2`,children:[R(Ge,{}),`Draw a box on the canvas`]}),i?R(`div`,{className:`relative p-3 line-clamp-3 prose-p:text-slate-600`,children:R(`div`,{className:`prose-headings:mt-1 prose-headings:mb-1 prose-sm`,children:R(`div`,{dangerouslySetInnerHTML:{__html:t.bodyValue||La}})})}):R(ze,{className:`border-none`,value:t.bodyValue||La,onChange:e=>n({bodyValue:e})}),z(`div`,{className:`flex gap-2 p-3`,children:[z(W,{isDisabled:e?.points.length===0,onPress:()=>o(),children:[R(Ia,{}),` Finish editing`]}),z(W,{className:`gap-2 flex`,onPress:()=>a(),children:[R(Fe,{}),` Delete`]}),R(b,{})]})]})}function Ba(){let{editorFeatureFlags:e}=c(),{annotationPopups:t}=e,n=y();return R(W,{className:`ml-auto`,onPress:()=>n({editorFeatureFlags:{...e,annotationPopups:!t}}),children:R(t?Me:Ne,{})})}function Va({highlightProps:e,useSlideshowWorkbench:t=!1}){let r=ke(n),i=_e(),{editorFeatureFlags:a}=c(),{annotationPopups:o}=a,s=Dn(e=>e.startTourStepRepositioning),l=J(e=>e.requestTab),u=J(e=>e.setShowTourSteps),{isPending:d,cancelRequest:f,busy:p,requestAnnotationFromTarget:m,deleteAnnotation:h}=le({annotationPopup:R(me,{annotation:i.id,children:R(n.Provider,{value:r,children:R(Ha,{})})})}),[g,_]=U(!1),v=()=>!t||!i?.id?!1:(u(!0),s(i.id),l(`tour`),!0);return B(()=>{g&&!d&&_(!0)},[d,g]),z(`div`,{...e,className:`exhibition-tour-step-card border border-gray-300 hover:border-me-500 shadow-sm rounded bg-white relative`,onClick:v,children:[R(`div`,{className:`relative`,children:g&&!o?R(T,{className:`border-none`}):R(Re,{className:`exhibition-tour-step-body px-3 pt-3 line-clamp-3 prose-p:text-slate-600`,locale:`en`})}),z(`div`,{className:`flex gap-2 p-2`,children:[g&&d?z(L,{children:[z(W,{primary:!0,onPress:()=>{_(!1),f()},children:[R(Ia,{}),` Finish editing`]}),R(b,{})]}):z(W,{isDisabled:p,onPress:()=>{t&&i?.id&&(u(!0),s(i.id),l(`tour`)),_(!0),m().then(()=>{_(!1)})},children:[R(Ie,{}),` Edit`]}),z(W,{className:`gap-2 flex`,onPress:()=>h(),children:[R(Fe,{}),` Delete`]})]}),R(`div`,{className:`absolute -bottom-5 left-5 h-5 border-l-2 border-gray-300 w-0`})]})}function Ha(){let{editorFeatureFlags:e}=c(),{annotationPopups:t}=e,{saveAnnotation:n}=ye();return t?z(`div`,{className:`bg-white shadow-md rounded-lg relative max-h-[50vh] overflow-y-auto`,children:[R(`div`,{className:`prose-headings:mt-1 rounded prose-headings:mb-1 prose-sm focus-within:ring-1 focus-within:ring-me-primary-500`,children:R(T,{className:`border-none`})}),z(`div`,{className:`flex gap-2 p-2 sticky bottom-0 z-50 bg-white`,children:[z(W,{primary:!0,onPress:()=>{n()},children:[R(Ia,{}),` Finish editing`]}),R(Ba,{})]})]}):z(`div`,{className:`flex gap-2`,children:[z(W,{primary:!0,onPress:()=>n(),children:[R(Ia,{}),` Finish editing`]}),R(b,{})]})}function Ua({originalAnnotationId:e,highlightProps:t,useSlideshowWorkbench:n=!1}){let r=p(ve()),i=_e(),a=P(),o=I(),{edit:s}=h(),[c,l]=U(!1),u=Dn(e=>e.startTourStepRepositioning),d=J(e=>e.requestTab),f=J(e=>e.setShowTourSteps),m=a?.items?.[0],g=m?.id&&i?.id?(o.get(m)?.items||[]).findIndex(e=>e.id===i.id):-1,_=()=>{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)}},v=()=>!n||!e?!1:(f(!0),u(e),d(`tour`),!0);return z(`div`,{...t,className:`exhibition-tour-step-card border border-gray-300 hover:border-me-500 shadow-sm rounded bg-white relative`,onClick:v,children:[R(`div`,{className:`flex gap-2 mb-2 p-3`,children:R(`div`,{className:`flex-1 min-w-0`,children:c?z(L,{children:[R(`h3`,{className:`text-lg font-semibold border-b pt-1 pb-2 mb-2`,children:`Edit step`}),R(D,{dispatchType:`label`}),R(D,{dispatchType:`summary`})]}):z(L,{children:[R(N,{as:`div`,defaultText:R(`span`,{className:`opacity-50`,children:`Untitled`}),className:`whitespace-nowrap overflow-ellipsis w-full overflow-x-hidden`,children:i?.label}),R(N,{className:`exhibition-tour-step-body text-gray-500 text-sm bg-white line-clamp-2`,as:`div`,children:i?.summary})]})})}),z(`div`,{className:`flex gap-2 p-2`,children:[c?z(W,{onPress:()=>l(!1),children:[R(Ia,{}),` Finish editing`]}):z(W,{onPress:()=>l(!0),children:[R(Ie,{}),` Edit body`]}),R(W,{onPress:()=>{v()||i&&s({id:i.id,type:`Annotation`},m?{parent:m,property:`items`,index:g}:void 0,{forceOpen:!0})},children:`Edit annotation`}),z(W,{className:`gap-2 flex`,onPress:()=>_(),children:[R(Fe,{}),` Delete`]})]}),R(`div`,{className:`absolute -bottom-5 left-5 h-5 border-l-2 border-gray-300 w-0`})]})}function Wa({useSlideshowWorkbench:e=!1}){let[n,{annotationTarget:r,highlightProps:i}]=ue(),a=V(()=>r?{id:r,type:`Annotation`}:{id:n?.id,type:`Annotation`},[n?.id,r]);return r?R(t,{resource:a,children:R(me,{annotation:r,children:R(Ua,{originalAnnotationId:n?.id,highlightProps:i,useSlideshowWorkbench:e})})}):R(t,{resource:a,children:R(Va,{highlightProps:i,useSlideshowWorkbench:e})})}function Ga({reorderable:e=!1,useSlideshowWorkbench:t=!1}){let n=ve(),r=p(n);return n?e?R(L,{children:R(ie,{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)=>R(me,{annotation:e.id,children:R(Wa,{useSlideshowWorkbench:t})})})}):R(L,{children:n.items.map(e=>R(me,{annotation:e.id,children:R(Wa,{useSlideshowWorkbench:t})},e.id))}):null}const Ka={id:`@exhibition/tour-steps`,supports:{edit:!0,properties:[`annotations`],resourceTypes:[`Canvas`],custom:({resource:e},t)=>Cn(e,t)?!wn(e,t)&&!Tn(e,t):!1},label:`Tour steps`,component:()=>R(qa,{})};function qa({mode:e=`advanced`}){let t=P(),n=t?.annotations[0],r=t?.items[0];return!n||!t||!r?R(Ja,{}):R(He,{children:R(Ue,{padding:!0,children:R(Ya,{mode:e})})})}function Ja(){let e=P(),t=m(),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 z(`div`,{className:`flex flex-col items-center justify-center p-4`,children:[R(`div`,{className:`p-4 opacity-50 text-center`,children:`This image does not yet have a tour.`}),R(G,{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 Ya({mode:e,useSlideshowWorkbench:n=!1}){let r=P(),i=r?.annotations?.[0],a=r?.items?.[0],[o,s]=U(!1),c=J(e=>e.setShowTourSteps),l=Dn(e=>e.stopRepositioning),u=Dn(e=>e.stopTextRepositioning);B(()=>{c(!0),l(),u()},[c,l,u]);let{requestTourStep:d,isPending:f,busy:p}=Xa({onBeforeRequest:n?()=>{c(!0),l(),u()}:void 0});if(!r)return null;if(!i)return R(Ja,{});let m=e===`advanced`&&!!a;return z(L,{children:[z(`div`,{className:`flex gap-4 border-b pt-4 pb-2 mb-2`,children:[R(`h2`,{className:`text-lg font-semibold flex-1`,children:`Tour steps`}),e===`advanced`?R(W,{onPress:()=>s(e=>!e),children:o?`Done`:`Reorder`}):null]}),R(t,{resource:r,children:z(he,{annotationPage:i.id,children:[z(`div`,{className:`flex flex-col gap-4`,children:[R(Ga,{reorderable:e===`advanced`?o:!1,useSlideshowWorkbench:n}),p?null:f?R(za,{}):R(G,{onPress:d,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`})]}),m&&a?R(L,{children:R(O,{title:R(`h3`,{className:`text-md border-b pt-4 pb-2 mb-2`,children:`Available tour steps from images`}),painting:a,page:i,canvasId:r.id})}):null]})})]})}function Xa({onBeforeRequest:e}={}){let t=P(),n=t?.annotations?.[0],r=m(),{requestAnnotation:i,isPending:a,busy:o}=Ce({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:R(Ra,{})})},isPending:a,busy:o,canRequestTourStep:!!(t&&n)}}const Za={id:`@exhibition/info-box-editor`,supports:{edit:!0,properties:[`label`,`behavior`],resourceTypes:[`Canvas`],custom:({resource:e},t)=>Cn(e,t)?wn(e,t):!1},label:`Text box`,component:()=>R(Qa,{})};function Qa(){let[e,n]=_(`exhibition-info-box-mode`,`simple`),r=P(),i=I(),a=F(),o=f();if(!r||o.technical.type!==`Canvas`)return null;let s=o.technical.behavior.get()||[],c=la(s)||12,l=e=>{let t=s.filter(e=>!e.startsWith(`w-`)&&!e.startsWith(`h-`)),n=s.find(e=>e.startsWith(`h-`));t.push(`w-${e}`),n||t.push(`h-4`),o.technical.behavior.set(t)},u=a?.items&&r?ua(r.id,a.items,i):null;return R(He,{children:z(Ue,{className:`bg-white px-6 pt-5 pb-20`,children:[R(`div`,{className:`flex justify-center`,children:R($i,{value:e,onChange:n})}),z(`div`,{className:`mt-8 flex flex-col gap-7`,children:[R(t,{resource:r,children:e===`simple`?z(ea,{children:[R(ta,{children:`Title`}),R(`div`,{className:`mt-2`,children:R(D,{dispatchType:`label`,disableMultiline:!0,disallowHTML:!0})})]}):z(ea,{children:[R(ta,{children:`Label & summary`}),z(`div`,{className:`mt-2 flex flex-col gap-3`,children:[R(D,{dispatchType:`label`,disableMultiline:!0,disallowHTML:!0}),R(D,{dispatchType:`summary`})]})]})}),e===`simple`?z(L,{children:[z(ea,{children:[R(ta,{children:`Width`}),R(`div`,{className:`mt-3 grid grid-cols-2 gap-3`,children:ca.map(e=>R(Zi,{selected:c===e.value,onClick:()=>l(e.value),children:e.label},e.value))})]}),u?z(ea,{children:[z(ta,{children:[`Fit alongside `,u.neighbour,` slide`]}),R(`div`,{className:`mt-3`,children:z(Zi,{selected:c===u.width,onClick:()=>l(u.width),children:[`w-`,u.width,` — fills remaining space`]})})]}):null,z(`div`,{className:`text-center text-xs`,style:{color:Q.muted},children:[`w-`,c]})]}):z(L,{children:[R(`div`,{className:`px-2`,children:R(E,{$wide:!0,children:R(w,{widthId:o.technical.width.containerId(),width:o.technical.width.get()||0,changeWidth:e=>o.technical.width.set(e),heightId:o.technical.height.containerId(),height:o.technical.height.get()||0,changeHeight:e=>o.technical.height.set(e)})})}),R(S,{behavior:s,onChange:e=>o.technical.behavior.set(e),configs:[{id:`size`,component:(e,t)=>R(Ui,{behaviors:e,setBehaviors:t}),label:{en:[`Size`]},type:`custom`,initialOpen:!0,supports:e=>e.startsWith(`w-`)||e.startsWith(`h-`)}]})]})]})]})})}const $a=`editorial-text`;function eo(){let e=P(),t=e?.items?.[0]?{id:e.items[0].id,type:`AnnotationPage`}:void 0,[,n]=l(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:d,startTextRepositioning:f,stopTextRepositioning:p}=Dn(),m=J(e=>e.setShowTourSteps),h=we((t,n)=>e?Fn(n,e):[],[e?.id,t?.id]),g=Bn(e).text,_=h.length||g;return!e||!t?z(`div`,{children:[R(lo,{children:`Content on this slide`}),R(`p`,{className:`exhibition-workbench-muted mt-2 text-sm leading-relaxed`,children:`This slide does not have a content layer yet.`})]}):z(`div`,{className:`flex flex-col gap-5`,children:[z(`div`,{children:[R(lo,{children:`Content on this slide`}),R(`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.`})]}),_?z(`div`,{className:`flex flex-col gap-2`,children:[g?R(no,{box:g,selected:a===$a,repositioning:o===$a,onSelect:()=>{m(!1),d($a)},onReposition:()=>{m(!1),f($a)},onStopReposition:p}):null,h.map((e,t)=>R(to,{layer:e,index:t,selected:r===e.annotation.id,repositioning:i===e.annotation.id,onSelect:()=>{m(!1),s(e.annotation.id)},onReposition:()=>{m(!1),c(e.annotation.id)},onStopReposition:u,onAdvancedEdit:()=>n.edit({id:e.annotation.id,type:`Annotation`},t)},e.annotation.id))]}):R(`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 to({layer:e,index:t,selected:n,repositioning:r,onSelect:i,onReposition:a,onStopReposition:o,onAdvancedEdit:s}){let c=I(),l=de({annotationId:e.annotation.id,options:{maxWidth:96,maxHeight:96}}),u=so(e.annotation,c),d=io(e,u),f=ao(e,u,t),p=oo(e,u,d);return z(`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:[z(G,{className:`flex w-full items-center gap-3 border-none bg-transparent p-0 text-left`,onPress:i,children:[R(ro,{thumbnailUrl:l?.id,type:d}),z(`span`,{className:`min-w-0 flex-1`,children:[R(`span`,{className:`block text-[11px] font-semibold uppercase tracking-wide text-me-primary-500`,children:d}),R(`span`,{className:`mt-0.5 block truncate text-sm font-semibold`,children:f}),R(`span`,{className:`exhibition-workbench-muted mt-0.5 block truncate text-xs`,children:p})]})]}),z(`div`,{className:`mt-3 flex items-center justify-between gap-3`,children:[R(`span`,{className:`exhibition-workbench-muted text-xs`,children:r?`Drag or resize in the workbench`:n?`Selected in workbench`:`Click to select on slide`}),z(`div`,{className:`flex gap-2`,children:[R(G,{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`}),R(G,{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 no({box:e,selected:t,repositioning:n,onSelect:r,onReposition:i,onStopReposition:a}){return z(`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:[z(G,{className:`flex w-full items-center gap-3 border-none bg-transparent p-0 text-left`,onPress:r,children:[R(ro,{type:`Text`}),z(`span`,{className:`min-w-0 flex-1`,children:[R(`span`,{className:`block text-[11px] font-semibold uppercase tracking-wide text-me-primary-500`,children:`Editorial text`}),R(`span`,{className:`mt-0.5 block truncate text-sm font-semibold`,children:`Slide label and summary`}),z(`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)]})]})]}),z(`div`,{className:`mt-3 flex items-center justify-between gap-3`,children:[R(`span`,{className:`exhibition-workbench-muted text-xs`,children:n?`Drag or resize in the workbench`:t?`Selected in workbench`:`Click to select on slide`}),R(G,{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 ro({thumbnailUrl:e,type:t}){return R(`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?R(`img`,{alt:``,className:`h-full w-full object-cover`,src:e}):R(`span`,{children:t})})}function io(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 ao(e,t,n){let r=j(t?.label,``),i=j(e.annotation.label,``),a=e.html?co(e.html).slice(0,80):``;return r||i||a||`${io(e,t)} layer ${n+1}`}function oo(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 so(e,t){return M(t,Array.isArray(e?.body)?e.body[0]:e?.body)}function co(e){return e.replace(/<br\s*\/?>/gi,` `).replace(/<\/p>/gi,` `).replace(/<[^>]+>/g,` `).replace(/\s+/g,` `).trim()}function lo({children:e}){return R(`div`,{className:`exhibition-workbench-muted text-sm font-semibold`,children:e})}const uo=[{id:`layout`,label:`Layout`},{id:`summary`,label:`Summary`},{id:`tour`,label:`Tour steps`}],fo=[{id:`layout`,label:`Layout`},{id:`content`,label:`Content`},{id:`summary`,label:`Summary`},{id:`tour`,label:`Tour steps`}],po=[{value:`simple`,label:`Simple`},{value:`advanced`,label:`Advanced`}],mo={track:`#f5eaf0`,active:`#b84c74`,inactiveText:`#8b3f61`,activeText:`#ffffff`,activeShadow:`0 1px 3px rgba(15, 23, 42, 0.18)`},ho={id:`@exhibition/workbench-editor`,supports:{edit:!0,properties:[`label`,`summary`,`behavior`,`annotations`],resourceTypes:[`Canvas`],custom:({resource:e},t)=>Cn(e,t)?wn(e,t):!1},label:`Canvas`,component:()=>R(_o,{})},go={...ho,id:`@exhibition/slideshow-workbench-editor`,supports:{...ho.supports,custom:({resource:e},t)=>Cn(e,t)},component:()=>R(_o,{preset:`slideshow`})};function _o({preset:e=`default`}){let[t,n]=_(`exhibition-right-panel-mode`,`simple`),r=P(),i=I(),a=!!r?.behavior?.includes(`info`),o=Nn(i,r),s=V(()=>(e===`slideshow`?fo:uo).filter(e=>e.id!==`tour`||o),[e,o]),[c,l]=U(`layout`),u=J(e=>e.requestedTab),d=J(e=>e.clearRequestedTab),f=J(e=>e.setShowTourSteps),p=J(e=>e.setCenterPanelMode);B(()=>{c===`tour`?p(`edit`):c===`layout`&&p(`preview`)},[]),B(()=>{if(u&&s.some(e=>e.id===u)){let e=u;l(e),f(e===`tour`),e===`tour`?p(`edit`):e===`layout`&&p(`preview`),d()}},[d,u,p,f,s]),B(()=>{c===`tour`&&!o&&(l(`layout`),f(!1))},[c,f,o]);let m=e=>{l(e),f(e===`tour`),e===`tour`?p(`edit`):e===`layout`&&p(`preview`)};return a?R(Qa,{}):R(He,{children:z(Ue,{className:`bg-white px-6 pt-5 pb-20`,children:[R(`div`,{className:`flex justify-center`,children:R(vo,{value:t,options:po,onChange:n})}),R(`div`,{className:[`mt-5 grid border-b border-[#e4ddd6]`,s.length===4?`grid-cols-4`:`grid-cols-3`].join(` `),children:s.map(e=>R(`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:()=>m(e.id),children:e.label},e.id))}),z(`div`,{className:`mt-8 px-4`,children:[c===`layout`?R(Gi,{mode:t,layoutContext:e===`slideshow`?`slideshow`:`default`}):null,c===`content`?R(eo,{}):null,c===`summary`?R(t===`simple`?yo:Pa,{}):null,c===`tour`?R(Ya,{mode:t,useSlideshowWorkbench:e===`slideshow`}):null]})]})})}function vo({value:e,options:t,onChange:n}){return R(`div`,{className:`grid w-full max-w-[240px] grid-cols-2 rounded-full p-1`,style:{backgroundColor:mo.track},children:t.map(t=>{let r=e===t.value;return R(G,{className:`border-none rounded-full bg-transparent px-4 py-2 text-sm font-semibold transition-colors`,style:{backgroundColor:r?mo.active:`transparent`,color:r?mo.activeText:mo.inactiveText,boxShadow:r?mo.activeShadow:`none`},onPress:()=>n(t.value),children:t.label},t.value)})})}function yo(){let e=P();return e?R(t,{resource:e,children:z(`div`,{className:`flex flex-col gap-7`,children:[z(`div`,{children:[R(bo,{children:`Slide title`}),R(`div`,{className:`mt-2`,children:R(D,{dispatchType:`label`,disableMultiline:!0,disallowHTML:!0})})]}),z(`div`,{children:[R(bo,{children:`Slide summary`}),R(`div`,{className:`mt-2`,children:R(D,{dispatchType:`summary`})})]})]})}):null}function bo({children:e}){return R(`div`,{className:`exhibition-workbench-muted text-sm font-semibold`,children:e})}var xo=e=>R(`svg`,{xmlns:`http://www.w3.org/2000/svg`,width:`1em`,height:`1em`,viewBox:`0 0 15 15`,...e,children:R(`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`})});const So=i(a(e),{id:`exhibition-scrolling-editor`,title:`Exhibition Editor (scrolling)`,project:!0,projectType:`Manifest`},{config:{editorConfig:{}},leftPanels:[],centerPanels:[],annotations:[],background:[],canvasEditors:[],editors:[Za,ho,Ta,zi,Ma,Ka],creators:[ui,gi,ni,ei,ii,ci,pi]}),Co={id:`slideshow-canvas-editor`,label:`Slideshow canvas editor`,component:()=>R(wo,{}),supports:{strategy:(e,t,n)=>{let r=n.get(t.resource);return r?.type===`Canvas`&&En(r)}}};function wo(){let e=P(),t=F(),{edit:n}=h(),{rightPanel:r}=g(),i=J(e=>e.centerPanelMode),a=xe(),o=ce(e=>e.annotationId),[s,c]=U(1),l=t?.items?.findIndex(t=>t.id===e?.id),u=typeof l==`number`?t?.items?.[l-1]:void 0,d=typeof l==`number`?t?.items?.[l+1]:void 0;return e?a||o||i===`edit`||r.current===`@manifest-editor/editor`&&r.state?.currentTab?.startsWith(`@exhibition/tour-steps`)?R(C,{asFallback:!0}):z(`div`,{className:`exhibition-slideshow-current-canvas flex h-full min-h-0 flex-col bg-slate-100`,children:[z(`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:[R(`div`,{className:`min-w-0 flex-1`,children:R(N,{className:`block truncate text-sm font-semibold text-slate-800`,children:e.label})}),z(`div`,{className:`flex items-center gap-2`,children:[R(To,{onPress:()=>c(1),children:`Home`}),R(To,{onPress:()=>c(e=>Math.max(.25,e-.25)),children:`-`}),R(To,{onPress:()=>c(e=>Math.min(3,e+.25)),children:`+`}),R(To,{isDisabled:!u,onPress:()=>u&&n({id:u.id,type:`Canvas`},void 0,{forceOpen:!1}),children:`Previous`}),R(To,{isDisabled:!d,onPress:()=>d&&n({id:d.id,type:`Canvas`},void 0,{forceOpen:!1}),children:`Next`})]})]}),R(`div`,{className:`exhibition-slideshow-current-viewport min-h-0 flex-1 overflow-auto p-8`,children:R(`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:R(ge,{canvas:e.id,children:R(Zn,{})})})})]}):null}function To({children:e,isDisabled:t,onPress:n}){return R(G,{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})}var Eo=e=>R(`svg`,{xmlns:`http://www.w3.org/2000/svg`,width:`1em`,height:`1em`,viewBox:`0 0 48 48`,...e,children:z(`g`,{fill:`none`,stroke:`#000`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:4,children:[R(`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`}),R(`circle`,{cx:24,cy:24,r:2})]})}),Do=e=>R(`svg`,{xmlns:`http://www.w3.org/2000/svg`,width:`1em`,height:`1em`,viewBox:`0 0 24 24`,...e,children:R(`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`})});const Oo={skipEditingOnCreate:!0},ko={id:`@exhibitions/slideshow-center-panel`,label:`Slideshow workbench`,icon:R(Do,{}),render:()=>R(Ao,{})};function Ao(){let{structural:e,technical:t}=v(),n=e.items.get(),r={id:t.id.get(),type:`Manifest`},i=I(),[,a]=l(r,`items`,`Canvas`,void 0,{isPainting:!0}),o=fe(`Canvas`),{edit:s}=h(),c=Dn(e=>e.clear),u=o?.resource.source.id||n[0]?.id,d=u?n.findIndex(e=>e.id===u):-1,f=d>=0?d:0,p=d>=0?n[d]:n[0]||null;B(()=>{for(let e of n)zn(i,i.get(e))},[n,i]);let m=()=>{a.createFiltered(`exhibition-slideshow-slide`,n.length?f+1:void 0)},g=(e,t,n=!1)=>{s({id:e.id,type:`Canvas`},{parent:r,property:`items`,index:t},{forceOpen:n})},_=(e,t)=>{c(),g(e,t)},y=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&&g(r,Math.max(0,i))},b=f>0?n[f-1]:void 0,x=f<n.length-1?n[f+1]:void 0;return n.length?R(jo,{children:z(`div`,{className:`exhibition-slideshow-main flex min-h-full flex-col gap-6 pb-12 pt-16`,children:[z(`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:[z(`div`,{className:`min-w-0 flex-1`,children:[R(`p`,{className:`text-sm font-semibold uppercase tracking-wider text-me-primary-500`,children:`Slideshow workbench`}),R(`h2`,{className:`exhibition-slideshow-heading truncate text-2xl font-bold text-slate-900`,children:p?R(ge,{canvas:p.id,children:R(Mo,{})}):`Slides`}),z(`p`,{className:`exhibition-slideshow-muted mt-1 text-sm font-semibold text-slate-500`,children:[`Slide `,f+1,` of `,n.length]})]}),R(No,{current:f+1,total:n.length,onPrevious:b?()=>_(b,f-1):void 0,onNext:x?()=>_(x,f+1):void 0}),R(`div`,{children:R(W,{primary:!0,onPress:m,children:`Add new slide`})})]}),z(`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:[R(`div`,{className:`exhibition-slideshow-preview-frame flex items-center justify-center overflow-hidden rounded-lg bg-slate-100`,children:p?R(ge,{canvas:p.id,children:R(Fo,{})}):null}),z(`aside`,{className:`exhibition-slideshow-slide-strip overflow-hidden rounded-lg border border-slate-200 bg-white p-4`,children:[R(`div`,{className:`exhibition-slideshow-heading mb-3 text-sm font-semibold text-slate-700`,children:`Slides`}),R(`div`,{className:`flex gap-3 overflow-x-auto pb-2`,children:n.map((e,t)=>R(ge,{canvas:e.id,children:R(Zo,{index:t,selected:p?.id===e.id,onPress:()=>_(e,t),onDelete:()=>y(t)})},e.id))})]})]})]})}):R(jo,{children:R(`div`,{className:`flex min-h-full items-center justify-center px-24 py-12`,children:z(`div`,{className:`w-full max-w-4xl`,children:[R(`p`,{className:`text-sm font-semibold uppercase tracking-wider text-me-primary-500`,children:`Slideshow exhibition`}),R(`h2`,{className:`mt-2 text-3xl font-bold text-slate-900`,children:`Create your first slideshow slide`}),R(`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.`}),R(`div`,{className:`mt-8`,children:R(W,{primary:!0,large:!0,onPress:m,children:`Add new slide`})})]})})})}function jo({children:e}){return R(Ue,{className:`exhibition-slideshow-workbench h-full overflow-x-hidden overflow-y-auto bg-[#f8f6f3]`,children:e})}function Mo(){return R(L,{children:Yo(P()?.label,`Untitled slide`)||`Untitled slide`})}function No({current:e,total:t,onPrevious:n,onNext:r}){return z(`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:[R(G,{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`}),z(`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]}),R(G,{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 Po({current:e,total:t,onPrevious:n,onNext:r}){return z(`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:[R(G,{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`}),R(`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`}),R(G,{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 Fo(){let e=P(),t=I(),n=m(),r=J(e=>e.centerPanelMode),i=J(e=>e.setCenterPanelMode),a=r,o=i,[s,c]=U(null),[u,d]=U(`box`),f=H(null),p=H(null),h=e?.annotations?.[0]?.id,g=e?.items?.[0]?{id:e.items[0].id,type:`AnnotationPage`}:void 0,[,_]=l(g,`items`,`Annotation`,e?An(e):void 0,{isPainting:!0}),{selectedAnnotationId:v,repositioningAnnotationId:y,selectedTextRegion:b,repositioningTextRegion:x,selectedTourStepId:S,selectAnnotation:C,startRepositioning:w,stopRepositioning:T,startTextRepositioning:ee,stopTextRepositioning:E,selectTourStep:te,stopTourStepRepositioning:D}=Dn(),ne=J(e=>e.requestTab),re=J(e=>e.showTourSteps),O=J(e=>e.setShowTourSteps),ie=we((t,n)=>e?jn(n,e):[],[e?.id,g?.id]),ae=ie.find(e=>e.id===v),oe=b===`editorial-text`?Bn(e).text:null,k=we((t,n)=>e?Mn(n,e):[],[e?.id,h]),A=k.find(e=>e.id===S)||k[0],j=A?Math.max(0,k.findIndex(e=>e.id===A.id)):-1,se=Nn(t,e),M=re&&se,ce=e=>{let t=k[e];t?.id&&te(t.id)};B(()=>{f.current=null,p.current=null,c(null),d(`box`)},[e?.id]),B(()=>{!se&&re&&(O(!1),D(),c(null))},[O,re,D,se]),B(()=>{M&&o(`edit`)},[M]),B(()=>{if(f.current===null){f.current=ie.length;return}let e=ie[ie.length-1];ie.length>f.current&&e?.id&&(C(e.id),ne(`content`),O(!1)),f.current=ie.length},[ie,ne,C,O]),B(()=>{if(p.current===null){p.current=k.length;return}let e=k[k.length-1];k.length>p.current&&e?.id&&(te(e.id),T(),E(),O(!0)),p.current=k.length},[te,O,T,E,k]);let le=()=>{let e=!re;O(e),e?(T(),E(),A?.id&&te(A.id)):D()},ue=()=>{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`}}})},de=()=>{!e||!h||(O(!0),T(),E(),d(`box`),c({type:`add`}))},fe=()=>{A?.id&&(O(!0),T(),E(),d(`box`),c({type:`edit`,annotationId:A.id}))};return z(`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:[z(`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:[R(`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)`}),z(`div`,{className:`flex flex-wrap items-center gap-2`,children:[a===`edit`?z(L,{children:[se?R(G,{className:K(`rounded-md border px-3 py-2 text-xs font-semibold shadow-sm transition`,M?`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:le,children:M?`Hide tour steps`:`Show tour steps`}):null,M?z(L,{children:[R(Po,{current:j+1,total:k.length,onPrevious:j>0?()=>ce(j-1):void 0,onNext:j>=0&&j<k.length-1?()=>ce(j+1):void 0}),h?R(G,{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:de,children:`Add tour step`}):R(G,{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:ue,children:`Create tour`})]}):R(G,{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:()=>{O(!1),D(),_.create(void 0,Oo)},children:`Add content`})]}):null,z(`div`,{className:`flex shrink-0 overflow-hidden rounded-md border border-slate-200 bg-slate-50 text-xs font-semibold`,children:[R(Xo,{selected:a===`edit`,onPress:()=>o(`edit`),children:`Edit`}),R(Xo,{selected:a===`preview`,onPress:()=>o(`preview`),children:`Preview`})]})]})]}),z(`div`,{className:`relative min-h-0 flex-1 bg-black`,children:[R(Zn,{editable:a===`edit`,mode:a,showTourSteps:M}),s&&e&&h?R(Uo,{annotationPageId:h,canvas:e,mode:s,selectedTool:u,setSelectedTool:d,vault:t,onCancel:()=>c(null),onComplete:e=>{e&&te(e),O(!0),c(null)}}):null,!s&&a===`edit`&&!M&&ae&&e?R(zo,{annotation:ae,canvas:e,isRepositioning:y===ae.id,onStartReposition:()=>w(ae.id),onStopReposition:T,vault:t}):null,!s&&a===`edit`&&!M&&oe&&e?R(zo,{canvas:e,currentBox:oe,isRepositioning:x===b,label:`Editorial text`,onStartReposition:()=>ee(`editorial-text`),onStopReposition:E,setBox:n=>Rn(t,e,n),vault:t}):null,!s&&a===`edit`&&M&&e?A?R(zo,{annotation:A,canvas:e,isRepositioning:!1,label:`Selected tour step target`,onStopReposition:D,showBoxFields:!0,showRepositionButton:!1,vault:t,children:h?R(Io,{annotationPageId:h,canvas:e,onAddTourStep:de,onEditTarget:fe,selectedTourStepId:A?.id}):null}):R(Ro,{label:`Tour steps`,children:h?R(Io,{annotationPageId:h,canvas:e,onAddTourStep:de,onEditTarget:fe,selectedTourStepId:A?.id}):R(Lo,{onCreate:ue})}):null]})]})}function Io({annotationPageId:e,canvas:n,onAddTourStep:r,onEditTarget:i,selectedTourStepId:a}){return R(t,{resource:n,children:R(he,{annotationPage:e,children:z(`div`,{className:`space-y-3 text-slate-800`,children:[z(`div`,{className:`flex items-center justify-between gap-2`,children:[R(`h3`,{className:`text-sm font-semibold text-slate-800`,children:`Tour steps`}),z(`div`,{className:`flex flex-wrap gap-2`,children:[a?R($,{label:`Edit target`,onPress:i}):null,R($,{primary:!0,label:`Add step`,onPress:r})]})]}),R(`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.`}),R(`div`,{className:`max-h-72 overflow-y-auto pr-1`,children:R(Ga,{reorderable:!1,useSlideshowWorkbench:!0})})]})})})}function Lo({onCreate:e}){return z(`div`,{className:`space-y-3 text-slate-800`,children:[R(`p`,{className:`text-xs text-slate-600`,children:`This slide does not have a tour annotation page yet.`}),R($,{primary:!0,label:`Create tour`,onPress:e})]})}function Ro({children:e,label:t}){return z(`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:[R(`div`,{className:`mb-2 font-semibold text-slate-700`,children:t}),e]})}function zo({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 p=H(null),m=H(null),[h,g]=U(null),_=Number(t?.width)||1920,v=Number(t?.height)||1080,y=r||In(e,t),b=c||(n=>Ln(l,t,e.id,n)),x=Math.round(_/2),S=Math.round(v/2),C=e=>{let t=p.current,n=t?.offsetParent,r=t?.getBoundingClientRect(),i=n?.getBoundingClientRect();!t||!r||!i||(e.currentTarget.setPointerCapture(e.pointerId),m.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)})},w=e=>{let t=m.current;!t||t.pointerId!==e.pointerId||g({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))})},T=e=>{m.current?.pointerId===e.pointerId&&(m.current=null,e.currentTarget.hasPointerCapture(e.pointerId)&&e.currentTarget.releasePointerCapture(e.pointerId))};return R(`div`,{ref:p,className:K(`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`,h?null:`bottom-4 left-4`),style:h?{left:h.x,top:h.y}:void 0,children:z(`div`,{className:`flex flex-col gap-3`,children:[z(`div`,{className:`min-w-[280px]`,children:[z(`div`,{className:`mb-2 flex items-center justify-between gap-3`,children:[R(`span`,{className:`font-semibold text-slate-700`,children:a}),z(`div`,{className:`flex items-center gap-2`,children:[R(`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:C,onPointerMove:w,onPointerUp:T,onPointerCancel:T,children:R(Eo,{})}),z(`span`,{className:`text-slate-400`,children:[Math.round(y.width),` x `,Math.round(y.height)]})]})]}),u?null:z(`div`,{className:`space-y-2`,children:[z(`div`,{className:`flex flex-wrap gap-2`,children:[f&&o?R($,{onPress:o,label:`Reposition`,primary:!0}):null,i&&s?R($,{onPress:s,label:`Stop moving`}):null,R($,{onPress:()=>b({x:0,y:0,width:_,height:v}),label:`Fill`}),R($,{onPress:()=>b({x:Math.round(_*.1),y:Math.round(v*.1),width:Math.round(_*.8),height:Math.round(v*.8)}),label:`Centre`}),R($,{onPress:()=>b({x:0,y:0,width:x,height:v}),label:`Left`}),R($,{onPress:()=>b({x,y:0,width:x,height:v}),label:`Right`}),R($,{onPress:()=>b({x:0,y:0,width:_,height:S}),label:`Top`}),R($,{onPress:()=>b({x:0,y:S,width:_,height:S}),label:`Bottom`})]}),d?R(Bo,{box:y,onChange:b}):null]})]}),n?R(`div`,{className:`w-full border-t border-slate-200 pt-3`,children:n}):null]})})}function Bo({box:e,onChange:t}){let n=(n,r)=>{let i=Number(r);Number.isFinite(i)&&t({...e,[n]:Math.round(i)})};return z(`div`,{className:`grid grid-cols-4 gap-2 pt-1`,children:[R(Vo,{label:`X`,value:e.x,onChange:e=>n(`x`,e)}),R(Vo,{label:`Y`,value:e.y,onChange:e=>n(`y`,e)}),R(Vo,{label:`W`,value:e.width,onChange:e=>n(`width`,e)}),R(Vo,{label:`H`,value:e.height,onChange:e=>n(`height`,e)})]})}function Vo({label:e,value:t,onChange:n}){return z(`label`,{className:`block text-[11px] font-semibold text-slate-500`,children:[e,R(`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 Ho(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(St({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(xt({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 Uo({annotationPageId:e,canvas:t,mode:n,selectedTool:r,setSelectedTool:i,vault:a,onCancel:o,onComplete:s}){let c=H(null),[l,u]=U(null),[d,f]=U(null),[p,m]=U([]),h=Number(t?.width)||1920,g=Number(t?.height)||1080,_=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:Jo(Math.round(i.x),0,h),y:Jo(Math.round(i.y),0,g)}},v=e=>{if(e.preventDefault(),r===`polygon`){let t=_(e);m(e=>[...e,t]);return}u(_(e)),f(null)},y=e=>{if(!l||r===`polygon`)return;let t=_(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})},b=()=>{u(null)},x=r===`polygon`&&p.length?{type:`polygon`,points:p}:d,S=()=>{u(null),f(null),m([])};return z(`div`,{className:`absolute inset-0 z-30`,children:[z(`svg`,{ref:c,className:`absolute inset-0 h-full w-full cursor-crosshair touch-none`,preserveAspectRatio:`xMidYMid meet`,viewBox:`0 0 ${h} ${g}`,onPointerDown:v,onPointerMove:y,onPointerUp:b,onPointerCancel:b,children:[R(`rect`,{x:0,y:0,width:h,height:g,fill:`transparent`}),x?R(Go,{shape:x}):null,p.map((e,t)=>R(`circle`,{cx:e.x,cy:e.y,r:8,fill:`white`,stroke:`#be4778`,strokeWidth:4},`${e.x}-${e.y}-${t}`))]}),z(`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:[R(`span`,{className:`mr-2 font-semibold text-slate-700`,children:n.type===`add`?`Draw new tour step`:`Edit target`}),R(Wo,{active:r===`box`,label:`Box`,onPress:()=>{S(),i(`box`)}}),R(Wo,{active:r===`circle`,label:`Circle`,onPress:()=>{S(),i(`circle`)}}),R(Wo,{active:r===`line`,label:`Line`,onPress:()=>{S(),i(`line`)}}),R(Wo,{active:r===`polygon`,label:`Polygon`,onPress:()=>{S(),i(`polygon`)}}),R($,{primary:!0,label:n.type===`add`?`Create step`:`Save target`,onPress:()=>{if(!x)return;let r=Ko(t.id,x);if(n.type===`edit`){a.modifyEntityField({id:n.annotationId,type:`Annotation`},`target`,r),s(n.annotationId);return}s(Ho(a,t,e,r))}}),R($,{label:`Clear`,onPress:S}),R($,{label:`Cancel`,onPress:o})]})]})}function Wo({active:e,label:t,onPress:n}){return R(G,{className:K(`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 Go({shape:e}){let t={fill:`rgba(190, 71, 120, 0.18)`,stroke:`#be4778`,strokeWidth:6,vectorEffect:`non-scaling-stroke`};return e.type===`box`?R(`rect`,{...t,x:e.x,y:e.y,width:e.width,height:e.height}):e.type===`circle`?R(`circle`,{...t,cx:e.cx,cy:e.cy,r:e.r}):e.type===`line`?R(`line`,{x1:e.x1,y1:e.y1,x2:e.x2,y2:e.y2,stroke:`#be4778`,strokeWidth:6,vectorEffect:`non-scaling-stroke`}):R(`polygon`,{...t,points:e.points.map(e=>`${e.x},${e.y}`).join(` `)})}function Ko(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:qo(t)}}}function qo(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 Jo(e,t,n){return Math.min(n,Math.max(t,e))}function Yo(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 R(G,{className:K(`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 Xo({children:e,selected:t,onPress:n}){return R(G,{className:K(`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 Zo({index:e,selected:t,onPress:n,onDelete:r}){let i=P();return z(`div`,{className:K(`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:[z(G,{className:`block w-full border-none bg-transparent p-0 text-left`,onPress:n,children:[R(`div`,{className:`aspect-video overflow-hidden rounded`,style:{backgroundColor:`#0e0d12`},children:R(Zn,{className:`pointer-events-none h-full w-full`,mode:`preview`})}),z(`div`,{className:`mt-2 flex items-center gap-2 pr-7`,children:[R(`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}),R(N,{className:`min-w-0 truncate text-sm font-medium text-slate-800`,children:i?.label})]})]}),R(G,{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 Qo=i(a(e),{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:[ur],centerPanels:[ko],annotations:[Ct],leftPanelIds:[`left-panel-manifest`],background:[kr],canvasEditors:[Co],editors:[go,Za,Ta,zi,Ma,Ka],creators:[ai,oi,mi,_i,di]}),$o=i(a(e),{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:[lr,vr],centerPanels:[Yt,mn],annotations:[Ct],leftPanelIds:[`left-panel-manifest`],background:[kr],canvasEditors:[jr,Qr,Fr],editors:[Za,ho,Ta,zi,Ma,Ka],creators:[ui,gi,ni,ei,ii,ci,pi]});export{xo as PresetIcon,$o as exhibitionEditorPreset,So as exhibitionEditorScrollingPreset,Qo as exhibitionEditorSlideshowPreset};
|
|
1
|
+
import*as e from"@manifest-editor/manifest-preset";import{ButtonChange as t,ButtonContainer as n,ButtonMain as r,MenuContainer as i,MenuItemLabel as a,MenuItemStatus as o,ResourceEditingProvider as s,createIframeVaultBridge as c,extendApp as l,mapApp as u,useApp as d,useAppResource as f,useAtlasStore as p,useConfig as m,useCreator as h,useEditingResource as g,useEditingStack as _,useEditor as v,useGenericEditor as y,useInlineCreator as b,useLayoutActions as x,useLayoutState as S,useLocalStorage as C,useManifestEditor as w,useOpenPresetOnboarding as T,usePresetTemplateSelection as ee,usePreviewContext as E,usePreviewWindow as D}from"@manifest-editor/shell";import{AppDropdown as O,BehaviorEditor as te,CanvasPanelEditor as k,DimensionsTriplet as A,Input as ne,InputContainer as j,InputFieldset as re,InputLabel as ie,LanguageFieldEditor as ae,LanguageMapEditor as oe,LinkingPropertyList as se,MediaEditor as ce,PaintingAnnotationList as le,PromptToAddPaintingAnnotations as ue,ReorderList as de,TiptapLanguageFieldEditor as fe,ViewerAnnotationPage as pe,createAppActions as me,getInternationalStringText as he,getYouTubeId as ge,resolveContentResource as _e,targetWholeCanvas as ve,useAnnotationEditing as ye,useAnnotationEditor as be,useAnnotationInfo as xe,useAnnotationThumbnail as Se,useInStack as Ce,useToggleList as we}from"@manifest-editor/editors";import{AnnotationContext as Te,AnnotationPageContext as Ee,AtlasStoreReactContext as De,CanvasContext as Oe,CanvasPanel as ke,LocaleString as M,VaultProvider as Ae,useAnnotation as je,useAnnotationPage as Me,useCanvas as N,useCurrentAnnotationActions as Ne,useCurrentAnnotationMetadata as Pe,useCurrentAnnotationRequest as Fe,useManifest as P,useRequestAnnotation as Ie,useVault as F,useVaultSelector as I}from"react-iiif-vault";import{create as Le,useStore as Re}from"zustand";import{Fragment as L,jsx as R,jsxs as z}from"react/jsx-runtime";import{forwardRef as ze,useCallback as Be,useEffect as B,useId as Ve,useLayoutEffect as He,useMemo as V,useRef as H,useState as U}from"react";import{ActionButton as W,AddIcon as Ue,ArrowRightIcon as We,DeleteIcon as Ge,DownloadButton as Ke,EditTextIcon as qe,EmptyCanvasIcon as Je,HTMLAnnotationBodyRender as Ye,HTMLEditor as Xe,LazyThumbnail as Ze,Modal as Qe,MoreMenu as $e,OnboardingTour as et,Sidebar as tt,SidebarContent as nt,SidebarHeader as rt,TargetIcon as it,useCanvasRenderingStrategy as at}from"@manifest-editor/components";import{DelftExhibition as ot}from"exhibition-viewer";import{EditorHooksProvider as st}from"exhibition-viewer/library";import{Button as G,Dialog as ct,DialogTrigger as lt,Menu as ut,MenuItem as dt,MenuTrigger as ft,Popover as pt}from"react-aria-components";import{twMerge as K}from"tailwind-merge";import{CanvasListView as mt,CanvasListingIcon as ht}from"@manifest-editor/manifest-preset/components";import gt from"tiny-invariant";import{canonicalServiceUrl as _t,createImageServiceRequest as vt,imageServiceRequestToString as yt,isImageService as bt,parseImageServiceRequest as xt}from"@iiif/parser/image-3";import{DndContext as St,KeyboardSensor as Ct,PointerSensor as wt,closestCenter as Tt,useSensor as Et,useSensors as Dt}from"@dnd-kit/core";import{restrictToParentElement as Ot}from"@dnd-kit/modifiers";import{SortableContext as kt,rectSortingStrategy as At,sortableKeyboardCoordinates as jt,useSortable as Mt,verticalListSortingStrategy as Nt}from"@dnd-kit/sortable";import{CSS as Pt}from"@dnd-kit/utilities";import{addMappings as Ft,importEntities as It}from"@iiif/helpers/vault/actions";import{creatorHelper as Lt,defineCreator as q}from"@manifest-editor/creator-api";import{createYoutubeBodyResource as Rt,iiifBrowserCreator as zt,imageServiceCreator as Bt,imageUrlCreator as Vt,videoAnnotation as Ht,youTubeBodyCreator as Ut}from"@manifest-editor/creators";import{emptyAnnotation as Wt,emptyAnnotationPage as Gt,emptyCanvas as Kt}from"@iiif/parser";import{Vault as qt,getValue as Jt}from"@iiif/helpers";import{HTMLPortal as Yt}from"@atlas-viewer/atlas";const Xt={id:`@exhibition/tour-step-annotations`,label:`Tour steps`,render:()=>R(Qt,{})},Zt={border:`2px solid rgba(255, 255, 255, 0.3)`,":hover":{borderColor:`#4B67E1`,backgroundColor:`rgba(255, 255, 255, 0.2)`}};function Qt(){let e=N(),t=p(),n=Re(t,e=>e.tool.enabled),{rightPanel:r}=S(),i=r.current===`@manifest-editor/editor`&&r.state?.currentTab?.startsWith(`@exhibition/tour-steps`),a=e?.annotations[0];return!i||!e||n||!a?null:R(L,{children:R(Ee,{annotationPage:a.id,children:R(pe,{showAnnotationNumber:!0,style:Zt})})})}const $t=`https://exhibitionviewer.org/iiif/theme-service`,en={en:[`Exhibition viewer theme`]},tn={fontSans:`"Tahoma", "Fira Sans", sans-serif`,fontMono:`"Fira Mono", monospace`,titleTransform:`uppercase`},nn={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`},rn={...nn,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`},an={titleBackground:`#fff`,titleColor:`#444`,annotationBackground:`#fff`,annotationColor:`#333`,annotationRadius:`0px`,annotationMaxWidth:`30em`,infoBlockBackground:`#fff`,infoBlockColor:`#444`},on={cutCorners:!0,fullTitleBar:!1,fullWidthGrid:!1,hideTableOfContents:!1,tableOfContentsPlacement:`footer`,showProgressBar:!0,showProgressTableOfContents:!0,showNavigationControls:!0,disablePresentation:!1,hideTitle:!1,hideTitleCard:!1,alternativeImageMode:!0,transitionScale:!1,imageInfoIcon:!1,coverImages:!1,ignoreCanvasBackgrounds:!1},sn={cutCorners:!1,isFloating:!1,floatingPosition:`bottom-left`,labelOnlyFloating:!0,ignoreCanvasBackgrounds:!1},cn={alternativeImageMode:!0,transitionScale:!1,imageInfoIcon:!1,coverImages:!1,ignoreCanvasBackgrounds:!1},ln={showTitleBlock:!0,showTableOfContents:!1,tableOfContentsPlacement:`header`,showProgressBar:!0,showProgressTableOfContents:!0,showScrollToTop:!0,showNavigationControls:!0,ignoreCanvasBackgrounds:!1,titleBlock:{fullHeight:!0}},un={version:1,preset:`delft`,shared:tn,delft:{tokens:nn,exhibition:on,presentation:sn,slideshow:cn},scroll:{tokens:an,options:ln}},dn={delft:un,minimal:{...un,preset:`minimal`,shared:{...tn,titleTransform:`none`},delft:{...un.delft,tokens:rn}},gallery:{version:1,preset:`gallery`,shared:{fontSans:`"Gill Sans", "Trebuchet MS", sans-serif`,fontMono:`"Courier Prime", "Courier New", monospace`,titleTransform:`capitalize`},delft:{tokens:{...nn,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:{...on,cutCorners:!1,fullTitleBar:!0,fullWidthGrid:!0,alternativeImageMode:!1,transitionScale:!0,imageInfoIcon:!0,coverImages:!0},presentation:{...sn,isFloating:!0,floatingPosition:`bottom-right`},slideshow:{...cn,alternativeImageMode:!1,transitionScale:!0,imageInfoIcon:!0,coverImages:!0}},scroll:{tokens:{...an,titleBackground:`#f8efe1`,titleColor:`#2a2119`,annotationBackground:`#22313f`,annotationColor:`#f8efe1`,annotationRadius:`18px`,annotationMaxWidth:`34em`,infoBlockBackground:`#fff8ee`,infoBlockColor:`#2a2119`},options:{...ln,showTableOfContents:!0,tableOfContentsPlacement:`header`,titleBlock:{fullHeight:!1}}}}};function fn(e){return JSON.parse(JSON.stringify(e))}function pn(e){return!!e&&typeof e==`object`&&!Array.isArray(e)}function mn(e,t){if(!t)return fn(e);let n=fn(e);for(let[e,r]of Object.entries(t)){if(r===void 0)continue;let t=n[e];if(pn(t)&&pn(r)){n[e]=mn(t,r);continue}n[e]=r}return n}function hn(e){return typeof e==`string`&&e in dn}function gn(e=`delft`){return fn(dn[e]||un)}function _n(e){let t=hn(e?.preset)?e.preset:`delft`,n=mn(gn(t),e||{});return n.version=1,n.preset=t,n}function vn(e){return`${e}#exhibition-viewer-theme`}function yn(e,t){return{id:vn(e),type:`Service`,profile:$t,label:en,theme:_n(t)}}function bn(e){if(!e?.length)return null;let t=e.findIndex(e=>e?.profile===`https://exhibitionviewer.org/iiif/theme-service`||e?.theme);return t===-1?null:{index:t,service:e[t]}}function xn(e){return bn(e)?.service?.theme}function Sn(e,t){let n=[...e||[]],r=bn(n);return r?t?(n[r.index]=t,n):(n.splice(r.index,1),n):(t&&n.push(t),n)}function Cn(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 wn={id:`@exhibitions/center-panel`,label:`Exhibition editor`,icon:null,render:()=>R(Tn,{}),options:{minWidth:350,maxWidth:350}};function Tn(){let e=P(),t=F(),[n,r]=U(.8),i=H(null),{edit:a,leftPanel:o}=x(),s=V(()=>e?_n(xn(e.service||e.services)):null,[e]),c=V(()=>({localeStringEditor:e=>z(`span`,{className:`inline-flex items-center hover:ring-4 hover:ring-me-primary-500`,children:[e.original,R(G,{className:`py-1 px-2 inline-block`,onPress:()=>a(e.resource),children:R(qe,{className:`text-xl`})})]}),canvasPreviewEditor:e=>z(`div`,{className:`w-full h-full flex-1 flex relative`,children:[e.original,R(`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 B(()=>{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]),He(()=>{if(i.current){let e=i.current.offsetWidth/1200;r(Math.max(1,e))}},[]),e?R(`div`,{ref:i,className:`overflow-y-auto delft-exhibition exhibition-viewer`,style:s?Cn(s):void 0,children:R(st,{hooks:c,children:R(ot,{skipLoadManifest:!0,customVault:t,manifest:e.id,options:{...s?.delft.exhibition||{},disablePresentation:!0,hideTableOfContents:!0,hideTitle:!0}},n)})}):null}function En(e,t){let n=new URLSearchParams;switch(On(n,`manifest`,t.manifest),On(n,`canvas`,t.canvas),e){case`delft`:case`exhibition`:{let e=t;J(n,`cut-corners`,e.cutCorners),J(n,`full-title-bar`,e.fullTitleBar),J(n,`hide-toc`,e.hideTableOfContents),J(n,`show-navigation-controls`,e.showNavigationControls),J(n,`show-progress-bar`,e.showProgressBar),On(n,`toc-placement`,e.tableOfContentsPlacement),J(n,`ignore-canvas-backgrounds`,e.ignoreCanvasBackgrounds);break}case`minimal`:{let e=t;n.set(`minimal`,`true`),J(n,`cut-corners`,e.cutCorners),J(n,`full-title-bar`,e.fullTitleBar),On(n,`toc-placement`,e.tableOfContentsPlacement),J(n,`ignore-canvas-backgrounds`,e.ignoreCanvasBackgrounds);break}case`presentation`:{let e=t;n.set(`type`,`presentation`),J(n,`cut-corners`,e.cutCorners),J(n,`floating`,e.floating??e.isFloating),On(n,`floating-position`,e.floatingPosition),J(n,`label-only-floating`,e.labelOnlyFloating),J(n,`ignore-canvas-backgrounds`,e.ignoreCanvasBackgrounds);break}case`scroll`:{let e=t;n.set(`type`,`scroll`),kn(n,`minimal`,e.minimal),On(n,`toc-placement`,e.tableOfContentsPlacement),J(n,`ignore-canvas-backgrounds`,e.ignoreCanvasBackgrounds),kn(n,`manifest-editor-preview`,e.manifestEditorPreview),On(n,`manifest-editor-preview-origin`,e.manifestEditorPreviewOrigin);break}case`slideshow`:{let e=t;n.set(`type`,`slideshow`),kn(n,`minimal`,e.minimal),J(n,`floating`,e.floating),On(n,`floating-position`,e.floatingPosition),J(n,`label-only-floating`,e.labelOnlyFloating),J(n,`ignore-canvas-backgrounds`,e.ignoreCanvasBackgrounds);break}}return n}function Dn(e,t,n){let r=En(e,t||{}),i=new URL(n||`https://preview.exhibitionviewer.org/preview/${e}`);return!n&&(window.location.hostname===`localhost`||window.location.hostname===`127.0.0.1`)&&window.location.port===`3000`&&(i.protocol=`http:`,i.host=`localhost:5174`),r.forEach((e,t)=>{i.searchParams.set(t,e)}),i.searchParams.set(`manifest-editor-preview`,`true`),i.searchParams.set(`manifest-editor-preview-origin`,window.location.origin),i}function On(e,t,n){n&&e.set(t,n)}function J(e,t,n){typeof n==`boolean`&&e.set(t,String(n))}function kn(e,t,n){n&&e.set(t,`true`)}function An(e){return e===`exhibition-slideshow-editor`?`slideshow`:e===`exhibition-scrolling-editor`?`scroll`:`fullpage`}function jn(e,t=[]){let n=t.find(e=>e.startsWith(`template-`))?.slice(9);return e.find(e=>e.id===n)||e.find(e=>t.includes(e.type))||null}function Mn(e,t,n){return t?e.filter(e=>e.type===t.type||e.id===n?.id):e}function Nn(){let e=d(),t=e.preset?.templates||[],n=P(),{selectedTemplate:r}=ee();return jn(t,n?.behavior)||r||t.find(t=>t.type===An(e.metadata.id))||null}const Y=Le(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})})),X=Le(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 Pn(e){let t=Number(e?.width)||1920,n=Number(e?.height)||1080,r=Gn(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 Fn(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 In(e){return Fn(e,Pn(e))}function Ln(e,t){return Bn(e,t?.items||[]).filter(e=>(Array.isArray(e?.motivation)?e.motivation:[e?.motivation]).includes(`painting`))}function Rn(e,t){return Bn(e,t?.annotations||[])}function zn(e,t){return!t||(Array.isArray(t?.behavior)?t.behavior:[]).includes(`info`)?!1:!Ln(e,t).some(t=>{let n=qn(e,t);return!!($n(n)||er(n))})}function Bn(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 Vn(e,t){return Ln(e,t).map(n=>{let r=qn(e,n);return{annotation:n,box:Hn(n,t),html:Zn(r),imageUrl:Xn(e,r),videoUrl:$n(r),youtubeId:er(r)}})}function Hn(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=Jn(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=Jn(s.split(`xywh=`)[1]);if(e)return e}return{x:0,y:0,width:n,height:r}}function Un(e,t,n,r){e.modifyEntityField({id:n,type:`Annotation`},`target`,Fn(t,Kn(t,r)))}function Wn(e,t,n){let r=Kn(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 Gn(e){let t=Number(e?.width)||1920,n=Number(e?.height)||1080,r=Array.isArray(e?.behavior)?e.behavior:[],i=Yn(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 Kn(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 qn(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 Jn(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 Yn(e){let t=e.find(e=>e.startsWith(`text-xywh=`))?.replace(`text-xywh=`,``);return Jn(t)}function Xn(e,t){let n=Qn(e,t);if(n?.type===`Choice`){let t=Array.isArray(n.items)?n.items:[];for(let n of t){let t=Xn(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 Ln(e,t)){let t=Xn(e,qn(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 Zn(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 Qn(e,t){return t?.type===`SpecificResource`?Qn(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 $n(e){let t=e?.type===`SpecificResource`?e.source:e;return t?.type===`Video`&&!er(t)?t.id:null}function er(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}function tr(e,t){return JSON.stringify([e.id,e.type,...(t||[]).map(e=>[e.id,e.type])])}function nr(e,t){let n=[];for(let r of t||[]){let t=e.get(r,{skipSelfReturn:!1});for(let r of Ln(e,t)){let t=Array.isArray(r.body)?r.body:r.body?[r.body]:[];for(let i of t){let t=i?.id&&e.get(i,{preserveSpecificResources:!0,skipSelfReturn:!1})||i,a=Array.isArray(t?.selector)?t.selector:t?.selector?[t.selector]:[];for(let e of a)(e?.type===`ImageApiSelector`||e?.type===`iiif:ImageApiSelector`)&&n.push([r.id,e.region??null,e.rotation??null])}}}return JSON.stringify(n)}const rr=1024,ir=.5;function ar({preset:e,presetOptions:t,focusSelectedCanvas:n=!0}){let r=or({preset:e,presetOptions:t,focusSelectedCanvas:n}),i=F(),a=f(),o=P(),s=Nn(),l=Ce(`Canvas`),u=H(null),d=H(null),p=H(null),m=H(a),h=H(null),g=H(null),[_,v]=U(`waiting`),[y,b]=U(0),[x,S]=U(!1),[C,w]=U(!1),T=Y(e=>e.selectedTourStepId),ee=n&&(l?.resource.source.id||o?.items?.[0]?.id)||null,E=tr(a,o?.items),D=I((e,t)=>nr(t,o?.items),[E]),O=H(E),te=V(()=>Dn(e,t,s?.previewUrl).toString(),[e,t,s?.previewUrl]),k=V(()=>new URL(te).origin,[te]),A=C?440:y?Math.round(y/(x?ir:1)):0,ne=A>0&&A<=rr;m.current=a,h.current=ee,g.current=T;let j=Be(()=>{let e=u.current;if(!e?.contentWindow)return;p.current?.(),v(`waiting`);let t=new MessageChannel;p.current=c(i,t.port1);try{e.contentWindow.postMessage({_type:`manifest-editor:iframe-preview:connect`,resource:m.current,canvasId:h.current,annotationId:g.current||void 0},k,[t.port2]),v(`connected`)}catch{p.current?.(),p.current=null,v(`error`)}},[k,i]);B(()=>{function e(e){e.origin===k&&e.source===u.current?.contentWindow&&e.data?._type===`manifest-editor:iframe-preview:ready`&&j()}return window.addEventListener(`message`,e),()=>{window.removeEventListener(`message`,e),p.current?.(),p.current=null}},[j,k]),B(()=>{let e=u.current?.contentWindow;!e||_!==`connected`||e.postMessage({_type:`manifest-editor:iframe-preview:selection`,resource:a,canvasId:ee,annotationId:T||void 0},k)},[_,a,ee,T,k]),B(()=>{let e=O.current!==E;O.current=E,e&&_===`connected`&&j()},[j,_,E]),B(()=>{let e=d.current;if(!e)return;let t=()=>{b(e.getBoundingClientRect().width)};t();let n=new ResizeObserver(t);return n.observe(e),()=>n.disconnect()},[]),B(()=>{if(y){if(y>rr){S(!1);return}w(!1)}},[y]);let re=Be(e=>{S(e),e&&w(!1)},[]),ie=Be(e=>{w(e),e&&S(!1)},[]);return z(`div`,{className:`flex h-full min-h-0 flex-col bg-zinc-950`,children:[_===`connected`?null:R(`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 exhibition viewer...`}),R(sr,{iframeViewportWidth:A,isMobileViewport:ne,showScaleOption:y>0&&y<=rr,showMobileWidthOption:y>rr,useScaledPreview:x,useMobileWidthPreview:C,onUseScaledPreviewChange:re,onUseMobileWidthPreviewChange:ie,previewWindow:r}),R(`div`,{ref:d,className:K(`flex min-h-0 flex-1 overflow-hidden bg-white`,x?`justify-start`:`justify-center`),children:R(`iframe`,{ref:u,src:te,title:`Exhibition preview`,className:K(`block h-full shrink-0 border-0 bg-white`,C?`shadow-2xl shadow-black/40`:``),style:{width:C?440:x?`${100/ir}%`:`100%`,maxWidth:C?`100%`:void 0,height:x?`${100/ir}%`:`100%`,transform:x?`scale(${ir})`:void 0,transformOrigin:`top left`},onLoad:()=>v(`waiting`)},D)})]})}function or({preset:e,presetOptions:t,focusSelectedCanvas:n=!0}){let{open:r,update:i,focus:a,isClosed:o}=D(),s=f(),c=P(),l=Nn(),u=Ce(`Canvas`),d=Y(e=>e.selectedTourStepId),p=n&&(u?.resource.source.id||c?.items?.[0]?.id)||null,m=tr(s,c?.items),h=I((e,t)=>nr(t,c?.items),[m]),g=V(()=>Dn(e,t,l?.previewUrl).toString(),[e,t,l?.previewUrl]),_=V(()=>({url:g,resource:s,canvasId:p,annotationId:d,name:`manifest-editor-exhibition-preview`,reloadKey:`${m}:${h}`}),[p,h,s,d,m,g]);return B(()=>i(_),[_,i]),V(()=>({open:()=>r(_),focus:a,isClosed:o}),[a,o,r,_])}function sr({iframeViewportWidth:e,isMobileViewport:t,showScaleOption:n,showMobileWidthOption:r,useScaledPreview:i,useMobileWidthPreview:a,onUseScaledPreviewChange:o,onUseMobileWidthPreviewChange:s,previewWindow:c}){return e?z(`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:[z(`div`,{className:`flex min-w-0 items-center gap-2`,children:[R(`span`,{className:K(`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`}),z(`span`,{className:`truncate text-zinc-400`,children:[`Iframe viewport: `,e,`px. Mobile starts at `,rr,`px and below.`]})]}),z(`div`,{className:`flex items-center gap-2`,children:[n?R(cr,{label:`50% scale`,checked:i,onChange:o}):null,r?R(cr,{label:`Mobile width`,checked:a,onChange:s}):null,R(`button`,{type:`button`,className:`shrink-0 rounded-md border border-zinc-700 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-600 hover:bg-zinc-950`,onClick:c.isClosed?c.open:c.focus,children:c.isClosed?`Open in new window`:`Focus preview window`})]})]}):null}function cr({label:e,checked:t,onChange:n}){return z(`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:[R(`span`,{children:e}),R(`input`,{type:`checkbox`,className:`peer sr-only`,checked:t,onChange:e=>n(e.currentTarget.checked)}),R(`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`})]})}function lr(){switch(Nn()?.type){case`slideshow`:return`slideshow`;case`scroll`:return`scroll`;default:return`exhibition`}}function ur(e){return z(`svg`,{xmlns:`http://www.w3.org/2000/svg`,width:`1em`,height:`1em`,viewBox:`0 0 24 24`,...e,children:[R(`title`,{children:`Preview`}),R(`path`,{fill:`currentColor`,d:`M12 4.5C7 4.5 2.73 7.61 1 12c1.73 4.39 6 7.5 11 7.5s9.27-3.11 11-7.5c-1.73-4.39-6-7.5-11-7.5M12 17c-2.76 0-5-2.24-5-5s2.24-5 5-5s5 2.24 5 5s-2.24 5-5 5m0-8c-1.66 0-3 1.34-3 3s1.34 3 3 3s3-1.34 3-3s-1.34-3-3-3`})]})}const dr={id:`@exhibitions/remote-preview-panel`,label:`Exhibition preview`,icon:R(ur,{}),render:()=>R(fr,{}),options:{minWidth:350}};function fr(){let e=lr(),t=P(),n=_n(xn(t?.service)||xn(t?.services)),r;return r=e===`scroll`?{ignoreCanvasBackgrounds:n.scroll.options.ignoreCanvasBackgrounds,tableOfContentsPlacement:n.scroll.options.tableOfContentsPlacement}:e===`slideshow`?{ignoreCanvasBackgrounds:n.delft.slideshow.ignoreCanvasBackgrounds}:{cutCorners:n.delft.exhibition.cutCorners,fullTitleBar:n.delft.exhibition.fullTitleBar,hideTableOfContents:n.delft.exhibition.hideTableOfContents,ignoreCanvasBackgrounds:n.delft.exhibition.ignoreCanvasBackgrounds,showNavigationControls:n.delft.exhibition.showNavigationControls,showProgressBar:n.delft.exhibition.showProgressBar,tableOfContentsPlacement:n.delft.exhibition.tableOfContentsPlacement},R(ar,{preset:e,presetOptions:r,focusSelectedCanvas:!1})}function pr({children:e}){let t=P(),{edit:n}=x();return z(`div`,{className:`grid auto-rows-auto grid-cols-12 content-center justify-center gap-2 p-2`,children:[R(`div`,{className:`col-span-12 row-span-2 text-black flex flex-col items-center justify-center`,children:R(G,{onPress:()=>t&&n(t,void 0,{forceOpen:!0,selectedTab:`@manifest-editor/descriptive-properties`}),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:R(M,{className:`block w-full text-left`,children:t?.label})})}),e]})}const mr={"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`},hr={"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`},gr={"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 _r(e){let{isLeft:t,isRight:n,isBottom:r}=yr(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 vr(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?hr[r]:mr[r]),a.push(gr[i]),a.join(` `)}function yr(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 br(e,t){return t.get(e)?.type===`Canvas`}function xr(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 Sr(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 Cr(e){if(!e)return!1;let t=e.behavior||[];if(t.includes(`image`)||t.includes(`info`)||t.includes(`splash`))return!0;for(let e of t)if(e.startsWith(`w-`)||e.startsWith(`h-`))return!0;return!1}function wr(){let e=N();gt(e);let t=e.width&&e.height?e.width/e.height:0,n=_r(e.behavior||[]);return Math.abs(t-n.ratio)<.01?null:z(`div`,{className:`exhibition-aspect-warning p-2 rounded bg-me-100`,children:[R(`div`,{className:`font-semibold text-me-700`,children:`Aspect ratio warning`}),z(`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.`,R(`div`,{className:`relative h-32 w-full mt-2`,children:R(`div`,{className:`bg-[red] left-0 top-0 z-2 opacity-50 max-w-32 max-h-32`,style:{aspectRatio:t.toFixed(2)},children:R(`div`,{className:`asbolute bg-[white] left-0 top-0 z-1 opacity-50 max-w-32 max-h-32`,style:{aspectRatio:n.ratio}})})})]})]})}const Tr=[{value:`float-top-left`,label:`Top left`},{value:`float-top`,label:`Top centre`},{value:`float-top-right`,label:`Top right`},{value:`float-left`,label:`Centre left`},{value:`float-right`,label:`Centre right`},{value:`float-bottom-left`,label:`Bottom left`},{value:`float-bottom`,label:`Bottom centre`},{value:`float-bottom-right`,label:`Bottom right`}],Er={"float-top-left":{x:2,y:2},"float-top":{x:8.5,y:2},"float-top-right":{x:15,y:2},"float-left":{x:2,y:8.5},"float-right":{x:15,y:8.5},"float-bottom-left":{x:2,y:15},"float-bottom":{x:8.5,y:15},"float-bottom-right":{x:15,y:15}};function Dr({position:e}){return z(`svg`,{width:`1.6em`,height:`1.6em`,viewBox:`0 0 24 24`,fill:`none`,"aria-hidden":`true`,children:[R(`rect`,{x:`2`,y:`2`,width:`20`,height:`20`,rx:`3`,stroke:`currentColor`,strokeWidth:`1.5`,opacity:`0.4`}),e?R(`rect`,{...Er[e],width:`7`,height:`7`,rx:`1.5`,fill:`currentColor`}):R(`circle`,{cx:`12`,cy:`12`,r:`3`,stroke:`currentColor`,strokeWidth:`1.5`,opacity:`0.7`})]})}function Or({value:e,onChange:t}){let n=kr();return R(`div`,{className:`grid w-fit grid-cols-3 gap-2`,children:n.map(n=>{let r=e===n.value;return z(`button`,{type:`button`,title:n.label,"aria-pressed":r,className:`flex min-h-11 items-center justify-center rounded-md border px-3 py-2 transition-colors`,style:{backgroundColor:r?`var(--exhibition-primary, #b84c74)`:`#fff`,borderColor:r?`var(--exhibition-primary, #b84c74)`:`#dcd5ce`,color:r?`#fff`:`#332f2c`},onClick:()=>t(n.value),children:[R(Dr,{position:n.value}),R(`span`,{className:`sr-only`,children:n.label})]},n.value||`off`)})})}function kr(e=`No overlay`){return[...Tr.slice(0,4),{value:``,label:e},...Tr.slice(4)]}function Ar(){let e=N(),t=g(),n=b(),[r,i]=h(t?.resource.source,`thumbnail`,`ContentResource`),{descriptive:a}=v(),{thumbnail:o}=a,s=o.get()||[],c=F(),l=V(()=>e?Nr(c,e):[],[e,c]);return!e||!t?null:!s.length&&l.length?R(jr,{candidates:l,canCreateThumbnail:r,onCreateThumbnail:()=>i.create(),onAddThumbnail:({service:t,width:r,height:i})=>n.create(`@manifest-editor/thumbnail-image`,{service:t,width:r,height:i},Mr(e))}):R(se,{containerId:o.containerId(),label:`Thumbnail`,property:`thumbnail`,items:s,singleMode:!0,reorder:e=>o.reorder(e.startIndex,e.endIndex),createActions:me(o),creationType:`ContentResource`,emptyLabel:`No thumbnail`,parent:t.resource})}function jr({candidates:e,canCreateThumbnail:t,onCreateThumbnail:n,onAddThumbnail:r}){let[i,a]=U(null),[o,s]=U(``),[c,l]=U({}),u=e.find(e=>e.id===i)||e[0],d=u?c[u.id]:void 0,f=u?d===null?null:d||u.service:null,p=f?zr(f):[],m=Vr(p,350),h=p.find(e=>Br(e)===o)||m,g=f&&h?Hr(f,h):null,_=u&&!u.service.sizes?.length&&!(u.id in c);return B(()=>{!i&&e[0]&&a(e[0].id)},[e,i]),B(()=>{let t=e.filter(e=>{let t=e.service;return!t.sizes?.length&&Lr(t)&&!(e.id in c)});for(let e of t){let t=Lr(e.service);t&&fetch(Rr(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]),B(()=>{m&&!p.some(e=>Br(e)===o)&&s(Br(m))},[m,o,p]),R(j,{$wide:!0,children:z(`div`,{className:`rounded-md border border-[#dcd5ce] bg-[#f8f6f3] p-4`,children:[R(`div`,{className:`text-sm font-semibold text-[#25211f]`,children:`Thumbnail`}),R(`div`,{className:`mt-1 text-sm text-[#6a625c]`,children:`Use an image service from this canvas to add a thumbnail.`}),e.length>1?z(`div`,{className:`mt-3`,children:[R(`label`,{className:`text-xs font-semibold uppercase text-[#6a625c]`,htmlFor:`thumbnail-source-image`,children:`Image`}),R(`select`,{id:`thumbnail-source-image`,className:`mt-1 w-full rounded-md border border-[#dcd5ce] bg-white px-3 py-2 text-sm`,value:u?.id||``,onChange:e=>{a(e.currentTarget.value),s(``)},children:e.map(e=>R(`option`,{value:e.id,children:e.label},e.id))})]}):null,p.length?z(L,{children:[R(`div`,{className:`mt-3 flex flex-wrap gap-2`,children:p.map(e=>{let t=Br(e),n=h?t===Br(h):!1;return z(`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)})}),g?R(`div`,{className:`mt-3 overflow-hidden rounded-md border border-[#dcd5ce] bg-white`,children:R(`img`,{src:g,alt:``,className:`max-h-40 w-full object-contain`})}):null,R(`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:!g||!h,onClick:()=>{!f||!h||r({service:f,width:h.width,height:h.height})},children:`Add thumbnail from image`})]}):_?R(`div`,{className:`mt-3 text-sm text-[#6a625c]`,children:`Finding available sizes...`}):R(`div`,{className:`mt-3 text-sm text-[#6a625c]`,children:`No fixed thumbnail sizes were found for this image service.`}),t?R(`div`,{className:`mt-4 border-t border-[#dcd5ce] pt-3`,children:z(W,{onPress:n,children:[R(Ue,{}),` Create thumbnail`]})}):null]})})}function Mr(e){return{parent:{property:`thumbnail`,resource:{id:e.id,type:`Canvas`}}}}function Nr(e,t){let n=[],r=new Set;return Ln(e,t).forEach((t,i)=>{Pr(e,qn(e,t)).forEach((e,a)=>{let o=Ir(e),s=o?Lr(o):``;!o||!s||r.has(s)||(r.add(s),n.push({id:`${t.id||i}-${e.id||s}-${a}`,label:Ur(e.label)||Ur(t.label)||`Image ${n.length+1}`,imageId:e.id,service:o}))})}),n}function Pr(e,t){let n=Fr(e,t);return n?n.type===`Choice`&&Array.isArray(n.items)?n.items.flatMap(t=>Pr(e,t)):n.type===`SpecificResource`?Pr(e,n.source):n.type===`Canvas`?Ln(e,n).flatMap(t=>Pr(e,qn(e,t))):Ir(n)?[n]:[]:[]}function Fr(e,t){return t?t.id&&!t.service&&!t.items&&!t.value&&e.get(t,{skipSelfReturn:!1})||t:null}function Ir(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 Lr(e){return(e.id||e[`@id`]||``).replace(/\/info\.json$/,``)}function Rr(e){return e.endsWith(`/info.json`)?e:`${e.replace(/\/$/,``)}/info.json`}function zr(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 Br(e){return`${e.width},${e.height||``}`}function Vr(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 Hr(e,t){let n={...e};n[`@id`]&&(n.id=n[`@id`]),n[`@type`]&&(n.type=n[`@type`]);let r=vt(n);return yt({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 Ur(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 Wr=new Set([`left`,`right`,`bottom`,`top`]),Gr=new Set([...Wr,`image`]),Kr=new Set([`cover`,`image-cover`]);function qr(e,t,n){let r=e.findIndex(e=>t.has(e)),i=e.filter(e=>!t.has(e));return i.splice(r<0?i.length:r,0,n),i}function Jr(e,t,n,r){let i=e.findIndex(e=>t.has(e)),a=e.filter(e=>!t.has(e));return r&&a.splice(i<0?a.length:i,0,n),a}function Yr(e,t){return qr(e,t===`image`?Gr:Wr,t)}const Xr=new Set([`scroll`,`page-scroll`]),Zr=new Set([`splash`,`fixed`,`invert`,`backdrop-light`,`backdrop-dark`,`compact-deck`]),Qr=[{value:`image`,label:`Image only`},{value:`top`,label:`Text above image`},{value:`bottom`,label:`Text below image`},{value:`left`,label:`Text left of image`},{value:`right`,label:`Text right of image`}],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)`},$r=[{value:12,label:`Full width`},{value:8,label:`2/3 width`},{value:6,label:`Half width`},{value:4,label:`1/3 width`}],ei=new Set(Tr.map(e=>e.value));function ti(e){return e.some(e=>Xr.has(e))}function ni(e){return e.some(e=>Kr.has(e))}function ri(e,t){return e===`slideshow`||e===`scroll`||e===`fullpage`?e:t===`exhibition-slideshow-editor`?`slideshow`:t===`exhibition-scrolling-editor`?`scroll`:`fullpage`}function ii(e,t=!1,n=!0,r=!1,i=!0){let a=e===`scroll`||t;return{showGridSizing:e===`fullpage`&&!t&&!r,isSlideshow:e===`slideshow`,showFloating:!r&&(e===`slideshow`||e===`scroll`||t),showImageCover:i&&!r&&(e===`fullpage`&&!t||a&&n),showScrollToggle:!r&&e===`fullpage`,showScrollDisplay:e===`slideshow`||e===`scroll`,showFixedCover:e===`scroll`,showCoverBackdrop:!1,scrollContext:a,layoutOptions:r?[]:a?n?[{value:`left`,label:`Annotations on left`},{value:`right`,label:`Annotations on right`}]:[]:Qr}}function ai(e=[],t=!0){let n=d();return ii(ri(Nn()?.type,n.metadata.id),ti(e),t,e.includes(`splash`))}const oi={component:()=>R(mi,{}),supports:{edit:!0,resourceTypes:[`Canvas`],properties:[`behavior`],custom:({resource:e},t)=>br(e,t)?!xr(e,t):!1},id:`slide-behaviors`,label:`Layout`,tabs:{showTitle:!0}},si={id:`floating`,type:`choice`,label:{en:[`Floating`]},initialOpen:!1,addNone:!0,groupBehavior:`floating`,items:Tr.map(e=>({label:{en:[`Float ${e.label.toLowerCase()}`]},value:e.value}))},ci={id:`size`,component:(e,t)=>R(pi,{behaviors:e,setBehaviors:t}),label:{en:[`Size`]},type:`custom`,initialOpen:!0,supports:e=>e.startsWith(`w-`)||e.startsWith(`h-`)};function li({behaviors:e,setBehaviors:t,flags:n}){let r=(n,r)=>{let i=Jr(e,new Set([n.value,...n.aliases||[],...n.group||[]]),n.value,r);t(n.clean?n.clean(i,r):i)};return R(`div`,{className:`flex flex-col gap-2`,children:n.map(t=>R(Si,{checked:e.includes(t.value)||!!t.aliases?.some(t=>e.includes(t)),label:t.label,onChange:e=>r(t,e)},t.value))})}function ui({behaviors:e,setBehaviors:t,options:n}){let r=Ei(e);return R(`div`,{className:`grid grid-cols-2 gap-2`,children:n.map(n=>R(xi,{selected:r===n.value&&(n.value===`image`||e.includes(n.value)),onClick:()=>t(Yr(e,n.value)),children:n.label},n.value))})}function di(e,t=[],n=!0,r=!0,i=!0){let a=ii(e,ti(t),r,t.includes(`splash`)&&n,i),o=a.showScrollDisplay&&n,s=[];return a.layoutOptions.length&&!(a.isSlideshow&&ki(t))&&s.push({id:`layout`,type:`custom`,label:{en:[`Layout`]},initialOpen:!0,supports:e=>Gr.has(e),component:(e,t)=>R(ui,{behaviors:e,setBehaviors:t,options:a.layoutOptions})}),a.showScrollToggle&&s.push({id:`scroll`,type:`custom`,label:{en:[`Scrolling section`]},initialOpen:!1,supports:e=>Xr.has(e),component:(e,t)=>R(li,{behaviors:e,setBehaviors:t,flags:[{value:`scroll`,label:`Show as a scrolling section`,aliases:[`page-scroll`],clean:(e,t)=>t?e.filter(e=>!Ni(e)):e}]})}),a.showImageCover&&s.push({id:`display`,type:`custom`,label:{en:[`Display`]},initialOpen:!1,supports:e=>Kr.has(e),component:(e,t)=>R(li,{behaviors:e,setBehaviors:t,flags:[{value:`cover`,label:`Crop image to fill its frame`,aliases:[`image-cover`]}]})}),o&&s.push({id:`cover`,type:`custom`,label:{en:[`Cover`]},initialOpen:!1,supports:e=>Zr.has(e),component:(e,t)=>R(li,{behaviors:e,setBehaviors:t,flags:[{value:`splash`,label:`Use as opening cover`},...a.showFixedCover?[{value:`fixed`,label:`Keep image fixed while scrolling`}]:[],{value:`invert`,label:`Use light text`}]})}),a.showFloating&&s.push(si),a.showGridSizing&&s.push(ci),s}function fi(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 pi({behaviors:e,setBehaviors:t}){let{width:n,height:r}=fi(e),[i,a]=U({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)},s=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`),R(`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)});return R(`div`,{className:`grid grid-cols-12 grid-rows-12 gap-1`,onMouseLeave:()=>a({x:-1,y:-1}),children:s})}function mi(){let[e,t]=C(`exhibition-layout-panel-mode`,`simple`),n=X(e=>e.setCenterPanelMode);return B(()=>{n(`preview`)},[n]),R(tt,{children:z(nt,{className:`bg-white px-6 pt-5 pb-20`,children:[R(`div`,{className:`mb-6 flex justify-center`,children:R(Ci,{value:e,onChange:t})}),R(hi,{mode:e})]})})}function hi({mode:e=`advanced`,layoutContext:t=`default`}){let n=Ce(`Canvas`),r=N(),i=v(),a=d(),o=F(),s=P(),c=ri(Nn()?.type,t===`slideshow`?`exhibition-slideshow-editor`:a.metadata.id),{width:l,height:u}=i.technical,f=i.technical.behavior.get()||[],p=I((e,t)=>r?Rn(t,r).length>0:!1,[r?.id,r?.annotations?.[0]?.id]),m=!!(r&&Fi(o,r)),h=!!(r&&Pi(s)===r.id&&m),g=ii(c,ti(f),p,f.includes(`splash`)&&h,m);return!n||i.technical.type!==`Canvas`?R(`div`,{className:`p-4`,children:`Please select canvas`}):e===`simple`?R(gi,{behavior:i.technical.behavior.get()||[],controls:g,canvasWidth:l.get()||0,canvasHeight:u.get()||0,onChange:e=>{i.technical.behavior.set(e)}}):z(L,{children:[R(`div`,{className:`px-2`,children:z(j,{$wide:!0,children:[R(A,{widthId:l.containerId(),width:l.get()||0,changeWidth:e=>l.set(e),heightId:u.containerId(),height:u.get()||0,changeHeight:e=>u.set(e)}),R(`div`,{children:R(wr,{})})]})}),R(te,{behavior:i.technical.behavior.get()||[],onChange:e=>{i.technical.behavior.set(e)},configs:di(c,f,h,p,m)}),R(Ar,{})]})}function gi({behavior:e,controls:t,canvasWidth:n,canvasHeight:r,onChange:i}){let a=Ei(e),o=t.showGridSizing?Oi(e):12,s=ki(e),c=Ai(e),l=ni(e),u=ti(e),d=e.includes(`splash`),f=e.includes(`fixed`),p=e.includes(`invert`),m=e.includes(`backdrop-dark`)?`backdrop-dark`:e.includes(`backdrop-light`)?`backdrop-light`:``,h=X(e=>e.requestTab),g=N(),_=F(),v=P(),y=t.showGridSizing?o:12,b=Ii({canvasWidth:n,canvasHeight:r,layoutPreset:a,displayWidth:y}),x=t.showGridSizing&&v?.items&&g?zi(g.id,v.items,_):null,S=!!(g&&Pi(v)===g.id&&Fi(_,g)),C=h=>{let v=t.layoutOptions.length?h.layoutPreset??a:void 0,y=t.showGridSizing?h.displayWidth??o:12,b=h.floating??s,x=h.floatingBehavior??c,C=h.cover??l,w=h.scrollEnabled??u,T=h.splash??d,ee=h.fixed??f,E=h.invert??p,D=h.backdrop??m;i(Mi({behavior:e,layoutPreset:v,displayWidth:y,canvasWidth:n,canvasHeight:r,floating:b,floatingBehavior:x,cover:C,scrollEnabled:w,splash:T,fixed:t.showFixedCover&&ee,invert:E,backdrop:t.showCoverBackdrop?D:``,showGridSizing:t.showGridSizing&&!w,showFloating:t.showFloating,showImageCover:t.showImageCover,showScrollToggle:t.showScrollToggle,showScrollDisplay:t.showScrollDisplay&&S})),g&&v&&Vi(_,g,v)};return z(`div`,{className:`flex flex-col gap-7`,children:[R(_i,{layoutPreset:a,cover:l,floating:s,width:y,height:b,showGridSizing:t.showGridSizing,onTextClick:()=>h(`summary`)}),t.layoutOptions.length&&!(t.isSlideshow&&s)?z(wi,{children:[R(Ti,{children:`Text placement`}),R(`div`,{className:`mt-3 grid grid-cols-2 gap-3`,children:t.layoutOptions.map(e=>R(vi,{preset:e.value,label:e.label,selected:a===e.value,onClick:()=>C({layoutPreset:e.value})},e.value))})]}):null,t.showGridSizing?z(wi,{children:[R(Ti,{children:`Width`}),R(`div`,{className:`mt-3 grid grid-cols-2 gap-3`,children:$r.map(e=>R(xi,{selected:o===e.value,onClick:()=>C({displayWidth:e.value}),children:e.label},e.value))})]}):null,x?z(wi,{children:[z(Ti,{children:[`Fit alongside `,x.neighbour,` slide`]}),R(`div`,{className:`mt-3`,children:z(xi,{selected:o===x.width,onClick:()=>C({displayWidth:x.width}),children:[`w-`,x.width,` — fills remaining space`]})})]}):null,z(`div`,{className:`flex flex-col gap-3`,children:[t.showScrollToggle?R(Si,{checked:u,label:`Show as a scrolling section`,onChange:e=>C({scrollEnabled:e})}):null,t.showFloating?R(Si,{checked:s,label:`Overlay text on the image`,onChange:e=>C({floating:e})}):null,t.isSlideshow&&s?z(wi,{children:[R(Ti,{children:`Text overlay position`}),R(`div`,{className:`mt-3`,children:R(Or,{value:c,onChange:e=>{C(e?{floatingBehavior:e}:{floating:!1})}})})]}):null,t.showImageCover?R(Si,{checked:l,label:`Crop image to fill its frame`,onChange:e=>C({cover:e})}):null,t.showScrollDisplay&&S?z(wi,{children:[R(Ti,{children:`Cover`}),z(`div`,{className:`mt-3 flex flex-col gap-3`,children:[R(Si,{checked:d,label:`Use as opening cover`,onChange:e=>C({splash:e})}),t.showFixedCover?R(Si,{checked:f,label:`Keep image fixed while scrolling`,onChange:e=>C({fixed:e})}):null,R(Si,{checked:p,label:`Use light text`,onChange:e=>C({invert:e})}),t.showCoverBackdrop?z(wi,{children:[R(Ti,{children:`Backdrop`}),R(`div`,{className:`mt-3 grid grid-cols-3 gap-2`,children:[{value:``,label:`Default`},{value:`backdrop-light`,label:`Light`},{value:`backdrop-dark`,label:`Dark`}].map(e=>R(xi,{selected:m===e.value,onClick:()=>C({backdrop:e.value}),children:e.label},e.value||`default`))})]}):null]})]}):null]})]})}function _i({layoutPreset:e,cover:t,floating:n,width:r,height:i,showGridSizing:a,onTextClick:o}){let s=e===`bottom`,c=e===`image`,l=e===`left`;return z(`div`,{children:[z(`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:[z(`div`,{className:K(`flex h-full w-full min-h-0`,l?`flex-row-reverse`:s?`flex-col`:`flex-row`),children:[R(`div`,{className:`relative min-h-0 flex-1 overflow-hidden bg-white`,children:R(`div`,{className:`absolute inset-0`,children:R(Ze,{cover:t,fade:!1})})}),c?null:R(`button`,{type:`button`,"aria-label":`Edit slide text`,className:K(`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`,s?`h-1/3 w-full`:`h-full w-1/3`),onClick:o,children:R(bi,{tone:`light`})})]}),n?R(`div`,{className:`absolute right-2 top-2 h-7 w-10 rounded bg-white/90 shadow ring-1 ring-black/10`}):null]}),a?z(`div`,{className:`mt-2 text-center text-xs`,style:{color:Z.muted},children:[`w-`,r,` h-`,i]}):null]})}function vi({preset:e,label:t,selected:n,onClick:r}){return z(`button`,{type:`button`,"aria-pressed":n,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:[R(yi,{preset:e,selected:n}),R(`span`,{className:`leading-tight`,children:t})]})}function yi({preset:e,selected:t}){let n=e===`image`,r=e===`bottom`,i=e===`top`,a=e===`left`,o=t?`bg-white/80`:`bg-[#25211f]`,s=t?`bg-white/25 ring-white/70`:`bg-[#f8f6f3] ring-[#dcd5ce]`;return z(`span`,{className:K(`flex h-12 w-16 gap-1 overflow-hidden rounded border p-1`,t?`border-white/70 bg-white/15`:`border-[#dcd5ce] bg-white`,a?`flex-row-reverse`:r?`flex-col`:i?`flex-col-reverse`:`flex-row`),"aria-hidden":`true`,children:[R(`span`,{className:K(`flex-1 rounded-sm ring-1`,s)}),n?null:R(`span`,{className:K(`flex flex-shrink-0 flex-col justify-center gap-0.5 rounded-sm px-0.5`,o,r||i?`h-3 w-full`:`h-full w-4`),children:R(bi,{compact:!0,tone:t?`dark`:`light`})})]})}function bi({compact:e=!1,tone:t=`light`}){let n=t===`light`?`bg-white/70`:`bg-[#8b3f61]/70`;return z(`span`,{className:K(`block space-y-1.5`,e?`space-y-0.5`:`mt-1`),"aria-hidden":`true`,children:[R(`span`,{className:K(`block rounded`,n,e?`h-0.5 w-full`:`h-1.5 w-3/4`)}),R(`span`,{className:K(`block rounded`,n,e?`h-0.5 w-4/5`:`h-1.5 w-full`)}),R(`span`,{className:K(`block rounded`,n,e?`h-0.5 w-2/3`:`h-1.5 w-2/3`)})]})}function xi({selected:e,onClick:t,children:n,title:r}){return R(`button`,{type:`button`,title:r,"aria-pressed":e,className:`flex min-h-11 items-center justify-center gap-1.5 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,boxShadow:e?`0 0 0 2px ${Z.primary}33`:void 0},onClick:t,children:n})}function Si({checked:e,label:t,onChange:n}){return z(`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,R(`input`,{type:`checkbox`,className:`h-4 w-4 accent-me-primary-500`,checked:e,onChange:e=>n(e.currentTarget.checked)})]})}function Ci({value:e,onChange:t}){return R(`div`,{role:`group`,"aria-label":`Editing mode`,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 R(G,{"aria-pressed":r,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 wi({children:e}){return R(`div`,{children:e})}function Ti({children:e}){return R(`div`,{className:`text-sm font-semibold`,style:{color:Z.muted},children:e})}function Ei(e){return e.includes(`left`)?`left`:e.includes(`top`)?`top`:e.includes(`bottom`)?`bottom`:e.includes(`right`)?`right`:(e.includes(`image`),`image`)}function Di(e,t,n){let r=Yr(e,t);if(n?.width&&n?.height){let{width:i}=fi(e),a=i?i<=4?4:i<=6?6:i<=8?8:12:12,o=Ii({canvasWidth:n.width,canvasHeight:n.height,layoutPreset:t,displayWidth:a}),s=r.filter(e=>!e.startsWith(`h-`));return s.push(`h-${o}`),s}return r}function Oi(e){let{width:t}=fi(e);return t?t<=4?4:t<=6?6:t<=8?8:12:12}function ki(e){return e.includes(`floating`)||e.some(e=>ei.has(e))}function Ai(e){return e.find(e=>ei.has(e))||`float-top-right`}function ji(e,t){let n=e.filter(e=>e!==`floating`&&!ei.has(e));return t?[...n,t]:n}function Mi({behavior:e,layoutPreset:t,displayWidth:n,canvasWidth:r,canvasHeight:i,floating:a,floatingBehavior:o,cover:s,scrollEnabled:c,splash:l,fixed:u,invert:d,backdrop:f,showGridSizing:p,showFloating:m,showImageCover:h,showScrollToggle:g,showScrollDisplay:_}){let v=e.filter(e=>!((p||c)&&Ni(e)||m&&(e===`floating`||ei.has(e))||h&&Kr.has(e)||g&&Xr.has(e)||_&&Zr.has(e)));if(t&&(v=Yr(v,t)),g&&c&&v.push(`scroll`),p){let e=Ii({canvasWidth:r,canvasHeight:i,layoutPreset:t||`image`,displayWidth:n});v.push(`w-${n}`,`h-${e}`)}return m&&a&&v.push(o||`float-top-right`),h&&s&&v.push(`cover`),_&&(l&&v.push(`splash`),u&&v.push(`fixed`),d&&v.push(`invert`),f&&v.push(f)),v}function Ni(e){return e.startsWith(`w-`)||e.startsWith(`h-`)||e.startsWith(`start-`)}function Pi(e){return e?.items?.[0]?.id}function Fi(e,t){return!t||t.behavior?.includes(`info`)?!1:Ln(e,t).some(t=>{let n=qn(e,t),r=n?.type===`SpecificResource`?n.source:n,i=Array.isArray(r?.service)?r.service:r?.service?[r.service]:[];return r?.type===`Image`||i.length>0})}function Ii({canvasWidth:e,canvasHeight:t,layoutPreset:n,displayWidth:r}){let i=e&&t?e/t:1.5,a=n===`left`||n===`right`?2/3*r:r,o=n===`bottom`?3/2:1,s=Math.round(a/i*o);return Math.max(1,Math.min(12,s))}const Li=[{value:4,label:`1/3 width`},{value:6,label:`Half width`},{value:8,label:`2/3 width`},{value:12,label:`Full width`}];function Ri(e){let{width:t}=fi(e);return t}function zi(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 Ri(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 Bi=new Set([`left`,`right`,`bottom`,`top`]);function Vi(e,t,n){Bi.has(n)&&(he(t.label)||e.modifyEntityField(t,`label`,{en:[`Untitled`]}),he(t.summary)||e.modifyEntityField(t,`summary`,{en:[`Add a description for this slide.`]}))}const Hi=`non-linear-tour`,Ui=`tour-marker-pin`,Wi=`editorial-text`;function Gi({className:e,editable:t=!1,mode:n=`edit`,showTourSteps:r=!1}){let i=N(),a=F(),o=Ce(`Annotation`),s=H(null),[c,l]=U(null),u=X(e=>e.requestTab),{selectedAnnotationId:d,repositioningAnnotationId:f,selectedTextRegion:p,repositioningTextRegion:m,selectedTourStepId:h,selectAnnotation:g,startRepositioning:_,selectTextRegion:v,selectTourStep:y}=Y(),b=I((e,t)=>i?Vn(t,i):[],[i?.id,i?.items?.[0]?.id]),x=I((e,t)=>i?Rn(t,i):[],[i?.id,i?.annotations?.[0]?.id]),S=o?.resource.source.id,C=n===`edit`&&r,w=Array.isArray(i?.behavior)?i.behavior:[],T=w.includes(Hi),ee=w.includes(`tour-marker-pin`)?`pin`:`circle`,E=n===`edit`&&!r,D=x.find(e=>e.id===c);if(B(()=>{l(null)},[i?.id,r]),B(()=>{T&&C&&h&&l(h)},[T,h,C]),!i)return null;let O=Number(i.width)||1920,te=Number(i.height)||1080,k=Gn(i);return z(`div`,{ref:s,className:K(`relative h-full w-full overflow-hidden`,n===`edit`&&`bg-white`,e),style:{aspectRatio:`${O} / ${te}`},children:[b.length?b.map(e=>{let r=S===e.annotation.id,o=r||d===e.annotation.id,c=f===e.annotation.id;return z(`div`,{className:K(`absolute overflow-hidden`,E&&o&&`ring-4 ring-me-primary-500 ring-offset-2 ring-offset-white`,(c||r)&&E&&`cursor-move select-none touch-none`),style:{left:`${e.box.x/O*100}%`,top:`${e.box.y/te*100}%`,width:`${e.box.width/O*100}%`,height:`${e.box.height/te*100}%`},onPointerDown:E&&(c||r)?t=>$i({event:t,mode:`move`,canvas:i,annotation:e.annotation,vault:a,startBox:e.box,stage:s.current}):E&&t?t=>{g(e.annotation.id),_(e.annotation.id),u(`content`),$i({event:t,mode:`move`,canvas:i,annotation:e.annotation,vault:a,startBox:e.box,stage:s.current})}:void 0,children:[R(Qi,{layer:e,mode:n,cover:w.includes(`cover`)||w.includes(`image-cover`)}),E&&(c||r)?R(`div`,{className:`absolute bottom-0 right-0 h-4 w-4 cursor-se-resize rounded-tl bg-me-primary-500`,onPointerDown:t=>{t.stopPropagation(),$i({event:t,mode:`resize`,canvas:i,annotation:e.annotation,vault:a,startBox:e.box,stage:s.current})}}):null]},e.annotation.id)}):R(`div`,{className:K(`flex h-full w-full items-center justify-center text-sm font-semibold`,n===`preview`?`text-white/70`:`bg-white text-slate-600`),children:n===`preview`?`This slide has no content yet`:`Empty slide`}),k.text?R(Zi,{canvas:i,box:k.text,editable:t&&E,mode:n,repositioning:m===Wi,selected:p===Wi,stage:s,onSelect:()=>{v(Wi),u(`content`)}}):null,C?x.map((e,t)=>R(Ki,{annotation:e,canvas:i,index:t,active:c===e.id,markerStyle:ee,nonLinear:T,selected:h===e.id,onSelect:()=>{y(e.id),T&&l(e.id)}},e.id)):null,C&&T&&D?R(Yi,{annotation:D,onExit:()=>l(null)}):null]})}function Ki({active:e,annotation:t,canvas:n,index:r,markerStyle:i,nonLinear:a,selected:o,onSelect:s}){let c=Hn(t,n),l=Array.isArray(n.behavior)?n.behavior:[],u=Array.isArray(t.behavior)?t.behavior:[],d=ki(l)?Ai(u.length?u:l):null,f=Number(n.width)||1920,p=Number(n.height)||1080,m=`#6d5aa8`;return a?R(`button`,{type:`button`,className:K(`absolute z-30 border-none bg-transparent p-0 transition-transform hover:scale-110 focus:outline-none focus:ring-4 focus:ring-white/80`,e&&`z-40 scale-110`),style:{left:`${(c.x+c.width/2)/f*100}%`,top:`${(c.y+c.height/2)/p*100}%`,transform:`translate(-50%, -50%)`},onClick:e=>{e.stopPropagation(),s()},children:R(qi,{index:r+1,style:i})}):z(`button`,{type:`button`,"aria-label":`Select tour step ${r+1}`,className:K(`absolute select-none border-2 border-me-primary-500 bg-me-primary-500/10 touch-none`,o?`z-40`:`z-30`,`cursor-pointer`,o?`border-4`:`ring-2 ring-white`),style:{left:`${c.x/f*100}%`,top:`${c.y/p*100}%`,width:`${c.width/f*100}%`,height:`${c.height/p*100}%`,...o?{backgroundColor:`rgba(109, 90, 168, 0.2)`,borderColor:m,boxShadow:`0 0 0 4px rgba(109, 90, 168, 0.22), 0 0 0 8px rgba(109, 90, 168, 0.14)`}:{}},onClick:e=>{e.stopPropagation(),s()},children:[R(`span`,{className:`absolute left-1 top-1`,children:R(Ji,{index:r+1})}),z(`span`,{className:K(`absolute rounded px-1.5 py-0.5 text-xs font-semibold text-white`,Xi(d),!o&&`bg-me-primary-500`),style:o?{backgroundColor:m}:void 0,children:[`Step `,r+1]})]})}function qi({index:e,style:t}){return z(`span`,{className:K(`inline-flex items-center justify-center border-2 border-white bg-black text-white shadow-lg ring-1 ring-black/40`,t===`pin`?`h-10 w-10 rounded-full`:`h-8 min-w-8 rounded px-2 text-xs font-semibold`),children:[t===`pin`?R(`span`,{className:`h-2.5 w-2.5 rounded-full bg-white`,"aria-hidden":`true`}):e,z(`span`,{className:`sr-only`,children:[`Tour step `,e]})]})}function Ji({index:e}){return z(`span`,{className:`inline-flex h-10 w-10 items-center justify-center rounded-full border-2 border-white bg-black shadow-lg ring-1 ring-black/40`,children:[R(`span`,{className:`h-2.5 w-2.5 rounded-full bg-white`,"aria-hidden":`true`}),e?z(`span`,{className:`sr-only`,children:[`Tour step `,e]}):null]})}function Yi({annotation:e,onExit:t}){let n=ta(e.label),r=ta(e.summary);return z(L,{children:[R(`div`,{className:`absolute right-4 top-4 z-50`,children:R(`button`,{type:`button`,className:`rounded bg-white px-4 py-2 text-sm font-semibold text-slate-900 shadow ring-1 ring-black/10`,onClick:t,children:`Exit`})}),z(`div`,{className:`absolute left-4 top-4 z-50 max-h-[calc(100%-2rem)] w-[min(26rem,calc(100%-2rem))] overflow-y-auto rounded bg-white p-5 text-slate-900 shadow-2xl ring-1 ring-black/10`,children:[z(`div`,{className:`mb-4 flex items-start justify-between gap-3`,children:[R(`h3`,{className:`text-xl font-bold leading-tight`,children:n||`Tour step`}),R(`button`,{type:`button`,className:`text-2xl leading-none text-slate-900`,"aria-label":`Close`,onClick:t,children:`x`})]}),r?R(`p`,{className:`mb-4 text-sm leading-relaxed text-slate-700`,children:r}):null,R(Te,{annotation:e.id,children:R(Ye,{className:`prose prose-sm max-w-none text-slate-800`,locale:`en`})})]})]})}function Xi(e){switch(e){case`float-top`:return`left-1/2 top-1 -translate-x-1/2`;case`float-top-right`:return`right-1 top-1`;case`float-left`:return`left-1 top-1/2 -translate-y-1/2`;case`float-right`:return`right-1 top-1/2 -translate-y-1/2`;case`float-bottom-left`:return`bottom-1 left-1`;case`float-bottom`:return`bottom-1 left-1/2 -translate-x-1/2`;case`float-bottom-right`:return`bottom-1 right-1`;default:return`left-1 top-1`}}function Zi({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=F();return z(`div`,{className:K(`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&&ea({event:n,mode:`move`,canvas:e,vault:u,startBox:t,stage:s.current})}:void 0,children:[r===`edit`?z(L,{children:[R(`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:ta(e.label)||`Untitled`}),R(`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:ta(e.summary)||`Add editorial text`})]}):z(L,{children:[R(M,{className:`block font-semibold uppercase leading-tight`,style:{fontSize:`clamp(13px, 5cqw, 26px)`},children:e.label}),R(M,{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?R(`div`,{className:`absolute bottom-0 right-0 h-4 w-4 cursor-se-resize rounded-tl bg-me-primary-500`,onPointerDown:n=>{n.stopPropagation(),ea({event:n,mode:`resize`,canvas:e,vault:u,startBox:t,stage:s.current})}}):null]})}function Qi({layer:e,mode:t,cover:n}){return e.imageUrl?R(`img`,{src:e.imageUrl,alt:``,className:K(`h-full w-full`,n?`object-cover`:`object-contain`)}):e.html===null?e.youtubeId?R(`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?R(`video`,{className:`h-full w-full bg-black object-contain`,controls:!0,children:R(`source`,{src:e.videoUrl})}):R(`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?R(`div`,{className:`h-full w-full overflow-hidden bg-white p-4 text-slate-900`,dangerouslySetInnerHTML:{__html:e.html}}):t===`preview`?null:R(`div`,{className:`h-full w-full overflow-hidden bg-white p-4 text-slate-900`,children:R(`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 $i({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};Un(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 ea({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;Wn(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 ta(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 na=ze(function({isFirst:e,item:t,children:n,onClick:r,...i},a){let o=N(),s=at(),c=o?.behavior||[],l=Ce(`Canvas`),u=vr(o?.behavior,e),{isBottom:d,isImage:f,isInfo:p,isLeft:m}=yr(o?.behavior),h=l?.resource.source?.id===o?.id,g=he(o?.label,`Untitled`),_=c.includes(`w-12`)&&c.includes(`h-8`),v=null;return v=_?R(Gi,{className:`pointer-events-none h-full w-full`,mode:`preview`}):p?R(`div`,{className:`bg-black w-full h-full text-white max-h-40`,children:R(`div`,{className:`p-1.5 text-[4px]`,children:s.type===`textual-content`?R(M,{enableDangerouslySetInnerHTML:!0,children:s.items[0]?.text}):null})}):z(`div`,{className:K(`flex h-full max-h-full min-h-0`,m?`flex-row-reverse`:d?`flex-col`:`flex-row`),children:[R(`div`,{className:`flex-1 overflow-hidden relative justify-self-stretch`,children:R(`div`,{className:`absolute inset-0 w-full h-full`,children:R(Ze,{cover:c.includes(`cover`)||c.includes(`image-cover`),fade:!1})})}),f?null:R(`div`,{className:`${d?`min-h-3 w-full`:`w-1/3`} flex-shrink-0 self-stretch p-2 text-white bg-black rounded`,children:z(`div`,{className:`p-1.5 text-[4px]`,children:[R(M,{className:`block mb-1 text-[5px]`,children:o?.label}),R(M,{children:o?.summary})]})})]}),z(`div`,{ref:a,className:K(u,`bg-me-gray-700 overflow-hidden hover:ring-2 ring-me-primary-500 relative`,h?`ring-2 ring-me-primary-500`:``),...i,children:[v,R(`button`,{type:`button`,className:`absolute inset-0 z-20 cursor-pointer bg-transparent focus:outline focus:outline-2 focus:outline-offset-[-2px] focus:outline-me-primary-500`,"aria-label":`Edit slide ${g}`,onClick:r}),n]})});function ra(){let{open:e}=x(),{structural:t,technical:n}=w(),[,r]=h({id:n.id.get(),type:`Manifest`},`items`,`Canvas`),i=t.items.get();return R(pr,{children:i.map((t,n)=>R(Oe,{canvas:t.id,children:R(na,{isFirst:n===0,item:t,onClick:()=>{e({id:`current-canvas`}),r.edit(t,n)}})},n))})}const ia=new Set([`a`,`blockquote`,`br`,`code`,`em`,`h1`,`h2`,`h3`,`h4`,`h5`,`h6`,`hr`,`i`,`img`,`li`,`ol`,`p`,`pre`,`s`,`span`,`strong`,`u`,`ul`]),aa={a:new Set([`href`,`rel`,`target`,`title`]),img:new Set([`alt`,`data-iiif-image`,`loading`,`src`,`title`])};function oa(e){let t=da(e),n={};for(let[e,r]of Object.entries(t)){let t=r.filter(e=>typeof e==`string`).map(e=>fa(e)?la(e):pa(e)).filter(Boolean).join(``);t&&(n[e]=[t])}return n}function sa(e){let t={};for(let[n,r]of Object.entries(e||{})){let e=(r||[]).filter(e=>typeof e==`string`).map(e=>fa(e)?la(e):pa(e)).filter(Boolean).join(``);e&&(t[n]=[e])}return t}function ca(e){return Object.values(oa(e)).flatMap(e=>Array.isArray(e)?e:[e]).filter(e=>typeof e==`string`).join(``)}function la(e){if(typeof document>`u`)return ha(e);let t=document.createElement(`template`);return t.innerHTML=e||``,ua(t.content),t.innerHTML}function ua(e){for(let t of Array.from(e.childNodes)){if(t.nodeType===Node.ELEMENT_NODE){let e=t,n=e.tagName.toLowerCase();if(!ia.has(n)){ua(e),e.replaceWith(...Array.from(e.childNodes));continue}for(let t of Array.from(e.attributes))ga(n,t.name.toLowerCase(),t.value)||e.removeAttribute(t.name);n===`a`&&e.getAttribute(`target`)?.toLowerCase()===`_blank`&&e.setAttribute(`rel`,`noopener noreferrer`)}ua(t)}}function da(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 fa(e){return e.trimStart().startsWith(`<`)}function pa(e){return e.replace(/\r\n?/g,`
|
|
2
|
+
`).split(/\n+/).map(e=>e.trim()).filter(Boolean).map(e=>`<p>${ma(e)}</p>`).join(``)}function ma(e){return e.replace(/&/g,`&`).replace(/</g,`<`).replace(/>/g,`>`).replace(/"/g,`"`).replace(/'/g,`'`)}function ha(e){return(e||``).replace(/<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi,``).replace(/<style\b[^<]*(?:(?!<\/style>)<[^<]*)*<\/style>/gi,``).replace(/<\s*(\/?)\s*([a-z0-9]+)([^>]*)>/gi,(e,t,n,r)=>{let i=n.toLowerCase();if(!ia.has(i))return``;if(t)return`</${i}>`;let a=new Map;for(let e of r.matchAll(/([^\s=/>]+)(?:\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s"'=<>`]+)))?/g)){let t=e[1].toLowerCase(),n=e[2]??e[3]??e[4];n!==void 0&&ga(i,t,n)&&a.set(t,n)}return i===`a`&&a.get(`target`)?.toLowerCase()===`_blank`&&a.set(`rel`,`noopener noreferrer`),`<${i}${Array.from(a,([e,t])=>` ${e}="${va(t)}"`).join(``)}${/\/\s*$/.test(r)?` /`:``}>`})}function ga(e,t,n){return aa[e]?.has(t)?t===`data-iiif-image`?n===`true`:!((t===`href`||t===`src`)&&_a(n)):!1}function _a(e){let t=e.search(/[/?#]/);if(e.slice(0,t===-1?void 0:t).includes(`&`))return!0;let n=e.indexOf(`:`);if(n===-1)return!1;let r=e.slice(0,n).replace(/[\u0000-\u0020]/g,``).toLowerCase();return r.includes(`&`)||r===`javascript`||r===`data`}function va(e){return e.replace(/&(?!(?:#\d+|#x[\da-f]+|[a-z][\w-]*);)/gi,`&`).replace(/"/g,`"`).replace(/</g,`<`).replace(/>/g,`>`)}function ya(e){let t=e||``;if(typeof document<`u`){let e=document.createElement(`template`);e.innerHTML=t;let n=Array.from(e.content.childNodes).find(e=>e.nodeType===Node.ELEMENT_NODE||e.nodeType===Node.TEXT_NODE&&e.textContent?.trim());if(n?.nodeType===Node.ELEMENT_NODE&&/^h[1-6]$/i.test(n.tagName)){let t=n.textContent?.trim()||``;return n.remove(),{label:t,summary:la(e.innerHTML.trim())}}return{label:void 0,summary:la(t)}}let n=t.match(/^(?:\s|<!--[\s\S]*?-->)*<h[1-6][^>]*>([\s\S]*?)<\/h[1-6]>\s*/i);return n?{label:Sa(xa(n[1]||``)).trim(),summary:la(t.slice(n[0].length).trim())}:{label:void 0,summary:la(t)}}function ba(e,t){return`${e===void 0?``:e.trim()?`<h2>${Ca(e.trim())}</h2>`:`<h2></h2>`}${la(t||``)}`}function xa(e){return e.replace(/<[^>]*>/g,``)}function Sa(e){let t={amp:`&`,apos:`'`,gt:`>`,lt:`<`,nbsp:`\xA0`,quot:`"`};return e.replace(/&(?:#(\d+)|#x([\da-f]+)|([a-z]+));/gi,(e,n,r,i)=>{if(i)return t[i.toLowerCase()]??e;let a=Number.parseInt(n||r||``,n?10:16);return a>0&&a<=1114111&&!(a>=55296&&a<=57343)?String.fromCodePoint(a):e})}function Ca(e){return e.replace(/&/g,`&`).replace(/</g,`<`).replace(/>/g,`>`).replace(/"/g,`"`).replace(/'/g,`'`)}function wa({mode:e}){let{open:t}=x(),{structural:n,technical:r}=w(),[,i]=h({id:r.id.get(),type:`Manifest`},`items`,`Canvas`),a=n.items.get();return R(Ta,{children:a.map((n,r)=>R(Oe,{canvas:n.id,children:R(Ea,{mode:e,onClick:()=>{t({id:`current-canvas`}),i.edit(n,r)}})},n.id))})}function Ta({children:e}){let t=P(),{edit:n}=x();return z(`div`,{className:`flex flex-col gap-3 p-2`,children:[R(`button`,{type:`button`,onClick:()=>t&&n(t,void 0,{forceOpen:!0,selectedTab:`@manifest-editor/descriptive-properties`}),className:`w-full rounded border border-slate-200 bg-white p-2 text-left text-sm font-semibold text-slate-800 hover:bg-slate-50`,children:R(M,{children:t?.label})}),e]})}function Ea({mode:e,onClick:t}){let n=N(),r=P(),i=Ce(`Canvas`)?.resource.source?.id===n?.id,[a,o]=U(!1),s=Ve(),c=(n?.behavior||[]).includes(`info`),l=e===`scroll`&&c,u=I((e,t)=>!!(r?.items?.[0]?.id===n?.id&&n&&Aa(t,n)),[r?.items?.[0]?.id,n?.id,n?.items?.[0]?.id]),d=I((e,t)=>n?Rn(t,n):[],[n?.id,n?.annotations?.[0]?.id]);return n?z(`article`,{className:K(`overflow-hidden rounded border bg-white shadow-sm`,i?`border-me-primary-500 ring-2 ring-me-primary-100`:`border-slate-200`),children:[z(`button`,{type:`button`,className:`block w-full text-left`,onClick:t,children:[R(`div`,{className:`border-b border-slate-100 px-2 py-1.5 text-xs font-semibold text-slate-700`,children:R(M,{children:n.label})}),u&&n.behavior?.includes(`splash`)?R(Oa,{height:180}):e===`slideshow`?c?R(ka,{height:180}):R(`div`,{style:{height:180,backgroundColor:`#303030`},children:R(Gi,{className:`pointer-events-none h-full w-full`,mode:`preview`})}):R(Da,{})]}),d.length&&!l?z(`div`,{className:`border-t border-slate-100`,children:[z(`button`,{type:`button`,"aria-expanded":a,"aria-controls":s,className:`flex w-full items-center justify-between px-2 py-1.5 text-xs font-semibold text-slate-600 hover:bg-slate-50`,onClick:e=>{e.stopPropagation(),o(e=>!e)},children:[R(`span`,{children:a?`Hide steps`:`Show steps`}),R(`span`,{children:d.length})]}),a?R(`div`,{id:s,className:`flex flex-col gap-2 border-t border-slate-100 p-2`,children:d.map((e,r)=>R(ja,{annotation:e,canvas:n,onClick:t},e.id||r))}):null]}):null]}):null}function Da(){let e=N(),t=e?.behavior||[],{isInfo:n}=yr(t);if(!e)return null;let r=Number(e.width)||1920,i=Number(e.height)||1080,a=Math.max(80,Math.round(332/r*i));return n?R(ka,{}):R(`div`,{className:`min-h-0`,style:{height:a,backgroundColor:`#303030`},children:R(`div`,{className:`relative h-full min-h-0 overflow-hidden`,style:{backgroundColor:`#303030`},children:R(`div`,{className:`absolute inset-0`,children:R(Ze,{cover:t.includes(`cover`)||t.includes(`image-cover`),fade:!1})})})})}function Oa({height:e=180}){let t=P(),n=N(),r=he(t?.summary,``),i=he(t?.requiredStatement?.label,``),a=he(t?.requiredStatement?.value,``),o=(n?.behavior||[]).includes(`invert`),s=typeof n?.backgroundColor==`string`?n.backgroundColor:null;return z(`div`,{className:K(`relative overflow-hidden bg-black p-4`,o?`text-white`:`text-black`),style:{height:e},children:[R(`div`,{className:`absolute inset-0`,children:R(Ze,{cover:!0,fade:!1})}),R(`div`,{className:`absolute inset-0 z-10 opacity-35`,style:{background:s||`transparent`}}),z(`div`,{className:K(`relative z-20 flex h-full flex-col justify-end p-3`,s?``:o?`bg-black/25 backdrop-blur-sm`:`bg-white/25 backdrop-blur-sm`),children:[R(M,{className:`block text-base font-semibold leading-tight`,children:t?.label}),r?R(`div`,{className:`mt-2 line-clamp-3 text-xs leading-relaxed opacity-75`,children:r}):null,a?z(`div`,{className:`mt-3 border-t border-current/20 pt-2 text-[11px] leading-snug opacity-75`,children:[i?R(`div`,{className:`font-semibold opacity-85`,children:i}):null,R(`div`,{children:a})]}):null]})]})}function ka({height:e}){let t=N(),n=I((e,n)=>t?Pa(n,t.annotations?.[0]):``,[t?.id,t?.annotations?.[0]?.id]);return t?z(`div`,{className:`overflow-y-auto bg-white p-3 text-black`,style:e?{height:e}:void 0,children:[R(M,{className:`mb-2 block text-sm font-semibold uppercase leading-tight`,children:t.label}),R(`div`,{className:`prose prose-sm max-w-none text-xs leading-relaxed`,dangerouslySetInnerHTML:{__html:n||he(t.summary,``)}})]}):null}function Aa(e,t){return!t||t.behavior?.includes(`info`)?!1:Ln(e,t).some(t=>{let n=qn(e,t),r=n?.type===`SpecificResource`?n.source:n,i=Array.isArray(r?.service)?r.service:r?.service?[r.service]:[];return r?.type===`Image`||i.length>0})}function ja({annotation:e,canvas:t,onClick:n}){let{edit:r}=x(),i=Y(e=>e.selectTourStep),a=Y(e=>e.stopRepositioning),o=Y(e=>e.stopTextRepositioning),s=X(e=>e.requestTab),c=X(e=>e.setShowTourSteps),l=X(e=>e.setCenterPanelMode),u=I((n,r)=>Na(r,e,t),[e?.id,e?.target,t?.id]),d=I((t,n)=>Ma(n,e),[e?.id,e?.body,e?.label,e?.summary]);return z(`button`,{type:`button`,className:`flex gap-2 rounded border border-slate-200 bg-white p-1.5 text-left hover:bg-slate-50`,onClick:()=>{n(),r({id:t.id,type:`Canvas`},void 0,{selectedTab:`@exhibition/tour-steps`,forceOpen:!0}),e?.id&&i(e.id),a(),o(),c(!0),l(`edit`),s(`tour`)},children:[R(`div`,{className:`relative h-12 w-16 shrink-0 overflow-hidden rounded bg-slate-100`,children:R(Ze,{cover:!0,fade:!1,region:u.region,singleImage:u.singleImage})}),z(`div`,{className:`min-w-0 flex-1`,children:[R(`div`,{className:`truncate text-xs font-semibold text-slate-800`,children:d.label}),R(`div`,{className:`line-clamp-1 text-xs text-slate-500 [&_*]:m-0 [&_*]:inline`,dangerouslySetInnerHTML:{__html:d.summary}})]})]})}function Ma(e,t){let n=qn(e,t);if(typeof n?.value==`string`){let{label:e,summary:r}=ya(n.value);return{label:e||he(t.label,`Step`),summary:r}}return{label:he(t.label,`Step`),summary:la(he(t.summary,``))}}function Na(e,t,n){let r=t?.target,i=typeof r==`string`?null:r?.source,a=typeof i==`string`?i:i?.id||r?.id;if((typeof i==`string`?null:i?.type||r?.type)===`Annotation`&&a){let t=e.get({id:a,type:`Annotation`},{skipSelfReturn:!1});return{region:t?Hn(t,n):void 0,singleImage:!0}}let o=Hn(t,n),s=Number(n?.width)||1920,c=Number(n?.height)||1080;return{region:o.x===0&&o.y===0&&o.width===s&&o.height===c?void 0:o,singleImage:!1}}function Pa(e,t){let n=t?e.get(t,{skipSelfReturn:!1}):null;for(let t of n?.items||[]){let n=e.get(t,{skipSelfReturn:!1})||t,r=Array.isArray(n?.body)?n.body:[n?.body];for(let t of r){let n=t?e.get(t,{skipSelfReturn:!1})||t:null;if(typeof n?.value==`string`&&n.value)return n.value}}return``}function Fa(e,t,n){if(t!==n)return t;let r=e.findIndex(e=>e.id===n);return r===-1?t:e[r+1]?.id||e[r-1]?.id}function Ia(e){return z(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 24 24`,height:`1em`,width:`1em`,...e,children:[R(`title`,{children:`Rearrange`}),R(`path`,{fill:`none`,d:`M0 0h24v24H0z`}),R(`path`,{d:`M20 9H4v2h16V9zM4 15h16v-2H4v2z`,fill:`currentColor`})]})}function La({isFirst:e,onClick:t,item:n,actions:r,mode:i}){let{attributes:a,listeners:o,setActivatorNodeRef:s,setNodeRef:c,transform:l,transition:u}=Mt({id:n.id,transition:{duration:150,easing:`cubic-bezier(0.25, 1, 0.5, 1)`}}),d={transform:Pt.Translate.toString(l),transition:u},f=z(`div`,{className:`absolute right-0.5 top-0.5 z-30 flex items-stretch gap-0.5`,onClick:e=>e.stopPropagation(),children:[r?.length?R(O,{as:G,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:R($e,{})}):null,R(G,{ref:s,...a,...o,"aria-label":`Reorder item`,className:`flex h-8 cursor-grab items-center rounded-sm bg-white p-1 text-2xl hover:bg-me-100 hover:text-me-500 focus:outline focus:outline-2 focus:outline-me-primary-500 active:cursor-grabbing`,children:R(Ia,{"aria-hidden":`true`})})]});return i?z(`div`,{ref:c,style:d,className:`relative`,children:[R(Ea,{mode:i,onClick:t}),f]}):R(na,{ref:c,style:d,onClick:t,isFirst:e,item:n,children:f})}function Ra({mode:e=`grid`}){let t=P(),{structural:n,technical:r}=w(),i=_(),a=Ce(`Canvas`),o=n.items.get(),{open:s}=x(),c=Dt(Et(wt,{activationConstraint:{distance:5}}),Et(Ct,{coordinateGetter:jt})),[,l]=h({id:r.id.get(),type:`Manifest`},`items`,`Canvas`),u=Be(e=>{let{active:t,over:r}=e;r&&t.id!==r.id&&n.items.reorder(o.findIndex(e=>e.id===t.id),o.findIndex(e=>e.id===r.id))},[o,n.items]),d=a?.resource.source.id;function f(e){if(d!==e)return;let t=Fa(o,d,e);if(i.close(),t){let e=n.items.getWithoutTracking(),r=e.findIndex(e=>e.id===t),i=e[r];i&&l.edit(i,r)}}let p=o.map((r,i)=>r?R(Oe,{canvas:r.id,children:R(La,{item:r,isFirst:i===0,mode:e===`grid`?void 0:e,onClick:()=>{s({id:`current-canvas`}),l.edit(r,i)},actions:me(n.items,()=>f(r.id))(r,i,t)})},r.id):null);return R(St,{sensors:c,collisionDetection:Tt,onDragEnd:u,modifiers:[Ot],children:R(kt,{items:o,strategy:e===`grid`?At:Nt,children:R(e===`grid`?pr:Ta,{children:p})})})}function za(e){return e.length===0?{imageSlideBehavior:[`splash`]}:void 0}function Ba(e,t){return!!(e&&t?.[0]?.id===e.id&&e.behavior?.includes(`splash`))}function Va(e,t){return Ba(t.get(e.resource),(e.parent?t.get(e.parent):void 0)?.items)}const Ha=Ga({label:`Exhibition grid`,creatorFilter:`exhibition-slide`,previewMode:`configured`}),Ua=Ga({label:`Slideshow`,creatorFilter:`exhibition-slideshow-slide`,previewMode:`slideshow`}),Wa=Ga({label:`Scroll`,creatorFilter:`exhibition-slide`,previewMode:`scroll`});function Ga({label:e,creatorFilter:t,previewMode:n}){return{id:`canvas-listing`,label:e,icon:R(Ja,{}),render:()=>R(Ka,{creatorFilter:t,previewMode:n}),options:{minWidth:350,maxWidth:350}}}function Ka({creatorFilter:e,previewMode:t}){let{structural:n,technical:r}=w(),i=qa(t,Nn()?.type),a=i===`slideshow`?`exhibition-slideshow-slide`:e,o={id:r.id.get(),type:`Manifest`},s=n.items.get()||[],c=Ce(`Canvas`),l=_(),u=c?.resource.source.id,d=u?s.findIndex(e=>e.id===u):-1,f=d>=0?d+1:void 0,p=i===`scroll`?za(s):void 0,[m,g]=h(o,`items`,`Canvas`,void 0,{isPainting:!0}),[v,y]=we(),b=()=>g.createFiltered(a,f,p),x=i===`scroll`?`section`:`slide`;return z(tt,{children:[R(rt,{title:`Exhibition`,actions:[{icon:v.list?R(ht,{className:`text-2xl`}):R(Ja,{}),title:v.list?`List view`:`Grid view`,onClick:()=>y(`list`)},{icon:R(Ya,{}),title:`Edit ${x}s`,toggled:v.editing,onClick:()=>y(`editing`)},{icon:R(Xa,{}),title:`Add new ${x}`,disabled:!m,onClick:b}]}),z(nt,{children:[v.editing?R(Ra,{mode:i}):v.list?R(mt,{isEditing:v.editing,onDelete:e=>{if(u!==e)return;let t=Fa(s,u,e);if(l.close(),t){let e=n.items.getWithoutTracking(),r=e.findIndex(e=>e.id===t),i=e[r];i&&g.edit(i,r)}}}):i===`slideshow`||i===`scroll`?R(wa,{mode:i}):R(ra,{}),R(`div`,{className:`flex justify-center p-4`,children:z(W,{primary:!0,large:!0,isDisabled:!m,onPress:b,children:[`Create new `,x]})})]})]})}function qa(e,t){return e===`configured`?t===`slideshow`||t===`scroll`?t:`grid`:e}function Ja(){return z(`svg`,{xmlns:`http://www.w3.org/2000/svg`,width:`24`,height:`24`,fill:`currentColor`,viewBox:`0 -960 960 960`,children:[R(`title`,{children:`Exhibition grid`}),R(`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 Ya(){return z(`svg`,{xmlns:`http://www.w3.org/2000/svg`,height:`24`,viewBox:`0 0 24 24`,width:`24`,children:[R(`title`,{children:`Edit slides`}),R(`path`,{d:`M0 0h24v24H0V0z`,fill:`none`}),R(`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 Xa(){return z(`svg`,{xmlns:`http://www.w3.org/2000/svg`,width:`24`,height:`24`,fill:`currentColor`,viewBox:`0 -960 960 960`,children:[R(`title`,{children:`Add new slide`}),R(`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 Za={id:`@exhibitions/overview-panel`,label:`Preview`,icon:R(ur,{}),render:()=>R(Qa,{})};function Qa(){return P()?R(`div`,{children:`Coming soon.`}):null}const $a=({rotate:e=0,...t})=>R(`svg`,{version:`1.2`,xmlns:`http://www.w3.org/2000/svg`,overflow:`visible`,preserveAspectRatio:`none`,viewBox:`0 0 24 24`,width:`1em`,height:`1em`,style:{fill:`rgba(0, 0, 0, 0.6)`,transform:`rotate(${e}deg)`,transition:`transform 0.2s`},...t,children:R(`path`,{d:`M8.12 9.29 12 13.17l3.88-3.88a.996.996 0 1 1 1.41 1.41l-4.59 4.59a.996.996 0 0 1-1.41 0L6.7 10.7a.996.996 0 0 1 0-1.41c.39-.38 1.03-.39 1.42 0z`,fill:`currentColor`})}),eo=(e,t,n)=>({id:e,label:t,type:`boolean`,defaultValue:n}),to=[{id:`exhibition-fullpage`,label:`Delft exhibition`,summary:`A guided exhibition layout with full-page scenes and focused narrative steps.`,type:`fullpage`,previewUrl:`https://preview.exhibitionviewer.org/preview/delft/full-page`,thumbnailUrl:`https://manifest-editor-docs.netlify.app/exhibition-fullpage.png`,configuration:[eo(`delft.exhibition.cutCorners`,`Cut corners`,!0),eo(`delft.exhibition.hideTableOfContents`,`Hide table of contents`,!1),eo(`delft.exhibition.showNavigationControls`,`Show navigation controls`,!1),eo(`delft.exhibition.hideTitle`,`Hide title`,!1)]},{id:`exhibition-slideshow`,label:`Slideshow`,summary:`A slide-based exhibition for linear presentations and teaching material.`,type:`slideshow`,previewUrl:`https://preview.exhibitionviewer.org/preview/delft/slideshow`,thumbnailUrl:`https://manifest-editor-docs.netlify.app/exhibition-slideshow.png`,configuration:[eo(`delft.presentation.cutCorners`,`Cut corners`,!1),eo(`delft.presentation.isFloating`,`Floating controls`,!1),{id:`delft.presentation.floatingPosition`,label:`Floating position`,type:`select`,defaultValue:`top-left`,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`}]},eo(`delft.presentation.labelOnlyFloating`,`Only float labels`,!0)]},{id:`exhibition-scroll`,label:`Scrolling story`,summary:`A vertical reading experience for essays, object stories, and long-form interpretation.`,type:`scroll`,previewUrl:`https://preview.exhibitionviewer.org/preview/delft/scroll`,thumbnailUrl:`https://manifest-editor-docs.netlify.app/exhibition-scroll.png`,configuration:[eo(`scroll.options.showTitleBlock`,`Show title block`,!0),eo(`scroll.options.titleBlock.fullHeight`,`Full-height title block`,!0),eo(`scroll.options.showTableOfContents`,`Show table of contents`,!1),eo(`scroll.options.showProgressBar`,`Show progress bar`,!0),eo(`scroll.options.showProgressTableOfContents`,`Show contents in progress bar`,!0),eo(`scroll.options.showScrollToTop`,`Show scroll-to-top button`,!0),eo(`scroll.options.showNavigationControls`,`Show navigation controls`,!0)]},{id:`leeds-exhibition`,label:`Leeds exhibition`,summary:`A full-page exhibition template for the Leeds University Library.`,type:`fullpage`,previewUrl:`https://preview.exhibitionviewer.org/preview/leeds/full-page`,thumbnailUrl:`https://manifest-editor-docs.netlify.app/exhibition-fullpage-leeds.png`,configuration:[]},{id:`leeds-exhibition-slideshow`,label:`Leeds exhibition slideshow`,summary:`A slideshow exhibition template for the Leeds University Library.`,type:`slideshow`,previewUrl:`https://preview.exhibitionviewer.org/preview/leeds/slideshow`,thumbnailUrl:`https://manifest-editor-docs.netlify.app/exhibition-slideshow-leeds.png`,configuration:[]},{id:`leeds-exhibition-scroll`,label:`Leeds exhibition scroll`,summary:`A scroll exhibition template for the Leeds University Library.`,type:`scroll`,previewUrl:`https://preview.exhibitionviewer.org/preview/leeds/scroll`,thumbnailUrl:`https://manifest-editor-docs.netlify.app/exhibition-scroll-leeds.png`,configuration:[]}];function no(e,t){let n=e;for(let e of t.split(`.`))n=n?.[e];return n}function ro(e,t,n){var r;let i=structuredClone(e),a=t.split(`.`),o=i;for(let e of a.slice(0,-1))o=(r=o)[e]||(r[e]={});return o[a.at(-1)]=n,i}const io={id:`@exhibitions/theme-panel`,label:`Preview`,icon:R(ur,{}),render:()=>R(ao,{}),options:{minWidth:360,maxWidth:440}};function ao(){let e=P(),t=F(),n=Nn(),r=T(),i=e?.service||[],a=e?.services||[],o=bn(i)||bn(a),s=n?.configuration||[],c=o?.service?.theme||{},l=s.reduce((e,t)=>ro(e,t.id,no(c,t.id)??t.defaultValue??oo(t)),{});if(!e||!n)return null;let u=n=>{let r=n?{id:`${e.id}#exhibition-viewer-theme`,type:`Service`,profile:$t,label:en,theme:n}:null,o={id:e.id,type:`Manifest`};t.batch(t=>{t.modifyEntityField(o,`service`,Sn(i,r)),(e.services||bn(a))&&t.modifyEntityField(o,`services`,Sn(a,null))})};return R(tt,{children:z(nt,{padding:!0,children:[z(co,{title:n.label,description:n.summary,children:[R(`img`,{src:n.thumbnailUrl,alt:``,className:`aspect-video w-full rounded border border-slate-200 object-cover`}),R(G,{className:`rounded border border-slate-300 px-3 py-2 text-sm hover:bg-slate-50`,onPress:r,children:`Change template`})]}),z(co,{title:`Preview configuration`,description:`These settings are defined by the selected template and stored as a service on the Manifest.`,children:[s.map(e=>R(so,{field:e,value:no(c,e.id)??e.defaultValue??oo(e),onChange:t=>u(ro(l,e.id,t))},e.id)),s.length?null:R(`p`,{className:`text-sm text-slate-500`,children:`This template has no configurable settings.`}),o?R(G,{className:`rounded border border-slate-300 px-3 py-2 text-sm hover:bg-slate-50`,onPress:()=>u(null),children:`Remove preview service`}):R(G,{className:`rounded bg-me-primary-600 px-3 py-2 text-sm text-white hover:bg-me-primary-700`,onPress:()=>u(l),children:`Add preview service`})]}),R(_o,{})]})})}function oo(e){return e.type===`boolean`?!1:e.type===`number`?0:``}function so({field:e,value:t,onChange:n}){return e.type===`boolean`?R(Q,{label:e.label,checked:!!t,onChange:n}):e.type===`select`?R(fo,{label:e.label,value:String(t),onChange:n,options:(e.options||[]).map(e=>({label:e.label,value:String(e.value)}))}):z(j,{$wide:!0,children:[R(ie,{children:e.label}),e.type===`textarea`?R(`textarea`,{"aria-label":e.label,className:`w-full rounded border border-slate-300 bg-slate-50 px-3 py-2 text-sm`,value:String(t),onChange:e=>n(e.target.value)}):R(ne,{"aria-label":e.label,type:e.type===`number`?`number`:`text`,value:String(t),onChange:t=>n(e.type===`number`?t.target.valueAsNumber:t.target.value)})]})}function co({title:e,description:t,children:n,collapsible:r=!1}){let[i,a]=U(!0);return r?z(`section`,{className:`mb-3 rounded-md border border-slate-200 bg-white last:mb-0`,children:[z(G,{className:`flex w-full items-center justify-between gap-3 px-3 py-3 text-left hover:bg-slate-50`,"aria-expanded":i,onPress:()=>a(e=>!e),children:[z(`span`,{className:`min-w-0`,children:[R(`span`,{className:`block text-sm font-semibold`,children:e}),t?R(`span`,{className:`mt-1 block text-xs text-slate-500`,children:t}):null]}),R($a,{className:`shrink-0 text-base text-slate-500`,rotate:i?0:-90,"aria-hidden":!0})]}),i&&n?R(`div`,{className:`space-y-3 border-t border-slate-200 px-3 py-3`,children:n}):null]}):z(`section`,{className:`mb-5 border-b border-slate-200 pb-5 last:mb-0 last:border-b-0`,children:[z(`div`,{className:`mb-3`,children:[R(`h3`,{className:`text-sm font-semibold`,children:e}),t?R(`p`,{className:`mt-1 text-xs text-slate-500`,children:t}):null]}),n?R(`div`,{className:`space-y-3`,children:n}):null]})}function lo({label:e,value:t,onChange:n,options:r}){return z(`div`,{children:[R(`div`,{className:`mb-2 text-xs font-medium text-slate-500`,children:e}),R(`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 R(G,{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,disabled:n=!1,onChange:r}){return z(`label`,{className:`flex items-center gap-3 text-sm ${n?`opacity-50`:``}`,children:[R(`input`,{type:`checkbox`,checked:t,disabled:n,onChange:e=>r(e.target.checked)}),R(`span`,{children:e})]})}function $({label:e,value:t,onChange:n}){return z(`div`,{className:`items-center`,style:{display:`grid`,gap:`0.5rem`,gridTemplateColumns:`minmax(0, 1fr) 3rem 100px`},children:[R(`label`,{className:`min-w-0 truncate whitespace-nowrap text-sm`,children:e}),R(`input`,{"aria-label":`${e} colour picker`,className:`h-9 w-12 shrink-0 cursor-pointer rounded border border-slate-300 bg-white p-1`,type:`color`,value:po(t),onChange:e=>n(e.target.value)}),R(`div`,{className:`min-w-0`,children:R(ne,{"aria-label":`${e} colour value`,style:{width:`100%`},value:t,onChange:e=>n(e.target.value)})})]})}function uo({label:e,value:t,onChange:n}){return z(j,{$wide:!0,children:[R(ie,{children:e}),R(ne,{"aria-label":e,value:t,onChange:e=>n(e.target.value)})]})}function fo({label:e,value:t,disabled:n=!1,onChange:r,options:i}){return z(j,{$wide:!0,children:[R(ie,{children:e}),R(`select`,{"aria-label":e,className:`w-full rounded border border-slate-300 bg-slate-50 px-3 py-2 text-sm disabled:cursor-not-allowed disabled:opacity-50`,value:t,disabled:n,onChange:e=>r(e.target.value),children:i.map(e=>R(`option`,{value:e.value,children:e.label},e.value))})]})}function po(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 mo(e){return JSON.parse(JSON.stringify(e))}function ho(e,t,n){let r=mo(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 go(e,t){let n=mo(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 _o(){let e=P(),t=F(),n=lr(),[r,i]=U(`simple`),a=n===`scroll`?`scroll`:n===`slideshow`?`slideshow`:`presentation`,o=e?.service||[],s=e?.services||[],c=V(()=>{let e=bn(o);if(e)return{service:e.service};let t=bn(s);return t?{service:t.service}:null},[o,s]),l=V(()=>c?_n(c.service.theme):null,[c])||gn(`delft`);if(!e)return null;let u=n=>{let r=n?yn(e.id,n):null,i=Sn(o,r),a=Sn(s,null),c={id:e.id,type:`Manifest`};t.batch(t=>{t.modifyEntityField(c,`service`,i),(e.services||a.length!==s.length)&&t.modifyEntityField(c,`services`,a)})},d=(e,t)=>{u(ho(l,e,t))},f=e=>{u(go(l,e))},p=e=>{let t=[{path:[`delft`,`tokens`,`backgroundPrimary`],value:e},{path:[`delft`,`tokens`,`backgroundSecondary`],value:e},{path:[`delft`,`tokens`,`backgroundOverlay`],value:e},{path:[`delft`,`tokens`,`controlBar`],value:e},{path:[`delft`,`tokens`,`controlBarBorder`],value:e},{path:[`delft`,`tokens`,`closeBackground`],value:e},{path:[`delft`,`tokens`,`closeBackgroundHover`],value:e},{path:[`delft`,`tokens`,`infoBlock`],value:e},{path:[`delft`,`tokens`,`viewerBackground`],value:e}],n=a===`presentation`?[{path:[`delft`,`tokens`,`titleCard`],value:e}]:[];if(a===`scroll`){f([...t,{path:[`scroll`,`tokens`,`titleBackground`],value:e},{path:[`scroll`,`tokens`,`annotationBackground`],value:e},{path:[`scroll`,`tokens`,`infoBlockBackground`],value:e}]);return}f([...t,...n])},m=e=>{let t=[{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`,`infoBlockText`],value:e}],n=a===`presentation`?[{path:[`delft`,`tokens`,`titleCardText`],value:e}]:[];if(a===`scroll`){f([...t,{path:[`scroll`,`tokens`,`titleColor`],value:e},{path:[`scroll`,`tokens`,`annotationColor`],value:e},{path:[`scroll`,`tokens`,`infoBlockColor`],value:e}]);return}f([...t,...n])},h=e=>{if(a===`scroll`){d([`scroll`,`options`,`showTableOfContents`],e);return}d([`delft`,`exhibition`,`hideTableOfContents`],!e)},g=e=>{if(a===`scroll`){d([`scroll`,`options`,`tableOfContentsPlacement`],e);return}d([`delft`,`exhibition`,`tableOfContentsPlacement`],e)},_=e=>{d(a===`slideshow`?[`delft`,`slideshow`,`alternativeImageMode`]:[`delft`,`exhibition`,`alternativeImageMode`],e===`alternative`)},v=e=>{d(a===`slideshow`?[`delft`,`slideshow`,`coverImages`]:[`delft`,`exhibition`,`coverImages`],e)},y=a===`scroll`?l.scroll.options.showTableOfContents:!l.delft.exhibition.hideTableOfContents,b=a===`scroll`?l.scroll.options.tableOfContentsPlacement:l.delft.exhibition.tableOfContentsPlacement,x=(a===`slideshow`?l.delft.slideshow.alternativeImageMode:l.delft.exhibition.alternativeImageMode)?`alternative`:`default`,S=a===`slideshow`?l.delft.slideshow.coverImages:l.delft.exhibition.coverImages,C=a===`scroll`?l.scroll.options.showProgressBar:l.delft.exhibition.showProgressBar;return z(L,{children:[z(co,{title:`Saved Theme`,description:`Save custom exhibition styling and viewer defaults on the Manifest.`,children:[R(Q,{label:`Save custom theme`,checked:!!c,onChange:e=>{if(!e){u(null);return}u(gn(`delft`))}}),z(`div`,{className:`flex flex-wrap gap-2`,children:[R(G,{className:`rounded border border-slate-300 px-3 py-2 text-sm hover:bg-slate-50 disabled:cursor-not-allowed disabled:opacity-50`,onPress:()=>{u(gn(l.preset))},isDisabled:!c,children:`Reset selected theme`}),R(G,{className:`rounded border border-slate-300 px-3 py-2 text-sm hover:bg-slate-50 disabled:cursor-not-allowed disabled:opacity-50`,onPress:()=>u(null),isDisabled:!c,children:`Clear saved settings`})]}),R(lo,{label:`Preset`,value:l.preset,onChange:e=>{u(gn(e))},options:[{label:`Delft`,value:`delft`},{label:`Gallery`,value:`gallery`},{label:`Minimal`,value:`minimal`}]})]}),R(co,{title:`Theme Options`,description:`Choose a shorter or more detailed set of theme controls.`,children:R(lo,{label:`Editing mode`,value:r,onChange:i,options:[{label:`Simple`,value:`simple`},{label:`Advanced`,value:`advanced`}]})}),r===`simple`?z(co,{title:`Key Settings`,description:a===`scroll`?`Main background updates the opening title, annotation cards, info blocks, and viewer background.`:`The main controls most people need for this theme.`,children:[R($,{label:`Main background`,value:a===`scroll`?l.scroll.tokens.titleBackground:l.delft.tokens.viewerBackground,onChange:p}),R($,{label:`Text colour`,value:a===`scroll`?l.scroll.tokens.titleColor:l.delft.tokens.textSecondary,onChange:m}),R(uo,{label:`Heading font`,value:l.shared.fontSans,onChange:e=>d([`shared`,`fontSans`],e)}),R(uo,{label:`Body font`,value:l.shared.fontMono,onChange:e=>d([`shared`,`fontMono`],e)}),a===`scroll`?null:R(fo,{label:`Title capitalisation`,value:l.shared.titleTransform,onChange:e=>d([`shared`,`titleTransform`],e),options:[{label:`Uppercase`,value:`uppercase`},{label:`None`,value:`none`},{label:`Capitalize`,value:`capitalize`}]}),a===`presentation`?z(L,{children:[R(Q,{label:`Table of Contents bar`,checked:y,onChange:h}),R(Q,{label:`Full-width title bar`,checked:l.delft.exhibition.fullTitleBar,onChange:e=>d([`delft`,`exhibition`,`fullTitleBar`],e)}),R(fo,{label:`Image layout`,value:x,onChange:_,options:[{label:`Standard`,value:`default`},{label:`Feature image`,value:`alternative`}]}),R(Q,{label:`Fill image area`,checked:S,onChange:v})]}):null,a===`slideshow`?z(L,{children:[R(fo,{label:`Image layout`,value:x,onChange:_,options:[{label:`Standard`,value:`default`},{label:`Feature image`,value:`alternative`}]}),R(Q,{label:`Fill image area`,checked:S,onChange:v}),R(Q,{label:`Zoom effect`,checked:l.delft.slideshow.transitionScale,onChange:e=>d([`delft`,`slideshow`,`transitionScale`],e)})]}):null,a===`scroll`?R(L,{children:R(Q,{label:`Full-height title`,checked:l.scroll.options.titleBlock.fullHeight,onChange:e=>d([`scroll`,`options`,`titleBlock`,`fullHeight`],e)})}):null]}):z(L,{children:[a===`presentation`?z(co,{title:`Opening Title`,collapsible:!0,children:[R($,{label:`Card background`,value:l.delft.tokens.titleCard,onChange:e=>d([`delft`,`tokens`,`titleCard`],e)}),R($,{label:`Card text`,value:l.delft.tokens.titleCardText,onChange:e=>d([`delft`,`tokens`,`titleCardText`],e)}),R(Q,{label:`Hide title`,checked:l.delft.exhibition.hideTitle,onChange:e=>d([`delft`,`exhibition`,`hideTitle`],e)}),R(Q,{label:`Hide title card`,checked:l.delft.exhibition.hideTitleCard,onChange:e=>d([`delft`,`exhibition`,`hideTitleCard`],e)})]}):null,a===`scroll`?z(co,{title:`Opening Title`,collapsible:!0,children:[R(Q,{label:`Show opening title`,checked:l.scroll.options.showTitleBlock,onChange:e=>d([`scroll`,`options`,`showTitleBlock`],e)}),R(Q,{label:`Show table of contents`,checked:y,onChange:h}),R($,{label:`Background`,value:l.scroll.tokens.titleBackground,onChange:e=>d([`scroll`,`tokens`,`titleBackground`],e)}),R($,{label:`Text`,value:l.scroll.tokens.titleColor,onChange:e=>d([`scroll`,`tokens`,`titleColor`],e)}),R(Q,{label:`Full-height title`,checked:l.scroll.options.titleBlock.fullHeight,onChange:e=>d([`scroll`,`options`,`titleBlock`,`fullHeight`],e)})]}):null,z(co,{title:`Page & Viewer`,description:a===`scroll`?`Shared backgrounds around the Scroll view. Opening title, annotation, and info block colours are controlled below.`:void 0,collapsible:!0,children:[R($,{label:`Viewer background`,value:l.delft.tokens.viewerBackground,onChange:e=>d([`delft`,`tokens`,`viewerBackground`],e)}),R($,{label:`Main`,value:l.delft.tokens.backgroundPrimary,onChange:e=>d([`delft`,`tokens`,`backgroundPrimary`],e)}),R($,{label:`Secondary`,value:l.delft.tokens.backgroundSecondary,onChange:e=>d([`delft`,`tokens`,`backgroundSecondary`],e)}),R($,{label:`Overlay`,value:l.delft.tokens.backgroundOverlay,onChange:e=>d([`delft`,`tokens`,`backgroundOverlay`],e)}),a===`scroll`?R(Q,{label:`Use theme background instead of canvas colours`,checked:l.scroll.options.ignoreCanvasBackgrounds,onChange:e=>d([`scroll`,`options`,`ignoreCanvasBackgrounds`],e)}):null]}),a===`scroll`?null:z(co,{title:`Text Colours`,description:`General fallback text colours. Captions, info blocks, and controls have their own options below.`,collapsible:!0,children:[R($,{label:`Dark text`,value:l.delft.tokens.textPrimary,onChange:e=>d([`delft`,`tokens`,`textPrimary`],e)}),R($,{label:`Light text`,value:l.delft.tokens.textSecondary,onChange:e=>d([`delft`,`tokens`,`textSecondary`],e)})]}),R(co,{title:`Info Blocks`,collapsible:!0,children:a===`scroll`?z(L,{children:[R($,{label:`Background`,value:l.scroll.tokens.infoBlockBackground,onChange:e=>d([`scroll`,`tokens`,`infoBlockBackground`],e)}),R($,{label:`Text`,value:l.scroll.tokens.infoBlockColor,onChange:e=>d([`scroll`,`tokens`,`infoBlockColor`],e)})]}):z(L,{children:[R($,{label:`Background`,value:l.delft.tokens.infoBlock,onChange:e=>d([`delft`,`tokens`,`infoBlock`],e)}),R($,{label:`Text`,value:l.delft.tokens.infoBlockText,onChange:e=>d([`delft`,`tokens`,`infoBlockText`],e)})]})}),z(co,{title:`Images & Annotations`,collapsible:!0,children:[a===`scroll`?null:z(L,{children:[R($,{label:`Image caption`,value:l.delft.tokens.imageCaption,onChange:e=>d([`delft`,`tokens`,`imageCaption`],e)}),R($,{label:`Selected hotspot`,value:l.delft.tokens.annotationSelected,onChange:e=>d([`delft`,`tokens`,`annotationSelected`],e)}),R(fo,{label:`Image layout`,value:x,onChange:_,options:[{label:`Standard`,value:`default`},{label:`Feature image`,value:`alternative`}]}),R(Q,{label:`Info button`,checked:a===`slideshow`?l.delft.slideshow.imageInfoIcon:l.delft.exhibition.imageInfoIcon,onChange:e=>d(a===`slideshow`?[`delft`,`slideshow`,`imageInfoIcon`]:[`delft`,`exhibition`,`imageInfoIcon`],e)}),R(Q,{label:`Fill image area`,checked:S,onChange:v}),R(Q,{label:`Use theme background instead of canvas colours`,checked:a===`slideshow`?l.delft.slideshow.ignoreCanvasBackgrounds:l.delft.exhibition.ignoreCanvasBackgrounds,onChange:e=>d(a===`slideshow`?[`delft`,`slideshow`,`ignoreCanvasBackgrounds`]:[`delft`,`exhibition`,`ignoreCanvasBackgrounds`],e)})]}),a===`scroll`?z(L,{children:[R($,{label:`Annotation background`,value:l.scroll.tokens.annotationBackground,onChange:e=>d([`scroll`,`tokens`,`annotationBackground`],e)}),R($,{label:`Annotation text`,value:l.scroll.tokens.annotationColor,onChange:e=>d([`scroll`,`tokens`,`annotationColor`],e)}),R(uo,{label:`Corner radius`,value:l.scroll.tokens.annotationRadius,onChange:e=>d([`scroll`,`tokens`,`annotationRadius`],e)}),R(uo,{label:`Max width`,value:l.scroll.tokens.annotationMaxWidth,onChange:e=>d([`scroll`,`tokens`,`annotationMaxWidth`],e)})]}):null]}),z(co,{title:`Navigation & Controls`,description:a===`scroll`?`Scroll contents navigation, placement, dropdown text, and progress colours.`:a===`slideshow`?`Slideshow controls, progress, and overlay buttons. Contents controls only apply to Full page and Scroll.`:`Contents, viewer controls, progress, and overlay buttons.`,collapsible:!0,children:[a===`presentation`||a===`scroll`?R(Q,{label:`Progress bar`,checked:C,onChange:e=>d(a===`scroll`?[`scroll`,`options`,`showProgressBar`]:[`delft`,`exhibition`,`showProgressBar`],e)}):null,a===`presentation`||a===`scroll`?R(Q,{label:`Previous/next side controls`,checked:a===`scroll`?l.scroll.options.showNavigationControls:l.delft.exhibition.showNavigationControls,onChange:e=>d(a===`scroll`?[`scroll`,`options`,`showNavigationControls`]:[`delft`,`exhibition`,`showNavigationControls`],e)}):null,a===`presentation`?R(Q,{label:`Table of Contents bar`,checked:y,onChange:h}):null,a===`presentation`||a===`scroll`?R(fo,{label:`Contents position`,value:b,disabled:!y,onChange:g,options:[{label:`Header`,value:`header`},{label:`Footer`,value:`footer`}]}):null,a===`scroll`?R(Q,{label:`Back to top button`,checked:l.scroll.options.showScrollToTop,onChange:e=>d([`scroll`,`options`,`showScrollToTop`],e)}):null,R($,{label:`Navigation bar background`,value:l.delft.tokens.controlBar,onChange:e=>f([{path:[`delft`,`tokens`,`controlBar`],value:e},{path:[`delft`,`tokens`,`controlBarBorder`],value:e}])}),R($,{label:`Navigation text colour`,value:l.delft.tokens.closeText,onChange:e=>d([`delft`,`tokens`,`closeText`],e)}),R($,{label:`Progress bar colour`,value:l.delft.tokens.progressBar,onChange:e=>d([`delft`,`tokens`,`progressBar`],e)}),a===`scroll`?R($,{label:`Back to top button background`,value:l.delft.tokens.closeBackground,onChange:e=>d([`delft`,`tokens`,`closeBackground`],e)}):z(L,{children:[R($,{label:`Close button background`,value:l.delft.tokens.closeBackground,onChange:e=>d([`delft`,`tokens`,`closeBackground`],e)}),R($,{label:`Close button hover`,value:l.delft.tokens.closeBackgroundHover,onChange:e=>d([`delft`,`tokens`,`closeBackgroundHover`],e)})]})]}),a===`presentation`?z(L,{children:[z(co,{title:`Display & Layout`,collapsible:!0,children:[R(Q,{label:`Angled corners`,checked:l.delft.exhibition.cutCorners,onChange:e=>d([`delft`,`exhibition`,`cutCorners`],e)}),R(Q,{label:`Full-width title bar`,checked:l.delft.exhibition.fullTitleBar,onChange:e=>d([`delft`,`exhibition`,`fullTitleBar`],e)}),R(Q,{label:`Full-width item grid`,checked:l.delft.exhibition.fullWidthGrid,onChange:e=>d([`delft`,`exhibition`,`fullWidthGrid`],e)}),R(Q,{label:`Use theme background instead of canvas colours`,checked:l.delft.exhibition.ignoreCanvasBackgrounds,onChange:e=>d([`delft`,`exhibition`,`ignoreCanvasBackgrounds`],e)})]}),z(co,{title:`Interaction Behaviour`,collapsible:!0,children:[R(fo,{label:`Presentation mode`,value:l.delft.exhibition.disablePresentation?`disabled`:`available`,onChange:e=>d([`delft`,`exhibition`,`disablePresentation`],e===`disabled`),options:[{label:`Available`,value:`available`},{label:`Disabled`,value:`disabled`}]}),R(Q,{label:`Zoom effect`,checked:l.delft.exhibition.transitionScale,onChange:e=>d([`delft`,`exhibition`,`transitionScale`],e)}),R(Q,{label:`Floating panels`,checked:l.delft.presentation.isFloating,onChange:e=>d([`delft`,`presentation`,`isFloating`],e)}),l.delft.presentation.isFloating?R(Q,{label:`Label-only floating`,checked:l.delft.presentation.labelOnlyFloating,onChange:e=>d([`delft`,`presentation`,`labelOnlyFloating`],e)}):null,l.delft.presentation.isFloating?R(fo,{label:`Panel position`,value:l.delft.presentation.floatingPosition,onChange:e=>d([`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`},{label:`Top`,value:`top`},{label:`Bottom`,value:`bottom`},{label:`Left`,value:`left`},{label:`Right`,value:`right`}]}):null,R(Q,{label:`Angled panel corners`,checked:l.delft.presentation.cutCorners,onChange:e=>d([`delft`,`presentation`,`cutCorners`],e)}),R(Q,{label:`Use theme background instead of canvas colours`,checked:l.delft.presentation.ignoreCanvasBackgrounds,onChange:e=>d([`delft`,`presentation`,`ignoreCanvasBackgrounds`],e)})]})]}):null,a===`slideshow`?R(co,{title:`Interaction Behaviour`,collapsible:!0,children:R(Q,{label:`Zoom effect`,checked:l.delft.slideshow.transitionScale,onChange:e=>d([`delft`,`slideshow`,`transitionScale`],e)})}):null]})]})}function vo(e){return e===`left-panel-manifest`||e===Ha.id}const yo={id:`exhibition-background-task`,label:`Query string`,render:()=>R(bo,{})};function bo(){let e=P(),{leftPanel:t,rightPanel:n}=S(),{edit:r,centerPanel:i,rightPanel:a}=x(),[o,s]=U(!1),c=H(null),l=H(null);return B(()=>{let u=e?.id||null,d=c.current!==t.current,f=l.current!==u,p=c.current;if(c.current=t.current,l.current=u,!(!e||!d&&!f)){if(t.current===Za.id){r(e),i.open({id:wn.id}),s(!1);return}if(t.current===io.id){r(e),n.open?(a.close(),s(!0)):s(!1),i.open({id:dr.id});return}!n.open&&n.current&&vo(t.current)&&(p===null||p===io.id&&o)&&(a.open(),s(!1))}},[i,r,t.current,e?.id,n.current,n.open,a,o]),null}const xo={id:`image-block-editor`,label:`Image Block Editor`,component:e=>R(So,{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 So({strategy:e}){let[t,n]=C(`exhibition-preview-mode`),r=X(e=>e.centerPanelMode),i=X(e=>e.setCenterPanelMode),a=lr(),o=Ce(`Canvas`);return B(()=>{r===`edit`&&t?n(!1):r===`preview`&&!t&&n(!0)},[r,t,n]),o?R(Oe,{canvas:o.resource.source?.id,children:R(Co,{isPreview:!!t,previewPreset:a,onModeChange:e=>{i(e?`preview`:`edit`),n(e)}})}):null}function Co({isPreview:e,previewPreset:t,onModeChange:n}){let r=N();return z(`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:[z(`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:[R(`div`,{className:`min-w-0 flex-1`,children:R(M,{className:`block truncate text-sm font-semibold text-slate-800`,children:r?.label})}),R(`div`,{className:`flex items-center gap-2`,children:z(`div`,{className:`flex shrink-0 overflow-hidden rounded-md border border-slate-200 bg-slate-50 text-xs font-semibold`,children:[R(wo,{selected:!e,onPress:()=>n(!1),children:`Edit`}),R(wo,{selected:e,onPress:()=>n(!0),children:`Preview`})]})})]}),e?R(`div`,{className:`min-h-0 flex-1`,children:R(ar,{preset:t})}):R(`div`,{className:`flex min-h-0 flex-1`,children:R(k,{asFallback:!0})})]})}function wo({children:e,selected:t,onPress:n}){return R(G,{className:K(`px-3 py-2 text-xs font-semibold transition`,t?`bg-me-primary-500 text-white shadow-sm`:`text-slate-500 hover:text-slate-700`),onPress:n,children:e})}const To={id:`info-block-editor`,label:`info Block Editor`,component:e=>R(ko,{strategy:e}),supports:{strategy:(e,t,n)=>e.type===`textual-content`}};function Eo(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 Do({selectedLanguage:e,languages:t,availableLanguages:n,onSelectLanguage:r,onAddLanguage:i}){let[a,o]=U(!1),s=H(null);B(()=>{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)),l=Eo(e);return z(`div`,{ref:s,className:`relative`,children:[z(`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:[R(`span`,{className:``,children:l?.label||e}),R(`svg`,{className:`h-3 w-3 text-slate-400`,viewBox:`0 0 12 12`,fill:`none`,stroke:`currentColor`,strokeWidth:2,children:R(`path`,{d:`M2 4l4 4 4-4`})})]}),a&&z(`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&&z(L,{children:[R(`div`,{className:`px-3 py-1 text-[10px] font-semibold uppercase tracking-wider text-slate-400`,children:`Language`}),t.map(t=>{let n=Eo(t);return z(`button`,{type:`button`,className:K(`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?R(`svg`,{className:`h-3 w-3 shrink-0 text-slate-500`,viewBox:`0 0 12 12`,fill:`currentColor`,children:R(`path`,{d:`M2 6l3 3 5-5`,stroke:`currentColor`,strokeWidth:2,fill:`none`})}):R(`div`,{className:`h-3 w-3 shrink-0 text-slate-500`}),R(`span`,{children:n?.label||t})]},t)})]}),c.length>0&&z(L,{children:[t.length>0&&R(`div`,{className:`my-1 border-t border-slate-100`}),R(`div`,{className:`px-3 py-1 text-[10px] font-semibold uppercase tracking-wider text-slate-400`,children:`Add language`}),c.map(e=>{let t=Eo(e);return z(`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:[R(`svg`,{className:`h-3 w-3 shrink-0 text-slate-400`,viewBox:`0 0 12 12`,fill:`none`,stroke:`currentColor`,strokeWidth:2,children:R(`path`,{d:`M6 2v8M2 6h8`})}),t?.label||e]},e)})]}),c.length===0&&t.length===0&&R(`div`,{className:`px-3 py-2 text-xs text-slate-400`,children:`No languages available`})]})]})}function Oo(e,t){if(!e)return[];let n=e.items||[],r=new Set;for(let e of n){let n=Bo(e,t);if(!n)continue;let i=Vo(n.body);for(let e of i){let n=Bo(e,t);n?.language&&r.add(n.language)}}return Array.from(r)}function ko({strategy:e}){let t=N(),n=t?.behavior||[],r=_r(n),i=!!(r.h&&r.w),{isBottom:a,isLeft:o,isRight:s}=yr(n),c=i&&r.w<=6,l=I((e,n)=>t?.items[0]?n.get(t.items[0]):null),u=I((e,n)=>t?.annotations[0]?n.get(t?.annotations[0]):null),{i18n:{availableLanguages:d,defaultLanguage:f}}=m(),[p,h]=C(`exhibition-info-block-mode`,`edit`),g=lr(),_=g===`exhibition`,v=_,y=_?`Read more text in modal`:`Summary`,b=I((e,t)=>{let n=Oo(l,t),r=Oo(u,t),i=new Set([...n,...r]);return i.size===0&&i.add(f||`en`),Array.from(i)},[l?.id,u?.id,f]),[x,S]=U(),w=x||(b.includes(f)?f:b[0]||f||`en`),T=e=>{S(e)},ee=c?`30rem`:void 0;return z(`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:[z(`div`,{className:`exhibition-slideshow-current-toolbar relative z-[70] flex items-center gap-3 border-b border-slate-200 bg-white px-4 py-3 shadow-sm`,children:[R(`div`,{className:`min-w-0 flex-1`,children:R(M,{className:`block truncate text-sm font-semibold text-slate-800`,children:t?.label})}),z(`div`,{className:`flex items-center gap-2`,children:[p===`edit`&&R(Do,{selectedLanguage:w,languages:b,availableLanguages:d,onSelectLanguage:S,onAddLanguage:T}),z(`div`,{className:`flex shrink-0 overflow-hidden rounded-md border border-slate-200 bg-slate-50 text-xs font-semibold`,children:[R(Ao,{selected:p===`edit`,onPress:()=>h(`edit`),children:`Edit`}),R(Ao,{selected:p===`preview`,onPress:()=>h(`preview`),children:`Preview`})]})]})]}),p===`preview`?R(`div`,{className:`min-h-0 flex-1`,children:R(ar,{preset:g})}):z(`div`,{className:`min-h-0 flex-1 overflow-x-hidden overflow-y-auto`,children:[v?R(jo,{annotationPage:l,compact:c,editorMaxWidth:ee,fallbackText:e.items[0]?.text,heading:`Short text in info box`,panelClassName:K(`border-b border-gray-100`,c?`p-3`:`p-5`,i&&(o||s)?`max-w-xl`:``,i&&a?`max-w-4xl`:``),parentProperty:`items`,selectedLanguage:w,onLanguageAdded:T}):null,R(jo,{annotationPage:u,compact:c,heading:y,panelClassName:K(c?`p-3`:`p-5`),parentProperty:`annotations`,selectedLanguage:w,onLanguageAdded:T})]})]})}function Ao({children:e,selected:t,onPress:n}){return R(G,{className:K(`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 jo({annotationPage:e,compact:t,editorMaxWidth:n,fallbackText:r,heading:i,panelClassName:a,parentProperty:o,selectedLanguage:s,onLanguageAdded:c}){let l=N(),u=b(),d=F(),{i18n:{defaultLanguage:f}}=m(),p=e||null,h=p?.items||[],g=Po(h,d),_=()=>{l&&u.create(`@manifest-editor/empty-annotation-page`,{label:{en:[i]}},{target:{id:l.id,type:`Canvas`},targetType:`AnnotationPage`,parent:{property:o,resource:{id:l.id,type:`Canvas`}}})},v=()=>{if(l){if(!p){_();return}u.create(`@manifest-editor/html-annotation`,{label:{en:[i]},body:{[s||f||`en`]:[``]},motivation:o===`annotations`?`tagging`:`painting`},{target:{id:l.id,type:`Canvas`},targetType:`Annotation`,parent:{property:`items`,resource:{id:p.id,type:`AnnotationPage`}},initialData:{}})}},y=()=>{if(!p){v(),c(s);return}let e=!1;for(let t of h){let n=Bo(t,d);if(!n)continue;let r=Vo(n.body);if(r.some(e=>Bo(e,d)?.language===s))continue;let i=r[0],a=i?Bo(i,d):null,o=`${n.id}-body-${s}-${Date.now()}`;d.batch(()=>{d.dispatch(It({entities:{ContentResource:{[o]:{id:o,type:a?.type||`TextualBody`,language:s,value:``,format:a?.format||`text/html`}}}})),d.dispatch(Ft({mapping:{[o]:`ContentResource`}})),d.modifyEntityField({id:n.id,type:`Annotation`},`body`,[...r,{id:o,type:`ContentResource`}])}),e=!0}e||v(),c(s)},x=I((e,t)=>{if(!p)return!1;for(let e of h){let n=Bo(e,t);if(!n)continue;let r=Vo(n.body);for(let e of r)if(Bo(e,t)?.language===s)return!0}return!1},[p?.id,h,s]);return z(`section`,{className:K(`min-w-0 max-w-full`,a),children:[z(`div`,{className:K(`flex items-center justify-between gap-3`,g.length?`mb-3`:`mb-0`),children:[R(`h2`,{className:K(`font-semibold tracking-tight text-gray-700`,t?`text-xs uppercase`:`text-sm uppercase tracking-wide`),children:i}),!x&&R(W,{primary:!0,onPress:y,children:p?`Add text`:`Add`})]}),!p&&r?R(`div`,{className:`mt-2 text-sm text-gray-600`,children:R(M,{enableDangerouslySetInnerHTML:!0,children:r})}):null,g.length?R(`div`,{className:`min-w-0 max-w-full`,children:g.map(({item:e,index:t})=>R(Te,{annotation:e.id,children:R(Mo,{editorMaxWidth:n,pageItems:h,pageRef:{id:p.id,type:`AnnotationPage`},selectedLanguage:s,onRemoveAnnotation:()=>{d.modifyEntityField({id:p.id,type:`AnnotationPage`},`items`,h.filter((e,n)=>n!==t))}})},e.id+t))}):p&&x?R(`div`,{className:K(`mt-2 text-sm text-gray-400 italic`,``),children:`No text added yet.`}):null]})}function Mo({editorMaxWidth:e,onRemoveAnnotation:t,pageItems:n,pageRef:r,selectedLanguage:i}){let a=je(),o=F(),s=a?.body||[],c=y(a);if(!a)return null;let l=s.map((e,t)=>({item:e,index:t})).filter(({item:e})=>Bo(e,o)?.language===i),u=l.length>0?l:[],d=Be(e=>{let t=Io(s,o,e);t.length!==s.length&&o.modifyEntityField({id:a.id,type:`Annotation`},`body`,t);let i=Fo(n,o,a.id);i.length!==n.length&&o.modifyEntityField(r,`items`,i)},[a.id,r.id,n,o]);return u.length?R(`div`,{className:`min-w-0 max-w-full overflow-hidden`,children:u.map(({item:t,index:n})=>R(No,{resourceId:t.id,onRemove:()=>c.annotation.body.deleteAtIndex(n),onUpdate:()=>d(t.id),editorMaxWidth:e},t.id||n))}):null}function No({editorMaxWidth:e,resourceId:t,onRemove:n,onUpdate:r}){let i=V(()=>({id:t,type:`ContentResource`}),[t]),a=y(i),{i18n:{advancedLanguageMode:o,availableLanguages:s,defaultLanguage:c}}=m(),{language:l,value:u}=a.descriptive,d=l.get(),f=Array.isArray(d)?d[0]||c||`en`:d||c||`en`;return B(()=>{let e=Array.isArray(l.get())?l.get()[0]:l.get();!o&&e!==f&&l.set(f)},[o,f]),z(`div`,{className:`min-w-0 max-w-full overflow-hidden`,style:e?{maxWidth:e}:void 0,children:[o?z(`div`,{className:`mb-2 flex items-center justify-between gap-2`,children:[R(`select`,{"aria-label":`Language`,className:`rounded border border-slate-200 bg-white px-2 py-1 text-sm`,value:f,onChange:e=>l.set(e.currentTarget.value),children:s.map(e=>R(`option`,{value:e,children:e},e))}),R(`button`,{type:`button`,className:`text-sm text-slate-600 hover:text-slate-900`,onClick:n,children:`Remove`})]}):null,R(Xe,{value:u.get()||``,onChange:e=>{u.set(e),r()}},`${t}:${f}`)]})}function Po(e,t){let n=e.map((e,t)=>({item:e,index:t})),r=n.filter(({item:e})=>!Lo(e,t));return r.length?r:n.slice(0,1)}function Fo(e,t,n){let r=e.filter(e=>e?.id===n||!Lo(e,t));return r.length?r:e.slice(0,1)}function Io(e,t,n){let r=e.filter(e=>e?.id===n||!Ro(e,t));return r.length?r:e.slice(0,1)}function Lo(e,t){let n=Vo(Bo(e,t)?.body);return!n.length||n.every(e=>Ro(e,t))}function Ro(e,t){let n=Bo(e,t);return!n||zo(n.value||``)}function zo(e){let t=String(e||``);return!/<img\b/i.test(t)&&t.replace(/<[^>]*>/g,``).replace(/ /gi,` `).replace(/\s+/g,``).trim()===``}function Bo(e,t){return!e?.id||e.value||e.items||e.body?e:t.get(e,{skipSelfReturn:!1})||e}function Vo(e){return Array.isArray(e)?e:e==null?[]:[e]}const Ho={id:`youtube-main-editor`,label:`YouTube main editor`,component:e=>e.type===`media`?R(Uo,{strategy:e,video:e.media}):null,supports:{strategy:(e,t,n)=>e.type===`media`&&e.media.type===`VideoYouTube`}};function Uo({strategy:e,video:t}){let{edit:n}=x(),r=N(),i=I((e,t)=>t.get(r?.items[0]).items[0]);gt(r&&i);let a=H(null),o=y(i),s=t,c=(r.width||1)/(r.height||1);return`${s.youTubeId}`,z(`div`,{className:`overflow-y-auto`,children:[R(`div`,{className:`p-8`,children:R(`div`,{className:`bg-black z-20 flex p-8 rounded-lg max-w-full max-h-[70vh] mx-auto`,style:{aspectRatio:c},children:R(`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`})})}),z(`div`,{className:`bg-white shadow w-full p-8 flex gap-8`,children:[R(`div`,{children:R(`div`,{className:`w-64 bg-black flex-shrink-0 flex items-center justify-center rounded overflow-clip`,style:{aspectRatio:c},children:r.thumbnail?.length?R(Ze,{cover:!0}):R(`div`,{className:`text-white/50 text-center py-16`,children:`No thumbnail`})})}),z(`div`,{className:`flex-1`,children:[R(M,{as:`h3`,className:`text-2xl font-bold mt-4`,defaultText:R(`span`,{className:`text-black/30`,children:`No Label`}),children:o.descriptive.label.get()}),R(M,{as:`p`,className:`mt-2 mb-8`,defaultText:R(`span`,{className:`text-black/30`,children:`No summary`}),children:o.descriptive.summary.get()}),R(W,{onPress:()=>n(o.ref()),children:`Edit properties`})]})]})]})}const Wo=q({...zt,id:`@exhibitions/browser-creator`,configKey:zt.id,create:Ko,sideEffects:[],tags:[`image`,`exhibition-slide`,`exhibition-slideshow-slide`],label:`IIIF Browser`,summary:`Browse IIIF Resources`,resourceType:`Canvas`,resourceFields:[`id`,`language`,`type`,`format`,`value`],additionalTypes:[],supports:{initialData:!0,onlyPainting:!0,parentTypes:[`Manifest`],parentFields:[`items`],parentFieldMap:{Manifest:[`items`]}}});function Go(e){return{...e,additionalTypes:e.additionalTypes?.filter(e=>e!==`Canvas`),supports:{...e.supports,parentTypes:[`Annotation`,`AnnotationPage`],parentFieldMap:{Annotation:[`body`],AnnotationPage:[`items`]}}}}async function Ko(e,t){let n=t.generateId(`canvas`),r=t.generateId(`annotation-page`,{id:n,type:`Canvas`}),i={width:0,height:0},a,o=await Lt(t,{id:r,type:`AnnotationPage`},`items`,`@manifest-editor/iiif-browser-creator`)({...e,trackSize({width:e,height:t}){i.height=t,i.width=e},trackManifest(e){a=e}},{targetType:`Annotation`,target:{id:n,type:`Canvas`}});return await Lt(t,`Manifest`,`items`,`@exhibitions/image-slide-creator`)({canvasId:n,width:i.width,height:i.height,type:`default`,items:o,imageSlideBehavior:t.options.initialData?.imageSlideBehavior,...a})}const qo=q({...Bt,id:`@exhibitions/image-service-creator`,create:Jo,tags:[`image`,`exhibition-slide`,`exhibition-slideshow-slide`],label:`IIIF Image`,summary:`IIIF Image service`,resourceType:`Canvas`,supports:{initialData:!0,parentTypes:[`Manifest`],parentFields:[`items`]}});async function Jo(e,t){let n=t.generateId(`canvas`);t.generateId(`annotation-page`,{id:n,type:`Canvas`});let r=t.generateId(`annotation`),i=await Lt(t,{id:r,type:`Annotation`},`body`,`@manifest-editor/image-service-creator`)(e,{target:{id:n,type:`Canvas`}}),{width:a,height:o}=i.get(),s=t.embed({id:t.generateId(`annotation`),type:`Annotation`,motivation:`painting`,body:[i],target:{type:`SpecificResource`,source:{id:n,type:`Canvas`}}});return await Lt(t,`Manifest`,`items`,`@exhibitions/image-slide-creator`)({canvasId:n,width:a,height:o,type:e.slideType??`default`,items:[s],imageSlideBehavior:e.imageSlideBehavior??t.options.initialData?.imageSlideBehavior})}const Yo=q({id:`@exhibitions/image-slide-creator`,create:Qo,label:`Empty slide`,summary:`An empty image slide.`,icon:R(Je,{}),tags:[`exhibition-slide`],resourceType:`Canvas`,resourceFields:[`id`,`type`,`label`,`height`,`width`,`items`],supports:{initialData:!0,parentTypes:[`Manifest`],parentFields:[`items`]}});q({...Yo,id:`@exhibitions/image-slide-creator-left`,label:`Image (Left)`,summary:`An image with text on the left.`,icon:R(`div`,{children:`IMAGE (LEFT)`}),create:(e,t)=>Qo({...e,type:`left`},t)}),q({...Yo,id:`@exhibitions/image-slide-creator-right`,label:`Image (Right)`,summary:`An image with text on the right.`,icon:R(`div`,{children:`IMAGE (RIGHT)`}),create:(e,t)=>Qo({...e,type:`right`},t)}),q({...Yo,id:`@exhibitions/image-slide-creator-bottom`,label:`Image (Bottom)`,summary:`An image with text at the bottom.`,icon:R(`div`,{children:`IMAGE (BOTTOM)`}),create:(e,t)=>Qo({...e,type:`bottom`},t)});const Xo=q({...Yo,id:`@exhibitions/slideshow-image-only-creator`,label:`Multiple images`,summary:`An empty slideshow slide`,tags:[`exhibition-slideshow-slide`],create:(e,t)=>Qo({...e,behavior:[`w-12`,`h-8`,`image`],height:e.height||1080,width:e.width||1920,type:`default`},t)}),Zo=q({...Yo,id:`@exhibitions/slideshow-image-text-creator`,label:`Multiple images with text`,summary:`An empty slideshow slide, with text`,tags:[`exhibition-slideshow-slide`],create:(e,t)=>Qo({...e,behavior:[`w-12`,`h-8`,`right`],height:e.height||1080,width:e.width||1920,type:`right`},t)});q({...Yo,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)=>Qo({...e,behavior:[`w-12`,`h-8`,`compact-deck`],height:e.height||1080,width:e.width||1920,type:`default`},t)});function Qo(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,s=e.imageSlideBehavior||t.options.initialData?.imageSlideBehavior;if(e.behavior)a.push(...e.behavior);else if(s)a.push(...s);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?8: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`)}e.items?.length||a.push(`multi-image`);let c={...e.metadata?{metadata:e.metadata}:{},...e.requiredStatement?{requiredStatement:e.requiredStatement}:{},...e.rights?{rights:e.rights}:{},...e.partOf?{partOf:e.partOf}:{}};return t.embed({...Kt,id:n,behavior:a,label:e.label||{en:[`Untitled`]},...c,height:e.height||4e3,duration:e.duration,width:e.width||o,items:[t.embed({...Gt,id:r,type:`AnnotationPage`,items:e.items?e.items:[]})],annotations:[t.embed({...Gt,id:i,type:`AnnotationPage`,items:[]})]})}const $o=q({...Vt,id:`@exhibitions/image-url-creator`,create:es,tags:[`exhibition-slide`,`exhibition-slideshow-slide`],label:`Image from URL`,summary:`Image from URL`,resourceType:`Canvas`,supports:{initialData:!0,parentTypes:[`Manifest`],parentFields:[`items`]}});async function es(e,t){let n=t.generateId(`canvas`);t.generateId(`annotation-page`,{id:n,type:`Canvas`});let r=t.generateId(`annotation`),i=await Lt(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 Lt(t,`Manifest`,`items`,`@exhibitions/image-slide-creator`)({canvasId:n,width:a,height:o,type:`default`,items:[s],imageSlideBehavior:t.options.initialData?.imageSlideBehavior})}const ts={fullpage:`Full page`,slideshow:`Slideshow`,scroll:`Scroll`},ns={templates:to,onboarding:{id:`exhibition-template-selection`,mode:`per-resource`,title:`Choose exhibition format`,summary:`Pick a starting point for this exhibition.`,openLabel:`Exhibition formats`,dismissLabel:`Skip for now`,primaryLabel:`Start building`,renderPreviewButton:e=>R(is,{...e}),renderBody:({templates:e,selectedTemplateId:t,setSelectedTemplateId:n,dismiss:r})=>R(`div`,{className:`grid gap-3 sm:grid-cols-3`,children:e.length?e.map(e=>{let i=t===e.id;return z(`article`,{className:[`relative overflow-hidden rounded border-2 bg-white`,i?`border-me-primary-500`:`border-gray-200`].join(` `),children:[R(G,{"aria-label":`Use ${e.label} format`,"aria-pressed":i,className:`absolute inset-0 z-10 cursor-pointer rounded outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-me-primary-500`,onPress:()=>{n(e.id),r()}}),R(`img`,{src:e.thumbnailUrl,alt:``,className:`aspect-video w-full bg-gray-100 object-cover`}),z(`div`,{className:`pointer-events-none flex flex-col gap-2 p-3`,children:[z(`div`,{children:[R(`h3`,{className:`text-sm font-semibold text-gray-900`,children:e.label}),R(`p`,{className:`mt-1 text-xs uppercase tracking-normal text-gray-500`,children:e.type})]}),R(`p`,{className:`text-sm text-gray-600`,children:e.summary}),R(`a`,{href:e.previewUrl,target:`_blank`,rel:`noreferrer`,className:`pointer-events-auto relative z-20 inline-flex w-fit items-center rounded py-0.5 text-sm font-medium text-me-700 hover:text-me-900 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-me-primary-500 focus-visible:ring-offset-2`,children:`Preview`})]})]},e.id)}):R(`p`,{className:`text-sm text-gray-600`,children:`No exhibition formats are available for this editor.`})})}};function rs(e,t){let n=new URL(e);return n.searchParams.set(`manifest`,t),n.toString()}function is({downloadEnabled:e,fileName:s,preview:c,showOnboardingPreviewHint:l,onOnboardingPreviewHintClose:u}){let{actions:d,configs:p,active:h}=E(),g=F(),_=m(),v=f(),y=x(),b=T(),{selectedTemplate:S,templates:C}=ee(),w=Nn(),D=p.filter(e=>e.type===`external-manifest-preview`),O=Mn(C,S,w),te=D.find(e=>e.id===_.defaultPreview)||D.find(e=>!e.id.includes(`theseus`)&&e.id!==`raw-manifest`)||D[0],k=D.find(e=>e.id===`theseus`||e.id===`theseus-viewer`),A=D.find(e=>e.id===`raw-manifest`);async function ne(e){let t=await d.getPreviewLink();t&&window.open(rs(e.previewUrl,t),e.id)}function j(e){d.selectPreview(e)}function re(){y.leftPanel.open({id:`@exhibitions/theme-panel`})}return!O.length&&!c?.mainAction&&!c?.actions?.length?null:z(L,{children:[e?R(`div`,{className:`mr-4`,children:R(Ke,{fileName:s||`manifest.json`,label:`Download manifest`,getData:()=>_.export&&_.export.version===2?JSON.stringify(g.toPresentation2(v),null,2):JSON.stringify(g.toPresentation3(v),null,2)})}):null,z(n,{style:{width:`auto`,minWidth:`10em`},children:[z(r,{as:G,"data-preview-action":c?.mainAction?.id,isDisabled:c?.mainAction?.disabled,onPress:c?.mainAction?.onClick||re,children:[c?.mainAction?.label||`Preview`,w?z(`span`,{className:`ml-1 whitespace-nowrap opacity-75`,children:[`· `,ts[w.type]]}):null]}),z(ft,{children:[R(t,{as:G,$open:!1,"aria-label":`Choose preview`,className:`exhibition-preview-preset-menu`,children:R($a,{})}),R(pt,{placement:`bottom right`,className:`z-50`,children:z(i,{as:ut,$open:!0,className:`outline-none`,style:{position:`relative`,top:`auto`,left:`auto`,marginTop:0,width:`15em`},children:[z(dt,{className:`flex cursor-pointer items-center border-b border-gray-100 p-1 outline-none hover:bg-gray-50 focus:bg-gray-50`,onAction:b,children:[R(`span`,{className:`mx-2 flex h-4 w-8 shrink-0 items-center justify-center`,children:R(as,{className:`h-4 w-4 text-gray-500`})}),R(a,{children:`Change exhibition format`})]}),O.map(e=>{let t=w?.id===e.id;return z(dt,{"aria-current":t?`true`:void 0,className:`flex cursor-pointer items-center p-1 outline-none hover:bg-gray-50 focus:bg-gray-50`,onAction:()=>ne(e),children:[R(o,{$status:t?`active`:`available`}),z(a,{children:[e.label,t?` (current)`:``]})]},e.id)}),c?.actions?.map(e=>z(dt,{className:`flex cursor-pointer items-center p-1 outline-none hover:bg-gray-50 focus:bg-gray-50`,isDisabled:e.disabled,onAction:e.onClick,children:[R(o,{$status:e.status||`available`}),R(a,{children:e.label})]},e.id)),k&&k.id!==te?.id?z(dt,{className:`flex cursor-pointer items-center p-1 outline-none hover:bg-gray-50 focus:bg-gray-50`,onAction:()=>j(k.id),children:[R(o,{$status:h.includes(k.id)?`configured`:`available`}),R(a,{children:k.label})]}):null,A&&A.id!==te?.id?z(dt,{className:`flex cursor-pointer items-center p-1 outline-none hover:bg-gray-50 focus:bg-gray-50`,onAction:()=>j(A.id),children:[R(o,{$status:h.includes(A.id)?`configured`:`available`}),R(a,{children:A.label})]}):null]})})]})]}),R(et,{id:`exhibition-preview-preset-menu`,forceStart:l,onClose:u,lastButtonLabel:`Dismiss`,steps:[{target:`.exhibition-preview-preset-menu`,placement:`bottom`,disableBeacon:!0,content:`You can change the exhibition format again from this preview menu.`}]})]})}function as(e){return R(`svg`,{xmlns:`http://www.w3.org/2000/svg`,width:`1em`,height:`1em`,viewBox:`0 0 24 24`,...e,children:z(`g`,{fill:`none`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:`2`,children:[R(`path`,{d:`M3 17h2.397a5 5 0 0 0 4.096-2.133l.177-.253m3.66-5.227l.177-.254A5 5 0 0 1 17.603 7H21`}),R(`path`,{d:`m18 4l3 3l-3 3M3 7h2.397a5 5 0 0 1 4.096 2.133l4.014 5.734A5 5 0 0 0 17.603 17H21`}),R(`path`,{d:`m18 20l3-3l-3-3`})]})})}const os=q({id:`@exhibitions/info-box-creator`,create:cs,label:`Info box`,summary:`A text panel for an exhibition`,icon:z(`svg`,{xmlns:`http://www.w3.org/2000/svg`,width:`1em`,height:`1em`,viewBox:`0 0 24 24`,children:[R(`title`,{children:`Info box`}),R(`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:{initialData:!0,parentTypes:[`Manifest`],parentFields:[`items`]}}),ss=q({...os,id:`@exhibitions/slideshow-long-editorial-creator`,label:`Long editorial`,summary:`A text-led slideshow slide.`,tags:[`exhibition-slideshow-slide`],create:(e,t)=>cs({...e,behavior:[`w-12`,`h-8`,`info`],height:e.height||1080,width:e.width||1920},t)});async function cs(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={...Wt,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({...Kt,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 ls=q({...Ht,id:`@exhibitions/video-creator`,create:ds,tags:[`video`,`exhibition-slide`],label:`Video`,summary:`A video for an exhibition`,resourceType:`Canvas`,resourceFields:[`id`,`type`,`label`,`height`,`width`,`items`],supports:{initialData:!0,parentTypes:[`Manifest`],parentFields:[`items`]}}),us=q({...ls,id:`@exhibitions/slideshow-video-creator`,label:`Video`,summary:`A video slide for a slideshow exhibition.`,tags:[`exhibition-slideshow-slide`],create:(e,t)=>ds({...e,behavior:[`w-12`,`h-8`,`image`],height:e.height||1080,slideType:`default`,width:e.width||1920},t)});async function ds(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 Lt(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 fs=q({...Ut,id:`@exhibitions/youtube-creator`,create:ms,tags:[`video`,`exhibition-slide`],label:`YouTube`,summary:`A YouTube for an exhibition`}),ps=q({...fs,id:`@exhibitions/slideshow-youtube-creator`,label:`YouTube`,summary:`A YouTube slide for a slideshow exhibition.`,tags:[`exhibition-slideshow-slide`]});async function ms(e,t){let n=ge(e.youtubeUrl),r=t.generateId(`canvas`),i=t.generateId(`annotation-page`,{id:r,type:`Canvas`}),a=t.embed({id:t.generateId(`annotation`,{id:i,type:`AnnotationPage`}),type:`Annotation`,motivation:`painting`,body:[Rt(e,t)],target:{type:`SpecificResource`,source:{id:r,type:`Canvas`}}}),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({...Kt,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 hs(e){return!Jt(e)}function gs(e,t,n){let r=t>0&&n>0?Math.max(1,Math.min(12,Math.round(t/n*12))):4;return[...e.filter(e=>!e.startsWith(`w-`)&&!e.startsWith(`h-`)),`w-12`,`h-${r}`]}function _s({misplacedSplash:e=!1}){let t=v(),n=()=>{let n=t.technical.width.get(),r=t.technical.height.get(),i=t.descriptive.summary,a=t.technical.behavior,o=a.get(),s=gs(e?o.filter(e=>e!==`splash`):o,n,r);hs(i.get())&&i.set({en:[`Summary of image`]}),(s.length!==o.length||s.some((e,t)=>e!==o[t]))&&a.set(s)};return z(`div`,{className:`flex flex-col items-center gap-4 border-me-100 border-2 p-4 rounded`,children:[e?`Opening cover canvases must be first. Apply defaults to use this canvas as a regular exhibition slide.`:`This canvas was not created in the exhibition editor. Do you want to apply default settings?`,R(W,{onPress:()=>n(),children:`Apply defaults`})]})}function vs({editor:e}){let t=e.get()||``;return z(j,{$wide:!0,id:e.containerId(),children:[R(ie,{htmlFor:e.focusId(),children:`Background colour`}),z(`div`,{className:`flex min-w-0 items-center gap-2`,children:[R(`input`,{id:e.focusId(),"aria-label":`Choose background colour`,className:`h-9 w-12 shrink-0 cursor-pointer rounded border border-[#dcd5ce] bg-white p-1`,type:`color`,value:ys(t),onChange:t=>e.set(t.target.value)}),R(ne,{"aria-label":`Background colour value`,placeholder:`No colour`,value:t,onChange:t=>e.set(t.target.value||null)}),t?R(`button`,{type:`button`,className:`rounded border border-[#dcd5ce] bg-white px-3 py-2 text-sm font-semibold text-[#332f2c]`,onClick:()=>e.set(null),children:`Remove`}):null]}),R(`p`,{className:`mt-1 text-xs text-[#6a625c]`,children:`Shown behind the image and text for this section.`})]})}function ys(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 bs(e,t){if(!t?.behavior?.includes(`multi-image`))return null;let n=Ln(e,t);if(n.length!==1)return null;let r=n[0],i=Array.isArray(r?.body)?r.body[0]:r?.body,a=i?.type===`SpecificResource`?i.selector:null,o=a?.region?.split(`,`).map(Number);return r?.target?.selector&&qn(e,r)?.type===`Image`&&[`ImageApiSelector`,`iiif:ImageApiSelector`].includes(a?.type)&&o?.length===4&&o.every(Number.isFinite)&&o[2]>0&&o[3]>0?r:null}function xs(){let e=N(),t=F(),n=I((t,n)=>bs(n,e),[e?.id,e?.items]),r=y(n?{id:n.id,type:`Annotation`}:void 0,{allowNull:!0});return!e||!n||!r?.annotation?null:z(`div`,{className:`mb-6 rounded-md border border-amber-300 bg-amber-50 p-4 text-sm text-amber-950`,children:[R(`p`,{className:`mb-3`,children:`This slide has one image positioned for a multi-image layout. Rescale the slide to fit it.`}),R(G,{className:`rounded-md bg-amber-900 px-3 py-2 font-semibold text-white hover:bg-amber-800`,onPress:()=>ve(t,e,r.annotation),children:`Rescale for current image`})]})}const Ss={id:`@exhibition/summary-editor`,supports:{edit:!0,properties:[`summary`,`requiredStatement`],resourceTypes:[`Canvas`],custom:(e,t)=>{let{resource:n}=e;return br(n,t)?!Va(e,t)&&!xr(n,t):!1}},label:`Text content`,component:()=>R(Cs,{})};function Cs(){return R(tt,{children:R(nt,{padding:!0,children:R(ws,{})})})}function ws(){let e=X(e=>e.setCenterPanelMode),t=N();return B(()=>{e(`preview`)},[e]),t?z(s,{resource:t,children:[R(oe,{dispatchType:`label`}),R(Es,{resource:t}),R(Ts,{})]}):null}function Ts(){let{descriptive:e}=v(),{requiredStatement:t}=e,n=t.get();return z(j,{$wide:!0,id:t.containerId(),children:[R(ie,{htmlFor:t.focusId(),children:`Required statement`}),z(re,{id:t.focusId(),children:[R(ae,{focusId:`${t.focusId()}_label`,label:`Label`,fields:n?.label||{none:[]},onSave:e=>t.updateLabel(e.toInternationalString())}),R(ae,{focusId:`${t.focusId()}_value`,label:`Value`,fields:n?.value||{none:[]},onSave:e=>t.update(e.toInternationalString())})]})]})}function Es({resource:e}){let t=F(),n=V(()=>oa(e.summary),[e.summary]);return R(fe,{label:`summary`,metadataKey:`summary`,fields:n,onSave:n=>{t.modifyEntityField(e,`summary`,sa(n.toInternationalString()))}},e.id)}const Ds={id:`@exhibition/right-panel-editor`,supports:{edit:!0,properties:[`label`,`summary`],resourceTypes:[`Canvas`],custom:({resource:e},t)=>br(e,t)?!xr(e,t):!1},label:`Exhibition`,component:()=>R(Os,{})};function Os(){return R(tt,{children:R(nt,{padding:!0,children:R(ks,{})})})}function ks(){let e=X(e=>e.setCenterPanelMode),t=N(),n=F(),r=w(),i=g(),{structural:a,technical:o}=v(),{items:c}=a,l=o.behavior.get()||[],u=c.get()[0],[,d]=h(u?{id:u.id,type:`AnnotationPage`}:void 0,`items`,`Annotation`,t?{id:t.id,type:`Canvas`}:void 0,{isPainting:!0}),f=Cr(t),p=l.includes(`info`),m=Ba(t,r.structural.items.get()),_=l.includes(`splash`)&&!m,y=zn(n,t),b=ai(l,I((e,n)=>t?Rn(n,t).length>0:!1,[t?.id,t?.annotations?.[0]?.id]));return B(()=>{e(`preview`)},[e]),!t||!u||!i?R(`div`,{className:`p-8`,children:`Canvas, page, or resource not found`}):p?z(s,{resource:t,children:[!f||_?R(_s,{misplacedSplash:_}):null,R(js,{canvas:t}),y?R(Ms,{canvas:t}):null]}):z(s,{resource:t,children:[!f||_?R(_s,{misplacedSplash:_}):null,R(xs,{}),m?R(As,{manifestEditor:r}):R(js,{canvas:t}),R(vs,{editor:o.backgroundColor}),b.layoutOptions.length||b.isSlideshow&&ki(l)?R(j,{$wide:!0,children:z(`div`,{children:[R(`div`,{className:`exhibition-workbench-muted mb-3 text-sm font-semibold`,children:b.isSlideshow&&ki(l)?`Text overlay position`:`Text placement`}),b.isSlideshow&&ki(l)?R(Or,{value:Ai(l),onChange:e=>o.behavior.set(ji(l,e))}):R(`div`,{className:`grid grid-cols-2 gap-3`,children:b.layoutOptions.map(e=>R(vi,{preset:e.value,label:e.label,selected:Ei(l)===e.value,onClick:()=>{o.behavior.set(Di(l,e.value,t?{width:t.width,height:t.height}:void 0)),t&&Vi(n,t,e.value)}},e.value))}),R(Ns,{canvas:t,tabId:`slide-behaviors`,label:`More display options`})]})}):null,y&&!m?R(Ms,{canvas:t}):null,R(Ee,{annotationPage:u.id,children:R(le,{onCreate:()=>{e(`edit`),d.createFiltered(`image`,void 0,{skipEditingOnCreate:!0})}})})]})}function As({manifestEditor:e}){let t={...e.ref(),summary:e.descriptive.summary.get()};return z(s,{resource:t,children:[R(oe,{dispatchType:`label`}),R(Es,{resource:t})]})}function js({canvas:e}){let{edit:t}=x(),n=H(null),[r,i]=U(!1),[a,o]=U(!1),s=Ps(e.label)||`Untitled`,c=ca(e.summary);return B(()=>{let e=n.current;if(!e){o(!1);return}o(e.scrollHeight>e.clientHeight+1)},[c,r]),R(j,{$wide:!0,children:z(`div`,{className:`rounded-md border border-[#dcd5ce] bg-[#f8f6f3] p-4`,children:[z(`div`,{className:`flex items-start justify-between gap-3`,children:[z(`div`,{className:`min-w-0`,children:[R(`div`,{className:`text-xs font-semibold uppercase text-[#6a625c]`,children:`Label`}),R(`div`,{className:`mt-1 break-words text-base font-semibold text-[#25211f]`,children:s})]}),R(`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`})]}),z(`div`,{className:`mt-5`,children:[R(`div`,{className:`text-xs font-semibold uppercase text-[#6a625c]`,children:`Summary`}),R(`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?R(`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}}):R(`span`,{className:`text-[#6a625c]`,children:`No summary added.`})}),a||r?R(`button`,{type:`button`,className:`mt-2 text-sm font-semibold text-[#b84c74]`,onClick:()=>i(e=>!e),children:r?`Read less`:`Read more`}):null]})]})})}function Ms({canvas:e}){let t=F(),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 R(j,{$wide:!0,children:z(`div`,{className:`rounded-md border border-[#dcd5ce] bg-white p-4`,children:[R(`div`,{className:`text-sm font-semibold text-[#25211f]`,children:`Tour steps`}),R(`div`,{className:`mt-1 text-sm text-[#6a625c]`,children:a}),R(Ns,{canvas:e,tabId:`@exhibition/tour-steps`,label:i===0?`Open Tour steps tab to add one`:`Open Tour steps tab`})]})})}function Ns({canvas:e,tabId:t,label:n}){let{edit:r}=x();return z(`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:[R(`span`,{className:`text-left text-sm font-semibold`,children:n}),R(We,{})]})}function Ps(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(` `):``:``}function Fs(e,t=e=>e){let n=Array.isArray(e?.motivation)?e.motivation:[e?.motivation],r=Array.isArray(e?.body)?e.body:e?.body?[e.body]:[];if(!n.includes(`painting`)||r.length!==1)return null;let i=r[0];if(!e?.id||i?.type===`Choice`||i?.source?.type===`Choice`)return null;let a=i?.type===`SpecificResource`,o=a?i.selector:void 0;if(o&&![`ImageApiSelector`,`iiif:ImageApiSelector`].includes(o.type))return null;let s=a?i.source:i,c=t(s)||s;if(c?.type!==`Image`)return null;let l=(Array.isArray(c.service)?c.service:c.service?[c.service]:[]).map(e=>t(e)||e).find(e=>bt(e)&&(e.id||e[`@id`]));return l?{annotation:e,annotationRef:{id:e.id,type:`Annotation`},body:a?i:{type:`SpecificResource`,source:s},selector:o||{type:`ImageApiSelector`},source:c,service:l}:null}function Is(e){if(typeof e!=`string`)return null;let t=e.split(`,`).map(Number);if(t.length!==4||!t.every(Number.isFinite))return null;let n=t[0],r=t[1],i=t[2],a=t[3];return i<=0||a<=0?null:{x:n,y:r,width:i,height:a}}function Ls(e){let t={x:Math.max(0,Math.round(e.x)),y:Math.max(0,Math.round(e.y)),width:Math.round(e.width),height:Math.round(e.height)};if(t.width<=0||t.height<=0)throw Error(`The crop must have a positive width and height`);return t}function Rs(e,t){return Bs(e,Ls(t),e.selector.rotation)}function zs(e,t){let n=Is(e.selector.region),r=n||Xs(e.service);if(!r)throw Error(`The image service did not provide full image dimensions`);return Bs(e,n,ac(t),r)}function Bs(e,t,n,r=t){let i={...e.selector,...n===void 0?{}:{rotation:String(n)}};t?i.region=$s(t):delete i.region;let a=nc(e,t,n),o=Math.min(512,r.width),s=nc(e,t,n,o),c=Ks(r.width,r.height,n);return{region:t,imageDimensions:c,thumbnailDimensions:Ks(o,Math.round(r.height/r.width*o),n),selector:i,source:{...e.source,id:a,...e.source[`@id`]?{"@id":a}:{},width:c.width,height:c.height},sourceId:a,thumbnailId:s}}function Vs(e,t,n,r){return!r||r.cancelled||!r.boundingBox?null:Us(e,t,n,r.boundingBox)}function Hs(e,t,n){let r=Array.isArray(e?.behavior)?e.behavior:e?.behavior?[e.behavior]:[];return(Array.isArray(t?.target)?t.target:t?.target?[t.target]:[]).some(t=>ec(t,e))&&n===1&&!r.includes(`multi-image`)}function Us(e,t,n,r){return Gs(e,t,n,Rs(t,r))}function Ws(e,t,n,r){return Gs(e,t,n,zs(t,r))}function Gs(e,t,n,r){let i=sc(e,n),a=Hs(n,t.annotation,i);return e.batch(()=>{e.dispatch(It({entities:{ContentResource:{[r.sourceId]:r.source,[r.thumbnailId]:{id:r.thumbnailId,type:`Image`,format:`image/jpeg`,width:r.thumbnailDimensions.width,height:r.thumbnailDimensions.height,service:[t.service]}}}})),e.dispatch(Ft({mapping:{[r.sourceId]:`ContentResource`,[r.thumbnailId]:`ContentResource`}})),e.modifyEntityField(t.annotationRef,`body`,[{...t.body,selector:r.selector,source:{id:r.sourceId,type:`ContentResource`}}]),e.modifyEntityField({id:n.id,type:`Canvas`},`thumbnail`,[{id:r.thumbnailId,type:`ContentResource`}]),a&&(e.modifyEntityField({id:n.id,type:`Canvas`},`width`,r.imageDimensions.width),e.modifyEntityField({id:n.id,type:`Canvas`},`height`,r.imageDimensions.height),e.modifyEntityField(t.annotationRef,`target`,tc(t.annotation.target,n)))}),r}function Ks(e,t,n){let r=Number(String(n??0).replace(/^!/,``)),i=Number.isFinite(r)?(r%360+360)%360:0;return i===90||i===270?{width:t,height:e}:{width:e,height:t}}function qs(e,t,n){switch(ac(n)){case 90:return{x:t.height-e.y-e.height,y:e.x,width:e.height,height:e.width};case 180:return{x:t.width-e.x-e.width,y:t.height-e.y-e.height,width:e.width,height:e.height};case 270:return{x:e.y,y:t.width-e.x-e.width,width:e.height,height:e.width};default:return{...e}}}function Js(e,t,n){return qs(String(n??``).startsWith(`!`)?{...e,x:t.width-e.x-e.width}:e,t,n)}function Ys(e,t,n){let r=qs(e,Ks(t.width,t.height,n),360-ac(n));return String(n??``).startsWith(`!`)?{...r,x:t.width-r.x-r.width}:r}function Xs(e){let t=Number(e?.width),n=Number(e?.height);return t>0&&n>0?{width:t,height:n}:null}async function Zs(e,t=fetch){if(Xs(e))return e;let n=e?.id||e?.[`@id`];if(!n)throw Error(`The image service has no identifier`);let r=await t(_t(n));if(!r.ok)throw Error(`The image service returned ${r.status}`);let i=await r.json(),a={...e,...i,id:i.id||i[`@id`]||n};if(!Xs(a))throw Error(`The image service did not provide full image dimensions`);return a}function Qs(e,t=0){let n=vt(oc(e));return yt({...n,type:`image`,region:{full:!0},size:{max:!0,confined:!1,upscaled:!1},rotation:ic(t),quality:`default`,format:`jpg`})}function $s(e){return`${e.x},${e.y},${e.width},${e.height}`}function ec(e,t){let n=e?.type===`SpecificResource`?e.source:e,r=typeof n==`string`?n:n?.id;if(typeof r!=`string`)return!1;let[i,a]=r.split(`#`,2);if(i!==t.id)return!1;let o=Array.isArray(e?.selector)?e.selector:e?.selector?[e.selector]:[];if(!o.length&&!a)return!0;let s=o.find(e=>e?.spatial||typeof e?.value==`string`&&e.value.startsWith(`xywh=`)),c=s?.spatial,l=a||s?.value;if(!c&&typeof l==`string`&&l.startsWith(`xywh=`)){let[e,t,n,r]=l.replace(/^xywh=(?:pixel:)?/,``).split(/[,&]/).slice(0,4).map(Number);c={x:e,y:t,width:n,height:r}}return c?Number(c?.x)===0&&Number(c?.y)===0&&Number(c?.width)===Number(t?.width)&&Number(c?.height)===Number(t?.height):!1}function tc(e,t){return Array.isArray(e)?e.map(e=>ec(e,t)?tc(e,t):e):typeof e==`string`?t.id:e?.type===`SpecificResource`?{...e,source:typeof e.source==`string`?t.id:e.source?.id?.includes(`#`)?{...e.source,id:t.id}:e.source,selector:void 0}:e}function nc(e,t,n,r){let i=rc(e.source.id),a=i||vt(oc(e.service)),o=n===void 0?i?.rotation||{angle:0}:ic(n);return yt({...a,type:`image`,region:t?{x:t.x,y:t.y,w:t.width,h:t.height}:{full:!0},size:r?{max:!1,confined:!1,upscaled:!1,width:r}:{max:!0,confined:!1,upscaled:!1},rotation:o,quality:i?.quality||`default`,format:i?.format||`jpg`})}function rc(e){if(typeof e!=`string`)return null;try{let t=xt(e);return t.type===`image`?t:null}catch{return null}}function ic(e){let t=String(e??0),n=Number(t.replace(/^!/,``));return{angle:Number.isFinite(n)?n:0,...t.startsWith(`!`)?{mirror:!0}:{}}}function ac(e){let t=Number(String(e??0).replace(/^!/,``)),n=Number.isFinite(t)?(t%360+360)%360:0;return[0,90,180,270].includes(n)?n:0}function oc(e){return{...e,id:e.id||e[`@id`],type:e.type||e[`@type`]}}function sc(e,t){let n=0;for(let r of t?.items||[]){let t=e.get(r,{skipSelfReturn:!1})||r;for(let r of t?.items||[]){let t=e.get(r,{skipSelfReturn:!1})||r;(Array.isArray(t?.motivation)?t.motivation:[t?.motivation]).includes(`painting`)&&n++}}return n}const cc={id:`@exhibition/image-crop-editor`,label:`Media`,supports:{edit:!0,sortKey:`annotation-target`,properties:[`body`],resourceTypes:[`Annotation`],custom:({resource:e},t)=>{let n=t.get(e,{skipSelfReturn:!1});return!!(n&&Fs(n,e=>_c(t,e)))}},component:()=>R(lc,{})};function lc(){let e=F(),t=v(),n=N({id:t.annotation.target.getSourceId()}),r=e.get(t.ref(),{skipSelfReturn:!1}),i=r?Fs(r,t=>_c(e,t)):null,a=Is(i?.selector.region),o=H(null),[s,c]=U(!1),[l,u]=U(!1),[d,f]=U(null),p=ac(i?.selector.rotation),m=async t=>{if(!(!i||!n||t===p)){u(!0),f(null);try{let r=await Zs(i.service);Ws(e,{...i,service:r},n,t)}catch(e){f(e instanceof Error?e.message:`The rotation could not be saved`)}finally{u(!1)}}},h=()=>{c(!1),requestAnimationFrame(()=>o.current?.querySelector(`button`)?.focus())};if(!i||!n)return null;let g=z(`div`,{className:`flex flex-col gap-3`,children:[a?z(`dl`,{className:`grid grid-cols-[auto_1fr] gap-x-3 gap-y-1 rounded border border-gray-200 bg-gray-50 p-3 text-sm`,children:[R(`dt`,{className:`font-semibold text-gray-700`,children:`Position`}),z(`dd`,{className:`text-gray-600`,children:[a.x,`, `,a.y]}),R(`dt`,{className:`font-semibold text-gray-700`,children:`Size`}),z(`dd`,{className:`text-gray-600`,children:[a.width,` × `,a.height]})]}):R(`p`,{className:`rounded border border-gray-200 bg-gray-50 p-3 text-sm text-gray-600`,children:`This image currently uses the full image. Create a crop to select a smaller visible region.`}),R(`span`,{ref:o,children:R(W,{onPress:()=>c(!0),children:a?`Edit crop`:`Create crop`})})]}),_=z(`div`,{className:`flex flex-col gap-3`,children:[R(`div`,{className:`grid grid-cols-4 gap-2`,"aria-label":`Image rotation`,children:[0,90,180,270].map(e=>z(W,{"aria-pressed":e===p,primary:e===p,isDisabled:l,onPress:()=>m(e),children:[e,`°`]},e))}),d?R(`p`,{className:`text-sm text-red-700`,children:d}):null]});return z(L,{children:[R(ce,{additionalSections:[{label:`Image crop`,initialOpen:!!a,children:g},{label:`Image rotation`,initialOpen:p!==0,children:_}]}),s?R(uc,{crop:i,canvas:n,onClose:h,vault:e}):null]})}function uc({crop:e,canvas:t,vault:n,onClose:r}){let[i,a]=U(()=>Xs(e.service)?e.service:null),[o,s]=U(null),[c,l]=U(!1),[u,d]=U(!1);B(()=>{let t=!0;return Zs(e.service).then(e=>{t&&a(e)}).catch(e=>{t&&s(e instanceof Error?e.message:`Unable to load the image service`)}),()=>{t=!1}},[e.service]);let f=Xs(i),p=Is(e.selector.region)||(f?{x:0,y:0,width:f.width,height:f.height}:null),m=f?Ks(f.width,f.height,e.selector.rotation):null,h=f&&p?Js(p,f,e.selector.rotation):null,g=i?.id||i?.[`@id`],_=Be(async a=>{if(a.cancelled||!a.boundingBox||!f)return l(!1);d(!0),s(null);try{Vs(n,{...e,service:i},t,{...a,boundingBox:Ys(a.boundingBox,f,e.selector.rotation)}),r()}catch(e){s(e instanceof Error?e.message:`The crop could not be saved`),d(!1)}},[t,e,r,i,n]),v=Be(e=>s(e),[]);return R(Qe,{title:Is(e.selector.region)?`Edit image crop`:`Create image crop`,onClose:r,className:`max-w-5xl`,height:`80vh`,disableAnimation:!0,children:z(`div`,{className:`flex min-h-0 flex-1 flex-col p-4`,children:[o?R(gc,{message:o}):f&&m&&h&&g?z(`div`,{className:`relative min-h-0 flex-1 overflow-hidden rounded border border-gray-200 bg-gray-950`,children:[R(dc,{crop:e,service:i,dimensions:m,initialRegion:h,editing:c,onEditingChange:l,onResolve:_,onError:v}),u?R(`div`,{className:`absolute inset-0 z-20 grid place-items-center bg-black/40 text-sm font-semibold text-white`,children:`Saving crop…`}):null]}):R(`div`,{className:`grid min-h-[20rem] flex-1 place-items-center text-sm text-gray-500`,children:`Loading full image…`}),R(`div`,{className:`mt-3 flex justify-end`,children:R(W,{onPress:r,children:`Cancel`})})]})})}function dc({crop:e,service:t,dimensions:n,initialRegion:r,editing:i,onEditingChange:a,onResolve:o,onError:s}){let c=H(()=>void 0),l=V(()=>fc(e,t,n,e.selector.rotation),[e.annotationRef.id,e.selector.rotation,n.height,n.width,t]),u=V(()=>{let e=new qt;return e.loadManifestSync(l.id,l),e},[l]),d=V(()=>function(){return R(pc,{bounds:{x:0,y:0,width:n.width,height:n.height},initialRegion:r,changeCropRef:c,onEditingChange:a,onResolve:o,onError:s})},[n.height,n.width,r.height,r.width,r.x,r.y,a,s,o]);return R(Ae,{vault:u,children:R(De.Provider,{value:null,children:R(ke,{manifest:l.id,startCanvas:l.items[0].id,pagingEnabled:!1,padding:0,components:{ViewerControls:d},annotations:i?null:R(mc,{region:r,onChange:()=>c.current()})})})})}function fc(e,t,n,r){let i=`${e.annotationRef.id}/crop-editor/manifest`,a=`${i}/canvas`,o=`${a}/painting-page`;return{"@context":`http://iiif.io/api/presentation/3/context.json`,id:i,type:`Manifest`,label:{en:[`Image crop editor`]},items:[{id:a,type:`Canvas`,width:n.width,height:n.height,items:[{id:o,type:`AnnotationPage`,items:[{id:`${o}/painting`,type:`Annotation`,motivation:`painting`,target:a,body:{id:Qs(t,r),type:`Image`,format:`image/jpeg`,width:n.width,height:n.height}}]}]}]}}function pc({bounds:e,initialRegion:t,changeCropRef:n,onEditingChange:r,onResolve:i,onError:a}){let o=V(()=>R(hc,{}),[]),{requestAnnotation:s,cancelRequest:c,requestId:l,isActive:u,busy:d}=Ie(),f=H(c);f.current=c,B(()=>()=>f.current(),[]);let p=()=>{r(!0),s({type:`box`,bounds:e,selector:t,annotationPopup:o}).then(e=>{if(e)return i(e);r(!1)}).catch(e=>{r(!1),a(e instanceof Error?e.message:`The crop editor could not be opened`)})};return n.current=p,u?null:R(`div`,{className:`absolute bottom-3 right-3 z-20 rounded bg-white p-2 shadow-lg`,children:R(W,{primary:!0,isDisabled:!l||d,onPress:p,children:`Change crop`})})}function mc({region:e,onChange:t}){return z(L,{children:[R(`box`,{html:!0,relativeStyle:!0,interactive:!1,target:e,style:{backgroundColor:`rgba(250, 204, 21, 0.18)`,border:`6px solid #facc15`,boxShadow:`inset 0 0 0 2px #111827, inset 0 0 20px rgba(250, 204, 21, 0.65)`,boxSizing:`border-box`}}),R(Yt,{target:e,relative:!0,interactive:!0,children:R(`button`,{type:`button`,"aria-label":`Change crop`,title:`Change crop`,onClick:t,className:`absolute inset-0 cursor-pointer bg-transparent text-left`,style:{border:0,padding:0},children:R(`span`,{className:`absolute left-2 top-2 rounded px-3 py-1.5 text-sm font-semibold shadow-lg`,style:{background:`rgba(17, 24, 39, 0.94)`,border:`2px solid #fde047`,color:`#fde047`},children:`Change crop`})})})]})}function hc(){let{saveAnnotation:e,cancelRequest:t}=Ne();return z(`div`,{className:`flex gap-2 rounded bg-white p-2 shadow-lg`,children:[R(W,{onPress:()=>t(),children:`Discard`}),R(W,{primary:!0,onPress:e,children:`Confirm`})]})}function gc({message:e}){return R(`div`,{role:`alert`,className:`grid min-h-[20rem] place-items-center rounded border border-red-200 bg-red-50 p-6 text-center text-sm text-red-800`,children:z(`div`,{children:[R(`div`,{className:`font-semibold`,children:`The full image could not be loaded`}),R(`div`,{className:`mt-1`,children:e})]})})}function _c(e,t){return t?.id&&e.get(t,{preserveSpecificResources:!0,skipSelfReturn:!1})||t}function vc(e){return R(`svg`,{xmlns:`http://www.w3.org/2000/svg`,width:`1em`,height:`1em`,viewBox:`0 0 24 24`,...e,children:R(`path`,{fill:`currentColor`,d:`M9 16.17L4.83 12l-1.42 1.41L9 19L21 7l-1.41-1.41z`})})}function yc({value:e,onChange:t}){let[n]=U(()=>ya(e)),r=H(e);return R(bc,{label:n.label??``,summary:n.summary,onChange:({label:e,summary:n})=>{r.current=ba(e,n),t(r.current)}})}function bc({label:e,summary:t,onChange:n}){let[r,i]=U(e),a=H(e),o=H(t),s=(e,t)=>{n({label:e,summary:t})};return z(`div`,{className:`flex flex-col gap-3`,children:[z(`label`,{className:`block text-sm font-medium text-slate-700`,children:[`Label`,R(`input`,{className:`mt-1 w-full rounded border border-slate-200 bg-white px-3 py-2 text-sm text-slate-900 outline-none focus:border-me-primary-400 focus:ring-1 focus:ring-me-primary-100`,value:r,onChange:e=>{let t=e.currentTarget.value;a.current=t,i(t),s(t,o.current)}})]}),z(`div`,{className:`block text-sm font-medium text-slate-700`,children:[`Summary`,R(`div`,{className:`mt-1`,children:R(Xe,{value:o.current,onChange:e=>{o.current=e,s(a.current,e)}})})]})]})}function xc({value:e}){let{label:t,summary:n}=ya(e);return R(Sc,{label:t??``,summary:n})}function Sc({label:e,summary:t}){return z(L,{children:[R(`div`,{className:`whitespace-nowrap overflow-ellipsis w-full overflow-x-hidden`,children:e||R(`span`,{className:`opacity-50`,children:`Untitled`})}),R(`div`,{className:`exhibition-tour-step-body text-gray-500 text-sm bg-white line-clamp-2 prose-headings:mt-1 prose-headings:mb-1 prose-sm`,dangerouslySetInnerHTML:{__html:la(t)}})]})}function Cc(){let e=p(),t=Re(e,e=>e.polygon),[n,r]=Pe(),{cancelRequest:i,saveAnnotation:a}=Ne();return z(`div`,{className:`border border-gray-300 hover:border-me-500 shadow-sm rounded bg-white relative`,children:[z(`div`,{className:`bg-me-primary-500 text-white p-2 m-1 rounded flex gap-2`,children:[R(it,{}),`Draw a box on the canvas`]}),R(`div`,{className:`p-3`,children:R(yc,{value:n.bodyValue??`<p>Description</p>`,onChange:e=>r({bodyValue:e})})}),z(`div`,{className:`flex gap-2 p-3`,children:[z(W,{isDisabled:t?.points.length===0,onPress:()=>a(),children:[R(vc,{}),` Finish editing`]}),z(W,{className:`gap-2 flex`,onPress:()=>i(),children:[R(Ge,{}),` Delete`]})]})]})}const wc=[{name:`Black`,value:`#121212`},{name:`Red`,value:`#E5484D`},{name:`Orange`,value:`#F76B15`},{name:`Amber`,value:`#FFB224`},{name:`Green`,value:`#46A758`},{name:`Teal`,value:`#12A594`},{name:`Blue`,value:`#0091FF`},{name:`Indigo`,value:`#3E63DD`},{name:`Purple`,value:`#8E4EC6`},{name:`Pink`,value:`#E93D82`}];function Tc(e){if(!e)return;let t=e.match(/#[0-9a-fA-F]{3,8}|rgba?\([^)]*\)|hsla?\([^)]*\)/);return t?t[0]:void 0}function Ec(e,t){return!e||!t?!1:e.toLowerCase()===t.toLowerCase()}function Dc(){let e=je(),t=y(e)?.annotation?.target;if(!e||!t)return null;let n=t.getBoxStyle(),r=Tc(n.border)??n.borderColor,i=e=>{e?t.setBorder(`3px solid ${e}`):t.setBorder(void 0)};return R(`span`,{title:`Choose a border colour for this tour step's highlight`,className:`inline-flex`,children:z(lt,{children:[R(G,{"aria-label":`Tour step border colour`,className:`flex-none w-6 h-6 rounded-full border border-gray-300 shadow-sm cursor-pointer outline-none focus-visible:ring-2 focus-visible:ring-me-500`,style:r?{backgroundColor:r}:{backgroundImage:`linear-gradient(45deg, transparent 45%, #d1d5db 45%, #d1d5db 55%, transparent 55%)`}}),R(pt,{placement:`bottom`,style:{zIndex:1000010},children:R(`div`,{className:`manifest-editor`,children:R(ct,{className:`outline-none bg-white rounded-lg shadow-lg border border-gray-200 p-2`,children:({close:e})=>z(L,{children:[R(`div`,{className:`text-[11px] font-semibold text-gray-500 px-1 pb-1.5`,children:`Border colour`}),R(`div`,{className:`grid grid-cols-5 gap-1.5`,children:wc.map(t=>{let n=Ec(r,t.value);return R(`button`,{type:`button`,"aria-label":t.name,title:t.name,onClick:()=>{i(t.value),e()},className:`w-6 h-6 rounded-full border cursor-pointer outline-none transition-transform hover:scale-110 focus-visible:ring-2 focus-visible:ring-me-500 ${n?`ring-2 ring-offset-1 ring-me-500 border-transparent`:`border-gray-300`}`,style:{backgroundColor:t.value}},t.value)})}),R(`button`,{type:`button`,title:`Remove the border colour`,onClick:()=>{i(null),e()},className:`mt-2 w-full text-[11px] text-gray-500 hover:text-me-500 rounded px-1 py-1 cursor-pointer outline-none focus-visible:ring-2 focus-visible:ring-me-500`,children:`None`})]})})})})]})})}function Oc(e){let t=Array.isArray(e)?e:[];return t.includes(`left`)?`left`:t.includes(`right`)?`right`:``}function kc(e,t){let n=(Array.isArray(e)?e:[]).filter(e=>e!==`left`&&e!==`right`);return t&&n.push(t),n}function Ac(e,t){let n=new Set(Tr.map(e=>e.value)),r=(Array.isArray(e)?e:[]).filter(e=>!n.has(e));return t&&r.push(t),r}function jc({annotation:e}){let t=F(),n=N(),r=Y(e=>e.selectTourStep),i=Oc(e?.behavior),a=ki(Array.isArray(n?.behavior)?n.behavior:[]),o=Array.isArray(e?.behavior)?e.behavior:[],s=o.some(e=>e.startsWith(`float-`)),c=Ai(o);if(!e?.id)return null;let l=()=>{r(e.id)},u=n=>{t.modifyEntityField({id:e.id,type:`Annotation`},`behavior`,kc(e.behavior,n)),l()};return z(`div`,{className:`flex flex-col gap-2`,children:[a?null:R(`div`,{className:`grid grid-cols-3 overflow-hidden rounded border border-slate-200 text-xs font-semibold`,children:[{value:``,label:`Default`},{value:`left`,label:`Left`},{value:`right`,label:`Right`}].map(e=>R(`button`,{type:`button`,className:i===e.value?`bg-me-primary-500 px-2 py-1 text-white`:`bg-white px-2 py-1 text-slate-700`,onClick:()=>u(e.value),children:e.label},e.label))}),a?R(Mc,{value:s?c:``,onChange:n=>{t.modifyEntityField({id:e.id,type:`Annotation`},`behavior`,Ac(e.behavior,n)),l()}}):null]})}function Mc({value:e,onChange:t}){let n=!!e;return R(`span`,{title:`Floating position override`,className:`inline-flex`,children:z(lt,{children:[z(G,{"aria-label":`Floating position override`,className:`relative inline-grid h-8 w-8 place-items-center rounded-md border bg-white shadow-sm outline-none transition-colors hover:border-me-primary-400 focus-visible:ring-2 focus-visible:ring-me-500 ${n?`border-me-primary-500 text-me-primary-600`:`border-slate-200 text-slate-500`}`,children:[R(Dr,{position:e}),n?R(`span`,{className:`absolute -right-1 -top-1 h-2.5 w-2.5 rounded-full bg-me-primary-500 ring-2 ring-white`}):null]}),R(pt,{placement:`bottom`,style:{zIndex:1000010},children:R(`div`,{className:`manifest-editor`,children:R(ct,{className:`rounded-lg border border-slate-200 bg-white p-2 shadow-lg outline-none`,children:({close:n})=>R(`div`,{className:`grid grid-cols-3 gap-1`,children:kr(`No override`).map(r=>R(`button`,{type:`button`,"aria-label":r.label,title:r.label,onClick:()=>{t(r.value),n()},className:`grid h-8 w-8 place-items-center rounded-md border outline-none transition-colors hover:border-me-primary-400 hover:bg-me-primary-50 focus-visible:ring-2 focus-visible:ring-me-500 ${e===r.value?`border-me-primary-500 bg-me-primary-50 text-me-primary-600`:`border-slate-200 bg-white text-slate-500`}`,children:R(Dr,{position:r.value})},r.value||`none`))})})})})]})})}function Nc({editAlignment:e=!1,highlightProps:t,index:n=0,tourStyle:r=`linear`,useSlideshowWorkbench:i=!1}){let a=je(),o=F(),s=Pc(a?.body||[],o),c=H(s?.resource?.value||``),l=Y(e=>e.startTourStepRepositioning),u=Y(e=>e.selectTourStep),d=X(e=>e.requestTab),f=X(e=>e.setShowTourSteps),{target:p,isPending:m,cancelRequest:h,busy:g,requestAnnotationFromTarget:_,deleteAnnotation:v}=be(),y=!p,[b,x]=U(!1),S=()=>(a?.id&&u(a.id),!i||!a?.id?!1:(f(!0),l(a.id),d(`tour`),!0));return B(()=>{b||(c.current=s?.resource?.value||``)},[s?.resource?.value,b]),B(()=>{b&&!m&&x(!0)},[m,b]),z(`div`,{...t,className:`exhibition-tour-step-card border shadow-sm rounded bg-white relative ${r===`non-linear`?`border-gray-900 hover:border-black`:`border-gray-300 hover:border-me-500`}`,onClick:S,children:[R(`div`,{className:`absolute right-3 top-3 z-10 rounded-full px-2 py-1 text-xs font-semibold`,style:{backgroundColor:`#f5f5f5`,color:`#b84c74`},children:r===`non-linear`?`Point ${n+1}`:`Step ${n+1}`}),z(`div`,{className:`relative`,children:[y?R(`div`,{className:`mx-3 mt-3 rounded border border-amber-300 bg-amber-50 px-3 py-2 text-xs text-amber-900`,children:`Invalid region. Select Edit to draw a new region.`}):null,b?R(`div`,{className:`p-3`,children:R(yc,{value:s?.resource?.value||``,onChange:e=>c.current=e})}):R(`div`,{className:`px-3 pt-3`,children:R(xc,{value:s?.resource?.value||``})})]}),z(`div`,{className:`flex gap-2 p-2`,onClick:e=>e.stopPropagation(),children:[b&&m?R(L,{children:z(W,{primary:!0,onPress:()=>{Ic(o,a,s,c.current),x(!1),h()},children:[R(vc,{}),` Finish editing`]})}):z(W,{isDisabled:g,onPress:()=>{i&&a?.id&&(f(!0),l(a.id),d(`tour`)),x(!0),_().then(()=>{x(!1)})},children:[R(qe,{}),` Edit`]}),z(W,{className:`gap-2 flex`,onPress:()=>v(),children:[R(Ge,{}),` Delete`]}),z(`div`,{className:`ml-auto flex items-center gap-2`,children:[e?R(jc,{annotation:a}):null,R(Dc,{})]})]}),r===`linear`?R(`div`,{className:`absolute -bottom-5 left-5 h-5 border-l-2 border-gray-300 w-0`}):null]})}function Pc(e,t){for(let n=0;n<e.length;n++){let r=e[n],i=Fc(r,t);if(i?.type===`TextualBody`||i?.type===`Text`||i?.format===`text/html`)return{ref:r?.id?{id:r.id,type:`ContentResource`}:null,resource:i,bodyIndex:n}}return null}function Fc(e,t){return!e?.id||e.value?e:t.get(e,{skipSelfReturn:!1})||e}function Ic(e,t,n,r){if(!t||!n)return;if(n.ref?.id){e.modifyEntityField(n.ref,`value`,r);return}let i=Array.isArray(t.body)?t.body:[];e.modifyEntityField({id:t.id,type:`Annotation`},`body`,[...i.slice(0,n.bodyIndex),{...n.resource,value:r},...i.slice(n.bodyIndex+1)])}function Lc({editAlignment:e=!1,originalAnnotationId:t,highlightProps:n,index:r=0,tourStyle:i=`linear`,useSlideshowWorkbench:a=!1}){let o=Me(),s=y(o),c=je(),l=N(),u=F(),{edit:d}=x(),[f,p]=U(!1),m=H(Rc(c?.label)),h=H(Rc(c?.summary)),g=Y(e=>e.selectTourStep),_=Y(e=>e.startTourStepRepositioning),v=X(e=>e.requestTab),b=X(e=>e.setShowTourSteps),S=l?.items?.[0],C=S?.id&&c?.id?(u.get(S)?.items||[]).findIndex(e=>e.id===c.id):-1,w=()=>{if(t&&confirm(`Are you sure you want to delete this annotation?`)){let e=s.structural.items.getWithoutTracking().findIndex(e=>e.id===t);s.structural.items.deleteAtIndex(e)}},T=()=>(t&&g(t),!a||!t?!1:(b(!0),_(t),v(`tour`),!0)),ee=()=>{c&&(u.modifyEntityField({id:c.id,type:`Annotation`},`label`,{en:[m.current]}),u.modifyEntityField({id:c.id,type:`Annotation`},`summary`,sa({en:[h.current]})))};return z(`div`,{...n,className:`exhibition-tour-step-card border shadow-sm rounded bg-white relative ${i===`non-linear`?`border-gray-900 hover:border-black`:`border-gray-300 hover:border-me-500`}`,onClick:T,children:[R(`div`,{className:`absolute right-3 top-3 z-10 rounded-full px-2 py-1 text-xs font-semibold`,style:{backgroundColor:`#f5f5f5`,color:`#b84c74`},children:i===`non-linear`?`Point ${r+1}`:`Step ${r+1}`}),R(`div`,{className:`flex gap-2 mb-2 p-3`,children:R(`div`,{className:`flex-1 min-w-0`,children:f?R(`div`,{className:`flex flex-col gap-3`,children:R(bc,{label:m.current,summary:h.current,onChange:({label:e,summary:t})=>{m.current=e,h.current=t}})}):R(Sc,{label:Rc(c?.label),summary:Rc(c?.summary)})})}),z(`div`,{className:`flex gap-2 p-2`,onClick:e=>e.stopPropagation(),children:[f?z(W,{primary:!0,onPress:()=>{ee(),p(!1)},children:[R(vc,{}),` Finish editing`]}):z(W,{onPress:()=>p(!0),children:[R(qe,{}),` Edit`]}),z(W,{className:`gap-2 flex`,onPress:()=>w(),children:[R(Ge,{}),` Delete`]}),R(W,{onPress:()=>{T()||c&&d({id:c.id,type:`Annotation`},S?{parent:S,property:`items`,index:C}:void 0,{forceOpen:!0})},children:`Edit annotation`}),e?R(`div`,{className:`ml-auto flex items-center`,children:R(jc,{annotation:c})}):null]}),i===`linear`?R(`div`,{className:`absolute -bottom-5 left-5 h-5 border-l-2 border-gray-300 w-0`}):null]})}function Rc(e){if(!e)return``;if(typeof e==`string`)return e;if(Array.isArray(e))return e.find(e=>typeof e==`string`)||``;let t=e.en||Object.values(e)[0];return Array.isArray(t)&&t.find(e=>typeof e==`string`)||``}function zc({editAlignment:e=!1,index:t=0,tourStyle:n=`linear`,useSlideshowWorkbench:r=!1}){let[i,{annotationTarget:a,highlightProps:o}]=xe(),c=V(()=>a?{id:a,type:`Annotation`}:{id:i?.id,type:`Annotation`},[i?.id,a]);return a?R(s,{resource:c,children:R(Te,{annotation:a,children:R(Lc,{editAlignment:e,originalAnnotationId:i?.id,highlightProps:o,index:t,tourStyle:n,useSlideshowWorkbench:r})})}):R(s,{resource:c,children:R(Nc,{editAlignment:e,highlightProps:o,index:t,tourStyle:n,useSlideshowWorkbench:r})})}function Bc({editAlignment:e=!1,reorderable:t=!1,tourStyle:n=`linear`,useSlideshowWorkbench:r=!1}){let i=Me(),a=y(i);return i?t?R(L,{children:R(de,{id:i.id,marginBottom:`0.5em`,items:i.items||[],inlineHandle:!1,reorder:({startIndex:e,endIndex:t})=>a.structural.items.reorder(e,t),renderItem:(t,i)=>R(Te,{annotation:t.id,children:R(zc,{index:i,tourStyle:n,editAlignment:e,useSlideshowWorkbench:r})})})}):R(L,{children:i.items.map((t,i)=>R(Te,{annotation:t.id,children:R(zc,{index:i,tourStyle:n,editAlignment:e,useSlideshowWorkbench:r})},t.id))}):null}function Vc(e){return e&&[e.x,e.y,e.width,e.height].every(Number.isFinite)&&e.width>0&&e.height>0}function Hc(e){return!e||Array.isArray(e.points)&&e.points.length&&e.points.every(e=>Array.isArray(e)&&Number.isFinite(e[0])&&Number.isFinite(e[1]))}function Uc(e){if(e?.type===`FragmentSelector`){let t=e.value?.replace(/^xywh=/,``).split(`,`).map(Number);return t?.length===4&&t.every(Number.isFinite)&&t[2]>0&&t[3]>0}return e?.type===`SvgSelector`&&typeof e.value==`string`&&!/\b(?:NaN|Infinity|undefined)\b/.test(e.value)}function Wc(e,t){let n=Number(t?.width)||1920,r=Number(t?.height)||1080,i=e?.boundingBox;if(Hc(e?.polygon)&&Vc(i)&&i.x>=0&&i.y>=0&&i.x+i.width<=n&&i.y+i.height<=r&&Uc(e?.target))return e;let a=Kn(t,Vc(e?.boundingBox)?e.boundingBox:{x:0,y:0,width:n,height:r});return{...e,polygon:null,boundingBox:a,target:{type:`FragmentSelector`,value:`xywh=${a.x},${a.y},${a.width},${a.height}`}}}const Gc={id:`@exhibition/tour-steps`,supports:{edit:!0,properties:[`annotations`,`behavior`],resourceTypes:[`Canvas`],custom:({resource:e},t)=>br(e,t)?!t.get(e)?.behavior?.includes(`splash`)&&!xr(e,t)&&!Sr(e,t):!1},label:`Tour steps`,component:()=>R(Kc,{})};function Kc({mode:e=`advanced`}){let t=N(),n=t?.annotations[0],r=t?.items[0];return!n||!t||!r?R(qc,{}):R(tt,{children:R(nt,{padding:!0,children:R(Jc,{mode:e})})})}function qc(){let e=N(),t=b(),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 z(`div`,{className:`flex flex-col items-center justify-center p-4`,children:[R(`div`,{className:`p-4 opacity-50 text-center`,children:`This image does not yet have a tour.`}),R(G,{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-[#6a625c] hover:text-me-500`,onPress:()=>n(),children:`Create Tour`})]})}function Jc({mode:e,useSlideshowWorkbench:t=!1}){let n=N(),r=v(),i=n?.annotations?.[0],a=n?.items?.[0],[o,c]=U(!1),[l,u]=U(!1),f=d(),p=ri(Nn()?.type,f.metadata.id),m=p===`slideshow`,h=Array.isArray(n?.behavior)?n.behavior:[],g=p===`scroll`||ki(h),_=X(e=>e.setShowTourSteps),y=X(e=>e.setCenterPanelMode),b=Y(e=>e.stopRepositioning),x=Y(e=>e.stopTextRepositioning);B(()=>{_(!0),y(`edit`),b(),x()},[y,_,b,x]);let{requestTourStep:S,isPending:C,busy:w}=Xc({onBeforeRequest:t?()=>{_(!0),y(`edit`),b(),x()}:void 0}),T=()=>{u(e=>{let t=!e;return y(t?`preview`:`edit`),t})};if(!n)return null;if(!i)return R(qc,{});let ee=e===`advanced`&&!!a,E=r.technical.type===`Canvas`&&r.technical.behavior.get()||[],D=m&&E.includes(`non-linear-tour`),O=E.includes(`tour-marker-pin`)?`pin`:`circle`,te=D?`non-linear`:`linear`,k=e=>{if(r.technical.type!==`Canvas`)return;let t=E.filter(e=>e!==Hi);r.technical.behavior.set(e?[...t,Hi]:t)},A=e=>{if(r.technical.type!==`Canvas`)return;let t=E.filter(e=>e!==Ui);r.technical.behavior.set(e===`pin`?[...t,Ui]:t)};return z(L,{children:[z(`div`,{className:`flex gap-4 border-b pt-4 pb-2 mb-2`,children:[R(`h2`,{className:`text-lg font-semibold flex-1`,children:`Tour steps`}),e===`advanced`&&!D?R(W,{onPress:()=>c(e=>!e),children:o?`Done`:`Reorder`}):null,e===`advanced`&&g?R(W,{onPress:T,children:l?`Done`:`Edit alignment`}):null]}),m?z(`div`,{className:`mb-4 rounded border border-gray-200 bg-white p-3`,children:[R(`div`,{className:`mb-2 text-sm font-semibold text-gray-700`,children:`Tour style`}),R(Si,{checked:D,label:`Let visitors choose map points`,onChange:k}),R(`p`,{className:`mt-2 text-xs leading-relaxed text-gray-500`,children:`Shows all tour steps as markers that visitors can open in any order.`}),D?z(`div`,{className:`mt-4 space-y-3 border-t border-gray-100 pt-3`,children:[z(`div`,{className:`flex items-center justify-between gap-3`,children:[R(`div`,{className:`text-sm font-semibold text-gray-700`,children:`Marker`}),z(`div`,{role:`group`,"aria-label":`Tour marker style`,className:`inline-flex rounded-md border border-gray-200 bg-gray-50 p-0.5`,children:[R(Yc,{selected:O===`circle`,onPress:()=>A(`circle`),children:`Circle`}),R(Yc,{selected:O===`pin`,onPress:()=>A(`pin`),children:`Pin`})]})]}),R(`p`,{className:`text-xs leading-relaxed text-gray-500`,children:`Marker colour follows the exhibition theme annotation text colour.`})]}):null]}):null,R(s,{resource:n,children:z(Ee,{annotationPage:i.id,children:[z(`div`,{className:`flex flex-col gap-4`,children:[R(`div`,{className:`text-sm font-semibold text-gray-700`,children:D?`Map points`:`Linear step list`}),R(Bc,{reorderable:e===`advanced`&&!D&&o,tourStyle:te,editAlignment:g&&l,useSlideshowWorkbench:t}),w?null:C?R(Cc,{}):R(G,{onPress:S,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-[#6a625c] hover:text-me-500`,children:D?`+ Add map point`:`+ Add new step`})]}),ee&&a?R(L,{children:R(ue,{title:R(`h3`,{className:`text-md border-b pt-4 pb-2 mb-2`,children:`Available tour steps from images`}),painting:a,page:i,canvasId:n.id})}):null]})})]})}function Yc({children:e,selected:t,onPress:n}){return R(G,{"aria-pressed":t,className:`rounded px-2.5 py-1 text-xs font-semibold transition-colors ${t?`bg-white text-me-primary-600 shadow-sm`:`text-gray-500 hover:text-gray-800`}`,onPress:n,children:e})}function Xc({onBeforeRequest:e}={}){let t=N(),n=t?.annotations?.[0],r=b(),{requestAnnotation:i,isPending:a,busy:o}=Ie({onSuccess:e=>{let i=e.metadata.bodyValue??`<p>Description</p>`;if(!e.cancelled&&e.target&&t&&n){let a=Wc(e,t);r.create(`@manifest-editor/html-annotation`,{label:{en:[`Tour step`]},body:{en:[i]},motivation:`tagging`},{target:{id:t.id,type:`Canvas`},targetType:`Annotation`,parent:{property:`items`,resource:{id:n.id,type:`AnnotationPage`}},initialData:{selector:a}})}}});return{requestTourStep:()=>{e?.(),i({type:`box`})},isPending:a,busy:o,canRequestTourStep:!!(t&&n)}}function Zc(){let e=Nn(),t=v(),n=t.technical.duration;return e?.type!==`slideshow`||t.technical.type!==`Canvas`?null:z(j,{$wide:!0,id:n.containerId(),children:[R(ie,{htmlFor:n.focusId(),children:`Slide duration`}),R(ne,{id:n.focusId(),min:0,type:`number`,value:n.get()||0,onChange:e=>{let t=e.currentTarget.valueAsNumber;Number.isFinite(t)&&n.set(t)}})]})}const Qc={id:`@exhibition/info-box-editor`,supports:{edit:!0,properties:[`label`,`behavior`],resourceTypes:[`Canvas`],custom:({resource:e},t)=>br(e,t)?xr(e,t):!1},label:`Text box`,component:()=>R($c,{})};function $c(){let[e,t]=C(`exhibition-info-box-mode`,`simple`),n=N(),r=F(),i=P(),a=v(),o=ai();if(!n||a.technical.type!==`Canvas`)return null;let c=a.technical.behavior.get()||[],l=Ri(c)||12,u=e=>{let t=c.filter(e=>!e.startsWith(`w-`)&&!e.startsWith(`h-`)),n=c.find(e=>e.startsWith(`h-`));t.push(`w-${e}`),n||t.push(`h-4`),a.technical.behavior.set(t)},d=o.showGridSizing&&i?.items&&n?zi(n.id,i.items,r):null;return R(tt,{children:z(nt,{className:`bg-white px-6 pt-5 pb-20`,children:[R(`div`,{className:`flex justify-center`,children:R(Ci,{value:e,onChange:t})}),z(`div`,{className:`mt-8 flex flex-col gap-7`,children:[R(Zc,{}),R(s,{resource:n,children:e===`simple`?z(wi,{children:[R(Ti,{children:`Title`}),R(`div`,{className:`mt-2`,children:R(oe,{dispatchType:`label`,disableMultiline:!0,disallowHTML:!0})})]}):z(wi,{children:[R(Ti,{children:`Label & summary`}),z(`div`,{className:`mt-2 flex flex-col gap-3`,children:[R(oe,{dispatchType:`label`,disableMultiline:!0,disallowHTML:!0}),R(Es,{resource:n})]})]})}),e===`simple`&&o.showGridSizing?z(L,{children:[z(wi,{children:[R(Ti,{children:`Width`}),R(`div`,{className:`mt-3 grid grid-cols-2 gap-3`,children:Li.map(e=>R(xi,{selected:l===e.value,onClick:()=>u(e.value),children:e.label},e.value))})]}),d?z(wi,{children:[z(Ti,{children:[`Fit alongside `,d.neighbour,` slide`]}),R(`div`,{className:`mt-3`,children:z(xi,{selected:l===d.width,onClick:()=>u(d.width),children:[`w-`,d.width,` — fills remaining space`]})})]}):null,z(`div`,{className:`text-center text-xs`,style:{color:Z.muted},children:[`w-`,l]})]}):e===`advanced`?z(L,{children:[R(`div`,{className:`px-2`,children:R(j,{$wide:!0,children:R(A,{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)})})}),o.showGridSizing?R(te,{behavior:c,onChange:e=>a.technical.behavior.set(e),configs:[{id:`size`,component:(e,t)=>R(pi,{behaviors:e,setBehaviors:t}),label:{en:[`Size`]},type:`custom`,initialOpen:!0,supports:e=>e.startsWith(`w-`)||e.startsWith(`h-`)}]}):null]}):null]})]})})}const el=`editorial-text`;function tl(){let e=N(),t=e?.items?.[0]?{id:e.items[0].id,type:`AnnotationPage`}:void 0,[,n]=h(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:l,selectTextRegion:u,startTextRepositioning:d,stopTextRepositioning:f}=Y(),p=X(e=>e.setShowTourSteps),m=I((t,n)=>e?Vn(n,e):[],[e?.id,t?.id]),g=Gn(e).text,_=m.length||g;return!e||!t?z(`div`,{children:[R(ul,{children:`Content on this slide`}),R(`p`,{className:`exhibition-workbench-muted mt-2 text-sm leading-relaxed`,children:`This slide does not have a content layer yet.`})]}):z(`div`,{className:`flex flex-col gap-5`,children:[z(`div`,{children:[R(ul,{children:`Content on this slide`}),R(`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.`})]}),_?z(`div`,{className:`flex flex-col gap-2`,children:[g?R(rl,{box:g,selected:a===el,repositioning:o===el,onSelect:()=>{p(!1),u(el)},onReposition:()=>{p(!1),d(el)},onStopReposition:f}):null,m.map((e,t)=>R(nl,{layer:e,index:t,selected:r===e.annotation.id,repositioning:i===e.annotation.id,onSelect:()=>{p(!1),s(e.annotation.id)},onReposition:()=>{p(!1),c(e.annotation.id)},onStopReposition:l,onAdvancedEdit:()=>n.edit({id:e.annotation.id,type:`Annotation`},t)},e.annotation.id))]}):R(`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 nl({layer:e,index:t,selected:n,repositioning:r,onSelect:i,onReposition:a,onStopReposition:o,onAdvancedEdit:s}){let c=F(),l=Se({annotationId:e.annotation.id,options:{maxWidth:96,maxHeight:96}}),u=cl(e.annotation,c),d=al(e,u),f=ol(e,u,t),p=sl(e,u,d);return z(`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:[z(G,{className:`flex w-full items-center gap-3 border-none bg-transparent p-0 text-left`,onPress:i,children:[R(il,{thumbnailUrl:l?.id,type:d}),z(`span`,{className:`min-w-0 flex-1`,children:[R(`span`,{className:`block text-[11px] font-semibold uppercase tracking-wide text-me-primary-500`,children:d}),R(`span`,{className:`mt-0.5 block truncate text-sm font-semibold`,children:f}),R(`span`,{className:`exhibition-workbench-muted mt-0.5 block truncate text-xs`,children:p})]})]}),z(`div`,{className:`mt-3 flex items-center justify-between gap-3`,children:[R(`span`,{className:`exhibition-workbench-muted text-xs`,children:r?`Drag or resize in the workbench`:n?`Selected in workbench`:`Click to select on slide`}),z(`div`,{className:`flex gap-2`,children:[R(G,{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`}),R(G,{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 rl({box:e,selected:t,repositioning:n,onSelect:r,onReposition:i,onStopReposition:a}){return z(`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:[z(G,{className:`flex w-full items-center gap-3 border-none bg-transparent p-0 text-left`,onPress:r,children:[R(il,{type:`Text`}),z(`span`,{className:`min-w-0 flex-1`,children:[R(`span`,{className:`block text-[11px] font-semibold uppercase tracking-wide text-me-primary-500`,children:`Editorial text`}),R(`span`,{className:`mt-0.5 block truncate text-sm font-semibold`,children:`Slide label and summary`}),z(`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)]})]})]}),z(`div`,{className:`mt-3 flex items-center justify-between gap-3`,children:[R(`span`,{className:`exhibition-workbench-muted text-xs`,children:n?`Drag or resize in the workbench`:t?`Selected in workbench`:`Click to select on slide`}),R(G,{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 il({thumbnailUrl:e,type:t}){return R(`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?R(`img`,{alt:``,className:`h-full w-full object-cover`,src:e}):R(`span`,{children:t})})}function al(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 ol(e,t,n){let r=he(t?.label,``),i=he(e.annotation.label,``),a=e.html?ll(e.html).slice(0,80):``;return r||i||a||`${al(e,t)} layer ${n+1}`}function sl(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 cl(e,t){let n=Array.isArray(e?.body)?e.body[0]:e?.body;return _e(t,n)}function ll(e){return e.replace(/<br\s*\/?>/gi,` `).replace(/<\/p>/gi,` `).replace(/<[^>]+>/g,` `).replace(/\s+/g,` `).trim()}function ul({children:e}){return R(`div`,{className:`exhibition-workbench-muted text-sm font-semibold`,children:e})}const dl=[{id:`layout`,label:`Layout`},{id:`summary`,label:`Text content`},{id:`tour`,label:`Tour steps`}],fl=[{id:`layout`,label:`Layout`},{id:`content`,label:`Content`},{id:`summary`,label:`Text content`},{id:`tour`,label:`Tour steps`}],pl=[{value:`simple`,label:`Simple`},{value:`advanced`,label:`Advanced`}],ml={track:`#f5eaf0`,active:`#b84c74`,inactiveText:`#8b3f61`,activeText:`#ffffff`,activeShadow:`0 1px 3px rgba(15, 23, 42, 0.18)`},hl={id:`@exhibition/workbench-editor`,supports:{edit:!0,properties:[`label`,`summary`,`requiredStatement`,`behavior`,`annotations`],resourceTypes:[`Canvas`],custom:({resource:e},t)=>br(e,t)?xr(e,t):!1},label:`Canvas`,component:()=>R(_l,{})},gl={...hl,id:`@exhibition/slideshow-workbench-editor`,supports:{...hl.supports,custom:({resource:e},t)=>br(e,t)},component:()=>R(_l,{preset:`slideshow`})};function _l({preset:e=`default`}){let[t,n]=C(`exhibition-right-panel-mode`,`simple`),r=N(),i=F(),a=!!r?.behavior?.includes(`info`),o=zn(i,r),s=V(()=>(e===`slideshow`?fl:dl).filter(e=>e.id!==`tour`||o),[e,o]),[c,l]=U(`layout`),u=X(e=>e.requestedTab),d=X(e=>e.clearRequestedTab),f=X(e=>e.setShowTourSteps),p=X(e=>e.setCenterPanelMode);B(()=>{c===`tour`?p(`edit`):(c===`layout`||c===`summary`)&&p(`preview`)},[]),B(()=>{if(u&&s.some(e=>e.id===u)){let e=u;l(e),f(e===`tour`),e===`tour`?p(`edit`):(e===`layout`||e===`summary`)&&p(`preview`),d()}},[d,u,p,f,s]),B(()=>{c===`tour`&&!o&&(l(`layout`),f(!1))},[c,f,o]);let m=e=>{l(e),f(e===`tour`),e===`tour`?p(`edit`):(e===`layout`||e===`summary`)&&p(`preview`)};return a?R($c,{}):R(tt,{children:z(nt,{className:`bg-white px-6 pt-5 pb-20`,children:[R(`div`,{className:`flex justify-center`,children:R(vl,{value:t,options:pl,onChange:n})}),R(`div`,{role:`tablist`,"aria-label":`Canvas editing sections`,className:[`mt-5 grid border-b border-[#e4ddd6]`,s.length===4?`grid-cols-4`:`grid-cols-3`].join(` `),children:s.map(e=>R(`button`,{type:`button`,id:`exhibition-workbench-tab-${e.id}`,role:`tab`,"aria-selected":c===e.id,"aria-controls":`exhibition-workbench-panel-${e.id}`,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:()=>m(e.id),children:e.label},e.id))}),z(`div`,{id:`exhibition-workbench-panel-${c}`,role:`tabpanel`,"aria-labelledby":`exhibition-workbench-tab-${c}`,className:`mt-8 px-4`,children:[c===`layout`?z(L,{children:[R(xs,{}),R(Zc,{}),R(hi,{mode:t,layoutContext:e===`slideshow`?`slideshow`:`default`})]}):null,c===`content`?R(tl,{}):null,c===`summary`?R(t===`simple`?yl:ws,{}):null,c===`tour`?R(Jc,{mode:t,useSlideshowWorkbench:e===`slideshow`}):null]})]})})}function vl({value:e,options:t,onChange:n}){return R(`div`,{role:`group`,"aria-label":`Editing mode`,className:`grid w-full max-w-[240px] grid-cols-2 rounded-full p-1`,style:{backgroundColor:ml.track},children:t.map(t=>{let r=e===t.value;return R(G,{"aria-pressed":r,className:`border-none rounded-full bg-transparent px-4 py-2 text-sm font-semibold transition-colors`,style:{backgroundColor:r?ml.active:`transparent`,color:r?ml.activeText:ml.inactiveText,boxShadow:r?ml.activeShadow:`none`},onPress:()=>n(t.value),children:t.label},t.value)})})}function yl(){let e=N();return e?R(s,{resource:e,children:z(`div`,{className:`flex flex-col gap-7`,children:[z(`div`,{children:[R(bl,{children:`Slide title`}),R(`div`,{className:`mt-2`,children:R(oe,{dispatchType:`label`,disableMultiline:!0,disallowHTML:!0})})]}),z(`div`,{children:[R(bl,{children:`Slide summary`}),R(`div`,{className:`mt-2`,children:R(Es,{resource:e})})]}),R(Ts,{})]})}):null}function bl({children:e}){return R(`div`,{className:`exhibition-workbench-muted text-sm font-semibold`,children:e})}const xl=e=>R(`svg`,{xmlns:`http://www.w3.org/2000/svg`,width:`1em`,height:`1em`,viewBox:`0 0 15 15`,...e,children:R(`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`})}),Sl=l(u(e,e=>({...e,layout:{...e.layout,creators:e.layout.creators?.map(e=>e.id===`@manifest-editor/iiif-browser-creator`?Go(e):e)}})),{id:`exhibition-scrolling-editor`,title:`Exhibition Editor (scrolling)`,project:!0,projectType:`Manifest`},{preset:ns,config:{editorConfig:{}},leftPanels:[Wa,io],leftPanelIds:[`left-panel-manifest`],centerPanels:[],annotations:[],background:[],canvasEditors:[],editors:[Qc,hl,Ds,oi,Ss,Gc],creators:[os,fs,qo,Wo,Yo,$o,ls]}),Cl={id:`slideshow-canvas-editor`,label:`Slideshow canvas editor`,component:()=>R(wl,{}),supports:{strategy:(e,t,n)=>{let r=n.get(t.resource);return r?.type===`Canvas`&&Cr(r)}}};function wl(){let e=N(),t=P(),{edit:n}=x(),{rightPanel:r}=S(),i=X(e=>e.centerPanelMode),a=Fe(),o=ye(e=>e.annotationId),[s,c]=U(1),l=t?.items?.findIndex(t=>t.id===e?.id),u=typeof l==`number`?t?.items?.[l-1]:void 0,d=typeof l==`number`?t?.items?.[l+1]:void 0;return e?a||o||i===`edit`||r.current===`@manifest-editor/editor`&&r.state?.currentTab?.startsWith(`@exhibition/tour-steps`)?R(k,{asFallback:!0}):z(`div`,{className:`exhibition-slideshow-current-canvas flex h-full min-h-0 flex-col bg-slate-100`,children:[z(`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:[R(`div`,{className:`min-w-0 flex-1`,children:R(M,{className:`block truncate text-sm font-semibold text-slate-800`,children:e.label})}),z(`div`,{className:`flex items-center gap-2`,children:[R(Tl,{onPress:()=>c(1),children:`Home`}),R(Tl,{onPress:()=>c(e=>Math.max(.25,e-.25)),children:`-`}),R(Tl,{onPress:()=>c(e=>Math.min(3,e+.25)),children:`+`}),R(Tl,{isDisabled:!u,onPress:()=>u&&n({id:u.id,type:`Canvas`},void 0,{forceOpen:!1}),children:`Previous`}),R(Tl,{isDisabled:!d,onPress:()=>d&&n({id:d.id,type:`Canvas`},void 0,{forceOpen:!1}),children:`Next`})]})]}),R(`div`,{className:`exhibition-slideshow-current-viewport min-h-0 flex-1 overflow-auto p-8`,children:R(`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:R(Oe,{canvas:e.id,children:R(Gi,{})})})})]}):null}function Tl({children:e,isDisabled:t,onPress:n}){return R(G,{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 El=e=>R(`svg`,{xmlns:`http://www.w3.org/2000/svg`,width:`1em`,height:`1em`,viewBox:`0 0 48 48`,...e,children:z(`g`,{fill:`none`,stroke:`#000`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:4,children:[R(`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`}),R(`circle`,{cx:24,cy:24,r:2})]})}),Dl=e=>R(`svg`,{xmlns:`http://www.w3.org/2000/svg`,width:`1em`,height:`1em`,viewBox:`0 0 24 24`,...e,children:R(`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`})}),Ol={skipEditingOnCreate:!0},kl={id:`@exhibitions/slideshow-center-panel`,label:`Slideshow workbench`,icon:R(Dl,{}),render:()=>R(Al,{})};function Al(){let{structural:e,technical:t}=w(),n=e.items.get(),r={id:t.id.get(),type:`Manifest`};F();let[,i]=h(r,`items`,`Canvas`,void 0,{isPainting:!0}),a=Ce(`Canvas`),o=_(),{edit:s}=x(),c=Y(e=>e.clear),l=a?.resource.source.id||n[0]?.id,u=l?n.findIndex(e=>e.id===l):-1,d=u>=0?u:0,f=u>=0?n[u]:n[0]||null,p=()=>{i.createFiltered(`exhibition-slideshow-slide`,n.length?d+1:void 0)},m=(e,t,n=!1)=>{s({id:e.id,type:`Canvas`},{parent:r,property:`items`,index:t},{forceOpen:n})},g=(e,t)=>{c(),m(e,t)},v=t=>{let r=n[t];if(!r||!confirm(`Are you sure you want to delete this slide?`))return;let i=Fa(n,f?.id,r.id);if(e.items.deleteAtIndex(t),f?.id!==r.id||(c(),o.close(),!i))return;let a=e.items.getWithoutTracking(),s=a.findIndex(e=>e.id===i),l=a[s];l&&m(l,s)},y=d>0?n[d-1]:void 0,b=d<n.length-1?n[d+1]:void 0;return n.length?R(jl,{children:z(`div`,{className:`exhibition-slideshow-main flex min-h-full flex-col gap-6 pb-12 pt-16`,children:[z(`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:[z(`div`,{className:`min-w-0 flex-1`,children:[R(`p`,{className:`text-sm font-semibold uppercase tracking-wider text-me-primary-500`,children:`Slideshow workbench`}),R(`h2`,{className:`exhibition-slideshow-heading truncate text-2xl font-bold text-slate-900`,children:f?R(Oe,{canvas:f.id,children:R(Ml,{})}):`Slides`}),z(`p`,{className:`exhibition-slideshow-muted mt-1 text-sm font-semibold text-slate-500`,children:[`Slide `,d+1,` of `,n.length]})]}),R(Nl,{current:d+1,total:n.length,onPrevious:y?()=>g(y,d-1):void 0,onNext:b?()=>g(b,d+1):void 0}),R(`div`,{children:R(W,{primary:!0,onPress:p,children:`Add new slide`})})]}),z(`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:[R(`div`,{className:`exhibition-slideshow-preview-frame flex items-center justify-center overflow-hidden rounded-lg bg-slate-100`,children:f?R(Oe,{canvas:f.id,children:R(Fl,{})}):null}),z(`aside`,{className:`exhibition-slideshow-slide-strip overflow-hidden rounded-lg border border-slate-200 bg-white p-4`,children:[R(`div`,{className:`exhibition-slideshow-heading mb-3 text-sm font-semibold text-slate-700`,children:`Slides`}),R(`div`,{className:`flex gap-3 overflow-x-auto pb-2`,children:n.map((e,t)=>R(Oe,{canvas:e.id,children:R($l,{index:t,selected:f?.id===e.id,onPress:()=>g(e,t),onDelete:()=>v(t)})},e.id))})]})]})]})}):R(jl,{children:R(`div`,{className:`flex min-h-full items-center justify-center px-24 py-12`,children:z(`div`,{className:`w-full max-w-4xl`,children:[R(`p`,{className:`text-sm font-semibold uppercase tracking-wider text-me-primary-500`,children:`Slideshow exhibition`}),R(`h2`,{className:`mt-2 text-3xl font-bold text-slate-900`,children:`Create your first slideshow slide`}),R(`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.`}),R(`div`,{className:`mt-8`,children:R(W,{primary:!0,large:!0,onPress:p,children:`Add new slide`})})]})})})}function jl({children:e}){return R(nt,{className:`exhibition-slideshow-workbench h-full overflow-x-hidden overflow-y-auto bg-[#f8f6f3]`,children:e})}function Ml(){let e=Xl(N()?.label,`Untitled slide`);return R(L,{children:e||`Untitled slide`})}function Nl({current:e,total:t,onPrevious:n,onNext:r}){return z(`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:[R(G,{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`}),z(`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]}),R(G,{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 Pl({current:e,total:t,onPrevious:n,onNext:r}){return z(`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:[R(G,{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`}),R(`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`}),R(G,{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 Fl(){let e=N(),t=P(),n=F(),r=b(),i=X(e=>e.centerPanelMode),a=X(e=>e.setCenterPanelMode),o=i,s=a,[c,l]=U(null),[u,d]=U(`box`),f=H(null),p=e?.annotations?.[0]?.id,m=e?.items?.[0]?{id:e.items[0].id,type:`AnnotationPage`}:void 0,[,g]=h(m,`items`,`Annotation`,e?In(e):void 0,{isPainting:!0}),{selectedAnnotationId:_,repositioningAnnotationId:v,selectedTextRegion:y,repositioningTextRegion:x,selectedTourStepId:S,selectAnnotation:C,startRepositioning:w,stopRepositioning:T,startTextRepositioning:ee,stopTextRepositioning:E,selectTourStep:D,stopTourStepRepositioning:O}=Y(),te=X(e=>e.showTourSteps),k=X(e=>e.setShowTourSteps),A=I((t,n)=>e?Ln(n,e):[],[e?.id,m?.id]).find(e=>e.id===_),ne=y===`editorial-text`?Gn(e).text:null,j=I((t,n)=>e?Rn(n,e):[],[e?.id,p]),re=j.find(e=>e.id===S)||j[0],ie=re?Math.max(0,j.findIndex(e=>e.id===re.id)):-1,ae=zn(n,e),oe=te&&ae,se=e=>{let t=j[e];t?.id&&D(t.id)};B(()=>{f.current=null,l(null),d(`box`)},[e?.id]),B(()=>{!ae&&te&&(k(!1),O(),l(null))},[k,te,O,ae]),B(()=>{oe&&s(`edit`)},[oe]),B(()=>{if(f.current===null){f.current=j.length;return}let e=j[j.length-1];j.length>f.current&&e?.id&&(D(e.id),T(),E(),k(!0)),f.current=j.length},[D,k,T,E,j]);let ce=()=>{let e=!te;k(e),e?(T(),E(),re?.id&&D(re.id)):O()},le=()=>{e&&r.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`}}})},ue=()=>{!e||!p||(k(!0),T(),E(),d(`box`),l({type:`add`}))},de=()=>{re?.id&&(k(!0),T(),E(),d(Jl(re)),l({type:`edit`,annotationId:re.id}))};return z(`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:[z(`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:[R(`span`,{className:`exhibition-slideshow-muted text-xs font-semibold text-slate-500`,children:o===`edit`?`Click content to edit or reposition it`:`Live slideshow preview`}),z(`div`,{className:`flex flex-wrap items-center gap-2`,children:[o===`edit`?z(L,{children:[ae?R(G,{className:K(`rounded-md border px-3 py-2 text-xs font-semibold shadow-sm transition`,oe?`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:ce,children:oe?`Hide tour steps`:`Show tour steps`}):null,oe?z(L,{children:[R(Pl,{current:ie+1,total:j.length,onPrevious:ie>0?()=>se(ie-1):void 0,onNext:ie>=0&&ie<j.length-1?()=>se(ie+1):void 0}),p?R(G,{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:ue,children:`Add tour step`}):R(G,{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:le,children:`Create tour`})]}):R(G,{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:()=>{s(`edit`),C(null),k(!1),O(),g.create(void 0,Ol)},children:`Add content`})]}):null,z(`div`,{className:`flex shrink-0 overflow-hidden rounded-md border border-slate-200 bg-slate-50 text-xs font-semibold`,children:[R(Ql,{selected:o===`edit`,onPress:()=>s(`edit`),children:`Edit`}),R(Ql,{selected:o===`preview`,onPress:()=>s(`preview`),children:`Preview`})]})]})]}),z(`div`,{className:`relative min-h-0 flex-1 bg-black`,children:[o===`preview`?R(ar,{preset:`slideshow`,presetOptions:{manifest:t?.id||``,canvas:e?.id,minimal:!0}}):R(Gi,{editable:!0,mode:o,showTourSteps:oe}),o===`edit`&&c&&e&&p?R(Ul,{annotationPageId:p,canvas:e,mode:c,selectedTool:u,setSelectedTool:d,vault:n,onCancel:()=>l(null),onComplete:e=>{e&&D(e),k(!0),l(null)}}):null,!c&&o===`edit`&&!oe&&A&&e?R(zl,{annotation:A,canvas:e,isRepositioning:v===A.id,onStartReposition:()=>w(A.id),onStopReposition:T,vault:n}):null,!c&&o===`edit`&&!oe&&ne&&e?R(zl,{canvas:e,currentBox:ne,isRepositioning:x===y,label:`Editorial text`,onStartReposition:()=>ee(`editorial-text`),onStopReposition:E,setBox:t=>Wn(n,e,t),vault:n}):null,!c&&o===`edit`&&oe&&e?re?R(zl,{annotation:re,canvas:e,isRepositioning:!1,label:`Selected tour step target`,onStopReposition:O,showBoxFields:!0,showRepositionButton:!1,vault:n,children:p?R(Il,{annotationPageId:p,canvas:e,onAddTourStep:ue,onEditTarget:de,selectedTourStepId:re?.id}):null}):R(Rl,{label:`Tour steps`,children:p?R(Il,{annotationPageId:p,canvas:e,onAddTourStep:ue,onEditTarget:de,selectedTourStepId:re?.id}):R(Ll,{onCreate:le})}):null]})]})}function Il({annotationPageId:e,canvas:t,onAddTourStep:n,onEditTarget:r,selectedTourStepId:i}){return R(s,{resource:t,children:R(Ee,{annotationPage:e,children:z(`div`,{className:`space-y-3 text-slate-800`,children:[z(`div`,{className:`flex items-center justify-between gap-2`,children:[R(`h3`,{className:`text-sm font-semibold text-slate-800`,children:`Tour steps`}),z(`div`,{className:`flex flex-wrap gap-2`,children:[i?R(Zl,{label:`Edit target`,onPress:r}):null,R(Zl,{primary:!0,label:`Add step`,onPress:n})]})]}),R(`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.`}),R(`div`,{className:`max-h-72 overflow-y-auto pr-1`,children:R(Bc,{reorderable:!1,useSlideshowWorkbench:!0})})]})})})}function Ll({onCreate:e}){return z(`div`,{className:`space-y-3 text-slate-800`,children:[R(`p`,{className:`text-xs text-slate-600`,children:`This slide does not have a tour annotation page yet.`}),R(Zl,{primary:!0,label:`Create tour`,onPress:e})]})}function Rl({children:e,label:t}){return z(`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:[R(`div`,{className:`mb-2 font-semibold text-slate-700`,children:t}),e]})}function zl({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 p=H(null),m=H(null),[h,g]=U(null),_=Number(t?.width)||1920,v=Number(t?.height)||1080,y=r||Hn(e,t),b=c||(n=>Un(l,t,e.id,n)),x=Math.round(_/2),S=Math.round(v/2),C=e=>{let t=p.current,n=t?.offsetParent,r=t?.getBoundingClientRect(),i=n?.getBoundingClientRect();!t||!r||!i||(e.currentTarget.setPointerCapture(e.pointerId),m.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)})},w=e=>{let t=m.current;!t||t.pointerId!==e.pointerId||g({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))})},T=e=>{m.current?.pointerId===e.pointerId&&(m.current=null,e.currentTarget.hasPointerCapture(e.pointerId)&&e.currentTarget.releasePointerCapture(e.pointerId))};return R(`div`,{ref:p,className:K(`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`,h?null:`bottom-4 left-4`),style:h?{left:h.x,top:h.y}:void 0,children:z(`div`,{className:`flex flex-col gap-3`,children:[z(`div`,{className:`min-w-[280px]`,children:[z(`div`,{className:`mb-2 flex items-center justify-between gap-3`,children:[R(`span`,{className:`font-semibold text-slate-700`,children:a}),z(`div`,{className:`flex items-center gap-2`,children:[R(`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:C,onPointerMove:w,onPointerUp:T,onPointerCancel:T,children:R(El,{})}),z(`span`,{className:`text-slate-400`,children:[Math.round(y.width),` x `,Math.round(y.height)]})]})]}),u?null:z(`div`,{className:`space-y-2`,children:[z(`div`,{className:`flex flex-wrap gap-2`,children:[f&&o?R(Zl,{onPress:o,label:`Reposition`,primary:!0}):null,i&&s?R(Zl,{onPress:s,label:`Stop moving`}):null,R(Zl,{onPress:()=>b({x:0,y:0,width:_,height:v}),label:`Fill`}),R(Zl,{onPress:()=>b({x:Math.round(_*.1),y:Math.round(v*.1),width:Math.round(_*.8),height:Math.round(v*.8)}),label:`Centre`}),R(Zl,{onPress:()=>b({x:0,y:0,width:x,height:v}),label:`Left`}),R(Zl,{onPress:()=>b({x,y:0,width:x,height:v}),label:`Right`}),R(Zl,{onPress:()=>b({x:0,y:0,width:_,height:S}),label:`Top`}),R(Zl,{onPress:()=>b({x:0,y:S,width:_,height:S}),label:`Bottom`})]}),d?R(Bl,{box:y,onChange:b}):null]})]}),n?R(`div`,{className:`w-full border-t border-slate-200 pt-3`,children:n}):null]})})}function Bl({box:e,onChange:t}){let n=(n,r)=>{let i=Number(r);Number.isFinite(i)&&t({...e,[n]:Math.round(i)})};return z(`div`,{className:`grid grid-cols-4 gap-2 pt-1`,children:[R(Vl,{label:`X`,value:e.x,onChange:e=>n(`x`,e)}),R(Vl,{label:`Y`,value:e.y,onChange:e=>n(`y`,e)}),R(Vl,{label:`W`,value:e.width,onChange:e=>n(`width`,e)}),R(Vl,{label:`H`,value:e.height,onChange:e=>n(`height`,e)})]})}function Vl({label:e,value:t,onChange:n}){return z(`label`,{className:`block text-[11px] font-semibold text-slate-500`,children:[e,R(`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 Hl(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(It({entities:{ContentResource:{[a]:{id:a,type:`TextualBody`,language:`en`,format:`text/html`,value:`<p>Description</p>`}},Annotation:{[i]:{id:i,type:`Annotation`,motivation:`tagging`,body:[{id:a,type:`ContentResource`}],target:r}}}})),e.dispatch(Ft({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 Ul({annotationPageId:e,canvas:t,mode:n,selectedTool:r,setSelectedTool:i,vault:a,onCancel:o,onComplete:s}){let c=H(null),[l,u]=U(null),[d,f]=U(null),[p,m]=U([]),h=Number(t?.width)||1920,g=Number(t?.height)||1080,_=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:Yl(Math.round(i.x),0,h),y:Yl(Math.round(i.y),0,g)}},v=e=>{if(e.preventDefault(),r===`polygon`){let t=_(e);m(e=>[...e,t]);return}let t=_(e);u(t),f(null)},y=e=>{if(!l||r===`polygon`)return;let t=_(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})},b=()=>{u(null)},x=r===`polygon`&&p.length?{type:`polygon`,points:p}:d,S=()=>{u(null),f(null),m([])};return z(`div`,{className:`absolute inset-0 z-30`,children:[z(`svg`,{ref:c,className:`absolute inset-0 h-full w-full cursor-crosshair touch-none`,preserveAspectRatio:`xMidYMid meet`,viewBox:`0 0 ${h} ${g}`,onPointerDown:v,onPointerMove:y,onPointerUp:b,onPointerCancel:b,children:[R(`rect`,{x:0,y:0,width:h,height:g,fill:`transparent`}),x?R(Gl,{shape:x}):null,p.map((e,t)=>R(`circle`,{cx:e.x,cy:e.y,r:8,fill:`white`,stroke:`#be4778`,strokeWidth:4},`${e.x}-${e.y}-${t}`))]}),z(`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:[R(`span`,{className:`mr-2 font-semibold text-slate-700`,children:n.type===`add`?`Draw new tour step`:`Edit target`}),R(Wl,{active:r===`box`,label:`Box`,onPress:()=>{S(),i(`box`)}}),R(Wl,{active:r===`circle`,label:`Circle`,onPress:()=>{S(),i(`circle`)}}),R(Wl,{active:r===`line`,label:`Line`,onPress:()=>{S(),i(`line`)}}),R(Wl,{active:r===`polygon`,label:`Polygon`,onPress:()=>{S(),i(`polygon`)}}),R(Zl,{primary:!0,label:n.type===`add`?`Create step`:`Save target`,onPress:()=>{if(!x)return;let r=Kl(t.id,x);if(n.type===`edit`){a.modifyEntityField({id:n.annotationId,type:`Annotation`},`target`,r),s(n.annotationId);return}s(Hl(a,t,e,r))}}),R(Zl,{label:`Clear`,onPress:S}),R(Zl,{label:`Cancel`,onPress:o})]})]})}function Wl({active:e,label:t,onPress:n}){return R(G,{className:K(`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 Gl({shape:e}){let t={fill:`rgba(190, 71, 120, 0.18)`,stroke:`#be4778`,strokeWidth:6,vectorEffect:`non-scaling-stroke`};return e.type===`box`?R(`rect`,{...t,x:e.x,y:e.y,width:e.width,height:e.height}):e.type===`circle`?R(`circle`,{...t,cx:e.cx,cy:e.cy,r:e.r}):e.type===`line`?R(`line`,{x1:e.x1,y1:e.y1,x2:e.x2,y2:e.y2,stroke:`#be4778`,strokeWidth:6,vectorEffect:`non-scaling-stroke`}):R(`polygon`,{...t,points:e.points.map(e=>`${e.x},${e.y}`).join(` `)})}function Kl(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:ql(t)}}}function ql(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 Jl(e){let t=Array.isArray(e?.target?.selector)?e.target.selector.find(e=>e?.type===`SvgSelector`):e?.target?.selector;return t?.type===`SvgSelector`&&(Array.isArray(t.points)&&t.svgShape!==`polyline`||typeof t.value==`string`&&/<polygon\b/i.test(t.value))?`polygon`:`box`}function Yl(e,t,n){return Math.min(n,Math.max(t,e))}function Xl(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 Zl({label:e,onPress:t,primary:n}){return R(G,{className:K(`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 Ql({children:e,selected:t,onPress:n}){return R(G,{className:K(`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 $l({index:e,selected:t,onPress:n,onDelete:r}){let i=N();return z(`div`,{className:K(`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:[z(G,{className:`block w-full border-none bg-transparent p-0 text-left`,onPress:n,children:[R(`div`,{className:`aspect-video overflow-hidden rounded`,style:{backgroundColor:`#0e0d12`},children:R(Gi,{className:`pointer-events-none h-full w-full`,mode:`preview`})}),z(`div`,{className:`mt-2 flex items-center gap-2 pr-7`,children:[R(`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}),R(M,{className:`min-w-0 truncate text-sm font-medium text-slate-800`,children:i?.label})]})]}),R(G,{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 eu=l(u(e),{id:`exhibition-slideshow-editor`,title:`Exhibition Editor (slideshow)`,project:!0,projectType:`Manifest`},{preset:ns,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:[Ua,io],centerPanels:[kl],annotations:[Xt],leftPanelIds:[`left-panel-manifest`],background:[yo],canvasEditors:[Cl],editors:[gl,Qc,Ds,oi,Ss,Gc],creators:[Wo,qo,$o,Xo,Zo,us,ps,ss]}),tu=l(u(e,e=>({...e,layout:{...e.layout,leftPanels:[Ha,...e.layout.leftPanels.filter(e=>e.id===`left-panel-manifest`)]}})),{id:`exhibition-editor`,title:`Exhibition Editor`,project:!0,projectType:`Manifest`},{preset:ns,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:[io],centerPanels:[wn,dr],annotations:[Xt],leftPanelIds:[`canvas-listing`,`left-panel-manifest`],background:[yo],canvasEditors:[xo,Ho,To],editors:[Qc,hl,Ds,cc,oi,Ss,Gc],creators:[os,fs,qo,Wo,Yo,$o,ls,Xo,Zo,us,ps,ss]});export{xl as PresetIcon,tu as exhibitionEditorPreset,Sl as exhibitionEditorScrollingPreset,eu as exhibitionEditorSlideshowPreset,qo as imageServiceSlideCreator,or as useExhibitionPreviewWindow};
|
|
3
3
|
//# sourceMappingURL=index.js.map
|