@triiiceratops/plugin-image-export 1.0.0-rc.0 → 1.0.0-rc.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/dist/iife.js CHANGED
@@ -2,7 +2,7 @@
2
2
  \r\f \v\uFEFF`];function yo(n,o,e){var t=n==null?"":""+n;if(o&&(t=t?t+" "+o:o),e){for(var r in e)if(e[r])t=t?t+" "+r:r;else if(t.length)for(var i=r.length,s=0;(s=t.indexOf(r,s))>=0;){var l=s+i;(s===0||sn.includes(t[s-1]))&&(l===t.length||sn.includes(t[l]))?t=(s===0?"":t.substring(0,s))+t.substring(l+1):s=l}}return t===""?null:t}function on(n,o=!1){var e=o?" !important;":";",t="";for(var r in n){var i=n[r];i!=null&&i!==""&&(t+=" "+r+": "+i+e)}return t}function Gi(n){return n[0]!=="-"||n[1]!=="-"?n.toLowerCase():n}function _o(n,o){if(o){var e="",t,r;if(Array.isArray(o)?(t=o[0],r=o[1]):t=o,n){n=String(n).replaceAll(/\s*\/\*.*?\*\/\s*/g,"").trim();var i=!1,s=0,l=!1,a=[];t&&a.push(...Object.keys(t).map(Gi)),r&&a.push(...Object.keys(r).map(Gi));var u=0,h=-1;const y=n.length;for(var c=0;c<y;c++){var d=n[c];if(l?d==="/"&&n[c-1]==="*"&&(l=!1):i?i===d&&(i=!1):d==="/"&&n[c+1]==="*"?l=!0:d==='"'||d==="'"?i=d:d==="("?s++:d===")"&&s--,!l&&i===!1&&s===0){if(d===":"&&h===-1)h=c;else if(d===";"||c===y-1){if(h!==-1){var m=Gi(n.substring(u,h).trim());if(!a.includes(m)){d!==";"&&c++;var v=n.substring(u,c).trim();e+=" "+v+";"}}u=c+1,h=-1}}}}return t&&(e+=on(t)),r&&(e+=on(r,!0)),e=e.trim(),e===""?null:e}return n==null?null:String(n)}function $t(n,o,e,t,r,i){var s=n.__className;if(s!==e||s===void 0){var l=yo(e,t,i);l==null?n.removeAttribute("class"):o?n.className=l:n.setAttribute("class",l),n.__className=e}else if(i&&r!==i)for(var a in i){var u=!!i[a];(r==null||u!==!!r[a])&&n.classList.toggle(a,u)}return i}function qi(n,o={},e,t){for(var r in e){var i=e[r];o[r]!==i&&(e[r]==null?n.style.removeProperty(r):n.style.setProperty(r,i,t))}}function Zi(n,o,e,t){var r=n.__style;if(r!==o){var i=_o(o,t);i==null?n.removeAttribute("style"):n.style.cssText=i,n.__style=o}else t&&(Array.isArray(t)?(qi(n,e?.[0],t[0]),qi(n,e?.[1],t[1],"important")):qi(n,e,t));return t}function mi(n,o,e=!1){if(n.multiple){if(o==null)return;if(!Ri(o))return ys();for(var t of n.options)t.selected=o.includes(ei(t));return}for(t of n.options){var r=ei(t);if(zs(r,o)){t.selected=!0;return}}(!e||o!==void 0)&&(n.selectedIndex=-1)}function an(n){var o=new MutationObserver(()=>{mi(n,n.__value)});o.observe(n,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["value"]}),Ir(()=>{o.disconnect()})}function To(n,o,e=o){var t=new WeakSet,r=!0;Vs(n,"change",i=>{var s=i?"[selected]":":checked",l;if(n.multiple)l=[].map.call(n.querySelectorAll(s),ei);else{var a=n.querySelector(s)??n.querySelector("option:not([disabled])");l=a&&ei(a)}e(l),ae!==null&&t.add(ae)}),Zt(()=>{var i=o();if(n===document.activeElement){var s=oi??ae;if(t.has(s))return}if(mi(n,i,r),r&&i===void 0){var l=n.querySelector(":checked");l!==null&&(i=ei(l),e(i))}n.__value=i,r=!1}),an(n)}function ei(n){return"__value"in n?n.__value:n.value}const Mt=Symbol("class"),ti=Symbol("style"),ln=Symbol("is custom element"),un=Symbol("is html");function xo(n,o){o?n.hasAttribute("selected")||n.setAttribute("selected",""):n.removeAttribute("selected")}function Ze(n,o,e,t){var r=cn(n);r[o]!==(r[o]=e)&&(o==="loading"&&(n[Yn]=e),e==null?n.removeAttribute(o):typeof e!="string"&&fn(n).includes(o)?n[o]=e:n.setAttribute(o,e))}function Eo(n,o,e,t,r=!1,i=!1){var s=cn(n),l=s[ln],a=!s[un],u=o||{},h=n.tagName==="OPTION";for(var c in o)c in e||(e[c]=null);e.class?e.class=wo(e.class):(t||e[Mt])&&(e.class=null),e[ti]&&(e.style??=null);var d=fn(n);for(const P in e){let L=e[P];if(h&&P==="value"&&L==null){n.value=n.__value="",u[P]=L;continue}if(P==="class"){var m=n.namespaceURI==="http://www.w3.org/1999/xhtml";$t(n,m,L,t,o?.[Mt],e[Mt]),u[P]=L,u[Mt]=e[Mt];continue}if(P==="style"){Zi(n,L,o?.[ti],e[ti]),u[P]=L,u[ti]=e[ti];continue}var v=u[P];if(!(L===v&&!(L===void 0&&n.hasAttribute(P)))){u[P]=L;var y=P[0]+P[1];if(y!=="$$")if(y==="on"){const F={},H="$$"+P;let B=P.slice(2);var _=to(B);if($s(B)&&(B=B.slice(0,-7),F.capture=!0),!_&&v){if(L!=null)continue;n.removeEventListener(B,u[H],F),u[H]=null}if(L!=null)if(_)n[`__${B}`]=L,Qr([B]);else{let V=function(Y){u[P].call(this,Y)};u[H]=oo(B,n,V,F)}else _&&(n[`__${B}`]=void 0)}else if(P==="style")Ze(n,P,L);else if(P==="autofocus")Us(n,!!L);else if(!l&&(P==="__value"||P==="value"&&L!=null))n.value=n.__value=L;else if(P==="selected"&&h)xo(n,L);else{var E=P;a||(E=ro(E));var S=E==="defaultValue"||E==="defaultChecked";if(L==null&&!l&&!S)if(s[P]=null,E==="value"||E==="checked"){let F=n;const H=o===void 0;if(E==="value"){let B=F.defaultValue;F.removeAttribute(E),F.defaultValue=B,F.value=F.__value=H?B:null}else{let B=F.defaultChecked;F.removeAttribute(E),F.defaultChecked=B,F.checked=H?B:!1}}else n.removeAttribute(P);else S||d.includes(E)&&(l||typeof L!="string")?(n[E]=L,E in s&&(s[E]=be)):typeof L!="function"&&Ze(n,E,L)}}}return u}function hn(n,o,e=[],t=[],r=[],i,s=!1,l=!1){vr(r,e,t,a=>{var u=void 0,h={},c=n.nodeName==="SELECT",d=!1;if(Lr(()=>{var v=o(...a.map(b)),y=Eo(n,u,v,i,s,l);d&&c&&"value"in v&&mi(n,v.value);for(let E of Object.getOwnPropertySymbols(h))v[E]||Pe(h[E]);for(let E of Object.getOwnPropertySymbols(v)){var _=v[E];E.description===ws&&(!u||_!==u[E])&&(h[E]&&Pe(h[E]),h[E]=Oe(()=>mo(n,()=>_))),y[E]=_}u=y}),c){var m=n;Zt(()=>{mi(m,u.value,!0),an(m)})}d=!0})}function cn(n){return n.__attributes??={[ln]:n.nodeName.includes("-"),[un]:n.namespaceURI===vs}}var dn=new Map;function fn(n){var o=n.getAttribute("is")||n.nodeName,e=dn.get(o);if(e)return e;dn.set(o,e=[]);for(var t,r=n,i=Element.prototype;i!==r;){t=Vn(r);for(var s in t)t[s].set&&e.push(s);r=ir(r)}return e}function pn(n,o){return n===o||n?.[mt]===o}function vi(n={},o,e,t){return Zt(()=>{var r,i;return Fr(()=>{r=i,i=[],pi(()=>{n!==e(...i)&&(o(n,...i),r&&pn(e(...r),n)&&o(null,...r))})}),()=>{vt(()=>{i&&pn(e(...i),n)&&o(null,...i)})}}),n}let wi=!1;function bo(n){var o=wi;try{return wi=!1,[n(),wi]}finally{wi=o}}const So={get(n,o){if(!n.exclude.includes(o))return n.props[o]},set(n,o){return!1},getOwnPropertyDescriptor(n,o){if(!n.exclude.includes(o)&&o in n.props)return{enumerable:!0,configurable:!0,value:n.props[o]}},has(n,o){return n.exclude.includes(o)?!1:o in n.props},ownKeys(n){return Reflect.ownKeys(n.props).filter(o=>!n.exclude.includes(o))}};function gn(n,o,e){return new Proxy({props:n,exclude:o},So)}function Le(n,o,e,t){var r=(e&fs)!==0,i=(e&ps)!==0,s=t,l=!0,a=()=>(l&&(l=!1,s=i?pi(t):t),s),u;if(r){var h=mt in n||Xn in n;u=Rt(n,o)?.set??(h&&o in n?S=>n[o]=S:void 0)}var c,d=!1;r?[c,d]=bo(()=>n[o]):c=n[o],c===void 0&&t!==void 0&&(c=a(),u&&(is(),u(c)));var m;if(m=()=>{var S=n[o];return S===void 0?a():(l=!0,S)},(e&ds)===0)return m;if(u){var v=n.$$legacy;return(function(S,P){return arguments.length>0?((!P||v||d)&&u(P?m():S),S):m()})}var y=!1,_=((e&cs)!==0?li:wr)(()=>(y=!1,m()));r&&b(_);var E=ne;return(function(S,P){if(arguments.length>0){const L=P?b(_):r?lt(S):S;return G(_,L),y=!0,s!==void 0&&(s=L),S}return xt&&y||(E.f&tt)!==0?_.v:b(_)})}const Po=/^v?(\d+)\.(\d+)\.(\d+)(?:-([0-9A-Za-z-.]+))?(?:\+[0-9A-Za-z-.]+)?$/;function yi(n){const o=Po.exec(n.trim());if(!o)return null;const[,e,t,r,i]=o,s=i?i.split(".").map(l=>/^\d+$/.test(l)?Number(l):l):[];return{major:Number(e),minor:Number(t),patch:Number(r),prerelease:s}}function Ro(n,o){return n.major-o.major||n.minor-o.minor||n.patch-o.patch}function Co(n,o){if(n.prerelease.length===0&&o.prerelease.length===0)return 0;if(n.prerelease.length===0)return 1;if(o.prerelease.length===0)return-1;const e=Math.max(n.prerelease.length,o.prerelease.length);for(let t=0;t<e;t++){const r=n.prerelease[t],i=o.prerelease[t];if(r===void 0)return-1;if(i===void 0)return 1;if(r===i)continue;const s=typeof r=="number",l=typeof i=="number";return s&&l?r<i?-1:1:s?-1:l?1:String(r)<String(i)?-1:1}return 0}function Do(n,o){return Ro(n,o)||Co(n,o)}function Ao(n){return n.major>0?{major:n.major+1,minor:0,patch:0,prerelease:[]}:n.minor>0?{major:0,minor:n.minor+1,patch:0,prerelease:[]}:{major:0,minor:0,patch:n.patch+1,prerelease:[]}}function Io(n){if(n===""||n==="*"||n==="x"||n==="X")return[];let o;if(o=/^\^\s*(.+)$/.exec(n)){const e=yi(o[1]??"");return e?[{op:">=",ver:e},{op:"<",ver:Ao(e)}]:null}if(o=/^~\s*(.+)$/.exec(n)){const e=yi(o[1]??"");return e?[{op:">=",ver:e},{op:"<",ver:{major:e.major,minor:e.minor+1,patch:0,prerelease:[]}}]:null}if(o=/^(>=|<=|>|<|=)?\s*(.+)$/.exec(n)){const e=yi(o[2]??"");return e?[{op:o[1]??"=",ver:e}]:null}return null}function Oo(n,o){const e=Do(n,o.ver);switch(o.op){case"<":return e<0;case"<=":return e<=0;case">":return e>0;case">=":return e>=0;case"=":return e===0}}function Fo(n,o){const e=o.trim();if(e===""||e==="*"||e==="x")return!0;const t=e.split(/\s+/).filter(Boolean);for(const r of t){const i=Io(r);if(i===null||!i.every(s=>Oo(n,s)))return!1}return!0}function mn(n,o){const e=yi(n);if(!e)return!1;const t=o.split("||").map(r=>r.trim()).filter(r=>r.length>0);return t.length===0?!0:t.some(r=>Fo(e,r))}class Xi extends Error{code="PLUGIN_INCOMPATIBLE";pluginName;pluginVersion;reasons;constructor(o,e,t){super(Lo(o,e,t)),this.name="PluginCompatibilityError",this.pluginName=o,this.pluginVersion=e,this.reasons=t,Object.setPrototypeOf(this,Xi.prototype)}}function Lo(n,o,e){const t=e.map(r=>` - ${r.message}`).join(`
3
3
  `);return`Plugin "${n}"@${o} cannot activate — incompatible with this viewer:
4
4
  ${t}
5
- Update the plugin or the core viewer so their declared ranges and capabilities overlap.`}function Mo(n,o){const e=[];mn(o.coreVersion,n.coreRange)||e.push({kind:"core",required:n.coreRange,actual:o.coreVersion,message:`requires core ${n.coreRange} but this viewer is core ${o.coreVersion}`}),mn(o.pluginApiVersion,n.pluginApiRange)||e.push({kind:"pluginApi",required:n.pluginApiRange,actual:o.pluginApiVersion,message:`requires plugin API ${n.pluginApiRange} but this viewer provides plugin API ${o.pluginApiVersion}`});const t=new Set(o.capabilities);for(const r of n.requiredCapabilities)t.has(r)||e.push({kind:"capability",required:r,actual:o.capabilities.join(", ")||"(none)",message:`requires capability "${r}" which this viewer does not provide (has: ${o.capabilities.join(", ")||"none"})`});return e}function Bo(n,o){const e=Mo(n,o);if(e.length>0)throw new Xi(n.name,n.version,e)}function Ho(n,o={}){let e=0,t=!1;const r=new Set,i=n.subscribe(()=>{e++;for(const l of[...r])l()},o.onListenerError);return{selectors:{select(l,a=Object.is){let u=-1,h;const c=()=>(u!==e&&(h=l(n),u=e),h);return{get:c,subscribe(d){if(t)return()=>{};let m=c();const v=()=>{let y;try{y=c()}catch(_){o.onProjectionError?.(_);return}a(m,y)||(m=y,d(y))};return r.add(v),()=>{r.delete(v)}}}}},dispose(){t||(t=!0,r.clear(),i())}}}const Yi=()=>{};function zo(){return{install(n,o){return Yi}}}function ko(){return{current:"en",t(n,o){return n},subscribe(n){return Yi}}}function No(){return{renderIcon(n,o){return Yi}}}function Uo(n){const o=new Set;return{service:{install(e,t){const r=n.install(e,t);let i=!1;const s=()=>{i||(i=!0,o.delete(s),r())};return o.add(s),s}},releaseAll(){for(const e of[...o])e();o.clear()}}}function Wo(n){const o=new Set;return{service:{get current(){return n.current},t(e,t){return n.t(e,t)},subscribe(e){const t=n.subscribe(e);let r=!1;const i=()=>{r||(r=!0,o.delete(i),t())};return o.add(i),i}},releaseAll(){for(const e of[...o])e();o.clear()}}}const Vo={deactivate(){}};function jo(n,o){const e=o.reportError;let t,r,i,s;try{Bo(n,o),t=Ho(o.viewerState,{onProjectionError:e?d=>e({phase:"command",error:d}):void 0,onListenerError:e?d=>e({phase:"subscription",error:d}):void 0}),r=Uo(o.styles??zo()),i=Wo(o.locale??ko()),s={viewerState:o.viewerState,selectors:t.selectors,styles:r.service,locale:i.service,ui:o.ui??No()}}catch(d){if(t?.dispose(),r?.releaseAll(),i?.releaseAll(),e)return e({phase:"setup",error:d}),Vo;throw d}const l=[],a=r,u=i,h=t;try{const d=n.view.mount(o.container,s);typeof d=="function"&&l.push(d)}catch(d){if(!e)throw a.releaseAll(),u.releaseAll(),h.dispose(),d;e({phase:"mount",error:d})}l.push(()=>a.releaseAll()),l.push(()=>u.releaseAll()),l.push(()=>h.dispose());let c=!1;return{deactivate(){if(!c){c=!0;for(let d=l.length-1;d>=0;d--)try{l[d]?.()}catch(m){e?e({phase:"cleanup",error:m}):console.error(`[triiiceratops] Plugin "${n.name}" cleanup threw during deactivation; teardown continues.`,m)}l.length=0}}}}const Go="triiiceratops-plugin";function qo(n){const o={name:n.name,uiId:n.uiId,version:n.version,coreRange:n.coreRange,pluginApiRange:n.pluginApiRange,requiredCapabilities:n.requiredCapabilities??[],icon:n.icon,target:n.target??"panel",dismiss:n.dismiss,catalog:n.catalog,view:n.view};return{kind:Go,...o,activate(e){return jo(o,e)}}}class Zo extends Error{name="SvgIconError";constructor(o){super(`svgIcon: ${o}`)}}const Xo="0 0 24 24";function bt(n,o){if(!n)throw new Zo(o)}const Yo=/<svg\b[^>]*>/i;function Ko(n){bt(typeof n=="string","expected an SVG string.");const o=n.trim();bt(o.length>0,"received an empty string.");const e=Yo.exec(o);bt(e!==null,"the markup must contain an <svg> root element."),bt(!/<script[\s/>]/i.test(o),"<script> elements are not allowed in plugin icons."),bt(!/<foreignObject[\s/>]/i.test(o),"<foreignObject> is not allowed in plugin icons."),bt(!/\son[a-z]+\s*=/i.test(o),"on* event-handler attributes (e.g. onload, onclick) are not allowed in plugin icons.");for(const l of o.matchAll(/(?:xlink:)?href\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s"'>]+))/gi)){const a=(l[1]??l[2]??l[3]??"").trim();bt(a.startsWith("#"),`external href/xlink:href URLs are not allowed in plugin icons (found "${a}"); only internal "#id" references are.`)}const t=e[0],r=/\bviewBox\s*=\s*(?:"([^"]*)"|'([^']*)')/i.exec(t);let i=(r?.[1]??r?.[2])?.trim();if(!i){const l=/\bwidth\s*=\s*(?:"([^"]*)"|'([^']*)')/i.exec(t),a=/\bheight\s*=\s*(?:"([^"]*)"|'([^']*)')/i.exec(t),u=parseFloat(l?.[1]??l?.[2]??""),h=parseFloat(a?.[1]??a?.[2]??"");i=Number.isFinite(u)&&Number.isFinite(h)?`0 0 ${u} ${h}`:Xo}let s="";if(!/\/\s*>$/.test(t)){const l=e.index+t.length,a=o.lastIndexOf("</svg>");s=(a>=l?o.slice(l,a):o.slice(l)).trim()}return{kind:"svg",inner:s,viewBox:i}}function Qo(n,o){return{STYLES:n,STYLE_ID:o}}function Jo(n,o,e,t,r){const i={pluginName:o,pluginVersion:e,phase:"command",error:t,retry:r};n.dispatchEvent(new CustomEvent("pluginerror",{detail:i,bubbles:!0,composed:!0}))}const $o=".btn.svelte-kz0hjp{display:inline-flex;flex-wrap:nowrap;flex-shrink:0;justify-content:center;align-items:center;gap:.375rem;cursor:pointer;text-align:center;vertical-align:middle;user-select:none;-webkit-user-select:none;touch-action:manipulation;font-weight:600;height:var(--size);padding-inline:var(--btn-p);font-size:var(--fontsize, .875rem);color:var(--btn-fg);background-color:var(--btn-bg);border-width:var(--tri-border);border-style:solid;border-color:var(--btn-border);border-start-start-radius:var(--join-ss, var(--tri-radius-buttons));border-start-end-radius:var(--join-se, var(--tri-radius-buttons));border-end-end-radius:var(--join-ee, var(--tri-radius-buttons));border-end-start-radius:var(--join-es, var(--tri-radius-buttons));outline-offset:2px;outline-color:var(--btn-color, var(--tri-content));text-shadow:0 .5px oklch(100% 0 0 / calc(var(--tri-depth) * .15));box-shadow:0 .5px 0 .5px oklch(100% 0 0 / calc(var(--tri-depth) * 6%)) inset,var(--btn-shadow);transition-property:color,background-color,border-color,box-shadow;transition-duration:.2s;transition-timing-function:cubic-bezier(0,0,.2,1);--size: calc(var(--tri-size-field, .25rem) * 10);--btn-bg: var(--btn-color, var(--tri-toolbar-bg));--btn-fg: var(--tri-content);--btn-p: 1rem;--btn-border: color-mix( in oklab, var(--btn-bg), #000 calc(var(--tri-depth) * 5%) );--btn-shadow: 0 3px 2px -2px color-mix( in oklab, var(--btn-bg) calc(var(--tri-depth) * 30%), #0000 ), 0 4px 3px -2px color-mix( in oklab, var(--btn-bg) calc(var(--tri-depth) * 30%), #0000 )}@media(hover:hover){.btn.svelte-kz0hjp:hover{--btn-bg: color-mix( in oklab, var(--btn-color, var(--tri-toolbar-bg)), #000 7% )}}.btn.svelte-kz0hjp:focus-visible{isolation:isolate;outline-width:2px;outline-style:solid}.btn.svelte-kz0hjp:active:not(.active){--btn-bg: color-mix( in oklab, var(--btn-color, var(--tri-toolbar-bg)), #000 5% );--btn-border: color-mix( in oklab, var(--btn-color, var(--tri-toolbar-bg)), #000 7% );--btn-shadow: 0 0 0 0 oklch(0% 0 0 / 0), 0 0 0 0 oklch(0% 0 0 / 0);translate:0 .5px}.btn.active.svelte-kz0hjp{--btn-bg: color-mix( in oklab, var(--btn-color, var(--tri-toolbar-bg)), #000 7% )}.btn.svelte-kz0hjp:disabled,.btn[disabled].svelte-kz0hjp{pointer-events:none;--btn-border: #0000;--btn-fg: color-mix(in oklch, var(--tri-content) 20%, #0000)}.btn.svelte-kz0hjp:disabled:not(.ghost):not(.outline),.btn[disabled].svelte-kz0hjp:not(.ghost):not(.outline){background-color:color-mix(in oklab,var(--tri-content) 10%,transparent);box-shadow:none}.circle.svelte-kz0hjp{width:var(--size);height:var(--size);border-radius:3.40282e38px;padding-inline:0}.square.svelte-kz0hjp{width:var(--size);height:var(--size);padding-inline:0}.ghost.svelte-kz0hjp{--btn-bg: transparent;--btn-border: transparent;--btn-fg: var(--btn-color-text, var(--btn-color, var(--tri-content)));box-shadow:none;text-shadow:none}@media(hover:hover){.ghost.svelte-kz0hjp:hover{--btn-bg: color-mix(in oklab, var(--tri-content) 10%, transparent)}}.ghost.svelte-kz0hjp:active:not(.active),.ghost.active.svelte-kz0hjp{--btn-bg: color-mix(in oklab, var(--tri-content) 10%, transparent);--btn-border: transparent}.outline.svelte-kz0hjp:not(:hover):not(:active):not(:focus-visible):not(.active):not(:disabled):not([disabled]){--btn-bg: transparent;--btn-fg: var(--btn-color-text, var(--btn-color, var(--tri-content)));--btn-border: var(--btn-color, var(--tri-content));box-shadow:none;text-shadow:none}.select-wrapper.svelte-1h1ta11{display:inline-flex;width:clamp(3rem,20rem,100%);max-width:100%}.native-select.svelte-1h1ta11{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0 0 0 0);white-space:nowrap;border:0;pointer-events:none}.select.svelte-1h1ta11{border:var(--tri-border) solid var(--input-color);appearance:none;background-color:var(--tri-input-bg);vertical-align:middle;width:100%;height:var(--size);touch-action:manipulation;white-space:nowrap;box-shadow:0 1px color-mix(in oklab,var(--input-color) calc(var(--tri-depth) * 10%),#0000) inset,0 -1px oklch(100% 0 0 / calc(var(--tri-depth) * .1)) inset;--input-color: color-mix(in oklab, var(--tri-content) 20%, #0000);--size: calc(var(--tri-size-field, .25rem) * 10);background-image:linear-gradient(45deg,#0000 50%,currentColor 50%),linear-gradient(135deg,currentColor 50%,#0000 50%);background-position:calc(100% - 20px) calc(1px + 50%),calc(100% - 16.1px) calc(1px + 50%);background-repeat:no-repeat;background-size:4px 4px,4px 4px;border-start-start-radius:var(--join-ss, var(--tri-radius-buttons));border-start-end-radius:var(--join-se, var(--tri-radius-buttons));border-end-end-radius:var(--join-ee, var(--tri-radius-buttons));border-end-start-radius:var(--join-es, var(--tri-radius-buttons));align-items:center;gap:.375rem;padding-inline:.75rem 1.75rem;font-size:.875rem;display:inline-flex;position:relative;cursor:pointer;color:inherit;text-align:start}.select-label.svelte-1h1ta11{flex:1;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.select-label.placeholder.svelte-1h1ta11{color:color-mix(in oklab,var(--tri-content) 55%,transparent)}.select.svelte-1h1ta11:hover:not(:disabled){--input-color: color-mix(in oklab, var(--tri-content) 40%, #0000)}.select.svelte-1h1ta11:focus-visible,.select.open.svelte-1h1ta11{--input-color: var(--tri-content);box-shadow:0 1px color-mix(in oklab,var(--input-color) calc(var(--tri-depth) * 10%),#0000);outline:2px solid var(--input-color);outline-offset:2px;isolation:isolate;z-index:1}.select.svelte-1h1ta11:is(:where(.svelte-1h1ta11):disabled,[disabled]:where(.svelte-1h1ta11)){cursor:not-allowed;border-color:var(--tri-panel-bg);background-color:var(--tri-panel-bg);color:color-mix(in oklab,var(--tri-content) 40%,transparent)}.ghost.svelte-1h1ta11{box-shadow:none;background-color:#0000;border-color:#0000;transition:background-color .2s}.ghost.svelte-1h1ta11:hover:not(:disabled){background-color:color-mix(in oklab,var(--tri-content) 8%,transparent)}.ghost.svelte-1h1ta11:focus-visible,.ghost.open.svelte-1h1ta11{background-color:var(--tri-input-bg);color:var(--tri-content)}.listbox.svelte-1h1ta11{position:fixed;inset:auto;margin:0;padding:.1875rem;border:var(--tri-border) solid color-mix(in oklab,var(--tri-content) 20%,#0000);background-color:var(--tri-input-bg);color:var(--tri-content);border-radius:var(--tri-radius-buttons);box-shadow:0 8px 24px oklch(0 0 0 / calc(.12 + var(--tri-depth) * .06));max-height:16rem;overflow-y:auto;min-width:8rem;z-index:1}.listbox.svelte-1h1ta11:not(:popover-open){display:none}.option.svelte-1h1ta11{padding:.25rem .5rem;border-radius:calc(var(--tri-radius-buttons) * .6);cursor:pointer;font-size:.8125rem;line-height:1.3;white-space:nowrap;color:inherit}.option.active.svelte-1h1ta11{background-color:color-mix(in oklab,var(--tri-content) 12%,#0000)}.option.selected.svelte-1h1ta11{background-color:color-mix(in oklab,var(--tri-color-primary) 90%,#0000);color:var(--tri-color-primary-content)}.option.selected.active.svelte-1h1ta11{background-color:var(--tri-color-primary)}.option[aria-disabled=true].svelte-1h1ta11{opacity:.5;cursor:not-allowed;color:color-mix(in oklab,var(--tri-content) 55%,transparent)}\n",ea={en:{image_download_title:"Download Image",image_download_close:"Close Download Image",image_download_description:"Download the current canvas as an image.",image_download_mode:"What to download",image_download_mode_composite:"Composite canvas",image_download_mode_composite_hint:"Every image on the current canvas, composited together.",image_download_mode_single:"Single image",image_download_mode_single_hint:"One image from the current canvas.",image_download_mode_world:"Current view",image_download_mode_world_hint:"Everything currently laid out together in the viewer.",image_download_canvas:"Canvas",image_download_image:"Image",image_download_resolution:"Resolution",image_download_resolution_placeholder:"Select a resolution",image_download_downloading:"Downloading...",image_download_download:"Download",image_download_disabled_no_canvas:"Load a manifest to download an image.",image_download_disabled_no_resolution:"Select a resolution to download.",image_download_result_downloaded:"Downloaded {filename}.",image_download_error_failed:"Unable to download image. Check the browser console for details."},de:{image_download_title:"Bild herunterladen",image_download_close:"Bild-Download schließen",image_download_description:"Die aktuelle Leinwand als Bild herunterladen.",image_download_mode:"Was heruntergeladen werden soll",image_download_mode_composite:"Zusammengesetzte Leinwand",image_download_mode_composite_hint:"Alle Bilder der aktuellen Leinwand, zusammengesetzt.",image_download_mode_single:"Einzelbild",image_download_mode_single_hint:"Ein Bild von der aktuellen Leinwand.",image_download_mode_world:"Aktuelle Ansicht",image_download_mode_world_hint:"Alles, was aktuell zusammen im Viewer angezeigt wird.",image_download_canvas:"Leinwand",image_download_image:"Bild",image_download_resolution:"Auflösung",image_download_resolution_placeholder:"Auflösung auswählen",image_download_downloading:"Wird heruntergeladen...",image_download_download:"Herunterladen",image_download_disabled_no_canvas:"Laden Sie ein Manifest, um ein Bild herunterzuladen.",image_download_disabled_no_resolution:"Wählen Sie eine Auflösung zum Herunterladen aus.",image_download_result_downloaded:"{filename} heruntergeladen.",image_download_error_failed:"Bild kann nicht heruntergeladen werden. Details in der Browserkonsole."}},vn=Symbol("triiiceratops:plugin-image-download"),wn=Ko('<svg viewBox="0 0 256 256"><path d="M224,144v64a8,8,0,0,1-8,8H40a8,8,0,0,1-8-8V144a8,8,0,0,1,16,0v56H208V144a8,8,0,0,1,16,0Zm-101.66,5.66a8,8,0,0,0,11.32,0l40-40a8,8,0,0,0-11.32-11.32L136,124.69V32a8,8,0,0,0-16,0v92.69L93.66,98.34a8,8,0,0,0-11.32,11.32Z"/></svg>'),ta="5";typeof window<"u"&&((window.__svelte??={}).v??=new Set).add(ta);var ia=me("<button><!></button>");function ra(n,o){let e=Le(o,"variant",3,"default"),t=Le(o,"size",3,"md"),r=Le(o,"circle",3,!1),i=Le(o,"square",3,!1),s=Le(o,"ghost",3,!1),l=Le(o,"outline",3,!1),a=Le(o,"active",3,!1),u=Le(o,"class",3,""),h=Le(o,"style",3,""),c=gn(o,["$$slots","$$events","$$legacy","variant","size","circle","square","ghost","outline","active","class","style","children"]);const d={default:"",primary:"--btn-color:var(--tri-color-primary);--btn-color-text:var(--tri-color-primary-text);--btn-fg:var(--tri-color-primary-content);",neutral:"--btn-color:var(--tri-color-neutral);--btn-fg:var(--tri-color-neutral-content);",success:"--btn-color:var(--tri-color-success);--btn-fg:var(--tri-color-success-content);",warning:"--btn-color:var(--tri-color-warning);--btn-fg:var(--tri-color-warning-content);",error:"--btn-color:var(--tri-color-error);--btn-fg:var(--tri-color-error-content);"},m={xs:"--fontsize:0.6875rem;--btn-p:0.5rem;--size:calc(var(--tri-size-field,0.25rem)*6);",sm:"--fontsize:0.75rem;--btn-p:0.75rem;--size:calc(var(--tri-size-field,0.25rem)*8);",md:"--fontsize:0.875rem;--btn-p:1rem;--size:calc(var(--tri-size-field,0.25rem)*10);",lg:"--fontsize:1.125rem;--btn-p:1.25rem;--size:calc(var(--tri-size-field,0.25rem)*12);"};let v=le(()=>`${m[t()]}${d[e()]}${h()}`);var y=ia();hn(y,()=>({class:`btn ${u()??""}`,style:b(v),...c,[Mt]:{circle:r(),square:i(),ghost:s(),outline:l(),active:a()}}),void 0,void 0,void 0,"svelte-kz0hjp");var _=$(y);rn(_,()=>o.children??nr),ge(n,y)}let na=0;var sa=me('<div role="option"> </div>'),oa=me('<div><select><!></select> <button type="button" role="combobox" aria-haspopup="listbox"><span> </span></button> <div role="listbox" class="listbox svelte-1h1ta11" popover="manual" tabindex="-1"></div></div>');function _i(n,o){Fi(o,!0);let e=Le(o,"value",15),t=Le(o,"size",3,"md"),r=Le(o,"ghost",3,!1),i=Le(o,"class",3,""),s=Le(o,"style",3,""),l=gn(o,["$$slots","$$events","$$legacy","value","size","ghost","class","style","children"]);const a={xs:"calc(var(--tri-size-field,0.25rem)*6)",sm:"calc(var(--tri-size-field,0.25rem)*8)",md:"calc(var(--tri-size-field,0.25rem)*10)",lg:"calc(var(--tri-size-field,0.25rem)*12)"};let u=le(()=>`--size:${a[t()]};${s()}`);const h=`tri-listbox-${na++}`;let c=ue(null),d=ue(null),m=ue(null),v=ue(lt([])),y=ue(!1),_=ue(-1),E=le(()=>!!o.disabled),S=le(()=>e()==null?"":String(e())),P=le(()=>b(v).find(k=>k.value===b(S))??b(v)[0]);function L(){b(c)&&G(v,Array.from(b(c).querySelectorAll("option")).map(k=>({value:k.value,label:(k.textContent??"").trim(),disabled:k.disabled})),!0)}qt(()=>{if(!b(c))return;L();const k=new MutationObserver(()=>L());return k.observe(b(c),{childList:!0,subtree:!0,characterData:!0,attributes:!0}),()=>k.disconnect()});function F(k){const te=b(v)[k];!b(c)||!te||te.disabled||(b(c).value=te.value,b(c).dispatchEvent(new Event("input",{bubbles:!0})),b(c).dispatchEvent(new Event("change",{bubbles:!0})),J())}function H(){if(!b(d)||!b(m))return;const k=b(d).getBoundingClientRect();b(m).style.minWidth=`${k.width}px`,b(m).style.left=`${k.left}px`;const te=b(m).offsetHeight,de=window.innerHeight-k.bottom;de<te&&k.top>de?b(m).style.top=`${Math.max(4,k.top-te-4)}px`:b(m).style.top=`${k.bottom+4}px`}function B(){b(m)?.children[b(_)]?.scrollIntoView({block:"nearest"})}function V(k){const te=k.composedPath();b(d)&&te.includes(b(d))||b(m)&&te.includes(b(m))||J()}function Y(){b(E)||b(y)||!b(m)||(G(y,!0),b(m).showPopover(),H(),G(_,b(v).findIndex(k=>k.value===b(S)),!0),b(_)<0&&G(_,b(v).findIndex(k=>!k.disabled),!0),B(),window.addEventListener("scroll",H,!0),window.addEventListener("resize",H),document.addEventListener("pointerdown",V,!0))}function J(){b(y)&&(G(y,!1),b(m)?.hidePopover(),window.removeEventListener("scroll",H,!0),window.removeEventListener("resize",H),document.removeEventListener("pointerdown",V,!0),b(d)?.focus())}function re(){b(y)?J():Y()}function Z(k){if(!b(v).length)return;let te=b(_);for(let de=0;de<b(v).length;de++)if(te=(te+k+b(v).length)%b(v).length,!b(v)[te]?.disabled){G(_,te,!0),B();return}}function ie(k){const te=k==="start"?b(v).map((de,ye)=>ye):b(v).map((de,ye)=>b(v).length-1-ye);for(const de of te)if(!b(v)[de]?.disabled){G(_,de,!0),B();return}}let he="",pe;function ce(k){he+=k.toLowerCase(),clearTimeout(pe),pe=setTimeout(()=>he="",600);const te=b(v).findIndex(de=>!de.disabled&&de.label.toLowerCase().startsWith(he));te>=0&&(G(_,te,!0),B())}function ve(k){if(!b(E)){if(!b(y)){["ArrowDown","ArrowUp","Enter"," "].includes(k.key)&&(k.preventDefault(),Y());return}switch(k.key){case"ArrowDown":k.preventDefault(),Z(1);break;case"ArrowUp":k.preventDefault(),Z(-1);break;case"Home":k.preventDefault(),ie("start");break;case"End":k.preventDefault(),ie("end");break;case"Enter":case" ":k.preventDefault(),b(_)>=0&&F(b(_));break;case"Escape":k.preventDefault(),J();break;case"Tab":J();break;default:k.key.length===1&&!k.metaKey&&!k.ctrlKey&&ce(k.key)}}}var fe=oa(),we=$(fe);hn(we,()=>({class:"native-select",tabindex:"-1","aria-hidden":"true",...l}),void 0,void 0,void 0,"svelte-1h1ta11");var He=$(we);rn(He,()=>o.children??nr),vi(we,k=>G(c,k),()=>b(c));var xe=_e(we,2);let Xe;xe.__click=re,xe.__keydown=ve;var X=$(xe);let Ye;var ct=$(X);vi(xe,k=>G(d,k),()=>b(d));var Ue=_e(xe,2);gi(Ue,23,()=>b(v),(k,te)=>k.value+"\0"+te,(k,te,de)=>{var ye=sa();let Ke;ye.__click=()=>F(b(de)),ye.__pointermove=()=>G(_,b(de),!0);var St=$(ye);Se(()=>{Ze(ye,"id",`${h}-opt-${b(de)??""}`),Ke=$t(ye,1,"option svelte-1h1ta11",null,Ke,{active:b(de)===b(_),selected:b(te).value===b(S)}),Ze(ye,"aria-selected",b(te).value===b(S)),Ze(ye,"aria-disabled",b(te).disabled),Te(St,b(te).label)}),ge(k,ye)}),vi(Ue,k=>G(m,k),()=>b(m)),Se(()=>{$t(fe,1,`select-wrapper ${i()??""}`,"svelte-1h1ta11"),Zi(fe,s()),Xe=$t(xe,1,"select svelte-1h1ta11",null,Xe,{ghost:r(),open:b(y)}),Zi(xe,b(u)),xe.disabled=b(E),Ze(xe,"aria-expanded",b(y)),Ze(xe,"aria-controls",h),Ze(xe,"aria-activedescendant",b(y)&&b(_)>=0?`${h}-opt-${b(_)}`:void 0),Ze(xe,"aria-label",l["aria-label"]),Ye=$t(X,1,"select-label svelte-1h1ta11",null,Ye,{placeholder:b(P)?.disabled}),Te(ct,b(P)?.label??""),Ze(Ue,"id",h)}),To(we,e),ge(n,fe),Li()}Qr(["click","keydown","pointermove"]);function Bt(n){return n?.id||n?.["@id"]||n?.__jsonld?.id||n?.__jsonld?.["@id"]||(typeof n?.getId=="function"?n.getId():null)||null}function Ht(n){return Bt(n)||(typeof n?.getCanvasId=="function"?n.getCanvasId():null)||(typeof n?.getId=="function"?n.getId():null)||""}function aa(n){const o=n?.behavior||n?.__jsonld?.behavior||(typeof n?.getBehavior=="function"?n.getBehavior():[]);return o?(Array.isArray(o)?o:[o]).map(t=>{const r=String(t).trim().toLowerCase(),i=r.split(/[#/:]/);return i[i.length-1]||r}):[]}function yn(n){const o=aa(n);return o.includes("non-paged")||o.includes("facing-pages")}function la(n,o){const e=[];for(let t=0;t<Math.min(o,n.length);t++){const r=n[t],i=Ht(r);e.push({startIndex:t,endIndex:t,entries:i?[{canvasId:i,canvas:r}]:[]})}for(let t=o;t<n.length;){const r=n[t],i=Ht(r),s=n[t+1],l=Ht(s),a=!!s&&!!i&&!!l&&!yn(r)&&!yn(s);e.push({startIndex:t,endIndex:a?t+1:t,entries:[...i?[{canvasId:i,canvas:r}]:[],...a?[{canvasId:l,canvas:s}]:[]]}),t+=a?2:1}return e}function ua({canvases:n,currentCanvasId:o,currentCanvasIndex:e,viewingMode:t,pagedOffset:r}){if(!o)return[];if(e<0||e>=n.length)return[];const i=[],s=n[e];return s?t!=="paged"?(i.push({canvasId:o,canvas:s}),i):la(n,r).find(({startIndex:a,endIndex:u})=>e>=a&&e<=u)?.entries??i:i}function Ti(n,o){if(!n)return"";if(typeof n=="string")return n;if(typeof n=="object"&&!Array.isArray(n)){const e=n;if("@value"in e){const i=e["@value"];return Array.isArray(i)&&i.length>0?String(i[0]):i===void 0?"":String(i)}const t=Object.keys(e),r=i=>{const s=e[i];if(s!==void 0)return Array.isArray(s)&&s.length>0?String(s[0]):String(s)};for(const i of["en","none"]){const s=r(i);if(s!==void 0)return s}return t.length>0?r(t[0])??"":""}if(Array.isArray(n)&&n.length>0){if(typeof n[0]=="string")return n[0];const e=n,t=l=>l?.value??l?._value,i=(l=>e.find(a=>a.locale===l||a._locale===l||a.language===l))("en");{const l=t(i);if(l)return l}const s=e.find(l=>!l.locale&&!l._locale&&!l.language);{const l=t(s);if(l)return l}return t(e[0])??""}return String(n)}function _n(n,o){const e=o===void 0?"Untitled canvas":`Canvas ${o+1}`;try{const r=n.getLabel?.();if(Array.isArray(r)&&r.length>0)return Ti(r)||e}catch{}const t=n.label||n.__jsonld?.label;if(t){const r=Ti(t);if(r)return r}return e}function Ki(n){if(!n)return null;const o=n.match(/xywh=(?:pixel:)?([\d.]+),([\d.]+),([\d.]+),([\d.]+)/);return o?[Number(o[1]),Number(o[2]),Number(o[3]),Number(o[4])]:null}function ha(n){const[o]=n.split("#");return o||null}function Qi(n){if(!n)return null;if(typeof n=="string")return n;if(Array.isArray(n)){for(const e of n){const t=Qi(e);if(t)return t}return null}if(typeof n!="object")return null;const o=n;return typeof o.id=="string"?o.id:typeof o["@id"]=="string"?o["@id"]:o.source?Qi(o.source):null}function Ji(n){if(!n)return[];if(Array.isArray(n))return n.flatMap(e=>Ji(e));if(typeof n!="object")return[];const o=n;return o.item?Ji(o.item):[o]}function ca(n){const o=n.find(t=>t?.type==="FragmentSelector"&&typeof t?.value=="string"&&t.value.includes("xywh="));if(o)return Ki(o.value);const e=n.find(t=>typeof t?.value=="string"&&t.value.includes("xywh="));return e?Ki(e.value):null}function Tn(n){if(!n)return[];if(Array.isArray(n))return n.flatMap(r=>Tn(r));const o=Qi(n),e=typeof n=="object"&&n&&"selector"in n?Ji(n.selector):[],t=ca(e)||(o?Ki(o):null);return[{raw:n,targetId:o,canvasId:o?ha(o):null,selectors:e,xywh:t}]}function xn(n){return n.endsWith("/info.json")?n.slice(0,-10):n}function zt(n){return typeof n=="number"&&Number.isFinite(n)&&n>0?n:null}function da(n){const o=n?.__jsonld||n;return{width:zt(n?.width)||zt(o?.width)||(typeof n?.getWidth=="function"?zt(n.getWidth()):null),height:zt(n?.height)||zt(o?.height)||(typeof n?.getHeight=="function"?zt(n.getHeight()):null)}}function En(n){const o=n?.__jsonld||n;return o?.type==="SpecificResource"&&o?.source?o.source:null}function fa(n,o){return o?.type==="Choice"||o?.type==="oa:Choice"||!!n&&!Array.isArray(n)&&(n.type==="Choice"||n.type==="oa:Choice")}function bn(n,o){return o&&(o.items||o.item)?o.items||o.item:Array.isArray(n)?n:n&&(n.items||n.item)?n.items||n.item:[]}function pa({body:n,rawBody:o,canvasId:e,getSelectedChoice:t}){const r=Array.isArray(n)?n:bn(n,null),i=bn(null,o),s=t?.(e);if(s){const l=r.find(u=>Bt(u)===s);if(l)return l;const a=i.findIndex(u=>Bt(u)===s);if(a>=0)return r[a]||i[a]}return r[0]||i[0]||null}function ga(n){let o=n.getImages?.()||[];return(!o||!o.length)&&n.getContent&&(o=n.getContent()),o||[]}function ma(n){const o=n?.width||n?.__jsonld?.width||(typeof n?.getWidth=="function"?n.getWidth():null),e=n?.height||n?.__jsonld?.height||(typeof n?.getHeight=="function"?n.getHeight():null);return typeof o!="number"||typeof e!="number"?null:{width:o,height:e}}function va(n){const o=Tn(n?.target||n?.__jsonld?.target).find(e=>e.xywh)?.xywh;return o?{x:o[0],y:o[1],width:o[2],height:o[3]}:null}function wa(n,o){if(typeof n!="string"||!n.trim())return null;const e=n.trim(),t=e.startsWith("pct:"),i=(t?e.slice(4):e).split(",").map(s=>Number(s.trim()));return i.length!==4||i.some(s=>!Number.isFinite(s)||s<0)?null:t?typeof o.width!="number"||typeof o.height!="number"?null:{x:i[0]/100*o.width,y:i[1]/100*o.height,width:i[2]/100*o.width,height:i[3]/100*o.height}:{x:i[0],y:i[1],width:i[2],height:i[3]}}function ya(n,o){const e=n?.__jsonld||n;return wa(e?.selector?.type==="ImageApiSelector"?e.selector.region:null,o)}function _a(n){return[n.x,n.y,n.width,n.height].map(o=>Math.round(o)).join(",")}function Ta(n){const o=n?.__jsonld||n,e=En(n);return!!(n&&(n.id||n["@id"]||o?.service||e||o?.id||o?.["@id"]))}function xa(n,o,e){let t=n.getResource?n.getResource():null;if(!t&&n.getBody){const r=n.getBody(),i=n.__jsonld?.body||n.body;fa(r,i)?t=pa({body:r,rawBody:i,canvasId:o,getSelectedChoice:e}):Array.isArray(r)&&r.length>0?t=r[0]:r&&(t=r)}if(t&&!Ta(t)&&(t=null),!t){const r=n.__jsonld||n;if(r.body){let i=r.body;if(i.type==="Choice"||i.type==="oa:Choice"){const s=i.items||i.item||[],l=e?.(o);i=(l?s.find(u=>Bt(u)===l):null)||s[0]||null}t=Array.isArray(i)?i[0]:i}}return t}function Sn(n){return typeof n=="string"?/^https?:\/\/iiif\.io\/api\/image\//.test(n)||n==="level0"||n==="level1"||n==="level2":Array.isArray(n)?n.some(o=>Sn(o)):!1}function Ea(n){return typeof n=="string"?n||null:Array.isArray(n)&&n.find(e=>typeof e=="string")||null}function ba(n){let o=[];const e=n?.__jsonld||n;return e?.service&&(o=Array.isArray(e.service)?e.service:[e.service]),!o.length&&n?.getServices&&(o=n.getServices()),o.length&&o.find(t=>{const r=t.getType?t.getType():t.type||t["@type"]||"",i=t.getProfile?t.getProfile():t.profile||"";return r==="ImageService1"||r==="ImageService2"||r==="ImageService3"||Sn(i)})||null}function Sa(n,o){for(const e of[n,o]){if(!e)continue;try{const r=e.getLabel?.();if(Array.isArray(r)&&r.length>0){const i=Ti(r);if(i)return i}}catch{}const t=e.label||e.__jsonld?.label;if(t){const r=Ti(t);if(r)return r}}return null}function Pa(n){const o=ba(n),e=Bt(o),t=o?o.getProfile?o.getProfile():o.profile||"":null;return{serviceId:e?xn(e):null,serviceProfile:Ea(t)}}function Ra(n){if(!n||!n.includes("/iiif/"))return null;const o=n.split("/"),e=o.findIndex(t=>t==="full"||/^\d+,\d+,\d+,\d+$/.test(t));return e>0?o.slice(0,e).join("/"):null}function xi(n,o={}){const e=Ht(n);if(!e)return[];const t=ma(n);if(!t)return[];const r=ga(n);return r.length?r.map(i=>{const s=xa(i,e,o.getSelectedChoice),l=En(s)||s;if(!l)return null;const a=Bt(l),u=da(l),h=Pa(l),c=h.serviceId||Ra(a),d=va(i),m=ya(s,u);return{canvasId:e,annotation:i,resource:l,resourceId:a,label:Sa(l,i),canvasWidth:t.width,canvasHeight:t.height,resourceWidth:m?.width||u.width,resourceHeight:m?.height||u.height,serviceId:c,serviceProfile:h.serviceProfile,imageApiRegion:m,x:d?d.x/t.width:0,y:d?d.y/t.width:0,width:d?d.width/t.width:1}}).filter(i=>i!==null):[]}function Ca(n,o={width:1600}){const e=xn(n),t=o.region||"full",r=o.quality||"default",i=o.format||"jpg",s=typeof o.width=="number"?Math.max(1,Math.round(o.width)):null,l=typeof o.height=="number"?Math.max(1,Math.round(o.height)):null,a=o.size||(s?`${s},`:`,${l||1600}`);return`${e}/${t}/${a}/0/${r}.${i}`}function Da(n){return typeof n=="string"?n:Array.isArray(n)&&typeof n[0]=="string"?n[0]:null}function Ei(n){const o=Da(n);return o?o==="level0"||o.endsWith("/level0.json")||o.endsWith("#level0"):!1}function Aa(n,o,e,t){if(!n?.IIIFTileSource?.prototype)return o;try{const r=n.IIIFTileSource.prototype.configure.call({},o,e,null),i=new n.IIIFTileSource(r);return Ia(i,t),i}catch{return o}}function Ia(n,o){if(!Ei(n?.profile)||typeof n?.getTileUrl!="function"||n.__triiiceratopsLevel0LowZoomPrepared)return;const e=n.getTileUrl.bind(n),t=typeof n.getNumTiles=="function"?n.getNumTiles.bind(n):null,r=La(),i=Fa(n),s=Oa(n,i,t);t&&(n.getNumTiles=function(l){return Rn(l,s,i,this)?{x:0,y:0}:Pn(this,l,r,i,t,s)?{x:1,y:1}:t(l)}),typeof n?.minLevel=="number"&&s>=0&&(n.minLevel=Math.max(n.minLevel,s)),n.getTileUrl=function(l,a,u){if(Rn(l,s,i,this)){const h=s>=0?s:l;return e(h,a,u)}return Pn(this,l,r,i,t,s)?Cn(this,l):e(l,a,u)},n.__triiiceratopsLevel0LowZoomPrepared=!0}function Pn(n,o,e,t,r,i){if(i>=0)return!1;if(e>=0&&o<=e||!$i(n,o,t))return!0;if(!r)return!1;const s=r(o);return s?.x===1&&s?.y===1}function Oa(n,o,e){if(!e||typeof n?.minLevel!="number"||typeof n?.maxLevel!="number"||o.size===0)return-1;for(let t=n.minLevel;t<=n.maxLevel;t++){if(!$i(n,t,o))continue;const r=e(t);if(r?.x>1||r?.y>1)return t}return-1}function Rn(n,o,e,t){return o<0?!1:n<o?!0:!$i(t,n,e)}function Fa(n){const o=new Set,e=n?.scale_factors;if(Array.isArray(e))for(const t of e)typeof t=="number"&&t>0&&o.add(t);return o}function $i(n,o,e){if(e.size===0||typeof n?.maxLevel!="number"||typeof o!="number")return!0;const t=Math.pow(2,n.maxLevel-o);return e.has(t)}function La(n,o){return-1}function Cn(n,o){const e=n.getLevelScale(o),t=Math.ceil(n.width*e),r=Math.ceil(n.height*e),i=n.version===3,s=Ei(n?.profile),l=i?t===n.width&&r===n.height?"max":s?`${t},`:`${t},${r}`:t===n.width?"full":`${t},`,a=i?"default":"native";return`${n._id}/full/${l}/0/${a}.${n.tileFormat}`}const bi=8e3,Dn=4e7;function Ma(n,o,e,t){const r=Math.max(1,Math.round(n.width*o*t)),i=n.resourceWidth&&n.resourceHeight?n.resourceHeight/n.resourceWidth:e/o;return{x:Math.round(n.x*o*t),y:Math.round(n.y*e*t),width:r,height:Math.max(1,Math.round(r*i))}}function Ba(n,o){const e=URL.createObjectURL(n),t=document.createElement("a");t.href=e,t.download=o,document.body.appendChild(t),t.click(),t.remove(),URL.revokeObjectURL(e)}async function er(n,o){const e=await fetch(n,o);if(!e.ok)throw new Error(`Image request failed with ${e.status}.`);return e.blob()}async function Ha(n){const o=URL.createObjectURL(n);try{return await new Promise((e,t)=>{const r=new Image;r.onload=()=>e(r),r.onerror=()=>t(new Error("Unable to decode image for export.")),r.src=o})}finally{URL.revokeObjectURL(o)}}async function An(n,o,e,t="image/png"){const r=document.createElement("canvas");r.width=Math.max(1,Math.round(o)),r.height=Math.max(1,Math.round(e));const i=r.getContext("2d");if(!i)throw new Error("Unable to create a canvas for image export.");for(const s of n){const l=await Ha(s.blob);i.drawImage(l,s.x,s.y,s.width,s.height)}return new Promise((s,l)=>{r.toBlob(a=>{if(a){s(a);return}l(new Error("Unable to export composed image."))},t)})}function In(n,o){let e=1;n>bi&&(e=Math.min(e,bi/n)),o>bi&&(e=Math.min(e,bi/o));const t=n*o;return t*e*e>Dn&&(e=Math.min(e,Math.sqrt(Dn/t))),e>=1?{width:Math.round(n),height:Math.round(o),clamped:!1}:{width:Math.max(1,Math.round(n*e)),height:Math.max(1,Math.round(o*e)),clamped:!0}}function ii(n,o={}){if(Ei(n.serviceProfile))return n.resourceId??null;if(n.serviceId){const e=n.imageApiRegion?_a(n.imageApiRegion):void 0,t=!!(o.width||o.height);return Ca(n.serviceId,{region:e,size:t?void 0:"max",width:o.width,height:o.height})}return n.resourceId??null}async function za(n){if(!n.serviceId)return[];const o=n.serviceId.endsWith("/info.json")?n.serviceId:`${n.serviceId}/info.json`;try{const e=await fetch(o);if(!e.ok)return[];const t=await e.json(),r=await Promise.resolve().then(()=>Al),i=r.default||r,s=Aa(i,t,o);if(!s||typeof s.minLevel!="number"||typeof s.maxLevel!="number"||typeof s.getLevelScale!="function")return[];const l=new Set,a=[];for(let u=s.minLevel;u<=s.maxLevel;u+=1){const h=s.getLevelScale(u),c=Math.ceil(s.width*h),d=Math.ceil(s.height*h),m=`${c}x${d}`;l.has(m)||(l.add(m),a.push({width:c,height:d,label:`${c} × ${d}px`,url:Cn(s,u)}))}return a.sort((u,h)=>h.width-u.width)}catch{return[]}}const ka=[{fraction:1,label:"Original"},{fraction:.5,label:"50%"},{fraction:.25,label:"25%"}];function tr(n,o,e){return ka.map(({fraction:t,label:r})=>{const i=Math.max(1,Math.round(n*t)),s=Math.max(1,Math.round(o*t)),l=e?.({width:i,height:s,isOriginal:t===1});return{width:i,height:s,label:`${r} (${i} × ${s}px)`,url:l??void 0}}).filter(t=>!e||!!t.url)}function Na(n){const o=n.resourceWidth,e=n.resourceHeight;if(!n.serviceId||!o||!e){const t=ii(n);return t?[{width:o??0,height:e??0,label:"Original",url:t}]:[]}return tr(o,e,({width:t,height:r,isOriginal:i})=>ii(n,i?{}:{width:t,height:r}))}async function Ua(n){if(Ei(n.serviceProfile)){const o=await za(n);return o.length?o:n.resourceId?[{width:n.resourceWidth??0,height:n.resourceHeight??0,label:"Original",url:n.resourceId}]:[]}return Na(n)}const Wa=.0125;function Va(n){return!!n&&typeof n=="object"&&"tileSource"in n}function On(n,o){if(!n||typeof n!="object")return null;const e=n[o];return typeof e=="number"&&Number.isFinite(e)&&e>0?e:null}function ja(n,o,e){return Math.min(e,Math.max(o,n))}function Ga(n){const o=[...n].sort((t,r)=>t-r),e=Math.floor(o.length/2);return o.length%2===0?(o[e-1]+o[e])/2:o[e]}function qa(n){const o=new Map;return n.forEach((e,t)=>{const r=Va(e),i=r?e.tileSource:e,s=r?e.canvasId??`canvas-${t}`:`canvas-${t}`,l=r?e.x??0:0,a=r?e.y??0:0,u=r?e.width??1:1,h=On(i,"width"),c=On(i,"height"),d=h&&c?u*c/h:null;let m=o.get(s);m||(m={canvasId:s,sources:[],width:0,height:null},o.set(s,m)),m.sources.push({source:e,tileSource:i,localX:l,localY:a,localWidth:u,localHeight:d}),m.width=Math.max(m.width,l+u),m.height=d===null?null:Math.max(m.height??0,a+d)}),[...o.values()]}function Za(n){return{layouts:n.map(o=>({canvasId:o.canvasId,x:0,y:0,width:o.width,height:o.height??1})),sources:n.flatMap(o=>o.sources.map(({tileSource:e,localX:t,localY:r,localWidth:i})=>({tileSource:e,x:t,y:r,width:i,canvasId:o.canvasId})))}}function Xa(n,o){const e=qa(n);if(o.mode==="individuals"||e.length<=1)return Za(e);const t=!o.preserveCanvasScale&&e.every(s=>s.height!==null),r=t?Ga(e.map(s=>s.height)):1,i=e.map(s=>{const l=t?ja(r/s.height,.25,4):1;return{group:s,scale:l,width:s.width*l,height:(s.height??1)*l,x:0,y:0}});if(o.mode==="continuous"){let s=0;const l=o.direction==="top-to-bottom"||o.direction==="bottom-to-top",a=o.direction==="right-to-left"||o.direction==="bottom-to-top";for(const u of i)l?(u.y=a?-s:s,s+=(t?u.height:1)+o.gap):(u.x=a?-s:s,s+=(t?u.width:1)+o.gap)}else if(o.mode==="paged"){const s=Math.max(...i.map(a=>a.height)),l=o.direction==="right-to-left";i.forEach((a,u)=>{const h=l?i.slice(u+1):i.slice(0,u);a.x=h.reduce((c,d)=>c+(t?d.width:1)+o.gap,0),a.y=(s-a.height)/2})}return{layouts:i.map(s=>({canvasId:s.group.canvasId,x:s.x,y:s.y,width:s.width,height:s.height})),sources:i.flatMap(s=>s.group.sources.map(({tileSource:l,localX:a,localY:u,localWidth:h})=>({tileSource:l,x:s.x+a*s.scale,y:s.y+u*s.scale,width:h*s.scale,canvasId:s.group.canvasId})))}}function Ya(n,o,e){Jo(n,"@triiiceratops/plugin-image-export","1.0.0-rc.0",o,e)}function Ka(n){return n.replace(/[^a-z0-9-_]+/gi,"-").replace(/-+/g,"-").replace(/^-|-$/g,"")}function Qa(n,o,e){const r=Ka(n)||"image",i=o==="single"?"":`-${o}`;return`${r}${i}.png`}function Fn(n,o){return xi(n,{getSelectedChoice:o})}function Ja(n){return Ua(n)}function $a(n,o){const t=xi(n,{getSelectedChoice:o})[0];return!t?.canvasWidth||!t?.canvasHeight?[]:tr(t.canvasWidth,t.canvasHeight)}async function el(n,o){const e=o.url??ii(n,{width:o.width,height:o.height});if(!e)throw new Error("No exportable image found for this canvas.");return er(e)}async function tl(n,o,e={}){const t=xi(n,{getSelectedChoice:e.getSelectedChoice}),r=t[0];if(!r)throw new Error("No exportable image found for this canvas.");const{canvasWidth:i,canvasHeight:s}=r;if(!i||!s)throw new Error("Unable to determine canvas dimensions for export.");const{width:l,height:a}=In(o.width,o.height),u=l/i,h=await Promise.all(t.map(async c=>il(c,i,s,u)));return An(h,l,a,e.format??"image/png")}async function il(n,o,e,t){const r=Ma(n,o,e,t),i=ii(n,{width:r.width});if(!i)throw new Error("No exportable image found for this canvas.");return{blob:await er(i),...r}}function Ln(n){return ua({canvases:n.canvases,currentCanvasId:n.canvasId,currentCanvasIndex:n.currentCanvasIndex,viewingMode:n.viewingMode,pagedOffset:n.pagedOffset}).map(o=>o.canvas)}function Mn(n,o){const e=Ln(n);if(!e.length)return null;const t=e.flatMap((c,d)=>{const m=Ht(c)??`canvas-${d}`;return xi(c,{getSelectedChoice:o}).map(v=>({canvasId:m,x:v.x,y:v.y,width:v.width,tileSource:{width:v.resourceWidth||v.canvasWidth,height:v.resourceHeight||v.canvasHeight,resolved:v}}))});if(!t.length)return null;const{layouts:r,sources:i}=Xa(t,{mode:n.viewingMode,direction:n.viewingDirection,preserveCanvasScale:n.preserveCanvasScale,gap:Wa});if(!r.length)return null;const s=Math.min(...r.map(c=>c.x)),l=Math.min(...r.map(c=>c.y)),a=Math.max(...r.map(c=>c.x+c.width)),u=Math.max(...r.map(c=>c.y+c.height));return{entries:i.map(c=>({resolved:c.tileSource.resolved,x:c.x-s,y:c.y-l,width:c.width})),worldWidth:a-s,worldHeight:u-l}}function rl(n,o){const e=Mn(n,o);if(!e)return[];const t=e.entries[0],r=t?.resolved.resourceWidth&&t.width>0?t.resolved.resourceWidth/t.width:1600,i=Math.round(e.worldWidth*r),s=Math.round(e.worldHeight*r);return!i||!s?[]:tr(i,s)}async function nl(n,o,e={}){const t=Mn(n,e.getSelectedChoice);if(!t)throw new Error("Nothing is currently displayed in the viewer.");const{width:r,height:i}=In(o.width,o.height),s=r/t.worldWidth,l=await Promise.all(t.entries.map(async({resolved:a,x:u,y:h,width:c})=>{const d=Math.max(1,Math.round(c*s)),m=a.resourceWidth&&a.resourceHeight?a.resourceHeight/a.resourceWidth:1,v=Math.max(1,Math.round(d*m)),y=ii(a,{width:d});if(!y)throw new Error("No exportable image found for the current view.");return{blob:await er(y),x:Math.round(u*s),y:Math.round(h*s),width:d,height:v}}));return An(l,r,i,e.format??"image/png")}var sl=me("<option> </option>"),ol=me("<option> </option>"),al=me("<!> <option> </option> <!>",1),ll=me('<div class="tri-id-field"><label class="tri-id-label" for="tri-id-mode"><span> </span></label> <!></div>'),ul=me("<option> </option>"),hl=me('<div class="tri-id-field"><label class="tri-id-label" for="tri-id-canvas"><span> </span></label> <!></div>'),cl=me("<option> </option>"),dl=me('<div class="tri-id-field"><label class="tri-id-label" for="tri-id-image"><span> </span></label> <!></div>'),fl=me("<option> </option>"),pl=me("<option disabled> </option> <!>",1),gl=me('<div class="tri-id-alert is-success" data-tri-id-result=""><span> </span></div>'),ml=me('<div class="tri-id-alert is-error" data-tri-id-error=""><span> </span></div>'),vl=me('<div class="tri-id-alert"><span> </span></div>'),wl=me('<div class="tri-id-card"><div class="tri-id-card-body"><!> <!> <!></div></div>'),yl=me('<span aria-hidden="true"></span> ',1),_l=me('<div class="tri-id" data-tri-id="" data-panel-id="image-download"><div class="tri-id-body"><p class="tri-id-desc"> </p> <div class="tri-id-fields"><!> <!> <!> <div class="tri-id-field"><label class="tri-id-label" for="tri-id-resolution"><span> </span></label> <!></div></div> <!></div> <div class="tri-id-footer"><!></div></div>');function Tl(n,o){Fi(o,!0);const{context:e}=Es(vn),{viewerState:t,selectors:r,locale:i,ui:s}=e;let l=ue(0),a=ue(0);r.select(I=>[I.canvasId,I.currentCanvasIndex,I.canvases,I.viewingMode,I.viewingDirection,I.pagedOffset,I.preserveCanvasScale]).subscribe(()=>{xr(l)}),i.subscribe(()=>{xr(a)});const u=(I,D)=>(b(a),i.t(I,D));let h=ue("single"),c=ue(0),d=ue(0),m=ue(lt([])),v=ue(null),y=ue(!1),_=ue(!1),E=ue(""),S=ue(""),P=ue(null);const L=I=>t.getSelectedChoice(I),F=le(()=>(b(l),t.currentCanvasIndex>=0?t.canvases[t.currentCanvasIndex]??null:null)),H=le(()=>(b(l),b(F)?Fn(b(F),L):[])),B=le(()=>b(H).length>1),V=le(()=>b(B)),Y=le(()=>(b(l),Ln(t))),J=le(()=>b(Y).length>1),re=le(()=>b(J)),Z=le(()=>b(V)||b(re)),ie=le(()=>(b(l),b(h)==="single"&&b(J)?b(Y)[b(c)]??b(F):b(F))),he=le(()=>(b(l),b(ie)?Fn(b(ie),L):[])),pe=le(()=>b(he).length>1),ce=le(()=>b(v)!==null?b(m)[b(v)]??null:null),ve=le(()=>!b(_)&&!b(y)&&!!b(F)&&!!b(ce)),fe=le(()=>(b(a),b(F)?!b(y)&&!b(m).length?u("image_download_disabled_no_resolution"):null:u("image_download_disabled_no_canvas")));qt(()=>{(b(h)==="composite"&&!b(V)||b(h)==="world"&&!b(re))&&G(h,"single")}),qt(()=>{b(l);const I=t.canvasId,D=b(Y).findIndex(z=>Ht(z)===I);G(c,D>=0?D:0,!0)}),qt(()=>{b(ie),G(d,0)}),qt(()=>{const I=b(F),D=b(h),z=b(d);let j=!1;if(G(m,[],!0),G(v,null),!!I){if(D==="single"){const q=b(he)[z];if(!q)return;G(y,!0),Ja(q).then(U=>{j||(G(m,U,!0),G(v,U.length?0:null,!0))}).finally(()=>{j||G(y,!1)})}else if(D==="composite"){const q=$a(I,L);G(m,q,!0),G(v,q.length?0:null,!0)}else{const q=rl(t,L);G(m,q,!0),G(v,q.length?0:null,!0)}return()=>{j=!0}}});function we(I){const D=Number(I);return Number.isInteger(D)?D:0}async function He(){if(!(!b(F)||!b(ce)||!b(ve))){G(_,!0),G(E,""),G(S,"");try{let I,D=b(F);if(b(h)==="single"){D=b(ie);const j=b(he)[b(d)];if(!j)return;I=await el(j,b(ce))}else b(h)==="composite"?I=await tl(b(F),b(ce),{getSelectedChoice:L}):I=await nl(t,b(ce),{getSelectedChoice:L});const z=Qa(_n(D,t.currentCanvasIndex),b(h),"image/png");Ba(I,z),G(S,u("image_download_result_downloaded",{filename:z}),!0)}catch(I){G(E,u("image_download_error_failed"),!0),b(P)&&Ya(b(P),I,()=>void He())}finally{G(_,!1)}}}function xe(I){return{destroy:s.renderIcon(wn,I)}}var Xe=_l(),X=$(Xe),Ye=$(X),ct=$(Ye),Ue=_e(Ye,2),k=$(Ue);{var te=I=>{var D=ll(),z=$(D),j=$(z),q=$(j),U=_e(z,2);{let K=le(()=>u("image_download_mode"));_i(U,{id:"tri-id-mode",class:"tri-id-field-select","data-tri-id-mode":!0,get"aria-label"(){return b(K)},get disabled(){return b(_)},get value(){return b(h)},onchange:g=>{G(h,g.currentTarget.value,!0)},children:(g,p)=>{var w=al(),x=jt(w);{var C=oe=>{var se=sl(),Qe=$(se);se.value=se.__value="composite",Se(Ut=>Te(Qe,Ut),[()=>u("image_download_mode_composite")]),ge(oe,se)};st(x,oe=>{b(V)&&oe(C)})}var A=_e(x,2),N=$(A);A.value=A.__value="single";var Q=_e(A,2);{var W=oe=>{var se=ol(),Qe=$(se);se.value=se.__value="world",Se(Ut=>Te(Qe,Ut),[()=>u("image_download_mode_world")]),ge(oe,se)};st(Q,oe=>{b(re)&&oe(W)})}Se(oe=>Te(N,oe),[()=>u("image_download_mode_single")]),ge(g,w)},$$slots:{default:!0}})}Se(K=>Te(q,K),[()=>u("image_download_mode")]),ge(I,D)};st(k,I=>{b(Z)&&I(te)})}var de=_e(k,2);{var ye=I=>{var D=hl(),z=$(D),j=$(z),q=$(j),U=_e(z,2);{let K=le(()=>u("image_download_canvas"));_i(U,{id:"tri-id-canvas",class:"tri-id-field-select",get"aria-label"(){return b(K)},get disabled(){return b(_)},get value(){return b(c)},onchange:g=>{G(c,we(g.currentTarget.value),!0)},children:(g,p)=>{var w=$r(),x=jt(w);gi(x,17,()=>b(Y),Vi,(C,A,N)=>{var Q=ul(),W=$(Q);Q.value=Q.__value=N,Se(oe=>Te(W,oe),[()=>_n(b(A),N)]),ge(C,Q)}),ge(g,w)},$$slots:{default:!0}})}Se(K=>Te(q,K),[()=>u("image_download_canvas")]),ge(I,D)};st(de,I=>{b(h)==="single"&&b(J)&&I(ye)})}var Ke=_e(de,2);{var St=I=>{var D=dl(),z=$(D),j=$(z),q=$(j),U=_e(z,2);{let K=le(()=>u("image_download_image"));_i(U,{id:"tri-id-image",class:"tri-id-field-select",get"aria-label"(){return b(K)},get disabled(){return b(_)},get value(){return b(d)},onchange:g=>{G(d,we(g.currentTarget.value),!0)},children:(g,p)=>{var w=$r(),x=jt(w);gi(x,17,()=>b(he),Vi,(C,A,N)=>{var Q=cl(),W=$(Q);Q.value=Q.__value=N,Se(oe=>Te(W,oe),[()=>b(A).label??`${u("image_download_image")} ${N+1}`]),ge(C,Q)}),ge(g,w)},$$slots:{default:!0}})}Se(K=>Te(q,K),[()=>u("image_download_image")]),ge(I,D)};st(Ke,I=>{b(h)==="single"&&b(pe)&&I(St)})}var kt=_e(Ke,2),Nt=$(kt),Pt=$(Nt),dt=$(Pt),f=_e(Nt,2);{let I=le(()=>u("image_download_resolution")),D=le(()=>b(_)||b(y)||!b(m).length),z=le(()=>b(v)??"");_i(f,{id:"tri-id-resolution",class:"tri-id-field-select","data-tri-id-resolution":!0,get"aria-label"(){return b(I)},get disabled(){return b(D)},get value(){return b(z)},onchange:j=>{G(v,we(j.currentTarget.value),!0)},children:(j,q)=>{var U=pl(),K=jt(U),g=$(K);K.value=K.__value="";var p=_e(K,2);gi(p,17,()=>b(m),Vi,(w,x,C)=>{var A=fl(),N=$(A);A.value=A.__value=C,Se(()=>Te(N,b(x).label)),ge(w,A)}),Se(w=>Te(g,w),[()=>u("image_download_resolution_placeholder")]),ge(j,U)},$$slots:{default:!0}})}var T=_e(Ue,2);{var R=I=>{var D=wl(),z=$(D),j=$(z);{var q=w=>{var x=gl(),C=$(x),A=$(C);Se(()=>Te(A,b(S))),ge(w,x)};st(j,w=>{b(S)&&w(q)})}var U=_e(j,2);{var K=w=>{var x=ml(),C=$(x),A=$(C);Se(()=>Te(A,b(E))),ge(w,x)};st(U,w=>{b(E)&&w(K)})}var g=_e(U,2);{var p=w=>{var x=vl(),C=$(x),A=$(C);Se(()=>Te(A,b(fe))),ge(w,x)};st(g,w=>{b(fe)&&w(p)})}ge(I,D)};st(T,I=>{(b(S)||b(E)||b(fe))&&I(R)})}var O=_e(X,2),M=$(O);{let I=le(()=>!b(ve));ra(M,{variant:"primary",class:"tri-id-download","data-tri-id-download":!0,style:"width:100%",get disabled(){return b(I)},onclick:He,children:(D,z)=>{var j=yl(),q=jt(j);go(q,K=>xe?.(K));var U=_e(q);Se(K=>Te(U,` ${K??""}`),[()=>b(_)?u("image_download_downloading"):u("image_download_download")]),ge(D,j)},$$slots:{default:!0}})}vi(Xe,I=>G(P,I),()=>b(P)),Se((I,D)=>{Te(ct,I),Te(dt,D)},[()=>u("image_download_description"),()=>u("image_download_resolution")]),ge(n,Xe),Li()}const{STYLES:xl,STYLE_ID:El}=Qo(`
5
+ Update the plugin or the core viewer so their declared ranges and capabilities overlap.`}function Mo(n,o){const e=[];mn(o.coreVersion,n.coreRange)||e.push({kind:"core",required:n.coreRange,actual:o.coreVersion,message:`requires core ${n.coreRange} but this viewer is core ${o.coreVersion}`}),mn(o.pluginApiVersion,n.pluginApiRange)||e.push({kind:"pluginApi",required:n.pluginApiRange,actual:o.pluginApiVersion,message:`requires plugin API ${n.pluginApiRange} but this viewer provides plugin API ${o.pluginApiVersion}`});const t=new Set(o.capabilities);for(const r of n.requiredCapabilities)t.has(r)||e.push({kind:"capability",required:r,actual:o.capabilities.join(", ")||"(none)",message:`requires capability "${r}" which this viewer does not provide (has: ${o.capabilities.join(", ")||"none"})`});return e}function Bo(n,o){const e=Mo(n,o);if(e.length>0)throw new Xi(n.name,n.version,e)}function Ho(n,o={}){let e=0,t=!1;const r=new Set,i=n.subscribe(()=>{e++;for(const l of[...r])l()},o.onListenerError);return{selectors:{select(l,a=Object.is){let u=-1,h;const c=()=>(u!==e&&(h=l(n),u=e),h);return{get:c,subscribe(d){if(t)return()=>{};let m=c();const v=()=>{let y;try{y=c()}catch(_){o.onProjectionError?.(_);return}a(m,y)||(m=y,d(y))};return r.add(v),()=>{r.delete(v)}}}}},dispose(){t||(t=!0,r.clear(),i())}}}const Yi=()=>{};function zo(){return{install(n,o){return Yi}}}function ko(){return{current:"en",t(n,o){return n},subscribe(n){return Yi}}}function No(){return{renderIcon(n,o){return Yi}}}function Uo(n){const o=new Set;return{service:{install(e,t){const r=n.install(e,t);let i=!1;const s=()=>{i||(i=!0,o.delete(s),r())};return o.add(s),s}},releaseAll(){for(const e of[...o])e();o.clear()}}}function Wo(n){const o=new Set;return{service:{get current(){return n.current},t(e,t){return n.t(e,t)},subscribe(e){const t=n.subscribe(e);let r=!1;const i=()=>{r||(r=!0,o.delete(i),t())};return o.add(i),i}},releaseAll(){for(const e of[...o])e();o.clear()}}}const Vo={deactivate(){}};function jo(n,o){const e=o.reportError;let t,r,i,s;try{Bo(n,o),t=Ho(o.viewerState,{onProjectionError:e?d=>e({phase:"command",error:d}):void 0,onListenerError:e?d=>e({phase:"subscription",error:d}):void 0}),r=Uo(o.styles??zo()),i=Wo(o.locale??ko()),s={viewerState:o.viewerState,selectors:t.selectors,styles:r.service,locale:i.service,ui:o.ui??No()}}catch(d){if(t?.dispose(),r?.releaseAll(),i?.releaseAll(),e)return e({phase:"setup",error:d}),Vo;throw d}const l=[],a=r,u=i,h=t;try{const d=n.view.mount(o.container,s);typeof d=="function"&&l.push(d)}catch(d){if(!e)throw a.releaseAll(),u.releaseAll(),h.dispose(),d;e({phase:"mount",error:d})}l.push(()=>a.releaseAll()),l.push(()=>u.releaseAll()),l.push(()=>h.dispose());let c=!1;return{deactivate(){if(!c){c=!0;for(let d=l.length-1;d>=0;d--)try{l[d]?.()}catch(m){e?e({phase:"cleanup",error:m}):console.error(`[triiiceratops] Plugin "${n.name}" cleanup threw during deactivation; teardown continues.`,m)}l.length=0}}}}const Go="triiiceratops-plugin";function qo(n){const o={name:n.name,uiId:n.uiId,version:n.version,coreRange:n.coreRange,pluginApiRange:n.pluginApiRange,requiredCapabilities:n.requiredCapabilities??[],icon:n.icon,target:n.target??"panel",dismiss:n.dismiss,catalog:n.catalog,view:n.view};return{kind:Go,...o,activate(e){return jo(o,e)}}}class Zo extends Error{name="SvgIconError";constructor(o){super(`svgIcon: ${o}`)}}const Xo="0 0 24 24";function bt(n,o){if(!n)throw new Zo(o)}const Yo=/<svg\b[^>]*>/i;function Ko(n){bt(typeof n=="string","expected an SVG string.");const o=n.trim();bt(o.length>0,"received an empty string.");const e=Yo.exec(o);bt(e!==null,"the markup must contain an <svg> root element."),bt(!/<script[\s/>]/i.test(o),"<script> elements are not allowed in plugin icons."),bt(!/<foreignObject[\s/>]/i.test(o),"<foreignObject> is not allowed in plugin icons."),bt(!/\son[a-z]+\s*=/i.test(o),"on* event-handler attributes (e.g. onload, onclick) are not allowed in plugin icons.");for(const l of o.matchAll(/(?:xlink:)?href\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s"'>]+))/gi)){const a=(l[1]??l[2]??l[3]??"").trim();bt(a.startsWith("#"),`external href/xlink:href URLs are not allowed in plugin icons (found "${a}"); only internal "#id" references are.`)}const t=e[0],r=/\bviewBox\s*=\s*(?:"([^"]*)"|'([^']*)')/i.exec(t);let i=(r?.[1]??r?.[2])?.trim();if(!i){const l=/\bwidth\s*=\s*(?:"([^"]*)"|'([^']*)')/i.exec(t),a=/\bheight\s*=\s*(?:"([^"]*)"|'([^']*)')/i.exec(t),u=parseFloat(l?.[1]??l?.[2]??""),h=parseFloat(a?.[1]??a?.[2]??"");i=Number.isFinite(u)&&Number.isFinite(h)?`0 0 ${u} ${h}`:Xo}let s="";if(!/\/\s*>$/.test(t)){const l=e.index+t.length,a=o.lastIndexOf("</svg>");s=(a>=l?o.slice(l,a):o.slice(l)).trim()}return{kind:"svg",inner:s,viewBox:i}}function Qo(n,o){return{STYLES:n,STYLE_ID:o}}function Jo(n,o,e,t,r){const i={pluginName:o,pluginVersion:e,phase:"command",error:t,retry:r};n.dispatchEvent(new CustomEvent("pluginerror",{detail:i,bubbles:!0,composed:!0}))}const $o=".btn.svelte-sgoebi{display:inline-flex;flex-wrap:nowrap;flex-shrink:0;justify-content:center;align-items:center;gap:.375rem;cursor:pointer;text-align:center;vertical-align:middle;user-select:none;-webkit-user-select:none;touch-action:manipulation;font-weight:600;height:var(--size);padding-inline:var(--btn-p);font-size:var(--fontsize, .875rem);color:var(--btn-fg);background-color:var(--btn-bg);border-width:var(--tri-border);border-style:solid;border-color:var(--btn-border);border-start-start-radius:var(--join-ss, var(--tri-radius-buttons));border-start-end-radius:var(--join-se, var(--tri-radius-buttons));border-end-end-radius:var(--join-ee, var(--tri-radius-buttons));border-end-start-radius:var(--join-es, var(--tri-radius-buttons));outline-offset:2px;outline-color:var(--btn-color, var(--tri-content));text-shadow:0 .5px oklch(100% 0 0 / calc(var(--tri-depth) * .15));box-shadow:0 .5px 0 .5px oklch(100% 0 0 / calc(var(--tri-depth) * 6%)) inset,var(--btn-shadow);transition-property:color,background-color,border-color,box-shadow;transition-duration:.2s;transition-timing-function:cubic-bezier(0,0,.2,1);--size: calc(var(--tri-size-field, .25rem) * 10);--btn-bg: var(--btn-color, var(--tri-toolbar-bg));--btn-fg: var(--tri-content);--btn-p: 1rem;--btn-border: color-mix( in oklab, var(--btn-bg), #000 calc(var(--tri-depth) * 5%) );--btn-shadow: 0 3px 2px -2px color-mix( in oklab, var(--btn-bg) calc(var(--tri-depth) * 30%), #0000 ), 0 4px 3px -2px color-mix( in oklab, var(--btn-bg) calc(var(--tri-depth) * 30%), #0000 )}@media(hover:hover){.btn.svelte-sgoebi:hover{--btn-bg: color-mix( in oklab, var(--btn-color, var(--tri-toolbar-bg)), #000 7% )}}.btn.svelte-sgoebi:focus-visible{isolation:isolate;outline-width:2px;outline-style:solid}.btn.svelte-sgoebi:active:not(.active){--btn-bg: color-mix( in oklab, var(--btn-color, var(--tri-toolbar-bg)), #000 5% );--btn-border: color-mix( in oklab, var(--btn-color, var(--tri-toolbar-bg)), #000 7% );--btn-shadow: 0 0 0 0 oklch(0% 0 0 / 0), 0 0 0 0 oklch(0% 0 0 / 0);translate:0 .5px}.btn.active.svelte-sgoebi{--btn-bg: color-mix( in oklab, var(--btn-color, var(--tri-toolbar-bg)), #000 7% )}.btn.svelte-sgoebi:disabled,.btn[disabled].svelte-sgoebi{pointer-events:none;--btn-border: #0000;--btn-fg: color-mix(in oklch, var(--tri-content) 20%, #0000)}.btn.svelte-sgoebi:disabled:not(.ghost):not(.outline),.btn[disabled].svelte-sgoebi:not(.ghost):not(.outline){background-color:color-mix(in oklab,var(--tri-content) 10%,transparent);box-shadow:none}.circle.svelte-sgoebi{width:var(--size);height:var(--size);border-radius:3.40282e38px;padding-inline:0}.square.svelte-sgoebi{width:var(--size);height:var(--size);padding-inline:0}.ghost.svelte-sgoebi{--btn-bg: transparent;--btn-border: transparent;--btn-fg: var(--btn-color-text, var(--btn-color, var(--tri-content)));box-shadow:none;text-shadow:none}@media(hover:hover){.ghost.svelte-sgoebi:hover{--btn-bg: color-mix(in oklab, var(--tri-content) 10%, transparent)}}.ghost.svelte-sgoebi:active:not(.active),.ghost.active.svelte-sgoebi{--btn-bg: color-mix(in oklab, var(--tri-content) 10%, transparent);--btn-border: transparent}.outline.svelte-sgoebi:not(:hover):not(:active):not(:focus-visible):not(.active):not(:disabled):not([disabled]){--btn-bg: transparent;--btn-fg: var(--btn-color-text, var(--btn-color, var(--tri-content)));--btn-border: var(--btn-color, var(--tri-content));box-shadow:none;text-shadow:none}.select-wrapper.svelte-1hwvamm{display:inline-flex;width:clamp(3rem,20rem,100%);max-width:100%}.native-select.svelte-1hwvamm{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0 0 0 0);white-space:nowrap;border:0;pointer-events:none}.select.svelte-1hwvamm{border:var(--tri-border) solid var(--input-color);appearance:none;background-color:var(--tri-input-bg);vertical-align:middle;width:100%;height:var(--size);touch-action:manipulation;white-space:nowrap;box-shadow:0 1px color-mix(in oklab,var(--input-color) calc(var(--tri-depth) * 10%),#0000) inset,0 -1px oklch(100% 0 0 / calc(var(--tri-depth) * .1)) inset;--input-color: color-mix(in oklab, var(--tri-content) 20%, #0000);--size: calc(var(--tri-size-field, .25rem) * 10);background-image:linear-gradient(45deg,#0000 50%,currentColor 50%),linear-gradient(135deg,currentColor 50%,#0000 50%);background-position:calc(100% - 20px) calc(1px + 50%),calc(100% - 16.1px) calc(1px + 50%);background-repeat:no-repeat;background-size:4px 4px,4px 4px;border-start-start-radius:var(--join-ss, var(--tri-radius-buttons));border-start-end-radius:var(--join-se, var(--tri-radius-buttons));border-end-end-radius:var(--join-ee, var(--tri-radius-buttons));border-end-start-radius:var(--join-es, var(--tri-radius-buttons));align-items:center;gap:.375rem;padding-inline:.75rem 1.75rem;font-size:.875rem;display:inline-flex;position:relative;cursor:pointer;color:inherit;text-align:start}.select-label.svelte-1hwvamm{flex:1;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.select-label.placeholder.svelte-1hwvamm{color:color-mix(in oklab,var(--tri-content) 55%,transparent)}.select.svelte-1hwvamm:hover:not(:disabled){--input-color: color-mix(in oklab, var(--tri-content) 40%, #0000)}.select.svelte-1hwvamm:focus-visible,.select.open.svelte-1hwvamm{--input-color: var(--tri-content);box-shadow:0 1px color-mix(in oklab,var(--input-color) calc(var(--tri-depth) * 10%),#0000);outline:2px solid var(--input-color);outline-offset:2px;isolation:isolate;z-index:1}.select.svelte-1hwvamm:is(:where(.svelte-1hwvamm):disabled,[disabled]:where(.svelte-1hwvamm)){cursor:not-allowed;border-color:var(--tri-panel-bg);background-color:var(--tri-panel-bg);color:color-mix(in oklab,var(--tri-content) 40%,transparent)}.ghost.svelte-1hwvamm{box-shadow:none;background-color:#0000;border-color:#0000;transition:background-color .2s}.ghost.svelte-1hwvamm:hover:not(:disabled){background-color:color-mix(in oklab,var(--tri-content) 8%,transparent)}.ghost.svelte-1hwvamm:focus-visible,.ghost.open.svelte-1hwvamm{background-color:var(--tri-input-bg);color:var(--tri-content)}.listbox.svelte-1hwvamm{position:fixed;inset:auto;margin:0;padding:.1875rem;border:var(--tri-border) solid color-mix(in oklab,var(--tri-content) 20%,#0000);background-color:var(--tri-input-bg);color:var(--tri-content);border-radius:var(--tri-radius-buttons);box-shadow:0 8px 24px oklch(0 0 0 / calc(.12 + var(--tri-depth) * .06));max-height:16rem;overflow-y:auto;min-width:8rem;z-index:1}.listbox.svelte-1hwvamm:not(:popover-open){display:none}.option.svelte-1hwvamm{padding:.25rem .5rem;border-radius:calc(var(--tri-radius-buttons) * .6);cursor:pointer;font-size:.8125rem;line-height:1.3;white-space:nowrap;color:inherit}.option.active.svelte-1hwvamm{background-color:color-mix(in oklab,var(--tri-content) 12%,#0000)}.option.selected.svelte-1hwvamm{background-color:color-mix(in oklab,var(--tri-color-primary) 90%,#0000);color:var(--tri-color-primary-content)}.option.selected.active.svelte-1hwvamm{background-color:var(--tri-color-primary)}.option[aria-disabled=true].svelte-1hwvamm{opacity:.5;cursor:not-allowed;color:color-mix(in oklab,var(--tri-content) 55%,transparent)}\n",ea={en:{image_download_title:"Download Image",image_download_close:"Close Download Image",image_download_description:"Download the current canvas as an image.",image_download_mode:"What to download",image_download_mode_composite:"Composite canvas",image_download_mode_composite_hint:"Every image on the current canvas, composited together.",image_download_mode_single:"Single image",image_download_mode_single_hint:"One image from the current canvas.",image_download_mode_world:"Current view",image_download_mode_world_hint:"Everything currently laid out together in the viewer.",image_download_canvas:"Canvas",image_download_image:"Image",image_download_resolution:"Resolution",image_download_resolution_placeholder:"Select a resolution",image_download_downloading:"Downloading...",image_download_download:"Download",image_download_disabled_no_canvas:"Load a manifest to download an image.",image_download_disabled_no_resolution:"Select a resolution to download.",image_download_result_downloaded:"Downloaded {filename}.",image_download_error_failed:"Unable to download image. Check the browser console for details."},de:{image_download_title:"Bild herunterladen",image_download_close:"Bild-Download schließen",image_download_description:"Die aktuelle Leinwand als Bild herunterladen.",image_download_mode:"Was heruntergeladen werden soll",image_download_mode_composite:"Zusammengesetzte Leinwand",image_download_mode_composite_hint:"Alle Bilder der aktuellen Leinwand, zusammengesetzt.",image_download_mode_single:"Einzelbild",image_download_mode_single_hint:"Ein Bild von der aktuellen Leinwand.",image_download_mode_world:"Aktuelle Ansicht",image_download_mode_world_hint:"Alles, was aktuell zusammen im Viewer angezeigt wird.",image_download_canvas:"Leinwand",image_download_image:"Bild",image_download_resolution:"Auflösung",image_download_resolution_placeholder:"Auflösung auswählen",image_download_downloading:"Wird heruntergeladen...",image_download_download:"Herunterladen",image_download_disabled_no_canvas:"Laden Sie ein Manifest, um ein Bild herunterzuladen.",image_download_disabled_no_resolution:"Wählen Sie eine Auflösung zum Herunterladen aus.",image_download_result_downloaded:"{filename} heruntergeladen.",image_download_error_failed:"Bild kann nicht heruntergeladen werden. Details in der Browserkonsole."}},vn=Symbol("triiiceratops:plugin-image-download"),wn=Ko('<svg viewBox="0 0 256 256"><path d="M224,144v64a8,8,0,0,1-8,8H40a8,8,0,0,1-8-8V144a8,8,0,0,1,16,0v56H208V144a8,8,0,0,1,16,0Zm-101.66,5.66a8,8,0,0,0,11.32,0l40-40a8,8,0,0,0-11.32-11.32L136,124.69V32a8,8,0,0,0-16,0v92.69L93.66,98.34a8,8,0,0,0-11.32,11.32Z"/></svg>'),ta="5";typeof window<"u"&&((window.__svelte??={}).v??=new Set).add(ta);var ia=me("<button><!></button>");function ra(n,o){let e=Le(o,"variant",3,"default"),t=Le(o,"size",3,"md"),r=Le(o,"circle",3,!1),i=Le(o,"square",3,!1),s=Le(o,"ghost",3,!1),l=Le(o,"outline",3,!1),a=Le(o,"active",3,!1),u=Le(o,"class",3,""),h=Le(o,"style",3,""),c=gn(o,["$$slots","$$events","$$legacy","variant","size","circle","square","ghost","outline","active","class","style","children"]);const d={default:"",primary:"--btn-color:var(--tri-color-primary);--btn-color-text:var(--tri-color-primary-text);--btn-fg:var(--tri-color-primary-content);",neutral:"--btn-color:var(--tri-color-neutral);--btn-fg:var(--tri-color-neutral-content);",success:"--btn-color:var(--tri-color-success);--btn-fg:var(--tri-color-success-content);",warning:"--btn-color:var(--tri-color-warning);--btn-fg:var(--tri-color-warning-content);",error:"--btn-color:var(--tri-color-error);--btn-fg:var(--tri-color-error-content);"},m={xs:"--fontsize:0.6875rem;--btn-p:0.5rem;--size:calc(var(--tri-size-field,0.25rem)*6);",sm:"--fontsize:0.75rem;--btn-p:0.75rem;--size:calc(var(--tri-size-field,0.25rem)*8);",md:"--fontsize:0.875rem;--btn-p:1rem;--size:calc(var(--tri-size-field,0.25rem)*10);",lg:"--fontsize:1.125rem;--btn-p:1.25rem;--size:calc(var(--tri-size-field,0.25rem)*12);"};let v=le(()=>`${m[t()]}${d[e()]}${h()}`);var y=ia();hn(y,()=>({class:`btn ${u()??""}`,style:b(v),...c,[Mt]:{circle:r(),square:i(),ghost:s(),outline:l(),active:a()}}),void 0,void 0,void 0,"svelte-sgoebi");var _=$(y);rn(_,()=>o.children??nr),ge(n,y)}let na=0;var sa=me('<div role="option"> </div>'),oa=me('<div><select><!></select> <button type="button" role="combobox" aria-haspopup="listbox"><span> </span></button> <div role="listbox" class="listbox svelte-1hwvamm" popover="manual" tabindex="-1"></div></div>');function _i(n,o){Fi(o,!0);let e=Le(o,"value",15),t=Le(o,"size",3,"md"),r=Le(o,"ghost",3,!1),i=Le(o,"class",3,""),s=Le(o,"style",3,""),l=gn(o,["$$slots","$$events","$$legacy","value","size","ghost","class","style","children"]);const a={xs:"calc(var(--tri-size-field,0.25rem)*6)",sm:"calc(var(--tri-size-field,0.25rem)*8)",md:"calc(var(--tri-size-field,0.25rem)*10)",lg:"calc(var(--tri-size-field,0.25rem)*12)"};let u=le(()=>`--size:${a[t()]};${s()}`);const h=`tri-listbox-${na++}`;let c=ue(null),d=ue(null),m=ue(null),v=ue(lt([])),y=ue(!1),_=ue(-1),E=le(()=>!!o.disabled),S=le(()=>e()==null?"":String(e())),P=le(()=>b(v).find(k=>k.value===b(S))??b(v)[0]);function L(){b(c)&&G(v,Array.from(b(c).querySelectorAll("option")).map(k=>({value:k.value,label:(k.textContent??"").trim(),disabled:k.disabled})),!0)}qt(()=>{if(!b(c))return;L();const k=new MutationObserver(()=>L());return k.observe(b(c),{childList:!0,subtree:!0,characterData:!0,attributes:!0}),()=>k.disconnect()});function F(k){const te=b(v)[k];!b(c)||!te||te.disabled||(b(c).value=te.value,b(c).dispatchEvent(new Event("input",{bubbles:!0})),b(c).dispatchEvent(new Event("change",{bubbles:!0})),J())}function H(){if(!b(d)||!b(m))return;const k=b(d).getBoundingClientRect();b(m).style.minWidth=`${k.width}px`,b(m).style.left=`${k.left}px`;const te=b(m).offsetHeight,de=window.innerHeight-k.bottom;de<te&&k.top>de?b(m).style.top=`${Math.max(4,k.top-te-4)}px`:b(m).style.top=`${k.bottom+4}px`}function B(){b(m)?.children[b(_)]?.scrollIntoView({block:"nearest"})}function V(k){const te=k.composedPath();b(d)&&te.includes(b(d))||b(m)&&te.includes(b(m))||J()}function Y(){b(E)||b(y)||!b(m)||(G(y,!0),b(m).showPopover(),H(),G(_,b(v).findIndex(k=>k.value===b(S)),!0),b(_)<0&&G(_,b(v).findIndex(k=>!k.disabled),!0),B(),window.addEventListener("scroll",H,!0),window.addEventListener("resize",H),document.addEventListener("pointerdown",V,!0))}function J(){b(y)&&(G(y,!1),b(m)?.hidePopover(),window.removeEventListener("scroll",H,!0),window.removeEventListener("resize",H),document.removeEventListener("pointerdown",V,!0),b(d)?.focus())}function re(){b(y)?J():Y()}function Z(k){if(!b(v).length)return;let te=b(_);for(let de=0;de<b(v).length;de++)if(te=(te+k+b(v).length)%b(v).length,!b(v)[te]?.disabled){G(_,te,!0),B();return}}function ie(k){const te=k==="start"?b(v).map((de,ye)=>ye):b(v).map((de,ye)=>b(v).length-1-ye);for(const de of te)if(!b(v)[de]?.disabled){G(_,de,!0),B();return}}let he="",pe;function ce(k){he+=k.toLowerCase(),clearTimeout(pe),pe=setTimeout(()=>he="",600);const te=b(v).findIndex(de=>!de.disabled&&de.label.toLowerCase().startsWith(he));te>=0&&(G(_,te,!0),B())}function ve(k){if(!b(E)){if(!b(y)){["ArrowDown","ArrowUp","Enter"," "].includes(k.key)&&(k.preventDefault(),Y());return}switch(k.key){case"ArrowDown":k.preventDefault(),Z(1);break;case"ArrowUp":k.preventDefault(),Z(-1);break;case"Home":k.preventDefault(),ie("start");break;case"End":k.preventDefault(),ie("end");break;case"Enter":case" ":k.preventDefault(),b(_)>=0&&F(b(_));break;case"Escape":k.preventDefault(),J();break;case"Tab":J();break;default:k.key.length===1&&!k.metaKey&&!k.ctrlKey&&ce(k.key)}}}var fe=oa(),we=$(fe);hn(we,()=>({class:"native-select",tabindex:"-1","aria-hidden":"true",...l}),void 0,void 0,void 0,"svelte-1hwvamm");var He=$(we);rn(He,()=>o.children??nr),vi(we,k=>G(c,k),()=>b(c));var xe=_e(we,2);let Xe;xe.__click=re,xe.__keydown=ve;var X=$(xe);let Ye;var ct=$(X);vi(xe,k=>G(d,k),()=>b(d));var Ue=_e(xe,2);gi(Ue,23,()=>b(v),(k,te)=>k.value+"\0"+te,(k,te,de)=>{var ye=sa();let Ke;ye.__click=()=>F(b(de)),ye.__pointermove=()=>G(_,b(de),!0);var St=$(ye);Se(()=>{Ze(ye,"id",`${h}-opt-${b(de)??""}`),Ke=$t(ye,1,"option svelte-1hwvamm",null,Ke,{active:b(de)===b(_),selected:b(te).value===b(S)}),Ze(ye,"aria-selected",b(te).value===b(S)),Ze(ye,"aria-disabled",b(te).disabled),Te(St,b(te).label)}),ge(k,ye)}),vi(Ue,k=>G(m,k),()=>b(m)),Se(()=>{$t(fe,1,`select-wrapper ${i()??""}`,"svelte-1hwvamm"),Zi(fe,s()),Xe=$t(xe,1,"select svelte-1hwvamm",null,Xe,{ghost:r(),open:b(y)}),Zi(xe,b(u)),xe.disabled=b(E),Ze(xe,"aria-expanded",b(y)),Ze(xe,"aria-controls",h),Ze(xe,"aria-activedescendant",b(y)&&b(_)>=0?`${h}-opt-${b(_)}`:void 0),Ze(xe,"aria-label",l["aria-label"]),Ye=$t(X,1,"select-label svelte-1hwvamm",null,Ye,{placeholder:b(P)?.disabled}),Te(ct,b(P)?.label??""),Ze(Ue,"id",h)}),To(we,e),ge(n,fe),Li()}Qr(["click","keydown","pointermove"]);function Bt(n){return n?.id||n?.["@id"]||n?.__jsonld?.id||n?.__jsonld?.["@id"]||(typeof n?.getId=="function"?n.getId():null)||null}function Ht(n){return Bt(n)||(typeof n?.getCanvasId=="function"?n.getCanvasId():null)||(typeof n?.getId=="function"?n.getId():null)||""}function aa(n){const o=n?.behavior||n?.__jsonld?.behavior||(typeof n?.getBehavior=="function"?n.getBehavior():[]);return o?(Array.isArray(o)?o:[o]).map(t=>{const r=String(t).trim().toLowerCase(),i=r.split(/[#/:]/);return i[i.length-1]||r}):[]}function yn(n){const o=aa(n);return o.includes("non-paged")||o.includes("facing-pages")}function la(n,o){const e=[];for(let t=0;t<Math.min(o,n.length);t++){const r=n[t],i=Ht(r);e.push({startIndex:t,endIndex:t,entries:i?[{canvasId:i,canvas:r}]:[]})}for(let t=o;t<n.length;){const r=n[t],i=Ht(r),s=n[t+1],l=Ht(s),a=!!s&&!!i&&!!l&&!yn(r)&&!yn(s);e.push({startIndex:t,endIndex:a?t+1:t,entries:[...i?[{canvasId:i,canvas:r}]:[],...a?[{canvasId:l,canvas:s}]:[]]}),t+=a?2:1}return e}function ua({canvases:n,currentCanvasId:o,currentCanvasIndex:e,viewingMode:t,pagedOffset:r}){if(!o)return[];if(e<0||e>=n.length)return[];const i=[],s=n[e];return s?t!=="paged"?(i.push({canvasId:o,canvas:s}),i):la(n,r).find(({startIndex:a,endIndex:u})=>e>=a&&e<=u)?.entries??i:i}function Ti(n,o){if(!n)return"";if(typeof n=="string")return n;if(typeof n=="object"&&!Array.isArray(n)){const e=n;if("@value"in e){const i=e["@value"];return Array.isArray(i)&&i.length>0?String(i[0]):i===void 0?"":String(i)}const t=Object.keys(e),r=i=>{const s=e[i];if(s!==void 0)return Array.isArray(s)&&s.length>0?String(s[0]):String(s)};for(const i of["en","none"]){const s=r(i);if(s!==void 0)return s}return t.length>0?r(t[0])??"":""}if(Array.isArray(n)&&n.length>0){if(typeof n[0]=="string")return n[0];const e=n,t=l=>l?.value??l?._value,i=(l=>e.find(a=>a.locale===l||a._locale===l||a.language===l))("en");{const l=t(i);if(l)return l}const s=e.find(l=>!l.locale&&!l._locale&&!l.language);{const l=t(s);if(l)return l}return t(e[0])??""}return String(n)}function _n(n,o){const e=o===void 0?"Untitled canvas":`Canvas ${o+1}`;try{const r=n.getLabel?.();if(Array.isArray(r)&&r.length>0)return Ti(r)||e}catch{}const t=n.label||n.__jsonld?.label;if(t){const r=Ti(t);if(r)return r}return e}function Ki(n){if(!n)return null;const o=n.match(/xywh=(?:pixel:)?([\d.]+),([\d.]+),([\d.]+),([\d.]+)/);return o?[Number(o[1]),Number(o[2]),Number(o[3]),Number(o[4])]:null}function ha(n){const[o]=n.split("#");return o||null}function Qi(n){if(!n)return null;if(typeof n=="string")return n;if(Array.isArray(n)){for(const e of n){const t=Qi(e);if(t)return t}return null}if(typeof n!="object")return null;const o=n;return typeof o.id=="string"?o.id:typeof o["@id"]=="string"?o["@id"]:o.source?Qi(o.source):null}function Ji(n){if(!n)return[];if(Array.isArray(n))return n.flatMap(e=>Ji(e));if(typeof n!="object")return[];const o=n;return o.item?Ji(o.item):[o]}function ca(n){const o=n.find(t=>t?.type==="FragmentSelector"&&typeof t?.value=="string"&&t.value.includes("xywh="));if(o)return Ki(o.value);const e=n.find(t=>typeof t?.value=="string"&&t.value.includes("xywh="));return e?Ki(e.value):null}function Tn(n){if(!n)return[];if(Array.isArray(n))return n.flatMap(r=>Tn(r));const o=Qi(n),e=typeof n=="object"&&n&&"selector"in n?Ji(n.selector):[],t=ca(e)||(o?Ki(o):null);return[{raw:n,targetId:o,canvasId:o?ha(o):null,selectors:e,xywh:t}]}function xn(n){return n.endsWith("/info.json")?n.slice(0,-10):n}function zt(n){return typeof n=="number"&&Number.isFinite(n)&&n>0?n:null}function da(n){const o=n?.__jsonld||n;return{width:zt(n?.width)||zt(o?.width)||(typeof n?.getWidth=="function"?zt(n.getWidth()):null),height:zt(n?.height)||zt(o?.height)||(typeof n?.getHeight=="function"?zt(n.getHeight()):null)}}function En(n){const o=n?.__jsonld||n;return o?.type==="SpecificResource"&&o?.source?o.source:null}function fa(n,o){return o?.type==="Choice"||o?.type==="oa:Choice"||!!n&&!Array.isArray(n)&&(n.type==="Choice"||n.type==="oa:Choice")}function bn(n,o){return o&&(o.items||o.item)?o.items||o.item:Array.isArray(n)?n:n&&(n.items||n.item)?n.items||n.item:[]}function pa({body:n,rawBody:o,canvasId:e,getSelectedChoice:t}){const r=Array.isArray(n)?n:bn(n,null),i=bn(null,o),s=t?.(e);if(s){const l=r.find(u=>Bt(u)===s);if(l)return l;const a=i.findIndex(u=>Bt(u)===s);if(a>=0)return r[a]||i[a]}return r[0]||i[0]||null}function ga(n){let o=n.getImages?.()||[];return(!o||!o.length)&&n.getContent&&(o=n.getContent()),o||[]}function ma(n){const o=n?.width||n?.__jsonld?.width||(typeof n?.getWidth=="function"?n.getWidth():null),e=n?.height||n?.__jsonld?.height||(typeof n?.getHeight=="function"?n.getHeight():null);return typeof o!="number"||typeof e!="number"?null:{width:o,height:e}}function va(n){const o=Tn(n?.target||n?.__jsonld?.target).find(e=>e.xywh)?.xywh;return o?{x:o[0],y:o[1],width:o[2],height:o[3]}:null}function wa(n,o){if(typeof n!="string"||!n.trim())return null;const e=n.trim(),t=e.startsWith("pct:"),i=(t?e.slice(4):e).split(",").map(s=>Number(s.trim()));return i.length!==4||i.some(s=>!Number.isFinite(s)||s<0)?null:t?typeof o.width!="number"||typeof o.height!="number"?null:{x:i[0]/100*o.width,y:i[1]/100*o.height,width:i[2]/100*o.width,height:i[3]/100*o.height}:{x:i[0],y:i[1],width:i[2],height:i[3]}}function ya(n,o){const e=n?.__jsonld||n;return wa(e?.selector?.type==="ImageApiSelector"?e.selector.region:null,o)}function _a(n){return[n.x,n.y,n.width,n.height].map(o=>Math.round(o)).join(",")}function Ta(n){const o=n?.__jsonld||n,e=En(n);return!!(n&&(n.id||n["@id"]||o?.service||e||o?.id||o?.["@id"]))}function xa(n,o,e){let t=n.getResource?n.getResource():null;if(!t&&n.getBody){const r=n.getBody(),i=n.__jsonld?.body||n.body;fa(r,i)?t=pa({body:r,rawBody:i,canvasId:o,getSelectedChoice:e}):Array.isArray(r)&&r.length>0?t=r[0]:r&&(t=r)}if(t&&!Ta(t)&&(t=null),!t){const r=n.__jsonld||n;if(r.body){let i=r.body;if(i.type==="Choice"||i.type==="oa:Choice"){const s=i.items||i.item||[],l=e?.(o);i=(l?s.find(u=>Bt(u)===l):null)||s[0]||null}t=Array.isArray(i)?i[0]:i}}return t}function Sn(n){return typeof n=="string"?/^https?:\/\/iiif\.io\/api\/image\//.test(n)||n==="level0"||n==="level1"||n==="level2":Array.isArray(n)?n.some(o=>Sn(o)):!1}function Ea(n){return typeof n=="string"?n||null:Array.isArray(n)&&n.find(e=>typeof e=="string")||null}function ba(n){let o=[];const e=n?.__jsonld||n;return e?.service&&(o=Array.isArray(e.service)?e.service:[e.service]),!o.length&&n?.getServices&&(o=n.getServices()),o.length&&o.find(t=>{const r=t.getType?t.getType():t.type||t["@type"]||"",i=t.getProfile?t.getProfile():t.profile||"";return r==="ImageService1"||r==="ImageService2"||r==="ImageService3"||Sn(i)})||null}function Sa(n,o){for(const e of[n,o]){if(!e)continue;try{const r=e.getLabel?.();if(Array.isArray(r)&&r.length>0){const i=Ti(r);if(i)return i}}catch{}const t=e.label||e.__jsonld?.label;if(t){const r=Ti(t);if(r)return r}}return null}function Pa(n){const o=ba(n),e=Bt(o),t=o?o.getProfile?o.getProfile():o.profile||"":null;return{serviceId:e?xn(e):null,serviceProfile:Ea(t)}}function Ra(n){if(!n||!n.includes("/iiif/"))return null;const o=n.split("/"),e=o.findIndex(t=>t==="full"||/^\d+,\d+,\d+,\d+$/.test(t));return e>0?o.slice(0,e).join("/"):null}function xi(n,o={}){const e=Ht(n);if(!e)return[];const t=ma(n);if(!t)return[];const r=ga(n);return r.length?r.map(i=>{const s=xa(i,e,o.getSelectedChoice),l=En(s)||s;if(!l)return null;const a=Bt(l),u=da(l),h=Pa(l),c=h.serviceId||Ra(a),d=va(i),m=ya(s,u);return{canvasId:e,annotation:i,resource:l,resourceId:a,label:Sa(l,i),canvasWidth:t.width,canvasHeight:t.height,resourceWidth:m?.width||u.width,resourceHeight:m?.height||u.height,serviceId:c,serviceProfile:h.serviceProfile,imageApiRegion:m,x:d?d.x/t.width:0,y:d?d.y/t.width:0,width:d?d.width/t.width:1}}).filter(i=>i!==null):[]}function Ca(n,o={width:1600}){const e=xn(n),t=o.region||"full",r=o.quality||"default",i=o.format||"jpg",s=typeof o.width=="number"?Math.max(1,Math.round(o.width)):null,l=typeof o.height=="number"?Math.max(1,Math.round(o.height)):null,a=o.size||(s?`${s},`:`,${l||1600}`);return`${e}/${t}/${a}/0/${r}.${i}`}function Da(n){return typeof n=="string"?n:Array.isArray(n)&&typeof n[0]=="string"?n[0]:null}function Ei(n){const o=Da(n);return o?o==="level0"||o.endsWith("/level0.json")||o.endsWith("#level0"):!1}function Aa(n,o,e,t){if(!n?.IIIFTileSource?.prototype)return o;try{const r=n.IIIFTileSource.prototype.configure.call({},o,e,null),i=new n.IIIFTileSource(r);return Ia(i,t),i}catch{return o}}function Ia(n,o){if(!Ei(n?.profile)||typeof n?.getTileUrl!="function"||n.__triiiceratopsLevel0LowZoomPrepared)return;const e=n.getTileUrl.bind(n),t=typeof n.getNumTiles=="function"?n.getNumTiles.bind(n):null,r=La(),i=Fa(n),s=Oa(n,i,t);t&&(n.getNumTiles=function(l){return Rn(l,s,i,this)?{x:0,y:0}:Pn(this,l,r,i,t,s)?{x:1,y:1}:t(l)}),typeof n?.minLevel=="number"&&s>=0&&(n.minLevel=Math.max(n.minLevel,s)),n.getTileUrl=function(l,a,u){if(Rn(l,s,i,this)){const h=s>=0?s:l;return e(h,a,u)}return Pn(this,l,r,i,t,s)?Cn(this,l):e(l,a,u)},n.__triiiceratopsLevel0LowZoomPrepared=!0}function Pn(n,o,e,t,r,i){if(i>=0)return!1;if(e>=0&&o<=e||!$i(n,o,t))return!0;if(!r)return!1;const s=r(o);return s?.x===1&&s?.y===1}function Oa(n,o,e){if(!e||typeof n?.minLevel!="number"||typeof n?.maxLevel!="number"||o.size===0)return-1;for(let t=n.minLevel;t<=n.maxLevel;t++){if(!$i(n,t,o))continue;const r=e(t);if(r?.x>1||r?.y>1)return t}return-1}function Rn(n,o,e,t){return o<0?!1:n<o?!0:!$i(t,n,e)}function Fa(n){const o=new Set,e=n?.scale_factors;if(Array.isArray(e))for(const t of e)typeof t=="number"&&t>0&&o.add(t);return o}function $i(n,o,e){if(e.size===0||typeof n?.maxLevel!="number"||typeof o!="number")return!0;const t=Math.pow(2,n.maxLevel-o);return e.has(t)}function La(n,o){return-1}function Cn(n,o){const e=n.getLevelScale(o),t=Math.ceil(n.width*e),r=Math.ceil(n.height*e),i=n.version===3,s=Ei(n?.profile),l=i?t===n.width&&r===n.height?"max":s?`${t},`:`${t},${r}`:t===n.width?"full":`${t},`,a=i?"default":"native";return`${n._id}/full/${l}/0/${a}.${n.tileFormat}`}const bi=8e3,Dn=4e7;function Ma(n,o,e,t){const r=Math.max(1,Math.round(n.width*o*t)),i=n.resourceWidth&&n.resourceHeight?n.resourceHeight/n.resourceWidth:e/o;return{x:Math.round(n.x*o*t),y:Math.round(n.y*e*t),width:r,height:Math.max(1,Math.round(r*i))}}function Ba(n,o){const e=URL.createObjectURL(n),t=document.createElement("a");t.href=e,t.download=o,document.body.appendChild(t),t.click(),t.remove(),URL.revokeObjectURL(e)}async function er(n,o){const e=await fetch(n,o);if(!e.ok)throw new Error(`Image request failed with ${e.status}.`);return e.blob()}async function Ha(n){const o=URL.createObjectURL(n);try{return await new Promise((e,t)=>{const r=new Image;r.onload=()=>e(r),r.onerror=()=>t(new Error("Unable to decode image for export.")),r.src=o})}finally{URL.revokeObjectURL(o)}}async function An(n,o,e,t="image/png"){const r=document.createElement("canvas");r.width=Math.max(1,Math.round(o)),r.height=Math.max(1,Math.round(e));const i=r.getContext("2d");if(!i)throw new Error("Unable to create a canvas for image export.");for(const s of n){const l=await Ha(s.blob);i.drawImage(l,s.x,s.y,s.width,s.height)}return new Promise((s,l)=>{r.toBlob(a=>{if(a){s(a);return}l(new Error("Unable to export composed image."))},t)})}function In(n,o){let e=1;n>bi&&(e=Math.min(e,bi/n)),o>bi&&(e=Math.min(e,bi/o));const t=n*o;return t*e*e>Dn&&(e=Math.min(e,Math.sqrt(Dn/t))),e>=1?{width:Math.round(n),height:Math.round(o),clamped:!1}:{width:Math.max(1,Math.round(n*e)),height:Math.max(1,Math.round(o*e)),clamped:!0}}function ii(n,o={}){if(Ei(n.serviceProfile))return n.resourceId??null;if(n.serviceId){const e=n.imageApiRegion?_a(n.imageApiRegion):void 0,t=!!(o.width||o.height);return Ca(n.serviceId,{region:e,size:t?void 0:"max",width:o.width,height:o.height})}return n.resourceId??null}async function za(n){if(!n.serviceId)return[];const o=n.serviceId.endsWith("/info.json")?n.serviceId:`${n.serviceId}/info.json`;try{const e=await fetch(o);if(!e.ok)return[];const t=await e.json(),r=await Promise.resolve().then(()=>Al),i=r.default||r,s=Aa(i,t,o);if(!s||typeof s.minLevel!="number"||typeof s.maxLevel!="number"||typeof s.getLevelScale!="function")return[];const l=new Set,a=[];for(let u=s.minLevel;u<=s.maxLevel;u+=1){const h=s.getLevelScale(u),c=Math.ceil(s.width*h),d=Math.ceil(s.height*h),m=`${c}x${d}`;l.has(m)||(l.add(m),a.push({width:c,height:d,label:`${c} × ${d}px`,url:Cn(s,u)}))}return a.sort((u,h)=>h.width-u.width)}catch{return[]}}const ka=[{fraction:1,label:"Original"},{fraction:.5,label:"50%"},{fraction:.25,label:"25%"}];function tr(n,o,e){return ka.map(({fraction:t,label:r})=>{const i=Math.max(1,Math.round(n*t)),s=Math.max(1,Math.round(o*t)),l=e?.({width:i,height:s,isOriginal:t===1});return{width:i,height:s,label:`${r} (${i} × ${s}px)`,url:l??void 0}}).filter(t=>!e||!!t.url)}function Na(n){const o=n.resourceWidth,e=n.resourceHeight;if(!n.serviceId||!o||!e){const t=ii(n);return t?[{width:o??0,height:e??0,label:"Original",url:t}]:[]}return tr(o,e,({width:t,height:r,isOriginal:i})=>ii(n,i?{}:{width:t,height:r}))}async function Ua(n){if(Ei(n.serviceProfile)){const o=await za(n);return o.length?o:n.resourceId?[{width:n.resourceWidth??0,height:n.resourceHeight??0,label:"Original",url:n.resourceId}]:[]}return Na(n)}const Wa=.0125;function Va(n){return!!n&&typeof n=="object"&&"tileSource"in n}function On(n,o){if(!n||typeof n!="object")return null;const e=n[o];return typeof e=="number"&&Number.isFinite(e)&&e>0?e:null}function ja(n,o,e){return Math.min(e,Math.max(o,n))}function Ga(n){const o=[...n].sort((t,r)=>t-r),e=Math.floor(o.length/2);return o.length%2===0?(o[e-1]+o[e])/2:o[e]}function qa(n){const o=new Map;return n.forEach((e,t)=>{const r=Va(e),i=r?e.tileSource:e,s=r?e.canvasId??`canvas-${t}`:`canvas-${t}`,l=r?e.x??0:0,a=r?e.y??0:0,u=r?e.width??1:1,h=On(i,"width"),c=On(i,"height"),d=h&&c?u*c/h:null;let m=o.get(s);m||(m={canvasId:s,sources:[],width:0,height:null},o.set(s,m)),m.sources.push({source:e,tileSource:i,localX:l,localY:a,localWidth:u,localHeight:d}),m.width=Math.max(m.width,l+u),m.height=d===null?null:Math.max(m.height??0,a+d)}),[...o.values()]}function Za(n){return{layouts:n.map(o=>({canvasId:o.canvasId,x:0,y:0,width:o.width,height:o.height??1})),sources:n.flatMap(o=>o.sources.map(({tileSource:e,localX:t,localY:r,localWidth:i})=>({tileSource:e,x:t,y:r,width:i,canvasId:o.canvasId})))}}function Xa(n,o){const e=qa(n);if(o.mode==="individuals"||e.length<=1)return Za(e);const t=!o.preserveCanvasScale&&e.every(s=>s.height!==null),r=t?Ga(e.map(s=>s.height)):1,i=e.map(s=>{const l=t?ja(r/s.height,.25,4):1;return{group:s,scale:l,width:s.width*l,height:(s.height??1)*l,x:0,y:0}});if(o.mode==="continuous"){let s=0;const l=o.direction==="top-to-bottom"||o.direction==="bottom-to-top",a=o.direction==="right-to-left"||o.direction==="bottom-to-top";for(const u of i)l?(u.y=a?-s:s,s+=(t?u.height:1)+o.gap):(u.x=a?-s:s,s+=(t?u.width:1)+o.gap)}else if(o.mode==="paged"){const s=Math.max(...i.map(a=>a.height)),l=o.direction==="right-to-left";i.forEach((a,u)=>{const h=l?i.slice(u+1):i.slice(0,u);a.x=h.reduce((c,d)=>c+(t?d.width:1)+o.gap,0),a.y=(s-a.height)/2})}return{layouts:i.map(s=>({canvasId:s.group.canvasId,x:s.x,y:s.y,width:s.width,height:s.height})),sources:i.flatMap(s=>s.group.sources.map(({tileSource:l,localX:a,localY:u,localWidth:h})=>({tileSource:l,x:s.x+a*s.scale,y:s.y+u*s.scale,width:h*s.scale,canvasId:s.group.canvasId})))}}function Ya(n,o,e){Jo(n,"@triiiceratops/plugin-image-export","1.0.0-rc.0",o,e)}function Ka(n){return n.replace(/[^a-z0-9-_]+/gi,"-").replace(/-+/g,"-").replace(/^-|-$/g,"")}function Qa(n,o,e){const r=Ka(n)||"image",i=o==="single"?"":`-${o}`;return`${r}${i}.png`}function Fn(n,o){return xi(n,{getSelectedChoice:o})}function Ja(n){return Ua(n)}function $a(n,o){const t=xi(n,{getSelectedChoice:o})[0];return!t?.canvasWidth||!t?.canvasHeight?[]:tr(t.canvasWidth,t.canvasHeight)}async function el(n,o){const e=o.url??ii(n,{width:o.width,height:o.height});if(!e)throw new Error("No exportable image found for this canvas.");return er(e)}async function tl(n,o,e={}){const t=xi(n,{getSelectedChoice:e.getSelectedChoice}),r=t[0];if(!r)throw new Error("No exportable image found for this canvas.");const{canvasWidth:i,canvasHeight:s}=r;if(!i||!s)throw new Error("Unable to determine canvas dimensions for export.");const{width:l,height:a}=In(o.width,o.height),u=l/i,h=await Promise.all(t.map(async c=>il(c,i,s,u)));return An(h,l,a,e.format??"image/png")}async function il(n,o,e,t){const r=Ma(n,o,e,t),i=ii(n,{width:r.width});if(!i)throw new Error("No exportable image found for this canvas.");return{blob:await er(i),...r}}function Ln(n){return ua({canvases:n.canvases,currentCanvasId:n.canvasId,currentCanvasIndex:n.currentCanvasIndex,viewingMode:n.viewingMode,pagedOffset:n.pagedOffset}).map(o=>o.canvas)}function Mn(n,o){const e=Ln(n);if(!e.length)return null;const t=e.flatMap((c,d)=>{const m=Ht(c)??`canvas-${d}`;return xi(c,{getSelectedChoice:o}).map(v=>({canvasId:m,x:v.x,y:v.y,width:v.width,tileSource:{width:v.resourceWidth||v.canvasWidth,height:v.resourceHeight||v.canvasHeight,resolved:v}}))});if(!t.length)return null;const{layouts:r,sources:i}=Xa(t,{mode:n.viewingMode,direction:n.viewingDirection,preserveCanvasScale:n.preserveCanvasScale,gap:Wa});if(!r.length)return null;const s=Math.min(...r.map(c=>c.x)),l=Math.min(...r.map(c=>c.y)),a=Math.max(...r.map(c=>c.x+c.width)),u=Math.max(...r.map(c=>c.y+c.height));return{entries:i.map(c=>({resolved:c.tileSource.resolved,x:c.x-s,y:c.y-l,width:c.width})),worldWidth:a-s,worldHeight:u-l}}function rl(n,o){const e=Mn(n,o);if(!e)return[];const t=e.entries[0],r=t?.resolved.resourceWidth&&t.width>0?t.resolved.resourceWidth/t.width:1600,i=Math.round(e.worldWidth*r),s=Math.round(e.worldHeight*r);return!i||!s?[]:tr(i,s)}async function nl(n,o,e={}){const t=Mn(n,e.getSelectedChoice);if(!t)throw new Error("Nothing is currently displayed in the viewer.");const{width:r,height:i}=In(o.width,o.height),s=r/t.worldWidth,l=await Promise.all(t.entries.map(async({resolved:a,x:u,y:h,width:c})=>{const d=Math.max(1,Math.round(c*s)),m=a.resourceWidth&&a.resourceHeight?a.resourceHeight/a.resourceWidth:1,v=Math.max(1,Math.round(d*m)),y=ii(a,{width:d});if(!y)throw new Error("No exportable image found for the current view.");return{blob:await er(y),x:Math.round(u*s),y:Math.round(h*s),width:d,height:v}}));return An(l,r,i,e.format??"image/png")}var sl=me("<option> </option>"),ol=me("<option> </option>"),al=me("<!> <option> </option> <!>",1),ll=me('<div class="tri-id-field"><label class="tri-id-label" for="tri-id-mode"><span> </span></label> <!></div>'),ul=me("<option> </option>"),hl=me('<div class="tri-id-field"><label class="tri-id-label" for="tri-id-canvas"><span> </span></label> <!></div>'),cl=me("<option> </option>"),dl=me('<div class="tri-id-field"><label class="tri-id-label" for="tri-id-image"><span> </span></label> <!></div>'),fl=me("<option> </option>"),pl=me("<option disabled> </option> <!>",1),gl=me('<div class="tri-id-alert is-success" data-tri-id-result=""><span> </span></div>'),ml=me('<div class="tri-id-alert is-error" data-tri-id-error=""><span> </span></div>'),vl=me('<div class="tri-id-alert"><span> </span></div>'),wl=me('<div class="tri-id-card"><div class="tri-id-card-body"><!> <!> <!></div></div>'),yl=me('<span aria-hidden="true"></span> ',1),_l=me('<div class="tri-id" data-tri-id="" data-panel-id="image-download"><div class="tri-id-body"><p class="tri-id-desc"> </p> <div class="tri-id-fields"><!> <!> <!> <div class="tri-id-field"><label class="tri-id-label" for="tri-id-resolution"><span> </span></label> <!></div></div> <!></div> <div class="tri-id-footer"><!></div></div>');function Tl(n,o){Fi(o,!0);const{context:e}=Es(vn),{viewerState:t,selectors:r,locale:i,ui:s}=e;let l=ue(0),a=ue(0);r.select(I=>[I.canvasId,I.currentCanvasIndex,I.canvases,I.viewingMode,I.viewingDirection,I.pagedOffset,I.preserveCanvasScale]).subscribe(()=>{xr(l)}),i.subscribe(()=>{xr(a)});const u=(I,D)=>(b(a),i.t(I,D));let h=ue("single"),c=ue(0),d=ue(0),m=ue(lt([])),v=ue(null),y=ue(!1),_=ue(!1),E=ue(""),S=ue(""),P=ue(null);const L=I=>t.getSelectedChoice(I),F=le(()=>(b(l),t.currentCanvasIndex>=0?t.canvases[t.currentCanvasIndex]??null:null)),H=le(()=>(b(l),b(F)?Fn(b(F),L):[])),B=le(()=>b(H).length>1),V=le(()=>b(B)),Y=le(()=>(b(l),Ln(t))),J=le(()=>b(Y).length>1),re=le(()=>b(J)),Z=le(()=>b(V)||b(re)),ie=le(()=>(b(l),b(h)==="single"&&b(J)?b(Y)[b(c)]??b(F):b(F))),he=le(()=>(b(l),b(ie)?Fn(b(ie),L):[])),pe=le(()=>b(he).length>1),ce=le(()=>b(v)!==null?b(m)[b(v)]??null:null),ve=le(()=>!b(_)&&!b(y)&&!!b(F)&&!!b(ce)),fe=le(()=>(b(a),b(F)?!b(y)&&!b(m).length?u("image_download_disabled_no_resolution"):null:u("image_download_disabled_no_canvas")));qt(()=>{(b(h)==="composite"&&!b(V)||b(h)==="world"&&!b(re))&&G(h,"single")}),qt(()=>{b(l);const I=t.canvasId,D=b(Y).findIndex(z=>Ht(z)===I);G(c,D>=0?D:0,!0)}),qt(()=>{b(ie),G(d,0)}),qt(()=>{const I=b(F),D=b(h),z=b(d);let j=!1;if(G(m,[],!0),G(v,null),!!I){if(D==="single"){const q=b(he)[z];if(!q)return;G(y,!0),Ja(q).then(U=>{j||(G(m,U,!0),G(v,U.length?0:null,!0))}).finally(()=>{j||G(y,!1)})}else if(D==="composite"){const q=$a(I,L);G(m,q,!0),G(v,q.length?0:null,!0)}else{const q=rl(t,L);G(m,q,!0),G(v,q.length?0:null,!0)}return()=>{j=!0}}});function we(I){const D=Number(I);return Number.isInteger(D)?D:0}async function He(){if(!(!b(F)||!b(ce)||!b(ve))){G(_,!0),G(E,""),G(S,"");try{let I,D=b(F);if(b(h)==="single"){D=b(ie);const j=b(he)[b(d)];if(!j)return;I=await el(j,b(ce))}else b(h)==="composite"?I=await tl(b(F),b(ce),{getSelectedChoice:L}):I=await nl(t,b(ce),{getSelectedChoice:L});const z=Qa(_n(D,t.currentCanvasIndex),b(h),"image/png");Ba(I,z),G(S,u("image_download_result_downloaded",{filename:z}),!0)}catch(I){G(E,u("image_download_error_failed"),!0),b(P)&&Ya(b(P),I,()=>void He())}finally{G(_,!1)}}}function xe(I){return{destroy:s.renderIcon(wn,I)}}var Xe=_l(),X=$(Xe),Ye=$(X),ct=$(Ye),Ue=_e(Ye,2),k=$(Ue);{var te=I=>{var D=ll(),z=$(D),j=$(z),q=$(j),U=_e(z,2);{let K=le(()=>u("image_download_mode"));_i(U,{id:"tri-id-mode",class:"tri-id-field-select","data-tri-id-mode":!0,get"aria-label"(){return b(K)},get disabled(){return b(_)},get value(){return b(h)},onchange:g=>{G(h,g.currentTarget.value,!0)},children:(g,p)=>{var w=al(),x=jt(w);{var C=oe=>{var se=sl(),Qe=$(se);se.value=se.__value="composite",Se(Ut=>Te(Qe,Ut),[()=>u("image_download_mode_composite")]),ge(oe,se)};st(x,oe=>{b(V)&&oe(C)})}var A=_e(x,2),N=$(A);A.value=A.__value="single";var Q=_e(A,2);{var W=oe=>{var se=ol(),Qe=$(se);se.value=se.__value="world",Se(Ut=>Te(Qe,Ut),[()=>u("image_download_mode_world")]),ge(oe,se)};st(Q,oe=>{b(re)&&oe(W)})}Se(oe=>Te(N,oe),[()=>u("image_download_mode_single")]),ge(g,w)},$$slots:{default:!0}})}Se(K=>Te(q,K),[()=>u("image_download_mode")]),ge(I,D)};st(k,I=>{b(Z)&&I(te)})}var de=_e(k,2);{var ye=I=>{var D=hl(),z=$(D),j=$(z),q=$(j),U=_e(z,2);{let K=le(()=>u("image_download_canvas"));_i(U,{id:"tri-id-canvas",class:"tri-id-field-select",get"aria-label"(){return b(K)},get disabled(){return b(_)},get value(){return b(c)},onchange:g=>{G(c,we(g.currentTarget.value),!0)},children:(g,p)=>{var w=$r(),x=jt(w);gi(x,17,()=>b(Y),Vi,(C,A,N)=>{var Q=ul(),W=$(Q);Q.value=Q.__value=N,Se(oe=>Te(W,oe),[()=>_n(b(A),N)]),ge(C,Q)}),ge(g,w)},$$slots:{default:!0}})}Se(K=>Te(q,K),[()=>u("image_download_canvas")]),ge(I,D)};st(de,I=>{b(h)==="single"&&b(J)&&I(ye)})}var Ke=_e(de,2);{var St=I=>{var D=dl(),z=$(D),j=$(z),q=$(j),U=_e(z,2);{let K=le(()=>u("image_download_image"));_i(U,{id:"tri-id-image",class:"tri-id-field-select",get"aria-label"(){return b(K)},get disabled(){return b(_)},get value(){return b(d)},onchange:g=>{G(d,we(g.currentTarget.value),!0)},children:(g,p)=>{var w=$r(),x=jt(w);gi(x,17,()=>b(he),Vi,(C,A,N)=>{var Q=cl(),W=$(Q);Q.value=Q.__value=N,Se(oe=>Te(W,oe),[()=>b(A).label??`${u("image_download_image")} ${N+1}`]),ge(C,Q)}),ge(g,w)},$$slots:{default:!0}})}Se(K=>Te(q,K),[()=>u("image_download_image")]),ge(I,D)};st(Ke,I=>{b(h)==="single"&&b(pe)&&I(St)})}var kt=_e(Ke,2),Nt=$(kt),Pt=$(Nt),dt=$(Pt),f=_e(Nt,2);{let I=le(()=>u("image_download_resolution")),D=le(()=>b(_)||b(y)||!b(m).length),z=le(()=>b(v)??"");_i(f,{id:"tri-id-resolution",class:"tri-id-field-select","data-tri-id-resolution":!0,get"aria-label"(){return b(I)},get disabled(){return b(D)},get value(){return b(z)},onchange:j=>{G(v,we(j.currentTarget.value),!0)},children:(j,q)=>{var U=pl(),K=jt(U),g=$(K);K.value=K.__value="";var p=_e(K,2);gi(p,17,()=>b(m),Vi,(w,x,C)=>{var A=fl(),N=$(A);A.value=A.__value=C,Se(()=>Te(N,b(x).label)),ge(w,A)}),Se(w=>Te(g,w),[()=>u("image_download_resolution_placeholder")]),ge(j,U)},$$slots:{default:!0}})}var T=_e(Ue,2);{var R=I=>{var D=wl(),z=$(D),j=$(z);{var q=w=>{var x=gl(),C=$(x),A=$(C);Se(()=>Te(A,b(S))),ge(w,x)};st(j,w=>{b(S)&&w(q)})}var U=_e(j,2);{var K=w=>{var x=ml(),C=$(x),A=$(C);Se(()=>Te(A,b(E))),ge(w,x)};st(U,w=>{b(E)&&w(K)})}var g=_e(U,2);{var p=w=>{var x=vl(),C=$(x),A=$(C);Se(()=>Te(A,b(fe))),ge(w,x)};st(g,w=>{b(fe)&&w(p)})}ge(I,D)};st(T,I=>{(b(S)||b(E)||b(fe))&&I(R)})}var O=_e(X,2),M=$(O);{let I=le(()=>!b(ve));ra(M,{variant:"primary",class:"tri-id-download","data-tri-id-download":!0,style:"width:100%",get disabled(){return b(I)},onclick:He,children:(D,z)=>{var j=yl(),q=jt(j);go(q,K=>xe?.(K));var U=_e(q);Se(K=>Te(U,` ${K??""}`),[()=>b(_)?u("image_download_downloading"):u("image_download_download")]),ge(D,j)},$$slots:{default:!0}})}vi(Xe,I=>G(P,I),()=>b(P)),Se((I,D)=>{Te(ct,I),Te(dt,D)},[()=>u("image_download_description"),()=>u("image_download_resolution")]),ge(n,Xe),Li()}const{STYLES:xl,STYLE_ID:El}=Qo(`
6
6
  .tri-id {
7
7
  display: flex;
8
8
  flex-direction: column;
package/dist/index.js CHANGED
@@ -2675,7 +2675,7 @@ function se(e, t, r, n) {
2675
2675
  })
2676
2676
  );
2677
2677
  }
2678
- const io = ".btn.svelte-kz0hjp{display:inline-flex;flex-wrap:nowrap;flex-shrink:0;justify-content:center;align-items:center;gap:.375rem;cursor:pointer;text-align:center;vertical-align:middle;user-select:none;-webkit-user-select:none;touch-action:manipulation;font-weight:600;height:var(--size);padding-inline:var(--btn-p);font-size:var(--fontsize, .875rem);color:var(--btn-fg);background-color:var(--btn-bg);border-width:var(--tri-border);border-style:solid;border-color:var(--btn-border);border-start-start-radius:var(--join-ss, var(--tri-radius-buttons));border-start-end-radius:var(--join-se, var(--tri-radius-buttons));border-end-end-radius:var(--join-ee, var(--tri-radius-buttons));border-end-start-radius:var(--join-es, var(--tri-radius-buttons));outline-offset:2px;outline-color:var(--btn-color, var(--tri-content));text-shadow:0 .5px oklch(100% 0 0 / calc(var(--tri-depth) * .15));box-shadow:0 .5px 0 .5px oklch(100% 0 0 / calc(var(--tri-depth) * 6%)) inset,var(--btn-shadow);transition-property:color,background-color,border-color,box-shadow;transition-duration:.2s;transition-timing-function:cubic-bezier(0,0,.2,1);--size: calc(var(--tri-size-field, .25rem) * 10);--btn-bg: var(--btn-color, var(--tri-toolbar-bg));--btn-fg: var(--tri-content);--btn-p: 1rem;--btn-border: color-mix( in oklab, var(--btn-bg), #000 calc(var(--tri-depth) * 5%) );--btn-shadow: 0 3px 2px -2px color-mix( in oklab, var(--btn-bg) calc(var(--tri-depth) * 30%), #0000 ), 0 4px 3px -2px color-mix( in oklab, var(--btn-bg) calc(var(--tri-depth) * 30%), #0000 )}@media(hover:hover){.btn.svelte-kz0hjp:hover{--btn-bg: color-mix( in oklab, var(--btn-color, var(--tri-toolbar-bg)), #000 7% )}}.btn.svelte-kz0hjp:focus-visible{isolation:isolate;outline-width:2px;outline-style:solid}.btn.svelte-kz0hjp:active:not(.active){--btn-bg: color-mix( in oklab, var(--btn-color, var(--tri-toolbar-bg)), #000 5% );--btn-border: color-mix( in oklab, var(--btn-color, var(--tri-toolbar-bg)), #000 7% );--btn-shadow: 0 0 0 0 oklch(0% 0 0 / 0), 0 0 0 0 oklch(0% 0 0 / 0);translate:0 .5px}.btn.active.svelte-kz0hjp{--btn-bg: color-mix( in oklab, var(--btn-color, var(--tri-toolbar-bg)), #000 7% )}.btn.svelte-kz0hjp:disabled,.btn[disabled].svelte-kz0hjp{pointer-events:none;--btn-border: #0000;--btn-fg: color-mix(in oklch, var(--tri-content) 20%, #0000)}.btn.svelte-kz0hjp:disabled:not(.ghost):not(.outline),.btn[disabled].svelte-kz0hjp:not(.ghost):not(.outline){background-color:color-mix(in oklab,var(--tri-content) 10%,transparent);box-shadow:none}.circle.svelte-kz0hjp{width:var(--size);height:var(--size);border-radius:3.40282e38px;padding-inline:0}.square.svelte-kz0hjp{width:var(--size);height:var(--size);padding-inline:0}.ghost.svelte-kz0hjp{--btn-bg: transparent;--btn-border: transparent;--btn-fg: var(--btn-color-text, var(--btn-color, var(--tri-content)));box-shadow:none;text-shadow:none}@media(hover:hover){.ghost.svelte-kz0hjp:hover{--btn-bg: color-mix(in oklab, var(--tri-content) 10%, transparent)}}.ghost.svelte-kz0hjp:active:not(.active),.ghost.active.svelte-kz0hjp{--btn-bg: color-mix(in oklab, var(--tri-content) 10%, transparent);--btn-border: transparent}.outline.svelte-kz0hjp:not(:hover):not(:active):not(:focus-visible):not(.active):not(:disabled):not([disabled]){--btn-bg: transparent;--btn-fg: var(--btn-color-text, var(--btn-color, var(--tri-content)));--btn-border: var(--btn-color, var(--tri-content));box-shadow:none;text-shadow:none}.select-wrapper.svelte-1h1ta11{display:inline-flex;width:clamp(3rem,20rem,100%);max-width:100%}.native-select.svelte-1h1ta11{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0 0 0 0);white-space:nowrap;border:0;pointer-events:none}.select.svelte-1h1ta11{border:var(--tri-border) solid var(--input-color);appearance:none;background-color:var(--tri-input-bg);vertical-align:middle;width:100%;height:var(--size);touch-action:manipulation;white-space:nowrap;box-shadow:0 1px color-mix(in oklab,var(--input-color) calc(var(--tri-depth) * 10%),#0000) inset,0 -1px oklch(100% 0 0 / calc(var(--tri-depth) * .1)) inset;--input-color: color-mix(in oklab, var(--tri-content) 20%, #0000);--size: calc(var(--tri-size-field, .25rem) * 10);background-image:linear-gradient(45deg,#0000 50%,currentColor 50%),linear-gradient(135deg,currentColor 50%,#0000 50%);background-position:calc(100% - 20px) calc(1px + 50%),calc(100% - 16.1px) calc(1px + 50%);background-repeat:no-repeat;background-size:4px 4px,4px 4px;border-start-start-radius:var(--join-ss, var(--tri-radius-buttons));border-start-end-radius:var(--join-se, var(--tri-radius-buttons));border-end-end-radius:var(--join-ee, var(--tri-radius-buttons));border-end-start-radius:var(--join-es, var(--tri-radius-buttons));align-items:center;gap:.375rem;padding-inline:.75rem 1.75rem;font-size:.875rem;display:inline-flex;position:relative;cursor:pointer;color:inherit;text-align:start}.select-label.svelte-1h1ta11{flex:1;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.select-label.placeholder.svelte-1h1ta11{color:color-mix(in oklab,var(--tri-content) 55%,transparent)}.select.svelte-1h1ta11:hover:not(:disabled){--input-color: color-mix(in oklab, var(--tri-content) 40%, #0000)}.select.svelte-1h1ta11:focus-visible,.select.open.svelte-1h1ta11{--input-color: var(--tri-content);box-shadow:0 1px color-mix(in oklab,var(--input-color) calc(var(--tri-depth) * 10%),#0000);outline:2px solid var(--input-color);outline-offset:2px;isolation:isolate;z-index:1}.select.svelte-1h1ta11:is(:where(.svelte-1h1ta11):disabled,[disabled]:where(.svelte-1h1ta11)){cursor:not-allowed;border-color:var(--tri-panel-bg);background-color:var(--tri-panel-bg);color:color-mix(in oklab,var(--tri-content) 40%,transparent)}.ghost.svelte-1h1ta11{box-shadow:none;background-color:#0000;border-color:#0000;transition:background-color .2s}.ghost.svelte-1h1ta11:hover:not(:disabled){background-color:color-mix(in oklab,var(--tri-content) 8%,transparent)}.ghost.svelte-1h1ta11:focus-visible,.ghost.open.svelte-1h1ta11{background-color:var(--tri-input-bg);color:var(--tri-content)}.listbox.svelte-1h1ta11{position:fixed;inset:auto;margin:0;padding:.1875rem;border:var(--tri-border) solid color-mix(in oklab,var(--tri-content) 20%,#0000);background-color:var(--tri-input-bg);color:var(--tri-content);border-radius:var(--tri-radius-buttons);box-shadow:0 8px 24px oklch(0 0 0 / calc(.12 + var(--tri-depth) * .06));max-height:16rem;overflow-y:auto;min-width:8rem;z-index:1}.listbox.svelte-1h1ta11:not(:popover-open){display:none}.option.svelte-1h1ta11{padding:.25rem .5rem;border-radius:calc(var(--tri-radius-buttons) * .6);cursor:pointer;font-size:.8125rem;line-height:1.3;white-space:nowrap;color:inherit}.option.active.svelte-1h1ta11{background-color:color-mix(in oklab,var(--tri-content) 12%,#0000)}.option.selected.svelte-1h1ta11{background-color:color-mix(in oklab,var(--tri-color-primary) 90%,#0000);color:var(--tri-color-primary-content)}.option.selected.active.svelte-1h1ta11{background-color:var(--tri-color-primary)}.option[aria-disabled=true].svelte-1h1ta11{opacity:.5;cursor:not-allowed;color:color-mix(in oklab,var(--tri-content) 55%,transparent)}\n", ao = {
2678
+ const io = ".btn.svelte-sgoebi{display:inline-flex;flex-wrap:nowrap;flex-shrink:0;justify-content:center;align-items:center;gap:.375rem;cursor:pointer;text-align:center;vertical-align:middle;user-select:none;-webkit-user-select:none;touch-action:manipulation;font-weight:600;height:var(--size);padding-inline:var(--btn-p);font-size:var(--fontsize, .875rem);color:var(--btn-fg);background-color:var(--btn-bg);border-width:var(--tri-border);border-style:solid;border-color:var(--btn-border);border-start-start-radius:var(--join-ss, var(--tri-radius-buttons));border-start-end-radius:var(--join-se, var(--tri-radius-buttons));border-end-end-radius:var(--join-ee, var(--tri-radius-buttons));border-end-start-radius:var(--join-es, var(--tri-radius-buttons));outline-offset:2px;outline-color:var(--btn-color, var(--tri-content));text-shadow:0 .5px oklch(100% 0 0 / calc(var(--tri-depth) * .15));box-shadow:0 .5px 0 .5px oklch(100% 0 0 / calc(var(--tri-depth) * 6%)) inset,var(--btn-shadow);transition-property:color,background-color,border-color,box-shadow;transition-duration:.2s;transition-timing-function:cubic-bezier(0,0,.2,1);--size: calc(var(--tri-size-field, .25rem) * 10);--btn-bg: var(--btn-color, var(--tri-toolbar-bg));--btn-fg: var(--tri-content);--btn-p: 1rem;--btn-border: color-mix( in oklab, var(--btn-bg), #000 calc(var(--tri-depth) * 5%) );--btn-shadow: 0 3px 2px -2px color-mix( in oklab, var(--btn-bg) calc(var(--tri-depth) * 30%), #0000 ), 0 4px 3px -2px color-mix( in oklab, var(--btn-bg) calc(var(--tri-depth) * 30%), #0000 )}@media(hover:hover){.btn.svelte-sgoebi:hover{--btn-bg: color-mix( in oklab, var(--btn-color, var(--tri-toolbar-bg)), #000 7% )}}.btn.svelte-sgoebi:focus-visible{isolation:isolate;outline-width:2px;outline-style:solid}.btn.svelte-sgoebi:active:not(.active){--btn-bg: color-mix( in oklab, var(--btn-color, var(--tri-toolbar-bg)), #000 5% );--btn-border: color-mix( in oklab, var(--btn-color, var(--tri-toolbar-bg)), #000 7% );--btn-shadow: 0 0 0 0 oklch(0% 0 0 / 0), 0 0 0 0 oklch(0% 0 0 / 0);translate:0 .5px}.btn.active.svelte-sgoebi{--btn-bg: color-mix( in oklab, var(--btn-color, var(--tri-toolbar-bg)), #000 7% )}.btn.svelte-sgoebi:disabled,.btn[disabled].svelte-sgoebi{pointer-events:none;--btn-border: #0000;--btn-fg: color-mix(in oklch, var(--tri-content) 20%, #0000)}.btn.svelte-sgoebi:disabled:not(.ghost):not(.outline),.btn[disabled].svelte-sgoebi:not(.ghost):not(.outline){background-color:color-mix(in oklab,var(--tri-content) 10%,transparent);box-shadow:none}.circle.svelte-sgoebi{width:var(--size);height:var(--size);border-radius:3.40282e38px;padding-inline:0}.square.svelte-sgoebi{width:var(--size);height:var(--size);padding-inline:0}.ghost.svelte-sgoebi{--btn-bg: transparent;--btn-border: transparent;--btn-fg: var(--btn-color-text, var(--btn-color, var(--tri-content)));box-shadow:none;text-shadow:none}@media(hover:hover){.ghost.svelte-sgoebi:hover{--btn-bg: color-mix(in oklab, var(--tri-content) 10%, transparent)}}.ghost.svelte-sgoebi:active:not(.active),.ghost.active.svelte-sgoebi{--btn-bg: color-mix(in oklab, var(--tri-content) 10%, transparent);--btn-border: transparent}.outline.svelte-sgoebi:not(:hover):not(:active):not(:focus-visible):not(.active):not(:disabled):not([disabled]){--btn-bg: transparent;--btn-fg: var(--btn-color-text, var(--btn-color, var(--tri-content)));--btn-border: var(--btn-color, var(--tri-content));box-shadow:none;text-shadow:none}.select-wrapper.svelte-1hwvamm{display:inline-flex;width:clamp(3rem,20rem,100%);max-width:100%}.native-select.svelte-1hwvamm{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0 0 0 0);white-space:nowrap;border:0;pointer-events:none}.select.svelte-1hwvamm{border:var(--tri-border) solid var(--input-color);appearance:none;background-color:var(--tri-input-bg);vertical-align:middle;width:100%;height:var(--size);touch-action:manipulation;white-space:nowrap;box-shadow:0 1px color-mix(in oklab,var(--input-color) calc(var(--tri-depth) * 10%),#0000) inset,0 -1px oklch(100% 0 0 / calc(var(--tri-depth) * .1)) inset;--input-color: color-mix(in oklab, var(--tri-content) 20%, #0000);--size: calc(var(--tri-size-field, .25rem) * 10);background-image:linear-gradient(45deg,#0000 50%,currentColor 50%),linear-gradient(135deg,currentColor 50%,#0000 50%);background-position:calc(100% - 20px) calc(1px + 50%),calc(100% - 16.1px) calc(1px + 50%);background-repeat:no-repeat;background-size:4px 4px,4px 4px;border-start-start-radius:var(--join-ss, var(--tri-radius-buttons));border-start-end-radius:var(--join-se, var(--tri-radius-buttons));border-end-end-radius:var(--join-ee, var(--tri-radius-buttons));border-end-start-radius:var(--join-es, var(--tri-radius-buttons));align-items:center;gap:.375rem;padding-inline:.75rem 1.75rem;font-size:.875rem;display:inline-flex;position:relative;cursor:pointer;color:inherit;text-align:start}.select-label.svelte-1hwvamm{flex:1;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.select-label.placeholder.svelte-1hwvamm{color:color-mix(in oklab,var(--tri-content) 55%,transparent)}.select.svelte-1hwvamm:hover:not(:disabled){--input-color: color-mix(in oklab, var(--tri-content) 40%, #0000)}.select.svelte-1hwvamm:focus-visible,.select.open.svelte-1hwvamm{--input-color: var(--tri-content);box-shadow:0 1px color-mix(in oklab,var(--input-color) calc(var(--tri-depth) * 10%),#0000);outline:2px solid var(--input-color);outline-offset:2px;isolation:isolate;z-index:1}.select.svelte-1hwvamm:is(:where(.svelte-1hwvamm):disabled,[disabled]:where(.svelte-1hwvamm)){cursor:not-allowed;border-color:var(--tri-panel-bg);background-color:var(--tri-panel-bg);color:color-mix(in oklab,var(--tri-content) 40%,transparent)}.ghost.svelte-1hwvamm{box-shadow:none;background-color:#0000;border-color:#0000;transition:background-color .2s}.ghost.svelte-1hwvamm:hover:not(:disabled){background-color:color-mix(in oklab,var(--tri-content) 8%,transparent)}.ghost.svelte-1hwvamm:focus-visible,.ghost.open.svelte-1hwvamm{background-color:var(--tri-input-bg);color:var(--tri-content)}.listbox.svelte-1hwvamm{position:fixed;inset:auto;margin:0;padding:.1875rem;border:var(--tri-border) solid color-mix(in oklab,var(--tri-content) 20%,#0000);background-color:var(--tri-input-bg);color:var(--tri-content);border-radius:var(--tri-radius-buttons);box-shadow:0 8px 24px oklch(0 0 0 / calc(.12 + var(--tri-depth) * .06));max-height:16rem;overflow-y:auto;min-width:8rem;z-index:1}.listbox.svelte-1hwvamm:not(:popover-open){display:none}.option.svelte-1hwvamm{padding:.25rem .5rem;border-radius:calc(var(--tri-radius-buttons) * .6);cursor:pointer;font-size:.8125rem;line-height:1.3;white-space:nowrap;color:inherit}.option.active.svelte-1hwvamm{background-color:color-mix(in oklab,var(--tri-content) 12%,#0000)}.option.selected.svelte-1hwvamm{background-color:color-mix(in oklab,var(--tri-color-primary) 90%,#0000);color:var(--tri-color-primary-content)}.option.selected.active.svelte-1hwvamm{background-color:var(--tri-color-primary)}.option[aria-disabled=true].svelte-1hwvamm{opacity:.5;cursor:not-allowed;color:color-mix(in oklab,var(--tri-content) 55%,transparent)}\n", ao = {
2679
2679
  en: {
2680
2680
  image_download_title: "Download Image",
2681
2681
  image_download_close: "Close Download Image",
@@ -2773,13 +2773,13 @@ function fo(e, t) {
2773
2773
  void 0,
2774
2774
  void 0,
2775
2775
  void 0,
2776
- "svelte-kz0hjp"
2776
+ "svelte-sgoebi"
2777
2777
  );
2778
2778
  var h = S(w);
2779
2779
  Vn(h, () => t.children ?? tn), W(e, w);
2780
2780
  }
2781
2781
  let co = 0;
2782
- var vo = /* @__PURE__ */ U('<div role="option"> </div>'), _o = /* @__PURE__ */ U('<div><select><!></select> <button type="button" role="combobox" aria-haspopup="listbox"><span> </span></button> <div role="listbox" class="listbox svelte-1h1ta11" popover="manual" tabindex="-1"></div></div>');
2782
+ var vo = /* @__PURE__ */ U('<div role="option"> </div>'), _o = /* @__PURE__ */ U('<div><select><!></select> <button type="button" role="combobox" aria-haspopup="listbox"><span> </span></button> <div role="listbox" class="listbox svelte-1hwvamm" popover="manual" tabindex="-1"></div></div>');
2783
2783
  function Wt(e, t) {
2784
2784
  Ar(t, !0);
2785
2785
  let r = se(t, "value", 15), n = se(t, "size", 3, "md"), i = se(t, "ghost", 3, !1), a = se(t, "class", 3, ""), l = se(t, "style", 3, ""), f = /* @__PURE__ */ Xn(t, [
@@ -2920,7 +2920,7 @@ function Wt(e, t) {
2920
2920
  void 0,
2921
2921
  void 0,
2922
2922
  void 0,
2923
- "svelte-1h1ta11"
2923
+ "svelte-1hwvamm"
2924
2924
  );
2925
2925
  var $t = S(Ie);
2926
2926
  Vn($t, () => t.children ?? tn), qt(Ie, (m) => x(d, m), () => o(d));
@@ -2938,13 +2938,13 @@ function Wt(e, t) {
2938
2938
  le.__click = () => C(o(B)), le.__pointermove = () => x(h, o(B), !0);
2939
2939
  var ir = S(le);
2940
2940
  Z(() => {
2941
- ye(le, "id", `${c}-opt-${o(B) ?? ""}`), wt = At(le, 1, "option svelte-1h1ta11", null, wt, {
2941
+ ye(le, "id", `${c}-opt-${o(B) ?? ""}`), wt = At(le, 1, "option svelte-1hwvamm", null, wt, {
2942
2942
  active: o(B) === o(h),
2943
2943
  selected: o(D).value === o(A)
2944
2944
  }), ye(le, "aria-selected", o(D).value === o(A)), ye(le, "aria-disabled", o(D).disabled), K(ir, o(D).label);
2945
2945
  }), W(m, le);
2946
2946
  }), qt(at, (m) => x(_, m), () => o(_)), Z(() => {
2947
- At(Fe, 1, `select-wrapper ${a() ?? ""}`, "svelte-1h1ta11"), mr(Fe, l()), it = At(oe, 1, "select svelte-1h1ta11", null, it, { ghost: i(), open: o(w) }), mr(oe, o(u)), oe.disabled = o(g), ye(oe, "aria-expanded", o(w)), ye(oe, "aria-controls", c), ye(oe, "aria-activedescendant", o(w) && o(h) >= 0 ? `${c}-opt-${o(h)}` : void 0), ye(oe, "aria-label", f["aria-label"]), mt = At(gt, 1, "select-label svelte-1h1ta11", null, mt, { placeholder: o(y)?.disabled }), K(nr, o(y)?.label ?? ""), ye(at, "id", c);
2947
+ At(Fe, 1, `select-wrapper ${a() ?? ""}`, "svelte-1hwvamm"), mr(Fe, l()), it = At(oe, 1, "select svelte-1hwvamm", null, it, { ghost: i(), open: o(w) }), mr(oe, o(u)), oe.disabled = o(g), ye(oe, "aria-expanded", o(w)), ye(oe, "aria-controls", c), ye(oe, "aria-activedescendant", o(w) && o(h) >= 0 ? `${c}-opt-${o(h)}` : void 0), ye(oe, "aria-label", f["aria-label"]), mt = At(gt, 1, "select-label svelte-1hwvamm", null, mt, { placeholder: o(y)?.disabled }), K(nr, o(y)?.label ?? ""), ye(at, "id", c);
2948
2948
  }), Qa(Ie, r), W(e, Fe), Ir();
2949
2949
  }
2950
2950
  Wn(["click", "keydown", "pointermove"]);
package/package.json CHANGED
@@ -1,67 +1,67 @@
1
1
  {
2
- "name": "@triiiceratops/plugin-image-export",
3
- "version": "1.0.0-rc.0",
4
- "type": "module",
5
- "description": "Image download (single/composite/current-view export) plugin for the triiiceratops IIIF viewer, authored on @triiiceratops/plugin-sdk.",
6
- "license": "MIT",
7
- "author": "David Flood",
8
- "repository": {
9
- "type": "git",
10
- "url": "git+https://github.com/d-flood/triiiceratops.git",
11
- "directory": "packages/plugin-image-export"
12
- },
13
- "homepage": "https://d-flood.github.io/triiiceratops/",
14
- "publishConfig": {
15
- "access": "public",
16
- "provenance": true
17
- },
18
- "private": false,
19
- "engines": {
20
- "node": ">=22"
21
- },
22
- "sideEffects": [
23
- "./dist/iife.js"
24
- ],
25
- "files": [
26
- "dist",
27
- "LICENSE"
28
- ],
29
- "main": "./dist/index.js",
30
- "module": "./dist/index.js",
31
- "types": "./dist/index.d.ts",
32
- "exports": {
33
- ".": {
34
- "types": "./dist/index.d.ts",
35
- "import": "./dist/index.js"
2
+ "name": "@triiiceratops/plugin-image-export",
3
+ "version": "1.0.0-rc.2",
4
+ "type": "module",
5
+ "description": "Image download (single/composite/current-view export) plugin for the triiiceratops IIIF viewer, authored on @triiiceratops/plugin-sdk.",
6
+ "license": "MIT",
7
+ "author": "David Flood",
8
+ "repository": {
9
+ "type": "git",
10
+ "url": "git+https://github.com/d-flood/triiiceratops.git",
11
+ "directory": "packages/plugin-image-export"
36
12
  },
37
- "./iife": "./dist/iife.js"
38
- },
39
- "peerDependencies": {
40
- "triiiceratops": "^1.0.0-rc.25",
41
- "@triiiceratops/plugin-sdk": "^1.0.0-rc.0"
42
- },
43
- "devDependencies": {
44
- "@sveltejs/vite-plugin-svelte": "^6.2.1",
45
- "@vitest/coverage-v8": "4.0.15",
46
- "svelte": "5.45.5",
47
- "svelte-check": "^4.3.4",
48
- "typescript": "~5.9.3",
49
- "vite": "^6.0.0",
50
- "vitest": "^4.0.15",
51
- "@triiiceratops/plugin-sdk": "1.0.0-rc.0",
52
- "@triiiceratops/ui": "0.0.0",
53
- "triiiceratops": "1.0.0-rc.25"
54
- },
55
- "scripts": {
56
- "build": "pnpm build:esm && pnpm build:iife && pnpm build:types",
57
- "build:esm": "BUILD_FORMAT=es vite build",
58
- "build:iife": "BUILD_FORMAT=iife vite build",
59
- "build:types": "tsc -p tsconfig.build.json",
60
- "check": "svelte-check --tsconfig ./tsconfig.json --fail-on-warnings && tsc -p tsconfig.build.json --noEmit",
61
- "test": "vitest run",
62
- "clean": "rm -rf dist",
63
- "test:coverage": "vitest run --coverage",
64
- "lint": "eslint . --max-warnings 0",
65
- "lint:fix": "eslint . --fix --max-warnings 0"
66
- }
67
- }
13
+ "homepage": "https://d-flood.github.io/triiiceratops/",
14
+ "publishConfig": {
15
+ "access": "public",
16
+ "provenance": true
17
+ },
18
+ "private": false,
19
+ "engines": {
20
+ "node": ">=22"
21
+ },
22
+ "sideEffects": [
23
+ "./dist/iife.js"
24
+ ],
25
+ "files": [
26
+ "dist",
27
+ "LICENSE"
28
+ ],
29
+ "main": "./dist/index.js",
30
+ "module": "./dist/index.js",
31
+ "types": "./dist/index.d.ts",
32
+ "exports": {
33
+ ".": {
34
+ "types": "./dist/index.d.ts",
35
+ "import": "./dist/index.js"
36
+ },
37
+ "./iife": "./dist/iife.js"
38
+ },
39
+ "scripts": {
40
+ "build": "pnpm build:esm && pnpm build:iife && pnpm build:types",
41
+ "build:esm": "BUILD_FORMAT=es vite build",
42
+ "build:iife": "BUILD_FORMAT=iife vite build",
43
+ "build:types": "tsc -p tsconfig.build.json",
44
+ "check": "svelte-check --tsconfig ./tsconfig.json --fail-on-warnings && tsc -p tsconfig.build.json --noEmit",
45
+ "test": "vitest run",
46
+ "clean": "rm -rf dist",
47
+ "test:coverage": "vitest run --coverage",
48
+ "lint": "eslint . --max-warnings 0",
49
+ "lint:fix": "eslint . --fix --max-warnings 0"
50
+ },
51
+ "peerDependencies": {
52
+ "triiiceratops": "^1.0.0-rc.26",
53
+ "@triiiceratops/plugin-sdk": "^1.0.0-rc.1"
54
+ },
55
+ "devDependencies": {
56
+ "@sveltejs/vite-plugin-svelte": "^6.2.1",
57
+ "@triiiceratops/plugin-sdk": "1.0.0-rc.1",
58
+ "@triiiceratops/ui": "0.0.0",
59
+ "@vitest/coverage-v8": "4.0.15",
60
+ "svelte": "5.45.5",
61
+ "svelte-check": "^4.3.4",
62
+ "triiiceratops": "1.0.0-rc.26",
63
+ "typescript": "~5.9.3",
64
+ "vite": "^6.0.0",
65
+ "vitest": "^4.0.15"
66
+ }
67
+ }