@manifest-editor/shell 2.2.2-next.0.903673e → 2.2.2-next.0.92cba17
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 +374 -349
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +253 -56
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.ts +254 -57
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +148 -123
- package/dist/index.js.map +1 -1
- package/package.json +22 -12
package/dist/index.js
CHANGED
|
@@ -1,13 +1,31 @@
|
|
|
1
|
-
import{ActionButton as e,ArrowRightIcon as t,BackIcon as n,BackgroundActionMenuButton as r,BackgroundActionMenuDivider as i,BackgroundActionMenuInfoButton as a,BackgroundActionMenuInlineAction as o,BackgroundActionMenuItem as s,BackgroundActionMenuLabel as c,BackgroundActionMenuMeta as l,BackgroundActionMenuPanel as u,BackgroundActionMenuProgressBar as d,BackgroundActionMenuRoot as f,BackgroundActionMenuSection as p,BackgroundActionMenuText as m,BackgroundActionMenuTrigger as h,CheckIcon as g,CreatorGrid as _,DefaultTooltipContent as v,DownloadButton as y,EmptyState as b,ErrorMessage as x,Form as S,GridIcon as C,IconButton as w,IconHandle as T,ManifestEditorLogo as E,Modal as ee,ModalBackSlot as D,PaddedSidebarContainer as O,PanelSideMenu as k,ResetIcon as te,ResizeHandle as ne,Sidebar as re,SidebarContent as ie,SidebarHeader as ae,SidebarTabs as oe,Spinner as A,Tab as se,TabList as ce,TabPanel as le,Tabs as ue,ToastRegion as de,Tooltip as fe,TooltipTrigger as pe,useLocalStorage as me,useOptionalLocalStorage as he,useOptionalLocalStorage as ge}from"@manifest-editor/components";import*as _e from"react";import{Component as ve,Fragment as ye,Suspense as be,createContext as j,createElement as xe,createRef as Se,forwardRef as Ce,memo as we,useCallback as M,useContext as N,useEffect as P,useImperativeHandle as Te,useLayoutEffect as F,useMemo as I,useReducer as Ee,useRef as L,useState as R}from"react";import{Fragment as z,jsx as B,jsxs as V}from"react/jsx-runtime";import{create as De,createStore as Oe,useStore as ke}from"zustand";import Ae from"localforage";import{AtlasStoreProvider as je,AtlasStoreProvider as Me,AtlasStoreReactContext as Ne,CollectionContext as Pe,ImageServiceLoaderContext as Fe,ManifestContext as Ie,ReactVaultContext as Le,ResourceReactContext as Re,VaultProvider as ze,useAtlasStore as Be,useCurrentAnnotationMetadata as Ve,useExistingVault as He,useManifest as Ue,useResourceContext as We,useVault as H,useVaultSelector as Ge}from"react-iiif-vault";import{isSpecificResource as Ke,toRef as qe}from"@iiif/parser";import U,{ThemeProvider as Je,css as W}from"styled-components";import{original as Ye,produce as Xe}from"immer";import{EditorInstance as Ze}from"@manifest-editor/editor-api";import{useToastState as Qe}from"@react-stately/toast";import{getValue as $e}from"@iiif/helpers";import*as et from"@iiif/helpers/vault";import{Vault as tt}from"@iiif/helpers/vault";import{Creator as nt,getCreatorConfigKey as rt,matchBasedOnResource as it}from"@manifest-editor/creator-api";import{ErrorBoundary as at}from"react-error-boundary";import{addReference as ot,batchActions as st,modifyEntityField as ct,reorderEntityField as lt,requestResource as ut}from"@iiif/helpers/vault/actions";import{actionListFromResource as dt}from"@iiif/helpers/vault/utility";import ft from"mitt";import{useDebounce as pt}from"tiny-use-debounce";import{Transition as mt}from"react-transition-group";import ht from"shallowequal";import{ImageServiceLoader as gt}from"@atlas-viewer/iiif-image-api";import{MessagePortClientVault as _t}from"@manifest-editor/client-vault";var vt=Object.create,yt=Object.defineProperty,bt=Object.getOwnPropertyDescriptor,xt=Object.getOwnPropertyNames,St=Object.getPrototypeOf,Ct=Object.prototype.hasOwnProperty,wt=(e,t)=>()=>(t||(e((t={exports:{}}).exports,t),e=null),t.exports),Tt=(e,t,n,r)=>{if(t&&typeof t==`object`||typeof t==`function`)for(var i=xt(t),a=0,o=i.length,s;a<o;a++)s=i[a],!Ct.call(e,s)&&s!==n&&yt(e,s,{get:(e=>t[e]).bind(null,s),enumerable:!(r=bt(t,s))||r.enumerable});return e},Et=(e,t,n)=>(n=e==null?{}:vt(St(e)),Tt(t||!e||!e.__esModule||!Ct.call(e,`default`)?yt(n,`default`,{value:e,enumerable:!0}):n,e)),Dt=`Invariant failed`;function G(e,t){if(!e)throw Error(Dt)}const Ot={previews:[],behaviorPresets:[`auto-advance`,`no-auto-advance`,`repeat`,`no-repeat`,`unordered`,`individuals`,`continuous`,`paged`,`non-paged`,`facing-pages`,`multi-part`,`together`,`sequence`,`thumbnail-nav`,`no-nav`,`hidden`],defaultPreview:null,editorConfig:{},newTemplates:null,i18n:{advancedLanguageMode:!1,availableLanguages:[`en`,`cy`,`nl`,`fr`],defaultLanguage:`en`},editorFeatureFlags:{enableMultiImageCanvases:!0,enableMultiMediaCanvases:!0,annotationPopups:!1,rememberCanvasId:!0,manifestGridOptions:!1,rememberLeftPanelId:!1},uploadBackends:[],plugins:{apps:{}},export:{baseIdentifier:null,version:3},creators:{"iiif-image-services":{compact:`with-dimensions`,includeSizes:!1,includeTiles:!1}}};function kt(e,t){if(!e&&!t)return;let n={...e||{}};for(let[e,r]of Object.entries(t||{}))n[e]={...n[e]||{},...r||{}};return n}function At(e,t){if(!e&&!t)return;let n={...e?.apps||{}};for(let[e,r]of Object.entries(t?.apps||{})){let t=n[e]||{};n[e]={...t,...r,settings:{...t.settings||{},...r.settings||{}}}}return{apps:n}}function jt(e,t){if(!e&&!t)return;let n={...e||{}};for(let[e,r]of Object.entries(t||{}))n[e]={...n[e]||{},...r||{}};return n}function Mt(...e){let t={};for(let n of e)n&&(t={...t,...n,editorConfig:kt(t.editorConfig,n.editorConfig),editorFeatureFlags:t.editorFeatureFlags||n.editorFeatureFlags?{...t.editorFeatureFlags||{},...n.editorFeatureFlags||{}}:void 0,i18n:t.i18n||n.i18n?{...t.i18n||{},...n.i18n||{}}:void 0,export:t.export||n.export?{...t.export||{},...n.export||{}}:void 0,creators:jt(t.creators,n.creators),plugins:At(t.plugins,n.plugins)});return t}function Nt(...e){return Mt(Ot,...e)}const Pt=j(Ot),Ft=j(()=>{});function K(){return N(Pt)}function It(){return N(Ft)}function Lt({children:e,config:t,saveConfig:n}){let[r,i]=R(null),a=I(()=>Nt(t,r),[t,r]),o=M(e=>{i(t=>Mt(t,e)),n&&n(e)},[n]);return B(Ft.Provider,{value:o,children:B(Pt.Provider,{value:a,children:e})})}const Rt=`@manifest-editor/canvas-progress`,zt=`status`,Bt=new Set([`queued`,`pending`,`done`]);function Vt(e){return typeof e==`string`?e:e?.id||null}function Ht(e){return typeof e==`string`&&Bt.has(e)?e:`none`}function Ut(e){return typeof e==`string`&&Bt.has(e)}function Wt(e,t){let n=Vt(t);return n?Ht(e.getResourceMeta(n,Rt)?.[zt]):`none`}function Gt(e,t){let n=Vt(t);return n?Ht(e?.iiif?.meta?.[n]?.[Rt]?.[zt]):`none`}function Kt(e,t,n){let r=Vt(t);if(!r)return`none`;let i=Ut(n)?n:void 0;return e.setMetaValue([r,Rt,zt],i),i||`none`}function qt(e,t){return Kt(e,t,`none`)}function Jt(e,t,n){let r={};for(let i of t){let t=Vt(i);t&&(r[t]=Kt(e,i,n))}return r}function Yt(e,t){return Jt(e,t,`none`)}function Xt(e){return{getStatus(t){return Wt(e,t)},setStatus(t,n){return Kt(e,t,n)},clearStatus(t){return qt(e,t)},setStatuses(t,n){return Jt(e,t,n)},clearStatuses(t){return Yt(e,t)}}}function Zt(e,t=new Set){function n(e){let n=Vt(e);n&&t.add(n)}function r(e){for(let t of e)n(t)}return{trackedResourceIds:t,getStatus(t){return e.getStatus(t)},setStatus(t,r){return n(t),e.setStatus(t,r)},clearStatus(t){return n(t),e.clearStatus(t)},setStatuses(t,n){return r(t),e.setStatuses(t,n)},clearStatuses(t){return r(t),e.clearStatuses(t)},clearTrackedStatuses(){e.clearStatuses(Array.from(t).map(e=>({id:e,type:`Canvas`}))),t.clear()}}}function Qt(e){let t=Vt(e);return Ge(e=>t?Gt(e,t):`none`,[t])}function $t(e){let t=H(),n=Vt(e),r=I(()=>Xt(t),[t]);return I(()=>({setStatus(e){return r.setStatus(n,e)},clearStatus(){return r.clearStatus(n)},getStatus(){return r.getStatus(n)}}),[r,n])}const en={queued:{label:`Queued`,stripClass:`bg-zinc-400/80`,badgeClass:`bg-zinc-500`,dimOverlay:!0},pending:{label:`In progress`,stripClass:`bg-amber-400/90 animate-pulse`,badgeClass:`bg-amber-500`},done:{label:`Done`,stripClass:`bg-me-primary-500`,badgeClass:`bg-me-primary-500`}};function tn({className:e}){return V(`svg`,{className:e,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2.5`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[B(`circle`,{cx:`12`,cy:`12`,r:`9`}),B(`path`,{d:`M12 7v5l2.5 2.5`})]})}function nn({className:e}){return V(`svg`,{className:e,viewBox:`0 0 24 24`,fill:`none`,children:[B(`circle`,{cx:`12`,cy:`12`,r:`9`,stroke:`currentColor`,strokeWidth:`2.5`,strokeOpacity:`0.3`}),B(`path`,{d:`M12 3a9 9 0 0 1 9 9`,stroke:`currentColor`,strokeWidth:`2.5`,strokeLinecap:`round`})]})}function rn({className:e}){return B(`svg`,{className:e,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2.5`,strokeLinecap:`round`,strokeLinejoin:`round`,children:B(`path`,{d:`M5 12l4 4 8-8`})})}function an({resource:e,status:t,className:n}){return t?B(sn,{status:t,className:n}):B(on,{resource:e,className:n})}function on({resource:e,className:t}){let n=Qt(e);return B(sn,{status:n,className:t})}function sn({status:e,className:t}){if(e===`none`)return null;let n=en[e];return V(z,{children:[n.dimOverlay&&B(`div`,{"aria-hidden":`true`,className:`pointer-events-none absolute inset-0 z-10 bg-white/40`}),B(`div`,{"aria-hidden":`true`,className:`pointer-events-none absolute inset-x-0 top-0 z-10 h-[3px] rounded-t-sm ${n.stripClass} ${t||``}`}),V(`div`,{className:`pointer-events-none absolute right-1.5 top-1.5 z-10 flex h-[18px] w-[18px] items-center justify-center rounded-full ${n.badgeClass} shadow-md ring-2 ring-white/70`,title:n.label,children:[B(`span`,{className:`sr-only`,children:n.label}),e===`queued`&&B(tn,{className:`h-2.5 w-2.5 text-white`}),e===`pending`&&B(nn,{className:`h-2.5 w-2.5 animate-spin text-white`}),e===`done`&&B(rn,{className:`h-2.5 w-2.5 text-white`})]})]})}function cn(e,t){return`${e}::${t.type}::${t.id}`}function ln(e=[],t=[]){let n=[],r=new Set;for(let e=t.length-1;e>=0;--e){let i=t[e];i&&!r.has(i.id)&&(r.add(i.id),n.unshift(i))}return[...e.filter(e=>!r.has(e.id)),...n]}function un(e){return[...e].sort((e,t)=>{let n=(e.section||``).localeCompare(t.section||``);if(n!==0)return n;let r=(e.order||0)-(t.order||0);if(r!==0)return r;let i=e.label.localeCompare(t.label);return i===0?e.id.localeCompare(t.id):i})}function dn(e){return e instanceof Error?{message:e.message,stack:e.stack,detail:e}:{message:typeof e==`string`?e:`Background action failed`,detail:e}}function fn(e){return e&&typeof e==`object`&&typeof e.message==`string`?{message:e.message,stack:typeof e.stack==`string`?e.stack:void 0,detail:e.detail}:dn(e)}function pn(e,t){return!e.resourceTypes?.length||e.resourceTypes.includes(t.type)}function mn({definitions:e,instances:t,systemContext:n,targets:r,onSupportsError:i}){let a=un(e),o=[];for(let e of r){let r=[];for(let o of a){if(!pn(o,e))continue;let a=cn(o.id,e),s={...n,definition:o,target:e,instanceKey:a,instance:t[a]};try{if(o.supports&&!o.supports(s))continue}catch(e){i?.(o,e);continue}r.push({definition:o,target:e,instanceKey:a,instance:t[a],context:s})}r.length&&o.push({id:`${e.scope}:${e.type}:${e.id}`,label:e.label,target:e,actions:r})}return o}let hn=0;function gn(e){return hn+=1,`${e}-${Date.now()}-${hn}`}function _n(e,t,n,r=Date.now()){return{id:gn(`event`),createdAt:r,type:e,message:t,data:n}}function q(e,t,n,r,i=Date.now()){return{...e,events:[...e.events,_n(t,n,r,i)]}}function vn(e){return e.filter(e=>String(e.type)!==`progress`)}function yn(e){return{...e,logs:[...e.logs],events:vn(e.events),progress:e.progress?{...e.progress}:void 0}}function bn(e,t,n){if(!Tn(n.status))return e;let r=e[t]||[],i=yn(n),a=r.findIndex(e=>e.runId===n.runId),o=a>=0?r.map((e,t)=>t===a?i:e):[...r,i];return{...e,[t]:o}}function xn(e,t,n){let r=e.instances[t];if(!r)return{instances:e.instances,histories:e.histories};let i=n(r);return{instances:{...e.instances,[t]:i},histories:bn(e.histories,t,i)}}function Sn(e){return Number.isFinite(e)?Math.min(100,Math.max(0,e)):0}function Cn(e){let t=e,n=typeof t.current==`number`&&Number.isFinite(t.current)?t.current:void 0,r=typeof t.total==`number`&&Number.isFinite(t.total)?t.total:void 0;return{percent:Sn(typeof t.percent==`number`&&Number.isFinite(t.percent)?t.percent:typeof n==`number`&&typeof r==`number`&&r>0?n/r*100:0),current:n,total:r,label:t.label}}function wn(e){return e===`preparing`||e===`running`}function Tn(e){return e===`complete`||e===`error`||e===`cancelled`}function En(e){return e===`queued`||e===`running`||e===`complete`||e===`skipped`||e===`error`||e===`cancelled`}function Dn(e){return!e||e===`queued`||e===`running`}function On(e){return e===`complete`||e===`skipped`||e===`error`||e===`cancelled`}function kn(e){if(e!==void 0)try{return JSON.parse(JSON.stringify(e))}catch{return}}function An(e){return e&&{message:e.message,stack:e.stack,detail:kn(e.detail)}}function jn(e){return{...e,error:An(e.error)||null,result:kn(e.result),logs:e.logs.map(e=>({...e,data:kn(e.data)})),events:vn(e.events).map(e=>({...e,data:kn(e.data)})),progress:e.progress?{...e.progress}:void 0}}function Mn(e){return{...e,status:Rn(e.status),input:kn(e.input),result:kn(e.result),error:An(e.error)||null}}function Nn(e){return{version:1,data:kn(e.data),tasks:e.tasks.map(Mn)}}function Pn(e){return{version:1,savedAt:Date.now(),instances:Object.fromEntries(Object.entries(e.instances).map(([e,t])=>[e,jn(t)])),histories:Object.fromEntries(Object.entries(e.histories).map(([e,t])=>[e,t.map(jn)])),plans:Object.fromEntries(Object.entries(e.plans).map(([e,t])=>[e,Nn(t)]))}}function Fn(){return{version:1,savedAt:Date.now(),instances:{},histories:{},plans:{}}}function In(e,t){return{version:1,savedAt:t.savedAt,instances:{...e.instances,...t.instances},histories:{...e.histories,...t.histories},plans:{...e.plans,...t.plans}}}function Ln(e){return!Object.keys(e.instances).length&&!Object.keys(e.histories).length&&!Object.keys(e.plans).length}function Rn(e){return En(e)?e:`queued`}function zn(e,t){let n=Date.now(),r=typeof e.id==`string`&&e.id?e.id:`task-${t+1}`;return{...e,id:r,label:typeof e.label==`string`&&e.label?e.label:r,status:Rn(e.status),error:e.error?fn(e.error):null,createdAt:typeof e.createdAt==`number`?e.createdAt:n}}function Bn(e){return!e||e.version!==1||!Array.isArray(e.tasks)?null:{version:1,data:e.data,tasks:e.tasks.map(zn)}}function Vn(e){return{...e,tasks:e.tasks.map(e=>e.status===`running`?{...e,status:`queued`,statusText:`Queued after reload`,startedAt:void 0}:e)}}function Hn(e,t=Date.now()){return{...e,tasks:e.tasks.map(e=>Dn(e.status)?{...e,status:`cancelled`,statusText:`Cancelled`,error:null,completedAt:t}:e)}}function Un(e){return{...e,error:e.error?fn(e.error):null,logs:Array.isArray(e.logs)?e.logs:[],events:vn(Array.isArray(e.events)?e.events:[]),resultsAvailable:e.resultsAvailable===!0}}function Wn(e){return!e||e.version!==1?Fn():{version:1,savedAt:typeof e.savedAt==`number`?e.savedAt:Date.now(),instances:e.instances||{},histories:e.histories||{},plans:e.plans||{}}}function Gn(e,t,n){let r=e,i=t;if(wn(e.status)){if(e.cancelRequestedAt){let t=Date.now();i=i&&Hn(i,t),r=q({...e,status:`cancelled`,statusText:`Cancelled`,completedAt:t,cancelledAt:t},`status`,`Cancelled`,{status:`cancelled`},t)}else if(n.resumable&&i)i=Vn(i),r=q({...e,status:`running`,statusText:`Resuming`,completedAt:void 0,cancelledAt:void 0},`status`,`Resuming`,{status:`running`});else{let t=Date.now();r=q({...e,status:`cancelled`,statusText:`Interrupted by page reload`,completedAt:t,cancelledAt:t},`status`,`Interrupted by page reload`,{status:`cancelled`},t)}}return{instance:r,plan:i}}function Kn(e,t){let n=Wn(e),r=new Map(t.map(e=>[e.id,e])),i={},a={},o={},s=Fn();for(let[e,t]of Object.entries(n.histories)){let n=(Array.isArray(t)?t:[]).map(Un),i=n.filter(e=>r.has(e.actionId)),o=n.filter(e=>!r.has(e.actionId));i.length&&(a[e]=i),o.length&&(s.histories[e]=o)}for(let[e,t]of Object.entries(n.instances)){let c=Un(t),l=Bn(n.plans[e]),u=r.get(c.actionId);if(!u){s.instances[e]=jn(c),l&&(s.plans[e]=Nn(l));continue}let d=Gn(c,l,u);i[e]=d.instance,a=bn(a,e,d.instance),d.plan&&(o[e]=d.plan)}return{instances:i,histories:a,plans:o,deferred:s}}function qn(e,t){let n=e.tasks.length;if(!n)return;let r=e.tasks.filter(e=>On(e.status)).length;return Cn({current:r,total:n,label:t})}function Jn(e){return e&&typeof e==`object`&&`taskStatus`in e&&(e.taskStatus===`complete`||e.taskStatus===`skipped`)?{taskStatus:e.taskStatus,result:e.result,statusText:e.statusText}:{taskStatus:`complete`,result:e}}function Yn(e,t){for(let n of t.tasks)!n.target||n.target.type!==`Canvas`||(n.status===`running`?e.setStatus(n.target,`pending`):n.status===`queued`&&e.setStatus(n.target,`queued`))}function Xn(e,t,n){let{store:r,context:i}=e,{instanceKey:a}=i;function o(){return r.getState().plans[a]}function s(){return o()?.tasks||[]}function c(e=[`queued`,`running`]){let t=new Set(e);return s().filter(e=>t.has(Rn(e.status)))}function l(e,t,n=!1){r.getState().updateActionTask(a,e,t,n)}async function u(e,i={}){let u=c(i.statuses||[`queued`,`running`]),d=s().length,f=u.length,p=i.yieldEveryMs===!1?!1:i.yieldEveryMs??16,m=0;for(let[c,h]of u.entries()){if(t.aborted||Zn(m,p)&&(await Qn(),m=Date.now(),t.aborted))throw Error(`Background action cancelled.`);let u=s().find(e=>e.id===h.id)||h,g=s().findIndex(e=>e.id===u.id),_=i.progressLabel?.(u,g,d)||u.label||`Task ${g+1}/${d}`;u.target?.type===`Canvas`&&n.setStatus(u.target,`pending`),l(u.id,{status:`running`,statusText:_,error:null,startedAt:Date.now(),completedAt:void 0},!0),r.getState().setActionStatus(a,`running`,_),r.getState().setActionProgress(a,{current:s().filter(e=>On(e.status)).length,total:d,label:_});try{let r=await e(u,{index:g,total:d,pendingIndex:c,pendingTotal:f});if(t.aborted)throw Error(`Background action cancelled.`);let i=Jn(r);l(u.id,{status:i.taskStatus,statusText:i.statusText||(i.taskStatus===`skipped`?`Skipped`:`Complete`),result:i.result,error:null,completedAt:Date.now()},!0),u.target?.type===`Canvas`&&n.setStatus(u.target,`done`)}catch(e){if(t.aborted||rr(e))throw l(u.id,{status:`cancelled`,statusText:`Cancelled`,error:null,completedAt:Date.now()},!0),e;let n=dn(e);l(u.id,{status:`error`,statusText:n.message,error:n,completedAt:Date.now()},!0),r.getState().appendActionLog(a,`Task failed: ${u.label}`,`warn`,{taskId:u.id,error:n.message})}finally{let e=o();e&&r.getState().setActionProgress(a,{current:e.tasks.filter(e=>On(e.status)).length,total:d,label:_})}}return s()}return{getAll:s,getPending:()=>c(),update:l,runEach:u}}function Zn(e,t){return t!==!1&&(!e||Date.now()-e>=t)}function Qn(){return new Promise(e=>{setTimeout(e,0)})}function $n(e=[]){let t=null,n=null,r=null,i=Fn();return Oe((a,o)=>{function s(e,t){let n=ln([],t),r=Kn(i,n);return i=r.deferred,{definitions:n,instances:{...e.instances,...r.instances},histories:{...e.histories,...r.histories},plans:{...e.plans,...r.plans},controllers:Object.fromEntries(Object.entries(e.controllers).filter(([t,n])=>n&&e.instances[t]?.status&&wn(e.instances[t].status)))}}async function c(){if(r&&(clearTimeout(r),r=null),!t||!n||!o().hasHydrated)return;let e=In(i,Pn(o()));if(Ln(e)){await t.clear(n);return}await t.save(n,e)}function l(e=!1){if(!(!t||!n||!o().hasHydrated)){if(e){c();return}r&&clearTimeout(r),r=setTimeout(()=>{c()},300)}}return{definitions:ln([],e),instances:{},histories:{},plans:{},controllers:{},hasHydrated:!0,setDefinitions(e){a(t=>s(t,e)),l()},setPersistence(e,r){t=e,n=e&&r?r:null,a({hasHydrated:!t})},hydrate(e){let t=Kn(Wn(e),o().definitions);i=t.deferred,a({instances:t.instances,histories:t.histories,plans:t.plans,controllers:{},hasHydrated:!0}),l(!0)},persist(e=!1){l(e)},flushPersistence:c,registerAction(e){return a(t=>s(t,ln(t.definitions,[e]))),l(),()=>o().unregisterAction(e.id)},unregisterAction(e){a(t=>{let n={};for(let[r,i]of Object.entries(t.instances))i.actionId!==e&&(n[r]=i);let r={};for(let[n,i]of Object.entries(t.histories)){let t=i.filter(t=>t.actionId!==e);t.length&&(r[n]=t)}let i={...t.plans},a={...t.controllers};for(let[n,r]of Object.entries(t.instances))r.actionId===e&&(a[n]?.abort(),delete a[n],delete i[n]);return{definitions:t.definitions.filter(t=>t.id!==e),instances:n,histories:r,plans:i,controllers:a}}),l(!0)},resetAction(e){a(t=>{t.controllers[e]?.abort();let n={...t.instances},r={...t.histories},i={...t.plans},a={...t.controllers};return delete n[e],delete r[e],delete i[e],delete a[e],{instances:n,histories:r,plans:i,controllers:a}}),l(!0)},startAction(e,t,n,r){let i=Date.now();a(a=>{let o={...a.plans};return delete o[e],{instances:{...a.instances,[e]:{id:e,runId:gn(`run`),actionId:t.id,target:n,label:t.label,status:`preparing`,statusText:`Preparing`,error:null,result:void 0,resultsAvailable:!1,logs:[],events:[_n(`started`,`Preparing`,{status:`preparing`},i)],progress:void 0,startedAt:i,completedAt:void 0,cancelRequestedAt:void 0,cancelledAt:void 0}},plans:o,controllers:r?{...a.controllers,[e]:r}:a.controllers}}),l(!0)},resumeAction(e,t){let n=Date.now();a(r=>({...xn(r,e,e=>q({...e,status:`running`,statusText:`Resuming`,completedAt:void 0,cancelledAt:void 0},`status`,`Resuming`,{status:`running`},n)),controllers:{...r.controllers,[e]:t}})),l(!0)},cancelAction(e){let t=o().controllers[e],n=o().instances[e];if(!n||!wn(n.status))return;let r=Date.now();a(t=>{let n=xn(t,e,e=>q(q({...e,status:`cancelled`,statusText:`Cancelled`,completedAt:r,cancelledAt:r,cancelRequestedAt:e.cancelRequestedAt||r},`cancel-requested`,`Cancelling`,void 0,r),`status`,`Cancelled`,{status:`cancelled`},r)),i=t.plans[e];return{...n,plans:i?{...t.plans,[e]:Hn(i,r)}:t.plans,controllers:Object.fromEntries(Object.entries(t.controllers).filter(([t])=>t!==e))}}),l(!0),t?.abort()},setActionLabel(e,t){let n=Date.now();a(r=>({...xn(r,e,e=>q({...e,label:t},`label`,t,{label:t},n))})),l()},setActionStatus(e,t,n){let r=Date.now(),i=Tn(t)?r:void 0;a(a=>({...xn(a,e,e=>q({...e,status:t,statusText:n,completedAt:i,cancelledAt:t===`cancelled`?r:void 0},`status`,n||t,{status:t},r)),controllers:wn(t)?a.controllers:Object.fromEntries(Object.entries(a.controllers).filter(([t])=>t!==e))})),l(Tn(t))},setActionError(e,t,n){let r=Date.now(),i=dn(t);a(t=>({...xn(t,e,e=>q({...e,status:`error`,statusText:n,error:i,completedAt:r,cancelledAt:void 0},`error`,n||i.message,i,r)),controllers:Object.fromEntries(Object.entries(t.controllers).filter(([t])=>t!==e))})),l(!0)},appendActionLog(e,t,n=`info`,r){let i=Date.now(),o={id:gn(`log`),createdAt:i,level:n,message:t,data:r};a(a=>({...xn(a,e,e=>q({...e,logs:[...e.logs,o]},`log`,t,{level:n,data:r},i))})),l()},setActionProgress(e,t){let n=t?Cn(t):void 0;a(t=>({...xn(t,e,e=>({...e,progress:n}))}))},setResult(e,t){let n=Date.now();a(r=>({...xn(r,e,e=>q({...e,result:t},`result`,`Result recorded`,void 0,n))})),l(!0)},setResultsAvailable(e,t){let n=Date.now();a(r=>({...xn(r,e,e=>q({...e,resultsAvailable:t},`results-available`,t?`Results available`:`Results hidden`,{available:t},n))})),l(!0)},setActionPlan(e,t){let n=Bn(t);n&&(a(t=>({...xn(t,e,e=>({...e,progress:qn(n,`Queued`)})),plans:{...t.plans,[e]:n}})),l(!0))},updateActionTask(e,t,n,r=!1){a(r=>{let i=r.plans[e];if(!i)return r;let a=i.tasks.map(e=>e.id===t?zn({...e,...n,status:n.status?Rn(n.status):e.status,error:n.error?fn(n.error):n.error===null?null:e.error},0):e),o={...i,tasks:a};return{...xn(r,e,e=>({...e,progress:qn(o,n.statusText||n.label)})),plans:{...r.plans,[e]:o}}}),l(r)}}})}function er(e,t,n){let{store:r,context:i}=e,{instanceKey:a}=i,o=Xn(e,t,n);return{...i,canvasProgress:n,instance:r.getState().instances[a],plan:r.getState().plans[a],tasks:o,signal:t,prepareData:e.prepareData,setActionLabel(e){r.getState().setActionLabel(a,e)},setActionStatus(e,t){r.getState().setActionStatus(a,e,t)},setActionError(e,t){r.getState().setActionError(a,e,t)},appendActionLog(e,t,n){r.getState().appendActionLog(a,e,t,n)},setActionProgress(e){r.getState().setActionProgress(a,e)},setResult(e){r.getState().setResult(a,e)},setResultsAvailable(e){r.getState().setResultsAvailable(a,e)}}}function tr(e){return!!e&&typeof e==`object`&&e.version===1&&Array.isArray(e.tasks)}async function nr(e){let{store:t,context:n}=e,{definition:r,instanceKey:i,target:a}=n,o=t.getState().instances[i],s=t.getState().controllers[i];if((o?.status===`preparing`||o?.status===`running`)&&(!e.resume||s))return o;let c=new AbortController,l=c.signal,u=Zt(n.canvasProgress),d=()=>c.abort();e.signal&&(e.signal.aborted?c.abort():e.signal.addEventListener(`abort`,d,{once:!0})),e.resume&&o&&wn(o.status)?t.getState().resumeAction(i,c):t.getState().startAction(i,r,a,c);let f=()=>{let e=t.getState().instances[i];e&&!Tn(e.status)&&t.getState().setActionStatus(i,`cancelled`,`Cancelled`)};try{if(!e.resume&&r.prepare){let n=await r.prepare(er(e,l,u));if(l.aborted)return f(),t.getState().instances[i];if(n===!1)return t.getState().setActionStatus(i,`idle`),t.getState().instances[i];tr(n)&&t.getState().setActionPlan(i,n)}if(l.aborted)return f(),t.getState().instances[i];let n=t.getState().plans[i];n&&Yn(u,n),t.getState().setActionStatus(i,`running`,e.resume?`Resuming`:`Running`);let a=await r.run(er(e,l,u));if(l.aborted)return f(),t.getState().instances[i];let o=t.getState().instances[i];a!==void 0&&o&&!Tn(o.status)&&t.getState().setResult(i,a),o=t.getState().instances[i],o&&wn(o.status)&&((a!==void 0||o?.resultsAvailable)&&t.getState().setResultsAvailable(i,!0),t.getState().setActionStatus(i,`complete`,`Complete`))}catch(e){l.aborted||rr(e)?f():t.getState().setActionError(i,e,`Error`)}finally{u.clearTrackedStatuses(),e.signal?.removeEventListener(`abort`,d),await t.getState().flushPersistence()}return t.getState().instances[i]}function rr(e){return e instanceof Error&&(e.name===`AbortError`||e.message.toLowerCase().includes(`aborted`))}function ir(e){return JSON.stringify([e.appId,e.instanceId,e.rootResource.type,e.rootResource.id])}let ar;function or(){if(typeof window>`u`)return null;let e=Ae.createInstance({name:`manifest-editor-background-actions-v1`,storeName:`background-actions`});return{async load(t){return e.getItem(ir(t))},async save(t,n){await e.setItem(ir(t),n)},async clear(t){await e.removeItem(ir(t))}}}function sr(){return ar===void 0&&(ar=or()),ar}const cr=j(null);function lr({children:e,persistence:t,persistenceKey:n}){let r=Y(),i=xi(),a=I(()=>$n(),[]),o=r.layout.backgroundActions||[],s=I(()=>t===!1?null:t||sr(),[t]),c=I(()=>n||null,[n]);return P(()=>{a.getState().setDefinitions(o)},[a,o]),P(()=>{let e=c||{appId:i.appId,instanceId:i.instanceId,rootResource:{id:`global`,type:`Manifest`}},t=!1;return a.getState().setPersistence(s,e),s?(s.load(e).then(e=>{t||a.getState().hydrate(e)}).catch(e=>{console.warn(`[manifest-editor/background-actions] Failed to load persisted actions`,e),t||a.getState().hydrate(null)}),()=>{t=!0,a.getState().flushPersistence()}):(a.getState().hydrate(null),()=>void 0)},[i.appId,i.instanceId,s,c?.appId,c?.instanceId,c?.rootResource.id,c?.rootResource.type,a]),P(()=>{let e=()=>{a.getState().flushPersistence()};return window.addEventListener(`beforeunload`,e),()=>window.removeEventListener(`beforeunload`,e)},[a]),xe(cr.Provider,{value:a},e)}function ur(){let e=N(cr);if(!e)throw Error(`useBackgroundActionsStore must be used within a BackgroundActionsProvider`);return e}function J(e=e=>e){return ke(ur(),e)}function dr(e){return J(t=>t.instances[e])}function fr(e){return J(t=>t.histories[e]||[])}async function pr(e){let t;try{await fetch(e).then(e=>e.json().catch(e=>{console.error(`'${e}' happened!`)})).then(e=>{t={...e}})}catch(e){console.log(e)}return t}function mr(e,t,n){return`create_${e}_${t}_${qe(n)?.type||`unknown`}`}function hr(e,t,n=`text/json`){let r=e instanceof Blob?e:new Blob([e],{type:n}),i=document.createElement(`a`);i.download=t,i.href=window.URL.createObjectURL(r);let a=new MouseEvent(`click`,{view:window,bubbles:!0,cancelable:!0});i.dispatchEvent(a),i.remove()}async function gr(e){return navigator.clipboard.writeText(typeof e==`string`?e:JSON.stringify(e,null,2))}function _r(){return`${Math.random().toString(36).substr(2)}-${Date.now().toString(36)}`}function vr(e,t){let{default:n,config:r,preset:i,...a}=e,o={metadata:n,layout:{leftPanels:[],rightPanels:[],centerPanels:[],...a},config:r,preset:i},s=t?t(o):o;return{...s,preset:yr(void 0,s.preset)}}function yr(e,t){if(!e&&!t)return;let n=e?.templateFilter&&t?.templateFilter?n=>e.templateFilter(n)&&t.templateFilter(n):t?.templateFilter||e?.templateFilter,r=t?.templateStrategy===`replace`?t.templates||[]:[...e?.templates||[],...t?.templates||[]],i=e?.preview||t?.preview?{...e?.preview||{},...t?.preview||{},actions:[...e?.preview?.actions||[],...t?.preview?.actions||[]]}:void 0;return{...e||{},...t||{},templateFilter:n,templates:n?r.filter(n):r,preview:i}}function br(e,t,n){return{...e,metadata:t,config:Mt(e.config||{},n.config||{}),preset:yr(e.preset,n.preset),layout:{...e.layout,leftPanels:[...(e.layout.leftPanels||[]).filter(e=>!n?.leftPanelIds||n.leftPanelIds.includes(e.id)),...n?.leftPanels||[]],annotations:[...n?.annotations||[],...e.layout.annotations||[]],canvasEditors:[...n?.canvasEditors||[],...e.layout.canvasEditors||[]],creators:[...n?.creators||[],...e.layout.creators||[]],background:[...e.layout?.background||[],...n?.background||[]],backgroundActions:ln(e.layout?.backgroundActions||[],n?.backgroundActions||[]),editors:[...n?.editors||[],...e.layout.editors||[]],rightPanels:[...e.layout.rightPanels||[],...n?.rightPanels||[]],centerPanels:[...e.layout.centerPanels||[],...n?.centerPanels||[]],modals:[...e.layout.modals||[],...n?.modalPanels||[]]}}}const xr=[`leftPanels`,`centerPanels`,`rightPanels`,`modalPanels`,`annotations`,`canvasEditors`,`editors`,`creators`,`background`,`backgroundActions`],Sr={plugins:[],enabled:[],disabled:[],globalApps:{},apps:{}};function Cr(){return Sr}function wr(e=[]){return Array.from(new Set(e.filter(Boolean)))}function Tr(e){return!!e&&typeof e==`object`&&!Array.isArray(e)}function Er(e={}){return{...e,enabled:wr(e.enabled||[]),disabled:wr(e.disabled||[]),settings:e.settings?{...e.settings}:void 0}}function Dr(e){let t={};for(let[n,r]of Object.entries(e?.apps||{}))t[n]=Er(r);return t}function Or(e={},t){return{...e,enabled:wr([...(e.enabled||[]).filter(e=>e!==t),t]),disabled:(e.disabled||[]).filter(e=>e!==t)}}function kr(e={},t){return{...e,enabled:(e.enabled||[]).filter(e=>e!==t),disabled:wr([...(e.disabled||[]).filter(e=>e!==t),t])}}function Ar(e={},t){return{...e,enabled:(e.enabled||[]).filter(e=>e!==t),disabled:(e.disabled||[]).filter(e=>e!==t)}}function jr(e={},t={}){let n=e.enabled||[],r=t.enabled||[],i=e.disabled||[],a=t.disabled||[];return n.length===r.length&&n.every((e,t)=>e===r[t])&&i.length===a.length&&i.every((e,t)=>e===a[t])&&JSON.stringify(e.settings||{})===JSON.stringify(t.settings||{})}function Mr(e,t){let{default:n,config:r,settings:i,...a}=e,o={metadata:n,extension:{...a,config:r},settings:i};return t?t(o):o}function Nr(e){return{metadata:e.default,extension:{},settings:e.settings,load:e.load,loadStatus:`idle`}}function Pr(e){return!!e&&`metadata`in e&&`extension`in e}function Fr(e){return!!e&&`load`in e&&`default`in e}function Ir(e){return Pr(e)?e:Fr(e)?Nr(e):Mr(e)}function Lr(e=[]){return e.map(Ir)}function Rr(e,t){let n=new Map(e.map(e=>[e.metadata.id,e]));return t.map(e=>{let t=n.get(e.metadata.id);return t?t.loadStatus===`loaded`&&e.load?{...t,metadata:e.metadata,load:e.load}:t.loadStatus===`loading`&&e.load?{...e,loadStatus:`loading`}:t.loadStatus===`error`&&e.load?{...e,loadStatus:`error`,loadError:t.loadError}:e:e})}function zr(e,t,n){let r=e.metadata.supports;if(!r)return!0;if(r.apps?.length){let e=new Set([n,t?.metadata.id].filter(Boolean));if(!r.apps.some(t=>e.has(t)))return!1}if(r.projectTypes?.length){let e=t?.metadata.projectType;if(!e||!r.projectTypes.includes(e))return!1}return!0}function Br(e,t,n){let r=e.metadata.supports;if(!r)return null;if(r.apps?.length){let e=new Set([n,t?.metadata.id].filter(Boolean));if(!r.apps.some(t=>e.has(t)))return`This plugin does not support the current app.`}if(r.projectTypes?.length){let e=t?.metadata.projectType;if(!e||!r.projectTypes.includes(e))return`This plugin does not support the current project type.`}return null}function Vr(e,t,n){let r=n?t.apps[n]:void 0,i=n?t.globalApps[n]:void 0,a=e.metadata.id;return r?.disabled?.includes(a)?!1:r?.enabled?.includes(a)?!0:i?.disabled?.includes(a)?!1:i?.enabled?.includes(a)?!0:t.disabled.includes(a)?!1:t.enabled.includes(a)?!0:e.metadata.defaultEnabled===!0}function Hr(e,t,n){let r=n?t.apps[n]:void 0,i=n?t.globalApps[n]:void 0,a=e.metadata.id;return r?.disabled?.includes(a)||r?.enabled?.includes(a)?`workspace`:i?.disabled?.includes(a)||i?.enabled?.includes(a)?`global`:t.disabled.includes(a)||t.enabled.includes(a)?`provider`:`default`}function Ur(e,t,n){let r=[],i=new Set,a=new Set,o=new Set(e.plugins.filter(r=>zr(r,t,n)&&Vr(r,e,n)).map(e=>e.metadata.id)),s=new Map(e.plugins.map(e=>[e.metadata.id,e])),c=new Set;function l(e){let u=e.metadata.id;if(i.has(u))return!0;if(a.has(u))return!1;if(c.has(u))return Qr(`Plugin "${u}" was not enabled because its dependency graph contains a cycle.`),a.add(u),!1;c.add(u);for(let r of e.metadata.dependencies||[]){let e=s.get(r);if(!e||!o.has(r))return Qr(`Plugin "${u}" was not enabled because dependency "${r}" is not enabled.`),c.delete(u),a.add(u),!1;if(!zr(e,t,n))return Qr(`Plugin "${u}" was not enabled because dependency "${r}" is not compatible.`),c.delete(u),a.add(u),!1;if(!l(e))return c.delete(u),a.add(u),!1}return c.delete(u),r.push(e),i.add(u),!0}for(let r of e.plugins)zr(r,t,n)&&Vr(r,e,n)&&l(r);return r}function Wr(e,t){let n=e?.settings?.[t];return Tr(n)?n:{}}function Gr(e={},t,n){return{...e,settings:{...e.settings||{},[t]:n}}}function Kr(e={},t){let n={...e.settings||{}};return delete n[t],{...e,settings:n}}function qr(e){return{...e?.settings?.defaults||{}}}function Jr(e,t,n){let r=e.plugins.find(e=>e.metadata.id===t),i=n?e.globalApps[n]:void 0,a=n?e.apps[n]:void 0;return{...qr(r),...Wr(i,t),...Wr(a,t)}}function Yr(e,t){return{getSettings(n){return Jr(e,n,t)}}}function Xr(e,t,n,r,i){let a=new Map(t.plugins.map(e=>[e.metadata.id,e])),o=[],s=[],c=new Set,l=e;function u(e){let t=e.metadata.id;if(!o.includes(t)){if(c.has(t)){s.push(`${t} has a circular dependency`);return}c.add(t);for(let t of e.metadata.dependencies||[]){let e=a.get(t);if(!e){s.push(`${t} is not available`);continue}if(!zr(e,r,i)){s.push(`${e.metadata.label} is not compatible`);continue}u(e)}c.delete(t),l=Or(l,t),o.push(t)}}return u(n),s.length?{config:e,enabledIds:[],blocked:s}:{config:l,enabledIds:o,blocked:s}}function Zr(e,t){return t===`modalPanels`?e.layout.modals||[]:e.layout[t]||[]}function Qr(e){globalThis.process?.env?.NODE_ENV!==`production`&&console.warn(`[manifest-editor/plugin] ${e}`)}function $r(e,t,n,r){if(!r?.length)return;let i=[];for(let a of r){if(n.has(a.id)){Qr(`Plugin "${e.metadata.id}" contribution "${a.id}" for "${t}" was skipped because that id already exists.`);continue}n.add(a.id),i.push(a)}return i.length?i:void 0}function ei(e,t){let n=t.extension,r={config:n.config,preset:n.preset,disableSideEffects:n.disableSideEffects};for(let i of xr){let a=$r(t,i,new Set(Zr(e,i).map(e=>e.id)),n[i]);a&&(r[i]=a)}return r}function ti(e,t,n){if(!t.length)return e;let r=e,i=new Set;for(let a of t){if(!zr(a,e,n))continue;let t=(a.metadata.dependencies||[]).filter(e=>!i.has(e));if(t.length){Qr(`Plugin "${a.metadata.id}" was not applied because dependencies are missing or later in the plugin order: ${t.join(`, `)}`);continue}let o=ei(r,a);r=br(r,r.metadata,o),i.add(a.metadata.id)}let a=new Set(e.layout.leftPanels.map(e=>e.id)),o=r.layout.leftPanels.filter(e=>e.divide),s=r.layout.leftPanels.filter(e=>!e.divide),c=!1,l=s.map(e=>!c&&!a.has(e.id)?(c=!0,{...e,separator:!0}):e);return{...r,config:Mt(e.config||{},...t.filter(e=>i.has(e.metadata.id)).map(e=>e.extension.config||{}),r.config||{}),layout:{...r.layout,leftPanels:[...l,...o],backgroundActions:ln([],r.layout.backgroundActions||[])}}}function ni({plugins:e=[],enabled:t=[],disabled:n=[],globalPluginConfig:r}={}){let i=(e=[])=>Array.from(new Set(e.filter(Boolean)));return Oe(a=>({plugins:e,enabled:i(t),disabled:i(n),globalApps:Dr(r),apps:{},setProviderState(e){a(t=>({...t,plugins:Rr(t.plugins,e.plugins||[]),enabled:i(e.enabled||[]),disabled:i(e.disabled||[]),globalApps:Dr(e.globalPluginConfig)}))},setPluginLoading(e){a(t=>({...t,plugins:t.plugins.map(t=>t.metadata.id===e?{...t,loadStatus:`loading`,loadError:void 0}:t)}))},setPluginLoaded(e,t){a(n=>({...n,plugins:n.plugins.map(n=>n.metadata.id===e?{...t,metadata:{...n.metadata,...t.metadata},settings:t.settings||n.settings,load:n.load,loadStatus:`loaded`,loadError:void 0}:n)}))},setPluginLoadError(e,t){a(n=>({...n,plugins:n.plugins.map(n=>n.metadata.id===e?{...n,loadStatus:`error`,loadError:t}:n)}))},setAppConfig(e,t){let n=Er(t);a(t=>jr(t.apps[e],n)?t:{...t,apps:{...t.apps,[e]:n}})},setGlobalConfig(e){a(t=>({...t,globalApps:Dr(e)}))},setGlobalAppConfig(e,t){let n=Er(t);a(t=>jr(t.globalApps[e],n)?t:{...t,globalApps:{...t.globalApps,[e]:n}})},enable(e,t,n=`workspace`){a(r=>({...r,plugins:r.plugins.map(e=>e.metadata.id===t&&e.loadStatus===`error`?{...e,loadStatus:`idle`,loadError:void 0}:e),...n===`global`?{globalApps:{...r.globalApps,[e]:Or(r.globalApps[e],t)}}:{apps:{...r.apps,[e]:Or(r.apps[e],t)}}}))},disable(e,t,n=`workspace`){a(r=>({...r,...n===`global`?{globalApps:{...r.globalApps,[e]:kr(r.globalApps[e],t)}}:{apps:{...r.apps,[e]:kr(r.apps[e],t)}}}))}}))}const ri=j(null),ii=j({});function ai({plugins:e,enabled:t,disabled:n,globalPluginConfig:r,saveGlobalPluginConfig:i,children:a}){let o=I(()=>Lr(e),[e]),s=I(()=>ni({plugins:o,enabled:t,disabled:n,globalPluginConfig:r}),[]);P(()=>{s.getState().setProviderState({plugins:o,enabled:t,disabled:n,globalPluginConfig:r})},[s,o,t,n,r]);let c=I(()=>({globalPluginConfig:r,saveGlobalPluginConfig:i}),[r,i]);return xe(ii.Provider,{value:c},xe(ri.Provider,{value:s},a))}function oi(){return N(ri)}function si(){let e=oi();if(!e)throw Error(`usePluginStoreApi must be used within <PluginProvider />`);return e}function ci(e){let t=oi();return t?ke(t,e):e(Cr())}function li(){return ci(e=>({plugins:e.plugins,enabled:e.enabled,disabled:e.disabled,globalApps:e.globalApps,apps:e.apps}))}function ui(e){let t=N(yi),n=N(vi),r=li(),i=e||t?.appId;return I(()=>Ur(r,n,i),[r,n,i])}function di(){let e=oi();return I(()=>e?{enable(t,n,r){e.getState().enable(t,n,r||`workspace`)},disable(t,n,r){e.getState().disable(t,n,r||`workspace`)},setAppConfig(t,n){e.getState().setAppConfig(t,n)},setGlobalAppConfig(t,n){e.getState().setGlobalAppConfig(t,n)}}:{enable(){},disable(){},setAppConfig(){},setGlobalAppConfig(){}},[e])}function fi(e){let t=N(yi),n=li(),r=e||t?.appId;return I(()=>Yr(n,r),[n,r])}function pi(e,t){let n=N(yi),r=li(),i=t||n?.appId;return I(()=>Jr(r,e,i),[r,e,i])}function mi(e,t){let n=N(yi),r=oi(),i=li(),a=K(),o=It(),{saveGlobalPluginConfig:s}=N(ii),c=t||n?.appId||``,l=i.plugins.find(t=>t.metadata.id===e)||null,u=c?i.globalApps[c]:void 0,d=c?i.apps[c]:void 0,f=I(()=>qr(l||void 0),[l]),p=I(()=>Wr(u,e),[u,e]),m=I(()=>Wr(d,e),[d,e]),h=I(()=>Jr(i,e,c),[i,e,c]),g=M(e=>{c&&(r?.getState().setAppConfig(c,e),o({plugins:{...a.plugins||{},apps:{...a.plugins?.apps||{},[c]:e}}}))},[a.plugins,c,o,r]),_=M(t=>{g(Gr(d||{},e,t))},[g,e,d]),v=M(()=>{g(Kr(d||{},e))},[g,e,d]),y=M(async e=>{if(!c||!s)return;let t=i.globalApps[c]||{},n={apps:{...i.globalApps,[c]:e}};r?.getState().setGlobalAppConfig(c,e);try{await s(n)}catch(e){throw r?.getState().setGlobalAppConfig(c,t),e}},[c,s,i.globalApps,r]),b=M(async t=>{await y(Gr(u||{},e,t))},[u,y,e]),x=M(async()=>{await y(Kr(u||{},e))},[u,y,e]);return{plugin:l,appId:c,defaults:f,global:p,workspace:m,effective:h,canSaveGlobal:!!s,setWorkspaceSettings:_,resetWorkspaceSettings:v,setGlobalSettings:b,resetGlobalSettings:x}}function hi(e,t){let n=li(),r=oi(),i=I(()=>Ur(n,e,t),[n,e,t]);return P(()=>{if(r)for(let e of i)!e.load||e.loadStatus===`loading`||e.loadStatus===`loaded`||e.loadStatus===`error`||(r.getState().setPluginLoading(e.metadata.id),e.load().then(t=>{r.getState().setPluginLoaded(e.metadata.id,Ir(t))}).catch(t=>{r.getState().setPluginLoadError(e.metadata.id,gi(t))}))},[r,i]),I(()=>ti(e,i.filter(e=>!e.load||e.loadStatus===`loaded`),t),[e,i,t])}function gi(e){return e instanceof Error?e.message:typeof e==`string`?e:`Plugin failed to load.`}function _i({config:e}){let t=N(yi),n=oi(),r=t?.appId,i=r?e?.plugins?.apps?.[r]:void 0;return P(()=>{!n||!r||n.getState().setAppConfig(r,i||{})},[n,r,i]),null}const vi=j(null),yi=j(null),bi=j({state:null,setState:()=>{}});function xi(){let e=N(yi);return G(e,`Hook useAppInstance must be used inside <AppProvider />`),e}function Y(){let e=N(vi);return G(e,`Hook useApp must be used inside <AppProvider />`),e}function Si(){return N(bi)}function Ci(e,t){return e.find(e=>e.id===t)||null}function wi(){let e=Y(),{state:t,setState:n}=Si(),r=e.preset?.templates||[],i=typeof t?.presetTemplateId==`string`?t.presetTemplateId:null;return{templates:r,selectedTemplateId:i,selectedTemplate:I(()=>Ci(r,i),[i,r]),setSelectedTemplateId:M(e=>n({presetTemplateId:e}),[n])}}function Ti(e){let[t,n,r]=me(`app-state/${e.appId}/${e.instanceId}`,e.initialState||{}),i=M(e=>{let t=r.current?JSON.parse(r.current||`{}`):{},i=(typeof e==`function`?e(t):e)||{};n({...t,...i})},[]);P(()=>{e.args&&i(e.args)},[e.appId]);let a=I(()=>({state:t||{},setState:i}),[i,t]);return B(bi.Provider,{value:a,children:e.children})}function Ei({instanceId:e,appId:t,args:n,definition:r,children:i,initialState:a}){let o=I(()=>({instanceId:e,appId:t,args:n}),[e,t,n]),s=I(()=>a||{},[e]),c=hi(r,t);return B(Lt,{config:c.config||{},children:B(vi.Provider,{value:c,children:B(yi.Provider,{value:o,children:B(Ti,{instanceId:o.instanceId,appId:o.appId,args:o.args,initialState:s,children:i})})})})}const Di=j(null);function Oi(){let e=N(Di);return G(e,`Hook useApps must be used inside <MultiAppProvider />`),e}function ki(e,t=!1){let[n,r]=ge(`SelectedApplication`,e||{id:`splash`},!t);return[n,r]}function Ai({apps:e,initialApp:t,saveCurrentApp:n=!0,instanceId:r,children:i,config:a={}}){let{defaultApp:o=`splash`,collectionApp:s=`collection-editor`,manifestApp:c=`manifest-editor`}=a,[l,u]=ki(t,n),d=e=>{e===`Manifest`&&u({id:c}),e===`Collection`&&u({id:s})},f=I(()=>({currentApp:l||{id:o},initialApp:t||{id:o},apps:e,changeApp:u,changeProjectType:d}),[t,e,l]),p=e[f.currentApp.id];return!l||!p?null:B(Ei,{appId:l.id,definition:p,instanceId:l.id+r,args:l.args,children:B(Di.Provider,{value:f,children:i})})}const ji=U.div`
|
|
1
|
+
import{ActionButton as e,AddImageIcon as t,ArrowRightIcon as n,BackIcon as r,BackgroundActionMenuButton as i,BackgroundActionMenuDivider as a,BackgroundActionMenuInfoButton as o,BackgroundActionMenuInlineAction as s,BackgroundActionMenuItem as c,BackgroundActionMenuLabel as l,BackgroundActionMenuMeta as u,BackgroundActionMenuPanel as d,BackgroundActionMenuProgressBar as f,BackgroundActionMenuRoot as p,BackgroundActionMenuSection as m,BackgroundActionMenuText as h,BackgroundActionMenuTrigger as g,CheckIcon as _,CreatorGrid as v,DefaultTooltipContent as y,DownloadButton as b,EmptyState as x,ErrorMessage as S,Form as C,GridIcon as ee,IIIFBrowserI18nProvider as w,IIIFBrowserIcon as T,IIIFLogo as E,IconButton as D,IconHandle as O,InfoIcon as k,ManifestEditorLogo as A,Modal as te,ModalBackSlot as ne,PaddedSidebarContainer as re,PanelSideMenu as ie,ResetIcon as ae,ResizeHandle as oe,Sidebar as se,SidebarContent as j,SidebarHeader as ce,SidebarTabs as le,Spinner as ue,Tab as de,TabList as fe,TabPanel as pe,Tabs as me,ToastRegion as he,Tooltip as ge,TooltipTrigger as _e,VideoIcon as ve,YouTubeIcon as ye,useLocalStorage as be,useOptionalLocalStorage as xe,useOptionalLocalStorage as Se}from"@manifest-editor/components";import*as Ce from"react";import{Component as we,Fragment as Te,Suspense as Ee,createContext as M,createElement as De,createRef as Oe,forwardRef as ke,memo as Ae,useCallback as N,useContext as P,useEffect as F,useId as je,useImperativeHandle as Me,useLayoutEffect as Ne,useMemo as I,useReducer as Pe,useRef as L,useState as R}from"react";import{Fragment as z,jsx as B,jsxs as V}from"react/jsx-runtime";import{EditorI18nProvider as Fe,useEditorI18n as H,useOptionalEditorI18nInstance as Ie,useTranslations as U}from"@manifest-editor/i18n";import{create as Le,createStore as Re,useStore as ze}from"zustand";import{createEditorI18n as Be}from"@manifest-editor/i18n/core";import Ve from"localforage";import{AtlasStoreProvider as He,AtlasStoreProvider as Ue,AtlasStoreReactContext as We,CollectionContext as Ge,ImageServiceLoaderContext as Ke,ManifestContext as qe,ReactVaultContext as Je,ResourceReactContext as Ye,VaultProvider as Xe,useAtlasStore as Ze,useCurrentAnnotationMetadata as Qe,useExistingVault as $e,useManifest as et,useResourceContext as tt,useVault as W,useVaultSelector as nt}from"react-iiif-vault";import{isSpecificResource as rt,toRef as it}from"@iiif/parser";import{getValue as at}from"@iiif/helpers";import G,{ThemeProvider as ot,css as K}from"styled-components";import{IIIFNotebook as st,createNotebook as ct,noteResources as lt,notebookPlugin as ut,notebookResourceHistory as dt}from"iiif-browser/notebook";import*as ft from"@iiif/helpers/vault";import{Vault as pt}from"@iiif/helpers/vault";import{addReference as mt,batchActions as ht,modifyEntityField as gt,reorderEntityField as _t,requestResource as vt}from"@iiif/helpers/vault/actions";import{actionListFromResource as yt}from"@iiif/helpers/vault/utility";import{TaskItem as bt,TaskList as xt}from"@tiptap/extension-list";import{IIIFImage as St}from"iiif-browser/tiptap";import{MarkdownManager as Ct}from"@tiptap/markdown";import wt from"@tiptap/starter-kit";import{original as Tt,produce as Et}from"immer";import{EditorInstance as Dt}from"@manifest-editor/editor-api";import{useToastState as Ot}from"@react-stately/toast";import{Creator as kt,getCreatorConfigKey as At,matchBasedOnResource as jt}from"@manifest-editor/creator-api";import{ErrorBoundary as Mt}from"react-error-boundary";import Nt from"mitt";import{useDebounce as Pt}from"tiny-use-debounce";import{Transition as Ft}from"react-transition-group";import It from"shallowequal";import{ImageServiceLoader as Lt}from"@atlas-viewer/iiif-image-api";import{MessagePortClientVault as Rt}from"@manifest-editor/client-vault";var zt=Object.create,Bt=Object.defineProperty,Vt=Object.getOwnPropertyDescriptor,Ht=Object.getOwnPropertyNames,Ut=Object.getPrototypeOf,Wt=Object.prototype.hasOwnProperty,Gt=(e,t)=>()=>(t||(e((t={exports:{}}).exports,t),e=null),t.exports),Kt=(e,t,n,r)=>{if(t&&typeof t==`object`||typeof t==`function`)for(var i=Ht(t),a=0,o=i.length,s;a<o;a++)s=i[a],!Wt.call(e,s)&&s!==n&&Bt(e,s,{get:(e=>t[e]).bind(null,s),enumerable:!(r=Vt(t,s))||r.enumerable});return e},qt=(e,t,n)=>(n=e==null?{}:zt(Ut(e)),Kt(t||!e||!e.__esModule||!Wt.call(e,`default`)?Bt(n,`default`,{value:e,enumerable:!0}):n,e)),Jt=`Invariant failed`;function q(e,t){if(!e)throw Error(Jt)}function Yt(e,t){if(!(!e&&!t))return e&&Qt(e),t&&Qt(t),{...e,...t,requiredNamespaces:[...new Set([...e?.requiredNamespaces||[],...t?.requiredNamespaces||[]])]}}function Xt(e,t){if(!e&&!t)return;let n=(e,t)=>{let r={...e};for(let[e,i]of Object.entries(t||{}))r[e]=i&&typeof i==`object`&&!Array.isArray(i)?n(r[e],i):i;return r};return{...e,...t,config:{...e?.config,...t?.config},catalogs:n(e?.catalogs,t?.catalogs),profiles:n(e?.profiles,t?.profiles),presetProfiles:n(e?.presetProfiles,t?.presetProfiles),host:n(e?.host,t?.host),policies:[...e?.policies||[],...t?.policies||[]],presets:[...e?.presets||[],...t?.presets||[]],registrations:[...e?.registrations||[],...t?.registrations||[]],resourceLoaders:[...new Set([...e?.resourceLoaders||[],...t?.resourceLoaders||[]])],requiredNamespaces:[...new Set([...e?.requiredNamespaces||[],...t?.requiredNamespaces||[]])]}}const Zt={type:`object`,additionalProperties:!1,properties:{timeZone:{type:`string`,minLength:1},defaultLocale:{type:`string`,minLength:1},fallbackLocale:{type:`string`,minLength:1},defaultProfile:{type:`string`,minLength:1},availableLocales:{type:`array`,minItems:1,items:{type:`string`,minLength:1}},availableProfiles:{type:`array`,minItems:1,items:{type:`string`,minLength:1}},requiredNamespaces:{type:`array`,items:{type:`string`,minLength:1}}}};function Qt(e){if(!e||typeof e!=`object`||Array.isArray(e))throw TypeError(`uiI18n must be an object`);for(let[t,n]of Object.entries(e)){if(!Object.hasOwn(Zt.properties,t))throw TypeError(`Unknown uiI18n field: ${t}`);let e=Zt.properties[t];if(!e)throw TypeError(`Unknown uiI18n field: ${t}`);if(n!==void 0&&(t===`timeZone`&&new Intl.DateTimeFormat(`en-GB`,{timeZone:n}),e.type===`string`?typeof n!=`string`||!n.trim():!Array.isArray(n)||t!==`requiredNamespaces`&&!n.length||n.some(e=>typeof e!=`string`||!e.trim())))throw TypeError(`Invalid uiI18n field: ${t}`)}}const $t={previews:[],behaviorPresets:[`auto-advance`,`no-auto-advance`,`repeat`,`no-repeat`,`unordered`,`individuals`,`continuous`,`paged`,`non-paged`,`facing-pages`,`multi-part`,`together`,`sequence`,`thumbnail-nav`,`no-nav`,`hidden`],defaultPreview:null,editorConfig:{},newTemplates:null,i18n:{advancedLanguageMode:!1,availableLanguages:[`en`,`cy`,`nl`,`fr`],defaultLanguage:`en`},editorFeatureFlags:{enableMultiImageCanvases:!0,enableMultiMediaCanvases:!0,annotationPopups:!1,rememberCanvasId:!0,manifestGridOptions:!0,rememberLeftPanelId:!0},uploadBackends:[],plugins:{apps:{}},export:{baseIdentifier:null,version:3},creators:{"iiif-image-services":{compact:`with-dimensions`,includeSizes:!1,includeTiles:!1}}};function en(e,t){if(!e&&!t)return;let n={...e||{}};for(let[e,r]of Object.entries(t||{}))n[e]={...n[e]||{},...r||{}};return n}function tn(e,t){if(!e&&!t)return;let n={...e?.apps||{}};for(let[e,r]of Object.entries(t?.apps||{})){let t=n[e]||{};n[e]={...t,...r,settings:{...t.settings||{},...r.settings||{}}}}return{apps:n}}function nn(e,t){if(!e&&!t)return;let n={...e||{}};for(let[e,r]of Object.entries(t||{}))n[e]={...n[e]||{},...r||{}};return n}function rn(...e){let t={};for(let n of e)n&&(t={...t,...n,uiI18n:Yt(t.uiI18n,n.uiI18n),notebook:t.notebook||n.notebook?{...t.notebook,...n.notebook}:void 0,editorConfig:en(t.editorConfig,n.editorConfig),editorFeatureFlags:t.editorFeatureFlags||n.editorFeatureFlags?{...t.editorFeatureFlags||{},...n.editorFeatureFlags||{}}:void 0,i18n:t.i18n||n.i18n?{...t.i18n||{},...n.i18n||{}}:void 0,export:t.export||n.export?{...t.export||{},...n.export||{}}:void 0,creators:nn(t.creators,n.creators),plugins:tn(t.plugins,n.plugins)});return t}function an(...e){return rn($t,...e)}const on=M($t),sn=M(()=>{});function J(){return P(on)}function cn(){return P(sn)}function ln({children:e,config:t,saveConfig:n}){let[r,i]=R(null),a=I(()=>an(t,r),[t,r]),o=N(e=>{i(t=>rn(t,e)),n&&n(e)},[n]);return B(sn.Provider,{value:o,children:B(on.Provider,{value:a,children:e})})}function un(e){let t=e=>Object.entries(e).sort(([e],[t])=>e.localeCompare(t)).map(([e,t])=>[e,t.allowEmpty,[...t.placeholders].sort(),[...t.tags].sort()]);return JSON.stringify([t(e.messages),t(e.plurals)])}function dn(e,t){if(e===t)return!0;if(e.owner!==t.owner||e.namespace!==t.namespace||e.sourceLocale!==t.sourceLocale)return!1;let n=Object.keys(e.loaders);return n.length===Object.keys(t.loaders).length&&n.every(n=>e.loaders[n]===t.loaders[n])&&un(e.contract)===un(t.contract)}function fn(...e){let t=[];for(let n of e.flat())t.some(e=>dn(e,n))||t.push(n);return t}function pn(e){return e||Be()}function mn(e,t,n){return t?n.resolveMessage(t.labelMessage,t.label):n.resolveMessage(e.labelMessage,e.label)}function hn(e,t){return!e||e.status===`idle`?``:e.status===`error`?t.resolveMessage(e.error?.messageReference,e.error?.message)||t.resolveMessage(e.statusTextMessage,e.statusText)||t.translate(`shell`)(`background.error`):e.status===`complete`&&e.resultsAvailable?t.translate(`shell`)(`background.ready`):t.resolveMessage(e.statusTextMessage,e.statusText)||t.translate(`shell`)(`background.${e.status}`)}function Y(e,t){return{namespace:`shell`,key:`background.${e}`,defaultValue:t}}const gn=`@manifest-editor/canvas-progress`,_n=`status`,vn=new Set([`queued`,`pending`,`done`]);function yn(e){return typeof e==`string`?e:e?.id||null}function bn(e){return typeof e==`string`&&vn.has(e)?e:`none`}function xn(e){return typeof e==`string`&&vn.has(e)}function Sn(e,t){let n=yn(t);return n?bn(e.getResourceMeta(n,gn)?.[_n]):`none`}function Cn(e,t){let n=yn(t);return n?bn(e?.iiif?.meta?.[n]?.[gn]?.[_n]):`none`}function wn(e,t,n){let r=yn(t);if(!r)return`none`;let i=xn(n)?n:void 0;return e.setMetaValue([r,gn,_n],i),i||`none`}function Tn(e,t){return wn(e,t,`none`)}function En(e,t,n){let r={};for(let i of t){let t=yn(i);t&&(r[t]=wn(e,i,n))}return r}function Dn(e,t){return En(e,t,`none`)}function On(e){return{getStatus(t){return Sn(e,t)},setStatus(t,n){return wn(e,t,n)},clearStatus(t){return Tn(e,t)},setStatuses(t,n){return En(e,t,n)},clearStatuses(t){return Dn(e,t)}}}function kn(e,t=new Set){function n(e){let n=yn(e);n&&t.add(n)}function r(e){for(let t of e)n(t)}return{trackedResourceIds:t,getStatus(t){return e.getStatus(t)},setStatus(t,r){return n(t),e.setStatus(t,r)},clearStatus(t){return n(t),e.clearStatus(t)},setStatuses(t,n){return r(t),e.setStatuses(t,n)},clearStatuses(t){return r(t),e.clearStatuses(t)},clearTrackedStatuses(){e.clearStatuses(Array.from(t).map(e=>({id:e,type:`Canvas`}))),t.clear()}}}function An(e){let t=yn(e);return nt(e=>t?Cn(e,t):`none`,[t])}function jn(e){let t=W(),n=yn(e),r=I(()=>On(t),[t]);return I(()=>({setStatus(e){return r.setStatus(n,e)},clearStatus(){return r.clearStatus(n)},getStatus(){return r.getStatus(n)}}),[r,n])}const Mn={queued:{stripClass:`bg-zinc-400/80`,badgeClass:`bg-zinc-500`,dimOverlay:!0},pending:{stripClass:`bg-amber-400/90 animate-pulse`,badgeClass:`bg-amber-500`},done:{stripClass:`bg-me-primary-500`,badgeClass:`bg-me-primary-500`}};function Nn({className:e}){return V(`svg`,{className:e,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2.5`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[B(`circle`,{cx:`12`,cy:`12`,r:`9`}),B(`path`,{d:`M12 7v5l2.5 2.5`})]})}function Pn({className:e}){return V(`svg`,{className:e,viewBox:`0 0 24 24`,fill:`none`,children:[B(`circle`,{cx:`12`,cy:`12`,r:`9`,stroke:`currentColor`,strokeWidth:`2.5`,strokeOpacity:`0.3`}),B(`path`,{d:`M12 3a9 9 0 0 1 9 9`,stroke:`currentColor`,strokeWidth:`2.5`,strokeLinecap:`round`})]})}function Fn({className:e}){return B(`svg`,{className:e,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2.5`,strokeLinecap:`round`,strokeLinejoin:`round`,children:B(`path`,{d:`M5 12l4 4 8-8`})})}function In({resource:e,status:t,className:n}){return t?B(Rn,{status:t,className:n}):B(Ln,{resource:e,className:n})}function Ln({resource:e,className:t}){let n=An(e);return B(Rn,{status:n,className:t})}function Rn({status:e,className:t}){let n=U(`shell`);if(e===`none`)return null;let r=Mn[e];return V(z,{children:[r.dimOverlay&&B(`div`,{"aria-hidden":`true`,className:`pointer-events-none absolute inset-0 z-10 bg-white/40`}),B(`div`,{"aria-hidden":`true`,className:`pointer-events-none absolute inset-x-0 top-0 z-10 h-[3px] rounded-t-sm ${r.stripClass} ${t||``}`}),V(`div`,{className:`pointer-events-none absolute right-1.5 top-1.5 z-10 flex h-[18px] w-[18px] items-center justify-center rounded-full ${r.badgeClass} shadow-md ring-2 ring-white/70`,title:n(`progress.${e}`),children:[B(`span`,{className:`sr-only`,children:n(`progress.${e}`)}),e===`queued`&&B(Nn,{className:`h-2.5 w-2.5 text-white`}),e===`pending`&&B(Pn,{className:`h-2.5 w-2.5 animate-spin text-white`}),e===`done`&&B(Fn,{className:`h-2.5 w-2.5 text-white`})]})]})}function zn(e,t){return`${e}::${t.type}::${t.id}`}function Bn(e=[],t=[]){let n=[],r=new Set;for(let e=t.length-1;e>=0;--e){let i=t[e];i&&!r.has(i.id)&&(r.add(i.id),n.unshift(i))}return[...e.filter(e=>!r.has(e.id)),...n]}function Vn(e){return[...e].sort((e,t)=>{let n=(e.section||``).localeCompare(t.section||``);if(n!==0)return n;let r=(e.order||0)-(t.order||0);if(r!==0)return r;let i=e.label.localeCompare(t.label);return i===0?e.id.localeCompare(t.id):i})}function Hn(e){return e instanceof Error?{message:e.message,stack:e.stack,detail:e}:{message:typeof e==`string`?e:`Background action failed`,messageReference:typeof e==`string`?void 0:Y(`failedGeneric`,`Background action failed`),detail:e}}function Un(e){return e&&typeof e==`object`&&typeof e.message==`string`?{message:e.message,messageReference:e.messageReference,stack:typeof e.stack==`string`?e.stack:void 0,detail:e.detail}:Hn(e)}function Wn(e,t){return!e.resourceTypes?.length||e.resourceTypes.includes(t.type)}function Gn({definitions:e,instances:t,systemContext:n,targets:r,onSupportsError:i}){let a=Vn(e),o=[];for(let e of r){let r=[];for(let o of a){if(!Wn(o,e))continue;let a=zn(o.id,e),s={...n,definition:o,target:e,instanceKey:a,instance:t[a]};try{if(o.supports&&!o.supports(s))continue}catch(e){i?.(o,e);continue}r.push({definition:o,target:e,instanceKey:a,instance:t[a],context:s})}r.length&&o.push({id:`${e.scope}:${e.type}:${e.id}`,label:e.label,target:e,actions:r})}return o}let Kn=0;function qn(e){return Kn+=1,`${e}-${Date.now()}-${Kn}`}function Jn(e,t,n,r=Date.now(),i){return{id:qn(`event`),createdAt:r,type:e,message:t,messageReference:i,data:n}}function Yn(e,t,n,r,i=Date.now(),a=t===`label`?e.labelMessage:t===`status`?e.statusTextMessage:void 0){return{...e,events:[...e.events,Jn(t,n,r,i,a)]}}function Xn(e){return e.filter(e=>String(e.type)!==`progress`)}function Zn(e){return{...e,logs:[...e.logs],events:Xn(e.events),progress:e.progress?{...e.progress}:void 0}}function Qn(e,t,n){if(!rr(n.status))return e;let r=e[t]||[],i=Zn(n),a=r.findIndex(e=>e.runId===n.runId),o=a>=0?r.map((e,t)=>t===a?i:e):[...r,i];return{...e,[t]:o}}function $n(e,t,n){let r=e.instances[t];if(!r)return{instances:e.instances,histories:e.histories};let i=n(r);return{instances:{...e.instances,[t]:i},histories:Qn(e.histories,t,i)}}function er(e){return Number.isFinite(e)?Math.min(100,Math.max(0,e)):0}function tr(e){let t=e,n=typeof t.current==`number`&&Number.isFinite(t.current)?t.current:void 0,r=typeof t.total==`number`&&Number.isFinite(t.total)?t.total:void 0;return{percent:er(typeof t.percent==`number`&&Number.isFinite(t.percent)?t.percent:typeof n==`number`&&typeof r==`number`&&r>0?n/r*100:0),current:n,total:r,label:t.label,labelMessage:t.labelMessage}}function nr(e){return e===`preparing`||e===`running`}function rr(e){return e===`complete`||e===`error`||e===`cancelled`}function ir(e){return e===`queued`||e===`running`||e===`complete`||e===`skipped`||e===`error`||e===`cancelled`}function ar(e){return!e||e===`queued`||e===`running`}function or(e){return e===`complete`||e===`skipped`||e===`error`||e===`cancelled`}function sr(e){if(e!==void 0)try{return JSON.parse(JSON.stringify(e))}catch{return}}function cr(e){return e&&{message:e.message,messageReference:e.messageReference,stack:e.stack,detail:sr(e.detail)}}function lr(e){return{...e,error:cr(e.error)||null,result:sr(e.result),logs:e.logs.map(e=>({...e,data:sr(e.data)})),events:Xn(e.events).map(e=>({...e,data:sr(e.data)})),progress:e.progress?{...e.progress}:void 0}}function ur(e){return{...e,status:gr(e.status),input:sr(e.input),result:sr(e.result),error:cr(e.error)||null}}function dr(e){return{version:1,data:sr(e.data),tasks:e.tasks.map(ur)}}function fr(e){return{version:1,savedAt:Date.now(),instances:Object.fromEntries(Object.entries(e.instances).map(([e,t])=>[e,lr(t)])),histories:Object.fromEntries(Object.entries(e.histories).map(([e,t])=>[e,t.map(lr)])),plans:Object.fromEntries(Object.entries(e.plans).map(([e,t])=>[e,dr(t)]))}}function pr(){return{version:1,savedAt:Date.now(),instances:{},histories:{},plans:{}}}function mr(e,t){return{version:1,savedAt:t.savedAt,instances:{...e.instances,...t.instances},histories:{...e.histories,...t.histories},plans:{...e.plans,...t.plans}}}function hr(e){return!Object.keys(e.instances).length&&!Object.keys(e.histories).length&&!Object.keys(e.plans).length}function gr(e){return ir(e)?e:`queued`}function _r(e,t){let n=Date.now(),r=typeof e.id==`string`&&e.id?e.id:`task-${t+1}`;return{...e,id:r,label:typeof e.label==`string`&&e.label?e.label:r,status:gr(e.status),error:e.error?Un(e.error):null,createdAt:typeof e.createdAt==`number`?e.createdAt:n}}function vr(e){return!e||e.version!==1||!Array.isArray(e.tasks)?null:{version:1,data:e.data,tasks:e.tasks.map(_r)}}function yr(e){return{...e,tasks:e.tasks.map(e=>e.status===`running`?{...e,status:`queued`,statusText:`Queued after reload`,statusTextMessage:{namespace:`shell`,key:`background.requeued`},startedAt:void 0}:e)}}function br(e,t=Date.now()){return{...e,tasks:e.tasks.map(e=>ar(e.status)?{...e,status:`cancelled`,statusText:`Cancelled`,statusTextMessage:{namespace:`shell`,key:`background.cancelled`},error:null,completedAt:t}:e)}}function xr(e){return{...e,error:e.error?Un(e.error):null,logs:Array.isArray(e.logs)?e.logs:[],events:Xn(Array.isArray(e.events)?e.events:[]),resultsAvailable:e.resultsAvailable===!0}}function Sr(e){return!e||e.version!==1?pr():{version:1,savedAt:typeof e.savedAt==`number`?e.savedAt:Date.now(),instances:e.instances||{},histories:e.histories||{},plans:e.plans||{}}}function Cr(e,t,n){let r=e,i=t;if(nr(e.status)){if(e.cancelRequestedAt){let t=Date.now();i=i&&br(i,t),r=Yn({...e,status:`cancelled`,statusText:`Cancelled`,statusTextMessage:{namespace:`shell`,key:`background.cancelled`},completedAt:t,cancelledAt:t},`status`,`Cancelled`,{status:`cancelled`},t,Y(`cancelled`,`Cancelled`))}else if(n.resumable&&i)i=yr(i),r=Yn({...e,status:`running`,statusText:`Resuming`,statusTextMessage:{namespace:`shell`,key:`background.resuming`},completedAt:void 0,cancelledAt:void 0},`status`,`Resuming`,{status:`running`},void 0,Y(`resuming`,`Resuming`));else{let t=Date.now();r=Yn({...e,status:`cancelled`,statusText:`Interrupted by page reload`,statusTextMessage:{namespace:`shell`,key:`background.interrupted`},completedAt:t,cancelledAt:t},`status`,`Interrupted by page reload`,{status:`cancelled`},t,Y(`interrupted`,`Interrupted by page reload`))}}return{instance:r,plan:i}}function wr(e,t){let n=Sr(e),r=new Map(t.map(e=>[e.id,e])),i={},a={},o={},s=pr();for(let[e,t]of Object.entries(n.histories)){let n=(Array.isArray(t)?t:[]).map(xr),i=n.filter(e=>r.has(e.actionId)),o=n.filter(e=>!r.has(e.actionId));i.length&&(a[e]=i),o.length&&(s.histories[e]=o)}for(let[e,t]of Object.entries(n.instances)){let c=xr(t),l=vr(n.plans[e]),u=r.get(c.actionId);if(!u){s.instances[e]=lr(c),l&&(s.plans[e]=dr(l));continue}let d=Cr(c,l,u);i[e]=d.instance,a=Qn(a,e,d.instance),d.plan&&(o[e]=d.plan)}return{instances:i,histories:a,plans:o,deferred:s}}function Tr(e,t,n){let r=e.tasks.length;if(!r)return;let i=e.tasks.filter(e=>or(e.status)).length;return tr({current:i,total:r,label:t,labelMessage:n})}function Er(e){return e&&typeof e==`object`&&`taskStatus`in e&&(e.taskStatus===`complete`||e.taskStatus===`skipped`)?{taskStatus:e.taskStatus,result:e.result,statusText:e.statusText,statusTextMessage:e.statusTextMessage}:{taskStatus:`complete`,result:e}}function Dr(e,t){for(let n of t.tasks)!n.target||n.target.type!==`Canvas`||(n.status===`running`?e.setStatus(n.target,`pending`):n.status===`queued`&&e.setStatus(n.target,`queued`))}function Or(e,t,n){let{store:r,context:i}=e,{instanceKey:a}=i;function o(){return r.getState().plans[a]}function s(){return o()?.tasks||[]}function c(e=[`queued`,`running`]){let t=new Set(e);return s().filter(e=>t.has(gr(e.status)))}function l(e,t,n=!1){r.getState().updateActionTask(a,e,t,n)}async function u(e,i={}){let u=c(i.statuses||[`queued`,`running`]),d=s().length,f=u.length,p=i.yieldEveryMs===!1?!1:i.yieldEveryMs??16,m=0;for(let[c,h]of u.entries()){if(t.aborted||kr(m,p)&&(await Ar(),m=Date.now(),t.aborted))throw Error(`Background action cancelled.`);let u=s().find(e=>e.id===h.id)||h,g=s().findIndex(e=>e.id===u.id),_=i.progressLabel?.(u,g,d)||u.label||`Task ${g+1}/${d}`,v=i.progressLabel?void 0:u.labelMessage||(u.label?void 0:{namespace:`shell`,key:`background.task`,values:{current:g+1,total:d},defaultValue:`Task {{current}}/{{total}}`});u.target?.type===`Canvas`&&n.setStatus(u.target,`pending`),l(u.id,{status:`running`,statusText:_,statusTextMessage:v,error:null,startedAt:Date.now(),completedAt:void 0},!0),r.getState().setActionStatus(a,`running`,_,v),r.getState().setActionProgress(a,{current:s().filter(e=>or(e.status)).length,total:d,label:_,labelMessage:v});try{let r=await e(u,{index:g,total:d,pendingIndex:c,pendingTotal:f});if(t.aborted)throw Error(`Background action cancelled.`);let i=Er(r);l(u.id,{status:i.taskStatus,statusText:i.statusText||(i.taskStatus===`skipped`?`Skipped`:`Complete`),statusTextMessage:i.statusTextMessage||(i.statusText?void 0:Y(i.taskStatus===`skipped`?`skipped`:`complete`,i.taskStatus===`skipped`?`Skipped`:`Complete`)),result:i.result,error:null,completedAt:Date.now()},!0),u.target?.type===`Canvas`&&n.setStatus(u.target,`done`)}catch(e){if(t.aborted||Fr(e))throw l(u.id,{status:`cancelled`,statusText:`Cancelled`,statusTextMessage:{namespace:`shell`,key:`background.cancelled`},error:null,completedAt:Date.now()},!0),e;let n=Hn(e);l(u.id,{status:`error`,statusText:n.message,error:n,completedAt:Date.now()},!0),r.getState().appendActionLog(a,`Task failed: ${u.label}`,`warn`,{taskId:u.id,error:n.message})}finally{let e=o();e&&r.getState().setActionProgress(a,{current:e.tasks.filter(e=>or(e.status)).length,total:d,label:_})}}return s()}return{getAll:s,getPending:()=>c(),update:l,runEach:u}}function kr(e,t){return t!==!1&&(!e||Date.now()-e>=t)}function Ar(){return new Promise(e=>{setTimeout(e,0)})}function jr(e=[]){let t=null,n=null,r=null,i=pr();return Re((a,o)=>{function s(e,t){let n=Bn([],t),r=wr(i,n);return i=r.deferred,{definitions:n,instances:{...e.instances,...r.instances},histories:{...e.histories,...r.histories},plans:{...e.plans,...r.plans},controllers:Object.fromEntries(Object.entries(e.controllers).filter(([t,n])=>n&&e.instances[t]?.status&&nr(e.instances[t].status)))}}async function c(){if(r&&(clearTimeout(r),r=null),!t||!n||!o().hasHydrated)return;let e=mr(i,fr(o()));if(hr(e)){await t.clear(n);return}await t.save(n,e)}function l(e=!1){if(!(!t||!n||!o().hasHydrated)){if(e){c();return}r&&clearTimeout(r),r=setTimeout(()=>{c()},300)}}return{definitions:Bn([],e),instances:{},histories:{},plans:{},controllers:{},hasHydrated:!0,setDefinitions(e){a(t=>s(t,e)),l()},setPersistence(e,r){t=e,n=e&&r?r:null,a({hasHydrated:!t})},hydrate(e){let t=wr(Sr(e),o().definitions);i=t.deferred,a({instances:t.instances,histories:t.histories,plans:t.plans,controllers:{},hasHydrated:!0}),l(!0)},persist(e=!1){l(e)},flushPersistence:c,registerAction(e){return a(t=>s(t,Bn(t.definitions,[e]))),l(),()=>o().unregisterAction(e.id)},unregisterAction(e){a(t=>{let n={};for(let[r,i]of Object.entries(t.instances))i.actionId!==e&&(n[r]=i);let r={};for(let[n,i]of Object.entries(t.histories)){let t=i.filter(t=>t.actionId!==e);t.length&&(r[n]=t)}let i={...t.plans},a={...t.controllers};for(let[n,r]of Object.entries(t.instances))r.actionId===e&&(a[n]?.abort(),delete a[n],delete i[n]);return{definitions:t.definitions.filter(t=>t.id!==e),instances:n,histories:r,plans:i,controllers:a}}),l(!0)},resetAction(e){a(t=>{t.controllers[e]?.abort();let n={...t.instances},r={...t.histories},i={...t.plans},a={...t.controllers};return delete n[e],delete r[e],delete i[e],delete a[e],{instances:n,histories:r,plans:i,controllers:a}}),l(!0)},startAction(e,t,n,r){let i=Date.now();a(a=>{let o={...a.plans};return delete o[e],{instances:{...a.instances,[e]:{id:e,runId:qn(`run`),actionId:t.id,target:n,label:t.label,labelMessage:t.labelMessage,status:`preparing`,statusText:`Preparing`,statusTextMessage:{namespace:`shell`,key:`background.preparing`},error:null,result:void 0,resultsAvailable:!1,logs:[],events:[Jn(`started`,`Preparing`,{status:`preparing`},i,Y(`preparing`,`Preparing`))],progress:void 0,startedAt:i,completedAt:void 0,cancelRequestedAt:void 0,cancelledAt:void 0}},plans:o,controllers:r?{...a.controllers,[e]:r}:a.controllers}}),l(!0)},resumeAction(e,t){let n=Date.now();a(r=>({...$n(r,e,e=>Yn({...e,status:`running`,statusText:`Resuming`,statusTextMessage:{namespace:`shell`,key:`background.resuming`},completedAt:void 0,cancelledAt:void 0},`status`,`Resuming`,{status:`running`},n,Y(`resuming`,`Resuming`))),controllers:{...r.controllers,[e]:t}})),l(!0)},cancelAction(e){let t=o().controllers[e],n=o().instances[e];if(!n||!nr(n.status))return;let r=Date.now();a(t=>{let n=$n(t,e,e=>Yn(Yn({...e,status:`cancelled`,statusText:`Cancelled`,statusTextMessage:{namespace:`shell`,key:`background.cancelled`},completedAt:r,cancelledAt:r,cancelRequestedAt:e.cancelRequestedAt||r},`cancel-requested`,`Cancelling`,void 0,r,Y(`cancelling`,`Cancelling`)),`status`,`Cancelled`,{status:`cancelled`},r,Y(`cancelled`,`Cancelled`))),i=t.plans[e];return{...n,plans:i?{...t.plans,[e]:br(i,r)}:t.plans,controllers:Object.fromEntries(Object.entries(t.controllers).filter(([t])=>t!==e))}}),l(!0),t?.abort()},setActionLabel(e,t,n){let r=Date.now();a(i=>({...$n(i,e,e=>Yn({...e,label:t,labelMessage:n},`label`,t,{label:t},r))})),l()},setActionStatus(e,t,n,r){let i=Date.now(),o=rr(t)?i:void 0;a(a=>({...$n(a,e,e=>Yn({...e,status:t,statusText:n,statusTextMessage:r,completedAt:o,cancelledAt:t===`cancelled`?i:void 0},`status`,n||t,{status:t},i)),controllers:nr(t)?a.controllers:Object.fromEntries(Object.entries(a.controllers).filter(([t])=>t!==e))})),l(rr(t))},setActionError(e,t,n,r){let i=Date.now(),o=Hn(t);a(t=>({...$n(t,e,e=>Yn({...e,status:`error`,statusText:n,statusTextMessage:r,error:o,completedAt:i,cancelledAt:void 0},`error`,n||o.message,o,i)),controllers:Object.fromEntries(Object.entries(t.controllers).filter(([t])=>t!==e))})),l(!0)},appendActionLog(e,t,n=`info`,r,i){let o=Date.now(),s={id:qn(`log`),createdAt:o,level:n,message:t,messageReference:i,data:r};a(i=>({...$n(i,e,e=>Yn({...e,logs:[...e.logs,s]},`log`,t,{level:n,data:r},o))})),l()},setActionProgress(e,t){let n=t?tr(t):void 0;a(t=>({...$n(t,e,e=>({...e,progress:n}))}))},setResult(e,t){let n=Date.now();a(r=>({...$n(r,e,e=>Yn({...e,result:t},`result`,`Result recorded`,void 0,n,Y(`resultRecorded`,`Result recorded`)))})),l(!0)},setResultsAvailable(e,t){let n=Date.now();a(r=>({...$n(r,e,e=>Yn({...e,resultsAvailable:t},`results-available`,t?`Results available`:`Results hidden`,{available:t},n,t?Y(`resultsAvailable`,`Results available`):Y(`resultsHidden`,`Results hidden`)))})),l(!0)},setActionPlan(e,t){let n=vr(t);n&&(a(t=>({...$n(t,e,e=>({...e,progress:Tr(n,`Queued`,Y(`queued`,`Queued`))})),plans:{...t.plans,[e]:n}})),l(!0))},updateActionTask(e,t,n,r=!1){a(r=>{let i=r.plans[e];if(!i)return r;let a=i.tasks.map(e=>e.id===t?_r({...e,...n,status:n.status?gr(n.status):e.status,error:n.error?Un(n.error):n.error===null?null:e.error},0):e),o={...i,tasks:a};return{...$n(r,e,e=>({...e,progress:Tr(o,n.statusText||n.label)})),plans:{...r.plans,[e]:o}}}),l(r)}}})}function Mr(e,t,n){let{store:r,context:i}=e,{instanceKey:a}=i,o=Or(e,t,n);return{...i,i18n:pn(i.i18n),canvasProgress:n,instance:r.getState().instances[a],plan:r.getState().plans[a],tasks:o,signal:t,prepareData:e.prepareData,setActionLabel(e,t){r.getState().setActionLabel(a,e,t)},setActionStatus(e,t,n){r.getState().setActionStatus(a,e,t,n)},setActionError(e,t,n){r.getState().setActionError(a,e,t,n)},appendActionLog(e,t,n,i){r.getState().appendActionLog(a,e,t,n,i)},setActionProgress(e){r.getState().setActionProgress(a,e)},setResult(e){r.getState().setResult(a,e)},setResultsAvailable(e){r.getState().setResultsAvailable(a,e)}}}function Nr(e){return!!e&&typeof e==`object`&&e.version===1&&Array.isArray(e.tasks)}async function Pr(e){let{store:t,context:n}=e,{definition:r,instanceKey:i,target:a}=n,o=t.getState().instances[i],s=t.getState().controllers[i];if((o?.status===`preparing`||o?.status===`running`)&&(!e.resume||s))return o;let c=new AbortController,l=c.signal,u=kn(n.canvasProgress),d=()=>c.abort();e.signal&&(e.signal.aborted?c.abort():e.signal.addEventListener(`abort`,d,{once:!0})),e.resume&&o&&nr(o.status)?t.getState().resumeAction(i,c):t.getState().startAction(i,r,a,c);let f=()=>{let e=t.getState().instances[i];e&&!rr(e.status)&&t.getState().setActionStatus(i,`cancelled`,`Cancelled`,Y(`cancelled`,`Cancelled`))};try{if(!e.resume&&r.prepare){let n=await r.prepare(Mr(e,l,u));if(l.aborted)return f(),t.getState().instances[i];if(n===!1)return t.getState().setActionStatus(i,`idle`),t.getState().instances[i];Nr(n)&&t.getState().setActionPlan(i,n)}if(l.aborted)return f(),t.getState().instances[i];let n=t.getState().plans[i];n&&Dr(u,n),t.getState().setActionStatus(i,`running`,e.resume?`Resuming`:`Running`,Y(e.resume?`resuming`:`running`,e.resume?`Resuming`:`Running`));let a=await r.run(Mr(e,l,u));if(l.aborted)return f(),t.getState().instances[i];let o=t.getState().instances[i];a!==void 0&&o&&!rr(o.status)&&t.getState().setResult(i,a),o=t.getState().instances[i],o&&nr(o.status)&&((a!==void 0||o?.resultsAvailable)&&t.getState().setResultsAvailable(i,!0),t.getState().setActionStatus(i,`complete`,`Complete`,Y(`complete`,`Complete`)))}catch(e){l.aborted||Fr(e)?f():t.getState().setActionError(i,e,`Error`,Y(`error`,`Error`))}finally{u.clearTrackedStatuses(),e.signal?.removeEventListener(`abort`,d),await t.getState().flushPersistence()}return t.getState().instances[i]}function Fr(e){return e instanceof Error&&(e.name===`AbortError`||e.message.toLowerCase().includes(`aborted`))}function Ir(e){return JSON.stringify([e.appId,e.instanceId,e.rootResource.type,e.rootResource.id])}let Lr;function Rr(){if(typeof window>`u`)return null;let e=Ve.createInstance({name:`manifest-editor-background-actions-v1`,storeName:`background-actions`});return{async load(t){return e.getItem(Ir(t))},async save(t,n){await e.setItem(Ir(t),n)},async clear(t){await e.removeItem(Ir(t))}}}function zr(){return Lr===void 0&&(Lr=Rr()),Lr}const Br=M(null);function Vr({children:e,persistence:t,persistenceKey:n}){let r=X(),i=ia(),a=I(()=>jr(),[]),o=r.layout.backgroundActions||[],s=I(()=>t===!1?null:t||zr(),[t]),c=I(()=>n||null,[n]);return F(()=>{a.getState().setDefinitions(o)},[a,o]),F(()=>{let e=c||{appId:i.appId,instanceId:i.instanceId,rootResource:{id:`global`,type:`Manifest`}},t=!1;return a.getState().setPersistence(s,e),s?(s.load(e).then(e=>{t||a.getState().hydrate(e)}).catch(e=>{console.warn(`[manifest-editor/background-actions] Failed to load persisted actions`,e),t||a.getState().hydrate(null)}),()=>{t=!0,a.getState().flushPersistence()}):(a.getState().hydrate(null),()=>void 0)},[i.appId,i.instanceId,s,c?.appId,c?.instanceId,c?.rootResource.id,c?.rootResource.type,a]),F(()=>{let e=()=>{a.getState().flushPersistence()};return window.addEventListener(`beforeunload`,e),()=>window.removeEventListener(`beforeunload`,e)},[a]),De(Br.Provider,{value:a},e)}function Hr(){let e=P(Br);if(!e)throw Error(`useBackgroundActionsStore must be used within a BackgroundActionsProvider`);return e}function Ur(e=e=>e){return ze(Hr(),e)}function Wr(e){return Ur(t=>t.instances[e])}function Gr(e){return Ur(t=>t.histories[e]||[])}async function Kr(e){let t;try{await fetch(e).then(e=>e.json().catch(e=>{console.error(`'${e}' happened!`)})).then(e=>{t={...e}})}catch(e){console.log(e)}return t}function qr(e,t,n){return`create_${e}_${t}_${it(n)?.type||`unknown`}`}function Jr(e,t,n=`text/json`){let r=e instanceof Blob?e:new Blob([e],{type:n}),i=document.createElement(`a`);i.download=t,i.href=window.URL.createObjectURL(r);let a=new MouseEvent(`click`,{view:window,bubbles:!0,cancelable:!0});i.dispatchEvent(a),i.remove()}async function Yr(e){return navigator.clipboard.writeText(typeof e==`string`?e:JSON.stringify(e,null,2))}function Xr(){return`${Math.random().toString(36).substr(2)}-${Date.now().toString(36)}`}function Zr(e,t){let{default:n,config:r,preset:i,...a}=e,o={metadata:n,layout:{leftPanels:[],rightPanels:[],centerPanels:[],...a},config:r,preset:i},s=t?t(o):o;return{...s,preset:Qr(void 0,s.preset)}}function Qr(e,t){if(!e&&!t)return;let n=e?.templateFilter&&t?.templateFilter?n=>e.templateFilter(n)&&t.templateFilter(n):t?.templateFilter||e?.templateFilter,r=t?.templateStrategy===`replace`?t.templates||[]:[...e?.templates||[],...t?.templates||[]],i=e?.preview||t?.preview?{...e?.preview||{},...t?.preview||{},actions:[...e?.preview?.actions||[],...t?.preview?.actions||[]]}:void 0;return{...e||{},...t||{},localisation:Xt(e?.localisation,t?.localisation),templateFilter:n,templates:n?r.filter(n):r,preview:i}}function $r(e,t,n){return{...e,metadata:t,config:rn(e.config||{},n.config||{}),preset:Qr(e.preset,n.preset),layout:{...e.layout,leftPanels:[...(e.layout.leftPanels||[]).filter(e=>!n?.leftPanelIds||n.leftPanelIds.includes(e.id)),...n?.leftPanels||[]],annotations:[...n?.annotations||[],...e.layout.annotations||[]],canvasEditors:[...n?.canvasEditors||[],...e.layout.canvasEditors||[]],creators:[...n?.creators||[],...e.layout.creators||[]],background:[...e.layout?.background||[],...n?.background||[]],backgroundActions:Bn(e.layout?.backgroundActions||[],n?.backgroundActions||[]),editors:[...n?.editors||[],...e.layout.editors||[]],rightPanels:[...e.layout.rightPanels||[],...n?.rightPanels||[]],centerPanels:[...e.layout.centerPanels||[],...n?.centerPanels||[]],modals:[...e.layout.modals||[],...n?.modalPanels||[]]}}}const ei=[`leftPanels`,`centerPanels`,`rightPanels`,`modalPanels`,`annotations`,`canvasEditors`,`editors`,`creators`,`background`,`backgroundActions`],ti={plugins:[],enabled:[],disabled:[],globalApps:{},apps:{}};function ni(){return ti}function ri(e=[]){return Array.from(new Set(e.filter(Boolean)))}function ii(e){return!!e&&typeof e==`object`&&!Array.isArray(e)}function ai(e={}){return{...e,enabled:ri(e.enabled||[]),disabled:ri(e.disabled||[]),settings:e.settings?{...e.settings}:void 0}}function oi(e){let t={};for(let[n,r]of Object.entries(e?.apps||{}))t[n]=ai(r);return t}function si(e={},t){return{...e,enabled:ri([...(e.enabled||[]).filter(e=>e!==t),t]),disabled:(e.disabled||[]).filter(e=>e!==t)}}function ci(e={},t){return{...e,enabled:(e.enabled||[]).filter(e=>e!==t),disabled:ri([...(e.disabled||[]).filter(e=>e!==t),t])}}function li(e={},t){return{...e,enabled:(e.enabled||[]).filter(e=>e!==t),disabled:(e.disabled||[]).filter(e=>e!==t)}}function ui(e={},t={}){let n=e.enabled||[],r=t.enabled||[],i=e.disabled||[],a=t.disabled||[];return n.length===r.length&&n.every((e,t)=>e===r[t])&&i.length===a.length&&i.every((e,t)=>e===a[t])&&JSON.stringify(e.settings||{})===JSON.stringify(t.settings||{})}function di(e,t){let{default:n,config:r,settings:i,...a}=e,o={metadata:n,extension:{...a,config:r},settings:i};return t?t(o):o}function fi(e){return{metadata:e.default,extension:{},settings:e.settings,load:e.load,loadStatus:`idle`}}function pi(e){return!!e&&`metadata`in e&&`extension`in e}function mi(e){return!!e&&`load`in e&&`default`in e}function hi(e){return pi(e)?e:mi(e)?fi(e):di(e)}function gi(e=[]){return e.map(hi)}function _i(e,t){let n=new Map(e.map(e=>[e.metadata.id,e]));return t.map(e=>{let t=n.get(e.metadata.id);return t?t.loadStatus===`loaded`&&e.load?{...t,metadata:e.metadata,load:e.load}:t.loadStatus===`loading`&&e.load?{...e,loadStatus:`loading`}:t.loadStatus===`error`&&e.load?{...e,loadStatus:`error`,loadError:t.loadError}:e:e})}function vi(e,t,n){let r=e.metadata.supports;if(!r)return!0;if(r.apps?.length){let e=new Set([n,t?.metadata.id].filter(Boolean));if(!r.apps.some(t=>e.has(t)))return!1}if(r.projectTypes?.length){let e=t?.metadata.projectType;if(!e||!r.projectTypes.includes(e))return!1}return!0}function yi(e,t,n,r){let i=e.metadata.supports;if(!i)return null;if(i.apps?.length){let e=new Set([n,t?.metadata.id].filter(Boolean));if(!i.apps.some(t=>e.has(t)))return r?.app||`This plugin does not support the current app.`}if(i.projectTypes?.length){let e=t?.metadata.projectType;if(!e||!i.projectTypes.includes(e))return r?.project||`This plugin does not support the current project type.`}return null}function bi(e,t,n){let r=n?t.apps[n]:void 0,i=n?t.globalApps[n]:void 0,a=e.metadata.id;return r?.disabled?.includes(a)?!1:r?.enabled?.includes(a)?!0:i?.disabled?.includes(a)?!1:i?.enabled?.includes(a)?!0:t.disabled.includes(a)?!1:t.enabled.includes(a)?!0:e.metadata.defaultEnabled===!0}function xi(e,t,n){let r=n?t.apps[n]:void 0,i=n?t.globalApps[n]:void 0,a=e.metadata.id;return r?.disabled?.includes(a)||r?.enabled?.includes(a)?`workspace`:i?.disabled?.includes(a)||i?.enabled?.includes(a)?`global`:t.disabled.includes(a)||t.enabled.includes(a)?`provider`:`default`}function Si(e,t,n){let r=[],i=new Set,a=new Set,o=new Set(e.plugins.filter(r=>vi(r,t,n)&&bi(r,e,n)).map(e=>e.metadata.id)),s=new Map(e.plugins.map(e=>[e.metadata.id,e])),c=new Set;function l(e){let u=e.metadata.id;if(i.has(u))return!0;if(a.has(u))return!1;if(c.has(u))return ji(`Plugin "${u}" was not enabled because its dependency graph contains a cycle.`),a.add(u),!1;c.add(u);for(let r of e.metadata.dependencies||[]){let e=s.get(r);if(!e||!o.has(r))return ji(`Plugin "${u}" was not enabled because dependency "${r}" is not enabled.`),c.delete(u),a.add(u),!1;if(!vi(e,t,n))return ji(`Plugin "${u}" was not enabled because dependency "${r}" is not compatible.`),c.delete(u),a.add(u),!1;if(!l(e))return c.delete(u),a.add(u),!1}return c.delete(u),r.push(e),i.add(u),!0}for(let r of e.plugins)vi(r,t,n)&&bi(r,e,n)&&l(r);return r}function Ci(e,t){let n=e?.settings?.[t];return ii(n)?n:{}}function wi(e={},t,n){return{...e,settings:{...e.settings||{},[t]:n}}}function Ti(e={},t){let n={...e.settings||{}};return delete n[t],{...e,settings:n}}function Ei(e){return{...e?.settings?.defaults||{}}}function Di(e,t,n){let r=e.plugins.find(e=>e.metadata.id===t),i=n?e.globalApps[n]:void 0,a=n?e.apps[n]:void 0;return{...Ei(r),...Ci(i,t),...Ci(a,t)}}function Oi(e,t){return{getSettings(n){return Di(e,n,t)}}}function ki(e,t,n,r,i){let a=new Map(t.plugins.map(e=>[e.metadata.id,e])),o=[],s=[],c=new Set,l=e;function u(e){let t=e.metadata.id;if(!o.includes(t)){if(c.has(t)){s.push(`${t} has a circular dependency`);return}c.add(t);for(let t of e.metadata.dependencies||[]){let e=a.get(t);if(!e){s.push(`${t} is not available`);continue}if(!vi(e,r,i)){s.push(`${e.metadata.label} is not compatible`);continue}u(e)}c.delete(t),l=si(l,t),o.push(t)}}return u(n),s.length?{config:e,enabledIds:[],blocked:s}:{config:l,enabledIds:o,blocked:s}}function Ai(e,t){return t===`modalPanels`?e.layout.modals||[]:e.layout[t]||[]}function ji(e){globalThis.process?.env?.NODE_ENV!==`production`&&console.warn(`[manifest-editor/plugin] ${e}`)}function Mi(e,t,n,r){if(!r?.length)return;let i=[];for(let a of r){if(n.has(a.id)){ji(`Plugin "${e.metadata.id}" contribution "${a.id}" for "${t}" was skipped because that id already exists.`);continue}n.add(a.id),i.push(a)}return i.length?i:void 0}function Ni(e,t){let n=t.extension,r={config:n.config,preset:n.preset,disableSideEffects:n.disableSideEffects};for(let i of ei){let a=Mi(t,i,new Set(Ai(e,i).map(e=>e.id)),n[i]);a&&(r[i]=a)}return r}function Pi(e,t,n){if(!t.length)return e;let r=e,i=new Set;for(let a of t){if(!vi(a,e,n))continue;let t=(a.metadata.dependencies||[]).filter(e=>!i.has(e));if(t.length){ji(`Plugin "${a.metadata.id}" was not applied because dependencies are missing or later in the plugin order: ${t.join(`, `)}`);continue}let o=Ni(r,a);r=$r(r,r.metadata,o),i.add(a.metadata.id)}let a=new Set(e.layout.leftPanels.map(e=>e.id)),o=r.layout.leftPanels.filter(e=>e.divide),s=r.layout.leftPanels.filter(e=>!e.divide),c=!1,l=s.map(e=>!c&&!a.has(e.id)?(c=!0,{...e,separator:!0}):e);return{...r,config:rn(e.config||{},...t.filter(e=>i.has(e.metadata.id)).map(e=>e.extension.config||{}),r.config||{}),layout:{...r.layout,leftPanels:[...l,...o],backgroundActions:Bn([],r.layout.backgroundActions||[])}}}function Fi({plugins:e=[],enabled:t=[],disabled:n=[],globalPluginConfig:r}={}){let i=(e=[])=>Array.from(new Set(e.filter(Boolean)));return Re(a=>({plugins:e,enabled:i(t),disabled:i(n),globalApps:oi(r),apps:{},setProviderState(e){a(t=>({...t,plugins:_i(t.plugins,e.plugins||[]),enabled:i(e.enabled||[]),disabled:i(e.disabled||[]),globalApps:oi(e.globalPluginConfig)}))},setPluginLoading(e){a(t=>({...t,plugins:t.plugins.map(t=>t.metadata.id===e?{...t,loadStatus:`loading`,loadError:void 0}:t)}))},setPluginLoaded(e,t){a(n=>({...n,plugins:n.plugins.map(n=>n.metadata.id===e?{...t,metadata:{...n.metadata,...t.metadata,localisation:n.metadata.localisation||t.metadata.localisation?{registrations:fn(n.metadata.localisation?.registrations||[],t.metadata.localisation?.registrations||[]),requiredNamespaces:[...new Set([...n.metadata.localisation?.requiredNamespaces||[],...t.metadata.localisation?.requiredNamespaces||[]])]}:void 0},settings:t.settings||n.settings,load:n.load,loadStatus:`loaded`,loadError:void 0}:n)}))},setPluginLoadError(e,t){a(n=>({...n,plugins:n.plugins.map(n=>n.metadata.id===e?{...n,loadStatus:`error`,loadError:t}:n)}))},setAppConfig(e,t){let n=ai(t);a(t=>ui(t.apps[e],n)?t:{...t,apps:{...t.apps,[e]:n}})},setGlobalConfig(e){a(t=>({...t,globalApps:oi(e)}))},setGlobalAppConfig(e,t){let n=ai(t);a(t=>ui(t.globalApps[e],n)?t:{...t,globalApps:{...t.globalApps,[e]:n}})},enable(e,t,n=`workspace`){a(r=>({...r,plugins:r.plugins.map(e=>e.metadata.id===t&&e.loadStatus===`error`?{...e,loadStatus:`idle`,loadError:void 0}:e),...n===`global`?{globalApps:{...r.globalApps,[e]:si(r.globalApps[e],t)}}:{apps:{...r.apps,[e]:si(r.apps[e],t)}}}))},disable(e,t,n=`workspace`){a(r=>({...r,...n===`global`?{globalApps:{...r.globalApps,[e]:ci(r.globalApps[e],t)}}:{apps:{...r.apps,[e]:ci(r.apps[e],t)}}}))}}))}const Ii=M(null),Li=M({});function Ri({plugins:e,enabled:t,disabled:n,globalPluginConfig:r,saveGlobalPluginConfig:i,children:a}){let o=I(()=>gi(e),[e]),s=I(()=>Fi({plugins:o,enabled:t,disabled:n,globalPluginConfig:r}),[]);F(()=>{s.getState().setProviderState({plugins:o,enabled:t,disabled:n,globalPluginConfig:r})},[s,o,t,n,r]);let c=I(()=>({globalPluginConfig:r,saveGlobalPluginConfig:i}),[r,i]);return De(Li.Provider,{value:c},De(Ii.Provider,{value:s},a))}function zi(){return P(Ii)}function Bi(){let e=zi();if(!e)throw Error(`usePluginStoreApi must be used within <PluginProvider />`);return e}function Vi(e){let t=zi();return t?ze(t,e):e(ni())}function Hi(){return Vi(e=>({plugins:e.plugins,enabled:e.enabled,disabled:e.disabled,globalApps:e.globalApps,apps:e.apps}))}function Ui(e){let t=P(na),n=P(ta),r=Hi(),i=e||t?.appId;return I(()=>Si(r,n,i),[r,n,i])}function Wi(){let e=zi();return I(()=>e?{enable(t,n,r){e.getState().enable(t,n,r||`workspace`)},disable(t,n,r){e.getState().disable(t,n,r||`workspace`)},setAppConfig(t,n){e.getState().setAppConfig(t,n)},setGlobalAppConfig(t,n){e.getState().setGlobalAppConfig(t,n)}}:{enable(){},disable(){},setAppConfig(){},setGlobalAppConfig(){}},[e])}function Gi(e){let t=P(na),n=Hi(),r=e||t?.appId;return I(()=>Oi(n,r),[n,r])}function Ki(e,t){let n=P(na),r=Hi(),i=t||n?.appId;return I(()=>Di(r,e,i),[r,e,i])}function qi(e,t){let n=P(na),r=zi(),i=Hi(),a=J(),o=cn(),{saveGlobalPluginConfig:s}=P(Li),c=t||n?.appId||``,l=i.plugins.find(t=>t.metadata.id===e)||null,u=c?i.globalApps[c]:void 0,d=c?i.apps[c]:void 0,f=I(()=>Ei(l||void 0),[l]),p=I(()=>Ci(u,e),[u,e]),m=I(()=>Ci(d,e),[d,e]),h=I(()=>Di(i,e,c),[i,e,c]),g=N(e=>{c&&(r?.getState().setAppConfig(c,e),o({plugins:{...a.plugins||{},apps:{...a.plugins?.apps||{},[c]:e}}}))},[a.plugins,c,o,r]),_=N(t=>{g(wi(d||{},e,t))},[g,e,d]),v=N(()=>{g(Ti(d||{},e))},[g,e,d]),y=N(async e=>{if(!c||!s)return;let t=i.globalApps[c]||{},n={apps:{...i.globalApps,[c]:e}};r?.getState().setGlobalAppConfig(c,e);try{await s(n)}catch(e){throw r?.getState().setGlobalAppConfig(c,t),e}},[c,s,i.globalApps,r]),b=N(async t=>{await y(wi(u||{},e,t))},[u,y,e]),x=N(async()=>{await y(Ti(u||{},e))},[u,y,e]);return{plugin:l,appId:c,defaults:f,global:p,workspace:m,effective:h,canSaveGlobal:!!s,setWorkspaceSettings:_,resetWorkspaceSettings:v,setGlobalSettings:b,resetGlobalSettings:x}}function Ji(e,t){let n=Hi(),r=zi(),i=I(()=>Si(n,e,t),[n,e,t]);return F(()=>{if(r)for(let e of i)!e.load||e.loadStatus===`loading`||e.loadStatus===`loaded`||e.loadStatus===`error`||(r.getState().setPluginLoading(e.metadata.id),e.load().then(t=>{r.getState().setPluginLoaded(e.metadata.id,hi(t))}).catch(t=>{r.getState().setPluginLoadError(e.metadata.id,Yi(t))}))},[r,i]),I(()=>Pi(e,i.filter(e=>!e.load||e.loadStatus===`loaded`),t),[e,i,t])}function Yi(e){return e instanceof Error?e.message:typeof e==`string`?e:`Plugin failed to load.`}function Xi({config:e}){let t=P(na),n=zi(),r=t?.appId,i=r?e?.plugins?.apps?.[r]:void 0;return F(()=>{!n||!r||n.getState().setAppConfig(r,i||{})},[n,r,i]),null}const Zi=new WeakMap,Qi=new WeakMap;function $i(e,t,n,r){let i=e.get(t);i||(i=new Map,e.set(t,i));let a=i.get(n);if(a)return a;let o=Promise.resolve().then(r);return i.set(n,o),o.catch(()=>{i.get(n)===o&&i.delete(n)}),o}function ea(){let e=Ie(),{plugins:t}=Hi();return F(()=>{if(!e)return;let n=!0;return(async()=>{for(let r of t){if(!n)return;for(let t of r.metadata.localisation?.registrations||[]){if(!n)return;try{let n=[...Zi.get(e)?.keys()||[]].find(e=>dn(e,t))||t;await $i(Zi,e,n,()=>e.register(n))}catch(e){n&&console.error(`Plugin translation registration failed`,r.metadata.id,e)}}if(!n)return;let t=[...new Set(r.metadata.localisation?.requiredNamespaces||[])].sort();for(let i of t){if(!n)return;try{await $i(Qi,e,i,()=>e.loadNamespaces([i]))}catch(e){n&&console.error(`Plugin translation namespace failed`,r.metadata.id,i,e)}}}})().catch(e=>{n&&console.error(`Plugin translation registration failed`,e)}),()=>{n=!1}},[e,t]),null}const ta=M(null),na=M(null),ra=M({state:null,setState:()=>{}});function ia(){let e=P(na);return q(e,`Hook useAppInstance must be used inside <AppProvider />`),e}function X(){let e=P(ta);return q(e,`Hook useApp must be used inside <AppProvider />`),e}function aa(){return P(ra)}function oa(e,t){return e.find(e=>e.id===t)||null}function sa(){let e=X(),{state:t,setState:n}=aa(),r=e.preset?.templates||[],i=typeof t?.presetTemplateId==`string`?t.presetTemplateId:null;return{templates:r,selectedTemplateId:i,selectedTemplate:I(()=>oa(r,i),[i,r]),setSelectedTemplateId:N(e=>n({presetTemplateId:e}),[n])}}function ca(e){let[t,n,r]=be(`app-state/${e.appId}/${e.instanceId}`,e.initialState||{}),i=N(e=>{let t=r.current?JSON.parse(r.current||`{}`):{},i=(typeof e==`function`?e(t):e)||{};n({...t,...i})},[]);F(()=>{e.args&&i(e.args)},[e.appId]);let a=I(()=>({state:t||{},setState:i}),[i,t]);return B(ra.Provider,{value:a,children:e.children})}function la({instanceId:e,appId:t,args:n,definition:r,children:i,initialState:a}){let o=I(()=>({instanceId:e,appId:t,args:n}),[e,t,n]),s=I(()=>a||{},[e]),c=Ji(r,t);return B(ln,{config:c.config||{},children:B(ta.Provider,{value:c,children:B(na.Provider,{value:o,children:B(ca,{instanceId:o.instanceId,appId:o.appId,args:o.args,initialState:s,children:i})})})})}const ua=M(null);function da(){let e=P(ua);return q(e,`Hook useApps must be used inside <MultiAppProvider />`),e}function fa(e,t=!1){let[n,r]=Se(`SelectedApplication`,e||{id:`splash`},!t);return[n,r]}function pa({apps:e,initialApp:t,saveCurrentApp:n=!0,instanceId:r,children:i,config:a={}}){let{defaultApp:o=`splash`,collectionApp:s=`collection-editor`,manifestApp:c=`manifest-editor`}=a,[l,u]=fa(t,n),d=e=>{e===`Manifest`&&u({id:c}),e===`Collection`&&u({id:s})},f=I(()=>({currentApp:l||{id:o},initialApp:t||{id:o},apps:e,changeApp:u,changeProjectType:d}),[t,e,l]),p=e[f.currentApp.id];return!l||!p?null:B(la,{appId:l.id,definition:p,instanceId:l.id+r,args:l.args,children:B(ua.Provider,{value:f,children:i})})}const ma=M(null),ha=M(null);function ga(){let e=P(ha),t=P(ma),n=e||t?.id;return q(n,`useResourceInstance can only be called from inside <ResourceProvider />`),n}function _a(){let e=P(ma);return q(e,`useResource can only be called from inside <ResourceProvider />`),e}function va({id:e,children:t}){return e?B(ha.Provider,{value:e,children:t}):t}function ya({resource:e,children:t}){let n=$e(),r=t;return e&&e.type===`Manifest`&&(r=B(Xe,{vault:n||void 0,children:B(qe,{manifest:e.id||``,children:t})})),e&&e.type===`Collection`&&(r=B(Xe,{vault:n||void 0,children:B(Ge,{collection:e.id||``,children:t})})),B(ma.Provider,{value:e,children:r})}const ba=M(null),xa=M(null),Sa=M(`default`);function Ca(){return P(xa)}function wa(){return P(ba)}function Ta(){return P(Sa)}function Ea(){return X().layout}function Da(){let e=X(),t=e.layout,n=P(ba),r=P(xa);return I(()=>({actions:n,state:r,...t}),[e,r])}function Oa(e=`vault://homepage-collection.json`){let t=new pt,n=window.localStorage.getItem(`preview-vault-collection`),r=!1;if(n)try{let i=JSON.parse(n);if(i.id&&i.id===e){t.dispatch(vt({id:i.id}));let e=yt(i.id,i);t.dispatch(ht({actions:e})),r=!0}}catch{}if(!r){let n=yt(e,{"@context":`http://iiif.io/api/presentation/3/context.json`,id:e,type:`Collection`,label:{en:[`Recent items`]},items:[]});t.dispatch(vt({id:e})),t.dispatch(ht({actions:n}))}return t.on(`after:@iiif/REMOVE_REFERENCE`,n=>{n.action.payload.id===e&&window.localStorage.setItem(`preview-vault-collection`,JSON.stringify(t.toPresentation3({id:e,type:`Collection`})))}),{vault:t,unsubscribe:()=>{},addHistory:(n,r)=>{let i=t.getState();if(n&&r&&(r===`Collection`||r===`Manifest`)){let a=i.iiif.entities.Collection[e];if(a){let i=a.items.findIndex(e=>e.id===n);i===-1?t.dispatch(mt({id:e,type:`Collection`,reference:{id:n,type:r},key:`items`,index:0})):t.dispatch(_t({id:e,type:`Collection`,key:`items`,startIndex:i,endIndex:0})),window.localStorage.setItem(`preview-vault-collection`,JSON.stringify(t.toPresentation3({id:e,type:`Collection`})))}}},clearHistory:()=>{t.dispatch(gt({id:e,type:`Collection`,key:`items`,value:[]})),window.localStorage.setItem(`preview-vault-collection`,JSON.stringify(t.toPresentation3({id:e,type:`Collection`})))}}}function ka(){return P(Aa)}const Aa=M(new pt),ja=M({addHistory:(e,t)=>{},clearHistory:()=>{}}),Ma=`manifest-editor://homepage-collection.json`;function Na(){return P(ja)}function Pa(e){let{vault:t,unsubscribe:n,addHistory:r,clearHistory:i}=I(()=>Oa(Ma),[]);return F(()=>n,[]),B(ja.Provider,{value:{addHistory:r,clearHistory:i},children:B(Aa.Provider,{value:t,children:e.children})})}function Fa({children:e}){let t=ka();return B(Xe,{vault:t,children:e})}const Ia=new Map;function La(e){if(typeof window>`u`)return ct({storageKey:!1});let t=Ia.get(e);return t||(t=ct({storageKey:`manifest-editor:notebook:${e}`}),Ia.set(e,t)),t}function Ra(e){return new Ct({extensions:[wt,xt,bt.configure({nested:!0}),St.extend({markdownTokenName:`image`,parseMarkdown:(e,t)=>t.createNode(`iiifImage`,{src:e.href,alt:e.text||``})})]}).parse(e)}function za(e,t,n){let r=e.getState().notes,i=new Date().toISOString(),a=(n.initialNotes||[]).filter(e=>!r.some(n=>n.id===e.id&&n.projectId===t)).map(e=>({id:e.id,title:e.title,projectId:t,content:e.content??(n.parseMarkdown??Ra)(e.markdown??``),createdAt:i,updatedAt:i}));a.length&&e.setState({notes:[...r,...a]})}function Ba(e){if(e.type!==`ImageService`)return e.source||e.id;if(e.infoUrl)return e.infoUrl;let t=new URL(e.id);return t.pathname=`${t.pathname.replace(/\/info\.json$|\/$/g,``)}/info.json`,t.toString()}function Va(e,t){let n=new Map;for(let r of e.filter(e=>e.projectId===t)){for(let e of lt(r.content)){let t=Ba(e);n.has(t)||n.set(t,{url:t,label:e.label,thumbnail:e.thumbnail,noteTitle:r.title})}let e=t=>{for(let e of t.marks??[]){let i=e.type===`link`?e.attrs?.href:void 0;typeof i==`string`&&/^https?:\/\//.test(i)&&!n.has(i)&&n.set(i,{url:i,label:t.text||i,noteTitle:r.title})}t.content?.forEach(e)};e(r.content)}return[...n.values()]}function Ha(e,t,n,r){let i=e.getState(),a=i.notes.filter(e=>e.projectId===t).sort((e,t)=>e.createdAt.localeCompare(t.createdAt)||e.id.localeCompare(t.id)),o=a.find(e=>e.id===r)??a[0]??i.createNote(t,n);return o.title!==n&&i.updateNote(o.id,{title:n}),o.id}const Ua=`@manifest-editor/notebook`;function Wa({className:e=``}){return B(`svg`,{xmlns:`http://www.w3.org/2000/svg`,className:e,width:`1em`,height:`1em`,viewBox:`0 0 24 24`,"aria-hidden":`true`,children:B(`path`,{fill:`currentColor`,d:`M6 15.325q.35-.175.725-.25T7.5 15H8V4h-.5q-.625 0-1.062.438T6 5.5zM10 15h8V4h-8zm-4 .325V4zM7.5 22q-1.45 0-2.475-1.025T4 18.5v-13q0-1.45 1.025-2.475T7.5 2H18q.825 0 1.413.587T20 4v12.525q0 .2-.162.363t-.588.362q-.35.175-.55.5t-.2.75t.2.763t.55.487t.55.413t.2.562v.25q0 .425-.288.725T19 22zm0-2h9.325q-.15-.35-.237-.712T16.5 18.5q0-.4.075-.775t.25-.725H7.5q-.65 0-1.075.438T6 18.5q0 .65.425 1.075T7.5 20`})})}function Ga(){let e=ga(),t=J().notebook,n=t?.projectId??e;return{notebook:I(()=>La(n),[n]),projectId:n,enabled:!!t?.enabled}}function Ka(){let{notebook:e,projectId:t,enabled:n}=Ga(),r=J().notebook;return F(()=>{if(!n||!r)return;let i=e.subscribe((e,n)=>{e.notes!==n.notes&&r.onChange?.(e.notes,t)});return za(e,t,r),i},[e,t,r,n]),null}function qa(){let{notebook:e,projectId:t,enabled:n}=Ga();return I(()=>n?[ut({notebook:e,projectId:t})]:[],[e,t,n])}function Ja(){return J().notebook?.enabled?B(`div`,{className:`flex justify-end p-2`,children:B(Ya,{})}):null}function Ya(){let e=U(`shell`),t=J(),n=wa(),r=Ca();if(!t.notebook?.enabled)return null;let a=r.leftPanel.current===`@manifest-editor/notebook`&&r.leftPanel.open;return B(i,{title:e(`notebook.hint`),"aria-label":e(`notebook.title`),"aria-expanded":a,active:a,onClick:()=>a?n.leftPanel.close():n.leftPanel.open({id:Ua}),children:B(Wa,{})})}const Xa=G(st)`
|
|
2
|
+
font-family: inherit;
|
|
3
|
+
.iiif-notebook__sidebar,
|
|
4
|
+
.iiif-notebook__resize,
|
|
5
|
+
.iiif-notebook__title-row {
|
|
6
|
+
display: none;
|
|
7
|
+
}
|
|
8
|
+
.iiif-notebook__main {
|
|
9
|
+
padding: 0 16px;
|
|
10
|
+
}
|
|
11
|
+
.iiif-notebook__toolbar {
|
|
12
|
+
padding: 6px 0;
|
|
13
|
+
}
|
|
14
|
+
.iiif-notebook__prose {
|
|
15
|
+
font-size: 14px;
|
|
16
|
+
line-height: 1.65;
|
|
17
|
+
padding-bottom: 40px;
|
|
18
|
+
}
|
|
19
|
+
`;function Za(){let e=U(`shell`),{notebook:t,projectId:n}=Ga(),r=J().notebook,i=et(),a=at(i?.label),o=a||e(`notebook.untitled`),s=ka(),[c,l]=R(),{create:u}=wa(),d=N(e=>{if(!i)return;let t=Ba(e),n=e.type===`ImageService`?{...e,id:t}:e;u({type:`Canvas`,isPainting:!0,parent:{id:i.id,type:`Manifest`},property:`items`,initialCreator:r?.browserCreatorId??`@manifest-editor/iiif-browser-creator`,initialData:{url:t,iiifBrowserOptions:{history:dt(n)}}})},[u,i,r?.browserCreatorId]);return F(()=>{l(Ha(t,n,a||`Untitled manifest`,r?.initialNotes?.[0]?.id)),t.getState().setWorkspaceView(n,{sidebarCollapsed:!0})},[t,n,a,r?.initialNotes]),B(Fa,{children:V(`div`,{className:`flex h-full min-h-0 flex-col bg-white`,children:[V(`div`,{className:`border-b border-gray-100 px-4 py-4`,children:[B(`h2`,{className:`m-0 text-base font-medium leading-snug text-gray-800`,children:o}),B(`p`,{className:`mb-0 mt-1 text-xs leading-relaxed text-gray-500`,children:e(`notebook.description`)})]}),B(`div`,{className:`min-h-0 flex-1`,children:c?B(w,{children:B(Xa,{notebook:t,projectId:n,noteId:c,height:`100%`,defaultSidebarCollapsed:!0,className:`manifest-project-notebook`,browserProps:{vault:s},onOpenResource:d})}):null})]})})}function Qa(e){try{return new URL(e).hostname.replace(/^www\./,``)}catch{return e}}function $a({onSelect:e,isDisabled:t,onOpenNotebook:n}){let r=U(`shell`),{notebook:i,projectId:a,enabled:o}=Ga(),s=ze(i,e=>e.notes),c=I(()=>Va(s,a),[s,a]);return!o||!c.length?null:V(`section`,{"aria-label":r(`notebook.saved`),className:`mt-4`,children:[B(`h3`,{className:`mb-1 text-xs font-medium text-gray-500`,children:r(`notebook.saved`)}),V(`div`,{className:`flex flex-col`,children:[c.length>4&&n?V(`button`,{type:`button`,disabled:t,onClick:n,className:`flex w-full items-center gap-3 rounded-md px-2 py-1.5 text-left text-sm text-me-primary-500 hover:bg-gray-50 focus-visible:outline focus-visible:outline-2 focus-visible:outline-me-primary-500 disabled:opacity-50`,children:[B(`span`,{className:`flex h-8 w-8 shrink-0 items-center justify-center`,children:B(T,{className:`h-5 w-5`})}),r(`notebook.viewAll`,{count:c.length})]}):null,c.slice(0,4).map(n=>V(`button`,{type:`button`,disabled:t,title:n.url,className:`flex w-full items-center gap-3 rounded-md px-2 py-1.5 text-left hover:bg-gray-50 focus-visible:outline focus-visible:outline-2 focus-visible:outline-me-primary-500 disabled:opacity-50`,onClick:()=>e(n.url),children:[n.thumbnail?B(`img`,{src:n.thumbnail,alt:``,loading:`lazy`,className:`h-8 w-8 shrink-0 rounded object-cover`}):B(`span`,{className:`flex h-8 w-8 shrink-0 items-center justify-center rounded bg-gray-50 text-gray-400`,children:B(Wa,{className:`h-4 w-4`})}),V(`span`,{className:`min-w-0`,children:[B(`span`,{className:`block truncate text-sm text-gray-700`,children:n.label}),V(`span`,{className:`block truncate text-xs text-gray-400`,children:[Qa(n.url),n.noteTitle?` · ${n.noteTitle}`:``]})]})]},n.url))]})]})}const eo=G.div`
|
|
2
20
|
display: flex;
|
|
3
21
|
align-items: center;
|
|
4
22
|
height: 3em;
|
|
5
23
|
padding: 0.5em;
|
|
6
|
-
`,
|
|
24
|
+
`,to=G.div`
|
|
7
25
|
display: flex;
|
|
8
26
|
padding: 0.25em;
|
|
9
27
|
flex-direction: column;
|
|
10
|
-
`;
|
|
28
|
+
`;G.button`
|
|
11
29
|
height: 1.75em;
|
|
12
30
|
width: 1.75em;
|
|
13
31
|
background: #e9e9e9;
|
|
@@ -26,9 +44,9 @@ import{ActionButton as e,ArrowRightIcon as t,BackIcon as n,BackgroundActionMenuB
|
|
|
26
44
|
fill: #fff;
|
|
27
45
|
}
|
|
28
46
|
}
|
|
29
|
-
`,
|
|
47
|
+
`,G.div`
|
|
30
48
|
flex: 1;
|
|
31
|
-
`;const
|
|
49
|
+
`;const no=G.div`
|
|
32
50
|
color: #6e6e6e;
|
|
33
51
|
display: flex;
|
|
34
52
|
align-items: center;
|
|
@@ -39,7 +57,7 @@ import{ActionButton as e,ArrowRightIcon as t,BackIcon as n,BackgroundActionMenuB
|
|
|
39
57
|
user-select: none;
|
|
40
58
|
cursor: pointer;
|
|
41
59
|
margin-right: 0.5em;
|
|
42
|
-
`;
|
|
60
|
+
`;G.div`
|
|
43
61
|
margin: 0 auto;
|
|
44
62
|
padding: 3px;
|
|
45
63
|
background: #f4f4f4;
|
|
@@ -52,7 +70,7 @@ import{ActionButton as e,ArrowRightIcon as t,BackIcon as n,BackgroundActionMenuB
|
|
|
52
70
|
@media (max-width: 450px) {
|
|
53
71
|
display: none;
|
|
54
72
|
}
|
|
55
|
-
`,
|
|
73
|
+
`,G.button`
|
|
56
74
|
background: #e7fff4;
|
|
57
75
|
border: 1px solid #c5e3cd;
|
|
58
76
|
box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.06);
|
|
@@ -60,7 +78,7 @@ import{ActionButton as e,ArrowRightIcon as t,BackIcon as n,BackgroundActionMenuB
|
|
|
60
78
|
color: #666666;
|
|
61
79
|
padding: 0.35em 0.7em;
|
|
62
80
|
letter-spacing: -0.42px;
|
|
63
|
-
`;const Pi=({height:e=16})=>V(`svg`,{xmlns:`http://www.w3.org/2000/svg`,height:e,viewBox:`0 0 24 24`,width:`24px`,fill:`currentColor`,children:[B(`path`,{d:`M0 0h24v24H0z`,fill:`none`}),B(`path`,{d:`M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z`})]}),Fi=({rotate:e=0,...t})=>B(`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:B(`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`})});var Ii=wt(((e,t)=>{t.exports={..._e}})),Li=Et(wt((e=>{Object.defineProperty(e,"__esModule",{value:!0});let t=Ii();function n(e,n){let[r,i]=(0,t.useState)(!1),a=(0,t.useRef)(null),o=(0,t.useRef)(!0),s=(0,t.useRef)(!1),c=(0,t.useRef)(null),l=(0,t.useMemo)(()=>Array.from({length:e},()=>(0,t.createRef)()),[e]),u=e=>e.key!==void 0,d=e=>{var t;a.current=e,(t=l[e].current)==null||t.focus()};(0,t.useEffect)(()=>{if(o.current){o.current=!1;return}r&&(!s.current||n?.focusFirstItemOnClick)?d(0):r||(s.current=!1)},[r]),(0,t.useEffect)(()=>{if(!r)return;let e={removed:!1},t=e=>{setTimeout(()=>{e.target instanceof Element&&(e.target.closest(`[role="menu"]`)instanceof Element||i(!1))},10)};return setTimeout(()=>{e.removed||document.addEventListener(`click`,t)},1),()=>{e.removed=!0,document.removeEventListener(`click`,t)}},[r]),(0,t.useEffect)(()=>{let e=e=>{r&&(e.key===`ArrowDown`||e.key===`ArrowUp`)&&e.preventDefault()};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[r]);let f=e=>{if(u(e)){let{key:t}=e;if(![`Enter`,` `,`Tab`,`ArrowDown`,`Escape`].includes(t))return;(t===`Tab`||t===`ArrowDown`)&&s.current&&r&&(e.preventDefault(),d(0)),(t===`Enter`||t===` `)&&(e.preventDefault(),i(!0)),t===`Escape`&&(e.preventDefault(),i(!1))}else n?.focusFirstItemOnClick||(s.current=!r),i(!r)},p=e=>{var t;let{key:n}=e;if([`Tab`,`Shift`,`Enter`,`Escape`,`ArrowUp`,`ArrowDown`,` `].includes(n)){let r=a.current;if(n===`Escape`){i(!1),(t=c.current)==null||t.focus();return}if(n===`Tab`){i(!1);return}if(n===`Enter`||n===` `){e.currentTarget.href||e.currentTarget.click(),i(!1);return}r!==null&&(n===`ArrowUp`?--r:n===`ArrowDown`&&(r+=1),r>l.length-1?r=0:r<0&&(r=l.length-1)),r!==null&&d(r);return}if(/[a-zA-Z0-9./<>?;:"'`!@#$%^&*()\\[\]{}_+=|\\-~,]/.test(n)){let e=l.findIndex(e=>(e.current?.innerText)?.toLowerCase().startsWith(n.toLowerCase())||(e.current?.textContent)?.toLowerCase().startsWith(n.toLowerCase())||(e.current?.getAttribute(`aria-label`))?.toLowerCase().startsWith(n.toLowerCase()));e!==-1&&d(e)}};return{buttonProps:{onKeyDown:f,onClick:f,tabIndex:0,ref:c,role:`button`,"aria-haspopup":!0,"aria-expanded":r},itemProps:Array.from({length:e},(e,t)=>({onKeyDown:p,tabIndex:-1,role:`menuitem`,ref:l[t]})),isOpen:r,setIsOpen:i,moveFocus:d}}e.default=n}))(),1);const Ri=typeof Li.default==`object`&&Li.default!==null&&`default`in Li.default?Li.default.default:Li.default,zi=j(null),Bi=j(null);function Vi(){let e=N(Bi),t=N(zi),n=e||t?.id;return G(n,`useResourceInstance can only be called from inside <ResourceProvider />`),n}function Hi(){let e=N(zi);return G(e,`useResource can only be called from inside <ResourceProvider />`),e}function Ui({id:e,children:t}){return e?B(Bi.Provider,{value:e,children:t}):t}function Wi({resource:e,children:t}){let n=He(),r=t;return e&&e.type===`Manifest`&&(r=B(ze,{vault:n||void 0,children:B(Ie,{manifest:e.id||``,children:t})})),e&&e.type===`Collection`&&(r=B(ze,{vault:n||void 0,children:B(Pe,{collection:e.id||``,children:t})})),B(zi.Provider,{value:e,children:r})}function Gi(e){"@babel/helpers - typeof";return Gi=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},Gi(e)}function Ki(e,t){if(Gi(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(Gi(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function qi(e){var t=Ki(e,`string`);return Gi(t)==`symbol`?t:t+``}function X(e,t,n){return(t=qi(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var Ji=class{constructor({id:e,config:t,label:n}){X(this,`id`,void 0),X(this,`label`,void 0),X(this,`type`,`external-manifest-preview`),X(this,`focusable`,!0),X(this,`serviceUrl`,void 0),X(this,`windows`,{}),this.id=e,this.label=n,this.serviceUrl=t.url}isPreviewValid(e){let t=this.windows[e];return!!(t&&t.window&&!t.window.closed)}getRequires(){return[`readOnlyManifest`]}getProvides(){return[]}async createPreview(e,t,n,r){let i=`${this.serviceUrl}`.replace(/\{manifestId}/,r.readOnlyManifest).replace(/\{time}/,`${Date.now()}`),a=window.open(i,this.id);return this.windows[e]={location:i,window:a},{id:this.id,type:`external-manifest-preview`,data:{url:i}}}async focus(e){let t=this.windows[e];t&&t.window&&t.window.focus()}async updatePreview(e,t,n,r){let i=this.windows[e];if(i)try{i.window?.close()}catch{}return this.createPreview(e,t,n,r)}async deletePreview(e){let t=this.windows[e];t&&t.window&&(t.window.close(),delete this.windows[e])}},Yi=class{constructor({id:e,config:t,label:n}){X(this,`id`,void 0),X(this,`label`,void 0),X(this,`type`,`iiif-preview-service`),X(this,`focusable`,!1),X(this,`serviceUrl`,void 0),X(this,`cache`,{}),this.id=e,this.label=n,this.serviceUrl=t.url}getRequires(){return[]}getProvides(){return[`readOnlyManifest`]}async isPreviewValid(e,t){if(this.cache[e])return!0;if(!t||!t.data||!t.data.readOnlyManifest)return!1;let n=t.data.readOnlyManifest;try{return(await fetch(n,{cache:`no-cache`})).ok}catch{return!1}}async createPreview(e,t,n){let r=n.toPresentation3(t),i=await fetch(this.serviceUrl,{method:`POST`,headers:{"Content-Type":`application/json`,Origin:`*`},body:JSON.stringify(r)});G(i.ok,`Unknown error creating preview`);let a=await i.json();return G(a.location,`Missing IIIF location while creating preview`),this.cache[e]={...a,time:Date.now()},{id:this.id,type:`external-manifest-preview`,data:{readOnlyManifest:`${a.location}/${Date.now()}`}}}async focus(){}async updatePreview(e,t,n){let r=this.cache[e];if(!r||Date.now()>r.expirationTtl+r.time||!r.updateLocation)return this.createPreview(e,t,n);let i=r.updateLocation,a=n.toPresentation3(t),o=await fetch(i,{method:`PUT`,headers:{"Content-Type":`application/json`,Origin:`*`},body:JSON.stringify(a)});G(o.ok,`Unknown error updating preview`);let s=await o.json();G(s.location),s.updateLocation&&(r.updateLocation=s.updateLocation);let c=`${s.location}/${Date.now()}`;return await fetch(c,{cache:`no-cache`}),{id:this.id,type:`external-manifest-preview`,data:{readOnlyManifest:`${s.location}/${Date.now()}`}}}async deletePreview(e){let t=this.cache[e];if(t&&t.deleteLocation)try{await fetch(t.deleteLocation,{method:`DELETE`,headers:{"Content-Type":`application/json`,Origin:`*`}})}catch{}}};function Xi(e,t,n,r,i){let a=Hi(),o=Vi(),s=H(),c=I(()=>({setPreview:e=>{e&&i(t=>[...t.filter(t=>t.id!==e.id),e])},removePreview:e=>{i(t=>t.filter(t=>t.id!==e))}}),[i,o]),[l,u]=I(()=>{let e={},t={};for(let r of n){e[r.id]=r;let n=r.getProvides();if(n.length)for(let e of n)t[e]||(t[e]=r.id)}return[e,t]},[n]);async function d(){let n=e.selected,i=r.find(e=>e.id===n);if(r&&r.length&&i){let e=l[i.id].getRequires(),n={};for(let i of r){let r=l[i.id];if(r){let i=r.getProvides();for(let l of i)if(e.indexOf(l)!==-1){let e=await r.updatePreview(o,a,s,n);e&&(c.setPreview(e),t({type:`activatePreview`,payload:e.id}),Object.assign(n,e.data||{}))}}}let u=l[i.id];if(u){let e=await u.updatePreview(o,a,s,n);e?c.setPreview(e):(c.removePreview(i.id),await u.deletePreview(o))}}}async function f(e){l[e]&&o&&(t({type:`selectPreview`,payload:e}),await g(e))}async function p(){let e=u.readOnlyManifest,t=e?l[e]:null;if(t&&o){let e=r.find(e=>e.type===`iiif-preview-service`);if(!e||!await t.isPreviewValid(o,e)){let e=await t.createPreview(o,a,s,{});if(e)return e.data.readOnlyManifest}}return null}function m(e){let n=l[e];n&&o&&(c.removePreview(e),n.deletePreview(o).then(()=>{t({type:`deletePreview`,payload:e})}))}async function h(e){let n=l[e];l[e]&&o&&n&&(await n.focus(o),t({type:`focusPreview`,payload:e}))}async function g(n){let i=l[n];if(i&&o){let d=r.find(e=>e.id===n);if(!d||!i.isPreviewValid(o,d)){let n={},d=i.getRequires();for(let i of d){let d=u[i],f=d?l[d]:null;G(f,`Missing handler for Preview requirement "${i}"`),r.find(e=>e.id===d),e.active.find(e=>e===d);{let e=await f.createPreview(o,a,s,n);Object.assign(n,e?.data||{}),c.setPreview(e),t({type:`activatePreview`,payload:e.id})}}let f=await i.createPreview(o,a,s,n);f&&(c.setPreview(f),t({type:`activatePreview`,payload:f.id}))}}}return I(()=>({selectPreview:f,deletePreview:m,focusPreview:h,activatePreview:g,updatePreviews:d,getPreviewLink:p}),[l,o,s,e.selected,e.active,r])}function Zi(e){return I(()=>{let t=[];for(let n of e)switch(n.type){case`iiif-preview-service`:t.push(new Yi(n));break;case`external-manifest-preview`:t.push(new Ji(n))}return t},[])}const Qi=Xe(function(e,t){switch(t.type){case`focusPreview`:break;case`deletePreview`:e.selected===t.payload&&(e.selected=null),e.active=e.active.filter(e=>e!==t.payload);break;case`activatePreview`:e.active.indexOf(t.payload)===-1&&e.active.push(t.payload);break;case`selectPreview`:e.selected=t.payload,e.active.indexOf(t.payload)===-1&&e.active.push(t.payload)}});function $i(){return{active:[],selected:null}}const ea=j(null),ta=j([]),na=we(function({children:e,configs:t=[]}){let n=Vi(),r=Zi(t),[i,a]=me(`preview-${n}`,[]),[o,s]=Ee(Qi,void 0,$i),c=Xi(o,s,r,i,a),l=I(()=>({configs:t,actions:c,handlers:r,...o}),[c,t,r,o]);return P(()=>{for(let e of i)if(!o.active.includes(e.id)){let t=r.find(t=>t.id===e.id);t&&Promise.resolve(t.isPreviewValid(n,e)).then(t=>{t?s({type:`activatePreview`,payload:e.id}):a(t=>t.filter(t=>t.id!==e.id))})}},[n]),B(ta.Provider,{value:i,children:B(ea.Provider,{value:l,children:e})})});function ra(){return N(ta)}function ia(){let e=N(ea);return G(e,`usePreviewContext() can only be called from inside <PreviewProvider />`),e}const aa=U.button`
|
|
81
|
+
`;const ro=({height:e=16})=>V(`svg`,{xmlns:`http://www.w3.org/2000/svg`,height:e,viewBox:`0 0 24 24`,width:`24px`,fill:`currentColor`,children:[B(`path`,{d:`M0 0h24v24H0z`,fill:`none`}),B(`path`,{d:`M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z`})]}),io=({rotate:e=0,...t})=>B(`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:B(`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`})});var ao=Gt(((e,t)=>{t.exports={...Ce}}));const oo=qt(Gt((e=>{Object.defineProperty(e,"__esModule",{value:!0});let t=ao();function n(e,n){let[r,i]=(0,t.useState)(!1),a=(0,t.useRef)(null),o=(0,t.useRef)(!0),s=(0,t.useRef)(!1),c=(0,t.useRef)(null),l=(0,t.useMemo)(()=>Array.from({length:e},()=>(0,t.createRef)()),[e]),u=e=>e.key!==void 0,d=e=>{var t;a.current=e,(t=l[e].current)==null||t.focus()};(0,t.useEffect)(()=>{if(o.current){o.current=!1;return}r&&(!s.current||n?.focusFirstItemOnClick)?d(0):r||(s.current=!1)},[r]),(0,t.useEffect)(()=>{if(!r)return;let e={removed:!1},t=e=>{setTimeout(()=>{e.target instanceof Element&&(e.target.closest(`[role="menu"]`)instanceof Element||i(!1))},10)};return setTimeout(()=>{e.removed||document.addEventListener(`click`,t)},1),()=>{e.removed=!0,document.removeEventListener(`click`,t)}},[r]),(0,t.useEffect)(()=>{let e=e=>{r&&(e.key===`ArrowDown`||e.key===`ArrowUp`)&&e.preventDefault()};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[r]);let f=e=>{if(u(e)){let{key:t}=e;if(![`Enter`,` `,`Tab`,`ArrowDown`,`Escape`].includes(t))return;(t===`Tab`||t===`ArrowDown`)&&s.current&&r&&(e.preventDefault(),d(0)),(t===`Enter`||t===` `)&&(e.preventDefault(),i(!0)),t===`Escape`&&(e.preventDefault(),i(!1))}else n?.focusFirstItemOnClick||(s.current=!r),i(!r)},p=e=>{var t;let{key:n}=e;if([`Tab`,`Shift`,`Enter`,`Escape`,`ArrowUp`,`ArrowDown`,` `].includes(n)){let r=a.current;if(n===`Escape`){i(!1),(t=c.current)==null||t.focus();return}if(n===`Tab`){i(!1);return}if(n===`Enter`||n===` `){e.currentTarget.href||e.currentTarget.click(),i(!1);return}r!==null&&(n===`ArrowUp`?--r:n===`ArrowDown`&&(r+=1),r>l.length-1?r=0:r<0&&(r=l.length-1)),r!==null&&d(r);return}if(/[a-zA-Z0-9./<>?;:"'`!@#$%^&*()\\[\]{}_+=|\\-~,]/.test(n)){let e=l.findIndex(e=>(e.current?.innerText)?.toLowerCase().startsWith(n.toLowerCase())||(e.current?.textContent)?.toLowerCase().startsWith(n.toLowerCase())||(e.current?.getAttribute(`aria-label`))?.toLowerCase().startsWith(n.toLowerCase()));e!==-1&&d(e)}};return{buttonProps:{onKeyDown:f,onClick:f,tabIndex:0,ref:c,role:`button`,"aria-haspopup":!0,"aria-expanded":r},itemProps:Array.from({length:e},(e,t)=>({onKeyDown:p,tabIndex:-1,role:`menuitem`,ref:l[t]})),isOpen:r,setIsOpen:i,moveFocus:d}}e.default=n}))(),1).default,so=typeof oo==`object`&&oo&&`default`in oo?oo.default:oo;function co(e){"@babel/helpers - typeof";return co=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},co(e)}function lo(e,t){if(co(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(co(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function uo(e){var t=lo(e,`string`);return co(t)==`symbol`?t:t+``}function fo(e,t,n){return(t=uo(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var po=class{constructor({id:e,config:t,label:n,labelMessage:r}){fo(this,`id`,void 0),fo(this,`label`,void 0),fo(this,`labelMessage`,void 0),fo(this,`type`,`external-manifest-preview`),fo(this,`focusable`,!0),fo(this,`serviceUrl`,void 0),fo(this,`windows`,{}),this.id=e,this.label=n,this.labelMessage=r,this.serviceUrl=t.url}isPreviewValid(e){let t=this.windows[e];return!!(t&&t.window&&!t.window.closed)}getRequires(){return[`readOnlyManifest`]}getProvides(){return[]}async createPreview(e,t,n,r){let i=`${this.serviceUrl}`.replace(/\{manifestId}/,r.readOnlyManifest).replace(/\{time}/,`${Date.now()}`),a=window.open(i,this.id);return this.windows[e]={location:i,window:a},{id:this.id,type:`external-manifest-preview`,data:{url:i}}}async focus(e){let t=this.windows[e];t&&t.window&&t.window.focus()}async updatePreview(e,t,n,r){let i=this.windows[e];if(i)try{i.window?.close()}catch{}return this.createPreview(e,t,n,r)}async deletePreview(e){let t=this.windows[e];t&&t.window&&(t.window.close(),delete this.windows[e])}},mo=class{constructor({id:e,config:t,label:n,labelMessage:r}){fo(this,`id`,void 0),fo(this,`label`,void 0),fo(this,`labelMessage`,void 0),fo(this,`type`,`iiif-preview-service`),fo(this,`focusable`,!1),fo(this,`serviceUrl`,void 0),fo(this,`cache`,{}),this.id=e,this.label=n,this.labelMessage=r,this.serviceUrl=t.url}getRequires(){return[]}getProvides(){return[`readOnlyManifest`]}async isPreviewValid(e,t){if(this.cache[e])return!0;if(!t||!t.data||!t.data.readOnlyManifest)return!1;let n=t.data.readOnlyManifest;try{return(await fetch(n,{cache:`no-cache`})).ok}catch{return!1}}async createPreview(e,t,n){let r=n.toPresentation3(t),i=await fetch(this.serviceUrl,{method:`POST`,headers:{"Content-Type":`application/json`,Origin:`*`},body:JSON.stringify(r)});q(i.ok,`Unknown error creating preview`);let a=await i.json();return q(a.location,`Missing IIIF location while creating preview`),this.cache[e]={...a,time:Date.now()},{id:this.id,type:`external-manifest-preview`,data:{readOnlyManifest:`${a.location}/${Date.now()}`}}}async focus(){}async updatePreview(e,t,n){let r=this.cache[e];if(!r||Date.now()>r.expirationTtl+r.time||!r.updateLocation)return this.createPreview(e,t,n);let i=r.updateLocation,a=n.toPresentation3(t),o=await fetch(i,{method:`PUT`,headers:{"Content-Type":`application/json`,Origin:`*`},body:JSON.stringify(a)});q(o.ok,`Unknown error updating preview`);let s=await o.json();q(s.location),s.updateLocation&&(r.updateLocation=s.updateLocation);let c=`${s.location}/${Date.now()}`;return await fetch(c,{cache:`no-cache`}),{id:this.id,type:`external-manifest-preview`,data:{readOnlyManifest:`${s.location}/${Date.now()}`}}}async deletePreview(e){let t=this.cache[e];if(t&&t.deleteLocation)try{await fetch(t.deleteLocation,{method:`DELETE`,headers:{"Content-Type":`application/json`,Origin:`*`}})}catch{}}};function ho(e,t,n,r,i){let a=_a(),o=ga(),s=W(),c=I(()=>({setPreview:e=>{e&&i(t=>[...t.filter(t=>t.id!==e.id),e])},removePreview:e=>{i(t=>t.filter(t=>t.id!==e))}}),[i,o]),[l,u]=I(()=>{let e={},t={};for(let r of n){e[r.id]=r;let n=r.getProvides();if(n.length)for(let e of n)t[e]||(t[e]=r.id)}return[e,t]},[n]);async function d(){let n=e.selected,i=r.find(e=>e.id===n);if(r&&r.length&&i){let e=l[i.id].getRequires(),n={};for(let i of r){let r=l[i.id];if(r){let i=r.getProvides();for(let l of i)if(e.indexOf(l)!==-1){let e=await r.updatePreview(o,a,s,n);e&&(c.setPreview(e),t({type:`activatePreview`,payload:e.id}),Object.assign(n,e.data||{}))}}}let u=l[i.id];if(u){let e=await u.updatePreview(o,a,s,n);e?c.setPreview(e):(c.removePreview(i.id),await u.deletePreview(o))}}}async function f(e){l[e]&&o&&(t({type:`selectPreview`,payload:e}),await g(e))}async function p(){let e=u.readOnlyManifest,t=e?l[e]:null;if(t&&o){let e=r.find(e=>e.type===`iiif-preview-service`);if(!e||!await t.isPreviewValid(o,e)){let e=await t.createPreview(o,a,s,{});if(e)return e.data.readOnlyManifest}}return null}function m(e){let n=l[e];n&&o&&(c.removePreview(e),n.deletePreview(o).then(()=>{t({type:`deletePreview`,payload:e})}))}async function h(e){let n=l[e];l[e]&&o&&n&&(await n.focus(o),t({type:`focusPreview`,payload:e}))}async function g(n){let i=l[n];if(i&&o){let d=r.find(e=>e.id===n);if(!d||!i.isPreviewValid(o,d)){let n={},d=i.getRequires();for(let i of d){let d=u[i],f=d?l[d]:null;q(f,`Missing handler for Preview requirement "${i}"`),r.find(e=>e.id===d),e.active.find(e=>e===d);{let e=await f.createPreview(o,a,s,n);Object.assign(n,e?.data||{}),c.setPreview(e),t({type:`activatePreview`,payload:e.id})}}let f=await i.createPreview(o,a,s,n);f&&(c.setPreview(f),t({type:`activatePreview`,payload:f.id}))}}}return I(()=>({selectPreview:f,deletePreview:m,focusPreview:h,activatePreview:g,updatePreviews:d,getPreviewLink:p}),[l,o,s,e.selected,e.active,r])}function go(e){return I(()=>{let t=[];for(let n of e)switch(n.type){case`iiif-preview-service`:t.push(new mo(n));break;case`external-manifest-preview`:t.push(new po(n))}return t},[])}const _o=Et(function(e,t){switch(t.type){case`focusPreview`:break;case`deletePreview`:e.selected===t.payload&&(e.selected=null),e.active=e.active.filter(e=>e!==t.payload);break;case`activatePreview`:e.active.indexOf(t.payload)===-1&&e.active.push(t.payload);break;case`selectPreview`:e.selected=t.payload,e.active.indexOf(t.payload)===-1&&e.active.push(t.payload)}});function vo(){return{active:[],selected:null}}const yo=M(null),bo=M([]),xo=Ae(function({children:e,configs:t=[]}){let n=ga(),r=go(t),[i,a]=be(`preview-${n}`,[]),[o,s]=Pe(_o,void 0,vo),c=ho(o,s,r,i,a),l=I(()=>({configs:t,actions:c,handlers:r,...o}),[c,t,r,o]);return F(()=>{for(let e of i)if(!o.active.includes(e.id)){let t=r.find(t=>t.id===e.id);t&&Promise.resolve(t.isPreviewValid(n,e)).then(t=>{t?s({type:`activatePreview`,payload:e.id}):a(t=>t.filter(t=>t.id!==e.id))})}},[n]),B(bo.Provider,{value:i,children:B(yo.Provider,{value:l,children:e})})});function So(){return P(bo)}function Co(){let e=P(yo);return q(e,`usePreviewContext() can only be called from inside <PreviewProvider />`),e}const wo=G.button`
|
|
64
82
|
border: none;
|
|
65
83
|
outline: none;
|
|
66
84
|
background-color: transparent;
|
|
@@ -72,7 +90,7 @@ import{ActionButton as e,ArrowRightIcon as t,BackIcon as n,BackgroundActionMenuB
|
|
|
72
90
|
&:hover {
|
|
73
91
|
color: inherit;
|
|
74
92
|
}
|
|
75
|
-
`,
|
|
93
|
+
`,To=G.button`
|
|
76
94
|
padding: 0.5rem 1rem;
|
|
77
95
|
color: ${e=>e.theme.color.main||`none`};
|
|
78
96
|
background-color: ${e=>e.theme.color.white||`white`};
|
|
@@ -90,11 +108,11 @@ import{ActionButton as e,ArrowRightIcon as t,BackIcon as n,BackgroundActionMenuB
|
|
|
90
108
|
&:hover {
|
|
91
109
|
background: #eee;
|
|
92
110
|
}
|
|
93
|
-
`;
|
|
111
|
+
`;G(To)`
|
|
94
112
|
padding: 0.25em ${e=>e.theme.padding.xs||`0.4em`};
|
|
95
113
|
height: unset;
|
|
96
114
|
background: none;
|
|
97
|
-
`,
|
|
115
|
+
`,G(To)`
|
|
98
116
|
{
|
|
99
117
|
padding: 0 ${e=>e.theme.padding.medium||`1rem`};
|
|
100
118
|
color: ${e=>e.theme.color.main||`#B84C74;`};
|
|
@@ -113,7 +131,7 @@ import{ActionButton as e,ArrowRightIcon as t,BackIcon as n,BackgroundActionMenuB
|
|
|
113
131
|
cursor: not-allowed;
|
|
114
132
|
}
|
|
115
133
|
}
|
|
116
|
-
`;const
|
|
134
|
+
`;const Eo=G(To)`
|
|
117
135
|
padding: 0 ${e=>e.theme.padding.medium||`1rem`};
|
|
118
136
|
color: ${e=>e.theme.color.white||`white`};
|
|
119
137
|
background-color: ${e=>e.theme.color.main||`#B84C74;`};
|
|
@@ -126,17 +144,17 @@ import{ActionButton as e,ArrowRightIcon as t,BackIcon as n,BackgroundActionMenuB
|
|
|
126
144
|
&:hover {
|
|
127
145
|
background-color: ${e=>e.theme.color.mainHover||`#B84C74;`};
|
|
128
146
|
}
|
|
129
|
-
`;
|
|
147
|
+
`;G.div`
|
|
130
148
|
display: flex;
|
|
131
149
|
flex-direction: row;
|
|
132
150
|
flex-wrap: wrap;
|
|
133
151
|
align-items: flex-start;
|
|
134
152
|
justify-content: ${e=>e.$right?`flex-end`:`flex-start`};
|
|
135
|
-
`;const
|
|
153
|
+
`;const Do=G.div.attrs({"data-preview-button":!0})`
|
|
136
154
|
display: flex;
|
|
137
155
|
position: relative;
|
|
138
156
|
width: 10em;
|
|
139
|
-
`,
|
|
157
|
+
`,Oo=G(wo)`
|
|
140
158
|
flex: 1;
|
|
141
159
|
padding: 0.5em 0.8em;
|
|
142
160
|
background: #b84c74;
|
|
@@ -157,7 +175,7 @@ import{ActionButton as e,ArrowRightIcon as t,BackIcon as n,BackgroundActionMenuB
|
|
|
157
175
|
background: #892c4e;
|
|
158
176
|
box-shadow: inset 0 2px 8px 0 rgba(0, 0, 0, 0.15);
|
|
159
177
|
}
|
|
160
|
-
`,
|
|
178
|
+
`,ko=G(wo)`
|
|
161
179
|
background: #b84c74;
|
|
162
180
|
border-top-right-radius: 5px;
|
|
163
181
|
border-bottom-right-radius: 5px;
|
|
@@ -178,11 +196,11 @@ import{ActionButton as e,ArrowRightIcon as t,BackIcon as n,BackgroundActionMenuB
|
|
|
178
196
|
box-shadow: inset 0 2px 8px 0 rgba(0, 0, 0, 0.15);
|
|
179
197
|
}
|
|
180
198
|
|
|
181
|
-
${e=>e.$open&&
|
|
199
|
+
${e=>e.$open&&K`
|
|
182
200
|
background: #892c4e;
|
|
183
201
|
box-shadow: inset 0 2px 8px 0 rgba(0, 0, 0, 0.15);
|
|
184
202
|
`}
|
|
185
|
-
`,
|
|
203
|
+
`,Ao=G.div`
|
|
186
204
|
position: absolute;
|
|
187
205
|
opacity: 0;
|
|
188
206
|
top: 100%;
|
|
@@ -199,11 +217,11 @@ import{ActionButton as e,ArrowRightIcon as t,BackIcon as n,BackgroundActionMenuB
|
|
|
199
217
|
color: #25211f;
|
|
200
218
|
overflow: hidden;
|
|
201
219
|
|
|
202
|
-
${e=>e.$open&&
|
|
220
|
+
${e=>e.$open&&K`
|
|
203
221
|
opacity: 1;
|
|
204
222
|
pointer-events: visible;
|
|
205
223
|
`}
|
|
206
|
-
`,
|
|
224
|
+
`,jo=G.div`
|
|
207
225
|
display: flex;
|
|
208
226
|
background: #fff;
|
|
209
227
|
color: #25211f;
|
|
@@ -213,13 +231,13 @@ import{ActionButton as e,ArrowRightIcon as t,BackIcon as n,BackgroundActionMenuB
|
|
|
213
231
|
&:hover {
|
|
214
232
|
background: #f9f9f9;
|
|
215
233
|
}
|
|
216
|
-
`,
|
|
234
|
+
`,Mo={available:`#ddd`,configured:`#e37266`,active:`#4cb235`},No=G.div`
|
|
217
235
|
margin: 0.2em 0.5em;
|
|
218
236
|
width: 8px;
|
|
219
237
|
height: 8px;
|
|
220
238
|
border-radius: 50%;
|
|
221
|
-
background-color: ${e=>
|
|
222
|
-
`,
|
|
239
|
+
background-color: ${e=>Mo[e.$status]};
|
|
240
|
+
`,Po=G.div`
|
|
223
241
|
flex: 1;
|
|
224
242
|
font-size: 0.925em;
|
|
225
243
|
color: #25211f;
|
|
@@ -228,10 +246,10 @@ import{ActionButton as e,ArrowRightIcon as t,BackIcon as n,BackgroundActionMenuB
|
|
|
228
246
|
cursor: pointer;
|
|
229
247
|
white-space: nowrap;
|
|
230
248
|
overflow: hidden;
|
|
231
|
-
`,
|
|
249
|
+
`,Fo=G.div`
|
|
232
250
|
background: #f9f9f9;
|
|
233
251
|
font-size: 0.8em;
|
|
234
|
-
`,
|
|
252
|
+
`,Io=G.div`
|
|
235
253
|
color: #999;
|
|
236
254
|
font-size: 0.8em;
|
|
237
255
|
padding: 0.6em 0.8em;
|
|
@@ -239,10 +257,10 @@ import{ActionButton as e,ArrowRightIcon as t,BackIcon as n,BackgroundActionMenuB
|
|
|
239
257
|
border-radius: 5px;
|
|
240
258
|
user-select: none;
|
|
241
259
|
cursor: not-allowed;
|
|
242
|
-
`;function va(e,t){return e>0||!!t?.mainAction||!!t?.actions?.length}function ya({downloadEnabled:e,fileName:t,preview:n}){let{active:r,configs:i,actions:a,selected:o}=ia(),s=H(),c=K(),l=Hi(),u=i.filter(e=>e.type===`external-manifest-preview`),d=n?.actions||[],{isOpen:f,buttonProps:p,itemProps:m}=Ri(u.length+d.length);return va(u.length,n)?V(z,{children:[e?B(`div`,{className:`mr-4`,children:B(y,{fileName:t||`manifest.json`,label:`Download manifest`,getData:()=>c.export&&c.export.version===2?JSON.stringify(s.toPresentation2(l),null,2):JSON.stringify(s.toPresentation3(l),null,2)})}):null,V(ca,{children:[B(la,{"data-preview-action":n?.mainAction?.id,disabled:n?.mainAction?.disabled||!n?.mainAction&&u.length===0,onClick:()=>{if(n?.mainAction){n.mainAction.onClick();return}if(u.length){if(!o){let e=c.defaultPreview;if(e){let t=i.find(t=>t.id===e);if(t){a.selectPreview(t.id);return}}a.selectPreview(i[0].id)}a.updatePreviews()}},children:n?.mainAction?.label||`Preview`}),u.length+d.length>0?B(ua,{$open:f,...p,"aria-label":`Choose preview`,children:B(Fi,{"aria-hidden":!0})}):null,V(da,{$open:f,role:`menu`,children:[u.map((e,t)=>{let n=r.indexOf(e.id)===-1;return V(fa,{...m[t],children:[B(ma,{$status:n?`available`:e.id===o?`active`:`configured`}),B(ha,{onClick:()=>{a.selectPreview(e.id)},children:e.label}),n?null:B(ga,{onClick:()=>a.deletePreview(e.id),children:B(Pi,{})})]},e.id)}),d.map((e,t)=>V(fa,{...m[u.length+t],"aria-disabled":e.disabled||void 0,onClick:()=>{e.disabled||e.onClick()},children:[B(ma,{$status:e.status||`available`}),B(ha,{children:e.label})]},e.id))]})]})]}):B(_a,{children:`Preview not available`})}const ba=j({resource:null});function xa(){return N(ba)}function Sa(){let e=H(),{resource:t}=xa();G(t,`Nothing selected`);let{id:n,type:r}=t;return Ge(()=>e.get({id:n,type:r}),[n,r])}function Ca(){let{resource:e}=xa();return e}function wa({resource:e,children:t}){let{id:n,type:r}=e||{};return B(ba.Provider,{value:I(()=>({resource:n&&r?{id:n,type:r}:null}),[n,r]),children:t})}function Ta(e,t){switch(t.type){case`setStack`:return{...e,stack:t.payload.resources,current:t.payload.resources[0]||null};case`edit`:{let n=t.payload.reset;return(t.payload.resource?.resource.source?.type===`Manifest`||t.payload.resource?.resource.source?.type===`Canvas`)&&(n=!0),e.current?.resource.source.id===t.payload.resource?.resource.source.id?{...e,current:t.payload.resource}:{...e,current:t.payload.resource,stack:n?[]:e.current?[e.current,...e.stack]:e.stack}}case`syncRemoval`:{let n=qe(t.payload.resource.resource);if(!n||!e.stack.find(e=>qe(e.resource)?.id===n.id))return e;let r=e.current?.resource.id===n.id?null:e.current,i=Ea(e.stack.filter(e=>qe(e.resource)?.id!==n.id),r);return{...e,stack:i,current:r}}case`updateCurrent`:return{...e,current:t.payload.resource};case`back`:{let t=e.stack[0];return{...e,stack:e.stack.slice(1),current:t||null}}case`close`:return{...e,stack:[],current:null};case`create`:return t.payload.resource===null?{...e,create:null}:{...e,create:t.payload}}return e}function Ea(e,t){let n=[],r=null;for(let t of e)r?.resource.id!==t.resource.id&&(n.push(t),r=t);return r&&r.resource.id===t?.resource.id?n.slice(0,n.length-1):n}const Da={stack:[],current:null,create:null},Oa=j(Da),ka=j({edit(){},close(){},back(){},setStack(){},updateCurrent(){},create(){return()=>{}}});function Aa(){return N(ka)}function ja(){return N(Oa).current}function Ma(){return N(Oa).stack}function Na(){return N(Oa).create}function Pa(){let{manifest:e}=We(),t=H(),[n,r]=Ee(e=>e+1,0);G(e,`Manifest not found`);let i=I(()=>new Ze({reference:{id:e,type:`Manifest`},vault:t}),[e,t]);return P(()=>i.observe.start(r),[i]),i.observe.key=`${n}`,i.observe.reset(),i}function Fa(){let{collection:e}=We(),t=H(),[n,r]=Ee(e=>e+1,0);G(e,`Collection not found`);let i=I(()=>new Ze({reference:{id:e,type:`Collection`},vault:t}),[e,t]);return P(()=>i.observe.start(r),[i]),i.observe.key=`${n}`,i.observe.reset(),i}function Ia(e,t={}){let n=H(),[r,i]=Ee(e=>e+1,0);!t.allowNull&&G(e,`Resource not found`);let a=I(()=>t.allowNull&&!e?null:new Ze({reference:qe(e),vault:n,context:{resource:e,parent:t.parent,index:t.index,parentProperty:t.parentProperty}}),[e,n]);return P(()=>a?.observe.start(i),[a]),a&&(a.observe.key=`${r}`,a.observe.reset()),a}function La(){let{annotationPage:e}=We();return G(e,`Annotation page not found`),Ia({id:e,type:`AnnotationPage`})}function Ra(){let e=ja(),{resource:t}=xa(),n=H(),[r,i]=Ee(e=>e+1,0);G(e,`No resource selected`);let a=I(()=>new Ze({reference:t||e.resource.source||e.resource,vault:n}),[t,e,n]);return P(()=>a.observe.start(i),[a]),a.observe.key=`${r}`,a.observe.reset(),a}function za(e){let t=H(),[n,r]=Ee(Ta,e),i=M(e=>{r(e)},[]);P(()=>t.on(`@iiif/REMOVE_REFERENCE`,e=>{let t=e.action,n={id:t.payload.id,type:t.payload.type},i=t.payload.reference;r({type:`syncRemoval`,payload:{resource:{parent:n,resource:i}}})}),[t]);let a=M((e,t=!1)=>i({type:`edit`,payload:{resource:e,reset:t}}),[]),o=M(e=>i({type:`setStack`,payload:{resources:e}}),[]),s=M(e=>i({type:`updateCurrent`,payload:{resource:e}}),[]),c=M(()=>i({type:`close`}),[]),l=M(()=>i({type:`back`}),[]),u=M((e,t)=>(i({type:`create`,payload:{resource:e,options:t}}),()=>{i({type:`create`,payload:{resource:null}})}),[]);return[n,I(()=>({edit:a,updateCurrent:s,close:c,back:l,create:u,setStack:o}),[])]}function Ba(e){let{instanceId:t}=xi(),[n,r]=za(e.initialState||Da);return B(ka.Provider,{value:r,children:B(Oa.Provider,{value:n,children:e.children})},t)}function Va({resource:e,children:t}){let{instanceId:n}=xi(),[r,i]=za(I(()=>({create:null,stack:[],current:{resource:{type:`SpecificResource`,source:{id:e.id,type:e.type}}}}),[]));return B(ka.Provider,{value:i,children:B(Oa.Provider,{value:r,children:t})},n)}const Ha=j(null),Ua=j(null),Wa=j(`default`);function Ga(){return N(Ua)}function Ka(){return N(Ha)}function qa(){return N(Wa)}function Ja(){return Y().layout}function Ya(){let e=Y(),t=e.layout,n=N(Ha),r=N(Ua);return I(()=>({actions:n,state:r,...t}),[e,r])}const Xa=`@manifest-editor/tags`,Za=`tags`,Qa={type:`flag`,id:`flag`,label:`Flag`,backgroundColor:`#b91c1c`,textColor:`#ffffff`,icon:`flag`},$a=[];function eo(e){return typeof e==`string`?e:e?.id||null}function to(e){return e.type||e.id}function no(e){return`${e.type}:${e.id}`}function ro(e){if(!Array.isArray(e))return $a;let t=new Map;for(let n of e){if(!n?.id)continue;let e=to(n);t.set(e,{...n,type:e})}return Array.from(t.values())}function io(e){return e.label||e.id||e.type}function ao(e,t){return e===Qa.type&&(!t||t===Qa.id)}function oo(e,t){return ao(e.type,e.id)?-1:ao(t.type,t.id)?1:io(e.tag).localeCompare(io(t.tag))||e.type.localeCompare(t.type)||e.id.localeCompare(t.id)}function so(e,t){return ao(e.type)?-1:ao(t.type)?1:e.type.localeCompare(t.type)}function co(e,t){let n=eo(t);return n?ro(e.getResourceMeta(n,Xa)?.[Za]):$a}function lo(e,t){let n=eo(t);return n?ro(e?.iiif?.meta?.[n]?.[Xa]?.[Za]):$a}function uo(e,t,n){let r=eo(t);if(!r)return $a;let i=ro(n);return e.setMetaValue([r,Xa,Za],i),i}function fo(e,t,n){return uo(e,t,[...co(e,t),n])}function po(e,t,n){return co(e,t).find(e=>e.type===n)}function mo(e,t,n,r){return uo(e,t,co(e,t).filter(e=>e.type!==n||(r?e.id!==r:!1)))}function ho(e,t){let n=new Map;for(let r of t){let t=eo(r);if(t)for(let i of co(e,r)){let e=i.type,r=no(i),a=n.get(e);a||(a={key:e,type:i.type,rows:[],canvasIds:[],canvasCount:0,tagCount:0},n.set(e,a));let o=a.rows.find(e=>e.key===r);o||(o={key:r,type:i.type,id:i.id,tag:i,canvasIds:[],canvasCount:0},a.rows.push(o)),o.canvasIds.push(t),o.canvasCount=o.canvasIds.length,a.tagCount+=1}}for(let e of n.values())e.rows.sort(oo),e.canvasIds=Array.from(new Set(e.rows.flatMap(e=>e.canvasIds))),e.canvasCount=e.canvasIds.length;return Array.from(n.values()).sort(so)}function go(e,t,n,r){let i=po(e,t,n);return r?i?.id===r:!!i}function _o(e,t,n){return go(e,t,n.type,n.id)?mo(e,t,n.type):fo(e,t,n)}function vo(e){return{getTags(t){return co(e,t)},setTags(t,n){return uo(e,t,n)},addTag(t,n){return fo(e,t,n)},upsertTag(t,n){return fo(e,t,n)},getTag(t,n){return po(e,t,n)},removeTag(t,n,r){return mo(e,t,n,r)},hasTag(t,n,r){return go(e,t,n,r)},toggleTag(t,n){return _o(e,t,n)}}}function yo(e){let t=eo(e);return Ge(e=>t?lo(e,t):$a,[t])}function bo(e){let t=H(),n=eo(e),r=I(()=>vo(t),[t]);return I(()=>({setTags(e){return r.setTags(n,e)},addTag(e){return r.addTag(n,e)},getTag(e){return r.getTag(n,e)},removeTag(e,t){return r.removeTag(n,e,t)},toggleTag(e){return r.toggleTag(n,e)},hasTag(e,t){return r.hasTag(n,e,t)}}),[r,n])}function xo({icon:e,title:t,...n}){return e===`flag`?V(`svg`,{viewBox:`0 0 24 24`,width:`1em`,height:`1em`,"aria-hidden":!t||void 0,...n,children:[t?B(`title`,{children:t}):null,B(`path`,{fill:`currentColor`,d:`M5 21a1 1 0 0 1-1-1V5.6c0-.42.26-.8.65-.94C6.7 3.9 8.65 4 10.5 4.7c1.55.58 3.05.7 4.5.36l3.75-.88A1 1 0 0 1 20 5.15v9.25c0 .46-.31.86-.75.97l-3.79.9c-1.85.43-3.76.28-5.66-.43-1.28-.48-2.55-.59-3.8-.33V20a1 1 0 0 1-1 1Z`})]}):null}function So({tag:e,showIcon:t=!0,className:n,style:r}){return V(`span`,{className:`inline-flex max-w-full items-center gap-0.5 rounded px-1 py-0.5 font-medium shadow-sm ${n||``}`,style:{backgroundColor:e.backgroundColor||`#e5e7eb`,color:e.textColor||`#111827`,fontSize:9,lineHeight:`11px`,...r},children:[t&&e.icon?B(xo,{icon:e.icon,className:`h-2.5 w-2.5 flex-shrink-0`}):null,B(`span`,{className:`min-w-0 truncate`,children:io(e)})]})}function Co({resource:e,tags:t,className:n}){return t?B(To,{tags:t,className:n}):B(wo,{resource:e,className:n})}function wo({resource:e,className:t}){let n=yo(e);return B(To,{tags:n,className:t})}function To({tags:e,className:t}){let n=e;return n.length?B(`div`,{className:`pointer-events-none absolute bottom-1 right-1 z-10 flex max-w-full flex-wrap justify-end gap-0.5 ${t||``}`,children:n.map(e=>B(So,{tag:e},e.type))}):null}const Eo=j(null);function Do(e){return e===`error`?8e3:5e3}function Oo({children:e,maxVisibleToasts:t=3}){let n=Qe({maxVisibleToasts:t}),r=I(()=>{let e=(e,t)=>n.add(e,{...t,timeout:t?.timeout??Do(e.variant)}),t=(t,n,r)=>e({...n,variant:t},r);return{add:e,info:(e,n)=>t(`info`,e,n),success:(e,n)=>t(`success`,e,n),warning:(e,n)=>t(`warning`,e,n),error:(e,n)=>t(`error`,e,n),close:n.close}},[n]);return V(Eo.Provider,{value:r,children:[e,B(de,{state:n})]})}function ko(){let e=N(Eo);if(!e)throw Error(`useToasts must be used within a ToastProvider`);return e}function Ao(e){return e.status!==`complete`&&e.status!==`error`||!e.completedAt?null:`${e.id}:${e.status}:${e.completedAt}`}function jo(e,t,n){let r=t.label||e.label;return t.status===`complete`?{variant:`success`,title:`${r} complete`,description:t.resultsAvailable?`Results are ready.`:void 0,action:t.resultsAvailable&&n?{label:`Results`,onPress:n}:void 0}:t.status===`error`?{variant:`error`,title:`${r} failed`,description:t.error?.message||t.statusText||`Action failed`}:null}function Mo(e){return{id:e.id,type:e.type,label:e.type,scope:`root`}}function No(e){if(!(!e||!e.id||e.type!==`Canvas`))return{id:e.id,type:`Canvas`,label:`Current canvas`,scope:`canvas`}}function Po(){let e=ja(),t=Ma();return I(()=>No([e,...t].find(e=>e?.resource?.source?.type===`Canvas`)?.resource?.source),[e,t])}function Fo(){let e=Hi(),t=Po(),n=H(),r=I(()=>vo(n),[n]),i=I(()=>Xt(n),[n]),a=fi(),o=K(),s=Ga(),c=Ka();return I(()=>({rootResource:e,currentCanvas:t,vault:n,tags:r,canvasProgress:i,plugins:a,config:o,layoutState:s,layoutActions:c}),[e,t,n,r,i,a,o,s,c])}function Io(){let e=J(e=>e.definitions),t=J(e=>e.instances),n=Fo(),r=I(()=>Mo(n.rootResource),[n.rootResource]);return I(()=>{let i=[r,...n.currentCanvas?[n.currentCanvas]:[]];return mn({definitions:e,instances:t,systemContext:n,targets:i,onSupportsError:(e,t)=>{console.error(`Background action "${e.id}" failed support check`,t)}})},[e,t,r,n])}function Lo(){let e=ur(),t=J(e=>e.definitions),n=J(e=>e.instances),r=J(e=>e.plans),i=J(e=>e.controllers),a=J(e=>e.hasHydrated),o=Fo(),s=L(new Set);return P(()=>{if(!a)return;let c=new Map(t.map(e=>[e.id,e]));for(let[t,a]of Object.entries(n)){let n=c.get(a.actionId),l=`${t}:${a.runId}`;!n?.resumable||!zo(a)||!r[t]||i[t]||s.current.has(l)||(s.current.add(l),nr({store:e,resume:!0,context:{...o,definition:n,target:a.target,instanceKey:t,instance:a}}))}},[i,t,a,n,r,e,o]),B(z,{children:t.map(e=>e.render?B(ye,{children:e.render({...o,definition:e})},e.id):null)})}function Ro(){let e=J(e=>e.definitions),t=J(e=>e.instances),n=Fo(),r=ko(),i=L(new Set),a=I(()=>new Map(e.map(e=>[e.id,e])),[e]);return P(()=>{for(let e of Object.values(t)){let t=Ao(e);if(!t||i.current.has(t))continue;let o=a.get(e.actionId);if(!o)continue;let s={...n,definition:o,target:e.target,instanceKey:e.id,instance:e},c=jo(o,e,e.resultsAvailable&&o.onResults?()=>{o.onResults?.(s)}:void 0);c&&(r.add(c),i.current.add(t))}},[a,t,n,r]),null}function zo(e){return e?.status===`preparing`||e?.status===`running`}function Bo(e){return!e||e.status===`idle`?``:e.status===`error`?e.error?.message||e.statusText||`Error`:e.status===`complete`&&e.resultsAvailable?`Results ready`:e.status===`cancelled`?`Cancelled`:e.statusText||e.status}function Vo(e){return e?new Date(e).toLocaleString():`Not recorded`}function Ho(e){return e?new Date(e).toLocaleTimeString(void 0,{hour:`2-digit`,minute:`2-digit`,second:`2-digit`}):`--:--:--`}function Uo(e){if(!e.startedAt)return`Not recorded`;let t=e.completedAt||Date.now(),n=Math.max(0,Math.round((t-e.startedAt)/1e3)),r=Math.floor(n/60),i=n%60;return r?`${r}m ${i}s`:`${i}s`}function Wo(e){if(e===void 0)return``;if(typeof e==`string`)return e;try{return JSON.stringify(e,null,2)}catch{return String(e)}}function Go({label:e,value:t}){return V(`div`,{className:`min-w-0`,children:[B(`dt`,{className:`text-[10px] font-semibold uppercase tracking-widest text-zinc-400`,children:e}),B(`dd`,{className:`mt-1 break-words text-sm text-zinc-800`,children:t})]})}const Ko={debug:{label:`DBG`,className:`text-zinc-500`},verbose:{label:`VRB`,className:`text-zinc-500`},info:{label:`INF`,className:`text-sky-400`},log:{label:`LOG`,className:`text-zinc-300`},warn:{label:`WRN`,className:`text-amber-400`},warning:{label:`WRN`,className:`text-amber-400`},error:{label:`ERR`,className:`text-red-400`}};function qo(e){return Ko[e?.toLowerCase()]??{label:e?.toUpperCase().slice(0,3)??`LOG`,className:`text-zinc-300`}}const Jo={error:`bg-red-100 text-red-700`,failed:`bg-red-100 text-red-700`,completed:`bg-green-100 text-green-700`,success:`bg-green-100 text-green-700`,started:`bg-sky-100 text-sky-700`,cancelled:`bg-zinc-100 text-zinc-600`,warning:`bg-amber-100 text-amber-700`,warn:`bg-amber-100 text-amber-700`};function Yo(e){return Jo[e?.toLowerCase()]??`bg-zinc-100 text-zinc-600`}function Xo(e){return e?.toLowerCase()in Jo}function Zo({definition:e,instance:t,onClose:n}){let[r,i]=R(`overview`),a=L(null),o=t.logs.length;P(()=>{r===`logs`&&a.current?.scrollIntoView({behavior:`instant`})},[r]);let s={idle:`bg-zinc-100 text-zinc-600`,preparing:`bg-orange-100 text-orange-700`,running:`bg-orange-100 text-orange-700`,complete:`bg-green-100 text-green-700`,error:`bg-red-100 text-red-700`,cancelled:`bg-zinc-100 text-zinc-500`},c=t.events.filter(e=>Xo(e.type)),l=[{id:`overview`,label:`Overview`},{id:`logs`,label:`Logs`,count:o}];return V(ee,{title:t.label||e.label,onClose:n,className:`max-w-3xl`,children:[B(`div`,{className:`sticky top-0 z-10 border-b border-zinc-200 bg-white px-2`,children:B(`div`,{className:`flex gap-0.5`,children:l.map(e=>V(`button`,{type:`button`,onClick:()=>i(e.id),className:[`flex items-center gap-1.5 border-b-2 px-3 py-2.5 text-sm transition-colors -mb-px`,r===e.id?`border-me-primary-500 font-semibold text-me-primary-600`:`border-transparent text-zinc-500 hover:text-zinc-800`].join(` `),children:[e.label,e.count?B(`span`,{className:`rounded-full bg-zinc-100 px-1.5 py-0.5 text-[10px] font-medium text-zinc-500`,children:e.count}):null]},e.id))})}),r===`overview`&&V(`div`,{className:`flex flex-col gap-5 p-5`,children:[V(`div`,{className:`flex flex-wrap items-center gap-2`,children:[B(`span`,{className:[`inline-flex items-center gap-1.5 rounded-full px-3 py-1 text-xs font-semibold uppercase tracking-wide`,s[t.status]??`bg-zinc-100 text-zinc-600`].join(` `),children:t.status}),t.statusText?B(`span`,{className:`text-sm text-zinc-500`,children:t.statusText}):null]}),V(`dl`,{className:`grid gap-x-6 gap-y-4 sm:grid-cols-2`,children:[B(Go,{label:`Target`,value:`${t.target.label} (${t.target.type})`}),B(Go,{label:`Run ID`,value:t.runId}),B(Go,{label:`Started`,value:Vo(t.startedAt)}),B(Go,{label:`Finished`,value:Vo(t.completedAt)}),B(Go,{label:`Duration`,value:Uo(t)}),t.progress?B(Go,{label:`Progress`,value:`${Math.round(t.progress.percent)}%${t.progress.label?` — ${t.progress.label}`:``}`}):null]}),t.progress?V(`div`,{children:[B(d,{percent:t.progress.percent,label:t.progress.label||`Background action progress`}),typeof t.progress.current==`number`&&typeof t.progress.total==`number`?V(`div`,{className:`mt-1 text-xs text-zinc-500`,children:[t.progress.current,` of `,t.progress.total,` items`]}):null]}):null,t.error?V(`div`,{className:`rounded-lg border border-red-200 bg-red-50`,children:[B(`div`,{className:`border-b border-red-200 px-4 py-2.5`,children:B(`span`,{className:`text-xs font-semibold uppercase tracking-widest text-red-600`,children:`Error`})}),V(`div`,{className:`p-4`,children:[B(`div`,{className:`text-sm font-medium text-red-800`,children:t.error.message}),t.error.stack?B(`pre`,{className:`mt-3 max-h-40 overflow-auto rounded bg-red-100 p-3 text-xs text-red-700 leading-relaxed whitespace-pre-wrap`,children:t.error.stack}):null]})]}):null,c.length>0?V(`div`,{children:[B(`h3`,{className:`mb-2 text-[10px] font-semibold uppercase tracking-widest text-zinc-400`,children:`Key events`}),B(`div`,{className:`divide-y divide-zinc-100 rounded-lg border border-zinc-200`,children:c.map(e=>V(`div`,{className:`flex items-baseline gap-3 px-3 py-2`,children:[B(`span`,{className:[`shrink-0 rounded px-1.5 py-0.5 text-[10px] font-semibold uppercase tracking-wide`,Yo(e.type)].join(` `),children:e.type}),B(`span`,{className:`min-w-0 flex-1 truncate text-sm text-zinc-700`,children:e.message||e.type}),B(`time`,{className:`shrink-0 text-xs text-zinc-400`,children:Ho(e.createdAt)})]},e.id))})]}):null]}),r===`logs`&&B(`div`,{className:`p-5`,children:o===0?B(`div`,{className:`rounded-lg border border-zinc-200 p-6 text-center text-sm text-zinc-400`,children:`No logs recorded.`}):V(`div`,{className:`overflow-hidden rounded-lg bg-zinc-950 shadow-inner`,children:[V(`div`,{className:`flex items-center gap-1.5 border-b border-white/10 px-3 py-2`,children:[B(`div`,{className:`h-2.5 w-2.5 rounded-full bg-zinc-700`}),B(`div`,{className:`h-2.5 w-2.5 rounded-full bg-zinc-700`}),B(`div`,{className:`h-2.5 w-2.5 rounded-full bg-zinc-700`}),V(`span`,{className:`ml-2 text-[10px] text-zinc-500 font-mono`,children:[o,` `,o===1?`entry`:`entries`]})]}),V(`div`,{className:`max-h-[50vh] overflow-y-auto p-1 font-mono text-xs`,children:[t.logs.map(e=>{let t=qo(e.level);return V(`div`,{className:`group flex gap-0 hover:bg-white/5 rounded px-2 py-1 leading-relaxed`,children:[B(`time`,{className:`w-20 shrink-0 text-zinc-600 select-none pr-2`,children:Ho(e.createdAt)}),B(`span`,{className:[`w-10 shrink-0 select-none font-bold pr-2`,t.className].join(` `),children:t.label}),V(`span`,{className:`min-w-0 flex-1 text-zinc-200 break-words`,children:[e.message,e.data===void 0?null:B(`span`,{className:`block mt-0.5 text-zinc-500 whitespace-pre-wrap`,children:Wo(e.data)})]})]},e.id)}),B(`div`,{ref:a})]})]})})]})}function Qo(){let e=ur(),t=Io(),[n,g]=R(null),_=t.reduce((e,t)=>e+t.actions.length,0),v=t.reduce((e,t)=>e+t.actions.filter(e=>zo(e.instance)).length,0),y=t.reduce((e,t)=>e+t.actions.filter(e=>e.instance?.status===`error`).length,0),{isOpen:b,buttonProps:x,itemProps:S,setIsOpen:C}=Ri(_);if(!_)return null;let w=n?t.flatMap(e=>e.actions).find(e=>e.instanceKey===n):void 0,T=0;return V(f,{children:[B(r,{active:b,runningCount:v,errorCount:y,"aria-label":`Actions menu`,...x}),B(u,{open:b,role:`menu`,"aria-hidden":!b,inert:!b,children:B(`div`,{className:`py-1.5`,children:t.map((t,n)=>V(ye,{children:[n?B(i,{}):null,B(p,{children:t.label}),t.actions.map(t=>{let{onKeyDown:n,...r}=S[T++]||{},i=Bo(t.instance),u=zo(t.instance),f=()=>{u||(nr({store:e,context:t.context}),C(!0))},p=()=>{u&&(e.getState().cancelAction(t.instanceKey),C(!0))};return V(s,{status:t.instance?.status||`idle`,children:[B(h,{running:u,...r,"aria-label":u?`Cancel ${t.definition.label}`:`Run ${t.definition.label}`,onMouseDown:e=>{e.preventDefault()},onClick:e=>{e.stopPropagation(),u?p():f()},onKeyDown:e=>{e.key===`Enter`||e.key===` `?(e.preventDefault(),e.stopPropagation(),u?p():f()):n?.(e)},children:V(m,{children:[B(c,{running:u,children:t.instance?.label||t.definition.label}),i?B(l,{variant:t.instance?.status===`error`?`error`:`default`,children:i}):null,t.definition.summary&&!i?B(l,{children:t.definition.summary}):null,u&&t.instance?.progress?B(d,{percent:t.instance.progress.percent,label:t.instance.progress.label||i||t.definition.label}):null]})}),t.instance?.resultsAvailable&&t.definition.onResults?B(o,{onClick:e=>{e.stopPropagation(),t.definition.onResults?.(t.context)},children:`Results`}):null,t.instance?B(a,{"aria-label":`View ${t.definition.label} details`,onClick:e=>{e.preventDefault(),e.stopPropagation(),g(t.instanceKey),C(!0)}}):null]},t.instanceKey)})]},t.id))})}),w?.instance?B(Zo,{definition:w.definition,instance:w.instance,onClose:()=>g(null)}):null]})}const $o=new Set([`fullpage`,`slideshow`,`scroll`]);function es(e,t){return[...e.filter(e=>!e.startsWith(`template-`)&&!$o.has(e)),t.type,`template-${t.id}`]}function ts(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 ns(e,t,n=[]){return ts(e,n)||e.find(e=>e.id===t)||e[0]||null}const rs=`manifest-editor:preset-onboarding:open`;function is(e){return typeof window<`u`&&window.localStorage.getItem(e)===`true`}function as(e){typeof window<`u`&&window.localStorage.setItem(e,`true`)}function os(e,t){return e.mode===`global`||!t?`preset-onboarding/${e.id}`:`preset-onboarding/${e.id}/${t.type}/${t.id}`}function ss(){let e=Y(),t=Hi(),n=e.preset?.onboarding,r=n?os(n,t):null;return()=>window.dispatchEvent(new CustomEvent(rs,{detail:r}))}function cs({className:t}){let n=Y().preset?.onboarding,r=ss();return n?B(e,{className:t,onPress:r,children:n.openLabel||`Open guide`}):null}function ls(e){let t=Y(),n=Hi(),{state:r,setState:i}=Si(),a=t.preset?.onboarding,o=t.preset?.onboarding?.renderPreviewButton,s=a?os(a,n):null,c=!!s&&r?.presetOnboardingPreviewHintKey===s;return o?o({...e,preview:t.preset?.preview,showOnboardingPreviewHint:c,onOnboardingPreviewHintClose:()=>{c&&i({presetOnboardingPreviewHintKey:null})}}):B(ya,{...e,preview:t.preset?.preview})}function us(){let t=Y(),n=Hi(),r=t.preset?.onboarding,{setState:i}=Si(),a=wi(),o=Ue(),s=H(),c=o?.behavior||[],l=ts(a.templates,c),u=ns(a.templates,a.selectedTemplateId,c),d=L(u?.id||null);d.current=u?.id||null;let f=I(()=>r?os(r,n):null,[r,n]),[p,m]=R(!1),[h,g]=R(!1);if(P(()=>{if(!f)return;let e=!l&&!is(f);m(e),g(e)},[l,f]),P(()=>{let e=e=>{e.detail===f&&(i({presetOnboardingPreviewHintKey:null}),m(!!r),g(!1))};return window.addEventListener(rs,e),()=>window.removeEventListener(rs,e)},[f,r,i]),!r||!f)return null;let _=()=>{a.setSelectedTemplateId(ns(a.templates,d.current)?.id||null),as(f),h&&i({presetOnboardingPreviewHintKey:f}),m(!1),g(!1)},v=e=>{d.current=e,a.setSelectedTemplateId(e);let t=a.templates.find(t=>t.id===e);if(!o||!t)return;let n=o.behavior||[],r=es(n,t);r.length===n.length&&r.every((e,t)=>e===n[t])||s.modifyEntityField(o,`behavior`,r)};return B(ee,{title:r.title,open:p,onClose:_,actions:V(`div`,{className:`flex gap-2`,children:[B(e,{onPress:_,children:r.dismissLabel||`Dismiss`}),u?B(e,{primary:!0,onPress:()=>{v(d.current),_()},children:r.primaryLabel||`Continue`}):null]}),children:V(`div`,{className:`flex flex-col gap-4 p-6`,children:[r.summary?B(`p`,{className:`text-sm text-gray-600`,children:r.summary}):null,r.renderBody({...a,selectedTemplateId:u?.id||null,selectedTemplate:u,setSelectedTemplateId:v,dismiss:_})]})})}const ds=we(function(e){let[t]=me(`menu-hidden`);return B(Mi,{children:V(ji,{children:[B(Ni,{onClick:e.onClickLogo,children:B(E,{})}),B(ya,{}),B(cs,{}),B(Qo,{})]})})}),fs=j(null);function ps(){return N(fs)||null}function ms(e,t){let n=ps();return n?n[e][t]:null}function hs({children:e,menu:t}){return B(fs.Provider,{value:t,children:e})}function gs(){return N(Ne)}function _s(e){if(!e)return null;if(e.points.length>2){let t=Math.min(...e.points.map(e=>e[0])),n=Math.min(...e.points.map(e=>e[1])),r=Math.max(0,...e.points.map(e=>e[0])),i=Math.max(0,...e.points.map(e=>e[1]));return{x:t,y:n,width:r-t,height:i-n}}return null}const vs=async e=>new Promise((t,n)=>{let r=document.createElement(`img`);r.onload=()=>t(r),r.onerror=()=>n(),r.src=e,r.complete&&t(r)}),ys=async e=>new Promise((t,n)=>{let r=document.createElement(`video`);r.onloadedmetadata=()=>t(r),r.onerror=()=>n(),r.preload=`metadata`,r.src=e});async function bs(){}async function xs(e,...t){if(!e)return;if(e.endsWith(`.mp3`)||e.endsWith(`.mp4`)||e.endsWith(`.m4a`)||e.endsWith(`.m4v`))try{let t=await ys(e);if(t){let n=t.videoWidth===0;return{id:e,type:t.videoWidth===0?`Sound`:`Video`,width:t.videoWidth||void 0,height:t.videoHeight||void 0,duration:t.duration,format:n?`audio/mp4`:`video/mp4`}}}catch{}let n=null;try{n=await fetch(e)}catch{return ws(e)}if(!n.ok&&(n=await fetch(e+`/info.json`),!n.ok))return ws(e);let r=n.headers.get(`Content-Type`);if(r?.includes(`image/`))return ws(e,r);let i=null;try{i=await n.json()}catch{return null}return await Cs(i,e)}function Ss(e){return e.protocol&&e.protocol===`http://iiif.io/api/image`?(e.type||(e.type=`ImageService`),e):null}async function Cs(e,t){let n=Ss(e);if(n)return n;if(!(e.id||e[`@id`]))return null;let r=await new et.Vault().load(t,e);if(r&&(r&&r?.type===`Manifest`||r?.type===`Collection`))return{id:t,type:r.type,label:$e(r.label)}}async function ws(e,t){let n=e.split(`/`);if(n.length>=8){let e=n.slice(-4);if(e[3].split(`.`).length===2&&(e[2][0]===`!`||e[2]===e[2])){let e=await Ts(n.slice(0,n.length-4).join(`/`)+`/info.json`);if(e&&e?.type&&e?.type?.startsWith(`ImageService`))return e}}try{let n=await vs(e);return{id:e,type:`Image`,width:n.width,height:n.height,format:await Es(e,t)}}catch{}return null}async function Ts(e){try{let t=await fetch(e);return t.ok?await Cs(await t.json(),e):null}catch(e){return console.log(e),null}}async function Es(e,t){if(t)return t;try{let t=(await fetch(e,{method:`HEAD`,mode:`no-cors`})).headers.get(`Content-type`);if(t)return t}catch{}let n=e.toLowerCase();return n.endsWith(`jpg`)||n.endsWith(`jpeg`)?`image/jpeg`:n.endsWith(`png`)?`image/png`:`image/jpeg`}async function Ds(e){try{let t=await vs(e);if(t)return{width:t.naturalWidth||t.width,height:t.naturalHeight||t.height}}catch{return null}return null}const Os=De(e=>({regions:{},resources:[],setRegion:(t,n)=>{e(e=>({...e.regions,regions:{[t]:n||null}}))},setHighlight:t=>{e({resources:Array.isArray(t)?t:[t]})},highlight:t=>{e(e=>e.resources.indexOf(t)===-1?{resources:[...e.resources,t]}:e)},clearHighlight:t=>{e(e=>({resources:e.resources.filter(e=>e!==t)}))}}));function ks(e){let t=I(()=>_r(),[]),n=Os(e=>e.regions[t]),r=Os(e=>e.setRegion);P(()=>{n&&e?n!==e&&(n.x!==e.x||n.y!==e.y||n.width!==e.width||n.height!==e.height)&&r(t,e||null):r(t,e||null)},[n]),P(()=>()=>r(t,null),[])}function As(e){let t=Os(e=>e.highlight),n=Os(e=>e.clearHighlight);return P(()=>()=>{e&&n(e)},[n,e]),I(()=>({onMouseEnter(){e&&t(e)},onMouseLeave(){e&&n(e)}}),[e,t,n])}const js=U.div`
|
|
260
|
+
`;function Lo(e,t){return e>0||!!t?.mainAction||!!t?.actions?.length}function Ro({downloadEnabled:e,fileName:t,preview:n}){let{resolveMessage:r}=H(),i=U(`shell`),{active:a,configs:o,actions:s,selected:c}=Co(),l=W(),u=J(),d=_a(),f=o.filter(e=>e.type===`external-manifest-preview`),p=n?.actions||[],{isOpen:m,buttonProps:h,itemProps:g}=so(f.length+p.length);return Lo(f.length,n)?V(z,{children:[e?B(`div`,{className:`mr-4`,children:B(b,{fileName:t||`manifest.json`,label:i(`preview.download`),getData:()=>u.export&&u.export.version===2?JSON.stringify(l.toPresentation2(d),null,2):JSON.stringify(l.toPresentation3(d),null,2)})}):null,V(Do,{children:[B(Oo,{"data-preview-action":n?.mainAction?.id,disabled:n?.mainAction?.disabled||!n?.mainAction&&f.length===0,onClick:()=>{if(n?.mainAction){n.mainAction.onClick();return}if(f.length){if(!c){let e=u.defaultPreview;if(e){let t=o.find(t=>t.id===e);if(t){s.selectPreview(t.id);return}}s.selectPreview(o[0].id)}s.updatePreviews()}},children:r(n?.mainAction?.labelMessage,n?.mainAction?.label)||i(`preview.open`)}),f.length+p.length>0?B(ko,{$open:m,...h,"aria-label":i(`preview.choose`),children:B(io,{"aria-hidden":!0})}):null,V(Ao,{$open:m,role:`menu`,children:[f.map((e,t)=>{let n=a.indexOf(e.id)===-1;return V(jo,{...g[t],children:[B(No,{$status:n?`available`:e.id===c?`active`:`configured`}),B(Po,{onClick:()=>{s.selectPreview(e.id)},children:r(e?.labelMessage,e.label)}),n?null:B(Fo,{onClick:()=>s.deletePreview(e.id),children:B(ro,{})})]},e.id)}),p.map((e,t)=>V(jo,{...g[f.length+t],"aria-disabled":e.disabled||void 0,onClick:()=>{e.disabled||e.onClick()},children:[B(No,{$status:e.status||`available`}),B(Po,{children:r(e?.labelMessage,e.label)})]},e.id))]})]})]}):B(Io,{children:i(`preview.unavailable`)})}const zo=M({resource:null});function Bo(){return P(zo)}function Vo(){let e=W(),{resource:t}=Bo();q(t,`Nothing selected`);let{id:n,type:r}=t;return nt(()=>e.get({id:n,type:r}),[n,r])}function Ho(){let{resource:e}=Bo();return e}function Uo({resource:e,children:t}){let{id:n,type:r}=e||{};return B(zo.Provider,{value:I(()=>({resource:n&&r?{id:n,type:r}:null}),[n,r]),children:t})}function Wo(e,t){switch(t.type){case`setStack`:return{...e,stack:t.payload.resources,current:t.payload.resources[0]||null};case`edit`:{let n=t.payload.reset;return(t.payload.resource?.resource.source?.type===`Manifest`||t.payload.resource?.resource.source?.type===`Canvas`)&&(n=!0),e.current?.resource.source.id===t.payload.resource?.resource.source.id?{...e,current:t.payload.resource}:{...e,current:t.payload.resource,stack:n?[]:e.current?[e.current,...e.stack]:e.stack}}case`syncRemoval`:{let n=it(t.payload.resource.resource);if(!n||!e.stack.find(e=>it(e.resource)?.id===n.id))return e;let r=e.current?.resource.id===n.id?null:e.current,i=Go(e.stack.filter(e=>it(e.resource)?.id!==n.id),r);return{...e,stack:i,current:r}}case`updateCurrent`:return{...e,current:t.payload.resource};case`back`:{let t=e.stack[0];return{...e,stack:e.stack.slice(1),current:t||null}}case`close`:return{...e,stack:[],current:null};case`create`:return t.payload.resource===null?{...e,create:null}:{...e,create:t.payload}}return e}function Go(e,t){let n=[],r=null;for(let t of e)r?.resource.id!==t.resource.id&&(n.push(t),r=t);return r&&r.resource.id===t?.resource.id?n.slice(0,n.length-1):n}const Ko={stack:[],current:null,create:null},qo=M(Ko),Jo=M({edit(){},close(){},back(){},setStack(){},updateCurrent(){},create(){return()=>{}}});function Yo(){return P(Jo)}function Xo(){return P(qo).current}function Zo(){return P(qo).stack}function Qo(){return P(qo).create}function $o(){let{manifest:e}=tt(),t=W(),[n,r]=Pe(e=>e+1,0);q(e,`Manifest not found`);let i=I(()=>new Dt({reference:{id:e,type:`Manifest`},vault:t}),[e,t]);return F(()=>i.observe.start(r),[i]),i.observe.key=`${n}`,i.observe.reset(),i}function es(){let{collection:e}=tt(),t=W(),[n,r]=Pe(e=>e+1,0);q(e,`Collection not found`);let i=I(()=>new Dt({reference:{id:e,type:`Collection`},vault:t}),[e,t]);return F(()=>i.observe.start(r),[i]),i.observe.key=`${n}`,i.observe.reset(),i}function ts(e,t={}){let n=W(),[r,i]=Pe(e=>e+1,0);!t.allowNull&&q(e,`Resource not found`);let a=I(()=>t.allowNull&&!e?null:new Dt({reference:it(e),vault:n,context:{resource:e,parent:t.parent,index:t.index,parentProperty:t.parentProperty}}),[e,n]);return F(()=>a?.observe.start(i),[a]),a&&(a.observe.key=`${r}`,a.observe.reset()),a}function ns(){let{annotationPage:e}=tt();return q(e,`Annotation page not found`),ts({id:e,type:`AnnotationPage`})}function rs(){let e=Xo(),{resource:t}=Bo(),n=W(),[r,i]=Pe(e=>e+1,0);q(e,`No resource selected`);let a=I(()=>new Dt({reference:t||e.resource.source||e.resource,vault:n}),[t,e,n]);return F(()=>a.observe.start(i),[a]),a.observe.key=`${r}`,a.observe.reset(),a}function is(e){let t=W(),[n,r]=Pe(Wo,e),i=N(e=>{r(e)},[]);F(()=>t.on(`@iiif/REMOVE_REFERENCE`,e=>{let t=e.action,n={id:t.payload.id,type:t.payload.type},i=t.payload.reference;r({type:`syncRemoval`,payload:{resource:{parent:n,resource:i}}})}),[t]);let a=N((e,t=!1)=>i({type:`edit`,payload:{resource:e,reset:t}}),[]),o=N(e=>i({type:`setStack`,payload:{resources:e}}),[]),s=N(e=>i({type:`updateCurrent`,payload:{resource:e}}),[]),c=N(()=>i({type:`close`}),[]),l=N(()=>i({type:`back`}),[]),u=N((e,t)=>(i({type:`create`,payload:{resource:e,options:t}}),()=>{i({type:`create`,payload:{resource:null}})}),[]);return[n,I(()=>({edit:a,updateCurrent:s,close:c,back:l,create:u,setStack:o}),[])]}function as(e){let{instanceId:t}=ia(),[n,r]=is(e.initialState||Ko);return B(Jo.Provider,{value:r,children:B(qo.Provider,{value:n,children:e.children})},t)}function os({resource:e,children:t}){let{instanceId:n}=ia(),[r,i]=is(I(()=>({create:null,stack:[],current:{resource:{type:`SpecificResource`,source:{id:e.id,type:e.type}}}}),[]));return B(Jo.Provider,{value:i,children:B(qo.Provider,{value:r,children:t})},n)}const ss=`@manifest-editor/tags`,cs=`tags`,ls={type:`flag`,id:`flag`,label:`Flag`,backgroundColor:`#b91c1c`,textColor:`#ffffff`,icon:`flag`},us=[];function ds(e){return typeof e==`string`?e:e?.id||null}function fs(e){return e.type||e.id}function ps(e){return`${e.type}:${e.id}`}function ms(e){if(!Array.isArray(e))return us;let t=new Map;for(let n of e){if(!n?.id)continue;let e=fs(n);t.set(e,{...n,type:e})}return Array.from(t.values())}function hs(e){return e.label||e.id||e.type}function gs(e,t){return e===ls.type&&(!t||t===ls.id)}function _s(e,t){return gs(e.type,e.id)?-1:gs(t.type,t.id)?1:hs(e.tag).localeCompare(hs(t.tag))||e.type.localeCompare(t.type)||e.id.localeCompare(t.id)}function vs(e,t){return gs(e.type)?-1:gs(t.type)?1:e.type.localeCompare(t.type)}function ys(e,t){let n=ds(t);return n?ms(e.getResourceMeta(n,ss)?.[cs]):us}function bs(e,t){let n=ds(t);return n?ms(e?.iiif?.meta?.[n]?.[ss]?.[cs]):us}function xs(e,t,n){let r=ds(t);if(!r)return us;let i=ms(n);return e.setMetaValue([r,ss,cs],i),i}function Ss(e,t,n){return xs(e,t,[...ys(e,t),n])}function Cs(e,t,n){return ys(e,t).find(e=>e.type===n)}function ws(e,t,n,r){return xs(e,t,ys(e,t).filter(e=>e.type!==n||(r?e.id!==r:!1)))}function Ts(e,t){let n=new Map;for(let r of t){let t=ds(r);if(t)for(let i of ys(e,r)){let e=i.type,r=ps(i),a=n.get(e);a||(a={key:e,type:i.type,rows:[],canvasIds:[],canvasCount:0,tagCount:0},n.set(e,a));let o=a.rows.find(e=>e.key===r);o||(o={key:r,type:i.type,id:i.id,tag:i,canvasIds:[],canvasCount:0},a.rows.push(o)),o.canvasIds.push(t),o.canvasCount=o.canvasIds.length,a.tagCount+=1}}for(let e of n.values())e.rows.sort(_s),e.canvasIds=Array.from(new Set(e.rows.flatMap(e=>e.canvasIds))),e.canvasCount=e.canvasIds.length;return Array.from(n.values()).sort(vs)}function Es(e,t,n,r){let i=Cs(e,t,n);return r?i?.id===r:!!i}function Ds(e,t,n){return Es(e,t,n.type,n.id)?ws(e,t,n.type):Ss(e,t,n)}function Os(e){return{getTags(t){return ys(e,t)},setTags(t,n){return xs(e,t,n)},addTag(t,n){return Ss(e,t,n)},upsertTag(t,n){return Ss(e,t,n)},getTag(t,n){return Cs(e,t,n)},removeTag(t,n,r){return ws(e,t,n,r)},hasTag(t,n,r){return Es(e,t,n,r)},toggleTag(t,n){return Ds(e,t,n)}}}function ks(e){let t=ds(e);return nt(e=>t?bs(e,t):us,[t])}function As(e){let t=W(),n=ds(e),r=I(()=>Os(t),[t]);return I(()=>({setTags(e){return r.setTags(n,e)},addTag(e){return r.addTag(n,e)},getTag(e){return r.getTag(n,e)},removeTag(e,t){return r.removeTag(n,e,t)},toggleTag(e){return r.toggleTag(n,e)},hasTag(e,t){return r.hasTag(n,e,t)}}),[r,n])}function js({icon:e,title:t,...n}){return e===`flag`?V(`svg`,{viewBox:`0 0 24 24`,width:`1em`,height:`1em`,"aria-hidden":!t||void 0,...n,children:[t?B(`title`,{children:t}):null,B(`path`,{fill:`currentColor`,d:`M5 21a1 1 0 0 1-1-1V5.6c0-.42.26-.8.65-.94C6.7 3.9 8.65 4 10.5 4.7c1.55.58 3.05.7 4.5.36l3.75-.88A1 1 0 0 1 20 5.15v9.25c0 .46-.31.86-.75.97l-3.79.9c-1.85.43-3.76.28-5.66-.43-1.28-.48-2.55-.59-3.8-.33V20a1 1 0 0 1-1 1Z`})]}):null}function Ms({tag:e,showIcon:t=!0,className:n,style:r}){return V(`span`,{className:`inline-flex max-w-full items-center gap-0.5 rounded px-1 py-0.5 font-medium shadow-sm ${n||``}`,style:{backgroundColor:e.backgroundColor||`#e5e7eb`,color:e.textColor||`#111827`,fontSize:9,lineHeight:`11px`,...r},children:[t&&e.icon?B(js,{icon:e.icon,className:`h-2.5 w-2.5 flex-shrink-0`}):null,B(`span`,{className:`min-w-0 truncate`,children:hs(e)})]})}function Ns({resource:e,tags:t,className:n}){return t?B(Fs,{tags:t,className:n}):B(Ps,{resource:e,className:n})}function Ps({resource:e,className:t}){let n=ks(e);return B(Fs,{tags:n,className:t})}function Fs({tags:e,className:t}){let n=e;return n.length?B(`div`,{className:`pointer-events-none absolute bottom-1 right-1 z-10 flex max-w-full flex-wrap justify-end gap-0.5 ${t||``}`,children:n.map(e=>B(Ms,{tag:e},e.type))}):null}const Is=M(null);function Ls(e){return e===`error`?8e3:5e3}function Rs({children:e,maxVisibleToasts:t=3}){let n=Ot({maxVisibleToasts:t}),r=I(()=>{let e=(e,t)=>n.add(e,{...t,timeout:t?.timeout??Ls(e.variant)}),t=(t,n,r)=>e({...n,variant:t},r);return{add:e,info:(e,n)=>t(`info`,e,n),success:(e,n)=>t(`success`,e,n),warning:(e,n)=>t(`warning`,e,n),error:(e,n)=>t(`error`,e,n),close:n.close}},[n]);return V(Is.Provider,{value:r,children:[e,B(he,{state:n})]})}function zs(){let e=P(Is);if(!e)throw Error(`useToasts must be used within a ToastProvider`);return e}function Bs(e){return e.status!==`complete`&&e.status!==`error`||!e.completedAt?null:`${e.id}:${e.status}:${e.completedAt}`}function Vs(e,t,n,r){let i=pn(r),a=i.translate(`shell`),o=mn(e,t,i);return t.status===`complete`?{variant:`success`,title:a(`background.toastComplete`,{name:o}),description:t.resultsAvailable?a(`background.resultsReady`):void 0,action:t.resultsAvailable&&n?{label:a(`background.results`),onPress:n}:void 0}:t.status===`error`?{variant:`error`,title:a(`background.toastFailed`,{name:o}),description:hn(t,i)||a(`background.failed`)}:null}function Hs(e){return{id:e.id,type:e.type,label:e.type,labelMessage:{namespace:`editor-api`,key:`resources.${e.type.charAt(0).toLowerCase()}${e.type.slice(1)}`,defaultValue:e.type},scope:`root`}}function Us(e){if(!(!e||!e.id||e.type!==`Canvas`))return{id:e.id,type:`Canvas`,label:`Current canvas`,labelMessage:{namespace:`shell`,key:`background.currentCanvas`},scope:`canvas`}}function Ws(){let e=Xo(),t=Zo();return I(()=>Us([e,...t].find(e=>e?.resource?.source?.type===`Canvas`)?.resource?.source),[e,t])}function Gs(){let{resolveMessage:e,translate:t}=H(),n=L({resolveMessage:e,translate:t});return n.current={resolveMessage:e,translate:t},I(()=>({resolveMessage:(e,t)=>n.current.resolveMessage(e,t),translate:e=>(...t)=>n.current.translate(e)(...t)}),[])}function Ks(){let e=Gs(),t=_a(),n=Ws(),r=W(),i=I(()=>Os(r),[r]),a=I(()=>On(r),[r]),o=Gi(),s=J(),c=Ca(),l=wa();return I(()=>({i18n:e,rootResource:t,currentCanvas:n,vault:r,tags:i,canvasProgress:a,plugins:o,config:s,layoutState:c,layoutActions:l}),[e,t,n,r,i,a,o,s,c,l])}function qs(){let e=Ur(e=>e.definitions),t=Ur(e=>e.instances),n=Ks(),r=I(()=>Hs(n.rootResource),[n.rootResource]);return I(()=>{let i=[r,...n.currentCanvas?[n.currentCanvas]:[]];return Gn({definitions:e,instances:t,systemContext:n,targets:i,onSupportsError:(e,t)=>{console.error(`Background action "${e.id}" failed support check`,t)}})},[e,t,r,n])}function Js(){let e=Hr(),t=Ur(e=>e.definitions),n=Ur(e=>e.instances),r=Ur(e=>e.plans),i=Ur(e=>e.controllers),a=Ur(e=>e.hasHydrated),o=Ks(),s=L(new Set);return F(()=>{if(!a)return;let c=new Map(t.map(e=>[e.id,e]));for(let[t,a]of Object.entries(n)){let n=c.get(a.actionId),l=`${t}:${a.runId}`;!n?.resumable||!Zs(a)||!r[t]||i[t]||s.current.has(l)||(s.current.add(l),Pr({store:e,resume:!0,context:{...o,definition:n,target:a.target,instanceKey:t,instance:a}}))}},[i,t,a,n,r,e,o]),B(z,{children:t.map(e=>e.render?B(Te,{children:e.render({...o,definition:e})},e.id):null)})}function Ys({definition:e,instance:t,part:n}){let r=Vs(e,t,()=>{},H());return B(z,{children:n===`action`?r?.action?.label:r?.[n]})}function Xs(){let e=Ur(e=>e.definitions),t=Ur(e=>e.instances),n=Ks(),r=zs(),i=L(new Set),a=I(()=>new Map(e.map(e=>[e.id,e])),[e]);return F(()=>{for(let e of Object.values(t)){let t=Bs(e);if(!t||i.current.has(t))continue;let o=a.get(e.actionId);if(!o)continue;let s={...n,definition:o,target:e.target,instanceKey:e.id,instance:e},c=Vs(o,e,e.resultsAvailable&&o.onResults?()=>{o.onResults?.(s)}:void 0,n.i18n);c&&(r.add({...c,title:B(Ys,{definition:o,instance:e,part:`title`}),description:c.description?B(Ys,{definition:o,instance:e,part:`description`}):void 0,action:c.action?{...c.action,label:B(Ys,{definition:o,instance:e,part:`action`})}:void 0}),i.current.add(t))}},[a,t,n,r]),null}function Zs(e){return e?.status===`preparing`||e?.status===`running`}function Qs(e,t,n,r){return e&&Number.isFinite(e)?new Intl.DateTimeFormat(t,{dateStyle:`medium`,timeStyle:`medium`,timeZone:n}).format(e):r}function $s(e,t,n){return e&&Number.isFinite(e)?new Intl.DateTimeFormat(t,{hour:`2-digit`,minute:`2-digit`,second:`2-digit`,timeZone:n}).format(e):`--:--:--`}function ec(e){if(e===void 0)return``;if(typeof e==`string`)return e;try{return JSON.stringify(e,null,2)}catch{return String(e)}}function tc({label:e,value:t}){return V(`div`,{className:`min-w-0`,children:[B(`dt`,{className:`text-[10px] font-semibold uppercase tracking-widest text-zinc-400`,children:e}),B(`dd`,{className:`mt-1 break-words text-sm text-zinc-800`,children:t})]})}const nc={debug:{label:`DBG`,className:`text-zinc-500`},verbose:{label:`VRB`,className:`text-zinc-500`},info:{label:`INF`,className:`text-sky-400`},log:{label:`LOG`,className:`text-zinc-300`},warn:{label:`WRN`,className:`text-amber-400`},warning:{label:`WRN`,className:`text-amber-400`},error:{label:`ERR`,className:`text-red-400`}};function rc(e){return nc[e?.toLowerCase()]??{label:e?.toUpperCase().slice(0,3)??`LOG`,className:`text-zinc-300`}}const ic={error:`bg-red-100 text-red-700`,failed:`bg-red-100 text-red-700`,completed:`bg-green-100 text-green-700`,success:`bg-green-100 text-green-700`,started:`bg-sky-100 text-sky-700`,cancelled:`bg-zinc-100 text-zinc-600`,warning:`bg-amber-100 text-amber-700`,warn:`bg-amber-100 text-amber-700`};function ac(e){return ic[e?.toLowerCase()]??`bg-zinc-100 text-zinc-600`}function oc(e){return e?.toLowerCase()in ic}function sc({definition:e,instance:t,onClose:n}){let r=H(),{resolveMessage:i,locale:a}=r,o=J().uiI18n?.timeZone||`UTC`,s=U(`shell`),[c,l]=R(`overview`),u=L(null),d=t.logs.length,p=i(t.progress?.labelMessage,t.progress?.label),m=new Intl.NumberFormat(a,{style:`percent`,maximumFractionDigits:0}).format((t.progress?.percent||0)/100);F(()=>{c===`logs`&&u.current?.scrollIntoView({behavior:`instant`})},[c]);let h={idle:`bg-zinc-100 text-zinc-600`,preparing:`bg-orange-100 text-orange-700`,running:`bg-orange-100 text-orange-700`,complete:`bg-green-100 text-green-700`,error:`bg-red-100 text-red-700`,cancelled:`bg-zinc-100 text-zinc-500`},g=t.events.filter(e=>oc(e.type)),_=[{id:`overview`,label:s(`background.overview`)},{id:`logs`,label:s(`background.logs`),count:d}];return V(te,{title:mn(e,t,r),onClose:n,className:`max-w-3xl`,children:[B(`div`,{className:`sticky top-0 z-10 border-b border-zinc-200 bg-white px-2`,children:B(`div`,{className:`flex gap-0.5`,children:_.map(e=>V(`button`,{type:`button`,onClick:()=>l(e.id),className:[`flex items-center gap-1.5 border-b-2 px-3 py-2.5 text-sm transition-colors -mb-px`,c===e.id?`border-me-primary-500 font-semibold text-me-primary-600`:`border-transparent text-zinc-500 hover:text-zinc-800`].join(` `),children:[e.label,e.count?B(`span`,{className:`rounded-full bg-zinc-100 px-1.5 py-0.5 text-[10px] font-medium text-zinc-500`,children:e.count}):null]},e.id))})}),c===`overview`&&V(`div`,{className:`flex flex-col gap-5 p-5`,children:[V(`div`,{className:`flex flex-wrap items-center gap-2`,children:[B(`span`,{className:[`inline-flex items-center gap-1.5 rounded-full px-3 py-1 text-xs font-semibold uppercase tracking-wide`,h[t.status]??`bg-zinc-100 text-zinc-600`].join(` `),children:s(`background.${t.status}`)}),t.statusText?B(`span`,{className:`text-sm text-zinc-500`,children:i(t.statusTextMessage,t.statusText)}):null]}),B(`p`,{className:`text-xs text-zinc-500`,children:s(`background.timeZone`,{timeZone:o})}),V(`dl`,{className:`grid gap-x-6 gap-y-4 sm:grid-cols-2`,children:[B(tc,{label:s(`background.target`),value:i(t.target.labelMessage,t.target.label)}),B(tc,{label:s(`background.runId`),value:t.runId}),B(tc,{label:s(`background.started`),value:Qs(t.startedAt,a,o,s(`background.notRecorded`))}),B(tc,{label:s(`background.finished`),value:Qs(t.completedAt,a,o,s(`background.notRecorded`))}),B(tc,{label:s(`background.duration`),value:t.startedAt?s(`background.seconds`,{count:Math.max(0,Math.round(((t.completedAt||Date.now())-t.startedAt)/1e3))}):s(`background.notRecorded`)}),t.progress?B(tc,{label:s(`background.progressLabel`),value:p?s(`background.progressValue`,{percent:m,label:p}):m}):null]}),t.progress?V(`div`,{children:[B(f,{percent:t.progress.percent,label:i(t.progress.labelMessage,t.progress.label)||s(`background.progressAccessible`)}),typeof t.progress.current==`number`&&typeof t.progress.total==`number`?B(`div`,{className:`mt-1 text-xs text-zinc-500`,children:s(`background.items`,{current:t.progress.current,count:t.progress.total})}):null]}):null,t.error?V(`div`,{className:`rounded-lg border border-red-200 bg-red-50`,children:[B(`div`,{className:`border-b border-red-200 px-4 py-2.5`,children:B(`span`,{className:`text-xs font-semibold uppercase tracking-widest text-red-600`,children:s(`background.error`)})}),V(`div`,{className:`p-4`,children:[B(`div`,{className:`text-sm font-medium text-red-800`,children:i(t.error.messageReference,t.error.message)}),t.error.stack?B(`pre`,{className:`mt-3 max-h-40 overflow-auto rounded bg-red-100 p-3 text-xs text-red-700 leading-relaxed whitespace-pre-wrap`,children:t.error.stack}):null]})]}):null,g.length>0?V(`div`,{children:[B(`h3`,{className:`mb-2 text-[10px] font-semibold uppercase tracking-widest text-zinc-400`,children:s(`background.events`)}),B(`div`,{className:`divide-y divide-zinc-100 rounded-lg border border-zinc-200`,children:g.map(e=>V(`div`,{className:`flex items-baseline gap-3 px-3 py-2`,children:[B(`span`,{className:[`shrink-0 rounded px-1.5 py-0.5 text-[10px] font-semibold uppercase tracking-wide`,ac(e.type)].join(` `),children:s(`events.${e.type}`,void 0,{defaultValue:e.type})}),B(`span`,{className:`min-w-0 flex-1 truncate text-sm text-zinc-700`,children:i(e.messageReference,e.message)||s(`events.${s(`events.${e.type}`,void 0,{defaultValue:e.type})}`,void 0,{defaultValue:e.type})}),B(`time`,{className:`shrink-0 text-xs text-zinc-400`,children:$s(e.createdAt,a,o)})]},e.id))})]}):null]}),c===`logs`&&B(`div`,{className:`p-5`,children:d===0?B(`div`,{className:`rounded-lg border border-zinc-200 p-6 text-center text-sm text-zinc-400`,children:s(`background.noLogs`)}):V(`div`,{className:`overflow-hidden rounded-lg bg-zinc-950 shadow-inner`,children:[V(`div`,{className:`flex items-center gap-1.5 border-b border-white/10 px-3 py-2`,children:[B(`div`,{className:`h-2.5 w-2.5 rounded-full bg-zinc-700`}),B(`div`,{className:`h-2.5 w-2.5 rounded-full bg-zinc-700`}),B(`div`,{className:`h-2.5 w-2.5 rounded-full bg-zinc-700`}),B(`span`,{className:`ml-2 text-[10px] text-zinc-500 font-mono`,children:s(`background.entries`,{count:d})})]}),V(`div`,{className:`max-h-[50vh] overflow-y-auto p-1 font-mono text-xs`,children:[t.logs.map(e=>{let t=rc(e.level);return V(`div`,{className:`group flex gap-0 hover:bg-white/5 rounded px-2 py-1 leading-relaxed`,children:[B(`time`,{className:`w-20 shrink-0 text-zinc-600 select-none pr-2`,children:$s(e.createdAt,a,o)}),B(`span`,{className:[`w-10 shrink-0 select-none font-bold pr-2`,t.className].join(` `),children:s(`logLevels.${e.level}`,void 0,{defaultValue:t.label})}),V(`span`,{className:`min-w-0 flex-1 text-zinc-200 break-words`,children:[i(e.messageReference,e.message),e.data===void 0?null:B(`span`,{className:`block mt-0.5 text-zinc-500 whitespace-pre-wrap`,children:ec(e.data)})]})]},e.id)}),B(`div`,{ref:u})]})]})})]})}function cc(){let e=H(),{resolveMessage:t}=e,n=U(`shell`),r=Hr(),_=qs(),[v,y]=R(null),b=_.reduce((e,t)=>e+t.actions.length,0),x=_.reduce((e,t)=>e+t.actions.filter(e=>Zs(e.instance)).length,0),S=_.reduce((e,t)=>e+t.actions.filter(e=>e.instance?.status===`error`).length,0),{isOpen:C,buttonProps:ee,itemProps:w,setIsOpen:T}=so(b);if(!b)return null;let E=v?_.flatMap(e=>e.actions).find(e=>e.instanceKey===v):void 0,D=0;return V(p,{children:[B(i,{active:C,runningCount:x,errorCount:S,"aria-label":n(`background.menu`),...ee}),B(d,{open:C,role:`menu`,"aria-hidden":!C,inert:!C,children:B(`div`,{className:`py-1.5`,children:_.map((i,d)=>V(Te,{children:[d?B(a,{}):null,B(m,{children:t(i.target.labelMessage,i.label)}),i.actions.map(i=>{let{onKeyDown:a,...d}=w[D++]||{},p=hn(i.instance,e),m=Zs(i.instance),_=()=>{m||(Pr({store:r,context:i.context}),T(!0))},v=()=>{m&&(r.getState().cancelAction(i.instanceKey),T(!0))};return V(c,{status:i.instance?.status||`idle`,children:[B(g,{running:m,...d,"aria-label":n(m?`background.cancelAction`:`background.runAction`,{name:t(i.definition.labelMessage,i.definition.label)}),onMouseDown:e=>{e.preventDefault()},onClick:e=>{e.stopPropagation(),m?v():_()},onKeyDown:e=>{e.key===`Enter`||e.key===` `?(e.preventDefault(),e.stopPropagation(),m?v():_()):a?.(e)},children:V(h,{children:[B(l,{running:m,children:mn(i.definition,i.instance,e)}),p?B(u,{variant:i.instance?.status===`error`?`error`:`default`,children:p}):null,t(i.definition.summaryMessage,i.definition.summary)&&!p?B(u,{children:t(i.definition.summaryMessage,i.definition.summary)}):null,m&&i.instance?.progress?B(f,{percent:i.instance.progress.percent,label:t(i.instance.progress.labelMessage,i.instance.progress.label)||p||t(i.definition.labelMessage,i.definition.label)}):null]})}),i.instance?.resultsAvailable&&i.definition.onResults?B(s,{onClick:e=>{e.stopPropagation(),i.definition.onResults?.(i.context)},children:n(`background.results`)}):null,i.instance?B(o,{"aria-label":n(`background.viewDetails`,{name:t(i.definition.labelMessage,i.definition.label)}),onClick:e=>{e.preventDefault(),e.stopPropagation(),y(i.instanceKey),T(!0)}}):null]},i.instanceKey)})]},i.id))})}),E?.instance?B(sc,{definition:E.definition,instance:E.instance,onClose:()=>y(null)}):null]})}const lc=new Set([`fullpage`,`slideshow`,`scroll`]);function uc(e,t){return[...e.filter(e=>!e.startsWith(`template-`)&&!lc.has(e)),t.type,`template-${t.id}`]}function dc(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 fc(e,t,n=[]){return dc(e,n)||e.find(e=>e.id===t)||e[0]||null}const pc=`manifest-editor:preset-onboarding:open`;function mc(e){return typeof window<`u`&&window.localStorage.getItem(e)===`true`}function hc(e){typeof window<`u`&&window.localStorage.setItem(e,`true`)}function gc(e,t){return e.mode===`global`||!t?`preset-onboarding/${e.id}`:`preset-onboarding/${e.id}/${t.type}/${t.id}`}function _c(){let e=X(),t=_a(),n=e.preset?.onboarding,r=n?gc(n,t):null;return()=>window.dispatchEvent(new CustomEvent(pc,{detail:r}))}function vc({className:t}){let{resolveMessage:n}=H(),r=U(`shell`),i=X().preset?.onboarding,a=_c();return i?B(e,{className:t,onPress:a,children:n(i?.openLabelMessage,i.openLabel)||r(`onboarding.openGuide`)}):null}function yc(e){let{resolveMessage:t}=H(),n=X(),r=_a(),{state:i,setState:a}=aa(),o=n.preset?.onboarding,s=n.preset?.onboarding?.renderPreviewButton,c=o?gc(o,r):null,l=!!c&&i?.presetOnboardingPreviewHintKey===c;return s?s({i18n:{resolveMessage:t},...e,preview:n.preset?.preview,showOnboardingPreviewHint:l,onOnboardingPreviewHintClose:()=>{l&&a({presetOnboardingPreviewHintKey:null})}}):B(Ro,{...e,preview:n.preset?.preview})}function bc(){let{resolveMessage:t}=H(),n=U(`shell`),r=X(),i=_a(),a=r.preset?.onboarding,{setState:o}=aa(),s=sa(),c=et(),l=W(),u=c?.behavior||[],d=dc(s.templates,u),f=fc(s.templates,s.selectedTemplateId,u),p=L(f?.id||null);p.current=f?.id||null;let m=I(()=>a?gc(a,i):null,[a,i]),[h,g]=R(!1),[_,v]=R(!1);if(F(()=>{if(!m)return;let e=!d&&!mc(m);g(e),v(e)},[d,m]),F(()=>{let e=e=>{e.detail===m&&(o({presetOnboardingPreviewHintKey:null}),g(!!a),v(!1))};return window.addEventListener(pc,e),()=>window.removeEventListener(pc,e)},[m,a,o]),!a||!m)return null;let y=()=>{s.setSelectedTemplateId(fc(s.templates,p.current)?.id||null),hc(m),_&&o({presetOnboardingPreviewHintKey:m}),g(!1),v(!1)},b=e=>{p.current=e,s.setSelectedTemplateId(e);let t=s.templates.find(t=>t.id===e);if(!c||!t)return;let n=c.behavior||[],r=uc(n,t);r.length===n.length&&r.every((e,t)=>e===n[t])||l.modifyEntityField(c,`behavior`,r)};return B(te,{title:t(a?.titleMessage,a.title),open:h,onClose:y,actions:V(`div`,{className:`flex gap-2`,children:[B(e,{onPress:y,children:t(a?.dismissLabelMessage,a.dismissLabel)||n(`onboarding.close`)}),f?B(e,{primary:!0,onPress:()=>{b(p.current),y()},children:t(a?.primaryLabelMessage,a.primaryLabel)||n(`onboarding.continue`)}):null]}),children:V(`div`,{className:`flex flex-col gap-4 p-6`,children:[t(a?.summaryMessage,a.summary)?B(`p`,{className:`text-sm text-gray-600`,children:t(a?.summaryMessage,a.summary)}):null,a.renderBody({i18n:{resolveMessage:t},...s,selectedTemplateId:f?.id||null,selectedTemplate:f,setSelectedTemplateId:b,dismiss:y})]})})}const xc=Ae(function(e){let[t]=be(`menu-hidden`);return B(to,{children:V(eo,{children:[B(no,{onClick:e.onClickLogo,children:B(A,{})}),B(Ya,{}),B(Ro,{}),B(vc,{}),B(cc,{})]})})}),Sc=M(null);function Cc(){return P(Sc)||null}function wc(e,t){let n=Cc();return n?n[e][t]:null}function Tc({children:e,menu:t}){return B(Sc.Provider,{value:t,children:e})}function Ec(){return P(We)}function Dc(){let e=Ec();return Ne(()=>e.subscribe((e,t)=>{if(e.tool.requestId===t.tool.requestId)return;let n=e.polygons;Object.assign(n.state,{transitionPoints:null,transitionBoundingBox:null,transitionOrigin:null,transitionDirection:null,transitionBezierLine:null,transitionDraw:[],transitionRotate:!1,selectionBox:null,line:null,lineBox:null}),n.setState({transitioning:!1,transitionIntentType:null,actionIntentType:null}),n.blur(),e.tool.requestId||n.setShape(null),e.requests[e.tool.requestId||``]?.type!==`target`&&n.unlockAspectRatio()}),[e]),null}function Oc(e){if(!e)return null;if(e.points.length>2){let t=Math.min(...e.points.map(e=>e[0])),n=Math.min(...e.points.map(e=>e[1])),r=Math.max(0,...e.points.map(e=>e[0])),i=Math.max(0,...e.points.map(e=>e[1]));return{x:t,y:n,width:r-t,height:i-n}}return null}const kc=async e=>new Promise((t,n)=>{let r=document.createElement(`img`);r.onload=()=>t(r),r.onerror=()=>n(),r.src=e,r.complete&&t(r)}),Ac=async e=>new Promise((t,n)=>{let r=document.createElement(`video`);r.onloadedmetadata=()=>t(r),r.onerror=()=>n(),r.preload=`metadata`,r.src=e});async function jc(){}async function Mc(e,...t){if(!e)return;if(e.endsWith(`.mp3`)||e.endsWith(`.mp4`)||e.endsWith(`.m4a`)||e.endsWith(`.m4v`))try{let t=await Ac(e);if(t){let n=t.videoWidth===0;return{id:e,type:t.videoWidth===0?`Sound`:`Video`,width:t.videoWidth||void 0,height:t.videoHeight||void 0,duration:t.duration,format:n?`audio/mp4`:`video/mp4`}}}catch{}let n=null;try{n=await fetch(e)}catch{return Fc(e)}if(!n.ok&&(n=await fetch(e+`/info.json`),!n.ok))return Fc(e);let r=n.headers.get(`Content-Type`);if(r?.includes(`image/`))return Fc(e,r);let i=null;try{i=await n.json()}catch{return null}return await Pc(i,e)}function Nc(e){return e.protocol&&e.protocol===`http://iiif.io/api/image`?(e.type||(e.type=`ImageService`),e):null}async function Pc(e,t){let n=Nc(e);if(n)return n;if(!(e.id||e[`@id`]))return null;let r=await new ft.Vault().load(t,e);if(r&&(r&&r?.type===`Manifest`||r?.type===`Collection`))return{id:t,type:r.type,label:at(r.label)}}async function Fc(e,t){let n=e.split(`/`);if(n.length>=8){let e=n.slice(-4);if(e[3].split(`.`).length===2&&(e[2][0]===`!`||e[2]===e[2])){let e=await Ic(n.slice(0,n.length-4).join(`/`)+`/info.json`);if(e&&e?.type&&e?.type?.startsWith(`ImageService`))return e}}try{let n=await kc(e);return{id:e,type:`Image`,width:n.width,height:n.height,format:await Lc(e,t)}}catch{}return null}async function Ic(e){try{let t=await fetch(e);return t.ok?await Pc(await t.json(),e):null}catch(e){return console.log(e),null}}async function Lc(e,t){if(t)return t;try{let t=(await fetch(e,{method:`HEAD`,mode:`no-cors`})).headers.get(`Content-type`);if(t)return t}catch{}let n=e.toLowerCase();return n.endsWith(`jpg`)||n.endsWith(`jpeg`)?`image/jpeg`:n.endsWith(`png`)?`image/png`:`image/jpeg`}async function Rc(e){try{let t=await kc(e);if(t)return{width:t.naturalWidth||t.width,height:t.naturalHeight||t.height}}catch{return null}return null}const zc=Le(e=>({regions:{},resources:[],setRegion:(t,n)=>{e(e=>({...e.regions,regions:{[t]:n||null}}))},setHighlight:t=>{e({resources:Array.isArray(t)?t:[t]})},highlight:t=>{e(e=>e.resources.indexOf(t)===-1?{resources:[...e.resources,t]}:e)},clearHighlight:t=>{e(e=>({resources:e.resources.filter(e=>e!==t)}))}}));function Bc(e){let t=I(()=>Xr(),[]),n=zc(e=>e.regions[t]),r=zc(e=>e.setRegion);F(()=>{n&&e?n!==e&&(n.x!==e.x||n.y!==e.y||n.width!==e.width||n.height!==e.height)&&r(t,e||null):r(t,e||null)},[n]),F(()=>()=>r(t,null),[])}function Vc(e){let t=zc(e=>e.highlight),n=zc(e=>e.clearHighlight);return F(()=>()=>{e&&n(e)},[n,e]),I(()=>({onMouseEnter(){e&&t(e)},onMouseLeave(){e&&n(e)}}),[e,t,n])}const Hc=G.div`
|
|
243
261
|
position: relative;
|
|
244
262
|
display: inline-block;
|
|
245
|
-
`;
|
|
263
|
+
`;G.div`
|
|
246
264
|
display: flex;
|
|
247
265
|
flex-direction: column;
|
|
248
266
|
position: absolute;
|
|
@@ -257,7 +275,7 @@ import{ActionButton as e,ArrowRightIcon as t,BackIcon as n,BackgroundActionMenuB
|
|
|
257
275
|
background-color: ${e=>e.theme.color.lightgrey||`lightgrey`};
|
|
258
276
|
}
|
|
259
277
|
}
|
|
260
|
-
`;const
|
|
278
|
+
`;const Uc=G.button`
|
|
261
279
|
padding: 0 ${e=>e.theme.padding.small||`0.5rem`};
|
|
262
280
|
color: ${e=>e.theme.color.main||`none`};
|
|
263
281
|
background-color: ${e=>e.theme.color.white||`white`};
|
|
@@ -276,7 +294,7 @@ import{ActionButton as e,ArrowRightIcon as t,BackIcon as n,BackgroundActionMenuB
|
|
|
276
294
|
background-color: ${e=>e.theme.color.lightgrey||`lightgrey`};
|
|
277
295
|
}
|
|
278
296
|
|
|
279
|
-
${e=>e.$active&&
|
|
297
|
+
${e=>e.$active&&K`
|
|
280
298
|
background: #b84c74;
|
|
281
299
|
color: #fff;
|
|
282
300
|
&:hover {
|
|
@@ -284,7 +302,7 @@ import{ActionButton as e,ArrowRightIcon as t,BackIcon as n,BackgroundActionMenuB
|
|
|
284
302
|
color: #fff;
|
|
285
303
|
}
|
|
286
304
|
`}
|
|
287
|
-
`,
|
|
305
|
+
`,Wc=G.div`
|
|
288
306
|
display: none;
|
|
289
307
|
flex-direction: column;
|
|
290
308
|
position: absolute;
|
|
@@ -302,26 +320,26 @@ import{ActionButton as e,ArrowRightIcon as t,BackIcon as n,BackgroundActionMenuB
|
|
|
302
320
|
overflow: hidden;
|
|
303
321
|
padding-bottom: 3px;
|
|
304
322
|
|
|
305
|
-
${
|
|
323
|
+
${To} {
|
|
306
324
|
&:hover {
|
|
307
325
|
background-color: ${e=>e.theme.color.lightgrey||`lightgrey`};
|
|
308
326
|
}
|
|
309
327
|
}
|
|
310
328
|
|
|
311
|
-
${e=>e.$open&&
|
|
329
|
+
${e=>e.$open&&K`
|
|
312
330
|
display: flex;
|
|
313
331
|
`}
|
|
314
|
-
`,
|
|
332
|
+
`,Gc=G.div`
|
|
315
333
|
color: #999;
|
|
316
334
|
text-transform: uppercase;
|
|
317
335
|
font-weight: 600;
|
|
318
336
|
padding: 0.7em;
|
|
319
337
|
font-size: 0.875em;
|
|
320
|
-
`,
|
|
338
|
+
`,Kc=G.div`
|
|
321
339
|
height: 1px;
|
|
322
340
|
margin: 0 0.5em;
|
|
323
341
|
background: #eee;
|
|
324
|
-
`,
|
|
342
|
+
`,qc=({style:e})=>V(`svg`,{xmlns:`http://www.w3.org/2000/svg`,height:`1rem`,viewBox:`0 0 24 24`,width:`1rem`,fill:`#000000`,style:e,children:[B(`path`,{d:`M0 0h24v24H0z`,fill:`none`}),B(`path`,{d:`M20 11H7.83l5.59-5.59L12 4l-8 8 8 8 1.41-1.41L7.83 13H20v-2z`})]}),Jc=e=>V(`svg`,{xmlns:`http://www.w3.org/2000/svg`,height:`1em`,width:`1em`,viewBox:`0 0 24 24`,...e,children:[B(`path`,{d:`M0 0h24v24H0z`,fill:`none`}),B(`path`,{d:`M0 0h24v24H0z`,fill:`none`}),B(`path`,{d:`M12 17.27 18.18 21l-1.64-7.03L22 9.24l-7.19-.61L12 2 9.19 8.63 2 9.24l5.46 4.73L5.82 21z`,fill:`currentColor`})]});function Yc(e){return e&&e.pinnable}function Xc({initial:e,fallback:t,options:n={}}){return Math.max(n.minWidth||0,Math.min(n.maxWidth||1/0,e||t))}function Zc(e){return typeof e==`string`?De(`div`,{dangerouslySetInnerHTML:{__html:e}}):e}function Qc(e){let t=U(`shell`),n=e.error.toString(),[r,i]=R(!1);return V(re,{children:[B(S,{className:`mb-2`,children:t(`panels.error`)}),V(`details`,{className:`mb-2 text-sm`,children:[B(`summary`,{children:t(`panels.technicalDetails`)}),B(`pre`,{className:`whitespace-pre-wrap`,children:n})]}),B(Eo,{onClick:e.resetErrorBoundary,children:t(`actions.retry`)})]})}const $c=M(null);function el(){return P($c)}const tl=G.div`
|
|
325
343
|
display: flex;
|
|
326
344
|
flex-direction: column;
|
|
327
345
|
position: relative;
|
|
@@ -377,7 +395,7 @@ import{ActionButton as e,ArrowRightIcon as t,BackIcon as n,BackgroundActionMenuB
|
|
|
377
395
|
&[data-state="unmounted"] {
|
|
378
396
|
transform: translateX(100%);
|
|
379
397
|
}
|
|
380
|
-
`,
|
|
398
|
+
`,nl=G.div`
|
|
381
399
|
background: #fff;
|
|
382
400
|
display: flex;
|
|
383
401
|
height: 2.8em;
|
|
@@ -399,7 +417,7 @@ import{ActionButton as e,ArrowRightIcon as t,BackIcon as n,BackgroundActionMenuB
|
|
|
399
417
|
background: #ffc2d2;
|
|
400
418
|
box-shadow: inset 0 -5px 10px 0 rgba(255, 255, 255, 0.5);
|
|
401
419
|
}
|
|
402
|
-
`,
|
|
420
|
+
`,rl=G.button`
|
|
403
421
|
border: none;
|
|
404
422
|
background: transparent;
|
|
405
423
|
padding: 0 0.4em;
|
|
@@ -420,9 +438,9 @@ import{ActionButton as e,ArrowRightIcon as t,BackIcon as n,BackgroundActionMenuB
|
|
|
420
438
|
svg {
|
|
421
439
|
font-size: 1.2em;
|
|
422
440
|
}
|
|
423
|
-
`,
|
|
441
|
+
`,il=G.div`
|
|
424
442
|
flex: 1 1 0px;
|
|
425
|
-
`,
|
|
443
|
+
`,al=G.h2`
|
|
426
444
|
font-size: 0.875em;
|
|
427
445
|
font-weight: 400;
|
|
428
446
|
margin: 0;
|
|
@@ -430,7 +448,7 @@ import{ActionButton as e,ArrowRightIcon as t,BackIcon as n,BackgroundActionMenuB
|
|
|
430
448
|
padding-left: 1em;
|
|
431
449
|
text-align: center;
|
|
432
450
|
align-self: center;
|
|
433
|
-
`,
|
|
451
|
+
`,ol=G.div`
|
|
434
452
|
flex: 1 1 0px;
|
|
435
453
|
display: flex;
|
|
436
454
|
|
|
@@ -441,13 +459,20 @@ import{ActionButton as e,ArrowRightIcon as t,BackIcon as n,BackgroundActionMenuB
|
|
|
441
459
|
> * {
|
|
442
460
|
min-width: 0;
|
|
443
461
|
}
|
|
444
|
-
`;function Xs({panel:e,state:t,actions:n,isLeft:r,pinActions:i=n,transition:a,close:o,available:s=[],style:c,noHeader:l,isModal:u}){let d=N(Le)||null,[f,p]=R(!1),m=Si(),h=Ya(),{tabs:g,pinnable:_,hideHeader:v}=e?.options||{},y=I(()=>(s||[]).filter(e=>!e.requiresState),[s]),{itemProps:b,isOpen:x,setIsOpen:S}=Ri(y.length),[C,w]=R(``),T=L(void 0);P(()=>p(!1),[m.state.canvasId,e?.id]),P(()=>w(``),[e]),P(()=>(T.current=w,()=>{T.current=void 0}),[]);let E=M(e=>{T.current&&T.current(e)},[]),ee=M(r=>{let i=e?t.stack.length?n.popStack:e.backAction?()=>e&&e.backAction&&e.backAction(t,{...h,current:n},m):null:null;r&&(!i||r.metaKey)&&y.length?(r.preventDefault(),S(!0)):i?.()},[n,m,h,e,S,t,y.length]),D=r=>{n.change({id:r.id,state:r.defaultState,stacked:!!(t.stack.length||e?.backAction)})};if(!e||!t.current)return null;let O=e.backAction||t.stack.length?B(Ks,{"aria-label":`Back`,onClick:ee,children:B(Is,{"aria-hidden":`true`})}):null,k=B(Ks,{"aria-label":`Close panel`,onClick:o||n.close,children:B(Pi,{"aria-hidden":`true`})});return B(Hs.Provider,{value:E,children:V(Ws,{"data-modal":u,"data-state":a,"data-flipped":r,style:c,"data-header":!l,children:[l?null:V(Gs,{"data-tabs":!!g,"data-error":f,children:[V(js,{style:{display:`flex`,height:`100%`},children:[e.renderBackAction?e.renderBackAction({backAction:ee,fallback:O}):O,y.length?V(Ns,{$open:x,role:`menu`,style:{left:`0.5em`},children:[B(Ps,{children:`All panels`}),B(Fs,{}),y.map((t,n)=>B(Ms,{...b[n],onClick:()=>D(t),$active:e.id===t.id,children:t.label},n))]}):null]}),C?B(Js,{as:r?`h1`:`h2`,children:C}):v?B(qs,{}):B(Js,{as:r?`h1`:`h2`,children:e.label}),_?t.pinned?B(Ks,{"aria-label":`Unpin panel`,onClick:i.unpin,children:B(Ls,{"aria-hidden":`true`,fill:`orange`})}):B(Ks,{"aria-label":`Pin panel`,onClick:()=>i.pin({id:e.id,state:t.state}),children:B(Ls,{"aria-hidden":`true`,fill:`#ddd`})}):null,e.renderCloseAction?e.renderCloseAction({closeAction:o||n.close,fallback:k}):k]}),B(Ys,{className:`OverrideScrollbar`,children:B(at,{onError:()=>p(!0),FallbackComponent:Vs,resetKeys:[m.state.canvasId,e?.id],onReset:()=>p(!1),children:Bs(e.render(t.state||e.defaultState||{},{...h,current:n,vault:d,transition:a,isModal:u},m))})})]})})}function Zs(e=`vault://homepage-collection.json`){let t=new tt,n=window.localStorage.getItem(`preview-vault-collection`),r=!1;if(n)try{let i=JSON.parse(n);if(i.id&&i.id===e){t.dispatch(ut({id:i.id}));let e=dt(i.id,i);t.dispatch(st({actions:e})),r=!0}}catch{}if(!r){let n=dt(e,{"@context":`http://iiif.io/api/presentation/3/context.json`,id:e,type:`Collection`,label:{en:[`Recent items`]},items:[]});t.dispatch(ut({id:e})),t.dispatch(st({actions:n}))}return t.on(`after:@iiif/REMOVE_REFERENCE`,n=>{n.action.payload.id===e&&window.localStorage.setItem(`preview-vault-collection`,JSON.stringify(t.toPresentation3({id:e,type:`Collection`})))}),{vault:t,unsubscribe:()=>{},addHistory:(n,r)=>{let i=t.getState();if(n&&r&&(r===`Collection`||r===`Manifest`)){let a=i.iiif.entities.Collection[e];if(a){let i=a.items.findIndex(e=>e.id===n);i===-1?t.dispatch(ot({id:e,type:`Collection`,reference:{id:n,type:r},key:`items`,index:0})):t.dispatch(lt({id:e,type:`Collection`,key:`items`,startIndex:i,endIndex:0})),window.localStorage.setItem(`preview-vault-collection`,JSON.stringify(t.toPresentation3({id:e,type:`Collection`})))}}},clearHistory:()=>{t.dispatch(ct({id:e,type:`Collection`,key:`items`,value:[]})),window.localStorage.setItem(`preview-vault-collection`,JSON.stringify(t.toPresentation3({id:e,type:`Collection`})))}}}function Qs(){return N($s)}const $s=j(new tt),ec=j({addHistory:(e,t)=>{},clearHistory:()=>{}}),tc=`manifest-editor://homepage-collection.json`;function nc(){return N(ec)}function rc(e){let{vault:t,unsubscribe:n,addHistory:r,clearHistory:i}=I(()=>Zs(tc),[]);return P(()=>n,[]),B(ec.Provider,{value:{addHistory:r,clearHistory:i},children:B($s.Provider,{value:t,children:e.children})})}function ic({children:e}){let t=Qs();return B(ze,{vault:t,children:e})}function ac(e,t,n,r,i){let a=H(),o=Y(),{create:s,edit:c}=Ka(),l=I(()=>it({type:n,parent:e,index:0,property:t},o.layout.creators||[],{vault:a}),[e,t,o.layout.creators,n,a]),u=e&&l.length!==0,d=M((a,o)=>{if(e)return s({type:n,parent:qe(e),property:t,index:a,target:r,initialData:o,...i||{}})},[s,e,t,n,i,r]),f=M((a,o,c)=>{if(e)return s({type:n,filter:a,parent:qe(e),property:t,index:o,target:r,initialData:c,...i||{}})},[s,e,t,n,i,r]);return[u,{create:d,edit:M((n,r)=>{c(n,e?{parent:qe(e),property:t,index:r}:void 0)},[c,e,t]),createFiltered:f,creator:M((a,o)=>{if(e)return s({type:n,initialCreator:a,parent:qe(e),property:t,target:r,initialData:o,...i||{}})},[n,t,e,r,s,i]),buttonProps:I(()=>({"data-action-id":mr(n,t,e)}),[n,t,e])}]}function oc(){let e=H(),t=Qs(),n=Y(),r=K();return I(()=>new nt(e,n.layout.creators||[],t,r.creators),[n.layout.creators,r.creators,t,e])}async function sc(e){let t=await e.create(),n=Array.isArray(t)?t[0]:t;return n?(e.onCreate?.(),e.close?.(),e.edit?.(n),!0):!1}const cc=j({});function lc(e){return N(cc)[e]||{}}function uc(e){let t=N(cc),n=I(()=>({...t,[e.id]:e.data}),[t,e.id,e.data]);return B(cc.Provider,{value:n,children:e.children})}const dc=we(function(t){let n=H(),{edit:r,modal:i}=Ka(),[a,o]=R(!1),[s,c]=R(null),l=oc(),u=K(),d=L(!1),f=t.resource.initialData?.selector;ks(f);let p=lc(t.creator.id),m={targetType:t.resource.type,parent:t.resource.parent?{property:t.resource.property,atIndex:t.resource.index,resource:t.resource.parent}:void 0,target:t.resource.target,initialData:{...p,...t.resource.initialData||{},...t.initialData||{}}},h=async e=>{if(!(a||d.current)){o(!0),d.current=!0;try{await sc({create:()=>l.create(t.creator.id,e,m),onCreate:t.onCreate,close:t.skipEditingOnCreate?void 0:()=>{i.popStack(),i.close()},edit:t.skipEditingOnCreate||t.resource.initialData?.skipEditingOnCreate?void 0:e=>r(e,{parent:qe(t.resource.parent),property:t.resource.property,index:t.resource.index})})}catch(e){c(e?.message||`Unknown error`)}finally{o(!1),d.current=!1}}},g=async()=>!0;if(P(()=>{t.resource.initialData?.showEmptyForm||!t.creator.render&&!a&&h({})},[t.creator]),s)return B(`div`,{className:`flex flex-col items-center p-4`,children:B(x,{children:s})});let _=B(`div`,{className:`flex flex-col items-center py-8`,children:V(`div`,{className:`flex gap-2 items-center`,children:[B(A,{}),` `,B(`span`,{children:`Loading`})]})});return a?_:t.creator.render?B(z,{children:B(be,{fallback:_,children:t.creator.render({vault:n,runCreate:h,validate:g,options:m,config:u.creators?.[rt(t.creator)]||{}})})}):V(z,{children:[B(b,{children:`No options available`}),B(e,{primary:!0,onPress:()=>h({}),children:t.creator.actionButton||`Create`})]})});function fc(t){let n=Y(),r=H(),[i,a]=R(t.resource.initialCreator||``),[o,s]=R(),[c,l]=R(``),[u,d]=R(!1),[f,p]=R(``),[m,h]=R(null),g=L(null),v=Us(),y=I(()=>it(t.resource,n.layout.creators||[],{vault:r}),[t.resource,n.layout.creators,r]),x=y.some(e=>e.supportsResource);P(()=>{y.length===1&&!i&&!x&&a(y[0].id)},[x,i,y]),P(()=>{x&&!i&&g.current?.focus()},[x,i]);let S=y.find(e=>e.id===i);if(P(()=>{S&&v?.(S.label)}),y.length===0)return B(b,{children:`Not currently supported`});let T=(e,t)=>{s(t||gc(c)),a(e.id)},E=async e=>{e.preventDefault();let n=c.trim();if(!n||u)return;d(!0),p(``),h(null);let i=_c(),a=await Promise.all(y.map(async e=>{if(!e.supportsResource)return null;try{let a=await e.supportsResource(n,i,{vault:r,resource:t.resource});return a?{creator:e,initialData:hc(n,a).initialData}:null}catch(t){return{creator:e,error:t?.message||`Could not check this link`}}})),o=a.filter(pc),s=a.filter(mc);if(d(!1),o.length===1){T(o[0].creator,o[0].initialData);return}if(o.length>1){h(o),p(`Multiple creators can use this link. Choose one below.`);return}p(s[0]?.error||`No creator recognised this link. Choose one below.`)},ee=B(D,{children:B(w,{root:document.getElementById(`headlessui-portal-root`)||void 0,label:`Back to Add content options`,className:`group`,placement:`right`,onPress:()=>{a(``),s(void 0)},children:B(C,{className:`text-2xl opacity-50 group-hover:opacity-70`})})});if(S)return S.hiddenModal?V(z,{children:[ee,B(dc,{creator:S,resource:t.resource,initialData:o})]}):V(`div`,{children:[ee,B(`div`,{className:`p-2 py-6`,children:B(dc,{creator:S,resource:t.resource,initialData:o})})]});let O=m?.length?m.map(e=>e.creator):y,k=new Map(m?.map(e=>[e.creator.id,e.initialData]));return V(z,{children:[x?V(`form`,{className:`p-4 pb-0`,onSubmit:E,children:[B(`label`,{className:`block text-sm font-medium text-gray-700`,htmlFor:`creator-resource-link`,children:`Paste a link`}),V(`div`,{className:`mt-1 flex gap-2`,children:[B(`input`,{ref:g,id:`creator-resource-link`,className:`min-w-0 flex-1 rounded border border-gray-300 px-3 py-2 text-sm`,value:c,onChange:e=>{l(e.currentTarget.value),p(``),h(null)},placeholder:`https://example.org/resource`,type:`url`}),B(e,{primary:!0,type:`submit`,isDisabled:!c.trim()||u,children:u?`Checking`:`Use link`})]}),f?B(`div`,{className:`mt-2 text-sm text-gray-600`,role:`status`,children:f}):null]}):null,B(_,{label:`Select a type`,items:O.map(e=>({id:e.id,title:e.label,description:e.summary||``,icon:e.icon,onClick:()=>T(e,k.get(e.id))}))})]})}function pc(e){return!!e&&!(`error`in e)}function mc(e){return!!e&&`error`in e}function hc(e,t){return typeof t==`object`?t:{initialData:gc(e)}}function gc(e){let t=e.trim();return t?{url:t,youtubeUrl:t}:void 0}function _c(){let e=new Map,t=new Map,n=new Map,r=t=>(e.has(t)||e.set(t,fetch(t).then(e=>{if(!e.ok)throw Error(`Could not load ${t}`);return e.text()})),e.get(t)),i=e=>(n.has(e)||n.set(e,fetch(e,{method:`HEAD`}).then(t=>{if(!t.ok)throw Error(`Could not check ${e}`);return t})),n.get(e));return{text:r,head:i,json(e){return t.has(e)||t.set(e,r(e).then(e=>JSON.parse(e))),t.get(e)},async contentType(e){return(await i(e)).headers.get(`content-type`)||``}}}const vc={id:`@manifest-editor/creator`,label:`Add content`,options:{hideHeader:!0,tabs:!1},render(e){return B(fc,{resource:e})}},yc={color:{main:`#B84C74`,mainHover:`#4a89ff`,logoPink:`#E94581`,white:`white`,grey:`grey`,black:`black`,lightgrey:`#F8F9FA`,mediumgrey:`#dddddd`,danger:`#a90e21`,warning:`#e38627`,lightdanger:`#ffeaea`,lightsuccess:`#c5e8c5`,success:`#6ccd55`,greyOverlay:`rgba(0, 0, 0, 0.2)`,highlight:`#faeed7`},iiifColor:{manifest:`rgba(0, 0, 0, 0.2)`,canvas:`rgba(255, 222, 219, 0.8)`,service:`rgba(13, 110, 253, 0.8)`,annotation:`rgba(247, 226, 173, 0.8)`,contentResource:`rgba(207, 247, 255, 0.8)`,ranges:`rgba(144, 213, 157, 0.8)`},padding:{xs:`0.25rem`,small:`0.5rem`,medium:`1rem`,large:`2rem`},device:{mobile:`375px`,tablet:`768px`,laptop:`992px`,desktop:`1200px`},shadows:{standard:`rgba(0, 0, 0, 0.1) 0px 1px 3px 0px, rgba(0, 0, 0, 0.05) 0px 5px 15px 0px`,bottom:`rgba(0, 0, 0, 0.1) 0px 4px 2px -2px`}};function bc(e){let{}=e,t=H(),n=Y(),r=I(()=>it(e.resource,n.layout.creators||[],{vault:t}),[e.resource,n.layout.creators,t]);return r.length===0?B(`div`,{children:`No supported creators found`}):B(`div`,{children:V(ue,{className:`w-full flex-1 overflow-hidden flex flex-col`,children:[B(ce,{className:`flex-1 overflow-hidden w-full flex text-sm whitespace-nowrap`,items:r,children:e=>B(se,{id:e.id,children:e.label})}),r.map(t=>B(le,{id:t.id,className:`p-2`,children:B(Je,{theme:yc,children:B(dc,{creator:t,resource:e.resource,onCreate:e.onCreate,skipEditingOnCreate:!0})})},t.id))]})})}function xc({fallback:e,backAction:t}){let n=Ma(),{back:r}=Aa();return n.length?B(Ks,{"aria-label":`Back`,onClick:r,children:B(Is,{"aria-hidden":`true`})}):e}function Sc({closeAction:e,fallback:t}){let n=Ma();return ja()||n.length?B(Ks,{"aria-label":`Close panel`,onClick:()=>{e()},children:B(Pi,{"aria-hidden":`true`})}):t}function Cc(e,t,n,r){let i=t.filter(t=>t.resourceType===e.resource.source.type);if(i.length===0)return null;for(let t of i){let i=[],a={},o=e.property===`partOf`,s=(t.editors||[]).filter(t=>{if(o&&t.id!==`@manifest-editor/part-of-reference`||r.hideTabs&&r.hideTabs.includes(t.id)||r.onlyTabs&&!r.onlyTabs.includes(t.id))return!1;if(t.supports.sortKey){if(i.includes(t.supports.sortKey))return!1;t.supports.sortFallback&&(a[t.supports.sortKey]=t)}return n.edit&&!t.supports.edit||t.supports.custom&&t.supports.custom(e,n.vault)===!1?!1:(t.supports.sortKey&&i.push(t.supports.sortKey),!0)}),c=Object.keys(a);for(let e of c)!i.includes(e)&&a[e]&&!s.includes(a[e])&&s.push(a[e]);if(s.length)return{...t,editors:s}}return null}function wc({currentTab:e=void 0}){let t=ja(),n=N(Re),r=Y(),i=Hi(),a=H(),{change:o}=Ka(),s=Us(),{editorConfig:c}=K(),l=t?.resource.source?.id,u=t?.resource.source?.type,d=l!==i.id;l&&d&&i.type===`Collection`&&u===`Collection`&&(u=`EmbeddedCollection`);let f=(u?c[u]:c.All)||{},p=I(()=>{let e={...n},r=t?.resource.source.id,i=t?.resource.source.type,a={Collection:`collection`,Manifest:`manifest`,Range:`range`,Canvas:`canvas`,Annotation:`annotation`,AnnotationPage:`annotationPage`};return i&&a[i]&&(e[a[i]]=r),e},[t,n]);function m(e){return t?B(Re.Provider,{value:p,children:e}):e}let h=I(()=>{if(!t)return null;let e=r.layout.editors||[],n=(r.layout.resources||[]).map(t=>typeof t==`string`?{id:`@default/`+t,label:t,resourceType:t,auto:!0,editors:e.filter(e=>e.supports.resourceTypes.includes(t))}:t);return Cc(t,n,{edit:!0,vault:a},f)},[t,r]);P(()=>{s(h?.label||``)},[h]),P(()=>{let t=h?.editors.map(e=>e.id)||[];t.find(t=>t===e)||o(`@manifest-editor/editor`,{currentTab:t[0]})},[h?.editors,e,o]);let g=I(()=>(h?.editors||[]).map(e=>({id:e.id,label:e.label,renderComponent:()=>e.component(f)})),[h?.editors,f]);if(!t||!h)return null;if(f.singleTab){let e=(h?.editors||[]).find(e=>e.id===f.singleTab);if(e)return m(B(`div`,{className:`w-full`,children:e.component(f)},t.resource.source?.id))}return m(B(oe,{isNested:d,rootResource:i,menuId:t.resource.source.id,menu:g,selectedKey:e,onSelectionChange:e=>{o(`@manifest-editor/editor`,{currentTab:e})}},t.resource.source?.id))}const Tc={id:`@manifest-editor/editor`,label:`Editor`,options:{hideHeader:!0,tabs:!0,minWidth:400},renderBackAction:({backAction:e,fallback:t})=>B(xc,{backAction:e,fallback:t}),renderCloseAction:({closeAction:e,fallback:t})=>B(Sc,{closeAction:e,fallback:t}),render({currentTab:e}){return B(wc,{currentTab:e})}};function Ec(e){let[t,n]=R(!1),r=L(null),i=L(0);function a(t){i.current--,!(t&&i.current!==0)&&(r.current&&(clearTimeout(r.current),r.current=0),r.current=setTimeout(()=>{n(!1)},e))}function o(){i.current++,r.current&&clearTimeout(r.current),n(!0)}return I(()=>[t,{set:o,clear:a}],[t])}function Dc(e){return e?typeof e==`string`?{src:e,alt:``}:e:null}function Oc(e){return e?typeof e==`string`?e:e.name:null}function kc(e){let t=e.extension,n=t.leftPanels?.[0]||t.centerPanels?.[0]||t.rightPanels?.[0]||t.modalPanels?.[0];return n?{id:n.id,label:n.label||`Open plugin`,modal:t.modalPanels?.some(e=>e.id===n.id)||!1}:null}function Ac(e){return e instanceof Error?e.message:`Plugin configuration could not be saved.`}function jc(e){return V(`svg`,{xmlns:`http://www.w3.org/2000/svg`,width:`1em`,height:`1em`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,...e,children:[B(`path`,{d:`M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z`}),B(`circle`,{cx:`12`,cy:`12`,r:`3`})]})}function Mc(e){return V(`svg`,{xmlns:`http://www.w3.org/2000/svg`,width:`1em`,height:`1em`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,...e,children:[B(`path`,{d:`M7 7h10v10`}),B(`path`,{d:`M7 17 17 7`})]})}function Nc(){let e=Y(),{appId:t}=xi(),n=K(),r=It(),i=li(),a=di(),o=Ka(),{saveGlobalPluginConfig:s}=N(ii),[c,l]=R(!1),[u,d]=R(``),[f,p]=R(null),[m,h]=R(null),[_,v]=R(null),y=I(()=>new Set(Ur(i,e,t).map(e=>e.metadata.id)),[i,e,t]),b=I(()=>{let n=u.trim().toLowerCase();return i.plugins.filter(r=>{let i=zr(r,e,t);return!c&&!i?!1:!n||[r.metadata.label,r.metadata.id,r.metadata.description,Oc(r.metadata.author),...r.metadata.tags||[]].filter(Boolean).join(` `).toLowerCase().includes(n)})},[e,t,i.plugins,u,c]),x=f&&i.plugins.find(e=>e.metadata.id===f)||null;if(!i.plugins.length)return null;function S(e){a.setAppConfig(t,e),r({plugins:{...n.plugins||{},apps:{...n.plugins?.apps||{},[t]:e}}})}async function C(e){if(!s){v(`Global plugin settings are not available in this host.`);return}let n=i.globalApps[t]||{},r={apps:{...i.globalApps,[t]:e}};a.setGlobalAppConfig(t,e);try{await s(r)}catch(e){a.setGlobalAppConfig(t,n),v(Ac(e))}}async function w(n,r,a){v(null),h(`${a}:${n.metadata.id}`);let o=a===`global`?i.globalApps[t]||{}:i.apps[t]||{},s=r?Xr(o,i,n,e,t):{config:kr(o,n.metadata.id),blocked:[]};if(s.blocked.length){h(null),v(`Cannot enable ${n.metadata.label}: ${s.blocked.join(`, `)}.`);return}a===`global`?await C(s.config):S(s.config),h(null)}function T(e){let t=kc(e);if(t){if(t.modal){o.modal.open({id:t.id});return}o.open(t.id)}}return V(`section`,{className:`flex flex-col gap-3 border-t border-gray-200 pt-4 mt-4`,children:[V(`div`,{className:`flex items-center gap-2`,children:[B(`div`,{className:`min-w-0 flex-1`,children:B(`h3`,{className:`font-semibold text-sm text-gray-900`,children:`Plugins`})}),B(`button`,{type:`button`,className:`rounded border border-gray-200 bg-white px-2 py-1 text-xs text-gray-500 hover:text-gray-700 hover:border-gray-300 transition-colors`,onClick:()=>l(e=>!e),children:c?`Compatible only`:`Show all`})]}),B(`input`,{"aria-label":`Search plugins`,className:`rounded border border-gray-200 px-2.5 py-1.5 text-xs focus:border-me-primary-500 focus:ring-2 focus:ring-me-primary-500/20 focus:outline-none`,type:`search`,placeholder:`Search plugins…`,value:u,onChange:e=>d(e.currentTarget.value)}),_?B(`div`,{className:`rounded border border-red-200 bg-red-50 px-3 py-2 text-xs text-red-700`,children:_}):null,B(`div`,{className:`flex flex-col gap-2`,children:b.map(n=>{let r=Vr(n,i,t),a=y.has(n.metadata.id),o=r&&n.loadStatus===`loading`,s=r&&n.loadStatus===`error`?n.loadError:null,c=Dc(n.metadata.image),l=r&&!a&&!o&&!s,u=zr(n,e,t),d=Br(n,e,t),f=kc(n),h=!!n.settings,_=m===`workspace:${n.metadata.id}`;return V(`article`,{className:`flex gap-2.5 rounded-lg border bg-white p-3 text-sm transition-colors ${a?`border-gray-200`:`border-gray-100 bg-gray-50`} ${u?``:`bg-gray-100`}`,children:[c?B(`img`,{className:`h-9 w-9 rounded object-cover flex-none mt-0.5`,src:c.src,alt:c.alt||n.metadata.label}):B(`div`,{className:`h-9 w-9 rounded flex items-center justify-center flex-none mt-0.5 text-lg ${a?`bg-me-primary-50 text-me-primary-500`:`bg-gray-100 text-gray-600`}`,children:B(jc,{className:`w-4 h-4`})}),V(`div`,{className:`flex min-w-0 flex-1 flex-col gap-1`,children:[V(`div`,{className:`flex items-start justify-between gap-1`,children:[V(`div`,{className:`flex flex-wrap items-center gap-1.5 min-w-0`,children:[B(`span`,{className:`font-medium text-gray-900 text-xs`,children:n.metadata.label}),n.metadata.official?V(`span`,{className:`rounded-full text-me-primary-500 px-1.5 py-0 text-[9px] font-bold inline-flex items-center gap-1`,children:[B(g,{className:`w-3 h-3`}),` Verified`]}):null,n.metadata.version?B(`span`,{className:`text-[10px] text-gray-600`,children:n.metadata.version}):null]}),V(`div`,{className:`flex items-center gap-1 flex-none`,children:[h?B(`button`,{type:`button`,title:`Configure plugin`,"aria-label":`Configure ${n.metadata.label}`,className:`rounded p-1 text-gray-600 hover:text-gray-700 hover:bg-gray-100 transition-colors`,onClick:()=>p(n.metadata.id),children:B(jc,{className:`w-3.5 h-3.5`})}):null,a&&f?B(`button`,{type:`button`,title:`Open ${f.label}`,"aria-label":`Open ${f.label}`,className:`rounded p-1 text-me-primary-500 hover:bg-me-primary-50 transition-colors`,onClick:()=>T(n),children:B(Mc,{className:`w-3.5 h-3.5`})}):null,B(`button`,{type:`button`,disabled:!u||_,onClick:()=>w(n,!r,`workspace`),className:`relative inline-flex h-5 w-9 flex-none items-center rounded-full transition-colors disabled:opacity-40 focus:outline-none focus:ring-2 focus:ring-me-primary-500/30 ${r?`bg-me-primary-500`:`bg-gray-200`}`,title:r?`Disable plugin`:`Enable plugin`,"aria-label":`${r?`Disable`:`Enable`} ${n.metadata.label}`,children:B(`span`,{className:`inline-block h-3.5 w-3.5 transform rounded-full bg-white shadow transition-transform ${r?`translate-x-4`:`translate-x-0.5`}`})})]})]}),n.metadata.description?B(`p`,{className:`text-xs text-gray-500 leading-relaxed`,children:n.metadata.description}):null,o?B(`span`,{className:`text-xs text-gray-500`,children:`Loading plugin…`}):null,s?B(`span`,{className:`text-xs text-red-600`,children:s}):null,l?B(`span`,{className:`text-xs text-amber-600`,children:`Waiting for required dependencies`}):null,!u&&d?B(`span`,{className:`text-xs text-gray-600`,children:d}):null]})]},n.metadata.id)})}),b.length?null:B(`div`,{className:`rounded-lg border border-gray-100 bg-gray-50 p-4 text-center text-xs text-gray-500`,children:`No plugins found.`}),x?B(ee,{title:`Configure ${x.metadata.label}`,onClose:()=>p(null),width:`560px`,children:B(Pc,{plugin:x,onClose:()=>p(null),canSaveGlobal:!!s})}):null]})}function Pc({plugin:e,onClose:t,canSaveGlobal:n}){let r=mi(e.metadata.id),[i,a]=R(`workspace`),[o,s]=R({}),[c,l]=R(!1),[u,d]=R(!1),[f,p]=R(null),m=i===`global`?r.global:r.workspace;P(()=>{s({...m}),p(null),d(!1)},[e.metadata.id,i]);async function h(){let t=e.settings?.validate?.(o);if(t){p(t);return}l(!0),p(null);try{i===`global`?await r.setGlobalSettings(o):r.setWorkspaceSettings(o),d(!0),setTimeout(()=>d(!1),2e3)}catch(e){p(Ac(e))}finally{l(!1)}}async function g(){l(!0),p(null);try{i===`global`?await r.resetGlobalSettings():r.resetWorkspaceSettings(),s({})}catch(e){p(Ac(e))}finally{l(!1)}}let _=n&&r.canSaveGlobal;return V(`div`,{className:`flex flex-col flex-1 min-h-0`,children:[_?V(`div`,{className:`flex items-center gap-1 px-5 pt-4 pb-3 border-b border-gray-100`,children:[B(`span`,{className:`text-xs text-gray-500 mr-2`,children:`Scope:`}),B(`button`,{type:`button`,className:`rounded-full px-3 py-1 text-xs font-medium transition-colors ${i===`workspace`?`bg-me-primary-500 text-white`:`bg-gray-100 text-gray-600 hover:bg-gray-200`}`,onClick:()=>a(`workspace`),children:`This workspace`}),B(`button`,{type:`button`,className:`rounded-full px-3 py-1 text-xs font-medium transition-colors ${i===`global`?`bg-me-primary-500 text-white`:`bg-gray-100 text-gray-600 hover:bg-gray-200`}`,onClick:()=>a(`global`),children:`All workspaces`})]}):null,f?B(`div`,{className:`mx-5 mt-4 rounded-lg border border-red-200 bg-red-50 px-3 py-2 text-xs text-red-700`,children:f}):null,B(`div`,{className:`flex-1 overflow-y-auto p-5`,children:B(`div`,{className:`flex flex-col gap-3`,children:e.settings?.render?e.settings.render({plugin:e,appId:r.appId,scope:i,value:o,defaults:r.defaults,effective:r.effective,onChange:s}):e.settings?.fields?.length?e.settings.fields.map(e=>B(Fc,{field:e,draft:o,setDraft:s},e.id)):B(`div`,{className:`rounded-lg border border-gray-100 bg-gray-50 p-4 text-center text-sm text-gray-500`,children:`This plugin has no configurable settings.`})})}),V(`div`,{className:`flex items-center justify-between gap-3 border-t border-gray-100 px-5 py-4`,children:[B(`button`,{type:`button`,className:`text-xs text-gray-600 hover:text-gray-700 transition-colors disabled:opacity-40`,disabled:c,onClick:g,children:`Reset to defaults`}),V(`div`,{className:`flex items-center gap-2`,children:[u?B(`span`,{className:`text-xs text-green-600`,children:`✓ Saved`}):null,B(`button`,{type:`button`,className:`rounded-lg bg-me-primary-500 px-4 py-2 text-sm font-medium text-white hover:bg-me-primary-600 disabled:opacity-50 transition-colors`,disabled:c,onClick:h,children:c?`Saving…`:`Save ${i}`})]})]})]})}function Fc({field:e,draft:t,setDraft:n}){let r=t[e.id],i=`plugin-setting-${e.id}`;function a(r){n({...t,[e.id]:r})}let o=B(`label`,{className:`text-sm font-medium text-gray-900`,htmlFor:i,children:e.label}),s=`rounded-lg border border-gray-200 bg-white px-3 py-2 text-sm focus:border-me-primary-500 focus:ring-2 focus:ring-me-primary-500/20 focus:outline-none`;return e.type===`boolean`?V(`div`,{className:`flex items-center justify-between rounded-lg border border-gray-100 bg-white px-4 py-3`,children:[V(`div`,{className:`flex flex-col gap-0.5`,children:[o,e.description?B(`span`,{className:`text-xs text-gray-500`,children:e.description}):null]}),B(`input`,{id:i,type:`checkbox`,checked:r===!0,onChange:e=>a(e.currentTarget.checked),className:`h-4 w-4 rounded border-gray-300 text-me-primary-500 focus:ring-me-primary-500`})]}):e.type===`textarea`?V(`div`,{className:`flex flex-col gap-2 rounded-lg border border-gray-100 bg-white px-4 py-3`,children:[o,e.description?B(`span`,{className:`text-xs text-gray-500`,children:e.description}):null,B(`textarea`,{id:i,className:`${s} min-h-24 resize-y`,value:typeof r==`string`?r:``,placeholder:e.placeholder,onChange:e=>a(e.currentTarget.value)})]}):e.type===`select`?V(`div`,{className:`flex flex-col gap-2 rounded-lg border border-gray-100 bg-white px-4 py-3`,children:[o,e.description?B(`span`,{className:`text-xs text-gray-500`,children:e.description}):null,V(`select`,{id:i,className:s,value:r===void 0?``:String(r),onChange:t=>{let n=e.options?.find(e=>String(e.value)===t.currentTarget.value);a(n?n.value:t.currentTarget.value)},children:[B(`option`,{value:``,children:`Default`}),(e.options||[]).map(e=>B(`option`,{value:String(e.value),children:e.label},String(e.value)))]})]}):V(`div`,{className:`flex flex-col gap-2 rounded-lg border border-gray-100 bg-white px-4 py-3`,children:[o,e.description?B(`span`,{className:`text-xs text-gray-500`,children:e.description}):null,B(`input`,{id:i,className:s,type:e.type===`number`?`number`:`text`,value:typeof r==`string`||typeof r==`number`?r:``,placeholder:e.placeholder,onChange:t=>{a(e.type===`number`?Number(t.currentTarget.value):t.currentTarget.value)}})]})}function Ic(){let e=K(),t=It(),n=e.creators[`iiif-image-services`]||{};return V(S.Form,{className:`flex max-w-3xl flex-col gap-4`,onChange:e=>{let n=new FormData(e.currentTarget);t({creators:{"iiif-image-services":{compact:n.get(`compact`)===`compact`?`compact`:`with-dimensions`,includeSizes:n.get(`includeSizes`)===`on`,includeTiles:n.get(`includeTiles`)===`on`}}})},onSubmit:e=>e.preventDefault(),children:[B(`h2`,{className:`text-xl font-semibold text-gray-900`,children:`IIIF Options`}),V(`fieldset`,{className:`flex flex-col gap-4`,children:[B(`legend`,{className:`mb-3 text-base font-semibold`,children:`Image services`}),V(S.InputContainer,{children:[B(S.Label,{htmlFor:`compactImageServices`,children:`Compact services`}),V(`select`,{id:`compactImageServices`,name:`compact`,className:`rounded border border-gray-300 p-2`,defaultValue:n.compact===`compact`?`compact`:`with-dimensions`,children:[B(`option`,{value:`with-dimensions`,children:`id, type, profile, width, height (default)`}),B(`option`,{value:`compact`,children:`id, type, profile (compact)`})]})]}),V(S.InputContainer,{horizontal:!0,children:[B(S.Input,{id:`includeSizes`,name:`includeSizes`,type:`checkbox`,defaultChecked:n.includeSizes===!0}),B(S.Label,{htmlFor:`includeSizes`,children:`Include sizes`})]}),V(S.InputContainer,{horizontal:!0,children:[B(S.Input,{id:`includeTiles`,name:`includeTiles`,type:`checkbox`,defaultChecked:n.includeTiles===!0}),B(S.Label,{htmlFor:`includeTiles`,children:`Include tiles`})]}),B(`p`,{className:`text-sm text-gray-500`,children:`Applies to newly added images. Thumbnails always include available sizes and tiles.`})]})]})}function Lc(){let t=ia(),n=Hi(),r=K(),i=It(),[a,o]=Ec(2e3);function s(e){e.preventDefault();let t=new FormData(e.target),n={defaultPreview:t.get(`defaultPreview`),i18n:{...r.i18n||{},advancedLanguageMode:t.get(`advancedLanguageMode`)===`on`,availableLanguages:(t.get(`availableLanguages`)||``).split(`,`).map(e=>e.trim()),defaultLanguage:t.get(`defaultLanguage`)},export:{...r.export||{},version:t.get(`isVersion2`)===`on`?2:3,baseIdentifier:t.get(`base`)||null},plugins:r.plugins,editorFeatureFlags:{...r.editorFeatureFlags||{},rememberCanvasId:t.get(`rememberCanvasId`)===`on`,rememberLeftPanelId:t.get(`rememberLeftPanelId`)===`on`,annotationPopups:t.get(`annotationPopups`)===`on`,manifestGridOptions:t.get(`manifestGridOptions`)===`on`,enableMultiImageCanvases:t.get(`enableMultiImageCanvases`)===`on`,enableMultiMediaCanvases:t.get(`enableMultiMediaCanvases`)===`on`}};i(n),o.set(),o.clear()}return V(re,{children:[B(ae,{title:`Workspace configuration`}),a?B(`div`,{className:`bg-me-primary-500 text-white p-3 text-sm`,children:`Changes saved`}):null,V(ie,{className:`p-4`,children:[B(Ic,{}),V(S.Form,{onSubmit:s,className:`flex flex-col gap-3`,children:[V(S.InputContainer,{children:[B(S.Label,{htmlFor:`defaultLanguage`,children:`Default Language`}),B(S.Input,{type:`text`,name:`defaultLanguage`,id:`defaultLanguage`,defaultValue:r.i18n?.defaultLanguage||``})]}),V(S.InputContainer,{children:[B(S.Label,{htmlFor:`availableLanguages`,children:`Available Languages`}),B(S.Input,{type:`text`,name:`availableLanguages`,id:`availableLanguages`,defaultValue:(r.i18n?.availableLanguages||[]).join(`, `)})]}),V(S.InputContainer,{horizontal:!0,className:`my-3`,children:[B(S.Input,{type:`checkbox`,name:`advancedLanguageMode`,id:`advancedLanguageMode`,defaultChecked:r.i18n?.advancedLanguageMode||!1}),B(S.Label,{htmlFor:`advancedLanguageMode`,children:`Advanced Language Mode`})]}),V(S.InputContainer,{horizontal:!0,className:`my-3`,children:[B(S.Input,{type:`checkbox`,name:`textGranularityEnabled`,id:`textGranularityEnabled`,defaultChecked:r.i18n?.textGranularityEnabled||!1}),B(S.Label,{htmlFor:`textGranularityEnabled`,children:`Enable text granularity`})]}),V(S.InputContainer,{horizontal:!0,className:`my-3`,children:[B(S.Input,{type:`checkbox`,name:`rememberCanvasId`,id:`rememberCanvasId`,defaultChecked:r.editorFeatureFlags?.rememberCanvasId||!1}),B(S.Label,{htmlFor:`rememberCanvasId`,children:`Remember Canvas ID`})]}),V(S.InputContainer,{horizontal:!0,className:`my-3`,children:[B(S.Input,{type:`checkbox`,name:`rememberLeftPanelId`,id:`rememberLeftPanelId`,defaultChecked:r.editorFeatureFlags?.rememberLeftPanelId||!1}),B(S.Label,{htmlFor:`rememberLeftPanelId`,children:`Remember Left panel`})]}),V(S.InputContainer,{horizontal:!0,className:`my-3`,children:[B(S.Input,{type:`checkbox`,name:`manifestGridOptions`,id:`manifestGridOptions`,defaultChecked:r.editorFeatureFlags?.manifestGridOptions||!1}),B(S.Label,{htmlFor:`manifestGridOptions`,children:`Manifest Grid Options`})]}),V(S.InputContainer,{horizontal:!0,className:`my-3`,children:[B(S.Input,{type:`checkbox`,name:`isVersion2`,id:`isVersion2`,defaultChecked:r.export?.version===2}),V(S.Label,{htmlFor:`isVersion2`,children:[`Export Presentation 2 `,n.type,`s`]})]}),V(S.InputContainer,{children:[B(S.Label,{htmlFor:`defaultPreview`,children:`Default preview`}),B(`div`,{children:t.configs.map((e,t)=>e.type===`iiif-preview-service`?null:V(S.InputContainer,{horizontal:!0,children:[B(S.Input,{type:`radio`,id:e.id,name:`defaultPreview`,value:e.id,defaultChecked:r.defaultPreview?r.defaultPreview===e.id:t===0}),B(`label`,{htmlFor:e.id,children:e.label})]},e.id))})]}),n.type===`Manifest`?B(`a`,{className:`text-sm text-me-primary-500 hover:underline hover:text-me-primary-600`,href:window.location.pathname.includes(`/exhibition`)?window.location.pathname.replace(`/exhibition`,``)||`/`:`${window.location.pathname}/exhibition`,children:window.location.pathname.includes(`/exhibition`)?`Return to Manifest Editor`:`Go to Exhibition Editor`}):null,B(Nc,{}),B(`div`,{className:`mt-5`,children:B(e,{type:`submit`,children:`Save changes`})})]})]})]})}function Rc(e){let t=new Map;for(let n of e){if(!n.configuration?.fields.length)continue;let e=rt(n);(!t.has(e)||n.id===e)&&t.set(e,n)}return Array.from(t.values())}function zc(){let e=Y(),t=K(),n=It(),r=I(()=>Rc(e.layout.creators||[]),[e.layout.creators]);function i(e,t){let r=rt(e),i=new FormData(t),a={};for(let t of e.configuration?.fields||[])t.type===`checkbox`&&(a[t.id]=i.get(t.id)===`on`);n({creators:{[r]:a}})}return r.length?B(`div`,{className:`flex max-w-3xl flex-col gap-6`,children:r.map(e=>V(S.Form,{className:`flex flex-col gap-3 border-b border-gray-100 pb-5 last:border-b-0`,onChange:t=>i(e,t.currentTarget),children:[V(`div`,{className:`flex flex-col gap-1`,children:[B(`h3`,{className:`text-base font-semibold text-gray-900`,children:e.label}),e.summary?B(`p`,{className:`text-sm text-gray-500`,children:e.summary}):null]}),e.configuration?.fields.map(n=>{let r=rt(e),i=t.creators?.[r]?.[n.id],a=`${r}-${n.id}`;return n.type===`checkbox`?V(S.InputContainer,{horizontal:!0,className:`my-1 items-start`,children:[B(S.Input,{type:`checkbox`,name:n.id,id:a,defaultChecked:typeof i==`boolean`?i:n.defaultValue||!1}),V(`div`,{className:`flex flex-col gap-1`,children:[B(S.Label,{htmlFor:a,children:n.label}),n.summary?B(`p`,{className:`text-sm text-gray-500`,children:n.summary}):null]})]},n.id):null})]},rt(e)))}):B(b,{children:`No creator settings available`})}function Bc(){return Oe((e,t)=>({specificMenus:{},resourceMenus:{},hookMenuItem(t){let n=_r(),r=t.resource?.id||``,i=t.resource?.type;return i?r?(e(e=>({specificMenus:{...e.specificMenus,[r]:{...e.specificMenus[r]||{},menus:{...e.specificMenus[r]?.menus||{},[n]:{sectionTitle:t.sectionTitle,items:t.items}}}}})),()=>{e(e=>({specificMenus:{...e.specificMenus,[r]:{...e.specificMenus[r]||{},menus:{...e.specificMenus[r]?.menus||{},[n]:void 0}}}}))}):(e(e=>({resourceMenus:{...e.resourceMenus,[i]:{...e.resourceMenus[i]||{},menus:{...e.resourceMenus[i]?.menus||{},[n]:{sectionTitle:t.sectionTitle,items:t.items}}}}})),()=>{e(e=>({resourceMenus:{...e.resourceMenus,[i]:{...e.resourceMenus[i]||{},menus:{...e.resourceMenus[i]?.menus||{},[n]:void 0}}}}))}):()=>{}}}))}const Vc=j(null);function Hc({children:e}){let t=I(()=>Bc(),[]);return B(Vc.Provider,{value:t,children:e})}function Uc(){let e=N(Vc);if(!e)throw Error(`useContextMenuStore must be used within a ContextMenuProvider`);return e}function Wc(e){let t=Uc(),n=ke(t,e=>e.resourceMenus),r=ke(t,e=>e.specificMenus);return I(()=>{let t=r[e.id||``]?.menus||{},i=n[e.type]?.menus||{},a=Object.values(t).flat(),o=[...Object.values(i).flat(),...a].filter(e=>e!==void 0),s=[],c=[];for(let e of o){let t=[];for(let n of e.items||[])n.id&&s.includes(n.id)||(s.push(n.id),t.push(n));t.length&&c.push({...e,items:t})}return Gc(c)},[r,n,e.id,e.type])}function Gc(e){let t={},n=[];e.forEach(e=>{if(!e)return;let r=e.sectionTitle;if(!r){n.push(...e.items||[]);return}t[r]||(t[r]=[]),t[r].push(...e.items)});let r=Object.entries(t).map(([e,t])=>({sectionTitle:e,items:t}));return n.length&&r.push({items:n}),r}function Kc(e,t=[]){let n=Uc(),r=ke(n,e=>e.hookMenuItem);P(()=>r(e),[r,e.resource?.id,e.resource?.type,...t])}var qc={CenterPanelContainer:`_CenterPanelContainer_1sbe6_1`,CenterPanelHeader:`_CenterPanelHeader_1sbe6_16`,CenterPanelClose:`_CenterPanelClose_1sbe6_23`,CenterPanelTitle:`_CenterPanelTitle_1sbe6_28`};function Jc(e){return V(`div`,{className:qc.CenterPanelContainer,children:[e.title||e.close?V(`div`,{className:qc.CenterPanelHeader,children:[e.title?B(`h2`,{className:qc.CenterPanelTitle,children:e.title}):null,e.close?B(oa,{className:qc.CenterPanelClose,onClick:e.close,children:B(Pi,{})}):null]}):null,e.children]})}const Yc=U.div`
|
|
462
|
+
`;function sl({panel:e,state:t,actions:n,isLeft:r,pinActions:i=n,transition:a,close:o,available:s=[],style:c,noHeader:l,isModal:u}){let{resolveMessage:d}=H(),f=U(`shell`),p=P(Je)||null,[m,h]=R(!1),g=aa(),_=Da(),{tabs:v,pinnable:y,hideHeader:b}=e?.options||{},x=I(()=>(s||[]).filter(e=>!e.requiresState),[s]),{itemProps:S,isOpen:C,setIsOpen:ee}=so(x.length),[w,T]=R(``),E=L(void 0);F(()=>h(!1),[g.state.canvasId,e?.id]),F(()=>T(``),[e]),F(()=>(E.current=T,()=>{E.current=void 0}),[]);let D=N(e=>{E.current&&E.current(e)},[]),O=N(r=>{let i=e?t.stack.length?n.popStack:e.backAction?()=>e&&e.backAction&&e.backAction(t,{..._,current:n},g):null:null;r&&(!i||r.metaKey)&&x.length?(r.preventDefault(),ee(!0)):i?.()},[n,g,_,e,ee,t,x.length]),k=r=>{n.change({id:r.id,state:r.defaultState,stacked:!!(t.stack.length||e?.backAction)})};if(!e||!t.current)return null;let A=e.backAction||t.stack.length?B(rl,{"aria-label":f(`actions.back`),onClick:O,children:B(qc,{"aria-hidden":`true`})}):null,te=B(rl,{"aria-label":f(`actions.closePanel`),onClick:o||n.close,children:B(ro,{"aria-hidden":`true`})});return B($c.Provider,{value:D,children:V(tl,{"data-modal":u,"data-state":a,"data-flipped":r,style:c,"data-header":!l,children:[l?null:V(nl,{"data-tabs":!!v,"data-error":m,children:[V(Hc,{style:{display:`flex`,height:`100%`},children:[e.renderBackAction?e.renderBackAction({backAction:O,fallback:A}):A,x.length?V(Wc,{$open:C,role:`menu`,style:{left:`0.5em`},children:[B(Gc,{children:f(`panels.all`)}),B(Kc,{}),x.map((t,n)=>B(Uc,{...S[n],onClick:()=>k(t),$active:e.id===t.id,children:d(t?.labelMessage,t.label)},n))]}):null]}),w?B(al,{as:r?`h1`:`h2`,children:w}):b?B(il,{}):B(al,{as:r?`h1`:`h2`,children:d(e?.labelMessage,e.label)}),y?t.pinned?B(rl,{"aria-label":f(`panels.unpin`),onClick:i.unpin,children:B(Jc,{"aria-hidden":`true`,fill:`orange`})}):B(rl,{"aria-label":f(`panels.pin`),onClick:()=>i.pin({id:e.id,state:t.state}),children:B(Jc,{"aria-hidden":`true`,fill:`#ddd`})}):null,e.renderCloseAction?e.renderCloseAction({closeAction:o||n.close,fallback:te}):te]}),B(ol,{className:`OverrideScrollbar`,children:B(Mt,{onError:()=>h(!0),FallbackComponent:Qc,resetKeys:[g.state.canvasId,e?.id],onReset:()=>h(!1),children:Zc(e.render(t.state||e.defaultState||{},{..._,current:n,vault:p,transition:a,isModal:u},g))})})]})})}function cl(e,t,n,r,i){let a=W(),o=X(),{create:s,edit:c}=wa(),l=I(()=>jt({type:n,parent:e,index:0,property:t,filter:i?.filter},o.layout.creators||[],{vault:a}),[e,t,o.layout.creators,n,a,i?.filter]),u=e&&l.length!==0,d=N((a,o)=>{if(e)return s({type:n,parent:it(e),property:t,index:a,target:r,initialData:o,...i||{}})},[s,e,t,n,i,r]),f=N((a,o,c)=>{if(e)return s({type:n,filter:a,parent:it(e),property:t,index:o,target:r,initialData:c,...i||{}})},[s,e,t,n,i,r]);return[u,{create:d,edit:N((n,r)=>{c(n,e?{parent:it(e),property:t,index:r}:void 0)},[c,e,t]),createFiltered:f,creator:N((a,o)=>{if(e)return s({type:n,initialCreator:a,parent:it(e),property:t,target:r,initialData:o,...i||{}})},[n,t,e,r,s,i]),buttonProps:I(()=>({"data-action-id":qr(n,t,e)}),[n,t,e])}]}function ll(){let e=W(),t=ka(),n=X(),r=J();return I(()=>new kt(e,n.layout.creators||[],t,r.creators),[n.layout.creators,r.creators,t,e])}async function ul(e){let t=await e.create(),n=Array.isArray(t)?t[0]:t;return n?(e.onCreate?.(),e.close?.(),e.edit?.(n),!0):!1}const dl=M({});function fl(e){return P(dl)[e]||{}}function pl(e){let t=P(dl),n=I(()=>({...t,[e.id]:e.data}),[t,e.id,e.data]);return B(dl.Provider,{value:n,children:e.children})}function ml(){return V(`svg`,{xmlns:`http://www.w3.org/2000/svg`,height:`24px`,viewBox:`0 0 24 24`,width:`24px`,fill:`#000000`,children:[B(`path`,{d:`M0 0h24v24H0z`,fill:`none`}),B(`path`,{d:`M3.9 12c0-1.71 1.39-3.1 3.1-3.1h4V7H7c-2.76 0-5 2.24-5 5s2.24 5 5 5h4v-1.9H7c-1.71 0-3.1-1.39-3.1-3.1zM8 13h8v-2H8v2zm9-6h-4v1.9h4c1.71 0 3.1 1.39 3.1 3.1s-1.39 3.1-3.1 3.1h-4V17h4c2.76 0 5-2.24 5-5s-2.24-5-5-5z`})]})}const hl=[{icon:B(E,{}),text:`https://example.org/iiif/manifest.json`},{icon:B(t,{}),text:`https://example.org/photo.jpg`},{icon:B(ve,{}),text:`https://example.org/video.mp4`},{icon:B(ye,{}),text:`https://www.youtube.com/watch?v=…`}];function gl(){let[e,t]=R(!0);return F(()=>{let e=window.matchMedia(`(prefers-reduced-motion: reduce)`);t(e.matches);let n=e=>t(e.matches);return e.addEventListener(`change`,n),()=>e.removeEventListener(`change`,n)},[]),e}function _l({value:t,onChange:n,inputRef:r,isChecking:i,rotateExamples:a=!0,onBrowse:o}){let s=U(`shell`),c=gl(),[l,u]=R(0),d=a&&!c&&!t&&!i;F(()=>{if(!d)return;let e=setInterval(()=>u(e=>(e+1)%hl.length),2e3);return()=>clearInterval(e)},[d]);let f=hl[l];return V(`div`,{children:[B(`style`,{children:`
|
|
463
|
+
@keyframes creator-resource-hint-in {
|
|
464
|
+
from { opacity: 0; transform: translateY(6px); }
|
|
465
|
+
to { opacity: 1; transform: translateY(0); }
|
|
466
|
+
}
|
|
467
|
+
.creator-resource-hint { animation: creator-resource-hint-in 180ms ease-out; }
|
|
468
|
+
@media (prefers-reduced-motion: reduce) { .creator-resource-hint { animation: none; } }
|
|
469
|
+
`}),B(`label`,{className:`block text-sm font-medium text-gray-700`,htmlFor:`creator-resource-link`,children:s(`creator.paste`)}),V(`div`,{className:`mt-1 flex min-h-12 w-full items-center rounded-md border border-gray-300 bg-white p-1 focus-within:border-me-primary-500 focus-within:ring-2 focus-within:ring-me-primary-500`,children:[V(`div`,{className:`relative min-w-0 flex-1`,children:[B(`input`,{ref:r,id:`creator-resource-link`,type:`url`,autoComplete:`off`,spellCheck:!1,value:t,onChange:e=>n(e.currentTarget.value),placeholder:d?``:a?`https://example.org/manifest.json`:`https://example.org/resource`,className:`block h-10 w-full min-w-0 border-none bg-transparent pl-9 pr-2 text-sm outline-none focus:outline-none`}),B(`span`,{className:`pointer-events-none absolute inset-y-0 left-3 flex items-center text-gray-400 [&>svg]:h-4 [&>svg]:w-4`,"aria-hidden":`true`,children:d?f.icon:B(ml,{})}),d?B(`span`,{"aria-hidden":`true`,className:`creator-resource-hint pointer-events-none absolute inset-y-0 left-9 right-3 flex items-center overflow-hidden`,children:B(`span`,{className:`truncate text-sm text-gray-400`,children:f.text})},l):null]}),o?B(`button`,{type:`button`,"aria-label":s(`creator.browse`),title:s(`creator.browse`),disabled:i,onClick:o,className:`mr-1 flex h-9 w-9 shrink-0 items-center justify-center rounded bg-transparent text-gray-500 hover:bg-gray-100 hover:text-me-primary-500 focus-visible:outline focus-visible:outline-2 focus-visible:outline-me-primary-500 disabled:opacity-50`,children:B(T,{className:`h-5 w-5`})}):null,B(e,{primary:!0,type:`submit`,isDisabled:!t.trim()||i,className:`h-9 shrink-0 justify-center px-3`,children:s(i?`creator.checkingShort`:`creator.useLink`)})]})]})}const vl=Ae(function(t){let{resolveMessage:n}=H(),r=U(`shell`),i=W(),{edit:a,modal:o,open:s}=wa(),[c,l]=R(!1),[u,d]=R(null),f=ll(),p=J(),m=L(!1),h=t.resource.initialData?.selector;Bc(h);let g=fl(t.creator.id),_={targetType:t.resource.type,parent:t.resource.parent?{property:t.resource.property,atIndex:t.resource.index,resource:t.resource.parent}:void 0,target:t.resource.target,placeholderPosition:t.resource.placeholderPosition,initialData:{...g,...t.resource.initialData||{},...t.initialData||{}}},v=async e=>{if(!(c||m.current)){d(null),l(!0),m.current=!0;try{await ul({create:()=>f.create(t.creator.id,e,_),onCreate:t.onCreate,close:t.skipEditingOnCreate?void 0:()=>{o.popStack(),o.close()},edit:t.skipEditingOnCreate||t.resource.initialData?.skipEditingOnCreate?void 0:e=>{e.type===`Canvas`&&s({id:`current-canvas`}),a(e,{parent:it(t.resource.parent),property:t.resource.property,index:t.resource.index},{selectedTab:t.creator.initialEditor})}})}catch(n){d(t.creator.validationErrorMessage?.(n,{payload:e,vault:i})||n?.message||{message:{namespace:`shell`,key:`creator.unknownError`}})}finally{l(!1),m.current=!1}}},b=async()=>!0;F(()=>{t.resource.initialData?.showEmptyForm||!t.creator.render&&!c&&v({})},[t.creator]);let C=B(`div`,{className:`flex flex-col items-center py-8`,children:V(`div`,{className:`flex gap-2 items-center`,children:[B(ue,{}),` `,B(`span`,{children:r(`creator.loading`)})]})});return t.creator.render?V(z,{children:[c?C:null,V(`div`,{hidden:c,children:[n(t.creator.helpMessage||t.creator.summaryMessage,t.creator.summary)&&!t.compact&&!t.creator.hideSummary?B(`div`,{className:`flex justify-end px-4`,children:V(ge,{children:[B(_e,{"aria-label":r(`creator.help`,{name:n(t.creator.labelMessage,t.creator.label)}),className:`rounded p-1 text-gray-500 focus-visible:outline focus-visible:outline-2`,children:B(k,{className:`h-5 w-5`})}),B(y,{className:`max-w-xs`,root:document.getElementById(`headlessui-portal-root`)||void 0,children:n(t.creator.helpMessage||t.creator.summaryMessage,t.creator.summary)})]})}):null,u?B(S,{children:typeof u==`string`?u:n(u.message)}):null,B(Ee,{fallback:C,children:t.creator.render({vault:i,i18n:{resolveMessage:n},runCreate:v,validate:b,options:_,config:p.creators?.[At(t.creator)]||{}})})]})]}):c?C:t.compact?V(z,{children:[u?B(S,{children:typeof u==`string`?u:n(u.message)}):null,B(`div`,{className:`flex justify-end`,children:B(e,{primary:!0,onPress:()=>v({}),children:n(t.creator?.actionButtonMessage,t.creator.actionButton)||r(`creator.create`)})})]}):V(z,{children:[u?B(S,{children:typeof u==`string`?u:n(u.message)}):B(x,{children:r(`creator.noOptions`)}),B(e,{primary:!0,onPress:()=>v({}),children:n(t.creator?.actionButtonMessage,t.creator.actionButton)||r(`creator.create`)})]})});function yl(e){let{resolveMessage:t}=H(),n=U(`shell`),r=X(),i=J(),a=W(),[o,s]=R(e.resource.initialCreator||``),[c,l]=R(),[u,d]=R(``),[f,p]=R(!1),[m,h]=R(``),[g,_]=R(null),y=L(null),b=L(0),S=L(null),C=je(),w=e.resource.type===`Canvas`&&e.resource.parent?.type===`Manifest`&&e.resource.property===`items`,[T,E]=R(!1),O=el(),k=I(()=>jt(e.resource,r.layout.creators||[],{vault:a}),[e.resource,r.layout.creators,a]),A=k.some(e=>e.supportsResource),te=k.find(e=>e.id===i.notebook?.browserCreatorId)??k.find(e=>At(e)===`@manifest-editor/iiif-browser-creator`),re=k.filter(e=>!e.supportsResource);F(()=>()=>{b.current++,S.current?.abort()},[]);let ie=()=>{b.current++,S.current?.abort(),S.current=null,p(!1)};F(()=>{k.length===1&&!o&&!A&&s(k[0].id)},[A,o,k]),F(()=>{A&&!o&&y.current?.focus()},[A,o]);let ae=k.find(e=>e.id===o);if(F(()=>{O?.(t(ae?.labelMessage,ae?.label)||n(`creator.add`))}),k.length===0)return B(x,{children:n(`creator.unsupported`)});let oe=(e,t)=>{ie(),l(t||Cl(u)),s(e.id)},se=te?e=>oe(te,{url:e??(u.trim()||void 0)}):void 0,j=async(t,r)=>{t?.preventDefault();let i=(r??u).trim();if(r&&d(r),!i||f)return;let o=++b.current,s=new AbortController;S.current=s,p(!0),h(``),_(null);let c=!1,l=!1,m=wl(s.signal,()=>{c=!0}),g,v=new Promise(e=>{g=setTimeout(()=>{l=!0,s.abort(),e(null)},1e4)}),y=await Promise.all(k.map(async t=>t.supportsResource?Promise.race([(async()=>{try{let n=await t.supportsResource(i,m,{vault:a,resource:e.resource});return n?{creator:t,initialData:Sl(i,n).initialData}:null}catch{return{creator:t,error:n(`creator.probeFailed`)}}})(),v]):null));if(clearTimeout(g),o!==b.current)return;S.current=null,p(!1);let x=y.filter(bl);if(x.length===1){oe(x[0].creator,x[0].initialData);return}if(x.length>1){E(!1),_(x);return}E(!0),h(l?`creator.timeout`:c||y.some(xl)?`creator.requestFailed`:`creator.unrecognised`)},ce=B(ne,{children:B(D,{root:document.getElementById(`headlessui-portal-root`)||void 0,label:n(`creator.back`),className:`group`,placement:`right`,onPress:()=>{ie(),s(``),l(void 0)},children:B(ee,{className:`text-2xl opacity-50 group-hover:opacity-70`})})});if(ae)return ae.hiddenModal?V(z,{children:[ce,B(vl,{creator:ae,resource:e.resource,initialData:c})]}):V(`div`,{children:[ce,B(`div`,{className:`p-2 py-6`,children:B(vl,{creator:ae,resource:e.resource,initialData:c})})]});let le=!A||T||!w&&!g,ue=le?k:g?.map(e=>e.creator)||[],de=new Map(g?.map(e=>[e.creator.id,e.initialData])),fe=(e,n,r=!1)=>B(v,{label:n,compact:r,items:e.map(e=>({id:e.id,title:t(e?.labelMessage,e.label),description:t(e?.summaryMessage,e.summary)||``,icon:e.icon,onClick:()=>oe(e,de.get(e.id))}))});return V(z,{children:[A?V(`form`,{className:`p-4`,onSubmit:e=>void j(e),"aria-busy":f,children:[B(_l,{inputRef:y,rotateExamples:w,onBrowse:se?()=>se():void 0,value:u,isChecking:f,onChange:e=>{ie(),d(e),h(``),_(null)}}),V(`div`,{role:`status`,"aria-live":`polite`,className:`text-sm text-gray-600`,children:[f?B(`span`,{className:`sr-only`,children:n(`creator.checking`)}):null,m?B(`p`,{className:`mt-3`,children:n(m)}):null,g&&!le?B(`p`,{className:`mt-3`,children:n(`creator.chooseLink`)}):null]}),u?null:B($a,{isDisabled:f,onSelect:e=>void j(void 0,e),onOpenNotebook:se?()=>se(`iiif://notes`):void 0})]}):null,B(`div`,{id:C,children:ue.length?fe(ue,n(g&&!le?`creator.matches`:`creator.selectType`)):null}),w&&!le&&re.length?fe(re,n(`creator.noLink`),!0):null,A&&(w||g)?B(`div`,{className:`px-4 pb-4`,children:B(To,{className:`rounded px-2 py-1 text-sm text-me-gray-700 hover:bg-gray-100 focus-visible:outline focus-visible:outline-2`,"aria-expanded":T,"aria-controls":C,onClick:()=>{ie(),E(!T)},children:n(T?`creator.fewer`:`creator.chooseType`)})}):null]})}function bl(e){return!!e&&!(`error`in e)}function xl(e){return!!e&&`error`in e}function Sl(e,t){return typeof t==`object`?t:{initialData:Cl(e)}}function Cl(e){let t=e.trim();return t?{url:t,youtubeUrl:t}:void 0}function wl(e,t){let n=async(n,r=`GET`)=>{try{let t=await fetch(n,{method:r,signal:e});if(!t.ok)throw Error(`Could not load link`);return t}catch(e){throw t(),e}},r=new Map,i=new Map,a=new Map,o=e=>(r.has(e)||r.set(e,n(e).then(e=>e.text())),r.get(e)),s=e=>(a.has(e)||a.set(e,n(e,`HEAD`)),a.get(e));return{text:o,head:s,json(e){return i.has(e)||i.set(e,o(e).then(e=>JSON.parse(e))),i.get(e)},async contentType(e){return(await s(e)).headers.get(`content-type`)||``}}}const Tl={id:`@manifest-editor/creator`,label:`Add content`,labelMessage:{namespace:`shell`,key:`creator.add`},options:{hideHeader:!0,tabs:!1},render(e){return B(yl,{resource:e})}},El={color:{main:`#B84C74`,mainHover:`#4a89ff`,logoPink:`#E94581`,white:`white`,grey:`grey`,black:`black`,lightgrey:`#F8F9FA`,mediumgrey:`#dddddd`,danger:`#a90e21`,warning:`#e38627`,lightdanger:`#ffeaea`,lightsuccess:`#c5e8c5`,success:`#6ccd55`,greyOverlay:`rgba(0, 0, 0, 0.2)`,highlight:`#faeed7`},iiifColor:{manifest:`rgba(0, 0, 0, 0.2)`,canvas:`rgba(255, 222, 219, 0.8)`,service:`rgba(13, 110, 253, 0.8)`,annotation:`rgba(247, 226, 173, 0.8)`,contentResource:`rgba(207, 247, 255, 0.8)`,ranges:`rgba(144, 213, 157, 0.8)`},padding:{xs:`0.25rem`,small:`0.5rem`,medium:`1rem`,large:`2rem`},device:{mobile:`375px`,tablet:`768px`,laptop:`992px`,desktop:`1200px`},shadows:{standard:`rgba(0, 0, 0, 0.1) 0px 1px 3px 0px, rgba(0, 0, 0, 0.05) 0px 5px 15px 0px`,bottom:`rgba(0, 0, 0, 0.1) 0px 4px 2px -2px`}};function Dl(e){let{resolveMessage:t}=H(),n=U(`shell`),r=W(),i=X(),a=I(()=>jt(e.resource,i.layout.creators||[],{vault:r}),[e.resource,i.layout.creators,r]),[o,s]=R(null),c=a.find(e=>e.id===o)||a[0];return a.length===0?B(`div`,{className:`p-4 text-sm text-gray-500`,children:n(`creator.noCreators`)}):V(me,{className:`flex w-full flex-col`,selectedKey:c?.id,onSelectionChange:s,children:[a.length>1?B(fe,{"aria-label":n(`creator.annotationType`),className:`mx-3 mt-3 flex gap-0.5 rounded-md bg-gray-100 p-0.5 text-sm`,items:a,children:e=>V(de,{id:e.id,className:({isSelected:e,isFocusVisible:t})=>[`flex min-w-0 flex-auto items-center justify-center gap-1.5 rounded border-b-0 px-2 py-1 font-medium`,e?`bg-white text-gray-900 shadow-sm`:`text-gray-600 hover:text-gray-900`,t?`bg-white ring-2 ring-me-primary-500`:``].join(` `),children:[B(`span`,{"aria-hidden":!0,className:`flex flex-none text-base [&>svg]:h-4 [&>svg]:w-4`,children:e.icon}),B(`span`,{className:`truncate`,children:t(e?.labelMessage,e.label)})]})}):null,t(c?.summaryMessage,c?.summary)?B(`p`,{className:`mx-4 mt-2 text-xs text-gray-500`,children:t(c?.summaryMessage,c?.summary)}):null,a.map(t=>B(pe,{id:t.id,className:`p-3 pt-2 outline-none`,children:B(ot,{theme:El,children:B(vl,{creator:t,resource:e.resource,onCreate:e.onCreate,skipEditingOnCreate:!0,compact:!0})})},t.id))]})}function Ol({fallback:e,backAction:t}){let n=U(`shell`),r=Zo(),{back:i}=Yo();return r.length?B(rl,{"aria-label":n(`actions.back`),onClick:i,children:B(qc,{"aria-hidden":`true`})}):e}function kl({closeAction:e,fallback:t}){let n=U(`shell`),r=Zo();return Xo()||r.length?B(rl,{"aria-label":n(`actions.closePanel`),onClick:()=>{e()},children:B(ro,{"aria-hidden":`true`})}):t}function Al(e,t,n,r){let i=t.filter(t=>t.resourceType===e.resource.source.type);if(i.length===0)return null;for(let t of i){let i=[],a={},o=e.property===`partOf`,s=(t.editors||[]).filter(t=>{if(o&&t.id!==`@manifest-editor/part-of-reference`||r.hideTabs&&r.hideTabs.includes(t.id)||r.onlyTabs&&!r.onlyTabs.includes(t.id))return!1;if(t.supports.sortKey){if(i.includes(t.supports.sortKey))return!1;t.supports.sortFallback&&(a[t.supports.sortKey]=t)}return n.edit&&!t.supports.edit||t.supports.custom&&t.supports.custom(e,n.vault)===!1?!1:(t.supports.sortKey&&i.push(t.supports.sortKey),!0)}),c=Object.keys(a);for(let e of c)!i.includes(e)&&a[e]&&!s.includes(a[e])&&s.push(a[e]);if(s.length)return{...t,editors:s}}return null}function jl({currentTab:e=void 0}){let{resolveMessage:t,locale:n,profile:r}=H(),i=Xo(),a=P(Ye),o=X(),s=_a(),c=W(),{change:l}=wa(),u=el(),{editorConfig:d}=J(),f=i?.resource.source?.id,p=i?.resource.source?.type,m=f!==s.id;f&&m&&s.type===`Collection`&&p===`Collection`&&(p=`EmbeddedCollection`);let h=(p?d[p]:d.All)||{},g=I(()=>{let e={...a},t=i?.resource.source.id,n=i?.resource.source.type,r={Collection:`collection`,Manifest:`manifest`,Range:`range`,Canvas:`canvas`,Annotation:`annotation`,AnnotationPage:`annotationPage`};return n&&r[n]&&(e[r[n]]=t),e},[i,a]);function _(e){return i?B(Ye.Provider,{value:g,children:e}):e}let v=I(()=>{if(!i)return null;let e=o.layout.editors||[],t=(o.layout.resources||[]).map(t=>typeof t==`string`?{id:`@default/`+t,label:t,labelMessage:{namespace:`editor-api`,key:`resources.${t.charAt(0).toLowerCase()}${t.slice(1)}`,defaultValue:t},resourceType:t,auto:!0,editors:e.filter(e=>e.supports.resourceTypes.includes(t))}:t);return Al(i,t,{edit:!0,vault:c},h)},[i,o]);F(()=>{u(t(v?.labelMessage,v?.label)||``)},[v,t,n,r,u]),F(()=>{let t=v?.editors.map(e=>e.id)||[];t.find(t=>t===e)||l(`@manifest-editor/editor`,{currentTab:t[0]})},[v?.editors,e,l]);let y=I(()=>(v?.editors||[]).map(e=>({id:e.id,label:t(e?.labelMessage,e.label),renderComponent:()=>e.component(h)})),[v?.editors,h,t,n,r]);if(!i||!v)return null;if(h.singleTab){let e=(v?.editors||[]).find(e=>e.id===h.singleTab);if(e)return _(B(`div`,{className:`w-full`,children:e.component(h)},i.resource.source?.id))}return _(B(le,{isNested:m,rootResource:s,menuId:i.resource.source.id,menu:y,selectedKey:e,onSelectionChange:e=>{l(`@manifest-editor/editor`,{currentTab:e})}},i.resource.source?.id))}const Ml={id:`@manifest-editor/editor`,label:`Editor`,labelMessage:{namespace:`shell`,key:`panels.editor`},options:{hideHeader:!0,tabs:!0,minWidth:400},renderBackAction:({backAction:e,fallback:t})=>B(Ol,{backAction:e,fallback:t}),renderCloseAction:({closeAction:e,fallback:t})=>B(kl,{closeAction:e,fallback:t}),render({currentTab:e}){return B(jl,{currentTab:e})}};function Nl(e){let[t,n]=R(!1),r=L(null),i=L(0);function a(t){i.current--,!(t&&i.current!==0)&&(r.current&&(clearTimeout(r.current),r.current=0),r.current=setTimeout(()=>{n(!1)},e))}function o(){i.current++,r.current&&clearTimeout(r.current),n(!0)}return I(()=>[t,{set:o,clear:a}],[t])}function Pl(e){return e?typeof e==`string`?{src:e,alt:``,altMessage:void 0}:e:null}function Fl(e){return e?typeof e==`string`?e:e.name:null}function Il(e){let t=e.extension,n=t.leftPanels?.[0]||t.centerPanels?.[0]||t.rightPanels?.[0]||t.modalPanels?.[0];return n?{id:n.id,label:n.label||`Open plugin`,labelMessage:n.labelMessage,modal:t.modalPanels?.some(e=>e.id===n.id)||!1}:null}function Ll(e,t){return e instanceof Error?e.message:t}function Rl(e){return V(`svg`,{xmlns:`http://www.w3.org/2000/svg`,width:`1em`,height:`1em`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,...e,children:[B(`path`,{d:`M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z`}),B(`circle`,{cx:`12`,cy:`12`,r:`3`})]})}function zl(e){return V(`svg`,{xmlns:`http://www.w3.org/2000/svg`,width:`1em`,height:`1em`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,...e,children:[B(`path`,{d:`M7 7h10v10`}),B(`path`,{d:`M7 17 17 7`})]})}function Bl(){let{resolveMessage:e,locale:t,profile:n}=H(),r=U(`shell`),i=X(),{appId:a}=ia(),o=J(),s=cn(),c=Hi(),l=Wi(),u=wa(),{saveGlobalPluginConfig:d}=P(Li),[f,p]=R(!1),[m,h]=R(``),[g,v]=R(null),[y,b]=R(null),[x,S]=R(null),C=I(()=>new Set(Si(c,i,a).map(e=>e.metadata.id)),[c,i,a]),ee=I(()=>{let t=m.trim().toLowerCase();return c.plugins.filter(n=>{let r=vi(n,i,a);return!f&&!r?!1:!t||[e(n.metadata?.labelMessage,n.metadata.label),n.metadata.id,e(n.metadata?.descriptionMessage,n.metadata.description),Fl(n.metadata.author),...n.metadata.tags||[]].filter(Boolean).join(` `).toLowerCase().includes(t)})},[i,a,c.plugins,m,f,t,n,e]),w=g&&c.plugins.find(e=>e.metadata.id===g)||null;if(!c.plugins.length)return null;function T(e){l.setAppConfig(a,e),s({plugins:{...o.plugins||{},apps:{...o.plugins?.apps||{},[a]:e}}})}async function E(e){if(!d){S(r(`plugins.globalUnavailable`));return}let t=c.globalApps[a]||{},n={apps:{...c.globalApps,[a]:e}};l.setGlobalAppConfig(a,e);try{await d(n)}catch(e){l.setGlobalAppConfig(a,t),S(Ll(e,r(`plugins.saveFailed`)))}}async function D(t,n,o){S(null),b(`${o}:${t.metadata.id}`);let s=o===`global`?c.globalApps[a]||{}:c.apps[a]||{},l=n?ki(s,c,t,i,a):{config:ci(s,t.metadata.id),blocked:[]};if(l.blocked.length){b(null),S(r(`plugins.cannotEnable`,{name:e(t.metadata.labelMessage,t.metadata.label),dependencies:l.blocked.join(`, `)}));return}o===`global`?await E(l.config):T(l.config),b(null)}function O(e){let t=Il(e);if(t){if(t.modal){u.modal.open({id:t.id});return}u.open(t.id)}}return V(`section`,{className:`flex flex-col gap-3 border-t border-gray-200 pt-4 mt-4`,children:[V(`div`,{className:`flex items-center gap-2`,children:[B(`div`,{className:`min-w-0 flex-1`,children:B(`h3`,{className:`font-semibold text-sm text-gray-900`,children:r(`plugins.title`)})}),B(`button`,{type:`button`,className:`rounded border border-gray-200 bg-white px-2 py-1 text-xs text-gray-500 hover:text-gray-700 hover:border-gray-300 transition-colors`,onClick:()=>p(e=>!e),children:r(f?`plugins.compatible`:`plugins.showAll`)})]}),B(`input`,{"aria-label":r(`plugins.search`),className:`rounded border border-gray-200 px-2.5 py-1.5 text-xs focus:border-me-primary-500 focus:ring-2 focus:ring-me-primary-500/20 focus:outline-none`,type:`search`,placeholder:r(`plugins.searchPlaceholder`),value:m,onChange:e=>h(e.currentTarget.value)}),x?B(`div`,{className:`rounded border border-red-200 bg-red-50 px-3 py-2 text-xs text-red-700`,children:x}):null,B(`div`,{className:`flex flex-col gap-2`,children:ee.map(t=>{let n=bi(t,c,a),o=C.has(t.metadata.id),s=n&&t.loadStatus===`loading`,l=n&&t.loadStatus===`error`?t.loadError:null,u=Pl(t.metadata.image),d=n&&!o&&!s&&!l,f=vi(t,i,a),p=yi(t,i,a,{app:r(`plugins.incompatibleApp`),project:r(`plugins.incompatibleProject`)}),m=Il(t),h=!!t.settings,g=y===`workspace:${t.metadata.id}`;return V(`article`,{className:`flex gap-2.5 rounded-lg border bg-white p-3 text-sm transition-colors ${o?`border-gray-200`:`border-gray-100 bg-gray-50`} ${f?``:`bg-gray-100`}`,children:[u?B(`img`,{className:`h-9 w-9 rounded object-cover flex-none mt-0.5`,src:u.src,alt:e(u.altMessage,u.alt)||e(t.metadata?.labelMessage,t.metadata.label)}):B(`div`,{className:`h-9 w-9 rounded flex items-center justify-center flex-none mt-0.5 text-lg ${o?`bg-me-primary-50 text-me-primary-500`:`bg-gray-100 text-gray-600`}`,children:B(Rl,{className:`w-4 h-4`})}),V(`div`,{className:`flex min-w-0 flex-1 flex-col gap-1`,children:[V(`div`,{className:`flex items-start justify-between gap-1`,children:[V(`div`,{className:`flex flex-wrap items-center gap-1.5 min-w-0`,children:[B(`span`,{className:`font-medium text-gray-900 text-xs`,children:e(t.metadata?.labelMessage,t.metadata.label)}),t.metadata.official?V(`span`,{className:`rounded-full text-me-primary-500 px-1.5 py-0 text-[9px] font-bold inline-flex items-center gap-1`,children:[B(_,{className:`w-3 h-3`}),r(`plugins.verified`)]}):null,t.metadata.version?B(`span`,{className:`text-[10px] text-gray-600`,children:t.metadata.version}):null]}),V(`div`,{className:`flex items-center gap-1 flex-none`,children:[h?B(`button`,{type:`button`,title:r(`plugins.configure`),"aria-label":r(`plugins.configureNamed`,{name:e(t.metadata.labelMessage,t.metadata.label)}),className:`rounded p-1 text-gray-600 hover:text-gray-700 hover:bg-gray-100 transition-colors`,onClick:()=>v(t.metadata.id),children:B(Rl,{className:`w-3.5 h-3.5`})}):null,o&&m?B(`button`,{type:`button`,title:r(`plugins.openNamed`,{name:e(m.labelMessage,m.label)}),"aria-label":r(`plugins.openNamed`,{name:e(m.labelMessage,m.label)}),className:`rounded p-1 text-me-primary-500 hover:bg-me-primary-50 transition-colors`,onClick:()=>O(t),children:B(zl,{className:`w-3.5 h-3.5`})}):null,B(`button`,{type:`button`,disabled:!f||g,onClick:()=>D(t,!n,`workspace`),className:`relative inline-flex h-5 w-9 flex-none items-center rounded-full transition-colors disabled:opacity-40 focus:outline-none focus:ring-2 focus:ring-me-primary-500/30 ${n?`bg-me-primary-500`:`bg-gray-200`}`,title:r(n?`plugins.disablePlugin`:`plugins.enablePlugin`),"aria-label":r(n?`plugins.disableNamed`:`plugins.enableNamed`,{name:e(t.metadata.labelMessage,t.metadata.label)}),children:B(`span`,{className:`inline-block h-3.5 w-3.5 transform rounded-full bg-white shadow transition-transform ${n?`translate-x-4`:`translate-x-0.5`}`})})]})]}),e(t.metadata?.descriptionMessage,t.metadata.description)?B(`p`,{className:`text-xs text-gray-500 leading-relaxed`,children:e(t.metadata?.descriptionMessage,t.metadata.description)}):null,s?B(`span`,{className:`text-xs text-gray-500`,children:r(`plugins.loading`)}):null,l?B(`span`,{className:`text-xs text-red-600`,children:r(`plugins.loadFailed`,{pluginName:e(t.metadata.labelMessage,t.metadata.label)})}):null,d?B(`span`,{className:`text-xs text-amber-600`,children:r(`plugins.waiting`)}):null,!f&&p?B(`span`,{className:`text-xs text-gray-600`,children:p}):null]})]},t.metadata.id)})}),ee.length?null:B(`div`,{className:`rounded-lg border border-gray-100 bg-gray-50 p-4 text-center text-xs text-gray-500`,children:r(`plugins.empty`)}),w?B(te,{title:r(`plugins.configureNamed`,{name:e(w.metadata.labelMessage,w.metadata.label)}),onClose:()=>v(null),width:`560px`,children:B(Vl,{plugin:w,onClose:()=>v(null),canSaveGlobal:!!d})}):null]})}function Vl({plugin:e,onClose:t,canSaveGlobal:n}){let r=U(`shell`),{resolveMessage:i}=H(),a=qi(e.metadata.id),[o,s]=R(`workspace`),[c,l]=R({}),[u,d]=R(!1),[f,p]=R(!1),[m,h]=R(null),g=o===`global`?a.global:a.workspace;F(()=>{l({...g}),h(null),p(!1)},[e.metadata.id,o]);async function _(){let t=e.settings?.validate?.(c);if(t){h(t);return}d(!0),h(null);try{o===`global`?await a.setGlobalSettings(c):a.setWorkspaceSettings(c),p(!0),setTimeout(()=>p(!1),2e3)}catch(e){h(Ll(e,r(`plugins.saveFailed`)))}finally{d(!1)}}async function v(){d(!0),h(null);try{o===`global`?await a.resetGlobalSettings():a.resetWorkspaceSettings(),l({})}catch(e){h(Ll(e,r(`plugins.saveFailed`)))}finally{d(!1)}}let y=n&&a.canSaveGlobal;return V(`div`,{className:`flex flex-col flex-1 min-h-0`,children:[y?V(`div`,{className:`flex items-center gap-1 px-5 pt-4 pb-3 border-b border-gray-100`,children:[B(`span`,{className:`text-xs text-gray-500 mr-2`,children:r(`plugins.scope`)}),B(`button`,{type:`button`,className:`rounded-full px-3 py-1 text-xs font-medium transition-colors ${o===`workspace`?`bg-me-primary-500 text-white`:`bg-gray-100 text-gray-600 hover:bg-gray-200`}`,onClick:()=>s(`workspace`),children:r(`plugins.workspace`)}),B(`button`,{type:`button`,className:`rounded-full px-3 py-1 text-xs font-medium transition-colors ${o===`global`?`bg-me-primary-500 text-white`:`bg-gray-100 text-gray-600 hover:bg-gray-200`}`,onClick:()=>s(`global`),children:r(`plugins.global`)})]}):null,m?B(`div`,{className:`mx-5 mt-4 rounded-lg border border-red-200 bg-red-50 px-3 py-2 text-xs text-red-700`,children:m}):null,B(`div`,{className:`flex-1 overflow-y-auto p-5`,children:B(`div`,{className:`flex flex-col gap-3`,children:e.settings?.render?e.settings.render({i18n:{resolveMessage:i},plugin:e,appId:a.appId,scope:o,value:c,defaults:a.defaults,effective:a.effective,onChange:l}):e.settings?.fields?.length?e.settings.fields.map(e=>B(Hl,{field:e,draft:c,setDraft:l},e.id)):B(`div`,{className:`rounded-lg border border-gray-100 bg-gray-50 p-4 text-center text-sm text-gray-500`,children:r(`plugins.noSettings`)})})}),V(`div`,{className:`flex items-center justify-between gap-3 border-t border-gray-100 px-5 py-4`,children:[B(`button`,{type:`button`,className:`text-xs text-gray-600 hover:text-gray-700 transition-colors disabled:opacity-40`,disabled:u,onClick:v,children:r(`plugins.reset`)}),V(`div`,{className:`flex items-center gap-2`,children:[f?B(`span`,{className:`text-xs text-green-600`,children:r(`plugins.saved`)}):null,B(`button`,{type:`button`,className:`rounded-lg bg-me-primary-500 px-4 py-2 text-sm font-medium text-white hover:bg-me-primary-600 disabled:opacity-50 transition-colors`,disabled:u,onClick:_,children:r(u?`plugins.saving`:o===`workspace`?`plugins.saveWorkspace`:`plugins.saveGlobal`)})]})]})]})}function Hl({field:e,draft:t,setDraft:n}){let{resolveMessage:r}=H(),i=U(`shell`),a=t[e.id],o=`plugin-setting-${e.id}`;function s(r){n({...t,[e.id]:r})}let c=B(`label`,{className:`text-sm font-medium text-gray-900`,htmlFor:o,children:r(e?.labelMessage,e.label)}),l=`rounded-lg border border-gray-200 bg-white px-3 py-2 text-sm focus:border-me-primary-500 focus:ring-2 focus:ring-me-primary-500/20 focus:outline-none`;return e.type===`boolean`?V(`div`,{className:`flex items-center justify-between rounded-lg border border-gray-100 bg-white px-4 py-3`,children:[V(`div`,{className:`flex flex-col gap-0.5`,children:[c,r(e?.descriptionMessage,e.description)?B(`span`,{className:`text-xs text-gray-500`,children:r(e?.descriptionMessage,e.description)}):null]}),B(`input`,{id:o,type:`checkbox`,checked:a===!0,onChange:e=>s(e.currentTarget.checked),className:`h-4 w-4 rounded border-gray-300 text-me-primary-500 focus:ring-me-primary-500`})]}):e.type===`textarea`?V(`div`,{className:`flex flex-col gap-2 rounded-lg border border-gray-100 bg-white px-4 py-3`,children:[c,r(e?.descriptionMessage,e.description)?B(`span`,{className:`text-xs text-gray-500`,children:r(e?.descriptionMessage,e.description)}):null,B(`textarea`,{id:o,className:`${l} min-h-24 resize-y`,value:typeof a==`string`?a:``,placeholder:r(e?.placeholderMessage,e.placeholder),onChange:e=>s(e.currentTarget.value)})]}):e.type===`select`?V(`div`,{className:`flex flex-col gap-2 rounded-lg border border-gray-100 bg-white px-4 py-3`,children:[c,r(e?.descriptionMessage,e.description)?B(`span`,{className:`text-xs text-gray-500`,children:r(e?.descriptionMessage,e.description)}):null,V(`select`,{id:o,className:l,value:a===void 0?``:String(a),onChange:t=>{let n=e.options?.find(e=>String(e.value)===t.currentTarget.value);s(n?n.value:t.currentTarget.value)},children:[B(`option`,{value:``,children:i(`plugins.default`)}),(e.options||[]).map(e=>B(`option`,{value:String(e.value),children:r(e?.labelMessage,e.label)},String(e.value)))]})]}):V(`div`,{className:`flex flex-col gap-2 rounded-lg border border-gray-100 bg-white px-4 py-3`,children:[c,r(e?.descriptionMessage,e.description)?B(`span`,{className:`text-xs text-gray-500`,children:r(e?.descriptionMessage,e.description)}):null,B(`input`,{id:o,className:l,type:e.type===`number`?`number`:`text`,value:typeof a==`string`||typeof a==`number`?a:``,placeholder:r(e?.placeholderMessage,e.placeholder),onChange:t=>{s(e.type===`number`?Number(t.currentTarget.value):t.currentTarget.value)}})]})}function Ul(){let e=U(`shell`),t=J(),n=cn(),r=t.creators[`iiif-image-services`]||{};return V(C.Form,{className:`flex max-w-3xl flex-col gap-4`,onChange:e=>{let t=new FormData(e.currentTarget);n({creators:{"iiif-image-services":{compact:t.get(`compact`)===`compact`?`compact`:`with-dimensions`,includeSizes:t.get(`includeSizes`)===`on`,includeTiles:t.get(`includeTiles`)===`on`}}})},onSubmit:e=>e.preventDefault(),children:[B(`h2`,{className:`text-xl font-semibold text-gray-900`,children:e(`settings.iiif`)}),V(`fieldset`,{className:`flex flex-col gap-4`,children:[B(`legend`,{className:`mb-3 text-base font-semibold`,children:e(`settings.imageServices`)}),V(C.InputContainer,{children:[B(C.Label,{htmlFor:`compactImageServices`,children:e(`settings.compact`)}),V(`select`,{id:`compactImageServices`,name:`compact`,className:`rounded border border-gray-300 p-2`,defaultValue:r.compact===`compact`?`compact`:`with-dimensions`,children:[B(`option`,{value:`with-dimensions`,children:e(`settings.dimensions`)}),B(`option`,{value:`compact`,children:e(`settings.minimal`)})]})]}),V(C.InputContainer,{horizontal:!0,children:[B(C.Input,{id:`includeSizes`,name:`includeSizes`,type:`checkbox`,defaultChecked:r.includeSizes===!0}),B(C.Label,{htmlFor:`includeSizes`,children:e(`settings.sizes`)})]}),V(C.InputContainer,{horizontal:!0,children:[B(C.Input,{id:`includeTiles`,name:`includeTiles`,type:`checkbox`,defaultChecked:r.includeTiles===!0}),B(C.Label,{htmlFor:`includeTiles`,children:e(`settings.tiles`)})]}),B(`p`,{className:`text-sm text-gray-500`,children:e(`settings.imageHelp`)})]})]})}function Wl(){let{resolveMessage:t}=H(),n=U(`shell`),r=Co(),i=_a(),a=J(),o=cn(),[s,c]=Nl(2e3);function l(e){e.preventDefault();let t=new FormData(e.target),n={defaultPreview:t.get(`defaultPreview`),i18n:{...a.i18n||{},advancedLanguageMode:t.get(`advancedLanguageMode`)===`on`,availableLanguages:(t.get(`availableLanguages`)||``).split(`,`).map(e=>e.trim()),defaultLanguage:t.get(`defaultLanguage`)},export:{...a.export||{},version:t.get(`isVersion2`)===`on`?2:3,baseIdentifier:t.get(`base`)||null},plugins:a.plugins,editorFeatureFlags:{...a.editorFeatureFlags||{},rememberCanvasId:t.get(`rememberCanvasId`)===`on`,rememberLeftPanelId:t.get(`rememberLeftPanelId`)===`on`,annotationPopups:t.get(`annotationPopups`)===`on`,manifestGridOptions:t.get(`manifestGridOptions`)===`on`,enableMultiImageCanvases:t.get(`enableMultiImageCanvases`)===`on`,enableMultiMediaCanvases:t.get(`enableMultiMediaCanvases`)===`on`}};o(n),c.set(),c.clear()}return V(se,{children:[B(ce,{title:n(`settings.title`)}),s?B(`div`,{className:`bg-me-primary-500 text-white p-3 text-sm`,children:n(`settings.saved`)}):null,V(j,{className:`p-4`,children:[B(Ul,{}),V(C.Form,{onSubmit:l,className:`flex flex-col gap-3`,children:[V(C.InputContainer,{children:[B(C.Label,{htmlFor:`defaultLanguage`,children:n(`settings.contentDefault`)}),B(C.Input,{type:`text`,name:`defaultLanguage`,id:`defaultLanguage`,defaultValue:a.i18n?.defaultLanguage||``})]}),V(C.InputContainer,{children:[B(C.Label,{htmlFor:`availableLanguages`,children:n(`settings.contentAvailable`)}),B(C.Input,{type:`text`,name:`availableLanguages`,id:`availableLanguages`,defaultValue:(a.i18n?.availableLanguages||[]).join(`, `)})]}),V(C.InputContainer,{horizontal:!0,className:`my-3`,children:[B(C.Input,{type:`checkbox`,name:`advancedLanguageMode`,id:`advancedLanguageMode`,defaultChecked:a.i18n?.advancedLanguageMode||!1}),B(C.Label,{htmlFor:`advancedLanguageMode`,children:n(`settings.contentAdvanced`)})]}),V(C.InputContainer,{horizontal:!0,className:`my-3`,children:[B(C.Input,{type:`checkbox`,name:`textGranularityEnabled`,id:`textGranularityEnabled`,defaultChecked:a.i18n?.textGranularityEnabled||!1}),B(C.Label,{htmlFor:`textGranularityEnabled`,children:n(`settings.textGranularity`)})]}),V(C.InputContainer,{horizontal:!0,className:`my-3`,children:[B(C.Input,{type:`checkbox`,name:`rememberCanvasId`,id:`rememberCanvasId`,defaultChecked:a.editorFeatureFlags?.rememberCanvasId||!1}),B(C.Label,{htmlFor:`rememberCanvasId`,children:n(`settings.rememberCanvas`)})]}),V(C.InputContainer,{horizontal:!0,className:`my-3`,children:[B(C.Input,{type:`checkbox`,name:`rememberLeftPanelId`,id:`rememberLeftPanelId`,defaultChecked:a.editorFeatureFlags?.rememberLeftPanelId||!1}),B(C.Label,{htmlFor:`rememberLeftPanelId`,children:n(`settings.rememberPanel`)})]}),V(C.InputContainer,{horizontal:!0,className:`my-3`,children:[B(C.Input,{type:`checkbox`,name:`manifestGridOptions`,id:`manifestGridOptions`,defaultChecked:a.editorFeatureFlags?.manifestGridOptions||!1}),B(C.Label,{htmlFor:`manifestGridOptions`,children:n(`settings.grid`)})]}),V(C.InputContainer,{horizontal:!0,className:`my-3`,children:[B(C.Input,{type:`checkbox`,name:`isVersion2`,id:`isVersion2`,defaultChecked:a.export?.version===2}),B(C.Label,{htmlFor:`isVersion2`,children:n(i.type===`Collection`?`settings.exportCollections`:`settings.exportManifests`)})]}),V(C.InputContainer,{children:[B(C.Label,{htmlFor:`defaultPreview`,children:n(`settings.defaultPreview`)}),B(`div`,{children:r.configs.map((e,n)=>e.type===`iiif-preview-service`?null:V(C.InputContainer,{horizontal:!0,children:[B(C.Input,{type:`radio`,id:e.id,name:`defaultPreview`,value:e.id,defaultChecked:a.defaultPreview?a.defaultPreview===e.id:n===0}),B(`label`,{htmlFor:e.id,children:t(e?.labelMessage,e.label)})]},e.id))})]}),i.type===`Manifest`?B(`a`,{className:`text-sm text-me-primary-500 hover:underline hover:text-me-primary-600`,href:window.location.pathname.includes(`/exhibition`)?window.location.pathname.replace(`/exhibition`,``)||`/`:`${window.location.pathname}/exhibition`,children:window.location.pathname.includes(`/exhibition`)?n(`settings.return`):n(`settings.exhibition`)}):null,B(Bl,{}),B(`div`,{className:`mt-5`,children:B(e,{type:`submit`,children:n(`actions.save`)})})]})]})]})}function Gl(e){let t=new Map;for(let n of e){if(!n.configuration?.fields.length)continue;let e=At(n);(!t.has(e)||n.id===e)&&t.set(e,n)}return Array.from(t.values())}function Kl(){let{resolveMessage:e}=H(),t=U(`shell`),n=X(),r=J(),i=cn(),a=I(()=>Gl(n.layout.creators||[]),[n.layout.creators]);function o(e,t){let n=At(e),r=new FormData(t),a={};for(let t of e.configuration?.fields||[])t.type===`checkbox`&&(a[t.id]=r.get(t.id)===`on`);i({creators:{[n]:a}})}return a.length?B(`div`,{className:`flex max-w-3xl flex-col gap-6`,children:a.map(t=>V(C.Form,{className:`flex flex-col gap-3 border-b border-gray-100 pb-5 last:border-b-0`,onChange:e=>o(t,e.currentTarget),children:[V(`div`,{className:`flex flex-col gap-1`,children:[B(`h3`,{className:`text-base font-semibold text-gray-900`,children:e(t?.labelMessage,t.label)}),e(t?.summaryMessage,t.summary)?B(`p`,{className:`text-sm text-gray-500`,children:e(t?.summaryMessage,t.summary)}):null]}),t.configuration?.fields.map(n=>{let i=At(t),a=r.creators?.[i]?.[n.id],o=`${i}-${n.id}`;return n.type===`checkbox`?V(C.InputContainer,{horizontal:!0,className:`my-1 items-start`,children:[B(C.Input,{type:`checkbox`,name:n.id,id:o,defaultChecked:typeof a==`boolean`?a:n.defaultValue||!1}),V(`div`,{className:`flex flex-col gap-1`,children:[B(C.Label,{htmlFor:o,children:e(n?.labelMessage,n.label)}),e(n?.summaryMessage,n.summary)?B(`p`,{className:`text-sm text-gray-500`,children:e(n?.summaryMessage,n.summary)}):null]})]},n.id):null})]},At(t)))}):B(x,{children:t(`settings.noCreators`)})}function ql(){return Re((e,t)=>({specificMenus:{},resourceMenus:{},hookMenuItem(t){let n=Xr(),r=t.resource?.id||``,i=t.resource?.type;return i?r?(e(e=>({specificMenus:{...e.specificMenus,[r]:{...e.specificMenus[r]||{},menus:{...e.specificMenus[r]?.menus||{},[n]:{sectionTitle:t.sectionTitle,items:t.items}}}}})),()=>{e(e=>({specificMenus:{...e.specificMenus,[r]:{...e.specificMenus[r]||{},menus:{...e.specificMenus[r]?.menus||{},[n]:void 0}}}}))}):(e(e=>({resourceMenus:{...e.resourceMenus,[i]:{...e.resourceMenus[i]||{},menus:{...e.resourceMenus[i]?.menus||{},[n]:{sectionTitle:t.sectionTitle,items:t.items}}}}})),()=>{e(e=>({resourceMenus:{...e.resourceMenus,[i]:{...e.resourceMenus[i]||{},menus:{...e.resourceMenus[i]?.menus||{},[n]:void 0}}}}))}):()=>{}}}))}const Jl=M(null);function Yl({children:e}){let t=I(()=>ql(),[]);return B(Jl.Provider,{value:t,children:e})}function Xl(){let e=P(Jl);if(!e)throw Error(`useContextMenuStore must be used within a ContextMenuProvider`);return e}function Zl(e){let t=Xl(),n=ze(t,e=>e.resourceMenus),r=ze(t,e=>e.specificMenus);return I(()=>{let t=r[e.id||``]?.menus||{},i=n[e.type]?.menus||{},a=Object.values(t).flat(),o=[...Object.values(i).flat(),...a].filter(e=>e!==void 0),s=[],c=[];for(let e of o){let t=[];for(let n of e.items||[])n.id&&s.includes(n.id)||(s.push(n.id),t.push(n));t.length&&c.push({...e,items:t})}return Ql(c)},[r,n,e.id,e.type])}function Ql(e){let t={},n=[];e.forEach(e=>{if(!e)return;let r=e.sectionTitle;if(!r){n.push(...e.items||[]);return}t[r]||(t[r]=[]),t[r].push(...e.items)});let r=Object.entries(t).map(([e,t])=>({sectionTitle:e,items:t}));return n.length&&r.push({items:n}),r}function $l(e,t=[]){let n=Xl(),r=ze(n,e=>e.hookMenuItem);F(()=>r(e),[r,e.resource?.id,e.resource?.type,...t])}var eu={CenterPanelContainer:`_CenterPanelContainer_1sbe6_1`,CenterPanelHeader:`_CenterPanelHeader_1sbe6_16`,CenterPanelClose:`_CenterPanelClose_1sbe6_23`,CenterPanelTitle:`_CenterPanelTitle_1sbe6_28`};function tu(e){let t=U(`ui`);return V(`div`,{className:eu.CenterPanelContainer,children:[e.title||e.close?V(`div`,{className:eu.CenterPanelHeader,children:[e.title?B(`h2`,{className:eu.CenterPanelTitle,children:e.title}):null,e.close?B(To,{"aria-label":t(`actions.close`),className:eu.CenterPanelClose,onClick:e.close,children:B(ro,{})}):null]}):null,e.children]})}const nu=G.div`
|
|
445
470
|
flex: 1;
|
|
446
471
|
display: flex;
|
|
447
472
|
width: 100%;
|
|
448
473
|
flex-direction: column;
|
|
449
474
|
position: relative;
|
|
450
|
-
`,
|
|
475
|
+
`,ru=G.div`
|
|
451
476
|
background: #fff;
|
|
452
477
|
position: relative;
|
|
453
478
|
border-bottom: 1px solid #d0d0d0;
|
|
@@ -465,11 +490,11 @@ import{ActionButton as e,ArrowRightIcon as t,BackIcon as n,BackgroundActionMenuB
|
|
|
465
490
|
//flex-direction: column;
|
|
466
491
|
//justify-content: center;
|
|
467
492
|
}
|
|
468
|
-
`,
|
|
493
|
+
`,iu=G.p`
|
|
469
494
|
font-size: 0.9em;
|
|
470
495
|
color: #777;
|
|
471
496
|
font-weight: 400;
|
|
472
|
-
`,
|
|
497
|
+
`,au=G.button`
|
|
473
498
|
color: inherit;
|
|
474
499
|
text-rendering: geometricPrecision;
|
|
475
500
|
border: none;
|
|
@@ -511,7 +536,7 @@ import{ActionButton as e,ArrowRightIcon as t,BackIcon as n,BackgroundActionMenuB
|
|
|
511
536
|
margin-top: 0.5em;
|
|
512
537
|
}
|
|
513
538
|
}
|
|
514
|
-
|
|
539
|
+
`,ou=G.div`
|
|
515
540
|
font-size: 1.4em;
|
|
516
541
|
padding-right: 0.3em;
|
|
517
542
|
display: flex;
|
|
@@ -520,7 +545,7 @@ import{ActionButton as e,ArrowRightIcon as t,BackIcon as n,BackgroundActionMenuB
|
|
|
520
545
|
[data-large="true"] & {
|
|
521
546
|
font-size: 2em;
|
|
522
547
|
}
|
|
523
|
-
`,
|
|
548
|
+
`,su=G.div`
|
|
524
549
|
width: 2em;
|
|
525
550
|
align-items: center;
|
|
526
551
|
//padding-top: 0.5em;
|
|
@@ -533,11 +558,11 @@ import{ActionButton as e,ArrowRightIcon as t,BackIcon as n,BackgroundActionMenuB
|
|
|
533
558
|
fill: #999;
|
|
534
559
|
color: #999;
|
|
535
560
|
}
|
|
536
|
-
`,
|
|
561
|
+
`,cu=G.div`
|
|
537
562
|
min-height: 0;
|
|
538
563
|
overflow: visible;
|
|
539
564
|
display: flex;
|
|
540
|
-
`,
|
|
565
|
+
`,lu=G.div`
|
|
541
566
|
min-height: 0;
|
|
542
567
|
overflow: visible;
|
|
543
568
|
flex: 1;
|
|
@@ -550,7 +575,7 @@ import{ActionButton as e,ArrowRightIcon as t,BackIcon as n,BackgroundActionMenuB
|
|
|
550
575
|
&[data-max-height="true"] {
|
|
551
576
|
overflow-y: auto;
|
|
552
577
|
}
|
|
553
|
-
`,
|
|
578
|
+
`,uu=G.section`
|
|
554
579
|
display: grid;
|
|
555
580
|
grid-template-rows: 0fr;
|
|
556
581
|
overflow: hidden;
|
|
@@ -578,7 +603,7 @@ import{ActionButton as e,ArrowRightIcon as t,BackIcon as n,BackgroundActionMenuB
|
|
|
578
603
|
&[data-scrolled="true"] {
|
|
579
604
|
box-shadow: inset 0px 2px 0px 0 rgba(0, 0, 0, 0.1);
|
|
580
605
|
}
|
|
581
|
-
`,
|
|
606
|
+
`,du=G.div`
|
|
582
607
|
position: sticky;
|
|
583
608
|
display: flex;
|
|
584
609
|
top: 0;
|
|
@@ -614,7 +639,7 @@ import{ActionButton as e,ArrowRightIcon as t,BackIcon as n,BackgroundActionMenuB
|
|
|
614
639
|
right: 0.5em;
|
|
615
640
|
}
|
|
616
641
|
}
|
|
617
|
-
`,
|
|
642
|
+
`,fu=(()=>void 0);let pu=0;function mu(){return I(()=>pu++,[])}function hu(e,t=!1){let[n,r]=R([]),i=L(-1),a=t=>{let r=document.activeElement,i=n.findIndex(e=>e.current?.button?.current===r);if(i!==-1)switch(t.code){case`Home`:n[0]&&n[0].current?.focus();break;case`End`:{let t=e-1;n[t]&&n[t].current?.focus();break}case`ArrowDown`:if(i!==e-1){let e=i+1;n[e]&&n[e].current?.focus()}break;case`ArrowUp`:if(i!==0){let e=i-1;n[e]&&n[e].current?.focus()}break;case`ArrowLeft`:{let e=n[i];e&&e.current&&e.current.close();break}case`ArrowRight`:{let e=n[i];e&&e.current&&e.current.open();break}}},o=(e,r)=>{if(t&&r&&e!==i.current){i.current=e;for(let t=0;t<n.length;t++){let r=n[t];t!==e&&r.current?.close()}}};return F(()=>{r(t=>Array(e).fill(0).map((e,n)=>t[n]||Oe()))},[e]),{open:e=>{let t=n[e];t&&t.current&&t.current.open()},close:e=>{let t=n[e];t&&t.current&&t.current.close()},toggle:e=>{let t=n[e];t&&t.current&&t.current.toggle()},focus:e=>{let t=n[e];t&&t.current&&t.current.focus()},openAll:()=>{for(let e=0;e<n.length;e++)n[e].current?.open()},closeAll:()=>{for(let e=0;e<n.length;e++)n[e].current?.close()},onKeyDown:a,getItemProps:e=>({ref:n[e],onChange:t=>o(e,t)})}}const gu=ke(function(e,t){let n=L(null),r=L(null),i=mu(),[a,o]=R(e.initialOpen||!1),s=e.onChange||fu,c=()=>{s(!a),o(e=>!e)},l=e.maxHeight,[u,d]=R(!1);return Me(t,()=>({open(){s(!0),o(!0)},close(){s(!1),o(!1)},toggle(){c()},focus(){r.current&&r.current.focus()},button:r})),V(ru,{"data-large":e.large,"data-open":a,children:[V(du,{"data-open":a,children:[e.icon?B(su,{onClick:c,children:e.icon}):null,V(au,{ref:r,onClick:c,"aria-expanded":a,"aria-controls":`accordion-${i}`,children:[e.label,e.description?B(iu,{children:e.description}):null]}),B(ou,{onClick:c,children:B(io,{width:`1em`,height:`1em`,rotate:a?0:180})})]}),B(uu,{"aria-labelledby":`accordion-${i}`,"aria-hidden":!a,"data-overflow":!!e.overflow,"data-has-icon":!!e.icon,onScroll:e=>{e.target.scrollTop>0?d(!0):d(!1)},ref:n,$initial:!a,"data-scrolled":u,hidden:!a,children:B(cu,{children:B(lu,{"data-max-height":!!l,"data-full":e.fullWidth,style:{maxHeight:l||void 0},children:e.children})})})]})});function _u(e){let{getItemProps:t,onKeyDown:n}=hu(e.items.length,e.singleMode);return B(nu,{onKeyDown:n,children:e.items.map((n,r)=>B(gu,{overflow:e.overflow,maxHeight:e.maxHeight,...n,...t(r),children:n.children},r))})}function vu(){return B(`svg`,{xmlns:`http://www.w3.org/2000/svg`,height:`48`,viewBox:`0 -960 960 960`,width:`48`,children:B(`path`,{d:`M220-160q-24 0-42-18t-18-42v-143h60v143h520v-143h60v143q0 24-18 42t-42 18H220Zm260-153L287-506l43-43 120 120v-371h60v371l120-120 43 43-193 193Z`})})}const yu=G.div`
|
|
618
643
|
padding: 0.3em;
|
|
619
644
|
|
|
620
645
|
display: flex;
|
|
@@ -636,12 +661,12 @@ import{ActionButton as e,ArrowRightIcon as t,BackIcon as n,BackgroundActionMenuB
|
|
|
636
661
|
position: sticky;
|
|
637
662
|
bottom: 0;
|
|
638
663
|
}
|
|
639
|
-
`;function
|
|
664
|
+
`;function bu(e){let t=U(`shell`),n=et(),r=W(),i=wa(),a=I(()=>JSON.stringify(r.toPresentation3(n),null,2),[n,r]),o=I(()=>JSON.stringify(r.toPresentation2(n),null,2),[n,r]);return B(tu,{title:t(`export.title`),close:i.centerPanel.popStack,children:B(`div`,{style:{flex:1,overflowY:`auto`},children:B(_u,{items:[{label:t(`export.presentation3`),description:t(`export.instructions`),maxHeight:400,large:!0,initialOpen:!0,overflow:!0,icon:B(To,{onClick:()=>Jr(a,`manifest.json`),children:B(vu,{})}),children:V(`div`,{style:{maxWidth:`100%`},children:[B(`pre`,{style:{whiteSpace:`pre-wrap`},children:JSON.stringify(r.toPresentation3(n),null,2)}),V(yu,{"data-sticky":`true`,children:[B(To,{onClick:()=>Yr(a),children:t(`export.copy`)}),B(To,{onClick:()=>Jr(a,`manifest.json`),children:t(`export.download`)})]})]})},{label:t(`export.presentation2`),description:t(`export.instructions`),maxHeight:400,large:!0,icon:B(To,{onClick:()=>Jr(o,`manifest.json`),children:B(vu,{})}),children:V(`div`,{style:{maxWidth:`100%`},children:[B(`pre`,{style:{whiteSpace:`pre-wrap`},children:JSON.stringify(r.toPresentation2(n),null,2)}),V(yu,{"data-sticky":`true`,children:[B(To,{onClick:()=>Yr(o),children:t(`export.copy`)}),B(To,{onClick:()=>Jr(o,`manifest.json`),children:t(`export.download`)})]})]})}]})})})}function xu({key:e,initialValue:t,requestId:n,getInitialValue:r}){let[i,a]=Qe({requestId:n}),[o,s]=R(r&&r(i)||i[e]||t);return[o,N(t=>{a({[e]:t}),s(t)},[])]}const Su=Nt(),Cu=M(Su);function wu({children:e,emitter:t}){return B(Cu.Provider,{value:t,children:e})}function Tu(){return P(Cu)}function Eu(e,t,n=[]){let r=P(Cu);F(()=>{let n=e=>{t(e)};return r.on(e,n),()=>{r.off(e,n)}},[r,e,...n])}function Du(e,t=[]){let n=t.length?t:Array(e.length).fill(!1);if(typeof window>`u`)return n;let r=e.map(e=>window.matchMedia(e)),i=()=>r.map(e=>e.matches),[a,o]=R(i);return Ne(()=>{let e=()=>o(i);return r.forEach(t=>t.addListener(e)),()=>r.forEach(t=>t.removeListener(e))},[]),a}function Ou(e,t,n,r=!0){let i=Pt(t,n);F(()=>typeof window>`u`?()=>void 0:(window.addEventListener(`beforeunload`,t,!1),()=>{t(),window.removeEventListener(`beforeunload`,t)}),[t]),F(()=>{if(e&&r)return e.subscribe(i,!0)},[i,e,r])}function ku(){let e=Ze(),t=ze(e,e=>e.switchTool),n=ze(e,e=>e.polygonState.currentTool),r=ze(e,e=>e.polygonState.selectedStamp),i=ze(e,e=>e.polygonState.showBoundingBox);return I(()=>({currentTool:n,selectedStamp:r,draw:{active:n===`pencil`,enable:t.draw},polygon:{active:n===`pen`,enable:t.pen},line:{active:n===`line`,enable:t.line},lineBox:{active:n===`lineBox`,enable:t.lineBox},square:{active:n===`box`,enable:t.box},triangle:{active:r?.id===`triangle`,enable:t.triangle},hexagon:{active:r?.id===`hexagon`,enable:t.hexagon},circle:{active:r?.id===`circle`,enable:t.circle},remove:{active:i,enable:t.remove}}),[i,r,n,t])}const Au=G.div`
|
|
640
665
|
position: relative;
|
|
641
666
|
width: 1px;
|
|
642
667
|
background: rgba(0, 0, 0, 0.2);
|
|
643
668
|
z-index: 50;
|
|
644
|
-
`,
|
|
669
|
+
`,ju=G(wo)`
|
|
645
670
|
transition:
|
|
646
671
|
opacity 300ms,
|
|
647
672
|
transform 300ms;
|
|
@@ -653,7 +678,7 @@ import{ActionButton as e,ArrowRightIcon as t,BackIcon as n,BackgroundActionMenuB
|
|
|
653
678
|
&:focus {
|
|
654
679
|
outline: 2px solid salmon;
|
|
655
680
|
}
|
|
656
|
-
`;
|
|
681
|
+
`;G(ju)`
|
|
657
682
|
background: #fff;
|
|
658
683
|
width: 30px;
|
|
659
684
|
height: 30px;
|
|
@@ -667,7 +692,7 @@ import{ActionButton as e,ArrowRightIcon as t,BackIcon as n,BackgroundActionMenuB
|
|
|
667
692
|
svg {
|
|
668
693
|
fill: #9999;
|
|
669
694
|
}
|
|
670
|
-
`;const
|
|
695
|
+
`;const Mu=G(ju)`
|
|
671
696
|
position: relative;
|
|
672
697
|
display: flex;
|
|
673
698
|
opacity: 1;
|
|
@@ -694,7 +719,7 @@ import{ActionButton as e,ArrowRightIcon as t,BackIcon as n,BackgroundActionMenuB
|
|
|
694
719
|
svg {
|
|
695
720
|
font-size: 1.5em;
|
|
696
721
|
}
|
|
697
|
-
`,
|
|
722
|
+
`,Nu=G.div`
|
|
698
723
|
background: rgba(0, 0, 0, 0);
|
|
699
724
|
position: absolute;
|
|
700
725
|
width: 16px;
|
|
@@ -717,12 +742,12 @@ import{ActionButton as e,ArrowRightIcon as t,BackIcon as n,BackgroundActionMenuB
|
|
|
717
742
|
&:hover {
|
|
718
743
|
transform: scaleX(100%);
|
|
719
744
|
background: rgba(0, 0, 0, 0.1);
|
|
720
|
-
${
|
|
745
|
+
${ju} {
|
|
721
746
|
transform: scaleX(100%);
|
|
722
747
|
opacity: 1;
|
|
723
748
|
}
|
|
724
749
|
}
|
|
725
|
-
`,
|
|
750
|
+
`,Pu=G.div`
|
|
726
751
|
background: rgba(0, 0, 0, 0);
|
|
727
752
|
position: absolute;
|
|
728
753
|
pointer-events: none;
|
|
@@ -731,7 +756,7 @@ import{ActionButton as e,ArrowRightIcon as t,BackIcon as n,BackgroundActionMenuB
|
|
|
731
756
|
top: 0;
|
|
732
757
|
bottom: 0;
|
|
733
758
|
z-index: 51; // This will always be quite high.
|
|
734
|
-
`,
|
|
759
|
+
`,Fu=ke(function({dir:e,open:t,actions:n,reset:r},i){let a=U(`shell`),[o,s]=R(!0),c=`mt-[calc(50vh+8px)]`,l=e===`left`?`${c} ml-[13px]`:`${c} ml-[3px]`;return V(Au,{onClick:()=>n.open(),children:[B(Pu,{$open:t,$dir:e,className:`group`,children:t?null:V(ge,{placement:e===`left`?`right`:`left`,children:[B(_e,{"aria-label":a(e===`left`?`panels.openLeft`:`panels.openRight`),as:Mu,$dir:e,onClick:e=>n.open(),children:B(io,{"aria-hidden":`true`,className:`text-2xl`,rotate:e===`right`?90:270})}),B(y,{children:a(`actions.open`)})]})}),V(ge,{placement:e===`left`?`right`:`left`,children:[B(_e,{asChild:!0,children:B(`div`,{children:V(Nu,{ref:i,$open:t,$dir:e,className:`group`,children:[t?V(ge,{placement:e===`left`?`right`:`left`,children:[B(_e,{"aria-label":a(e===`left`?`panels.closeLeft`:`panels.closeRight`),as:O,onPress:()=>n.close(),children:B(`div`,{onMouseOut:()=>{s(!0)},onMouseOver:()=>{s(!1)},children:B(ro,{"aria-hidden":`true`})})}),B(y,{children:a(`actions.close`)})]}):null,r&&t?V(ge,{placement:e===`left`?`right`:`left`,children:[B(_e,{"aria-label":a(e===`left`?`panels.resetLeft`:`panels.resetRight`),as:O,onPress:()=>r(),children:B(`div`,{onMouseOut:()=>{s(!0)},onMouseOver:()=>{s(!1)},children:B(ae,{"aria-hidden":`true`})})}),B(y,{children:a(`actions.reset`)})]}):null,t?V(ge,{placement:e===`left`?`right`:`left`,children:[B(_e,{asChild:!0,children:B(`div`,{onMouseOut:()=>{s(!0)},onMouseOver:()=>{s(!1)},children:B(oe,{"aria-label":a(`panels.resize`)})})}),B(y,{children:a(`panels.resize`)})]}):null]})})}),o&&B(y,{className:l,children:a(`panels.resize`)})]})]})});function Iu(e){return B(`svg`,{width:`1em`,height:`1em`,viewBox:`0 0 42 42`,xmlns:`http://www.w3.org/2000/svg`,stroke:`currentColor`,...e,children:V(`g`,{transform:`translate(2 2)`,strokeWidth:5,fill:`none`,fillRule:`evenodd`,children:[B(`circle`,{strokeOpacity:.5,cx:18,cy:18,r:18}),B(`path`,{d:`M36 18c0-9.94-8.06-18-18-18`,children:B(`animateTransform`,{attributeName:`transform`,type:`rotate`,from:`0 18 18`,to:`360 18 18`,dur:`1s`,repeatCount:`indefinite`})})]})})}var Lu={ghostLoadingBlock:`_ghostLoadingBlock_1i1t4_1`,"ghost-loading":`_ghost-loading_1i1t4_1`,ghostLoading:`_ghost-loading_1i1t4_1`,ghostBlockList:`_ghostBlockList_1i1t4_28`};function Ru(){return V(z,{children:[B(`div`,{"data-header":`true`,className:Lu.ghostLoadingBlock}),V(`div`,{className:Lu.ghostBlockList,children:[B(`div`,{className:Lu.ghostLoadingBlock}),B(`div`,{className:Lu.ghostLoadingBlock}),B(`div`,{className:Lu.ghostLoadingBlock}),B(`div`,{className:Lu.ghostLoadingBlock})]})]})}function zu(e,t,n,r=[]){Ne(()=>{let r=e.current;if(r)return r.addEventListener(t,n),()=>{r.removeEventListener(t,n)}},[t,...r])}function Bu(e,t,n,r){return Math.sqrt(Math.abs(n-e)**2+Math.abs(r-t)**2)}function Vu(e,t,n,r){return n||(r?r/e:t)}function Hu(e,t={}){let n=L(null),r=L(null),i=L(null),a=L(null),o=L(.5),[s,c]=R(!1),l=L(!1),u=L(0),d=L({x:0,y:0}),[{widthA:f,widthB:p},m]=be(`resize-layout/${e}`,{widthA:`auto`,widthB:`${Xc({initial:t.widthA,fallback:320,options:{minWidth:t.minWidthPx,maxWidth:t.maxWidthPx}})}px`}),{loading:h=!1}=t;return zu(a,`mousedown`,e=>{d.current.x=e.pageX,d.current.y=e.pageY,u.current&&(clearTimeout(u.current),u.current=0),u.current=setTimeout(()=>{c(!0),l.current=!0},350)},[h]),zu({current:typeof window<`u`?window:void 0},`mouseup`,()=>{let e=n.current;if(e&&l.current){let{x:n,width:r}=e.getBoundingClientRect(),i=t.marginLeft||0,a=Vu(r,.8,t.maxWidthPct,t.maxWidthPx)*r,s=Vu(r,.2,t.minWidthPct,t.minWidthPx)*r;if(t.left){let e=o.current*r-i;m({widthA:`${(1-o.current)*r-i}`,widthB:`${e>a?a:e<s?s:e}px`})}else{let e=1-o.current*r-i;m({widthA:`${e>a?a:e<s?s:e}px`,widthB:`${o.current*r-i}px`})}c(!1),l.current=!1,t.onDragEnd&&t.onDragEnd()}clearTimeout(u.current),u.current=0},[h]),zu(n,`mousemove`,e=>{if(!l.current&&u.current&&Bu(d.current.x,d.current.y,e.pageX,e.pageY)>20&&(c(!0),l.current=!0,clearTimeout(u.current),u.current=0),l.current&&r.current){let i=n.current;if(i){let{x:n,width:a}=i.getBoundingClientRect(),s=t.marginLeft||0,c=t.left||!1,l=Vu(a,.8,t.maxWidthPct,t.maxWidthPx),u=Vu(a,.2,t.minWidthPct,t.minWidthPx);o.current=(a+n-e.pageX-5)/a,c&&(o.current=1-o.current),o.current=o.current<u?u:o.current,o.current=o.current>l?l:o.current,r.current.style.width=`${o.current*a-s}px`}}},[s,h]),{refs:{container:n,resizer:a,resizableDiv:r,otherDiv:i},setWidths:m,isDragging:s,widthA:f,widthB:p}}const Z=`.manifest-editor.exhibition-focused &`,Q=`[data-exhibition-theme="dark"] ${Z}`,$={pink:`#b84c74`,pinkHover:`#9f3f64`,lightApp:`#f4f1ec`,lightStage:`#dfdbd4`,lightPanel:`#fff`,lightPanelSoft:`#f8f6f3`,lightBorder:`#dcd5ce`,lightPanelBorder:`#ddd5ce`,lightText:`#25211f`,lightMuted:`#6a625c`,darkApp:`#18161d`,darkStage:`#0e0d12`,darkPanel:`#28222d`,darkPanelSoft:`#2f2934`,darkPanelHeader:`#25222b`,darkHover:`#312c34`,darkSelected:`#3a3440`,darkText:`#f6f1f4`,darkMuted:`#c8c0c6`,darkSubtle:`#999088`,darkLabel:`#d9d1da`,darkWarning:`#4a2636`,darkWarningBorder:`#7a3f59`,darkBorder:`rgba(246, 241, 244, 0.16)`,darkBorderSoft:`rgba(246, 241, 244, 0.14)`},Uu=G.div`
|
|
735
760
|
display: flex;
|
|
736
761
|
flex: 1 1 0;
|
|
737
762
|
min-height: 0;
|
|
@@ -745,7 +770,7 @@ import{ActionButton as e,ArrowRightIcon as t,BackIcon as n,BackgroundActionMenuB
|
|
|
745
770
|
${Q} {
|
|
746
771
|
background: ${$.darkApp};
|
|
747
772
|
}
|
|
748
|
-
`,
|
|
773
|
+
`,Wu=G.div`
|
|
749
774
|
flex: 1 1 0;
|
|
750
775
|
min-width: 0;
|
|
751
776
|
min-height: 0;
|
|
@@ -772,12 +797,12 @@ import{ActionButton as e,ArrowRightIcon as t,BackIcon as n,BackgroundActionMenuB
|
|
|
772
797
|
}
|
|
773
798
|
|
|
774
799
|
${Z} .atlas-container {
|
|
775
|
-
--atlas-background: ${$.lightStage} !important;
|
|
776
|
-
background: ${$.lightStage} !important;
|
|
800
|
+
--atlas-background: var(--canvas-workspace-background, ${$.lightStage}) !important;
|
|
801
|
+
background: var(--canvas-workspace-background, ${$.lightStage}) !important;
|
|
777
802
|
}
|
|
778
803
|
|
|
779
804
|
${Z} .atlas-canvas {
|
|
780
|
-
background: ${$.lightStage} !important;
|
|
805
|
+
background: var(--canvas-workspace-background, ${$.lightStage}) !important;
|
|
781
806
|
}
|
|
782
807
|
|
|
783
808
|
${Q} > .delft-exhibition {
|
|
@@ -786,12 +811,12 @@ import{ActionButton as e,ArrowRightIcon as t,BackIcon as n,BackgroundActionMenuB
|
|
|
786
811
|
}
|
|
787
812
|
|
|
788
813
|
${Q} .atlas-container {
|
|
789
|
-
--atlas-background: ${$.darkStage} !important;
|
|
790
|
-
background: ${$.darkStage} !important;
|
|
814
|
+
--atlas-background: var(--canvas-workspace-background, ${$.darkStage}) !important;
|
|
815
|
+
background: var(--canvas-workspace-background, ${$.darkStage}) !important;
|
|
791
816
|
}
|
|
792
817
|
|
|
793
818
|
${Q} .atlas-canvas {
|
|
794
|
-
background: ${$.darkStage} !important;
|
|
819
|
+
background: var(--canvas-workspace-background, ${$.darkStage}) !important;
|
|
795
820
|
}
|
|
796
821
|
|
|
797
822
|
${Q} [class*="CanvasContainer"],
|
|
@@ -861,12 +886,12 @@ import{ActionButton as e,ArrowRightIcon as t,BackIcon as n,BackgroundActionMenuB
|
|
|
861
886
|
background: ${$.darkHover} !important;
|
|
862
887
|
color: #fff !important;
|
|
863
888
|
}
|
|
864
|
-
`,
|
|
889
|
+
`,Gu=G.div`
|
|
865
890
|
display: flex;
|
|
866
891
|
flex: 1;
|
|
867
892
|
justify-content: center;
|
|
868
893
|
align-items: center;
|
|
869
|
-
`,
|
|
894
|
+
`,Ku=G.div`
|
|
870
895
|
position: absolute;
|
|
871
896
|
top: 3rem;
|
|
872
897
|
z-index: 40;
|
|
@@ -891,12 +916,12 @@ import{ActionButton as e,ArrowRightIcon as t,BackIcon as n,BackgroundActionMenuB
|
|
|
891
916
|
box-shadow: 0 12px 28px rgba(0, 0, 0, 0.36);
|
|
892
917
|
}
|
|
893
918
|
|
|
894
|
-
${e=>e.$side===`left`?
|
|
919
|
+
${e=>e.$side===`left`?K`
|
|
895
920
|
left: 1rem;
|
|
896
|
-
`:
|
|
921
|
+
`:K`
|
|
897
922
|
right: 1rem;
|
|
898
923
|
`}
|
|
899
|
-
`,
|
|
924
|
+
`,qu=G.button`
|
|
900
925
|
width: 2.35rem;
|
|
901
926
|
height: 2.35rem;
|
|
902
927
|
border: 0;
|
|
@@ -956,16 +981,16 @@ import{ActionButton as e,ArrowRightIcon as t,BackIcon as n,BackgroundActionMenuB
|
|
|
956
981
|
width: 2.75rem;
|
|
957
982
|
height: 2.75rem;
|
|
958
983
|
}
|
|
959
|
-
`,
|
|
984
|
+
`,Ju=G.div`
|
|
960
985
|
display: flex;
|
|
961
986
|
flex-direction: column;
|
|
962
987
|
gap: 0.25rem;
|
|
963
|
-
`,
|
|
988
|
+
`,Yu=G.div`
|
|
964
989
|
width: 100%;
|
|
965
990
|
height: 1px;
|
|
966
991
|
margin: 0.25rem 0;
|
|
967
992
|
background: rgba(15, 23, 42, 0.14);
|
|
968
|
-
`,
|
|
993
|
+
`,Xu=G.aside`
|
|
969
994
|
position: absolute;
|
|
970
995
|
top: 3rem;
|
|
971
996
|
bottom: 1rem;
|
|
@@ -1020,7 +1045,7 @@ import{ActionButton as e,ArrowRightIcon as t,BackIcon as n,BackgroundActionMenuB
|
|
|
1020
1045
|
box-shadow: 0 20px 50px rgba(0, 0, 0, 0.42);
|
|
1021
1046
|
}
|
|
1022
1047
|
|
|
1023
|
-
${Q} ${
|
|
1048
|
+
${Q} ${nl} {
|
|
1024
1049
|
background: ${$.darkPanelHeader} !important;
|
|
1025
1050
|
border-color: ${$.darkBorder} !important;
|
|
1026
1051
|
color: ${$.darkText} !important;
|
|
@@ -1029,11 +1054,11 @@ import{ActionButton as e,ArrowRightIcon as t,BackIcon as n,BackgroundActionMenuB
|
|
|
1029
1054
|
inset 0 1px 0 0 ${$.darkBorder} !important;
|
|
1030
1055
|
}
|
|
1031
1056
|
|
|
1032
|
-
${Q} ${
|
|
1057
|
+
${Q} ${rl} {
|
|
1033
1058
|
color: ${$.darkText} !important;
|
|
1034
1059
|
}
|
|
1035
1060
|
|
|
1036
|
-
${Q} ${
|
|
1061
|
+
${Q} ${rl}:hover {
|
|
1037
1062
|
background: ${$.darkHover} !important;
|
|
1038
1063
|
color: #fff !important;
|
|
1039
1064
|
}
|
|
@@ -1232,10 +1257,10 @@ import{ActionButton as e,ArrowRightIcon as t,BackIcon as n,BackgroundActionMenuB
|
|
|
1232
1257
|
border-color: ${$.darkBorder} !important;
|
|
1233
1258
|
}
|
|
1234
1259
|
|
|
1235
|
-
${e=>e.$side===`left`?
|
|
1260
|
+
${e=>e.$side===`left`?K`
|
|
1236
1261
|
left: 4.5rem;
|
|
1237
1262
|
transform: translateX(${e.$open?`0`:`-0.75rem`});
|
|
1238
|
-
`:
|
|
1263
|
+
`:K`
|
|
1239
1264
|
right: 4.5rem;
|
|
1240
1265
|
transform: translateX(${e.$open?`0`:`0.75rem`});
|
|
1241
1266
|
`}
|
|
@@ -1250,13 +1275,13 @@ import{ActionButton as e,ArrowRightIcon as t,BackIcon as n,BackgroundActionMenuB
|
|
|
1250
1275
|
min-width: 0;
|
|
1251
1276
|
transform: translateY(${e=>e.$open?`0`:`0.75rem`});
|
|
1252
1277
|
}
|
|
1253
|
-
`,
|
|
1278
|
+
`,Zu=G.div`
|
|
1254
1279
|
display: flex;
|
|
1255
1280
|
flex: 1;
|
|
1256
1281
|
min-width: 0;
|
|
1257
1282
|
height: 100%;
|
|
1258
1283
|
overflow: hidden;
|
|
1259
|
-
`,
|
|
1284
|
+
`,Qu=G.div`
|
|
1260
1285
|
display: flex;
|
|
1261
1286
|
flex-direction: column;
|
|
1262
1287
|
flex: 1;
|
|
@@ -1265,16 +1290,16 @@ import{ActionButton as e,ArrowRightIcon as t,BackIcon as n,BackgroundActionMenuB
|
|
|
1265
1290
|
max-width: 100%;
|
|
1266
1291
|
min-width: 0;
|
|
1267
1292
|
overflow: hidden;
|
|
1268
|
-
|
|
1293
|
+
`,$u=G.header`
|
|
1269
1294
|
//box-shadow: 0 3px 2px 0 rgba(0, 0, 0, 0.04), 0 1px 0 0 rgba(0, 0, 0, 0.17);
|
|
1270
1295
|
z-index: 200;
|
|
1271
|
-
`,
|
|
1296
|
+
`,ed=G.div`
|
|
1272
1297
|
background: #fff;
|
|
1273
|
-
`,
|
|
1298
|
+
`,td=G.div`
|
|
1274
1299
|
display: flex;
|
|
1275
1300
|
flex: 1 1 0;
|
|
1276
1301
|
min-height: 0;
|
|
1277
|
-
`,
|
|
1302
|
+
`,nd=G.div`
|
|
1278
1303
|
background: #fff;
|
|
1279
1304
|
display: flex;
|
|
1280
1305
|
flex-direction: column;
|
|
@@ -1282,18 +1307,18 @@ import{ActionButton as e,ArrowRightIcon as t,BackIcon as n,BackgroundActionMenuB
|
|
|
1282
1307
|
max-width: 720px;
|
|
1283
1308
|
align-items: flex-end;
|
|
1284
1309
|
|
|
1285
|
-
${e=>e.$motion?
|
|
1310
|
+
${e=>e.$motion?K`
|
|
1286
1311
|
transition: max-width 400ms;
|
|
1287
1312
|
`:``}
|
|
1288
1313
|
|
|
1289
|
-
${e=>{switch(e.$state){case`entering`:return
|
|
1314
|
+
${e=>{switch(e.$state){case`entering`:return K`
|
|
1290
1315
|
max-width: ${e.$width};
|
|
1291
|
-
`;case`exiting`:return
|
|
1316
|
+
`;case`exiting`:return K`
|
|
1292
1317
|
max-width: 0;
|
|
1293
|
-
`;case`unmounted`:case`exited`:return
|
|
1318
|
+
`;case`unmounted`:case`exited`:return K`
|
|
1294
1319
|
max-width: 0;
|
|
1295
1320
|
`}}}
|
|
1296
|
-
`,
|
|
1321
|
+
`,rd=G.div`
|
|
1297
1322
|
flex: 1 1 0;
|
|
1298
1323
|
background: #e3e7f0;
|
|
1299
1324
|
// background: #efefef;
|
|
@@ -1312,7 +1337,7 @@ import{ActionButton as e,ArrowRightIcon as t,BackIcon as n,BackgroundActionMenuB
|
|
|
1312
1337
|
> * {
|
|
1313
1338
|
min-width: 0;
|
|
1314
1339
|
}
|
|
1315
|
-
`,
|
|
1340
|
+
`,id=G.div`
|
|
1316
1341
|
background: #fff;
|
|
1317
1342
|
display: flex;
|
|
1318
1343
|
flex-direction: column;
|
|
@@ -1321,14 +1346,14 @@ import{ActionButton as e,ArrowRightIcon as t,BackIcon as n,BackgroundActionMenuB
|
|
|
1321
1346
|
|
|
1322
1347
|
${e=>e.$motion?`transition: max-width 400ms;`:``}
|
|
1323
1348
|
|
|
1324
|
-
${e=>{switch(e.$state){case`entering`:return
|
|
1349
|
+
${e=>{switch(e.$state){case`entering`:return K`
|
|
1325
1350
|
max-width: ${e.$width};
|
|
1326
|
-
`;case`exiting`:return
|
|
1351
|
+
`;case`exiting`:return K`
|
|
1327
1352
|
max-width: 0;
|
|
1328
|
-
`;case`unmounted`:case`exited`:return
|
|
1353
|
+
`;case`unmounted`:case`exited`:return K`
|
|
1329
1354
|
max-width: 0;
|
|
1330
1355
|
`}}}
|
|
1331
|
-
`,
|
|
1356
|
+
`,ad=G.div`
|
|
1332
1357
|
display: flex;
|
|
1333
1358
|
flex: 1;
|
|
1334
1359
|
height: 100%;
|
|
@@ -1336,28 +1361,28 @@ import{ActionButton as e,ArrowRightIcon as t,BackIcon as n,BackgroundActionMenuB
|
|
|
1336
1361
|
transition: min-width 400ms;
|
|
1337
1362
|
overflow: hidden;
|
|
1338
1363
|
|
|
1339
|
-
${e=>{switch(e.$menu){case`top`:return
|
|
1364
|
+
${e=>{switch(e.$menu){case`top`:return K`
|
|
1340
1365
|
flex-direction: column;
|
|
1341
|
-
${
|
|
1366
|
+
${od} {
|
|
1342
1367
|
flex-direction: column;
|
|
1343
1368
|
}
|
|
1344
|
-
`;case`left`:return
|
|
1369
|
+
`;case`left`:return K`
|
|
1345
1370
|
flex-direction: row;
|
|
1346
|
-
${
|
|
1371
|
+
${od} {
|
|
1347
1372
|
flex-direction: row;
|
|
1348
1373
|
}
|
|
1349
|
-
`;default:case`bottom`:return
|
|
1374
|
+
`;default:case`bottom`:return K`
|
|
1350
1375
|
flex-direction: column-reverse;
|
|
1351
|
-
${
|
|
1376
|
+
${od} {
|
|
1352
1377
|
flex-direction: column;
|
|
1353
1378
|
}
|
|
1354
|
-
`;case`right`:return
|
|
1379
|
+
`;case`right`:return K`
|
|
1355
1380
|
flex-direction: row-reverse;
|
|
1356
|
-
${
|
|
1381
|
+
${od} {
|
|
1357
1382
|
flex-direction: row;
|
|
1358
1383
|
}
|
|
1359
1384
|
`}}}
|
|
1360
|
-
`;
|
|
1385
|
+
`;G.div`
|
|
1361
1386
|
background: #fff;
|
|
1362
1387
|
border-top: 1px solid #e3e7f0;
|
|
1363
1388
|
border-right: 1px solid #e3e7f0;
|
|
@@ -1367,7 +1392,7 @@ import{ActionButton as e,ArrowRightIcon as t,BackIcon as n,BackgroundActionMenuB
|
|
|
1367
1392
|
/* width: 3.35em;
|
|
1368
1393
|
padding: 0.3em;
|
|
1369
1394
|
gap: 0.3em; */
|
|
1370
|
-
`,
|
|
1395
|
+
`,G.button`
|
|
1371
1396
|
cursor: pointer;
|
|
1372
1397
|
aspect-ratio: 1;
|
|
1373
1398
|
width: 3em;
|
|
@@ -1394,32 +1419,32 @@ import{ActionButton as e,ArrowRightIcon as t,BackIcon as n,BackgroundActionMenuB
|
|
|
1394
1419
|
font-size: 1.5em;
|
|
1395
1420
|
color: #999;
|
|
1396
1421
|
}
|
|
1397
|
-
`;const
|
|
1422
|
+
`;const od=G.div`
|
|
1398
1423
|
display: flex;
|
|
1399
1424
|
box-shadow:
|
|
1400
1425
|
0 -3px 2px 0 rgba(0, 0, 0, 0.04),
|
|
1401
1426
|
0 -1px 0 0 rgba(0, 0, 0, 0.17);
|
|
1402
1427
|
|
|
1403
|
-
${e=>!e.$open&&(e.$position===`top`||e.$position===`bottom`)?
|
|
1428
|
+
${e=>!e.$open&&(e.$position===`top`||e.$position===`bottom`)?K`
|
|
1404
1429
|
display: none;
|
|
1405
1430
|
`:``}
|
|
1406
|
-
`,
|
|
1431
|
+
`,sd=G.div`
|
|
1407
1432
|
display: flex;
|
|
1408
1433
|
flex-direction: column;
|
|
1409
1434
|
flex: 1;
|
|
1410
1435
|
min-width: 0;
|
|
1411
1436
|
overflow: hidden;
|
|
1412
|
-
`;function
|
|
1437
|
+
`;function cd(e,t,n){return e.filter(e=>{if(!e.supports)return!0;try{return e.supports(t)}catch(t){return n?.(e,t),!1}})}function ld(e,t){return t?e.some(e=>e.id===t)?t:e[0]?.id||null:null}function ud(e){return e.map(e=>e.id).join(`,`)}function dd(e){let t=e?.resource;return t?.source?.type||t?.type||null}const fd=Ae(function(e){let{resolveMessage:t}=H(),n=U(`shell`),r=X(),i=aa(),a=_a(),o=Da(),{vault:s}=P(Je),c=s||void 0,l=nt(e=>e.iiif),{loading:u,state:d,leftPanels:f,centerPanels:p,rightPanels:m,modals:h=[],actions:g}=o,_=e.isLoading||!1,v=I(()=>({rootResource:a,vault:c,app:r,layoutState:d,appState:i}),[a,c,r,d,i,l]),b=I(()=>cd(f,v,(e,t)=>{console.error(`Layout panel "${e.id}" failed support check`,t)}).filter(e=>!e.focusedMode?.hide),[f,v]),x=I(()=>cd(p,v,(e,t)=>{console.error(`Layout panel "${e.id}" failed support check`,t)}),[p,v]),S=I(()=>cd(m,v,(e,t)=>{console.error(`Layout panel "${e.id}" failed support check`,t)}).filter(e=>!e.focusedMode?.hide),[m,v]),C=I(()=>cd(h,v,(e,t)=>{console.error(`Layout panel "${e.id}" failed support check`,t)}),[h,v]),ee=I(()=>b.filter(e=>e.modal),[b]),w=I(()=>b.filter(e=>!e.modal),[b]),T=I(()=>[...C,...ee],[C,ee]),E=I(()=>({...o,leftPanels:b,centerPanels:x,rightPanels:S,modals:T}),[o,b,x,S,T]),D=w.find(e=>e.id===d.leftPanel.current),O=S.find(e=>e.id===d.rightPanel.current),k=x.find(e=>e.id===d.centerPanel.current),A=T.find(e=>e.id===d.modal.current),ne=d.modal.open&&ee.some(e=>e.id===d.modal.current)?d.modal.current:d.leftPanel.current,re=d.pinnedRightPanel.pinned?S.find(e=>e.id===d.pinnedRightPanel.current):void 0,ie=O&&(re?.id!==O.id||!It(d.pinnedRightPanel.state,d.rightPanel.state)),ae=I(()=>({rootResource:a,vault:c,app:r,layoutState:d,appState:i,actions:g}),[a,c,r,d,i,g]),oe=e=>{e.focusedMode?.onSelect?.(ae)},se=!D||D.focusedMode?.closeOnMainPanelClick!==!1,[j]=Du([`(max-width: 1020px)`]),ce=I(()=>(o.background||[]).map((e,t)=>B(Te,{children:e.render()},t)),[o.background]);Ne(()=>{S.length&&g.rightPanel.change({id:S[0].id}),w.length&&g.leftPanel.change({id:w[0].id}),x.length&&g.centerPanel.change({id:x[0].id}),g.leftPanel.close(),g.rightPanel.close()},[]),Ne(()=>{if(k&&k.onMount)return k.onMount(d.centerPanel.state||k.defaultState||{},{...E,current:g.centerPanel,vault:c},i)},[d.centerPanel.current,k?.id]),Ne(()=>{j&&d.leftPanel.open&&d.rightPanel.open&&g.rightPanel.close()},[j,d.leftPanel.open,d.rightPanel.open]),Ne(()=>{if(!d.leftPanel.open||!d.leftPanel.current)return;let e=b.find(e=>e.id===d.leftPanel.current);e?.focusedMode?.onSelect&&oe(e)},[d.leftPanel.open,d.leftPanel.current,ud(b)]),Ne(()=>{if(d.leftPanel.current&&!D){let e=ld(w,d.leftPanel.current);e?g.leftPanel.change({id:e}):g.leftPanel.close()}if(d.centerPanel.current&&!k){let e=ld(x,d.centerPanel.current);e?g.centerPanel.change({id:e}):g.centerPanel.close()}if(d.rightPanel.current&&!O){let e=ld(S,d.rightPanel.current);e?g.rightPanel.change({id:e}):g.rightPanel.close()}if(d.modal.current&&!A){let e=ld(T,d.modal.current);e?g.modal.change({id:e}):g.modal.close()}},[d.leftPanel.current,d.centerPanel.current,d.rightPanel.current,d.modal.current,D?.id,k?.id,O?.id,A?.id,ud(w),ud(x),ud(S),ud(T)]),Eu(`layout.edit`,e=>{dd(e)===`Canvas`&&!d.rightPanel.open||(S.find(e=>e.id===`@manifest-editor/editor`)?g.rightPanel.open({id:`@manifest-editor/editor`,stacked:!0}):O&&g.rightPanel.open())},[ud(S),O?.id,d.rightPanel.open]);let le=`4.5rem`,ue=`${Xc({options:D?.options,fallback:340})}px`,de=`${Xc({options:O?.options,fallback:420})}px`,fe={"--manifest-editor-layout-left-sidebar-small":le,"--manifest-editor-layout-left-sidebar-large":d.leftPanel.open?`calc(${le} + ${ue})`:le,"--manifest-editor-layout-right-sidebar-small":le,"--manifest-editor-layout-right-sidebar-large":d.rightPanel.open?`calc(${le} + ${de})`:le};return Ne(()=>{if(typeof document>`u`)return;let e=document.documentElement,t=Object.keys(fe).map(t=>[t,e.style.getPropertyValue(t)]);for(let[t,n]of Object.entries(fe))e.style.setProperty(t,n);return()=>{for(let[n,r]of t)r?e.style.setProperty(n,r):e.style.removeProperty(n)}},[ue,de,d.leftPanel.open,d.rightPanel.open]),u?null:B(Sa.Provider,{value:`focused`,children:V(Qu,{id:e.htmlId||`manifest-editor-container`,className:`manifest-editor ${e.className||``}`,"data-layout-mode":`focused`,style:fe,children:[e.hideHeader?null:V($u,{children:[e.header||null,e.menu?B(`menu`,{children:e.menu}):null]}),V(Uu,{children:[B(Wu,{onClick:()=>{se&&g.leftPanel.close()},children:V(ad,{$menu:e.centerPanelMenuPosition||`top`,children:[e.centerPanelMenu?B(od,{$open:d.centerPanel.open,$position:e.centerPanelMenuPosition||`top`,children:e.centerPanelMenu}):null,B(sd,{children:B(Mt,{resetKeys:[k?.id],FallbackComponent:Qc,children:_?B(Gu,{children:B(Iu,{stroke:`rgba(0,0,0,.3)`,fontSize:`2em`})}):d.centerPanel.open&&k?Zc(k.render(d.centerPanel.state||k.defaultState||{},{...E,current:g.centerPanel,vault:c},i)):null})})]})}),!x.length&&!b.length?null:V(Ku,{$side:`left`,"aria-label":n(`panels.mainAndLeft`),children:[x.length?B(Ju,{"aria-label":n(`panels.main`),children:x.filter(e=>!e.focusedMode?.hide).map(e=>V(ge,{placement:`right`,children:[B(_e,{asChild:!0,children:B(qu,{type:`button`,"aria-label":t(e?.labelMessage,e.label),"data-selected":d.centerPanel.current===e.id,onClick:()=>{g.centerPanel.open({id:e.id}),g.leftPanel.close(),g.rightPanel.close(),oe(e)},children:e.icon||t(e?.labelMessage,e.label).slice(0,1)})}),B(y,{children:t(e?.labelMessage,e.label)})]},e.id))}):null,x.length&&b.length?B(Yu,{}):null,b.length?B(Ju,{"aria-label":n(`panels.left`),children:b.map(e=>V(ge,{placement:`right`,children:[B(_e,{asChild:!0,children:B(qu,{type:`button`,"aria-label":t(e?.labelMessage,e.label),"data-selected":ne===e.id,onClick:()=>{if(e.modal){j&&g.rightPanel.close(),d.modal.open&&d.modal.current===e.id?g.modal.close():(g.modal.open({id:e.id,state:e.defaultState}),oe(e));return}j&&g.rightPanel.close(),d.leftPanel.current===e.id?g.leftPanel.toggle():g.leftPanel.open({id:e.id})},children:e.icon||t(e?.labelMessage,e.label).slice(0,1)})}),B(y,{children:t(e?.labelMessage,e.label)})]},e.id))}):null]}),((e,n,r)=>{if(!n.length)return null;let i=e===`left`?g.leftPanel:g.rightPanel;return B(Ku,{$side:e,"aria-label":`${e} panels`,children:n.map(n=>V(ge,{placement:e===`left`?`right`:`left`,children:[B(_e,{asChild:!0,children:B(qu,{type:`button`,"aria-label":t(n?.labelMessage,n.label),"data-selected":r===n.id,onClick:()=>{j&&(e===`left`?g.rightPanel.close():g.leftPanel.close()),r===n.id?i.toggle():i.open({id:n.id})},children:n.icon||t(n?.labelMessage,n.label).slice(0,1)})}),B(y,{children:t(n?.labelMessage,n.label)})]},n.id))})})(`right`,S,d.rightPanel.current),w.length>0?B(Xu,{$side:`left`,$open:d.leftPanel.open,style:{width:ue,minWidth:D?.options?.minWidth,maxWidth:D?.options?.maxWidth},children:B(Zu,{children:_?B(sd,{children:B(Ru,{})}):V(z,{children:[e.leftPanelMenu?B(od,{$open:d.leftPanel.open,$position:e.leftPanelMenuPosition||`bottom`,children:e.leftPanelMenu}):null,B(sd,{children:D?B(sl,{isLeft:!0,panel:D,state:d.leftPanel,actions:g.leftPanel}):null})]})})}):null,S.length>0?B(Xu,{$side:`right`,$open:d.rightPanel.open,style:{width:de,minWidth:O?.options?.minWidth,maxWidth:O?.options?.maxWidth},children:B(Zu,{children:_?B(sd,{children:B(Ru,{})}):V(z,{children:[e.rightPanelMenu?B(od,{$open:d.rightPanel.open,$position:e.rightPanelMenuPosition||`bottom`,children:e.rightPanelMenu}):null,V(sd,{children:[ie?B(sl,{panel:O,state:d.rightPanel,actions:g.rightPanel,pinActions:g.pinnedRightPanel,available:S}):null,re?B(sl,{panel:re,state:d.pinnedRightPanel,actions:g.pinnedRightPanel,close:g.rightPanel.close}):null]})]})})}):null]}),B(ed,{children:e.footer||null}),B(`div`,{className:`hidden`,children:ce}),B(Js,{}),B(Xs,{}),B(z,{children:A?B(te,{title:t(A?.labelMessage,A.label),open:d.modal.open,onClose:()=>g.modal.close(),children:A.modal?B(`div`,{className:`h-[70vh] min-h-[60vh] max-h-full flex w-full`,children:B(sl,{isLeft:!0,isModal:!0,noHeader:!0,panel:A,state:d.modal,actions:g.modal})}):Zc(A.render(d.modal.state||A.defaultState||{},{...E,current:g.modal,vault:c,isModal:!0},i))}):null}),B(bc,{})]})})}),pd=G.div`
|
|
1413
1438
|
position: relative;
|
|
1414
1439
|
display: flex;
|
|
1415
1440
|
flex: 1;
|
|
1416
1441
|
overflow: hidden;
|
|
1417
1442
|
flex-direction: column;
|
|
1418
|
-
`,
|
|
1443
|
+
`,md=G.div`
|
|
1419
1444
|
flex: 1;
|
|
1420
1445
|
position: relative;
|
|
1421
1446
|
z-index: 7;
|
|
1422
|
-
`,
|
|
1447
|
+
`,hd=G.div`
|
|
1423
1448
|
display: flex;
|
|
1424
1449
|
gap: 0.5rem;
|
|
1425
1450
|
width: 100%;
|
|
@@ -1428,7 +1453,7 @@ import{ActionButton as e,ArrowRightIcon as t,BackIcon as n,BackgroundActionMenuB
|
|
|
1428
1453
|
padding: 0.5rem;
|
|
1429
1454
|
min-height: 4rem;
|
|
1430
1455
|
z-index: 9;
|
|
1431
|
-
`,
|
|
1456
|
+
`,gd=G.button`
|
|
1432
1457
|
flex: 1;
|
|
1433
1458
|
min-width: 0;
|
|
1434
1459
|
padding: 0.75rem 1rem;
|
|
@@ -1439,11 +1464,11 @@ import{ActionButton as e,ArrowRightIcon as t,BackIcon as n,BackgroundActionMenuB
|
|
|
1439
1464
|
overflow: hidden;
|
|
1440
1465
|
text-overflow: ellipsis;
|
|
1441
1466
|
white-space: nowrap;
|
|
1442
|
-
`,
|
|
1467
|
+
`,_d=G.div`
|
|
1443
1468
|
display: flex;
|
|
1444
1469
|
flex: 1;
|
|
1445
1470
|
min-width: 0;
|
|
1446
|
-
`,
|
|
1471
|
+
`,vd=G.button`
|
|
1447
1472
|
display: flex;
|
|
1448
1473
|
align-items: center;
|
|
1449
1474
|
justify-content: center;
|
|
@@ -1463,7 +1488,7 @@ import{ActionButton as e,ArrowRightIcon as t,BackIcon as n,BackgroundActionMenuB
|
|
|
1463
1488
|
flex: 0 0 auto;
|
|
1464
1489
|
font-size: 1.25em;
|
|
1465
1490
|
}
|
|
1466
|
-
`,
|
|
1491
|
+
`,yd=G.div`
|
|
1467
1492
|
background: #fff;
|
|
1468
1493
|
display: flex;
|
|
1469
1494
|
position: absolute;
|
|
@@ -1481,20 +1506,20 @@ import{ActionButton as e,ArrowRightIcon as t,BackIcon as n,BackgroundActionMenuB
|
|
|
1481
1506
|
transition:
|
|
1482
1507
|
0.3s transform ease-in-out,
|
|
1483
1508
|
0.3s box-shadow;
|
|
1484
|
-
${e=>e.$open&&
|
|
1509
|
+
${e=>e.$open&&K`
|
|
1485
1510
|
box-shadow:
|
|
1486
1511
|
-5px 0 15px 0 rgba(0, 0, 0, 0.1),
|
|
1487
1512
|
-3px 0 5px 0 rgba(0, 0, 0, 0.1);
|
|
1488
1513
|
transform: translateX(0);
|
|
1489
1514
|
`}
|
|
1490
1515
|
|
|
1491
|
-
${
|
|
1516
|
+
${nl} {
|
|
1492
1517
|
box-shadow: none;
|
|
1493
1518
|
padding-left: 0.5em;
|
|
1494
1519
|
padding-right: 0.5em;
|
|
1495
1520
|
font-size: 1.1em;
|
|
1496
1521
|
}
|
|
1497
|
-
`,
|
|
1522
|
+
`,bd=G.div`
|
|
1498
1523
|
display: flex;
|
|
1499
1524
|
flex-direction: column;
|
|
1500
1525
|
position: absolute;
|
|
@@ -1507,10 +1532,10 @@ import{ActionButton as e,ArrowRightIcon as t,BackIcon as n,BackgroundActionMenuB
|
|
|
1507
1532
|
z-index: 10;
|
|
1508
1533
|
overflow: hidden;
|
|
1509
1534
|
transition: 0.5s transform;
|
|
1510
|
-
${e=>e.$open&&
|
|
1535
|
+
${e=>e.$open&&K`
|
|
1511
1536
|
transform: translateX(0);
|
|
1512
1537
|
`}
|
|
1513
|
-
`,
|
|
1538
|
+
`,xd=G.button`
|
|
1514
1539
|
border: 0;
|
|
1515
1540
|
background: rgba(0, 0, 0, 0.4);
|
|
1516
1541
|
pointer-events: none;
|
|
@@ -1523,10 +1548,10 @@ import{ActionButton as e,ArrowRightIcon as t,BackIcon as n,BackgroundActionMenuB
|
|
|
1523
1548
|
opacity: 0;
|
|
1524
1549
|
transition: opacity 0.5s;
|
|
1525
1550
|
|
|
1526
|
-
${e=>e.$open&&
|
|
1551
|
+
${e=>e.$open&&K`
|
|
1527
1552
|
pointer-events: visible;
|
|
1528
1553
|
opacity: 1;
|
|
1529
1554
|
`}
|
|
1530
|
-
`,hu=we(function(e){if(e.layoutMode===`focused`)return B(au,{...e});let t=Y(),n=Si(),r=Hi(),i=Ya(),{vault:a}=N(Le),o=a||void 0,s=Ge(e=>e.iiif),c=L(null),l=L(null),{loading:u,state:d,leftPanels:f,centerPanels:p,rightPanels:m,modals:h=[],actions:g}=i,_=I(()=>({rootResource:r,vault:o,app:t,layoutState:d,appState:n}),[r,o,t,d,n,s]),v=I(()=>tu(f,_,(e,t)=>{console.error(`Layout panel "${e.id}" failed support check`,t)}),[f,_]),y=I(()=>tu(p,_,(e,t)=>{console.error(`Layout panel "${e.id}" failed support check`,t)}),[p,_]),b=I(()=>tu(m,_,(e,t)=>{console.error(`Layout panel "${e.id}" failed support check`,t)}),[m,_]),x=I(()=>tu(h,_,(e,t)=>{console.error(`Layout panel "${e.id}" failed support check`,t)}),[h,_]),S=I(()=>v.filter(e=>e.modal),[v]),C=I(()=>v.filter(e=>!e.modal),[v]),w=I(()=>[...x,...S],[x,S]),T=I(()=>({...i,leftPanels:v,centerPanels:y,rightPanels:b,modals:w}),[i,v,y,b,w]),E=C.find(e=>e.id===d.leftPanel.current),D=b.find(e=>e.id===d.rightPanel.current),O=y.find(e=>e.id===d.centerPanel.current),te=w.find(e=>e.id===d.modal.current),ne=d.modal.open&&S.some(e=>e.id===d.modal.current)?d.modal.current:d.leftPanel.current,re=d.pinnedRightPanel.pinned?b.find(e=>e.id===d.pinnedRightPanel.current):void 0,[ie]=bl([`(max-width: 1020px)`]),ae=e.isLoading||!1,oe=I(()=>(i.background||[]).map((e,t)=>B(ye,{children:e.render()},t)),[i.background]),A=Fl(`left-panel/${E?.id}`,{left:!0,marginLeft:60,minWidthPx:E?.options?.minWidth||200,maxWidthPx:E?.options?.maxWidth||720,loading:u}),se=Fl(`right-panel/${D?.id}`,{left:!1,minWidthPx:D?.options?.minWidth||320,maxWidthPx:D?.options?.maxWidth||720,loading:u}),ce=D&&(re?.id!==D.id||!ht(d.pinnedRightPanel.state,d.rightPanel.state)),le=A.widthB===`auto`?void 0:()=>A.setWidths({widthA:`auto`,widthB:zs({options:E?.options,fallback:320})}),ue=se.widthB===`auto`?void 0:()=>se.setWidths({widthA:`auto`,widthB:zs({options:D?.options,fallback:320})});if(F(()=>{ie&&d.leftPanel.open&&d.rightPanel.open&&(g.leftPanel.close(),g.rightPanel.close())},[ie]),F(()=>{if(O&&O.onMount)return O.onMount(d.centerPanel.state||O.defaultState||{},{...T,current:g.centerPanel,vault:o},n)},[d.centerPanel.current,O?.id]),F(()=>{if(d.leftPanel.current&&!E){let e=nu(C,d.leftPanel.current);e?g.leftPanel.change({id:e}):g.leftPanel.close()}if(d.centerPanel.current&&!O){let e=nu(y,d.centerPanel.current);e?g.centerPanel.change({id:e}):g.centerPanel.close()}if(d.rightPanel.current&&!D){let e=nu(b,d.rightPanel.current);e?g.rightPanel.change({id:e}):g.rightPanel.close()}if(d.modal.current&&!te){let e=nu(w,d.modal.current);e?g.modal.change({id:e}):g.modal.close()}},[d.leftPanel.current,d.centerPanel.current,d.rightPanel.current,d.modal.current,E?.id,O?.id,D?.id,te?.id,ru(C),ru(y),ru(b),ru(w)]),F(()=>{b.length&&g.rightPanel.change({id:b[0].id}),C.length&&g.leftPanel.change({id:C[0].id}),y.length&&g.centerPanel.change({id:y[0].id})},[]),u)return null;let de=t=>B(Ql,{$menu:e.leftPanelMenuPosition||`bottom`,ref:A.refs.resizableDiv,className:[`manifest-editor`,t?`transition transition-${t}`:``].join(` `),style:{width:d.leftPanel.open||t!==`exited`?A.widthB:void 0,minWidth:E?.options?.minWidth},children:ae?B(eu,{children:B(jl,{})}):V(z,{children:[e.leftPanelMenu?B($l,{$open:d.leftPanel.open&&t!==`exited`,$position:e.leftPanelMenuPosition||`bottom`,children:e.leftPanelMenu}):null,B(eu,{children:d.leftPanel.open||t!==`exited`?B(z,{children:E?B(Xs,{isLeft:!0,noHeader:!0,transition:t,panel:E,state:d.leftPanel,actions:g.leftPanel}):null}):null})]})}),fe=()=>te?B(ee,{title:te.label,open:d.modal.open,onClose:()=>g.modal.close(),children:te.modal?B(`div`,{className:`h-[70vh] min-h-[60vh] max-h-full flex w-full`,children:B(Xs,{isLeft:!0,isModal:!0,noHeader:!0,panel:te,state:d.modal,actions:g.modal})}):Bs(te.render(d.modal.state||te.defaultState||{},{...T,current:g.modal,vault:o,isModal:!0},n))}):null,pe=()=>V(Ql,{$menu:e.centerPanelMenuPosition||`top`,children:[e.centerPanelMenu?B($l,{$open:d.centerPanel.open,$position:e.centerPanelMenuPosition||`top`,children:e.centerPanelMenu}):null,B(eu,{children:B(at,{resetKeys:[O?.id],FallbackComponent:Vs,children:ae?B(`div`,{style:{display:`flex`,flex:1,justifyContent:`center`,alignItems:`center`},children:B(kl,{stroke:`rgba(0,0,0,.3)`,fontSize:`2em`})}):d.centerPanel.open&&O?Bs(O.render(d.centerPanel.state||O.defaultState||{},{...T,current:g.centerPanel,vault:o},n)):null})})]}),me=t=>B(Ql,{$menu:e.rightPanelMenuPosition||`bottom`,ref:se.refs.resizableDiv,className:t?`transition transition-${t}`:``,style:{width:d.rightPanel.open||t!==`exited`?se.widthB:void 0,minWidth:D?.options?.minWidth},children:ae?B(eu,{children:B(jl,{})}):V(z,{children:[e.rightPanelMenu?B($l,{$open:d.rightPanel.open,$position:e.rightPanelMenuPosition||`bottom`,children:e.rightPanelMenu}):null,B(eu,{children:d.rightPanel.open||t!==`exited`?V(z,{children:[ce?B(Xs,{panel:D,state:d.rightPanel,actions:g.rightPanel,pinActions:g.pinnedRightPanel,available:b}):null,re?B(Xs,{panel:re,state:d.pinnedRightPanel,actions:g.pinnedRightPanel,close:g.rightPanel.close}):null]}):null})]})});return ie?V(Gl,{children:[e.hideHeader?null:V(Kl,{children:[e.header||null,e.menu?B(`menu`,{children:e.menu}):null]}),B(Jl,{children:V(ou,{children:[V(cu,{children:[C.length>0?B(lu,{type:`button`,"aria-expanded":d.leftPanel.open,onClick:()=>{g.rightPanel.close(),g.leftPanel.toggle()},children:E?.label}):null,b.length>0?B(uu,{children:V(du,{type:`button`,"aria-expanded":d.rightPanel.open,onClick:()=>{g.leftPanel.close(),g.rightPanel.toggle()},children:[B(Fi,{"aria-hidden":`true`,rotate:90}),D?.label]})}):null]}),B(su,{children:pe()}),b.length>0?B(fu,{$open:d.rightPanel.open,children:me()}):null,C.length>0?V(pu,{$open:d.leftPanel.open,children:[B(`nav`,{"aria-label":`Left panel tabs`,className:`flex flex-none overflow-x-auto border-b border-gray-300`,children:C.map(e=>V(`button`,{type:`button`,"aria-pressed":d.leftPanel.current===e.id,className:`flex flex-1 shrink-0 items-center justify-center gap-1.5 border-0 border-b-[3px] p-3 text-gray-700 [&>svg]:shrink-0 [&>svg]:text-xl ${d.leftPanel.current===e.id?`border-b-[#b83265] bg-[#f9e8ef]`:`border-b-transparent bg-white`}`,onClick:()=>{g.rightPanel.close(),g.leftPanel.open({id:e.id,state:e.defaultState})},children:[e.icon,e.label]},e.id))}),de()]}):null,v.length>0||b.length>0?B(mu,{type:`button`,"aria-label":`Close panels`,$open:d.leftPanel.open||d.rightPanel.open,onClick:()=>{g.leftPanel.close(),g.rightPanel.close()}}):null]})}),B(`div`,{className:`hidden`,children:oe}),B(Lo,{}),B(Ro,{}),B(z,{children:fe()}),B(us,{})]}):V(Gl,{id:e.htmlId||`manifest-editor-container`,className:`manifest-editor ${e.className||``}`,children:[e.hideHeader?null:V(Kl,{children:[e.header||null,e.menu?B(`menu`,{children:e.menu}):null]}),V(Jl,{ref:e=>{A.refs.container.current=e,se.refs.container.current=e},children:[v.length>0?B(k,{current:ne,items:v.map(e=>({id:e.id,label:e.label,icon:e.icon,divide:e.divide,separator:e.separator,onClick:()=>{if(e.modal){d.modal.open&&d.modal.current===e.id?g.modal.close():g.modal.open({id:e.id,state:e.defaultState});return}d.leftPanel.current===e.id?g.leftPanel.toggle():g.leftPanel.change({id:e.id})}})),open:d.leftPanel.open}):null,C.length>0?B(mt,{nodeRef:c,in:d.leftPanel.open,timeout:400,unmountOnExit:!1,children:e=>V(z,{children:[B(Yl,{ref:c,$width:A.widthB,$state:e,$motion:!0,children:de(e)}),B(Ol,{ref:A.refs.resizer,reset:le,dir:`left`,transition:e,open:d.leftPanel.open||e!==`exited`,actions:g.leftPanel})]})}):null,B(Xl,{children:pe()}),b.length>0?B(mt,{nodeRef:l,in:d.rightPanel.open,timeout:400,unmountOnExit:!1,children:e=>V(z,{children:[B(Ol,{ref:se.refs.resizer,dir:`right`,reset:ue,open:d.rightPanel.open,actions:g.rightPanel}),B(Zl,{ref:l,$width:se.widthB,$state:e,$motion:!0,children:me(e)})]})}):null]}),B(ql,{children:e.footer||null}),B(`div`,{className:`hidden`,children:oe}),B(Lo,{}),B(Ro,{}),B(z,{children:fe()}),B(us,{})]})});function gu(e,t){function n(){t({type:`popStack`,panel:e,payload:void 0})}function r(n){t({type:`change`,panel:e,payload:n})}function i(n){t({type:`open`,panel:e,payload:n})}function a(){t({type:`close`,panel:e,payload:void 0})}function o(){t({type:`toggle`,panel:e,payload:void 0})}function s(){t({type:`minimise`,panel:e,payload:void 0})}function c(n){t({type:`maximise`,panel:e,payload:n})}function l(n){t({type:`setCustomWidth`,panel:e,payload:n})}function u(){t({type:`resetSize`,panel:e,payload:void 0})}function d(n){t({type:`pin`,panel:e,payload:n})}function f(){t({type:`unpin`,panel:e,payload:void 0})}return I(()=>({popStack:n,change:r,open:i,close:a,toggle:o,minimise:s,maximise:c,setCustomWidth:l,resetSize:u,pin:d,unpin:f}),[])}function _u(e,t){if(t.payload&&t.payload.stacked){if(e.current){let n=e.stack[e.stack.length-1];if(n&&n.id===e.current)return;t.payload.unique&&(e.stack=e.stack.filter(t=>t.id!==e.current)),e.stack.push({id:e.current,state:e.state?{...Ye(e.state)}:{}})}}else e.stack=[]}function vu(e,t){switch(t.type){case`popStack`:if(e.stack.length){let t=e.stack[e.stack.length-1];t&&(e.current=t.id,e.state=t.state),e.stack=e.stack.slice(0,-1)}break;case`change`:t.payload.id!==e.current&&_u(e,t),e.state=t.payload.state,e.current=t.payload.id;break;case`close`:e.open=!1;break;case`open`:e.open=!0,t.payload&&(t.payload.id!==e.current&&_u(e,t),e.state=t.payload.state,e.current=t.payload.id);break;case`toggle`:e.open=!e.open;break;case`maximise`:e.minimised=!1,t.payload&&(e.state=t.payload.state,e.current=t.payload.id);break;case`minimise`:e.minimised=!0;break;case`setCustomWidth`:e.customWidth=t.payload;break;case`resetSize`:e.customWidth=void 0}if(Rs(e))switch(t.type){case`pin`:e.pinned=!0,e.state=t.payload.state,e.current=t.payload.id;break;case`unpin`:e.pinned=!1,e.state=void 0}}const yu=Xe((e,t)=>{switch(t.panel){case`centerPanel`:vu(e.centerPanel,t);break;case`leftPanel`:vu(e.leftPanel,t);break;case`rightPanel`:vu(e.rightPanel,t);break;case`modal`:vu(e.modal,t);break;case`pinnedRightPanel`:vu(e.pinnedRightPanel,t)}});function bu(){return{customWidth:void 0,minimised:!1,open:!0,current:null,state:null,stack:[]}}function xu(){return{leftPanel:bu(),centerPanel:bu(),rightPanel:bu(),modal:bu(),pinnedRightPanel:{...bu(),pinnable:!0,pinned:!1}}}function Su({className:e,variant:t=`light`}){let n=Ue(),r=H(),{edit:i}=Ka(),a=ja(),o=Ma(),s=n?.items||[],c=n?.viewingDirection===`right-to-left`||n?.viewingDirection===`bottom-to-top`,l=n?.viewingDirection===`top-to-bottom`||n?.viewingDirection===`bottom-to-top`,u=Cu(a)||o.map(Cu).find(Boolean)||s[0]?.id||``,d=Math.max(0,s.findIndex(e=>e.id===u)),f=s[d]?.id||``,p=d+1,m=I(()=>s.map((e,t)=>{let n=r.get({id:e.id,type:`Canvas`});return{id:e.id,pageNumber:t+1,labelText:$e(n?.label)||`Page ${t+1}`}}),[s,r]),h=e=>{let t=s.findIndex(t=>t.id===e),r=s[t];!r||!n||i({id:r.id,type:`Canvas`},{parent:{id:n.id,type:`Manifest`},property:`items`,index:t},{forceOpen:!1})};if(!n||s.length<2)return B(`div`,{});let g=s[d-1],_=s[d+1],v=t===`dark`;return V(`nav`,{"aria-label":`Manifest pagination`,className:Du(`inline-flex shrink-0 items-center gap-1 rounded-full border px-1.5 py-1`,`focus-within:ring-2 focus-within:ring-me-primary-500/40`,c&&`flex-row-reverse`,v?`border-white/20 bg-white/10 text-white`:`border-me-gray-300 bg-white text-me-gray-900`,e),children:[B(wu,{ariaLabel:`Previous canvas`,disabled:!g,onClick:()=>g&&h(g.id),dark:v,children:B(Tu,{reverse:c,vertical:l})}),V(`label`,{htmlFor:`manifest-pagination-page-select`,"aria-label":`Page ${p} of ${s.length}`,className:Du(`relative inline-flex min-h-8 cursor-pointer select-none items-center gap-0.5`,`whitespace-nowrap rounded-full border px-2.5 text-xs font-semibold leading-none`,`focus-within:outline-none focus-within:ring-2 focus-within:ring-me-primary-500/40`,v?`border-white/20 bg-white/10 text-white hover:bg-white/15`:`border-me-gray-300 bg-me-gray-100 text-me-gray-900 hover:bg-me-primary-50`),children:[V(`span`,{children:[p,` / `,s.length]}),B(Eu,{className:Du(`shrink-0 text-base`,v?`text-white/60`:`text-me-gray-500`)}),B(`select`,{id:`manifest-pagination-page-select`,"aria-label":`Jump to canvas`,value:f,onChange:e=>h(e.target.value),className:`absolute inset-0 cursor-pointer appearance-none border-0 bg-white opacity-0`,children:m.map(e=>V(`option`,{value:e.id,children:[`Page `,e.pageNumber,` - `,e.labelText]},e.id))})]}),B(wu,{ariaLabel:`Next canvas`,disabled:!_,onClick:()=>_&&h(_.id),dark:v,children:B(Tu,{reverse:!c,vertical:l})})]})}function Cu(e){let t=e?.resource?.source;return t?.type===`Canvas`?t.id:null}function wu({ariaLabel:e,children:t,dark:n,disabled:r,onClick:i}){return B(`button`,{type:`button`,"aria-label":e,disabled:r,onClick:i,className:Du(`inline-flex h-8 w-8 items-center justify-center rounded-full border-0 bg-transparent p-0`,`text-lg transition-colors focus:outline-none focus-visible:ring-2 focus-visible:ring-me-primary-500/50`,n?`text-white hover:bg-white/15 disabled:text-white/40 disabled:hover:bg-transparent`:`text-me-gray-900 hover:bg-me-primary-50 disabled:text-me-gray-500 disabled:hover:bg-transparent`,`disabled:cursor-not-allowed`),children:t})}function Tu({reverse:e,vertical:r}){return B(e?t:n,{"aria-hidden":!0,className:Du(`block`,r&&`rotate-90`)})}function Eu(e){return B(`svg`,{xmlns:`http://www.w3.org/2000/svg`,width:`1em`,height:`1em`,viewBox:`0 0 24 24`,"aria-hidden":!0,...e,children:B(`path`,{fill:`currentColor`,d:`m7 10l5 5l5-5z`})})}function Du(...e){return e.filter(Boolean).join(` `)}const Ou=new WeakMap;function ku(e,t){let n={port:t,lastActionId:`@genesis`},r=Au(e);function i(e){t.postMessage(typeof e==`string`?e:JSON.stringify(e))}function a(){i({_id:_r(),_type:`init-response`,_lastActionId:n.lastActionId,data:e.getState()})}function o(e){i({_id:e,_type:`vault-action-rejection`,_lastActionId:n.lastActionId,action:e})}function s(e){let t=Mu(e.data);if(t){if(t._type===`init-request`){a();return}t._type===`vault-action`&&o(t._id)}}return r.targets.add(n),t.addEventListener(`message`,s),t.start(),()=>{t.removeEventListener(`message`,s),r.targets.delete(n),r.targets.size===0&&e.dispatch===r.patchedDispatch&&(e.dispatch=r.originalDispatch,Ou.delete(e)),t.close()}}function Au(e){let t=Ou.get(e);if(t)return t;let n=e.dispatch.bind(e),r=new Set,i=(e=>{let t=n(e);for(let t of r)ju(t,e);return t}),a={originalDispatch:n,patchedDispatch:i,targets:r};return e.dispatch=i,Ou.set(e,a),a}function ju(e,t){let n={_id:_r(),_type:`vault-action`,_lastActionId:e.lastActionId,action:t};e.lastActionId=n._id,e.port.postMessage(JSON.stringify(n))}function Mu(e){try{if(typeof e==`string`)return JSON.parse(e);if(typeof e==`object`&&e)return e}catch{return null}return null}const Nu=j(null);function Pu({children:e}){let t=H(),n=L(null),r=L(null),i=L(null),a=L(!1),[o,s]=R(!0),c=M(()=>{if(!n.current||n.current.closed||!r.current)return;i.current?.();let e=new MessageChannel;i.current=ku(t,e.port1),n.current.postMessage({_type:`manifest-editor:iframe-preview:connect`,resource:r.current.resource,canvasId:r.current.canvasId||null,annotationId:r.current.annotationId||void 0},new URL(r.current.url).origin,[e.port2]),a.current=!0},[t]);P(()=>{let e=e=>{!r.current||e.source!==n.current||e.origin===new URL(r.current.url).origin&&e.data?._type===`manifest-editor:iframe-preview:ready`&&c()},t=window.setInterval(()=>{n.current?.closed&&(i.current?.(),i.current=null,a.current=!1,n.current=null,s(!0))},1e3);return window.addEventListener(`message`,e),()=>{window.removeEventListener(`message`,e),window.clearInterval(t),i.current?.()}},[c]);let l=M(e=>{r.current=e;let t=n.current;if(t&&!t.closed){t.focus();return}i.current?.(),i.current=null,a.current=!1,n.current=window.open(e.url,e.name||`manifest-editor-preview`,e.features||`popup,width=1200,height=900`),s(!n.current)},[]),u=M(e=>{let t=r.current;r.current=e;let o=n.current;if(!(!o||o.closed)){if(t&&(t.url!==e.url||t.reloadKey!==e.reloadKey)){i.current?.(),i.current=null,a.current=!1,o.location.href=e.url;return}a.current&&o.postMessage({_type:`manifest-editor:iframe-preview:selection`,resource:e.resource,canvasId:e.canvasId||null,annotationId:e.annotationId||void 0},new URL(e.url).origin)}},[]),d=M(()=>{n.current&&!n.current.closed&&n.current.focus()},[]);return B(Nu.Provider,{value:{open:l,update:u,focus:d,isClosed:o},children:e})}function Fu(){let e=N(Nu);return G(e,`usePreviewWindow() can only be called from inside <PreviewWindowProvider />`),e}var Iu=class extends ve{constructor(...e){super(...e),X(this,`state`,{hasError:!1})}static getDerivedStateFromError(e){return console.error(e),{hasError:!0}}componentDidCatch(e,t){console.error(`Uncaught error:`,e,t)}render(){return this.state.hasError?B(`h1`,{children:`Sorry.. there was an error`}):this.props.children}};function Lu(e,t){return typeof e==`string`?{id:e,state:t}:e}const Ru=we(function(e){let t=Y(),n=vl(),r=t.layout,[i,a]=Ee(yu,void 0,xu),o={centerPanel:gu(`centerPanel`,a),leftPanel:gu(`leftPanel`,a),rightPanel:gu(`rightPanel`,a),pinnedRightPanel:gu(`pinnedRightPanel`,a),modal:gu(`modal`,a),editingStack:Aa()};function s(e){let t=r.rightPanels.find(t=>t.id===e);if(t)return[t,o.rightPanel,o.pinnedRightPanel];let n=r.centerPanels.find(t=>t.id===e);if(n)return[n,o.centerPanel];let i=r.leftPanels.find(t=>t.id===e);if(i)return i.modal?[i,o.modal]:[i,o.leftPanel];G(!1,`Was not able to find panel with id "${e}"`)}function c(e,t){let{id:r,state:i,stacked:a}=Lu(e,t),[o,c,l]=s(r);if(l&&o.options?.openPinned)l.pin({id:r,state:{...o.defaultState||{},...i||{}}});else{let e={id:r,state:{...o.defaultState||{},...i||{}},stacked:a};n.emit(`layout.open`,e),c.open(e)}}function l(e,t){let{id:r,state:i}=Lu(e,t),[a,o]=s(r),c={id:r,state:{...a.defaultState||{},...i||{}},stacked:!0};n.emit(`layout.open`,c),o.open(c)}function u(e,t){let{id:r,state:i,stacked:a}=Lu(e,t),[o,c]=s(r),l={id:r,state:{...o.defaultState||{},...i||{}},stacked:a};n.emit(`layout.change`,l),c.change(l)}function d(e,t){let{id:r}=Lu(e,t),[,i]=s(r);n.emit(`layout.close`,{id:r}),i.close()}function f(e,t){let{id:r}=Lu(e,t),[,i]=s(r);n.emit(`layout.toggle`,{id:r}),i.toggle()}function p(e,t={},{reset:i,property:a,stacked:s,forceOpen:c,selectedTab:l}={}){let u={resource:Ke(e)?e:{type:`SpecificResource`,source:e},...t};n.emit(`layout.edit`,u),o.editingStack.edit(u,i),r.rightPanels.find(e=>e.id===`@manifest-editor/editor`)&&(c?o.rightPanel.open({id:`@manifest-editor/editor`,stacked:s!==!1,state:{property:a,currentTab:l},unique:!0}):o.rightPanel.change({id:`@manifest-editor/editor`,stacked:s!==!1,state:{property:a,currentTab:l},unique:!0}))}async function m(e){o.editingStack.create(e,{}),n.emit(`layout.create`,e),r.modals?.find(e=>e.id===`@manifest-editor/creator`)?o.modal.open({id:`@manifest-editor/creator`,stacked:!0,unique:!0,state:e}):r.rightPanels.find(e=>e.id===`@manifest-editor/creator`)&&o.rightPanel.open({id:`@manifest-editor/creator`,stacked:!0,unique:!0,state:e})}let h={open:c,change:u,close:d,toggle:f,stack:l,edit:p,create:m};return B(Ha.Provider,{value:I(()=>({...o,...h}),[r]),children:B(Ua.Provider,{value:i,children:e.children})})}),zu=[{id:`universal-viewer`,config:{url:`https://universalviewer.dev/#?iiifManifestId={manifestId}`},type:`external-manifest-preview`,label:`Universal viewer`},{id:`mirador-3`,type:`external-manifest-preview`,label:`Mirador 3`,config:{url:`https://tomcrane.github.io/scratch/mirador3/?iiif-content={manifestId}`}},{id:`annona`,type:`external-manifest-preview`,label:`Annona`,config:{url:`https://ncsu-libraries.github.io/annona/tools/#/display?url={manifestId}&viewtype=iiif-storyboard&settings=%7B%22fullpage%22%3Atrue%7D`}},{id:`iiif-preview`,config:{url:`https://iiif-preview.digirati.services/store`},type:`iiif-preview-service`,label:`IIIF Preview`}],Bu=new gt({approximateServices:!0,verificationsRequired:8,enableFetching:!0});function Vu({config:e,saveConfig:t,children:n,theme:r,previews:i,resource:a,editing:o,backgroundActionPersistence:s}){let c=xi(),l=K(),u=I(()=>{let t=e?.previews||(l.previews?.length?l.previews:zu);return Nt(l,{previews:t},e)},[l,e]),d=I(()=>({appId:c.appId,instanceId:c.instanceId,rootResource:{id:a.id,type:a.type}}),[c.appId,c.instanceId,a.id,a.type]);return B(Iu,{children:B(Fe.Provider,{value:Bu,children:B(Wi,{resource:a,children:B(rc,{children:B(Je,{theme:r||yc,children:V(Lt,{config:u,saveConfig:t,children:[B(_i,{config:u}),B(Ba,{children:B(Ru,{children:B(lr,{persistence:s,persistenceKey:d,children:B(Hc,{children:B(Oo,{children:B(na,{previews:i||[],configs:u.previews,children:B(Pu,{children:B(Me,{children:n})})})})})})})})]})})})})})})}const Hu=new Set([`Collection`,`Manifest`,`Canvas`,`Range`,`AnnotationPage`,`Annotation`,`ContentResource`,`Agent`]),Uu={satisfied:0,missing:0,invalid:0,disallowed:0,"not-applicable":0},Wu=new Set([`label`,`summary`,`language`,`navDate`,`provider`,`requiredStatement`,`rights`,`thumbnail`]);function Gu(e){return e?Array.isArray(e)?e.filter(Boolean):e.split(`.`).filter(Boolean):[]}function Ku(e,t){let n=Gu(e),r=Gu(t);return n.length===r.length&&n.every((e,t)=>e===r[t])}function qu(e,t){let n=e;for(let e of Gu(t)){if(n==null)return;n=n[e]}return n}function Ju(e,t,n){let r=Gu(t);if(!r.length)return n;let i=Array.isArray(e)?[...e]:{...e||{}},a=i;return r.forEach((e,t)=>{if(t===r.length-1){a[e]=n;return}let i=a[e];a[e]=Array.isArray(i)?[...i]:{...i||{}},a=a[e]}),i}function Yu(e){if(e==null)return!1;if(typeof e==`string`)return e.trim().length>0;if(typeof e==`number`||typeof e==`boolean`)return!0;if(Array.isArray(e))return e.some(e=>Yu(e));if(typeof e!=`object`)return!1;let t=Object.entries(e);return t.length?!t.every(([,e])=>typeof e==`string`||Array.isArray(e)&&e.every(e=>typeof e==`string`))||t.some(([,e])=>Yu(e)):!1}function Xu(e){return Array.isArray(e)?e.map(Xu):e&&typeof e==`object`?Object.keys(e).sort().reduce((t,n)=>(t[n]=Xu(e[n]),t),{}):e}function Zu(e,t){return JSON.stringify(Xu(e))===JSON.stringify(Xu(t))}function Qu(e,t,n,r){let i=Gu(n);for(let n of e||[])for(let e of n.terminology?.properties||[])if(!(e.entityType&&e.entityType!==t)&&Ku(e.path,i))return e.label;return r||Ed(i)}function $u(e,t,n){let r=Gu(n),i=[],a,o,s=!1,c=!1;if(!t||!Hu.has(t.type))return{entityType:t?.type,path:r,label:Qu(e,t?.type,r),disallowed:!1,required:!1,rules:i};for(let n of e||[])for(let e of n.rules||[])!(`entityType`in e)||!(`path`in e)||e.entityType===t.type&&Ku(e.path,r)&&(i.push(e),e.type===`disallow-property`&&(s=!0),e.type===`require-non-empty`&&(c=!0),e.type===`fixed-value`&&!o&&(a=e.value,o=e,c=!0));return{entityType:t.type,path:r,label:Qu(e,t.type,r),disallowed:s,required:c,fixedValue:a,fixedValueRule:o,rules:i}}function ed(e,t,n){let r=e||[],i=td(t,n),a=[];for(let e of r)for(let[n,r]of(e.rules||[]).entries())a.push(...nd(e,r,n,i,t));return{specifications:r,results:a,counts:dd(a)}}function td(e,t){let n=[],r=new Set;function i(t){let a=pd(t);if(!a)return;if(a.type===`SpecificResource`){i(t?.source);return}let o=fd(e,t)||fd(e,a);if(!o||!o.type)return;let s=`${o.type}:${o.id||JSON.stringify(a)}`;if(!r.has(s)){r.add(s),Hu.has(o.type)&&n.push({ref:{id:o.id,type:o.type},resource:o});for(let e of md(o))i(e)}}return i(t),n}function nd(e,t,n,r,i){switch(t.type){case`disallow-property`:case`require-non-empty`:case`fixed-value`:return rd(e,t,n,r);case`iiif:canvas-with-image-service`:return[id(e,t,n,r,i)];case`iiif:thumbnail-from-body-service`:return ad(e,t,n,r,i);case`iiif:valid-rights`:return od(e,t,n,r);case`iiif:required-statement`:return sd(e,t,n,r);case`iiif:metadata-template`:return cd(e,t,n,r);default:return[]}}function rd(e,t,n,r){let i=r.filter(e=>e.ref.type===t.entityType),a=Qu(e?[e]:[],t.entityType,t.path);return i.length?i.map(({ref:r,resource:i})=>{let o=qu(i,t.path),s=Yu(o);if(t.type===`disallow-property`)return ld(e,t,n,{target:r,path:t.path,status:s?`disallowed`:`satisfied`,displayLabel:a,actual:o,message:s?`${a} is present but is not allowed.`:`${a} is not present.`,editorTarget:ud(r,t.path)});if(t.type===`require-non-empty`)return ld(e,t,n,{target:r,path:t.path,status:s?`satisfied`:`missing`,displayLabel:a,actual:o,message:s?`${a} has a value.`:`${a} must be filled in.`,editorTarget:ud(r,t.path)});let c=Zu(o,t.value);return ld(e,t,n,{target:r,path:t.path,status:c?`satisfied`:s?`invalid`:`missing`,displayLabel:a,expected:t.value,actual:o,message:c?`${a} matches the required value.`:s?`${a} does not match the required value.`:`${a} must use the required value.`,editorTarget:ud(r,t.path)})}):[ld(e,t,n,{status:`not-applicable`,displayLabel:a,message:`No ${t.entityType} resources were found for ${a}.`,path:t.path})]}function id(e,t,n,r,i){let a=r.filter(e=>e.ref.type===`Canvas`),o=hd(t),s=a.find(({resource:e})=>gd(_d(e,i),o));return ld(e,t,n,{target:s?.ref,status:s?`satisfied`:`missing`,displayLabel:t.label||`Canvas image service`,expected:o,message:s?`A canvas contains the required image service.`:o.length?`A canvas must contain one of the required image services: ${o.join(`, `)}.`:`A canvas must contain a painting body with an image service.`,editorTarget:s?ud(s.ref,[`items`]):void 0})}function ad(e,t,n,r,i){let a=t.entityType||`Canvas`,o=r.filter(e=>e.ref.type===a);return o.length?o.map(({ref:o,resource:s})=>{let c=a===`Manifest`?r.filter(e=>e.ref.type===`Canvas`).flatMap(e=>_d(e.resource,i)):_d(s,i),l=vd(s,c,i),u=Yu(s.thumbnail);return ld(e,t,n,{target:o,path:[`thumbnail`],status:l?`satisfied`:c.length?u?`invalid`:t.requireThumbnail===!1?`not-applicable`:`missing`:`not-applicable`,displayLabel:Qu([e],o.type,[`thumbnail`],`Thumbnail`),expected:c,actual:s.thumbnail,message:l?`Thumbnail uses the same image service as the painting content.`:c.length?u?`Thumbnail does not use the same image service as the painting content.`:`Thumbnail must be created from the painting image service.`:`No painting image service was found to compare against.`,editorTarget:ud(o,[`thumbnail`])})}):[ld(e,t,n,{status:`not-applicable`,displayLabel:`Thumbnail`,message:`No ${a} resources were found for thumbnail checks.`})]}function od(e,t,n,r){let i=t.entityType||`Manifest`,a=r.filter(e=>e.ref.type===i),o=t.allowed||[];return a.map(({ref:r,resource:i})=>{let a=i.rights,s=Yu(a),c=typeof a==`string`&&o.map(Sd).includes(Sd(a));return ld(e,t,n,{target:r,path:[`rights`],status:c?`satisfied`:!s&&t.required!==!1?`missing`:`invalid`,displayLabel:Qu([e],r.type,[`rights`],`Rights`),expected:o,actual:a,message:c?`Rights uses an allowed URI.`:!s&&t.required!==!1?`Rights must use an allowed URI.`:`Rights is not one of the allowed URIs.`,editorTarget:ud(r,[`rights`])})})}function sd(e,t,n,r){let i=t.entityType||`Manifest`;return r.filter(e=>e.ref.type===i).map(({ref:r,resource:i})=>{let a=i.requiredStatement,o=t.label?Cd(a?.label,t.label):Yu(a?.label),s=t.value||t.valueRequired!==!1,c=t.value?Cd(a?.value,t.value):!s||Yu(a?.value),l=Yu(a);return ld(e,t,n,{target:r,path:[`requiredStatement`],status:o&&c?`satisfied`:l?`invalid`:`missing`,displayLabel:Qu([e],r.type,[`requiredStatement`],`Required statement`),expected:t.value||t.label,actual:a,message:o&&c?`Required statement is complete.`:l?`Required statement does not match the specification.`:`Required statement must be filled in.`,editorTarget:ud(r,[`requiredStatement`])})})}function cd(e,t,n,r){let i=t.entityType||`Manifest`,a=r.filter(e=>e.ref.type===i),o=[];for(let{ref:r,resource:i}of a){let a=Array.isArray(i.metadata)?i.metadata:[];t.items.forEach((i,s)=>{let c=a.find(e=>Cd(e?.label,i.label)),l=i.value?Cd(c?.value,i.value):!i.valueRequired||Yu(c?.value),u=c&&l?`satisfied`:c&&i.value?`invalid`:`missing`,d=Td(i.label);o.push(ld(e,t,n,{idSuffix:`metadata-${s}`,target:r,path:[`metadata`],status:u,displayLabel:d||`Metadata`,expected:i.value||i.label,actual:c,message:c&&l?`${d||`Metadata`} is present.`:c?`${d||`Metadata`} needs a value.`:`${d||`Metadata`} metadata must be added.`,editorTarget:ud(r,[`metadata`])}))})}return o}function ld(e,t,n,r){let i=t.id||`${t.type}-${n}`,a=r.idSuffix?`-${r.idSuffix}`:``;return{id:`${e.id}-${i}-${r.target?.type||`root`}-${r.target?.id||`none`}${a}`,specificationId:e.id,specificationLabel:e.label,ruleId:i,ruleType:t.type,ruleLabel:t.label||r.displayLabel,ruleIndex:n,target:r.target,path:r.path,status:r.status,displayLabel:r.displayLabel,message:t.message||r.message,expected:r.expected,actual:r.actual,editorTarget:r.editorTarget}}function ud(e,t){let n=t[0];return{resource:e,propertyPath:t,selectedTab:n===`metadata`?`@manifest-editor/metadata`:n&&Wu.has(n)?`@manifest-editor/descriptive-properties`:void 0}}function dd(e){let t={...Uu};for(let n of e)t[n.status]+=1;return t}function fd(e,t){let n=pd(t);if(!n)return t;try{return e.get(n,{skipSelfReturn:!1})||t}catch{try{return e.get(n)||t}catch{return t}}}function pd(e){return!e||typeof e!=`object`?null:e.type===`SpecificResource`?{id:e.id||e.source?.id||``,type:`SpecificResource`}:typeof e.id==`string`&&typeof e.type==`string`?{id:e.id,type:e.type}:null}function md(e){if(!e||typeof e!=`object`)return[];let t=[];for(let n of[`items`,`structures`,`annotations`,`thumbnail`,`provider`,`homepage`,`rendering`,`seeAlso`,`body`,`target`,`source`]){let r=e[n];Array.isArray(r)?t.push(...r):r&&t.push(r)}return t}function hd(e){return[...e.serviceIds||[],...e.serviceId?[e.serviceId]:[]].filter(Boolean)}function gd(e,t){let n=new Set(e.filter(Boolean));return t.length?t.some(e=>n.has(e)):n.size>0}function _d(e,t){let n=xd(t,e?.items),r=[];for(let e of n){let n=xd(t,e?.items);for(let e of n)if((Array.isArray(e?.motivation)?e.motivation:[e?.motivation]).includes(`painting`))for(let n of yd(e?.body,t))r.push(...bd(n))}return Array.from(new Set(r))}function vd(e,t,n){let r=xd(n,e?.thumbnail);if(!r.length||!t.length)return!1;for(let e of r){let n=bd(e),r=typeof e?.id==`string`?e.id:``;if(n.some(e=>t.includes(e))||t.some(e=>r.startsWith(e)))return!0}return!1}function yd(e,t){let n=fd(t,e);return n?Array.isArray(n)?n.flatMap(e=>yd(e,t)):n.type===`SpecificResource`?yd(n.source,t):n.type===`Choice`?n.items?.flatMap(e=>yd(e,t))||[]:[n]:[]}function bd(e){let t=e?.service||e?.services,n=Array.isArray(t)?t:t?[t]:[],r=[];for(let e of n){let t=typeof e==`string`?e:e?.id||e?.[`@id`];typeof t==`string`&&t&&r.push(t)}return Array.from(new Set(r))}function xd(e,t){if(!t)return[];let n=Array.isArray(t)?t:[t];try{let t=e.get(n);if(Array.isArray(t))return t.filter(Boolean)}catch{}return n.map(t=>fd(e,t)).filter(Boolean)}function Sd(e){return e.replace(/^https:/,`http:`).replace(/\/?$/,`/`)}function Cd(e,t){return typeof t==`string`?wd(e).some(e=>e===t):Zu(e,t)}function wd(e){return e?typeof e==`string`?[e.trim()].filter(Boolean):Array.isArray(e)?e.flatMap(wd):typeof e==`object`?Object.values(e).flatMap(wd):[]:[]}function Td(e){return typeof e==`string`?e:wd(e)[0]||``}function Ed(e){return(e[e.length-1]||`Property`).replace(/([A-Z])/g,` $1`).replace(/[-_]/g,` `).replace(/^./,e=>e.toUpperCase())}const Dd=j([]);function Od({children:e,specifications:t}){let n=I(()=>t||[],[t]);return B(Dd.Provider,{value:n,children:e})}function kd(){return N(Dd)}function Ad(e){let t=Hi(),n=kd(),r=e||t;return Ge((e,t)=>ed(n,t,r),[n,r.id,r.type])}function jd(){let e=kd();return I(()=>({getLabel(t,n,r){return Qu(e,t,n,r)}}),[e])}function Md(e,t){let n=kd();return I(()=>$u(n,e,t),[n,e?.id,e?.type,JSON.stringify(t)])}const Nd={},Pd=j(`global`);function Fd(){return N(Pd)}function Id(){let e,t;return{promise:new Promise((n,r)=>{e=n,t=r}),resolve:e,reject:t}}function Ld(e){let t=Fd(),[,n]=Ee(e=>e+1,0),r=I(()=>(Nd[t]||(Nd[t]={}),Nd[t][e]||(Nd[t][e]={name:e,emitter:ft(),status:`idle`,promise:Promise.resolve(),abort:new AbortController,reject:()=>void 0,resolve:()=>void 0}),Nd[t][e]),[t,e]);return Rd(r,`abort`,n),Rd(r,`error`,n),Rd(r,`complete`,n),Rd(r,`running`,n),r}function Rd(e,t,n){let r=M(()=>n(e),[n]);P(()=>{let n=e.emitter;return n.on(t,r),()=>n.off(t,r)},[t,r,e.emitter])}const zd=()=>void 0;function Bd(e,t){let n=Ld(e);return Rd(n,`complete`,t||zd),[e=>{n.status===`running`&&(n.abort.abort(),n.emitter.emit(`abort`)),n.error&&(n.error=``);let t=Id();t.promise.then(()=>n.emitter.emit(`complete`)).catch(()=>n.emitter.emit(`error`)),n.status=`running`,n.request=e,n.promise=t.promise,n.resolve=t.resolve,n.reject=t.reject,n.emitter.emit(`running`)},n]}function Vd(e,t){let n=Ld(e);return Rd(n,`running`,t),[e=>{n.status===`running`&&(n.response=e,n.status=`complete`,n.resolve())},n,(e,t)=>{n.status===`running`&&(n.error=t||e,n.status=`error`,n.reject(e))}]}function Hd({children:e}){return B(Pd.Provider,{value:I(()=>`id-${Date.now()}`,[]),children:e})}function Ud(e){return!1}function Wd({as:e,reference:t,onReference:n,onLink:r,onAnalysis:i,onDropReference:a,onDropLink:o,onDropAnalysis:s,onPasteReference:c,onPasteLink:l,onPasteAnalysis:u,...d}){let f=e||`div`,p=a||n,m=c||n,h=l||r,g=u||i,_=I(()=>t,[t?.id,t?.type]),v=M(function(e){e.defaultPrevented||(e.preventDefault(),e.clipboardData&&_&&_.id&&_.type&&e.clipboardData.setData(`application/json+vault`,JSON.stringify({id:_.id,type:_.type})))},[_]),y=M(async function(e){if(!e.defaultPrevented&&(e.preventDefault(),e.clipboardData)){if(d.onLoading&&d.onLoading(),m){let t=e.clipboardData.getData(`application/json+vault`);if(t)try{let e=JSON.parse(t);e&&e.id&&e.type&&m(e)}catch{}}if(h||g){let t=e.clipboardData.getData(`text`);if(t.startsWith(`http`)){let e=t.split(`
|
|
1531
|
-
`);for(let t of e){if(g)try{let e=await
|
|
1555
|
+
`,Sd=Ae(function(e){let{resolveMessage:t}=H(),n=U(`shell`);if(e.layoutMode===`focused`)return B(fd,{...e});let r=X(),i=aa(),a=_a(),o=Da(),{vault:s}=P(Je),c=s||void 0,l=nt(e=>e.iiif),u=L(null),d=L(null),{loading:f,state:p,leftPanels:m,centerPanels:h,rightPanels:g,modals:_=[],actions:v}=o,y=I(()=>({rootResource:a,vault:c,app:r,layoutState:p,appState:i}),[a,c,r,p,i,l]),b=I(()=>cd(m,y,(e,t)=>{console.error(`Layout panel "${e.id}" failed support check`,t)}),[m,y]),x=I(()=>cd(h,y,(e,t)=>{console.error(`Layout panel "${e.id}" failed support check`,t)}),[h,y]),S=I(()=>cd(g,y,(e,t)=>{console.error(`Layout panel "${e.id}" failed support check`,t)}),[g,y]),C=I(()=>cd(_,y,(e,t)=>{console.error(`Layout panel "${e.id}" failed support check`,t)}),[_,y]),ee=I(()=>b.filter(e=>e.modal),[b]),w=I(()=>b.filter(e=>!e.modal),[b]),T=I(()=>[...C,...ee],[C,ee]),E=I(()=>({...o,leftPanels:b,centerPanels:x,rightPanels:S,modals:T}),[o,b,x,S,T]),D=w.find(e=>e.id===p.leftPanel.current),O=S.find(e=>e.id===p.rightPanel.current),k=x.find(e=>e.id===p.centerPanel.current),A=T.find(e=>e.id===p.modal.current),ne=p.modal.open&&ee.some(e=>e.id===p.modal.current)?p.modal.current:p.leftPanel.current,re=p.pinnedRightPanel.pinned?S.find(e=>e.id===p.pinnedRightPanel.current):void 0,[ae]=Du([`(max-width: 1020px)`]),oe=e.isLoading||!1,se=I(()=>(o.background||[]).map((e,t)=>B(Te,{children:e.render()},t)),[o.background]),j=Hu(`left-panel/${D?.id}`,{left:!0,marginLeft:60,minWidthPx:D?.options?.minWidth||200,maxWidthPx:D?.options?.maxWidth||720,loading:f}),ce=Hu(`right-panel/${O?.id}`,{left:!1,minWidthPx:O?.options?.minWidth||320,maxWidthPx:O?.options?.maxWidth||720,loading:f}),le=O&&(re?.id!==O.id||!It(p.pinnedRightPanel.state,p.rightPanel.state)),ue=j.widthB===`auto`?void 0:()=>j.setWidths({widthA:`auto`,widthB:Xc({options:D?.options,fallback:320})}),de=ce.widthB===`auto`?void 0:()=>ce.setWidths({widthA:`auto`,widthB:Xc({options:O?.options,fallback:320})});if(Ne(()=>{ae&&p.leftPanel.open&&p.rightPanel.open&&(v.leftPanel.close(),v.rightPanel.close())},[ae]),Ne(()=>{if(k&&k.onMount)return k.onMount(p.centerPanel.state||k.defaultState||{},{...E,current:v.centerPanel,vault:c},i)},[p.centerPanel.current,k?.id]),Ne(()=>{if(p.leftPanel.current&&!D){let e=ld(w,p.leftPanel.current);e?v.leftPanel.change({id:e}):v.leftPanel.close()}if(p.centerPanel.current&&!k){let e=ld(x,p.centerPanel.current);e?v.centerPanel.change({id:e}):v.centerPanel.close()}if(p.rightPanel.current&&!O){let e=ld(S,p.rightPanel.current);e?v.rightPanel.change({id:e}):v.rightPanel.close()}if(p.modal.current&&!A){let e=ld(T,p.modal.current);e?v.modal.change({id:e}):v.modal.close()}},[p.leftPanel.current,p.centerPanel.current,p.rightPanel.current,p.modal.current,D?.id,k?.id,O?.id,A?.id,ud(w),ud(x),ud(S),ud(T)]),Ne(()=>{S.length&&v.rightPanel.change({id:S[0].id}),w.length&&v.leftPanel.change({id:w[0].id}),x.length&&v.centerPanel.change({id:x[0].id})},[]),f)return null;let fe=t=>B(ad,{$menu:e.leftPanelMenuPosition||`bottom`,ref:j.refs.resizableDiv,className:[`manifest-editor`,t?`transition transition-${t}`:``].join(` `),style:{width:p.leftPanel.open||t!==`exited`?j.widthB:void 0,minWidth:D?.options?.minWidth},children:oe?B(sd,{children:B(Ru,{})}):V(z,{children:[e.leftPanelMenu?B(od,{$open:p.leftPanel.open&&t!==`exited`,$position:e.leftPanelMenuPosition||`bottom`,children:e.leftPanelMenu}):null,B(sd,{children:p.leftPanel.open||t!==`exited`?B(z,{children:D?B(sl,{isLeft:!0,noHeader:!0,transition:t,panel:D,state:p.leftPanel,actions:v.leftPanel}):null}):null})]})}),pe=()=>A?B(te,{title:t(A?.labelMessage,A.label),open:p.modal.open,onClose:()=>v.modal.close(),children:A.modal?B(`div`,{className:`h-[70vh] min-h-[60vh] max-h-full flex w-full`,children:B(sl,{isLeft:!0,isModal:!0,noHeader:!0,panel:A,state:p.modal,actions:v.modal})}):Zc(A.render(p.modal.state||A.defaultState||{},{...E,current:v.modal,vault:c,isModal:!0},i))}):null,me=()=>V(ad,{$menu:e.centerPanelMenuPosition||`top`,children:[e.centerPanelMenu?B(od,{$open:p.centerPanel.open,$position:e.centerPanelMenuPosition||`top`,children:e.centerPanelMenu}):null,B(sd,{children:B(Mt,{resetKeys:[k?.id],FallbackComponent:Qc,children:oe?B(`div`,{style:{display:`flex`,flex:1,justifyContent:`center`,alignItems:`center`},children:B(Iu,{stroke:`rgba(0,0,0,.3)`,fontSize:`2em`})}):p.centerPanel.open&&k?Zc(k.render(p.centerPanel.state||k.defaultState||{},{...E,current:v.centerPanel,vault:c},i)):null})})]}),he=t=>B(ad,{$menu:e.rightPanelMenuPosition||`bottom`,ref:ce.refs.resizableDiv,className:t?`transition transition-${t}`:``,style:{width:p.rightPanel.open||t!==`exited`?ce.widthB:void 0,minWidth:O?.options?.minWidth},children:oe?B(sd,{children:B(Ru,{})}):V(z,{children:[e.rightPanelMenu?B(od,{$open:p.rightPanel.open,$position:e.rightPanelMenuPosition||`bottom`,children:e.rightPanelMenu}):null,B(sd,{children:p.rightPanel.open||t!==`exited`?V(z,{children:[le?B(sl,{panel:O,state:p.rightPanel,actions:v.rightPanel,pinActions:v.pinnedRightPanel,available:S}):null,re?B(sl,{panel:re,state:p.pinnedRightPanel,actions:v.pinnedRightPanel,close:v.rightPanel.close}):null]}):null})]})});return ae?V(Qu,{children:[e.hideHeader?null:V($u,{children:[e.header||B(Ja,{}),e.menu?B(`menu`,{children:e.menu}):null]}),B(td,{children:V(pd,{children:[V(hd,{children:[w.length>0?B(gd,{type:`button`,"aria-expanded":p.leftPanel.open,onClick:()=>{v.rightPanel.close(),v.leftPanel.toggle()},children:t(D?.labelMessage,D?.label)}):null,S.length>0?B(_d,{children:V(vd,{type:`button`,"aria-expanded":p.rightPanel.open,onClick:()=>{v.leftPanel.close(),v.rightPanel.toggle()},children:[B(io,{"aria-hidden":`true`,rotate:90}),t(O?.labelMessage,O?.label)]})}):null]}),B(md,{children:me()}),S.length>0?B(yd,{$open:p.rightPanel.open,children:he()}):null,w.length>0?V(bd,{$open:p.leftPanel.open,children:[B(`nav`,{"aria-label":n(`panels.leftTabs`),className:`flex flex-none overflow-x-auto border-b border-gray-300`,children:w.map(e=>V(`button`,{type:`button`,"aria-pressed":p.leftPanel.current===e.id,className:`flex flex-1 shrink-0 items-center justify-center gap-1.5 border-0 border-b-[3px] p-3 text-gray-700 [&>svg]:shrink-0 [&>svg]:text-xl ${p.leftPanel.current===e.id?`border-b-[#b83265] bg-[#f9e8ef]`:`border-b-transparent bg-white`}`,onClick:()=>{v.rightPanel.close(),v.leftPanel.open({id:e.id,state:e.defaultState})},children:[e.icon,t(e?.labelMessage,e.label)]},e.id))}),fe()]}):null,b.length>0||S.length>0?B(xd,{type:`button`,"aria-label":n(`panels.closeAll`),$open:p.leftPanel.open||p.rightPanel.open,onClick:()=>{v.leftPanel.close(),v.rightPanel.close()}}):null]})}),B(`div`,{className:`hidden`,children:se}),B(Js,{}),B(Xs,{}),B(z,{children:pe()}),B(bc,{})]}):V(Qu,{id:e.htmlId||`manifest-editor-container`,className:`manifest-editor ${e.className||``}`,children:[e.hideHeader?null:V($u,{children:[e.header||B(Ja,{}),e.menu?B(`menu`,{children:e.menu}):null]}),V(td,{ref:e=>{j.refs.container.current=e,ce.refs.container.current=e},children:[b.length>0?B(ie,{current:ne,items:b.map(e=>({id:e.id,label:t(e?.labelMessage,e.label),icon:e.icon,divide:e.divide,separator:e.separator,onClick:()=>{if(e.modal){p.modal.open&&p.modal.current===e.id?v.modal.close():v.modal.open({id:e.id,state:e.defaultState});return}p.leftPanel.current===e.id?v.leftPanel.toggle():v.leftPanel.change({id:e.id})}})),open:p.leftPanel.open}):null,w.length>0?B(Ft,{nodeRef:u,in:p.leftPanel.open,timeout:400,unmountOnExit:!1,children:e=>V(z,{children:[B(nd,{ref:u,$width:j.widthB,$state:e,$motion:!0,children:fe(e)}),B(Fu,{ref:j.refs.resizer,reset:ue,dir:`left`,transition:e,open:p.leftPanel.open||e!==`exited`,actions:v.leftPanel})]})}):null,B(rd,{children:me()}),S.length>0?B(Ft,{nodeRef:d,in:p.rightPanel.open,timeout:400,unmountOnExit:!1,children:e=>V(z,{children:[B(Fu,{ref:ce.refs.resizer,dir:`right`,reset:de,open:p.rightPanel.open,actions:v.rightPanel}),B(id,{ref:d,$width:ce.widthB,$state:e,$motion:!0,children:he(e)})]})}):null]}),B(ed,{children:e.footer||null}),B(`div`,{className:`hidden`,children:se}),B(Js,{}),B(Xs,{}),B(z,{children:pe()}),B(bc,{})]})});function Cd(e,t){function n(){t({type:`popStack`,panel:e,payload:void 0})}function r(n){t({type:`change`,panel:e,payload:n})}function i(n){t({type:`open`,panel:e,payload:n})}function a(){t({type:`close`,panel:e,payload:void 0})}function o(){t({type:`toggle`,panel:e,payload:void 0})}function s(){t({type:`minimise`,panel:e,payload:void 0})}function c(n){t({type:`maximise`,panel:e,payload:n})}function l(n){t({type:`setCustomWidth`,panel:e,payload:n})}function u(){t({type:`resetSize`,panel:e,payload:void 0})}function d(n){t({type:`pin`,panel:e,payload:n})}function f(){t({type:`unpin`,panel:e,payload:void 0})}return I(()=>({popStack:n,change:r,open:i,close:a,toggle:o,minimise:s,maximise:c,setCustomWidth:l,resetSize:u,pin:d,unpin:f}),[])}function wd(e,t){if(t.payload&&t.payload.stacked){if(e.current){let n=e.stack[e.stack.length-1];if(n&&n.id===e.current)return;t.payload.unique&&(e.stack=e.stack.filter(t=>t.id!==e.current)),e.stack.push({id:e.current,state:e.state?{...Tt(e.state)}:{}})}}else e.stack=[]}function Td(e,t){switch(t.type){case`popStack`:if(e.stack.length){let t=e.stack[e.stack.length-1];t&&(e.current=t.id,e.state=t.state),e.stack=e.stack.slice(0,-1)}break;case`change`:t.payload.id!==e.current&&wd(e,t),e.state=t.payload.state,e.current=t.payload.id;break;case`close`:e.open=!1;break;case`open`:e.open=!0,t.payload&&(t.payload.id!==e.current&&wd(e,t),e.state=t.payload.state,e.current=t.payload.id);break;case`toggle`:e.open=!e.open;break;case`maximise`:e.minimised=!1,t.payload&&(e.state=t.payload.state,e.current=t.payload.id);break;case`minimise`:e.minimised=!0;break;case`setCustomWidth`:e.customWidth=t.payload;break;case`resetSize`:e.customWidth=void 0}if(Yc(e))switch(t.type){case`pin`:e.pinned=!0,e.state=t.payload.state,e.current=t.payload.id;break;case`unpin`:e.pinned=!1,e.state=void 0}}const Ed=Et((e,t)=>{switch(t.panel){case`centerPanel`:Td(e.centerPanel,t);break;case`leftPanel`:Td(e.leftPanel,t);break;case`rightPanel`:Td(e.rightPanel,t);break;case`modal`:Td(e.modal,t);break;case`pinnedRightPanel`:Td(e.pinnedRightPanel,t)}});function Dd(){return{customWidth:void 0,minimised:!1,open:!0,current:null,state:null,stack:[]}}function Od(){return{leftPanel:Dd(),centerPanel:Dd(),rightPanel:Dd(),modal:Dd(),pinnedRightPanel:{...Dd(),pinnable:!0,pinned:!1}}}function kd({className:e,variant:t=`light`}){let n=U(`shell`),{locale:r,profile:i}=H(),a=et(),o=W(),{edit:s}=wa(),c=Xo(),l=Zo(),u=a?.items||[],d=a?.viewingDirection===`right-to-left`||a?.viewingDirection===`bottom-to-top`,f=a?.viewingDirection===`top-to-bottom`||a?.viewingDirection===`bottom-to-top`,p=Ad(c)||l.map(Ad).find(Boolean)||u[0]?.id||``,m=Math.max(0,u.findIndex(e=>e.id===p)),h=u[m]?.id||``,g=m+1,_=I(()=>u.map((e,t)=>{let r=o.get({id:e.id,type:`Canvas`});return{id:e.id,pageNumber:t+1,labelText:at(r?.label)||n(`navigation.page`,{number:t+1})}}),[u,o,n,r,i]),v=e=>{let t=u.findIndex(t=>t.id===e),n=u[t];!n||!a||s({id:n.id,type:`Canvas`},{parent:{id:a.id,type:`Manifest`},property:`items`,index:t},{forceOpen:!1})};if(!a||u.length<2)return B(`div`,{className:e});let y=u[m-1],b=u[m+1],x=t===`dark`;return V(`nav`,{"aria-label":n(`navigation.title`),className:Pd(`inline-flex shrink-0 items-center gap-1 rounded-full border px-1.5 py-1`,`focus-within:ring-2 focus-within:ring-me-primary-500/40`,d&&`flex-row-reverse`,x?`border-white/20 bg-white/10 text-white`:`border-me-gray-300 bg-white text-me-gray-900`,e),children:[B(jd,{ariaLabel:n(`navigation.previous`),disabled:!y,onClick:()=>y&&v(y.id),dark:x,children:B(Md,{reverse:d,vertical:f})}),V(`label`,{htmlFor:`manifest-pagination-page-select`,"aria-label":`Page ${g} of ${u.length}`,className:Pd(`relative inline-flex min-h-8 cursor-pointer select-none items-center gap-0.5`,`whitespace-nowrap rounded-full border px-2.5 text-xs font-semibold leading-none`,`focus-within:outline-none focus-within:ring-2 focus-within:ring-me-primary-500/40`,x?`border-white/20 bg-white/10 text-white hover:bg-white/15`:`border-me-gray-300 bg-me-gray-100 text-me-gray-900 hover:bg-me-primary-50`),children:[V(`span`,{children:[g,` / `,u.length]}),B(Nd,{className:Pd(`shrink-0 text-base`,x?`text-white/60`:`text-me-gray-500`)}),B(`select`,{id:`manifest-pagination-page-select`,"aria-label":n(`navigation.jump`),value:h,onChange:e=>v(e.target.value),className:`absolute inset-0 cursor-pointer appearance-none border-0 bg-white opacity-0`,children:_.map(e=>B(`option`,{value:e.id,children:n(`navigation.option`,{number:e.pageNumber,label:e.labelText})},e.id))})]}),B(jd,{ariaLabel:n(`navigation.next`),disabled:!b,onClick:()=>b&&v(b.id),dark:x,children:B(Md,{reverse:!d,vertical:f})})]})}function Ad(e){let t=e?.resource?.source;return t?.type===`Canvas`?t.id:null}function jd({ariaLabel:e,children:t,dark:n,disabled:r,onClick:i}){return B(`button`,{type:`button`,"aria-label":e,disabled:r,onClick:i,className:Pd(`inline-flex h-8 w-8 items-center justify-center rounded-full border-0 bg-transparent p-0`,`text-lg transition-colors focus:outline-none focus-visible:ring-2 focus-visible:ring-me-primary-500/50`,n?`text-white hover:bg-white/15 disabled:text-white/40 disabled:hover:bg-transparent`:`text-me-gray-900 hover:bg-me-primary-50 disabled:text-me-gray-500 disabled:hover:bg-transparent`,`disabled:cursor-not-allowed`),children:t})}function Md({reverse:e,vertical:t}){return B(e?n:r,{"aria-hidden":!0,className:Pd(`block`,t&&`rotate-90`)})}function Nd(e){return B(`svg`,{xmlns:`http://www.w3.org/2000/svg`,width:`1em`,height:`1em`,viewBox:`0 0 24 24`,"aria-hidden":!0,...e,children:B(`path`,{fill:`currentColor`,d:`m7 10l5 5l5-5z`})})}function Pd(...e){return e.filter(Boolean).join(` `)}const Fd=new WeakMap;function Id(e,t){let n={port:t,lastActionId:`@genesis`},r=Ld(e);function i(e){t.postMessage(typeof e==`string`?e:JSON.stringify(e))}function a(){i({_id:Xr(),_type:`init-response`,_lastActionId:n.lastActionId,data:e.getState()})}function o(e){i({_id:e,_type:`vault-action-rejection`,_lastActionId:n.lastActionId,action:e})}function s(e){let t=zd(e.data);if(t){if(t._type===`init-request`){a();return}t._type===`vault-action`&&o(t._id)}}return r.targets.add(n),t.addEventListener(`message`,s),t.start(),()=>{t.removeEventListener(`message`,s),r.targets.delete(n),r.targets.size===0&&e.dispatch===r.patchedDispatch&&(e.dispatch=r.originalDispatch,Fd.delete(e)),t.close()}}function Ld(e){let t=Fd.get(e);if(t)return t;let n=e.dispatch.bind(e),r=new Set,i=(e=>{let t=n(e);for(let t of r)Rd(t,e);return t}),a={originalDispatch:n,patchedDispatch:i,targets:r};return e.dispatch=i,Fd.set(e,a),a}function Rd(e,t){let n={_id:Xr(),_type:`vault-action`,_lastActionId:e.lastActionId,action:t};e.lastActionId=n._id,e.port.postMessage(JSON.stringify(n))}function zd(e){try{if(typeof e==`string`)return JSON.parse(e);if(typeof e==`object`&&e)return e}catch{return null}return null}const Bd=M(null);function Vd({children:e}){let t=W(),n=L(null),r=L(null),i=L(null),a=L(!1),[o,s]=R(!0),c=N(()=>{if(!n.current||n.current.closed||!r.current)return;i.current?.();let e=new MessageChannel;i.current=Id(t,e.port1),n.current.postMessage({_type:`manifest-editor:iframe-preview:connect`,resource:r.current.resource,canvasId:r.current.canvasId||null,annotationId:r.current.annotationId||void 0},new URL(r.current.url).origin,[e.port2]),a.current=!0},[t]);F(()=>{let e=e=>{!r.current||e.source!==n.current||e.origin===new URL(r.current.url).origin&&e.data?._type===`manifest-editor:iframe-preview:ready`&&c()},t=window.setInterval(()=>{n.current?.closed&&(i.current?.(),i.current=null,a.current=!1,n.current=null,s(!0))},1e3);return window.addEventListener(`message`,e),()=>{window.removeEventListener(`message`,e),window.clearInterval(t),i.current?.()}},[c]);let l=N(e=>{r.current=e;let t=n.current;if(t&&!t.closed){t.focus();return}i.current?.(),i.current=null,a.current=!1,n.current=window.open(e.url,e.name||`manifest-editor-preview`,e.features||`popup,width=1200,height=900`),s(!n.current)},[]),u=N(e=>{let t=r.current;r.current=e;let o=n.current;if(!(!o||o.closed)){if(t&&(t.url!==e.url||t.reloadKey!==e.reloadKey)){i.current?.(),i.current=null,a.current=!1,o.location.href=e.url;return}a.current&&o.postMessage({_type:`manifest-editor:iframe-preview:selection`,resource:e.resource,canvasId:e.canvasId||null,annotationId:e.annotationId||void 0},new URL(e.url).origin)}},[]),d=N(()=>{n.current&&!n.current.closed&&n.current.focus()},[]);return B(Bd.Provider,{value:{open:l,update:u,focus:d,isClosed:o},children:e})}function Hd(){let e=P(Bd);return q(e,`usePreviewWindow() can only be called from inside <PreviewWindowProvider />`),e}function Ud({children:e,localisation:t,preset:n}){let{uiI18n:r}=J(),i=Ie(),a=H(),o=L(null),s=a.availableLocales.map(e=>e.id).join(`|`)+`;`+a.availableProfiles.join(`|`),c=JSON.stringify(r),l=!!(r||t||n),u=I(()=>{if(i&&!l)return i;let e=o.current?.getSnapshot(),s=i?[{availableLocales:a.availableLocales.map(e=>e.id),availableProfiles:a.availableProfiles}]:[],c=Xt(n,t),u=Be({...c,locale:i?void 0:c?.locale,profile:i?void 0:c?.profile,locales:c?.locales||(i?a.availableLocales:void 0),config:{...n?.config,...t?.config,...r},policies:[...s,...n?.policies||[],...t?.policies||[]],presets:[...n?.presets||[],...t?.presets||[]],requiredNamespaces:[...new Set([`shell`,`editor-api`,...n?.requiredNamespaces||[],...t?.requiredNamespaces||[],...r?.requiredNamespaces||[]])],registrations:[...n?.registrations||[],...t?.registrations||[]],persistedLocale:i?a.locale:e?.locale,persistedProfile:i?a.profile:e?.profile});return o.current=u,u},[i,l,c,t,n,s]),d=u.getSnapshot(),f=i?d.availableLocales.some(e=>e.id===a.locale)?a.locale:d.locale:void 0,p=i?d.availableProfiles.includes(a.profile)?a.profile:d.profile:void 0;return B(Fe,{instance:u,locale:f,profile:p,onLocaleChange:i?e=>{if(!d.availableLocales.some(t=>t.id===e))throw RangeError(`Unavailable shell locale: ${e}`);return a.setLocale(e)}:void 0,onProfileChange:i?e=>{if(!d.availableProfiles.includes(e))throw RangeError(`Unavailable shell profile: ${e}`);return a.setProfile(e)}:void 0,children:e})}var Wd=class extends we{constructor(...e){super(...e),fo(this,`state`,{hasError:!1})}static getDerivedStateFromError(e){return console.error(e),{hasError:!0}}componentDidCatch(e,t){console.error(`Uncaught error:`,e,t)}render(){return this.state.hasError?B(Gd,{}):this.props.children}};function Gd(){let e=U(`ui`);return B(`h1`,{role:`alert`,children:e(`error.title`)})}function Kd(e,t){return typeof e==`string`?{id:e,state:t}:e}const qd=Ae(function(e){let t=X(),n=Tu(),r=t.layout,[i,a]=Pe(Ed,void 0,Od),o={centerPanel:Cd(`centerPanel`,a),leftPanel:Cd(`leftPanel`,a),rightPanel:Cd(`rightPanel`,a),pinnedRightPanel:Cd(`pinnedRightPanel`,a),modal:Cd(`modal`,a),editingStack:Yo()};function s(e){let t=r.rightPanels.find(t=>t.id===e);if(t)return[t,o.rightPanel,o.pinnedRightPanel];let n=r.centerPanels.find(t=>t.id===e);if(n)return[n,o.centerPanel];let i=r.leftPanels.find(t=>t.id===e);if(i)return i.modal?[i,o.modal]:[i,o.leftPanel];q(!1,`Was not able to find panel with id "${e}"`)}function c(e,t){let{id:r,state:i,stacked:a}=Kd(e,t),[o,c,l]=s(r);if(l&&o.options?.openPinned)l.pin({id:r,state:{...o.defaultState||{},...i||{}}});else{let e={id:r,state:{...o.defaultState||{},...i||{}},stacked:a};n.emit(`layout.open`,e),c.open(e)}}function l(e,t){let{id:r,state:i}=Kd(e,t),[a,o]=s(r),c={id:r,state:{...a.defaultState||{},...i||{}},stacked:!0};n.emit(`layout.open`,c),o.open(c)}function u(e,t){let{id:r,state:i,stacked:a}=Kd(e,t),[o,c]=s(r),l={id:r,state:{...o.defaultState||{},...i||{}},stacked:a};n.emit(`layout.change`,l),c.change(l)}function d(e,t){let{id:r}=Kd(e,t),[,i]=s(r);n.emit(`layout.close`,{id:r}),i.close()}function f(e,t){let{id:r}=Kd(e,t),[,i]=s(r);n.emit(`layout.toggle`,{id:r}),i.toggle()}function p(e,t={},{reset:i,property:a,stacked:s,forceOpen:c,selectedTab:l}={}){let u={resource:rt(e)?e:{type:`SpecificResource`,source:e},...t};n.emit(`layout.edit`,u),o.editingStack.edit(u,i),r.rightPanels.find(e=>e.id===`@manifest-editor/editor`)&&(c?o.rightPanel.open({id:`@manifest-editor/editor`,stacked:s!==!1,state:{property:a,currentTab:l},unique:!0}):o.rightPanel.change({id:`@manifest-editor/editor`,stacked:s!==!1,state:{property:a,currentTab:l},unique:!0}))}async function m(e){o.editingStack.create(e,{}),n.emit(`layout.create`,e),r.modals?.find(e=>e.id===`@manifest-editor/creator`)?o.modal.open({id:`@manifest-editor/creator`,stacked:!0,unique:!0,state:e}):r.rightPanels.find(e=>e.id===`@manifest-editor/creator`)&&o.rightPanel.open({id:`@manifest-editor/creator`,stacked:!0,unique:!0,state:e})}let h={open:c,change:u,close:d,toggle:f,stack:l,edit:p,create:m};return B(ba.Provider,{value:I(()=>({...o,...h}),[r]),children:B(xa.Provider,{value:i,children:e.children})})}),Jd=[{id:`universal-viewer`,config:{url:`https://universalviewer.dev/#?iiifManifestId={manifestId}`},type:`external-manifest-preview`,label:`Universal viewer`},{id:`mirador-3`,type:`external-manifest-preview`,label:`Mirador 3`,config:{url:`https://tomcrane.github.io/scratch/mirador3/?iiif-content={manifestId}`}},{id:`annona`,type:`external-manifest-preview`,label:`Annona`,config:{url:`https://ncsu-libraries.github.io/annona/tools/#/display?url={manifestId}&viewtype=iiif-storyboard&settings=%7B%22fullpage%22%3Atrue%7D`}},{id:`iiif-preview`,config:{url:`https://iiif-preview.digirati.services/store`},type:`iiif-preview-service`,label:`IIIF Preview`}],Yd=new Lt({approximateServices:!0,verificationsRequired:8,enableFetching:!0});function Xd({config:e,saveConfig:t,children:n,theme:r,previews:i,resource:a,editing:o,backgroundActionPersistence:s,localisation:c}){let l=ia(),u=X(),d=J(),f=I(()=>{let t=e?.previews||(d.previews?.length?d.previews:Jd);return an(d,{previews:t},e)},[d,e]),p=I(()=>({appId:l.appId,instanceId:l.instanceId,rootResource:{id:a.id,type:a.type}}),[l.appId,l.instanceId,a.id,a.type]);return B(Wd,{children:B(Ke.Provider,{value:Yd,children:B(ya,{resource:a,children:B(Pa,{children:B(ot,{theme:r||El,children:B(ln,{config:f,saveConfig:t,children:V(Ud,{localisation:c,preset:u.preset?.localisation,children:[B(Xi,{config:f}),B(ea,{}),B(Ka,{}),B(as,{children:B(qd,{children:B(Vr,{persistence:s,persistenceKey:p,children:B(Yl,{children:B(Rs,{children:B(xo,{previews:i||[],configs:f.previews,children:B(Vd,{children:V(Ue,{children:[B(Dc,{}),n]})})})})})})})})]})})})})})})})}const Zd=new Set([`Collection`,`Manifest`,`Canvas`,`Range`,`AnnotationPage`,`Annotation`,`ContentResource`,`Agent`]),Qd={satisfied:0,missing:0,invalid:0,disallowed:0,"not-applicable":0},$d=new Set([`label`,`summary`,`language`,`navDate`,`provider`,`requiredStatement`,`rights`,`thumbnail`]);function ef(e){return e?Array.isArray(e)?e.filter(Boolean):e.split(`.`).filter(Boolean):[]}function tf(e,t){let n=ef(e),r=ef(t);return n.length===r.length&&n.every((e,t)=>e===r[t])}function nf(e,t){let n=e;for(let e of ef(t)){if(n==null)return;n=n[e]}return n}function rf(e,t,n){let r=ef(t);if(!r.length)return n;let i=Array.isArray(e)?[...e]:{...e||{}},a=i;return r.forEach((e,t)=>{if(t===r.length-1){a[e]=n;return}let i=a[e];a[e]=Array.isArray(i)?[...i]:{...i||{}},a=a[e]}),i}function af(e){if(e==null)return!1;if(typeof e==`string`)return e.trim().length>0;if(typeof e==`number`||typeof e==`boolean`)return!0;if(Array.isArray(e))return e.some(e=>af(e));if(typeof e!=`object`)return!1;let t=Object.entries(e);return t.length?!t.every(([,e])=>typeof e==`string`||Array.isArray(e)&&e.every(e=>typeof e==`string`))||t.some(([,e])=>af(e)):!1}function of(e){return Array.isArray(e)?e.map(of):e&&typeof e==`object`?Object.keys(e).sort().reduce((t,n)=>(t[n]=of(e[n]),t),{}):e}function sf(e,t){return JSON.stringify(of(e))===JSON.stringify(of(t))}function cf(e,t,n,r,i){let a=ef(n);for(let n of e||[])for(let e of n.terminology?.properties||[])if(!(e.entityType&&e.entityType!==t)&&tf(e.path,a))return i?i.resolveMessage(e.labelMessage,e.label):e.label;return i?i.translate(`editor-api`)(`fields.${a.join(`.`)}`,void 0,{defaultValue:r||If(a)}):r||If(a)}function lf(e,t,n,r){let i=ef(n),a=[],o,s,c=!1,l=!1;if(!t||!Zd.has(t.type))return{entityType:t?.type,path:i,label:cf(e,t?.type,i,void 0,r),disallowed:!1,required:!1,rules:a};for(let n of e||[])for(let e of n.rules||[])!(`entityType`in e)||!(`path`in e)||e.entityType===t.type&&tf(e.path,i)&&(a.push(e),e.type===`disallow-property`&&(c=!0),e.type===`require-non-empty`&&(l=!0),e.type===`fixed-value`&&!s&&(o=e.value,s=e,l=!0));return{entityType:t.type,path:i,label:cf(e,t.type,i,void 0,r),disallowed:c,required:l,fixedValue:o,fixedValueRule:s,rules:a}}function uf(e,t,n,r){let i=e||[],a=df(t,n),o=[];for(let e of i)for(let[n,r]of(e.rules||[]).entries())o.push(...ff(e,r,n,a,t));return{specifications:i,results:r?o.map(e=>{let t=i.find(t=>t.id===e.specificationId),n=t?.rules[e.ruleIndex],a=e.ruleType===`iiif:metadata-template`?e.displayLabel:e.path?cf(t?[t]:[],e.target?.type,e.path,e.displayLabel,r):e.ruleType===`iiif:canvas-with-image-service`&&!n?.label?r.translate(`shell`)(`specificationFields.canvasImageService`):e.displayLabel,o=e.messageReference?.values?.label===e.displayLabel?{...e.messageReference,values:{...e.messageReference.values,label:a}}:e.messageReference;return{...e,displayLabel:a,ruleLabel:n?.label||a,specificationLabel:r.resolveMessage(t?.labelMessage,e.specificationLabel),messageReference:o,message:r.resolveMessage(o,e.message)}}):o,counts:xf(o)}}function df(e,t){let n=[],r=new Set;function i(t){let a=Cf(t);if(!a)return;if(a.type===`SpecificResource`){i(t?.source);return}let o=Sf(e,t)||Sf(e,a);if(!o||!o.type)return;let s=`${o.type}:${o.id||JSON.stringify(a)}`;if(!r.has(s)){r.add(s),Zd.has(o.type)&&n.push({ref:{id:o.id,type:o.type},resource:o});for(let e of wf(o))i(e)}}return i(t),n}function ff(e,t,n,r,i){switch(t.type){case`disallow-property`:case`require-non-empty`:case`fixed-value`:return pf(e,t,n,r);case`iiif:canvas-with-image-service`:return[mf(e,t,n,r,i)];case`iiif:thumbnail-from-body-service`:return hf(e,t,n,r,i);case`iiif:valid-rights`:return gf(e,t,n,r);case`iiif:required-statement`:return _f(e,t,n,r);case`iiif:metadata-template`:return vf(e,t,n,r);default:return[]}}function pf(e,t,n,r){let i=r.filter(e=>e.ref.type===t.entityType),a=cf(e?[e]:[],t.entityType,t.path);return i.length?i.map(({ref:r,resource:i})=>{let o=nf(i,t.path),s=af(o);if(t.type===`disallow-property`)return yf(e,t,n,{target:r,path:t.path,status:s?`disallowed`:`satisfied`,displayLabel:a,actual:o,message:s?`${a} is present but is not allowed.`:`${a} is not present.`,messageReference:s?{namespace:`shell`,key:`specification.disallowed`,defaultValue:`{{label}} is present but is not allowed.`,values:{label:a}}:{namespace:`shell`,key:`specification.absent`,defaultValue:`{{label}} is not present.`,values:{label:a}},editorTarget:bf(r,t.path)});if(t.type===`require-non-empty`)return yf(e,t,n,{target:r,path:t.path,status:s?`satisfied`:`missing`,displayLabel:a,actual:o,message:s?`${a} has a value.`:`${a} must be filled in.`,messageReference:s?{namespace:`shell`,key:`specification.hasValue`,defaultValue:`{{label}} has a value.`,values:{label:a}}:{namespace:`shell`,key:`specification.required`,defaultValue:`{{label}} must be filled in.`,values:{label:a}},editorTarget:bf(r,t.path)});let c=sf(o,t.value);return yf(e,t,n,{target:r,path:t.path,status:c?`satisfied`:s?`invalid`:`missing`,displayLabel:a,expected:t.value,actual:o,message:c?`${a} matches the required value.`:s?`${a} does not match the required value.`:`${a} must use the required value.`,messageReference:c?{namespace:`shell`,key:`specification.matches`,defaultValue:`{{label}} matches the required value.`,values:{label:a}}:s?{namespace:`shell`,key:`specification.mismatch`,defaultValue:`{{label}} does not match the required value.`,values:{label:a}}:{namespace:`shell`,key:`specification.fixed`,defaultValue:`{{label}} must use the required value.`,values:{label:a}},editorTarget:bf(r,t.path)})}):[yf(e,t,n,{status:`not-applicable`,displayLabel:a,message:`No ${t.entityType} resources were found for ${a}.`,messageReference:{namespace:`shell`,key:`specification.noResources`,defaultValue:`No {{type}} resources were found for {{label}}.`,values:{type:t.entityType,label:a}},path:t.path})]}function mf(e,t,n,r,i){let a=r.filter(e=>e.ref.type===`Canvas`),o=Tf(t),s=a.find(({resource:e})=>Ef(Df(e,i),o));return yf(e,t,n,{target:s?.ref,status:s?`satisfied`:`missing`,displayLabel:t.label||`Canvas image service`,expected:o,message:s?`A canvas contains the required image service.`:o.length?`A canvas must contain one of the required image services: ${o.join(`, `)}.`:`A canvas must contain a painting body with an image service.`,messageReference:s?{namespace:`shell`,key:`specification.servicePresent`,defaultValue:`A canvas contains the required image service.`}:o.length?{namespace:`shell`,key:`specification.serviceList`,defaultValue:`A canvas must contain one of the required image services: {{services}}.`,values:{services:o.join(`, `)}}:{namespace:`shell`,key:`specification.serviceRequired`,defaultValue:`A canvas must contain a painting body with an image service.`},editorTarget:s?bf(s.ref,[`items`]):void 0})}function hf(e,t,n,r,i){let a=t.entityType||`Canvas`,o=r.filter(e=>e.ref.type===a);return o.length?o.map(({ref:o,resource:s})=>{let c=a===`Manifest`?r.filter(e=>e.ref.type===`Canvas`).flatMap(e=>Df(e.resource,i)):Df(s,i),l=Of(s,c,i),u=af(s.thumbnail);return yf(e,t,n,{target:o,path:[`thumbnail`],status:l?`satisfied`:c.length?u?`invalid`:t.requireThumbnail===!1?`not-applicable`:`missing`:`not-applicable`,displayLabel:cf([e],o.type,[`thumbnail`],`Thumbnail`),expected:c,actual:s.thumbnail,message:l?`Thumbnail uses the same image service as the painting content.`:c.length?u?`Thumbnail does not use the same image service as the painting content.`:`Thumbnail must be created from the painting image service.`:`No painting image service was found to compare against.`,messageReference:l?{namespace:`shell`,key:`specification.thumbnailMatches`,defaultValue:`Thumbnail uses the same image service as the painting content.`}:c.length?u?{namespace:`shell`,key:`specification.thumbnailMismatch`,defaultValue:`Thumbnail does not use the same image service as the painting content.`}:{namespace:`shell`,key:`specification.thumbnailRequired`,defaultValue:`Thumbnail must be created from the painting image service.`}:{namespace:`shell`,key:`specification.noPaintingService`,defaultValue:`No painting image service was found to compare against.`},editorTarget:bf(o,[`thumbnail`])})}):[yf(e,t,n,{status:`not-applicable`,displayLabel:`Thumbnail`,message:`No ${a} resources were found for thumbnail checks.`,messageReference:{namespace:`shell`,key:`specification.noThumbnails`,defaultValue:`No {{type}} resources were found for thumbnail checks.`,values:{type:a}}})]}function gf(e,t,n,r){let i=t.entityType||`Manifest`,a=r.filter(e=>e.ref.type===i),o=t.allowed||[];return a.map(({ref:r,resource:i})=>{let a=i.rights,s=af(a),c=typeof a==`string`&&o.map(Mf).includes(Mf(a));return yf(e,t,n,{target:r,path:[`rights`],status:c?`satisfied`:!s&&t.required!==!1?`missing`:`invalid`,displayLabel:cf([e],r.type,[`rights`],`Rights`),expected:o,actual:a,message:c?`Rights uses an allowed URI.`:!s&&t.required!==!1?`Rights must use an allowed URI.`:`Rights is not one of the allowed URIs.`,messageReference:c?{namespace:`shell`,key:`specification.rightsValid`,defaultValue:`Rights uses an allowed URI.`}:!s&&t.required!==!1?{namespace:`shell`,key:`specification.rightsRequired`,defaultValue:`Rights must use an allowed URI.`}:{namespace:`shell`,key:`specification.rightsInvalid`,defaultValue:`Rights is not one of the allowed URIs.`},editorTarget:bf(r,[`rights`])})})}function _f(e,t,n,r){let i=t.entityType||`Manifest`;return r.filter(e=>e.ref.type===i).map(({ref:r,resource:i})=>{let a=i.requiredStatement,o=t.label?Nf(a?.label,t.label):af(a?.label),s=t.value||t.valueRequired!==!1,c=t.value?Nf(a?.value,t.value):!s||af(a?.value),l=af(a);return yf(e,t,n,{target:r,path:[`requiredStatement`],status:o&&c?`satisfied`:l?`invalid`:`missing`,displayLabel:cf([e],r.type,[`requiredStatement`],`Required statement`),expected:t.value||t.label,actual:a,message:o&&c?`Required statement is complete.`:l?`Required statement does not match the specification.`:`Required statement must be filled in.`,messageReference:o&&c?{namespace:`shell`,key:`specification.statementComplete`,defaultValue:`Required statement is complete.`}:l?{namespace:`shell`,key:`specification.statementInvalid`,defaultValue:`Required statement does not match the specification.`}:{namespace:`shell`,key:`specification.statementRequired`,defaultValue:`Required statement must be filled in.`},editorTarget:bf(r,[`requiredStatement`])})})}function vf(e,t,n,r){let i=t.entityType||`Manifest`,a=r.filter(e=>e.ref.type===i),o=[];for(let{ref:r,resource:i}of a){let a=Array.isArray(i.metadata)?i.metadata:[];t.items.forEach((i,s)=>{let c=a.find(e=>Nf(e?.label,i.label)),l=i.value?Nf(c?.value,i.value):!i.valueRequired||af(c?.value),u=c&&l?`satisfied`:c&&i.value?`invalid`:`missing`,d=Ff(i.label);o.push(yf(e,t,n,{idSuffix:`metadata-${s}`,target:r,path:[`metadata`],status:u,displayLabel:d||`Metadata`,expected:i.value||i.label,actual:c,message:c&&l?`${d||`Metadata`} is present.`:c?`${d||`Metadata`} needs a value.`:`${d||`Metadata`} metadata must be added.`,messageReference:c&&l?{namespace:`shell`,key:`specification.metadataPresent`,defaultValue:`{{label}} is present.`,values:{label:d||`Metadata`}}:c?{namespace:`shell`,key:`specification.metadataValue`,defaultValue:`{{label}} needs a value.`,values:{label:d||`Metadata`}}:{namespace:`shell`,key:`specification.metadataRequired`,defaultValue:`{{label}} metadata must be added.`,values:{label:d||`Metadata`}},editorTarget:bf(r,[`metadata`])}))})}return o}function yf(e,t,n,r){let i=t.id||`${t.type}-${n}`,a=r.idSuffix?`-${r.idSuffix}`:``;return{id:`${e.id}-${i}-${r.target?.type||`root`}-${r.target?.id||`none`}${a}`,specificationId:e.id,specificationLabel:e.label,ruleId:i,ruleType:t.type,ruleLabel:t.label||r.displayLabel,ruleIndex:n,target:r.target,path:r.path,status:r.status,displayLabel:r.displayLabel,message:t.message||r.message,messageReference:t.messageReference||(t.message?void 0:r.messageReference),expected:r.expected,actual:r.actual,editorTarget:r.editorTarget}}function bf(e,t){let n=t[0];return{resource:e,propertyPath:t,selectedTab:n===`metadata`?`@manifest-editor/metadata`:n&&$d.has(n)?`@manifest-editor/descriptive-properties`:void 0}}function xf(e){let t={...Qd};for(let n of e)t[n.status]+=1;return t}function Sf(e,t){let n=Cf(t);if(!n)return t;try{return e.get(n,{skipSelfReturn:!1})||t}catch{try{return e.get(n)||t}catch{return t}}}function Cf(e){return!e||typeof e!=`object`?null:e.type===`SpecificResource`?{id:e.id||e.source?.id||``,type:`SpecificResource`}:typeof e.id==`string`&&typeof e.type==`string`?{id:e.id,type:e.type}:null}function wf(e){if(!e||typeof e!=`object`)return[];let t=[];for(let n of[`items`,`structures`,`annotations`,`thumbnail`,`provider`,`homepage`,`rendering`,`seeAlso`,`body`,`target`,`source`]){let r=e[n];Array.isArray(r)?t.push(...r):r&&t.push(r)}return t}function Tf(e){return[...e.serviceIds||[],...e.serviceId?[e.serviceId]:[]].filter(Boolean)}function Ef(e,t){let n=new Set(e.filter(Boolean));return t.length?t.some(e=>n.has(e)):n.size>0}function Df(e,t){let n=jf(t,e?.items),r=[];for(let e of n){let n=jf(t,e?.items);for(let e of n)if((Array.isArray(e?.motivation)?e.motivation:[e?.motivation]).includes(`painting`))for(let n of kf(e?.body,t))r.push(...Af(n))}return Array.from(new Set(r))}function Of(e,t,n){let r=jf(n,e?.thumbnail);if(!r.length||!t.length)return!1;for(let e of r){let n=Af(e),r=typeof e?.id==`string`?e.id:``;if(n.some(e=>t.includes(e))||t.some(e=>r.startsWith(e)))return!0}return!1}function kf(e,t){let n=Sf(t,e);return n?Array.isArray(n)?n.flatMap(e=>kf(e,t)):n.type===`SpecificResource`?kf(n.source,t):n.type===`Choice`?n.items?.flatMap(e=>kf(e,t))||[]:[n]:[]}function Af(e){let t=e?.service||e?.services,n=Array.isArray(t)?t:t?[t]:[],r=[];for(let e of n){let t=typeof e==`string`?e:e?.id||e?.[`@id`];typeof t==`string`&&t&&r.push(t)}return Array.from(new Set(r))}function jf(e,t){if(!t)return[];let n=Array.isArray(t)?t:[t];try{let t=e.get(n);if(Array.isArray(t))return t.filter(Boolean)}catch{}return n.map(t=>Sf(e,t)).filter(Boolean)}function Mf(e){return e.replace(/^https:/,`http:`).replace(/\/?$/,`/`)}function Nf(e,t){return typeof t==`string`?Pf(e).some(e=>e===t):sf(e,t)}function Pf(e){return e?typeof e==`string`?[e.trim()].filter(Boolean):Array.isArray(e)?e.flatMap(Pf):typeof e==`object`?Object.values(e).flatMap(Pf):[]:[]}function Ff(e){return typeof e==`string`?e:Pf(e)[0]||``}function If(e){return(e[e.length-1]||`Property`).replace(/([A-Z])/g,` $1`).replace(/[-_]/g,` `).replace(/^./,e=>e.toUpperCase())}const Lf=M([]);function Rf({children:e,specifications:t}){let n=I(()=>t||[],[t]);return B(Lf.Provider,{value:n,children:e})}function zf(){return P(Lf)}function Bf(e){let{resolveMessage:t,translate:n,locale:r,profile:i}=H(),a=_a(),o=zf(),s=e||a;return nt((e,r)=>uf(o,r,s,{resolveMessage:t,translate:n}),[o,s.id,s.type,t,n,r,i])}function Vf(){let{resolveMessage:e,translate:t,locale:n,profile:r}=H(),i=zf();return I(()=>({getLabel(n,r,a){return cf(i,n,r,a,{resolveMessage:e,translate:t})}}),[i,e,t,n,r])}function Hf(e,t){let n=zf(),{resolveMessage:r,translate:i,locale:a,profile:o}=H();return I(()=>lf(n,e,t,{resolveMessage:r,translate:i}),[n,r,i,a,o,e?.id,e?.type,JSON.stringify(t)])}const Uf={},Wf=M(`global`);function Gf(){return P(Wf)}function Kf(){let e,t;return{promise:new Promise((n,r)=>{e=n,t=r}),resolve:e,reject:t}}function qf(e){let t=Gf(),[,n]=Pe(e=>e+1,0),r=I(()=>(Uf[t]||(Uf[t]={}),Uf[t][e]||(Uf[t][e]={name:e,emitter:Nt(),status:`idle`,promise:Promise.resolve(),abort:new AbortController,reject:()=>void 0,resolve:()=>void 0}),Uf[t][e]),[t,e]);return Jf(r,`abort`,n),Jf(r,`error`,n),Jf(r,`complete`,n),Jf(r,`running`,n),r}function Jf(e,t,n){let r=N(()=>n(e),[n]);F(()=>{let n=e.emitter;return n.on(t,r),()=>n.off(t,r)},[t,r,e.emitter])}const Yf=()=>void 0;function Xf(e,t){let n=qf(e);return Jf(n,`complete`,t||Yf),[e=>{n.status===`running`&&(n.abort.abort(),n.emitter.emit(`abort`)),n.error&&(n.error=``);let t=Kf();t.promise.then(()=>n.emitter.emit(`complete`)).catch(()=>n.emitter.emit(`error`)),n.status=`running`,n.request=e,n.promise=t.promise,n.resolve=t.resolve,n.reject=t.reject,n.emitter.emit(`running`)},n]}function Zf(e,t){let n=qf(e);return Jf(n,`running`,t),[e=>{n.status===`running`&&(n.response=e,n.status=`complete`,n.resolve())},n,(e,t)=>{n.status===`running`&&(n.error=t||e,n.status=`error`,n.reject(e))}]}function Qf({children:e}){return B(Wf.Provider,{value:I(()=>`id-${Date.now()}`,[]),children:e})}function $f(e){return!1}function ep({as:e,reference:t,onReference:n,onLink:r,onAnalysis:i,onDropReference:a,onDropLink:o,onDropAnalysis:s,onPasteReference:c,onPasteLink:l,onPasteAnalysis:u,...d}){let f=e||`div`,p=a||n,m=c||n,h=l||r,g=u||i,_=I(()=>t,[t?.id,t?.type]),v=N(function(e){e.defaultPrevented||(e.preventDefault(),e.clipboardData&&_&&_.id&&_.type&&e.clipboardData.setData(`application/json+vault`,JSON.stringify({id:_.id,type:_.type})))},[_]),y=N(async function(e){if(!e.defaultPrevented&&(e.preventDefault(),e.clipboardData)){if(d.onLoading&&d.onLoading(),m){let t=e.clipboardData.getData(`application/json+vault`);if(t)try{let e=JSON.parse(t);e&&e.id&&e.type&&m(e)}catch{}}if(h||g){let t=e.clipboardData.getData(`text`);if(t.startsWith(`http`)){let e=t.split(`
|
|
1556
|
+
`);for(let t of e){if(g)try{let e=await $f(t);if(e){g(e);continue}}catch{}h&&h(t)}}}d.onComplete&&d.onComplete()}},[]),b=N(function(e){e.defaultPrevented||(e.preventDefault(),e.dataTransfer&&d.draggable&&(e.dataTransfer.effectAllowed=`all`,_&&_.id&&_.type&&e.dataTransfer.setData(`application/json+vault`,JSON.stringify({id:_.id,type:_.type}))))},[]),x=N(async function(e){if(e.preventDefault(),e.dataTransfer){if(p){let t=e.dataTransfer.getData(`application/json+vault`);if(t)try{let n=JSON.parse(t);n&&n.id&&n.type&&p(n,e)}catch{return}}let t=e.dataTransfer.getData(`application/json`);if(t){JSON.parse(t);return}if(e.dataTransfer.getData(`text/plain`))return}},[]),S=N(e=>{e.preventDefault(),e.dataTransfer&&(e.dataTransfer.dropEffect=`copy`)},[]);return B(f,{onCopy:v,onPaste:y,onDrop:x,onDragOver:S,onDragStart:b,tabIndex:-1,...d})}export{Dc as AnnotationRequestCleanup,xc as AppHeader,Tc as AppMenuProvider,la as AppProvider,na as AppReactContext,va as AppResourceInstanceProvider,ya as AppResourceProvider,ra as AppStateReactContext,He as AtlasStoreProvider,We as AtlasStoreReactContext,Xs as BackgroundActionToasts,cc as BackgroundActionsMenu,Js as BackgroundActionsMount,Vr as BackgroundActionsProvider,Br as BackgroundActionsReactContext,Dl as BaseAnnotationCreator,jl as BaseEditor,Ol as BaseEditorBackButton,kl as BaseEditorCloseButton,ko as ButtonChange,Do as ButtonContainer,Io as ButtonEmpty,Oo as ButtonMain,gn as CANVAS_PROGRESS_META_NAMESPACE,_n as CANVAS_PROGRESS_STATUS_META_KEY,Wl as ConfigEditor,ln as ConfigProvider,on as ConfigReactContext,Yl as ContextMenuProvider,Jl as ContextMenuReactContext,pl as CreatorInitialData,Kl as CreatorSettings,as as EditingStack,qo as EditingStackContext,wu as EventEmitterProvider,bu as ExportPanel,ls as FLAG_TAG,Ma as HOMEPAGE_COLLECTION,Au as HandleContainer,Fu as HandleControls,Ul as IIIFOptions,os as InlineEditingStack,Sd as Layout,ba as LayoutActionsReactContext,Sa as LayoutModeReactContext,xa as LayoutStateReactContext,In as ManifestEditorCanvasProgressOverlay,Ms as ManifestEditorTagBadge,js as ManifestEditorTagIcon,Ns as ManifestEditorTagOverlay,kd as ManifestPaginationNavigation,Ao as MenuContainer,jo as MenuItem,Fo as MenuItemClose,Po as MenuItemLabel,No as MenuItemStatus,Rt as MessagePortClientVault,sl as ModularPanel,nl as ModularPanelHeader,rl as ModulePanelButton,pa as MultiAppProvider,Ua as NOTEBOOK_PANEL_ID,$a as NotebookCreatorSources,Wa as NotebookIcon,Qc as PanelError,Xi as PluginConfigBridge,Li as PluginGlobalConfigReactContext,ea as PluginI18nBridge,Bl as PluginManager,Ri as PluginProvider,Ii as PluginReactContext,bc as PresetOnboarding,vc as PresetOnboardingButton,yc as PresetPreviewButton,Ro as PreviewButton,xo as PreviewProvider,Fa as PreviewVaultBoundary,Pa as PreviewVaultContext,Vd as PreviewWindowProvider,ta as PrimeAppReactContext,Ya as ProjectNotebookButton,Ja as ProjectNotebookHeader,Za as ProjectNotebookPanel,Ka as ProjectNotebookSync,Cu as ReactEmitterContext,Uo as ResourceEditingProvider,zo as ResourceEditingReactContext,sn as SaveConfigReactContext,Ud as ShellI18nBoundary,Xd as ShellProvider,Rf as SpecificationProvider,cs as TAGS_META_KEY,ss as TAGS_META_NAMESPACE,Qf as TaskBridge,Rs as ToastProvider,ep as UniversalCopyTarget,Ss as addResourceTag,Mc as analyse,Pc as analyseJson,Pi as applyPlugins,pn as backgroundActionFormatter,mn as backgroundActionLabel,hn as backgroundActionStatus,Tl as baseCreator,Ml as baseEditor,Tn as clearCanvasProgressStatus,Dn as clearCanvasProgressStatuses,df as collectSpecificationResources,Yr as copyToClipboard,qr as createActionIdentity,jr as createBackgroundActionsStore,Jr as createDownload,Id as createIframeVaultBridge,Rr as createLocalForageBackgroundActionPersistence,On as createManifestEditorCanvasProgressApi,Os as createManifestEditorTagsApi,Oi as createPluginRuntimeApi,Fi as createPluginStore,Oa as createPreviewVault,kn as createTrackingCanvasProgressApi,jc as detectMedia,ci as disablePluginInConfig,Al as editBasedOnResource,ki as enablePluginAndDependenciesInConfig,si as enablePluginInConfig,Ha as ensureProjectNote,uf as evaluateSpecifications,$r as extendApp,cd as filterSupportedPanels,Gn as getAvailableBackgroundActionGroups,zn as getBackgroundActionInstanceKey,Sn as getCanvasProgressStatus,Cn as getCanvasProgressStatusFromState,Od as getDefaultLayoutState,Dd as getDefaultPanelState,Di as getEffectivePluginSettings,ni as getEmptyPluginState,Si as getEnabledPluginsForApp,Lc as getFormat,Rc as getImageDimensions,Kr as getManifestNomalized,yi as getPluginCompatibilityReason,Ei as getPluginDefaultSettings,xi as getPluginSelectionSource,Ci as getPluginSettingsFromConfig,gc as getPresetOnboardingDismissalKey,La as getProjectNotebook,lf as getPropertyPolicy,Cs as getResourceTag,Ts as getResourceTagGroups,ys as getResourceTags,bs as getResourceTagsFromState,oa as getSelectedPresetTemplate,ld as getSupportedPanelFallback,cf as getTerminologyLabel,nf as getValueAtPath,af as hasMeaningfulValue,Lo as hasPreviewOption,Es as hasResourceTag,mi as isLazyPlugin,pi as isMappedPlugin,Yc as isPinnableState,vi as isPluginCompatible,bi as isPluginSelected,Ed as layoutReducer,Zr as mapApp,fi as mapLazyPlugin,di as mapPlugin,Bn as mergeBackgroundActionDefinitions,an as mergeConfig,Xt as mergeLocalisation,rn as mergePartialConfig,Qr as mergePresetConfig,_i as mergeProviderPlugins,Yt as mergeUiI18n,Hn as normaliseBackgroundActionError,of as normaliseJsonValue,hi as normalisePlugin,ai as normalisePluginAppConfig,oi as normalisePluginAppsConfig,gi as normalisePlugins,ef as normaliseSpecificationPath,Ba as notebookResourceInput,ud as panelIds,Xc as panelSizing,Ra as parseNotebookMarkdown,ui as pluginAppConfigEquals,Oc as polygonToBoundingBox,Va as projectNotebookSources,Xr as randomId,ws as removeResourceTag,Zc as renderHelper,li as resetPluginInConfig,Ti as resetPluginSettingsInConfig,Pr as runBackgroundAction,za as seedProjectNotebook,wn as setCanvasProgressStatus,En as setCanvasProgressStatuses,wi as setPluginSettingsInConfig,xs as setResourceTags,rf as setValueAtPath,Y as shellTaskMessage,Zt as shellUiI18nSchema,Vn as sortBackgroundActionDefinitions,sf as specificationJsonEquals,tf as specificationPathEquals,Ds as toggleResourceTag,xu as useAnnotationCreatorState,ns as useAnnotationPageEditor,X as useApp,ia as useAppInstance,Cc as useAppMenu,wc as useAppMenuItem,_a as useAppResource,ga as useAppResourceInstance,aa as useAppState,da as useApps,Ec as useAtlasStore,qs as useAvailableBackgroundActions,Ea as useAvailableLayouts,Gs as useBackgroundActionFormatter,Gr as useBackgroundActionHistory,Wr as useBackgroundActionInstance,Ur as useBackgroundActionsStore,Hr as useBackgroundActionsStoreApi,jn as useCanvasProgressActions,An as useCanvasProgressStatus,es as useCollectionEditor,J as useConfig,Qo as useCreatingResource,cl as useCreator,$l as useCustomContextMenu,Nl as useDecayState,Bo as useEditingContext,Xo as useEditingResource,Zo as useEditingResourceStack,Yo as useEditingStack,rs as useEditor,Tu as useEmitter,Ui as useEnabledPlugins,Eu as useEvent,ts as useGenericEditor,zc as useHighlightedImageResource,Vc as useHoverHighlightImageResource,fl as useInitialData,ll as useInlineCreator,wa as useLayoutActions,Ta as useLayoutMode,Da as useLayoutProvider,Ca as useLayoutState,be as useLocalStorage,$o as useManifestEditor,Du as useMatchMedia,qa as useNotebookBrowserPlugins,_c as useOpenPresetOnboarding,xe as useOptionalLocalStorage,zi as useOptionalPluginStoreApi,Ho as useOptionalResource,Cd as usePanelActions,Wi as usePluginActions,qi as usePluginConfigApi,Gi as usePluginRuntimeApi,Ki as usePluginSettings,Bi as usePluginStoreApi,Hi as usePlugins,sa as usePresetTemplateSelection,Co as usePreviewContext,Na as usePreviewHistory,ka as usePreviewVault,Hd as usePreviewWindow,So as usePreviews,Ga as useProjectNotebook,Ji as useResolvedPluginApp,Vo as useResource,Zl as useResourceContextMenuItems,As as useResourceTagActions,ks as useResourceTags,cn as useSaveConfig,Ou as useSaveVault,el as useSetCustomTitle,Hf as useSpecificationPropertyPolicy,Bf as useSpecificationReport,Vf as useSpecificationTerminology,zf as useSpecifications,ku as useSvgTools,qf as useTask,Xf as useTaskDispatch,Jf as useTaskEvent,Zf as useTaskRunner,Bc as useTemporaryHighlight,zs as useToasts,Qt as validateShellUiI18n};
|
|
1532
1557
|
//# sourceMappingURL=index.js.map
|