@manifest-editor/shell 1.0.0 → 1.0.2
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/LICENSE +21 -0
- package/README.md +278 -0
- package/dist/index.cjs +5168 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.css +75 -0
- package/dist/index.css.map +1 -0
- package/dist/index.d.cts +808 -0
- package/dist/index.d.ts +808 -0
- package/dist/index.js +5151 -0
- package/dist/index.js.map +1 -0
- package/package.json +64 -26
- package/dist/cjs/index.cjs +0 -33
- package/dist/cjs/index.cjs.map +0 -1
- package/dist/esm/index.mjs +0 -11867
- package/dist/esm/index.mjs.map +0 -1
- package/dist/style.css +0 -1
- package/index.d.ts +0 -1301
package/dist/cjs/index.cjs
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
"use strict";var e=Object.defineProperty,t=(t,n,r)=>(((t,n,r)=>{n in t?e(t,n,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[n]=r})(t,"symbol"!=typeof n?n+"":n,r),r);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("react"),r=require("mitt"),i=require("styled-components"),o=require("@iiif/parser"),a=require("react-iiif-vault"),s=require("react-dom"),c=require("@manifest-editor/client-vault"),l=require("@iiif/vault"),u=require("react-transition-group");function d(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e)for(const n in e)if("default"!==n){const r=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,r.get?r:{enumerable:!0,get:()=>e[n]})}return t.default=e,Object.freeze(t)}const p=d(n),f=d(l);var h="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},m={},g={get exports(){return m},set exports(e){m=e}},v={},y=n,b=Symbol.for("react.element"),w=Symbol.for("react.fragment"),x=Object.prototype.hasOwnProperty,C=y.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,k={key:!0,ref:!0,__self:!0,__source:!0};function P(e,t,n){var r,i={},o=null,a=null;for(r in void 0!==n&&(o=""+n),void 0!==t.key&&(o=""+t.key),void 0!==t.ref&&(a=t.ref),t)x.call(t,r)&&!k.hasOwnProperty(r)&&(i[r]=t[r]);if(e&&e.defaultProps)for(r in t=e.defaultProps)void 0===i[r]&&(i[r]=t[r]);return{$$typeof:b,type:e,key:o,ref:a,props:i,_owner:C.current}}v.Fragment=w,v.jsx=P,v.jsxs=P,g.exports=v;const A=m.Fragment,S=m.jsx,I=m.jsxs,M=r();function E(e,t){const r=n.useRef(),[i,o]=n.useState(()=>{try{if("undefined"==typeof window||void 0===window.localStorage)return t;const n=window.localStorage.getItem(e);return n&&(r.current=n),n?JSON.parse(n):t}catch(n){return console.log(n),t}});return n.useEffect(()=>{const t=({valueJson:e})=>{if(e&&e!==r.current)try{o(JSON.parse(e)),r.current=e}catch(t){}};return M.on("change:"+e,t),()=>{M.off("change:"+e,t)}},[e]),[i,t=>{try{if("undefined"!=typeof window&&void 0!==window.localStorage){const n=t instanceof Function?t(i):t;o(n);const a=JSON.stringify(n);window.localStorage.setItem(e,a),r.current=a,M.emit("change:"+e,{valueJson:a})}}catch(n){console.log(n)}},r]}var R="Invariant failed";function j(e,t){if(!e)throw new Error(R)}const _=n.createContext(null),O=n.createContext({error:void 0,isError:!1,isLoading:!1});function T(){return n.useContext(O)}function N(){const e=n.useContext(_);return j(e),e}var D={},L=e=>encodeURIComponent(e).replace(/[!'()*]/g,e=>"%"+e.charCodeAt(0).toString(16).toUpperCase()),z=new RegExp("%[a-f0-9]{2}","gi"),F=new RegExp("(%[a-f0-9]{2})+","gi");function W(e,t){try{return decodeURIComponent(e.join(""))}catch(i){}if(1===e.length)return e;t=t||1;var n=e.slice(0,t),r=e.slice(t);return Array.prototype.concat.call([],W(n),W(r))}function B(e){try{return decodeURIComponent(e)}catch(r){for(var t=e.match(z),n=1;n<t.length;n++)t=(e=W(t,n).join("")).match(z);return e}}var $=function(e){if("string"!=typeof e)throw new TypeError("Expected `encodedURI` to be of type `string`, got `"+typeof e+"`");try{return e=e.replace(/\+/g," "),decodeURIComponent(e)}catch(t){return function(e){for(var n={"%FE%FF":"��","%FF%FE":"��"},r=F.exec(e);r;){try{n[r[0]]=decodeURIComponent(r[0])}catch(t){var i=B(r[0]);i!==r[0]&&(n[r[0]]=i)}r=F.exec(e)}n["%C2"]="�";for(var o=Object.keys(n),a=0;a<o.length;a++){var s=o[a];e=e.replace(new RegExp(s,"g"),n[s])}return e}(e)}},q=(e,t)=>{if("string"!=typeof e||"string"!=typeof t)throw new TypeError("Expected the arguments to be of type `string`");if(""===t)return[e];const n=e.indexOf(t);return-1===n?[e]:[e.slice(0,n),e.slice(n+t.length)]},U=function(e,t){for(var n={},r=Object.keys(e),i=Array.isArray(t),o=0;o<r.length;o++){var a=r[o],s=e[a];(i?-1!==t.indexOf(a):t(a,s,e))&&(n[a]=s)}return n};!function(e){const t=L,n=$,r=q,i=U,o=Symbol("encodeFragmentIdentifier");function a(e){if("string"!=typeof e||1!==e.length)throw new TypeError("arrayFormatSeparator must be single character string")}function s(e,n){return n.encode?n.strict?t(e):encodeURIComponent(e):e}function c(e,t){return t.decode?n(e):e}function l(e){const t=e.indexOf("#");return-1!==t&&(e=e.slice(0,t)),e}function u(e){const t=(e=l(e)).indexOf("?");return-1===t?"":e.slice(t+1)}function d(e,t){return t.parseNumbers&&!Number.isNaN(Number(e))&&"string"==typeof e&&""!==e.trim()?e=Number(e):!t.parseBooleans||null===e||"true"!==e.toLowerCase()&&"false"!==e.toLowerCase()||(e="true"===e.toLowerCase()),e}function p(e,t){a((t=Object.assign({decode:!0,sort:!0,arrayFormat:"none",arrayFormatSeparator:",",parseNumbers:!1,parseBooleans:!1},t)).arrayFormatSeparator);const n=function(e){let t;switch(e.arrayFormat){case"index":return(e,n,r)=>{t=/\[(\d*)\]$/.exec(e),e=e.replace(/\[\d*\]$/,""),t?(void 0===r[e]&&(r[e]={}),r[e][t[1]]=n):r[e]=n};case"bracket":return(e,n,r)=>{t=/(\[\])$/.exec(e),e=e.replace(/\[\]$/,""),t?void 0!==r[e]?r[e]=[].concat(r[e],n):r[e]=[n]:r[e]=n};case"colon-list-separator":return(e,n,r)=>{t=/(:list)$/.exec(e),e=e.replace(/:list$/,""),t?void 0!==r[e]?r[e]=[].concat(r[e],n):r[e]=[n]:r[e]=n};case"comma":case"separator":return(t,n,r)=>{const i="string"==typeof n&&n.includes(e.arrayFormatSeparator),o="string"==typeof n&&!i&&c(n,e).includes(e.arrayFormatSeparator);n=o?c(n,e):n;const a=i||o?n.split(e.arrayFormatSeparator).map(t=>c(t,e)):null===n?n:c(n,e);r[t]=a};case"bracket-separator":return(t,n,r)=>{const i=/(\[\])$/.test(t);if(t=t.replace(/\[\]$/,""),!i)return void(r[t]=n?c(n,e):n);const o=null===n?[]:n.split(e.arrayFormatSeparator).map(t=>c(t,e));void 0!==r[t]?r[t]=[].concat(r[t],o):r[t]=o};default:return(e,t,n)=>{void 0!==n[e]?n[e]=[].concat(n[e],t):n[e]=t}}}(t),i=Object.create(null);if("string"!=typeof e)return i;if(!(e=e.trim().replace(/^[?#&]/,"")))return i;for(const o of e.split("&")){if(""===o)continue;let[e,a]=r(t.decode?o.replace(/\+/g," "):o,"=");a=void 0===a?null:["comma","separator","bracket-separator"].includes(t.arrayFormat)?a:c(a,t),n(c(e,t),a,i)}for(const r of Object.keys(i)){const e=i[r];if("object"==typeof e&&null!==e)for(const n of Object.keys(e))e[n]=d(e[n],t);else i[r]=d(e,t)}return!1===t.sort?i:(!0===t.sort?Object.keys(i).sort():Object.keys(i).sort(t.sort)).reduce((e,t)=>{const n=i[t];return Boolean(n)&&"object"==typeof n&&!Array.isArray(n)?e[t]=function e(t){return Array.isArray(t)?t.sort():"object"==typeof t?e(Object.keys(t)).sort((e,t)=>Number(e)-Number(t)).map(e=>t[e]):t}(n):e[t]=n,e},Object.create(null))}e.extract=u,e.parse=p,e.stringify=(e,t)=>{if(!e)return"";a((t=Object.assign({encode:!0,strict:!0,arrayFormat:"none",arrayFormatSeparator:","},t)).arrayFormatSeparator);const n=n=>t.skipNull&&null==e[n]||t.skipEmptyString&&""===e[n],r=function(e){switch(e.arrayFormat){case"index":return t=>(n,r)=>{const i=n.length;return void 0===r||e.skipNull&&null===r||e.skipEmptyString&&""===r?n:null===r?[...n,[s(t,e),"[",i,"]"].join("")]:[...n,[s(t,e),"[",s(i,e),"]=",s(r,e)].join("")]};case"bracket":return t=>(n,r)=>void 0===r||e.skipNull&&null===r||e.skipEmptyString&&""===r?n:null===r?[...n,[s(t,e),"[]"].join("")]:[...n,[s(t,e),"[]=",s(r,e)].join("")];case"colon-list-separator":return t=>(n,r)=>void 0===r||e.skipNull&&null===r||e.skipEmptyString&&""===r?n:null===r?[...n,[s(t,e),":list="].join("")]:[...n,[s(t,e),":list=",s(r,e)].join("")];case"comma":case"separator":case"bracket-separator":{const t="bracket-separator"===e.arrayFormat?"[]=":"=";return n=>(r,i)=>void 0===i||e.skipNull&&null===i||e.skipEmptyString&&""===i?r:(i=null===i?"":i,0===r.length?[[s(n,e),t,s(i,e)].join("")]:[[r,s(i,e)].join(e.arrayFormatSeparator)])}default:return t=>(n,r)=>void 0===r||e.skipNull&&null===r||e.skipEmptyString&&""===r?n:null===r?[...n,s(t,e)]:[...n,[s(t,e),"=",s(r,e)].join("")]}}(t),i={};for(const a of Object.keys(e))n(a)||(i[a]=e[a]);const o=Object.keys(i);return!1!==t.sort&&o.sort(t.sort),o.map(n=>{const i=e[n];return void 0===i?"":null===i?s(n,t):Array.isArray(i)?0===i.length&&"bracket-separator"===t.arrayFormat?s(n,t)+"[]":i.reduce(r(n),[]).join("&"):s(n,t)+"="+s(i,t)}).filter(e=>e.length>0).join("&")},e.parseUrl=(e,t)=>{t=Object.assign({decode:!0},t);const[n,i]=r(e,"#");return Object.assign({url:n.split("?")[0]||"",query:p(u(e),t)},t&&t.parseFragmentIdentifier&&i?{fragmentIdentifier:c(i,t)}:{})},e.stringifyUrl=(t,n)=>{n=Object.assign({encode:!0,strict:!0,[o]:!0},n);const r=l(t.url).split("?")[0]||"",i=e.extract(t.url),a=e.parse(i,{sort:!1}),c=Object.assign(a,t.query);let u=e.stringify(c,n);u&&(u="?"+u);let d=function(e){let t="";const n=e.indexOf("#");return-1!==n&&(t=e.slice(n)),t}(t.url);return t.fragmentIdentifier&&(d="#"+(n[o]?s(t.fragmentIdentifier,n):t.fragmentIdentifier)),`${r}${u}${d}`},e.pick=(t,n,r)=>{r=Object.assign({parseFragmentIdentifier:!0,[o]:!1},r);const{url:a,query:s,fragmentIdentifier:c}=e.parseUrl(t,r);return e.stringifyUrl({url:a,query:i(s,n),fragmentIdentifier:c},r)},e.exclude=(t,n,r)=>{const i=Array.isArray(n)?e=>!n.includes(e):(e,t)=>!n(e,t);return e.pick(t,i,r)}}(D);const H=n.createContext(null),V=n.createContext({state:null,setState:()=>{}});function J(){const e=n.useContext(H);return j(e),e}function Y(){return n.useContext(V)}function G(e,t=!1){const r=Y(),[i,o]=function(e,t,r){const[i,o]=n.useState(t),[a,s]=E(e,t);return r?[i,o]:[a,s]}("SelectedApplication",e||{id:"splash"},!t);return n.useEffect(()=>{if("true"==={}.PULL_REQUEST&&window){const{app:e,...t}=D.parse(window.location.toString().split("?")[1]||"")||{};e&&(o({id:e,args:t}),t&&r.setState(t))}},[]),[i,o]}function Z({apps:e,initialApp:t,saveCurrentApp:r=!0,children:i}){const[o,a]=G(t,r),s=e=>{"Manifest"===e.resource.type&&a({id:"manifest-editor"}),"Collection"===e.resource.type&&a({id:"collection-editor"})},c=n.useMemo(()=>({currentApp:o||{id:"splash"},initialApp:t||{id:"splash"},apps:e,changeApp:a,editProject:s}),[t,e,o]);return S(H.Provider,{value:c,children:i})}const K=i.button.withConfig({displayName:"ButtonReset",componentId:"sc-u2n7tf-0"})(["border:none;outline:none;background-color:transparent;margin:0;padding:0;font-size:inherit;color:inherit;cursor:pointer;&:hover{color:inherit;}"]),X=i.button.withConfig({displayName:"Button",componentId:"sc-u2n7tf-1"})(["padding:0 ",";color:",";background-color:",";border-radius:inherit;border:none;cursor:pointer;display:flex;align-items:center;height:2rem;:disabled{opacity:0.65;cursor:not-allowed;}&:hover{background:#eee;}"],e=>e.theme.padding.small||"0.5rem",e=>e.theme.color.main||"none",e=>e.theme.color.white||"white"),Q=i(X).withConfig({displayName:"SmallButton",componentId:"sc-u2n7tf-2"})(["padding:0.25em ",";height:unset;background:none;"],e=>e.theme.padding.xs||"0.4em");i(X).withConfig({displayName:"SecondaryButton",componentId:"sc-u2n7tf-3"})(["{padding:0 ",";color:",";background-color:",";border:1px solid ",";border-radius:0.25rem;cursor:pointer;height:2rem;display:flex;align-items:center;white-space:nowrap;font-size:0.75rem;:disabled{opacity:0.65;cursor:not-allowed;}}"],e=>e.theme.padding.medium||"1rem",e=>e.theme.color.main||"#347cff;",e=>e.theme.color.white||"white",e=>e.theme.color.main||"#347cff;");const ee=i(X).withConfig({displayName:"CalltoButton",componentId:"sc-u2n7tf-4"})(["padding:0 ",";color:",";background-color:",";border:none;border-radius:0.25rem;cursor:pointer;justify-content:center;display:flex;align-items:center;&:hover{background-color:",";}"],e=>e.theme.padding.medium||"1rem",e=>e.theme.color.white||"white",e=>e.theme.color.main||"#347cff;",e=>e.theme.color.mainHover||"#347cff;");i.div.withConfig({displayName:"ButtonGroup",componentId:"sc-u2n7tf-5"})(["display:flex;flex-direction:row;flex-wrap:wrap;align-items:flex-start;justify-content:",";"],e=>e.$right?"flex-end":"flex-start");const te=i.div.withConfig({displayName:"Container",componentId:"sc-2rgia8-0"})(["display:flex;align-items:center;height:3em;padding:0.5em;"]),ne=i.div.withConfig({displayName:"Header",componentId:"sc-2rgia8-1"})(["display:flex;padding:0.25em;flex-direction:column;"]),re=i.button.withConfig({displayName:"IconButton",componentId:"sc-2rgia8-2"})(["height:1.75em;width:1.75em;background:#e9e9e9;border-radius:3px;display:flex;text-align:center;align-items:center;font-size:1.1em;border:none;justify-content:center;&:focus{background:#e94581;color:#fff;svg{fill:#fff;}}"]);i.div.withConfig({displayName:"Spacer",componentId:"sc-2rgia8-3"})(["flex:1;"]);const ie=i.div.withConfig({displayName:"Logo",componentId:"sc-2rgia8-4"})(["color:#6e6e6e;display:flex;align-items:center;margin-left:1em;font-weight:bold;text-rendering:geometricPrecision;letter-spacing:-0.5px;user-select:none;cursor:pointer;margin-right:0.5em;"]),oe=i.div.withConfig({displayName:"ProjectPreview",componentId:"sc-2rgia8-5"})(["margin:0 auto;padding:3px;background:#f4f4f4;border:1px solid #e0e0e0;border-radius:5px;width:26em;display:flex;flex-direction:row;@media (max-width:450px){display:none;}"]),ae=i.div.withConfig({displayName:"Draft",componentId:"sc-2rgia8-6"})(["display:flex;flex-direction:row;flex:1;padding:0.28em;padding-left:0.5em;align-items:center;overflow:hidden;"]),se=i.div.withConfig({displayName:"DraftsText",componentId:"sc-2rgia8-7"})(["color:#828282;padding-right:1em;"]),ce=i.form.withConfig({displayName:"DraftTitleEdit",componentId:"sc-2rgia8-8"})(["margin:0;padding:0;display:flex;flex:1;"]),le=i.input.withConfig({displayName:"DraftTitleEditInput",componentId:"sc-2rgia8-9"})(["font-size:1em;flex:1;border:1px solid #999;padding:0.2em;margin:-0.2em 0;"]),ue=i(Q).withConfig({displayName:"DraftTitleEditButton",componentId:"sc-2rgia8-10"})(["font-size:1em;display:inline-block;"]),de=i.div.withConfig({displayName:"DraftTitle",componentId:"sc-2rgia8-11"})(["color:#333;flex:1;text-overflow:ellipsis;white-space:nowrap;overflow:hidden;"]);i.button.withConfig({displayName:"ContextButton",componentId:"sc-2rgia8-12"})(["background:#e7fff4;border:1px solid #c5e3cd;box-shadow:0 1px 2px 0 rgba(0,0,0,0.06);border-radius:4px;color:#666666;padding:0.35em 0.7em;letter-spacing:-0.42px;"]);class pe{constructor({id:e,config:n,label:r}){t(this,"id"),t(this,"label"),t(this,"type","external-manifest-preview"),t(this,"focusable",!0),t(this,"serviceUrl"),t(this,"windows",{}),this.id=e,this.label=r,this.serviceUrl=n.url}isPreviewValid(e){const t=this.windows[e.id];return!(!t||!t.window||t.window.closed)}getRequires(){return["readOnlyManifest"]}getProvides(){return[]}async createPreview(e,t,n){const r=(""+this.serviceUrl).replace(/\{manifestId}/,n.readOnlyManifest).replace(/\{time}/,""+Date.now()),i=window.open(r,this.id);return this.windows[e.id]={location:r,window:i},{id:this.id,type:"external-manifest-preview",data:{url:r}}}async focus(e){const t=this.windows[e.id];t&&t.window&&t.window.focus()}async updatePreview(e,t,n){return this.windows[e.id],this.createPreview(e,t,n)}async deletePreview(e){const t=this.windows[e];t&&t.window&&(t.window.close(),delete this.windows[e])}}class fe{constructor({id:e,config:n,label:r}){t(this,"id"),t(this,"label"),t(this,"type","iiif-preview-service"),t(this,"focusable",!1),t(this,"serviceUrl"),t(this,"cache",{}),this.id=e,this.label=r,this.serviceUrl=n.url}getRequires(){return[]}getProvides(){return["readOnlyManifest"]}isPreviewValid(e){return!!this.cache[e.id]}async createPreview(e,t){const n=t.toPresentation3(e.resource),r=await fetch(this.serviceUrl,{method:"POST",headers:{"Content-Type":"application/json",Origin:"*"},body:JSON.stringify(n)});j(r.ok);const i=await r.json();return j(i.location),this.cache[e.id]={...i,time:Date.now()},{id:this.id,type:"external-manifest-preview",data:{readOnlyManifest:`${i.location}/${Date.now()}`}}}async focus(){}async updatePreview(e,t){const n=this.cache[e.id];if(!n||Date.now()>n.expirationTtl+n.time||!n.updateLocation)return this.createPreview(e,t);const r=n.updateLocation,i=t.toPresentation3(e.resource),o=await fetch(r,{method:"PUT",headers:{"Content-Type":"application/json",Origin:"*"},body:JSON.stringify(i)});j(o.ok);const a=await o.json();j(a.location),a.updateLocation&&(n.updateLocation=a.updateLocation);const s=`${a.location}/${Date.now()}`;return await fetch(s,{cache:"no-cache"}),{id:this.id,type:"external-manifest-preview",data:{readOnlyManifest:`${a.location}/${Date.now()}`}}}async deletePreview(e){const t=this.cache[e];if(t&&t.deleteLocation)try{await fetch(t.deleteLocation,{method:"DELETE",headers:{"Content-Type":"application/json",Origin:"*"}})}catch(n){}}}var he=function(e,t){return(he=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])})(e,t)};function me(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function n(){this.constructor=e}he(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}var ge=function(){return(ge=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e}).apply(this,arguments)};function ve(e,t,n,r){return new(n||(n=Promise))((function(i,o){function a(e){try{c(r.next(e))}catch(t){o(t)}}function s(e){try{c(r.throw(e))}catch(t){o(t)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(a,s)}c((r=r.apply(e,t||[])).next())}))}function ye(e,t){var n,r,i,o,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function s(o){return function(s){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(i=2&o[0]?r.return:o[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,o[1])).done)return i;switch(r=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return a.label++,{value:o[1],done:!1};case 5:a.label++,r=o[1],o=[0];continue;case 7:o=a.ops.pop(),a.trys.pop();continue;default:if(!((i=(i=a.trys).length>0&&i[i.length-1])||6!==o[0]&&2!==o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){a.label=o[1];break}if(6===o[0]&&a.label<i[1]){a.label=i[1],i=o;break}if(i&&a.label<i[2]){a.label=i[2],a.ops.push(o);break}i[2]&&a.ops.pop(),a.trys.pop();continue}o=t.call(e,a)}catch(s){o=[6,s],r=0}finally{n=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,s])}}}function be(e,t){void 0===t&&(t=!1);var n=window.crypto.getRandomValues(new Uint32Array(1))[0],r="_".concat(n);return Object.defineProperty(window,r,{value:function(n){return t&&Reflect.deleteProperty(window,r),null==e?void 0:e(n)},writable:!1,configurable:!0}),n}function we(e,t){return void 0===t&&(t={}),ve(this,void 0,void 0,(function(){return ye(this,(function(n){return[2,new Promise((function(n,r){var i=be((function(e){n(e),Reflect.deleteProperty(window,"_".concat(o))}),!0),o=be((function(e){r(e),Reflect.deleteProperty(window,"_".concat(i))}),!0);window.__TAURI_IPC__(ge({cmd:e,callback:i,error:o},t))}))]}))}))}function xe(e){return ve(this,void 0,void 0,(function(){return ye(this,(function(t){return[2,we("tauri",e)]}))}))}function Ce(e,t){return ve(this,void 0,void 0,(function(){return ye(this,(function(n){return[2,xe({__tauriModule:"Event",message:{cmd:"unlisten",event:e,eventId:t}})]}))}))}function ke(e,t,n){return ve(this,void 0,void 0,(function(){return ye(this,(function(r){switch(r.label){case 0:return[4,xe({__tauriModule:"Event",message:{cmd:"emit",event:e,windowLabel:t,payload:"string"==typeof n?n:JSON.stringify(n)}})];case 1:return r.sent(),[2]}}))}))}function Pe(e,t,n){return ve(this,void 0,void 0,(function(){var r=this;return ye(this,(function(i){return[2,xe({__tauriModule:"Event",message:{cmd:"listen",event:e,windowLabel:t,handler:be(n)}}).then((function(t){return function(){return ve(r,void 0,void 0,(function(){return ye(this,(function(n){return[2,Ce(e,t)]}))}))}}))]}))}))}function Ae(e,t,n){return ve(this,void 0,void 0,(function(){return ye(this,(function(r){return[2,Pe(e,t,(function(t){n(t),Ce(e,t.id).catch((function(){}))}))]}))}))}var Se,Ie,Me=function(e,t){this.type="Logical",this.width=e,this.height=t},Ee=function(){function e(e,t){this.type="Physical",this.width=e,this.height=t}return e.prototype.toLogical=function(e){return new Me(this.width/e,this.height/e)},e}(),Re=function(e,t){this.type="Logical",this.x=e,this.y=t},je=function(){function e(e,t){this.type="Physical",this.x=e,this.y=t}return e.prototype.toLogical=function(e){return new Re(this.x/e,this.y/e)},e}();(Ie=Se||(Se={}))[Ie.Critical=1]="Critical",Ie[Ie.Informational=2]="Informational";var _e=["tauri://created","tauri://error"],Oe=function(e){function t(t,n){void 0===n&&(n={});var r=e.call(this,t)||this;return(null==n?void 0:n.skip)||xe({__tauriModule:"Window",message:{cmd:"createWebview",data:{options:ge({label:t},n)}}}).then((function(){return ve(r,void 0,void 0,(function(){return ye(this,(function(e){return[2,this.emit("tauri://created")]}))}))})).catch((function(e){return ve(r,void 0,void 0,(function(){return ye(this,(function(t){return[2,this.emit("tauri://error",e)]}))}))})),r}return me(t,e),t.getByLabel=function(e){return window.__TAURI_METADATA__.__windows.map((function(e){return new Oe(e.label,{skip:!0})})).some((function(t){return t.label===e}))?new t(e,{skip:!0}):null},t}(function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return me(t,e),t.prototype.scaleFactor=function(){return ve(this,void 0,void 0,(function(){return ye(this,(function(e){return[2,xe({__tauriModule:"Window",message:{cmd:"manage",data:{label:this.label,cmd:{type:"scaleFactor"}}}})]}))}))},t.prototype.innerPosition=function(){return ve(this,void 0,void 0,(function(){return ye(this,(function(e){return[2,xe({__tauriModule:"Window",message:{cmd:"manage",data:{label:this.label,cmd:{type:"innerPosition"}}}}).then((function(e){var t=e.x,n=e.y;return new je(t,n)}))]}))}))},t.prototype.outerPosition=function(){return ve(this,void 0,void 0,(function(){return ye(this,(function(e){return[2,xe({__tauriModule:"Window",message:{cmd:"manage",data:{label:this.label,cmd:{type:"outerPosition"}}}}).then((function(e){var t=e.x,n=e.y;return new je(t,n)}))]}))}))},t.prototype.innerSize=function(){return ve(this,void 0,void 0,(function(){return ye(this,(function(e){return[2,xe({__tauriModule:"Window",message:{cmd:"manage",data:{label:this.label,cmd:{type:"innerSize"}}}}).then((function(e){var t=e.width,n=e.height;return new Ee(t,n)}))]}))}))},t.prototype.outerSize=function(){return ve(this,void 0,void 0,(function(){return ye(this,(function(e){return[2,xe({__tauriModule:"Window",message:{cmd:"manage",data:{label:this.label,cmd:{type:"outerSize"}}}}).then((function(e){var t=e.width,n=e.height;return new Ee(t,n)}))]}))}))},t.prototype.isFullscreen=function(){return ve(this,void 0,void 0,(function(){return ye(this,(function(e){return[2,xe({__tauriModule:"Window",message:{cmd:"manage",data:{label:this.label,cmd:{type:"isFullscreen"}}}})]}))}))},t.prototype.isMaximized=function(){return ve(this,void 0,void 0,(function(){return ye(this,(function(e){return[2,xe({__tauriModule:"Window",message:{cmd:"manage",data:{label:this.label,cmd:{type:"isMaximized"}}}})]}))}))},t.prototype.isDecorated=function(){return ve(this,void 0,void 0,(function(){return ye(this,(function(e){return[2,xe({__tauriModule:"Window",message:{cmd:"manage",data:{label:this.label,cmd:{type:"isDecorated"}}}})]}))}))},t.prototype.isResizable=function(){return ve(this,void 0,void 0,(function(){return ye(this,(function(e){return[2,xe({__tauriModule:"Window",message:{cmd:"manage",data:{label:this.label,cmd:{type:"isResizable"}}}})]}))}))},t.prototype.isVisible=function(){return ve(this,void 0,void 0,(function(){return ye(this,(function(e){return[2,xe({__tauriModule:"Window",message:{cmd:"manage",data:{label:this.label,cmd:{type:"isVisible"}}}})]}))}))},t.prototype.theme=function(){return ve(this,void 0,void 0,(function(){return ye(this,(function(e){return[2,xe({__tauriModule:"Window",message:{cmd:"manage",data:{label:this.label,cmd:{type:"theme"}}}})]}))}))},t.prototype.center=function(){return ve(this,void 0,void 0,(function(){return ye(this,(function(e){return[2,xe({__tauriModule:"Window",message:{cmd:"manage",data:{label:this.label,cmd:{type:"center"}}}})]}))}))},t.prototype.requestUserAttention=function(e){return ve(this,void 0,void 0,(function(){var t;return ye(this,(function(n){return t=null,e&&(t=e===Se.Critical?{type:"Critical"}:{type:"Informational"}),[2,xe({__tauriModule:"Window",message:{cmd:"manage",data:{label:this.label,cmd:{type:"requestUserAttention",payload:t}}}})]}))}))},t.prototype.setResizable=function(e){return ve(this,void 0,void 0,(function(){return ye(this,(function(t){return[2,xe({__tauriModule:"Window",message:{cmd:"manage",data:{label:this.label,cmd:{type:"setResizable",payload:e}}}})]}))}))},t.prototype.setTitle=function(e){return ve(this,void 0,void 0,(function(){return ye(this,(function(t){return[2,xe({__tauriModule:"Window",message:{cmd:"manage",data:{label:this.label,cmd:{type:"setTitle",payload:e}}}})]}))}))},t.prototype.maximize=function(){return ve(this,void 0,void 0,(function(){return ye(this,(function(e){return[2,xe({__tauriModule:"Window",message:{cmd:"manage",data:{label:this.label,cmd:{type:"maximize"}}}})]}))}))},t.prototype.unmaximize=function(){return ve(this,void 0,void 0,(function(){return ye(this,(function(e){return[2,xe({__tauriModule:"Window",message:{cmd:"manage",data:{label:this.label,cmd:{type:"unmaximize"}}}})]}))}))},t.prototype.toggleMaximize=function(){return ve(this,void 0,void 0,(function(){return ye(this,(function(e){return[2,xe({__tauriModule:"Window",message:{cmd:"manage",data:{label:this.label,cmd:{type:"toggleMaximize"}}}})]}))}))},t.prototype.minimize=function(){return ve(this,void 0,void 0,(function(){return ye(this,(function(e){return[2,xe({__tauriModule:"Window",message:{cmd:"manage",data:{label:this.label,cmd:{type:"minimize"}}}})]}))}))},t.prototype.unminimize=function(){return ve(this,void 0,void 0,(function(){return ye(this,(function(e){return[2,xe({__tauriModule:"Window",message:{cmd:"manage",data:{label:this.label,cmd:{type:"unminimize"}}}})]}))}))},t.prototype.show=function(){return ve(this,void 0,void 0,(function(){return ye(this,(function(e){return[2,xe({__tauriModule:"Window",message:{cmd:"manage",data:{label:this.label,cmd:{type:"show"}}}})]}))}))},t.prototype.hide=function(){return ve(this,void 0,void 0,(function(){return ye(this,(function(e){return[2,xe({__tauriModule:"Window",message:{cmd:"manage",data:{label:this.label,cmd:{type:"hide"}}}})]}))}))},t.prototype.close=function(){return ve(this,void 0,void 0,(function(){return ye(this,(function(e){return[2,xe({__tauriModule:"Window",message:{cmd:"manage",data:{label:this.label,cmd:{type:"close"}}}})]}))}))},t.prototype.setDecorations=function(e){return ve(this,void 0,void 0,(function(){return ye(this,(function(t){return[2,xe({__tauriModule:"Window",message:{cmd:"manage",data:{label:this.label,cmd:{type:"setDecorations",payload:e}}}})]}))}))},t.prototype.setAlwaysOnTop=function(e){return ve(this,void 0,void 0,(function(){return ye(this,(function(t){return[2,xe({__tauriModule:"Window",message:{cmd:"manage",data:{label:this.label,cmd:{type:"setAlwaysOnTop",payload:e}}}})]}))}))},t.prototype.setSize=function(e){return ve(this,void 0,void 0,(function(){return ye(this,(function(t){if(!e||"Logical"!==e.type&&"Physical"!==e.type)throw new Error("the `size` argument must be either a LogicalSize or a PhysicalSize instance");return[2,xe({__tauriModule:"Window",message:{cmd:"manage",data:{label:this.label,cmd:{type:"setSize",payload:{type:e.type,data:{width:e.width,height:e.height}}}}}})]}))}))},t.prototype.setMinSize=function(e){return ve(this,void 0,void 0,(function(){return ye(this,(function(t){if(e&&"Logical"!==e.type&&"Physical"!==e.type)throw new Error("the `size` argument must be either a LogicalSize or a PhysicalSize instance");return[2,xe({__tauriModule:"Window",message:{cmd:"manage",data:{label:this.label,cmd:{type:"setMinSize",payload:e?{type:e.type,data:{width:e.width,height:e.height}}:null}}}})]}))}))},t.prototype.setMaxSize=function(e){return ve(this,void 0,void 0,(function(){return ye(this,(function(t){if(e&&"Logical"!==e.type&&"Physical"!==e.type)throw new Error("the `size` argument must be either a LogicalSize or a PhysicalSize instance");return[2,xe({__tauriModule:"Window",message:{cmd:"manage",data:{label:this.label,cmd:{type:"setMaxSize",payload:e?{type:e.type,data:{width:e.width,height:e.height}}:null}}}})]}))}))},t.prototype.setPosition=function(e){return ve(this,void 0,void 0,(function(){return ye(this,(function(t){if(!e||"Logical"!==e.type&&"Physical"!==e.type)throw new Error("the `position` argument must be either a LogicalPosition or a PhysicalPosition instance");return[2,xe({__tauriModule:"Window",message:{cmd:"manage",data:{label:this.label,cmd:{type:"setPosition",payload:{type:e.type,data:{x:e.x,y:e.y}}}}}})]}))}))},t.prototype.setFullscreen=function(e){return ve(this,void 0,void 0,(function(){return ye(this,(function(t){return[2,xe({__tauriModule:"Window",message:{cmd:"manage",data:{label:this.label,cmd:{type:"setFullscreen",payload:e}}}})]}))}))},t.prototype.setFocus=function(){return ve(this,void 0,void 0,(function(){return ye(this,(function(e){return[2,xe({__tauriModule:"Window",message:{cmd:"manage",data:{label:this.label,cmd:{type:"setFocus"}}}})]}))}))},t.prototype.setIcon=function(e){return ve(this,void 0,void 0,(function(){return ye(this,(function(t){return[2,xe({__tauriModule:"Window",message:{cmd:"manage",data:{label:this.label,cmd:{type:"setIcon",payload:{icon:"string"==typeof e?e:Array.from(e)}}}}})]}))}))},t.prototype.setSkipTaskbar=function(e){return ve(this,void 0,void 0,(function(){return ye(this,(function(t){return[2,xe({__tauriModule:"Window",message:{cmd:"manage",data:{label:this.label,cmd:{type:"setSkipTaskbar",payload:e}}}})]}))}))},t.prototype.setCursorGrab=function(e){return ve(this,void 0,void 0,(function(){return ye(this,(function(t){return[2,xe({__tauriModule:"Window",message:{cmd:"manage",data:{label:this.label,cmd:{type:"setCursorGrab",payload:e}}}})]}))}))},t.prototype.setCursorVisible=function(e){return ve(this,void 0,void 0,(function(){return ye(this,(function(t){return[2,xe({__tauriModule:"Window",message:{cmd:"manage",data:{label:this.label,cmd:{type:"setCursorVisible",payload:e}}}})]}))}))},t.prototype.setCursorIcon=function(e){return ve(this,void 0,void 0,(function(){return ye(this,(function(t){return[2,xe({__tauriModule:"Window",message:{cmd:"manage",data:{label:this.label,cmd:{type:"setCursorIcon",payload:e}}}})]}))}))},t.prototype.setCursorPosition=function(e){return ve(this,void 0,void 0,(function(){return ye(this,(function(t){if(!e||"Logical"!==e.type&&"Physical"!==e.type)throw new Error("the `position` argument must be either a LogicalPosition or a PhysicalPosition instance");return[2,xe({__tauriModule:"Window",message:{cmd:"manage",data:{label:this.label,cmd:{type:"setCursorPosition",payload:{type:e.type,data:{x:e.x,y:e.y}}}}}})]}))}))},t.prototype.startDragging=function(){return ve(this,void 0,void 0,(function(){return ye(this,(function(e){return[2,xe({__tauriModule:"Window",message:{cmd:"manage",data:{label:this.label,cmd:{type:"startDragging"}}}})]}))}))},t}(function(){function e(e){this.label=e,this.listeners=Object.create(null)}return e.prototype.listen=function(e,t){return ve(this,void 0,void 0,(function(){var n=this;return ye(this,(function(r){return this._handleTauriEvent(e,t)?[2,Promise.resolve((function(){var r=n.listeners[e];r.splice(r.indexOf(t),1)}))]:[2,Pe(e,this.label,t)]}))}))},e.prototype.once=function(e,t){return ve(this,void 0,void 0,(function(){var n=this;return ye(this,(function(r){return this._handleTauriEvent(e,t)?[2,Promise.resolve((function(){var r=n.listeners[e];r.splice(r.indexOf(t),1)}))]:[2,Ae(e,this.label,t)]}))}))},e.prototype.emit=function(e,t){return ve(this,void 0,void 0,(function(){var n,r;return ye(this,(function(i){if(_e.includes(e)){for(n=0,r=this.listeners[e]||[];n<r.length;n++)(0,r[n])({event:e,id:-1,windowLabel:this.label,payload:t});return[2,Promise.resolve()]}return[2,ke(e,this.label,t)]}))}))},e.prototype._handleTauriEvent=function(e,t){return!!_e.includes(e)&&(e in this.listeners?this.listeners[e].push(t):this.listeners[e]=[t],!0)},e}()));"__TAURI_METADATA__"in window?new Oe(window.__TAURI_METADATA__.__currentWindow.label,{skip:!0}):(console.warn('Could not find "window.__TAURI_METADATA__". The "appWindow" value will reference the "main" window label.\nNote that this is not an issue if running this frontend on a browser instead of a Tauri window.'),new Oe("main",{skip:!0}));var Te,Ne,De={};function Le(e){for(var t=arguments.length,n=Array(t>1?t-1:0),r=1;r<t;r++)n[r-1]=arguments[r];throw Error("[Immer] minified error nr: "+e+(n.length?" "+n.map((function(e){return"'"+e+"'"})).join(","):"")+". Find the full error at: https://bit.ly/3cXEKWf")}function ze(e){return!!e&&!!e[Pt]}function Fe(e){return!!e&&(function(e){if(!e||"object"!=typeof e)return!1;var t=Object.getPrototypeOf(e);if(null===t)return!0;var n=Object.hasOwnProperty.call(t,"constructor")&&t.constructor;return n===Object||"function"==typeof n&&Function.toString.call(n)===At}(e)||Array.isArray(e)||!!e[kt]||!!e.constructor[kt]||He(e)||Ve(e))}function We(e){return ze(e)||Le(23,e),e[Pt].t}function Be(e,t,n){void 0===n&&(n=!1),0===$e(e)?(n?Object.keys:St)(e).forEach((function(r){n&&"symbol"==typeof r||t(r,e[r],e)})):e.forEach((function(n,r){return t(r,n,e)}))}function $e(e){var t=e[Pt];return t?t.i>3?t.i-4:t.i:Array.isArray(e)?1:He(e)?2:Ve(e)?3:0}function qe(e,t){return 2===$e(e)?e.has(t):Object.prototype.hasOwnProperty.call(e,t)}function Ue(e,t,n){var r=$e(e);2===r?e.set(t,n):3===r?(e.delete(t),e.add(n)):e[t]=n}function He(e){return bt&&e instanceof Map}function Ve(e){return wt&&e instanceof Set}function Je(e){return e.o||e.t}function Ye(e){if(Array.isArray(e))return Array.prototype.slice.call(e);var t=It(e);delete t[Pt];for(var n=St(t),r=0;r<n.length;r++){var i=n[r],o=t[i];!1===o.writable&&(o.writable=!0,o.configurable=!0),(o.get||o.set)&&(t[i]={configurable:!0,writable:!0,enumerable:o.enumerable,value:e[i]})}return Object.create(Object.getPrototypeOf(e),t)}function Ge(e,t){return void 0===t&&(t=!1),Ke(e)||ze(e)||!Fe(e)||($e(e)>1&&(e.set=e.add=e.clear=e.delete=Ze),Object.freeze(e),t&&Be(e,(function(e,t){return Ge(t,!0)}),!0)),e}function Ze(){Le(2)}function Ke(e){return null==e||"object"!=typeof e||Object.isFrozen(e)}function Xe(e){var t=Mt[e];return t||Le(18,e),t}function Qe(){return vt}function et(e,t){t&&(Xe("Patches"),e.u=[],e.s=[],e.v=t)}function tt(e){nt(e),e.p.forEach(it),e.p=null}function nt(e){e===vt&&(vt=e.l)}function rt(e){return vt={p:[],l:vt,h:e,m:!0,_:0}}function it(e){var t=e[Pt];0===t.i||1===t.i?t.j():t.O=!0}function ot(e,t){t._=t.p.length;var n=t.p[0],r=void 0!==e&&e!==n;return t.h.g||Xe("ES5").S(t,e,r),r?(n[Pt].P&&(tt(t),Le(4)),Fe(e)&&(e=at(t,e),t.l||ct(t,e)),t.u&&Xe("Patches").M(n[Pt].t,e,t.u,t.s)):e=at(t,n,[]),tt(t),t.u&&t.v(t.u,t.s),e!==Ct?e:void 0}function at(e,t,n){if(Ke(t))return t;var r=t[Pt];if(!r)return Be(t,(function(i,o){return st(e,r,t,i,o,n)}),!0),t;if(r.A!==e)return t;if(!r.P)return ct(e,r.t,!0),r.t;if(!r.I){r.I=!0,r.A._--;var i=4===r.i||5===r.i?r.o=Ye(r.k):r.o;Be(3===r.i?new Set(i):i,(function(t,o){return st(e,r,i,t,o,n)})),ct(e,i,!1),n&&e.u&&Xe("Patches").R(r,n,e.u,e.s)}return r.o}function st(e,t,n,r,i,o){if(ze(i)){var a=at(e,i,o&&t&&3!==t.i&&!qe(t.D,r)?o.concat(r):void 0);if(Ue(n,r,a),!ze(a))return;e.m=!1}if(Fe(i)&&!Ke(i)){if(!e.h.F&&e._<1)return;at(e,i),t&&t.A.l||ct(e,i)}}function ct(e,t,n){void 0===n&&(n=!1),e.h.F&&e.m&&Ge(t,n)}function lt(e,t){var n=e[Pt];return(n?Je(n):e)[t]}function ut(e,t){if(t in e)for(var n=Object.getPrototypeOf(e);n;){var r=Object.getOwnPropertyDescriptor(n,t);if(r)return r;n=Object.getPrototypeOf(n)}}function dt(e){e.P||(e.P=!0,e.l&&dt(e.l))}function pt(e){e.o||(e.o=Ye(e.t))}function ft(e,t,n){var r=He(t)?Xe("MapSet").N(t,n):Ve(t)?Xe("MapSet").T(t,n):e.g?function(e,t){var n=Array.isArray(e),r={i:n?1:0,A:t?t.A:Qe(),P:!1,I:!1,D:{},l:t,t:e,k:null,o:null,j:null,C:!1},i=r,o=Et;n&&(i=[r],o=Rt);var a=Proxy.revocable(i,o),s=a.revoke,c=a.proxy;return r.k=c,r.j=s,c}(t,n):Xe("ES5").J(t,n);return(n?n.A:Qe()).p.push(r),r}function ht(e){return ze(e)||Le(22,e),function e(t){if(!Fe(t))return t;var n,r=t[Pt],i=$e(t);if(r){if(!r.P&&(r.i<4||!Xe("ES5").K(r)))return r.t;r.I=!0,n=mt(t,i),r.I=!1}else n=mt(t,i);return Be(n,(function(t,i){r&&function(e,t){return 2===$e(e)?e.get(t):e[t]}(r.t,t)===i||Ue(n,t,e(i))})),3===i?new Set(n):n}(e)}function mt(e,t){switch(t){case 2:return new Map(e);case 3:return Array.from(e)}return Ye(e)}Ne=function(){var e=JSON.parse('{"$":"dollar","%":"percent","&":"and","<":"less",">":"greater","|":"or","¢":"cent","£":"pound","¤":"currency","¥":"yen","©":"(c)","ª":"a","®":"(r)","º":"o","À":"A","Á":"A","Â":"A","Ã":"A","Ä":"A","Å":"A","Æ":"AE","Ç":"C","È":"E","É":"E","Ê":"E","Ë":"E","Ì":"I","Í":"I","Î":"I","Ï":"I","Ð":"D","Ñ":"N","Ò":"O","Ó":"O","Ô":"O","Õ":"O","Ö":"O","Ø":"O","Ù":"U","Ú":"U","Û":"U","Ü":"U","Ý":"Y","Þ":"TH","ß":"ss","à":"a","á":"a","â":"a","ã":"a","ä":"a","å":"a","æ":"ae","ç":"c","è":"e","é":"e","ê":"e","ë":"e","ì":"i","í":"i","î":"i","ï":"i","ð":"d","ñ":"n","ò":"o","ó":"o","ô":"o","õ":"o","ö":"o","ø":"o","ù":"u","ú":"u","û":"u","ü":"u","ý":"y","þ":"th","ÿ":"y","Ā":"A","ā":"a","Ă":"A","ă":"a","Ą":"A","ą":"a","Ć":"C","ć":"c","Č":"C","č":"c","Ď":"D","ď":"d","Đ":"DJ","đ":"dj","Ē":"E","ē":"e","Ė":"E","ė":"e","Ę":"e","ę":"e","Ě":"E","ě":"e","Ğ":"G","ğ":"g","Ģ":"G","ģ":"g","Ĩ":"I","ĩ":"i","Ī":"i","ī":"i","Į":"I","į":"i","İ":"I","ı":"i","Ķ":"k","ķ":"k","Ļ":"L","ļ":"l","Ľ":"L","ľ":"l","Ł":"L","ł":"l","Ń":"N","ń":"n","Ņ":"N","ņ":"n","Ň":"N","ň":"n","Ō":"O","ō":"o","Ő":"O","ő":"o","Œ":"OE","œ":"oe","Ŕ":"R","ŕ":"r","Ř":"R","ř":"r","Ś":"S","ś":"s","Ş":"S","ş":"s","Š":"S","š":"s","Ţ":"T","ţ":"t","Ť":"T","ť":"t","Ũ":"U","ũ":"u","Ū":"u","ū":"u","Ů":"U","ů":"u","Ű":"U","ű":"u","Ų":"U","ų":"u","Ŵ":"W","ŵ":"w","Ŷ":"Y","ŷ":"y","Ÿ":"Y","Ź":"Z","ź":"z","Ż":"Z","ż":"z","Ž":"Z","ž":"z","Ə":"E","ƒ":"f","Ơ":"O","ơ":"o","Ư":"U","ư":"u","Lj":"LJ","lj":"lj","Nj":"NJ","nj":"nj","Ș":"S","ș":"s","Ț":"T","ț":"t","ə":"e","˚":"o","Ά":"A","Έ":"E","Ή":"H","Ί":"I","Ό":"O","Ύ":"Y","Ώ":"W","ΐ":"i","Α":"A","Β":"B","Γ":"G","Δ":"D","Ε":"E","Ζ":"Z","Η":"H","Θ":"8","Ι":"I","Κ":"K","Λ":"L","Μ":"M","Ν":"N","Ξ":"3","Ο":"O","Π":"P","Ρ":"R","Σ":"S","Τ":"T","Υ":"Y","Φ":"F","Χ":"X","Ψ":"PS","Ω":"W","Ϊ":"I","Ϋ":"Y","ά":"a","έ":"e","ή":"h","ί":"i","ΰ":"y","α":"a","β":"b","γ":"g","δ":"d","ε":"e","ζ":"z","η":"h","θ":"8","ι":"i","κ":"k","λ":"l","μ":"m","ν":"n","ξ":"3","ο":"o","π":"p","ρ":"r","ς":"s","σ":"s","τ":"t","υ":"y","φ":"f","χ":"x","ψ":"ps","ω":"w","ϊ":"i","ϋ":"y","ό":"o","ύ":"y","ώ":"w","Ё":"Yo","Ђ":"DJ","Є":"Ye","І":"I","Ї":"Yi","Ј":"J","Љ":"LJ","Њ":"NJ","Ћ":"C","Џ":"DZ","А":"A","Б":"B","В":"V","Г":"G","Д":"D","Е":"E","Ж":"Zh","З":"Z","И":"I","Й":"J","К":"K","Л":"L","М":"M","Н":"N","О":"O","П":"P","Р":"R","С":"S","Т":"T","У":"U","Ф":"F","Х":"H","Ц":"C","Ч":"Ch","Ш":"Sh","Щ":"Sh","Ъ":"U","Ы":"Y","Ь":"","Э":"E","Ю":"Yu","Я":"Ya","а":"a","б":"b","в":"v","г":"g","д":"d","е":"e","ж":"zh","з":"z","и":"i","й":"j","к":"k","л":"l","м":"m","н":"n","о":"o","п":"p","р":"r","с":"s","т":"t","у":"u","ф":"f","х":"h","ц":"c","ч":"ch","ш":"sh","щ":"sh","ъ":"u","ы":"y","ь":"","э":"e","ю":"yu","я":"ya","ё":"yo","ђ":"dj","є":"ye","і":"i","ї":"yi","ј":"j","љ":"lj","њ":"nj","ћ":"c","ѝ":"u","џ":"dz","Ґ":"G","ґ":"g","Ғ":"GH","ғ":"gh","Қ":"KH","қ":"kh","Ң":"NG","ң":"ng","Ү":"UE","ү":"ue","Ұ":"U","ұ":"u","Һ":"H","һ":"h","Ә":"AE","ә":"ae","Ө":"OE","ө":"oe","Ա":"A","Բ":"B","Գ":"G","Դ":"D","Ե":"E","Զ":"Z","Է":"E\'","Ը":"Y\'","Թ":"T\'","Ժ":"JH","Ի":"I","Լ":"L","Խ":"X","Ծ":"C\'","Կ":"K","Հ":"H","Ձ":"D\'","Ղ":"GH","Ճ":"TW","Մ":"M","Յ":"Y","Ն":"N","Շ":"SH","Չ":"CH","Պ":"P","Ջ":"J","Ռ":"R\'","Ս":"S","Վ":"V","Տ":"T","Ր":"R","Ց":"C","Փ":"P\'","Ք":"Q\'","Օ":"O\'\'","Ֆ":"F","և":"EV","ء":"a","آ":"aa","أ":"a","ؤ":"u","إ":"i","ئ":"e","ا":"a","ب":"b","ة":"h","ت":"t","ث":"th","ج":"j","ح":"h","خ":"kh","د":"d","ذ":"th","ر":"r","ز":"z","س":"s","ش":"sh","ص":"s","ض":"dh","ط":"t","ظ":"z","ع":"a","غ":"gh","ف":"f","ق":"q","ك":"k","ل":"l","م":"m","ن":"n","ه":"h","و":"w","ى":"a","ي":"y","ً":"an","ٌ":"on","ٍ":"en","َ":"a","ُ":"u","ِ":"e","ْ":"","٠":"0","١":"1","٢":"2","٣":"3","٤":"4","٥":"5","٦":"6","٧":"7","٨":"8","٩":"9","پ":"p","چ":"ch","ژ":"zh","ک":"k","گ":"g","ی":"y","۰":"0","۱":"1","۲":"2","۳":"3","۴":"4","۵":"5","۶":"6","۷":"7","۸":"8","۹":"9","฿":"baht","ა":"a","ბ":"b","გ":"g","დ":"d","ე":"e","ვ":"v","ზ":"z","თ":"t","ი":"i","კ":"k","ლ":"l","მ":"m","ნ":"n","ო":"o","პ":"p","ჟ":"zh","რ":"r","ს":"s","ტ":"t","უ":"u","ფ":"f","ქ":"k","ღ":"gh","ყ":"q","შ":"sh","ჩ":"ch","ც":"ts","ძ":"dz","წ":"ts","ჭ":"ch","ხ":"kh","ჯ":"j","ჰ":"h","Ṣ":"S","ṣ":"s","Ẁ":"W","ẁ":"w","Ẃ":"W","ẃ":"w","Ẅ":"W","ẅ":"w","ẞ":"SS","Ạ":"A","ạ":"a","Ả":"A","ả":"a","Ấ":"A","ấ":"a","Ầ":"A","ầ":"a","Ẩ":"A","ẩ":"a","Ẫ":"A","ẫ":"a","Ậ":"A","ậ":"a","Ắ":"A","ắ":"a","Ằ":"A","ằ":"a","Ẳ":"A","ẳ":"a","Ẵ":"A","ẵ":"a","Ặ":"A","ặ":"a","Ẹ":"E","ẹ":"e","Ẻ":"E","ẻ":"e","Ẽ":"E","ẽ":"e","Ế":"E","ế":"e","Ề":"E","ề":"e","Ể":"E","ể":"e","Ễ":"E","ễ":"e","Ệ":"E","ệ":"e","Ỉ":"I","ỉ":"i","Ị":"I","ị":"i","Ọ":"O","ọ":"o","Ỏ":"O","ỏ":"o","Ố":"O","ố":"o","Ồ":"O","ồ":"o","Ổ":"O","ổ":"o","Ỗ":"O","ỗ":"o","Ộ":"O","ộ":"o","Ớ":"O","ớ":"o","Ờ":"O","ờ":"o","Ở":"O","ở":"o","Ỡ":"O","ỡ":"o","Ợ":"O","ợ":"o","Ụ":"U","ụ":"u","Ủ":"U","ủ":"u","Ứ":"U","ứ":"u","Ừ":"U","ừ":"u","Ử":"U","ử":"u","Ữ":"U","ữ":"u","Ự":"U","ự":"u","Ỳ":"Y","ỳ":"y","Ỵ":"Y","ỵ":"y","Ỷ":"Y","ỷ":"y","Ỹ":"Y","ỹ":"y","–":"-","‘":"\'","’":"\'","“":"\\"","”":"\\"","„":"\\"","†":"+","•":"*","…":"...","₠":"ecu","₢":"cruzeiro","₣":"french franc","₤":"lira","₥":"mill","₦":"naira","₧":"peseta","₨":"rupee","₩":"won","₪":"new shequel","₫":"dong","€":"euro","₭":"kip","₮":"tugrik","₯":"drachma","₰":"penny","₱":"peso","₲":"guarani","₳":"austral","₴":"hryvnia","₵":"cedi","₸":"kazakhstani tenge","₹":"indian rupee","₺":"turkish lira","₽":"russian ruble","₿":"bitcoin","℠":"sm","™":"tm","∂":"d","∆":"delta","∑":"sum","∞":"infinity","♥":"love","元":"yuan","円":"yen","﷼":"rial","ﻵ":"laa","ﻷ":"laa","ﻹ":"lai","ﻻ":"la"}'),t=JSON.parse('{"bg":{"Й":"Y","Ц":"Ts","Щ":"Sht","Ъ":"A","Ь":"Y","й":"y","ц":"ts","щ":"sht","ъ":"a","ь":"y"},"de":{"Ä":"AE","ä":"ae","Ö":"OE","ö":"oe","Ü":"UE","ü":"ue","ß":"ss","%":"prozent","&":"und","|":"oder","∑":"summe","∞":"unendlich","♥":"liebe"},"es":{"%":"por ciento","&":"y","<":"menor que",">":"mayor que","|":"o","¢":"centavos","£":"libras","¤":"moneda","₣":"francos","∑":"suma","∞":"infinito","♥":"amor"},"fr":{"%":"pourcent","&":"et","<":"plus petit",">":"plus grand","|":"ou","¢":"centime","£":"livre","¤":"devise","₣":"franc","∑":"somme","∞":"infini","♥":"amour"},"pt":{"%":"porcento","&":"e","<":"menor",">":"maior","|":"ou","¢":"centavo","∑":"soma","£":"libra","∞":"infinito","♥":"amor"},"uk":{"И":"Y","и":"y","Й":"Y","й":"y","Ц":"Ts","ц":"ts","Х":"Kh","х":"kh","Щ":"Shch","щ":"shch","Г":"H","г":"h"},"vi":{"Đ":"D","đ":"d"},"da":{"Ø":"OE","ø":"oe","Å":"AA","å":"aa","%":"procent","&":"og","|":"eller","$":"dollar","<":"mindre end",">":"større end"},"nb":{"&":"og","Å":"AA","Æ":"AE","Ø":"OE","å":"aa","æ":"ae","ø":"oe"},"it":{"&":"e"},"nl":{"&":"en"},"sv":{"&":"och","Å":"AA","Ä":"AE","Ö":"OE","å":"aa","ä":"ae","ö":"oe"}}');function n(n,r){if("string"!=typeof n)throw new Error("slugify: string argument expected");var i=t[(r="string"==typeof r?{replacement:r}:r||{}).locale]||{},o=void 0===r.replacement?"-":r.replacement,a=void 0===r.trim||r.trim,s=n.normalize().split("").reduce((function(t,n){var a=i[n]||e[n]||n;return a===o&&(a=" "),t+a.replace(r.remove||/[^\w\s$*_+~.()'"!\-:@]+/g,"")}),"");return r.strict&&(s=s.replace(/[^A-Za-z0-9\s]/g,"")),a&&(s=s.trim()),s=s.replace(/\s+/g,o),r.lower&&(s=s.toLowerCase()),s}return n.extend=function(t){Object.assign(e,t)},n},(Te={get exports(){return De},set exports(e){De=e}}).exports=Ne(),Te.exports.default=Ne();var gt,vt,yt="undefined"!=typeof Symbol&&"symbol"==typeof Symbol("x"),bt="undefined"!=typeof Map,wt="undefined"!=typeof Set,xt="undefined"!=typeof Proxy&&void 0!==Proxy.revocable&&"undefined"!=typeof Reflect,Ct=yt?Symbol.for("immer-nothing"):((gt={})["immer-nothing"]=!0,gt),kt=yt?Symbol.for("immer-draftable"):"__$immer_draftable",Pt=yt?Symbol.for("immer-state"):"__$immer_state",At=""+Object.prototype.constructor,St="undefined"!=typeof Reflect&&Reflect.ownKeys?Reflect.ownKeys:void 0!==Object.getOwnPropertySymbols?function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:Object.getOwnPropertyNames,It=Object.getOwnPropertyDescriptors||function(e){var t={};return St(e).forEach((function(n){t[n]=Object.getOwnPropertyDescriptor(e,n)})),t},Mt={},Et={get:function(e,t){if(t===Pt)return e;var n=Je(e);if(!qe(n,t))return function(e,t,n){var r,i=ut(t,n);return i?"value"in i?i.value:null===(r=i.get)||void 0===r?void 0:r.call(e.k):void 0}(e,n,t);var r=n[t];return e.I||!Fe(r)?r:r===lt(e.t,t)?(pt(e),e.o[t]=ft(e.A.h,r,e)):r},has:function(e,t){return t in Je(e)},ownKeys:function(e){return Reflect.ownKeys(Je(e))},set:function(e,t,n){var r=ut(Je(e),t);if(null==r?void 0:r.set)return r.set.call(e.k,n),!0;if(!e.P){var i=lt(Je(e),t),o=null==i?void 0:i[Pt];if(o&&o.t===n)return e.o[t]=n,e.D[t]=!1,!0;if(function(e,t){return e===t?0!==e||1/e==1/t:e!=e&&t!=t}(n,i)&&(void 0!==n||qe(e.t,t)))return!0;pt(e),dt(e)}return e.o[t]===n&&"number"!=typeof n&&(void 0!==n||t in e.o)||(e.o[t]=n,e.D[t]=!0,!0)},deleteProperty:function(e,t){return void 0!==lt(e.t,t)||t in e.t?(e.D[t]=!1,pt(e),dt(e)):delete e.D[t],e.o&&delete e.o[t],!0},getOwnPropertyDescriptor:function(e,t){var n=Je(e),r=Reflect.getOwnPropertyDescriptor(n,t);return r?{writable:!0,configurable:1!==e.i||"length"!==t,enumerable:r.enumerable,value:n[t]}:r},defineProperty:function(){Le(11)},getPrototypeOf:function(e){return Object.getPrototypeOf(e.t)},setPrototypeOf:function(){Le(12)}},Rt={};Be(Et,(function(e,t){Rt[e]=function(){return arguments[0]=arguments[0][0],t.apply(this,arguments)}})),Rt.deleteProperty=function(e,t){return Rt.set.call(this,e,t,void 0)},Rt.set=function(e,t,n){return Et.set.call(this,e[0],t,n,e[0])};var jt=new(function(){function e(e){var t=this;this.g=xt,this.F=!0,this.produce=function(e,n,r){if("function"==typeof e&&"function"!=typeof n){var i=n;n=e;var o=t;return function(e){var t=this;void 0===e&&(e=i);for(var r=arguments.length,a=Array(r>1?r-1:0),s=1;s<r;s++)a[s-1]=arguments[s];return o.produce(e,(function(e){var r;return(r=n).call.apply(r,[t,e].concat(a))}))}}var a;if("function"!=typeof n&&Le(6),void 0!==r&&"function"!=typeof r&&Le(7),Fe(e)){var s=rt(t),c=ft(t,e,void 0),l=!0;try{a=n(c),l=!1}finally{l?tt(s):nt(s)}return"undefined"!=typeof Promise&&a instanceof Promise?a.then((function(e){return et(s,r),ot(e,s)}),(function(e){throw tt(s),e})):(et(s,r),ot(a,s))}if(!e||"object"!=typeof e){if(void 0===(a=n(e))&&(a=e),a===Ct&&(a=void 0),t.F&&Ge(a,!0),r){var u=[],d=[];Xe("Patches").M(e,a,u,d),r(u,d)}return a}Le(21,e)},this.produceWithPatches=function(e,n){if("function"==typeof e)return function(n){for(var r=arguments.length,i=Array(r>1?r-1:0),o=1;o<r;o++)i[o-1]=arguments[o];return t.produceWithPatches(n,(function(t){return e.apply(void 0,[t].concat(i))}))};var r,i,o=t.produce(e,n,(function(e,t){r=e,i=t}));return"undefined"!=typeof Promise&&o instanceof Promise?o.then((function(e){return[e,r,i]})):[o,r,i]},"boolean"==typeof(null==e?void 0:e.useProxies)&&this.setUseProxies(e.useProxies),"boolean"==typeof(null==e?void 0:e.autoFreeze)&&this.setAutoFreeze(e.autoFreeze)}var t=e.prototype;return t.createDraft=function(e){Fe(e)||Le(8),ze(e)&&(e=ht(e));var t=rt(this),n=ft(this,e,void 0);return n[Pt].C=!0,nt(t),n},t.finishDraft=function(e,t){var n=(e&&e[Pt]).A;return et(n,t),ot(void 0,n)},t.setAutoFreeze=function(e){this.F=e},t.setUseProxies=function(e){e&&!xt&&Le(20),this.g=e},t.applyPatches=function(e,t){var n;for(n=t.length-1;n>=0;n--){var r=t[n];if(0===r.path.length&&"replace"===r.op){e=r.value;break}}n>-1&&(t=t.slice(n+1));var i=Xe("Patches").$;return ze(e)?i(e,t):this.produce(e,(function(e){return i(e,t)}))},e}()),_t=jt.produce;jt.produceWithPatches.bind(jt),jt.setAutoFreeze.bind(jt),jt.setUseProxies.bind(jt),jt.applyPatches.bind(jt),jt.createDraft.bind(jt),jt.finishDraft.bind(jt);const Ot=_t,Tt=Ot((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":-1===e.active.indexOf(t.payload)&&e.active.push(t.payload);break;case"selectPreview":e.selected=t.payload,-1===e.active.indexOf(t.payload)&&e.active.push(t.payload)}}));function Nt(){return{active:[],selected:null}}const Dt=n.createContext(null),Lt=n.memo((function({children:e,configs:t=[]}){const r=function(e){return n.useMemo(()=>{const t=[];for(const n of e)switch(n.type){case"iiif-preview-service":t.push(new fe(n));break;case"external-manifest-preview":t.push(new pe(n))}return t},[])}(t),[i,o]=n.useReducer(Tt,void 0,Nt),s=function(e,t,r){const i=a.useVault(),o=N(),s=o.current,[c,l]=n.useMemo(()=>{const e={},t={};for(const n of r){e[n.id]=n;const r=n.getProvides();if(r.length)for(const e of r)t[e]||(t[e]=n.id)}return[e,t]},[r]);async function u(){const n=e.selected,r=null==s?void 0:s.previews,a=null==r?void 0:r.find(e=>e.id===n);if(s&&r&&r.length&&a){const e=c[a.id].getRequires(),n={};for(const o of r){const r=c[o.id];if(r){const o=r.getProvides();for(const a of o)if(-1!==e.indexOf(a)){const e=await r.updatePreview(s,i,n);e&&(t({type:"activatePreview",payload:e.id}),Object.assign(n,e.data||{}))}}}const l=c[a.id];if(l){console.log("newPreview?");const e=await l.updatePreview(s,i,n);e?o.actions.setPreview(e):(o.actions.removePreview(a.id),await l.deletePreview(s.id))}}}async function d(e){c[e]&&s&&(console.log("selectPreview?"),await h(e),t({type:"selectPreview",payload:e}))}function p(e){const n=c[e];n&&s&&(o.actions.removePreview(e),n.deletePreview(s.id).then(()=>{t({type:"deletePreview",payload:e})}))}async function f(e){console.log("focusPreview?");const n=c[e];c[e]&&s&&(await n.focus(s),t({type:"focusPreview",payload:e}))}async function h(e){const n=c[e];if(n&&s){const r=s.previews;if(!r.find(t=>t.id===e)||!n.isPreviewValid(s)){const a={},u=n.getRequires();for(const n of u){const u=l[n],d=u?c[u]:null;j(d);const p=r.find(e=>e.id===u);if(p&&d.isPreviewValid(s))Object.assign(a,(null==p?void 0:p.data)||{}),t({type:"activatePreview",payload:e});else{const e=await d.createPreview(s,i,a);Object.assign(a,(null==e?void 0:e.data)||{}),o.actions.setPreview(e),t({type:"activatePreview",payload:e.id})}}o.actions.setPreview(await n.createPreview(s,i,a)),t({type:"activatePreview",payload:e})}}}return n.useMemo(()=>({selectPreview:d,deletePreview:p,focusPreview:f,activatePreview:h,updatePreviews:u}),[c,s,i,e.selected])}(i,o,r),c=n.useMemo(()=>({configs:t,actions:s,handlers:r,...i}),[s,t,r,i]);return S(Dt.Provider,{value:c,children:e})}));function zt(){const e=n.useContext(Dt);return j(e),e}const Ft=i.div.withConfig({displayName:"ButtonContainer",componentId:"sc-3k3080-0"})(["display:flex;position:relative;width:10em;"]),Wt=i(K).withConfig({displayName:"ButtonMain",componentId:"sc-3k3080-1"})(["flex:1;padding:0.6em 0.8em;background:salmon;color:#fff;border-top-left-radius:5px;font-size:0.875em;border-bottom-left-radius:5px;border:1px solid salmon;border-right-width:0;&:hover{color:#fff;background:#ff988e;}&:active{background:#ff988e;box-shadow:inset 0 2px 8px 0 rgba(0,0,0,0.15);}"]),Bt=i(K).withConfig({displayName:"ButtonChange",componentId:"sc-3k3080-2"})(["background:salmon;border-top-right-radius:5px;border-bottom-right-radius:5px;border:1px solid salmon;border-left:1px solid #e37266;padding:0.4em;color:#fff;svg{fill:currentColor;}&:hover{color:#fff;background:#ff988e;}&:active{background:#ff988e;box-shadow:inset 0 2px 8px 0 rgba(0,0,0,0.15);}",""],e=>e.$open&&i.css(["background:#ff988e;box-shadow:inset 0 2px 8px 0 rgba(0,0,0,0.15);"])),$t=i.div.withConfig({displayName:"MenuContainer",componentId:"sc-3k3080-3"})(["position:absolute;opacity:0;top:100%;margin-top:0.3em;border-radius:3px;left:-50%;width:150%;pointer-events:none;box-shadow:0 4px 15px 0 rgba(0,0,0,0.18),0 0px 0px 1px rgba(0,0,0,0.15),inset 0 0 0 1px rgba(255,255,255,0.2);background:#fff;overflow:hidden;",""],e=>e.$open&&i.css(["opacity:1;pointer-events:visible;"])),qt=i.div.withConfig({displayName:"MenuItem",componentId:"sc-3k3080-4"})(["display:flex;background:#fff;padding:0.4em;align-items:center;&:hover{background:#f9f9f9;}"]),Ut={available:"#ddd",configured:"#e37266",active:"#4cb235"},Ht=i.div.withConfig({displayName:"MenuItemStatus",componentId:"sc-3k3080-5"})(["margin:0.2em 0.5em;width:8px;height:8px;border-radius:50%;background-color:",";"],e=>Ut[e.$status]),Vt=i.div.withConfig({displayName:"MenuItemLabel",componentId:"sc-3k3080-6"})(["flex:1;font-size:0.925em;padding:0.2em;text-overflow:ellipsis;cursor:pointer;white-space:nowrap;overflow:hidden;"]),Jt=i.div.withConfig({displayName:"MenuItemClose",componentId:"sc-3k3080-7"})(["background:#f9f9f9;font-size:0.8em;"]),Yt=i.div.withConfig({displayName:"ButtonEmpty",componentId:"sc-3k3080-8"})(["color:#999;font-size:0.8em;padding:0.6em 0.8em;border:2px dashed #f9f9f9;border-radius:5px;user-select:none;cursor:not-allowed;"]);var Gt={};Object.defineProperty(Gt,"__esModule",{value:!0});const Zt=n;var Kt=Gt.default=function(e,t){const[n,r]=Zt.useState(!1),i=Zt.useRef(null),o=Zt.useRef(!0),a=Zt.useRef(!1),s=Zt.useRef(null),c=Zt.useMemo(()=>Array.from({length:e},()=>Zt.createRef()),[e]),l=e=>{var t;i.current=e,null===(t=c[e].current)||void 0===t||t.focus()};Zt.useEffect(()=>{o.current?o.current=!1:n&&!(null==t?void 0:t.disableFocusFirstItemOnClick)?l(0):n||(a.current=!1)},[n]),Zt.useEffect(()=>{if(!n)return;const e={removed:!1},t=e=>{setTimeout(()=>{e.target instanceof Element&&(e.target.closest('[role="menu"]')instanceof Element||r(!1))},10)};return setTimeout(()=>{e.removed||document.addEventListener("click",t)},1),()=>{e.removed=!0,document.removeEventListener("click",t)}},[n]),Zt.useEffect(()=>{const e=e=>{!n||"ArrowDown"!==e.key&&"ArrowUp"!==e.key||e.preventDefault()};return document.addEventListener("keydown",e),()=>document.removeEventListener("keydown",e)},[n]);const u=e=>{if((e=>void 0!==e.key)(e)){const{key:t}=e;if(!["Enter"," ","Tab","ArrowDown","Escape"].includes(t))return;("Tab"===t||"ArrowDown"===t)&&a.current&&n&&(e.preventDefault(),l(0)),"Enter"!==t&&" "!==t||(e.preventDefault(),r(!0)),"Escape"===t&&(e.preventDefault(),r(!1))}else(null==t?void 0:t.disableFocusFirstItemOnClick)&&(a.current=!n),r(!n)},d=e=>{var t;const{key:n}=e;if(["Tab","Shift","Enter","Escape","ArrowUp","ArrowDown"," "].includes(n)){let o=i.current;return"Escape"===n?(r(!1),void(null===(t=s.current)||void 0===t||t.focus())):"Tab"===n?void r(!1):"Enter"===n||" "===n?(e.currentTarget.href||e.currentTarget.click(),void r(!1)):(null!==o&&("ArrowUp"===n?o-=1:"ArrowDown"===n&&(o+=1),o>c.length-1?o=0:o<0&&(o=c.length-1)),void(null!==o&&l(o)))}if(/[a-zA-Z0-9./<>?;:"'`!@#$%^&*()\\[\]{}_+=|\\-~,]/.test(n)){const e=c.findIndex(e=>{var t,r,i,o,a,s;return(null===(r=null===(t=e.current)||void 0===t?void 0:t.innerText)||void 0===r?void 0:r.toLowerCase().startsWith(n.toLowerCase()))||(null===(o=null===(i=e.current)||void 0===i?void 0:i.textContent)||void 0===o?void 0:o.toLowerCase().startsWith(n.toLowerCase()))||(null===(s=null===(a=e.current)||void 0===a?void 0:a.getAttribute("aria-label"))||void 0===s?void 0:s.toLowerCase().startsWith(n.toLowerCase()))});-1!==e&&l(e)}};return{buttonProps:{onKeyDown:u,onClick:u,tabIndex:0,ref:s,role:"button","aria-haspopup":!0,"aria-expanded":n},itemProps:Array.from({length:e},(e,t)=>({onKeyDown:d,tabIndex:-1,role:"menuitem",ref:c[t]})),isOpen:n,setIsOpen:r,moveFocus:l}};const Xt=({rotate:e=0,...t})=>S("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:S("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"})}),Qt=i(e=>I("svg",{xmlns:"http://www.w3.org/2000/svg",height:"24",viewBox:"0 0 24 24",width:"24",...e,children:[S("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"}),S("path",{d:"M0 0h24v24H0z",fill:"none"})]})).withConfig({displayName:"CloseIcon",componentId:"sc-ot4rvu-0"})(["fill:rgba(0,0,0,0.5);cursor:pointer;&:hover{fill:rgba(0,0,0,1);}"," ",""],e=>e.disabled?i.css(["pointer-events:none;opacity:0.6;"]):"",e=>e.$solid&&i.css(["fill:#000;"]));function en(){const{isLoading:e}=T(),{current:t}=N(),{currentApp:n,apps:r}=J(),{active:i,configs:o,actions:a,selected:s}=zt(),c=o.filter(e=>"external-manifest-preview"===e.type),{isOpen:l,buttonProps:u,itemProps:d}=Kt(c.length);return!t||"splash"===n.id||e?null:0===c.length?S(Yt,{children:"Preview not available"}):I(Ft,{children:[S(Wt,{onClick:()=>{s||a.selectPreview(o[0].id),a.updatePreviews()},children:"Preview"}),S(Bt,{$open:l,...u,children:S(Xt,{})}),S($t,{$open:l,children:c.map((e,t)=>{const n=-1===i.indexOf(e.id);return I(qt,{...d[t],children:[S(Ht,{$status:n?"available":e.id===s?"active":"configured"}),S(Vt,{onClick:()=>a.selectPreview(e.id),children:e.label}),n?null:S(Jt,{onClick:()=>a.deletePreview(e.id),children:S(Qt,{})})]},e.id)})})]})}const tn=i.div.withConfig({displayName:"Dropdown",componentId:"sc-1beuvjz-0"})(["position:relative;display:inline-block;"]),nn=i.div.withConfig({displayName:"DropdownContent",componentId:"sc-1beuvjz-1"})(["display:flex;flex-direction:column;position:absolute;background-color:",";color:",";font-size:0.75rem;min-width:160px;box-shadow:0px 8px 16px 0px rgba(0,0,0,0.2);z-index:150;button{&:hover{background-color:",";}}"],e=>e.theme.color.white||"white",e=>e.theme.color.black||" black",e=>e.theme.color.lightgrey||"lightgrey"),rn=i.button.withConfig({displayName:"DropdownItem",componentId:"sc-1beuvjz-2"})(["padding:0 ",";color:",";background-color:",";border-radius:0;border:none;cursor:pointer;display:flex;padding:0.65em 1em;align-items:center;:disabled{opacity:0.65;cursor:not-allowed;}&:hover{background-color:",";}",""],e=>e.theme.padding.small||"0.5rem",e=>e.theme.color.main||"none",e=>e.theme.color.white||"white",e=>e.theme.color.lightgrey||"lightgrey",e=>e.$active&&i.css(["background:#347cff;color:#fff;&:hover{background:#347cff;color:#fff;}"])),on=i.div.withConfig({displayName:"DropdownMenu",componentId:"sc-1beuvjz-3"})(["display:none;flex-direction:column;position:absolute;background:#fff;color:",";font-size:0.75rem;min-width:190px;top:calc(100% + 0.5em);box-shadow:0 4px 15px 0 rgba(0,0,0,0.18),0 0px 0px 1px rgba(0,0,0,0.15),inset 0 0 0 1px rgba(255,255,255,0.2);border-radius:3px;z-index:150;overflow:hidden;padding-bottom:3px;","{&:hover{background-color:",";}}",""],e=>e.theme.color.black||" black",X,e=>e.theme.color.lightgrey||"lightgrey",e=>e.$open&&i.css(["display:flex;"])),an=i.div.withConfig({displayName:"DropdownLabel",componentId:"sc-1beuvjz-4"})(["color:#999;text-transform:uppercase;font-weight:600;padding:0.7em;font-size:0.875em;"]),sn=i.div.withConfig({displayName:"DropdownDivider",componentId:"sc-1beuvjz-5"})(["height:1px;margin:0 0.5em;background:#eee;"]);i.div.withConfig({displayName:"FlexContainerRow",componentId:"sc-5igjm0-0"})(["display:flex;flex-direction:row;justify-content:",";"],e=>e.justify||"flex-start");const cn=i.div.withConfig({displayName:"FlexContainer",componentId:"sc-5igjm0-1"})(["display:flex;flex-direction:row;",""],e=>e.$align&&i.css(["align-items:center;"])),ln=i.div.withConfig({displayName:"FlexContainerColumn",componentId:"sc-5igjm0-2"})(["display:flex;flex-direction:column;justify-content:",";"],e=>e.justify||"flex-start");i.div.withConfig({displayName:"FlexImage",componentId:"sc-5igjm0-3"})(["max-height:300px;flex:1;display:flex;justify-content:center;background:#f9f9f9;margin-bottom:0.5em;img{object-fit:contain;width:100%;}"]);const un=i.div.withConfig({displayName:"RecentFilesWidget",componentId:"sc-jdgr6n-0"})(["min-height:10rem;width:100%;display:flex;flex-direction:column;box-shadow:",";padding:",";background:",";"],e=>e.theme.shadows.standard||"",e=>e.theme.padding.medium||"2rem",e=>e.theme.color.white||"white"),dn=i.div.withConfig({displayName:"RecentThumbnails",componentId:"sc-jdgr6n-1"})(["width:100%;overflow:auto;justify-content:flex-start;display:flex;"]);i.div.withConfig({displayName:"RecentManifestCard",componentId:"sc-jdgr6n-2"})(["display:flex;flex-direction:column;align-items:center;margin:",";"],e=>e.theme.padding.xs||"0.25rem");const pn=i.small.withConfig({displayName:"RecentLabel",componentId:"sc-jdgr6n-3"})(["text-align:center;"]);function fn(e,t={}){return function(e,t,n={}){const{strictFallback:r=!1,defaultText:i="",separator:o="\n",fallbackLanguages:a=[],closest:s}=n,c=Object.keys(e||{}),l=s?t:function(e,t,n=[],r=!1){if(!e||!t||0===t.length)return;if(1===t.length)return t[0];if(-1!==t.indexOf(e))return e;const i=-1!==e.indexOf("-")?e.slice(0,e.indexOf("-")):null;if(i&&-1!==t.indexOf(i))return i;for(const o of n)if(-1!==t.indexOf(o))return o;if(!r){const r=t.map(e=>-1!==e.indexOf("-")?e.slice(0,e.indexOf("-")):null).indexOf(e);if(-1!==r)return t[r];for(const e of n){const n=-1!==e.indexOf("-")?e.slice(0,e.indexOf("-")):null,r=n?t.indexOf(n):-1;if(-1!==r)return t[r]}}return-1!==t.indexOf("none")?"none":-1!==t.indexOf("@none")?"@none":t[0]}(t,c,a,r);if(!e)return i;if("string"==typeof e)return e;const u=l?e[l]:void 0;return u?"string"==typeof u?u:u.join(o):""}(e,"undefined"!=typeof navigator?navigator.language:void 0,t)}var hn=function(e,t){if(Array.isArray(e))return e;if(Symbol.iterator in Object(e))return function(e,t){var n=[],r=!0,i=!1,o=void 0;try{for(var a,s=e[Symbol.iterator]();!(r=(a=s.next()).done)&&(n.push(a.value),!t||n.length!==t);r=!0);}catch(c){i=!0,o=c}finally{try{!r&&s.return&&s.return()}finally{if(i)throw o}}return n}(e,t);throw new TypeError("Invalid attempt to destructure non-iterable instance")},mn=2*Math.PI,gn=function(e,t,n,r,i,o,a){var s=e.x,c=e.y;return{x:r*(s*=t)-i*(c*=n)+o,y:i*s+r*c+a}},vn=function(e,t){var n=1.5707963267948966===t?.551915024494:-1.5707963267948966===t?-.551915024494:4/3*Math.tan(t/4),r=Math.cos(e),i=Math.sin(e),o=Math.cos(e+t),a=Math.sin(e+t);return[{x:r-i*n,y:i+r*n},{x:o+a*n,y:a-o*n},{x:o,y:a}]},yn=function(e,t,n,r){var i=e*n+t*r;return i>1&&(i=1),i<-1&&(i=-1),(e*r-t*n<0?-1:1)*Math.acos(i)},bn=function(e){var t=e.px,n=e.py,r=e.cx,i=e.cy,o=e.rx,a=e.ry,s=e.xAxisRotation,c=void 0===s?0:s,l=e.largeArcFlag,u=void 0===l?0:l,d=e.sweepFlag,p=void 0===d?0:d,f=[];if(0===o||0===a)return[];var h=Math.sin(c*mn/360),m=Math.cos(c*mn/360),g=m*(t-r)/2+h*(n-i)/2,v=-h*(t-r)/2+m*(n-i)/2;if(0===g&&0===v)return[];o=Math.abs(o),a=Math.abs(a);var y=Math.pow(g,2)/Math.pow(o,2)+Math.pow(v,2)/Math.pow(a,2);y>1&&(o*=Math.sqrt(y),a*=Math.sqrt(y));var b=function(e,t,n,r,i,o,a,s,c,l,u,d){var p=Math.pow(i,2),f=Math.pow(o,2),h=Math.pow(u,2),m=Math.pow(d,2),g=p*f-p*m-f*h;g<0&&(g=0),g/=p*m+f*h;var v=(g=Math.sqrt(g)*(a===s?-1:1))*i/o*d,y=g*-o/i*u,b=l*v-c*y+(e+n)/2,w=c*v+l*y+(t+r)/2,x=(u-v)/i,C=(d-y)/o,k=(-u-v)/i,P=(-d-y)/o,A=yn(1,0,x,C),S=yn(x,C,k,P);return 0===s&&S>0&&(S-=mn),1===s&&S<0&&(S+=mn),[b,w,A,S]}(t,n,r,i,o,a,u,p,h,m,g,v),w=hn(b,4),x=w[0],C=w[1],k=w[2],P=w[3],A=Math.abs(P)/(mn/4);Math.abs(1-A)<1e-7&&(A=1);var S=Math.max(Math.ceil(A),1);P/=S;for(var I=0;I<S;I++)f.push(vn(k,P)),k+=P;return f.map((function(e){var t=gn(e[0],o,a,m,h,x,C),n=t.x,r=t.y,i=gn(e[1],o,a,m,h,x,C),s=i.x,c=i.y,l=gn(e[2],o,a,m,h,x,C);return{x1:n,y1:r,x2:s,y2:c,x:l.x,y:l.y}}))},wn=function(e){var t=[];return e.replace(Cn,(function(e,n,r){var i=n.toLowerCase();for(r=function(e){var t=e.match(kn);return t?t.map(Number):[]}(r),"m"==i&&r.length>2&&(t.push([n].concat(r.splice(0,2))),i="l",n="m"==n?"l":"L");;){if(r.length==xn[i])return r.unshift(n),t.push(r);if(r.length<xn[i])throw new Error("malformed path data");t.push([n].concat(r.splice(0,xn[i])))}})),t},xn={a:7,c:6,h:1,l:2,m:2,q:4,s:4,t:2,v:1,z:0},Cn=/([astvzqmhlc])([^astvzqmhlc]*)/gi;var kn=/-?[0-9]*\.?[0-9]+(?:e[-+]?\d+)?/gi;var Pn=function(e){var t=0,n=0,r=0,i=0;return e.map((function(e){var o=(e=e.slice())[0],a=o.toUpperCase();if(o!=a)switch(e[0]=a,o){case"a":e[6]+=r,e[7]+=i;break;case"v":e[1]+=i;break;case"h":e[1]+=r;break;default:for(var s=1;s<e.length;)e[s++]+=r,e[s++]+=i}switch(a){case"Z":r=t,i=n;break;case"H":r=e[1];break;case"V":i=e[1];break;case"M":r=t=e[1],i=n=e[2];break;default:r=e[e.length-2],i=e[e.length-1]}return e}))};function An(e){const t=wn(e),n=Pn(t);let r,i,o,a=0,s=0,c=0,l=0,u=0,d=0;const p=[];for(let f=0;f<n.length;f++){let e=n[f];const t=e[0];switch(t){case"M":a=e[1],s=e[2];break;case"H":e=["L",e[1],s];break;case"V":e=["L",a,e[1]];break;case"S":{let t=u,n=d;"C"!==r&&"S"!=r||(t+=t-c,n+=n-l),e=["C",t,n,e[1],e[2],e[3],e[4]]}break;case"T":"Q"===r||"T"==r?(i=2*u-i,o=2*d-o):(i=u,o=d),e=["Q",i,o,e[1],e[2]];break;case"Q":i=e[1],o=e[2];break;case"A":{const t=bn({px:u,py:d,cx:e[6],cy:e[7],rx:e[1],ry:e[2],xAxisRotation:e[3],largeArcFlag:e[4],sweepFlag:e[5]});if(!t.length)continue;for(const[n,r]of t.entries())e=["C",r.x1,r.y1,r.x2,r.y2,r.x,r.y],n<t.length-1&&p.push(e);e=e}break;case"Z":e=["L",a,s]}r=t,u=e[e.length-2],d=e[e.length-1],["C","Q","A"].indexOf(t)>-1?(c=e[e.length-4],l=e[e.length-3]):(c=u,l=d),p.push(e)}return p}
|
|
2
|
-
/** Code to "flatten" quadratic and cubic Bézier curves to polylines.
|
|
3
|
-
*
|
|
4
|
-
* All code in this module is based on JavaScript code by Raph Levien, published on his blog at
|
|
5
|
-
* https://raphlinus.github.io/.
|
|
6
|
-
* I merely changed the structure a bit, removed some unneeded parts and added some comments and type hints.
|
|
7
|
-
*
|
|
8
|
-
* Flattening of quadratic Bézier curves:
|
|
9
|
-
* - Article: https://raphlinus.github.io/graphics/curves/2019/12/23/flatten-quadbez.html
|
|
10
|
-
* - Code: https://github.com/raphlinus/raphlinus.github.io/blob/master/_posts/2019-12-23-flatten-quadbez.md?plain=1#L73-L212
|
|
11
|
-
*
|
|
12
|
-
* Flattening of cubic Bézier curves: https://levien.com/tmp/flatten.html
|
|
13
|
-
*
|
|
14
|
-
* Note that the code in this module has a different license than the rest of the package,
|
|
15
|
-
* due to the inclusion of Apache-licensed third party code.
|
|
16
|
-
*
|
|
17
|
-
* @license
|
|
18
|
-
* Copyright 2022 Johannes Baiter <johannes.baiter@gmail.com>
|
|
19
|
-
* Copyright 2019, 2022 Raph Levien <raph.levien@gmail.com>
|
|
20
|
-
*
|
|
21
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
22
|
-
* you may not use this file except in compliance with the License.
|
|
23
|
-
* You may obtain a copy of the License at
|
|
24
|
-
*
|
|
25
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
26
|
-
*
|
|
27
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
28
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
29
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
30
|
-
* See the License for the specific language governing permissions and
|
|
31
|
-
* limitations under the License.
|
|
32
|
-
*/function Sn(e,t,n,r=1){return new Rn(e,t,n).subdivide(r)}function In(e,t,n,r,i=1){return new jn(new Float64Array([e.x,e.y,t.x,t.y,n.x,n.y,r.x,r.y])).subdivide(i)}function Mn(e){return e/(1-.67+Math.pow(Math.pow(.67,4)+.25*e*e,.25))}function En(e){return e*(.61+Math.sqrt(.1521+.25*e*e))}class Rn{constructor(e,t,n){this.start=e,this.control=t,this.end=n}eval(e){const t=1-e;return{x:this.start.x*t*t+2*this.control.x*t*e+this.end.x*e*e,y:this.start.y*t*t+2*this.control.y*t*e+this.end.y*e*e}}mapToBasic(){const{x:e,y:t}=this.start,{x:n,y:r}=this.control,{x:i,y:o}=this.end,a=2*n-e-i,s=2*r-t-o,c=(i-e)*s-(o-t)*a,l=((n-e)*a+(r-t)*s)/c,u=((i-n)*a+(o-r)*s)/c;return{x0:e,x2:i,scale:Math.abs(c)/(Math.hypot(a,s)*Math.abs(u-l)),cross:c}}subdivide(e){const t=this.mapToBasic(),n=Mn(t.x0),r=Mn(t.x2),i=.5*Math.abs(r-n)*Math.sqrt(t.scale/e),o=Math.ceil(i),a=En(n),s=En(r),c=[0];for(let l=1;l<o;l++){const e=(En(n+(r-n)*l/o)-a)/(s-a);c.push(e)}return c.push(1),c.map(e=>this.eval(e))}}class jn{constructor(e){this.c=e}weightsum(e,t,n,r){return{x:e*this.c[0]+t*this.c[2]+n*this.c[4]+r*this.c[6],y:e*this.c[1]+t*this.c[3]+n*this.c[5]+r*this.c[7]}}eval(e){const t=1-e,n=t*t*t,r=3*t*t*e,i=3*t*e*e,o=e*e*e;return this.weightsum(n,r,i,o)}deriv(e){const t=1-e,n=-3*t*t,r=3*e*e,i=-6*e*t-n,o=6*e*t-r;return this.weightsum(n,i,o,r)}midpoint_quadbez(){const e=this.weightsum(-.25,.75,.75,-.25);return new Rn({x:this.c[0],y:this.c[1]},e,{x:this.c[6],y:this.c[7]})}subsegment(e,t){const n=new Float64Array(8),r=this.eval(e),i=this.eval(t);n[0]=r.x,n[1]=r.y;const o=(t-e)/3,a=this.deriv(e);n[2]=r.x+o*a.x,n[3]=r.y+o*a.y;const s=this.deriv(t);return n[4]=i.x-o*s.x,n[5]=i.y-o*s.y,n[6]=i.x,n[7]=i.y,new jn(n)}subdivide(e){const t=.1*e,n=e-t,r=Math.sqrt(n),i=(o=this.weightsum(1,-3,3,-1)).x*o.x+o.y*o.y;var o;const a=Math.ceil(Math.pow(i/(432*t*t),1/6)),s=[];let c=0;for(let h=0;h<a;h++){const e=h/a,t=(h+1)/a,n=this.subsegment(e,t).midpoint_quadbez(),i=n.mapToBasic(),o=Mn(i.x0),l=Mn(i.x2),u=Math.sqrt(i.scale);let d=Math.abs(l-o)*u;if(Math.sign(i.x0)!=Math.sign(i.x2)){const e=r/u,t=r*Math.abs(l-o)/Mn(e);d=Math.max(d,t)}s.push({quad:n,a0:o,a2:l,val:d}),c+=d}const l=.5*c/r,u=Math.ceil(l),d=[{x:this.c[0],y:this.c[1]}];let p=0,f=0;for(let h=1;h<u;h++){const e=c*h/u;for(;p+s[f].val<e;)p+=s[f].val,f++;const t=s[f].a0,n=s[f].a2,r=En(t),i=En(n),o=(En(t+(n-t)*(e-p)/s[f].val)-r)/(i-r);d.push(s[f].quad.eval(o))}return d.push({x:this.c[6],y:this.c[7]}),d}}const _n=/&?(xywh=)?(pixel:|percent:|pct:)?([0-9]+(?:\.[0-9]+)?),([0-9]+(?:\.[0-9]+)?),([0-9]+(?:\.[0-9]+)?),([0-9]+(?:\.[0-9]+)?)/,On=/&?(t=)(npt:)?([0-9]+(.[0-9]+)?)?(,([0-9]+(.[0-9]+)?))?/,Tn=/^rgba\((\d+),(\d+),(\d+),([0-9.]+)\)$/;function Nn(e,{domParser:t,svgPreprocessor:n,iiifRenderingHints:r}={}){var i,o;if(Array.isArray(e))return zn(e.reduce((e,i)=>{const{selector:o,selectors:a,iiifRenderingHints:s}=Nn(i,{domParser:t,svgPreprocessor:n,iiifRenderingHints:r});return o&&(e.selector||(e.selector=o),e.selectors.push(...a)),s&&(e.iiifRenderingHints=e.iiifRenderingHints||{type:"ImageApiSelector"},Object.assign(e.iiifRenderingHints,s)),e},{selector:null,selectors:[],iiifRenderingHints:r}));if(!e)return zn({selector:null,selectors:[],iiifRenderingHints:r});if("string"==typeof e){const[i,o]=e.split("#");return o?Nn({type:"FragmentSelector",value:o},{svgPreprocessor:n,iiifRenderingHints:r,domParser:t}):zn({selector:null,selectors:[],iiifRenderingHints:r})}if(e.type&&"PointSelector"===e.type&&(e.t||0===e.t)){const t={type:"TemporalSelector",temporal:{startTime:e.t}};return zn({selector:t,selectors:[t],iiifRenderingHints:r})}if(function(e){return!!e&&"iiif:ImageApiSelector"===e.type&&"iiif:ImageApiSelector"===e.type}(e)){const i=[];if(e.region){const o=Nn({type:"FragmentSelector",value:"xywh="+e.region},{domParser:t,svgPreprocessor:n,iiifRenderingHints:r});i.push(...o.selectors)}return zn({selector:i[0],selectors:i,iiifRenderingHints:r?{...r,...e}:e})}if("FragmentSelector"===e.type){const t=_n.exec(e.value);if(t){const e={type:"BoxSelector",spatial:{unit:"percent:"===t[2]||"pct:"===t[2]?"percent":"pixel",x:parseFloat(t[3]),y:parseFloat(t[4]),width:parseFloat(t[5]),height:parseFloat(t[6])}};return zn({selector:e,selectors:[e],iiifRenderingHints:r})}const n=e.value.match(On);if(n){const e={type:"TemporalSelector",temporal:{startTime:n[4]?parseFloat(n[4]):0,endTime:n[7]?parseFloat(n[7]):void 0}};return zn({selector:e,selectors:[e],iiifRenderingHints:r})}return zn({selector:null,selectors:[],iiifRenderingHints:r})}if("SvgSelector"===e.type&&"value"in e){t||("undefined"!=typeof window?t=new window.DOMParser:console.warn("No DOMParser available, cannot parse SVG selector, `points`, `spatial` and `style` will be unavailable and the SVG will not be normalized."));let a,s,c,l=[],u=null!=(i=null==n?void 0:n(e.value))?i:e.value;if(t){const n=t.parseFromString(e.value,"image/svg+xml").querySelector("svg");if(!n)return console.warn("Illegal SVG selector: "+e.value),zn({selector:null,selectors:[],iiifRenderingHints:r});const i=function e(t){var n,r,i,o,a,s,c,l,u,d,p,f,h,m,g,v,y;for(const b of Array.from(t.children))switch(null==b?void 0:b.tagName.toLowerCase()){case"g":{const t=e(b);if(t)return t}continue;case"path":{const e=b.getAttribute("d");if(!e)continue;const t=An(e);return{element:b,points:Ln(t),shapeType:Dn(t)}}case"circle":{const e=parseFloat(null!=(n=b.getAttribute("cx"))?n:"0"),t=parseFloat(null!=(r=b.getAttribute("cy"))?r:"0"),o=parseFloat(null!=(i=b.getAttribute("r"))?i:"0");if(!o)continue;const a=[];for(let n=0;n<=360;n+=12){const r=n*Math.PI/180;a.push([e+o*Math.cos(r),t+o*Math.sin(r)])}return{element:b,points:a,shapeType:"circle"}}case"ellipse":{const e=parseFloat(null!=(o=b.getAttribute("cx"))?o:"0"),t=parseFloat(null!=(a=b.getAttribute("cy"))?a:"0"),n=parseFloat(null!=(s=b.getAttribute("rx"))?s:"0"),r=parseFloat(null!=(c=b.getAttribute("ry"))?c:"0");if(!n&&!r)continue;const i=[];for(let o=0;o<=360;o+=12){const a=Math.tan(o/360*Math.PI),s=n*(1-a**2)/(1+a**2),c=2*r*a/(1+a**2);i.push([e+s,t+c])}return{element:b,points:i,shapeType:"ellipse"}}case"line":{const e=parseFloat(null!=(l=b.getAttribute("x0"))?l:"0"),t=parseFloat(null!=(u=b.getAttribute("y0"))?u:"0"),n=parseFloat(null!=(d=b.getAttribute("x1"))?d:"0"),r=parseFloat(null!=(p=b.getAttribute("y1"))?p:"0");if(e===n&&t===r)continue;return{element:b,points:[[e,t],[n,r]],shapeType:"polyline"}}case"polygon":case"polyline":{const e=null!=(h=null==(f=b.getAttribute("points"))?void 0:f.split(" ").map(e=>e.split(",").map(parseFloat)))?h:[];if(!e.length)continue;let t="polyline";return"polygon"===b.tagName.toLowerCase()&&(e.push(e[0]),t="polygon"),{element:b,points:e,shapeType:t}}case"rect":{const e=parseFloat(null!=(m=b.getAttribute("x"))?m:"0"),t=parseFloat(null!=(g=b.getAttribute("y"))?g:"0"),n=parseFloat(null!=(v=b.getAttribute("width"))?v:"0"),r=parseFloat(null!=(y=b.getAttribute("height"))?y:"0");if(!n||!r)continue;return{element:b,points:[[e,t],[e+n,t],[e+n,t+r],[e,t+r],[e,t]],shapeType:"rect"}}default:continue}return null}(n);i&&(l=i.points,c=i.shapeType,a=[Math.min(...l.map(e=>e[0])),Math.min(...l.map(e=>e[1])),Math.max(...l.map(e=>e[0])),Math.max(...l.map(e=>e[1]))],({style:s,svg:u}=null!=(o=function(e){const t={};e.hasAttribute("fill")?(t.fill=e.getAttribute("fill"),e.removeAttribute("fill")):e.style.fill&&(t.fill=e.style.fill);if(t.fill){const e=Tn.exec(t.fill);e&&(t.fillOpacity=parseFloat(e[4]),t.fill=`rgb(${e[1]}, ${e[2]}, ${e[3]})`)}e.hasAttribute("fill-opacity")?(t.fillOpacity=parseFloat(e.getAttribute("fill-opacity")),e.removeAttribute("fill-opacity")):e.style.fillOpacity&&(t.fillOpacity=parseFloat(e.style.fillOpacity));e.hasAttribute("stroke")?(t.stroke=e.getAttribute("stroke"),e.removeAttribute("stroke")):e.style.stroke&&(t.stroke=e.style.stroke);if(t.stroke){const e=Tn.exec(t.stroke);e&&(t.strokeOpacity=parseFloat(e[4]),t.stroke=`rgb(${e[1]}, ${e[2]}, ${e[3]})`)}e.hasAttribute("stroke-opacity")?(t.strokeOpacity=parseFloat(e.getAttribute("stroke-opacity")),e.removeAttribute("stroke-opacity")):e.style.strokeOpacity&&(t.strokeOpacity=parseFloat(e.style.strokeOpacity));e.hasAttribute("stroke-width")?(t.strokeWidth=e.getAttribute("stroke-width"),e.removeAttribute("stroke-width")):e.style.strokeWidth&&(t.strokeWidth=e.style.strokeWidth);e.hasAttribute("stroke-dasharray")?(t.strokeDasharray=e.getAttribute("stroke-dasharray"),e.removeAttribute("stroke-dasharray")):e.style.strokeDasharray&&(t.strokeDasharray=e.style.strokeDasharray);let n=e;for(;"svg"!==n.tagName.toLowerCase();)if(n=n.parentElement,null===n)throw new Error("Could not find root SVG element");return{svg:n.outerHTML,style:Object.keys(t).length>0?t:void 0}}(i.element))?o:{svg:u}))}const d={type:"SvgSelector",svg:u,svgShape:c,style:s,points:l.length?l:void 0,spatial:a?{unit:"pixel",x:a[0],y:a[1],width:a[2]-a[0],height:a[3]-a[1]}:void 0};return zn({selector:d,selectors:[d],iiifRenderingHints:r})}return zn({selector:null,selectors:[],iiifRenderingHints:r})}function Dn(e){const t=e.map(e=>e[0]).reduce((e,t)=>(e[t]+=1,e),{C:0,Q:0,L:0,M:0}),n=new Set(e.map(e=>e[0]));if(t.C>0||t.Q>0)return"path";if(t.L>0&&(1===n.size||2===n.size&&n.has("M"))){if(4===t.L)return"rect";const n=e.slice(-1)[0];return"M"===e[0][0]&&"L"===n[0]&&n[1]==e[0][1]&&n[2]===e[0][2]||0===n[1]&&0===n[2]?"polygon":"polyline"}return"path"}function Ln(e){var t;const n=[];for(let r=0;r<e.length;r++){const i=null!=(t=n[n.length-1])?t:[0,0],o=e[r];switch(o[0]){case"M":case"L":n.push([o[1],o[2]]);continue;case"C":n.push(...In({x:i[0],y:i[1]},{x:o[1],y:o[2]},{x:o[3],y:o[4]},{x:o[5],y:o[6]}).map(e=>[e.x,e.y]).slice(1));continue;case"Q":n.push(...Sn({x:i[0],y:i[1]},{x:o[1],y:o[2]},{x:o[3],y:o[4]}).map(e=>[e.x,e.y]).slice(1));continue}}return n}function zn(e){if(e.iiifRenderingHints){const t=e.iiifRenderingHints;if(t.rotation){const n=function(e){let t=parseFloat(e);t&&e.startsWith("!")&&(t=360-t);t&&(t%=360);if(t!=t)return 0;return t||0}(t.rotation);if(n)if(e.selectors.length)for(const t of e.selectors)t.rotation=n;else e.selectors.push({type:"RotationSelector",rotation:n})}}else delete e.iiifRenderingHints;return e}const Fn=i(ln).withConfig({displayName:"TemplateCardContainer",componentId:"sc-1bvkudb-0"})(["align-items:center;max-width:10rem;height:fit-content;color:grey;font-size:0.75rem;"]),Wn=i.div.withConfig({displayName:"TemplateCardNew",componentId:"sc-1bvkudb-1"})(["align-items:center;justify-content:center;display:flex;height:8rem;width:6.25rem;border-radius:2px;border:2px solid ",";padding:",";"],e=>e.theme.color.mediumgrey||"grey",e=>e.theme.padding.xs||"0.25rem"),Bn=i.div.withConfig({displayName:"TemplateCardPlaceholder",componentId:"sc-1bvkudb-2"})(["height:100%;width:100%;background-color:",";border-radius:2px;"],e=>e.theme.color.mediumgrey||"grey"),$n=({className:e,inline:t,height:n=16,color:r="black"})=>I("svg",{xmlns:"http://www.w3.org/2000/svg",height:n+"px",viewBox:"0 0 24 24",width:"24px",fill:r,style:{verticalAlign:t?"bottom":void 0},className:e,children:[S("path",{d:"M0 0h24v24H0z",fill:"none"}),S("path",{d:"M19 13h-6v6h-2v-6H5v-2h6V5h2v6h6v2z"})]}),qn=i.h4.withConfig({displayName:"WidgetHeader",componentId:"sc-uk5wf8-0"})(["padding:",";margin:unset;"],e=>e.theme.padding.medium||"1rem"),Un=({manifestUrl:e,changeManifest:t})=>{const r=new f.Vault,[i,o]=n.useState();return n.useEffect(()=>{(async()=>{const t=await r.loadManifest(e||"");o(t)})()},[e]),I(Fn,{onClick:()=>t(window.location.href+i.id),children:[S(Wn,{children:"Blank Manifest"===fn(null==i?void 0:i.label)?S($n,{}):S(Bn,{})}),S(pn,{children:fn(null==i?void 0:i.label)})]})},Hn=({newTemplates:e,changeManifest:t})=>I(un,{children:[S(qn,{children:"Start from template"}),S(dn,{children:e&&(null==e?void 0:e.items.map(e=>S(Un,{manifestUrl:window.location.href+e.id,changeManifest:t},e.id)))})]}),Vn=i.div.withConfig({displayName:"BaseMessage",componentId:"sc-1rwd5vp-0"})(["background:#000;color:#fff;width:100%;padding:0.5em 1em;line-height:1.9em;display:flex;a{color:#fff;}svg{fill:#fff;margin:0 0.5em;vertical-align:text-bottom;}"," "," "," ",""],e=>e.$small&&i.css(["font-size:0.75em;padding:0.25em 0.5em;line-height:1.6em;"]),e=>e.$wide&&i.css(["margin-left:-2em;margin-right:-2em;width:auto;svg{height:0.8em;vertical-align:baseline;}"]),e=>e.$margin&&i.css(["margin-bottom:1em;"]),e=>e.$banner&&i.css(["border-radius:5px;box-shadow:0 3px 15px 0 rgb(0 0 0 / 16%);"])),Jn=i(Vn).withConfig({displayName:"InfoMessage",componentId:"sc-19dvvj0-0"})(["background:#5476e9;color:#fff;"]);i.div.withConfig({displayName:"PaddingComponentLarge",componentId:"sc-123ig8a-0"})(["padding:",";"],e=>e.theme.padding.large||"2rem");const Yn=i.div.withConfig({displayName:"PaddingComponentMedium",componentId:"sc-123ig8a-1"})(["padding:",";"],e=>e.theme.padding.medium||"1rem");i.div.withConfig({displayName:"PaddingComponentSmall",componentId:"sc-123ig8a-2"})(["padding:",";"],e=>e.theme.padding.small||"0.5rem");const Gn=({close:e})=>{const{newTemplates:t}=hr(),{changeApp:n}=J(),{createProjectFromManifestId:r}=Ka(),{current:i}=N();return I(A,{children:[S(Hn,{changeManifest:t=>{r(t).then(()=>{e()})},newTemplates:t}),S(Yn,{}),i?I(Jn,{$banner:!0,children:[i.name," ",S(X,{style:{marginLeft:20},onClick:()=>n({id:"manifest-editor"}),children:"Continue editing"})]}):null]})};const Zn=i.div.withConfig({displayName:"ModalBackground",componentId:"sc-up4euj-0"})(["position:fixed;top:0;left:0;right:0;bottom:0;z-index:500;background:rgba(0,0,0,0.2);"]),Kn=i.div.withConfig({displayName:"ModalContainer",componentId:"sc-up4euj-1"})(["position:fixed;top:0;left:0;right:0;bottom:0;z-index:501;display:flex;"]),Xn={sm:{maxWidth:"600px"},md:{maxWidth:"800px"},lg:{maxWidth:"1000px"}},Qn=i.div.withConfig({displayName:"InnerModalContainer",componentId:"sc-up4euj-2"})(["max-width:",";width:100%;min-height:250px;height:auto;display:flex;margin:8em auto auto;padding:0;flex-direction:column;max-height:80vh;border-radius:5px;overflow:hidden;box-shadow:4px 0 40px 0 rgba(0,0,0,0.3),0 0 0 1px rgba(0,0,0,0.2);",""],e=>e.$expanded?"100%":Xn[e.size||"sm"].maxWidth,e=>e.$expanded&&i.css(["position:absolute;top:0;bottom:0;left:0;right:0;border-radius:0;box-shadow:none;margin:0;max-height:none;","{flex:1 1 0px;}"],ir)),er=i.div.withConfig({displayName:"ModalHeader",componentId:"sc-up4euj-3"})(["color:#000;background:#fff;width:100%;padding:1em;display:flex;"]),tr=i.div.withConfig({displayName:"ModalHeaderTitle",componentId:"sc-up4euj-4"})(["color:inherit;font-size:1.2em;flex:1 1 0px;"]),nr=i(Qt).withConfig({displayName:"ModalCloseIcon",componentId:"sc-up4euj-5"})(["fill:rgba(0,0,0,0.5);cursor:pointer;&:hover{fill:rgba(0,0,0,1);}"]),rr=i((function(e){return I("svg",{height:"1em",width:"1em",...e,children:[S("path",{d:"M0 0h24v24H0z",fill:"none"}),S("path",{d:"M7 14H5v5h5v-2H7v-3zm-2-4h2V7h3V5H5v5zm12 7h-3v2h5v-5h-2v3zM14 5v2h3v3h2V5h-5z"})]})})).withConfig({displayName:"ModalResizeIcon",componentId:"sc-up4euj-6"})(["fill:rgba(0,0,0,0.5);cursor:pointer;font-size:1.2em;margin-right:1em;&:hover{fill:rgba(0,0,0,1);}"]),ir=i.div.withConfig({displayName:"ModalBody",componentId:"sc-up4euj-7"})(["background:#fff;padding:1em;overflow-y:auto;overflow-x:hidden;min-height:230px;"]),or=i.div.withConfig({displayName:"ModalFooter",componentId:"sc-up4euj-8"})(["background:#eee;width:100%;color:#fff;padding:1em;display:flex;",""],e=>e.$footerAlignRight&&i.css(["flex-direction:row-reverse;"])),ar=n.forwardRef((function({as:e,className:t,disabled:r,button:i,title:o,render:a,renderFooter:c,onClose:l,onOpen:u,modalSize:d,autoHeight:p,footerAlignRight:f,children:h,openByDefault:m=!1,style:g,onKeyDown:v,tabIndex:y,role:b},w){const x=n.useRef(),[C,k]=n.useState(!1),[P,M]=n.useState(!1),E=n.useRef();n.useLayoutEffect(()=>{const e=document.createElement("div");return document.body.appendChild(e),x.current=e,m&&k(!0),()=>{x.current=void 0,document.body.removeChild(e)}},[]);const R=()=>{k(!1),M(!1),l&&l()},j=e||(i?"button":"span");return I(A,{children:[C&&x.current?s.createPortal(I(A,{children:[S(Zn,{}),S(Kn,{ref:E,onClick:e=>{e.target===E.current&&R()},children:I(Qn,{$expanded:P,size:d,"data-cy":"modal",children:[I(er,{children:[S(tr,{children:o}),S(rr,{onClick:()=>M(e=>!e)}),S(nr,{onClick:R})]}),S(ir,{children:a({close:R})}),c?S(or,{$footerAlignRight:f,children:c({close:R})}):null]})})]}),x.current):null,S(j,{onKeyDown:v,tabIndex:y,role:b,ref:w,className:t,disabled:r,onClick:()=>{k(!0),u&&u()},style:g,children:h})]})})),sr=()=>{const{changeApp:e}=J(),t=Zi(),[r,i]=n.useState(!1),[o,a]=n.useState(!1);return S(A,{children:I(cn,{children:[I(tn,{onMouseLeave:()=>i(!1),children:[S(X,{"aria-label":"open file menu",onClick:()=>i(!r),children:"File"}),S("div",{style:r?{opacity:1,pointerEvents:"visible"}:{visibility:"hidden",opacity:0},children:I(nn,{onMouseLeave:()=>i(!1),children:[S(ar,{as:X,"aria-label":"Start a new manifest",title:"Start a new Manifest",modalSize:"lg",onOpen:()=>i(!1),render:e=>S(Gn,{...e}),children:"New"}),S(X,{onClick:()=>{i(!1),e({id:"splash"})},"aria-label":"Load an existing manifest",title:"Load an existing manifest",color:"#6b6b6b",children:"Open"}),S(X,{onClick:()=>{t.open({id:"export",stacked:!0})},"aria-label":"Export to JSON",title:"Export to JSON",color:"#6b6b6b",children:"Export"})]})})]}),I(tn,{onMouseLeave:()=>a(!1),children:[S(X,{"aria-label":"Help menu",onClick:()=>a(!o),children:"Help"}),o&&S(nn,{children:S(X,{"aria-label":"About",onClick:()=>{a(!o),e({id:"about"})},children:"About"})})]})]})})},cr=e=>S("svg",{width:"1em",height:"1em",viewBox:"0 0 206 27",xmlns:"http://www.w3.org/2000/svg",className:"me-logo",...e,children:I("g",{fill:"none",children:[S("path",{d:"M62.558 5.41v14.873h-2.983v-9.675l-3.985 9.675h-2.26l-4.006-9.675v9.675H46.34V5.41h3.388l4.73 11.06L59.19 5.41zm2.173 8.928c0-1.194.238-2.252.714-3.176.476-.923 1.123-1.633 1.94-2.13.816-.498 1.73-.746 2.738-.746.88 0 1.651.177 2.312.532.66.355 1.19.803 1.588 1.343V8.477h3.004v11.806h-3.004v-1.726c-.384.554-.913 1.012-1.588 1.374-.675.363-1.453.544-2.334.544-.994 0-1.9-.256-2.717-.767-.816-.512-1.463-1.233-1.939-2.163-.476-.93-.714-2-.714-3.207Zm9.292.042c0-.724-.143-1.346-.427-1.864a3.005 3.005 0 0 0-1.15-1.194 3.076 3.076 0 0 0-1.556-.415c-.554 0-1.066.135-1.534.405-.47.27-.85.664-1.14 1.182-.292.519-.437 1.133-.437 1.844 0 .71.145 1.331.437 1.864.29.533.674.941 1.15 1.226.476.284.984.426 1.524.426.554 0 1.073-.139 1.556-.416a3.005 3.005 0 0 0 1.15-1.193c.284-.519.427-1.14.427-1.865Zm12.466-6.073c1.406 0 2.543.444 3.41 1.332.866.888 1.3 2.127 1.3 3.718v6.926h-2.984v-6.52c0-.938-.234-1.66-.703-2.164-.47-.504-1.108-.756-1.918-.756-.824 0-1.474.252-1.95.756-.476.505-.714 1.226-.714 2.163v6.521h-2.983V8.477h2.983v1.47a4.121 4.121 0 0 1 1.524-1.203 4.713 4.713 0 0 1 2.035-.437Zm9.057-1.237c-.526 0-.963-.166-1.311-.5a1.657 1.657 0 0 1-.522-1.247c0-.497.174-.912.522-1.246.348-.334.785-.5 1.31-.5.526 0 .963.166 1.311.5.348.334.522.75.522 1.246 0 .498-.174.913-.522 1.247-.348.334-.785.5-1.31.5Zm1.47 1.407v11.806h-2.983V8.477h2.983Zm8.354 2.451h-2.068v9.355h-3.026v-9.355h-1.342v-2.45h1.342V7.88c0-1.45.412-2.515 1.236-3.197.824-.682 2.067-1.001 3.73-.959V6.24c-.725-.014-1.23.106-1.513.362-.284.256-.427.718-.427 1.385v.49h2.068v2.451Zm12.913 3.197c0 .426-.028.81-.085 1.15h-8.63c.07.853.369 1.52.895 2.003.525.483 1.172.725 1.939.725 1.108 0 1.896-.476 2.365-1.428h3.218c-.34 1.137-.994 2.07-1.96 2.802-.967.732-2.153 1.098-3.56 1.098-1.136 0-2.155-.252-3.057-.757a5.325 5.325 0 0 1-2.11-2.141c-.504-.924-.756-1.99-.756-3.197 0-1.222.248-2.294.745-3.218a5.204 5.204 0 0 1 2.089-2.13c.895-.498 1.925-.746 3.09-.746 1.122 0 2.127.241 3.015.724a5.1 5.1 0 0 1 2.067 2.057c.49.887.735 1.907.735 3.058Zm-3.09-.853c-.014-.767-.29-1.381-.83-1.843-.54-.462-1.201-.693-1.982-.693-.74 0-1.36.224-1.865.671-.504.448-.813 1.07-.927 1.865h5.604Zm9.782 7.203c-.966 0-1.833-.174-2.6-.522-.767-.348-1.375-.82-1.822-1.417a3.591 3.591 0 0 1-.735-1.982h3.004c.057.454.281.83.672 1.13.39.298.877.447 1.46.447.568 0 1.012-.114 1.331-.341.32-.227.48-.519.48-.874 0-.383-.196-.671-.586-.863-.391-.192-1.012-.401-1.865-.629-.88-.213-1.602-.433-2.163-.66a3.755 3.755 0 0 1-1.449-1.044c-.405-.47-.607-1.101-.607-1.897 0-.653.188-1.25.564-1.79.377-.54.917-.966 1.62-1.279.703-.312 1.53-.468 2.483-.468 1.406 0 2.528.351 3.367 1.054.838.704 1.3 1.652 1.385 2.845h-2.856c-.042-.469-.238-.841-.586-1.118-.348-.277-.813-.416-1.396-.416-.54 0-.955.1-1.246.298a.951.951 0 0 0-.437.831c0 .398.199.7.597.906.397.206 1.015.416 1.854.629.852.213 1.555.433 2.11.66a3.727 3.727 0 0 1 1.438 1.055c.405.476.614 1.105.628 1.886 0 .682-.188 1.293-.564 1.833-.377.54-.917.962-1.62 1.268-.703.305-1.524.458-2.461.458Zm10.569-9.547v5.711c0 .398.096.686.288.863.192.178.515.267.97.267h1.385v2.514h-1.875c-2.515 0-3.772-1.222-3.772-3.665v-5.69h-1.407v-2.45h1.407v-2.92h3.004v2.92h2.643v2.45h-2.643Zm12.851-3.111v3.73h5.007v2.364h-5.007v3.943h5.647v2.43h-8.631V5.386h8.63v2.43zm7.585 6.521c0-1.194.239-2.252.715-3.176.476-.923 1.126-1.633 1.95-2.13.824-.498 1.74-.746 2.749-.746.767 0 1.498.167 2.194.5.697.334 1.25.778 1.663 1.332V4.514h3.026v15.77h-3.026v-1.748c-.37.582-.888 1.051-1.556 1.406s-1.442.533-2.323.533a5.07 5.07 0 0 1-2.727-.767c-.824-.512-1.474-1.233-1.95-2.163-.476-.93-.714-2-.714-3.207Zm9.292.042c0-.724-.142-1.346-.426-1.864a3.005 3.005 0 0 0-1.151-1.194 3.076 3.076 0 0 0-1.556-.415 3.02 3.02 0 0 0-1.534.405c-.469.27-.849.664-1.14 1.182-.291.519-.437 1.133-.437 1.844 0 .71.146 1.331.437 1.864.291.533.675.941 1.15 1.226a2.93 2.93 0 0 0 1.524.426c.554 0 1.073-.139 1.556-.416a3.005 3.005 0 0 0 1.15-1.193c.285-.519.427-1.14.427-1.865Zm7.438-7.31c-.527 0-.963-.166-1.311-.5a1.657 1.657 0 0 1-.523-1.247c0-.497.174-.912.523-1.246.348-.334.784-.5 1.31-.5s.963.166 1.31.5c.349.334.523.75.523 1.246 0 .498-.174.913-.522 1.247-.348.334-.785.5-1.31.5Zm1.47 1.407v11.806h-2.984V8.477h2.984Zm6.414 2.451v5.711c0 .398.096.686.287.863.192.178.515.267.97.267h1.385v2.514h-1.875c-2.515 0-3.772-1.222-3.772-3.665v-5.69h-1.406v-2.45h1.406v-2.92h3.005v2.92h2.642v2.45h-2.642Zm10.036 9.547c-1.136 0-2.159-.252-3.068-.757a5.447 5.447 0 0 1-2.141-2.141c-.519-.924-.778-1.99-.778-3.197s.266-2.273.799-3.196a5.553 5.553 0 0 1 2.184-2.142c.924-.504 1.954-.756 3.09-.756 1.137 0 2.167.252 3.09.756a5.553 5.553 0 0 1 2.184 2.142c.533.923.8 1.989.8 3.196 0 1.208-.274 2.273-.821 3.197a5.681 5.681 0 0 1-2.216 2.141c-.93.505-1.971.757-3.122.757Zm0-2.6a3.1 3.1 0 0 0 1.524-.394c.476-.263.856-.657 1.14-1.183.285-.526.427-1.165.427-1.918 0-1.122-.295-1.985-.885-2.589a2.907 2.907 0 0 0-2.163-.906c-.852 0-1.566.302-2.141.906-.576.604-.863 1.467-.863 2.59 0 1.122.28 1.985.841 2.588.562.604 1.268.906 2.12.906Zm11.338-7.565a4.194 4.194 0 0 1 1.502-1.47c.618-.356 1.325-.533 2.12-.533v3.132h-.788c-.938 0-1.644.22-2.12.661-.476.44-.714 1.208-.714 2.302v5.881h-2.984V8.477h2.984v1.833Z",fill:"#000"}),S("path",{fill:"#E94581",className:"me-logo-1",d:"M0 13.343 13.343 0l13.343 13.343-13.343 13.343z"}),S("path",{fill:"#E94581",className:"me-logo-2",d:"M12.137 13.346 25.48.003l13.343 13.343L25.48 26.69z"}),S("path",{fill:"#C63E75",className:"me-logo-3",d:"m12.104 13.348 7.311-7.311 7.312 7.311-7.312 7.312z"})]})});function lr(){const{actions:e}=N(),[t,r]=n.useState(!1),{current:i}=N();return I(ae,{children:[S(se,{children:"Drafts"}),i?S(A,{children:t?I(ce,{onSubmit:t=>{const n=new FormData(t.target),i=Object.fromEntries(n.entries());e.updateDetails(i),r(!1)},children:[S(le,{id:"project-title",defaultValue:i.name,name:"name"}),S(ue,{children:"Save"})]}):S(de,{onClick:()=>{var e;s.flushSync(()=>{r(!0)}),null==(e=document.getElementById("project-title"))||e.focus()},children:i.name||"Untitled project"})}):null]})}const ur=()=>I("svg",{xmlns:"http://www.w3.org/2000/svg",height:"1rem",viewBox:"0 0 24 24",width:"24px",fill:"#000000",children:[S("path",{d:"M0 0h24v24H0z",fill:"none"}),S("path",{d:"M3 18h18v-2H3v2zm0-5h18v-2H3v2zm0-7v2h18V6H3z"})]});function dr(e){const{current:t}=N(),[n,r]=E("menu-hidden"),{apps:i,changeApp:o}=J(),a=null==t?void 0:t.resource.type,s=Object.values(i).filter(e=>{if(e.metadata.project&&e.metadata.projectType!==a)return!1;if(!t&&e.metadata.project)return!1;if("launcher"===e.metadata.type)return!1;if(e.metadata.dev){try{if("true"==={}.PULL_REQUEST)return!0}catch(n){return!1}return!1}return!0}),{itemProps:c,buttonProps:l,isOpen:u,setIsOpen:d}=Kt(s.length+1);return I(tn,{children:[S(re,{...l,children:S(ur,{})}),I(on,{$open:u,children:[S(an,{children:"Apps"}),S(sn,{}),s.map((e,t)=>S(X,{...c[t],onClick:()=>{o({id:e.metadata.id}),d(!1)},children:e.metadata.title},e.metadata.id)),e.hideMenu?null:I(A,{children:[S(an,{children:"Quick Settings"}),S(sn,{}),S(X,{...c[s.length+0],onClick:()=>r(!n),children:n?"Show menu":"Hide menu"})]})]})]})}const pr=n.memo((function(e){const[t]=E("menu-hidden"),{changeApp:n,initialApp:r,currentApp:i,apps:o}=J(),a=o[null==i?void 0:i.id];return I(ne,{children:[I(te,{children:[S(dr,{}),S(ie,{onClick:e.onClickLogo||(()=>n(r)),children:S(cr,{height:27,width:200})}),a&&!1===a.metadata.drafts?null:S(oe,{children:S(lr,{})}),S(en,{})]}),t?null:S(sr,{})]})}));const fr=n.createContext(null);function hr(){return n.useContext(fr)}function mr({children:e,config:t}){const r=n.useMemo(()=>({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"],defaultLanguages:["en","none"],newTemplates:null,...t||{}}),[]);return S(fr.Provider,{value:r,children:e})}function gr(e,t){var n,r,i;switch(t.type){case"edit":return(null==(n=e.current)?void 0:n.resource.source.id)===(null==(r=t.payload.resource)?void 0:r.resource.source.id)?{...e,current:t.payload.resource}:{...e,current:t.payload.resource,stack:t.payload.reset?[]:e.current?[e.current,...e.stack]:e.stack};case"syncRemoval":{const n=o.toRef(t.payload.resource.resource);if(!n)return e;if(!e.stack.find(e=>{var t;return(null==(t=o.toRef(e.resource))?void 0:t.id)===n.id}))return e;const r=(null==(i=e.current)?void 0:i.resource.id)===n.id?null:e.current,a=function(e,t){const n=[];let r=null;for(const i of e)(null==r?void 0:r.resource.id)!==i.resource.id&&(n.push(i),r=i);if(r&&r.resource.id===(null==t?void 0:t.resource.id))return n.slice(0,n.length-1);return n}(e.stack.filter(e=>{var t;return(null==(t=o.toRef(e.resource))?void 0:t.id)!==n.id}),r);return{...e,stack:a,current:r}}case"updateCurrent":return{...e,current:t.payload.resource};case"back":{const t=e.stack[0];return{...e,stack:e.stack.slice(1),current:t}}case"close":return{...e,stack:[],current:null};case"create":return null===t.payload.resource?{...e,create:null}:{...e,create:t.payload}}return e}class vr{constructor(e){t(this,"config"),e.validators||(e.validators=[]),this.config=e}entity(){const e=this.ref();return this.config.vault.get(e,{skipSelfReturn:!1})}ref(){return this.config.reference}getId(){return this.ref().id}getType(){return this.ref().type}focusId(){return`${this.getId()}_${this.getType()}`}_observe(e,t,n=!0){return this.config.vault.subscribe(()=>e(this.entity(),this.config.context,this.config.vault),e=>{t(e,this.entity(),this.config.context)},n)}}const yr={all:["label","summary","metadata","requiredStatement","rights","navDate","language","thumbnail","provider","placeholderCanvas","accompanyingCanvas"],required:{Collection:["label"],Manifest:["label"],Canvas:[],Annotation:[],AnnotationPage:[],Range:[],AnnotationCollection:[],ContentResource:[],Agent:["label"]},recommended:{Collection:["metadata","summary","provider","thumbnail"],Manifest:["metadata","summary","provider","thumbnail"],Canvas:["label"],Annotation:[],AnnotationPage:[],Range:["label"],AnnotationCollection:["label"],ContentResource:["label"],Agent:[]},optional:{Collection:["requiredStatement","rights","navDate","placeholderCanvas","accompanyingCanvas"],Manifest:["requiredStatement","rights","navDate","placeholderCanvas","accompanyingCanvas"],Canvas:["metadata","summary","requiredStatement","rights","navDate","provider","thumbnail","placeholderCanvas","accompanyingCanvas"],Annotation:["label","metadata","summary","requiredStatement","rights","provider","thumbnail"],AnnotationPage:["label","metadata","summary","requiredStatement","rights","provider","thumbnail"],Range:["metadata","summary","requiredStatement","rights","navDate","provider","thumbnail","placeholderCanvas","accompanyingCanvas"],AnnotationCollection:["metadata","summary","requiredStatement","rights","provider","thumbnail"],ContentResource:["label","metadata","summary","requiredStatement","rights","provider","thumbnail"],Agent:[]},notAllowed:{Collection:["language"],Manifest:["language"],Canvas:["language"],Annotation:["navDate","language","placeholderCanvas","accompanyingCanvas"],AnnotationPage:["navDate","language","placeholderCanvas","accompanyingCanvas"],Range:["language"],AnnotationCollection:["navDate","placeholderCanvas","accompanyingCanvas"],ContentResource:["navDate","placeholderCanvas","accompanyingCanvas"],Agent:["provider","language","metadata","summary","thumbnail","requiredStatement","rights","navDate","placeholderCanvas","accompanyingCanvas"]}};class br extends vr{constructor(e,n){super(e),t(this,"property"),this.property=n}observe(e,t=!0){this._observe(e=>e&&e[this.property],e,t)}focusId(){return`${super.focusId()}_${this.property}`}containerId(){return`container_${super.focusId()}_${this.property}`}getContainerProps(){return{"data-property":this.property,"data-resource-id":this.getId(),"data-resource-type":this.getType()}}isRequired(){const e=this.getType();return-1!==(yr.required[e]||[]).indexOf(this.property)}isRecommended(){const e=this.getType();return-1!==(yr.recommended[e]||[]).indexOf(this.property)}isNotAllowed(){const e=this.getType();return-1!==(yr.notAllowed[e]||[]).indexOf(this.property)}isOptional(e=!1){const t=this.getType(),n=yr.optional[t]||[];return!n&&e?this.isRecommended():-1!==n.indexOf(this.property)}validate(){const e=this.config.validators,t=this.entity(),n=null==t?void 0:t.type,r={isError:!1,isWarning:!1,warnings:[],errors:[]};if(t&&n&&e.length&&n)for(const o of e)if(o.types.includes(n)&&o.properties.includes(this.property))try{o.valid(t,this.config.vault,this.config.context)||(o.error?(r.isError=!0,r.errors.push(o.message)):o.warning&&(r.isWarning=!0,r.warnings.push(o.message)))}catch(i){r.isWarning=!0,r.warnings.push("Validation error: "+(i||"unknown"))}return r}getWithoutTracking(){const e=this.entity();return e&&e[this.property]}get(){return this.config.tracker.track(this.property),this.getWithoutTracking()}set(e){this.config.vault.modifyEntityField(this.config.reference,this.property,e)}}const wr=function(e){return function(){const t={type:e,getType:()=>e,toString:()=>e};return(e,n)=>({...t,...void 0!==e&&{payload:e},...void 0!==n&&{meta:n}})}},xr=wr("@iiif/IMPORT_ENTITIES")(),Cr=wr("@iiif/MODIFY_ENTITY_FIELD")(),kr=wr("@iiif/REORDER_ENTITY_FIELD")(),Pr=wr("@iiif/ADD_REFERENCE")(),Ar=wr("@iiif/REMOVE_REFERENCE")(),Sr=wr("@iiif/UPDATE_REFERENCE")(),Ir=wr("@iiif/ADD_METADATA")(),Mr=wr("@iiif/UPDATE_METADATA")(),Er=wr("@iiif/REMOVE_METADATA")(),Rr=wr("@iiif/REORDER_METADATA")(),jr={importEntities:xr,modifyEntityField:Cr,reorderEntityField:kr,addReference:Pr,removeReference:Ar,updateReference:Sr,addMetadata:Ir,removeMetadata:Er,updateMetadata:Mr,reorderMetadata:Rr},_r=wr("@iiif/REQUEST_RESOURCE")(),Or=wr("@iiif/BATCH")();var Tr,Nr=new Uint8Array(16);function Dr(){if(!Tr&&!(Tr="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||"undefined"!=typeof msCrypto&&"function"==typeof msCrypto.getRandomValues&&msCrypto.getRandomValues.bind(msCrypto)))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return Tr(Nr)}const Lr=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;function zr(e){return"string"==typeof e&&Lr.test(e)}for(var Fr=[],Wr=0;Wr<256;++Wr)Fr.push((Wr+256).toString(16).substr(1));function Br(e,t,n){var r=(e=e||{}).random||(e.rng||Dr)();if(r[6]=15&r[6]|64,r[8]=63&r[8]|128,t){n=n||0;for(var i=0;i<16;++i)t[n+i]=r[i];return t}return function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=(Fr[e[t+0]]+Fr[e[t+1]]+Fr[e[t+2]]+Fr[e[t+3]]+"-"+Fr[e[t+4]]+Fr[e[t+5]]+"-"+Fr[e[t+6]]+Fr[e[t+7]]+"-"+Fr[e[t+8]]+Fr[e[t+9]]+"-"+Fr[e[t+10]]+Fr[e[t+11]]+Fr[e[t+12]]+Fr[e[t+13]]+Fr[e[t+14]]+Fr[e[t+15]]).toLowerCase();if(!zr(n))throw TypeError("Stringified UUID is invalid");return n}(r)}class $r extends br{constructor(e){super(e,"metadata"),t(this,"cachedList"),t(this,"cachedSortableList",[]),t(this,"idCache",new Map)}_getId(e){if(this.idCache.has(e))return this.idCache.get(e);const t=Br();return this.idCache.set(e,t),t}getSortable(){const e=this.get();return this.cachedList!==e&&(this.cachedSortableList=(e||[]).map(e=>e.id?e:{id:this._getId(e),...e})),this.cachedSortableList}add(e,t,n){const r=this.ref();this.config.vault.dispatch(jr.addMetadata({id:r.id,label:e,value:t,type:r.type,beforeIndex:n}))}update(e,t,n){const r=this.ref();this.config.vault.dispatch(jr.updateMetadata({id:r.id,label:t,value:n,type:r.type,atIndex:e}))}deleteAtIndex(e){const t=this.ref();this.config.vault.dispatch(jr.removeMetadata({id:t.id,type:t.type,atIndex:e}))}moveToStart(e){this.reorder(e,0)}moveToEnd(e){const t=this.getWithoutTracking().length;this.reorder(e,t)}reorder(e,t){const n=this.ref();this.config.vault.dispatch(jr.reorderMetadata({id:n.id,type:n.type,startIndex:e,endIndex:t}))}}class qr extends br{constructor(e){super(e,"requiredStatement")}updateLabel(e){const t={value:{none:[""]},...this.getWithoutTracking()||{},label:"string"==typeof e?{none:[e]}:e};this.set(t)}update(e){const t={label:{none:[""]},...this.getWithoutTracking()||{},value:"string"==typeof e?{none:[e]}:e};this.set(t)}}const Ur=[{label:"Public Domain",shortLabel:"CC0",description:"The person who associated a work with this deed has dedicated the work to the public domain by waiving all of his or her rights to the work worldwide under copyright law, including all related and neighboring rights, to the extent allowed by law.",icon:"https://licensebuttons.net/p/zero/1.0/88x31.png",value:"http://creativecommons.org/publicdomain/zero/1.0/",url:"https://creativecommons.org/publicdomain/zero/1.0/",legal:"https://creativecommons.org/publicdomain/zero/1.0/legalcode"},{label:"Attribution",shortLabel:"CC BY",description:"This license lets others distribute, remix, adapt, and build upon your work, even commercially, as long as they credit you for the original creation. This is the most accommodating of licenses offered. Recommended for maximum dissemination and use of licensed materials.",icon:"https://licensebuttons.net/l/by/3.0/88x31.png",value:"http://creativecommons.org/licenses/by/4.0/",url:"https://creativecommons.org/licenses/by/4.0/",legal:"http://creativecommons.org/licenses/by/4.0/legalcode"},{label:"Attribution-ShareAlike",shortLabel:"CC BY-SA",description:"This license lets others remix, adapt, and build upon your work even for commercial purposes, as long as they credit you and license their new creations under the identical terms. This license is often compared to “copyleft” free and open source software licenses. All new works based on yours will carry the same license, so any derivatives will also allow commercial use. This is the license used by Wikipedia, and is recommended for materials that would benefit from incorporating content from Wikipedia and similarly licensed projects.",icon:"https://licensebuttons.net/l/by-sa/3.0/88x31.png",value:"http://creativecommons.org/licenses/by-sa/4.0/",url:"https://creativecommons.org/licenses/by-sa/4.0/",legal:"http://creativecommons.org/licenses/by-sa/4.0/legalcode"},{label:"Attribution-NoDerivs",shortLabel:"CC BY-ND",description:"This license lets others reuse the work for any purpose, including commercially; however, it cannot be shared with others in adapted form, and credit must be provided to you.",icon:"https://licensebuttons.net/l/by-nd/3.0/88x31.png",value:"http://creativecommons.org/licenses/by-nd/4.0/",url:"https://creativecommons.org/licenses/by-nd/4.0/",legal:"http://creativecommons.org/licenses/by-nd/4.0/legalcode"},{label:"Attribution-NonCommercial",shortLabel:"CC BY-NC",description:"This license lets others remix, adapt, and build upon your work non-commercially, and although their new works must also acknowledge you and be non-commercial, they don’t have to license their derivative works on the same terms.",icon:"https://licensebuttons.net/l/by-nc/3.0/88x31.png",value:"http://creativecommons.org/licenses/by-nc/4.0/",url:"https://creativecommons.org/licenses/by-nc/4.0/",legal:"http://creativecommons.org/licenses/by-nc/4.0/legalcode"},{label:"Attribution-NonCommercial-ShareAlike",shortLabel:"CC BY-NC-SA",description:"This license lets others remix, adapt, and build upon your work non-commercially, as long as they credit you and license their new creations under the identical terms.",icon:"https://licensebuttons.net/l/by-nc-sa/3.0/88x31.png",value:"http://creativecommons.org/licenses/by-nc-sa/4.0/",url:"https://creativecommons.org/licenses/by-nc-sa/4.0/",legal:"http://creativecommons.org/licenses/by-nc-sa/4.0/legalcode"},{label:"Attribution-NonCommercial-NoDerivs",shortLabel:"CC BY-NC-ND",description:"This license is the most restrictive of our six main licenses, only allowing others to download your works and share them with others as long as they credit you, but they can’t change them in any way or use them commercially.",icon:"https://licensebuttons.net/l/by-nc-nd/3.0/88x31.png",value:"http://creativecommons.org/licenses/by-nc-nd/4.0/",url:"https://creativecommons.org/licenses/by-nc-nd/4.0/",legal:"http://creativecommons.org/licenses/by-nc-nd/4.0/legalcode"}];class Hr extends br{constructor(e){super(e,"rights")}getClean(){let e=this.get();return e&&(e.replace(/https/,"http"),e.endsWith("/")||(e+="/")),e}getDefinition(){const e=this.getClean();return Ur.find(t=>t.value===e)||null}getIcon(){const e=this.getDefinition();if(e)return e.icon}getOptions(){return Ur}}class Vr extends br{constructor(e){super(e,"navDate")}setDate(e){e?this.set(e.toISOString()):this.set(null)}getDate(){const e=this.get();return e?new Date(e):null}modifyAsDate(e){const t=this.getWithoutTracking(),n=t?new Date(t):new Date;e(n),this.setDate(n)}}class Jr extends br{constructor(e,t){super(e,t)}}class Yr extends br{constructor(e,n){super(e,n),t(this,"cachedList"),t(this,"cachedSortableList"),t(this,"idCache",new Map)}focusId(){return`${super.focusId()}_${this.property}_list`}_getId(e){if(this.idCache.has(e))return this.idCache.get(e);const t=Br();return this.idCache.set(e,t),t}getSortable(){const e=this.get();return this.cachedList!==e&&(this.cachedSortableList=(e||[]).map(e=>e.id?e:{id:this._getId(e),...e})),this.cachedSortableList}get(){this.config.tracker.track(this.property);const e=this.entity();return e&&e[this.property]}set(){throw new Error("Cannot set directly")}moveToStart(e){this.config.vault.dispatch(jr.reorderEntityField({id:this.getId(),type:this.getType(),startIndex:e,endIndex:0,key:this.property}))}moveToEnd(e){const t=this.getWithoutTracking();this.config.vault.dispatch(jr.reorderEntityField({id:this.getId(),type:this.getType(),startIndex:e,endIndex:t.length,key:this.property}))}deleteAtIndex(e){const t=this.getWithoutTracking()[e];t&&this.config.vault.dispatch(jr.removeReference({id:this.getId(),type:this.getType(),key:this.property,reference:t,index:e}))}addAfter(e,t){this.config.vault.dispatch(jr.addReference({id:this.getId(),type:this.getType(),key:this.property,reference:t,index:e}))}addBefore(e,t){this.config.vault.dispatch(jr.addReference({id:this.getId(),type:this.getType(),key:this.property,reference:t,index:e-1}))}add(e){this.config.vault.dispatch(jr.addReference({id:this.getId(),type:this.getType(),key:this.property,reference:e}))}reorder(e,t){console.log("reoder",{id:this.getId(),type:this.getType(),startIndex:e,endIndex:t,key:this.property}),this.config.vault.dispatch(jr.reorderEntityField({id:this.getId(),type:this.getType(),startIndex:e,endIndex:t,key:this.property}))}moveUpBy(e,t){this.config.vault.dispatch(jr.reorderEntityField({id:this.getId(),type:this.getType(),startIndex:e,endIndex:Math.max(0,e-t),key:this.property}))}moveDownBy(e,t){const n=this.getWithoutTracking();this.config.vault.dispatch(jr.reorderEntityField({id:this.getId(),type:this.getType(),startIndex:e,endIndex:Math.min(n.length+1,e+t),key:this.property}))}duplicate(e){throw new Error("Not implemented")}updateReference(e,t){this.config.vault.dispatch(jr.updateReference({id:this.getId(),type:this.getType(),reference:t,index:e,key:this.property}))}batchInsertAtIndex(e,t){let n=t;for(;-1!==n&&-1!==e.indexOf(n);)n--;const r=this.getWithoutTracking();throw-1===n||r[n],new Error("Not yet implemented")}}class Gr extends vr{constructor(e){super(e),t(this,"label"),t(this,"summary"),t(this,"metadata"),t(this,"requiredStatement"),t(this,"rights"),t(this,"navDate"),t(this,"language"),t(this,"thumbnail"),t(this,"provider"),t(this,"placeholderCanvas"),t(this,"accompanyingCanvas"),t(this,"value"),this.label=new Jr(e,"label"),this.metadata=new $r(e),this.summary=new Jr(e,"summary"),this.requiredStatement=new qr(e),this.rights=new Hr(e),this.navDate=new Vr(e),this.language=new br(e,"language"),this.thumbnail=new Yr(e,"thumbnail"),this.provider=new br(e,"provider"),this.placeholderCanvas=new br(e,"placeholderCanvas"),this.accompanyingCanvas=new br(e,"accompanyingCanvas"),this.value=new br(e,"value")}}class Zr{constructor(e,n){t(this,"observed"),t(this,"vault"),t(this,"entity"),t(this,"key",""),this.vault=e,this.observed=[],this.entity=n}subscribe(e){return this.vault.subscribe(()=>this.vault.get(this.entity),e,!0)}start(e){let t=this.vault.get(this.entity),n=[];return this.vault.subscribe(()=>{const e=this.vault.get(this.entity);if(e===t)return n;t=e;const r=[];for(const t of this.observed){r.push(t);const n=e[t];Array.isArray(n)?r.push(...n):r.push(n)}return n=r,r},e,!0)}track(e){this.observed.includes(e)||this.observed.push(e)}reset(){this.observed=[]}}const Kr={key:"",observed:[],reset(){},start:()=>()=>{},subscribe:()=>()=>{},track(){}};class Xr{constructor(e){t(this,"index"),t(this,"editor"),t(this,"config"),j(e.context.parent),j(void 0!==e.context.index),j(e.context.parentProperty),this.editor=new Yr({...e,reference:e.context.parent,tracker:Kr,context:{resource:{type:"SpecificResource",source:e.context.parent}}},e.context.parentProperty),this.config=e,this.index=e.context.index}getSelector(){const e=this.config.context.resource;return e.selector?e.selector:null}updateReference(e){this.editor.updateReference(this.index,e)}moveToStart(){this.editor.moveToStart(this.index),this.index=0}moveToEnd(){this.editor.moveToEnd(this.index),this.index=this.editor.getWithoutTracking().length-1}moveUpBy(e){this.editor.moveUpBy(this.index,e),this.index=Math.max(0,this.index-e)}moveDownBy(e){this.editor.moveDownBy(this.index,e),this.index=Math.min(this.editor.getWithoutTracking().length+1,this.index+e)}removeFromParent(){this.editor.deleteAtIndex(this.index)}addAfter(e){this.editor.addAfter(this.index,e)}addBefore(e){this.editor.addBefore(this.index,e),this.index++}}class Qr extends br{set(){throw new Error("Read only")}}const ei=["unordered","individuals","continuous","paged"],ti=ei,ni=ei;function ri(e){return{label:{none:[e]},value:e}}const ii={id:"@iiif/auto-advance",label:{en:["Auto-advance"]},type:"choice",addNone:!0,items:["auto-advance","no-auto-advance"].map(ri)},oi={id:"@iiif/repeat",label:{en:["Repeat"]},type:"choice",addNone:!0,items:["repeat","no-repeat"].map(ri)},ai={id:"@iiif/manifest-ordering",label:{en:["Manifest ordering"]},type:"choice",addNone:!0,items:ei.map(ri)},si={id:"@iiif/canvas-ordering",label:{en:["Canvas ordering"]},type:"choice",addNone:!0,items:["facing-pages","paged","non-paged"].map(ri)},ci={id:"@iiif/range",label:{en:["Collection"]},type:"choice",addNone:!0,items:["multi-part","together"].map(ri)},li={id:"@iiif/range",label:{en:["Range"]},type:"choice",addNone:!0,items:["sequence","thumbnail-nav","no-nav"].map(ri)},ui={id:"@iiif/collection-ordering",label:{en:["Collection ordering"]},type:"choice",addNone:!0,items:ti.map(ri)},di={id:"@iiif/range-ordering",label:{en:["Range ordering"]},type:"choice",addNone:!0,items:ni.map(ri)},pi={id:"@iiif/range-hidden",label:{en:["Visibility"]},type:"choice",addNone:!0,items:["hidden"].map(ri)},fi={Collection:[ui,ci,oi,ii],Manifest:[ai,oi,ii],Canvas:[si,ii],Annotation:[pi],AnnotationPage:[pi],Range:[di,li,ii],AnnotationCollection:[pi],ContentResource:[pi]};class hi extends br{constructor(e){super(e,"behavior")}getSupported(){return fi[this.getType()]||[]}}class mi extends vr{constructor(e){super(e),t(this,"id"),t(this,"type"),t(this,"mediaType"),t(this,"format"),t(this,"profile"),t(this,"height"),t(this,"width"),t(this,"duration"),t(this,"viewingDirection"),t(this,"behavior"),t(this,"timeMode"),t(this,"motivation"),this.id=new Qr(e,"id"),this.type=this.entity().type||e.reference.type,this.mediaType=new br(e,"type"),this.format=new br(e,"format"),this.profile=new br(e,"profile"),this.height=new br(e,"height"),this.width=new br(e,"width"),this.duration=new br(e,"duration"),this.viewingDirection=new br(e,"viewingDirection"),this.behavior=new hi(e),this.timeMode=new br(e,"timeMode"),this.motivation=new br(e,"motivation")}}class gi extends vr{constructor(e){super(e),t(this,"seeAlso"),t(this,"service"),t(this,"services"),t(this,"rendering"),t(this,"partOf"),t(this,"start"),t(this,"supplementary"),t(this,"homepage"),t(this,"logo"),this.seeAlso=new Yr(e,"seeAlso"),this.service=new Yr(e,"service"),this.services=new Yr(e,"services"),this.rendering=new Yr(e,"rendering"),this.partOf=new Yr(e,"partOf"),this.start=new br(e,"start"),this.supplementary=new Yr(e,"supplementary"),this.homepage=new Yr(e,"homepage"),this.logo=new Yr(e,"logo")}}class vi extends vr{constructor(e){super(e),t(this,"items"),t(this,"annotations"),t(this,"structures"),this.items=new Yr(e,"items"),this.annotations=new Yr(e,"annotations"),this.structures=new Yr(e,"structures")}}const yi={all:["seeAlso","service","services","rendering","partOf","start","supplementary","homepage","logo"],required:{Collection:[],Manifest:[],Canvas:[],Annotation:[],AnnotationPage:[],Range:[],AnnotationCollection:[],ContentResource:[],Agent:[]},recommended:{Collection:[],Manifest:[],Canvas:[],Annotation:[],AnnotationPage:[],Range:[],AnnotationCollection:[],ContentResource:[],Agent:["homepage","logo"]},optional:{Collection:["seeAlso","service","homepage","rendering","partOf","services"],Manifest:["seeAlso","service","homepage","rendering","partOf","start","services"],Canvas:["seeAlso","service","homepage","rendering","partOf"],Annotation:["seeAlso","service","homepage","rendering","partOf"],AnnotationPage:["seeAlso","service","homepage","rendering","partOf"],Range:["seeAlso","service","homepage","rendering","partOf","start","supplementary"],AnnotationCollection:["seeAlso","service","homepage","rendering","partOf"],ContentResource:["seeAlso","service","homepage","rendering","partOf"],Agent:["seeAlso"]},notAllowed:{Collection:["supplementary","logo"],Manifest:["supplementary","logo"],Canvas:["start","supplementary","services","logo"],Annotation:["start","supplementary","services","logo"],AnnotationPage:["start","supplementary","services","logo"],Range:["services","logo"],AnnotationCollection:["start","supplementary","services","logo"],ContentResource:["start","supplementary","services","logo"],Agent:["service","homepage","rendering","partOf","services","start","supplementary"]}},bi={all:["annotations","items","structures"],required:{Collection:["items"],Manifest:["items"],Canvas:[],Annotation:[],AnnotationPage:[],Range:[],AnnotationCollection:[],ContentResource:[],Agent:[]},recommended:{Collection:[],Manifest:[],Canvas:["items"],Annotation:[],AnnotationPage:["items"],Range:[],AnnotationCollection:[],ContentResource:[],Agent:[]},optional:{Collection:["annotations"],Manifest:["structures","annotations"],Canvas:["annotations"],Annotation:[],AnnotationPage:[],Range:["annotations"],AnnotationCollection:[],ContentResource:["annotations"],Agent:[]},notAllowed:{Collection:["structures"],Manifest:[],Canvas:["structures"],Annotation:["items","structures","annotations"],AnnotationPage:["structures","annotations"],Range:["structures"],AnnotationCollection:["structures","annotations"],ContentResource:["items","structures"],Agent:["items","structures","annotations"]}},wi=["motivation"],xi={all:["id","type","format","profile","height","width","duration","viewingDirection","behavior","timeMode","motivation"],required:{Collection:["id","type"],Manifest:["id","type"],Canvas:["id","type"],Annotation:["id","type"],AnnotationPage:["id","type"],Range:["id","type"],AnnotationCollection:["id","type"],ContentResource:["id","type"],Agent:["id","type"]},recommended:{Collection:[],Manifest:[],Canvas:[],Annotation:[],AnnotationPage:[],Range:[],AnnotationCollection:[],ContentResource:[],Agent:[]},optional:{Collection:["viewingDirection","behavior"],Manifest:["viewingDirection","behavior"],Canvas:["height","width","duration","behavior"],Annotation:["behavior","timeMode"],AnnotationPage:["behavior"],Range:["viewingDirection","behavior"],AnnotationCollection:["behavior"],ContentResource:["format","height","width","duration","behavior"],Agent:[]},notAllowed:{Collection:["format","profile","height","width","duration","timeMode",...wi],Manifest:["format","profile","height","width","duration","timeMode",...wi],Canvas:["format","profile","viewingDirection","timeMode",...wi],Annotation:["format","profile","height","width","duration","viewingDirection"],AnnotationPage:["format","profile","height","width","duration","viewingDirection","timeMode",...wi],Range:["format","profile","height","width","duration","timeMode",...wi],AnnotationCollection:["format","profile","height","width","duration","viewingDirection","timeMode",...wi],ContentResource:["viewingDirection","timeMode",...wi],Agent:["viewingDirection","format","profile","height","width","duration","timeMode","behavior",...wi]}},Ci={all:["navPlace","textGranularity"],required:{Collection:[],Manifest:[],Canvas:[],Annotation:[],AnnotationPage:[],Range:[],AnnotationCollection:[],ContentResource:[],Agent:[]},recommended:{Collection:[],Manifest:[],Canvas:[],Annotation:[],AnnotationPage:[],Range:[],AnnotationCollection:[],ContentResource:[],Agent:[]},optional:{Collection:["navPlace"],Manifest:["navPlace"],Canvas:["navPlace"],Annotation:["textGranularity"],AnnotationPage:[],Range:["navPlace"],AnnotationCollection:[],ContentResource:[],Agent:[]},notAllowed:{Collection:["textGranularity"],Manifest:["textGranularity"],Canvas:["textGranularity"],Annotation:["navPlace"],AnnotationPage:["textGranularity","navPlace"],Range:["textGranularity"],AnnotationCollection:["textGranularity","navPlace"],ContentResource:["textGranularity","navPlace"],Agent:["textGranularity","navPlace"]}};function ki(e){const t=[...xi.required[e||"ContentResource"]||[],...yr.required[e||"ContentResource"]||[],...yi.required[e||"ContentResource"]||[],...bi.required[e||"ContentResource"]||[],...Ci.required[e||"ContentResource"]||[]],n=[...xi.recommended[e||"ContentResource"]||[],...yr.recommended[e||"ContentResource"]||[],...yi.recommended[e||"ContentResource"]||[],...bi.recommended[e||"ContentResource"]||[],...Ci.recommended[e||"ContentResource"]||[]],r=[...xi.notAllowed[e||"ContentResource"]||[],...yr.notAllowed[e||"ContentResource"]||[],...yi.notAllowed[e||"ContentResource"]||[],...bi.notAllowed[e||"ContentResource"]||[],...Ci.notAllowed[e||"ContentResource"]||[]],i=[...xi.optional[e||"ContentResource"]||[],...yr.optional[e||"ContentResource"]||[],...yi.optional[e||"ContentResource"]||[],...bi.optional[e||"ContentResource"]||[],...Ci.optional[e||"ContentResource"]||[]],o=[...t,...n,...i];return{all:[...o,...r],allowed:o,required:t,recommended:n,notAllowed:r,optional:i}}const Pi=ki("Collection"),Ai=ki("Manifest"),Si=ki("Canvas"),Ii=ki("Annotation"),Mi=ki("AnnotationPage"),Ei=ki("Range"),Ri=ki("AnnotationCollection"),ji=ki("ContentResource"),_i=ki("Agent"),Oi={all:["Collection","Manifest","Canvas","Annotation","AnnotationPage","Range","AnnotationCollection","ContentResource","Agent"],getSupported:ki,supported:{Collection:Pi,Manifest:Ai,Canvas:Si,Annotation:Ii,AnnotationPage:Mi,Range:Ei,AnnotationCollection:Ri,ContentResource:ji,Agent:_i}};class Ti extends br{constructor(e){super(e,"target")}getSourceId(){const{source:e}=this.get()||{};return null==e?void 0:e.id}removeSelector(){const e=this.getWithoutTracking();this.set({...e,selector:void 0})}getParsedSelector(){var e;const t=this.get();return t.selector?null==(e=Nn(t.selector))?void 0:e.selector:null}setPosition(e){const t=this.getWithoutTracking();t&&t.source&&this.set({...t,selector:{type:"FragmentSelector",value:"xywh="+[~~e.x,~~e.y,~~e.width,~~e.height].join(",")}})}}class Ni extends Yr{constructor(e){super(e,"body")}isSpatial(){if(!this.hasBody())return!1;try{const e=this.getFirst(),t=this.config.vault.get(e),n=o.toRef(t);return"Video"===(null==n?void 0:n.type)||"Image"===(null==n?void 0:n.type)}catch(e){return!1}}hasBody(){return!!this.get()[0]}getFirst(){const e=this.get();return j(e[0]),e[0]}getFirstOrNone(){const e=this.get();if(e)return e[0]||void 0}}class Di extends vr{constructor(e){super(e),t(this,"target"),t(this,"body"),this.target=new Ti(e),this.body=new Ni(e)}}class Li extends br{constructor(e){super(e,"navPlace")}}class zi extends vr{constructor(e){super(e),t(this,"navPlace"),t(this,"textGranularity"),this.navPlace=new Li(e),this.textGranularity=new br(e,"textGranularity")}}class Fi extends vr{constructor(e){const n=e;n.context=n.context||{},n.context.resource=n.context.resource||{type:"SpecificResource",source:n.reference},n.tracker=n.tracker||new Zr(n.vault,n.reference),super(n),t(this,"technical"),t(this,"descriptive"),t(this,"metadata"),t(this,"linking"),t(this,"structural"),t(this,"annotation"),t(this,"extensions"),t(this,"required"),t(this,"recommended"),t(this,"notAllowed"),t(this,"optional"),t(this,"allowed"),t(this,"isMultiple"),t(this,"context"),t(this,"observe"),this.observe=n.tracker,this.technical=new mi(n),this.descriptive=new Gr(n),this.metadata=this.descriptive.metadata,this.linking=new gi(n),this.structural=new vi(n),this.extensions=new zi(n),this.isMultiple=!1,n.context.parent&&n.context.parentProperty&&void 0!==n.context.index&&(this.context=new Xr(n));const r=this.getType();"Annotation"===r&&(this.annotation=new Di(n));const i=Oi.supported[r]||Oi.getSupported(r);this.required=i.required,this.recommended=i.recommended,this.notAllowed=i.notAllowed,this.allowed=i.allowed,this.optional=i.optional}getPartOf(){const e=this.config.vault.get(this.ref());if(e&&e[o.HAS_PART]){const t=e[o.HAS_PART][0];if(t)return t[o.PART_OF]||null}return null}ref(){return this.config.reference}validate(){const e=this.config.validators,t=this.entity(),n=null==t?void 0:t.type,r={isError:!1,isWarning:!1,problems:[]};if(t&&n&&e.length&&n)for(const o of e)if(o.types.includes(n))try{o.valid(t,this.config.vault,this.config.context)||(o.error?r.isError=!0:o.warning&&(r.isWarning=!0),r.problems.push({isError:o.error||!1,isWarning:o.warning||!1,message:o.message,properties:o.properties}))}catch(i){r.isWarning=!0,r.problems.push({isWarning:!0,isError:!1,message:"Validation error: "+(i||"unknown"),properties:o.properties})}return r}}const Wi={stack:[],current:null,create:null},Bi=n.createContext(Wi),$i=n.createContext({edit(){},close(){},back(){},updateCurrent(){},create:()=>()=>{}});function qi(){return n.useContext($i)}function Ui(){return n.useContext(Bi).current}function Hi(e,t={}){const r=a.useVault(),[i,s]=n.useReducer(e=>e+1,0);j(e);const c=n.useMemo(()=>new Fi({reference:o.toRef(e),vault:r,context:{resource:e,parent:t.parent,index:t.index,parentProperty:t.parentProperty}}),[e,r]);return n.useEffect(()=>c.observe.start(s),[c]),c.observe.key=""+i,c.observe.reset(),c}function Vi(e){const t=a.useVault(),[r,i]=n.useReducer(gr,Wi),o=n.useCallback(e=>{s.flushSync(()=>i(e))},[]);n.useEffect(()=>t.on("@iiif/REMOVE_REFERENCE",e=>{const t=e.action,n={id:t.payload.id,type:t.payload.type},r=t.payload.reference;i({type:"syncRemoval",payload:{resource:{parent:n,resource:r}}})}),[t]);const c=n.useCallback((e,t=!1)=>o({type:"edit",payload:{resource:e,reset:t}}),[]),l=n.useCallback(e=>o({type:"updateCurrent",payload:{resource:e}}),[]),u=n.useCallback(()=>o({type:"close"}),[]),d=n.useCallback(()=>o({type:"back"}),[]),p=n.useCallback((e,t)=>(o({type:"create",payload:{resource:e,options:t}}),()=>{o({type:"create",payload:{resource:null}})}),[]),f=n.useMemo(()=>({edit:c,updateCurrent:l,close:u,back:d,create:p}),[]),{current:h}=N();return S($i.Provider,{value:f,children:S(Bi.Provider,{value:r,children:e.children})},null==h?void 0:h.id)}n.createContext(null);const Ji=n.createContext(null),Yi=n.createContext(null),Gi=n.createContext(null);function Zi(){return n.useContext(Yi)}function Ki(){const e=n.useContext(Ji),t=n.useContext(Yi),r=n.useContext(Gi);return n.useMemo(()=>({actions:t,state:r,...e}),[e,r])}const Xi=i.div.withConfig({displayName:"OuterWrapper",componentId:"sc-1xszkfq-0"})(["display:flex;flex-direction:column;flex:1;min-height:0;"]),Qi=i.header.withConfig({displayName:"Header",componentId:"sc-1xszkfq-1"})(["z-index:200;"]),eo=i.div.withConfig({displayName:"Footer",componentId:"sc-1xszkfq-2"})(["background:#fff;"]),to=i.div.withConfig({displayName:"Main",componentId:"sc-1xszkfq-3"})(["display:flex;flex:1 1 0;min-height:0;"]),no=i.div.withConfig({displayName:"LeftPanel",componentId:"sc-1xszkfq-4"})(["background:#fff;display:flex;flex-direction:column;overflow:hidden;max-width:720px;align-items:flex-end;"," ",""],e=>e.$motion?i.css(["transition:max-width 400ms;"]):"",e=>{switch(e.$state){case"entering":return i.css(["max-width:",";"],e.$width);case"exiting":return i.css(["max-width:0;"]);case"unmounted":case"exited":return i.css(["max-width:0;"])}}),ro=i.div.withConfig({displayName:"CenterPanel",componentId:"sc-1xszkfq-5"})(["flex:1 1 0;background:#e3e7f0;box-shadow:inset 0 3px 2px 0 rgba(0,0,0,0.04),inset 0 1px 0 0 rgba(0,0,0,0.14);padding-top:1px;min-width:320px;display:flex;min-height:0;overflow:hidden;> *{min-width:0;}"]),io=i.div.withConfig({displayName:"RightPanel",componentId:"sc-1xszkfq-6"})(["background:#fff;display:flex;flex-direction:column;overflow:hidden;max-width:720px;"," ",""],e=>e.$motion?"transition: max-width 400ms;":"",e=>{switch(e.$state){case"entering":return i.css(["max-width:",";"],e.$width);case"exiting":return i.css(["max-width:0;"]);case"unmounted":case"exited":return i.css(["max-width:0;"])}}),oo=i.div.withConfig({displayName:"PanelContainer",componentId:"sc-1xszkfq-7"})(["display:flex;flex:1;height:100%;min-width:50px;transition:min-width 400ms;overflow:hidden;",""],e=>{switch(e.$menu){case"top":return i.css(["flex-direction:column;","{flex-direction:column;}"],ao);case"left":return i.css(["flex-direction:row;","{flex-direction:row;}"],ao);default:case"bottom":return i.css(["flex-direction:column-reverse;","{flex-direction:column;}"],ao);case"right":return i.css(["flex-direction:row-reverse;","{flex-direction:row;}"],ao)}}),ao=i.div.withConfig({displayName:"PanelMenu",componentId:"sc-1xszkfq-8"})(["display:flex;box-shadow:0 -3px 2px 0 rgba(0,0,0,0.04),0 -1px 0 0 rgba(0,0,0,0.17);",""],e=>e.$open||"top"!==e.$position&&"bottom"!==e.$position?"":i.css(["display:none;"])),so=i.div.withConfig({displayName:"PanelContent",componentId:"sc-1xszkfq-9"})(["display:flex;flex-direction:column;flex:1;min-width:0;overflow:hidden;"]),co=e=>I("svg",{xmlns:"http://www.w3.org/2000/svg",height:"1em",width:"1em",viewBox:"0 0 24 24",...e,children:[S("path",{d:"M0 0h24v24H0z",fill:"none"}),S("path",{d:"M0 0h24v24H0z",fill:"none"}),S("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"})]}),lo=({height:e=16})=>I("svg",{xmlns:"http://www.w3.org/2000/svg",height:e,viewBox:"0 0 24 24",width:"24px",fill:"#000000",children:[S("path",{d:"M0 0h24v24H0z",fill:"none"}),S("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"})]}),uo=()=>I("svg",{xmlns:"http://www.w3.org/2000/svg",height:"1rem",viewBox:"0 0 24 24",width:"1rem",fill:"#000000",children:[S("path",{d:"M0 0h24v24H0z",fill:"none"}),S("path",{d:"M20 11H7.83l5.59-5.59L12 4l-8 8 8 8 1.41-1.41L7.83 13H20v-2z"})]});function po(e,t){return(po=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}var fo={error:null},ho=function(e){var t,n;function r(){for(var t,n=arguments.length,r=new Array(n),i=0;i<n;i++)r[i]=arguments[i];return(t=e.call.apply(e,[this].concat(r))||this).state=fo,t.resetErrorBoundary=function(){for(var e,n=arguments.length,r=new Array(n),i=0;i<n;i++)r[i]=arguments[i];null==t.props.onReset||(e=t.props).onReset.apply(e,r),t.reset()},t}n=e,(t=r).prototype=Object.create(n.prototype),t.prototype.constructor=t,po(t,n),r.getDerivedStateFromError=function(e){return{error:e}};var i=r.prototype;return i.reset=function(){this.setState(fo)},i.componentDidCatch=function(e,t){var n,r;null==(n=(r=this.props).onError)||n.call(r,e,t)},i.componentDidUpdate=function(e,t){var n,r,i,o,a=this.state.error,s=this.props.resetKeys;null!==a&&null!==t.error&&(void 0===(i=e.resetKeys)&&(i=[]),void 0===(o=s)&&(o=[]),i.length!==o.length||i.some((function(e,t){return!Object.is(e,o[t])})))&&(null==(n=(r=this.props).onResetKeysChange)||n.call(r,e.resetKeys,s),this.reset())},i.render=function(){var e=this.state.error,t=this.props,n=t.fallbackRender,r=t.FallbackComponent,i=t.fallback;if(null!==e){var o={error:e,resetErrorBoundary:this.resetErrorBoundary};if(p.isValidElement(i))return i;if("function"==typeof n)return n(o);if(r)return p.createElement(r,o);throw new Error("react-error-boundary requires either a fallback, fallbackRender, or FallbackComponent prop")}return this.props.children},r}(p.Component);const mo=i.div.withConfig({displayName:"PaddedSidebarContainer",componentId:"sc-17k82vx-0"})(["padding:0 0.7em;margin:0.7em 0;flex:1;overflow:visible;"]),go=i(Vn).withConfig({displayName:"ErrorMessage",componentId:"sc-1xkfji8-0"})(["background:#c74158;color:#fff;"]),vo=i(Vn).withConfig({displayName:"ExperimentalMessage",componentId:"sc-1dwg2ld-0"})(["background:#8a52f5;color:#fff;"]),yo=e=>I("svg",{xmlns:"http://www.w3.org/2000/svg",height:"1em",width:"1em",viewBox:"0 0 24 24",...e,children:[S("path",{fill:"none",d:"M0 0h24v24H0z"}),S("path",{fill:"currentColor",d:"M7 20h4c0 1.1-.9 2-2 2s-2-.9-2-2zm-2-1h8v-2H5v2zm11.5-9.5c0 3.82-2.66 5.86-3.77 6.5H5.27c-1.11-.64-3.77-2.68-3.77-6.5C1.5 5.36 4.86 2 9 2s7.5 3.36 7.5 7.5zm4.87-2.13L20 8l1.37.63L22 10l.63-1.37L24 8l-1.37-.63L22 6l-.63 1.37zM19 6l.94-2.06L22 3l-2.06-.94L19 0l-.94 2.06L16 3l2.06.94L19 6z"})]});class bo extends Error{}class wo extends Error{constructor(e,n){super(e),t(this,"fix"),this.fix=n}}const xo=i(Vn).withConfig({displayName:"WarningMessage",componentId:"sc-fek4ps-0"})(["background:#e89d3b;color:#fff;"]);function Co(e){let t=e.error.toString();const[r,i]=n.useState(!1);if(e.error instanceof wo){const t=e.error;return S(mo,{children:I(xo,{$banner:!0,children:[S(yo,{style:{fontSize:"2.2em",margin:"0 0.3em 0 0"}}),I("div",{children:[S("h4",{style:{margin:0},children:"There is a fixable error"}),S("p",{children:t.message}),S(X,{disabled:r,onClick:async()=>{i(!0),await t.fix(),e.resetErrorBoundary(),i(!1)},children:"Fix error"})]})]})})}return e.error instanceof bo?(t=e.error.message,S(mo,{children:I(vo,{$banner:!0,children:[S(yo,{style:{fontSize:"2.2em",margin:"0 0.3em 0 0"}}),I("div",{children:[S("h4",{style:{margin:0},children:"The manifest editor is still in development"}),S("p",{children:t})]})]})})):I(mo,{children:[S(go,{$margin:!0,children:t}),S(ee,{onClick:e.resetErrorBoundary,children:"Try again"})]})}function ko(e){return e&&e.pinnable}function Po({initial:e,fallback:t,options:n={}}){return Math.max(n.minWidth||0,Math.min(n.maxWidth||1/0,e||t))}function Ao(e){return"string"==typeof e?n.createElement("div",{dangerouslySetInnerHTML:{__html:e}}):e}function So(e){return I("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",height:"1em",width:"1em",...e,children:[S("path",{d:"M0 0h24v24H0V0z",fill:"none"}),S("path",{d:"M12 7.77 18.39 18H5.61L12 7.77M12 4 2 20h20L12 4z",fill:"currentColor"})]})}const Io=n.createContext(null);const Mo=i.div.withConfig({displayName:"ModularPanelWrapper",componentId:"sc-dh4gz0-0"})(['display:flex;flex-direction:column;position:relative;height:100%;overflow:hidden;transition:transform 300ms;&[data-floating="true"]{margin:10px;border-radius:5px;overflow:hidden;background:#fff;}&[data-state="entering"],&[data-state="entered"]{transform:translateX(0);}&[data-state="exiting"],&[data-state="exited"]{transform:translateX(100%);}&[data-state="exiting"][data-flipped="true"],&[data-state="exited"][data-flipped="true"]{transform:translateX(0);}&[data-state="exiting"][data-flipped="false"],&[data-state="exited"][data-flipped="false"]{transform:translateX(100%);}&[data-state="entering"][data-flipped="true"],&[data-state="entered"][data-flipped="true"]{transform:translateX(0);}&[data-state="entering"][data-flipped="false"],&[data-state="entered"][data-flipped="false"]{transform:translateX(100%);}&[data-state="unmounted"]{transform:translateX(100%);}']),Eo=i.div.withConfig({displayName:"ModularPanelHeader",componentId:"sc-dh4gz0-1"})(['background:#fff;display:flex;height:2.8em;z-index:2;&[data-tabs="true"]{box-shadow:inset 0 1px 0 0 rgba(0,0,0,0.17);}&[data-tabs="false"]{box-shadow:inset 0 -1px 0 0 rgba(0,0,0,0.17),inset 0 1px 0 0 rgba(0,0,0,0.17);}&[data-error="true"]{color:#b61717;background:#ffc2d2;box-shadow:inset 0 -5px 10px 0 rgba(255,255,255,0.5);}']),Ro=i.button.withConfig({displayName:"ModulePanelButton",componentId:"sc-dh4gz0-2"})(["border:none;background:transparent;padding:0 0.4em;margin:0.3em;border-radius:3px;&:hover{background:#eee;}svg{font-size:1.2em;}"]),jo=i.div.withConfig({displayName:"ModulePanelSpacer",componentId:"sc-dh4gz0-3"})(["flex:1 1 0px;"]),_o=i.h2.withConfig({displayName:"ModularPanelLabel",componentId:"sc-dh4gz0-4"})(["font-size:0.875em;flex:1 1 0px;padding-left:1em;text-align:center;"]),Oo=i.div.withConfig({displayName:"ModularPanelContent",componentId:"sc-dh4gz0-5"})(["flex:1 1 0px;display:flex;min-height:0;overflow-y:auto;overflow-x:hidden;> *{min-width:0;}"]);function To({panel:e,state:t,actions:r,isLeft:i,pinActions:o=r,transition:s,close:c,available:l=[],style:u}){const d=n.useContext(a.ReactVaultContext)||null,[p,f]=n.useState(!1),h=Y(),m=Ki(),{tabs:g,pinnable:v,hideHeader:y}=(null==e?void 0:e.options)||{},b=[h.state.canvasId,null==e?void 0:e.id],w=n.useMemo(()=>(l||[]).filter(e=>!e.requiresState),[l]),{itemProps:x,isOpen:C,setIsOpen:k}=Kt(w.length),[P,A]=n.useState(""),M=n.useRef();n.useEffect(()=>f(!1),b),n.useEffect(()=>A(""),[e]),n.useEffect(()=>(M.current=A,()=>{M.current=void 0}),[]);const E=n.useCallback(e=>{M.current&&M.current(e)},[]),R=n.useCallback(n=>{const i=e?t.stack.length?r.popStack:e.backAction?()=>e&&e.backAction&&e.backAction(t,{...m,current:r},h):null:null;n&&(!i||n.metaKey)&&w.length?(n.preventDefault(),k(!0)):i&&i()},[r,h,m,e,k,t,w.length]);if(!e||!t.current)return null;const j=e.backAction||t.stack.length?S(Ro,{onClick:R,children:S(uo,{})}):w.length?S(Ro,{onClick:R,children:S(So,{style:{color:"#999"}})}):null,_=S(Ro,{onClick:c||r.close,children:S(lo,{})});return S(Io.Provider,{value:E,children:I(Mo,{"data-state":s,"data-flipped":i,style:u,children:[I(Eo,{"data-tabs":!!g,"data-error":p,children:[I(tn,{style:{display:"flex",height:"100%"},children:[e.renderBackAction?e.renderBackAction({backAction:R,fallback:j}):j,w.length?I(on,{$open:C,style:{left:"0.5em"},children:[S(an,{children:"All panels"}),S(sn,{}),w.map((n,i)=>S(rn,{...x[i],onClick:()=>(n=>{r.change({id:n.id,state:n.defaultState,stacked:!(!t.stack.length&&!(null==e?void 0:e.backAction))})})(n),$active:e.id===n.id,children:n.label},i))]}):null]}),P?S(_o,{children:P}):y?S(jo,{}):S(_o,{children:e.label}),v?t.pinned?S(Ro,{onClick:o.unpin,children:S(co,{fill:"orange"})}):S(Ro,{onClick:()=>o.pin({id:e.id,state:t.state}),children:S(co,{fill:"#ddd"})}):null,e.renderCloseAction?e.renderCloseAction({closeAction:c||r.close,fallback:_}):_]}),S(Oo,{children:S(ho,{onResetKeysChange:()=>f(!1),onError:()=>f(!0),FallbackComponent:Co,resetKeys:b,onReset:()=>f(!1),children:Ao(e.render(t.state||e.defaultState||{},{...m,current:r,vault:d,transition:s},h))})})]})})}const No=i.div.withConfig({displayName:"Container",componentId:"sc-ypl98a-0"})(["position:relative;display:flex;flex:1;overflow:hidden;flex-direction:column;"]),Do=i.div.withConfig({displayName:"CenterPanel",componentId:"sc-ypl98a-1"})(["flex:1;position:relative;z-index:7;"]),Lo=i.div.withConfig({displayName:"MobileBar",componentId:"sc-ypl98a-2"})(["display:flex;justify-content:space-around;width:100%;background:#fff;border-top:1px solid #cbcbcb;padding:0.5em;height:3.4rem;"]),zo=i.button.withConfig({displayName:"LeftBarButton",componentId:"sc-ypl98a-3"})(["padding:0.5em 1em;width:32%;border-radius:5px;border:none;background:#ffffff;"]),Fo=i.button.withConfig({displayName:"PreviewBarButton",componentId:"sc-ypl98a-4"})(["padding:0.5em 1em;width:32%;border-radius:5px;background:#5e59c2;border:1px solid rgba(0,0,0,0.21);color:#ffffff;"]),Wo=i.div.withConfig({displayName:"DrawerContainer",componentId:"sc-ypl98a-5"})(["position:relative;width:32%;margin:0 0.75em;z-index:9;"]),Bo=i.button.withConfig({displayName:"DrawerButton",componentId:"sc-ypl98a-6"})(["padding:0.4em 1em 0.65em;position:absolute;width:100%;bottom:1em;background:#ffffff;box-shadow:0 3px 18px 0 rgba(0,0,0,0.04);border-radius:5px;border:1px solid #979797;letter-spacing:-0.46px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;svg{display:block;margin:auto;font-size:1.8em;}"]),$o=i.div.withConfig({displayName:"DrawerBody",componentId:"sc-ypl98a-7"})(["background:#fff;display:flex;position:absolute;transform:translateY(100%);overflow-y:auto;left:0;right:0;top:7em;z-index:10;box-shadow:0 -5px 15px 0 rgba(0,0,0,0),0 -3px 5px 0 rgba(0,0,0,0);bottom:0;transition:0.3s transform ease-in-out,0.3s box-shadow;"," ","{box-shadow:none;padding-left:0.5em;padding-right:0.5em;font-size:1.1em;}"],e=>e.$open&&i.css(["box-shadow:0 -5px 15px 0 rgba(0,0,0,0.1),0 -3px 5px 0 rgba(0,0,0,0.1);transform:translateY(0);"]),Eo),qo=i.div.withConfig({displayName:"LeftPanel",componentId:"sc-ypl98a-8"})(["position:absolute;transform:translateX(-100%);background:#fff;left:0;top:0;bottom:0;z-index:10;overflow-y:auto;transition:0.5s transform;",""],e=>e.$open&&i.css(["transform:translateX(0);"])),Uo=i.div.withConfig({displayName:"Lightbox",componentId:"sc-ypl98a-9"})(["background:rgba(0,0,0,0.4);pointer-events:none;position:absolute;z-index:8;top:0;left:0;right:0;bottom:0;opacity:0;transition:opacity 0.5s;",""],e=>e.$open&&i.css(["pointer-events:visible;opacity:1;"])),Ho=e=>I("svg",{xmlns:"http://www.w3.org/2000/svg",height:"1em",width:"1em",viewBox:"0 0 24 24",...e,children:[S("path",{d:"M0 0h24v24H0V0z",fill:"none"}),S("path",{d:"M12 5V2L8 6l4 4V7c3.31 0 6 2.69 6 6 0 2.97-2.17 5.43-5 5.91v2.02c3.95-.49 7-3.85 7-7.93 0-4.42-3.58-8-8-8zM6 13c0-1.65.67-3.15 1.76-4.24L6.34 7.34A8.014 8.014 0 0 0 4 13c0 4.08 3.05 7.44 7 7.93v-2.02c-2.83-.48-5-2.94-5-5.91z"})]}),Vo=i.div.withConfig({displayName:"HandleContainer",componentId:"sc-tzheps-0"})(["position:relative;width:1px;background:rgba(0,0,0,0.2);z-index:50;"]),Jo=i(K).withConfig({displayName:"HandleControl",componentId:"sc-tzheps-1"})(["transition:opacity 300ms,transform 300ms;margin-block-start:0.2em;margin-block-end:0.2em;user-select:none;opacity:0;transform:scaleY(70%);&:focus{outline:2px solid salmon;}"]),Yo=i(Jo).withConfig({displayName:"ResizeHandle",componentId:"sc-tzheps-2"})(["position:relative;background:#fff;height:40px;width:15px;border-radius:3px;box-shadow:0 2px 4px 0 rgba(0,0,0,0.2);user-select:none;"]),Go=i(Jo).withConfig({displayName:"IconControl",componentId:"sc-tzheps-3"})(["background:#fff;width:30px;height:30px;border-radius:50%;display:flex;justify-content:center;align-items:center;box-shadow:0 2px 4px 0 rgba(0,0,0,0.2);cursor:default;svg{fill:#9999;}"]),Zo=i(Jo).withConfig({displayName:"OpenControl",componentId:"sc-tzheps-4"})(["position:relative;display:flex;opacity:1;background:#fff;height:55px;pointer-events:visible;width:21px;margin-bottom:auto;margin-top:4.5em;cursor:pointer;border-radius:",";align-items:center;justify-content:center;box-shadow:0 2px 3px 0 rgba(0,0,0,0.2);transform:scaleX(100%);transform-origin:",";&:hover{background:#f9f9f9;transform:scaleX(125%);}svg{font-size:1.5em;}"],e=>"right"===e.$dir?"5px 0 0 5px":"0 5px 5px 0",e=>"right"===e.$dir?"right":"left"),Ko=i.div.withConfig({displayName:"InnerHandleContainer",componentId:"sc-tzheps-5"})(["background:rgba(0,0,0,0);position:absolute;width:21px;left:",";top:0;bottom:0;z-index:50;transition:background-color 300ms,transform 300ms;transform:scaleX(70%);cursor:",";display:flex;flex-direction:column;align-items:center;justify-content:center;&:hover{transform:scaleX(100%);background:rgba(0,0,0,0.1);","{transform:scaleX(100%);opacity:1;}}"],e=>e.$open?"-10px":"left"===e.$dir?0:"-20px",e=>e.$open?"col-resize":"pointer",Jo),Xo=i.div.withConfig({displayName:"UnscaledContainer",componentId:"sc-tzheps-6"})(["background:rgba(0,0,0,0);position:absolute;pointer-events:none;width:21px;left:",";top:0;bottom:0;z-index:51;"],e=>e.$open?"-10px":"left"===e.$dir?0:"-20px"),Qo=n.forwardRef((function({dir:e,open:t,actions:n,reset:r},i){return I(Vo,{onClick:()=>n.open(),children:[S(Xo,{$open:t,$dir:e,children:t?null:S(Zo,{$dir:e,onClick:e=>{e.stopPropagation(),n.open()},children:S(Xt,{rotate:"right"===e?90:270})})}),I(Ko,{ref:i,$open:t,$dir:e,children:[t?S(Go,{onClick:e=>{e.stopPropagation(),n.close()},children:S(lo,{})}):null,r&&t?S(Go,{onClick:e=>{e.stopPropagation(),r()},children:S(Ho,{})}):null,t?S(Yo,{}):null]})]})}));function ea(e,t,r,i=[]){n.useLayoutEffect(()=>{const n=e.current;if(n)return n.addEventListener(t,r),()=>{n.removeEventListener(t,r)}},[t,...i])}function ta(e,t,n,r){return n||(r?r/e:t)}function na(e,t={}){const r=n.useRef(null),i=n.useRef(null),o=n.useRef(null),a=n.useRef(null),s=n.useRef(.5),[c,l]=n.useState(!1),u=n.useRef(!1),d=n.useRef(0),p=n.useRef({x:0,y:0}),[{widthA:f,widthB:h},m]=E("resize-layout/"+e,{widthA:"auto",widthB:Po({initial:t.widthA,fallback:320,options:{minWidth:t.minWidthPx,maxWidth:t.maxWidthPx}})+"px"}),{loading:g=!1}=t;return ea(a,"mousedown",e=>{p.current.x=e.pageX,p.current.y=e.pageY,d.current&&(clearTimeout(d.current),d.current=0),d.current=setTimeout(()=>{l(!0),u.current=!0},350)},[g]),ea({current:"undefined"!=typeof window?window:void 0},"mouseup",()=>{const e=r.current;if(e&&u.current){const{x:n,width:r}=e.getBoundingClientRect(),i=ta(r,.8,t.maxWidthPct,t.maxWidthPx)*r,o=ta(r,.2,t.minWidthPct,t.minWidthPx)*r;if(t.left){const e=s.current*r;m({widthA:""+(1-s.current)*r,widthB:(e>i?i:e<o?o:e)+"px"})}else{const e=1-s.current*r;m({widthA:(e>i?i:e<o?o:e)+"px",widthB:s.current*r+"px"})}l(!1),u.current=!1,t.onDragEnd&&t.onDragEnd()}clearTimeout(d.current),d.current=0},[g]),ea(r,"mousemove",e=>{var n,o,a,c;if(!u.current&&d.current&&(n=p.current.x,o=p.current.y,a=e.pageX,c=e.pageY,Math.sqrt(Math.pow(Math.abs(a-n),2)+Math.pow(Math.abs(c-o),2))>20&&(l(!0),u.current=!0,clearTimeout(d.current),d.current=0)),u.current&&i.current){const n=r.current;if(n){const{x:r,width:o}=n.getBoundingClientRect(),a=t.left||!1,c=ta(o,.8,t.maxWidthPct,t.maxWidthPx),l=ta(o,.2,t.minWidthPct,t.minWidthPx);s.current=(o+r-e.pageX-5)/o,a&&(s.current=1-s.current),s.current=s.current<l?l:s.current,s.current=s.current>c?c:s.current,i.current.style.width=s.current*o+"px"}}},[c,g]),{refs:{container:r,resizer:a,resizableDiv:i,otherDiv:o},setWidths:m,isDragging:c,widthA:f,widthB:h}}var ra=function(e,t,n,r){var i=n?n.call(r,e,t):void 0;if(void 0!==i)return!!i;if(e===t)return!0;if("object"!=typeof e||!e||"object"!=typeof t||!t)return!1;var o=Object.keys(e),a=Object.keys(t);if(o.length!==a.length)return!1;for(var s=Object.prototype.hasOwnProperty.bind(t),c=0;c<o.length;c++){var l=o[c];if(!s(l))return!1;var u=e[l],d=t[l];if(!1===(i=n?n.call(r,u,d,l):void 0)||void 0===i&&u!==d)return!1}return!0};function ia(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){if(!(Symbol.iterator in Object(e))&&"[object Arguments]"!==Object.prototype.toString.call(e))return;var n=[],r=!0,i=!1,o=void 0;try{for(var a,s=e[Symbol.iterator]();!(r=(a=s.next()).done)&&(n.push(a.value),!t||n.length!==t);r=!0);}catch(c){i=!0,o=c}finally{try{r||null==s.return||s.return()}finally{if(i)throw o}}return n}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance")}()}function oa(e){return S("svg",{width:"1em",height:"1em",viewBox:"0 0 42 42",xmlns:"http://www.w3.org/2000/svg",stroke:"#fff",...e,children:I("g",{transform:"translate(2 2)",strokeWidth:5,fill:"none",fillRule:"evenodd",children:[S("circle",{strokeOpacity:.5,cx:18,cy:18,r:18}),S("path",{d:"M36 18c0-9.94-8.06-18-18-18",children:S("animateTransform",{attributeName:"transform",type:"rotate",from:"0 18 18",to:"360 18 18",dur:"1s",repeatCount:"indefinite"})})]})})}function aa(){return I(A,{children:[S("div",{"data-header":"true",className:"🎈-qhw709"}),I("div",{className:"🎈-139ofsv",children:[S("div",{className:"🎈-qhw709"}),S("div",{className:"🎈-qhw709"}),S("div",{className:"🎈-qhw709"}),S("div",{className:"🎈-qhw709"})]})]})}function sa(e){const{edit:t}=qi();return n.useEffect(()=>{e.resource&&t(e.resource)},[e.resource]),S("div",{children:e.children})}const ca=n.memo((function(e){var t,r,i,o;const s=T(),c=Ki(),l=Y(),{vault:d}=n.useContext(a.ReactVaultContext),p=d||void 0,{loading:f,state:h,leftPanels:m,centerPanels:g,rightPanels:v,actions:y}=c,b=m.find(e=>e.id===h.leftPanel.current),w=v.find(e=>e.id===h.rightPanel.current),x=g.find(e=>e.id===h.centerPanel.current),C=h.pinnedRightPanel.pinned?v.find(e=>e.id===h.pinnedRightPanel.current):void 0,[k]=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],r=t.length?t:Array(e.length).fill(!1);if("undefined"==typeof window)return r;var i=e.map((function(e){return window.matchMedia(e)})),o=function(){return i.map((function(e){return e.matches}))},a=n.useState(o),s=ia(a,2),c=s[0],l=s[1];return n.useLayoutEffect((function(){var e=function(){return l(o)};return i.forEach((function(t){return t.addListener(e)})),function(){return i.forEach((function(t){return t.removeListener(e)}))}}),[]),c}(["(max-width: 1020px)"]),P=na("left-panel/"+(null==b?void 0:b.id),{left:!0,minWidthPx:(null==(t=null==b?void 0:b.options)?void 0:t.minWidth)||200,maxWidthPx:(null==(r=null==b?void 0:b.options)?void 0:r.maxWidth)||720,loading:f}),M=na("right-panel/"+(null==w?void 0:w.id),{left:!1,minWidthPx:(null==(i=null==w?void 0:w.options)?void 0:i.minWidth)||320,maxWidthPx:(null==(o=null==w?void 0:w.options)?void 0:o.maxWidth)||720,loading:f}),E=s.isLoading&&e.isProject,R=w&&((null==C?void 0:C.id)!==w.id||!ra(h.pinnedRightPanel.state,h.rightPanel.state)),j="auto"!==P.widthB?()=>P.setWidths({widthA:"auto",widthB:Po({options:null==b?void 0:b.options,fallback:320})}):void 0,_="auto"!==M.widthB?()=>M.setWidths({widthA:"auto",widthB:Po({options:null==w?void 0:w.options,fallback:320})}):void 0;if(n.useEffect(()=>{y.setAvailable(e),e.rightPanels.length&&y.rightPanel.change({id:e.rightPanels[0].id}),e.leftPanels.length&&y.leftPanel.change({id:e.leftPanels[0].id}),e.centerPanels.length&&y.centerPanel.change({id:e.centerPanels[0].id})},[]),n.useLayoutEffect(()=>{k&&h.leftPanel.open&&h.rightPanel.open&&(y.leftPanel.close(),y.rightPanel.close())},[k]),n.useLayoutEffect(()=>{if(x&&x.onMount)return x.onMount(h.centerPanel.state||x.defaultState||{},{...c,current:y.centerPanel,vault:p},l)},[h.centerPanel.current]),f)return null;const O=t=>{var n;return S(oo,{$menu:e.leftPanelMenuPosition||"bottom",ref:P.refs.resizableDiv,className:t?"transition transition-"+t:"",style:{width:h.leftPanel.open||"exited"!==t?P.widthB:void 0,minWidth:null==(n=null==b?void 0:b.options)?void 0:n.minWidth},children:E?S(so,{children:S(aa,{})}):I(A,{children:[e.leftPanelMenu?S(ao,{$open:h.leftPanel.open&&"exited"!==t,$position:e.leftPanelMenuPosition||"bottom",children:e.leftPanelMenu}):null,S(so,{children:h.leftPanel.open||"exited"!==t?S(A,{children:b?S(To,{isLeft:!0,transition:t,panel:b,state:h.leftPanel,actions:y.leftPanel,available:m}):null}):null})]})})},N=()=>I(oo,{$menu:e.centerPanelMenuPosition||"top",children:[e.centerPanelMenu?S(ao,{$open:h.centerPanel.open,$position:e.centerPanelMenuPosition||"top",children:e.centerPanelMenu}):null,S(so,{children:E?S("div",{style:{display:"flex",flex:1,justifyContent:"center",alignItems:"center"},children:S(oa,{stroke:"rgba(0,0,0,.3)",fontSize:"2em"})}):h.centerPanel.open&&x?Ao(x.render(h.centerPanel.state||x.defaultState||{},{...c,current:y.centerPanel,vault:p},l)):null})]}),D=t=>{var n;return S(oo,{$menu:e.rightPanelMenuPosition||"bottom",ref:M.refs.resizableDiv,className:t?"transition transition-"+t:"",style:{width:h.rightPanel.open||"exited"!==t?M.widthB:void 0,minWidth:null==(n=null==w?void 0:w.options)?void 0:n.minWidth},children:E?S(so,{children:S(aa,{})}):I(A,{children:[e.rightPanelMenu?S(ao,{$open:h.rightPanel.open,$position:e.rightPanelMenuPosition||"bottom",children:e.rightPanelMenu}):null,S(so,{children:h.rightPanel.open||"exited"!==t?I(A,{children:[R?S(To,{panel:w,state:h.rightPanel,actions:y.rightPanel,pinActions:y.pinnedRightPanel,available:v}):null,C?S(To,{panel:C,state:h.pinnedRightPanel,actions:y.pinnedRightPanel,close:y.rightPanel.close}):null]}):null})]})})};return e.miniEditor?S(sa,{...e.miniEditor,children:D()}):I(Xi,k?{children:[e.hideHeader?null:I(Qi,{children:[e.header||null,e.menu?S("menu",{children:e.menu}):null]}),S(to,{children:I(No,{children:[S(Do,{children:N()}),I(Lo,{children:[e.leftPanels.length>0?S(zo,{onClick:y.leftPanel.toggle,children:null==b?void 0:b.label}):null,e.rightPanels.length>0?S(Wo,{children:I(Bo,{onClick:y.rightPanel.toggle,children:[S(Xt,{rotate:180}),null==w?void 0:w.label]})}):null,S(Fo,{children:"Preview"})]}),e.rightPanels.length>0?S($o,{$open:h.rightPanel.open,children:D()}):null,e.leftPanels.length>0?S(qo,{$open:h.leftPanel.open,children:O()}):null,e.leftPanels.length>0||e.rightPanels.length>0?S(Uo,{$open:h.leftPanel.open||h.rightPanel.open,onClick:()=>{y.leftPanel.close(),y.rightPanel.close()}}):null]})})]}:{className:e.className,children:[e.hideHeader?null:I(Qi,{children:[e.header||null,e.menu?S("menu",{children:e.menu}):null]}),I(to,{ref:e=>{P.refs.container.current=e,M.refs.container.current=e},children:[e.leftPanels.length>0?S(u.Transition,{in:h.leftPanel.open,timeout:400,unmountOnExit:!1,children:e=>I(A,{children:[S(no,{$width:P.widthB,$state:e,$motion:!0,children:O(e)}),S(Qo,{ref:P.refs.resizer,reset:j,dir:"left",transition:e,open:h.leftPanel.open||"exited"!==e,actions:y.leftPanel})]})}):null,S(ro,{children:N()}),e.rightPanels.length>0?S(u.Transition,{in:h.rightPanel.open,timeout:400,unmountOnExit:!1,children:e=>I(A,{children:[S(Qo,{ref:M.refs.resizer,dir:"right",reset:_,open:h.rightPanel.open,actions:y.rightPanel}),S(io,{$width:M.widthB,$state:e,$motion:!0,children:D(e)})]})}):null]}),S(eo,{children:e.footer||null})]})}));function la(e,t){if(t.payload&&t.payload.stacked){if(e.current){const 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?{...We(e.state)}:{}})}}else e.stack=[]}function ua(e,t){switch(t.type){case"popStack":if(e.stack.length){const 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&&la(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&&la(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(ko(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 da=Ot((e,t)=>{switch(t.panel){case"centerPanel":ua(e.centerPanel,t);break;case"leftPanel":ua(e.leftPanel,t);break;case"rightPanel":ua(e.rightPanel,t);break;case"pinnedRightPanel":ua(e.pinnedRightPanel,t)}});function pa(){return{customWidth:void 0,minimised:!1,open:!0,current:null,state:null,stack:[]}}function fa(){return{leftPanel:{customWidth:void 0,minimised:!1,open:!0,current:null,state:null,stack:[]},centerPanel:{customWidth:void 0,minimised:!1,open:!0,current:null,state:null,stack:[]},rightPanel:{customWidth:void 0,minimised:!1,open:!0,current:null,state:null,stack:[]},pinnedRightPanel:{customWidth:void 0,minimised:!1,open:!0,current:null,state:null,stack:[],pinnable:!0,pinned:!1}}}function ha(e,t){function r(){t({type:"popStack",panel:e,payload:void 0})}function i(n){t({type:"change",panel:e,payload:n})}function o(n){t({type:"open",panel:e,payload:n})}function a(){t({type:"close",panel:e,payload:void 0})}function s(){t({type:"toggle",panel:e,payload:void 0})}function c(){t({type:"minimise",panel:e,payload:void 0})}function l(n){t({type:"maximise",panel:e,payload:n})}function u(n){t({type:"setCustomWidth",panel:e,payload:n})}function d(){t({type:"resetSize",panel:e,payload:void 0})}function p(n){t({type:"pin",panel:e,payload:n})}function f(){t({type:"unpin",panel:e,payload:void 0})}return n.useMemo(()=>({popStack:r,change:i,open:o,close:a,toggle:s,minimise:c,maximise:l,setCustomWidth:u,resetSize:d,pin:p,unpin:f}),[])}const ma=function(e){return function(t,...r){const i=function(e){const t=n.useRef(e);return n.useLayoutEffect(()=>{t.current=e}),t}(t);return n.useMemo(()=>e((...e)=>{s.unstable_batchedUpdates(()=>{i.current(...e)})},...r),[i,...r])}}((e,t)=>{let n=null;const r=()=>{(e=>"number"==typeof e)(n)&&(clearTimeout(n),n=null)},i=(...i)=>{r(),n=window.setTimeout(()=>{e.apply(null,i),n=null},t)};return i.cancel=r,i});async function ga(e){let t=void 0;try{await fetch(e).then(e=>e.json().catch(e=>{console.error(`'${e}' happened!`)})).then(e=>{t={...e}})}catch(n){console.log(n)}return t}function va(e,t={}){const n=fn(e.label)||"Untitled manifest";return{id:"manifest-editor://project/"+Br(),filename:De(n,{lower:!0}),name:n,metadata:{created:Date.now(),modified:Date.now()},resource:{id:e.id,type:"Manifest"},publications:[],previews:[],settings:{},storage:{type:"manifest-storage",data:e},...t}}var ya=Object.defineProperty,ba=(e,t,n)=>(((e,t,n)=>{t in e?ya(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n})(e,"symbol"!=typeof t?t+"":t,n),n);const wa=["sc:Collection","sc:Manifest","sc:Canvas","sc:AnnotationList","oa:Annotation","sc:Range","sc:Layer","sc:Sequence","oa:Choice","Service","ContentResource"];class xa{constructor(e,t={}){ba(this,"traversals"),ba(this,"options"),this.traversals={collection:[],manifest:[],canvas:[],annotationList:[],sequence:[],annotation:[],contentResource:[],choice:[],range:[],service:[],layer:[],...e},this.options={convertPropsToArray:!0,mergeMemberProperties:!0,allowUndefinedReturn:!1,...t}}static all(e){return new xa({collection:[e],manifest:[e],canvas:[e],annotationList:[e],sequence:[e],annotation:[e],contentResource:[e],choice:[e],range:[e],service:[e],layer:[e]})}traverseCollection(e){return this.traverseType(this.traverseDescriptive(this.traverseLinking(this.traverseCollectionItems(e))),this.traversals.collection)}traverseCollectionItems(e){if(this.options.mergeMemberProperties){const t=[...(e.manifests||[]).map(e=>"string"==typeof e?{"@id":e,"@type":"sc:Manifest"}:e),...(e.collections||[]).map(e=>"string"==typeof e?{"@id":e,"@type":"sc:Collection"}:e),...e.members||[]];delete e.collections,delete e.manifests,e.members=t}return e.manifests&&(e.manifests=e.manifests.map(e=>this.traverseManifest("string"==typeof e?{"@id":e,"@type":"sc:Manifest"}:e))),e.collections&&(e.collections=e.collections.map(e=>this.traverseCollection("string"==typeof e?{"@id":e,"@type":"sc:Collection"}:e))),e.members&&(e.members=e.members.map(e=>"string"==typeof e?e:this.traverseUnknown(e))),e}traverseManifest(e){return this.traverseType(this.traverseDescriptive(this.traverseLinking(this.traverseManifestItems(e))),this.traversals.manifest)}traverseManifestItems(e){return e.sequences&&(e.sequences=e.sequences.map(e=>this.traverseSequence(e))),e.structures&&(e.structures=e.structures.map(e=>this.traverseRange(e))),e}traverseSequence(e){return this.traverseType(this.traverseDescriptive(this.traverseLinking(this.traverseSequenceItems(e))),this.traversals.sequence)}traverseSequenceItems(e){return e.canvases&&(e.canvases=e.canvases.map(e=>this.traverseCanvas(e))),e}traverseCanvas(e){return this.traverseType(this.traverseDescriptive(this.traverseLinking(this.traverseCanvasItems(e))),this.traversals.canvas)}traverseCanvasItems(e){return e.images&&(e.images=e.images.map(e=>this.traverseAnnotation(e))),e.otherContent&&(e.otherContent=e.otherContent.map(e=>this.traverseAnnotationList(e))),e}traverseRange(e){return this.traverseType(this.traverseDescriptive(this.traverseLinking(this.traverseRangeItems(e))),this.traversals.range)}traverseRangeItems(e){if(this.options.mergeMemberProperties){const t=[...(e.ranges||[]).map(e=>"string"==typeof e?{"@id":e,"@type":"sc:Range"}:e),...(e.canvases||[]).map(e=>"string"==typeof e?{"@id":e,"@type":"sc:Canvas"}:e),...e.members||[]];delete e.ranges,delete e.canvases,e.members=t.length?t.map(e=>this.traverseUnknown(e)):void 0}return e}traverseAnnotationList(e){const t="string"==typeof e?{"@id":e,"@type":"sc:AnnotationList"}:e;return this.traverseType(this.traverseDescriptive(this.traverseAnnotationListItems(t)),this.traversals.annotationList)}traverseAnnotationListItems(e){return e.resources&&(e.resources=e.resources.map(e=>this.traverseAnnotation(e))),e}traverseAnnotation(e){return this.traverseType(this.traverseDescriptive(this.traverseLinking(this.traverseAnnotationItems(e))),this.traversals.annotation)}traverseAnnotationItems(e){return e.resource&&(Array.isArray(e.resource)?e.resource=e.resource.map(e=>this.traverseContentResource(e)):e.resource=this.traverseContentResource(e.resource)),e.on,e}traverseLayer(e){return this.traverseType(this.traverseLinking(this.traverseLayerItems(e)),this.traversals.layer)}traverseLayerItems(e){return e.otherContent&&(e.otherContent=e.otherContent.map(e=>this.traverseAnnotationList(e))),e}traverseChoice(e){return this.traverseType(this.traverseChoiceItems(e),this.traversals.choice)}traverseChoiceItems(e){return e.default&&"rdf:nil"!==e.default&&(e.default=this.traverseContentResource(e.default)),e.item&&"rdf:nil"!==e.item&&(e.item=e.item.map(e=>this.traverseContentResource(e))),e}traverseService(e){return this.traverseType(this.traverseLinking(e),this.traversals.service)}traverseContentResource(e){return"oa:Choice"===e["@type"]?this.traverseChoice(e):this.traverseType(this.traverseDescriptive(this.traverseLinking(e)),this.traversals.contentResource)}traverseUnknown(e){if(!e["@type"]||"string"==typeof e)return e;switch(function(e){if(null==e)throw new Error("Null or undefined is not a valid entity.");if(Array.isArray(e))throw new Error("Array is not a valid entity");if("object"!=typeof e)throw new Error(typeof e+" is not a valid entity");if("string"==typeof e["@type"]){const t=wa.indexOf(e["@type"]);if(-1!==t)return wa[t]}if(e.profile)return"Service";if(e.format)return"ContentResource";if(e["@type"])return"ContentResource";throw new Error("Resource type is not known")}(e)){case"sc:Collection":return this.traverseCollection(e);case"sc:Manifest":return this.traverseManifest(e);case"sc:Canvas":return this.traverseCanvas(e);case"sc:Sequence":return this.traverseSequence(e);case"sc:Range":return this.traverseRange(e);case"oa:Annotation":return this.traverseAnnotation(e);case"sc:AnnotationList":return this.traverseAnnotationList(e);case"sc:Layer":return this.traverseLayer(e);case"Service":return this.traverseService(e);case"oa:Choice":return this.traverseChoice(e);case"ContentResource":return this.traverseContentResource(e)}return e.profile?this.traverseService(e):e}traverseImageResource(e){const t=Array.isArray(e),n=Array.isArray(e)?e:[e],r=[];for(const i of n)"string"==typeof i?r.push(this.traverseContentResource({"@id":i,"@type":"dctypes:Image"})):r.push(this.traverseContentResource(i));return t||this.options.convertPropsToArray?r:r[0]}traverseDescriptive(e){return e.thumbnail&&(e.thumbnail=this.traverseImageResource(e.thumbnail)),e.logo&&(e.logo=this.traverseImageResource(e.logo)),e}traverseOneOrMoreServices(e){const t=Array.isArray(e),n=Array.isArray(e)?e:[e],r=[];for(const i of n)r.push(this.traverseService(i));return t||this.options.convertPropsToArray?r:r[0]}traverseLinking(e){return e.related&&(e.related=this.traverseOneOrManyType(e.related,this.traversals.contentResource)),e.rendering&&(e.rendering=this.traverseOneOrManyType(e.rendering,this.traversals.contentResource)),e.service&&(e.service=this.traverseOneOrMoreServices(e.service)),e.seeAlso&&(e.seeAlso=this.traverseOneOrManyType(e.seeAlso,this.traversals.contentResource)),e.within&&("string"==typeof e.within||(e.within=this.traverseOneOrManyType(e.within,this.traversals.contentResource))),e.startCanvas&&("string"==typeof e.startCanvas?e.startCanvas=this.traverseType({"@id":e.startCanvas,"@type":"sc:Canvas"},this.traversals.canvas):e.startCanvas&&this.traverseType(e.startCanvas,this.traversals.canvas)),e.contentLayer&&("string"==typeof e.contentLayer?e.contentLayer=this.traverseLayer({"@id":e.contentLayer,"@type":"sc:Layer"}):e.contentLayer=this.traverseLayer(e.contentLayer)),e}traverseOneOrManyType(e,t){if(!Array.isArray(e)){if(!this.options.convertPropsToArray)return this.traverseType(e,t);e=[e]}return e.map(e=>this.traverseType(e,t))}traverseType(e,t){return t.reduce((e,t)=>{const n=t(e);return void 0!==n||this.options.allowUndefinedReturn?n:e},e)}}const Ca=["http://iiif.io/api/image/2/level1","http://iiif.io/api/image/2/level2","http://library.stanford.edu/iiif/image-api/compliance.html#level1","http://library.stanford.edu/iiif/image-api/compliance.html#level2","http://library.stanford.edu/iiif/image-api/conformance.html#level1","http://library.stanford.edu/iiif/image-api/conformance.html#level2","http://library.stanford.edu/iiif/image-api/1.1/compliance.html#level1","http://library.stanford.edu/iiif/image-api/1.1/compliance.html#level2","http://library.stanford.edu/iiif/image-api/1.1/conformance.html#level1","http://library.stanford.edu/iiif/image-api/1.1/conformance.html#level2","http://iiif.io/api/image/1/level1.json","http://iiif.io/api/image/1/profiles/level1.json","http://iiif.io/api/image/1/level2.json","http://iiif.io/api/image/1/profiles/level2.json","http://iiif.io/api/image/2/level1.json","http://iiif.io/api/image/2/profiles/level1.json","http://iiif.io/api/image/2/level2.json","http://iiif.io/api/image/2/profiles/level2.json","level1","level2"],ka=["http://iiif.io/api/image/2/level0","http://iiif.io/api/image/2/level1","http://iiif.io/api/image/2/level2","http://library.stanford.edu/iiif/image-api/compliance.html#level0","http://library.stanford.edu/iiif/image-api/compliance.html#level1","http://library.stanford.edu/iiif/image-api/compliance.html#level2","http://library.stanford.edu/iiif/image-api/conformance.html#level0","http://library.stanford.edu/iiif/image-api/conformance.html#level1","http://library.stanford.edu/iiif/image-api/conformance.html#level2","http://library.stanford.edu/iiif/image-api/1.1/compliance.html#level0","http://library.stanford.edu/iiif/image-api/1.1/compliance.html#level1","http://library.stanford.edu/iiif/image-api/1.1/compliance.html#level2","http://library.stanford.edu/iiif/image-api/1.1/conformance.html#level0","http://library.stanford.edu/iiif/image-api/1.1/conformance.html#level1","http://library.stanford.edu/iiif/image-api/1.1/conformance.html#level2","http://iiif.io/api/image/1/level0.json","http://iiif.io/api/image/1/profiles/level0.json","http://iiif.io/api/image/1/level1.json","http://iiif.io/api/image/1/profiles/level1.json","http://iiif.io/api/image/1/level2.json","http://iiif.io/api/image/1/profiles/level2.json","http://iiif.io/api/image/2/level0.json","http://iiif.io/api/image/2/profiles/level0.json","http://iiif.io/api/image/2/level1.json","http://iiif.io/api/image/2/profiles/level1.json","http://iiif.io/api/image/2/level2.json","http://iiif.io/api/image/2/profiles/level2.json","level0","level1","level2"];function Pa(e){for(const t in e)void 0!==e[t]&&null!==e[t]||delete e[t];return e}const Aa="Attribution",Sa="http://example.org/provider",Ia="Unknown";function Ma(e,t="none"){if(!e)return{};const n=Array.isArray(e)?e:[e],r={};for(const i of n){if("string"==typeof i){r[t]=r[t]?r[t]:[],r[t].push(i||"");continue}if(!i["@language"]){r[t]=r[t]?r[t]:[],r[t].push(i["@value"]||"");continue}const e=i["@language"];r[e]=r[e]?r[e]:[],r[e].push(i["@value"]||"")}return r}function Ea(e){for(const t of["sc","oa","dcterms","dctypes","iiif"])if(e.startsWith(t+":"))return e.slice(t.length+1);return e}const Ra=["Collection","Manifest","Annotation","AnnotationPage","Range","Service"];function ja(e){const t=e["@id"]||e.id;let n=e["@type"]||e.type;const r=e.profile||void 0,i=e["@context"]||void 0;if(r){const e=function(e){switch(e){case"http://iiif.io/api/image/2/level0.json":case"http://iiif.io/api/image/2/level1.json":case"http://iiif.io/api/image/2/level2.json":return"ImageService2";case"http://iiif.io/api/auth/1/kiosk":case"http://iiif.io/api/auth/1/login":case"http://iiif.io/api/auth/1/clickthrough":case"http://iiif.io/api/auth/1/external":case"http://iiif.io/api/auth/0/kiosk":case"http://iiif.io/api/auth/0/login":case"http://iiif.io/api/auth/0/clickthrough":case"http://iiif.io/api/auth/0/external":return"AuthCookieService1";case"http://iiif.io/api/auth/1/token":case"http://iiif.io/api/auth/0/token":return"AuthTokenService1";case"http://iiif.io/api/auth/1/logout":case"http://iiif.io/api/auth/0/logout":return"AuthLogoutService1";case"http://iiif.io/api/search/1/search":case"http://iiif.io/api/search/0/search":return"SearchService1";case"http://iiif.io/api/search/1/autocomplete":case"http://iiif.io/api/search/0/autocomplete":return"AutoCompleteService1"}}(r);if(e)return e}if(i){const e=function(e){const t=Array.isArray(e)?e:[e];for(const n of t)switch(n){case"http://iiif.io/api/image/2/context.json":case"http://library.stanford.edu/iiif/image-api/1.1/compliance.html#level2":return"ImageService2";case"http://iiif.io/api/image/1/context.json":case"http://library.stanford.edu/iiif/image-api/1.1/context.json":return"ImageService1";case"http://iiif.io/api/annex/openannotation/context.json":return"ImageApiSelector"}}(i);if(e)return e}if(n){if(Array.isArray(n)){if(-1!==n.indexOf("oa:CssStylesheet"))return"CssStylesheet";if(-1!==n.indexOf("cnt:ContentAsText"))return"TextualBody";n=n[0]}for(const e of["sc","oa","dcterms","dctypes","iiif"])if(n.startsWith(e+":")){n=n.slice(e.length+1);break}switch(n){case"Layer":return"AnnotationCollection";case"AnnotationList":return"AnnotationPage";case"cnt:ContentAsText":return"TextualBody"}}if(n&&-1!==Ra.indexOf(n))return n;if(e.format){if(e.format.startsWith("image/"))return"Image";if(e.format.startsWith("text/"))return"Text";if("application/pdf"===e.format)return"Text";if(e.format.startsWith("application/"))return"Dataset"}return t&&(t.endsWith(".jpg")||t.endsWith(".png")||t.endsWith(".jpeg"))?"Image":n||"unknown"}const _a=/http(s)?:\/\/(creativecommons.org|rightsstatements.org)[^"'\\<\n]+/gm;function Oa(e){const t=e.match(_a);return t?t[0]:e}const Ta=["http://iiif.io/api/presentation/2/context.json","http://iiif.io/api/image/2/context.json","http://iiif.io/api/image/1/context.json","http://library.stanford.edu/iiif/image-api/1.1/context.json","http://iiif.io/api/search/1/context.json","http://iiif.io/api/search/0/context.json","http://iiif.io/api/auth/1/context.json","http://iiif.io/api/auth/0/context.json","http://iiif.io/api/annex/openannotation/context.json"];function Na(e){if(e){const t=Array.isArray(e)?e:[e],n=[];for(const e of t)"http://iiif.io/api/presentation/2/context.json"===e&&n.push("http://iiif.io/api/presentation/3/context.json"),-1===Ta.indexOf(e)&&n.push(e);if(t.length)return 1===n.length?n[0]:n}}let Da=0;function La(e,t){const n=encodeURI(e.id||e["@id"]||"").trim();return n&&t?`${n}/${t}`:n||(Da++,`http://example.org/${e["@type"]}${t?"/"+t:""}/${Da}`)}function za(e){const t=[...e.behavior||[]];let n;return e.viewingHint&&t.push(e.viewingHint),Array.isArray(e.motivation)?n=e.motivation.map(Ea):e.motivation&&(n=Ea(e.motivation)),{"@context":e["@context"]?Na(e["@context"]):void 0,id:(e["@id"]||La(e)).trim(),type:ja(e),behavior:t.length?t:void 0,height:e.height?e.height:void 0,width:e.width?e.width:void 0,motivation:n,viewingDirection:e.viewingDirection,profile:e.profile,format:e.format?e.format:void 0,duration:void 0,timeMode:void 0}}function Fa(e){const[t,n]=function(e,t="Rights/License",n="none"){let r=null;const i=[],o=Array.isArray(e)?e:[e];for(const a of o){const e=a?Oa(a):void 0;!e||-1===e.indexOf("creativecommons.org")&&-1===e.indexOf("rightsstatements.org")?e&&i.push({label:{[n]:[t]},value:{[n]:[e]}}):r=e.startsWith("https://")?"http://"+e.slice(8):e}return[r,i]}(e.license),r=[...e.metadata?(i=e.metadata,i?i.map(e=>({label:Ma(e.label),value:Ma(e.value)})):[]):[],...n];var i;return{rights:t,metadata:r.length?r:void 0,label:e.label?Ma(e.label):void 0,requiredStatement:e.attribution?{label:Ma(Aa),value:Ma(e.attribution)}:void 0,navDate:e.navDate,summary:e.description?Ma(e.description):void 0,thumbnail:e.thumbnail}}function Wa(e){if(!e.within)return;const t=Array.isArray(e.within)?e.within:[e.within],n=[];for(const r of t)if("string"==typeof r){if(r)switch(e["@type"]){case"sc:Manifest":n.push({id:r,type:"Collection"})}}else r["@id"]&&n.push({id:r["@id"],type:ja(r)});return n.length?n:void 0}function Ba(e){const t=e.related?Array.isArray(e.related)?e.related:[e.related]:[],n=e.contentLayer;return{provider:e.logo||t.length?[{id:Sa,type:"Agent",homepage:t.length?[t[0]]:void 0,logo:e.logo?Array.isArray(e.logo)?e.logo:[e.logo]:void 0,label:Ma(Ia)}]:void 0,partOf:Wa(e),rendering:e.rendering,seeAlso:e.seeAlso,start:e.startCanvas,service:e.service?(r=e.service,Array.isArray(r)?r:r?[r]:[]):void 0,supplementary:n?[n]:void 0};var r}function $a(e){const t=e;return Pa({...za(t),...Fa(t),...Ba(t),...(n=t,{chars:n.chars,format:n.format?n.format:void 0,language:n.language})});var n}const qa=new xa({collection:[function(e){return Pa({...za(e),...Fa(e),...Ba(e),items:e.members})}],manifest:[function(e){const t=[],n=[];let r=void 0;for(const o of e.sequences||[])o.canvases.length&&t.push(...o.canvases),o.behavior&&n.push(...o.behavior),o.startCanvas&&(r=o.startCanvas);const i=za(e);return n.length&&(i.behavior?i.behavior.push(...n):i.behavior=n),Pa({...i,...Fa(e),...Ba(e),start:r,items:t,structures:e.structures})}],canvas:[function(e){return Pa({...za(e),...Fa(e),...Ba(e),annotations:e.otherContent&&e.otherContent.length?e.otherContent:void 0,items:e.images&&e.images.length?[{id:La(e,"annotation-page"),type:"AnnotationPage",items:e.images}]:void 0})}],annotationList:[function(e){return Pa({...za(e),...Fa(e),...Ba(e),items:e.resources&&e.resources.length?e.resources:void 0})}],sequence:[function(e){return e.canvases&&0!==e.canvases.length?{canvases:e.canvases,behavior:e.viewingHint?[e.viewingHint]:[],startCanvas:e.startCanvas}:{canvases:[],behavior:[]}}],annotation:[function(e){return Pa({...za(e),...Fa(e),...Ba(e),target:function e(t){if(Array.isArray(t)){if(t.length>1)return{type:"List",items:t.map(e)};t=t[0]}if("string"==typeof t)return encodeURI(t).trim();if("@type"in t){let e;if("string"==typeof t.full)e=t.full;else if("dctypes:Image"===t.full["@type"])e={id:t.full["@id"],type:"Image"};else{if("sc:Canvas"!==t.full["@type"])throw new Error("Unsupported source type on annotation: "+t.full["@type"]);e={id:t.full["@id"],type:"Canvas"}}return{type:"SpecificResource",source:e,selector:Ha(t.selector)}}return encodeURI(t["@id"]).trim()}(e.on),body:Array.isArray(e.resource)?e.resource.map($a):$a(e.resource)})}],contentResource:[$a],choice:[function(e){const t=[];return e.default&&"rdf:nil"!==e.default&&t.push(e.default),e.item&&"rdf:nil"!==e.item&&t.push(...e.item),{...za(e),...Fa(e),items:t}}],range:[function(e){return Pa({...za(e),...Fa(e),...Ba(e),items:e.members})}],service:[function(e){const{"@id":t,"@type":n,"@context":r,profile:i,...o}=e,a={};return t&&(a["@id"]=t),a["@type"]=ja(e),"unknown"===a["@type"]&&(r&&r.length&&(a["@context"]=r),a["@type"]="Service"),i&&(a.profile=function e(t){return Array.isArray(t)?e(t.find(e=>"string"==typeof e)):-1!==ka.indexOf(t)?"level2":-1!==Ca.indexOf(t)?"level1":"string"==typeof t?t:void 0}(i)),Pa({...a,...o})}],layer:[function(e){return Pa({...za(e),...Fa(e),...Ba(e)})}]});function Ua(e){return e&&e["@context"]&&("http://iiif.io/api/presentation/2/context.json"===e["@context"]||-1!==e["@context"].indexOf("http://iiif.io/api/presentation/2/context.json")||"http://www.shared-canvas.org/ns/context.json"===e["@context"])||"http://iiif.io/api/image/2/context.json"===e["@context"]?qa.traverseUnknown(e):e}function Ha(e){if((Array.isArray(e["@type"])&&e["@type"].includes("oa:SvgSelector")||"oa:SvgSelector"==e["@type"])&&("chars"in e||"value"in e))return{type:"SvgSelector",value:"chars"in e?e.chars:e.value};if("oa:FragmentSelector"===e["@type"])return{type:"FragmentSelector",value:e.value};if("oa:Choice"===e["@type"])return[Ha(e.default),...(Array.isArray(e.item)?e.item:[e.item]).map(Ha)];if("iiif:ImageApiSelector"==e["@type"])return{type:"ImageApiSelector",region:"region"in e?e.region:void 0,rotation:"rotation"in e?e.rotation:void 0};throw new Error("Unsupported selector type: "+e["@type"])}function Va(e,t){const n=t.map(e=>e.filename),r=(e.name||e.filename||"Untitled project").toLowerCase();if(e.filename&&-1!==n.indexOf(e.filename)&&(e.filename=void 0),!e.filename){let t=0;for(;!e.filename;){const i=`${De(r,{lower:!0})}${t?` (${t})`:""}`;if(-1===n.indexOf(i)){e.filename=i,e.name=`${e.name} (${t})`;break}t++}}console.log({project:e,filenames:n})}function Ja(e,t={}){const n=fn(e.label)||"Untitled collection";return{id:"manifest-editor://project/"+Br(),filename:De(n,{lower:!0}),name:n,metadata:{created:Date.now(),modified:Date.now()},resource:{id:e.id,type:"Collection"},publications:[],previews:[],settings:{},storage:{type:"collection-storage",data:e},...t}}function Ya(e,t,r){async function i(n){const i={...n};if(Va(i,await t.getAllProjects(!0)),!r.canCreate())throw new Error("Cannot create project with this storage backend");const o=await r.create(i,i.storage.data),s={...i,storage:o};await t.createProject(s),e({type:"createProject",payload:s}),a(i.id)}function o(n){t.canDelete()&&(e({type:"deleteProject",payload:n}),t.deleteProject(n).then(()=>{console.log("Loader: project deleted")}))}function a(n){e({type:"switchProject",payload:n}),t.setLastProject(n).then(()=>{})}function s(t){e({type:"deselectProject",payload:t})}function c(t){throw e({type:"forkProject",payload:t}),new Error("Not implemented yet")}function l(t){e({type:"setLoadingStatus",payload:t})}function u(n){console.log("trying to save project..."),e({type:"saveProject",payload:n}),Promise.all([t.updateProject(n),r.saveStorage(n.storage)]).then(()=>{console.log("Loader: project saved")})}function d(t){e({type:"updateDetails",payload:t})}function p(t){e({type:"createPublication",payload:t})}function f(t){e({type:"updatePublication",payload:t})}function h(t){e({type:"removePublication",payload:t})}function m(t){e({type:"updateSettings",payload:t})}function g(t){e({type:"updateThumbnail",payload:t})}function v(t){e({type:"updateStorage",payload:t})}function y(t){e({type:"load",payload:t})}function b(t){e({type:"setPreview",payload:t})}function w(t){e({type:"removePreview",payload:t})}return n.useMemo(()=>({createProject:i,deleteProject:o,switchProject:a,deselectProject:s,forkProject:c,saveProject:u,setLoadingStatus:l,load:y,updateDetails:d,createPublication:p,updatePublication:f,removePublication:h,updateSettings:m,updateThumbnail:g,updateStorage:v,setPreview:b,removePreview:w}),[])}function Ga({actions:e,current:t},r){n.useEffect(()=>{e.setLoadingStatus({loading:!0,lastLoaded:0,loaded:!1}),r.getAllProjects().then(async t=>{const n=await r.getLastProject(),i=t.find(e=>e.id===n);e.load({allProjects:t,current:i||null,loadingStatus:{loaded:!0,loading:!1,lastLoaded:Date.now()}})})},[])}function Za({actions:e,current:t},r){const i=n.useRef(null),[o,a]=n.useState(!1),[s,l]=n.useState(""),u=n.useCallback(()=>{const t=i.current;t&&r.saveStorage(t.storage).then(()=>{const n=r.getBackendStorage(t);ra(n,t.storage)||e.saveProject({...t,storage:n})})},[e,r]),d=ma(u,r.saveInterval),p=null==t?void 0:t.id;n.useEffect(()=>{i.current=t},[t]);const{vault:f,promise:h}=n.useMemo(()=>{if(t){const[e,n]=r.createVaultInstance(t);return{vault:e,promise:n}}return{vault:null,promise:null}},[r,p]);return n.useEffect(()=>{const e=r,n=t,i=f;return()=>{i&&n?e.closeVaultInstance(n,i):i instanceof c.ClientVault&&i.ws.close()}},[r,t,f]),n.useEffect(()=>{a(!1);let e=!1;return h&&h.then(()=>{e||a(!0)}).catch(e=>{l(e.message)}),()=>{e=!0}},[h]),n.useEffect(()=>(window.addEventListener("beforeunload",u,!1),()=>{window.removeEventListener("beforeunload",u)}),[u]),n.useEffect(()=>()=>{u()},[u,p]),n.useEffect(()=>{if(f&&r.shouldUpdateWithVault())return f.subscribe(d,!0)},[d,r,f]),{vault:f,ready:o,error:s}}function Ka(){const{changeApp:e}=J(),{actions:t}=N(),r=n.useCallback((function(){t.createProject(va({"@context":"http://iiif.io/api/presentation/3/context.json",id:"https://example.org/"+Br(),type:"Manifest",label:{en:["Blank Manifest"]},items:[]})),e({id:"manifest-editor"})}),[]),i=n.useCallback((async function(n){let r=await ga(n);r&&(r["@id"]&&(r=Ua(r)),r&&(t.createProject(va(r)),e({id:"manifest-editor"})))}),[]),o=n.useCallback((async function(n){let r=await ga(n);r&&(r["@id"]&&(r=Ua(r)),r&&(t.createProject(Ja(r)),e({id:"collection-editor"})))}),[]);return{createProjectFromManifestJson:n.useCallback((async function(n){let r=JSON.parse(n);r&&(r["@id"]&&(r=Ua(r)),r&&(t.createProject(va(r)),e({id:"manifest-editor"})))}),[]),createProjectFromManifestId:i,createProjectFromCollectionId:o,createBlankManifest:r}}function Xa(e){throw new Error('Could not dynamically require "'+e+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var Qa={};({get exports(){return Qa},set exports(e){Qa=e}}).exports=function e(t,n,r){function i(a,s){if(!n[a]){if(!t[a]){if(!s&&Xa)return Xa(a);if(o)return o(a,!0);var c=new Error("Cannot find module '"+a+"'");throw c.code="MODULE_NOT_FOUND",c}var l=n[a]={exports:{}};t[a][0].call(l.exports,(function(e){var n=t[a][1][e];return i(n||e)}),l,l.exports,e,t,n,r)}return n[a].exports}for(var o=Xa,a=0;a<r.length;a++)i(r[a]);return i}({1:[function(e,t,n){(function(e){var n,r,i=e.MutationObserver||e.WebKitMutationObserver;if(i){var o=0,a=new i(u),s=e.document.createTextNode("");a.observe(s,{characterData:!0}),n=function(){s.data=o=++o%2}}else if(e.setImmediate||void 0===e.MessageChannel)n="document"in e&&"onreadystatechange"in e.document.createElement("script")?function(){var t=e.document.createElement("script");t.onreadystatechange=function(){u(),t.onreadystatechange=null,t.parentNode.removeChild(t),t=null},e.document.documentElement.appendChild(t)}:function(){setTimeout(u,0)};else{var c=new e.MessageChannel;c.port1.onmessage=u,n=function(){c.port2.postMessage(0)}}var l=[];function u(){var e,t;r=!0;for(var n=l.length;n;){for(t=l,l=[],e=-1;++e<n;)t[e]();n=l.length}r=!1}t.exports=function(e){1!==l.push(e)||r||n()}}).call(this,void 0!==h?h:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],2:[function(e,t,n){var r=e(1);function i(){}var o={},a=["REJECTED"],s=["FULFILLED"],c=["PENDING"];function l(e){if("function"!=typeof e)throw new TypeError("resolver must be a function");this.state=c,this.queue=[],this.outcome=void 0,e!==i&&f(this,e)}function u(e,t,n){this.promise=e,"function"==typeof t&&(this.onFulfilled=t,this.callFulfilled=this.otherCallFulfilled),"function"==typeof n&&(this.onRejected=n,this.callRejected=this.otherCallRejected)}function d(e,t,n){r((function(){var r;try{r=t(n)}catch(i){return o.reject(e,i)}r===e?o.reject(e,new TypeError("Cannot resolve promise with itself")):o.resolve(e,r)}))}function p(e){var t=e&&e.then;if(e&&("object"==typeof e||"function"==typeof e)&&"function"==typeof t)return function(){t.apply(e,arguments)}}function f(e,t){var n=!1;function r(t){n||(n=!0,o.reject(e,t))}function i(t){n||(n=!0,o.resolve(e,t))}var a=h((function(){t(i,r)}));"error"===a.status&&r(a.value)}function h(e,t){var n={};try{n.value=e(t),n.status="success"}catch(r){n.status="error",n.value=r}return n}t.exports=l,l.prototype.catch=function(e){return this.then(null,e)},l.prototype.then=function(e,t){if("function"!=typeof e&&this.state===s||"function"!=typeof t&&this.state===a)return this;var n=new this.constructor(i);return this.state!==c?d(n,this.state===s?e:t,this.outcome):this.queue.push(new u(n,e,t)),n},u.prototype.callFulfilled=function(e){o.resolve(this.promise,e)},u.prototype.otherCallFulfilled=function(e){d(this.promise,this.onFulfilled,e)},u.prototype.callRejected=function(e){o.reject(this.promise,e)},u.prototype.otherCallRejected=function(e){d(this.promise,this.onRejected,e)},o.resolve=function(e,t){var n=h(p,t);if("error"===n.status)return o.reject(e,n.value);var r=n.value;if(r)f(e,r);else{e.state=s,e.outcome=t;for(var i=-1,a=e.queue.length;++i<a;)e.queue[i].callFulfilled(t)}return e},o.reject=function(e,t){e.state=a,e.outcome=t;for(var n=-1,r=e.queue.length;++n<r;)e.queue[n].callRejected(t);return e},l.resolve=function(e){return e instanceof this?e:o.resolve(new this(i),e)},l.reject=function(e){var t=new this(i);return o.reject(t,e)},l.all=function(e){var t=this;if("[object Array]"!==Object.prototype.toString.call(e))return this.reject(new TypeError("must be an array"));var n=e.length,r=!1;if(!n)return this.resolve([]);for(var a=new Array(n),s=0,c=-1,l=new this(i);++c<n;)u(e[c],c);return l;function u(e,i){t.resolve(e).then((function(e){a[i]=e,++s!==n||r||(r=!0,o.resolve(l,a))}),(function(e){r||(r=!0,o.reject(l,e))}))}},l.race=function(e){var t=this;if("[object Array]"!==Object.prototype.toString.call(e))return this.reject(new TypeError("must be an array"));var n=e.length,r=!1;if(!n)return this.resolve([]);for(var a,s=-1,c=new this(i);++s<n;)a=e[s],t.resolve(a).then((function(e){r||(r=!0,o.resolve(c,e))}),(function(e){r||(r=!0,o.reject(c,e))}));return c}},{1:1}],3:[function(e,t,n){(function(t){"function"!=typeof t.Promise&&(t.Promise=e(2))}).call(this,void 0!==h?h:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{2:2}],4:[function(e,t,n){var r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},i=function(){try{if("undefined"!=typeof indexedDB)return indexedDB;if("undefined"!=typeof webkitIndexedDB)return webkitIndexedDB;if("undefined"!=typeof mozIndexedDB)return mozIndexedDB;if("undefined"!=typeof OIndexedDB)return OIndexedDB;if("undefined"!=typeof msIndexedDB)return msIndexedDB}catch(e){return}}();function o(e,t){e=e||[],t=t||{};try{return new Blob(e,t)}catch(i){if("TypeError"!==i.name)throw i;for(var n=new("undefined"!=typeof BlobBuilder?BlobBuilder:"undefined"!=typeof MSBlobBuilder?MSBlobBuilder:"undefined"!=typeof MozBlobBuilder?MozBlobBuilder:WebKitBlobBuilder),r=0;r<e.length;r+=1)n.append(e[r]);return n.getBlob(t.type)}}"undefined"==typeof Promise&&e(3);var a=Promise;function s(e,t){t&&e.then((function(e){t(null,e)}),(function(e){t(e)}))}function c(e,t,n){"function"==typeof t&&e.then(t),"function"==typeof n&&e.catch(n)}function l(e){return"string"!=typeof e&&(console.warn(e+" used as a key, but it is not a string."),e=String(e)),e}function u(){if(arguments.length&&"function"==typeof arguments[arguments.length-1])return arguments[arguments.length-1]}var d=void 0,p={},f=Object.prototype.toString;function h(e){return"boolean"==typeof d?a.resolve(d):function(e){return new a((function(t){var n=e.transaction("local-forage-detect-blob-support","readwrite"),r=o([""]);n.objectStore("local-forage-detect-blob-support").put(r,"key"),n.onabort=function(e){e.preventDefault(),e.stopPropagation(),t(!1)},n.oncomplete=function(){var e=navigator.userAgent.match(/Chrome\/(\d+)/),n=navigator.userAgent.match(/Edge\//);t(n||!e||parseInt(e[1],10)>=43)}})).catch((function(){return!1}))}(e).then((function(e){return d=e}))}function m(e){var t=p[e.name],n={};n.promise=new a((function(e,t){n.resolve=e,n.reject=t})),t.deferredOperations.push(n),t.dbReady?t.dbReady=t.dbReady.then((function(){return n.promise})):t.dbReady=n.promise}function g(e){var t=p[e.name].deferredOperations.pop();if(t)return t.resolve(),t.promise}function v(e,t){var n=p[e.name].deferredOperations.pop();if(n)return n.reject(t),n.promise}function y(e,t){return new a((function(n,r){if(p[e.name]=p[e.name]||{forages:[],db:null,dbReady:null,deferredOperations:[]},e.db){if(!t)return n(e.db);m(e),e.db.close()}var o=[e.name];t&&o.push(e.version);var a=i.open.apply(i,o);t&&(a.onupgradeneeded=function(t){var n=a.result;try{n.createObjectStore(e.storeName),t.oldVersion<=1&&n.createObjectStore("local-forage-detect-blob-support")}catch(r){if("ConstraintError"!==r.name)throw r;console.warn('The database "'+e.name+'" has been upgraded from version '+t.oldVersion+" to version "+t.newVersion+', but the storage "'+e.storeName+'" already exists.')}}),a.onerror=function(e){e.preventDefault(),r(a.error)},a.onsuccess=function(){var t=a.result;t.onversionchange=function(e){e.target.close()},n(t),g(e)}}))}function b(e){return y(e,!1)}function w(e){return y(e,!0)}function x(e,t){if(!e.db)return!0;var n=!e.db.objectStoreNames.contains(e.storeName),r=e.version<e.db.version,i=e.version>e.db.version;if(r&&(e.version!==t&&console.warn('The database "'+e.name+"\" can't be downgraded from version "+e.db.version+" to version "+e.version+"."),e.version=e.db.version),i||n){if(n){var o=e.db.version+1;o>e.version&&(e.version=o)}return!0}return!1}function C(e){return o([function(e){for(var t=e.length,n=new ArrayBuffer(t),r=new Uint8Array(n),i=0;i<t;i++)r[i]=e.charCodeAt(i);return n}(atob(e.data))],{type:e.type})}function k(e){return e&&e.__local_forage_encoded_blob}function P(e){var t=this,n=t._initReady().then((function(){var e=p[t._dbInfo.name];if(e&&e.dbReady)return e.dbReady}));return c(n,e,e),n}function A(e,t,n,r){void 0===r&&(r=1);try{var i=e.db.transaction(e.storeName,t);n(null,i)}catch(o){if(r>0&&(!e.db||"InvalidStateError"===o.name||"NotFoundError"===o.name))return a.resolve().then((function(){if(!e.db||"NotFoundError"===o.name&&!e.db.objectStoreNames.contains(e.storeName)&&e.version<=e.db.version)return e.db&&(e.version=e.db.version+1),w(e)})).then((function(){return function(e){m(e);for(var t=p[e.name],n=t.forages,r=0;r<n.length;r++){var i=n[r];i._dbInfo.db&&(i._dbInfo.db.close(),i._dbInfo.db=null)}return e.db=null,b(e).then((function(t){return e.db=t,x(e)?w(e):t})).then((function(r){e.db=t.db=r;for(var i=0;i<n.length;i++)n[i]._dbInfo.db=r})).catch((function(t){throw v(e,t),t}))}(e).then((function(){A(e,t,n,r-1)}))})).catch(n);n(o)}}var S={_driver:"asyncStorage",_initStorage:function(e){var t=this,n={db:null};if(e)for(var r in e)n[r]=e[r];var i=p[n.name];i||(i={forages:[],db:null,dbReady:null,deferredOperations:[]},p[n.name]=i),i.forages.push(t),t._initReady||(t._initReady=t.ready,t.ready=P);var o=[];function s(){return a.resolve()}for(var c=0;c<i.forages.length;c++){var l=i.forages[c];l!==t&&o.push(l._initReady().catch(s))}var u=i.forages.slice(0);return a.all(o).then((function(){return n.db=i.db,b(n)})).then((function(e){return n.db=e,x(n,t._defaultConfig.version)?w(n):e})).then((function(e){n.db=i.db=e,t._dbInfo=n;for(var r=0;r<u.length;r++){var o=u[r];o!==t&&(o._dbInfo.db=n.db,o._dbInfo.version=n.version)}}))},_support:function(){try{if(!i||!i.open)return!1;var e="undefined"!=typeof openDatabase&&/(Safari|iPhone|iPad|iPod)/.test(navigator.userAgent)&&!/Chrome/.test(navigator.userAgent)&&!/BlackBerry/.test(navigator.platform),t="function"==typeof fetch&&-1!==fetch.toString().indexOf("[native code");return(!e||t)&&"undefined"!=typeof indexedDB&&"undefined"!=typeof IDBKeyRange}catch(n){return!1}}(),iterate:function(e,t){var n=this,r=new a((function(t,r){n.ready().then((function(){A(n._dbInfo,"readonly",(function(i,o){if(i)return r(i);try{var a=o.objectStore(n._dbInfo.storeName).openCursor(),s=1;a.onsuccess=function(){var n=a.result;if(n){var r=n.value;k(r)&&(r=C(r));var i=e(r,n.key,s++);void 0!==i?t(i):n.continue()}else t()},a.onerror=function(){r(a.error)}}catch(c){r(c)}}))})).catch(r)}));return s(r,t),r},getItem:function(e,t){var n=this;e=l(e);var r=new a((function(t,r){n.ready().then((function(){A(n._dbInfo,"readonly",(function(i,o){if(i)return r(i);try{var a=o.objectStore(n._dbInfo.storeName).get(e);a.onsuccess=function(){var e=a.result;void 0===e&&(e=null),k(e)&&(e=C(e)),t(e)},a.onerror=function(){r(a.error)}}catch(s){r(s)}}))})).catch(r)}));return s(r,t),r},setItem:function(e,t,n){var r=this;e=l(e);var i=new a((function(n,i){var o;r.ready().then((function(){return o=r._dbInfo,"[object Blob]"===f.call(t)?h(o.db).then((function(e){return e?t:(n=t,new a((function(e,t){var r=new FileReader;r.onerror=t,r.onloadend=function(t){var r=btoa(t.target.result||"");e({__local_forage_encoded_blob:!0,data:r,type:n.type})},r.readAsBinaryString(n)})));var n})):t})).then((function(t){A(r._dbInfo,"readwrite",(function(o,a){if(o)return i(o);try{var s=a.objectStore(r._dbInfo.storeName);null===t&&(t=void 0);var c=s.put(t,e);a.oncomplete=function(){void 0===t&&(t=null),n(t)},a.onabort=a.onerror=function(){var e=c.error?c.error:c.transaction.error;i(e)}}catch(l){i(l)}}))})).catch(i)}));return s(i,n),i},removeItem:function(e,t){var n=this;e=l(e);var r=new a((function(t,r){n.ready().then((function(){A(n._dbInfo,"readwrite",(function(i,o){if(i)return r(i);try{var a=o.objectStore(n._dbInfo.storeName).delete(e);o.oncomplete=function(){t()},o.onerror=function(){r(a.error)},o.onabort=function(){var e=a.error?a.error:a.transaction.error;r(e)}}catch(s){r(s)}}))})).catch(r)}));return s(r,t),r},clear:function(e){var t=this,n=new a((function(e,n){t.ready().then((function(){A(t._dbInfo,"readwrite",(function(r,i){if(r)return n(r);try{var o=i.objectStore(t._dbInfo.storeName).clear();i.oncomplete=function(){e()},i.onabort=i.onerror=function(){var e=o.error?o.error:o.transaction.error;n(e)}}catch(a){n(a)}}))})).catch(n)}));return s(n,e),n},length:function(e){var t=this,n=new a((function(e,n){t.ready().then((function(){A(t._dbInfo,"readonly",(function(r,i){if(r)return n(r);try{var o=i.objectStore(t._dbInfo.storeName).count();o.onsuccess=function(){e(o.result)},o.onerror=function(){n(o.error)}}catch(a){n(a)}}))})).catch(n)}));return s(n,e),n},key:function(e,t){var n=this,r=new a((function(t,r){e<0?t(null):n.ready().then((function(){A(n._dbInfo,"readonly",(function(i,o){if(i)return r(i);try{var a=o.objectStore(n._dbInfo.storeName),s=!1,c=a.openKeyCursor();c.onsuccess=function(){var n=c.result;n?0===e||s?t(n.key):(s=!0,n.advance(e)):t(null)},c.onerror=function(){r(c.error)}}catch(l){r(l)}}))})).catch(r)}));return s(r,t),r},keys:function(e){var t=this,n=new a((function(e,n){t.ready().then((function(){A(t._dbInfo,"readonly",(function(r,i){if(r)return n(r);try{var o=i.objectStore(t._dbInfo.storeName).openKeyCursor(),a=[];o.onsuccess=function(){var t=o.result;t?(a.push(t.key),t.continue()):e(a)},o.onerror=function(){n(o.error)}}catch(s){n(s)}}))})).catch(n)}));return s(n,e),n},dropInstance:function(e,t){t=u.apply(this,arguments);var n=this.config();(e="function"!=typeof e&&e||{}).name||(e.name=e.name||n.name,e.storeName=e.storeName||n.storeName);var r,o=this;if(e.name){var c=e.name===n.name&&o._dbInfo.db,l=c?a.resolve(o._dbInfo.db):b(e).then((function(t){var n=p[e.name],r=n.forages;n.db=t;for(var i=0;i<r.length;i++)r[i]._dbInfo.db=t;return t}));r=e.storeName?l.then((function(t){if(t.objectStoreNames.contains(e.storeName)){var n=t.version+1;m(e);var r=p[e.name],o=r.forages;t.close();for(var s=0;s<o.length;s++){var c=o[s];c._dbInfo.db=null,c._dbInfo.version=n}return new a((function(t,r){var o=i.open(e.name,n);o.onerror=function(e){o.result.close(),r(e)},o.onupgradeneeded=function(){o.result.deleteObjectStore(e.storeName)},o.onsuccess=function(){var e=o.result;e.close(),t(e)}})).then((function(e){r.db=e;for(var t=0;t<o.length;t++){var n=o[t];n._dbInfo.db=e,g(n._dbInfo)}})).catch((function(t){throw(v(e,t)||a.resolve()).catch((function(){})),t}))}})):l.then((function(t){m(e);var n=p[e.name],r=n.forages;t.close();for(var o=0;o<r.length;o++)r[o]._dbInfo.db=null;return new a((function(t,n){var r=i.deleteDatabase(e.name);r.onerror=function(){var e=r.result;e&&e.close(),n(r.error)},r.onblocked=function(){console.warn('dropInstance blocked for database "'+e.name+'" until all open connections are closed')},r.onsuccess=function(){var e=r.result;e&&e.close(),t(e)}})).then((function(e){n.db=e;for(var t=0;t<r.length;t++)g(r[t]._dbInfo)})).catch((function(t){throw(v(e,t)||a.resolve()).catch((function(){})),t}))}))}else r=a.reject("Invalid arguments");return s(r,t),r}},I="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",M=/^~~local_forage_type~([^~]+)~/,E="__lfsc__:".length,R=E+"arbf".length,j=Object.prototype.toString;function _(e){var t,n,r,i,o,a=.75*e.length,s=e.length,c=0;"="===e[e.length-1]&&(a--,"="===e[e.length-2]&&a--);var l=new ArrayBuffer(a),u=new Uint8Array(l);for(t=0;t<s;t+=4)n=I.indexOf(e[t]),r=I.indexOf(e[t+1]),i=I.indexOf(e[t+2]),o=I.indexOf(e[t+3]),u[c++]=n<<2|r>>4,u[c++]=(15&r)<<4|i>>2,u[c++]=(3&i)<<6|63&o;return l}function O(e){var t,n=new Uint8Array(e),r="";for(t=0;t<n.length;t+=3)r+=I[n[t]>>2],r+=I[(3&n[t])<<4|n[t+1]>>4],r+=I[(15&n[t+1])<<2|n[t+2]>>6],r+=I[63&n[t+2]];return n.length%3==2?r=r.substring(0,r.length-1)+"=":n.length%3==1&&(r=r.substring(0,r.length-2)+"=="),r}var T={serialize:function(e,t){var n="";if(e&&(n=j.call(e)),e&&("[object ArrayBuffer]"===n||e.buffer&&"[object ArrayBuffer]"===j.call(e.buffer))){var r,i="__lfsc__:";e instanceof ArrayBuffer?(r=e,i+="arbf"):(r=e.buffer,"[object Int8Array]"===n?i+="si08":"[object Uint8Array]"===n?i+="ui08":"[object Uint8ClampedArray]"===n?i+="uic8":"[object Int16Array]"===n?i+="si16":"[object Uint16Array]"===n?i+="ur16":"[object Int32Array]"===n?i+="si32":"[object Uint32Array]"===n?i+="ui32":"[object Float32Array]"===n?i+="fl32":"[object Float64Array]"===n?i+="fl64":t(new Error("Failed to get type for BinaryArray"))),t(i+O(r))}else if("[object Blob]"===n){var o=new FileReader;o.onload=function(){var n="~~local_forage_type~"+e.type+"~"+O(this.result);t("__lfsc__:blob"+n)},o.readAsArrayBuffer(e)}else try{t(JSON.stringify(e))}catch(a){console.error("Couldn't convert value into a JSON string: ",e),t(null,a)}},deserialize:function(e){if("__lfsc__:"!==e.substring(0,E))return JSON.parse(e);var t,n=e.substring(R),r=e.substring(E,R);if("blob"===r&&M.test(n)){var i=n.match(M);t=i[1],n=n.substring(i[0].length)}var a=_(n);switch(r){case"arbf":return a;case"blob":return o([a],{type:t});case"si08":return new Int8Array(a);case"ui08":return new Uint8Array(a);case"uic8":return new Uint8ClampedArray(a);case"si16":return new Int16Array(a);case"ur16":return new Uint16Array(a);case"si32":return new Int32Array(a);case"ui32":return new Uint32Array(a);case"fl32":return new Float32Array(a);case"fl64":return new Float64Array(a);default:throw new Error("Unkown type: "+r)}},stringToBuffer:_,bufferToString:O};function N(e,t,n,r){e.executeSql("CREATE TABLE IF NOT EXISTS "+t.storeName+" (id INTEGER PRIMARY KEY, key unique, value)",[],n,r)}function D(e,t,n,r,i,o){e.executeSql(n,r,i,(function(e,a){a.code===a.SYNTAX_ERR?e.executeSql("SELECT name FROM sqlite_master WHERE type='table' AND name = ?",[t.storeName],(function(e,s){s.rows.length?o(e,a):N(e,t,(function(){e.executeSql(n,r,i,o)}),o)}),o):o(e,a)}),o)}function L(e,t,n,r){var i=this;e=l(e);var o=new a((function(o,a){i.ready().then((function(){void 0===t&&(t=null);var s=t,c=i._dbInfo;c.serializer.serialize(t,(function(t,l){l?a(l):c.db.transaction((function(n){D(n,c,"INSERT OR REPLACE INTO "+c.storeName+" (key, value) VALUES (?, ?)",[e,t],(function(){o(s)}),(function(e,t){a(t)}))}),(function(t){if(t.code===t.QUOTA_ERR){if(r>0)return void o(L.apply(i,[e,s,n,r-1]));a(t)}}))}))})).catch(a)}));return s(o,n),o}function z(e){return new a((function(t,n){e.transaction((function(r){r.executeSql("SELECT name FROM sqlite_master WHERE type='table' AND name <> '__WebKitDatabaseInfoTable__'",[],(function(n,r){for(var i=[],o=0;o<r.rows.length;o++)i.push(r.rows.item(o).name);t({db:e,storeNames:i})}),(function(e,t){n(t)}))}),(function(e){n(e)}))}))}var F={_driver:"webSQLStorage",_initStorage:function(e){var t=this,n={db:null};if(e)for(var r in e)n[r]="string"!=typeof e[r]?e[r].toString():e[r];var i=new a((function(e,r){try{n.db=openDatabase(n.name,String(n.version),n.description,n.size)}catch(i){return r(i)}n.db.transaction((function(i){N(i,n,(function(){t._dbInfo=n,e()}),(function(e,t){r(t)}))}),r)}));return n.serializer=T,i},_support:"function"==typeof openDatabase,iterate:function(e,t){var n=this,r=new a((function(t,r){n.ready().then((function(){var i=n._dbInfo;i.db.transaction((function(n){D(n,i,"SELECT * FROM "+i.storeName,[],(function(n,r){for(var o=r.rows,a=o.length,s=0;s<a;s++){var c=o.item(s),l=c.value;if(l&&(l=i.serializer.deserialize(l)),void 0!==(l=e(l,c.key,s+1)))return void t(l)}t()}),(function(e,t){r(t)}))}))})).catch(r)}));return s(r,t),r},getItem:function(e,t){var n=this;e=l(e);var r=new a((function(t,r){n.ready().then((function(){var i=n._dbInfo;i.db.transaction((function(n){D(n,i,"SELECT * FROM "+i.storeName+" WHERE key = ? LIMIT 1",[e],(function(e,n){var r=n.rows.length?n.rows.item(0).value:null;r&&(r=i.serializer.deserialize(r)),t(r)}),(function(e,t){r(t)}))}))})).catch(r)}));return s(r,t),r},setItem:function(e,t,n){return L.apply(this,[e,t,n,1])},removeItem:function(e,t){var n=this;e=l(e);var r=new a((function(t,r){n.ready().then((function(){var i=n._dbInfo;i.db.transaction((function(n){D(n,i,"DELETE FROM "+i.storeName+" WHERE key = ?",[e],(function(){t()}),(function(e,t){r(t)}))}))})).catch(r)}));return s(r,t),r},clear:function(e){var t=this,n=new a((function(e,n){t.ready().then((function(){var r=t._dbInfo;r.db.transaction((function(t){D(t,r,"DELETE FROM "+r.storeName,[],(function(){e()}),(function(e,t){n(t)}))}))})).catch(n)}));return s(n,e),n},length:function(e){var t=this,n=new a((function(e,n){t.ready().then((function(){var r=t._dbInfo;r.db.transaction((function(t){D(t,r,"SELECT COUNT(key) as c FROM "+r.storeName,[],(function(t,n){var r=n.rows.item(0).c;e(r)}),(function(e,t){n(t)}))}))})).catch(n)}));return s(n,e),n},key:function(e,t){var n=this,r=new a((function(t,r){n.ready().then((function(){var i=n._dbInfo;i.db.transaction((function(n){D(n,i,"SELECT key FROM "+i.storeName+" WHERE id = ? LIMIT 1",[e+1],(function(e,n){var r=n.rows.length?n.rows.item(0).key:null;t(r)}),(function(e,t){r(t)}))}))})).catch(r)}));return s(r,t),r},keys:function(e){var t=this,n=new a((function(e,n){t.ready().then((function(){var r=t._dbInfo;r.db.transaction((function(t){D(t,r,"SELECT key FROM "+r.storeName,[],(function(t,n){for(var r=[],i=0;i<n.rows.length;i++)r.push(n.rows.item(i).key);e(r)}),(function(e,t){n(t)}))}))})).catch(n)}));return s(n,e),n},dropInstance:function(e,t){t=u.apply(this,arguments);var n=this.config();(e="function"!=typeof e&&e||{}).name||(e.name=e.name||n.name,e.storeName=e.storeName||n.storeName);var r,i=this;return s(r=e.name?new a((function(t){var r;r=e.name===n.name?i._dbInfo.db:openDatabase(e.name,"","",0),e.storeName?t({db:r,storeNames:[e.storeName]}):t(z(r))})).then((function(e){return new a((function(t,n){e.db.transaction((function(r){function i(e){return new a((function(t,n){r.executeSql("DROP TABLE IF EXISTS "+e,[],(function(){t()}),(function(e,t){n(t)}))}))}for(var o=[],s=0,c=e.storeNames.length;s<c;s++)o.push(i(e.storeNames[s]));a.all(o).then((function(){t()})).catch((function(e){n(e)}))}),(function(e){n(e)}))}))})):a.reject("Invalid arguments"),t),r}};function W(e,t){var n=e.name+"/";return e.storeName!==t.storeName&&(n+=e.storeName+"/"),n}function B(){return!function(){try{return localStorage.setItem("_localforage_support_test",!0),localStorage.removeItem("_localforage_support_test"),!1}catch(e){return!0}}()||localStorage.length>0}var $={_driver:"localStorageWrapper",_initStorage:function(e){var t={};if(e)for(var n in e)t[n]=e[n];return t.keyPrefix=W(e,this._defaultConfig),B()?(this._dbInfo=t,t.serializer=T,a.resolve()):a.reject()},_support:function(){try{return"undefined"!=typeof localStorage&&"setItem"in localStorage&&!!localStorage.setItem}catch(e){return!1}}(),iterate:function(e,t){var n=this,r=n.ready().then((function(){for(var t=n._dbInfo,r=t.keyPrefix,i=r.length,o=localStorage.length,a=1,s=0;s<o;s++){var c=localStorage.key(s);if(0===c.indexOf(r)){var l=localStorage.getItem(c);if(l&&(l=t.serializer.deserialize(l)),void 0!==(l=e(l,c.substring(i),a++)))return l}}}));return s(r,t),r},getItem:function(e,t){var n=this;e=l(e);var r=n.ready().then((function(){var t=n._dbInfo,r=localStorage.getItem(t.keyPrefix+e);return r&&(r=t.serializer.deserialize(r)),r}));return s(r,t),r},setItem:function(e,t,n){var r=this;e=l(e);var i=r.ready().then((function(){void 0===t&&(t=null);var n=t;return new a((function(i,o){var a=r._dbInfo;a.serializer.serialize(t,(function(t,r){if(r)o(r);else try{localStorage.setItem(a.keyPrefix+e,t),i(n)}catch(s){"QuotaExceededError"!==s.name&&"NS_ERROR_DOM_QUOTA_REACHED"!==s.name||o(s),o(s)}}))}))}));return s(i,n),i},removeItem:function(e,t){var n=this;e=l(e);var r=n.ready().then((function(){var t=n._dbInfo;localStorage.removeItem(t.keyPrefix+e)}));return s(r,t),r},clear:function(e){var t=this,n=t.ready().then((function(){for(var e=t._dbInfo.keyPrefix,n=localStorage.length-1;n>=0;n--){var r=localStorage.key(n);0===r.indexOf(e)&&localStorage.removeItem(r)}}));return s(n,e),n},length:function(e){var t=this.keys().then((function(e){return e.length}));return s(t,e),t},key:function(e,t){var n=this,r=n.ready().then((function(){var t,r=n._dbInfo;try{t=localStorage.key(e)}catch(i){t=null}return t&&(t=t.substring(r.keyPrefix.length)),t}));return s(r,t),r},keys:function(e){var t=this,n=t.ready().then((function(){for(var e=t._dbInfo,n=localStorage.length,r=[],i=0;i<n;i++){var o=localStorage.key(i);0===o.indexOf(e.keyPrefix)&&r.push(o.substring(e.keyPrefix.length))}return r}));return s(n,e),n},dropInstance:function(e,t){if(t=u.apply(this,arguments),!(e="function"!=typeof e&&e||{}).name){var n=this.config();e.name=e.name||n.name,e.storeName=e.storeName||n.storeName}var r,i=this;return s(r=e.name?new a((function(t){e.storeName?t(W(e,i._defaultConfig)):t(e.name+"/")})).then((function(e){for(var t=localStorage.length-1;t>=0;t--){var n=localStorage.key(t);0===n.indexOf(e)&&localStorage.removeItem(n)}})):a.reject("Invalid arguments"),t),r}},q=function(e,t){for(var n,r,i=e.length,o=0;o<i;){if((n=e[o])===(r=t)||"number"==typeof n&&"number"==typeof r&&isNaN(n)&&isNaN(r))return!0;o++}return!1},U=Array.isArray||function(e){return"[object Array]"===Object.prototype.toString.call(e)},H={},V={},J={INDEXEDDB:S,WEBSQL:F,LOCALSTORAGE:$},Y=[J.INDEXEDDB._driver,J.WEBSQL._driver,J.LOCALSTORAGE._driver],G=["dropInstance"],Z=["clear","getItem","iterate","key","keys","length","removeItem","setItem"].concat(G),K={description:"",driver:Y.slice(),name:"localforage",size:4980736,storeName:"keyvaluepairs",version:1};function X(e,t){e[t]=function(){var n=arguments;return e.ready().then((function(){return e[t].apply(e,n)}))}}function Q(){for(var e=1;e<arguments.length;e++){var t=arguments[e];if(t)for(var n in t)t.hasOwnProperty(n)&&(U(t[n])?arguments[0][n]=t[n].slice():arguments[0][n]=t[n])}return arguments[0]}var ee=new(function(){function e(t){for(var n in function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),J)if(J.hasOwnProperty(n)){var r=J[n],i=r._driver;this[n]=i,H[i]||this.defineDriver(r)}this._defaultConfig=Q({},K),this._config=Q({},this._defaultConfig,t),this._driverSet=null,this._initDriver=null,this._ready=!1,this._dbInfo=null,this._wrapLibraryMethodsWithReady(),this.setDriver(this._config.driver).catch((function(){}))}return e.prototype.config=function(e){if("object"===(void 0===e?"undefined":r(e))){if(this._ready)return new Error("Can't call config() after localforage has been used.");for(var t in e){if("storeName"===t&&(e[t]=e[t].replace(/\W/g,"_")),"version"===t&&"number"!=typeof e[t])return new Error("Database version must be a number.");this._config[t]=e[t]}return!("driver"in e)||!e.driver||this.setDriver(this._config.driver)}return"string"==typeof e?this._config[e]:this._config},e.prototype.defineDriver=function(e,t,n){var r=new a((function(t,n){try{var r=e._driver,i=new Error("Custom driver not compliant; see https://mozilla.github.io/localForage/#definedriver");if(!e._driver)return void n(i);for(var o=Z.concat("_initStorage"),c=0,l=o.length;c<l;c++){var u=o[c];if((!q(G,u)||e[u])&&"function"!=typeof e[u])return void n(i)}!function(){for(var t=function(e){return function(){var t=new Error("Method "+e+" is not implemented by the current driver"),n=a.reject(t);return s(n,arguments[arguments.length-1]),n}},n=0,r=G.length;n<r;n++){var i=G[n];e[i]||(e[i]=t(i))}}();var d=function(n){H[r]&&console.info("Redefining LocalForage driver: "+r),H[r]=e,V[r]=n,t()};"_support"in e?e._support&&"function"==typeof e._support?e._support().then(d,n):d(!!e._support):d(!0)}catch(p){n(p)}}));return c(r,t,n),r},e.prototype.driver=function(){return this._driver||null},e.prototype.getDriver=function(e,t,n){var r=H[e]?a.resolve(H[e]):a.reject(new Error("Driver not found."));return c(r,t,n),r},e.prototype.getSerializer=function(e){var t=a.resolve(T);return c(t,e),t},e.prototype.ready=function(e){var t=this,n=t._driverSet.then((function(){return null===t._ready&&(t._ready=t._initDriver()),t._ready}));return c(n,e,e),n},e.prototype.setDriver=function(e,t,n){var r=this;U(e)||(e=[e]);var i=this._getSupportedDrivers(e);function o(){r._config.driver=r.driver()}function s(e){return r._extend(e),o(),r._ready=r._initStorage(r._config),r._ready}var l=null!==this._driverSet?this._driverSet.catch((function(){return a.resolve()})):a.resolve();return this._driverSet=l.then((function(){var e=i[0];return r._dbInfo=null,r._ready=null,r.getDriver(e).then((function(e){var t;r._driver=e._driver,o(),r._wrapLibraryMethodsWithReady(),r._initDriver=(t=i,function(){var e=0;return function n(){for(;e<t.length;){var i=t[e];return e++,r._dbInfo=null,r._ready=null,r.getDriver(i).then(s).catch(n)}o();var c=new Error("No available storage method found.");return r._driverSet=a.reject(c),r._driverSet}()})}))})).catch((function(){o();var e=new Error("No available storage method found.");return r._driverSet=a.reject(e),r._driverSet})),c(this._driverSet,t,n),this._driverSet},e.prototype.supports=function(e){return!!V[e]},e.prototype._extend=function(e){Q(this,e)},e.prototype._getSupportedDrivers=function(e){for(var t=[],n=0,r=e.length;n<r;n++){var i=e[n];this.supports(i)&&t.push(i)}return t},e.prototype._wrapLibraryMethodsWithReady=function(){for(var e=0,t=Z.length;e<t;e++)X(this,Z[e])},e.prototype.createInstance=function(t){return new e(t)},e}());t.exports=ee},{3:3}]},{},[4])(4);class es{constructor(e){t(this,"namespace"),t(this,"saveInterval"),t(this,"storage"),this.namespace=(null==e?void 0:e.namespace)||"default-v1.1",this.saveInterval=5e3,this.storage=Qa.createInstance({name:"manifest-editor-projects"})}async deleteProject(e){await this.storage.removeItem(`${this.namespace}/projects/${e}`)}async createProject(e){const t=await this.getProjectIndex();await this.storage.setItem(`${this.namespace}/projects/${e.id}`,JSON.stringify(e)),-1===t.indexOf(e.id)&&(t.push(e.id),await this.saveProjectIndex(t))}canDelete(){return!0}async getAllProjects(){try{const t=await this.getProjectIndex(),n=[];for(const r of t){if("_index"===r)continue;const t=await this.storage.getItem(`${this.namespace}/projects/${r}`);if(t)try{n.push(JSON.parse(t))}catch(e){}}return n}catch(e){return console.error("Error loading from localstorage",e),[]}}async getLastProject(){return this.storage.getItem(this.namespace+"/last")}async setLastProject(e){await this.storage.setItem(this.namespace+"/last",e)}async updateProject(e){await this.storage.setItem(`${this.namespace}/projects/${e.id}`,JSON.stringify(e))}async saveProjectIndex(e){await this.storage.setItem(this.namespace+"/_index",JSON.stringify(e))}async getProjectIndex(){const e=await this.storage.getItem(this.namespace+"/_index");if(!e)return[];const t=JSON.parse(e);return Array.isArray(t)?t:[]}}class ts{constructor(e={}){t(this,"vaults",{}),t(this,"saveInterval"),this.saveInterval=e.saveInterval||5e3}shouldUpdateWithVault(){return!0}canCreate(){return!0}canDelete(){return!0}createVaultInstance(e){const t=this.vaults[e.storage.data.key];if(t)return[t,Promise.resolve()];const n=new l.Vault;return[n,(async()=>{const t=await this.getStorage(e.storage);await n.loadManifest(e.resource.id,JSON.parse(JSON.stringify(null==t?void 0:t.data))),this.vaults[e.storage.data.key]=n})()]}closeVaultInstance(e,t){}async saveStorage(e){const t=this.vaults[e.data.key],n={id:e.data.id,type:e.data.type};if(t){const r=t.toPresentation3(n),i="Collection"===r.type?{type:"collection-storage",data:r}:{type:"manifest-storage",data:r};await this.saveStorageData(i,e)}}}class ns extends ts{constructor(e){super({saveInterval:5e3}),t(this,"type","local-storage"),t(this,"namespace"),t(this,"storage"),t(this,"vaults",{}),this.namespace=(null==e?void 0:e.namespace)||"default",this.storage=Qa.createInstance({name:"local-storage-resource-loader"})}shouldUpdateWithVault(){return!0}async create(e,t){const n=Br();return await localStorage.setItem(`${this.namespace}/store/${n}`,JSON.stringify(t)),{type:"resource-keyed-storage",data:{id:t.id,type:t.type,key:n}}}async getStorage(e){try{const t=await localStorage.getItem(`${this.namespace}/store/${e.data.key}`),n=t?JSON.parse(t):null;return j(n),"Collection"===n.type?{type:"collection-storage",data:n}:{type:"manifest-storage",data:n}}catch(t){return null}}async saveStorageData(e,t){await localStorage.setItem(`${this.namespace}/store/${t.data.key}`,JSON.stringify(e.data))}async deleteStorage(e){this.vaults[e.data.key]=null,await localStorage.removeItem(`${this.namespace}/store/${e.data.key}`)}getBackendStorage(e){return e.storage}}const rs=function(e){return function(){const t={type:e,getType:()=>e,toString:()=>e};return(e,n)=>({...t,...void 0!==e&&{payload:e},...void 0!==n&&{meta:n}})}},is=rs("@iiif/IMPORT_ENTITIES")(),os=rs("@iiif/ADD_MAPPING")(),as=rs("@iiif/ADD_MAPPINGS")(),ss=rs("@iiif/REQUEST_ERROR")(),cs=rs("@iiif/REQUEST_MISMATCH")(),ls=rs("@iiif/REQUEST_COMPLETE")(),us=(e,t)=>{const{entities:n,resource:r,mapping:i}=o.normalize(t);if(void 0===r.id)return[ss({id:e,message:"ID is not defined in resource."})];const a=[is({entities:n}),as({mapping:i})];return r.id!==e&&(a.push(os({id:e,type:r.type})),a.push(cs({requestId:e,actualId:r.id}))),a.push(ls({id:e})),a};function ds(e="vault://homepage-collection.json"){const t=new l.Vault,n=window.localStorage.getItem("preview-vault-collection");let r=!1;if(n)try{const i=JSON.parse(n);if(i.id&&i.id===e){t.dispatch(_r({id:i.id}));const e=us(i.id,i);t.dispatch(Or({actions:e})),r=!0}}catch(i){}if(!r){const n=us(e,{"@context":"http://iiif.io/api/presentation/3/context.json",id:e,type:"Collection",label:{en:["Recent items"]},items:[]});t.dispatch(_r({id:e})),t.dispatch(Or({actions:n}))}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"})))});return{vault:t,unsubscribe:()=>{},addHistory:(n,r)=>{const i=t.getState();if(n&&r&&("Collection"===r||"Manifest"===r)){const o=i.iiif.entities.Collection[e];if(o){const i=o.items.findIndex(e=>e.id===n);-1===i?t.dispatch(Pr({id:e,type:"Collection",reference:{id:n,type:r},key:"items",index:0})):t.dispatch(kr({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(Cr({id:e,type:"Collection",key:"items",value:[]})),window.localStorage.setItem("preview-vault-collection",JSON.stringify(t.toPresentation3({id:e,type:"Collection"})))}}}function ps(){return n.useContext(fs)}const fs=n.createContext(new l.Vault),hs=n.createContext({addHistory:(e,t)=>{},clearHistory:()=>{}});function ms(e){const{vault:t,unsubscribe:r,addHistory:i,clearHistory:o}=n.useMemo(()=>ds("manifest-editor://homepage-collection.json"),[]);return n.useEffect(()=>r,[]),S(hs.Provider,{value:{addHistory:i,clearHistory:o},children:S(fs.Provider,{value:t,children:e.children})})}const gs=n.createContext({resource:null});function vs(){return n.useContext(gs)}function ys(e,t){return"string"==typeof e?{id:e,state:t}:e}const bs=n.memo((function(e){const[t,r]=n.useState({loading:!0,centerPanels:[],leftPanels:[],rightPanels:[]}),[i,a]=n.useReducer(da,void 0,fa),s={setAvailable:r,centerPanel:ha("centerPanel",a),leftPanel:ha("leftPanel",a),rightPanel:ha("rightPanel",a),pinnedRightPanel:ha("pinnedRightPanel",a),editingStack:qi()};function c(e){const n=t.rightPanels.find(t=>t.id===e);if(n)return[n,s.rightPanel,s.pinnedRightPanel];const r=t.centerPanels.find(t=>t.id===e);if(r)return[r,s.centerPanel];const i=t.leftPanels.find(t=>t.id===e);if(i)return[i,s.leftPanel];j(!1)}const l={open:function(e,t){var n;const{id:r,state:i,stacked:o}=ys(e,t),[a,s,l]=c(r);l&&(null==(n=a.options)?void 0:n.openPinned)?l.pin({id:r,state:{...a.defaultState||{},...i||{}}}):s.open({id:r,state:{...a.defaultState||{},...i||{}},stacked:o})},change:function(e,t){const{id:n,state:r,stacked:i}=ys(e,t),[o,a]=c(n);a.change({id:n,state:{...o.defaultState||{},...r||{}},stacked:i})},close:function(e,t){const{id:n}=ys(e,t),[,r]=c(n);r.close()},toggle:function(e,t){const{id:n}=ys(e,t),[,r]=c(n);r.toggle()},stack:function(e,t){const{id:n,state:r}=ys(e,t),[i,o]=c(n);o.open({id:n,state:{...i.defaultState||{},...r||{}},stacked:!0})},edit:function(e,n={},{reset:r,property:i,stacked:a}={}){const c={resource:o.isSpecificResource(e)?e:{type:"SpecificResource",source:e},...n};s.editingStack.edit(c,r),t.rightPanels.find(e=>"@manifest-editor/editor"===e.id)&&s.rightPanel.open({id:"@manifest-editor/editor",stacked:!1!==a,state:{property:i},unique:!0})},create:function(e){s.editingStack.create(e,{}),t.rightPanels.find(e=>"@manifest-editor/creator"===e.id)&&s.rightPanel.open({id:"@manifest-editor/creator",stacked:!0,unique:!0,state:e})}};return S(Ji.Provider,{value:t,children:S(Yi.Provider,{value:n.useMemo(()=>({...s,...l}),[t]),children:S(Gi.Provider,{value:i,children:e.children})})})}));var ws;function xs(){return navigator.appVersion.includes("Win")}!function(e){e[e.Audio=1]="Audio",e[e.Cache=2]="Cache",e[e.Config=3]="Config",e[e.Data=4]="Data",e[e.LocalData=5]="LocalData",e[e.Desktop=6]="Desktop",e[e.Document=7]="Document",e[e.Download=8]="Download",e[e.Executable=9]="Executable",e[e.Font=10]="Font",e[e.Home=11]="Home",e[e.Picture=12]="Picture",e[e.Public=13]="Public",e[e.Runtime=14]="Runtime",e[e.Template=15]="Template",e[e.Video=16]="Video",e[e.Resource=17]="Resource",e[e.App=18]="App",e[e.Log=19]="Log",e[e.Temp=20]="Temp"}(ws||(ws={})),xs(),xs();const Cs=Ot((function(e,t){var n,r;if(e.current)switch(t.type){case"removePublication":e.current.publications=e.current.publications.filter(e=>e.id!==t.payload);break;case"saveProject":e.current.metadata.modified=Date.now();break;case"updateDetails":e.current.name=t.payload.name,e.current.filename=t.payload.filename;break;case"updateStorage":e.current.storage=t.payload;break;case"createPublication":e.current.publications.find(e=>e.id===t.payload.id)||e.current.publications.push(t.payload);break;case"updateThumbnail":e.current.thumbnail=t.payload;break;case"updateSettings":e.current.settings=t.payload;break;case"updatePublication":{const n=e.current.publications.find(e=>e.id===t.payload.id);n&&(n.config=t.payload.config);break}case"removePreview":{const r=null==(n=e.current.previews)?void 0:n.findIndex(e=>e.id===t.payload);-1!==r&&e.current.previews.splice(r,1);break}case"setPreview":{const n=null==(r=e.current.previews)?void 0:r.findIndex(e=>e.id===t.payload.id);-1!==n?e.current.previews.splice(n,1,t.payload):e.current.previews.push(t.payload);break}}switch(t.type){case"load":e.allProjects=t.payload.allProjects,e.current=t.payload.current,e.loadingStatus=t.payload.loadingStatus;break;case"forkProject":break;case"deleteProject":e.allProjects=e.allProjects.filter(e=>e.id!==t.payload),e.current&&e.current.id===t.payload&&(e.current=null);break;case"deselectProject":e.current=null;break;case"createProject":e.allProjects.push(t.payload),e.current=t.payload;break;case"switchProject":e.current=e.allProjects.find(e=>e.id===t.payload)||null;break;case"setLoadingStatus":e.loadingStatus=t.payload}}));function ks(e={loading:!1,loaded:!0,lastLoaded:0}){return{allProjects:[],current:null,loadingStatus:e}}function Ps(e){var t,r,i,o;const{currentApp:s,changeApp:c,apps:l}=J();s&&l[s.id];const u=n.useMemo(()=>e.backend||new es,[]),d=n.useMemo(()=>e.storage||new ns,[]),[p,f]=n.useReducer(Cs,void 0,e.initialState||ks),h=Ya(f,u,d),m=n.useMemo(()=>({actions:h,canDelete:u.canDelete(),...p}),[h,u,p]),{vault:g,ready:v,error:y}=Za(m,d),b=null==(t=m.current)?void 0:t.resource,w=n.useMemo(()=>({isLoading:!v,isError:!!y,error:y}),[v,y]);return Ga(m,u),n.useEffect(()=>{!(p.loadingStatus&&p.loadingStatus.loaded&&v)||g&&b||(null==s?void 0:s.id)===(e.defaultApp||"splash")||c({id:e.defaultApp||"splash"})},[]),p.loadingStatus&&p.loadingStatus.loading||m.current&&!b?S("div",{children:"Loading..."}):"Manifest"===(null==b?void 0:b.type)?S(O.Provider,{value:w,children:S(_.Provider,{value:m,children:S(a.VaultProvider,{vault:g||void 0,children:S(a.ManifestContext,{manifest:(null==b?void 0:b.id)||"",children:e.children})},null==(r=p.current)?void 0:r.id)})}):"Collection"===(null==b?void 0:b.type)?S(O.Provider,{value:w,children:S(_.Provider,{value:m,children:S(a.VaultProvider,{vault:g||void 0,children:S(a.CollectionContext,{collection:(null==b?void 0:b.id)||"",children:e.children})},null==(i=p.current)?void 0:i.id)})}):S(O.Provider,{value:w,children:S(_.Provider,{value:m,children:S(a.VaultProvider,{vault:g||void 0,children:e.children},null==(o=p.current)?void 0:o.id)})})}const As=n.createContext(null);function Ss({children:e,ignoreQueryString:t}){const[r,i]=n.useState("manifest"),[o,a]=n.useState(0),[s,c]=n.useState(!1),[l,u]=n.useState("grid"),{createProjectFromManifestId:d}=Ka(),p=(e,t)=>{i(e),(t||0===t)&&a(t)};n.useEffect(()=>{if(!t){const e=D.parse(window.location.hash.slice(1));if(e&&e.manifest&&"string"==typeof e.manifest)return void d(e.manifest).then(()=>{window.location.hash=""})}},[]);const[f,h]=n.useState({w:128,h:128}),m=n.useMemo(()=>({selectedProperty:r,view:l,selectedPanel:o,addCanvasModalOpen:s,thumbnailSize:f,languages:[],behaviorProperties:[],changeSelectedProperty:p,setView:u,setAddCanvasModalOpen:c,setThumbnailSize:h}),[s,o,r,f,l]);return S(As.Provider,{value:m,children:e})}const Is={color:{main:"#347cff",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"}};class Ms extends n.Component{constructor(){super(...arguments),t(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?S("h1",{children:"Sorry.. there was an error"}):this.props.children}}const Es=[{id:"universal-viewer",config:{url:"https://uv-v4.netlify.app/#?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:"iiif-preview",config:{url:"https://iiif-preview.digirati.services/store"},type:"iiif-preview-service",label:"IIIF Preview"}],Rs={},js=n.createContext("global");function _s(e){const t=n.useContext(js),[,i]=n.useReducer(e=>e+1,0),o=n.useMemo(()=>(Rs[t]||(Rs[t]={}),Rs[t][e]||(Rs[t][e]={name:e,emitter:r(),status:"idle",promise:Promise.resolve(),abort:new AbortController,reject:()=>{},resolve:()=>{}}),Rs[t][e]),[t,e]);return Os(o,"abort",i),Os(o,"error",i),Os(o,"complete",i),Os(o,"running",i),o}function Os(e,t,r){const i=n.useCallback(()=>r(e),[r]);n.useEffect(()=>{const n=e.emitter;return n.on(t,i),()=>n.off(t,i)},[t,i,e.emitter])}const Ts=()=>{};async function Ns(e,...t){if(!e)return;if(e.endsWith(".mp3")||e.endsWith(".mp4")||e.endsWith(".m4a")||e.endsWith(".m4v"))try{const t=await(async e=>new Promise((t,n)=>{const r=document.createElement("video");r.onloadedmetadata=()=>t(r),r.onerror=()=>n(),r.preload="metadata",r.src=e}))(e);if(t){const n=0===t.videoWidth;return{id:e,type:0===t.videoWidth?"Sound":"Video",width:t.videoWidth||void 0,height:t.videoHeight||void 0,duration:t.duration,format:n?"audio/mp4":"video/mp4"}}}catch(o){}let n=null;try{await fetch(e,{method:"HEAD"}),n=await fetch(e)}catch{return Ls(e)}if(!n.ok&&(n=await fetch(e+"/info.json"),!n.ok))return Ls(e);const r=n.headers.get("Content-Type");if(null==r?void 0:r.includes("image/"))return Ls(e,r);let i=null;try{i=await n.json()}catch{return null}return await Ds(i,e)}async function Ds(e,t){const n=function(e){return e.protocol&&"http://iiif.io/api/image"===e.protocol?(e.type||(e.type="ImageService"),e):null}(e);if(n)return n;if(!(e.id||e["@id"]))return null;const r=new f.Vault,i=await r.load(t,e);return i&&(i&&"Manifest"===(null==i?void 0:i.type)||"Collection"===(null==i?void 0:i.type))?{id:t,type:i.type,label:fn(i.label)}:void 0}async function Ls(e,t){var n;const r=e.split("/");if(r.length>=8){const e=r.slice(-4);if(2===e[3].split(".").length&&("!"===e[2][0]||e[2]==e[2])){const e=r.slice(0,r.length-4).join("/")+"/info.json",t=await async function(e){try{const t=await fetch(e);if(t.ok){const n=await t.json();return await Ds(n,e)}return null}catch(t){return console.log(t),null}}(e);if(t&&(null==t?void 0:t.type)&&(null==(n=null==t?void 0:t.type)?void 0:n.startsWith("ImageService")))return t}}try{const n=await(async e=>new Promise((t,n)=>{const r=document.createElement("img");r.onload=()=>t(r),r.onerror=()=>n(),r.src=e,r.complete&&t(r)}))(e);return{id:e,type:"Image",width:n.width,height:n.height,format:await zs(e,t)}}catch{}return null}async function zs(e,t){if(t)return t;try{const t=(await fetch(e,{method:"HEAD",mode:"no-cors"})).headers.get("Content-type");if(t)return t}catch(r){}const n=e.toLowerCase();return n.endsWith("jpg")||n.endsWith("jpeg")?"image/jpeg":n.endsWith("png")?"image/png":"image/jpeg"}exports.AbstractVaultLoader=ts,exports.AppHeader=pr,exports.AppProvider=Z,exports.AppStateProvider=function(e){const{current:t}=N(),[r,i,o]=E("app-state/"+(null==t?void 0:t.id),e.initialValue||{}),a=n.useCallback(e=>{const t=o.current?JSON.parse(o.current||"{}"):{},n=("function"==typeof e?e(t):e)||{};i({...t,...n})},[]);n.useEffect(()=>{e.args&&a(e.args)},[e.appId]);const s=n.useMemo(()=>({state:r||{},setState:a}),[a,r]);return S(V.Provider,{value:s,children:e.children})},exports.ConfigProvider=mr,exports.DesktopContext=function({children:e}){return S(A,{children:e})},exports.EditingStack=Vi,exports.HOMEPAGE_COLLECTION="manifest-editor://homepage-collection.json",exports.HandleContainer=Vo,exports.HandleControls=Qo,exports.Layout=ca,exports.LayoutActionsReactContext=Yi,exports.LayoutPropsReactContext=Ji,exports.LayoutStateReactContext=Gi,exports.LocalStorageBackend=es,exports.LocalStorageLoader=ns,exports.ModularPanel=To,exports.ModularPanelHeader=Eo,exports.ModulePanelButton=Ro,exports.PanelError=Co,exports.PreviewProvider=Lt,exports.PreviewVaultBoundary=function({children:e}){const t=ps();return S(a.VaultProvider,{vault:t,children:e})},exports.PreviewVaultContext=ms,exports.ProjectLoadingReactContext=O,exports.ProjectReactContext=_,exports.ResourceEditingProvider=function({resource:e,children:t}){const{id:r,type:i}=e||{};return S(gs.Provider,{value:n.useMemo(()=>({resource:r&&i?{id:r,type:i}:null}),[r,i]),children:t})},exports.ShellProvider=({config:e,children:t,theme:n,saveCurrentApp:r,apps:o,initialApp:a,project:s})=>S(Ms,{children:S(ms,{children:S(i.ThemeProvider,{theme:n||Is,children:S(mr,{config:e,children:S(Z,{apps:o.allApps,initialApp:a,saveCurrentApp:r,children:S(Ps,{...s||{},children:S(Vi,{children:S(bs,{children:S(Lt,{configs:(null==e?void 0:e.previews)||Es,children:S(Ss,{children:t})})})})})})})})})}),exports.TaskBridge=function({children:e}){return S(js.Provider,{value:n.useMemo(()=>"id-"+Date.now(),[]),children:e})},exports.UniversalCopyTarget=function({as:e,reference:t,onReference:r,onLink:i,onAnalysis:o,onDropReference:a,onDropLink:s,onDropAnalysis:c,onPasteReference:l,onPasteLink:u,onPasteAnalysis:d,...p}){const f=e||"div",h=a||r,m=l||r,g=u||i,v=d||o,y=n.useMemo(()=>t,[null==t?void 0:t.id,null==t?void 0:t.type]),b=n.useCallback((function(e){e.defaultPrevented||(e.preventDefault(),e.clipboardData&&y&&y.id&&y.type&&e.clipboardData.setData("application/json+vault",JSON.stringify({id:y.id,type:y.type})))}),[y]),w=n.useCallback((async function(e){if(!e.defaultPrevented&&(e.preventDefault(),e.clipboardData)){if(p.onLoading&&p.onLoading(),m){const n=e.clipboardData.getData("application/json+vault");if(n)try{const e=JSON.parse(n);e&&e.id&&e.type&&m(e)}catch(t){}}if(g||v){const n=e.clipboardData.getData("text");if(n.startsWith("http")){const e=n.split("\n");for(const n of e){if(v)try{const e=await Ns(n);if(e){v(e);continue}}catch(t){}g&&g(n)}}}p.onComplete&&p.onComplete()}}),[]),x=n.useCallback((function(e){e.defaultPrevented||(e.preventDefault(),e.dataTransfer&&p.draggable&&(e.dataTransfer.effectAllowed="all",y&&y.id&&y.type&&e.dataTransfer.setData("application/json+vault",JSON.stringify({id:y.id,type:y.type}))))}),[]),C=n.useCallback((async function(e){if(e.preventDefault(),e.dataTransfer){if(h){const n=e.dataTransfer.getData("application/json+vault");if(n)try{const t=JSON.parse(n);t&&t.id&&t.type&&h(t,e)}catch(t){return}}const n=e.dataTransfer.getData("application/json");if(n)return void JSON.parse(n);const r=e.dataTransfer.getData("text/plain");if(r)return void console.log("link",r)}}),[]),k=n.useCallback(e=>{e.preventDefault(),e.dataTransfer&&(e.dataTransfer.dropEffect="copy")},[]);return S(f,{onCopy:b,onPaste:w,onDrop:C,onDragOver:k,onDragStart:x,tabIndex:-1,...p})},exports.WebsocketLoader=class extends ts{constructor(e){super({saveInterval:5e3}),t(this,"type","websocket-storage"),t(this,"baseUrl"),t(this,"token"),this.baseUrl=e.baseUrl,this.token=e.token}getStorage(e){throw new Error("Method not implemented.")}shouldUpdateWithVault(){return!0}async create(e,t){throw new Error("Cannot create new project from Manifest Editor")}canCreate(){return!1}canDelete(){return!1}createVaultInstance(e){const t=new c.ClientVault(`${this.baseUrl}/vault/${e.storage.data.id}?token=${this.token}`);return[t,t.waitUntilReady()]}closeVaultInstance(e,t){t instanceof c.ClientVault&&t.ws.close()}async saveStorageData(e,t){}async deleteStorage(e){throw new Error("Cannot delete")}getBackendStorage(e){return e.storage}},exports.createPreviewVault=ds,exports.ensureUniqueFilename=Va,exports.getDefaultLayoutState=fa,exports.getDefaultPanelState=pa,exports.isPinnableState=ko,exports.layoutReducer=da,exports.panelSizing=Po,exports.projectFromCollection=Ja,exports.projectFromManifest=va,exports.renderHelper=Ao,exports.useAnnotationPageEditor=function(){const{annotationPage:e}=a.useResourceContext();return j(e),Hi({id:e,type:"AnnotationPage"})},exports.useAppState=Y,exports.useApps=J,exports.useAvailableLayouts=function(){return n.useContext(Ji)},exports.useCollectionEditor=function(){const{collection:e}=a.useResourceContext(),t=a.useVault(),[r,i]=n.useReducer(e=>e+1,0);j(e);const o=n.useMemo(()=>new Fi({reference:{id:e,type:"Collection"},vault:t}),[e,t]);return n.useEffect(()=>o.observe.start(i),[o]),o.observe.key=""+r,o.observe.reset(),o},exports.useConfig=hr,exports.useCreatingResource=function(){return n.useContext(Bi).create},exports.useCurrentProject=function(){const e=N().current;return j(e),e},exports.useEditingContext=vs,exports.useEditingResource=Ui,exports.useEditingResourceStack=function(){return n.useContext(Bi).stack},exports.useEditingStack=qi,exports.useEditor=function(){const e=Ui(),t=a.useVault(),[r,i]=n.useReducer(e=>e+1,0);j(e);const o=n.useMemo(()=>new Fi({reference:e.resource.source||e.resource,vault:t}),[e,t]);return n.useEffect(()=>o.observe.start(i),[o]),o.observe.key=""+r,o.observe.reset(),o},exports.useGenericEditor=Hi,exports.useIsDesktop=function(){return!1},exports.useLayoutActions=Zi,exports.useLayoutProvider=Ki,exports.useLayoutState=function(){return n.useContext(Gi)},exports.useManifestEditor=function(){const{manifest:e}=a.useResourceContext(),t=a.useVault(),[r,i]=n.useReducer(e=>e+1,0);j(e);const o=n.useMemo(()=>new Fi({reference:{id:e,type:"Manifest"},vault:t}),[e,t]);return n.useEffect(()=>o.observe.start(i),[o]),o.observe.key=""+r,o.observe.reset(),o},exports.useOptionalResource=function(){const{resource:e}=vs();return e},exports.usePanelActions=ha,exports.usePreviewContext=zt,exports.usePreviewHistory=function(){return n.useContext(hs)},exports.usePreviewVault=ps,exports.useProjectActionsWithBackend=Ya,exports.useProjectBackend=Ga,exports.useProjectContext=N,exports.useProjectCreators=Ka,exports.useProjectLoader=Za,exports.useProjectLoading=T,exports.useResource=function(){const e=a.useVault(),{resource:t}=vs();j(t);const{id:n,type:r}=t;return a.useVaultSelector(()=>e.get({id:n,type:r}),[n,r])},exports.useSetCustomTitle=function(){return n.useContext(Io)},exports.useTask=_s,exports.useTaskDispatch=function(e,t){const n=_s(e);return Os(n,"complete",t||Ts),[e=>{"running"===n.status&&(n.abort.abort(),n.emitter.emit("abort")),n.error&&(n.error="");const t=function(){let e=void 0,t=void 0;return{promise:new Promise((n,r)=>{e=n,t=r}),resolve:e,reject:t}}();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]},exports.useTaskEvent=Os,exports.useTaskRunner=function(e,t){const n=_s(e);return Os(n,"running",t),[e=>{"running"===n.status&&(n.response=e,n.status="complete",n.resolve())},n,(e,t)=>{"running"===n.status&&(n.error=t||e,n.status="error",n.reject(e))}]};
|
|
33
|
-
//# sourceMappingURL=index.cjs.map
|