@pairbo/ui-kit 0.0.4 → 0.0.6

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.
@@ -1,46 +1,57 @@
1
- (function(z,Qe){typeof exports=="object"&&typeof module<"u"?Qe(exports):typeof define=="function"&&define.amd?define(["exports"],Qe):(z=typeof globalThis<"u"?globalThis:z||self,Qe(z.MyCustomElement={}))})(this,function(z){"use strict";/**
2
- * @license
3
- * Copyright 2019 Google LLC
4
- * SPDX-License-Identifier: BSD-3-Clause
5
- */var mu;const Qe=globalThis,Gn=Qe.ShadowRoot&&(Qe.ShadyCSS===void 0||Qe.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,Xn=Symbol(),$a=new WeakMap;let Va=class{constructor(t,e,i){if(this._$cssResult$=!0,i!==Xn)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=t,this.t=e}get styleSheet(){let t=this.o;const e=this.t;if(Gn&&t===void 0){const i=e!==void 0&&e.length===1;i&&(t=$a.get(e)),t===void 0&&((this.o=t=new CSSStyleSheet).replaceSync(this.cssText),i&&$a.set(e,t))}return t}toString(){return this.cssText}};const br=n=>new Va(typeof n=="string"?n:n+"",void 0,Xn),Ct=(n,...t)=>{const e=n.length===1?n[0]:t.reduce((i,s,r)=>i+(o=>{if(o._$cssResult$===!0)return o.cssText;if(typeof o=="number")return o;throw Error("Value passed to 'css' function must be a 'css' function result: "+o+". Use 'unsafeCSS' to pass non-literal values, but take care to ensure page security.")})(s)+n[r+1],n[0]);return new Va(e,n,Xn)},yu=(n,t)=>{if(Gn)n.adoptedStyleSheets=t.map(e=>e instanceof CSSStyleSheet?e:e.styleSheet);else for(const e of t){const i=document.createElement("style"),s=Qe.litNonce;s!==void 0&&i.setAttribute("nonce",s),i.textContent=e.cssText,n.appendChild(i)}},za=Gn?n=>n:n=>n instanceof CSSStyleSheet?(t=>{let e="";for(const i of t.cssRules)e+=i.cssText;return br(e)})(n):n;/**
6
- * @license
7
- * Copyright 2017 Google LLC
8
- * SPDX-License-Identifier: BSD-3-Clause
9
- */const{is:xu,defineProperty:Cu,getOwnPropertyDescriptor:Su,getOwnPropertyNames:wu,getOwnPropertySymbols:Tu,getPrototypeOf:Eu}=Object,ti=globalThis,Ha=ti.trustedTypes,Ou=Ha?Ha.emptyScript:"",Kn=ti.reactiveElementPolyfillSupport,Ss=(n,t)=>n,yr={toAttribute(n,t){switch(t){case Boolean:n=n?Ou:null;break;case Object:case Array:n=n==null?n:JSON.stringify(n)}return n},fromAttribute(n,t){let e=n;switch(t){case Boolean:e=n!==null;break;case Number:e=n===null?null:Number(n);break;case Object:case Array:try{e=JSON.parse(n)}catch{e=null}}return e}},qn=(n,t)=>!xu(n,t),Wa={attribute:!0,type:String,converter:yr,reflect:!1,hasChanged:qn};Symbol.metadata??(Symbol.metadata=Symbol("metadata")),ti.litPropertyMetadata??(ti.litPropertyMetadata=new WeakMap);let Hi=class extends HTMLElement{static addInitializer(t){this._$Ei(),(this.l??(this.l=[])).push(t)}static get observedAttributes(){return this.finalize(),this._$Eh&&[...this._$Eh.keys()]}static createProperty(t,e=Wa){if(e.state&&(e.attribute=!1),this._$Ei(),this.elementProperties.set(t,e),!e.noAccessor){const i=Symbol(),s=this.getPropertyDescriptor(t,i,e);s!==void 0&&Cu(this.prototype,t,s)}}static getPropertyDescriptor(t,e,i){const{get:s,set:r}=Su(this.prototype,t)??{get(){return this[e]},set(o){this[e]=o}};return{get(){return s==null?void 0:s.call(this)},set(o){const a=s==null?void 0:s.call(this);r.call(this,o),this.requestUpdate(t,a,i)},configurable:!0,enumerable:!0}}static getPropertyOptions(t){return this.elementProperties.get(t)??Wa}static _$Ei(){if(this.hasOwnProperty(Ss("elementProperties")))return;const t=Eu(this);t.finalize(),t.l!==void 0&&(this.l=[...t.l]),this.elementProperties=new Map(t.elementProperties)}static finalize(){if(this.hasOwnProperty(Ss("finalized")))return;if(this.finalized=!0,this._$Ei(),this.hasOwnProperty(Ss("properties"))){const e=this.properties,i=[...wu(e),...Tu(e)];for(const s of i)this.createProperty(s,e[s])}const t=this[Symbol.metadata];if(t!==null){const e=litPropertyMetadata.get(t);if(e!==void 0)for(const[i,s]of e)this.elementProperties.set(i,s)}this._$Eh=new Map;for(const[e,i]of this.elementProperties){const s=this._$Eu(e,i);s!==void 0&&this._$Eh.set(s,e)}this.elementStyles=this.finalizeStyles(this.styles)}static finalizeStyles(t){const e=[];if(Array.isArray(t)){const i=new Set(t.flat(1/0).reverse());for(const s of i)e.unshift(za(s))}else t!==void 0&&e.push(za(t));return e}static _$Eu(t,e){const i=e.attribute;return i===!1?void 0:typeof i=="string"?i:typeof t=="string"?t.toLowerCase():void 0}constructor(){super(),this._$Ep=void 0,this.isUpdatePending=!1,this.hasUpdated=!1,this._$Em=null,this._$Ev()}_$Ev(){var t;this._$ES=new Promise(e=>this.enableUpdating=e),this._$AL=new Map,this._$E_(),this.requestUpdate(),(t=this.constructor.l)==null||t.forEach(e=>e(this))}addController(t){var e;(this._$EO??(this._$EO=new Set)).add(t),this.renderRoot!==void 0&&this.isConnected&&((e=t.hostConnected)==null||e.call(t))}removeController(t){var e;(e=this._$EO)==null||e.delete(t)}_$E_(){const t=new Map,e=this.constructor.elementProperties;for(const i of e.keys())this.hasOwnProperty(i)&&(t.set(i,this[i]),delete this[i]);t.size>0&&(this._$Ep=t)}createRenderRoot(){const t=this.shadowRoot??this.attachShadow(this.constructor.shadowRootOptions);return yu(t,this.constructor.elementStyles),t}connectedCallback(){var t;this.renderRoot??(this.renderRoot=this.createRenderRoot()),this.enableUpdating(!0),(t=this._$EO)==null||t.forEach(e=>{var i;return(i=e.hostConnected)==null?void 0:i.call(e)})}enableUpdating(t){}disconnectedCallback(){var t;(t=this._$EO)==null||t.forEach(e=>{var i;return(i=e.hostDisconnected)==null?void 0:i.call(e)})}attributeChangedCallback(t,e,i){this._$AK(t,i)}_$EC(t,e){var r;const i=this.constructor.elementProperties.get(t),s=this.constructor._$Eu(t,i);if(s!==void 0&&i.reflect===!0){const o=(((r=i.converter)==null?void 0:r.toAttribute)!==void 0?i.converter:yr).toAttribute(e,i.type);this._$Em=t,o==null?this.removeAttribute(s):this.setAttribute(s,o),this._$Em=null}}_$AK(t,e){var r;const i=this.constructor,s=i._$Eh.get(t);if(s!==void 0&&this._$Em!==s){const o=i.getPropertyOptions(s),a=typeof o.converter=="function"?{fromAttribute:o.converter}:((r=o.converter)==null?void 0:r.fromAttribute)!==void 0?o.converter:yr;this._$Em=s,this[s]=a.fromAttribute(e,o.type),this._$Em=null}}requestUpdate(t,e,i){if(t!==void 0){if(i??(i=this.constructor.getPropertyOptions(t)),!(i.hasChanged??qn)(this[t],e))return;this.P(t,e,i)}this.isUpdatePending===!1&&(this._$ES=this._$ET())}P(t,e,i){this._$AL.has(t)||this._$AL.set(t,e),i.reflect===!0&&this._$Em!==t&&(this._$Ej??(this._$Ej=new Set)).add(t)}async _$ET(){this.isUpdatePending=!0;try{await this._$ES}catch(e){Promise.reject(e)}const t=this.scheduleUpdate();return t!=null&&await t,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){var i;if(!this.isUpdatePending)return;if(!this.hasUpdated){if(this.renderRoot??(this.renderRoot=this.createRenderRoot()),this._$Ep){for(const[r,o]of this._$Ep)this[r]=o;this._$Ep=void 0}const s=this.constructor.elementProperties;if(s.size>0)for(const[r,o]of s)o.wrapped!==!0||this._$AL.has(r)||this[r]===void 0||this.P(r,this[r],o)}let t=!1;const e=this._$AL;try{t=this.shouldUpdate(e),t?(this.willUpdate(e),(i=this._$EO)==null||i.forEach(s=>{var r;return(r=s.hostUpdate)==null?void 0:r.call(s)}),this.update(e)):this._$EU()}catch(s){throw t=!1,this._$EU(),s}t&&this._$AE(e)}willUpdate(t){}_$AE(t){var e;(e=this._$EO)==null||e.forEach(i=>{var s;return(s=i.hostUpdated)==null?void 0:s.call(i)}),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(t)),this.updated(t)}_$EU(){this._$AL=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$ES}shouldUpdate(t){return!0}update(t){this._$Ej&&(this._$Ej=this._$Ej.forEach(e=>this._$EC(e,this[e]))),this._$EU()}updated(t){}firstUpdated(t){}};Hi.elementStyles=[],Hi.shadowRootOptions={mode:"open"},Hi[Ss("elementProperties")]=new Map,Hi[Ss("finalized")]=new Map,Kn==null||Kn({ReactiveElement:Hi}),(ti.reactiveElementVersions??(ti.reactiveElementVersions=[])).push("2.0.4");/**
10
- * @license
11
- * Copyright 2017 Google LLC
12
- * SPDX-License-Identifier: BSD-3-Clause
13
- */const ws=globalThis,xr=ws.trustedTypes,Ya=xr?xr.createPolicy("lit-html",{createHTML:n=>n}):void 0,Ua="$lit$",ei=`lit$${Math.random().toFixed(9).slice(2)}$`,Ga="?"+ei,Au=`<${Ga}>`,xi=document,Ts=()=>xi.createComment(""),Es=n=>n===null||typeof n!="object"&&typeof n!="function",Jn=Array.isArray,Du=n=>Jn(n)||typeof(n==null?void 0:n[Symbol.iterator])=="function",Zn=`[
14
- \f\r]`,Os=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,Xa=/-->/g,Ka=/>/g,Ci=RegExp(`>|${Zn}(?:([^\\s"'>=/]+)(${Zn}*=${Zn}*(?:[^
15
- \f\r"'\`<>=]|("|')|))|$)`,"g"),qa=/'/g,Ja=/"/g,Za=/^(?:script|style|textarea|title)$/i,ku=n=>(t,...e)=>({_$litType$:n,strings:t,values:e}),St=ku(1),Jt=Symbol.for("lit-noChange"),mt=Symbol.for("lit-nothing"),Qa=new WeakMap,Si=xi.createTreeWalker(xi,129);function tl(n,t){if(!Jn(n)||!n.hasOwnProperty("raw"))throw Error("invalid template strings array");return Ya!==void 0?Ya.createHTML(t):t}const Mu=(n,t)=>{const e=n.length-1,i=[];let s,r=t===2?"<svg>":t===3?"<math>":"",o=Os;for(let a=0;a<e;a++){const l=n[a];let c,h,u=-1,d=0;for(;d<l.length&&(o.lastIndex=d,h=o.exec(l),h!==null);)d=o.lastIndex,o===Os?h[1]==="!--"?o=Xa:h[1]!==void 0?o=Ka:h[2]!==void 0?(Za.test(h[2])&&(s=RegExp("</"+h[2],"g")),o=Ci):h[3]!==void 0&&(o=Ci):o===Ci?h[0]===">"?(o=s??Os,u=-1):h[1]===void 0?u=-2:(u=o.lastIndex-h[2].length,c=h[1],o=h[3]===void 0?Ci:h[3]==='"'?Ja:qa):o===Ja||o===qa?o=Ci:o===Xa||o===Ka?o=Os:(o=Ci,s=void 0);const f=o===Ci&&n[a+1].startsWith("/>")?" ":"";r+=o===Os?l+Au:u>=0?(i.push(c),l.slice(0,u)+Ua+l.slice(u)+ei+f):l+ei+(u===-2?a:f)}return[tl(n,r+(n[e]||"<?>")+(t===2?"</svg>":t===3?"</math>":"")),i]};let Qn=class _u{constructor({strings:t,_$litType$:e},i){let s;this.parts=[];let r=0,o=0;const a=t.length-1,l=this.parts,[c,h]=Mu(t,e);if(this.el=_u.createElement(c,i),Si.currentNode=this.el.content,e===2||e===3){const u=this.el.content.firstChild;u.replaceWith(...u.childNodes)}for(;(s=Si.nextNode())!==null&&l.length<a;){if(s.nodeType===1){if(s.hasAttributes())for(const u of s.getAttributeNames())if(u.endsWith(Ua)){const d=h[o++],f=s.getAttribute(u).split(ei),g=/([.?@])?(.*)/.exec(d);l.push({type:1,index:r,name:g[2],strings:f,ctor:g[1]==="."?Iu:g[1]==="?"?Lu:g[1]==="@"?ju:Cr}),s.removeAttribute(u)}else u.startsWith(ei)&&(l.push({type:6,index:r}),s.removeAttribute(u));if(Za.test(s.tagName)){const u=s.textContent.split(ei),d=u.length-1;if(d>0){s.textContent=xr?xr.emptyScript:"";for(let f=0;f<d;f++)s.append(u[f],Ts()),Si.nextNode(),l.push({type:2,index:++r});s.append(u[d],Ts())}}}else if(s.nodeType===8)if(s.data===Ga)l.push({type:2,index:r});else{let u=-1;for(;(u=s.data.indexOf(ei,u+1))!==-1;)l.push({type:7,index:r}),u+=ei.length-1}r++}}static createElement(t,e){const i=xi.createElement("template");return i.innerHTML=t,i}};function Wi(n,t,e=n,i){var o,a;if(t===Jt)return t;let s=i!==void 0?(o=e._$Co)==null?void 0:o[i]:e._$Cl;const r=Es(t)?void 0:t._$litDirective$;return(s==null?void 0:s.constructor)!==r&&((a=s==null?void 0:s._$AO)==null||a.call(s,!1),r===void 0?s=void 0:(s=new r(n),s._$AT(n,e,i)),i!==void 0?(e._$Co??(e._$Co=[]))[i]=s:e._$Cl=s),s!==void 0&&(t=Wi(n,s._$AS(n,t.values),s,i)),t}let Pu=class{constructor(t,e){this._$AV=[],this._$AN=void 0,this._$AD=t,this._$AM=e}get parentNode(){return this._$AM.parentNode}get _$AU(){return this._$AM._$AU}u(t){const{el:{content:e},parts:i}=this._$AD,s=((t==null?void 0:t.creationScope)??xi).importNode(e,!0);Si.currentNode=s;let r=Si.nextNode(),o=0,a=0,l=i[0];for(;l!==void 0;){if(o===l.index){let c;l.type===2?c=new to(r,r.nextSibling,this,t):l.type===1?c=new l.ctor(r,l.name,l.strings,this,t):l.type===6&&(c=new Fu(r,this,t)),this._$AV.push(c),l=i[++a]}o!==(l==null?void 0:l.index)&&(r=Si.nextNode(),o++)}return Si.currentNode=xi,s}p(t){let e=0;for(const i of this._$AV)i!==void 0&&(i.strings!==void 0?(i._$AI(t,i,e),e+=i.strings.length-2):i._$AI(t[e])),e++}},to=class bu{get _$AU(){var t;return((t=this._$AM)==null?void 0:t._$AU)??this._$Cv}constructor(t,e,i,s){this.type=2,this._$AH=mt,this._$AN=void 0,this._$AA=t,this._$AB=e,this._$AM=i,this.options=s,this._$Cv=(s==null?void 0:s.isConnected)??!0}get parentNode(){let t=this._$AA.parentNode;const e=this._$AM;return e!==void 0&&(t==null?void 0:t.nodeType)===11&&(t=e.parentNode),t}get startNode(){return this._$AA}get endNode(){return this._$AB}_$AI(t,e=this){t=Wi(this,t,e),Es(t)?t===mt||t==null||t===""?(this._$AH!==mt&&this._$AR(),this._$AH=mt):t!==this._$AH&&t!==Jt&&this._(t):t._$litType$!==void 0?this.$(t):t.nodeType!==void 0?this.T(t):Du(t)?this.k(t):this._(t)}O(t){return this._$AA.parentNode.insertBefore(t,this._$AB)}T(t){this._$AH!==t&&(this._$AR(),this._$AH=this.O(t))}_(t){this._$AH!==mt&&Es(this._$AH)?this._$AA.nextSibling.data=t:this.T(xi.createTextNode(t)),this._$AH=t}$(t){var r;const{values:e,_$litType$:i}=t,s=typeof i=="number"?this._$AC(t):(i.el===void 0&&(i.el=Qn.createElement(tl(i.h,i.h[0]),this.options)),i);if(((r=this._$AH)==null?void 0:r._$AD)===s)this._$AH.p(e);else{const o=new Pu(s,this),a=o.u(this.options);o.p(e),this.T(a),this._$AH=o}}_$AC(t){let e=Qa.get(t.strings);return e===void 0&&Qa.set(t.strings,e=new Qn(t)),e}k(t){Jn(this._$AH)||(this._$AH=[],this._$AR());const e=this._$AH;let i,s=0;for(const r of t)s===e.length?e.push(i=new bu(this.O(Ts()),this.O(Ts()),this,this.options)):i=e[s],i._$AI(r),s++;s<e.length&&(this._$AR(i&&i._$AB.nextSibling,s),e.length=s)}_$AR(t=this._$AA.nextSibling,e){var i;for((i=this._$AP)==null?void 0:i.call(this,!1,!0,e);t&&t!==this._$AB;){const s=t.nextSibling;t.remove(),t=s}}setConnected(t){var e;this._$AM===void 0&&(this._$Cv=t,(e=this._$AP)==null||e.call(this,t))}},Cr=class{get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}constructor(t,e,i,s,r){this.type=1,this._$AH=mt,this._$AN=void 0,this.element=t,this.name=e,this._$AM=s,this.options=r,i.length>2||i[0]!==""||i[1]!==""?(this._$AH=Array(i.length-1).fill(new String),this.strings=i):this._$AH=mt}_$AI(t,e=this,i,s){const r=this.strings;let o=!1;if(r===void 0)t=Wi(this,t,e,0),o=!Es(t)||t!==this._$AH&&t!==Jt,o&&(this._$AH=t);else{const a=t;let l,c;for(t=r[0],l=0;l<r.length-1;l++)c=Wi(this,a[i+l],e,l),c===Jt&&(c=this._$AH[l]),o||(o=!Es(c)||c!==this._$AH[l]),c===mt?t=mt:t!==mt&&(t+=(c??"")+r[l+1]),this._$AH[l]=c}o&&!s&&this.j(t)}j(t){t===mt?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,t??"")}},Iu=class extends Cr{constructor(){super(...arguments),this.type=3}j(t){this.element[this.name]=t===mt?void 0:t}},Lu=class extends Cr{constructor(){super(...arguments),this.type=4}j(t){this.element.toggleAttribute(this.name,!!t&&t!==mt)}},ju=class extends Cr{constructor(t,e,i,s,r){super(t,e,i,s,r),this.type=5}_$AI(t,e=this){if((t=Wi(this,t,e,0)??mt)===Jt)return;const i=this._$AH,s=t===mt&&i!==mt||t.capture!==i.capture||t.once!==i.once||t.passive!==i.passive,r=t!==mt&&(i===mt||s);s&&this.element.removeEventListener(this.name,this,i),r&&this.element.addEventListener(this.name,this,t),this._$AH=t}handleEvent(t){var e;typeof this._$AH=="function"?this._$AH.call(((e=this.options)==null?void 0:e.host)??this.element,t):this._$AH.handleEvent(t)}},Fu=class{constructor(t,e,i){this.element=t,this.type=6,this._$AN=void 0,this._$AM=e,this.options=i}get _$AU(){return this._$AM._$AU}_$AI(t){Wi(this,t)}};const eo=ws.litHtmlPolyfillSupport;eo==null||eo(Qn,to),(ws.litHtmlVersions??(ws.litHtmlVersions=[])).push("3.2.1");const Ru=(n,t,e)=>{const i=(e==null?void 0:e.renderBefore)??t;let s=i._$litPart$;if(s===void 0){const r=(e==null?void 0:e.renderBefore)??null;i._$litPart$=s=new to(t.insertBefore(Ts(),r),r,void 0,e??{})}return s._$AI(n),s};/**
16
- * @license
17
- * Copyright 2017 Google LLC
18
- * SPDX-License-Identifier: BSD-3-Clause
19
- */let ae=class extends Hi{constructor(){super(...arguments),this.renderOptions={host:this},this._$Do=void 0}createRenderRoot(){var e;const t=super.createRenderRoot();return(e=this.renderOptions).renderBefore??(e.renderBefore=t.firstChild),t}update(t){const e=this.render();this.hasUpdated||(this.renderOptions.isConnected=this.isConnected),super.update(t),this._$Do=Ru(e,this.renderRoot,this.renderOptions)}connectedCallback(){var t;super.connectedCallback(),(t=this._$Do)==null||t.setConnected(!0)}disconnectedCallback(){var t;super.disconnectedCallback(),(t=this._$Do)==null||t.setConnected(!1)}render(){return Jt}};ae._$litElement$=!0,ae.finalized=!0,(mu=globalThis.litElementHydrateSupport)==null||mu.call(globalThis,{LitElement:ae});const io=globalThis.litElementPolyfillSupport;io==null||io({LitElement:ae}),(globalThis.litElementVersions??(globalThis.litElementVersions=[])).push("4.1.1");/**
20
- * @license
21
- * Copyright 2017 Google LLC
22
- * SPDX-License-Identifier: BSD-3-Clause
23
- */const Mt=n=>(t,e)=>{e!==void 0?e.addInitializer(()=>{customElements.define(n,t)}):customElements.define(n,t)};/**
24
- * @license
25
- * Copyright 2017 Google LLC
26
- * SPDX-License-Identifier: BSD-3-Clause
27
- */const Nu={attribute:!0,type:String,converter:yr,reflect:!1,hasChanged:qn},Bu=(n=Nu,t,e)=>{const{kind:i,metadata:s}=e;let r=globalThis.litPropertyMetadata.get(s);if(r===void 0&&globalThis.litPropertyMetadata.set(s,r=new Map),r.set(e.name,n),i==="accessor"){const{name:o}=e;return{set(a){const l=t.get.call(this);t.set.call(this,a),this.requestUpdate(o,l,n)},init(a){return a!==void 0&&this.P(o,void 0,n),a}}}if(i==="setter"){const{name:o}=e;return function(a){const l=this[o];t.call(this,a),this.requestUpdate(o,l,n)}}throw Error("Unsupported decorator location: "+i)};function H(n){return(t,e)=>typeof e=="object"?Bu(n,t,e):((i,s,r)=>{const o=s.hasOwnProperty(r);return s.constructor.createProperty(r,o?{...i,wrapped:!0}:i),o?Object.getOwnPropertyDescriptor(s,r):void 0})(n,t,e)}/**
28
- * @license
29
- * Copyright 2017 Google LLC
30
- * SPDX-License-Identifier: BSD-3-Clause
31
- */function st(n){return H({...n,state:!0,attribute:!1})}/**
32
- * @license
33
- * Copyright 2017 Google LLC
34
- * SPDX-License-Identifier: BSD-3-Clause
35
- */const el=(n,t,e)=>(e.configurable=!0,e.enumerable=!0,Reflect.decorate&&typeof t!="object"&&Object.defineProperty(n,t,e),e);/**
36
- * @license
37
- * Copyright 2017 Google LLC
38
- * SPDX-License-Identifier: BSD-3-Clause
39
- */function vt(n,t){return(e,i,s)=>{const r=o=>{var a;return((a=o.renderRoot)==null?void 0:a.querySelector(n))??null};return el(e,i,{get(){return r(this)}})}}/**
40
- * @license
41
- * Copyright 2017 Google LLC
42
- * SPDX-License-Identifier: BSD-3-Clause
43
- */let $u;function Vu(n){return(t,e)=>el(t,e,{get(){return(this.renderRoot??$u??($u=document.createDocumentFragment())).querySelectorAll(n)}})}const zu=Ct`
1
+ !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).MyCustomElement={})}(this,(function(t){"use strict";
2
+ /**
3
+ * @license
4
+ * Copyright 2019 Google LLC
5
+ * SPDX-License-Identifier: BSD-3-Clause
6
+ */var e;const i=globalThis,s=i.ShadowRoot&&(void 0===i.ShadyCSS||i.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,r=Symbol(),n=new WeakMap;let o=class{constructor(t,e,i){if(this._$cssResult$=!0,i!==r)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=t,this.t=e}get styleSheet(){let t=this.o;const e=this.t;if(s&&void 0===t){const i=void 0!==e&&1===e.length;i&&(t=n.get(e)),void 0===t&&((this.o=t=new CSSStyleSheet).replaceSync(this.cssText),i&&n.set(e,t))}return t}toString(){return this.cssText}};const a=t=>new o("string"==typeof t?t:t+"",void 0,r),l=(t,...e)=>{const i=1===t.length?t[0]:e.reduce(((e,i,s)=>e+(t=>{if(!0===t._$cssResult$)return t.cssText;if("number"==typeof t)return t;throw Error("Value passed to 'css' function must be a 'css' function result: "+t+". Use 'unsafeCSS' to pass non-literal values, but take care to ensure page security.")})(i)+t[s+1]),t[0]);return new o(i,t,r)},c=s?t=>t:t=>t instanceof CSSStyleSheet?(t=>{let e="";for(const i of t.cssRules)e+=i.cssText;return a(e)})(t):t
7
+ /**
8
+ * @license
9
+ * Copyright 2017 Google LLC
10
+ * SPDX-License-Identifier: BSD-3-Clause
11
+ */,{is:h,defineProperty:d,getOwnPropertyDescriptor:u,getOwnPropertyNames:p,getOwnPropertySymbols:g,getPrototypeOf:f}=Object,m=globalThis,v=m.trustedTypes,_=v?v.emptyScript:"",b=m.reactiveElementPolyfillSupport,y=(t,e)=>t,x={toAttribute(t,e){switch(e){case Boolean:t=t?_:null;break;case Object:case Array:t=null==t?t:JSON.stringify(t)}return t},fromAttribute(t,e){let i=t;switch(e){case Boolean:i=null!==t;break;case Number:i=null===t?null:Number(t);break;case Object:case Array:try{i=JSON.parse(t)}catch(s){i=null}}return i}},w=(t,e)=>!h(t,e),C={attribute:!0,type:String,converter:x,reflect:!1,hasChanged:w};Symbol.metadata??(Symbol.metadata=Symbol("metadata")),m.litPropertyMetadata??(m.litPropertyMetadata=new WeakMap);let S=class extends HTMLElement{static addInitializer(t){this._$Ei(),(this.l??(this.l=[])).push(t)}static get observedAttributes(){return this.finalize(),this._$Eh&&[...this._$Eh.keys()]}static createProperty(t,e=C){if(e.state&&(e.attribute=!1),this._$Ei(),this.elementProperties.set(t,e),!e.noAccessor){const i=Symbol(),s=this.getPropertyDescriptor(t,i,e);void 0!==s&&d(this.prototype,t,s)}}static getPropertyDescriptor(t,e,i){const{get:s,set:r}=u(this.prototype,t)??{get(){return this[e]},set(t){this[e]=t}};return{get(){return null==s?void 0:s.call(this)},set(e){const n=null==s?void 0:s.call(this);r.call(this,e),this.requestUpdate(t,n,i)},configurable:!0,enumerable:!0}}static getPropertyOptions(t){return this.elementProperties.get(t)??C}static _$Ei(){if(this.hasOwnProperty(y("elementProperties")))return;const t=f(this);t.finalize(),void 0!==t.l&&(this.l=[...t.l]),this.elementProperties=new Map(t.elementProperties)}static finalize(){if(this.hasOwnProperty(y("finalized")))return;if(this.finalized=!0,this._$Ei(),this.hasOwnProperty(y("properties"))){const t=this.properties,e=[...p(t),...g(t)];for(const i of e)this.createProperty(i,t[i])}const t=this[Symbol.metadata];if(null!==t){const e=litPropertyMetadata.get(t);if(void 0!==e)for(const[t,i]of e)this.elementProperties.set(t,i)}this._$Eh=new Map;for(const[e,i]of this.elementProperties){const t=this._$Eu(e,i);void 0!==t&&this._$Eh.set(t,e)}this.elementStyles=this.finalizeStyles(this.styles)}static finalizeStyles(t){const e=[];if(Array.isArray(t)){const i=new Set(t.flat(1/0).reverse());for(const t of i)e.unshift(c(t))}else void 0!==t&&e.push(c(t));return e}static _$Eu(t,e){const i=e.attribute;return!1===i?void 0:"string"==typeof i?i:"string"==typeof t?t.toLowerCase():void 0}constructor(){super(),this._$Ep=void 0,this.isUpdatePending=!1,this.hasUpdated=!1,this._$Em=null,this._$Ev()}_$Ev(){var t;this._$ES=new Promise((t=>this.enableUpdating=t)),this._$AL=new Map,this._$E_(),this.requestUpdate(),null==(t=this.constructor.l)||t.forEach((t=>t(this)))}addController(t){var e;(this._$EO??(this._$EO=new Set)).add(t),void 0!==this.renderRoot&&this.isConnected&&(null==(e=t.hostConnected)||e.call(t))}removeController(t){var e;null==(e=this._$EO)||e.delete(t)}_$E_(){const t=new Map,e=this.constructor.elementProperties;for(const i of e.keys())this.hasOwnProperty(i)&&(t.set(i,this[i]),delete this[i]);t.size>0&&(this._$Ep=t)}createRenderRoot(){const t=this.shadowRoot??this.attachShadow(this.constructor.shadowRootOptions);return((t,e)=>{if(s)t.adoptedStyleSheets=e.map((t=>t instanceof CSSStyleSheet?t:t.styleSheet));else for(const s of e){const e=document.createElement("style"),r=i.litNonce;void 0!==r&&e.setAttribute("nonce",r),e.textContent=s.cssText,t.appendChild(e)}})(t,this.constructor.elementStyles),t}connectedCallback(){var t;this.renderRoot??(this.renderRoot=this.createRenderRoot()),this.enableUpdating(!0),null==(t=this._$EO)||t.forEach((t=>{var e;return null==(e=t.hostConnected)?void 0:e.call(t)}))}enableUpdating(t){}disconnectedCallback(){var t;null==(t=this._$EO)||t.forEach((t=>{var e;return null==(e=t.hostDisconnected)?void 0:e.call(t)}))}attributeChangedCallback(t,e,i){this._$AK(t,i)}_$EC(t,e){var i;const s=this.constructor.elementProperties.get(t),r=this.constructor._$Eu(t,s);if(void 0!==r&&!0===s.reflect){const n=(void 0!==(null==(i=s.converter)?void 0:i.toAttribute)?s.converter:x).toAttribute(e,s.type);this._$Em=t,null==n?this.removeAttribute(r):this.setAttribute(r,n),this._$Em=null}}_$AK(t,e){var i;const s=this.constructor,r=s._$Eh.get(t);if(void 0!==r&&this._$Em!==r){const t=s.getPropertyOptions(r),n="function"==typeof t.converter?{fromAttribute:t.converter}:void 0!==(null==(i=t.converter)?void 0:i.fromAttribute)?t.converter:x;this._$Em=r,this[r]=n.fromAttribute(e,t.type),this._$Em=null}}requestUpdate(t,e,i){if(void 0!==t){if(i??(i=this.constructor.getPropertyOptions(t)),!(i.hasChanged??w)(this[t],e))return;this.P(t,e,i)}!1===this.isUpdatePending&&(this._$ES=this._$ET())}P(t,e,i){this._$AL.has(t)||this._$AL.set(t,e),!0===i.reflect&&this._$Em!==t&&(this._$Ej??(this._$Ej=new Set)).add(t)}async _$ET(){this.isUpdatePending=!0;try{await this._$ES}catch(e){Promise.reject(e)}const t=this.scheduleUpdate();return null!=t&&await t,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){var t;if(!this.isUpdatePending)return;if(!this.hasUpdated){if(this.renderRoot??(this.renderRoot=this.createRenderRoot()),this._$Ep){for(const[t,e]of this._$Ep)this[t]=e;this._$Ep=void 0}const t=this.constructor.elementProperties;if(t.size>0)for(const[e,i]of t)!0!==i.wrapped||this._$AL.has(e)||void 0===this[e]||this.P(e,this[e],i)}let e=!1;const i=this._$AL;try{e=this.shouldUpdate(i),e?(this.willUpdate(i),null==(t=this._$EO)||t.forEach((t=>{var e;return null==(e=t.hostUpdate)?void 0:e.call(t)})),this.update(i)):this._$EU()}catch(s){throw e=!1,this._$EU(),s}e&&this._$AE(i)}willUpdate(t){}_$AE(t){var e;null==(e=this._$EO)||e.forEach((t=>{var e;return null==(e=t.hostUpdated)?void 0:e.call(t)})),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(t)),this.updated(t)}_$EU(){this._$AL=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$ES}shouldUpdate(t){return!0}update(t){this._$Ej&&(this._$Ej=this._$Ej.forEach((t=>this._$EC(t,this[t])))),this._$EU()}updated(t){}firstUpdated(t){}};S.elementStyles=[],S.shadowRootOptions={mode:"open"},S[y("elementProperties")]=new Map,S[y("finalized")]=new Map,null==b||b({ReactiveElement:S}),(m.reactiveElementVersions??(m.reactiveElementVersions=[])).push("2.0.4");
12
+ /**
13
+ * @license
14
+ * Copyright 2017 Google LLC
15
+ * SPDX-License-Identifier: BSD-3-Clause
16
+ */
17
+ const T=globalThis,O=T.trustedTypes,E=O?O.createPolicy("lit-html",{createHTML:t=>t}):void 0,k="$lit$",D=`lit$${Math.random().toFixed(9).slice(2)}$`,A="?"+D,M=`<${A}>`,P=document,j=()=>P.createComment(""),L=t=>null===t||"object"!=typeof t&&"function"!=typeof t,F=Array.isArray,I="[ \t\n\f\r]",R=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,B=/-->/g,N=/>/g,z=RegExp(`>|${I}(?:([^\\s"'>=/]+)(${I}*=${I}*(?:[^ \t\n\f\r"'\`<>=]|("|')|))|$)`,"g"),V=/'/g,$=/"/g,W=/^(?:script|style|textarea|title)$/i,H=(q=1,(t,...e)=>({_$litType$:q,strings:t,values:e})),X=Symbol.for("lit-noChange"),U=Symbol.for("lit-nothing"),Y=new WeakMap,G=P.createTreeWalker(P,129);var q;function K(t,e){if(!F(t)||!t.hasOwnProperty("raw"))throw Error("invalid template strings array");return void 0!==E?E.createHTML(e):e}let J=class t{constructor({strings:e,_$litType$:i},s){let r;this.parts=[];let n=0,o=0;const a=e.length-1,l=this.parts,[c,h]=((t,e)=>{const i=t.length-1,s=[];let r,n=2===e?"<svg>":3===e?"<math>":"",o=R;for(let a=0;a<i;a++){const e=t[a];let i,l,c=-1,h=0;for(;h<e.length&&(o.lastIndex=h,l=o.exec(e),null!==l);)h=o.lastIndex,o===R?"!--"===l[1]?o=B:void 0!==l[1]?o=N:void 0!==l[2]?(W.test(l[2])&&(r=RegExp("</"+l[2],"g")),o=z):void 0!==l[3]&&(o=z):o===z?">"===l[0]?(o=r??R,c=-1):void 0===l[1]?c=-2:(c=o.lastIndex-l[2].length,i=l[1],o=void 0===l[3]?z:'"'===l[3]?$:V):o===$||o===V?o=z:o===B||o===N?o=R:(o=z,r=void 0);const d=o===z&&t[a+1].startsWith("/>")?" ":"";n+=o===R?e+M:c>=0?(s.push(i),e.slice(0,c)+k+e.slice(c)+D+d):e+D+(-2===c?a:d)}return[K(t,n+(t[i]||"<?>")+(2===e?"</svg>":3===e?"</math>":"")),s]})(e,i);if(this.el=t.createElement(c,s),G.currentNode=this.el.content,2===i||3===i){const t=this.el.content.firstChild;t.replaceWith(...t.childNodes)}for(;null!==(r=G.nextNode())&&l.length<a;){if(1===r.nodeType){if(r.hasAttributes())for(const t of r.getAttributeNames())if(t.endsWith(k)){const e=h[o++],i=r.getAttribute(t).split(D),s=/([.?@])?(.*)/.exec(e);l.push({type:1,index:n,name:s[2],strings:i,ctor:"."===s[1]?it:"?"===s[1]?st:"@"===s[1]?rt:et}),r.removeAttribute(t)}else t.startsWith(D)&&(l.push({type:6,index:n}),r.removeAttribute(t));if(W.test(r.tagName)){const t=r.textContent.split(D),e=t.length-1;if(e>0){r.textContent=O?O.emptyScript:"";for(let i=0;i<e;i++)r.append(t[i],j()),G.nextNode(),l.push({type:2,index:++n});r.append(t[e],j())}}}else if(8===r.nodeType)if(r.data===A)l.push({type:2,index:n});else{let t=-1;for(;-1!==(t=r.data.indexOf(D,t+1));)l.push({type:7,index:n}),t+=D.length-1}n++}}static createElement(t,e){const i=P.createElement("template");return i.innerHTML=t,i}};function Z(t,e,i=t,s){var r,n;if(e===X)return e;let o=void 0!==s?null==(r=i._$Co)?void 0:r[s]:i._$Cl;const a=L(e)?void 0:e._$litDirective$;return(null==o?void 0:o.constructor)!==a&&(null==(n=null==o?void 0:o._$AO)||n.call(o,!1),void 0===a?o=void 0:(o=new a(t),o._$AT(t,i,s)),void 0!==s?(i._$Co??(i._$Co=[]))[s]=o:i._$Cl=o),void 0!==o&&(e=Z(t,o._$AS(t,e.values),o,s)),e}let Q=class{constructor(t,e){this._$AV=[],this._$AN=void 0,this._$AD=t,this._$AM=e}get parentNode(){return this._$AM.parentNode}get _$AU(){return this._$AM._$AU}u(t){const{el:{content:e},parts:i}=this._$AD,s=((null==t?void 0:t.creationScope)??P).importNode(e,!0);G.currentNode=s;let r=G.nextNode(),n=0,o=0,a=i[0];for(;void 0!==a;){if(n===a.index){let e;2===a.type?e=new tt(r,r.nextSibling,this,t):1===a.type?e=new a.ctor(r,a.name,a.strings,this,t):6===a.type&&(e=new nt(r,this,t)),this._$AV.push(e),a=i[++o]}n!==(null==a?void 0:a.index)&&(r=G.nextNode(),n++)}return G.currentNode=P,s}p(t){let e=0;for(const i of this._$AV)void 0!==i&&(void 0!==i.strings?(i._$AI(t,i,e),e+=i.strings.length-2):i._$AI(t[e])),e++}},tt=class t{get _$AU(){var t;return(null==(t=this._$AM)?void 0:t._$AU)??this._$Cv}constructor(t,e,i,s){this.type=2,this._$AH=U,this._$AN=void 0,this._$AA=t,this._$AB=e,this._$AM=i,this.options=s,this._$Cv=(null==s?void 0:s.isConnected)??!0}get parentNode(){let t=this._$AA.parentNode;const e=this._$AM;return void 0!==e&&11===(null==t?void 0:t.nodeType)&&(t=e.parentNode),t}get startNode(){return this._$AA}get endNode(){return this._$AB}_$AI(t,e=this){t=Z(this,t,e),L(t)?t===U||null==t||""===t?(this._$AH!==U&&this._$AR(),this._$AH=U):t!==this._$AH&&t!==X&&this._(t):void 0!==t._$litType$?this.$(t):void 0!==t.nodeType?this.T(t):(t=>F(t)||"function"==typeof(null==t?void 0:t[Symbol.iterator]))(t)?this.k(t):this._(t)}O(t){return this._$AA.parentNode.insertBefore(t,this._$AB)}T(t){this._$AH!==t&&(this._$AR(),this._$AH=this.O(t))}_(t){this._$AH!==U&&L(this._$AH)?this._$AA.nextSibling.data=t:this.T(P.createTextNode(t)),this._$AH=t}$(t){var e;const{values:i,_$litType$:s}=t,r="number"==typeof s?this._$AC(t):(void 0===s.el&&(s.el=J.createElement(K(s.h,s.h[0]),this.options)),s);if((null==(e=this._$AH)?void 0:e._$AD)===r)this._$AH.p(i);else{const t=new Q(r,this),e=t.u(this.options);t.p(i),this.T(e),this._$AH=t}}_$AC(t){let e=Y.get(t.strings);return void 0===e&&Y.set(t.strings,e=new J(t)),e}k(e){F(this._$AH)||(this._$AH=[],this._$AR());const i=this._$AH;let s,r=0;for(const n of e)r===i.length?i.push(s=new t(this.O(j()),this.O(j()),this,this.options)):s=i[r],s._$AI(n),r++;r<i.length&&(this._$AR(s&&s._$AB.nextSibling,r),i.length=r)}_$AR(t=this._$AA.nextSibling,e){var i;for(null==(i=this._$AP)||i.call(this,!1,!0,e);t&&t!==this._$AB;){const e=t.nextSibling;t.remove(),t=e}}setConnected(t){var e;void 0===this._$AM&&(this._$Cv=t,null==(e=this._$AP)||e.call(this,t))}},et=class{get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}constructor(t,e,i,s,r){this.type=1,this._$AH=U,this._$AN=void 0,this.element=t,this.name=e,this._$AM=s,this.options=r,i.length>2||""!==i[0]||""!==i[1]?(this._$AH=Array(i.length-1).fill(new String),this.strings=i):this._$AH=U}_$AI(t,e=this,i,s){const r=this.strings;let n=!1;if(void 0===r)t=Z(this,t,e,0),n=!L(t)||t!==this._$AH&&t!==X,n&&(this._$AH=t);else{const s=t;let o,a;for(t=r[0],o=0;o<r.length-1;o++)a=Z(this,s[i+o],e,o),a===X&&(a=this._$AH[o]),n||(n=!L(a)||a!==this._$AH[o]),a===U?t=U:t!==U&&(t+=(a??"")+r[o+1]),this._$AH[o]=a}n&&!s&&this.j(t)}j(t){t===U?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,t??"")}},it=class extends et{constructor(){super(...arguments),this.type=3}j(t){this.element[this.name]=t===U?void 0:t}},st=class extends et{constructor(){super(...arguments),this.type=4}j(t){this.element.toggleAttribute(this.name,!!t&&t!==U)}},rt=class extends et{constructor(t,e,i,s,r){super(t,e,i,s,r),this.type=5}_$AI(t,e=this){if((t=Z(this,t,e,0)??U)===X)return;const i=this._$AH,s=t===U&&i!==U||t.capture!==i.capture||t.once!==i.once||t.passive!==i.passive,r=t!==U&&(i===U||s);s&&this.element.removeEventListener(this.name,this,i),r&&this.element.addEventListener(this.name,this,t),this._$AH=t}handleEvent(t){var e;"function"==typeof this._$AH?this._$AH.call((null==(e=this.options)?void 0:e.host)??this.element,t):this._$AH.handleEvent(t)}},nt=class{constructor(t,e,i){this.element=t,this.type=6,this._$AN=void 0,this._$AM=e,this.options=i}get _$AU(){return this._$AM._$AU}_$AI(t){Z(this,t)}};const ot=T.litHtmlPolyfillSupport;null==ot||ot(J,tt),(T.litHtmlVersions??(T.litHtmlVersions=[])).push("3.2.1");
18
+ /**
19
+ * @license
20
+ * Copyright 2017 Google LLC
21
+ * SPDX-License-Identifier: BSD-3-Clause
22
+ */
23
+ let at=class extends S{constructor(){super(...arguments),this.renderOptions={host:this},this._$Do=void 0}createRenderRoot(){var t;const e=super.createRenderRoot();return(t=this.renderOptions).renderBefore??(t.renderBefore=e.firstChild),e}update(t){const e=this.render();this.hasUpdated||(this.renderOptions.isConnected=this.isConnected),super.update(t),this._$Do=((t,e,i)=>{const s=(null==i?void 0:i.renderBefore)??e;let r=s._$litPart$;if(void 0===r){const t=(null==i?void 0:i.renderBefore)??null;s._$litPart$=r=new tt(e.insertBefore(j(),t),t,void 0,i??{})}return r._$AI(t),r})(e,this.renderRoot,this.renderOptions)}connectedCallback(){var t;super.connectedCallback(),null==(t=this._$Do)||t.setConnected(!0)}disconnectedCallback(){var t;super.disconnectedCallback(),null==(t=this._$Do)||t.setConnected(!1)}render(){return X}};at._$litElement$=!0,at.finalized=!0,null==(e=globalThis.litElementHydrateSupport)||e.call(globalThis,{LitElement:at});const lt=globalThis.litElementPolyfillSupport;null==lt||lt({LitElement:at}),(globalThis.litElementVersions??(globalThis.litElementVersions=[])).push("4.1.1");
24
+ /**
25
+ * @license
26
+ * Copyright 2017 Google LLC
27
+ * SPDX-License-Identifier: BSD-3-Clause
28
+ */
29
+ const ct=t=>(e,i)=>{void 0!==i?i.addInitializer((()=>{customElements.define(t,e)})):customElements.define(t,e)}
30
+ /**
31
+ * @license
32
+ * Copyright 2017 Google LLC
33
+ * SPDX-License-Identifier: BSD-3-Clause
34
+ */,ht={attribute:!0,type:String,converter:x,reflect:!1,hasChanged:w},dt=(t=ht,e,i)=>{const{kind:s,metadata:r}=i;let n=globalThis.litPropertyMetadata.get(r);if(void 0===n&&globalThis.litPropertyMetadata.set(r,n=new Map),n.set(i.name,t),"accessor"===s){const{name:s}=i;return{set(i){const r=e.get.call(this);e.set.call(this,i),this.requestUpdate(s,r,t)},init(e){return void 0!==e&&this.P(s,void 0,t),e}}}if("setter"===s){const{name:s}=i;return function(i){const r=this[s];e.call(this,i),this.requestUpdate(s,r,t)}}throw Error("Unsupported decorator location: "+s)};function ut(t){return(e,i)=>"object"==typeof i?dt(t,e,i):((t,e,i)=>{const s=e.hasOwnProperty(i);return e.constructor.createProperty(i,s?{...t,wrapped:!0}:t),s?Object.getOwnPropertyDescriptor(e,i):void 0})(t,e,i)}
35
+ /**
36
+ * @license
37
+ * Copyright 2017 Google LLC
38
+ * SPDX-License-Identifier: BSD-3-Clause
39
+ */function pt(t){return ut({...t,state:!0,attribute:!1})}
40
+ /**
41
+ * @license
42
+ * Copyright 2017 Google LLC
43
+ * SPDX-License-Identifier: BSD-3-Clause
44
+ */const gt=(t,e,i)=>(i.configurable=!0,i.enumerable=!0,Reflect.decorate&&"object"!=typeof e&&Object.defineProperty(t,e,i),i)
45
+ /**
46
+ * @license
47
+ * Copyright 2017 Google LLC
48
+ * SPDX-License-Identifier: BSD-3-Clause
49
+ */;function ft(t,e){return(e,i,s)=>gt(e,i,{get(){return(e=>{var i;return(null==(i=e.renderRoot)?void 0:i.querySelector(t))??null})(this)}})}
50
+ /**
51
+ * @license
52
+ * Copyright 2017 Google LLC
53
+ * SPDX-License-Identifier: BSD-3-Clause
54
+ */let mt;const vt=l`
44
55
  :host {
45
56
  display: block;
46
57
  font-family: Arial, sans-serif;
@@ -52,7 +63,7 @@
52
63
  background-color: #fff;
53
64
  color: black;
54
65
  }
55
- `;var Hu=Object.getOwnPropertyDescriptor,Wu=(n,t,e,i)=>{for(var s=i>1?void 0:i?Hu(t,e):t,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=o(s)||s);return s};z.MessageSelector=class extends ae{constructor(){super(),this.giftLabel="This is a gift?",this.premiumLabel="Add a premium greeting card",this.premiumDescription="Select a premium greeting card and add your personal message. You'll choose from our 100% recycled paper cards, priced at $6, and we'll package it with your gift for that extra thoughtful touch.",this.noteLabel="Add a free message",this.giftSelected=!1,this.premiumSelected=!1,this.freeMessageSelected=!1}toggleMessageSelector(){var e;const t=(e=this.shadowRoot)==null?void 0:e.querySelector(".message-selector");t&&t.classList.toggle("message-selector-hidden")}_onGiftChange(t){const e=t.target;this.giftSelected=e.checked,this.giftSelected||(this.premiumSelected=!1,this.freeMessageSelected=!1)}_onPremiumChange(t){t.target.checked?(this.premiumSelected=!0,this.freeMessageSelected=!1):this.premiumSelected=!1}_onFreeMessageChange(t){t.target.checked?(this.freeMessageSelected=!0,this.premiumSelected=!1):this.freeMessageSelected=!1}render(){return St`
66
+ `;var _t=Object.getOwnPropertyDescriptor;function bt(t,e,i){return(e="symbol"==typeof(s=function(t,e){if("object"!=typeof t||!t)return t;var i=t[Symbol.toPrimitive];if(void 0!==i){var s=i.call(t,e);if("object"!=typeof s)return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(e,"string"))?s:s+"")in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t;var s}function yt(t,e){var i=Object.keys(t);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(t);e&&(s=s.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),i.push.apply(i,s)}return i}function xt(t){for(var e=1;e<arguments.length;e++){var i=null!=arguments[e]?arguments[e]:{};e%2?yt(Object(i),!0).forEach((function(e){bt(t,e,i[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(i)):yt(Object(i)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(i,e))}))}return t}function wt(t,e){if(null==t)return{};var i,s,r=function(t,e){if(null==t)return{};var i={};for(var s in t)if({}.hasOwnProperty.call(t,s)){if(e.indexOf(s)>=0)continue;i[s]=t[s]}return i}(t,e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);for(s=0;s<n.length;s++)i=n[s],e.indexOf(i)>=0||{}.propertyIsEnumerable.call(t,i)&&(r[i]=t[i])}return r}function Ct(t,e){return e||(e=t.slice(0)),Object.freeze(Object.defineProperties(t,{raw:{value:Object.freeze(e)}}))}t.MessageSelector=class extends at{constructor(){super(),this.giftLabel="This is a gift?",this.premiumLabel="Add a premium greeting card",this.premiumDescription="Select a premium greeting card and add your personal message. You'll choose from our 100% recycled paper cards, priced at $6, and we'll package it with your gift for that extra thoughtful touch.",this.noteLabel="Add a free message",this.giftSelected=!1,this.premiumSelected=!1,this.freeMessageSelected=!1}toggleMessageSelector(){var t;const e=null==(t=this.shadowRoot)?void 0:t.querySelector(".message-selector");e&&e.classList.toggle("message-selector-hidden")}_onGiftChange(t){const e=t.target;this.giftSelected=e.checked,this.giftSelected||(this.premiumSelected=!1,this.freeMessageSelected=!1)}_onPremiumChange(t){t.target.checked?(this.premiumSelected=!0,this.freeMessageSelected=!1):this.premiumSelected=!1}_onFreeMessageChange(t){t.target.checked?(this.freeMessageSelected=!0,this.premiumSelected=!1):this.freeMessageSelected=!1}render(){return H`
56
67
  <div class="message-selector">
57
68
  <!-- Gift Checkbox: Always visible -->
58
69
  <div>
@@ -67,7 +78,7 @@
67
78
  </div>
68
79
 
69
80
  <!-- Premium and Free Message Options: Only visible if gift is selected -->
70
- ${this.giftSelected?St`
81
+ ${this.giftSelected?H`
71
82
  <div>
72
83
  <input
73
84
  type="checkbox"
@@ -103,7 +114,7 @@
103
114
  </ul>
104
115
  </div>
105
116
  </div>
106
- `}},z.MessageSelector.styles=[zu,Ct`
117
+ `}},t.MessageSelector.styles=[vt,l`
107
118
  .message-selector {
108
119
  text-align: left;
109
120
  }
@@ -124,524 +135,21 @@
124
135
  code {
125
136
  font-family: monospace;
126
137
  }
127
- `],z.MessageSelector.properties={giftLabel:{type:String},premiumLabel:{type:String},premiumDescription:{type:String},noteLabel:{type:String},giftSelected:{type:Boolean},premiumSelected:{type:Boolean},freeMessageSelected:{type:Boolean}},z.MessageSelector=Wu([Mt("pairbo-message-selector")],z.MessageSelector);function _(n,t,e){return(t=function(i){var s=function(r,o){if(typeof r!="object"||!r)return r;var a=r[Symbol.toPrimitive];if(a!==void 0){var l=a.call(r,o);if(typeof l!="object")return l;throw new TypeError("@@toPrimitive must return a primitive value.")}return(o==="string"?String:Number)(r)}(i,"string");return typeof s=="symbol"?s:s+""}(t))in n?Object.defineProperty(n,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):n[t]=e,n}function il(n,t){var e=Object.keys(n);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(n);t&&(i=i.filter(function(s){return Object.getOwnPropertyDescriptor(n,s).enumerable})),e.push.apply(e,i)}return e}function b(n){for(var t=1;t<arguments.length;t++){var e=arguments[t]!=null?arguments[t]:{};t%2?il(Object(e),!0).forEach(function(i){_(n,i,e[i])}):Object.getOwnPropertyDescriptors?Object.defineProperties(n,Object.getOwnPropertyDescriptors(e)):il(Object(e)).forEach(function(i){Object.defineProperty(n,i,Object.getOwnPropertyDescriptor(e,i))})}return n}function rt(n,t){if(n==null)return{};var e,i,s=function(o,a){if(o==null)return{};var l={};for(var c in o)if({}.hasOwnProperty.call(o,c)){if(a.indexOf(c)>=0)continue;l[c]=o[c]}return l}(n,t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(n);for(i=0;i<r.length;i++)e=r[i],t.indexOf(e)>=0||{}.propertyIsEnumerable.call(n,e)&&(s[e]=n[e])}return s}function ii(n,t){return t||(t=n.slice(0)),Object.freeze(Object.defineProperties(n,{raw:{value:Object.freeze(t)}}))}let sl=class{constructor(){_(this,"browserShadowBlurConstant",1),_(this,"DPI",96),_(this,"devicePixelRatio",typeof window<"u"?window.devicePixelRatio:1),_(this,"perfLimitSizeTotal",2097152),_(this,"maxCacheSideLimit",4096),_(this,"minCacheSideLimit",256),_(this,"disableStyleCopyPaste",!1),_(this,"enableGLFiltering",!0),_(this,"textureSize",4096),_(this,"forceGLPutImageData",!1),_(this,"cachesBoundsOfCurve",!1),_(this,"fontPaths",{}),_(this,"NUM_FRACTION_DIGITS",4)}};const J=new class extends sl{constructor(n){super(),this.configure(n)}configure(){let n=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};Object.assign(this,n)}addFonts(){let n=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};this.fontPaths=b(b({},this.fontPaths),n)}removeFonts(){(arguments.length>0&&arguments[0]!==void 0?arguments[0]:[]).forEach(n=>{delete this.fontPaths[n]})}clearFonts(){this.fontPaths={}}restoreDefaults(n){const t=new sl,e=(n==null?void 0:n.reduce((i,s)=>(i[s]=t[s],i),{}))||t;this.configure(e)}},si=function(n){for(var t=arguments.length,e=new Array(t>1?t-1:0),i=1;i<t;i++)e[i-1]=arguments[i];return console[n]("fabric",...e)};class ye extends Error{constructor(t,e){super("fabric: ".concat(t),e)}}class Yu extends ye{constructor(t){super("".concat(t," 'options.signal' is in 'aborted' state"))}}let Uu=class{},Gu=class extends Uu{testPrecision(t,e){const i="precision ".concat(e,` float;
128
- void main(){}`),s=t.createShader(t.FRAGMENT_SHADER);return!!s&&(t.shaderSource(s,i),t.compileShader(s),!!t.getShaderParameter(s,t.COMPILE_STATUS))}queryWebGL(t){const e=t.getContext("webgl");e&&(this.maxTextureSize=e.getParameter(e.MAX_TEXTURE_SIZE),this.GLPrecision=["highp","mediump","lowp"].find(i=>this.testPrecision(e,i)),e.getExtension("WEBGL_lose_context").loseContext(),si("log","WebGL: max texture size ".concat(this.maxTextureSize)))}isSupported(t){return!!this.maxTextureSize&&this.maxTextureSize>=t}};const Xu={};let rl;const xe=()=>rl||(rl={document,window,isTouchSupported:"ontouchstart"in window||"ontouchstart"in document||window&&window.navigator&&window.navigator.maxTouchPoints>0,WebGLProbe:new Gu,dispose(){},copyPasteData:Xu}),Yi=()=>xe().document,so=()=>xe().window,nl=()=>{var n;return Math.max((n=J.devicePixelRatio)!==null&&n!==void 0?n:so().devicePixelRatio,1)},As=new class{constructor(){_(this,"charWidthsCache",{}),_(this,"boundsOfCurveCache",{})}getFontCache(n){let{fontFamily:t,fontStyle:e,fontWeight:i}=n;t=t.toLowerCase(),this.charWidthsCache[t]||(this.charWidthsCache[t]={});const s=this.charWidthsCache[t],r="".concat(e.toLowerCase(),"_").concat((i+"").toLowerCase());return s[r]||(s[r]={}),s[r]}clearFontCache(n){(n=(n||"").toLowerCase())?this.charWidthsCache[n]&&delete this.charWidthsCache[n]:this.charWidthsCache={}}limitDimsByArea(n){const{perfLimitSizeTotal:t}=J,e=Math.sqrt(t*n);return[Math.floor(e),Math.floor(t/e)]}},ro="6.5.4";function Sr(){}const Ds=Math.PI/2,wr=2*Math.PI,no=Math.PI/180,Pt=Object.freeze([1,0,0,1,0,0]),oo=16,ri=.4477152502,G="center",Q="left",Ft="top",ao="bottom",dt="right",Rt="none",lo=/\r?\n/,ol="moving",Tr="scaling",al="rotating",co="rotate",ll="skewing",ks="resizing",Ku="modifyPoly",qu="modifyPath",Er="changed",Or="scale",Nt="scaleX",Zt="scaleY",Ui="skewX",Gi="skewY",bt="fill",Bt="stroke",Ar="modified",Xi="json",ho="svg",F=new class{constructor(){this[Xi]=new Map,this[ho]=new Map}has(n){return this[Xi].has(n)}getClass(n){const t=this[Xi].get(n);if(!t)throw new ye("No class registered for ".concat(n));return t}setClass(n,t){t?this[Xi].set(t,n):(this[Xi].set(n.type,n),this[Xi].set(n.type.toLowerCase(),n))}getSVGClass(n){return this[ho].get(n)}setSVGClass(n,t){this[ho].set(t??n.type.toLowerCase(),n)}},Dr=new class extends Array{remove(n){const t=this.indexOf(n);t>-1&&this.splice(t,1)}cancelAll(){const n=this.splice(0);return n.forEach(t=>t.abort()),n}cancelByCanvas(n){if(!n)return[];const t=this.filter(e=>{var i;return e.target===n||typeof e.target=="object"&&((i=e.target)===null||i===void 0?void 0:i.canvas)===n});return t.forEach(e=>e.abort()),t}cancelByTarget(n){if(!n)return[];const t=this.filter(e=>e.target===n);return t.forEach(e=>e.abort()),t}};class Ju{constructor(){_(this,"__eventListeners",{})}on(t,e){if(this.__eventListeners||(this.__eventListeners={}),typeof t=="object")return Object.entries(t).forEach(i=>{let[s,r]=i;this.on(s,r)}),()=>this.off(t);if(e){const i=t;return this.__eventListeners[i]||(this.__eventListeners[i]=[]),this.__eventListeners[i].push(e),()=>this.off(i,e)}return()=>!1}once(t,e){if(typeof t=="object"){const i=[];return Object.entries(t).forEach(s=>{let[r,o]=s;i.push(this.once(r,o))}),()=>i.forEach(s=>s())}if(e){const i=this.on(t,function(){for(var s=arguments.length,r=new Array(s),o=0;o<s;o++)r[o]=arguments[o];e.call(this,...r),i()});return i}return()=>!1}_removeEventListener(t,e){if(this.__eventListeners[t])if(e){const i=this.__eventListeners[t],s=i.indexOf(e);s>-1&&i.splice(s,1)}else this.__eventListeners[t]=[]}off(t,e){if(this.__eventListeners)if(t===void 0)for(const i in this.__eventListeners)this._removeEventListener(i);else typeof t=="object"?Object.entries(t).forEach(i=>{let[s,r]=i;this._removeEventListener(s,r)}):this._removeEventListener(t,e)}fire(t,e){var i;if(!this.__eventListeners)return;const s=(i=this.__eventListeners[t])===null||i===void 0?void 0:i.concat();if(s)for(let r=0;r<s.length;r++)s[r].call(this,e||{})}}const Ki=(n,t)=>{const e=n.indexOf(t);return e!==-1&&n.splice(e,1),n},Pe=n=>{if(n===0)return 1;switch(Math.abs(n)/Ds){case 1:case 3:return 0;case 2:return-1}return Math.cos(n)},Ie=n=>{if(n===0)return 0;const t=n/Ds,e=Math.sign(n);switch(t){case 1:return e;case 2:return 0;case 3:return-e}return Math.sin(n)};class C{constructor(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:0,e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0;typeof t=="object"?(this.x=t.x,this.y=t.y):(this.x=t,this.y=e)}add(t){return new C(this.x+t.x,this.y+t.y)}addEquals(t){return this.x+=t.x,this.y+=t.y,this}scalarAdd(t){return new C(this.x+t,this.y+t)}scalarAddEquals(t){return this.x+=t,this.y+=t,this}subtract(t){return new C(this.x-t.x,this.y-t.y)}subtractEquals(t){return this.x-=t.x,this.y-=t.y,this}scalarSubtract(t){return new C(this.x-t,this.y-t)}scalarSubtractEquals(t){return this.x-=t,this.y-=t,this}multiply(t){return new C(this.x*t.x,this.y*t.y)}scalarMultiply(t){return new C(this.x*t,this.y*t)}scalarMultiplyEquals(t){return this.x*=t,this.y*=t,this}divide(t){return new C(this.x/t.x,this.y/t.y)}scalarDivide(t){return new C(this.x/t,this.y/t)}scalarDivideEquals(t){return this.x/=t,this.y/=t,this}eq(t){return this.x===t.x&&this.y===t.y}lt(t){return this.x<t.x&&this.y<t.y}lte(t){return this.x<=t.x&&this.y<=t.y}gt(t){return this.x>t.x&&this.y>t.y}gte(t){return this.x>=t.x&&this.y>=t.y}lerp(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:.5;return e=Math.max(Math.min(1,e),0),new C(this.x+(t.x-this.x)*e,this.y+(t.y-this.y)*e)}distanceFrom(t){const e=this.x-t.x,i=this.y-t.y;return Math.sqrt(e*e+i*i)}midPointFrom(t){return this.lerp(t)}min(t){return new C(Math.min(this.x,t.x),Math.min(this.y,t.y))}max(t){return new C(Math.max(this.x,t.x),Math.max(this.y,t.y))}toString(){return"".concat(this.x,",").concat(this.y)}setXY(t,e){return this.x=t,this.y=e,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setFromPoint(t){return this.x=t.x,this.y=t.y,this}swap(t){const e=this.x,i=this.y;this.x=t.x,this.y=t.y,t.x=e,t.y=i}clone(){return new C(this.x,this.y)}rotate(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:uo;const i=Ie(t),s=Pe(t),r=this.subtract(e);return new C(r.x*s-r.y*i,r.x*i+r.y*s).add(e)}transform(t){let e=arguments.length>1&&arguments[1]!==void 0&&arguments[1];return new C(t[0]*this.x+t[2]*this.y+(e?0:t[4]),t[1]*this.x+t[3]*this.y+(e?0:t[5]))}}const uo=new C(0,0),kr=n=>!!n&&Array.isArray(n._objects);function cl(n){class t extends n{constructor(){super(...arguments),_(this,"_objects",[])}_onObjectAdded(i){}_onObjectRemoved(i){}_onStackOrderChanged(i){}add(){for(var i=arguments.length,s=new Array(i),r=0;r<i;r++)s[r]=arguments[r];const o=this._objects.push(...s);return s.forEach(a=>this._onObjectAdded(a)),o}insertAt(i){for(var s=arguments.length,r=new Array(s>1?s-1:0),o=1;o<s;o++)r[o-1]=arguments[o];return this._objects.splice(i,0,...r),r.forEach(a=>this._onObjectAdded(a)),this._objects.length}remove(){const i=this._objects,s=[];for(var r=arguments.length,o=new Array(r),a=0;a<r;a++)o[a]=arguments[a];return o.forEach(l=>{const c=i.indexOf(l);c!==-1&&(i.splice(c,1),s.push(l),this._onObjectRemoved(l))}),s}forEachObject(i){this.getObjects().forEach((s,r,o)=>i(s,r,o))}getObjects(){for(var i=arguments.length,s=new Array(i),r=0;r<i;r++)s[r]=arguments[r];return s.length===0?[...this._objects]:this._objects.filter(o=>o.isType(...s))}item(i){return this._objects[i]}isEmpty(){return this._objects.length===0}size(){return this._objects.length}contains(i,s){return!!this._objects.includes(i)||!!s&&this._objects.some(r=>r instanceof t&&r.contains(i,!0))}complexity(){return this._objects.reduce((i,s)=>i+=s.complexity?s.complexity():0,0)}sendObjectToBack(i){return!(!i||i===this._objects[0])&&(Ki(this._objects,i),this._objects.unshift(i),this._onStackOrderChanged(i),!0)}bringObjectToFront(i){return!(!i||i===this._objects[this._objects.length-1])&&(Ki(this._objects,i),this._objects.push(i),this._onStackOrderChanged(i),!0)}sendObjectBackwards(i,s){if(!i)return!1;const r=this._objects.indexOf(i);if(r!==0){const o=this.findNewLowerIndex(i,r,s);return Ki(this._objects,i),this._objects.splice(o,0,i),this._onStackOrderChanged(i),!0}return!1}bringObjectForward(i,s){if(!i)return!1;const r=this._objects.indexOf(i);if(r!==this._objects.length-1){const o=this.findNewUpperIndex(i,r,s);return Ki(this._objects,i),this._objects.splice(o,0,i),this._onStackOrderChanged(i),!0}return!1}moveObjectTo(i,s){return i!==this._objects[s]&&(Ki(this._objects,i),this._objects.splice(s,0,i),this._onStackOrderChanged(i),!0)}findNewLowerIndex(i,s,r){let o;if(r){o=s;for(let a=s-1;a>=0;--a)if(i.isOverlapping(this._objects[a])){o=a;break}}else o=s-1;return o}findNewUpperIndex(i,s,r){let o;if(r){o=s;for(let a=s+1;a<this._objects.length;++a)if(i.isOverlapping(this._objects[a])){o=a;break}}else o=s+1;return o}collectObjects(i){let{left:s,top:r,width:o,height:a}=i,{includeIntersecting:l=!0}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};const c=[],h=new C(s,r),u=h.add(new C(o,a));for(let d=this._objects.length-1;d>=0;d--){const f=this._objects[d];f.selectable&&f.visible&&(l&&f.intersectsWithRect(h,u)||f.isContainedWithinRect(h,u)||l&&f.containsPoint(h)||l&&f.containsPoint(u))&&c.push(f)}return c}}return t}class hl extends Ju{_setOptions(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};for(const e in t)this.set(e,t[e])}_setObject(t){for(const e in t)this._set(e,t[e])}set(t,e){return typeof t=="object"?this._setObject(t):this._set(t,e),this}_set(t,e){this[t]=e}toggle(t){const e=this.get(t);return typeof e=="boolean"&&this.set(t,!e),this}get(t){return this[t]}}function Mr(n){return so().requestAnimationFrame(n)}function Zu(n){return so().cancelAnimationFrame(n)}let Qu=0;const ni=()=>Qu++,le=()=>{const n=Yi().createElement("canvas");if(!n||n.getContext===void 0)throw new ye("Failed to create `canvas` element");return n},td=()=>Yi().createElement("img"),Ce=n=>{const t=le();return t.width=n.width,t.height=n.height,t},ul=(n,t,e)=>n.toDataURL("image/".concat(t),e),ft=n=>n*no,wi=n=>n/no,ed=n=>n.every((t,e)=>t===Pt[e]),$t=(n,t,e)=>new C(n).transform(t,e),ce=n=>{const t=1/(n[0]*n[3]-n[1]*n[2]),e=[t*n[3],-t*n[1],-t*n[2],t*n[0],0,0],{x:i,y:s}=new C(n[4],n[5]).transform(e,!0);return e[4]=-i,e[5]=-s,e},Tt=(n,t,e)=>[n[0]*t[0]+n[2]*t[1],n[1]*t[0]+n[3]*t[1],n[0]*t[2]+n[2]*t[3],n[1]*t[2]+n[3]*t[3],e?0:n[0]*t[4]+n[2]*t[5]+n[4],e?0:n[1]*t[4]+n[3]*t[5]+n[5]],fo=(n,t)=>n.reduceRight((e,i)=>i&&e?Tt(i,e,t):i||e,void 0)||Pt.concat(),dl=n=>{let[t,e]=n;return Math.atan2(e,t)},Pr=n=>{const t=dl(n),e=Math.pow(n[0],2)+Math.pow(n[1],2),i=Math.sqrt(e),s=(n[0]*n[3]-n[2]*n[1])/i,r=Math.atan2(n[0]*n[2]+n[1]*n[3],e);return{angle:wi(t),scaleX:i,scaleY:s,skewX:wi(r),skewY:0,translateX:n[4]||0,translateY:n[5]||0}},Ms=function(n){return[1,0,0,1,n,arguments.length>1&&arguments[1]!==void 0?arguments[1]:0]};function Ps(){let{angle:n=0}=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},{x:t=0,y:e=0}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};const i=ft(n),s=Pe(i),r=Ie(i);return[s,r,-r,s,t?t-(s*t-r*e):0,e?e-(r*t+s*e):0]}const go=function(n){return[n,0,0,arguments.length>1&&arguments[1]!==void 0?arguments[1]:n,0,0]},fl=n=>Math.tan(ft(n)),gl=n=>[1,0,fl(n),1,0,0],pl=n=>[1,fl(n),0,1,0,0],Ir=n=>{let{scaleX:t=1,scaleY:e=1,flipX:i=!1,flipY:s=!1,skewX:r=0,skewY:o=0}=n,a=go(i?-t:t,s?-e:e);return r&&(a=Tt(a,gl(r),!0)),o&&(a=Tt(a,pl(o),!0)),a},id=n=>{const{translateX:t=0,translateY:e=0,angle:i=0}=n;let s=Ms(t,e);i&&(s=Tt(s,Ps({angle:i})));const r=Ir(n);return ed(r)||(s=Tt(s,r)),s},Lr=function(n){let{signal:t,crossOrigin:e=null}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return new Promise(function(i,s){if(t&&t.aborted)return s(new Yu("loadImage"));const r=td();let o;t&&(o=function(l){r.src="",s(l)},t.addEventListener("abort",o,{once:!0}));const a=function(){r.onload=r.onerror=null,o&&(t==null||t.removeEventListener("abort",o)),i(r)};n?(r.onload=a,r.onerror=function(){o&&(t==null||t.removeEventListener("abort",o)),s(new ye("Error loading ".concat(r.src)))},e&&(r.crossOrigin=e),r.src=n):a()})},Is=function(n){let{signal:t,reviver:e=Sr}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return new Promise((i,s)=>{const r=[];t&&t.addEventListener("abort",s,{once:!0}),Promise.all(n.map(o=>F.getClass(o.type).fromObject(o,{signal:t}).then(a=>(e(o,a),r.push(a),a)))).then(i).catch(o=>{r.forEach(a=>{a.dispose&&a.dispose()}),s(o)}).finally(()=>{t&&t.removeEventListener("abort",s)})})},jr=function(n){let{signal:t}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return new Promise((e,i)=>{const s=[];t&&t.addEventListener("abort",i,{once:!0});const r=Object.values(n).map(a=>a&&a.type&&F.has(a.type)?Is([a],{signal:t}).then(l=>{let[c]=l;return s.push(c),c}):a),o=Object.keys(n);Promise.all(r).then(a=>a.reduce((l,c,h)=>(l[o[h]]=c,l),{})).then(e).catch(a=>{s.forEach(l=>{l.dispose&&l.dispose()}),i(a)}).finally(()=>{t&&t.removeEventListener("abort",i)})})},qi=function(n){return(arguments.length>1&&arguments[1]!==void 0?arguments[1]:[]).reduce((t,e)=>(e in n&&(t[e]=n[e]),t),{})},po=(n,t)=>Object.keys(n).reduce((e,i)=>(t(n[i],i,n)&&(e[i]=n[i]),e),{}),ml={aliceblue:"#F0F8FF",antiquewhite:"#FAEBD7",aqua:"#0FF",aquamarine:"#7FFFD4",azure:"#F0FFFF",beige:"#F5F5DC",bisque:"#FFE4C4",black:"#000",blanchedalmond:"#FFEBCD",blue:"#00F",blueviolet:"#8A2BE2",brown:"#A52A2A",burlywood:"#DEB887",cadetblue:"#5F9EA0",chartreuse:"#7FFF00",chocolate:"#D2691E",coral:"#FF7F50",cornflowerblue:"#6495ED",cornsilk:"#FFF8DC",crimson:"#DC143C",cyan:"#0FF",darkblue:"#00008B",darkcyan:"#008B8B",darkgoldenrod:"#B8860B",darkgray:"#A9A9A9",darkgrey:"#A9A9A9",darkgreen:"#006400",darkkhaki:"#BDB76B",darkmagenta:"#8B008B",darkolivegreen:"#556B2F",darkorange:"#FF8C00",darkorchid:"#9932CC",darkred:"#8B0000",darksalmon:"#E9967A",darkseagreen:"#8FBC8F",darkslateblue:"#483D8B",darkslategray:"#2F4F4F",darkslategrey:"#2F4F4F",darkturquoise:"#00CED1",darkviolet:"#9400D3",deeppink:"#FF1493",deepskyblue:"#00BFFF",dimgray:"#696969",dimgrey:"#696969",dodgerblue:"#1E90FF",firebrick:"#B22222",floralwhite:"#FFFAF0",forestgreen:"#228B22",fuchsia:"#F0F",gainsboro:"#DCDCDC",ghostwhite:"#F8F8FF",gold:"#FFD700",goldenrod:"#DAA520",gray:"#808080",grey:"#808080",green:"#008000",greenyellow:"#ADFF2F",honeydew:"#F0FFF0",hotpink:"#FF69B4",indianred:"#CD5C5C",indigo:"#4B0082",ivory:"#FFFFF0",khaki:"#F0E68C",lavender:"#E6E6FA",lavenderblush:"#FFF0F5",lawngreen:"#7CFC00",lemonchiffon:"#FFFACD",lightblue:"#ADD8E6",lightcoral:"#F08080",lightcyan:"#E0FFFF",lightgoldenrodyellow:"#FAFAD2",lightgray:"#D3D3D3",lightgrey:"#D3D3D3",lightgreen:"#90EE90",lightpink:"#FFB6C1",lightsalmon:"#FFA07A",lightseagreen:"#20B2AA",lightskyblue:"#87CEFA",lightslategray:"#789",lightslategrey:"#789",lightsteelblue:"#B0C4DE",lightyellow:"#FFFFE0",lime:"#0F0",limegreen:"#32CD32",linen:"#FAF0E6",magenta:"#F0F",maroon:"#800000",mediumaquamarine:"#66CDAA",mediumblue:"#0000CD",mediumorchid:"#BA55D3",mediumpurple:"#9370DB",mediumseagreen:"#3CB371",mediumslateblue:"#7B68EE",mediumspringgreen:"#00FA9A",mediumturquoise:"#48D1CC",mediumvioletred:"#C71585",midnightblue:"#191970",mintcream:"#F5FFFA",mistyrose:"#FFE4E1",moccasin:"#FFE4B5",navajowhite:"#FFDEAD",navy:"#000080",oldlace:"#FDF5E6",olive:"#808000",olivedrab:"#6B8E23",orange:"#FFA500",orangered:"#FF4500",orchid:"#DA70D6",palegoldenrod:"#EEE8AA",palegreen:"#98FB98",paleturquoise:"#AFEEEE",palevioletred:"#DB7093",papayawhip:"#FFEFD5",peachpuff:"#FFDAB9",peru:"#CD853F",pink:"#FFC0CB",plum:"#DDA0DD",powderblue:"#B0E0E6",purple:"#800080",rebeccapurple:"#639",red:"#F00",rosybrown:"#BC8F8F",royalblue:"#4169E1",saddlebrown:"#8B4513",salmon:"#FA8072",sandybrown:"#F4A460",seagreen:"#2E8B57",seashell:"#FFF5EE",sienna:"#A0522D",silver:"#C0C0C0",skyblue:"#87CEEB",slateblue:"#6A5ACD",slategray:"#708090",slategrey:"#708090",snow:"#FFFAFA",springgreen:"#00FF7F",steelblue:"#4682B4",tan:"#D2B48C",teal:"#008080",thistle:"#D8BFD8",tomato:"#FF6347",turquoise:"#40E0D0",violet:"#EE82EE",wheat:"#F5DEB3",white:"#FFF",whitesmoke:"#F5F5F5",yellow:"#FF0",yellowgreen:"#9ACD32"},mo=(n,t,e)=>(e<0&&(e+=1),e>1&&(e-=1),e<1/6?n+6*(t-n)*e:e<.5?t:e<2/3?n+(t-n)*(2/3-e)*6:n),vl=(n,t,e,i)=>{n/=255,t/=255,e/=255;const s=Math.max(n,t,e),r=Math.min(n,t,e);let o,a;const l=(s+r)/2;if(s===r)o=a=0;else{const c=s-r;switch(a=l>.5?c/(2-s-r):c/(s+r),s){case n:o=(t-e)/c+(t<e?6:0);break;case t:o=(e-n)/c+2;break;case e:o=(n-t)/c+4}o/=6}return[Math.round(360*o),Math.round(100*a),Math.round(100*l),i]},_l=function(){let n=arguments.length>0&&arguments[0]!==void 0?arguments[0]:"1";return parseFloat(n)/(n.endsWith("%")?100:1)},Fr=n=>Math.min(Math.round(n),255).toString(16).toUpperCase().padStart(2,"0"),bl=n=>{let[t,e,i,s=1]=n;const r=Math.round(.3*t+.59*e+.11*i);return[r,r,r,s]};class tt{constructor(t){if(_(this,"isUnrecognised",!1),t)if(t instanceof tt)this.setSource([...t._source]);else if(Array.isArray(t)){const[e,i,s,r=1]=t;this.setSource([e,i,s,r])}else this.setSource(this._tryParsingColor(t));else this.setSource([0,0,0,1])}_tryParsingColor(t){return(t=t.toLowerCase())in ml&&(t=ml[t]),t==="transparent"?[255,255,255,0]:tt.sourceFromHex(t)||tt.sourceFromRgb(t)||tt.sourceFromHsl(t)||(this.isUnrecognised=!0)&&[0,0,0,1]}getSource(){return this._source}setSource(t){this._source=t}toRgb(){const[t,e,i]=this.getSource();return"rgb(".concat(t,",").concat(e,",").concat(i,")")}toRgba(){return"rgba(".concat(this.getSource().join(","),")")}toHsl(){const[t,e,i]=vl(...this.getSource());return"hsl(".concat(t,",").concat(e,"%,").concat(i,"%)")}toHsla(){const[t,e,i,s]=vl(...this.getSource());return"hsla(".concat(t,",").concat(e,"%,").concat(i,"%,").concat(s,")")}toHex(){return this.toHexa().slice(0,6)}toHexa(){const[t,e,i,s]=this.getSource();return"".concat(Fr(t)).concat(Fr(e)).concat(Fr(i)).concat(Fr(Math.round(255*s)))}getAlpha(){return this.getSource()[3]}setAlpha(t){return this._source[3]=t,this}toGrayscale(){return this.setSource(bl(this.getSource())),this}toBlackWhite(t){const[e,,,i]=bl(this.getSource()),s=e<(t||127)?0:255;return this.setSource([s,s,s,i]),this}overlayWith(t){t instanceof tt||(t=new tt(t));const e=this.getSource(),i=t.getSource(),[s,r,o]=e.map((a,l)=>Math.round(.5*a+.5*i[l]));return this.setSource([s,r,o,e[3]]),this}static fromRgb(t){return tt.fromRgba(t)}static fromRgba(t){return new tt(tt.sourceFromRgb(t))}static sourceFromRgb(t){const e=t.match(/^rgba?\(\s*(\d{0,3}(?:\.\d+)?%?)\s*[\s|,]\s*(\d{0,3}(?:\.\d+)?%?)\s*[\s|,]\s*(\d{0,3}(?:\.\d+)?%?)\s*(?:\s*[,/]\s*(\d{0,3}(?:\.\d+)?%?)\s*)?\)$/i);if(e){const[i,s,r]=e.slice(1,4).map(o=>{const a=parseFloat(o);return o.endsWith("%")?Math.round(2.55*a):a});return[i,s,r,_l(e[4])]}}static fromHsl(t){return tt.fromHsla(t)}static fromHsla(t){return new tt(tt.sourceFromHsl(t))}static sourceFromHsl(t){const e=t.match(/^hsla?\(\s*([+-]?\d{0,3}(?:\.\d+)?(?:deg|turn|rad)?)\s*[\s|,]\s*(\d{0,3}(?:\.\d+)?%?)\s*[\s|,]\s*(\d{0,3}(?:\.\d+)?%?)\s*(?:\s*[,/]\s*(\d*(?:\.\d+)?%?)\s*)?\)$/i);if(!e)return;const i=(tt.parseAngletoDegrees(e[1])%360+360)%360/360,s=parseFloat(e[2])/100,r=parseFloat(e[3])/100;let o,a,l;if(s===0)o=a=l=r;else{const c=r<=.5?r*(s+1):r+s-r*s,h=2*r-c;o=mo(h,c,i+1/3),a=mo(h,c,i),l=mo(h,c,i-1/3)}return[Math.round(255*o),Math.round(255*a),Math.round(255*l),_l(e[4])]}static fromHex(t){return new tt(tt.sourceFromHex(t))}static sourceFromHex(t){if(t.match(/^#?(([0-9a-f]){3,4}|([0-9a-f]{2}){3,4})$/i)){const e=t.slice(t.indexOf("#")+1);let i;i=e.length<=4?e.split("").map(l=>l+l):e.match(/.{2}/g);const[s,r,o,a=255]=i.map(l=>parseInt(l,16));return[s,r,o,a/255]}}static parseAngletoDegrees(t){const e=t.toLowerCase(),i=parseFloat(e);return e.includes("rad")?wi(i):e.includes("turn")?360*i:i}}const lt=(n,t)=>parseFloat(Number(n).toFixed(t)),Ji=function(n){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:oo;const e=/\D{0,2}$/.exec(n),i=parseFloat(n),s=J.DPI;switch(e==null?void 0:e[0]){case"mm":return i*s/25.4;case"cm":return i*s/2.54;case"in":return i*s;case"pt":return i*s/72;case"pc":return i*s/72*12;case"em":return i*t;default:return i}},sd=n=>{const[t,e]=n.trim().split(" "),[i,s]=(r=t)&&r!==Rt?[r.slice(1,4),r.slice(5,8)]:r===Rt?[r,r]:["Mid","Mid"];var r;return{meetOrSlice:e||"meet",alignX:i,alignY:s}},Rr=n=>"matrix("+n.map(t=>lt(t,J.NUM_FRACTION_DIGITS)).join(" ")+")",Ls=function(n,t){let e,i,s=!(arguments.length>2&&arguments[2]!==void 0)||arguments[2];if(t)if(t.toLive)e="url(#SVGID_".concat(t.id,")");else{const r=new tt(t),o=r.getAlpha();e=r.toRgb(),o!==1&&(i=o.toString())}else e="none";return s?"".concat(n,": ").concat(e,"; ").concat(i?"".concat(n,"-opacity: ").concat(i,"; "):""):"".concat(n,'="').concat(e,'" ').concat(i?"".concat(n,'-opacity="').concat(i,'" '):"")},Qt=n=>!!n&&n.toLive!==void 0,yl=n=>!!n&&typeof n.toObject=="function",xl=n=>!!n&&n.offsetX!==void 0&&"source"in n,Ti=n=>!!n&&"multiSelectionStacking"in n;function Cl(n){const t=n&&he(n);let e=0,i=0;if(!n||!t)return{left:e,top:i};let s=n;const r=t.documentElement,o=t.body||{scrollLeft:0,scrollTop:0};for(;s&&(s.parentNode||s.host)&&(s=s.parentNode||s.host,s===t?(e=o.scrollLeft||r.scrollLeft||0,i=o.scrollTop||r.scrollTop||0):(e+=s.scrollLeft||0,i+=s.scrollTop||0),s.nodeType!==1||s.style.position!=="fixed"););return{left:e,top:i}}const he=n=>n.ownerDocument||null,Sl=n=>{var t;return((t=n.ownerDocument)===null||t===void 0?void 0:t.defaultView)||null},wl=function(n,t,e){let{width:i,height:s}=e,r=arguments.length>3&&arguments[3]!==void 0?arguments[3]:1;n.width=i,n.height=s,r>1&&(n.setAttribute("width",(i*r).toString()),n.setAttribute("height",(s*r).toString()),t.scale(r,r))},vo=(n,t)=>{let{width:e,height:i}=t;e&&(n.style.width=typeof e=="number"?"".concat(e,"px"):e),i&&(n.style.height=typeof i=="number"?"".concat(i,"px"):i)};function Tl(n){return n.onselectstart!==void 0&&(n.onselectstart=()=>!1),n.style.userSelect=Rt,n}class El{constructor(t){_(this,"_originalCanvasStyle",void 0),_(this,"lower",void 0);const e=this.createLowerCanvas(t);this.lower={el:e,ctx:e.getContext("2d")}}createLowerCanvas(t){const e=(i=t)&&i.getContext!==void 0?t:t&&Yi().getElementById(t)||le();var i;if(e.hasAttribute("data-fabric"))throw new ye("Trying to initialize a canvas that has already been initialized. Did you forget to dispose the canvas?");return this._originalCanvasStyle=e.style.cssText,e.setAttribute("data-fabric","main"),e.classList.add("lower-canvas"),e}cleanupDOM(t){let{width:e,height:i}=t;const{el:s}=this.lower;s.classList.remove("lower-canvas"),s.removeAttribute("data-fabric"),s.setAttribute("width","".concat(e)),s.setAttribute("height","".concat(i)),s.style.cssText=this._originalCanvasStyle||"",this._originalCanvasStyle=void 0}setDimensions(t,e){const{el:i,ctx:s}=this.lower;wl(i,s,t,e)}setCSSDimensions(t){vo(this.lower.el,t)}calcOffset(){return function(t){var e;const i=t&&he(t),s={left:0,top:0};if(!i)return s;const r=((e=Sl(t))===null||e===void 0?void 0:e.getComputedStyle(t,null))||{};s.left+=parseInt(r.borderLeftWidth,10)||0,s.top+=parseInt(r.borderTopWidth,10)||0,s.left+=parseInt(r.paddingLeft,10)||0,s.top+=parseInt(r.paddingTop,10)||0;let o={left:0,top:0};const a=i.documentElement;t.getBoundingClientRect!==void 0&&(o=t.getBoundingClientRect());const l=Cl(t);return{left:o.left+l.left-(a.clientLeft||0)+s.left,top:o.top+l.top-(a.clientTop||0)+s.top}}(this.lower.el)}dispose(){xe().dispose(this.lower.el),delete this.lower}}const rd={backgroundVpt:!0,backgroundColor:"",overlayVpt:!0,overlayColor:"",includeDefaultValues:!0,svgViewportTransformation:!0,renderOnAddRemove:!0,skipOffscreen:!0,enableRetinaScaling:!0,imageSmoothingEnabled:!0,controlsAboveOverlay:!1,allowTouchScrolling:!1,viewportTransform:[...Pt]};class js extends cl(hl){get lowerCanvasEl(){var t;return(t=this.elements.lower)===null||t===void 0?void 0:t.el}get contextContainer(){var t;return(t=this.elements.lower)===null||t===void 0?void 0:t.ctx}static getDefaults(){return js.ownDefaults}constructor(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};super(),Object.assign(this,this.constructor.getDefaults()),this.set(e),this.initElements(t),this._setDimensionsImpl({width:this.width||this.elements.lower.el.width||0,height:this.height||this.elements.lower.el.height||0}),this.skipControlsDrawing=!1,this.viewportTransform=[...this.viewportTransform],this.calcViewportBoundaries()}initElements(t){this.elements=new El(t)}add(){const t=super.add(...arguments);return arguments.length>0&&this.renderOnAddRemove&&this.requestRenderAll(),t}insertAt(t){for(var e=arguments.length,i=new Array(e>1?e-1:0),s=1;s<e;s++)i[s-1]=arguments[s];const r=super.insertAt(t,...i);return i.length>0&&this.renderOnAddRemove&&this.requestRenderAll(),r}remove(){const t=super.remove(...arguments);return t.length>0&&this.renderOnAddRemove&&this.requestRenderAll(),t}_onObjectAdded(t){t.canvas&&t.canvas!==this&&(si("warn",`Canvas is trying to add an object that belongs to a different canvas.
129
- Resulting to default behavior: removing object from previous canvas and adding to new canvas`),t.canvas.remove(t)),t._set("canvas",this),t.setCoords(),this.fire("object:added",{target:t}),t.fire("added",{target:this})}_onObjectRemoved(t){t._set("canvas",void 0),this.fire("object:removed",{target:t}),t.fire("removed",{target:this})}_onStackOrderChanged(){this.renderOnAddRemove&&this.requestRenderAll()}getRetinaScaling(){return this.enableRetinaScaling?nl():1}calcOffset(){return this._offset=this.elements.calcOffset()}getWidth(){return this.width}getHeight(){return this.height}setWidth(t,e){return this.setDimensions({width:t},e)}setHeight(t,e){return this.setDimensions({height:t},e)}_setDimensionsImpl(t){let{cssOnly:e=!1,backstoreOnly:i=!1}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(!e){const s=b({width:this.width,height:this.height},t);this.elements.setDimensions(s,this.getRetinaScaling()),this.hasLostContext=!0,this.width=s.width,this.height=s.height}i||this.elements.setCSSDimensions(t),this.calcOffset()}setDimensions(t,e){this._setDimensionsImpl(t,e),e&&e.cssOnly||this.requestRenderAll()}getZoom(){return this.viewportTransform[0]}setViewportTransform(t){this.viewportTransform=t,this.calcViewportBoundaries(),this.renderOnAddRemove&&this.requestRenderAll()}zoomToPoint(t,e){const i=t,s=[...this.viewportTransform],r=$t(t,ce(s));s[0]=e,s[3]=e;const o=$t(r,s);s[4]+=i.x-o.x,s[5]+=i.y-o.y,this.setViewportTransform(s)}setZoom(t){this.zoomToPoint(new C(0,0),t)}absolutePan(t){const e=[...this.viewportTransform];return e[4]=-t.x,e[5]=-t.y,this.setViewportTransform(e)}relativePan(t){return this.absolutePan(new C(-t.x-this.viewportTransform[4],-t.y-this.viewportTransform[5]))}getElement(){return this.elements.lower.el}clearContext(t){t.clearRect(0,0,this.width,this.height)}getContext(){return this.elements.lower.ctx}clear(){this.remove(...this.getObjects()),this.backgroundImage=void 0,this.overlayImage=void 0,this.backgroundColor="",this.overlayColor="",this.clearContext(this.getContext()),this.fire("canvas:cleared"),this.renderOnAddRemove&&this.requestRenderAll()}renderAll(){this.cancelRequestedRender(),this.destroyed||this.renderCanvas(this.getContext(),this._objects)}renderAndReset(){this.nextRenderHandle=0,this.renderAll()}requestRenderAll(){this.nextRenderHandle||this.disposed||this.destroyed||(this.nextRenderHandle=Mr(()=>this.renderAndReset()))}calcViewportBoundaries(){const t=this.width,e=this.height,i=ce(this.viewportTransform),s=$t({x:0,y:0},i),r=$t({x:t,y:e},i),o=s.min(r),a=s.max(r);return this.vptCoords={tl:o,tr:new C(a.x,o.y),bl:new C(o.x,a.y),br:a}}cancelRequestedRender(){this.nextRenderHandle&&(Zu(this.nextRenderHandle),this.nextRenderHandle=0)}drawControls(t){}renderCanvas(t,e){if(this.destroyed)return;const i=this.viewportTransform,s=this.clipPath;this.calcViewportBoundaries(),this.clearContext(t),t.imageSmoothingEnabled=this.imageSmoothingEnabled,t.patternQuality="best",this.fire("before:render",{ctx:t}),this._renderBackground(t),t.save(),t.transform(i[0],i[1],i[2],i[3],i[4],i[5]),this._renderObjects(t,e),t.restore(),this.controlsAboveOverlay||this.skipControlsDrawing||this.drawControls(t),s&&(s._set("canvas",this),s.shouldCache(),s._transformDone=!0,s.renderCache({forClipping:!0}),this.drawClipPathOnCanvas(t,s)),this._renderOverlay(t),this.controlsAboveOverlay&&!this.skipControlsDrawing&&this.drawControls(t),this.fire("after:render",{ctx:t}),this.__cleanupTask&&(this.__cleanupTask(),this.__cleanupTask=void 0)}drawClipPathOnCanvas(t,e){const i=this.viewportTransform;t.save(),t.transform(...i),t.globalCompositeOperation="destination-in",e.transform(t),t.scale(1/e.zoomX,1/e.zoomY),t.drawImage(e._cacheCanvas,-e.cacheTranslationX,-e.cacheTranslationY),t.restore()}_renderObjects(t,e){for(let i=0,s=e.length;i<s;++i)e[i]&&e[i].render(t)}_renderBackgroundOrOverlay(t,e){const i=this["".concat(e,"Color")],s=this["".concat(e,"Image")],r=this.viewportTransform,o=this["".concat(e,"Vpt")];if(!i&&!s)return;const a=Qt(i);if(i){if(t.save(),t.beginPath(),t.moveTo(0,0),t.lineTo(this.width,0),t.lineTo(this.width,this.height),t.lineTo(0,this.height),t.closePath(),t.fillStyle=a?i.toLive(t):i,o&&t.transform(...r),a){t.transform(1,0,0,1,i.offsetX||0,i.offsetY||0);const l=i.gradientTransform||i.patternTransform;l&&t.transform(...l)}t.fill(),t.restore()}if(s){t.save();const{skipOffscreen:l}=this;this.skipOffscreen=o,o&&t.transform(...r),s.render(t),this.skipOffscreen=l,t.restore()}}_renderBackground(t){this._renderBackgroundOrOverlay(t,"background")}_renderOverlay(t){this._renderBackgroundOrOverlay(t,"overlay")}getCenter(){return{top:this.height/2,left:this.width/2}}getCenterPoint(){return new C(this.width/2,this.height/2)}centerObjectH(t){return this._centerObject(t,new C(this.getCenterPoint().x,t.getCenterPoint().y))}centerObjectV(t){return this._centerObject(t,new C(t.getCenterPoint().x,this.getCenterPoint().y))}centerObject(t){return this._centerObject(t,this.getCenterPoint())}viewportCenterObject(t){return this._centerObject(t,this.getVpCenter())}viewportCenterObjectH(t){return this._centerObject(t,new C(this.getVpCenter().x,t.getCenterPoint().y))}viewportCenterObjectV(t){return this._centerObject(t,new C(t.getCenterPoint().x,this.getVpCenter().y))}getVpCenter(){return $t(this.getCenterPoint(),ce(this.viewportTransform))}_centerObject(t,e){t.setXY(e,G,G),t.setCoords(),this.renderOnAddRemove&&this.requestRenderAll()}toDatalessJSON(t){return this.toDatalessObject(t)}toObject(t){return this._toObjectMethod("toObject",t)}toJSON(){return this.toObject()}toDatalessObject(t){return this._toObjectMethod("toDatalessObject",t)}_toObjectMethod(t,e){const i=this.clipPath,s=i&&!i.excludeFromExport?this._toObject(i,t,e):null;return b(b(b({version:ro},qi(this,e)),{},{objects:this._objects.filter(r=>!r.excludeFromExport).map(r=>this._toObject(r,t,e))},this.__serializeBgOverlay(t,e)),s?{clipPath:s}:null)}_toObject(t,e,i){let s;this.includeDefaultValues||(s=t.includeDefaultValues,t.includeDefaultValues=!1);const r=t[e](i);return this.includeDefaultValues||(t.includeDefaultValues=!!s),r}__serializeBgOverlay(t,e){const i={},s=this.backgroundImage,r=this.overlayImage,o=this.backgroundColor,a=this.overlayColor;return Qt(o)?o.excludeFromExport||(i.background=o.toObject(e)):o&&(i.background=o),Qt(a)?a.excludeFromExport||(i.overlay=a.toObject(e)):a&&(i.overlay=a),s&&!s.excludeFromExport&&(i.backgroundImage=this._toObject(s,t,e)),r&&!r.excludeFromExport&&(i.overlayImage=this._toObject(r,t,e)),i}toSVG(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},e=arguments.length>1?arguments[1]:void 0;t.reviver=e;const i=[];return this._setSVGPreamble(i,t),this._setSVGHeader(i,t),this.clipPath&&i.push('<g clip-path="url(#'.concat(this.clipPath.clipPathId,`)" >
130
- `)),this._setSVGBgOverlayColor(i,"background"),this._setSVGBgOverlayImage(i,"backgroundImage",e),this._setSVGObjects(i,e),this.clipPath&&i.push(`</g>
131
- `),this._setSVGBgOverlayColor(i,"overlay"),this._setSVGBgOverlayImage(i,"overlayImage",e),i.push("</svg>"),i.join("")}_setSVGPreamble(t,e){e.suppressPreamble||t.push('<?xml version="1.0" encoding="',e.encoding||"UTF-8",`" standalone="no" ?>
132
- `,'<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" ',`"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
133
- `)}_setSVGHeader(t,e){const i=e.width||"".concat(this.width),s=e.height||"".concat(this.height),r=J.NUM_FRACTION_DIGITS,o=e.viewBox;let a;if(o)a='viewBox="'.concat(o.x," ").concat(o.y," ").concat(o.width," ").concat(o.height,'" ');else if(this.svgViewportTransformation){const l=this.viewportTransform;a='viewBox="'.concat(lt(-l[4]/l[0],r)," ").concat(lt(-l[5]/l[3],r)," ").concat(lt(this.width/l[0],r)," ").concat(lt(this.height/l[3],r),'" ')}else a='viewBox="0 0 '.concat(this.width," ").concat(this.height,'" ');t.push("<svg ",'xmlns="http://www.w3.org/2000/svg" ','xmlns:xlink="http://www.w3.org/1999/xlink" ','version="1.1" ','width="',i,'" ','height="',s,'" ',a,`xml:space="preserve">
134
- `,"<desc>Created with Fabric.js ",ro,`</desc>
135
- `,`<defs>
136
- `,this.createSVGFontFacesMarkup(),this.createSVGRefElementsMarkup(),this.createSVGClipPathMarkup(e),`</defs>
137
- `)}createSVGClipPathMarkup(t){const e=this.clipPath;return e?(e.clipPathId="CLIPPATH_".concat(ni()),'<clipPath id="'.concat(e.clipPathId,`" >
138
- `).concat(e.toClipPathSVG(t.reviver),`</clipPath>
139
- `)):""}createSVGRefElementsMarkup(){return["background","overlay"].map(t=>{const e=this["".concat(t,"Color")];if(Qt(e)){const i=this["".concat(t,"Vpt")],s=this.viewportTransform,r={isType:()=>!1,width:this.width/(i?s[0]:1),height:this.height/(i?s[3]:1)};return e.toSVG(r,{additionalTransform:i?Rr(s):""})}}).join("")}createSVGFontFacesMarkup(){const t=[],e={},i=J.fontPaths;this._objects.forEach(function r(o){t.push(o),kr(o)&&o._objects.forEach(r)}),t.forEach(r=>{if(!(o=r)||typeof o._renderText!="function")return;var o;const{styles:a,fontFamily:l}=r;!e[l]&&i[l]&&(e[l]=!0,a&&Object.values(a).forEach(c=>{Object.values(c).forEach(h=>{let{fontFamily:u=""}=h;!e[u]&&i[u]&&(e[u]=!0)})}))});const s=Object.keys(e).map(r=>` @font-face {
140
- font-family: '`.concat(r,`';
141
- src: url('`).concat(i[r],`');
142
- }
143
- `)).join("");return s?` <style type="text/css"><![CDATA[
144
- `.concat(s,`]]></style>
145
- `):""}_setSVGObjects(t,e){this.forEachObject(i=>{i.excludeFromExport||this._setSVGObject(t,i,e)})}_setSVGObject(t,e,i){t.push(e.toSVG(i))}_setSVGBgOverlayImage(t,e,i){const s=this[e];s&&!s.excludeFromExport&&s.toSVG&&t.push(s.toSVG(i))}_setSVGBgOverlayColor(t,e){const i=this["".concat(e,"Color")];if(i)if(Qt(i)){const s=i.repeat||"",r=this.width,o=this.height,a=this["".concat(e,"Vpt")]?Rr(ce(this.viewportTransform)):"";t.push('<rect transform="'.concat(a," translate(").concat(r/2,",").concat(o/2,')" x="').concat(i.offsetX-r/2,'" y="').concat(i.offsetY-o/2,'" width="').concat(s!=="repeat-y"&&s!=="no-repeat"||!xl(i)?r:i.source.width,'" height="').concat(s!=="repeat-x"&&s!=="no-repeat"||!xl(i)?o:i.source.height,'" fill="url(#SVGID_').concat(i.id,`)"></rect>
146
- `))}else t.push('<rect x="0" y="0" width="100%" height="100%" ','fill="',i,'"',`></rect>
147
- `)}loadFromJSON(t,e){let{signal:i}=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};if(!t)return Promise.reject(new ye("`json` is undefined"));const s=typeof t=="string"?JSON.parse(t):t,{objects:r=[],backgroundImage:o,background:a,overlayImage:l,overlay:c,clipPath:h}=s,u=this.renderOnAddRemove;return this.renderOnAddRemove=!1,Promise.all([Is(r,{reviver:e,signal:i}),jr({backgroundImage:o,backgroundColor:a,overlayImage:l,overlayColor:c,clipPath:h},{signal:i})]).then(d=>{let[f,g]=d;return this.clear(),this.add(...f),this.set(s),this.set(g),this.renderOnAddRemove=u,this})}clone(t){const e=this.toObject(t);return this.cloneWithoutData().loadFromJSON(e)}cloneWithoutData(){const t=Ce(this);return new this.constructor(t)}toDataURL(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};const{format:e="png",quality:i=1,multiplier:s=1,enableRetinaScaling:r=!1}=t,o=s*(r?this.getRetinaScaling():1);return ul(this.toCanvasElement(o,t),e,i)}toCanvasElement(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:1,{width:e,height:i,left:s,top:r,filter:o}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};const a=(e||this.width)*t,l=(i||this.height)*t,c=this.getZoom(),h=this.width,u=this.height,d=this.skipControlsDrawing,f=c*t,g=this.viewportTransform,p=[f,0,0,f,(g[4]-(s||0))*t,(g[5]-(r||0))*t],m=this.enableRetinaScaling,v=Ce({width:a,height:l}),y=o?this._objects.filter(x=>o(x)):this._objects;return this.enableRetinaScaling=!1,this.viewportTransform=p,this.width=a,this.height=l,this.skipControlsDrawing=!0,this.calcViewportBoundaries(),this.renderCanvas(v.getContext("2d"),y),this.viewportTransform=g,this.width=h,this.height=u,this.calcViewportBoundaries(),this.enableRetinaScaling=m,this.skipControlsDrawing=d,v}dispose(){return!this.disposed&&this.elements.cleanupDOM({width:this.width,height:this.height}),Dr.cancelByCanvas(this),this.disposed=!0,new Promise((t,e)=>{const i=()=>{this.destroy(),t(!0)};i.kill=e,this.__cleanupTask&&this.__cleanupTask.kill("aborted"),this.destroyed?t(!1):this.nextRenderHandle?this.__cleanupTask=i:i()})}destroy(){this.destroyed=!0,this.cancelRequestedRender(),this.forEachObject(t=>t.dispose()),this._objects=[],this.backgroundImage&&this.backgroundImage.dispose(),this.backgroundImage=void 0,this.overlayImage&&this.overlayImage.dispose(),this.overlayImage=void 0,this.elements.dispose()}toString(){return"#<Canvas (".concat(this.complexity(),"): { objects: ").concat(this._objects.length," }>")}}_(js,"ownDefaults",rd);const nd=["touchstart","touchmove","touchend"],od=n=>{const t=Cl(n.target),e=function(i){const s=i.changedTouches;return s&&s[0]?s[0]:i}(n);return new C(e.clientX+t.left,e.clientY+t.top)},_o=n=>nd.includes(n.type)||n.pointerType==="touch",bo=n=>{n.preventDefault(),n.stopPropagation()},Le=n=>{let t=0,e=0,i=0,s=0;for(let r=0,o=n.length;r<o;r++){const{x:a,y:l}=n[r];(a>i||!r)&&(i=a),(a<t||!r)&&(t=a),(l>s||!r)&&(s=l),(l<e||!r)&&(e=l)}return{left:t,top:e,width:i-t,height:s-e}},ad=["translateX","translateY","scaleX","scaleY"],ld=(n,t)=>Nr(n,Tt(t,n.calcOwnMatrix())),Nr=(n,t)=>{const e=Pr(t),{translateX:i,translateY:s,scaleX:r,scaleY:o}=e,a=rt(e,ad),l=new C(i,s);n.flipX=!1,n.flipY=!1,Object.assign(n,a),n.set({scaleX:r,scaleY:o}),n.setPositionByOrigin(l,G,G)},cd=n=>{n.scaleX=1,n.scaleY=1,n.skewX=0,n.skewY=0,n.flipX=!1,n.flipY=!1,n.rotate(0)},Ol=n=>({scaleX:n.scaleX,scaleY:n.scaleY,skewX:n.skewX,skewY:n.skewY,angle:n.angle,left:n.left,flipX:n.flipX,flipY:n.flipY,top:n.top}),yo=(n,t,e)=>{const i=n/2,s=t/2,r=[new C(-i,-s),new C(i,-s),new C(-i,s),new C(i,s)].map(a=>a.transform(e)),o=Le(r);return new C(o.width,o.height)},Br=function(){let n=arguments.length>0&&arguments[0]!==void 0?arguments[0]:Pt;return Tt(ce(arguments.length>1&&arguments[1]!==void 0?arguments[1]:Pt),n)},Zi=function(n){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:Pt,e=arguments.length>2&&arguments[2]!==void 0?arguments[2]:Pt;return n.transform(Br(t,e))},hd=function(n){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:Pt,e=arguments.length>2&&arguments[2]!==void 0?arguments[2]:Pt;return n.transform(Br(t,e),!0)},ud=(n,t,e)=>{const i=Br(t,e);return Nr(n,Tt(i,n.calcOwnMatrix())),i},Al=(n,t)=>{var e;const{transform:{target:i}}=t;(e=i.canvas)===null||e===void 0||e.fire("object:".concat(n),b(b({},t),{},{target:i})),i.fire(n,t)},dd={left:-.5,top:-.5,center:0,bottom:.5,right:.5},_t=n=>typeof n=="string"?dd[n]:n-.5,$r="not-allowed";function Dl(n){return _t(n.originX)===_t(G)&&_t(n.originY)===_t(G)}function kl(n){return .5-_t(n)}const ue=(n,t)=>n[t],Ml=(n,t,e,i)=>({e:n,transform:t,pointer:new C(e,i)});function Pl(n,t){const e=n.getTotalAngle()+wi(Math.atan2(t.y,t.x))+360;return Math.round(e%360/45)}function xo(n,t,e,i,s){var r;let{target:o,corner:a}=n;const l=o.controls[a],c=((r=o.canvas)===null||r===void 0?void 0:r.getZoom())||1,h=o.padding/c,u=function(d,f,g,p){const m=d.getRelativeCenterPoint(),v=g!==void 0&&p!==void 0?d.translateToGivenOrigin(m,G,G,g,p):new C(d.left,d.top);return(d.angle?f.rotate(-ft(d.angle),m):f).subtract(v)}(o,new C(i,s),t,e);return u.x>=h&&(u.x-=h),u.x<=-h&&(u.x+=h),u.y>=h&&(u.y-=h),u.y<=h&&(u.y+=h),u.x-=l.offsetX,u.y-=l.offsetY,u}const fd=(n,t,e,i)=>{const{target:s,offsetX:r,offsetY:o}=t,a=e-r,l=i-o,c=!ue(s,"lockMovementX")&&s.left!==a,h=!ue(s,"lockMovementY")&&s.top!==l;return c&&s.set(Q,a),h&&s.set(Ft,l),(c||h)&&Al(ol,Ml(n,t,e,i)),c||h};class Il{getSvgStyles(t){const e=this.fillRule?this.fillRule:"nonzero",i=this.strokeWidth?this.strokeWidth:"0",s=this.strokeDashArray?this.strokeDashArray.join(" "):Rt,r=this.strokeDashOffset?this.strokeDashOffset:"0",o=this.strokeLineCap?this.strokeLineCap:"butt",a=this.strokeLineJoin?this.strokeLineJoin:"miter",l=this.strokeMiterLimit?this.strokeMiterLimit:"4",c=this.opacity!==void 0?this.opacity:"1",h=this.visible?"":" visibility: hidden;",u=t?"":this.getSvgFilter(),d=Ls(bt,this.fill);return[Ls(Bt,this.stroke),"stroke-width: ",i,"; ","stroke-dasharray: ",s,"; ","stroke-linecap: ",o,"; ","stroke-dashoffset: ",r,"; ","stroke-linejoin: ",a,"; ","stroke-miterlimit: ",l,"; ",d,"fill-rule: ",e,"; ","opacity: ",c,";",u,h].join("")}getSvgFilter(){return this.shadow?"filter: url(#SVGID_".concat(this.shadow.id,");"):""}getSvgCommons(){return[this.id?'id="'.concat(this.id,'" '):"",this.clipPath?'clip-path="url(#'.concat(this.clipPath.clipPathId,')" '):""].join("")}getSvgTransform(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"";const i=t?this.calcTransformMatrix():this.calcOwnMatrix(),s='transform="'.concat(Rr(i));return"".concat(s).concat(e,'" ')}_toSVG(t){return[""]}toSVG(t){return this._createBaseSVGMarkup(this._toSVG(t),{reviver:t})}toClipPathSVG(t){return" "+this._createBaseClipPathSVGMarkup(this._toSVG(t),{reviver:t})}_createBaseClipPathSVGMarkup(t){let{reviver:e,additionalTransform:i=""}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};const s=[this.getSvgTransform(!0,i),this.getSvgCommons()].join(""),r=t.indexOf("COMMON_PARTS");return t[r]=s,e?e(t.join("")):t.join("")}_createBaseSVGMarkup(t){let{noStyle:e,reviver:i,withShadow:s,additionalTransform:r}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};const o=e?"":'style="'.concat(this.getSvgStyles(),'" '),a=s?'style="'.concat(this.getSvgFilter(),'" '):"",l=this.clipPath,c=this.strokeUniform?'vector-effect="non-scaling-stroke" ':"",h=l&&l.absolutePositioned,u=this.stroke,d=this.fill,f=this.shadow,g=[],p=t.indexOf("COMMON_PARTS");let m;l&&(l.clipPathId="CLIPPATH_".concat(ni()),m='<clipPath id="'.concat(l.clipPathId,`" >
148
- `).concat(l.toClipPathSVG(i),`</clipPath>
149
- `)),h&&g.push("<g ",a,this.getSvgCommons(),` >
150
- `),g.push("<g ",this.getSvgTransform(!1),h?"":a+this.getSvgCommons(),` >
151
- `);const v=[o,c,e?"":this.addPaintOrder()," ",r?'transform="'.concat(r,'" '):""].join("");return t[p]=v,Qt(d)&&g.push(d.toSVG(this)),Qt(u)&&g.push(u.toSVG(this)),f&&g.push(f.toSVG(this)),l&&g.push(m),g.push(t.join("")),g.push(`</g>
152
- `),h&&g.push(`</g>
153
- `),i?i(g.join("")):g.join("")}addPaintOrder(){return this.paintFirst!==bt?' paint-order="'.concat(this.paintFirst,'" '):""}}function Vr(n){return new RegExp("^("+n.join("|")+")\\b","i")}var Ll;const Ei=String.raw(Ll||(Ll=ii(["(?:[-+]?(?:d*.d+|d+.?)(?:[eE][-+]?d+)?)"],["(?:[-+]?(?:\\d*\\.\\d+|\\d+\\.?)(?:[eE][-+]?\\d+)?)"]))),gd=new RegExp("(normal|italic)?\\s*(normal|small-caps)?\\s*(normal|bold|bolder|lighter|100|200|300|400|500|600|700|800|900)?\\s*("+Ei+"(?:px|cm|mm|em|pt|pc|in)*)(?:\\/(normal|"+Ei+"))?\\s+(.*)"),pd={cx:Q,x:Q,r:"radius",cy:Ft,y:Ft,display:"visible",visibility:"visible",transform:"transformMatrix","fill-opacity":"fillOpacity","fill-rule":"fillRule","font-family":"fontFamily","font-size":"fontSize","font-style":"fontStyle","font-weight":"fontWeight","letter-spacing":"charSpacing","paint-order":"paintFirst","stroke-dasharray":"strokeDashArray","stroke-dashoffset":"strokeDashOffset","stroke-linecap":"strokeLineCap","stroke-linejoin":"strokeLineJoin","stroke-miterlimit":"strokeMiterLimit","stroke-opacity":"strokeOpacity","stroke-width":"strokeWidth","text-decoration":"textDecoration","text-anchor":"textAnchor",opacity:"opacity","clip-path":"clipPath","clip-rule":"clipRule","vector-effect":"strokeUniform","image-rendering":"imageSmoothing"},Co="font-size",So="clip-path";Vr(["path","circle","polygon","polyline","ellipse","rect","line","image","text"]),Vr(["symbol","image","marker","pattern","view","svg"]);const jl=Vr(["symbol","g","a","svg","clipPath","defs"]),md=new C(1,0),Fl=new C,Rl=(n,t)=>n.rotate(t),wo=(n,t)=>new C(t).subtract(n),To=n=>n.distanceFrom(Fl),Eo=(n,t)=>Math.atan2(Fs(n,t),_d(n,t)),vd=n=>Eo(md,n),Oo=n=>n.eq(Fl)?n:n.scalarDivide(To(n)),Nl=function(n){let t=!(arguments.length>1&&arguments[1]!==void 0)||arguments[1];return Oo(new C(-n.y,n.x).scalarMultiply(t?1:-1))},Fs=(n,t)=>n.x*t.y-n.y*t.x,_d=(n,t)=>n.x*t.x+n.y*t.y,Bl=(n,t,e)=>{if(n.eq(t)||n.eq(e))return!0;const i=Fs(t,e),s=Fs(t,n),r=Fs(e,n);return i>=0?s>=0&&r<=0:!(s<=0&&r>=0)},$l="(-?\\d+(?:\\.\\d*)?(?:px)?(?:\\s?|$))?",Vl=new RegExp("(?:\\s|^)"+$l+$l+"("+Ei+"?(?:px)?)?(?:\\s?|$)(?:$|\\s)");class je{constructor(t){const e=typeof t=="string"?je.parseShadow(t):t;Object.assign(this,je.ownDefaults,e),this.id=ni()}static parseShadow(t){const e=t.trim(),[,i=0,s=0,r=0]=(Vl.exec(e)||[]).map(o=>parseFloat(o)||0);return{color:(e.replace(Vl,"")||"rgb(0,0,0)").trim(),offsetX:i,offsetY:s,blur:r}}toString(){return[this.offsetX,this.offsetY,this.blur,this.color].join("px ")}toSVG(t){const e=Rl(new C(this.offsetX,this.offsetY),ft(-t.angle)),i=new tt(this.color);let s=40,r=40;return t.width&&t.height&&(s=100*lt((Math.abs(e.x)+this.blur)/t.width,J.NUM_FRACTION_DIGITS)+20,r=100*lt((Math.abs(e.y)+this.blur)/t.height,J.NUM_FRACTION_DIGITS)+20),t.flipX&&(e.x*=-1),t.flipY&&(e.y*=-1),'<filter id="SVGID_'.concat(this.id,'" y="-').concat(r,'%" height="').concat(100+2*r,'%" x="-').concat(s,'%" width="').concat(100+2*s,`%" >
154
- <feGaussianBlur in="SourceAlpha" stdDeviation="`).concat(lt(this.blur?this.blur/2:0,J.NUM_FRACTION_DIGITS),`"></feGaussianBlur>
155
- <feOffset dx="`).concat(lt(e.x,J.NUM_FRACTION_DIGITS),'" dy="').concat(lt(e.y,J.NUM_FRACTION_DIGITS),`" result="oBlur" ></feOffset>
156
- <feFlood flood-color="`).concat(i.toRgb(),'" flood-opacity="').concat(i.getAlpha(),`"/>
157
- <feComposite in2="oBlur" operator="in" />
158
- <feMerge>
159
- <feMergeNode></feMergeNode>
160
- <feMergeNode in="SourceGraphic"></feMergeNode>
161
- </feMerge>
162
- </filter>
163
- `)}toObject(){const t={color:this.color,blur:this.blur,offsetX:this.offsetX,offsetY:this.offsetY,affectStroke:this.affectStroke,nonScaling:this.nonScaling,type:this.constructor.type},e=je.ownDefaults;return this.includeDefaultValues?t:po(t,(i,s)=>i!==e[s])}static async fromObject(t){return new this(t)}}_(je,"ownDefaults",{color:"rgb(0,0,0)",blur:0,offsetX:0,offsetY:0,affectStroke:!1,includeDefaultValues:!0,nonScaling:!1}),_(je,"type","shadow"),F.setClass(je,"shadow");const Qi=(n,t,e)=>Math.max(n,Math.min(t,e)),bd=[Ft,Q,Nt,Zt,"flipX","flipY","originX","originY","angle","opacity","globalCompositeOperation","shadow","visible",Ui,Gi],Fe=[bt,Bt,"strokeWidth","strokeDashArray","width","height","paintFirst","strokeUniform","strokeLineCap","strokeDashOffset","strokeLineJoin","strokeMiterLimit","backgroundColor","clipPath"],yd={top:0,left:0,width:0,height:0,angle:0,flipX:!1,flipY:!1,scaleX:1,scaleY:1,minScaleLimit:0,skewX:0,skewY:0,originX:Q,originY:Ft,strokeWidth:1,strokeUniform:!1,padding:0,opacity:1,paintFirst:bt,fill:"rgb(0,0,0)",fillRule:"nonzero",stroke:null,strokeDashArray:null,strokeDashOffset:0,strokeLineCap:"butt",strokeLineJoin:"miter",strokeMiterLimit:4,globalCompositeOperation:"source-over",backgroundColor:"",shadow:null,visible:!0,includeDefaultValues:!0,excludeFromExport:!1,objectCaching:!0,clipPath:void 0,inverted:!1,absolutePositioned:!1,centeredRotation:!0,centeredScaling:!1,dirty:!0},xd=(n,t,e,i)=>-e*Math.cos(n/i*Ds)+e+t,Cd=()=>!1;class Ao{constructor(t){let{startValue:e,byValue:i,duration:s=500,delay:r=0,easing:o=xd,onStart:a=Sr,onChange:l=Sr,onComplete:c=Sr,abort:h=Cd,target:u}=t;_(this,"_state","pending"),_(this,"durationProgress",0),_(this,"valueProgress",0),this.tick=this.tick.bind(this),this.duration=s,this.delay=r,this.easing=o,this._onStart=a,this._onChange=l,this._onComplete=c,this._abort=h,this.target=u,this.startValue=e,this.byValue=i,this.value=this.startValue,this.endValue=Object.freeze(this.calculate(this.duration).value)}get state(){return this._state}isDone(){return this._state==="aborted"||this._state==="completed"}start(){const t=e=>{this._state==="pending"&&(this.startTime=e||+new Date,this._state="running",this._onStart(),this.tick(this.startTime))};this.register(),this.delay>0?setTimeout(()=>Mr(t),this.delay):Mr(t)}tick(t){const e=(t||+new Date)-this.startTime,i=Math.min(e,this.duration);this.durationProgress=i/this.duration;const{value:s,valueProgress:r}=this.calculate(i);this.value=Object.freeze(s),this.valueProgress=r,this._state!=="aborted"&&(this._abort(this.value,this.valueProgress,this.durationProgress)?(this._state="aborted",this.unregister()):e>=this.duration?(this.durationProgress=this.valueProgress=1,this._onChange(this.endValue,this.valueProgress,this.durationProgress),this._state="completed",this._onComplete(this.endValue,this.valueProgress,this.durationProgress),this.unregister()):(this._onChange(this.value,this.valueProgress,this.durationProgress),Mr(this.tick)))}register(){Dr.push(this)}unregister(){Dr.remove(this)}abort(){this._state="aborted",this.unregister()}}const Sd=["startValue","endValue"];class wd extends Ao{constructor(t){let{startValue:e=0,endValue:i=100}=t;super(b(b({},rt(t,Sd)),{},{startValue:e,byValue:i-e}))}calculate(t){const e=this.easing(t,this.startValue,this.byValue,this.duration);return{value:e,valueProgress:Math.abs((e-this.startValue)/this.byValue)}}}const Td=["startValue","endValue"];class Ed extends Ao{constructor(t){let{startValue:e=[0],endValue:i=[100]}=t;super(b(b({},rt(t,Td)),{},{startValue:e,byValue:i.map((s,r)=>s-e[r])}))}calculate(t){const e=this.startValue.map((i,s)=>this.easing(t,i,this.byValue[s],this.duration,s));return{value:e,valueProgress:Math.abs((e[0]-this.startValue[0])/this.byValue[0])}}}const Od=["startValue","endValue","easing","onChange","onComplete","abort"],Ad=(n,t,e,i)=>t+e*(1-Math.cos(n/i*Ds)),Do=n=>n&&((t,e,i)=>n(new tt(t).toRgba(),e,i));class Dd extends Ao{constructor(t){let{startValue:e,endValue:i,easing:s=Ad,onChange:r,onComplete:o,abort:a}=t,l=rt(t,Od);const c=new tt(e).getSource(),h=new tt(i).getSource();super(b(b({},l),{},{startValue:c,byValue:h.map((u,d)=>u-c[d]),easing:s,onChange:Do(r),onComplete:Do(o),abort:Do(a)}))}calculate(t){const[e,i,s,r]=this.startValue.map((a,l)=>this.easing(t,a,this.byValue[l],this.duration,l)),o=[...[e,i,s].map(Math.round),Qi(0,r,1)];return{value:o,valueProgress:o.map((a,l)=>this.byValue[l]!==0?Math.abs((a-this.startValue[l])/this.byValue[l]):0).find(a=>a!==0)||0}}}function zl(n){const t=(e=>Array.isArray(e.startValue)||Array.isArray(e.endValue))(n)?new Ed(n):new wd(n);return t.start(),t}function kd(n){const t=new Dd(n);return t.start(),t}class ct{constructor(t){this.status=t,this.points=[]}includes(t){return this.points.some(e=>e.eq(t))}append(){for(var t=arguments.length,e=new Array(t),i=0;i<t;i++)e[i]=arguments[i];return this.points=this.points.concat(e.filter(s=>!this.includes(s))),this}static isPointContained(t,e,i){let s=arguments.length>3&&arguments[3]!==void 0&&arguments[3];if(e.eq(i))return t.eq(e);if(e.x===i.x)return t.x===e.x&&(s||t.y>=Math.min(e.y,i.y)&&t.y<=Math.max(e.y,i.y));if(e.y===i.y)return t.y===e.y&&(s||t.x>=Math.min(e.x,i.x)&&t.x<=Math.max(e.x,i.x));{const r=wo(e,i),o=wo(e,t).divide(r);return s?Math.abs(o.x)===Math.abs(o.y):o.x===o.y&&o.x>=0&&o.x<=1}}static isPointInPolygon(t,e){const i=new C(t).setX(Math.min(t.x-1,...e.map(r=>r.x)));let s=0;for(let r=0;r<e.length;r++){const o=this.intersectSegmentSegment(e[r],e[(r+1)%e.length],t,i);if(o.includes(t))return!0;s+=+(o.status==="Intersection")}return s%2==1}static intersectLineLine(t,e,i,s){let r=!(arguments.length>4&&arguments[4]!==void 0)||arguments[4],o=!(arguments.length>5&&arguments[5]!==void 0)||arguments[5];const a=e.x-t.x,l=e.y-t.y,c=s.x-i.x,h=s.y-i.y,u=t.x-i.x,d=t.y-i.y,f=c*d-h*u,g=a*d-l*u,p=h*a-c*l;if(p!==0){const m=f/p,v=g/p;return(r||0<=m&&m<=1)&&(o||0<=v&&v<=1)?new ct("Intersection").append(new C(t.x+m*a,t.y+m*l)):new ct}if(f===0||g===0){const m=r||o||ct.isPointContained(t,i,s)||ct.isPointContained(e,i,s)||ct.isPointContained(i,t,e)||ct.isPointContained(s,t,e);return new ct(m?"Coincident":void 0)}return new ct("Parallel")}static intersectSegmentLine(t,e,i,s){return ct.intersectLineLine(t,e,i,s,!1,!0)}static intersectSegmentSegment(t,e,i,s){return ct.intersectLineLine(t,e,i,s,!1,!1)}static intersectLinePolygon(t,e,i){let s=!(arguments.length>3&&arguments[3]!==void 0)||arguments[3];const r=new ct,o=i.length;for(let a,l,c,h=0;h<o;h++){if(a=i[h],l=i[(h+1)%o],c=ct.intersectLineLine(t,e,a,l,s,!1),c.status==="Coincident")return c;r.append(...c.points)}return r.points.length>0&&(r.status="Intersection"),r}static intersectSegmentPolygon(t,e,i){return ct.intersectLinePolygon(t,e,i,!1)}static intersectPolygonPolygon(t,e){const i=new ct,s=t.length,r=[];for(let o=0;o<s;o++){const a=t[o],l=t[(o+1)%s],c=ct.intersectSegmentPolygon(a,l,e);c.status==="Coincident"?(r.push(c),i.append(a,l)):i.append(...c.points)}return r.length>0&&r.length===t.length?new ct("Coincident"):(i.points.length>0&&(i.status="Intersection"),i)}static intersectPolygonRectangle(t,e,i){const s=e.min(i),r=e.max(i),o=new C(r.x,s.y),a=new C(s.x,r.y);return ct.intersectPolygonPolygon(t,[s,o,r,a])}}class Md extends hl{getX(){return this.getXY().x}setX(t){this.setXY(this.getXY().setX(t))}getY(){return this.getXY().y}setY(t){this.setXY(this.getXY().setY(t))}getRelativeX(){return this.left}setRelativeX(t){this.left=t}getRelativeY(){return this.top}setRelativeY(t){this.top=t}getXY(){const t=this.getRelativeXY();return this.group?$t(t,this.group.calcTransformMatrix()):t}setXY(t,e,i){this.group&&(t=$t(t,ce(this.group.calcTransformMatrix()))),this.setRelativeXY(t,e,i)}getRelativeXY(){return new C(this.left,this.top)}setRelativeXY(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:this.originX,i=arguments.length>2&&arguments[2]!==void 0?arguments[2]:this.originY;this.setPositionByOrigin(t,e,i)}isStrokeAccountedForInDimensions(){return!1}getCoords(){const{tl:t,tr:e,br:i,bl:s}=this.aCoords||(this.aCoords=this.calcACoords()),r=[t,e,i,s];if(this.group){const o=this.group.calcTransformMatrix();return r.map(a=>$t(a,o))}return r}intersectsWithRect(t,e){return ct.intersectPolygonRectangle(this.getCoords(),t,e).status==="Intersection"}intersectsWithObject(t){const e=ct.intersectPolygonPolygon(this.getCoords(),t.getCoords());return e.status==="Intersection"||e.status==="Coincident"||t.isContainedWithinObject(this)||this.isContainedWithinObject(t)}isContainedWithinObject(t){return this.getCoords().every(e=>t.containsPoint(e))}isContainedWithinRect(t,e){const{left:i,top:s,width:r,height:o}=this.getBoundingRect();return i>=t.x&&i+r<=e.x&&s>=t.y&&s+o<=e.y}isOverlapping(t){return this.intersectsWithObject(t)||this.isContainedWithinObject(t)||t.isContainedWithinObject(this)}containsPoint(t){return ct.isPointInPolygon(t,this.getCoords())}isOnScreen(){if(!this.canvas)return!1;const{tl:t,br:e}=this.canvas.vptCoords;return!!this.getCoords().some(i=>i.x<=e.x&&i.x>=t.x&&i.y<=e.y&&i.y>=t.y)||!!this.intersectsWithRect(t,e)||this.containsPoint(t.midPointFrom(e))}isPartiallyOnScreen(){if(!this.canvas)return!1;const{tl:t,br:e}=this.canvas.vptCoords;return this.intersectsWithRect(t,e)?!0:this.getCoords().every(i=>(i.x>=e.x||i.x<=t.x)&&(i.y>=e.y||i.y<=t.y))&&this.containsPoint(t.midPointFrom(e))}getBoundingRect(){return Le(this.getCoords())}getScaledWidth(){return this._getTransformedDimensions().x}getScaledHeight(){return this._getTransformedDimensions().y}scale(t){this._set(Nt,t),this._set(Zt,t),this.setCoords()}scaleToWidth(t){const e=this.getBoundingRect().width/this.getScaledWidth();return this.scale(t/this.width/e)}scaleToHeight(t){const e=this.getBoundingRect().height/this.getScaledHeight();return this.scale(t/this.height/e)}getCanvasRetinaScaling(){var t;return((t=this.canvas)===null||t===void 0?void 0:t.getRetinaScaling())||1}getTotalAngle(){return this.group?wi(dl(this.calcTransformMatrix())):this.angle}getViewportTransform(){var t;return((t=this.canvas)===null||t===void 0?void 0:t.viewportTransform)||Pt.concat()}calcACoords(){const t=Ps({angle:this.angle}),{x:e,y:i}=this.getRelativeCenterPoint(),s=Ms(e,i),r=Tt(s,t),o=this._getTransformedDimensions(),a=o.x/2,l=o.y/2;return{tl:$t({x:-a,y:-l},r),tr:$t({x:a,y:-l},r),bl:$t({x:-a,y:l},r),br:$t({x:a,y:l},r)}}setCoords(){this.aCoords=this.calcACoords()}transformMatrixKey(){let t=arguments.length>0&&arguments[0]!==void 0&&arguments[0],e=[];return!t&&this.group&&(e=this.group.transformMatrixKey(t)),e.push(this.top,this.left,this.width,this.height,this.scaleX,this.scaleY,this.angle,this.strokeWidth,this.skewX,this.skewY,+this.flipX,+this.flipY,_t(this.originX),_t(this.originY)),e}calcTransformMatrix(){let t=arguments.length>0&&arguments[0]!==void 0&&arguments[0],e=this.calcOwnMatrix();if(t||!this.group)return e;const i=this.transformMatrixKey(t),s=this.matrixCache;return s&&s.key.every((r,o)=>r===i[o])?s.value:(this.group&&(e=Tt(this.group.calcTransformMatrix(!1),e)),this.matrixCache={key:i,value:e},e)}calcOwnMatrix(){const t=this.transformMatrixKey(!0),e=this.ownMatrixCache;if(e&&e.key===t)return e.value;const i=this.getRelativeCenterPoint(),s={angle:this.angle,translateX:i.x,translateY:i.y,scaleX:this.scaleX,scaleY:this.scaleY,skewX:this.skewX,skewY:this.skewY,flipX:this.flipX,flipY:this.flipY},r=id(s);return this.ownMatrixCache={key:t,value:r},r}_getNonTransformedDimensions(){return new C(this.width,this.height).scalarAdd(this.strokeWidth)}_calculateCurrentDimensions(t){return this._getTransformedDimensions(t).transform(this.getViewportTransform(),!0).scalarAdd(2*this.padding)}_getTransformedDimensions(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};const e=b({scaleX:this.scaleX,scaleY:this.scaleY,skewX:this.skewX,skewY:this.skewY,width:this.width,height:this.height,strokeWidth:this.strokeWidth},t),i=e.strokeWidth;let s=i,r=0;this.strokeUniform&&(s=0,r=i);const o=e.width+s,a=e.height+s;let l;return l=e.skewX===0&&e.skewY===0?new C(o*e.scaleX,a*e.scaleY):yo(o,a,Ir(e)),l.scalarAdd(r)}translateToGivenOrigin(t,e,i,s,r){let o=t.x,a=t.y;const l=_t(s)-_t(e),c=_t(r)-_t(i);if(l||c){const h=this._getTransformedDimensions();o+=l*h.x,a+=c*h.y}return new C(o,a)}translateToCenterPoint(t,e,i){if(e===G&&i===G)return t;const s=this.translateToGivenOrigin(t,e,i,G,G);return this.angle?s.rotate(ft(this.angle),t):s}translateToOriginPoint(t,e,i){const s=this.translateToGivenOrigin(t,G,G,e,i);return this.angle?s.rotate(ft(this.angle),t):s}getCenterPoint(){const t=this.getRelativeCenterPoint();return this.group?$t(t,this.group.calcTransformMatrix()):t}getRelativeCenterPoint(){return this.translateToCenterPoint(new C(this.left,this.top),this.originX,this.originY)}getPointByOrigin(t,e){return this.translateToOriginPoint(this.getRelativeCenterPoint(),t,e)}setPositionByOrigin(t,e,i){const s=this.translateToCenterPoint(t,e,i),r=this.translateToOriginPoint(s,this.originX,this.originY);this.set({left:r.x,top:r.y})}_getLeftTopCoords(){return this.translateToOriginPoint(this.getRelativeCenterPoint(),Q,Ft)}}const Pd=["type"],Id=["extraParam"];let Re=class Un extends Md{static getDefaults(){return Un.ownDefaults}get type(){const t=this.constructor.type;return t==="FabricObject"?"object":t.toLowerCase()}set type(t){si("warn","Setting type has no effect",t)}constructor(t){super(),_(this,"_cacheContext",null),Object.assign(this,Un.ownDefaults),this.setOptions(t)}_createCacheCanvas(){this._cacheCanvas=le(),this._cacheContext=this._cacheCanvas.getContext("2d"),this._updateCacheCanvas(),this.dirty=!0}_limitCacheSize(t){const e=t.width,i=t.height,s=J.maxCacheSideLimit,r=J.minCacheSideLimit;if(e<=s&&i<=s&&e*i<=J.perfLimitSizeTotal)return e<r&&(t.width=r),i<r&&(t.height=r),t;const o=e/i,[a,l]=As.limitDimsByArea(o),c=Qi(r,a,s),h=Qi(r,l,s);return e>c&&(t.zoomX/=e/c,t.width=c,t.capped=!0),i>h&&(t.zoomY/=i/h,t.height=h,t.capped=!0),t}_getCacheCanvasDimensions(){const t=this.getTotalObjectScaling(),e=this._getTransformedDimensions({skewX:0,skewY:0}),i=e.x*t.x/this.scaleX,s=e.y*t.y/this.scaleY;return{width:Math.ceil(i+2),height:Math.ceil(s+2),zoomX:t.x,zoomY:t.y,x:i,y:s}}_updateCacheCanvas(){const t=this._cacheCanvas,e=this._cacheContext,{width:i,height:s,zoomX:r,zoomY:o,x:a,y:l}=this._limitCacheSize(this._getCacheCanvasDimensions()),c=i!==t.width||s!==t.height,h=this.zoomX!==r||this.zoomY!==o;if(!t||!e)return!1;if(c||h){i!==t.width||s!==t.height?(t.width=i,t.height=s):(e.setTransform(1,0,0,1,0,0),e.clearRect(0,0,t.width,t.height));const u=a/2,d=l/2;return this.cacheTranslationX=Math.round(t.width/2-u)+u,this.cacheTranslationY=Math.round(t.height/2-d)+d,e.translate(this.cacheTranslationX,this.cacheTranslationY),e.scale(r,o),this.zoomX=r,this.zoomY=o,!0}return!1}setOptions(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};this._setOptions(t)}transform(t){const e=this.group&&!this.group._transformDone||this.group&&this.canvas&&t===this.canvas.contextTop,i=this.calcTransformMatrix(!e);t.transform(i[0],i[1],i[2],i[3],i[4],i[5])}getObjectScaling(){if(!this.group)return new C(Math.abs(this.scaleX),Math.abs(this.scaleY));const t=Pr(this.calcTransformMatrix());return new C(Math.abs(t.scaleX),Math.abs(t.scaleY))}getTotalObjectScaling(){const t=this.getObjectScaling();if(this.canvas){const e=this.canvas.getZoom(),i=this.getCanvasRetinaScaling();return t.scalarMultiply(e*i)}return t}getObjectOpacity(){let t=this.opacity;return this.group&&(t*=this.group.getObjectOpacity()),t}_constrainScale(t){return Math.abs(t)<this.minScaleLimit?t<0?-this.minScaleLimit:this.minScaleLimit:t===0?1e-4:t}_set(t,e){t!==Nt&&t!==Zt||(e=this._constrainScale(e)),t===Nt&&e<0?(this.flipX=!this.flipX,e*=-1):t==="scaleY"&&e<0?(this.flipY=!this.flipY,e*=-1):t!=="shadow"||!e||e instanceof je||(e=new je(e));const i=this[t]!==e;return this[t]=e,i&&this.constructor.cacheProperties.includes(t)&&(this.dirty=!0),this.parent&&(this.dirty||i&&this.constructor.stateProperties.includes(t))&&this.parent._set("dirty",!0),this}isNotVisible(){return this.opacity===0||!this.width&&!this.height&&this.strokeWidth===0||!this.visible}render(t){this.isNotVisible()||this.canvas&&this.canvas.skipOffscreen&&!this.group&&!this.isOnScreen()||(t.save(),this._setupCompositeOperation(t),this.drawSelectionBackground(t),this.transform(t),this._setOpacity(t),this._setShadow(t),this.shouldCache()?(this.renderCache(),this.drawCacheOnCanvas(t)):(this._removeCacheCanvas(),this.drawObject(t,!1,{}),this.dirty=!1),t.restore())}drawSelectionBackground(t){}renderCache(t){if(t=t||{},this._cacheCanvas&&this._cacheContext||this._createCacheCanvas(),this.isCacheDirty()&&this._cacheContext){const{zoomX:e,zoomY:i,cacheTranslationX:s,cacheTranslationY:r}=this,{width:o,height:a}=this._cacheCanvas;this.drawObject(this._cacheContext,t.forClipping,{zoomX:e,zoomY:i,cacheTranslationX:s,cacheTranslationY:r,width:o,height:a,parentClipPaths:[]}),this.dirty=!1}}_removeCacheCanvas(){this._cacheCanvas=void 0,this._cacheContext=null}hasStroke(){return this.stroke&&this.stroke!=="transparent"&&this.strokeWidth!==0}hasFill(){return this.fill&&this.fill!=="transparent"}needsItsOwnCache(){return!!(this.paintFirst===Bt&&this.hasFill()&&this.hasStroke()&&this.shadow)||!!this.clipPath}shouldCache(){return this.ownCaching=this.objectCaching&&(!this.parent||!this.parent.isOnACache())||this.needsItsOwnCache(),this.ownCaching}willDrawShadow(){return!!this.shadow&&(this.shadow.offsetX!==0||this.shadow.offsetY!==0)}drawClipPathOnCache(t,e,i){t.save(),e.inverted?t.globalCompositeOperation="destination-out":t.globalCompositeOperation="destination-in",t.setTransform(1,0,0,1,0,0),t.drawImage(i,0,0),t.restore()}drawObject(t,e,i){const s=this.fill,r=this.stroke;e?(this.fill="black",this.stroke="",this._setClippingProperties(t)):this._renderBackground(t),this._render(t),this._drawClipPath(t,this.clipPath,i),this.fill=s,this.stroke=r}createClipPathLayer(t,e){const i=Ce(e),s=i.getContext("2d");if(s.translate(e.cacheTranslationX,e.cacheTranslationY),s.scale(e.zoomX,e.zoomY),t._cacheCanvas=i,e.parentClipPaths.forEach(r=>{r.transform(s)}),e.parentClipPaths.push(t),t.absolutePositioned){const r=ce(this.calcTransformMatrix());s.transform(r[0],r[1],r[2],r[3],r[4],r[5])}return t.transform(s),t.drawObject(s,!0,e),i}_drawClipPath(t,e,i){if(!e)return;e._transformDone=!0;const s=this.createClipPathLayer(e,i);this.drawClipPathOnCache(t,e,s)}drawCacheOnCanvas(t){t.scale(1/this.zoomX,1/this.zoomY),t.drawImage(this._cacheCanvas,-this.cacheTranslationX,-this.cacheTranslationY)}isCacheDirty(){let t=arguments.length>0&&arguments[0]!==void 0&&arguments[0];if(this.isNotVisible())return!1;const e=this._cacheCanvas,i=this._cacheContext;return!(!e||!i||t||!this._updateCacheCanvas())||!!(this.dirty||this.clipPath&&this.clipPath.absolutePositioned)&&(e&&i&&!t&&(i.save(),i.setTransform(1,0,0,1,0,0),i.clearRect(0,0,e.width,e.height),i.restore()),!0)}_renderBackground(t){if(!this.backgroundColor)return;const e=this._getNonTransformedDimensions();t.fillStyle=this.backgroundColor,t.fillRect(-e.x/2,-e.y/2,e.x,e.y),this._removeShadow(t)}_setOpacity(t){this.group&&!this.group._transformDone?t.globalAlpha=this.getObjectOpacity():t.globalAlpha*=this.opacity}_setStrokeStyles(t,e){const i=e.stroke;i&&(t.lineWidth=e.strokeWidth,t.lineCap=e.strokeLineCap,t.lineDashOffset=e.strokeDashOffset,t.lineJoin=e.strokeLineJoin,t.miterLimit=e.strokeMiterLimit,Qt(i)?i.gradientUnits==="percentage"||i.gradientTransform||i.patternTransform?this._applyPatternForTransformedGradient(t,i):(t.strokeStyle=i.toLive(t),this._applyPatternGradientTransform(t,i)):t.strokeStyle=e.stroke)}_setFillStyles(t,e){let{fill:i}=e;i&&(Qt(i)?(t.fillStyle=i.toLive(t),this._applyPatternGradientTransform(t,i)):t.fillStyle=i)}_setClippingProperties(t){t.globalAlpha=1,t.strokeStyle="transparent",t.fillStyle="#000000"}_setLineDash(t,e){e&&e.length!==0&&t.setLineDash(e)}_setShadow(t){if(!this.shadow)return;const e=this.shadow,i=this.canvas,s=this.getCanvasRetinaScaling(),[r,,,o]=(i==null?void 0:i.viewportTransform)||Pt,a=r*s,l=o*s,c=e.nonScaling?new C(1,1):this.getObjectScaling();t.shadowColor=e.color,t.shadowBlur=e.blur*J.browserShadowBlurConstant*(a+l)*(c.x+c.y)/4,t.shadowOffsetX=e.offsetX*a*c.x,t.shadowOffsetY=e.offsetY*l*c.y}_removeShadow(t){this.shadow&&(t.shadowColor="",t.shadowBlur=t.shadowOffsetX=t.shadowOffsetY=0)}_applyPatternGradientTransform(t,e){if(!Qt(e))return{offsetX:0,offsetY:0};const i=e.gradientTransform||e.patternTransform,s=-this.width/2+e.offsetX||0,r=-this.height/2+e.offsetY||0;return e.gradientUnits==="percentage"?t.transform(this.width,0,0,this.height,s,r):t.transform(1,0,0,1,s,r),i&&t.transform(i[0],i[1],i[2],i[3],i[4],i[5]),{offsetX:s,offsetY:r}}_renderPaintInOrder(t){this.paintFirst===Bt?(this._renderStroke(t),this._renderFill(t)):(this._renderFill(t),this._renderStroke(t))}_render(t){}_renderFill(t){this.fill&&(t.save(),this._setFillStyles(t,this),this.fillRule==="evenodd"?t.fill("evenodd"):t.fill(),t.restore())}_renderStroke(t){if(this.stroke&&this.strokeWidth!==0){if(this.shadow&&!this.shadow.affectStroke&&this._removeShadow(t),t.save(),this.strokeUniform){const e=this.getObjectScaling();t.scale(1/e.x,1/e.y)}this._setLineDash(t,this.strokeDashArray),this._setStrokeStyles(t,this),t.stroke(),t.restore()}}_applyPatternForTransformedGradient(t,e){var i;const s=this._limitCacheSize(this._getCacheCanvasDimensions()),r=this.getCanvasRetinaScaling(),o=s.x/this.scaleX/r,a=s.y/this.scaleY/r,l=Ce({width:Math.ceil(o),height:Math.ceil(a)}),c=l.getContext("2d");c&&(c.beginPath(),c.moveTo(0,0),c.lineTo(o,0),c.lineTo(o,a),c.lineTo(0,a),c.closePath(),c.translate(o/2,a/2),c.scale(s.zoomX/this.scaleX/r,s.zoomY/this.scaleY/r),this._applyPatternGradientTransform(c,e),c.fillStyle=e.toLive(t),c.fill(),t.translate(-this.width/2-this.strokeWidth/2,-this.height/2-this.strokeWidth/2),t.scale(r*this.scaleX/s.zoomX,r*this.scaleY/s.zoomY),t.strokeStyle=(i=c.createPattern(l,"no-repeat"))!==null&&i!==void 0?i:"")}_findCenterFromElement(){return new C(this.left+this.width/2,this.top+this.height/2)}clone(t){const e=this.toObject(t);return this.constructor.fromObject(e)}cloneAsImage(t){const e=this.toCanvasElement(t);return new(F.getClass("image"))(e)}toCanvasElement(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};const e=Ol(this),i=this.group,s=this.shadow,r=Math.abs,o=t.enableRetinaScaling?nl():1,a=(t.multiplier||1)*o,l=t.canvasProvider||(y=>new js(y,{enableRetinaScaling:!1,renderOnAddRemove:!1,skipOffscreen:!1}));delete this.group,t.withoutTransform&&cd(this),t.withoutShadow&&(this.shadow=null),t.viewportTransform&&ud(this,this.getViewportTransform()),this.setCoords();const c=le(),h=this.getBoundingRect(),u=this.shadow,d=new C;if(u){const y=u.blur,x=u.nonScaling?new C(1,1):this.getObjectScaling();d.x=2*Math.round(r(u.offsetX)+y)*r(x.x),d.y=2*Math.round(r(u.offsetY)+y)*r(x.y)}const f=h.width+d.x,g=h.height+d.y;c.width=Math.ceil(f),c.height=Math.ceil(g);const p=l(c);t.format==="jpeg"&&(p.backgroundColor="#fff"),this.setPositionByOrigin(new C(p.width/2,p.height/2),G,G);const m=this.canvas;p._objects=[this],this.set("canvas",p),this.setCoords();const v=p.toCanvasElement(a||1,t);return this.set("canvas",m),this.shadow=s,i&&(this.group=i),this.set(e),this.setCoords(),p._objects=[],p.destroy(),v}toDataURL(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};return ul(this.toCanvasElement(t),t.format||"png",t.quality||1)}isType(){for(var t=arguments.length,e=new Array(t),i=0;i<t;i++)e[i]=arguments[i];return e.includes(this.constructor.type)||e.includes(this.type)}complexity(){return 1}toJSON(){return this.toObject()}rotate(t){const{centeredRotation:e,originX:i,originY:s}=this;if(e){const{x:r,y:o}=this.getRelativeCenterPoint();this.originX=G,this.originY=G,this.left=r,this.top=o}if(this.set("angle",t),e){const{x:r,y:o}=this.translateToOriginPoint(this.getRelativeCenterPoint(),i,s);this.left=r,this.top=o,this.originX=i,this.originY=s}}setOnGroup(){}_setupCompositeOperation(t){this.globalCompositeOperation&&(t.globalCompositeOperation=this.globalCompositeOperation)}dispose(){Dr.cancelByTarget(this),this.off(),this._set("canvas",void 0),this._cacheCanvas&&xe().dispose(this._cacheCanvas),this._cacheCanvas=void 0,this._cacheContext=null}animate(t,e){return Object.entries(t).reduce((i,s)=>{let[r,o]=s;return i[r]=this._animate(r,o,e),i},{})}_animate(t,e){let i=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};const s=t.split("."),r=this.constructor.colorProperties.includes(s[s.length-1]),{abort:o,startValue:a,onChange:l,onComplete:c}=i,h=b(b({},i),{},{target:this,startValue:a??s.reduce((u,d)=>u[d],this),endValue:e,abort:o==null?void 0:o.bind(this),onChange:(u,d,f)=>{s.reduce((g,p,m)=>(m===s.length-1&&(g[p]=u),g[p]),this),l&&l(u,d,f)},onComplete:(u,d,f)=>{this.setCoords(),c&&c(u,d,f)}});return r?kd(h):zl(h)}isDescendantOf(t){const{parent:e,group:i}=this;return e===t||i===t||!!e&&e.isDescendantOf(t)||!!i&&i!==e&&i.isDescendantOf(t)}getAncestors(){const t=[];let e=this;do e=e.parent,e&&t.push(e);while(e);return t}findCommonAncestors(t){if(this===t)return{fork:[],otherFork:[],common:[this,...this.getAncestors()]};const e=this.getAncestors(),i=t.getAncestors();if(e.length===0&&i.length>0&&this===i[i.length-1])return{fork:[],otherFork:[t,...i.slice(0,i.length-1)],common:[this]};for(let s,r=0;r<e.length;r++){if(s=e[r],s===t)return{fork:[this,...e.slice(0,r)],otherFork:[],common:e.slice(r)};for(let o=0;o<i.length;o++){if(this===i[o])return{fork:[],otherFork:[t,...i.slice(0,o)],common:[this,...e]};if(s===i[o])return{fork:[this,...e.slice(0,r)],otherFork:[t,...i.slice(0,o)],common:e.slice(r)}}}return{fork:[this,...e],otherFork:[t,...i],common:[]}}hasCommonAncestors(t){const e=this.findCommonAncestors(t);return e&&!!e.common.length}isInFrontOf(t){if(this===t)return;const e=this.findCommonAncestors(t);if(e.fork.includes(t))return!0;if(e.otherFork.includes(this))return!1;const i=e.common[0]||this.canvas;if(!i)return;const s=e.fork.pop(),r=e.otherFork.pop(),o=i._objects.indexOf(s),a=i._objects.indexOf(r);return o>-1&&o>a}toObject(){const t=(arguments.length>0&&arguments[0]!==void 0?arguments[0]:[]).concat(Un.customProperties,this.constructor.customProperties||[]);let e;const i=J.NUM_FRACTION_DIGITS,{clipPath:s,fill:r,stroke:o,shadow:a,strokeDashArray:l,left:c,top:h,originX:u,originY:d,width:f,height:g,strokeWidth:p,strokeLineCap:m,strokeDashOffset:v,strokeLineJoin:y,strokeUniform:x,strokeMiterLimit:E,scaleX:T,scaleY:k,angle:S,flipX:w,flipY:L,opacity:j,visible:A,backgroundColor:O,fillRule:D,paintFirst:I,globalCompositeOperation:$,skewX:X,skewY:K}=this;s&&!s.excludeFromExport&&(e=s.toObject(t.concat("inverted","absolutePositioned")));const R=M=>lt(M,i),N=b(b({},qi(this,t)),{},{type:this.constructor.type,version:ro,originX:u,originY:d,left:R(c),top:R(h),width:R(f),height:R(g),fill:yl(r)?r.toObject():r,stroke:yl(o)?o.toObject():o,strokeWidth:R(p),strokeDashArray:l&&l.concat(),strokeLineCap:m,strokeDashOffset:v,strokeLineJoin:y,strokeUniform:x,strokeMiterLimit:R(E),scaleX:R(T),scaleY:R(k),angle:R(S),flipX:w,flipY:L,opacity:R(j),shadow:a&&a.toObject(),visible:A,backgroundColor:O,fillRule:D,paintFirst:I,globalCompositeOperation:$,skewX:R(X),skewY:R(K)},e?{clipPath:e}:null);return this.includeDefaultValues?N:this._removeDefaultValues(N)}toDatalessObject(t){return this.toObject(t)}_removeDefaultValues(t){const e=this.constructor.getDefaults(),i=Object.keys(e).length>0?e:Object.getPrototypeOf(this);return po(t,(s,r)=>{if(r===Q||r===Ft||r==="type")return!0;const o=i[r];return s!==o&&!(Array.isArray(s)&&Array.isArray(o)&&s.length===0&&o.length===0)})}toString(){return"#<".concat(this.constructor.type,">")}static _fromObject(t){let e=rt(t,Pd),i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},{extraParam:s}=i,r=rt(i,Id);return jr(e,r).then(o=>s?(delete o[s],new this(e[s],o)):new this(o))}static fromObject(t,e){return this._fromObject(t,e)}};_(Re,"stateProperties",bd),_(Re,"cacheProperties",Fe),_(Re,"ownDefaults",yd),_(Re,"type","FabricObject"),_(Re,"colorProperties",[bt,Bt,"backgroundColor"]),_(Re,"customProperties",[]),F.setClass(Re),F.setClass(Re,"object");const ts=(n,t,e)=>(i,s,r,o)=>{const a=t(i,s,r,o);return a&&Al(n,b(b({},Ml(i,s,r,o)),e)),a};function es(n){return(t,e,i,s)=>{const{target:r,originX:o,originY:a}=e,l=r.getRelativeCenterPoint(),c=r.translateToOriginPoint(l,o,a),h=n(t,e,i,s);return r.setPositionByOrigin(c,e.originX,e.originY),h}}const Hl=ts(ks,es((n,t,e,i)=>{const s=xo(t,t.originX,t.originY,e,i);if(_t(t.originX)===_t(G)||_t(t.originX)===_t(dt)&&s.x<0||_t(t.originX)===_t(Q)&&s.x>0){const{target:r}=t,o=r.strokeWidth/(r.strokeUniform?r.scaleX:1),a=Dl(t)?2:1,l=r.width,c=Math.abs(s.x*a/r.scaleX)-o;return r.set("width",Math.max(c,1)),l!==r.width}return!1}));function Ld(n,t,e,i,s){i=i||{};const r=this.sizeX||i.cornerSize||s.cornerSize,o=this.sizeY||i.cornerSize||s.cornerSize,a=i.transparentCorners!==void 0?i.transparentCorners:s.transparentCorners,l=a?Bt:bt,c=!a&&(i.cornerStrokeColor||s.cornerStrokeColor);let h,u=t,d=e;n.save(),n.fillStyle=i.cornerColor||s.cornerColor||"",n.strokeStyle=i.cornerStrokeColor||s.cornerStrokeColor||"",r>o?(h=r,n.scale(1,o/r),d=e*r/o):o>r?(h=o,n.scale(r/o,1),u=t*o/r):h=r,n.beginPath(),n.arc(u,d,h/2,0,wr,!1),n[l](),c&&n.stroke(),n.restore()}function jd(n,t,e,i,s){i=i||{};const r=this.sizeX||i.cornerSize||s.cornerSize,o=this.sizeY||i.cornerSize||s.cornerSize,a=i.transparentCorners!==void 0?i.transparentCorners:s.transparentCorners,l=a?Bt:bt,c=!a&&(i.cornerStrokeColor||s.cornerStrokeColor),h=r/2,u=o/2;n.save(),n.fillStyle=i.cornerColor||s.cornerColor||"",n.strokeStyle=i.cornerStrokeColor||s.cornerStrokeColor||"",n.translate(t,e);const d=s.getTotalAngle();n.rotate(ft(d)),n["".concat(l,"Rect")](-h,-u,r,o),c&&n.strokeRect(-h,-u,r,o),n.restore()}class de{constructor(t){_(this,"visible",!0),_(this,"actionName",Or),_(this,"angle",0),_(this,"x",0),_(this,"y",0),_(this,"offsetX",0),_(this,"offsetY",0),_(this,"sizeX",0),_(this,"sizeY",0),_(this,"touchSizeX",0),_(this,"touchSizeY",0),_(this,"cursorStyle","crosshair"),_(this,"withConnection",!1),Object.assign(this,t)}shouldActivate(t,e,i,s){var r;let{tl:o,tr:a,br:l,bl:c}=s;return((r=e.canvas)===null||r===void 0?void 0:r.getActiveObject())===e&&e.isControlVisible(t)&&ct.isPointInPolygon(i,[o,a,l,c])}getActionHandler(t,e,i){return this.actionHandler}getMouseDownHandler(t,e,i){return this.mouseDownHandler}getMouseUpHandler(t,e,i){return this.mouseUpHandler}cursorStyleHandler(t,e,i){return e.cursorStyle}getActionName(t,e,i){return e.actionName}getVisibility(t,e){var i,s;return(i=(s=t._controlsVisibility)===null||s===void 0?void 0:s[e])!==null&&i!==void 0?i:this.visible}setVisibility(t,e,i){this.visible=t}positionHandler(t,e,i,s){return new C(this.x*t.x+this.offsetX,this.y*t.y+this.offsetY).transform(e)}calcCornerCoords(t,e,i,s,r,o){const a=fo([Ms(i,s),Ps({angle:t}),go((r?this.touchSizeX:this.sizeX)||e,(r?this.touchSizeY:this.sizeY)||e)]);return{tl:new C(-.5,-.5).transform(a),tr:new C(.5,-.5).transform(a),br:new C(.5,.5).transform(a),bl:new C(-.5,.5).transform(a)}}render(t,e,i,s,r){((s=s||{}).cornerStyle||r.cornerStyle)==="circle"?Ld.call(this,t,e,i,s,r):jd.call(this,t,e,i,s,r)}}const Fd=(n,t,e)=>e.lockRotation?$r:t.cursorStyle,Rd=ts(al,es((n,t,e,i)=>{let{target:s,ex:r,ey:o,theta:a,originX:l,originY:c}=t;const h=s.translateToOriginPoint(s.getRelativeCenterPoint(),l,c);if(ue(s,"lockRotation"))return!1;const u=Math.atan2(o-h.y,r-h.x),d=Math.atan2(i-h.y,e-h.x);let f=wi(d-u+a);if(s.snapAngle&&s.snapAngle>0){const p=s.snapAngle,m=s.snapThreshold||p,v=Math.ceil(f/p)*p,y=Math.floor(f/p)*p;Math.abs(f-y)<m?f=y:Math.abs(f-v)<m&&(f=v)}f<0&&(f=360+f),f%=360;const g=s.angle!==f;return s.angle=f,g}));function Wl(n,t){const e=t.canvas,i=n[e.uniScaleKey];return e.uniformScaling&&!i||!e.uniformScaling&&i}function Yl(n,t,e){const i=ue(n,"lockScalingX"),s=ue(n,"lockScalingY");if(i&&s||!t&&(i||s)&&e||i&&t==="x"||s&&t==="y")return!0;const{width:r,height:o,strokeWidth:a}=n;return r===0&&a===0&&t!=="y"||o===0&&a===0&&t!=="x"}const Nd=["e","se","s","sw","w","nw","n","ne","e"],Rs=(n,t,e)=>{const i=Wl(n,e);if(Yl(e,t.x!==0&&t.y===0?"x":t.x===0&&t.y!==0?"y":"",i))return $r;const s=Pl(e,t);return"".concat(Nd[s],"-resize")};function ko(n,t,e,i){let s=arguments.length>4&&arguments[4]!==void 0?arguments[4]:{};const r=t.target,o=s.by,a=Wl(n,r);let l,c,h,u,d,f;if(Yl(r,o,a))return!1;if(t.gestureScale)c=t.scaleX*t.gestureScale,h=t.scaleY*t.gestureScale;else{if(l=xo(t,t.originX,t.originY,e,i),d=o!=="y"?Math.sign(l.x||t.signX||1):1,f=o!=="x"?Math.sign(l.y||t.signY||1):1,t.signX||(t.signX=d),t.signY||(t.signY=f),ue(r,"lockScalingFlip")&&(t.signX!==d||t.signY!==f))return!1;if(u=r._getTransformedDimensions(),a&&!o){const m=Math.abs(l.x)+Math.abs(l.y),{original:v}=t,y=m/(Math.abs(u.x*v.scaleX/r.scaleX)+Math.abs(u.y*v.scaleY/r.scaleY));c=v.scaleX*y,h=v.scaleY*y}else c=Math.abs(l.x*r.scaleX/u.x),h=Math.abs(l.y*r.scaleY/u.y);Dl(t)&&(c*=2,h*=2),t.signX!==d&&o!=="y"&&(t.originX=kl(t.originX),c*=-1,t.signX=d),t.signY!==f&&o!=="x"&&(t.originY=kl(t.originY),h*=-1,t.signY=f)}const g=r.scaleX,p=r.scaleY;return o?(o==="x"&&r.set(Nt,c),o==="y"&&r.set(Zt,h)):(!ue(r,"lockScalingX")&&r.set(Nt,c),!ue(r,"lockScalingY")&&r.set(Zt,h)),g!==r.scaleX||p!==r.scaleY}const zr=ts(Tr,es((n,t,e,i)=>ko(n,t,e,i))),Bd=ts(Tr,es((n,t,e,i)=>ko(n,t,e,i,{by:"x"}))),$d=ts(Tr,es((n,t,e,i)=>ko(n,t,e,i,{by:"y"}))),Vd=["target","ex","ey","skewingSide"],Mo={x:{counterAxis:"y",scale:Nt,skew:Ui,lockSkewing:"lockSkewingX",origin:"originX",flip:"flipX"},y:{counterAxis:"x",scale:Zt,skew:Gi,lockSkewing:"lockSkewingY",origin:"originY",flip:"flipY"}},zd=["ns","nesw","ew","nwse"],Hd=(n,t,e)=>{if(t.x!==0&&ue(e,"lockSkewingY")||t.y!==0&&ue(e,"lockSkewingX"))return $r;const i=Pl(e,t)%4;return"".concat(zd[i],"-resize")};function Ul(n,t,e,i,s){const{target:r}=e,{counterAxis:o,origin:a,lockSkewing:l,skew:c,flip:h}=Mo[n];if(ue(r,l))return!1;const{origin:u,flip:d}=Mo[o],f=_t(e[u])*(r[d]?-1:1),g=-Math.sign(f)*(r[h]?-1:1),p=.5*-((r[c]===0&&xo(e,G,G,i,s)[n]>0||r[c]>0?1:-1)*g)+.5;return ts(ll,es((v,y,x,E)=>function(T,k,S){let{target:w,ex:L,ey:j,skewingSide:A}=k,O=rt(k,Vd);const{skew:D}=Mo[T],I=S.subtract(new C(L,j)).divide(new C(w.scaleX,w.scaleY))[T],$=w[D],X=O[D],K=Math.tan(ft(X)),R=T==="y"?w._getTransformedDimensions({scaleX:1,scaleY:1,skewX:0}).x:w._getTransformedDimensions({scaleX:1,scaleY:1}).y,N=2*I*A/Math.max(R,1)+K,M=wi(Math.atan(N));w.set(D,M);const V=$!==w[D];if(V&&T==="y"){const{skewX:q,scaleX:ut}=w,it=w._getTransformedDimensions({skewY:$}),qt=w._getTransformedDimensions(),P=q!==0?it.x/qt.x:1;P!==1&&w.set(Nt,P*ut)}return V}(n,y,new C(x,E))))(t,b(b({},e),{},{[a]:p,skewingSide:g}),i,s)}const Wd=(n,t,e,i)=>Ul("x",n,t,e,i),Yd=(n,t,e,i)=>Ul("y",n,t,e,i);function Hr(n,t){return n[t.canvas.altActionKey]}const Wr=(n,t,e)=>{const i=Hr(n,e);return t.x===0?i?Ui:Zt:t.y===0?i?Gi:Nt:""},is=(n,t,e)=>Hr(n,e)?Hd(0,t,e):Rs(n,t,e),Gl=(n,t,e,i)=>Hr(n,t.target)?Yd(n,t,e,i):Bd(n,t,e,i),Xl=(n,t,e,i)=>Hr(n,t.target)?Wd(n,t,e,i):$d(n,t,e,i),Kl=()=>({ml:new de({x:-.5,y:0,cursorStyleHandler:is,actionHandler:Gl,getActionName:Wr}),mr:new de({x:.5,y:0,cursorStyleHandler:is,actionHandler:Gl,getActionName:Wr}),mb:new de({x:0,y:.5,cursorStyleHandler:is,actionHandler:Xl,getActionName:Wr}),mt:new de({x:0,y:-.5,cursorStyleHandler:is,actionHandler:Xl,getActionName:Wr}),tl:new de({x:-.5,y:-.5,cursorStyleHandler:Rs,actionHandler:zr}),tr:new de({x:.5,y:-.5,cursorStyleHandler:Rs,actionHandler:zr}),bl:new de({x:-.5,y:.5,cursorStyleHandler:Rs,actionHandler:zr}),br:new de({x:.5,y:.5,cursorStyleHandler:Rs,actionHandler:zr}),mtr:new de({x:0,y:-.5,actionHandler:Rd,cursorStyleHandler:Fd,offsetY:-40,withConnection:!0,actionName:co})}),Ud=()=>({mr:new de({x:.5,y:0,actionHandler:Hl,cursorStyleHandler:is,actionName:ks}),ml:new de({x:-.5,y:0,actionHandler:Hl,cursorStyleHandler:is,actionName:ks})}),Gd=()=>b(b({},Kl()),Ud());class Ns extends Re{static getDefaults(){return b(b({},super.getDefaults()),Ns.ownDefaults)}constructor(t){super(),Object.assign(this,this.constructor.createControls(),Ns.ownDefaults),this.setOptions(t)}static createControls(){return{controls:Kl()}}_updateCacheCanvas(){const t=this.canvas;if(this.noScaleCache&&t&&t._currentTransform){const e=t._currentTransform,i=e.target,s=e.action;if(this===i&&s&&s.startsWith(Or))return!1}return super._updateCacheCanvas()}getActiveControl(){const t=this.__corner;return t?{key:t,control:this.controls[t],coord:this.oCoords[t]}:void 0}findControl(t){let e=arguments.length>1&&arguments[1]!==void 0&&arguments[1];if(!this.hasControls||!this.canvas)return;this.__corner=void 0;const i=Object.entries(this.oCoords);for(let s=i.length-1;s>=0;s--){const[r,o]=i[s],a=this.controls[r];if(a.shouldActivate(r,this,t,e?o.touchCorner:o.corner))return this.__corner=r,{key:r,control:a,coord:this.oCoords[r]}}}calcOCoords(){const t=this.getViewportTransform(),e=this.getCenterPoint(),i=Ms(e.x,e.y),s=Ps({angle:this.getTotalAngle()-(this.group&&this.flipX?180:0)}),r=Tt(i,s),o=Tt(t,r),a=Tt(o,[1/t[0],0,0,1/t[3],0,0]),l=this.group?Pr(this.calcTransformMatrix()):void 0;l&&(l.scaleX=Math.abs(l.scaleX),l.scaleY=Math.abs(l.scaleY));const c=this._calculateCurrentDimensions(l),h={};return this.forEachControl((u,d)=>{const f=u.positionHandler(c,a,this,u);h[d]=Object.assign(f,this._calcCornerCoords(u,f))}),h}_calcCornerCoords(t,e){const i=this.getTotalAngle();return{corner:t.calcCornerCoords(i,this.cornerSize,e.x,e.y,!1,this),touchCorner:t.calcCornerCoords(i,this.touchCornerSize,e.x,e.y,!0,this)}}setCoords(){super.setCoords(),this.canvas&&(this.oCoords=this.calcOCoords())}forEachControl(t){for(const e in this.controls)t(this.controls[e],e,this)}drawSelectionBackground(t){if(!this.selectionBackgroundColor||this.canvas&&this.canvas._activeObject!==this)return;t.save();const e=this.getRelativeCenterPoint(),i=this._calculateCurrentDimensions(),s=this.getViewportTransform();t.translate(e.x,e.y),t.scale(1/s[0],1/s[3]),t.rotate(ft(this.angle)),t.fillStyle=this.selectionBackgroundColor,t.fillRect(-i.x/2,-i.y/2,i.x,i.y),t.restore()}strokeBorders(t,e){t.strokeRect(-e.x/2,-e.y/2,e.x,e.y)}_drawBorders(t,e){let i=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};const s=b({hasControls:this.hasControls,borderColor:this.borderColor,borderDashArray:this.borderDashArray},i);t.save(),t.strokeStyle=s.borderColor,this._setLineDash(t,s.borderDashArray),this.strokeBorders(t,e),s.hasControls&&this.drawControlsConnectingLines(t,e),t.restore()}_renderControls(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};const{hasBorders:i,hasControls:s}=this,r=b({hasBorders:i,hasControls:s},e),o=this.getViewportTransform(),a=r.hasBorders,l=r.hasControls,c=Tt(o,this.calcTransformMatrix()),h=Pr(c);t.save(),t.translate(h.translateX,h.translateY),t.lineWidth=this.borderScaleFactor,this.group===this.parent&&(t.globalAlpha=this.isMoving?this.borderOpacityWhenMoving:1),this.flipX&&(h.angle-=180),t.rotate(ft(this.group?h.angle:this.angle)),a&&this.drawBorders(t,h,e),l&&this.drawControls(t,e),t.restore()}drawBorders(t,e,i){let s;if(i&&i.forActiveSelection||this.group){const r=yo(this.width,this.height,Ir(e)),o=this.isStrokeAccountedForInDimensions()?uo:(this.strokeUniform?new C().scalarAdd(this.canvas?this.canvas.getZoom():1):new C(e.scaleX,e.scaleY)).scalarMultiply(this.strokeWidth);s=r.add(o).scalarAdd(this.borderScaleFactor).scalarAdd(2*this.padding)}else s=this._calculateCurrentDimensions().scalarAdd(this.borderScaleFactor);this._drawBorders(t,s,i)}drawControlsConnectingLines(t,e){let i=!1;t.beginPath(),this.forEachControl((s,r)=>{s.withConnection&&s.getVisibility(this,r)&&(i=!0,t.moveTo(s.x*e.x,s.y*e.y),t.lineTo(s.x*e.x+s.offsetX,s.y*e.y+s.offsetY))}),i&&t.stroke()}drawControls(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};t.save();const i=this.getCanvasRetinaScaling(),{cornerStrokeColor:s,cornerDashArray:r,cornerColor:o}=this,a=b({cornerStrokeColor:s,cornerDashArray:r,cornerColor:o},e);t.setTransform(i,0,0,i,0,0),t.strokeStyle=t.fillStyle=a.cornerColor,this.transparentCorners||(t.strokeStyle=a.cornerStrokeColor),this._setLineDash(t,a.cornerDashArray),this.forEachControl((l,c)=>{if(l.getVisibility(this,c)){const h=this.oCoords[c];l.render(t,h.x,h.y,a,this)}}),t.restore()}isControlVisible(t){return this.controls[t]&&this.controls[t].getVisibility(this,t)}setControlVisible(t,e){this._controlsVisibility||(this._controlsVisibility={}),this._controlsVisibility[t]=e}setControlsVisibility(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};Object.entries(t).forEach(e=>{let[i,s]=e;return this.setControlVisible(i,s)})}clearContextTop(t){if(!this.canvas)return;const e=this.canvas.contextTop;if(!e)return;const i=this.canvas.viewportTransform;e.save(),e.transform(i[0],i[1],i[2],i[3],i[4],i[5]),this.transform(e);const s=this.width+4,r=this.height+4;return e.clearRect(-s/2,-r/2,s,r),t||e.restore(),e}onDeselect(t){return!1}onSelect(t){return!1}shouldStartDragging(t){return!1}onDragStart(t){return!1}canDrop(t){return!1}renderDragSourceEffect(t){}renderDropTargetEffect(t){}}function ql(n,t){return t.forEach(e=>{Object.getOwnPropertyNames(e.prototype).forEach(i=>{i!=="constructor"&&Object.defineProperty(n.prototype,i,Object.getOwnPropertyDescriptor(e.prototype,i)||Object.create(null))})}),n}_(Ns,"ownDefaults",{noScaleCache:!0,lockMovementX:!1,lockMovementY:!1,lockRotation:!1,lockScalingX:!1,lockScalingY:!1,lockSkewingX:!1,lockSkewingY:!1,lockScalingFlip:!1,cornerSize:13,touchCornerSize:24,transparentCorners:!0,cornerColor:"rgb(178,204,255)",cornerStrokeColor:"",cornerStyle:"rect",cornerDashArray:null,hasControls:!0,borderColor:"rgb(178,204,255)",borderDashArray:null,borderOpacityWhenMoving:.4,borderScaleFactor:1,hasBorders:!0,selectionBackgroundColor:"",selectable:!0,evented:!0,perPixelTargetFind:!1,activeOn:"down",hoverCursor:null,moveCursor:null});class Ot extends Ns{}ql(Ot,[Il]),F.setClass(Ot),F.setClass(Ot,"object");const Xd=(n,t,e,i)=>{const s=2*(i=Math.round(i))+1,{data:r}=n.getImageData(t-i,e-i,s,s);for(let o=3;o<r.length;o+=4)if(r[o]>0)return!1;return!0};class Jl{constructor(t){this.options=t,this.strokeProjectionMagnitude=this.options.strokeWidth/2,this.scale=new C(this.options.scaleX,this.options.scaleY),this.strokeUniformScalar=this.options.strokeUniform?new C(1/this.options.scaleX,1/this.options.scaleY):new C(1,1)}createSideVector(t,e){const i=wo(t,e);return this.options.strokeUniform?i.multiply(this.scale):i}projectOrthogonally(t,e,i){return this.applySkew(t.add(this.calcOrthogonalProjection(t,e,i)))}isSkewed(){return this.options.skewX!==0||this.options.skewY!==0}applySkew(t){const e=new C(t);return e.y+=e.x*Math.tan(ft(this.options.skewY)),e.x+=e.y*Math.tan(ft(this.options.skewX)),e}scaleUnitVector(t,e){return t.multiply(this.strokeUniformScalar).scalarMultiply(e)}}const Kd=new C;class ss extends Jl{static getOrthogonalRotationFactor(t,e){const i=e?Eo(t,e):vd(t);return Math.abs(i)<Ds?-1:1}constructor(t,e,i,s){super(s),_(this,"AB",void 0),_(this,"AC",void 0),_(this,"alpha",void 0),_(this,"bisector",void 0),this.A=new C(t),this.B=new C(e),this.C=new C(i),this.AB=this.createSideVector(this.A,this.B),this.AC=this.createSideVector(this.A,this.C),this.alpha=Eo(this.AB,this.AC),this.bisector=Oo(Rl(this.AB.eq(Kd)?this.AC:this.AB,this.alpha/2))}calcOrthogonalProjection(t,e){let i=arguments.length>2&&arguments[2]!==void 0?arguments[2]:this.strokeProjectionMagnitude;const s=this.createSideVector(t,e),r=Nl(s),o=ss.getOrthogonalRotationFactor(r,this.bisector);return this.scaleUnitVector(r,i*o)}projectBevel(){const t=[];return(this.alpha%wr==0?[this.B]:[this.B,this.C]).forEach(e=>{t.push(this.projectOrthogonally(this.A,e)),t.push(this.projectOrthogonally(this.A,e,-this.strokeProjectionMagnitude))}),t}projectMiter(){const t=[],e=Math.abs(this.alpha),i=1/Math.sin(e/2),s=this.scaleUnitVector(this.bisector,-this.strokeProjectionMagnitude*i),r=this.options.strokeUniform?To(this.scaleUnitVector(this.bisector,this.options.strokeMiterLimit)):this.options.strokeMiterLimit;return To(s)/this.strokeProjectionMagnitude<=r&&t.push(this.applySkew(this.A.add(s))),t.push(...this.projectBevel()),t}projectRoundNoSkew(t,e){const i=[],s=new C(ss.getOrthogonalRotationFactor(this.bisector),ss.getOrthogonalRotationFactor(new C(this.bisector.y,this.bisector.x)));return[new C(1,0).scalarMultiply(this.strokeProjectionMagnitude).multiply(this.strokeUniformScalar).multiply(s),new C(0,1).scalarMultiply(this.strokeProjectionMagnitude).multiply(this.strokeUniformScalar).multiply(s)].forEach(r=>{Bl(r,t,e)&&i.push(this.A.add(r))}),i}projectRoundWithSkew(t,e){const i=[],{skewX:s,skewY:r,scaleX:o,scaleY:a,strokeUniform:l}=this.options,c=new C(Math.tan(ft(s)),Math.tan(ft(r))),h=this.strokeProjectionMagnitude,u=l?h/a/Math.sqrt(1/a**2+1/o**2*c.y**2):h/Math.sqrt(1+c.y**2),d=new C(Math.sqrt(Math.max(h**2-u**2,0)),u),f=l?h/Math.sqrt(1+c.x**2*(1/a)**2/(1/o+1/o*c.x*c.y)**2):h/Math.sqrt(1+c.x**2/(1+c.x*c.y)**2),g=new C(f,Math.sqrt(Math.max(h**2-f**2,0)));return[g,g.scalarMultiply(-1),d,d.scalarMultiply(-1)].map(p=>this.applySkew(l?p.multiply(this.strokeUniformScalar):p)).forEach(p=>{Bl(p,t,e)&&i.push(this.applySkew(this.A).add(p))}),i}projectRound(){const t=[];t.push(...this.projectBevel());const e=this.alpha%wr==0,i=this.applySkew(this.A),s=t[e?0:2].subtract(i),r=t[e?1:0].subtract(i),o=e?this.applySkew(this.AB.scalarMultiply(-1)):this.applySkew(this.bisector.multiply(this.strokeUniformScalar).scalarMultiply(-1)),a=Fs(s,o)>0,l=a?s:r,c=a?r:s;return this.isSkewed()?t.push(...this.projectRoundWithSkew(l,c)):t.push(...this.projectRoundNoSkew(l,c)),t}projectPoints(){switch(this.options.strokeLineJoin){case"miter":return this.projectMiter();case"round":return this.projectRound();default:return this.projectBevel()}}project(){return this.projectPoints().map(t=>({originPoint:this.A,projectedPoint:t,angle:this.alpha,bisector:this.bisector}))}}class Zl extends Jl{constructor(t,e,i){super(i),this.A=new C(t),this.T=new C(e)}calcOrthogonalProjection(t,e){let i=arguments.length>2&&arguments[2]!==void 0?arguments[2]:this.strokeProjectionMagnitude;const s=this.createSideVector(t,e);return this.scaleUnitVector(Nl(s),i)}projectButt(){return[this.projectOrthogonally(this.A,this.T,this.strokeProjectionMagnitude),this.projectOrthogonally(this.A,this.T,-this.strokeProjectionMagnitude)]}projectRound(){const t=[];if(!this.isSkewed()&&this.A.eq(this.T)){const e=new C(1,1).scalarMultiply(this.strokeProjectionMagnitude).multiply(this.strokeUniformScalar);t.push(this.applySkew(this.A.add(e)),this.applySkew(this.A.subtract(e)))}else t.push(...new ss(this.A,this.T,this.T,this.options).projectRound());return t}projectSquare(){const t=[];if(this.A.eq(this.T)){const e=new C(1,1).scalarMultiply(this.strokeProjectionMagnitude).multiply(this.strokeUniformScalar);t.push(this.A.add(e),this.A.subtract(e))}else{const e=this.calcOrthogonalProjection(this.A,this.T,this.strokeProjectionMagnitude),i=this.scaleUnitVector(Oo(this.createSideVector(this.A,this.T)),-this.strokeProjectionMagnitude),s=this.A.add(i);t.push(s.add(e),s.subtract(e))}return t.map(e=>this.applySkew(e))}projectPoints(){switch(this.options.strokeLineCap){case"round":return this.projectRound();case"square":return this.projectSquare();default:return this.projectButt()}}project(){return this.projectPoints().map(t=>({originPoint:this.A,projectedPoint:t}))}}const qd=function(n,t){let e=arguments.length>2&&arguments[2]!==void 0&&arguments[2];const i=[];if(n.length===0)return i;const s=n.reduce((r,o)=>(r[r.length-1].eq(o)||r.push(new C(o)),r),[new C(n[0])]);if(s.length===1)e=!0;else if(!e){const r=s[0],o=((a,l)=>{for(let c=a.length-1;c>=0;c--)if(l(a[c],c,a))return c;return-1})(s,a=>!a.eq(r));s.splice(o+1)}return s.forEach((r,o,a)=>{let l,c;o===0?(c=a[1],l=e?r:a[a.length-1]):o===a.length-1?(l=a[o-1],c=e?r:a[0]):(l=a[o-1],c=a[o+1]),e&&a.length===1?i.push(...new Zl(r,r,t).project()):!e||o!==0&&o!==a.length-1?i.push(...new ss(r,l,c,t).project()):i.push(...new Zl(r,o===0?c:l,t).project())}),i},Po=n=>{const t={};return Object.keys(n).forEach(e=>{t[e]={},Object.keys(n[e]).forEach(i=>{t[e][i]=b({},n[e][i])})}),t},Jd=n=>n.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/'/g,"&apos;").replace(/</g,"&lt;").replace(/>/g,"&gt;"),Io=n=>{const t=[];for(let e,i=0;i<n.length;i++)(e=Zd(n,i))!==!1&&t.push(e);return t},Zd=(n,t)=>{const e=n.charCodeAt(t);if(isNaN(e))return"";if(e<55296||e>57343)return n.charAt(t);if(55296<=e&&e<=56319){if(n.length<=t+1)throw"High surrogate without following low surrogate";const s=n.charCodeAt(t+1);if(56320>s||s>57343)throw"High surrogate without following low surrogate";return n.charAt(t)+n.charAt(t+1)}if(t===0)throw"Low surrogate without preceding high surrogate";const i=n.charCodeAt(t-1);if(55296>i||i>56319)throw"Low surrogate without preceding high surrogate";return!1},Lo=function(n,t){let e=arguments.length>2&&arguments[2]!==void 0&&arguments[2];return n.fill!==t.fill||n.stroke!==t.stroke||n.strokeWidth!==t.strokeWidth||n.fontSize!==t.fontSize||n.fontFamily!==t.fontFamily||n.fontWeight!==t.fontWeight||n.fontStyle!==t.fontStyle||n.textBackgroundColor!==t.textBackgroundColor||n.deltaY!==t.deltaY||e&&(n.overline!==t.overline||n.underline!==t.underline||n.linethrough!==t.linethrough)},Qd=(n,t)=>{const e=t.split(`
164
- `),i=[];let s=-1,r={};n=Po(n);for(let o=0;o<e.length;o++){const a=Io(e[o]);if(n[o])for(let l=0;l<a.length;l++){s++;const c=n[o][l];c&&Object.keys(c).length>0&&(Lo(r,c,!0)?i.push({start:s,end:s+1,style:c}):i[i.length-1].end++),r=c||{}}else s+=a.length,r={}}return i},tf=(n,t)=>{if(!Array.isArray(n))return Po(n);const e=t.split(lo),i={};let s=-1,r=0;for(let o=0;o<e.length;o++){const a=Io(e[o]);for(let l=0;l<a.length;l++)s++,n[r]&&n[r].start<=s&&s<n[r].end&&(i[o]=i[o]||{},i[o][l]=b({},n[r].style),s===n[r].end-1&&r++)}return i},oi=["display","transform",bt,"fill-opacity","fill-rule","opacity",Bt,"stroke-dasharray","stroke-linecap","stroke-dashoffset","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke-width","id","paint-order","vector-effect","instantiated_by_use","clip-path"];function Ql(n,t){const e=n.nodeName,i=n.getAttribute("class"),s=n.getAttribute("id"),r="(?![a-zA-Z\\-]+)";let o;if(o=new RegExp("^"+e,"i"),t=t.replace(o,""),s&&t.length&&(o=new RegExp("#"+s+r,"i"),t=t.replace(o,"")),i&&t.length){const a=i.split(" ");for(let l=a.length;l--;)o=new RegExp("\\."+a[l]+r,"i"),t=t.replace(o,"")}return t.length===0}function ef(n,t){let e=!0;const i=Ql(n,t.pop());return i&&t.length&&(e=function(s,r){let o,a=!0;for(;s.parentElement&&s.parentElement.nodeType===1&&r.length;)a&&(o=r.pop()),a=Ql(s=s.parentElement,o);return r.length===0}(n,t)),i&&e&&t.length===0}const sf=n=>{var t;return(t=pd[n])!==null&&t!==void 0?t:n},rf=new RegExp("(".concat(Ei,")"),"gi"),nf=n=>n.replace(rf," $1 ").replace(/,/gi," ").replace(/\s+/gi," ");var tc,ec,ic,sc,rc,nc,oc;const It="(".concat(Ei,")"),of=String.raw(tc||(tc=ii(["(skewX)(",")"],["(skewX)\\(","\\)"])),It),af=String.raw(ec||(ec=ii(["(skewY)(",")"],["(skewY)\\(","\\)"])),It),lf=String.raw(ic||(ic=ii(["(rotate)(","(?: "," ",")?)"],["(rotate)\\(","(?: "," ",")?\\)"])),It,It,It),cf=String.raw(sc||(sc=ii(["(scale)(","(?: ",")?)"],["(scale)\\(","(?: ",")?\\)"])),It,It),hf=String.raw(rc||(rc=ii(["(translate)(","(?: ",")?)"],["(translate)\\(","(?: ",")?\\)"])),It,It),uf=String.raw(nc||(nc=ii(["(matrix)("," "," "," "," "," ",")"],["(matrix)\\("," "," "," "," "," ","\\)"])),It,It,It,It,It,It),jo="(?:".concat(uf,"|").concat(hf,"|").concat(lf,"|").concat(cf,"|").concat(of,"|").concat(af,")"),df="(?:".concat(jo,"*)"),ff=String.raw(oc||(oc=ii(["^s*(?:","?)s*$"],["^\\s*(?:","?)\\s*$"])),df),gf=new RegExp(ff),pf=new RegExp(jo),mf=new RegExp(jo,"g");function Fo(n){const t=[];if(!(n=nf(n).replace(/\s*([()])\s*/gi,"$1"))||n&&!gf.test(n))return[...Pt];for(const e of n.matchAll(mf)){const i=pf.exec(e[0]);if(!i)continue;let s=Pt;const r=i.filter(g=>!!g),[,o,...a]=r,[l,c,h,u,d,f]=a.map(g=>parseFloat(g));switch(o){case"translate":s=Ms(l,c);break;case co:s=Ps({angle:l},{x:c,y:h});break;case Or:s=go(l,c);break;case Ui:s=gl(l);break;case Gi:s=pl(l);break;case"matrix":s=[l,c,h,u,d,f]}t.push(s)}return fo(t)}function vf(n,t,e,i){const s=Array.isArray(t);let r,o=t;if(n!==bt&&n!==Bt||t!==Rt){if(n==="strokeUniform")return t==="non-scaling-stroke";if(n==="strokeDashArray")o=t===Rt?null:t.replace(/,/g," ").split(/\s+/).map(parseFloat);else if(n==="transformMatrix")o=e&&e.transformMatrix?Tt(e.transformMatrix,Fo(t)):Fo(t);else if(n==="visible")o=t!==Rt&&t!=="hidden",e&&e.visible===!1&&(o=!1);else if(n==="opacity")o=parseFloat(t),e&&e.opacity!==void 0&&(o*=e.opacity);else if(n==="textAnchor")o=t==="start"?Q:t==="end"?dt:G;else if(n==="charSpacing")r=Ji(t,i)/i*1e3;else if(n==="paintFirst"){const a=t.indexOf(bt),l=t.indexOf(Bt);o=bt,(a>-1&&l>-1&&l<a||a===-1&&l>-1)&&(o=Bt)}else{if(n==="href"||n==="xlink:href"||n==="font"||n==="id")return t;if(n==="imageSmoothing")return t==="optimizeQuality";r=s?t.map(Ji):Ji(t,i)}}else o="";return!s&&isNaN(r)?o:r}function _f(n,t){const e=n.match(gd);if(!e)return;const i=e[1],s=e[3],r=e[4],o=e[5],a=e[6];i&&(t.fontStyle=i),s&&(t.fontWeight=isNaN(parseFloat(s))?s:parseFloat(s)),r&&(t.fontSize=Ji(r)),a&&(t.fontFamily=a),o&&(t.lineHeight=o==="normal"?1:o)}function bf(n,t){n.replace(/;\s*$/,"").split(";").forEach(e=>{if(!e)return;const[i,s]=e.split(":");t[i.trim().toLowerCase()]=s.trim()})}function yf(n){const t={},e=n.getAttribute("style");return e&&(typeof e=="string"?bf(e,t):function(i,s){Object.entries(i).forEach(r=>{let[o,a]=r;a!==void 0&&(s[o.toLowerCase()]=a)})}(e,t)),t}const xf={stroke:"strokeOpacity",fill:"fillOpacity"};function Ne(n,t,e){if(!n)return{};let i,s={},r=oo;n.parentNode&&jl.test(n.parentNode.nodeName)&&(s=Ne(n.parentElement,t,e),s.fontSize&&(i=r=Ji(s.fontSize)));const o=b(b(b({},t.reduce((c,h)=>{const u=n.getAttribute(h);return u&&(c[h]=u),c},{})),function(c){let h=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},u={};for(const d in h)ef(c,d.split(" "))&&(u=b(b({},u),h[d]));return u}(n,e)),yf(n));o[So]&&n.setAttribute(So,o[So]),o[Co]&&(i=Ji(o[Co],r),o[Co]="".concat(i));const a={};for(const c in o){const h=sf(c),u=vf(h,o[c],s,i);a[h]=u}a&&a.font&&_f(a.font,a);const l=b(b({},s),a);return jl.test(n.nodeName)?l:function(c){const h=Ot.getDefaults();return Object.entries(xf).forEach(u=>{let[d,f]=u;if(c[f]===void 0||c[d]==="")return;if(c[d]===void 0){if(!h[d])return;c[d]=h[d]}if(c[d].indexOf("url(")===0)return;const g=new tt(c[d]);c[d]=g.setAlpha(lt(g.getAlpha()*c[f],2)).toRgba()}),c}(l)}const Cf=["left","top","width","height","visible"],ac=["rx","ry"];class Se extends Ot{static getDefaults(){return b(b({},super.getDefaults()),Se.ownDefaults)}constructor(t){super(),Object.assign(this,Se.ownDefaults),this.setOptions(t),this._initRxRy()}_initRxRy(){const{rx:t,ry:e}=this;t&&!e?this.ry=t:e&&!t&&(this.rx=e)}_render(t){const{width:e,height:i}=this,s=-e/2,r=-i/2,o=this.rx?Math.min(this.rx,e/2):0,a=this.ry?Math.min(this.ry,i/2):0,l=o!==0||a!==0;t.beginPath(),t.moveTo(s+o,r),t.lineTo(s+e-o,r),l&&t.bezierCurveTo(s+e-ri*o,r,s+e,r+ri*a,s+e,r+a),t.lineTo(s+e,r+i-a),l&&t.bezierCurveTo(s+e,r+i-ri*a,s+e-ri*o,r+i,s+e-o,r+i),t.lineTo(s+o,r+i),l&&t.bezierCurveTo(s+ri*o,r+i,s,r+i-ri*a,s,r+i-a),t.lineTo(s,r+a),l&&t.bezierCurveTo(s,r+ri*a,s+ri*o,r,s+o,r),t.closePath(),this._renderPaintInOrder(t)}toObject(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[];return super.toObject([...ac,...t])}_toSVG(){const{width:t,height:e,rx:i,ry:s}=this;return["<rect ","COMMON_PARTS",'x="'.concat(-t/2,'" y="').concat(-e/2,'" rx="').concat(i,'" ry="').concat(s,'" width="').concat(t,'" height="').concat(e,`" />
165
- `)]}static async fromElement(t,e,i){const s=Ne(t,this.ATTRIBUTE_NAMES,i),{left:r=0,top:o=0,width:a=0,height:l=0,visible:c=!0}=s,h=rt(s,Cf);return new this(b(b(b({},e),h),{},{left:r,top:o,width:a,height:l,visible:!!(c&&a&&l)}))}}_(Se,"type","Rect"),_(Se,"cacheProperties",[...Fe,...ac]),_(Se,"ownDefaults",{rx:0,ry:0}),_(Se,"ATTRIBUTE_NAMES",[...oi,"x","y","rx","ry","width","height"]),F.setClass(Se),F.setSVGClass(Se);const Be="initialization",Yr="added",Ro="removed",Ur="imperative",lc=(n,t)=>{const{strokeUniform:e,strokeWidth:i,width:s,height:r,group:o}=t,a=o&&o!==n?Br(o.calcTransformMatrix(),n.calcTransformMatrix()):null,l=a?t.getRelativeCenterPoint().transform(a):t.getRelativeCenterPoint(),c=!t.isStrokeAccountedForInDimensions(),h=e&&c?hd(new C(i,i),void 0,n.calcTransformMatrix()):uo,u=!e&&c?i:0,d=yo(s+u,r+u,fo([a,t.calcOwnMatrix()],!0)).add(h).scalarDivide(2);return[l.subtract(d),l.add(d)]};class Gr{calcLayoutResult(t,e){if(this.shouldPerformLayout(t))return this.calcBoundingBox(e,t)}shouldPerformLayout(t){let{type:e,prevStrategy:i,strategy:s}=t;return e===Be||e===Ur||!!i&&s!==i}shouldLayoutClipPath(t){let{type:e,target:{clipPath:i}}=t;return e!==Be&&i&&!i.absolutePositioned}getInitialSize(t,e){return e.size}calcBoundingBox(t,e){const{type:i,target:s}=e;if(i===Ur&&e.overrides)return e.overrides;if(t.length===0)return;const{left:r,top:o,width:a,height:l}=Le(t.map(u=>lc(s,u)).reduce((u,d)=>u.concat(d),[])),c=new C(a,l),h=new C(r,o).add(c.scalarDivide(2));if(i===Be){const u=this.getInitialSize(e,{size:c,center:h});return{center:h,relativeCorrection:new C(0,0),size:u}}return{center:h.transform(s.calcOwnMatrix()),size:c}}}_(Gr,"type","strategy");class No extends Gr{shouldPerformLayout(t){return!0}}_(No,"type","fit-content"),F.setClass(No);const Sf=["strategy"],wf=["target","strategy","bubbles","prevStrategy"],cc="layoutManager";class Bs{constructor(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:new No;_(this,"strategy",void 0),this.strategy=t,this._subscriptions=new Map}performLayout(t){const e=b(b({bubbles:!0,strategy:this.strategy},t),{},{prevStrategy:this._prevLayoutStrategy,stopPropagation(){this.bubbles=!1}});this.onBeforeLayout(e);const i=this.getLayoutResult(e);i&&this.commitLayout(e,i),this.onAfterLayout(e,i),this._prevLayoutStrategy=e.strategy}attachHandlers(t,e){const{target:i}=e;return[Ar,ol,ks,al,Tr,ll,Er,Ku,qu].map(s=>t.on(s,r=>this.performLayout(s===Ar?{type:"object_modified",trigger:s,e:r,target:i}:{type:"object_modifying",trigger:s,e:r,target:i})))}subscribe(t,e){this.unsubscribe(t,e);const i=this.attachHandlers(t,e);this._subscriptions.set(t,i)}unsubscribe(t,e){(this._subscriptions.get(t)||[]).forEach(i=>i()),this._subscriptions.delete(t)}unsubscribeTargets(t){t.targets.forEach(e=>this.unsubscribe(e,t))}subscribeTargets(t){t.targets.forEach(e=>this.subscribe(e,t))}onBeforeLayout(t){const{target:e,type:i}=t,{canvas:s}=e;if(i===Be||i===Yr?this.subscribeTargets(t):i===Ro&&this.unsubscribeTargets(t),e.fire("layout:before",{context:t}),s&&s.fire("object:layout:before",{target:e,context:t}),i===Ur&&t.deep){const r=rt(t,Sf);e.forEachObject(o=>o.layoutManager&&o.layoutManager.performLayout(b(b({},r),{},{bubbles:!1,target:o})))}}getLayoutResult(t){const{target:e,strategy:i,type:s}=t,r=i.calcLayoutResult(t,e.getObjects());if(!r)return;const o=s===Be?new C:e.getRelativeCenterPoint(),{center:a,correction:l=new C,relativeCorrection:c=new C}=r,h=o.subtract(a).add(l).transform(s===Be?Pt:ce(e.calcOwnMatrix()),!0).add(c);return{result:r,prevCenter:o,nextCenter:a,offset:h}}commitLayout(t,e){const{target:i}=t,{result:{size:s},nextCenter:r}=e;var o,a;i.set({width:s.x,height:s.y}),this.layoutObjects(t,e),t.type===Be?i.set({left:(o=t.x)!==null&&o!==void 0?o:r.x+s.x*_t(i.originX),top:(a=t.y)!==null&&a!==void 0?a:r.y+s.y*_t(i.originY)}):(i.setPositionByOrigin(r,G,G),i.setCoords(),i.set("dirty",!0))}layoutObjects(t,e){const{target:i}=t;i.forEachObject(s=>{s.group===i&&this.layoutObject(t,e,s)}),t.strategy.shouldLayoutClipPath(t)&&this.layoutObject(t,e,i.clipPath)}layoutObject(t,e,i){let{offset:s}=e;i.set({left:i.left+s.x,top:i.top+s.y})}onAfterLayout(t,e){const{target:i,strategy:s,bubbles:r,prevStrategy:o}=t,a=rt(t,wf),{canvas:l}=i;i.fire("layout:after",{context:t,result:e}),l&&l.fire("object:layout:after",{context:t,result:e,target:i});const c=i.parent;r&&c!=null&&c.layoutManager&&((a.path||(a.path=[])).push(i),c.layoutManager.performLayout(b(b({},a),{},{target:c}))),i.set("dirty",!0)}dispose(){const{_subscriptions:t}=this;t.forEach(e=>e.forEach(i=>i())),t.clear()}toObject(){return{type:cc,strategy:this.strategy.constructor.type}}toJSON(){return this.toObject()}}F.setClass(Bs,cc);const Tf=["type","objects","layoutManager"];class Ef extends Bs{performLayout(){}}class Oi extends cl(Ot){static getDefaults(){return b(b({},super.getDefaults()),Oi.ownDefaults)}constructor(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[],e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};super(),_(this,"_activeObjects",[]),_(this,"__objectSelectionTracker",void 0),_(this,"__objectSelectionDisposer",void 0),Object.assign(this,Oi.ownDefaults),this.setOptions(e),this.groupInit(t,e)}groupInit(t,e){var i;this._objects=[...t],this.__objectSelectionTracker=this.__objectSelectionMonitor.bind(this,!0),this.__objectSelectionDisposer=this.__objectSelectionMonitor.bind(this,!1),this.forEachObject(s=>{this.enterGroup(s,!1)}),this.layoutManager=(i=e.layoutManager)!==null&&i!==void 0?i:new Bs,this.layoutManager.performLayout({type:Be,target:this,targets:[...t],x:e.left,y:e.top})}canEnterGroup(t){return t===this||this.isDescendantOf(t)?(si("error","Group: circular object trees are not supported, this call has no effect"),!1):this._objects.indexOf(t)===-1||(si("error","Group: duplicate objects are not supported inside group, this call has no effect"),!1)}_filterObjectsBeforeEnteringGroup(t){return t.filter((e,i,s)=>this.canEnterGroup(e)&&s.indexOf(e)===i)}add(){for(var t=arguments.length,e=new Array(t),i=0;i<t;i++)e[i]=arguments[i];const s=this._filterObjectsBeforeEnteringGroup(e),r=super.add(...s);return this._onAfterObjectsChange(Yr,s),r}insertAt(t){for(var e=arguments.length,i=new Array(e>1?e-1:0),s=1;s<e;s++)i[s-1]=arguments[s];const r=this._filterObjectsBeforeEnteringGroup(i),o=super.insertAt(t,...r);return this._onAfterObjectsChange(Yr,r),o}remove(){const t=super.remove(...arguments);return this._onAfterObjectsChange(Ro,t),t}_onObjectAdded(t){this.enterGroup(t,!0),this.fire("object:added",{target:t}),t.fire("added",{target:this})}_onObjectRemoved(t,e){this.exitGroup(t,e),this.fire("object:removed",{target:t}),t.fire("removed",{target:this})}_onAfterObjectsChange(t,e){this.layoutManager.performLayout({type:t,targets:e,target:this})}_onStackOrderChanged(){this._set("dirty",!0)}_set(t,e){const i=this[t];return super._set(t,e),t==="canvas"&&i!==e&&(this._objects||[]).forEach(s=>{s._set(t,e)}),this}_shouldSetNestedCoords(){return this.subTargetCheck}removeAll(){return this._activeObjects=[],this.remove(...this._objects)}__objectSelectionMonitor(t,e){let{target:i}=e;const s=this._activeObjects;if(t)s.push(i),this._set("dirty",!0);else if(s.length>0){const r=s.indexOf(i);r>-1&&(s.splice(r,1),this._set("dirty",!0))}}_watchObject(t,e){t&&this._watchObject(!1,e),t?(e.on("selected",this.__objectSelectionTracker),e.on("deselected",this.__objectSelectionDisposer)):(e.off("selected",this.__objectSelectionTracker),e.off("deselected",this.__objectSelectionDisposer))}enterGroup(t,e){t.group&&t.group.remove(t),t._set("parent",this),this._enterGroup(t,e)}_enterGroup(t,e){e&&Nr(t,Tt(ce(this.calcTransformMatrix()),t.calcTransformMatrix())),this._shouldSetNestedCoords()&&t.setCoords(),t._set("group",this),t._set("canvas",this.canvas),this._watchObject(!0,t);const i=this.canvas&&this.canvas.getActiveObject&&this.canvas.getActiveObject();i&&(i===t||t.isDescendantOf(i))&&this._activeObjects.push(t)}exitGroup(t,e){this._exitGroup(t,e),t._set("parent",void 0),t._set("canvas",void 0)}_exitGroup(t,e){t._set("group",void 0),e||(Nr(t,Tt(this.calcTransformMatrix(),t.calcTransformMatrix())),t.setCoords()),this._watchObject(!1,t);const i=this._activeObjects.length>0?this._activeObjects.indexOf(t):-1;i>-1&&this._activeObjects.splice(i,1)}shouldCache(){const t=Ot.prototype.shouldCache.call(this);if(t){for(let e=0;e<this._objects.length;e++)if(this._objects[e].willDrawShadow())return this.ownCaching=!1,!1}return t}willDrawShadow(){if(super.willDrawShadow())return!0;for(let t=0;t<this._objects.length;t++)if(this._objects[t].willDrawShadow())return!0;return!1}isOnACache(){return this.ownCaching||!!this.parent&&this.parent.isOnACache()}drawObject(t,e,i){this._renderBackground(t);for(let r=0;r<this._objects.length;r++){var s;const o=this._objects[r];(s=this.canvas)!==null&&s!==void 0&&s.preserveObjectStacking&&o.group!==this?(t.save(),t.transform(...ce(this.calcTransformMatrix())),o.render(t),t.restore()):o.group===this&&o.render(t)}this._drawClipPath(t,this.clipPath,i)}setCoords(){super.setCoords(),this._shouldSetNestedCoords()&&this.forEachObject(t=>t.setCoords())}triggerLayout(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};this.layoutManager.performLayout(b({target:this,type:Ur},t))}render(t){this._transformDone=!0,super.render(t),this._transformDone=!1}__serializeObjects(t,e){const i=this.includeDefaultValues;return this._objects.filter(function(s){return!s.excludeFromExport}).map(function(s){const r=s.includeDefaultValues;s.includeDefaultValues=i;const o=s[t||"toObject"](e);return s.includeDefaultValues=r,o})}toObject(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[];const e=this.layoutManager.toObject();return b(b(b({},super.toObject(["subTargetCheck","interactive",...t])),e.strategy!=="fit-content"||this.includeDefaultValues?{layoutManager:e}:{}),{},{objects:this.__serializeObjects("toObject",t)})}toString(){return"#<Group: (".concat(this.complexity(),")>")}dispose(){this.layoutManager.unsubscribeTargets({targets:this.getObjects(),target:this}),this._activeObjects=[],this.forEachObject(t=>{this._watchObject(!1,t),t.dispose()}),super.dispose()}_createSVGBgRect(t){if(!this.backgroundColor)return"";const e=Se.prototype._toSVG.call(this),i=e.indexOf("COMMON_PARTS");e[i]='for="group" ';const s=e.join("");return t?t(s):s}_toSVG(t){const e=["<g ","COMMON_PARTS",` >
166
- `],i=this._createSVGBgRect(t);i&&e.push(" ",i);for(let s=0;s<this._objects.length;s++)e.push(" ",this._objects[s].toSVG(t));return e.push(`</g>
167
- `),e}getSvgStyles(){const t=this.opacity!==void 0&&this.opacity!==1?"opacity: ".concat(this.opacity,";"):"",e=this.visible?"":" visibility: hidden;";return[t,this.getSvgFilter(),e].join("")}toClipPathSVG(t){const e=[],i=this._createSVGBgRect(t);i&&e.push(" ",i);for(let s=0;s<this._objects.length;s++)e.push(" ",this._objects[s].toClipPathSVG(t));return this._createBaseClipPathSVGMarkup(e,{reviver:t})}static fromObject(t,e){let{type:i,objects:s=[],layoutManager:r}=t,o=rt(t,Tf);return Promise.all([Is(s,e),jr(o,e)]).then(a=>{let[l,c]=a;const h=new this(l,b(b(b({},o),c),{},{layoutManager:new Ef}));if(r){const u=F.getClass(r.type),d=F.getClass(r.strategy);h.layoutManager=new u(new d)}else h.layoutManager=new Bs;return h.layoutManager.subscribeTargets({type:Be,target:h,targets:h.getObjects()}),h.setCoords(),h})}}_(Oi,"type","Group"),_(Oi,"ownDefaults",{strokeWidth:0,subTargetCheck:!1,interactive:!1}),F.setClass(Oi);const Of=(n,t)=>Math.min(t.width/n.width,t.height/n.height),Af=(n,t)=>Math.max(t.width/n.width,t.height/n.height),Bo="\\s*,?\\s*",$s="".concat(Bo,"(").concat(Ei,")"),Df="".concat($s).concat($s).concat($s).concat(Bo,"([01])").concat(Bo,"([01])").concat($s).concat($s),kf={m:"l",M:"L"},Mf=(n,t,e,i,s,r,o,a,l,c,h)=>{const u=Pe(n),d=Ie(n),f=Pe(t),g=Ie(t),p=e*s*f-i*r*g+o,m=i*s*f+e*r*g+a;return["C",c+l*(-e*s*d-i*r*u),h+l*(-i*s*d+e*r*u),p+l*(e*s*g+i*r*f),m+l*(i*s*g-e*r*f),p,m]},hc=(n,t,e,i)=>{const s=Math.atan2(t,n),r=Math.atan2(i,e);return r>=s?r-s:2*Math.PI-(s-r)};function uc(n,t,e,i,s,r,o,a){let l;if(J.cachesBoundsOfCurve&&(l=[...arguments].join(),As.boundsOfCurveCache[l]))return As.boundsOfCurveCache[l];const c=Math.sqrt,h=Math.abs,u=[],d=[[0,0],[0,0]];let f=6*n-12*e+6*s,g=-3*n+9*e-9*s+3*o,p=3*e-3*n;for(let E=0;E<2;++E){if(E>0&&(f=6*t-12*i+6*r,g=-3*t+9*i-9*r+3*a,p=3*i-3*t),h(g)<1e-12){if(h(f)<1e-12)continue;const L=-p/f;0<L&&L<1&&u.push(L);continue}const T=f*f-4*p*g;if(T<0)continue;const k=c(T),S=(-f+k)/(2*g);0<S&&S<1&&u.push(S);const w=(-f-k)/(2*g);0<w&&w<1&&u.push(w)}let m=u.length;const v=m,y=dc(n,t,e,i,s,r,o,a);for(;m--;){const{x:E,y:T}=y(u[m]);d[0][m]=E,d[1][m]=T}d[0][v]=n,d[1][v]=t,d[0][v+1]=o,d[1][v+1]=a;const x=[new C(Math.min(...d[0]),Math.min(...d[1])),new C(Math.max(...d[0]),Math.max(...d[1]))];return J.cachesBoundsOfCurve&&(As.boundsOfCurveCache[l]=x),x}const Pf=(n,t,e)=>{let[i,s,r,o,a,l,c,h]=e;const u=((d,f,g,p,m,v,y)=>{if(g===0||p===0)return[];let x=0,E=0,T=0;const k=Math.PI,S=y*no,w=Ie(S),L=Pe(S),j=.5*(-L*d-w*f),A=.5*(-L*f+w*d),O=g**2,D=p**2,I=A**2,$=j**2,X=O*D-O*I-D*$;let K=Math.abs(g),R=Math.abs(p);if(X<0){const ot=Math.sqrt(1-X/(O*D));K*=ot,R*=ot}else T=(m===v?-1:1)*Math.sqrt(X/(O*I+D*$));const N=T*K*A/R,M=-T*R*j/K,V=L*N-w*M+.5*d,q=w*N+L*M+.5*f;let ut=hc(1,0,(j-N)/K,(A-M)/R),it=hc((j-N)/K,(A-M)/R,(-j-N)/K,(-A-M)/R);v===0&&it>0?it-=2*k:v===1&&it<0&&(it+=2*k);const qt=Math.ceil(Math.abs(it/k*2)),P=[],Z=it/qt,kt=8/3*Math.sin(Z/4)*Math.sin(Z/4)/Math.sin(Z/2);let nt=ut+Z;for(let ot=0;ot<qt;ot++)P[ot]=Mf(ut,nt,L,w,K,R,V,q,kt,x,E),x=P[ot][5],E=P[ot][6],ut=nt,nt+=Z;return P})(c-n,h-t,s,r,a,l,o);for(let d=0,f=u.length;d<f;d++)u[d][1]+=n,u[d][2]+=t,u[d][3]+=n,u[d][4]+=t,u[d][5]+=n,u[d][6]+=t;return u},If=n=>{let t=0,e=0,i=0,s=0;const r=[];let o,a=0,l=0;for(const c of n){const h=[...c];let u;switch(h[0]){case"l":h[1]+=t,h[2]+=e;case"L":t=h[1],e=h[2],u=["L",t,e];break;case"h":h[1]+=t;case"H":t=h[1],u=["L",t,e];break;case"v":h[1]+=e;case"V":e=h[1],u=["L",t,e];break;case"m":h[1]+=t,h[2]+=e;case"M":t=h[1],e=h[2],i=h[1],s=h[2],u=["M",t,e];break;case"c":h[1]+=t,h[2]+=e,h[3]+=t,h[4]+=e,h[5]+=t,h[6]+=e;case"C":a=h[3],l=h[4],t=h[5],e=h[6],u=["C",h[1],h[2],a,l,t,e];break;case"s":h[1]+=t,h[2]+=e,h[3]+=t,h[4]+=e;case"S":o==="C"?(a=2*t-a,l=2*e-l):(a=t,l=e),t=h[3],e=h[4],u=["C",a,l,h[1],h[2],t,e],a=u[3],l=u[4];break;case"q":h[1]+=t,h[2]+=e,h[3]+=t,h[4]+=e;case"Q":a=h[1],l=h[2],t=h[3],e=h[4],u=["Q",a,l,t,e];break;case"t":h[1]+=t,h[2]+=e;case"T":o==="Q"?(a=2*t-a,l=2*e-l):(a=t,l=e),t=h[1],e=h[2],u=["Q",a,l,t,e];break;case"a":h[6]+=t,h[7]+=e;case"A":Pf(t,e,h).forEach(d=>r.push(d)),t=h[6],e=h[7];break;case"z":case"Z":t=i,e=s,u=["Z"]}u?(r.push(u),o=u[0]):o=""}return r},Xr=(n,t,e,i)=>Math.sqrt((e-n)**2+(i-t)**2),dc=(n,t,e,i,s,r,o,a)=>l=>{const c=l**3,h=(f=>3*f**2*(1-f))(l),u=(f=>3*f*(1-f)**2)(l),d=(f=>(1-f)**3)(l);return new C(o*c+s*h+e*u+n*d,a*c+r*h+i*u+t*d)},fc=n=>n**2,gc=n=>2*n*(1-n),pc=n=>(1-n)**2,Lf=(n,t,e,i,s,r,o,a)=>l=>{const c=fc(l),h=gc(l),u=pc(l),d=3*(u*(e-n)+h*(s-e)+c*(o-s)),f=3*(u*(i-t)+h*(r-i)+c*(a-r));return Math.atan2(f,d)},jf=(n,t,e,i,s,r)=>o=>{const a=fc(o),l=gc(o),c=pc(o);return new C(s*a+e*l+n*c,r*a+i*l+t*c)},Ff=(n,t,e,i,s,r)=>o=>{const a=1-o,l=2*(a*(e-n)+o*(s-e)),c=2*(a*(i-t)+o*(r-i));return Math.atan2(c,l)},mc=(n,t,e)=>{let i=new C(t,e),s=0;for(let r=1;r<=100;r+=1){const o=n(r/100);s+=Xr(i.x,i.y,o.x,o.y),i=o}return s},Rf=(n,t)=>{let e,i=0,s=0,r={x:n.x,y:n.y},o=b({},r),a=.01,l=0;const c=n.iterator,h=n.angleFinder;for(;s<t&&a>1e-4;)o=c(i),l=i,e=Xr(r.x,r.y,o.x,o.y),e+s>t?(i-=a,a/=2):(r=o,i+=a,s+=e);return b(b({},o),{},{angle:h(l)})},vc=n=>{let t,e,i=0,s=0,r=0,o=0,a=0;const l=[];for(const c of n){const h={x:s,y:r,command:c[0],length:0};switch(c[0]){case"M":e=h,e.x=o=s=c[1],e.y=a=r=c[2];break;case"L":e=h,e.length=Xr(s,r,c[1],c[2]),s=c[1],r=c[2];break;case"C":t=dc(s,r,c[1],c[2],c[3],c[4],c[5],c[6]),e=h,e.iterator=t,e.angleFinder=Lf(s,r,c[1],c[2],c[3],c[4],c[5],c[6]),e.length=mc(t,s,r),s=c[5],r=c[6];break;case"Q":t=jf(s,r,c[1],c[2],c[3],c[4]),e=h,e.iterator=t,e.angleFinder=Ff(s,r,c[1],c[2],c[3],c[4]),e.length=mc(t,s,r),s=c[3],r=c[4];break;case"Z":e=h,e.destX=o,e.destY=a,e.length=Xr(s,r,o,a),s=o,r=a}i+=e.length,l.push(e)}return l.push({length:i,x:s,y:r}),l},Nf=function(n,t){let e=arguments.length>2&&arguments[2]!==void 0?arguments[2]:vc(n),i=0;for(;t-e[i].length>0&&i<e.length-2;)t-=e[i].length,i++;const s=e[i],r=t/s.length,o=n[i];switch(s.command){case"M":return{x:s.x,y:s.y,angle:0};case"Z":return b(b({},new C(s.x,s.y).lerp(new C(s.destX,s.destY),r)),{},{angle:Math.atan2(s.destY-s.y,s.destX-s.x)});case"L":return b(b({},new C(s.x,s.y).lerp(new C(o[1],o[2]),r)),{},{angle:Math.atan2(o[2]-s.y,o[1]-s.x)});case"C":case"Q":return Rf(s,t)}},Bf=new RegExp("[mzlhvcsqta][^mzlhvcsqta]*","gi"),_c=new RegExp(Df,"g"),$f=new RegExp(Ei,"gi"),Vf={m:2,l:2,h:1,v:1,c:6,s:4,q:4,t:2,a:7},zf=n=>{var t;const e=[],i=(t=n.match(Bf))!==null&&t!==void 0?t:[];for(const s of i){const r=s[0];if(r==="z"||r==="Z"){e.push([r]);continue}const o=Vf[r.toLowerCase()];let a=[];if(r==="a"||r==="A"){_c.lastIndex=0;for(let l=null;l=_c.exec(s);)a.push(...l.slice(1))}else a=s.match($f)||[];for(let l=0;l<a.length;l+=o){const c=new Array(o),h=kf[r];c[0]=l>0&&h?h:r;for(let u=0;u<o;u++)c[u+1]=parseFloat(a[l+u]);e.push(c)}}return e},Hf=(n,t)=>n.map(e=>e.map((i,s)=>s===0||t===void 0?i:lt(i,t)).join(" ")).join(" ");function $o(n,t){const e=n.style;e&&t&&(typeof t=="string"?e.cssText+=";"+t:Object.entries(t).forEach(i=>{let[s,r]=i;return e.setProperty(s,r)}))}class Wf extends El{constructor(t){let{allowTouchScrolling:e=!1,containerClass:i=""}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};super(t),_(this,"upper",void 0),_(this,"container",void 0);const{el:s}=this.lower,r=this.createUpperCanvas();this.upper={el:r,ctx:r.getContext("2d")},this.applyCanvasStyle(s,{allowTouchScrolling:e}),this.applyCanvasStyle(r,{allowTouchScrolling:e,styles:{position:"absolute",left:"0",top:"0"}});const o=this.createContainerElement();o.classList.add(i),s.parentNode&&s.parentNode.replaceChild(o,s),o.append(s,r),this.container=o}createUpperCanvas(){const{el:t}=this.lower,e=le();return e.className=t.className,e.classList.remove("lower-canvas"),e.classList.add("upper-canvas"),e.setAttribute("data-fabric","top"),e.style.cssText=t.style.cssText,e.setAttribute("draggable","true"),e}createContainerElement(){const t=Yi().createElement("div");return t.setAttribute("data-fabric","wrapper"),$o(t,{position:"relative"}),Tl(t),t}applyCanvasStyle(t,e){const{styles:i,allowTouchScrolling:s}=e;$o(t,b(b({},i),{},{"touch-action":s?"manipulation":Rt})),Tl(t)}setDimensions(t,e){super.setDimensions(t,e);const{el:i,ctx:s}=this.upper;wl(i,s,t,e)}setCSSDimensions(t){super.setCSSDimensions(t),vo(this.upper.el,t),vo(this.container,t)}cleanupDOM(t){const e=this.container,{el:i}=this.lower,{el:s}=this.upper;super.cleanupDOM(t),e.removeChild(s),e.removeChild(i),e.parentNode&&e.parentNode.replaceChild(i,e)}dispose(){super.dispose(),xe().dispose(this.upper.el),delete this.upper,delete this.container}}class Kr extends js{constructor(){super(...arguments),_(this,"targets",[]),_(this,"_hoveredTargets",[]),_(this,"_objectsToRender",void 0),_(this,"_currentTransform",null),_(this,"_groupSelector",null),_(this,"contextTopDirty",!1)}static getDefaults(){return b(b({},super.getDefaults()),Kr.ownDefaults)}get upperCanvasEl(){var t;return(t=this.elements.upper)===null||t===void 0?void 0:t.el}get contextTop(){var t;return(t=this.elements.upper)===null||t===void 0?void 0:t.ctx}get wrapperEl(){return this.elements.container}initElements(t){this.elements=new Wf(t,{allowTouchScrolling:this.allowTouchScrolling,containerClass:this.containerClass}),this._createCacheCanvas()}_onObjectAdded(t){this._objectsToRender=void 0,super._onObjectAdded(t)}_onObjectRemoved(t){this._objectsToRender=void 0,t===this._activeObject&&(this.fire("before:selection:cleared",{deselected:[t]}),this._discardActiveObject(),this.fire("selection:cleared",{deselected:[t]}),t.fire("deselected",{target:t})),t===this._hoveredTarget&&(this._hoveredTarget=void 0,this._hoveredTargets=[]),super._onObjectRemoved(t)}_onStackOrderChanged(){this._objectsToRender=void 0,super._onStackOrderChanged()}_chooseObjectsToRender(){const t=this._activeObject;return!this.preserveObjectStacking&&t?this._objects.filter(e=>!e.group&&e!==t).concat(t):this._objects}renderAll(){this.cancelRequestedRender(),this.destroyed||(!this.contextTopDirty||this._groupSelector||this.isDrawingMode||(this.clearContext(this.contextTop),this.contextTopDirty=!1),this.hasLostContext&&(this.renderTopLayer(this.contextTop),this.hasLostContext=!1),!this._objectsToRender&&(this._objectsToRender=this._chooseObjectsToRender()),this.renderCanvas(this.getContext(),this._objectsToRender))}renderTopLayer(t){t.save(),this.isDrawingMode&&this._isCurrentlyDrawing&&(this.freeDrawingBrush&&this.freeDrawingBrush._render(),this.contextTopDirty=!0),this.selection&&this._groupSelector&&(this._drawSelection(t),this.contextTopDirty=!0),t.restore()}renderTop(){const t=this.contextTop;this.clearContext(t),this.renderTopLayer(t),this.fire("after:render",{ctx:t})}setTargetFindTolerance(t){t=Math.round(t),this.targetFindTolerance=t;const e=this.getRetinaScaling(),i=Math.ceil((2*t+1)*e);this.pixelFindCanvasEl.width=this.pixelFindCanvasEl.height=i,this.pixelFindContext.scale(e,e)}isTargetTransparent(t,e,i){const s=this.targetFindTolerance,r=this.pixelFindContext;this.clearContext(r),r.save(),r.translate(-e+s,-i+s),r.transform(...this.viewportTransform);const o=t.selectionBackgroundColor;t.selectionBackgroundColor="",t.render(r),t.selectionBackgroundColor=o,r.restore();const a=Math.round(s*this.getRetinaScaling());return Xd(r,a,a,a)}_isSelectionKeyPressed(t){const e=this.selectionKey;return!!e&&(Array.isArray(e)?!!e.find(i=>!!i&&t[i]===!0):t[e])}_shouldClearSelection(t,e){const i=this.getActiveObjects(),s=this._activeObject;return!!(!e||e&&s&&i.length>1&&i.indexOf(e)===-1&&s!==e&&!this._isSelectionKeyPressed(t)||e&&!e.evented||e&&!e.selectable&&s&&s!==e)}_shouldCenterTransform(t,e,i){if(!t)return;let s;return e===Or||e===Nt||e===Zt||e===ks?s=this.centeredScaling||t.centeredScaling:e===co&&(s=this.centeredRotation||t.centeredRotation),s?!i:i}_getOriginFromCorner(t,e){const i={x:t.originX,y:t.originY};return e&&(["ml","tl","bl"].includes(e)?i.x=dt:["mr","tr","br"].includes(e)&&(i.x=Q),["tl","mt","tr"].includes(e)?i.y=ao:["bl","mb","br"].includes(e)&&(i.y=Ft)),i}_setupCurrentTransform(t,e,i){var s;const r=e.group?Zi(this.getScenePoint(t),void 0,e.group.calcTransformMatrix()):this.getScenePoint(t),{key:o="",control:a}=e.getActiveControl()||{},l=i&&a?(s=a.getActionHandler(t,e,a))===null||s===void 0?void 0:s.bind(a):fd,c=((f,g,p,m)=>{if(!g||!f)return"drag";const v=m.controls[g];return v.getActionName(p,v,m)})(i,o,t,e),h=t[this.centeredKey],u=this._shouldCenterTransform(e,c,h)?{x:G,y:G}:this._getOriginFromCorner(e,o),d={target:e,action:c,actionHandler:l,actionPerformed:!1,corner:o,scaleX:e.scaleX,scaleY:e.scaleY,skewX:e.skewX,skewY:e.skewY,offsetX:r.x-e.left,offsetY:r.y-e.top,originX:u.x,originY:u.y,ex:r.x,ey:r.y,lastX:r.x,lastY:r.y,theta:ft(e.angle),width:e.width,height:e.height,shiftKey:t.shiftKey,altKey:h,original:b(b({},Ol(e)),{},{originX:u.x,originY:u.y})};this._currentTransform=d,this.fire("before:transform",{e:t,transform:d})}setCursor(t){this.upperCanvasEl.style.cursor=t}_drawSelection(t){const{x:e,y:i,deltaX:s,deltaY:r}=this._groupSelector,o=new C(e,i).transform(this.viewportTransform),a=new C(e+s,i+r).transform(this.viewportTransform),l=this.selectionLineWidth/2;let c=Math.min(o.x,a.x),h=Math.min(o.y,a.y),u=Math.max(o.x,a.x),d=Math.max(o.y,a.y);this.selectionColor&&(t.fillStyle=this.selectionColor,t.fillRect(c,h,u-c,d-h)),this.selectionLineWidth&&this.selectionBorderColor&&(t.lineWidth=this.selectionLineWidth,t.strokeStyle=this.selectionBorderColor,c+=l,h+=l,u-=l,d-=l,Ot.prototype._setLineDash.call(this,t,this.selectionDashArray),t.strokeRect(c,h,u-c,d-h))}findTarget(t){if(this.skipTargetFind)return;const e=this.getViewportPoint(t),i=this._activeObject,s=this.getActiveObjects();if(this.targets=[],i&&s.length>=1){if(i.findControl(e,_o(t))||s.length>1&&this.searchPossibleTargets([i],e))return i;if(i===this.searchPossibleTargets([i],e)){if(this.preserveObjectStacking){const r=this.targets;this.targets=[];const o=this.searchPossibleTargets(this._objects,e);return t[this.altSelectionKey]&&o&&o!==i?(this.targets=r,i):o}return i}}return this.searchPossibleTargets(this._objects,e)}_pointIsInObjectSelectionArea(t,e){let i=t.getCoords();const s=this.getZoom(),r=t.padding/s;if(r){const[o,a,l,c]=i,h=Math.atan2(a.y-o.y,a.x-o.x),u=Pe(h)*r,d=Ie(h)*r,f=u+d,g=u-d;i=[new C(o.x-g,o.y-f),new C(a.x+f,a.y-g),new C(l.x+g,l.y+f),new C(c.x-f,c.y+g)]}return ct.isPointInPolygon(e,i)}_checkTarget(t,e){return!!(t&&t.visible&&t.evented&&this._pointIsInObjectSelectionArea(t,Zi(e,void 0,this.viewportTransform))&&(!this.perPixelTargetFind&&!t.perPixelTargetFind||t.isEditing||!this.isTargetTransparent(t,e.x,e.y)))}_searchPossibleTargets(t,e){let i=t.length;for(;i--;){const s=t[i];if(this._checkTarget(s,e)){if(kr(s)&&s.subTargetCheck){const r=this._searchPossibleTargets(s._objects,e);r&&this.targets.push(r)}return s}}}searchPossibleTargets(t,e){const i=this._searchPossibleTargets(t,e);if(i&&kr(i)&&i.interactive&&this.targets[0]){const s=this.targets;for(let r=s.length-1;r>0;r--){const o=s[r];if(!kr(o)||!o.interactive)return o}return s[0]}return i}getViewportPoint(t){return this._pointer?this._pointer:this.getPointer(t,!0)}getScenePoint(t){return this._absolutePointer?this._absolutePointer:this.getPointer(t)}getPointer(t){let e=arguments.length>1&&arguments[1]!==void 0&&arguments[1];const i=this.upperCanvasEl,s=i.getBoundingClientRect();let r=od(t),o=s.width||0,a=s.height||0;o&&a||(Ft in s&&ao in s&&(a=Math.abs(s.top-s.bottom)),dt in s&&Q in s&&(o=Math.abs(s.right-s.left))),this.calcOffset(),r.x=r.x-this._offset.left,r.y=r.y-this._offset.top,e||(r=Zi(r,void 0,this.viewportTransform));const l=this.getRetinaScaling();l!==1&&(r.x/=l,r.y/=l);const c=o===0||a===0?new C(1,1):new C(i.width/o,i.height/a);return r.multiply(c)}_setDimensionsImpl(t,e){this._resetTransformEventData(),super._setDimensionsImpl(t,e),this._isCurrentlyDrawing&&this.freeDrawingBrush&&this.freeDrawingBrush._setBrushStyles(this.contextTop)}_createCacheCanvas(){this.pixelFindCanvasEl=le(),this.pixelFindContext=this.pixelFindCanvasEl.getContext("2d",{willReadFrequently:!0}),this.setTargetFindTolerance(this.targetFindTolerance)}getTopContext(){return this.elements.upper.ctx}getSelectionContext(){return this.elements.upper.ctx}getSelectionElement(){return this.elements.upper.el}getActiveObject(){return this._activeObject}getActiveObjects(){const t=this._activeObject;return Ti(t)?t.getObjects():t?[t]:[]}_fireSelectionEvents(t,e){let i=!1,s=!1;const r=this.getActiveObjects(),o=[],a=[];t.forEach(l=>{r.includes(l)||(i=!0,l.fire("deselected",{e,target:l}),a.push(l))}),r.forEach(l=>{t.includes(l)||(i=!0,l.fire("selected",{e,target:l}),o.push(l))}),t.length>0&&r.length>0?(s=!0,i&&this.fire("selection:updated",{e,selected:o,deselected:a})):r.length>0?(s=!0,this.fire("selection:created",{e,selected:o})):t.length>0&&(s=!0,this.fire("selection:cleared",{e,deselected:a})),s&&(this._objectsToRender=void 0)}setActiveObject(t,e){const i=this.getActiveObjects(),s=this._setActiveObject(t,e);return this._fireSelectionEvents(i,e),s}_setActiveObject(t,e){const i=this._activeObject;return i!==t&&!(!this._discardActiveObject(e,t)&&this._activeObject)&&!t.onSelect({e})&&(this._activeObject=t,Ti(t)&&i!==t&&t.set("canvas",this),t.setCoords(),!0)}_discardActiveObject(t,e){const i=this._activeObject;return!!i&&!i.onDeselect({e:t,object:e})&&(this._currentTransform&&this._currentTransform.target===i&&this.endCurrentTransform(t),Ti(i)&&i===this._hoveredTarget&&(this._hoveredTarget=void 0),this._activeObject=void 0,!0)}discardActiveObject(t){const e=this.getActiveObjects(),i=this.getActiveObject();e.length&&this.fire("before:selection:cleared",{e:t,deselected:[i]});const s=this._discardActiveObject(t);return this._fireSelectionEvents(e,t),s}endCurrentTransform(t){const e=this._currentTransform;this._finalizeCurrentTransform(t),e&&e.target&&(e.target.isMoving=!1),this._currentTransform=null}_finalizeCurrentTransform(t){const e=this._currentTransform,i=e.target,s={e:t,target:i,transform:e,action:e.action};i._scaling&&(i._scaling=!1),i.setCoords(),e.actionPerformed&&(this.fire("object:modified",s),i.fire(Ar,s))}setViewportTransform(t){super.setViewportTransform(t);const e=this._activeObject;e&&e.setCoords()}destroy(){const t=this._activeObject;Ti(t)&&(t.removeAll(),t.dispose()),delete this._activeObject,super.destroy(),this.pixelFindContext=null,this.pixelFindCanvasEl=void 0}clear(){this.discardActiveObject(),this._activeObject=void 0,this.clearContext(this.contextTop),super.clear()}drawControls(t){const e=this._activeObject;e&&e._renderControls(t)}_toObject(t,e,i){const s=this._realizeGroupTransformOnObject(t),r=super._toObject(t,e,i);return t.set(s),r}_realizeGroupTransformOnObject(t){const{group:e}=t;if(e&&Ti(e)&&this._activeObject===e){const i=qi(t,["angle","flipX","flipY",Q,Nt,Zt,Ui,Gi,Ft]);return ld(t,e.calcOwnMatrix()),i}return{}}_setSVGObject(t,e,i){const s=this._realizeGroupTransformOnObject(e);super._setSVGObject(t,e,i),e.set(s)}}_(Kr,"ownDefaults",{uniformScaling:!0,uniScaleKey:"shiftKey",centeredScaling:!1,centeredRotation:!1,centeredKey:"altKey",altActionKey:"shiftKey",selection:!0,selectionKey:"shiftKey",selectionColor:"rgba(100, 100, 255, 0.3)",selectionDashArray:[],selectionBorderColor:"rgba(255, 255, 255, 0.3)",selectionLineWidth:1,selectionFullyContained:!1,hoverCursor:"move",moveCursor:"move",defaultCursor:"default",freeDrawingCursor:"crosshair",notAllowedCursor:"not-allowed",perPixelTargetFind:!1,targetFindTolerance:0,skipTargetFind:!1,stopContextMenu:!1,fireRightClick:!1,fireMiddleClick:!1,enablePointerEvents:!1,containerClass:"canvas-container",preserveObjectStacking:!1});class Yf{constructor(t){_(this,"targets",[]),_(this,"__disposer",void 0);const e=()=>{const{hiddenTextarea:s}=t.getActiveObject()||{};s&&s.focus()},i=t.upperCanvasEl;i.addEventListener("click",e),this.__disposer=()=>i.removeEventListener("click",e)}exitTextEditing(){this.target=void 0,this.targets.forEach(t=>{t.isEditing&&t.exitEditing()})}add(t){this.targets.push(t)}remove(t){this.unregister(t),Ki(this.targets,t)}register(t){this.target=t}unregister(t){t===this.target&&(this.target=void 0)}onMouseMove(t){var e;!((e=this.target)===null||e===void 0)&&e.isEditing&&this.target.updateSelectionOnMouseMove(t)}clear(){this.targets=[],this.target=void 0}dispose(){this.clear(),this.__disposer(),delete this.__disposer}}const Uf=["target","oldTarget","fireCanvas","e"],Gt={passive:!1},rs=(n,t)=>{const e=n.getViewportPoint(t),i=n.getScenePoint(t);return{viewportPoint:e,scenePoint:i,pointer:e,absolutePointer:i}},ai=function(n){for(var t=arguments.length,e=new Array(t>1?t-1:0),i=1;i<t;i++)e[i-1]=arguments[i];return n.addEventListener(...e)},te=function(n){for(var t=arguments.length,e=new Array(t>1?t-1:0),i=1;i<t;i++)e[i-1]=arguments[i];return n.removeEventListener(...e)},Gf={mouse:{in:"over",out:"out",targetIn:"mouseover",targetOut:"mouseout",canvasIn:"mouse:over",canvasOut:"mouse:out"},drag:{in:"enter",out:"leave",targetIn:"dragenter",targetOut:"dragleave",canvasIn:"drag:enter",canvasOut:"drag:leave"}};class Vo extends Kr{constructor(t){super(t,arguments.length>1&&arguments[1]!==void 0?arguments[1]:{}),_(this,"_isClick",void 0),_(this,"textEditingManager",new Yf(this)),["_onMouseDown","_onTouchStart","_onMouseMove","_onMouseUp","_onTouchEnd","_onResize","_onMouseWheel","_onMouseOut","_onMouseEnter","_onContextMenu","_onDoubleClick","_onDragStart","_onDragEnd","_onDragProgress","_onDragOver","_onDragEnter","_onDragLeave","_onDrop"].forEach(e=>{this[e]=this[e].bind(this)}),this.addOrRemove(ai,"add")}_getEventPrefix(){return this.enablePointerEvents?"pointer":"mouse"}addOrRemove(t,e){const i=this.upperCanvasEl,s=this._getEventPrefix();t(Sl(i),"resize",this._onResize),t(i,s+"down",this._onMouseDown),t(i,"".concat(s,"move"),this._onMouseMove,Gt),t(i,"".concat(s,"out"),this._onMouseOut),t(i,"".concat(s,"enter"),this._onMouseEnter),t(i,"wheel",this._onMouseWheel),t(i,"contextmenu",this._onContextMenu),t(i,"dblclick",this._onDoubleClick),t(i,"dragstart",this._onDragStart),t(i,"dragend",this._onDragEnd),t(i,"dragover",this._onDragOver),t(i,"dragenter",this._onDragEnter),t(i,"dragleave",this._onDragLeave),t(i,"drop",this._onDrop),this.enablePointerEvents||t(i,"touchstart",this._onTouchStart,Gt)}removeListeners(){this.addOrRemove(te,"remove");const t=this._getEventPrefix(),e=he(this.upperCanvasEl);te(e,"".concat(t,"up"),this._onMouseUp),te(e,"touchend",this._onTouchEnd,Gt),te(e,"".concat(t,"move"),this._onMouseMove,Gt),te(e,"touchmove",this._onMouseMove,Gt),clearTimeout(this._willAddMouseDown)}_onMouseWheel(t){this.__onMouseWheel(t)}_onMouseOut(t){const e=this._hoveredTarget,i=b({e:t},rs(this,t));this.fire("mouse:out",b(b({},i),{},{target:e})),this._hoveredTarget=void 0,e&&e.fire("mouseout",b({},i)),this._hoveredTargets.forEach(s=>{this.fire("mouse:out",b(b({},i),{},{target:s})),s&&s.fire("mouseout",b({},i))}),this._hoveredTargets=[]}_onMouseEnter(t){this._currentTransform||this.findTarget(t)||(this.fire("mouse:over",b({e:t},rs(this,t))),this._hoveredTarget=void 0,this._hoveredTargets=[])}_onDragStart(t){this._isClick=!1;const e=this.getActiveObject();if(e&&e.onDragStart(t)){this._dragSource=e;const i={e:t,target:e};return this.fire("dragstart",i),e.fire("dragstart",i),void ai(this.upperCanvasEl,"drag",this._onDragProgress)}bo(t)}_renderDragEffects(t,e,i){let s=!1;const r=this._dropTarget;r&&r!==e&&r!==i&&(r.clearContextTop(),s=!0),e==null||e.clearContextTop(),i!==e&&(i==null||i.clearContextTop());const o=this.contextTop;o.save(),o.transform(...this.viewportTransform),e&&(o.save(),e.transform(o),e.renderDragSourceEffect(t),o.restore(),s=!0),i&&(o.save(),i.transform(o),i.renderDropTargetEffect(t),o.restore(),s=!0),o.restore(),s&&(this.contextTopDirty=!0)}_onDragEnd(t){const e=!!t.dataTransfer&&t.dataTransfer.dropEffect!==Rt,i=e?this._activeObject:void 0,s={e:t,target:this._dragSource,subTargets:this.targets,dragSource:this._dragSource,didDrop:e,dropTarget:i};te(this.upperCanvasEl,"drag",this._onDragProgress),this.fire("dragend",s),this._dragSource&&this._dragSource.fire("dragend",s),delete this._dragSource,this._onMouseUp(t)}_onDragProgress(t){const e={e:t,target:this._dragSource,dragSource:this._dragSource,dropTarget:this._draggedoverTarget};this.fire("drag",e),this._dragSource&&this._dragSource.fire("drag",e)}findDragTargets(t){return this.targets=[],{target:this._searchPossibleTargets(this._objects,this.getViewportPoint(t)),targets:[...this.targets]}}_onDragOver(t){const e="dragover",{target:i,targets:s}=this.findDragTargets(t),r=this._dragSource,o={e:t,target:i,subTargets:s,dragSource:r,canDrop:!1,dropTarget:void 0};let a;this.fire(e,o),this._fireEnterLeaveEvents(i,o),i&&(i.canDrop(t)&&(a=i),i.fire(e,o));for(let l=0;l<s.length;l++){const c=s[l];c.canDrop(t)&&(a=c),c.fire(e,o)}this._renderDragEffects(t,r,a),this._dropTarget=a}_onDragEnter(t){const{target:e,targets:i}=this.findDragTargets(t),s={e:t,target:e,subTargets:i,dragSource:this._dragSource};this.fire("dragenter",s),this._fireEnterLeaveEvents(e,s)}_onDragLeave(t){const e={e:t,target:this._draggedoverTarget,subTargets:this.targets,dragSource:this._dragSource};this.fire("dragleave",e),this._fireEnterLeaveEvents(void 0,e),this._renderDragEffects(t,this._dragSource),this._dropTarget=void 0,this.targets=[],this._hoveredTargets=[]}_onDrop(t){const{target:e,targets:i}=this.findDragTargets(t),s=this._basicEventHandler("drop:before",b({e:t,target:e,subTargets:i,dragSource:this._dragSource},rs(this,t)));s.didDrop=!1,s.dropTarget=void 0,this._basicEventHandler("drop",s),this.fire("drop:after",s)}_onContextMenu(t){const e=this.findTarget(t),i=this.targets||[],s=this._basicEventHandler("contextmenu:before",{e:t,target:e,subTargets:i});return this.stopContextMenu&&bo(t),this._basicEventHandler("contextmenu",s),!1}_onDoubleClick(t){this._cacheTransformEventData(t),this._handleEvent(t,"dblclick"),this._resetTransformEventData()}getPointerId(t){const e=t.changedTouches;return e?e[0]&&e[0].identifier:this.enablePointerEvents?t.pointerId:-1}_isMainEvent(t){return t.isPrimary===!0||t.isPrimary!==!1&&(t.type==="touchend"&&t.touches.length===0||!t.changedTouches||t.changedTouches[0].identifier===this.mainTouchId)}_onTouchStart(t){let e=!this.allowTouchScrolling;const i=this._activeObject;this.mainTouchId===void 0&&(this.mainTouchId=this.getPointerId(t)),this.__onMouseDown(t),(this.isDrawingMode||i&&this._target===i)&&(e=!0),e&&t.preventDefault(),this._resetTransformEventData();const s=this.upperCanvasEl,r=this._getEventPrefix(),o=he(s);ai(o,"touchend",this._onTouchEnd,Gt),e&&ai(o,"touchmove",this._onMouseMove,Gt),te(s,"".concat(r,"down"),this._onMouseDown)}_onMouseDown(t){this.__onMouseDown(t),this._resetTransformEventData();const e=this.upperCanvasEl,i=this._getEventPrefix();te(e,"".concat(i,"move"),this._onMouseMove,Gt);const s=he(e);ai(s,"".concat(i,"up"),this._onMouseUp),ai(s,"".concat(i,"move"),this._onMouseMove,Gt)}_onTouchEnd(t){if(t.touches.length>0)return;this.__onMouseUp(t),this._resetTransformEventData(),delete this.mainTouchId;const e=this._getEventPrefix(),i=he(this.upperCanvasEl);te(i,"touchend",this._onTouchEnd,Gt),te(i,"touchmove",this._onMouseMove,Gt),this._willAddMouseDown&&clearTimeout(this._willAddMouseDown),this._willAddMouseDown=setTimeout(()=>{ai(this.upperCanvasEl,"".concat(e,"down"),this._onMouseDown),this._willAddMouseDown=0},400)}_onMouseUp(t){this.__onMouseUp(t),this._resetTransformEventData();const e=this.upperCanvasEl,i=this._getEventPrefix();if(this._isMainEvent(t)){const s=he(this.upperCanvasEl);te(s,"".concat(i,"up"),this._onMouseUp),te(s,"".concat(i,"move"),this._onMouseMove,Gt),ai(e,"".concat(i,"move"),this._onMouseMove,Gt)}}_onMouseMove(t){const e=this.getActiveObject();!this.allowTouchScrolling&&(!e||!e.shouldStartDragging(t))&&t.preventDefault&&t.preventDefault(),this.__onMouseMove(t)}_onResize(){this.calcOffset(),this._resetTransformEventData()}_shouldRender(t){const e=this.getActiveObject();return!!e!=!!t||e&&t&&e!==t}__onMouseUp(t){var e;this._cacheTransformEventData(t),this._handleEvent(t,"up:before");const i=this._currentTransform,s=this._isClick,r=this._target,{button:o}=t;if(o)return(this.fireMiddleClick&&o===1||this.fireRightClick&&o===2)&&this._handleEvent(t,"up"),void this._resetTransformEventData();if(this.isDrawingMode&&this._isCurrentlyDrawing)return void this._onMouseUpInDrawingMode(t);if(!this._isMainEvent(t))return;let a,l,c=!1;if(i&&(this._finalizeCurrentTransform(t),c=i.actionPerformed),!s){const h=r===this._activeObject;this.handleSelection(t),c||(c=this._shouldRender(r)||!h&&r===this._activeObject)}if(r){const h=r.findControl(this.getViewportPoint(t),_o(t)),{key:u,control:d}=h||{};if(l=u,r.selectable&&r!==this._activeObject&&r.activeOn==="up")this.setActiveObject(r,t),c=!0;else if(d){const f=d.getMouseUpHandler(t,r,d);f&&(a=this.getScenePoint(t),f.call(d,t,i,a.x,a.y))}r.isMoving=!1}if(i&&(i.target!==r||i.corner!==l)){const h=i.target&&i.target.controls[i.corner],u=h&&h.getMouseUpHandler(t,i.target,h);a=a||this.getScenePoint(t),u&&u.call(h,t,i,a.x,a.y)}this._setCursorFromEvent(t,r),this._handleEvent(t,"up"),this._groupSelector=null,this._currentTransform=null,r&&(r.__corner=void 0),c?this.requestRenderAll():s||(e=this._activeObject)!==null&&e!==void 0&&e.isEditing||this.renderTop()}_basicEventHandler(t,e){const{target:i,subTargets:s=[]}=e;this.fire(t,e),i&&i.fire(t,e);for(let r=0;r<s.length;r++)s[r]!==i&&s[r].fire(t,e);return e}_handleEvent(t,e){const i=this._target,s=this.targets||[],r=b(b({e:t,target:i,subTargets:s},rs(this,t)),{},{transform:this._currentTransform},e==="up:before"||e==="up"?{isClick:this._isClick,currentTarget:this.findTarget(t),currentSubTargets:this.targets}:{});this.fire("mouse:".concat(e),r),i&&i.fire("mouse".concat(e),r);for(let o=0;o<s.length;o++)s[o]!==i&&s[o].fire("mouse".concat(e),r)}_onMouseDownInDrawingMode(t){this._isCurrentlyDrawing=!0,this.getActiveObject()&&(this.discardActiveObject(t),this.requestRenderAll());const e=this.getScenePoint(t);this.freeDrawingBrush&&this.freeDrawingBrush.onMouseDown(e,{e:t,pointer:e}),this._handleEvent(t,"down")}_onMouseMoveInDrawingMode(t){if(this._isCurrentlyDrawing){const e=this.getScenePoint(t);this.freeDrawingBrush&&this.freeDrawingBrush.onMouseMove(e,{e:t,pointer:e})}this.setCursor(this.freeDrawingCursor),this._handleEvent(t,"move")}_onMouseUpInDrawingMode(t){const e=this.getScenePoint(t);this.freeDrawingBrush?this._isCurrentlyDrawing=!!this.freeDrawingBrush.onMouseUp({e:t,pointer:e}):this._isCurrentlyDrawing=!1,this._handleEvent(t,"up")}__onMouseDown(t){this._isClick=!0,this._cacheTransformEventData(t),this._handleEvent(t,"down:before");let e=this._target;const{button:i}=t;if(i)return(this.fireMiddleClick&&i===1||this.fireRightClick&&i===2)&&this._handleEvent(t,"down"),void this._resetTransformEventData();if(this.isDrawingMode)return void this._onMouseDownInDrawingMode(t);if(!this._isMainEvent(t)||this._currentTransform)return;let s=this._shouldRender(e),r=!1;if(this.handleMultiSelection(t,e)?(e=this._activeObject,r=!0,s=!0):this._shouldClearSelection(t,e)&&this.discardActiveObject(t),this.selection&&(!e||!e.selectable&&!e.isEditing&&e!==this._activeObject)){const o=this.getScenePoint(t);this._groupSelector={x:o.x,y:o.y,deltaY:0,deltaX:0}}if(e){const o=e===this._activeObject;e.selectable&&e.activeOn==="down"&&this.setActiveObject(e,t);const a=e.findControl(this.getViewportPoint(t),_o(t));if(e===this._activeObject&&(a||!r)){this._setupCurrentTransform(t,e,o);const l=a?a.control:void 0,c=this.getScenePoint(t),h=l&&l.getMouseDownHandler(t,e,l);h&&h.call(l,t,this._currentTransform,c.x,c.y)}}s&&(this._objectsToRender=void 0),this._handleEvent(t,"down"),s&&this.requestRenderAll()}_resetTransformEventData(){this._target=this._pointer=this._absolutePointer=void 0}_cacheTransformEventData(t){this._resetTransformEventData(),this._pointer=this.getViewportPoint(t),this._absolutePointer=Zi(this._pointer,void 0,this.viewportTransform),this._target=this._currentTransform?this._currentTransform.target:this.findTarget(t)}__onMouseMove(t){if(this._isClick=!1,this._cacheTransformEventData(t),this._handleEvent(t,"move:before"),this.isDrawingMode)return void this._onMouseMoveInDrawingMode(t);if(!this._isMainEvent(t))return;const e=this._groupSelector;if(e){const i=this.getScenePoint(t);e.deltaX=i.x-e.x,e.deltaY=i.y-e.y,this.renderTop()}else if(this._currentTransform)this._transformObject(t);else{const i=this.findTarget(t);this._setCursorFromEvent(t,i),this._fireOverOutEvents(t,i)}this.textEditingManager.onMouseMove(t),this._handleEvent(t,"move"),this._resetTransformEventData()}_fireOverOutEvents(t,e){const i=this._hoveredTarget,s=this._hoveredTargets,r=this.targets,o=Math.max(s.length,r.length);this.fireSyntheticInOutEvents("mouse",{e:t,target:e,oldTarget:i,fireCanvas:!0});for(let a=0;a<o;a++)this.fireSyntheticInOutEvents("mouse",{e:t,target:r[a],oldTarget:s[a]});this._hoveredTarget=e,this._hoveredTargets=this.targets.concat()}_fireEnterLeaveEvents(t,e){const i=this._draggedoverTarget,s=this._hoveredTargets,r=this.targets,o=Math.max(s.length,r.length);this.fireSyntheticInOutEvents("drag",b(b({},e),{},{target:t,oldTarget:i,fireCanvas:!0}));for(let a=0;a<o;a++)this.fireSyntheticInOutEvents("drag",b(b({},e),{},{target:r[a],oldTarget:s[a]}));this._draggedoverTarget=t}fireSyntheticInOutEvents(t,e){let{target:i,oldTarget:s,fireCanvas:r,e:o}=e,a=rt(e,Uf);const{targetIn:l,targetOut:c,canvasIn:h,canvasOut:u}=Gf[t],d=s!==i;if(s&&d){const f=b(b({},a),{},{e:o,target:s,nextTarget:i},rs(this,o));r&&this.fire(u,f),s.fire(c,f)}if(i&&d){const f=b(b({},a),{},{e:o,target:i,previousTarget:s},rs(this,o));r&&this.fire(h,f),i.fire(l,f)}}__onMouseWheel(t){this._cacheTransformEventData(t),this._handleEvent(t,"wheel"),this._resetTransformEventData()}_transformObject(t){const e=this.getScenePoint(t),i=this._currentTransform,s=i.target,r=s.group?Zi(e,void 0,s.group.calcTransformMatrix()):e;i.shiftKey=t.shiftKey,i.altKey=!!this.centeredKey&&t[this.centeredKey],this._performTransformAction(t,i,r),i.actionPerformed&&this.requestRenderAll()}_performTransformAction(t,e,i){const{action:s,actionHandler:r,target:o}=e,a=!!r&&r(t,e,i.x,i.y);a&&o.setCoords(),s==="drag"&&a&&(e.target.isMoving=!0,this.setCursor(e.target.moveCursor||this.moveCursor)),e.actionPerformed=e.actionPerformed||a}_setCursorFromEvent(t,e){if(!e)return void this.setCursor(this.defaultCursor);let i=e.hoverCursor||this.hoverCursor;const s=Ti(this._activeObject)?this._activeObject:null,r=(!s||e.group!==s)&&e.findControl(this.getViewportPoint(t));if(r){const o=r.control;this.setCursor(o.cursorStyleHandler(t,o,e))}else e.subTargetCheck&&this.targets.concat().reverse().map(o=>{i=o.hoverCursor||i}),this.setCursor(i)}handleMultiSelection(t,e){const i=this._activeObject,s=Ti(i);if(i&&this._isSelectionKeyPressed(t)&&this.selection&&e&&e.selectable&&(i!==e||s)&&(s||!e.isDescendantOf(i)&&!i.isDescendantOf(e))&&!e.onSelect({e:t})&&!i.getActiveControl()){if(s){const r=i.getObjects();if(e===i){const o=this.getViewportPoint(t);if(!(e=this.searchPossibleTargets(r,o)||this.searchPossibleTargets(this._objects,o))||!e.selectable)return!1}e.group===i?(i.remove(e),this._hoveredTarget=e,this._hoveredTargets=[...this.targets],i.size()===1&&this._setActiveObject(i.item(0),t)):(i.multiSelectAdd(e),this._hoveredTarget=i,this._hoveredTargets=[...this.targets]),this._fireSelectionEvents(r,t)}else{i.isEditing&&i.exitEditing();const r=new(F.getClass("ActiveSelection"))([],{canvas:this});r.multiSelectAdd(i,e),this._hoveredTarget=r,this._setActiveObject(r,t),this._fireSelectionEvents([i],t)}return!0}return!1}handleSelection(t){if(!this.selection||!this._groupSelector)return!1;const{x:e,y:i,deltaX:s,deltaY:r}=this._groupSelector,o=new C(e,i),a=o.add(new C(s,r)),l=o.min(a),c=o.max(a).subtract(l),h=this.collectObjects({left:l.x,top:l.y,width:c.x,height:c.y},{includeIntersecting:!this.selectionFullyContained}),u=o.eq(a)?h[0]?[h[0]]:[]:h.length>1?h.filter(d=>!d.onSelect({e:t})).reverse():h;if(u.length===1)this.setActiveObject(u[0],t);else if(u.length>1){const d=F.getClass("ActiveSelection");this.setActiveObject(new d(u,{canvas:this}),t)}return this._groupSelector=null,!0}clear(){this.textEditingManager.clear(),super.clear()}destroy(){this.removeListeners(),this.textEditingManager.dispose(),super.destroy()}}const bc={x1:0,y1:0,x2:0,y2:0},Xf=b(b({},bc),{},{r1:0,r2:0}),ns=(n,t)=>isNaN(n)&&typeof t=="number"?t:n,Kf=/^(\d+\.\d+)%|(\d+)%$/;function yc(n){return n&&Kf.test(n)}function xc(n,t){const e=typeof n=="number"?n:typeof n=="string"?parseFloat(n)/(yc(n)?100:1):NaN;return Qi(0,ns(e,t),1)}const qf=/\s*;\s*/,Jf=/\s*:\s*/;function Zf(n,t){let e,i;const s=n.getAttribute("style");if(s){const o=s.split(qf);o[o.length-1]===""&&o.pop();for(let a=o.length;a--;){const[l,c]=o[a].split(Jf).map(h=>h.trim());l==="stop-color"?e=c:l==="stop-opacity"&&(i=c)}}const r=new tt(e||n.getAttribute("stop-color")||"rgb(0,0,0)");return{offset:xc(n.getAttribute("offset"),0),color:r.toRgb(),opacity:ns(parseFloat(i||n.getAttribute("stop-opacity")||""),1)*r.getAlpha()*t}}function Qf(n,t){const e=[],i=n.getElementsByTagName("stop"),s=xc(t,1);for(let r=i.length;r--;)e.push(Zf(i[r],s));return e}function Cc(n){return n.nodeName==="linearGradient"||n.nodeName==="LINEARGRADIENT"?"linear":"radial"}function Sc(n){return n.getAttribute("gradientUnits")==="userSpaceOnUse"?"pixels":"percentage"}function fe(n,t){return n.getAttribute(t)}function tg(n,t){return function(e,i){let s,{width:r,height:o,gradientUnits:a}=i;return Object.keys(e).reduce((l,c)=>{const h=e[c];return h==="Infinity"?s=1:h==="-Infinity"?s=0:(s=typeof h=="string"?parseFloat(h):h,typeof h=="string"&&yc(h)&&(s*=.01,a==="pixels"&&(c!=="x1"&&c!=="x2"&&c!=="r2"||(s*=r),c!=="y1"&&c!=="y2"||(s*=o)))),l[c]=s,l},{})}(Cc(n)==="linear"?function(e){return{x1:fe(e,"x1")||0,y1:fe(e,"y1")||0,x2:fe(e,"x2")||"100%",y2:fe(e,"y2")||0}}(n):function(e){return{x1:fe(e,"fx")||fe(e,"cx")||"50%",y1:fe(e,"fy")||fe(e,"cy")||"50%",r1:0,x2:fe(e,"cx")||"50%",y2:fe(e,"cy")||"50%",r2:fe(e,"r")||"50%"}}(n),b(b({},t),{},{gradientUnits:Sc(n)}))}class qr{constructor(t){const{type:e="linear",gradientUnits:i="pixels",coords:s={},colorStops:r=[],offsetX:o=0,offsetY:a=0,gradientTransform:l,id:c}=t||{};Object.assign(this,{type:e,gradientUnits:i,coords:b(b({},e==="radial"?Xf:bc),s),colorStops:r,offsetX:o,offsetY:a,gradientTransform:l,id:c?"".concat(c,"_").concat(ni()):ni()})}addColorStop(t){for(const e in t){const i=new tt(t[e]);this.colorStops.push({offset:parseFloat(e),color:i.toRgb(),opacity:i.getAlpha()})}return this}toObject(t){return b(b({},qi(this,t)),{},{type:this.type,coords:b({},this.coords),colorStops:this.colorStops.map(e=>b({},e)),offsetX:this.offsetX,offsetY:this.offsetY,gradientUnits:this.gradientUnits,gradientTransform:this.gradientTransform?[...this.gradientTransform]:void 0})}toSVG(t){let{additionalTransform:e}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};const i=[],s=this.gradientTransform?this.gradientTransform.concat():Pt.concat(),r=this.gradientUnits==="pixels"?"userSpaceOnUse":"objectBoundingBox",o=this.colorStops.map(u=>b({},u)).sort((u,d)=>u.offset-d.offset);let a=-this.offsetX,l=-this.offsetY;var c;r==="objectBoundingBox"?(a/=t.width,l/=t.height):(a+=t.width/2,l+=t.height/2),(c=t)&&typeof c._renderPathCommands=="function"&&this.gradientUnits!=="percentage"&&(a-=t.pathOffset.x,l-=t.pathOffset.y),s[4]-=a,s[5]-=l;const h=['id="SVGID_'.concat(this.id,'"'),'gradientUnits="'.concat(r,'"'),'gradientTransform="'.concat(e?e+" ":"").concat(Rr(s),'"'),""].join(" ");if(this.type==="linear"){const{x1:u,y1:d,x2:f,y2:g}=this.coords;i.push("<linearGradient ",h,' x1="',u,'" y1="',d,'" x2="',f,'" y2="',g,`">
168
- `)}else if(this.type==="radial"){const{x1:u,y1:d,x2:f,y2:g,r1:p,r2:m}=this.coords,v=p>m;i.push("<radialGradient ",h,' cx="',v?u:f,'" cy="',v?d:g,'" r="',v?p:m,'" fx="',v?f:u,'" fy="',v?g:d,`">
169
- `),v&&(o.reverse(),o.forEach(x=>{x.offset=1-x.offset}));const y=Math.min(p,m);if(y>0){const x=y/Math.max(p,m);o.forEach(E=>{E.offset+=x*(1-E.offset)})}}return o.forEach(u=>{let{color:d,offset:f,opacity:g}=u;i.push("<stop ",'offset="',100*f+"%",'" style="stop-color:',d,g!==void 0?";stop-opacity: "+g:";",`"/>
170
- `)}),i.push(this.type==="linear"?"</linearGradient>":"</radialGradient>",`
171
- `),i.join("")}toLive(t){const{x1:e,y1:i,x2:s,y2:r,r1:o,r2:a}=this.coords,l=this.type==="linear"?t.createLinearGradient(e,i,s,r):t.createRadialGradient(e,i,o,s,r,a);return this.colorStops.forEach(c=>{let{color:h,opacity:u,offset:d}=c;l.addColorStop(d,u!==void 0?new tt(h).setAlpha(u).toRgba():h)}),l}static async fromObject(t){const{colorStops:e,gradientTransform:i}=t;return new this(b(b({},t),{},{colorStops:e?e.map(s=>b({},s)):void 0,gradientTransform:i?[...i]:void 0}))}static fromElement(t,e,i){const s=Sc(t),r=e._findCenterFromElement();return new this(b({id:t.getAttribute("id")||void 0,type:Cc(t),coords:tg(t,{width:i.viewBoxWidth||i.width,height:i.viewBoxHeight||i.height}),colorStops:Qf(t,i.opacity),gradientUnits:s,gradientTransform:Fo(t.getAttribute("gradientTransform")||"")},s==="pixels"?{offsetX:e.width/2-r.x,offsetY:e.height/2-r.y}:{offsetX:0,offsetY:0}))}}_(qr,"type","Gradient"),F.setClass(qr,"gradient"),F.setClass(qr,"linear"),F.setClass(qr,"radial");const eg=["type","source","patternTransform"];class zo{get type(){return"pattern"}set type(t){si("warn","Setting type has no effect",t)}constructor(t){_(this,"repeat","repeat"),_(this,"offsetX",0),_(this,"offsetY",0),_(this,"crossOrigin",""),this.id=ni(),Object.assign(this,t)}isImageSource(){return!!this.source&&typeof this.source.src=="string"}isCanvasSource(){return!!this.source&&!!this.source.toDataURL}sourceToString(){return this.isImageSource()?this.source.src:this.isCanvasSource()?this.source.toDataURL():""}toLive(t){return this.source&&(!this.isImageSource()||this.source.complete&&this.source.naturalWidth!==0&&this.source.naturalHeight!==0)?t.createPattern(this.source,this.repeat):null}toObject(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[];const{repeat:e,crossOrigin:i}=this;return b(b({},qi(this,t)),{},{type:"pattern",source:this.sourceToString(),repeat:e,crossOrigin:i,offsetX:lt(this.offsetX,J.NUM_FRACTION_DIGITS),offsetY:lt(this.offsetY,J.NUM_FRACTION_DIGITS),patternTransform:this.patternTransform?[...this.patternTransform]:null})}toSVG(t){let{width:e,height:i}=t;const{source:s,repeat:r,id:o}=this,a=ns(this.offsetX/e,0),l=ns(this.offsetY/i,0),c=r==="repeat-y"||r==="no-repeat"?1+Math.abs(a||0):ns(s.width/e,0),h=r==="repeat-x"||r==="no-repeat"?1+Math.abs(l||0):ns(s.height/i,0);return['<pattern id="SVGID_'.concat(o,'" x="').concat(a,'" y="').concat(l,'" width="').concat(c,'" height="').concat(h,'">'),'<image x="0" y="0" width="'.concat(s.width,'" height="').concat(s.height,'" xlink:href="').concat(this.sourceToString(),'"></image>'),"</pattern>",""].join(`
172
- `)}static async fromObject(t,e){let{type:i,source:s,patternTransform:r}=t,o=rt(t,eg);const a=await Lr(s,b(b({},e),{},{crossOrigin:o.crossOrigin}));return new this(b(b({},o),{},{patternTransform:r&&r.slice(0),source:a}))}}_(zo,"type","Pattern"),F.setClass(zo),F.setClass(zo,"pattern");const ig=["path","left","top"],sg=["d"];class Ai extends Ot{constructor(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},{path:i,left:s,top:r}=e,o=rt(e,ig);super(),Object.assign(this,Ai.ownDefaults),this.setOptions(o),this._setPath(t||[],!0),typeof s=="number"&&this.set(Q,s),typeof r=="number"&&this.set(Ft,r)}_setPath(t,e){this.path=If(Array.isArray(t)?t:zf(t)),this.setBoundingBox(e)}_findCenterFromElement(){const t=this._calcBoundsFromPath();return new C(t.left+t.width/2,t.top+t.height/2)}_renderPathCommands(t){const e=-this.pathOffset.x,i=-this.pathOffset.y;t.beginPath();for(const s of this.path)switch(s[0]){case"L":t.lineTo(s[1]+e,s[2]+i);break;case"M":t.moveTo(s[1]+e,s[2]+i);break;case"C":t.bezierCurveTo(s[1]+e,s[2]+i,s[3]+e,s[4]+i,s[5]+e,s[6]+i);break;case"Q":t.quadraticCurveTo(s[1]+e,s[2]+i,s[3]+e,s[4]+i);break;case"Z":t.closePath()}}_render(t){this._renderPathCommands(t),this._renderPaintInOrder(t)}toString(){return"#<Path (".concat(this.complexity(),'): { "top": ').concat(this.top,', "left": ').concat(this.left," }>")}toObject(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[];return b(b({},super.toObject(t)),{},{path:this.path.map(e=>e.slice())})}toDatalessObject(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[];const e=this.toObject(t);return this.sourcePath&&(delete e.path,e.sourcePath=this.sourcePath),e}_toSVG(){const t=Hf(this.path,J.NUM_FRACTION_DIGITS);return["<path ","COMMON_PARTS",'d="'.concat(t,`" stroke-linecap="round" />
173
- `)]}_getOffsetTransform(){const t=J.NUM_FRACTION_DIGITS;return" translate(".concat(lt(-this.pathOffset.x,t),", ").concat(lt(-this.pathOffset.y,t),")")}toClipPathSVG(t){const e=this._getOffsetTransform();return" "+this._createBaseClipPathSVGMarkup(this._toSVG(),{reviver:t,additionalTransform:e})}toSVG(t){const e=this._getOffsetTransform();return this._createBaseSVGMarkup(this._toSVG(),{reviver:t,additionalTransform:e})}complexity(){return this.path.length}setDimensions(){this.setBoundingBox()}setBoundingBox(t){const{width:e,height:i,pathOffset:s}=this._calcDimensions();this.set({width:e,height:i,pathOffset:s}),t&&this.setPositionByOrigin(s,G,G)}_calcBoundsFromPath(){const t=[];let e=0,i=0,s=0,r=0;for(const o of this.path)switch(o[0]){case"L":s=o[1],r=o[2],t.push({x:e,y:i},{x:s,y:r});break;case"M":s=o[1],r=o[2],e=s,i=r;break;case"C":t.push(...uc(s,r,o[1],o[2],o[3],o[4],o[5],o[6])),s=o[5],r=o[6];break;case"Q":t.push(...uc(s,r,o[1],o[2],o[1],o[2],o[3],o[4])),s=o[3],r=o[4];break;case"Z":s=e,r=i}return Le(t)}_calcDimensions(){const t=this._calcBoundsFromPath();return b(b({},t),{},{pathOffset:new C(t.left+t.width/2,t.top+t.height/2)})}static fromObject(t){return this._fromObject(t,{extraParam:"path"})}static async fromElement(t,e,i){const s=Ne(t,this.ATTRIBUTE_NAMES,i),{d:r}=s;return new this(r,b(b(b({},rt(s,sg)),e),{},{left:void 0,top:void 0}))}}_(Ai,"type","Path"),_(Ai,"cacheProperties",[...Fe,"path","fillRule"]),_(Ai,"ATTRIBUTE_NAMES",[...oi,"d"]),F.setClass(Ai),F.setSVGClass(Ai);const rg=["left","top","radius"],wc=["radius","startAngle","endAngle","counterClockwise"];class $e extends Ot{static getDefaults(){return b(b({},super.getDefaults()),$e.ownDefaults)}constructor(t){super(),Object.assign(this,$e.ownDefaults),this.setOptions(t)}_set(t,e){return super._set(t,e),t==="radius"&&this.setRadius(e),this}_render(t){t.beginPath(),t.arc(0,0,this.radius,ft(this.startAngle),ft(this.endAngle),this.counterClockwise),this._renderPaintInOrder(t)}getRadiusX(){return this.get("radius")*this.get(Nt)}getRadiusY(){return this.get("radius")*this.get(Zt)}setRadius(t){this.radius=t,this.set({width:2*t,height:2*t})}toObject(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[];return super.toObject([...wc,...t])}_toSVG(){const t=(this.endAngle-this.startAngle)%360;if(t===0)return["<circle ","COMMON_PARTS",'cx="0" cy="0" ','r="',"".concat(this.radius),`" />
174
- `];{const{radius:e}=this,i=ft(this.startAngle),s=ft(this.endAngle),r=Pe(i)*e,o=Ie(i)*e,a=Pe(s)*e,l=Ie(s)*e,c=t>180?1:0,h=this.counterClockwise?0:1;return['<path d="M '.concat(r," ").concat(o," A ").concat(e," ").concat(e," 0 ").concat(c," ").concat(h," ").concat(a," ").concat(l,'" '),"COMMON_PARTS",` />
175
- `]}}static async fromElement(t,e,i){const s=Ne(t,this.ATTRIBUTE_NAMES,i),{left:r=0,top:o=0,radius:a=0}=s;return new this(b(b({},rt(s,rg)),{},{radius:a,left:r-a,top:o-a}))}static fromObject(t){return super._fromObject(t)}}_($e,"type","Circle"),_($e,"cacheProperties",[...Fe,...wc]),_($e,"ownDefaults",{radius:0,startAngle:0,endAngle:360,counterClockwise:!1}),_($e,"ATTRIBUTE_NAMES",["cx","cy","r",...oi]),F.setClass($e),F.setSVGClass($e);const ng=["x1","y1","x2","y2"],og=["x1","y1","x2","y2"],Ho=["x1","x2","y1","y2"];class Di extends Ot{constructor(){let[t,e,i,s]=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[0,0,0,0],r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};super(),Object.assign(this,Di.ownDefaults),this.setOptions(r),this.x1=t,this.x2=i,this.y1=e,this.y2=s,this._setWidthHeight();const{left:o,top:a}=r;typeof o=="number"&&this.set(Q,o),typeof a=="number"&&this.set(Ft,a)}_setWidthHeight(){const{x1:t,y1:e,x2:i,y2:s}=this;this.width=Math.abs(i-t),this.height=Math.abs(s-e);const{left:r,top:o,width:a,height:l}=Le([{x:t,y:e},{x:i,y:s}]),c=new C(r+a/2,o+l/2);this.setPositionByOrigin(c,G,G)}_set(t,e){return super._set(t,e),Ho.includes(t)&&this._setWidthHeight(),this}_render(t){t.beginPath();const e=this.calcLinePoints();t.moveTo(e.x1,e.y1),t.lineTo(e.x2,e.y2),t.lineWidth=this.strokeWidth;const i=t.strokeStyle;var s;Qt(this.stroke)?t.strokeStyle=this.stroke.toLive(t):t.strokeStyle=(s=this.stroke)!==null&&s!==void 0?s:t.fillStyle,this.stroke&&this._renderStroke(t),t.strokeStyle=i}_findCenterFromElement(){return new C((this.x1+this.x2)/2,(this.y1+this.y2)/2)}toObject(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[];return b(b({},super.toObject(t)),this.calcLinePoints())}_getNonTransformedDimensions(){const t=super._getNonTransformedDimensions();return this.strokeLineCap==="butt"&&(this.width===0&&(t.y-=this.strokeWidth),this.height===0&&(t.x-=this.strokeWidth)),t}calcLinePoints(){const{x1:t,x2:e,y1:i,y2:s,width:r,height:o}=this,a=t<=e?-1:1,l=i<=s?-1:1;return{x1:a*r/2,x2:a*-r/2,y1:l*o/2,y2:l*-o/2}}_toSVG(){const{x1:t,x2:e,y1:i,y2:s}=this.calcLinePoints();return["<line ","COMMON_PARTS",'x1="'.concat(t,'" y1="').concat(i,'" x2="').concat(e,'" y2="').concat(s,`" />
176
- `)]}static async fromElement(t,e,i){const s=Ne(t,this.ATTRIBUTE_NAMES,i),{x1:r=0,y1:o=0,x2:a=0,y2:l=0}=s;return new this([r,o,a,l],rt(s,ng))}static fromObject(t){let{x1:e,y1:i,x2:s,y2:r}=t,o=rt(t,og);return this._fromObject(b(b({},o),{},{points:[e,i,s,r]}),{extraParam:"points"})}}_(Di,"type","Line"),_(Di,"cacheProperties",[...Fe,...Ho]),_(Di,"ATTRIBUTE_NAMES",oi.concat(Ho)),F.setClass(Di),F.setSVGClass(Di);class ki extends Ot{static getDefaults(){return b(b({},super.getDefaults()),ki.ownDefaults)}constructor(t){super(),Object.assign(this,ki.ownDefaults),this.setOptions(t)}_render(t){const e=this.width/2,i=this.height/2;t.beginPath(),t.moveTo(-e,i),t.lineTo(0,-i),t.lineTo(e,i),t.closePath(),this._renderPaintInOrder(t)}_toSVG(){const t=this.width/2,e=this.height/2;return["<polygon ","COMMON_PARTS",'points="',"".concat(-t," ").concat(e,",0 ").concat(-e,",").concat(t," ").concat(e),'" />']}}_(ki,"type","Triangle"),_(ki,"ownDefaults",{width:100,height:100}),F.setClass(ki),F.setSVGClass(ki);const Tc=["rx","ry"];class Ve extends Ot{static getDefaults(){return b(b({},super.getDefaults()),Ve.ownDefaults)}constructor(t){super(),Object.assign(this,Ve.ownDefaults),this.setOptions(t)}_set(t,e){switch(super._set(t,e),t){case"rx":this.rx=e,this.set("width",2*e);break;case"ry":this.ry=e,this.set("height",2*e)}return this}getRx(){return this.get("rx")*this.get(Nt)}getRy(){return this.get("ry")*this.get(Zt)}toObject(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[];return super.toObject([...Tc,...t])}_toSVG(){return["<ellipse ","COMMON_PARTS",'cx="0" cy="0" rx="'.concat(this.rx,'" ry="').concat(this.ry,`" />
177
- `)]}_render(t){t.beginPath(),t.save(),t.transform(1,0,0,this.ry/this.rx,0,0),t.arc(0,0,this.rx,0,wr,!1),t.restore(),this._renderPaintInOrder(t)}static async fromElement(t,e,i){const s=Ne(t,this.ATTRIBUTE_NAMES,i);return s.left=(s.left||0)-s.rx,s.top=(s.top||0)-s.ry,new this(s)}}function ag(n){if(!n)return[];const t=n.replace(/,/g," ").trim().split(/\s+/),e=[];for(let i=0;i<t.length;i+=2)e.push({x:parseFloat(t[i]),y:parseFloat(t[i+1])});return e}_(Ve,"type","Ellipse"),_(Ve,"cacheProperties",[...Fe,...Tc]),_(Ve,"ownDefaults",{rx:0,ry:0}),_(Ve,"ATTRIBUTE_NAMES",[...oi,"cx","cy","rx","ry"]),F.setClass(Ve),F.setSVGClass(Ve);const lg=["left","top"],Ec={exactBoundingBox:!1};class ge extends Ot{static getDefaults(){return b(b({},super.getDefaults()),ge.ownDefaults)}constructor(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[],e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};super(),_(this,"strokeDiff",void 0),Object.assign(this,ge.ownDefaults),this.setOptions(e),this.points=t;const{left:i,top:s}=e;this.initialized=!0,this.setBoundingBox(!0),typeof i=="number"&&this.set(Q,i),typeof s=="number"&&this.set(Ft,s)}isOpen(){return!0}_projectStrokeOnPoints(t){return qd(this.points,t,this.isOpen())}_calcDimensions(t){t=b({scaleX:this.scaleX,scaleY:this.scaleY,skewX:this.skewX,skewY:this.skewY,strokeLineCap:this.strokeLineCap,strokeLineJoin:this.strokeLineJoin,strokeMiterLimit:this.strokeMiterLimit,strokeUniform:this.strokeUniform,strokeWidth:this.strokeWidth},t||{});const e=this.exactBoundingBox?this._projectStrokeOnPoints(t).map(c=>c.projectedPoint):this.points;if(e.length===0)return{left:0,top:0,width:0,height:0,pathOffset:new C,strokeOffset:new C,strokeDiff:new C};const i=Le(e),s=Ir(b(b({},t),{},{scaleX:1,scaleY:1})),r=Le(this.points.map(c=>$t(c,s,!0))),o=new C(this.scaleX,this.scaleY);let a=i.left+i.width/2,l=i.top+i.height/2;return this.exactBoundingBox&&(a-=l*Math.tan(ft(this.skewX)),l-=a*Math.tan(ft(this.skewY))),b(b({},i),{},{pathOffset:new C(a,l),strokeOffset:new C(r.left,r.top).subtract(new C(i.left,i.top)).multiply(o),strokeDiff:new C(i.width,i.height).subtract(new C(r.width,r.height)).multiply(o)})}_findCenterFromElement(){const t=Le(this.points);return new C(t.left+t.width/2,t.top+t.height/2)}setDimensions(){this.setBoundingBox()}setBoundingBox(t){const{left:e,top:i,width:s,height:r,pathOffset:o,strokeOffset:a,strokeDiff:l}=this._calcDimensions();this.set({width:s,height:r,pathOffset:o,strokeOffset:a,strokeDiff:l}),t&&this.setPositionByOrigin(new C(e+s/2,i+r/2),G,G)}isStrokeAccountedForInDimensions(){return this.exactBoundingBox}_getNonTransformedDimensions(){return this.exactBoundingBox?new C(this.width,this.height):super._getNonTransformedDimensions()}_getTransformedDimensions(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(this.exactBoundingBox){let o;if(Object.keys(t).some(a=>this.strokeUniform||this.constructor.layoutProperties.includes(a))){var e,i;const{width:a,height:l}=this._calcDimensions(t);o=new C((e=t.width)!==null&&e!==void 0?e:a,(i=t.height)!==null&&i!==void 0?i:l)}else{var s,r;o=new C((s=t.width)!==null&&s!==void 0?s:this.width,(r=t.height)!==null&&r!==void 0?r:this.height)}return o.multiply(new C(t.scaleX||this.scaleX,t.scaleY||this.scaleY))}return super._getTransformedDimensions(t)}_set(t,e){const i=this.initialized&&this[t]!==e,s=super._set(t,e);return this.exactBoundingBox&&i&&((t===Nt||t===Zt)&&this.strokeUniform&&this.constructor.layoutProperties.includes("strokeUniform")||this.constructor.layoutProperties.includes(t))&&this.setDimensions(),s}toObject(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[];return b(b({},super.toObject(t)),{},{points:this.points.map(e=>{let{x:i,y:s}=e;return{x:i,y:s}})})}_toSVG(){const t=[],e=this.pathOffset.x,i=this.pathOffset.y,s=J.NUM_FRACTION_DIGITS;for(let r=0,o=this.points.length;r<o;r++)t.push(lt(this.points[r].x-e,s),",",lt(this.points[r].y-i,s)," ");return["<".concat(this.constructor.type.toLowerCase()," "),"COMMON_PARTS",'points="'.concat(t.join(""),`" />
178
- `)]}_render(t){const e=this.points.length,i=this.pathOffset.x,s=this.pathOffset.y;if(e&&!isNaN(this.points[e-1].y)){t.beginPath(),t.moveTo(this.points[0].x-i,this.points[0].y-s);for(let r=0;r<e;r++){const o=this.points[r];t.lineTo(o.x-i,o.y-s)}!this.isOpen()&&t.closePath(),this._renderPaintInOrder(t)}}complexity(){return this.points.length}static async fromElement(t,e,i){return new this(ag(t.getAttribute("points")),b(b({},rt(Ne(t,this.ATTRIBUTE_NAMES,i),lg)),e))}static fromObject(t){return this._fromObject(t,{extraParam:"points"})}}_(ge,"ownDefaults",Ec),_(ge,"type","Polyline"),_(ge,"layoutProperties",[Ui,Gi,"strokeLineCap","strokeLineJoin","strokeMiterLimit","strokeWidth","strokeUniform","points"]),_(ge,"cacheProperties",[...Fe,"points"]),_(ge,"ATTRIBUTE_NAMES",[...oi]),F.setClass(ge),F.setSVGClass(ge);class Jr extends ge{isOpen(){return!1}}_(Jr,"ownDefaults",Ec),_(Jr,"type","Polygon"),F.setClass(Jr),F.setSVGClass(Jr);const Oc=["fontSize","fontWeight","fontFamily","fontStyle"],Ac=["underline","overline","linethrough"],Dc=[...Oc,"lineHeight","text","charSpacing","textAlign","styles","path","pathStartOffset","pathSide","pathAlign"],kc=[...Dc,...Ac,"textBackgroundColor","direction"],cg=[...Oc,...Ac,Bt,"strokeWidth",bt,"deltaY","textBackgroundColor"],hg={_reNewline:lo,_reSpacesAndTabs:/[ \t\r]/g,_reSpaceAndTab:/[ \t\r]/,_reWords:/\S+/g,fontSize:40,fontWeight:"normal",fontFamily:"Times New Roman",underline:!1,overline:!1,linethrough:!1,textAlign:Q,fontStyle:"normal",lineHeight:1.16,superscript:{size:.6,baseline:-.35},subscript:{size:.6,baseline:.11},textBackgroundColor:"",stroke:null,shadow:null,path:void 0,pathStartOffset:0,pathSide:Q,pathAlign:"baseline",_fontSizeFraction:.222,offsets:{underline:.1,linethrough:-.315,overline:-.88},_fontSizeMult:1.13,charSpacing:0,deltaY:0,direction:"ltr",CACHE_FONT_SIZE:400,MIN_TEXT_WIDTH:2},we="justify",Zr="justify-left",Vs="justify-right",zs="justify-center";class Mc extends Ot{isEmptyStyles(t){if(!this.styles||t!==void 0&&!this.styles[t])return!0;const e=t===void 0?this.styles:{line:this.styles[t]};for(const i in e)for(const s in e[i])for(const r in e[i][s])return!1;return!0}styleHas(t,e){if(!this.styles||e!==void 0&&!this.styles[e])return!1;const i=e===void 0?this.styles:{0:this.styles[e]};for(const s in i)for(const r in i[s])if(i[s][r][t]!==void 0)return!0;return!1}cleanStyle(t){if(!this.styles)return!1;const e=this.styles;let i,s,r=0,o=!0,a=0;for(const l in e){i=0;for(const c in e[l]){const h=e[l][c]||{};r++,h[t]!==void 0?(s?h[t]!==s&&(o=!1):s=h[t],h[t]===this[t]&&delete h[t]):o=!1,Object.keys(h).length!==0?i++:delete e[l][c]}i===0&&delete e[l]}for(let l=0;l<this._textLines.length;l++)a+=this._textLines[l].length;o&&r===a&&(this[t]=s,this.removeStyle(t))}removeStyle(t){if(!this.styles)return;const e=this.styles;let i,s,r;for(s in e){for(r in i=e[s],i)delete i[r][t],Object.keys(i[r]).length===0&&delete i[r];Object.keys(i).length===0&&delete e[s]}}_extendStyles(t,e){const{lineIndex:i,charIndex:s}=this.get2DCursorLocation(t);this._getLineStyle(i)||this._setLineStyle(i);const r=po(b(b({},this._getStyleDeclaration(i,s)),e),o=>o!==void 0);this._setStyleDeclaration(i,s,r)}getSelectionStyles(t,e,i){const s=[];for(let r=t;r<(e||t);r++)s.push(this.getStyleAtPosition(r,i));return s}getStyleAtPosition(t,e){const{lineIndex:i,charIndex:s}=this.get2DCursorLocation(t);return e?this.getCompleteStyleDeclaration(i,s):this._getStyleDeclaration(i,s)}setSelectionStyles(t,e,i){for(let s=e;s<(i||e);s++)this._extendStyles(s,t);this._forceClearCache=!0}_getStyleDeclaration(t,e){var i;const s=this.styles&&this.styles[t];return s&&(i=s[e])!==null&&i!==void 0?i:{}}getCompleteStyleDeclaration(t,e){return b(b({},qi(this,this.constructor._styleProperties)),this._getStyleDeclaration(t,e))}_setStyleDeclaration(t,e,i){this.styles[t][e]=i}_deleteStyleDeclaration(t,e){delete this.styles[t][e]}_getLineStyle(t){return!!this.styles[t]}_setLineStyle(t){this.styles[t]={}}_deleteLineStyle(t){delete this.styles[t]}}_(Mc,"_styleProperties",cg);const ug=/ +/g,dg=/"/g;function Wo(n,t,e,i,s){return" ".concat(function(r,o){let{left:a,top:l,width:c,height:h}=o,u=arguments.length>2&&arguments[2]!==void 0?arguments[2]:J.NUM_FRACTION_DIGITS;const d=Ls(bt,r,!1),[f,g,p,m]=[a,l,c,h].map(v=>lt(v,u));return"<rect ".concat(d,' x="').concat(f,'" y="').concat(g,'" width="').concat(p,'" height="').concat(m,'"></rect>')}(n,{left:t,top:e,width:i,height:s}),`
179
- `)}const fg=["textAnchor","textDecoration","dx","dy","top","left","fontSize","strokeWidth"];let Yo;class Lt extends Mc{static getDefaults(){return b(b({},super.getDefaults()),Lt.ownDefaults)}constructor(t,e){super(),_(this,"__charBounds",[]),Object.assign(this,Lt.ownDefaults),this.setOptions(e),this.styles||(this.styles={}),this.text=t,this.initialized=!0,this.path&&this.setPathInfo(),this.initDimensions(),this.setCoords()}setPathInfo(){const t=this.path;t&&(t.segmentsInfo=vc(t.path))}_splitText(){const t=this._splitTextIntoLines(this.text);return this.textLines=t.lines,this._textLines=t.graphemeLines,this._unwrappedTextLines=t._unwrappedLines,this._text=t.graphemeText,t}initDimensions(){this._splitText(),this._clearCache(),this.dirty=!0,this.path?(this.width=this.path.width,this.height=this.path.height):(this.width=this.calcTextWidth()||this.cursorWidth||this.MIN_TEXT_WIDTH,this.height=this.calcTextHeight()),this.textAlign.includes(we)&&this.enlargeSpaces()}enlargeSpaces(){let t,e,i,s,r,o,a;for(let l=0,c=this._textLines.length;l<c;l++)if((this.textAlign===we||l!==c-1&&!this.isEndOfWrapping(l))&&(s=0,r=this._textLines[l],e=this.getLineWidth(l),e<this.width&&(a=this.textLines[l].match(this._reSpacesAndTabs)))){i=a.length,t=(this.width-e)/i;for(let h=0;h<=r.length;h++)o=this.__charBounds[l][h],this._reSpaceAndTab.test(r[h])?(o.width+=t,o.kernedWidth+=t,o.left+=s,s+=t):o.left+=s}}isEndOfWrapping(t){return t===this._textLines.length-1}missingNewlineOffset(t){return 1}get2DCursorLocation(t,e){const i=e?this._unwrappedTextLines:this._textLines;let s;for(s=0;s<i.length;s++){if(t<=i[s].length)return{lineIndex:s,charIndex:t};t-=i[s].length+this.missingNewlineOffset(s,e)}return{lineIndex:s-1,charIndex:i[s-1].length<t?i[s-1].length:t}}toString(){return"#<Text (".concat(this.complexity(),'): { "text": "').concat(this.text,'", "fontFamily": "').concat(this.fontFamily,'" }>')}_getCacheCanvasDimensions(){const t=super._getCacheCanvasDimensions(),e=this.fontSize;return t.width+=e*t.zoomX,t.height+=e*t.zoomY,t}_render(t){const e=this.path;e&&!e.isNotVisible()&&e._render(t),this._setTextStyles(t),this._renderTextLinesBackground(t),this._renderTextDecoration(t,"underline"),this._renderText(t),this._renderTextDecoration(t,"overline"),this._renderTextDecoration(t,"linethrough")}_renderText(t){this.paintFirst===Bt?(this._renderTextStroke(t),this._renderTextFill(t)):(this._renderTextFill(t),this._renderTextStroke(t))}_setTextStyles(t,e,i){if(t.textBaseline="alphabetic",this.path)switch(this.pathAlign){case G:t.textBaseline="middle";break;case"ascender":t.textBaseline=Ft;break;case"descender":t.textBaseline=ao}t.font=this._getFontDeclaration(e,i)}calcTextWidth(){let t=this.getLineWidth(0);for(let e=1,i=this._textLines.length;e<i;e++){const s=this.getLineWidth(e);s>t&&(t=s)}return t}_renderTextLine(t,e,i,s,r,o){this._renderChars(t,e,i,s,r,o)}_renderTextLinesBackground(t){if(!this.textBackgroundColor&&!this.styleHas("textBackgroundColor"))return;const e=t.fillStyle,i=this._getLeftOffset();let s=this._getTopOffset();for(let r=0,o=this._textLines.length;r<o;r++){const a=this.getHeightOfLine(r);if(!this.textBackgroundColor&&!this.styleHas("textBackgroundColor",r)){s+=a;continue}const l=this._textLines[r].length,c=this._getLineLeftOffset(r);let h,u,d=0,f=0,g=this.getValueOfPropertyAt(r,0,"textBackgroundColor");for(let p=0;p<l;p++){const m=this.__charBounds[r][p];u=this.getValueOfPropertyAt(r,p,"textBackgroundColor"),this.path?(t.save(),t.translate(m.renderLeft,m.renderTop),t.rotate(m.angle),t.fillStyle=u,u&&t.fillRect(-m.width/2,-a/this.lineHeight*(1-this._fontSizeFraction),m.width,a/this.lineHeight),t.restore()):u!==g?(h=i+c+f,this.direction==="rtl"&&(h=this.width-h-d),t.fillStyle=g,g&&t.fillRect(h,s,d,a/this.lineHeight),f=m.left,d=m.width,g=u):d+=m.kernedWidth}u&&!this.path&&(h=i+c+f,this.direction==="rtl"&&(h=this.width-h-d),t.fillStyle=u,t.fillRect(h,s,d,a/this.lineHeight)),s+=a}t.fillStyle=e,this._removeShadow(t)}_measureChar(t,e,i,s){const r=As.getFontCache(e),o=this._getFontDeclaration(e),a=i+t,l=i&&o===this._getFontDeclaration(s),c=e.fontSize/this.CACHE_FONT_SIZE;let h,u,d,f;if(i&&r[i]!==void 0&&(d=r[i]),r[t]!==void 0&&(f=h=r[t]),l&&r[a]!==void 0&&(u=r[a],f=u-d),h===void 0||d===void 0||u===void 0){const g=function(){return Yo||(Yo=Ce({width:0,height:0}).getContext("2d")),Yo}();this._setTextStyles(g,e,!0),h===void 0&&(f=h=g.measureText(t).width,r[t]=h),d===void 0&&l&&i&&(d=g.measureText(i).width,r[i]=d),l&&u===void 0&&(u=g.measureText(a).width,r[a]=u,f=u-d)}return{width:h*c,kernedWidth:f*c}}getHeightOfChar(t,e){return this.getValueOfPropertyAt(t,e,"fontSize")}measureLine(t){const e=this._measureLine(t);return this.charSpacing!==0&&(e.width-=this._getWidthOfCharSpacing()),e.width<0&&(e.width=0),e}_measureLine(t){let e,i,s=0;const r=this.pathSide===dt,o=this.path,a=this._textLines[t],l=a.length,c=new Array(l);this.__charBounds[t]=c;for(let h=0;h<l;h++){const u=a[h];i=this._getGraphemeBox(u,t,h,e),c[h]=i,s+=i.kernedWidth,e=u}if(c[l]={left:i?i.left+i.width:0,width:0,kernedWidth:0,height:this.fontSize,deltaY:0},o&&o.segmentsInfo){let h=0;const u=o.segmentsInfo[o.segmentsInfo.length-1].length;switch(this.textAlign){case Q:h=r?u-s:0;break;case G:h=(u-s)/2;break;case dt:h=r?0:u-s}h+=this.pathStartOffset*(r?-1:1);for(let d=r?l-1:0;r?d>=0:d<l;r?d--:d++)i=c[d],h>u?h%=u:h<0&&(h+=u),this._setGraphemeOnPath(h,i),h+=i.kernedWidth}return{width:s,numOfSpaces:0}}_setGraphemeOnPath(t,e){const i=t+e.kernedWidth/2,s=this.path,r=Nf(s.path,i,s.segmentsInfo);e.renderLeft=r.x-s.pathOffset.x,e.renderTop=r.y-s.pathOffset.y,e.angle=r.angle+(this.pathSide===dt?Math.PI:0)}_getGraphemeBox(t,e,i,s,r){const o=this.getCompleteStyleDeclaration(e,i),a=s?this.getCompleteStyleDeclaration(e,i-1):{},l=this._measureChar(t,o,s,a);let c,h=l.kernedWidth,u=l.width;this.charSpacing!==0&&(c=this._getWidthOfCharSpacing(),u+=c,h+=c);const d={width:u,left:0,height:o.fontSize,kernedWidth:h,deltaY:o.deltaY};if(i>0&&!r){const f=this.__charBounds[e][i-1];d.left=f.left+f.width+l.kernedWidth-l.width}return d}getHeightOfLine(t){if(this.__lineHeights[t])return this.__lineHeights[t];let e=this.getHeightOfChar(t,0);for(let i=1,s=this._textLines[t].length;i<s;i++)e=Math.max(this.getHeightOfChar(t,i),e);return this.__lineHeights[t]=e*this.lineHeight*this._fontSizeMult}calcTextHeight(){let t,e=0;for(let i=0,s=this._textLines.length;i<s;i++)t=this.getHeightOfLine(i),e+=i===s-1?t/this.lineHeight:t;return e}_getLeftOffset(){return this.direction==="ltr"?-this.width/2:this.width/2}_getTopOffset(){return-this.height/2}_renderTextCommon(t,e){t.save();let i=0;const s=this._getLeftOffset(),r=this._getTopOffset();for(let o=0,a=this._textLines.length;o<a;o++){const l=this.getHeightOfLine(o),c=l/this.lineHeight,h=this._getLineLeftOffset(o);this._renderTextLine(e,t,this._textLines[o],s+h,r+i+c,o),i+=l}t.restore()}_renderTextFill(t){(this.fill||this.styleHas(bt))&&this._renderTextCommon(t,"fillText")}_renderTextStroke(t){(this.stroke&&this.strokeWidth!==0||!this.isEmptyStyles())&&(this.shadow&&!this.shadow.affectStroke&&this._removeShadow(t),t.save(),this._setLineDash(t,this.strokeDashArray),t.beginPath(),this._renderTextCommon(t,"strokeText"),t.closePath(),t.restore())}_renderChars(t,e,i,s,r,o){const a=this.getHeightOfLine(o),l=this.textAlign.includes(we),c=this.path,h=!l&&this.charSpacing===0&&this.isEmptyStyles(o)&&!c,u=this.direction==="ltr",d=this.direction==="ltr"?1:-1,f=e.direction;let g,p,m,v,y,x="",E=0;if(e.save(),f!==this.direction&&(e.canvas.setAttribute("dir",u?"ltr":"rtl"),e.direction=u?"ltr":"rtl",e.textAlign=u?Q:dt),r-=a*this._fontSizeFraction/this.lineHeight,h)return this._renderChar(t,e,o,0,i.join(""),s,r),void e.restore();for(let T=0,k=i.length-1;T<=k;T++)v=T===k||this.charSpacing||c,x+=i[T],m=this.__charBounds[o][T],E===0?(s+=d*(m.kernedWidth-m.width),E+=m.width):E+=m.kernedWidth,l&&!v&&this._reSpaceAndTab.test(i[T])&&(v=!0),v||(g=g||this.getCompleteStyleDeclaration(o,T),p=this.getCompleteStyleDeclaration(o,T+1),v=Lo(g,p,!1)),v&&(c?(e.save(),e.translate(m.renderLeft,m.renderTop),e.rotate(m.angle),this._renderChar(t,e,o,T,x,-E/2,0),e.restore()):(y=s,this._renderChar(t,e,o,T,x,y,r)),x="",g=p,s+=d*E,E=0);e.restore()}_applyPatternGradientTransformText(t){const e=this.width+this.strokeWidth,i=this.height+this.strokeWidth,s=Ce({width:e,height:i}),r=s.getContext("2d");return s.width=e,s.height=i,r.beginPath(),r.moveTo(0,0),r.lineTo(e,0),r.lineTo(e,i),r.lineTo(0,i),r.closePath(),r.translate(e/2,i/2),r.fillStyle=t.toLive(r),this._applyPatternGradientTransform(r,t),r.fill(),r.createPattern(s,"no-repeat")}handleFiller(t,e,i){let s,r;return Qt(i)?i.gradientUnits==="percentage"||i.gradientTransform||i.patternTransform?(s=-this.width/2,r=-this.height/2,t.translate(s,r),t[e]=this._applyPatternGradientTransformText(i),{offsetX:s,offsetY:r}):(t[e]=i.toLive(t),this._applyPatternGradientTransform(t,i)):(t[e]=i,{offsetX:0,offsetY:0})}_setStrokeStyles(t,e){let{stroke:i,strokeWidth:s}=e;return t.lineWidth=s,t.lineCap=this.strokeLineCap,t.lineDashOffset=this.strokeDashOffset,t.lineJoin=this.strokeLineJoin,t.miterLimit=this.strokeMiterLimit,this.handleFiller(t,"strokeStyle",i)}_setFillStyles(t,e){let{fill:i}=e;return this.handleFiller(t,"fillStyle",i)}_renderChar(t,e,i,s,r,o,a){const l=this._getStyleDeclaration(i,s),c=this.getCompleteStyleDeclaration(i,s),h=t==="fillText"&&c.fill,u=t==="strokeText"&&c.stroke&&c.strokeWidth;if(u||h){if(e.save(),e.font=this._getFontDeclaration(c),l.textBackgroundColor&&this._removeShadow(e),l.deltaY&&(a+=l.deltaY),h){const d=this._setFillStyles(e,c);e.fillText(r,o-d.offsetX,a-d.offsetY)}if(u){const d=this._setStrokeStyles(e,c);e.strokeText(r,o-d.offsetX,a-d.offsetY)}e.restore()}}setSuperscript(t,e){this._setScript(t,e,this.superscript)}setSubscript(t,e){this._setScript(t,e,this.subscript)}_setScript(t,e,i){const s=this.get2DCursorLocation(t,!0),r=this.getValueOfPropertyAt(s.lineIndex,s.charIndex,"fontSize"),o=this.getValueOfPropertyAt(s.lineIndex,s.charIndex,"deltaY"),a={fontSize:r*i.size,deltaY:o+r*i.baseline};this.setSelectionStyles(a,t,e)}_getLineLeftOffset(t){const e=this.getLineWidth(t),i=this.width-e,s=this.textAlign,r=this.direction,o=this.isEndOfWrapping(t);let a=0;return s===we||s===zs&&!o||s===Vs&&!o||s===Zr&&!o?0:(s===G&&(a=i/2),s===dt&&(a=i),s===zs&&(a=i/2),s===Vs&&(a=i),r==="rtl"&&(s===dt||s===we||s===Vs?a=0:s===Q||s===Zr?a=-i:s!==G&&s!==zs||(a=-i/2)),a)}_clearCache(){this._forceClearCache=!1,this.__lineWidths=[],this.__lineHeights=[],this.__charBounds=[]}getLineWidth(t){if(this.__lineWidths[t]!==void 0)return this.__lineWidths[t];const{width:e}=this.measureLine(t);return this.__lineWidths[t]=e,e}_getWidthOfCharSpacing(){return this.charSpacing!==0?this.fontSize*this.charSpacing/1e3:0}getValueOfPropertyAt(t,e,i){var s;return(s=this._getStyleDeclaration(t,e)[i])!==null&&s!==void 0?s:this[i]}_renderTextDecoration(t,e){if(!this[e]&&!this.styleHas(e))return;let i=this._getTopOffset();const s=this._getLeftOffset(),r=this.path,o=this._getWidthOfCharSpacing(),a=this.offsets[e];for(let l=0,c=this._textLines.length;l<c;l++){const h=this.getHeightOfLine(l);if(!this[e]&&!this.styleHas(e,l)){i+=h;continue}const u=this._textLines[l],d=h/this.lineHeight,f=this._getLineLeftOffset(l);let g,p,m=0,v=0,y=this.getValueOfPropertyAt(l,0,e),x=this.getValueOfPropertyAt(l,0,bt);const E=i+d*(1-this._fontSizeFraction);let T=this.getHeightOfChar(l,0),k=this.getValueOfPropertyAt(l,0,"deltaY");for(let w=0,L=u.length;w<L;w++){const j=this.__charBounds[l][w];g=this.getValueOfPropertyAt(l,w,e),p=this.getValueOfPropertyAt(l,w,bt);const A=this.getHeightOfChar(l,w),O=this.getValueOfPropertyAt(l,w,"deltaY");if(r&&g&&p)t.save(),t.fillStyle=x,t.translate(j.renderLeft,j.renderTop),t.rotate(j.angle),t.fillRect(-j.kernedWidth/2,a*A+O,j.kernedWidth,this.fontSize/15),t.restore();else if((g!==y||p!==x||A!==T||O!==k)&&v>0){let D=s+f+m;this.direction==="rtl"&&(D=this.width-D-v),y&&x&&(t.fillStyle=x,t.fillRect(D,E+a*T+k,v,this.fontSize/15)),m=j.left,v=j.width,y=g,x=p,T=A,k=O}else v+=j.kernedWidth}let S=s+f+m;this.direction==="rtl"&&(S=this.width-S-v),t.fillStyle=p,g&&p&&t.fillRect(S,E+a*T+k,v-o,this.fontSize/15),i+=h}this._removeShadow(t)}_getFontDeclaration(){let{fontFamily:t=this.fontFamily,fontStyle:e=this.fontStyle,fontWeight:i=this.fontWeight,fontSize:s=this.fontSize}=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},r=arguments.length>1?arguments[1]:void 0;const o=t.includes("'")||t.includes('"')||t.includes(",")||Lt.genericFonts.includes(t.toLowerCase())?t:'"'.concat(t,'"');return[e,i,"".concat(r?this.CACHE_FONT_SIZE:s,"px"),o].join(" ")}render(t){this.visible&&(this.canvas&&this.canvas.skipOffscreen&&!this.group&&!this.isOnScreen()||(this._forceClearCache&&this.initDimensions(),super.render(t)))}graphemeSplit(t){return Io(t)}_splitTextIntoLines(t){const e=t.split(this._reNewline),i=new Array(e.length),s=[`
180
- `];let r=[];for(let o=0;o<e.length;o++)i[o]=this.graphemeSplit(e[o]),r=r.concat(i[o],s);return r.pop(),{_unwrappedLines:i,lines:e,graphemeText:r,graphemeLines:i}}toObject(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[];return b(b({},super.toObject([...kc,...t])),{},{styles:Qd(this.styles,this.text)},this.path?{path:this.path.toObject()}:{})}set(t,e){const{textLayoutProperties:i}=this.constructor;super.set(t,e);let s=!1,r=!1;if(typeof t=="object")for(const o in t)o==="path"&&this.setPathInfo(),s=s||i.includes(o),r=r||o==="path";else s=i.includes(t),r=t==="path";return r&&this.setPathInfo(),s&&this.initialized&&(this.initDimensions(),this.setCoords()),this}complexity(){return 1}static async fromElement(t,e,i){const s=Ne(t,Lt.ATTRIBUTE_NAMES,i),r=b(b({},e),s),{textAnchor:o=Q,textDecoration:a="",dx:l=0,dy:c=0,top:h=0,left:u=0,fontSize:d=oo,strokeWidth:f=1}=r,g=rt(r,fg),p=new this((t.textContent||"").replace(/^\s+|\s+$|\n+/g,"").replace(/\s+/g," "),b({left:u+l,top:h+c,underline:a.includes("underline"),overline:a.includes("overline"),linethrough:a.includes("line-through"),strokeWidth:0,fontSize:d},g)),m=p.getScaledHeight()/p.height,v=((p.height+p.strokeWidth)*p.lineHeight-p.height)*m,y=p.getScaledHeight()+v;let x=0;return o===G&&(x=p.getScaledWidth()/2),o===dt&&(x=p.getScaledWidth()),p.set({left:p.left-x,top:p.top-(y-p.fontSize*(.07+p._fontSizeFraction))/p.lineHeight,strokeWidth:f}),p}static fromObject(t){return this._fromObject(b(b({},t),{},{styles:tf(t.styles||{},t.text)}),{extraParam:"text"})}}_(Lt,"textLayoutProperties",Dc),_(Lt,"cacheProperties",[...Fe,...kc]),_(Lt,"ownDefaults",hg),_(Lt,"type","Text"),_(Lt,"genericFonts",["serif","sans-serif","monospace","cursive","fantasy","system-ui","ui-serif","ui-sans-serif","ui-monospace","ui-rounded","math","emoji","fangsong"]),_(Lt,"ATTRIBUTE_NAMES",oi.concat("x","y","dx","dy","font-family","font-style","font-weight","font-size","letter-spacing","text-decoration","text-anchor")),ql(Lt,[class extends Il{_toSVG(){const n=this._getSVGLeftTopOffsets(),t=this._getSVGTextAndBg(n.textTop,n.textLeft);return this._wrapSVGTextAndBg(t)}toSVG(n){return this._createBaseSVGMarkup(this._toSVG(),{reviver:n,noStyle:!0,withShadow:!0})}_getSVGLeftTopOffsets(){return{textLeft:-this.width/2,textTop:-this.height/2,lineTop:this.getHeightOfLine(0)}}_wrapSVGTextAndBg(n){let{textBgRects:t,textSpans:e}=n;const i=this.getSvgTextDecoration(this);return[t.join(""),' <text xml:space="preserve" ',this.fontFamily?'font-family="'.concat(this.fontFamily.replace(dg,"'"),'" '):"",this.fontSize?'font-size="'.concat(this.fontSize,'" '):"",this.fontStyle?'font-style="'.concat(this.fontStyle,'" '):"",this.fontWeight?'font-weight="'.concat(this.fontWeight,'" '):"",i?'text-decoration="'.concat(i,'" '):"",this.direction==="rtl"?'direction="'.concat(this.direction,'" '):"",'style="',this.getSvgStyles(!0),'"',this.addPaintOrder()," >",e.join(""),`</text>
181
- `]}_getSVGTextAndBg(n,t){const e=[],i=[];let s,r=n;this.backgroundColor&&i.push(...Wo(this.backgroundColor,-this.width/2,-this.height/2,this.width,this.height));for(let o=0,a=this._textLines.length;o<a;o++)s=this._getLineLeftOffset(o),this.direction==="rtl"&&(s+=this.width),(this.textBackgroundColor||this.styleHas("textBackgroundColor",o))&&this._setSVGTextLineBg(i,o,t+s,r),this._setSVGTextLineText(e,o,t+s,r),r+=this.getHeightOfLine(o);return{textSpans:e,textBgRects:i}}_createTextCharSpan(n,t,e,i){const s=this.getSvgSpanStyles(t,n!==n.trim()||!!n.match(ug)),r=s?'style="'.concat(s,'"'):"",o=t.deltaY,a=o?' dy="'.concat(lt(o,J.NUM_FRACTION_DIGITS),'" '):"";return'<tspan x="'.concat(lt(e,J.NUM_FRACTION_DIGITS),'" y="').concat(lt(i,J.NUM_FRACTION_DIGITS),'" ').concat(a).concat(r,">").concat(Jd(n),"</tspan>")}_setSVGTextLineText(n,t,e,i){const s=this.getHeightOfLine(t),r=this.textAlign.includes(we),o=this._textLines[t];let a,l,c,h,u,d="",f=0;i+=s*(1-this._fontSizeFraction)/this.lineHeight;for(let g=0,p=o.length-1;g<=p;g++)u=g===p||this.charSpacing,d+=o[g],c=this.__charBounds[t][g],f===0?(e+=c.kernedWidth-c.width,f+=c.width):f+=c.kernedWidth,r&&!u&&this._reSpaceAndTab.test(o[g])&&(u=!0),u||(a=a||this.getCompleteStyleDeclaration(t,g),l=this.getCompleteStyleDeclaration(t,g+1),u=Lo(a,l,!0)),u&&(h=this._getStyleDeclaration(t,g),n.push(this._createTextCharSpan(d,h,e,i)),d="",a=l,this.direction==="rtl"?e-=f:e+=f,f=0)}_setSVGTextLineBg(n,t,e,i){const s=this._textLines[t],r=this.getHeightOfLine(t)/this.lineHeight;let o,a=0,l=0,c=this.getValueOfPropertyAt(t,0,"textBackgroundColor");for(let h=0;h<s.length;h++){const{left:u,width:d,kernedWidth:f}=this.__charBounds[t][h];o=this.getValueOfPropertyAt(t,h,"textBackgroundColor"),o!==c?(c&&n.push(...Wo(c,e+l,i,a,r)),l=u,a=d,c=o):a+=f}o&&n.push(...Wo(c,e+l,i,a,r))}_getSVGLineTopOffset(n){let t,e=0;for(t=0;t<n;t++)e+=this.getHeightOfLine(t);const i=this.getHeightOfLine(t);return{lineTop:e,offset:(this._fontSizeMult-this._fontSizeFraction)*i/(this.lineHeight*this._fontSizeMult)}}getSvgStyles(n){return"".concat(super.getSvgStyles(n)," white-space: pre;")}getSvgSpanStyles(n,t){const{fontFamily:e,strokeWidth:i,stroke:s,fill:r,fontSize:o,fontStyle:a,fontWeight:l,deltaY:c}=n,h=this.getSvgTextDecoration(n);return[s?Ls(Bt,s):"",i?"stroke-width: ".concat(i,"; "):"",e?"font-family: ".concat(e.includes("'")||e.includes('"')?e:"'".concat(e,"'"),"; "):"",o?"font-size: ".concat(o,"px; "):"",a?"font-style: ".concat(a,"; "):"",l?"font-weight: ".concat(l,"; "):"",h&&"text-decoration: ".concat(h,"; "),r?Ls(bt,r):"",c?"baseline-shift: ".concat(-c,"; "):"",t?"white-space: pre; ":""].join("")}getSvgTextDecoration(n){return["overline","underline","line-through"].filter(t=>n[t.replace("-","")]).join(" ")}}]),F.setClass(Lt),F.setSVGClass(Lt);class gg{constructor(t){_(this,"target",void 0),_(this,"__mouseDownInPlace",!1),_(this,"__dragStartFired",!1),_(this,"__isDraggingOver",!1),_(this,"__dragStartSelection",void 0),_(this,"__dragImageDisposer",void 0),_(this,"_dispose",void 0),this.target=t;const e=[this.target.on("dragenter",this.dragEnterHandler.bind(this)),this.target.on("dragover",this.dragOverHandler.bind(this)),this.target.on("dragleave",this.dragLeaveHandler.bind(this)),this.target.on("dragend",this.dragEndHandler.bind(this)),this.target.on("drop",this.dropHandler.bind(this))];this._dispose=()=>{e.forEach(i=>i()),this._dispose=void 0}}isPointerOverSelection(t){const e=this.target,i=e.getSelectionStartFromPointer(t);return e.isEditing&&i>=e.selectionStart&&i<=e.selectionEnd&&e.selectionStart<e.selectionEnd}start(t){return this.__mouseDownInPlace=this.isPointerOverSelection(t)}isActive(){return this.__mouseDownInPlace}end(t){const e=this.isActive();return e&&!this.__dragStartFired&&(this.target.setCursorByClick(t),this.target.initDelayedCursor(!0)),this.__mouseDownInPlace=!1,this.__dragStartFired=!1,this.__isDraggingOver=!1,e}getDragStartSelection(){return this.__dragStartSelection}setDragImage(t,e){var i;let{selectionStart:s,selectionEnd:r}=e;const o=this.target,a=o.canvas,l=new C(o.flipX?-1:1,o.flipY?-1:1),c=o._getCursorBoundaries(s),h=new C(c.left+c.leftOffset,c.top+c.topOffset).multiply(l).transform(o.calcTransformMatrix()),u=a.getScenePoint(t).subtract(h),d=o.getCanvasRetinaScaling(),f=o.getBoundingRect(),g=h.subtract(new C(f.left,f.top)),p=a.viewportTransform,m=g.add(u).transform(p,!0),v=o.backgroundColor,y=Po(o.styles);o.backgroundColor="";const x={stroke:"transparent",fill:"transparent",textBackgroundColor:"transparent"};o.setSelectionStyles(x,0,s),o.setSelectionStyles(x,r,o.text.length),o.dirty=!0;const E=o.toCanvasElement({enableRetinaScaling:a.enableRetinaScaling,viewportTransform:!0});o.backgroundColor=v,o.styles=y,o.dirty=!0,$o(E,{position:"fixed",left:"".concat(-E.width,"px"),border:Rt,width:"".concat(E.width/d,"px"),height:"".concat(E.height/d,"px")}),this.__dragImageDisposer&&this.__dragImageDisposer(),this.__dragImageDisposer=()=>{E.remove()},he(t.target||this.target.hiddenTextarea).body.appendChild(E),(i=t.dataTransfer)===null||i===void 0||i.setDragImage(E,m.x,m.y)}onDragStart(t){this.__dragStartFired=!0;const e=this.target,i=this.isActive();if(i&&t.dataTransfer){const s=this.__dragStartSelection={selectionStart:e.selectionStart,selectionEnd:e.selectionEnd},r=e._text.slice(s.selectionStart,s.selectionEnd).join(""),o=b({text:e.text,value:r},s);t.dataTransfer.setData("text/plain",r),t.dataTransfer.setData("application/fabric",JSON.stringify({value:r,styles:e.getSelectionStyles(s.selectionStart,s.selectionEnd,!0)})),t.dataTransfer.effectAllowed="copyMove",this.setDragImage(t,o)}return e.abortCursorAnimation(),i}canDrop(t){if(this.target.editable&&!this.target.getActiveControl()&&!t.defaultPrevented){if(this.isActive()&&this.__dragStartSelection){const e=this.target.getSelectionStartFromPointer(t),i=this.__dragStartSelection;return e<i.selectionStart||e>i.selectionEnd}return!0}return!1}targetCanDrop(t){return this.target.canDrop(t)}dragEnterHandler(t){let{e}=t;const i=this.targetCanDrop(e);!this.__isDraggingOver&&i&&(this.__isDraggingOver=!0)}dragOverHandler(t){const{e}=t,i=this.targetCanDrop(e);!this.__isDraggingOver&&i?this.__isDraggingOver=!0:this.__isDraggingOver&&!i&&(this.__isDraggingOver=!1),this.__isDraggingOver&&(e.preventDefault(),t.canDrop=!0,t.dropTarget=this.target)}dragLeaveHandler(){(this.__isDraggingOver||this.isActive())&&(this.__isDraggingOver=!1)}dropHandler(t){var e;const{e:i}=t,s=i.defaultPrevented;this.__isDraggingOver=!1,i.preventDefault();let r=(e=i.dataTransfer)===null||e===void 0?void 0:e.getData("text/plain");if(r&&!s){const o=this.target,a=o.canvas;let l=o.getSelectionStartFromPointer(i);const{styles:c}=i.dataTransfer.types.includes("application/fabric")?JSON.parse(i.dataTransfer.getData("application/fabric")):{},h=r[Math.max(0,r.length-1)],u=0;if(this.__dragStartSelection){const d=this.__dragStartSelection.selectionStart,f=this.__dragStartSelection.selectionEnd;l>d&&l<=f?l=d:l>f&&(l-=f-d),o.removeChars(d,f),delete this.__dragStartSelection}o._reNewline.test(h)&&(o._reNewline.test(o._text[l])||l===o._text.length)&&(r=r.trimEnd()),t.didDrop=!0,t.dropTarget=o,o.insertChars(r,c,l),a.setActiveObject(o),o.enterEditing(i),o.selectionStart=Math.min(l+u,o._text.length),o.selectionEnd=Math.min(o.selectionStart+r.length,o._text.length),o.hiddenTextarea.value=o.text,o._updateTextarea(),o.hiddenTextarea.focus(),o.fire(Er,{index:l+u,action:"drop"}),a.fire("text:changed",{target:o}),a.contextTopDirty=!0,a.requestRenderAll()}}dragEndHandler(t){let{e}=t;if(this.isActive()&&this.__dragStartFired&&this.__dragStartSelection){var i;const s=this.target,r=this.target.canvas,{selectionStart:o,selectionEnd:a}=this.__dragStartSelection,l=((i=e.dataTransfer)===null||i===void 0?void 0:i.dropEffect)||Rt;l===Rt?(s.selectionStart=o,s.selectionEnd=a,s._updateTextarea(),s.hiddenTextarea.focus()):(s.clearContextTop(),l==="move"&&(s.removeChars(o,a),s.selectionStart=s.selectionEnd=o,s.hiddenTextarea&&(s.hiddenTextarea.value=s.text),s._updateTextarea(),s.fire(Er,{index:o,action:"dragend"}),r.fire("text:changed",{target:s}),r.requestRenderAll()),s.exitEditing())}this.__dragImageDisposer&&this.__dragImageDisposer(),delete this.__dragImageDisposer,delete this.__dragStartSelection,this.__isDraggingOver=!1}dispose(){this._dispose&&this._dispose()}}const Pc=/[ \n\.,;!\?\-]/;class pg extends Lt{constructor(){super(...arguments),_(this,"_currentCursorOpacity",1)}initBehavior(){this._tick=this._tick.bind(this),this._onTickComplete=this._onTickComplete.bind(this),this.updateSelectionOnMouseMove=this.updateSelectionOnMouseMove.bind(this)}onDeselect(t){return this.isEditing&&this.exitEditing(),this.selected=!1,super.onDeselect(t)}_animateCursor(t){let{toValue:e,duration:i,delay:s,onComplete:r}=t;return zl({startValue:this._currentCursorOpacity,endValue:e,duration:i,delay:s,onComplete:r,abort:()=>!this.canvas||this.selectionStart!==this.selectionEnd,onChange:o=>{this._currentCursorOpacity=o,this.renderCursorOrSelection()}})}_tick(t){this._currentTickState=this._animateCursor({toValue:0,duration:this.cursorDuration/2,delay:Math.max(t||0,100),onComplete:this._onTickComplete})}_onTickComplete(){var t;(t=this._currentTickCompleteState)===null||t===void 0||t.abort(),this._currentTickCompleteState=this._animateCursor({toValue:1,duration:this.cursorDuration,onComplete:this._tick})}initDelayedCursor(t){this.abortCursorAnimation(),this._tick(t?0:this.cursorDelay)}abortCursorAnimation(){let t=!1;[this._currentTickState,this._currentTickCompleteState].forEach(e=>{e&&!e.isDone()&&(t=!0,e.abort())}),this._currentCursorOpacity=1,t&&this.clearContextTop()}restartCursorIfNeeded(){[this._currentTickState,this._currentTickCompleteState].some(t=>!t||t.isDone())&&this.initDelayedCursor()}selectAll(){return this.selectionStart=0,this.selectionEnd=this._text.length,this._fireSelectionChanged(),this._updateTextarea(),this}getSelectedText(){return this._text.slice(this.selectionStart,this.selectionEnd).join("")}findWordBoundaryLeft(t){let e=0,i=t-1;if(this._reSpace.test(this._text[i]))for(;this._reSpace.test(this._text[i]);)e++,i--;for(;/\S/.test(this._text[i])&&i>-1;)e++,i--;return t-e}findWordBoundaryRight(t){let e=0,i=t;if(this._reSpace.test(this._text[i]))for(;this._reSpace.test(this._text[i]);)e++,i++;for(;/\S/.test(this._text[i])&&i<this._text.length;)e++,i++;return t+e}findLineBoundaryLeft(t){let e=0,i=t-1;for(;!/\n/.test(this._text[i])&&i>-1;)e++,i--;return t-e}findLineBoundaryRight(t){let e=0,i=t;for(;!/\n/.test(this._text[i])&&i<this._text.length;)e++,i++;return t+e}searchWordBoundary(t,e){const i=this._text;let s=t>0&&this._reSpace.test(i[t])&&(e===-1||!lo.test(i[t-1]))?t-1:t,r=i[s];for(;s>0&&s<i.length&&!Pc.test(r);)s+=e,r=i[s];return e===-1&&Pc.test(r)&&s++,s}selectWord(t){t=t||this.selectionStart;const e=this.searchWordBoundary(t,-1),i=Math.max(e,this.searchWordBoundary(t,1));this.selectionStart=e,this.selectionEnd=i,this._fireSelectionChanged(),this._updateTextarea(),this.renderCursorOrSelection()}selectLine(t){t=t||this.selectionStart;const e=this.findLineBoundaryLeft(t),i=this.findLineBoundaryRight(t);return this.selectionStart=e,this.selectionEnd=i,this._fireSelectionChanged(),this._updateTextarea(),this}enterEditing(t){!this.isEditing&&this.editable&&(this.enterEditingImpl(),this.fire("editing:entered",t?{e:t}:void 0),this._fireSelectionChanged(),this.canvas&&(this.canvas.fire("text:editing:entered",{target:this,e:t}),this.canvas.requestRenderAll()))}enterEditingImpl(){this.canvas&&(this.canvas.calcOffset(),this.canvas.textEditingManager.exitTextEditing()),this.isEditing=!0,this.initHiddenTextarea(),this.hiddenTextarea.focus(),this.hiddenTextarea.value=this.text,this._updateTextarea(),this._saveEditingProps(),this._setEditingProps(),this._textBeforeEdit=this.text,this._tick()}updateSelectionOnMouseMove(t){if(this.getActiveControl())return;const e=this.hiddenTextarea;he(e).activeElement!==e&&e.focus();const i=this.getSelectionStartFromPointer(t),s=this.selectionStart,r=this.selectionEnd;(i===this.__selectionStartOnMouseDown&&s!==r||s!==i&&r!==i)&&(i>this.__selectionStartOnMouseDown?(this.selectionStart=this.__selectionStartOnMouseDown,this.selectionEnd=i):(this.selectionStart=i,this.selectionEnd=this.__selectionStartOnMouseDown),this.selectionStart===s&&this.selectionEnd===r||(this._fireSelectionChanged(),this._updateTextarea(),this.renderCursorOrSelection()))}_setEditingProps(){this.hoverCursor="text",this.canvas&&(this.canvas.defaultCursor=this.canvas.moveCursor="text"),this.borderColor=this.editingBorderColor,this.hasControls=this.selectable=!1,this.lockMovementX=this.lockMovementY=!0}fromStringToGraphemeSelection(t,e,i){const s=i.slice(0,t),r=this.graphemeSplit(s).length;if(t===e)return{selectionStart:r,selectionEnd:r};const o=i.slice(t,e);return{selectionStart:r,selectionEnd:r+this.graphemeSplit(o).length}}fromGraphemeToStringSelection(t,e,i){const s=i.slice(0,t).join("").length;return t===e?{selectionStart:s,selectionEnd:s}:{selectionStart:s,selectionEnd:s+i.slice(t,e).join("").length}}_updateTextarea(){if(this.cursorOffsetCache={},this.hiddenTextarea){if(!this.inCompositionMode){const t=this.fromGraphemeToStringSelection(this.selectionStart,this.selectionEnd,this._text);this.hiddenTextarea.selectionStart=t.selectionStart,this.hiddenTextarea.selectionEnd=t.selectionEnd}this.updateTextareaPosition()}}updateFromTextArea(){if(!this.hiddenTextarea)return;this.cursorOffsetCache={};const t=this.hiddenTextarea;this.text=t.value,this.set("dirty",!0),this.initDimensions(),this.setCoords();const e=this.fromStringToGraphemeSelection(t.selectionStart,t.selectionEnd,t.value);this.selectionEnd=this.selectionStart=e.selectionEnd,this.inCompositionMode||(this.selectionStart=e.selectionStart),this.updateTextareaPosition()}updateTextareaPosition(){if(this.selectionStart===this.selectionEnd){const t=this._calcTextareaPosition();this.hiddenTextarea.style.left=t.left,this.hiddenTextarea.style.top=t.top}}_calcTextareaPosition(){if(!this.canvas)return{left:"1px",top:"1px"};const t=this.inCompositionMode?this.compositionStart:this.selectionStart,e=this._getCursorBoundaries(t),i=this.get2DCursorLocation(t),s=i.lineIndex,r=i.charIndex,o=this.getValueOfPropertyAt(s,r,"fontSize")*this.lineHeight,a=e.leftOffset,l=this.getCanvasRetinaScaling(),c=this.canvas.upperCanvasEl,h=c.width/l,u=c.height/l,d=h-o,f=u-o,g=new C(e.left+a,e.top+e.topOffset+o).transform(this.calcTransformMatrix()).transform(this.canvas.viewportTransform).multiply(new C(c.clientWidth/h,c.clientHeight/u));return g.x<0&&(g.x=0),g.x>d&&(g.x=d),g.y<0&&(g.y=0),g.y>f&&(g.y=f),g.x+=this.canvas._offset.left,g.y+=this.canvas._offset.top,{left:"".concat(g.x,"px"),top:"".concat(g.y,"px"),fontSize:"".concat(o,"px"),charHeight:o}}_saveEditingProps(){this._savedProps={hasControls:this.hasControls,borderColor:this.borderColor,lockMovementX:this.lockMovementX,lockMovementY:this.lockMovementY,hoverCursor:this.hoverCursor,selectable:this.selectable,defaultCursor:this.canvas&&this.canvas.defaultCursor,moveCursor:this.canvas&&this.canvas.moveCursor}}_restoreEditingProps(){this._savedProps&&(this.hoverCursor=this._savedProps.hoverCursor,this.hasControls=this._savedProps.hasControls,this.borderColor=this._savedProps.borderColor,this.selectable=this._savedProps.selectable,this.lockMovementX=this._savedProps.lockMovementX,this.lockMovementY=this._savedProps.lockMovementY,this.canvas&&(this.canvas.defaultCursor=this._savedProps.defaultCursor||this.canvas.defaultCursor,this.canvas.moveCursor=this._savedProps.moveCursor||this.canvas.moveCursor),delete this._savedProps)}_exitEditing(){const t=this.hiddenTextarea;this.selected=!1,this.isEditing=!1,t&&(t.blur&&t.blur(),t.parentNode&&t.parentNode.removeChild(t)),this.hiddenTextarea=null,this.abortCursorAnimation(),this.selectionStart!==this.selectionEnd&&this.clearContextTop()}exitEditingImpl(){this._exitEditing(),this.selectionEnd=this.selectionStart,this._restoreEditingProps(),this._forceClearCache&&(this.initDimensions(),this.setCoords())}exitEditing(){const t=this._textBeforeEdit!==this.text;return this.exitEditingImpl(),this.fire("editing:exited"),t&&this.fire(Ar),this.canvas&&(this.canvas.fire("text:editing:exited",{target:this}),t&&this.canvas.fire("object:modified",{target:this})),this}_removeExtraneousStyles(){for(const t in this.styles)this._textLines[t]||delete this.styles[t]}removeStyleFromTo(t,e){const{lineIndex:i,charIndex:s}=this.get2DCursorLocation(t,!0),{lineIndex:r,charIndex:o}=this.get2DCursorLocation(e,!0);if(i!==r){if(this.styles[i])for(let a=s;a<this._unwrappedTextLines[i].length;a++)delete this.styles[i][a];if(this.styles[r])for(let a=o;a<this._unwrappedTextLines[r].length;a++){const l=this.styles[r][a];l&&(this.styles[i]||(this.styles[i]={}),this.styles[i][s+a-o]=l)}for(let a=i+1;a<=r;a++)delete this.styles[a];this.shiftLineStyles(r,i-r)}else if(this.styles[i]){const a=this.styles[i],l=o-s;for(let c=s;c<o;c++)delete a[c];for(const c in this.styles[i]){const h=parseInt(c,10);h>=o&&(a[h-l]=a[c],delete a[c])}}}shiftLineStyles(t,e){const i=Object.assign({},this.styles);for(const s in this.styles){const r=parseInt(s,10);r>t&&(this.styles[r+e]=i[r],i[r-e]||delete this.styles[r])}}insertNewlineStyleObject(t,e,i,s){const r={},o=this._unwrappedTextLines[t].length,a=o===e;let l=!1;i||(i=1),this.shiftLineStyles(t,i);const c=this.styles[t]?this.styles[t][e===0?e:e-1]:void 0;for(const u in this.styles[t]){const d=parseInt(u,10);d>=e&&(l=!0,r[d-e]=this.styles[t][u],a&&e===0||delete this.styles[t][u])}let h=!1;for(l&&!a&&(this.styles[t+i]=r,h=!0),(h||o>e)&&i--;i>0;)s&&s[i-1]?this.styles[t+i]={0:b({},s[i-1])}:c?this.styles[t+i]={0:b({},c)}:delete this.styles[t+i],i--;this._forceClearCache=!0}insertCharStyleObject(t,e,i,s){this.styles||(this.styles={});const r=this.styles[t],o=r?b({},r):{};i||(i=1);for(const l in o){const c=parseInt(l,10);c>=e&&(r[c+i]=o[c],o[c-i]||delete r[c])}if(this._forceClearCache=!0,s){for(;i--;)Object.keys(s[i]).length&&(this.styles[t]||(this.styles[t]={}),this.styles[t][e+i]=b({},s[i]));return}if(!r)return;const a=r[e?e-1:1];for(;a&&i--;)this.styles[t][e+i]=b({},a)}insertNewStyleBlock(t,e,i){const s=this.get2DCursorLocation(e,!0),r=[0];let o,a=0;for(let l=0;l<t.length;l++)t[l]===`
182
- `?(a++,r[a]=0):r[a]++;for(r[0]>0&&(this.insertCharStyleObject(s.lineIndex,s.charIndex,r[0],i),i=i&&i.slice(r[0]+1)),a&&this.insertNewlineStyleObject(s.lineIndex,s.charIndex+r[0],a),o=1;o<a;o++)r[o]>0?this.insertCharStyleObject(s.lineIndex+o,0,r[o],i):i&&this.styles[s.lineIndex+o]&&i[0]&&(this.styles[s.lineIndex+o][0]=i[0]),i=i&&i.slice(r[o]+1);r[o]>0&&this.insertCharStyleObject(s.lineIndex+o,0,r[o],i)}removeChars(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:t+1;this.removeStyleFromTo(t,e),this._text.splice(t,e-t),this.text=this._text.join(""),this.set("dirty",!0),this.initDimensions(),this.setCoords(),this._removeExtraneousStyles()}insertChars(t,e,i){let s=arguments.length>3&&arguments[3]!==void 0?arguments[3]:i;s>i&&this.removeStyleFromTo(i,s);const r=this.graphemeSplit(t);this.insertNewStyleBlock(r,i,e),this._text=[...this._text.slice(0,i),...r,...this._text.slice(s)],this.text=this._text.join(""),this.set("dirty",!0),this.initDimensions(),this.setCoords(),this._removeExtraneousStyles()}setSelectionStartEndWithShift(t,e,i){i<=t?(e===t?this._selectionDirection=Q:this._selectionDirection===dt&&(this._selectionDirection=Q,this.selectionEnd=t),this.selectionStart=i):i>t&&i<e?this._selectionDirection===dt?this.selectionEnd=i:this.selectionStart=i:(e===t?this._selectionDirection=dt:this._selectionDirection===Q&&(this._selectionDirection=dt,this.selectionStart=e),this.selectionEnd=i)}}class mg extends pg{initHiddenTextarea(){const t=this.canvas&&he(this.canvas.getElement())||Yi(),e=t.createElement("textarea");Object.entries({autocapitalize:"off",autocorrect:"off",autocomplete:"off",spellcheck:"false","data-fabric":"textarea",wrap:"off"}).map(o=>{let[a,l]=o;return e.setAttribute(a,l)});const{top:i,left:s,fontSize:r}=this._calcTextareaPosition();e.style.cssText="position: absolute; top: ".concat(i,"; left: ").concat(s,"; z-index: -999; opacity: 0; width: 1px; height: 1px; font-size: 1px; padding-top: ").concat(r,";"),(this.hiddenTextareaContainer||t.body).appendChild(e),Object.entries({blur:"blur",keydown:"onKeyDown",keyup:"onKeyUp",input:"onInput",copy:"copy",cut:"copy",paste:"paste",compositionstart:"onCompositionStart",compositionupdate:"onCompositionUpdate",compositionend:"onCompositionEnd"}).map(o=>{let[a,l]=o;return e.addEventListener(a,this[l].bind(this))}),this.hiddenTextarea=e}blur(){this.abortCursorAnimation()}onKeyDown(t){if(!this.isEditing)return;const e=this.direction==="rtl"?this.keysMapRtl:this.keysMap;if(t.keyCode in e)this[e[t.keyCode]](t);else{if(!(t.keyCode in this.ctrlKeysMapDown)||!t.ctrlKey&&!t.metaKey)return;this[this.ctrlKeysMapDown[t.keyCode]](t)}t.stopImmediatePropagation(),t.preventDefault(),t.keyCode>=33&&t.keyCode<=40?(this.inCompositionMode=!1,this.clearContextTop(),this.renderCursorOrSelection()):this.canvas&&this.canvas.requestRenderAll()}onKeyUp(t){!this.isEditing||this._copyDone||this.inCompositionMode?this._copyDone=!1:t.keyCode in this.ctrlKeysMapUp&&(t.ctrlKey||t.metaKey)&&(this[this.ctrlKeysMapUp[t.keyCode]](t),t.stopImmediatePropagation(),t.preventDefault(),this.canvas&&this.canvas.requestRenderAll())}onInput(t){const e=this.fromPaste;if(this.fromPaste=!1,t&&t.stopPropagation(),!this.isEditing)return;const i=()=>{this.updateFromTextArea(),this.fire(Er),this.canvas&&(this.canvas.fire("text:changed",{target:this}),this.canvas.requestRenderAll())};if(this.hiddenTextarea.value==="")return this.styles={},void i();const s=this._splitTextIntoLines(this.hiddenTextarea.value).graphemeText,r=this._text.length,o=s.length,a=this.selectionStart,l=this.selectionEnd,c=a!==l;let h,u,d,f,g=o-r;const p=this.fromStringToGraphemeSelection(this.hiddenTextarea.selectionStart,this.hiddenTextarea.selectionEnd,this.hiddenTextarea.value),m=a>p.selectionStart;c?(u=this._text.slice(a,l),g+=l-a):o<r&&(u=m?this._text.slice(l+g,l):this._text.slice(a,a-g));const v=s.slice(p.selectionEnd-g,p.selectionEnd);if(u&&u.length&&(v.length&&(h=this.getSelectionStyles(a,a+1,!1),h=v.map(()=>h[0])),c?(d=a,f=l):m?(d=l-u.length,f=l):(d=l,f=l+u.length),this.removeStyleFromTo(d,f)),v.length){const{copyPasteData:y}=xe();e&&v.join("")===y.copiedText&&!J.disableStyleCopyPaste&&(h=y.copiedTextStyle),this.insertNewStyleBlock(v,a,h)}i()}onCompositionStart(){this.inCompositionMode=!0}onCompositionEnd(){this.inCompositionMode=!1}onCompositionUpdate(t){let{target:e}=t;const{selectionStart:i,selectionEnd:s}=e;this.compositionStart=i,this.compositionEnd=s,this.updateTextareaPosition()}copy(){if(this.selectionStart===this.selectionEnd)return;const{copyPasteData:t}=xe();t.copiedText=this.getSelectedText(),J.disableStyleCopyPaste?t.copiedTextStyle=void 0:t.copiedTextStyle=this.getSelectionStyles(this.selectionStart,this.selectionEnd,!0),this._copyDone=!0}paste(){this.fromPaste=!0}_getWidthBeforeCursor(t,e){let i,s=this._getLineLeftOffset(t);return e>0&&(i=this.__charBounds[t][e-1],s+=i.left+i.width),s}getDownCursorOffset(t,e){const i=this._getSelectionForOffset(t,e),s=this.get2DCursorLocation(i),r=s.lineIndex;if(r===this._textLines.length-1||t.metaKey||t.keyCode===34)return this._text.length-i;const o=s.charIndex,a=this._getWidthBeforeCursor(r,o),l=this._getIndexOnLine(r+1,a);return this._textLines[r].slice(o).length+l+1+this.missingNewlineOffset(r)}_getSelectionForOffset(t,e){return t.shiftKey&&this.selectionStart!==this.selectionEnd&&e?this.selectionEnd:this.selectionStart}getUpCursorOffset(t,e){const i=this._getSelectionForOffset(t,e),s=this.get2DCursorLocation(i),r=s.lineIndex;if(r===0||t.metaKey||t.keyCode===33)return-i;const o=s.charIndex,a=this._getWidthBeforeCursor(r,o),l=this._getIndexOnLine(r-1,a),c=this._textLines[r].slice(0,o),h=this.missingNewlineOffset(r-1);return-this._textLines[r-1].length+l-c.length+(1-h)}_getIndexOnLine(t,e){const i=this._textLines[t];let s,r,o=this._getLineLeftOffset(t),a=0;for(let l=0,c=i.length;l<c;l++)if(s=this.__charBounds[t][l].width,o+=s,o>e){r=!0;const h=o-s,u=o,d=Math.abs(h-e);a=Math.abs(u-e)<d?l:l-1;break}return r||(a=i.length-1),a}moveCursorDown(t){this.selectionStart>=this._text.length&&this.selectionEnd>=this._text.length||this._moveCursorUpOrDown("Down",t)}moveCursorUp(t){this.selectionStart===0&&this.selectionEnd===0||this._moveCursorUpOrDown("Up",t)}_moveCursorUpOrDown(t,e){const i=this["get".concat(t,"CursorOffset")](e,this._selectionDirection===dt);if(e.shiftKey?this.moveCursorWithShift(i):this.moveCursorWithoutShift(i),i!==0){const s=this.text.length;this.selectionStart=Qi(0,this.selectionStart,s),this.selectionEnd=Qi(0,this.selectionEnd,s),this.abortCursorAnimation(),this.initDelayedCursor(),this._fireSelectionChanged(),this._updateTextarea()}}moveCursorWithShift(t){const e=this._selectionDirection===Q?this.selectionStart+t:this.selectionEnd+t;return this.setSelectionStartEndWithShift(this.selectionStart,this.selectionEnd,e),t!==0}moveCursorWithoutShift(t){return t<0?(this.selectionStart+=t,this.selectionEnd=this.selectionStart):(this.selectionEnd+=t,this.selectionStart=this.selectionEnd),t!==0}moveCursorLeft(t){this.selectionStart===0&&this.selectionEnd===0||this._moveCursorLeftOrRight("Left",t)}_move(t,e,i){let s;if(t.altKey)s=this["findWordBoundary".concat(i)](this[e]);else{if(!t.metaKey&&t.keyCode!==35&&t.keyCode!==36)return this[e]+=i==="Left"?-1:1,!0;s=this["findLineBoundary".concat(i)](this[e])}return s!==void 0&&this[e]!==s&&(this[e]=s,!0)}_moveLeft(t,e){return this._move(t,e,"Left")}_moveRight(t,e){return this._move(t,e,"Right")}moveCursorLeftWithoutShift(t){let e=!0;return this._selectionDirection=Q,this.selectionEnd===this.selectionStart&&this.selectionStart!==0&&(e=this._moveLeft(t,"selectionStart")),this.selectionEnd=this.selectionStart,e}moveCursorLeftWithShift(t){return this._selectionDirection===dt&&this.selectionStart!==this.selectionEnd?this._moveLeft(t,"selectionEnd"):this.selectionStart!==0?(this._selectionDirection=Q,this._moveLeft(t,"selectionStart")):void 0}moveCursorRight(t){this.selectionStart>=this._text.length&&this.selectionEnd>=this._text.length||this._moveCursorLeftOrRight("Right",t)}_moveCursorLeftOrRight(t,e){const i="moveCursor".concat(t).concat(e.shiftKey?"WithShift":"WithoutShift");this._currentCursorOpacity=1,this[i](e)&&(this.abortCursorAnimation(),this.initDelayedCursor(),this._fireSelectionChanged(),this._updateTextarea())}moveCursorRightWithShift(t){return this._selectionDirection===Q&&this.selectionStart!==this.selectionEnd?this._moveRight(t,"selectionStart"):this.selectionEnd!==this._text.length?(this._selectionDirection=dt,this._moveRight(t,"selectionEnd")):void 0}moveCursorRightWithoutShift(t){let e=!0;return this._selectionDirection=dt,this.selectionStart===this.selectionEnd?(e=this._moveRight(t,"selectionStart"),this.selectionEnd=this.selectionStart):this.selectionStart=this.selectionEnd,e}}const Uo=n=>!!n.button;class vg extends mg{constructor(){super(...arguments),_(this,"draggableTextDelegate",void 0)}initBehavior(){this.on("mousedown",this._mouseDownHandler),this.on("mousedown:before",this._mouseDownHandlerBefore),this.on("mouseup",this.mouseUpHandler),this.on("mousedblclick",this.doubleClickHandler),this.on("tripleclick",this.tripleClickHandler),this.__lastClickTime=+new Date,this.__lastLastClickTime=+new Date,this.__lastPointer={},this.on("mousedown",this.onMouseDown),this.draggableTextDelegate=new gg(this),super.initBehavior()}shouldStartDragging(){return this.draggableTextDelegate.isActive()}onDragStart(t){return this.draggableTextDelegate.onDragStart(t)}canDrop(t){return this.draggableTextDelegate.canDrop(t)}onMouseDown(t){if(!this.canvas)return;this.__newClickTime=+new Date;const e=t.pointer;this.isTripleClick(e)&&(this.fire("tripleclick",t),bo(t.e)),this.__lastLastClickTime=this.__lastClickTime,this.__lastClickTime=this.__newClickTime,this.__lastPointer=e,this.__lastSelected=this.selected&&!this.getActiveControl()}isTripleClick(t){return this.__newClickTime-this.__lastClickTime<500&&this.__lastClickTime-this.__lastLastClickTime<500&&this.__lastPointer.x===t.x&&this.__lastPointer.y===t.y}doubleClickHandler(t){this.isEditing&&this.selectWord(this.getSelectionStartFromPointer(t.e))}tripleClickHandler(t){this.isEditing&&this.selectLine(this.getSelectionStartFromPointer(t.e))}_mouseDownHandler(t){let{e}=t;this.canvas&&this.editable&&!Uo(e)&&!this.getActiveControl()&&(this.draggableTextDelegate.start(e)||(this.canvas.textEditingManager.register(this),this.selected&&(this.inCompositionMode=!1,this.setCursorByClick(e)),this.isEditing&&(this.__selectionStartOnMouseDown=this.selectionStart,this.selectionStart===this.selectionEnd&&this.abortCursorAnimation(),this.renderCursorOrSelection())))}_mouseDownHandlerBefore(t){let{e}=t;this.canvas&&this.editable&&!Uo(e)&&(this.selected=this===this.canvas._activeObject)}mouseUpHandler(t){let{e,transform:i}=t;const s=this.draggableTextDelegate.end(e);if(this.canvas){this.canvas.textEditingManager.unregister(this);const r=this.canvas._activeObject;if(r&&r!==this)return}!this.editable||this.group&&!this.group.interactive||i&&i.actionPerformed||Uo(e)||s||(this.__lastSelected&&!this.getActiveControl()?(this.selected=!1,this.__lastSelected=!1,this.enterEditing(e),this.selectionStart===this.selectionEnd?this.initDelayedCursor(!0):this.renderCursorOrSelection()):this.selected=!0)}setCursorByClick(t){const e=this.getSelectionStartFromPointer(t),i=this.selectionStart,s=this.selectionEnd;t.shiftKey?this.setSelectionStartEndWithShift(i,s,e):(this.selectionStart=e,this.selectionEnd=e),this.isEditing&&(this._fireSelectionChanged(),this._updateTextarea())}getSelectionStartFromPointer(t){const e=this.canvas.getScenePoint(t).transform(ce(this.calcTransformMatrix())).add(new C(-this._getLeftOffset(),-this._getTopOffset()));let i=0,s=0,r=0;for(let c=0;c<this._textLines.length&&i<=e.y;c++)i+=this.getHeightOfLine(c),r=c,c>0&&(s+=this._textLines[c-1].length+this.missingNewlineOffset(c-1));let o=Math.abs(this._getLineLeftOffset(r));const a=this._textLines[r].length,l=this.__charBounds[r];for(let c=0;c<a;c++){const h=o+l[c].kernedWidth;if(e.x<=h){Math.abs(e.x-h)<=Math.abs(e.x-o)&&s++;break}o=h,s++}return Math.min(this.flipX?a-s:s,this._text.length)}}const Qr="moveCursorUp",tn="moveCursorDown",en="moveCursorLeft",sn="moveCursorRight",rn="exitEditing",_g=b({selectionStart:0,selectionEnd:0,selectionColor:"rgba(17,119,255,0.3)",isEditing:!1,editable:!0,editingBorderColor:"rgba(102,153,255,0.25)",cursorWidth:2,cursorColor:"",cursorDelay:1e3,cursorDuration:600,caching:!0,hiddenTextareaContainer:null,keysMap:{9:rn,27:rn,33:Qr,34:tn,35:sn,36:en,37:en,38:Qr,39:sn,40:tn},keysMapRtl:{9:rn,27:rn,33:Qr,34:tn,35:en,36:sn,37:sn,38:Qr,39:en,40:tn},ctrlKeysMapDown:{65:"selectAll"},ctrlKeysMapUp:{67:"copy",88:"cut"}},{_selectionDirection:null,_reSpace:/\s|\r?\n/,inCompositionMode:!1});class ze extends vg{static getDefaults(){return b(b({},super.getDefaults()),ze.ownDefaults)}get type(){const t=super.type;return t==="itext"?"i-text":t}constructor(t,e){super(t,b(b({},ze.ownDefaults),e)),this.initBehavior()}_set(t,e){return this.isEditing&&this._savedProps&&t in this._savedProps?(this._savedProps[t]=e,this):(t==="canvas"&&(this.canvas instanceof Vo&&this.canvas.textEditingManager.remove(this),e instanceof Vo&&e.textEditingManager.add(this)),super._set(t,e))}setSelectionStart(t){t=Math.max(t,0),this._updateAndFire("selectionStart",t)}setSelectionEnd(t){t=Math.min(t,this.text.length),this._updateAndFire("selectionEnd",t)}_updateAndFire(t,e){this[t]!==e&&(this._fireSelectionChanged(),this[t]=e),this._updateTextarea()}_fireSelectionChanged(){this.fire("selection:changed"),this.canvas&&this.canvas.fire("text:selection:changed",{target:this})}initDimensions(){this.isEditing&&this.initDelayedCursor(),super.initDimensions()}getSelectionStyles(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:this.selectionStart||0,e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:this.selectionEnd,i=arguments.length>2?arguments[2]:void 0;return super.getSelectionStyles(t,e,i)}setSelectionStyles(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:this.selectionStart||0,i=arguments.length>2&&arguments[2]!==void 0?arguments[2]:this.selectionEnd;return super.setSelectionStyles(t,e,i)}get2DCursorLocation(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:this.selectionStart,e=arguments.length>1?arguments[1]:void 0;return super.get2DCursorLocation(t,e)}render(t){super.render(t),this.cursorOffsetCache={},this.renderCursorOrSelection()}toCanvasElement(t){const e=this.isEditing;this.isEditing=!1;const i=super.toCanvasElement(t);return this.isEditing=e,i}renderCursorOrSelection(){if(!this.isEditing)return;const t=this.clearContextTop(!0);if(!t)return;const e=this._getCursorBoundaries();this.selectionStart!==this.selectionEnd||this.inCompositionMode?this.renderSelection(t,e):this.renderCursor(t,e),this.canvas.contextTopDirty=!0,t.restore()}_getCursorBoundaries(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:this.selectionStart,e=arguments.length>1?arguments[1]:void 0;const i=this._getLeftOffset(),s=this._getTopOffset(),r=this._getCursorBoundariesOffsets(t,e);return{left:i,top:s,leftOffset:r.left,topOffset:r.top}}_getCursorBoundariesOffsets(t,e){return e?this.__getCursorBoundariesOffsets(t):this.cursorOffsetCache&&"top"in this.cursorOffsetCache?this.cursorOffsetCache:this.cursorOffsetCache=this.__getCursorBoundariesOffsets(t)}__getCursorBoundariesOffsets(t){let e=0,i=0;const{charIndex:s,lineIndex:r}=this.get2DCursorLocation(t);for(let c=0;c<r;c++)e+=this.getHeightOfLine(c);const o=this._getLineLeftOffset(r),a=this.__charBounds[r][s];a&&(i=a.left),this.charSpacing!==0&&s===this._textLines[r].length&&(i-=this._getWidthOfCharSpacing());const l={top:e,left:o+(i>0?i:0)};return this.direction==="rtl"&&(this.textAlign===dt||this.textAlign===we||this.textAlign===Vs?l.left*=-1:this.textAlign===Q||this.textAlign===Zr?l.left=o-(i>0?i:0):this.textAlign!==G&&this.textAlign!==zs||(l.left=o-(i>0?i:0))),l}renderCursorAt(t){this._renderCursor(this.canvas.contextTop,this._getCursorBoundaries(t,!0),t)}renderCursor(t,e){this._renderCursor(t,e,this.selectionStart)}getCursorRenderingData(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:this.selectionStart,e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:this._getCursorBoundaries(t);const i=this.get2DCursorLocation(t),s=i.lineIndex,r=i.charIndex>0?i.charIndex-1:0,o=this.getValueOfPropertyAt(s,r,"fontSize"),a=this.getObjectScaling().x*this.canvas.getZoom(),l=this.cursorWidth/a,c=this.getValueOfPropertyAt(s,r,"deltaY"),h=e.topOffset+(1-this._fontSizeFraction)*this.getHeightOfLine(s)/this.lineHeight-o*(1-this._fontSizeFraction);return{color:this.cursorColor||this.getValueOfPropertyAt(s,r,"fill"),opacity:this._currentCursorOpacity,left:e.left+e.leftOffset-l/2,top:h+e.top+c,width:l,height:o}}_renderCursor(t,e,i){const{color:s,opacity:r,left:o,top:a,width:l,height:c}=this.getCursorRenderingData(i,e);t.fillStyle=s,t.globalAlpha=r,t.fillRect(o,a,l,c)}renderSelection(t,e){const i={selectionStart:this.inCompositionMode?this.hiddenTextarea.selectionStart:this.selectionStart,selectionEnd:this.inCompositionMode?this.hiddenTextarea.selectionEnd:this.selectionEnd};this._renderSelection(t,i,e)}renderDragSourceEffect(){const t=this.draggableTextDelegate.getDragStartSelection();this._renderSelection(this.canvas.contextTop,t,this._getCursorBoundaries(t.selectionStart,!0))}renderDropTargetEffect(t){const e=this.getSelectionStartFromPointer(t);this.renderCursorAt(e)}_renderSelection(t,e,i){const s=e.selectionStart,r=e.selectionEnd,o=this.textAlign.includes(we),a=this.get2DCursorLocation(s),l=this.get2DCursorLocation(r),c=a.lineIndex,h=l.lineIndex,u=a.charIndex<0?0:a.charIndex,d=l.charIndex<0?0:l.charIndex;for(let f=c;f<=h;f++){const g=this._getLineLeftOffset(f)||0;let p=this.getHeightOfLine(f),m=0,v=0,y=0;if(f===c&&(v=this.__charBounds[c][u].left),f>=c&&f<h)y=o&&!this.isEndOfWrapping(f)?this.width:this.getLineWidth(f)||5;else if(f===h)if(d===0)y=this.__charBounds[h][d].left;else{const S=this._getWidthOfCharSpacing();y=this.__charBounds[h][d-1].left+this.__charBounds[h][d-1].width-S}m=p,(this.lineHeight<1||f===h&&this.lineHeight>1)&&(p/=this.lineHeight);let x=i.left+g+v,E=p,T=0;const k=y-v;this.inCompositionMode?(t.fillStyle=this.compositionColor||"black",E=1,T=p):t.fillStyle=this.selectionColor,this.direction==="rtl"&&(this.textAlign===dt||this.textAlign===we||this.textAlign===Vs?x=this.width-x-k:this.textAlign===Q||this.textAlign===Zr?x=i.left+g-y:this.textAlign!==G&&this.textAlign!==zs||(x=i.left+g-y)),t.fillRect(x,i.top+i.topOffset+T,k,E),i.topOffset+=m}}getCurrentCharFontSize(){const t=this._getCurrentCharIndex();return this.getValueOfPropertyAt(t.l,t.c,"fontSize")}getCurrentCharColor(){const t=this._getCurrentCharIndex();return this.getValueOfPropertyAt(t.l,t.c,bt)}_getCurrentCharIndex(){const t=this.get2DCursorLocation(this.selectionStart,!0),e=t.charIndex>0?t.charIndex-1:0;return{l:t.lineIndex,c:e}}dispose(){this.exitEditingImpl(),this.draggableTextDelegate.dispose(),super.dispose()}}_(ze,"ownDefaults",_g),_(ze,"type","IText"),F.setClass(ze),F.setClass(ze,"i-text");class li extends ze{static getDefaults(){return b(b({},super.getDefaults()),li.ownDefaults)}constructor(t,e){super(t,b(b({},li.ownDefaults),e))}static createControls(){return{controls:Gd()}}initDimensions(){this.initialized&&(this.isEditing&&this.initDelayedCursor(),this._clearCache(),this.dynamicMinWidth=0,this._styleMap=this._generateStyleMap(this._splitText()),this.dynamicMinWidth>this.width&&this._set("width",this.dynamicMinWidth),this.textAlign.includes(we)&&this.enlargeSpaces(),this.height=this.calcTextHeight())}_generateStyleMap(t){let e=0,i=0,s=0;const r={};for(let o=0;o<t.graphemeLines.length;o++)t.graphemeText[s]===`
183
- `&&o>0?(i=0,s++,e++):!this.splitByGrapheme&&this._reSpaceAndTab.test(t.graphemeText[s])&&o>0&&(i++,s++),r[o]={line:e,offset:i},s+=t.graphemeLines[o].length,i+=t.graphemeLines[o].length;return r}styleHas(t,e){if(this._styleMap&&!this.isWrapping){const i=this._styleMap[e];i&&(e=i.line)}return super.styleHas(t,e)}isEmptyStyles(t){if(!this.styles)return!0;let e,i=0,s=t+1,r=!1;const o=this._styleMap[t],a=this._styleMap[t+1];o&&(t=o.line,i=o.offset),a&&(s=a.line,r=s===t,e=a.offset);const l=t===void 0?this.styles:{line:this.styles[t]};for(const c in l)for(const h in l[c]){const u=parseInt(h,10);if(u>=i&&(!r||u<e))for(const d in l[c][h])return!1}return!0}_getStyleDeclaration(t,e){if(this._styleMap&&!this.isWrapping){const i=this._styleMap[t];if(!i)return{};t=i.line,e=i.offset+e}return super._getStyleDeclaration(t,e)}_setStyleDeclaration(t,e,i){const s=this._styleMap[t];super._setStyleDeclaration(s.line,s.offset+e,i)}_deleteStyleDeclaration(t,e){const i=this._styleMap[t];super._deleteStyleDeclaration(i.line,i.offset+e)}_getLineStyle(t){const e=this._styleMap[t];return!!this.styles[e.line]}_setLineStyle(t){const e=this._styleMap[t];super._setLineStyle(e.line)}_wrapText(t,e){this.isWrapping=!0;const i=this.getGraphemeDataForRender(t),s=[];for(let r=0;r<i.wordsData.length;r++)s.push(...this._wrapLine(r,e,i));return this.isWrapping=!1,s}getGraphemeDataForRender(t){const e=this.splitByGrapheme,i=e?"":" ";let s=0;return{wordsData:t.map((r,o)=>{let a=0;const l=e?this.graphemeSplit(r):this.wordSplit(r);return l.length===0?[{word:[],width:0}]:l.map(c=>{const h=e?[c]:this.graphemeSplit(c),u=this._measureWord(h,o,a);return s=Math.max(u,s),a+=h.length+i.length,{word:h,width:u}})}),largestWordWidth:s}}_measureWord(t,e){let i,s=arguments.length>2&&arguments[2]!==void 0?arguments[2]:0,r=0;for(let o=0,a=t.length;o<a;o++)r+=this._getGraphemeBox(t[o],e,o+s,i,!0).kernedWidth,i=t[o];return r}wordSplit(t){return t.split(this._wordJoiners)}_wrapLine(t,e,i){let{largestWordWidth:s,wordsData:r}=i,o=arguments.length>3&&arguments[3]!==void 0?arguments[3]:0;const a=this._getWidthOfCharSpacing(),l=this.splitByGrapheme,c=[],h=l?"":" ";let u=0,d=[],f=0,g=0,p=!0;e-=o;const m=Math.max(e,s,this.dynamicMinWidth),v=r[t];let y;for(f=0,y=0;y<v.length;y++){const{word:x,width:E}=v[y];f+=x.length,u+=g+E-a,u>m&&!p?(c.push(d),d=[],u=E,p=!0):u+=a,p||l||d.push(h),d=d.concat(x),g=l?0:this._measureWord([h],t,f),f++,p=!1}return y&&c.push(d),s+o>this.dynamicMinWidth&&(this.dynamicMinWidth=s-a+o),c}isEndOfWrapping(t){return!this._styleMap[t+1]||this._styleMap[t+1].line!==this._styleMap[t].line}missingNewlineOffset(t,e){return this.splitByGrapheme&&!e?this.isEndOfWrapping(t)?1:0:1}_splitTextIntoLines(t){const e=super._splitTextIntoLines(t),i=this._wrapText(e.lines,this.width),s=new Array(i.length);for(let r=0;r<i.length;r++)s[r]=i[r].join("");return e.lines=s,e.graphemeLines=i,e}getMinWidth(){return Math.max(this.minWidth,this.dynamicMinWidth)}_removeExtraneousStyles(){const t=new Map;for(const e in this._styleMap){const i=parseInt(e,10);if(this._textLines[i]){const s=this._styleMap[e].line;t.set("".concat(s),!0)}}for(const e in this.styles)t.has(e)||delete this.styles[e]}toObject(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[];return super.toObject(["minWidth","splitByGrapheme",...t])}}_(li,"type","Textbox"),_(li,"textLayoutProperties",[...ze.textLayoutProperties,"width"]),_(li,"ownDefaults",{minWidth:20,dynamicMinWidth:2,lockScalingFlip:!0,noScaleCache:!1,_wordJoiners:/[ \t\r]/,splitByGrapheme:!1}),F.setClass(li);class Ic extends Gr{shouldPerformLayout(t){return!!t.target.clipPath&&super.shouldPerformLayout(t)}shouldLayoutClipPath(){return!1}calcLayoutResult(t,e){const{target:i}=t,{clipPath:s,group:r}=i;if(!s||!this.shouldPerformLayout(t))return;const{width:o,height:a}=Le(lc(i,s)),l=new C(o,a);if(s.absolutePositioned)return{center:Zi(s.getRelativeCenterPoint(),void 0,r?r.calcTransformMatrix():void 0),size:l};{const c=s.getRelativeCenterPoint().transform(i.calcOwnMatrix(),!0);if(this.shouldPerformLayout(t)){const{center:h=new C,correction:u=new C}=this.calcBoundingBox(e,t)||{};return{center:h.add(c),correction:u.subtract(c),size:l}}return{center:i.getRelativeCenterPoint().add(c),size:l}}}}_(Ic,"type","clip-path"),F.setClass(Ic);class Lc extends Gr{getInitialSize(t,e){let{target:i}=t,{size:s}=e;return new C(i.width||s.x,i.height||s.y)}}_(Lc,"type","fixed"),F.setClass(Lc);class bg extends Bs{subscribeTargets(t){const e=t.target;t.targets.reduce((i,s)=>(s.parent&&i.add(s.parent),i),new Set).forEach(i=>{i.layoutManager.subscribeTargets({target:i,targets:[e]})})}unsubscribeTargets(t){const e=t.target,i=e.getObjects();t.targets.reduce((s,r)=>(r.parent&&s.add(r.parent),s),new Set).forEach(s=>{!i.some(r=>r.parent===s)&&s.layoutManager.unsubscribeTargets({target:s,targets:[e]})})}}class Mi extends Oi{static getDefaults(){return b(b({},super.getDefaults()),Mi.ownDefaults)}constructor(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[],e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};super(),Object.assign(this,Mi.ownDefaults),this.setOptions(e);const{left:i,top:s,layoutManager:r}=e;this.groupInit(t,{left:i,top:s,layoutManager:r??new bg})}_shouldSetNestedCoords(){return!0}__objectSelectionMonitor(){}multiSelectAdd(){for(var t=arguments.length,e=new Array(t),i=0;i<t;i++)e[i]=arguments[i];this.multiSelectionStacking==="selection-order"?this.add(...e):e.forEach(s=>{const r=this._objects.findIndex(a=>a.isInFrontOf(s)),o=r===-1?this.size():r;this.insertAt(o,s)})}canEnterGroup(t){return this.getObjects().some(e=>e.isDescendantOf(t)||t.isDescendantOf(e))?(si("error","ActiveSelection: circular object trees are not supported, this call has no effect"),!1):super.canEnterGroup(t)}enterGroup(t,e){t.parent&&t.parent===t.group?t.parent._exitGroup(t):t.group&&t.parent!==t.group&&t.group.remove(t),this._enterGroup(t,e)}exitGroup(t,e){this._exitGroup(t,e),t.parent&&t.parent._enterGroup(t,!0)}_onAfterObjectsChange(t,e){super._onAfterObjectsChange(t,e);const i=new Set;e.forEach(s=>{const{parent:r}=s;r&&i.add(r)}),t===Ro?i.forEach(s=>{s._onAfterObjectsChange(Yr,e)}):i.forEach(s=>{s._set("dirty",!0)})}onDeselect(){return this.removeAll(),!1}toString(){return"#<ActiveSelection: (".concat(this.complexity(),")>")}shouldCache(){return!1}isOnACache(){return!1}_renderControls(t,e,i){t.save(),t.globalAlpha=this.isMoving?this.borderOpacityWhenMoving:1;const s=b(b({hasControls:!1},i),{},{forActiveSelection:!0});for(let r=0;r<this._objects.length;r++)this._objects[r]._renderControls(t,s);super._renderControls(t,e),t.restore()}}_(Mi,"type","ActiveSelection"),_(Mi,"ownDefaults",{multiSelectionStacking:"canvas-stacking"}),F.setClass(Mi),F.setClass(Mi,"activeSelection");class yg{constructor(){_(this,"resources",{})}applyFilters(t,e,i,s,r){const o=r.getContext("2d");if(!o)return;o.drawImage(e,0,0,i,s);const a={sourceWidth:i,sourceHeight:s,imageData:o.getImageData(0,0,i,s),originalEl:e,originalImageData:o.getImageData(0,0,i,s),canvasEl:r,ctx:o,filterBackend:this};t.forEach(c=>{c.applyTo(a)});const{imageData:l}=a;return l.width===i&&l.height===s||(r.width=l.width,r.height=l.height),o.putImageData(l,0,0),a}}class jc{constructor(){let{tileSize:t=J.textureSize}=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};_(this,"aPosition",new Float32Array([0,0,0,1,1,0,1,1])),_(this,"resources",{}),this.tileSize=t,this.setupGLContext(t,t),this.captureGPUInfo()}setupGLContext(t,e){this.dispose(),this.createWebGLCanvas(t,e)}createWebGLCanvas(t,e){const i=Ce({width:t,height:e}),s=i.getContext("webgl",{alpha:!0,premultipliedAlpha:!1,depth:!1,stencil:!1,antialias:!1});s&&(s.clearColor(0,0,0,0),this.canvas=i,this.gl=s)}applyFilters(t,e,i,s,r,o){const a=this.gl,l=r.getContext("2d");if(!a||!l)return;let c;o&&(c=this.getCachedTexture(o,e));const h={originalWidth:e.width||e.naturalWidth||0,originalHeight:e.height||e.naturalHeight||0,sourceWidth:i,sourceHeight:s,destinationWidth:i,destinationHeight:s,context:a,sourceTexture:this.createTexture(a,i,s,c?void 0:e),targetTexture:this.createTexture(a,i,s),originalTexture:c||this.createTexture(a,i,s,c?void 0:e),passes:t.length,webgl:!0,aPosition:this.aPosition,programCache:this.programCache,pass:0,filterBackend:this,targetCanvas:r},u=a.createFramebuffer();return a.bindFramebuffer(a.FRAMEBUFFER,u),t.forEach(d=>{d&&d.applyTo(h)}),function(d){const f=d.targetCanvas,g=f.width,p=f.height,m=d.destinationWidth,v=d.destinationHeight;g===m&&p===v||(f.width=m,f.height=v)}(h),this.copyGLTo2D(a,h),a.bindTexture(a.TEXTURE_2D,null),a.deleteTexture(h.sourceTexture),a.deleteTexture(h.targetTexture),a.deleteFramebuffer(u),l.setTransform(1,0,0,1,0,0),h}dispose(){this.canvas&&(this.canvas=null,this.gl=null),this.clearWebGLCaches()}clearWebGLCaches(){this.programCache={},this.textureCache={}}createTexture(t,e,i,s,r){const{NEAREST:o,TEXTURE_2D:a,RGBA:l,UNSIGNED_BYTE:c,CLAMP_TO_EDGE:h,TEXTURE_MAG_FILTER:u,TEXTURE_MIN_FILTER:d,TEXTURE_WRAP_S:f,TEXTURE_WRAP_T:g}=t,p=t.createTexture();return t.bindTexture(a,p),t.texParameteri(a,u,r||o),t.texParameteri(a,d,r||o),t.texParameteri(a,f,h),t.texParameteri(a,g,h),s?t.texImage2D(a,0,l,l,c,s):t.texImage2D(a,0,l,e,i,0,l,c,null),p}getCachedTexture(t,e,i){const{textureCache:s}=this;if(s[t])return s[t];{const r=this.createTexture(this.gl,e.width,e.height,e,i);return r&&(s[t]=r),r}}evictCachesForKey(t){this.textureCache[t]&&(this.gl.deleteTexture(this.textureCache[t]),delete this.textureCache[t])}copyGLTo2D(t,e){const i=t.canvas,s=e.targetCanvas,r=s.getContext("2d");if(!r)return;r.translate(0,s.height),r.scale(1,-1);const o=i.height-s.height;r.drawImage(i,0,o,s.width,s.height,0,0,s.width,s.height)}copyGLTo2DPutImageData(t,e){const i=e.targetCanvas.getContext("2d"),s=e.destinationWidth,r=e.destinationHeight,o=s*r*4;if(!i)return;const a=new Uint8Array(this.imageBuffer,0,o),l=new Uint8ClampedArray(this.imageBuffer,0,o);t.readPixels(0,0,s,r,t.RGBA,t.UNSIGNED_BYTE,a);const c=new ImageData(l,s,r);i.putImageData(c,0,0)}captureGPUInfo(){if(this.gpuInfo)return this.gpuInfo;const t=this.gl,e={renderer:"",vendor:""};if(!t)return e;const i=t.getExtension("WEBGL_debug_renderer_info");if(i){const s=t.getParameter(i.UNMASKED_RENDERER_WEBGL),r=t.getParameter(i.UNMASKED_VENDOR_WEBGL);s&&(e.renderer=s.toLowerCase()),r&&(e.vendor=r.toLowerCase())}return this.gpuInfo=e,e}}let Go;function xg(){const{WebGLProbe:n}=xe();return n.queryWebGL(le()),J.enableGLFiltering&&n.isSupported(J.textureSize)?new jc({tileSize:J.textureSize}):new yg}function Xo(){return!Go&&(!(arguments.length>0&&arguments[0]!==void 0)||arguments[0])&&(Go=xg()),Go}const Cg=["filters","resizeFilter","src","crossOrigin","type"],Fc=["cropX","cropY"];class Xt extends Ot{static getDefaults(){return b(b({},super.getDefaults()),Xt.ownDefaults)}constructor(t,e){super(),_(this,"_lastScaleX",1),_(this,"_lastScaleY",1),_(this,"_filterScalingX",1),_(this,"_filterScalingY",1),this.filters=[],Object.assign(this,Xt.ownDefaults),this.setOptions(e),this.cacheKey="texture".concat(ni()),this.setElement(typeof t=="string"?(this.canvas&&he(this.canvas.getElement())||Yi()).getElementById(t):t,e)}getElement(){return this._element}setElement(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};this.removeTexture(this.cacheKey),this.removeTexture("".concat(this.cacheKey,"_filtered")),this._element=t,this._originalElement=t,this._setWidthHeight(e),t.classList.add(Xt.CSS_CANVAS),this.filters.length!==0&&this.applyFilters(),this.resizeFilter&&this.applyResizeFilters()}removeTexture(t){const e=Xo(!1);e instanceof jc&&e.evictCachesForKey(t)}dispose(){super.dispose(),this.removeTexture(this.cacheKey),this.removeTexture("".concat(this.cacheKey,"_filtered")),this._cacheContext=null,["_originalElement","_element","_filteredEl","_cacheCanvas"].forEach(t=>{const e=this[t];e&&xe().dispose(e),this[t]=void 0})}getCrossOrigin(){return this._originalElement&&(this._originalElement.crossOrigin||null)}getOriginalSize(){const t=this.getElement();return t?{width:t.naturalWidth||t.width,height:t.naturalHeight||t.height}:{width:0,height:0}}_stroke(t){if(!this.stroke||this.strokeWidth===0)return;const e=this.width/2,i=this.height/2;t.beginPath(),t.moveTo(-e,-i),t.lineTo(e,-i),t.lineTo(e,i),t.lineTo(-e,i),t.lineTo(-e,-i),t.closePath()}toObject(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[];const e=[];return this.filters.forEach(i=>{i&&e.push(i.toObject())}),b(b({},super.toObject([...Fc,...t])),{},{src:this.getSrc(),crossOrigin:this.getCrossOrigin(),filters:e},this.resizeFilter?{resizeFilter:this.resizeFilter.toObject()}:{})}hasCrop(){return!!this.cropX||!!this.cropY||this.width<this._element.width||this.height<this._element.height}_toSVG(){const t=[],e=this._element,i=-this.width/2,s=-this.height/2;let r=[],o=[],a="",l="";if(!e)return[];if(this.hasCrop()){const c=ni();r.push('<clipPath id="imageCrop_'+c+`">
184
- `,' <rect x="'+i+'" y="'+s+'" width="'+this.width+'" height="'+this.height+`" />
185
- `,`</clipPath>
186
- `),a=' clip-path="url(#imageCrop_'+c+')" '}if(this.imageSmoothing||(l=' image-rendering="optimizeSpeed"'),t.push(" <image ","COMMON_PARTS",'xlink:href="'.concat(this.getSvgSrc(!0),'" x="').concat(i-this.cropX,'" y="').concat(s-this.cropY,'" width="').concat(e.width||e.naturalWidth,'" height="').concat(e.height||e.naturalHeight,'"').concat(l).concat(a,`></image>
187
- `)),this.stroke||this.strokeDashArray){const c=this.fill;this.fill=null,o=[' <rect x="'.concat(i,'" y="').concat(s,'" width="').concat(this.width,'" height="').concat(this.height,'" style="').concat(this.getSvgStyles(),`" />
188
- `)],this.fill=c}return r=this.paintFirst!==bt?r.concat(o,t):r.concat(t,o),r}getSrc(t){const e=t?this._element:this._originalElement;return e?e.toDataURL?e.toDataURL():this.srcFromAttribute?e.getAttribute("src")||"":e.src:this.src||""}getSvgSrc(t){return this.getSrc(t)}setSrc(t){let{crossOrigin:e,signal:i}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return Lr(t,{crossOrigin:e,signal:i}).then(s=>{e!==void 0&&this.set({crossOrigin:e}),this.setElement(s)})}toString(){return'#<Image: { src: "'.concat(this.getSrc(),'" }>')}applyResizeFilters(){const t=this.resizeFilter,e=this.minimumScaleTrigger,i=this.getTotalObjectScaling(),s=i.x,r=i.y,o=this._filteredEl||this._originalElement;if(this.group&&this.set("dirty",!0),!t||s>e&&r>e)return this._element=o,this._filterScalingX=1,this._filterScalingY=1,this._lastScaleX=s,void(this._lastScaleY=r);const a=Ce(o),{width:l,height:c}=o;this._element=a,this._lastScaleX=t.scaleX=s,this._lastScaleY=t.scaleY=r,Xo().applyFilters([t],o,l,c,this._element),this._filterScalingX=a.width/this._originalElement.width,this._filterScalingY=a.height/this._originalElement.height}applyFilters(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:this.filters||[];if(t=t.filter(r=>r&&!r.isNeutralState()),this.set("dirty",!0),this.removeTexture("".concat(this.cacheKey,"_filtered")),t.length===0)return this._element=this._originalElement,this._filteredEl=void 0,this._filterScalingX=1,void(this._filterScalingY=1);const e=this._originalElement,i=e.naturalWidth||e.width,s=e.naturalHeight||e.height;if(this._element===this._originalElement){const r=Ce({width:i,height:s});this._element=r,this._filteredEl=r}else this._filteredEl&&(this._element=this._filteredEl,this._filteredEl.getContext("2d").clearRect(0,0,i,s),this._lastScaleX=1,this._lastScaleY=1);Xo().applyFilters(t,this._originalElement,i,s,this._element),this._originalElement.width===this._element.width&&this._originalElement.height===this._element.height||(this._filterScalingX=this._element.width/this._originalElement.width,this._filterScalingY=this._element.height/this._originalElement.height)}_render(t){t.imageSmoothingEnabled=this.imageSmoothing,this.isMoving!==!0&&this.resizeFilter&&this._needsResize()&&this.applyResizeFilters(),this._stroke(t),this._renderPaintInOrder(t)}drawCacheOnCanvas(t){t.imageSmoothingEnabled=this.imageSmoothing,super.drawCacheOnCanvas(t)}shouldCache(){return this.needsItsOwnCache()}_renderFill(t){const e=this._element;if(!e)return;const i=this._filterScalingX,s=this._filterScalingY,r=this.width,o=this.height,a=Math.max(this.cropX,0),l=Math.max(this.cropY,0),c=e.naturalWidth||e.width,h=e.naturalHeight||e.height,u=a*i,d=l*s,f=Math.min(r*i,c-u),g=Math.min(o*s,h-d),p=-r/2,m=-o/2,v=Math.min(r,c/i-a),y=Math.min(o,h/s-l);e&&t.drawImage(e,u,d,f,g,p,m,v,y)}_needsResize(){const t=this.getTotalObjectScaling();return t.x!==this._lastScaleX||t.y!==this._lastScaleY}_resetWidthHeight(){this.set(this.getOriginalSize())}_setWidthHeight(){let{width:t,height:e}=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};const i=this.getOriginalSize();this.width=t||i.width,this.height=e||i.height}parsePreserveAspectRatioAttribute(){const t=sd(this.preserveAspectRatio||""),e=this.width,i=this.height,s={width:e,height:i};let r,o=this._element.width,a=this._element.height,l=1,c=1,h=0,u=0,d=0,f=0;return!t||t.alignX===Rt&&t.alignY===Rt?(l=e/o,c=i/a):(t.meetOrSlice==="meet"&&(l=c=Of(this._element,s),r=(e-o*l)/2,t.alignX==="Min"&&(h=-r),t.alignX==="Max"&&(h=r),r=(i-a*c)/2,t.alignY==="Min"&&(u=-r),t.alignY==="Max"&&(u=r)),t.meetOrSlice==="slice"&&(l=c=Af(this._element,s),r=o-e/l,t.alignX==="Mid"&&(d=r/2),t.alignX==="Max"&&(d=r),r=a-i/c,t.alignY==="Mid"&&(f=r/2),t.alignY==="Max"&&(f=r),o=e/l,a=i/c)),{width:o,height:a,scaleX:l,scaleY:c,offsetLeft:h,offsetTop:u,cropX:d,cropY:f}}static fromObject(t,e){let{filters:i,resizeFilter:s,src:r,crossOrigin:o,type:a}=t,l=rt(t,Cg);return Promise.all([Lr(r,b(b({},e),{},{crossOrigin:o})),i&&Is(i,e),s&&Is([s],e),jr(l,e)]).then(c=>{let[h,u=[],[d]=[],f={}]=c;return new this(h,b(b({},l),{},{src:r,filters:u,resizeFilter:d},f))})}static fromURL(t){let{crossOrigin:e=null,signal:i}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},s=arguments.length>2?arguments[2]:void 0;return Lr(t,{crossOrigin:e,signal:i}).then(r=>new this(r,s))}static async fromElement(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},i=arguments.length>2?arguments[2]:void 0;const s=Ne(t,this.ATTRIBUTE_NAMES,i);return this.fromURL(s["xlink:href"],e,s).catch(r=>(si("log","Unable to parse Image",r),null))}}_(Xt,"type","Image"),_(Xt,"cacheProperties",[...Fe,...Fc]),_(Xt,"ownDefaults",{strokeWidth:0,srcFromAttribute:!1,minimumScaleTrigger:.5,cropX:0,cropY:0,imageSmoothing:!0}),_(Xt,"CSS_CANVAS","canvas-img"),_(Xt,"ATTRIBUTE_NAMES",[...oi,"x","y","width","height","preserveAspectRatio","xlink:href","crossOrigin","image-rendering"]),F.setClass(Xt),F.setSVGClass(Xt),Vr(["pattern","defs","symbol","metadata","clipPath","mask","desc"]);const nn=n=>n.webgl!==void 0,Ko="precision highp float",Sg=`
189
- `.concat(Ko,`;
190
- varying vec2 vTexCoord;
191
- uniform sampler2D uTexture;
192
- void main() {
193
- gl_FragColor = texture2D(uTexture, vTexCoord);
194
- }`),wg=["type"],Tg=["type"],Eg=new RegExp(Ko,"g");class yt{get type(){return this.constructor.type}constructor(){let t=rt(arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},wg);Object.assign(this,this.constructor.defaults,t)}getFragmentSource(){return Sg}getVertexSource(){return`
195
- attribute vec2 aPosition;
196
- varying vec2 vTexCoord;
197
- void main() {
198
- vTexCoord = aPosition;
199
- gl_Position = vec4(aPosition * 2.0 - 1.0, 0.0, 1.0);
200
- }`}createProgram(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:this.getFragmentSource(),i=arguments.length>2&&arguments[2]!==void 0?arguments[2]:this.getVertexSource();const{WebGLProbe:{GLPrecision:s="highp"}}=xe();s!=="highp"&&(e=e.replace(Eg,Ko.replace("highp",s)));const r=t.createShader(t.VERTEX_SHADER),o=t.createShader(t.FRAGMENT_SHADER),a=t.createProgram();if(!r||!o||!a)throw new ye("Vertex, fragment shader or program creation error");if(t.shaderSource(r,i),t.compileShader(r),!t.getShaderParameter(r,t.COMPILE_STATUS))throw new ye("Vertex shader compile error for ".concat(this.type,": ").concat(t.getShaderInfoLog(r)));if(t.shaderSource(o,e),t.compileShader(o),!t.getShaderParameter(o,t.COMPILE_STATUS))throw new ye("Fragment shader compile error for ".concat(this.type,": ").concat(t.getShaderInfoLog(o)));if(t.attachShader(a,r),t.attachShader(a,o),t.linkProgram(a),!t.getProgramParameter(a,t.LINK_STATUS))throw new ye('Shader link error for "'.concat(this.type,'" ').concat(t.getProgramInfoLog(a)));const l=this.getUniformLocations(t,a)||{};return l.uStepW=t.getUniformLocation(a,"uStepW"),l.uStepH=t.getUniformLocation(a,"uStepH"),{program:a,attributeLocations:this.getAttributeLocations(t,a),uniformLocations:l}}getAttributeLocations(t,e){return{aPosition:t.getAttribLocation(e,"aPosition")}}getUniformLocations(t,e){const i=this.constructor.uniformLocations,s={};for(let r=0;r<i.length;r++)s[i[r]]=t.getUniformLocation(e,i[r]);return s}sendAttributeData(t,e,i){const s=e.aPosition,r=t.createBuffer();t.bindBuffer(t.ARRAY_BUFFER,r),t.enableVertexAttribArray(s),t.vertexAttribPointer(s,2,t.FLOAT,!1,0,0),t.bufferData(t.ARRAY_BUFFER,i,t.STATIC_DRAW)}_setupFrameBuffer(t){const e=t.context;if(t.passes>1){const i=t.destinationWidth,s=t.destinationHeight;t.sourceWidth===i&&t.sourceHeight===s||(e.deleteTexture(t.targetTexture),t.targetTexture=t.filterBackend.createTexture(e,i,s)),e.framebufferTexture2D(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,t.targetTexture,0)}else e.bindFramebuffer(e.FRAMEBUFFER,null),e.finish()}_swapTextures(t){t.passes--,t.pass++;const e=t.targetTexture;t.targetTexture=t.sourceTexture,t.sourceTexture=e}isNeutralState(t){return!1}applyTo(t){nn(t)?(this._setupFrameBuffer(t),this.applyToWebGL(t),this._swapTextures(t)):this.applyTo2d(t)}applyTo2d(t){}getCacheKey(){return this.type}retrieveShader(t){const e=this.getCacheKey();return t.programCache[e]||(t.programCache[e]=this.createProgram(t.context)),t.programCache[e]}applyToWebGL(t){const e=t.context,i=this.retrieveShader(t);t.pass===0&&t.originalTexture?e.bindTexture(e.TEXTURE_2D,t.originalTexture):e.bindTexture(e.TEXTURE_2D,t.sourceTexture),e.useProgram(i.program),this.sendAttributeData(e,i.attributeLocations,t.aPosition),e.uniform1f(i.uniformLocations.uStepW,1/t.sourceWidth),e.uniform1f(i.uniformLocations.uStepH,1/t.sourceHeight),this.sendUniformData(e,i.uniformLocations),e.viewport(0,0,t.destinationWidth,t.destinationHeight),e.drawArrays(e.TRIANGLE_STRIP,0,4)}bindAdditionalTexture(t,e,i){t.activeTexture(i),t.bindTexture(t.TEXTURE_2D,e),t.activeTexture(t.TEXTURE0)}unbindAdditionalTexture(t,e){t.activeTexture(e),t.bindTexture(t.TEXTURE_2D,null),t.activeTexture(t.TEXTURE0)}sendUniformData(t,e){}createHelpLayer(t){if(!t.helpLayer){const{sourceWidth:e,sourceHeight:i}=t,s=Ce({width:e,height:i});t.helpLayer=s}}toObject(){const t=Object.keys(this.constructor.defaults||{});return b({type:this.type},t.reduce((e,i)=>(e[i]=this[i],e),{}))}toJSON(){return this.toObject()}static async fromObject(t,e){return new this(rt(t,Tg))}}_(yt,"type","BaseFilter"),_(yt,"uniformLocations",[]);const Og={multiply:`gl_FragColor.rgb *= uColor.rgb;
201
- `,screen:`gl_FragColor.rgb = 1.0 - (1.0 - gl_FragColor.rgb) * (1.0 - uColor.rgb);
202
- `,add:`gl_FragColor.rgb += uColor.rgb;
203
- `,difference:`gl_FragColor.rgb = abs(gl_FragColor.rgb - uColor.rgb);
204
- `,subtract:`gl_FragColor.rgb -= uColor.rgb;
205
- `,lighten:`gl_FragColor.rgb = max(gl_FragColor.rgb, uColor.rgb);
206
- `,darken:`gl_FragColor.rgb = min(gl_FragColor.rgb, uColor.rgb);
207
- `,exclusion:`gl_FragColor.rgb += uColor.rgb - 2.0 * (uColor.rgb * gl_FragColor.rgb);
208
- `,overlay:`
209
- if (uColor.r < 0.5) {
210
- gl_FragColor.r *= 2.0 * uColor.r;
211
- } else {
212
- gl_FragColor.r = 1.0 - 2.0 * (1.0 - gl_FragColor.r) * (1.0 - uColor.r);
213
- }
214
- if (uColor.g < 0.5) {
215
- gl_FragColor.g *= 2.0 * uColor.g;
216
- } else {
217
- gl_FragColor.g = 1.0 - 2.0 * (1.0 - gl_FragColor.g) * (1.0 - uColor.g);
218
- }
219
- if (uColor.b < 0.5) {
220
- gl_FragColor.b *= 2.0 * uColor.b;
221
- } else {
222
- gl_FragColor.b = 1.0 - 2.0 * (1.0 - gl_FragColor.b) * (1.0 - uColor.b);
223
- }
224
- `,tint:`
225
- gl_FragColor.rgb *= (1.0 - uColor.a);
226
- gl_FragColor.rgb += uColor.rgb;
227
- `};class on extends yt{getCacheKey(){return"".concat(this.type,"_").concat(this.mode)}getFragmentSource(){return`
228
- precision highp float;
229
- uniform sampler2D uTexture;
230
- uniform vec4 uColor;
231
- varying vec2 vTexCoord;
232
- void main() {
233
- vec4 color = texture2D(uTexture, vTexCoord);
234
- gl_FragColor = color;
235
- if (color.a > 0.0) {
236
- `.concat(Og[this.mode],`
237
- }
238
- }
239
- `)}applyTo2d(t){let{imageData:{data:e}}=t;const i=new tt(this.color).getSource(),s=this.alpha,r=i[0]*s,o=i[1]*s,a=i[2]*s,l=1-s;for(let c=0;c<e.length;c+=4){const h=e[c],u=e[c+1],d=e[c+2];let f,g,p;switch(this.mode){case"multiply":f=h*r/255,g=u*o/255,p=d*a/255;break;case"screen":f=255-(255-h)*(255-r)/255,g=255-(255-u)*(255-o)/255,p=255-(255-d)*(255-a)/255;break;case"add":f=h+r,g=u+o,p=d+a;break;case"difference":f=Math.abs(h-r),g=Math.abs(u-o),p=Math.abs(d-a);break;case"subtract":f=h-r,g=u-o,p=d-a;break;case"darken":f=Math.min(h,r),g=Math.min(u,o),p=Math.min(d,a);break;case"lighten":f=Math.max(h,r),g=Math.max(u,o),p=Math.max(d,a);break;case"overlay":f=r<128?2*h*r/255:255-2*(255-h)*(255-r)/255,g=o<128?2*u*o/255:255-2*(255-u)*(255-o)/255,p=a<128?2*d*a/255:255-2*(255-d)*(255-a)/255;break;case"exclusion":f=r+h-2*r*h/255,g=o+u-2*o*u/255,p=a+d-2*a*d/255;break;case"tint":f=r+h*l,g=o+u*l,p=a+d*l}e[c]=f,e[c+1]=g,e[c+2]=p}}sendUniformData(t,e){const i=new tt(this.color).getSource();i[0]=this.alpha*i[0]/255,i[1]=this.alpha*i[1]/255,i[2]=this.alpha*i[2]/255,i[3]=this.alpha,t.uniform4fv(e.uColor,i)}}_(on,"defaults",{color:"#F95C63",mode:"multiply",alpha:1}),_(on,"type","BlendColor"),_(on,"uniformLocations",["uColor"]),F.setClass(on);const Ag={multiply:`
240
- precision highp float;
241
- uniform sampler2D uTexture;
242
- uniform sampler2D uImage;
243
- uniform vec4 uColor;
244
- varying vec2 vTexCoord;
245
- varying vec2 vTexCoord2;
246
- void main() {
247
- vec4 color = texture2D(uTexture, vTexCoord);
248
- vec4 color2 = texture2D(uImage, vTexCoord2);
249
- color.rgba *= color2.rgba;
250
- gl_FragColor = color;
251
- }
252
- `,mask:`
253
- precision highp float;
254
- uniform sampler2D uTexture;
255
- uniform sampler2D uImage;
256
- uniform vec4 uColor;
257
- varying vec2 vTexCoord;
258
- varying vec2 vTexCoord2;
259
- void main() {
260
- vec4 color = texture2D(uTexture, vTexCoord);
261
- vec4 color2 = texture2D(uImage, vTexCoord2);
262
- color.a = color2.a;
263
- gl_FragColor = color;
264
- }
265
- `},Dg=["type","image"];class an extends yt{getCacheKey(){return"".concat(this.type,"_").concat(this.mode)}getFragmentSource(){return Ag[this.mode]}getVertexSource(){return`
266
- attribute vec2 aPosition;
267
- varying vec2 vTexCoord;
268
- varying vec2 vTexCoord2;
269
- uniform mat3 uTransformMatrix;
270
- void main() {
271
- vTexCoord = aPosition;
272
- vTexCoord2 = (uTransformMatrix * vec3(aPosition, 1.0)).xy;
273
- gl_Position = vec4(aPosition * 2.0 - 1.0, 0.0, 1.0);
274
- }
275
- `}applyToWebGL(t){const e=t.context,i=this.createTexture(t.filterBackend,this.image);this.bindAdditionalTexture(e,i,e.TEXTURE1),super.applyToWebGL(t),this.unbindAdditionalTexture(e,e.TEXTURE1)}createTexture(t,e){return t.getCachedTexture(e.cacheKey,e.getElement())}calculateMatrix(){const t=this.image,{width:e,height:i}=t.getElement();return[1/t.scaleX,0,0,0,1/t.scaleY,0,-t.left/e,-t.top/i,1]}applyTo2d(t){let{imageData:{data:e,width:i,height:s},filterBackend:{resources:r}}=t;const o=this.image;r.blendImage||(r.blendImage=le());const a=r.blendImage,l=a.getContext("2d");a.width!==i||a.height!==s?(a.width=i,a.height=s):l.clearRect(0,0,i,s),l.setTransform(o.scaleX,0,0,o.scaleY,o.left,o.top),l.drawImage(o.getElement(),0,0,i,s);const c=l.getImageData(0,0,i,s).data;for(let h=0;h<e.length;h+=4){const u=e[h],d=e[h+1],f=e[h+2],g=e[h+3],p=c[h],m=c[h+1],v=c[h+2],y=c[h+3];switch(this.mode){case"multiply":e[h]=u*p/255,e[h+1]=d*m/255,e[h+2]=f*v/255,e[h+3]=g*y/255;break;case"mask":e[h+3]=y}}}sendUniformData(t,e){const i=this.calculateMatrix();t.uniform1i(e.uImage,1),t.uniformMatrix3fv(e.uTransformMatrix,!1,i)}toObject(){return b(b({},super.toObject()),{},{image:this.image&&this.image.toObject()})}static async fromObject(t,e){let{type:i,image:s}=t,r=rt(t,Dg);return Xt.fromObject(s,e).then(o=>new this(b(b({},r),{},{image:o})))}}_(an,"type","BlendImage"),_(an,"defaults",{mode:"multiply",alpha:1}),_(an,"uniformLocations",["uTransformMatrix","uImage"]),F.setClass(an);class ln extends yt{getFragmentSource(){return`
276
- precision highp float;
277
- uniform sampler2D uTexture;
278
- uniform vec2 uDelta;
279
- varying vec2 vTexCoord;
280
- const float nSamples = 15.0;
281
- vec3 v3offset = vec3(12.9898, 78.233, 151.7182);
282
- float random(vec3 scale) {
283
- /* use the fragment position for a different seed per-pixel */
284
- return fract(sin(dot(gl_FragCoord.xyz, scale)) * 43758.5453);
285
- }
286
- void main() {
287
- vec4 color = vec4(0.0);
288
- float total = 0.0;
289
- float offset = random(v3offset);
290
- for (float t = -nSamples; t <= nSamples; t++) {
291
- float percent = (t + offset - 0.5) / nSamples;
292
- float weight = 1.0 - abs(percent);
293
- color += texture2D(uTexture, vTexCoord + uDelta * percent) * weight;
294
- total += weight;
295
- }
296
- gl_FragColor = color / total;
297
- }
298
- `}applyTo(t){nn(t)?(this.aspectRatio=t.sourceWidth/t.sourceHeight,t.passes++,this._setupFrameBuffer(t),this.horizontal=!0,this.applyToWebGL(t),this._swapTextures(t),this._setupFrameBuffer(t),this.horizontal=!1,this.applyToWebGL(t),this._swapTextures(t)):this.applyTo2d(t)}applyTo2d(t){t.imageData=this.simpleBlur(t)}simpleBlur(t){let{ctx:e,imageData:i,filterBackend:{resources:s}}=t;const{width:r,height:o}=i;s.blurLayer1||(s.blurLayer1=le(),s.blurLayer2=le());const a=s.blurLayer1,l=s.blurLayer2;a.width===r&&a.height===o||(l.width=a.width=r,l.height=a.height=o);const c=a.getContext("2d"),h=l.getContext("2d"),u=15,d=.06*this.blur*.5;let f,g,p,m;for(c.putImageData(i,0,0),h.clearRect(0,0,r,o),m=-15;m<=u;m++)f=(Math.random()-.5)/4,g=m/u,p=d*g*r+f,h.globalAlpha=1-Math.abs(g),h.drawImage(a,p,f),c.drawImage(l,0,0),h.globalAlpha=1,h.clearRect(0,0,l.width,l.height);for(m=-15;m<=u;m++)f=(Math.random()-.5)/4,g=m/u,p=d*g*o+f,h.globalAlpha=1-Math.abs(g),h.drawImage(a,f,p),c.drawImage(l,0,0),h.globalAlpha=1,h.clearRect(0,0,l.width,l.height);e.drawImage(a,0,0);const v=e.getImageData(0,0,a.width,a.height);return c.globalAlpha=1,c.clearRect(0,0,a.width,a.height),v}sendUniformData(t,e){const i=this.chooseRightDelta();t.uniform2fv(e.uDelta,i)}isNeutralState(){return this.blur===0}chooseRightDelta(){let t=1;const e=[0,0];this.horizontal?this.aspectRatio>1&&(t=1/this.aspectRatio):this.aspectRatio<1&&(t=this.aspectRatio);const i=t*this.blur*.12;return this.horizontal?e[0]=i:e[1]=i,e}}_(ln,"type","Blur"),_(ln,"defaults",{blur:0}),_(ln,"uniformLocations",["uDelta"]),F.setClass(ln);class cn extends yt{getFragmentSource(){return`
299
- precision highp float;
300
- uniform sampler2D uTexture;
301
- uniform float uBrightness;
302
- varying vec2 vTexCoord;
303
- void main() {
304
- vec4 color = texture2D(uTexture, vTexCoord);
305
- color.rgb += uBrightness;
306
- gl_FragColor = color;
307
- }
308
- `}applyTo2d(t){let{imageData:{data:e}}=t;const i=Math.round(255*this.brightness);for(let s=0;s<e.length;s+=4)e[s]+=i,e[s+1]+=i,e[s+2]+=i}isNeutralState(){return this.brightness===0}sendUniformData(t,e){t.uniform1f(e.uBrightness,this.brightness)}}_(cn,"type","Brightness"),_(cn,"defaults",{brightness:0}),_(cn,"uniformLocations",["uBrightness"]),F.setClass(cn);const Rc={matrix:[1,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,1,0],colorsOnly:!0};class os extends yt{getFragmentSource(){return`
309
- precision highp float;
310
- uniform sampler2D uTexture;
311
- varying vec2 vTexCoord;
312
- uniform mat4 uColorMatrix;
313
- uniform vec4 uConstants;
314
- void main() {
315
- vec4 color = texture2D(uTexture, vTexCoord);
316
- color *= uColorMatrix;
317
- color += uConstants;
318
- gl_FragColor = color;
319
- }`}applyTo2d(t){const e=t.imageData.data,i=this.matrix,s=this.colorsOnly;for(let r=0;r<e.length;r+=4){const o=e[r],a=e[r+1],l=e[r+2];if(e[r]=o*i[0]+a*i[1]+l*i[2]+255*i[4],e[r+1]=o*i[5]+a*i[6]+l*i[7]+255*i[9],e[r+2]=o*i[10]+a*i[11]+l*i[12]+255*i[14],!s){const c=e[r+3];e[r]+=c*i[3],e[r+1]+=c*i[8],e[r+2]+=c*i[13],e[r+3]=o*i[15]+a*i[16]+l*i[17]+c*i[18]+255*i[19]}}}sendUniformData(t,e){const i=this.matrix,s=[i[0],i[1],i[2],i[3],i[5],i[6],i[7],i[8],i[10],i[11],i[12],i[13],i[15],i[16],i[17],i[18]],r=[i[4],i[9],i[14],i[19]];t.uniformMatrix4fv(e.uColorMatrix,!1,s),t.uniform4fv(e.uConstants,r)}toObject(){return b(b({},super.toObject()),{},{matrix:[...this.matrix]})}}function Pi(n,t){var e;const i=(_(e=class extends os{toObject(){return{type:this.type,colorsOnly:this.colorsOnly}}},"type",n),_(e,"defaults",{colorsOnly:!1,matrix:t}),e);return F.setClass(i,n),i}_(os,"type","ColorMatrix"),_(os,"defaults",Rc),_(os,"uniformLocations",["uColorMatrix","uConstants"]),F.setClass(os),Pi("Brownie",[.5997,.34553,-.27082,0,.186,-.0377,.86095,.15059,0,-.1449,.24113,-.07441,.44972,0,-.02965,0,0,0,1,0]),Pi("Vintage",[.62793,.32021,-.03965,0,.03784,.02578,.64411,.03259,0,.02926,.0466,-.08512,.52416,0,.02023,0,0,0,1,0]),Pi("Kodachrome",[1.12855,-.39673,-.03992,0,.24991,-.16404,1.08352,-.05498,0,.09698,-.16786,-.56034,1.60148,0,.13972,0,0,0,1,0]),Pi("Technicolor",[1.91252,-.85453,-.09155,0,.04624,-.30878,1.76589,-.10601,0,-.27589,-.2311,-.75018,1.84759,0,.12137,0,0,0,1,0]),Pi("Polaroid",[1.438,-.062,-.062,0,0,-.122,1.378,-.122,0,0,-.016,-.016,1.483,0,0,0,0,0,1,0]),Pi("Sepia",[.393,.769,.189,0,0,.349,.686,.168,0,0,.272,.534,.131,0,0,0,0,0,1,0]),Pi("BlackWhite",[1.5,1.5,1.5,0,-1,1.5,1.5,1.5,0,-1,1.5,1.5,1.5,0,-1,0,0,0,1,0]);class Nc extends yt{constructor(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};super(t),this.subFilters=t.subFilters||[]}applyTo(t){nn(t)&&(t.passes+=this.subFilters.length-1),this.subFilters.forEach(e=>{e.applyTo(t)})}toObject(){return{type:this.type,subFilters:this.subFilters.map(t=>t.toObject())}}isNeutralState(){return!this.subFilters.some(t=>!t.isNeutralState())}static fromObject(t,e){return Promise.all((t.subFilters||[]).map(i=>F.getClass(i.type).fromObject(i,e))).then(i=>new this({subFilters:i}))}}_(Nc,"type","Composed"),F.setClass(Nc);class hn extends yt{getFragmentSource(){return`
320
- precision highp float;
321
- uniform sampler2D uTexture;
322
- uniform float uContrast;
323
- varying vec2 vTexCoord;
324
- void main() {
325
- vec4 color = texture2D(uTexture, vTexCoord);
326
- float contrastF = 1.015 * (uContrast + 1.0) / (1.0 * (1.015 - uContrast));
327
- color.rgb = contrastF * (color.rgb - 0.5) + 0.5;
328
- gl_FragColor = color;
329
- }`}isNeutralState(){return this.contrast===0}applyTo2d(t){let{imageData:{data:e}}=t;const i=Math.floor(255*this.contrast),s=259*(i+255)/(255*(259-i));for(let r=0;r<e.length;r+=4)e[r]=s*(e[r]-128)+128,e[r+1]=s*(e[r+1]-128)+128,e[r+2]=s*(e[r+2]-128)+128}sendUniformData(t,e){t.uniform1f(e.uContrast,this.contrast)}}_(hn,"type","Contrast"),_(hn,"defaults",{contrast:0}),_(hn,"uniformLocations",["uContrast"]),F.setClass(hn);const kg={Convolute_3_1:`
330
- precision highp float;
331
- uniform sampler2D uTexture;
332
- uniform float uMatrix[9];
333
- uniform float uStepW;
334
- uniform float uStepH;
335
- varying vec2 vTexCoord;
336
- void main() {
337
- vec4 color = vec4(0, 0, 0, 0);
338
- for (float h = 0.0; h < 3.0; h+=1.0) {
339
- for (float w = 0.0; w < 3.0; w+=1.0) {
340
- vec2 matrixPos = vec2(uStepW * (w - 1), uStepH * (h - 1));
341
- color += texture2D(uTexture, vTexCoord + matrixPos) * uMatrix[int(h * 3.0 + w)];
342
- }
343
- }
344
- gl_FragColor = color;
345
- }
346
- `,Convolute_3_0:`
347
- precision highp float;
348
- uniform sampler2D uTexture;
349
- uniform float uMatrix[9];
350
- uniform float uStepW;
351
- uniform float uStepH;
352
- varying vec2 vTexCoord;
353
- void main() {
354
- vec4 color = vec4(0, 0, 0, 1);
355
- for (float h = 0.0; h < 3.0; h+=1.0) {
356
- for (float w = 0.0; w < 3.0; w+=1.0) {
357
- vec2 matrixPos = vec2(uStepW * (w - 1.0), uStepH * (h - 1.0));
358
- color.rgb += texture2D(uTexture, vTexCoord + matrixPos).rgb * uMatrix[int(h * 3.0 + w)];
359
- }
360
- }
361
- float alpha = texture2D(uTexture, vTexCoord).a;
362
- gl_FragColor = color;
363
- gl_FragColor.a = alpha;
364
- }
365
- `,Convolute_5_1:`
366
- precision highp float;
367
- uniform sampler2D uTexture;
368
- uniform float uMatrix[25];
369
- uniform float uStepW;
370
- uniform float uStepH;
371
- varying vec2 vTexCoord;
372
- void main() {
373
- vec4 color = vec4(0, 0, 0, 0);
374
- for (float h = 0.0; h < 5.0; h+=1.0) {
375
- for (float w = 0.0; w < 5.0; w+=1.0) {
376
- vec2 matrixPos = vec2(uStepW * (w - 2.0), uStepH * (h - 2.0));
377
- color += texture2D(uTexture, vTexCoord + matrixPos) * uMatrix[int(h * 5.0 + w)];
378
- }
379
- }
380
- gl_FragColor = color;
381
- }
382
- `,Convolute_5_0:`
383
- precision highp float;
384
- uniform sampler2D uTexture;
385
- uniform float uMatrix[25];
386
- uniform float uStepW;
387
- uniform float uStepH;
388
- varying vec2 vTexCoord;
389
- void main() {
390
- vec4 color = vec4(0, 0, 0, 1);
391
- for (float h = 0.0; h < 5.0; h+=1.0) {
392
- for (float w = 0.0; w < 5.0; w+=1.0) {
393
- vec2 matrixPos = vec2(uStepW * (w - 2.0), uStepH * (h - 2.0));
394
- color.rgb += texture2D(uTexture, vTexCoord + matrixPos).rgb * uMatrix[int(h * 5.0 + w)];
395
- }
396
- }
397
- float alpha = texture2D(uTexture, vTexCoord).a;
398
- gl_FragColor = color;
399
- gl_FragColor.a = alpha;
400
- }
401
- `,Convolute_7_1:`
402
- precision highp float;
403
- uniform sampler2D uTexture;
404
- uniform float uMatrix[49];
405
- uniform float uStepW;
406
- uniform float uStepH;
407
- varying vec2 vTexCoord;
408
- void main() {
409
- vec4 color = vec4(0, 0, 0, 0);
410
- for (float h = 0.0; h < 7.0; h+=1.0) {
411
- for (float w = 0.0; w < 7.0; w+=1.0) {
412
- vec2 matrixPos = vec2(uStepW * (w - 3.0), uStepH * (h - 3.0));
413
- color += texture2D(uTexture, vTexCoord + matrixPos) * uMatrix[int(h * 7.0 + w)];
414
- }
415
- }
416
- gl_FragColor = color;
417
- }
418
- `,Convolute_7_0:`
419
- precision highp float;
420
- uniform sampler2D uTexture;
421
- uniform float uMatrix[49];
422
- uniform float uStepW;
423
- uniform float uStepH;
424
- varying vec2 vTexCoord;
425
- void main() {
426
- vec4 color = vec4(0, 0, 0, 1);
427
- for (float h = 0.0; h < 7.0; h+=1.0) {
428
- for (float w = 0.0; w < 7.0; w+=1.0) {
429
- vec2 matrixPos = vec2(uStepW * (w - 3.0), uStepH * (h - 3.0));
430
- color.rgb += texture2D(uTexture, vTexCoord + matrixPos).rgb * uMatrix[int(h * 7.0 + w)];
431
- }
432
- }
433
- float alpha = texture2D(uTexture, vTexCoord).a;
434
- gl_FragColor = color;
435
- gl_FragColor.a = alpha;
436
- }
437
- `,Convolute_9_1:`
438
- precision highp float;
439
- uniform sampler2D uTexture;
440
- uniform float uMatrix[81];
441
- uniform float uStepW;
442
- uniform float uStepH;
443
- varying vec2 vTexCoord;
444
- void main() {
445
- vec4 color = vec4(0, 0, 0, 0);
446
- for (float h = 0.0; h < 9.0; h+=1.0) {
447
- for (float w = 0.0; w < 9.0; w+=1.0) {
448
- vec2 matrixPos = vec2(uStepW * (w - 4.0), uStepH * (h - 4.0));
449
- color += texture2D(uTexture, vTexCoord + matrixPos) * uMatrix[int(h * 9.0 + w)];
450
- }
451
- }
452
- gl_FragColor = color;
453
- }
454
- `,Convolute_9_0:`
455
- precision highp float;
456
- uniform sampler2D uTexture;
457
- uniform float uMatrix[81];
458
- uniform float uStepW;
459
- uniform float uStepH;
460
- varying vec2 vTexCoord;
461
- void main() {
462
- vec4 color = vec4(0, 0, 0, 1);
463
- for (float h = 0.0; h < 9.0; h+=1.0) {
464
- for (float w = 0.0; w < 9.0; w+=1.0) {
465
- vec2 matrixPos = vec2(uStepW * (w - 4.0), uStepH * (h - 4.0));
466
- color.rgb += texture2D(uTexture, vTexCoord + matrixPos).rgb * uMatrix[int(h * 9.0 + w)];
467
- }
468
- }
469
- float alpha = texture2D(uTexture, vTexCoord).a;
470
- gl_FragColor = color;
471
- gl_FragColor.a = alpha;
472
- }
473
- `};class un extends yt{getCacheKey(){return"".concat(this.type,"_").concat(Math.sqrt(this.matrix.length),"_").concat(this.opaque?1:0)}getFragmentSource(){return kg[this.getCacheKey()]}applyTo2d(t){const e=t.imageData,i=e.data,s=this.matrix,r=Math.round(Math.sqrt(s.length)),o=Math.floor(r/2),a=e.width,l=e.height,c=t.ctx.createImageData(a,l),h=c.data,u=this.opaque?1:0;let d,f,g,p,m,v,y,x,E,T,k,S,w;for(k=0;k<l;k++)for(T=0;T<a;T++){for(m=4*(k*a+T),d=0,f=0,g=0,p=0,w=0;w<r;w++)for(S=0;S<r;S++)y=k+w-o,v=T+S-o,y<0||y>=l||v<0||v>=a||(x=4*(y*a+v),E=s[w*r+S],d+=i[x]*E,f+=i[x+1]*E,g+=i[x+2]*E,u||(p+=i[x+3]*E));h[m]=d,h[m+1]=f,h[m+2]=g,h[m+3]=u?i[m+3]:p}t.imageData=c}sendUniformData(t,e){t.uniform1fv(e.uMatrix,this.matrix)}toObject(){return b(b({},super.toObject()),{},{opaque:this.opaque,matrix:[...this.matrix]})}}_(un,"type","Convolute"),_(un,"defaults",{opaque:!1,matrix:[0,0,0,0,1,0,0,0,0]}),_(un,"uniformLocations",["uMatrix","uOpaque","uHalfSize","uSize"]),F.setClass(un);const Bc="Gamma";class dn extends yt{getFragmentSource(){return`
474
- precision highp float;
475
- uniform sampler2D uTexture;
476
- uniform vec3 uGamma;
477
- varying vec2 vTexCoord;
478
- void main() {
479
- vec4 color = texture2D(uTexture, vTexCoord);
480
- vec3 correction = (1.0 / uGamma);
481
- color.r = pow(color.r, correction.r);
482
- color.g = pow(color.g, correction.g);
483
- color.b = pow(color.b, correction.b);
484
- gl_FragColor = color;
485
- gl_FragColor.rgb *= color.a;
486
- }
487
- `}constructor(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};super(t),this.gamma=t.gamma||this.constructor.defaults.gamma.concat()}applyTo2d(t){let{imageData:{data:e}}=t;const i=this.gamma,s=1/i[0],r=1/i[1],o=1/i[2];this.rgbValues||(this.rgbValues={r:new Uint8Array(256),g:new Uint8Array(256),b:new Uint8Array(256)});const a=this.rgbValues;for(let l=0;l<256;l++)a.r[l]=255*Math.pow(l/255,s),a.g[l]=255*Math.pow(l/255,r),a.b[l]=255*Math.pow(l/255,o);for(let l=0;l<e.length;l+=4)e[l]=a.r[e[l]],e[l+1]=a.g[e[l+1]],e[l+2]=a.b[e[l+2]]}sendUniformData(t,e){t.uniform3fv(e.uGamma,this.gamma)}isNeutralState(){const{gamma:t}=this;return t[0]===1&&t[1]===1&&t[2]===1}toObject(){return{type:Bc,gamma:this.gamma.concat()}}}_(dn,"type",Bc),_(dn,"defaults",{gamma:[1,1,1]}),_(dn,"uniformLocations",["uGamma"]),F.setClass(dn);const Mg={average:`
488
- precision highp float;
489
- uniform sampler2D uTexture;
490
- varying vec2 vTexCoord;
491
- void main() {
492
- vec4 color = texture2D(uTexture, vTexCoord);
493
- float average = (color.r + color.b + color.g) / 3.0;
494
- gl_FragColor = vec4(average, average, average, color.a);
495
- }
496
- `,lightness:`
497
- precision highp float;
498
- uniform sampler2D uTexture;
499
- uniform int uMode;
500
- varying vec2 vTexCoord;
501
- void main() {
502
- vec4 col = texture2D(uTexture, vTexCoord);
503
- float average = (max(max(col.r, col.g),col.b) + min(min(col.r, col.g),col.b)) / 2.0;
504
- gl_FragColor = vec4(average, average, average, col.a);
505
- }
506
- `,luminosity:`
507
- precision highp float;
508
- uniform sampler2D uTexture;
509
- uniform int uMode;
510
- varying vec2 vTexCoord;
511
- void main() {
512
- vec4 col = texture2D(uTexture, vTexCoord);
513
- float average = 0.21 * col.r + 0.72 * col.g + 0.07 * col.b;
514
- gl_FragColor = vec4(average, average, average, col.a);
515
- }
516
- `};class fn extends yt{applyTo2d(t){let{imageData:{data:e}}=t;for(let i,s=0;s<e.length;s+=4){const r=e[s],o=e[s+1],a=e[s+2];switch(this.mode){case"average":i=(r+o+a)/3;break;case"lightness":i=(Math.min(r,o,a)+Math.max(r,o,a))/2;break;case"luminosity":i=.21*r+.72*o+.07*a}e[s+2]=e[s+1]=e[s]=i}}getCacheKey(){return"".concat(this.type,"_").concat(this.mode)}getFragmentSource(){return Mg[this.mode]}sendUniformData(t,e){t.uniform1i(e.uMode,1)}isNeutralState(){return!1}}_(fn,"type","Grayscale"),_(fn,"defaults",{mode:"average"}),_(fn,"uniformLocations",["uMode"]),F.setClass(fn);const Pg=b(b({},Rc),{},{rotation:0});class qo extends os{calculateMatrix(){const t=this.rotation*Math.PI,e=Pe(t),i=Ie(t),s=1/3,r=Math.sqrt(s)*i,o=1-e;this.matrix=[e+o/3,s*o-r,s*o+r,0,0,s*o+r,e+s*o,s*o-r,0,0,s*o-r,s*o+r,e+s*o,0,0,0,0,0,1,0]}isNeutralState(){return this.rotation===0}applyTo(t){this.calculateMatrix(),super.applyTo(t)}toObject(){return{type:this.type,rotation:this.rotation}}}_(qo,"type","HueRotation"),_(qo,"defaults",Pg),F.setClass(qo);class gn extends yt{applyTo2d(t){let{imageData:{data:e}}=t;for(let i=0;i<e.length;i+=4)e[i]=255-e[i],e[i+1]=255-e[i+1],e[i+2]=255-e[i+2],this.alpha&&(e[i+3]=255-e[i+3])}getFragmentSource(){return`
517
- precision highp float;
518
- uniform sampler2D uTexture;
519
- uniform int uInvert;
520
- uniform int uAlpha;
521
- varying vec2 vTexCoord;
522
- void main() {
523
- vec4 color = texture2D(uTexture, vTexCoord);
524
- if (uInvert == 1) {
525
- if (uAlpha == 1) {
526
- gl_FragColor = vec4(1.0 - color.r,1.0 -color.g,1.0 -color.b,1.0 -color.a);
527
- } else {
528
- gl_FragColor = vec4(1.0 - color.r,1.0 -color.g,1.0 -color.b,color.a);
529
- }
530
- } else {
531
- gl_FragColor = color;
532
- }
533
- }
534
- `}isNeutralState(){return!this.invert}sendUniformData(t,e){t.uniform1i(e.uInvert,Number(this.invert)),t.uniform1i(e.uAlpha,Number(this.alpha))}}_(gn,"type","Invert"),_(gn,"defaults",{alpha:!1,invert:!0}),_(gn,"uniformLocations",["uInvert","uAlpha"]),F.setClass(gn);class pn extends yt{getFragmentSource(){return`
535
- precision highp float;
536
- uniform sampler2D uTexture;
537
- uniform float uStepH;
538
- uniform float uNoise;
539
- uniform float uSeed;
540
- varying vec2 vTexCoord;
541
- float rand(vec2 co, float seed, float vScale) {
542
- return fract(sin(dot(co.xy * vScale ,vec2(12.9898 , 78.233))) * 43758.5453 * (seed + 0.01) / 2.0);
543
- }
544
- void main() {
545
- vec4 color = texture2D(uTexture, vTexCoord);
546
- color.rgb += (0.5 - rand(vTexCoord, uSeed, 0.1 / uStepH)) * uNoise;
547
- gl_FragColor = color;
548
- }
549
- `}applyTo2d(t){let{imageData:{data:e}}=t;const i=this.noise;for(let s=0;s<e.length;s+=4){const r=(.5-Math.random())*i;e[s]+=r,e[s+1]+=r,e[s+2]+=r}}sendUniformData(t,e){t.uniform1f(e.uNoise,this.noise/255),t.uniform1f(e.uSeed,Math.random())}isNeutralState(){return this.noise===0}}_(pn,"type","Noise"),_(pn,"defaults",{noise:0}),_(pn,"uniformLocations",["uNoise","uSeed"]),F.setClass(pn);class mn extends yt{applyTo2d(t){let{imageData:{data:e,width:i,height:s}}=t;for(let r=0;r<s;r+=this.blocksize)for(let o=0;o<i;o+=this.blocksize){const a=4*r*i+4*o,l=e[a],c=e[a+1],h=e[a+2],u=e[a+3];for(let d=r;d<Math.min(r+this.blocksize,s);d++)for(let f=o;f<Math.min(o+this.blocksize,i);f++){const g=4*d*i+4*f;e[g]=l,e[g+1]=c,e[g+2]=h,e[g+3]=u}}}isNeutralState(){return this.blocksize===1}getFragmentSource(){return`
550
- precision highp float;
551
- uniform sampler2D uTexture;
552
- uniform float uBlocksize;
553
- uniform float uStepW;
554
- uniform float uStepH;
555
- varying vec2 vTexCoord;
556
- void main() {
557
- float blockW = uBlocksize * uStepW;
558
- float blockH = uBlocksize * uStepH;
559
- int posX = int(vTexCoord.x / blockW);
560
- int posY = int(vTexCoord.y / blockH);
561
- float fposX = float(posX);
562
- float fposY = float(posY);
563
- vec2 squareCoords = vec2(fposX * blockW, fposY * blockH);
564
- vec4 color = texture2D(uTexture, squareCoords);
565
- gl_FragColor = color;
566
- }
567
- `}sendUniformData(t,e){t.uniform1f(e.uBlocksize,this.blocksize)}}_(mn,"type","Pixelate"),_(mn,"defaults",{blocksize:4}),_(mn,"uniformLocations",["uBlocksize"]),F.setClass(mn);class vn extends yt{getFragmentSource(){return`
568
- precision highp float;
569
- uniform sampler2D uTexture;
570
- uniform vec4 uLow;
571
- uniform vec4 uHigh;
572
- varying vec2 vTexCoord;
573
- void main() {
574
- gl_FragColor = texture2D(uTexture, vTexCoord);
575
- if(all(greaterThan(gl_FragColor.rgb,uLow.rgb)) && all(greaterThan(uHigh.rgb,gl_FragColor.rgb))) {
576
- gl_FragColor.a = 0.0;
577
- }
578
- }
579
- `}applyTo2d(t){let{imageData:{data:e}}=t;const i=255*this.distance,s=new tt(this.color).getSource(),r=[s[0]-i,s[1]-i,s[2]-i],o=[s[0]+i,s[1]+i,s[2]+i];for(let a=0;a<e.length;a+=4){const l=e[a],c=e[a+1],h=e[a+2];l>r[0]&&c>r[1]&&h>r[2]&&l<o[0]&&c<o[1]&&h<o[2]&&(e[a+3]=0)}}sendUniformData(t,e){const i=new tt(this.color).getSource(),s=this.distance,r=[0+i[0]/255-s,0+i[1]/255-s,0+i[2]/255-s,1],o=[i[0]/255+s,i[1]/255+s,i[2]/255+s,1];t.uniform4fv(e.uLow,r),t.uniform4fv(e.uHigh,o)}}_(vn,"type","RemoveColor"),_(vn,"defaults",{color:"#FFFFFF",distance:.02,useAlpha:!1}),_(vn,"uniformLocations",["uLow","uHigh"]),F.setClass(vn);class _n extends yt{sendUniformData(t,e){t.uniform2fv(e.uDelta,this.horizontal?[1/this.width,0]:[0,1/this.height]),t.uniform1fv(e.uTaps,this.taps)}getFilterWindow(){const t=this.tempScale;return Math.ceil(this.lanczosLobes/t)}getCacheKey(){const t=this.getFilterWindow();return"".concat(this.type,"_").concat(t)}getFragmentSource(){const t=this.getFilterWindow();return this.generateShader(t)}getTaps(){const t=this.lanczosCreate(this.lanczosLobes),e=this.tempScale,i=this.getFilterWindow(),s=new Array(i);for(let r=1;r<=i;r++)s[r-1]=t(r*e);return s}generateShader(t){const e=new Array(t);for(let i=1;i<=t;i++)e[i-1]="".concat(i,".0 * uDelta");return`
580
- precision highp float;
581
- uniform sampler2D uTexture;
582
- uniform vec2 uDelta;
583
- varying vec2 vTexCoord;
584
- uniform float uTaps[`.concat(t,`];
585
- void main() {
586
- vec4 color = texture2D(uTexture, vTexCoord);
587
- float sum = 1.0;
588
- `).concat(e.map((i,s)=>`
589
- color += texture2D(uTexture, vTexCoord + `.concat(i,") * uTaps[").concat(s,"] + texture2D(uTexture, vTexCoord - ").concat(i,") * uTaps[").concat(s,`];
590
- sum += 2.0 * uTaps[`).concat(s,`];
591
- `)).join(`
592
- `),`
593
- gl_FragColor = color / sum;
594
- }
595
- `)}applyToForWebgl(t){t.passes++,this.width=t.sourceWidth,this.horizontal=!0,this.dW=Math.round(this.width*this.scaleX),this.dH=t.sourceHeight,this.tempScale=this.dW/this.width,this.taps=this.getTaps(),t.destinationWidth=this.dW,super.applyTo(t),t.sourceWidth=t.destinationWidth,this.height=t.sourceHeight,this.horizontal=!1,this.dH=Math.round(this.height*this.scaleY),this.tempScale=this.dH/this.height,this.taps=this.getTaps(),t.destinationHeight=this.dH,super.applyTo(t),t.sourceHeight=t.destinationHeight}applyTo(t){nn(t)?this.applyToForWebgl(t):this.applyTo2d(t)}isNeutralState(){return this.scaleX===1&&this.scaleY===1}lanczosCreate(t){return e=>{if(e>=t||e<=-t)return 0;if(e<11920929e-14&&e>-11920929e-14)return 1;const i=(e*=Math.PI)/t;return Math.sin(e)/e*Math.sin(i)/i}}applyTo2d(t){const e=t.imageData,i=this.scaleX,s=this.scaleY;this.rcpScaleX=1/i,this.rcpScaleY=1/s;const r=e.width,o=e.height,a=Math.round(r*i),l=Math.round(o*s);let c;c=this.resizeType==="sliceHack"?this.sliceByTwo(t,r,o,a,l):this.resizeType==="hermite"?this.hermiteFastResize(t,r,o,a,l):this.resizeType==="bilinear"?this.bilinearFiltering(t,r,o,a,l):this.resizeType==="lanczos"?this.lanczosResize(t,r,o,a,l):new ImageData(a,l),t.imageData=c}sliceByTwo(t,e,i,s,r){const o=t.imageData,a=.5;let l=!1,c=!1,h=e*a,u=i*a;const d=t.filterBackend.resources;let f=0,g=0;const p=e;let m=0;d.sliceByTwo||(d.sliceByTwo=le());const v=d.sliceByTwo;(v.width<1.5*e||v.height<i)&&(v.width=1.5*e,v.height=i);const y=v.getContext("2d");for(y.clearRect(0,0,1.5*e,i),y.putImageData(o,0,0),s=Math.floor(s),r=Math.floor(r);!l||!c;)e=h,i=u,s<Math.floor(h*a)?h=Math.floor(h*a):(h=s,l=!0),r<Math.floor(u*a)?u=Math.floor(u*a):(u=r,c=!0),y.drawImage(v,f,g,e,i,p,m,h,u),f=p,g=m,m+=u;return y.getImageData(f,g,s,r)}lanczosResize(t,e,i,s,r){const o=t.imageData.data,a=t.ctx.createImageData(s,r),l=a.data,c=this.lanczosCreate(this.lanczosLobes),h=this.rcpScaleX,u=this.rcpScaleY,d=2/this.rcpScaleX,f=2/this.rcpScaleY,g=Math.ceil(h*this.lanczosLobes/2),p=Math.ceil(u*this.lanczosLobes/2),m={},v={x:0,y:0},y={x:0,y:0};return function x(E){let T,k,S,w,L,j,A,O,D,I,$;for(v.x=(E+.5)*h,y.x=Math.floor(v.x),T=0;T<r;T++){for(v.y=(T+.5)*u,y.y=Math.floor(v.y),L=0,j=0,A=0,O=0,D=0,k=y.x-g;k<=y.x+g;k++)if(!(k<0||k>=e)){I=Math.floor(1e3*Math.abs(k-v.x)),m[I]||(m[I]={});for(let X=y.y-p;X<=y.y+p;X++)X<0||X>=i||($=Math.floor(1e3*Math.abs(X-v.y)),m[I][$]||(m[I][$]=c(Math.sqrt(Math.pow(I*d,2)+Math.pow($*f,2))/1e3)),S=m[I][$],S>0&&(w=4*(X*e+k),L+=S,j+=S*o[w],A+=S*o[w+1],O+=S*o[w+2],D+=S*o[w+3]))}w=4*(T*s+E),l[w]=j/L,l[w+1]=A/L,l[w+2]=O/L,l[w+3]=D/L}return++E<s?x(E):a}(0)}bilinearFiltering(t,e,i,s,r){let o,a,l,c,h,u,d,f,g,p,m,v,y,x=0;const E=this.rcpScaleX,T=this.rcpScaleY,k=4*(e-1),S=t.imageData.data,w=t.ctx.createImageData(s,r),L=w.data;for(d=0;d<r;d++)for(f=0;f<s;f++)for(h=Math.floor(E*f),u=Math.floor(T*d),g=E*f-h,p=T*d-u,y=4*(u*e+h),m=0;m<4;m++)o=S[y+m],a=S[y+4+m],l=S[y+k+m],c=S[y+k+4+m],v=o*(1-g)*(1-p)+a*g*(1-p)+l*p*(1-g)+c*g*p,L[x++]=v;return w}hermiteFastResize(t,e,i,s,r){const o=this.rcpScaleX,a=this.rcpScaleY,l=Math.ceil(o/2),c=Math.ceil(a/2),h=t.imageData.data,u=t.ctx.createImageData(s,r),d=u.data;for(let f=0;f<r;f++)for(let g=0;g<s;g++){const p=4*(g+f*s);let m=0,v=0,y=0,x=0,E=0,T=0,k=0;const S=(f+.5)*a;for(let w=Math.floor(f*a);w<(f+1)*a;w++){const L=Math.abs(S-(w+.5))/c,j=(g+.5)*o,A=L*L;for(let O=Math.floor(g*o);O<(g+1)*o;O++){let D=Math.abs(j-(O+.5))/l;const I=Math.sqrt(A+D*D);I>1&&I<-1||(m=2*I*I*I-3*I*I+1,m>0&&(D=4*(O+w*e),k+=m*h[D+3],y+=m,h[D+3]<255&&(m=m*h[D+3]/250),x+=m*h[D],E+=m*h[D+1],T+=m*h[D+2],v+=m))}}d[p]=x/v,d[p+1]=E/v,d[p+2]=T/v,d[p+3]=k/y}return u}}_(_n,"type","Resize"),_(_n,"defaults",{resizeType:"hermite",scaleX:1,scaleY:1,lanczosLobes:3}),_(_n,"uniformLocations",["uDelta","uTaps"]),F.setClass(_n);class bn extends yt{getFragmentSource(){return`
596
- precision highp float;
597
- uniform sampler2D uTexture;
598
- uniform float uSaturation;
599
- varying vec2 vTexCoord;
600
- void main() {
601
- vec4 color = texture2D(uTexture, vTexCoord);
602
- float rgMax = max(color.r, color.g);
603
- float rgbMax = max(rgMax, color.b);
604
- color.r += rgbMax != color.r ? (rgbMax - color.r) * uSaturation : 0.00;
605
- color.g += rgbMax != color.g ? (rgbMax - color.g) * uSaturation : 0.00;
606
- color.b += rgbMax != color.b ? (rgbMax - color.b) * uSaturation : 0.00;
607
- gl_FragColor = color;
608
- }
609
- `}applyTo2d(t){let{imageData:{data:e}}=t;const i=-this.saturation;for(let s=0;s<e.length;s+=4){const r=e[s],o=e[s+1],a=e[s+2],l=Math.max(r,o,a);e[s]+=l!==r?(l-r)*i:0,e[s+1]+=l!==o?(l-o)*i:0,e[s+2]+=l!==a?(l-a)*i:0}}sendUniformData(t,e){t.uniform1f(e.uSaturation,-this.saturation)}isNeutralState(){return this.saturation===0}}_(bn,"type","Saturation"),_(bn,"defaults",{saturation:0}),_(bn,"uniformLocations",["uSaturation"]),F.setClass(bn);class yn extends yt{getFragmentSource(){return`
610
- precision highp float;
611
- uniform sampler2D uTexture;
612
- uniform float uVibrance;
613
- varying vec2 vTexCoord;
614
- void main() {
615
- vec4 color = texture2D(uTexture, vTexCoord);
616
- float max = max(color.r, max(color.g, color.b));
617
- float avg = (color.r + color.g + color.b) / 3.0;
618
- float amt = (abs(max - avg) * 2.0) * uVibrance;
619
- color.r += max != color.r ? (max - color.r) * amt : 0.00;
620
- color.g += max != color.g ? (max - color.g) * amt : 0.00;
621
- color.b += max != color.b ? (max - color.b) * amt : 0.00;
622
- gl_FragColor = color;
623
- }
624
- `}applyTo2d(t){let{imageData:{data:e}}=t;const i=-this.vibrance;for(let s=0;s<e.length;s+=4){const r=e[s],o=e[s+1],a=e[s+2],l=Math.max(r,o,a),c=(r+o+a)/3,h=2*Math.abs(l-c)/255*i;e[s]+=l!==r?(l-r)*h:0,e[s+1]+=l!==o?(l-o)*h:0,e[s+2]+=l!==a?(l-a)*h:0}}sendUniformData(t,e){t.uniform1f(e.uVibrance,-this.vibrance)}isNeutralState(){return this.vibrance===0}}_(yn,"type","Vibrance"),_(yn,"defaults",{vibrance:0}),_(yn,"uniformLocations",["uVibrance"]),F.setClass(yn);var Ig=Object.defineProperty,Lg=Object.getOwnPropertyDescriptor,jt=(n,t,e,i)=>{for(var s=i>1?void 0:i?Lg(t,e):t,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(t,e,s):o(s))||s);return i&&s&&Ig(t,e,s),s};z.FabricExample=class extends ae{constructor(){super(),this.backgroundUrl="https://upload.wikimedia.org/wikipedia/commons/0/06/Daedalus_Spaceship_concept.jpg",this.message=`Dear fridends,
625
-
626
- My name is xxxxx. sadf;lkasdf
627
- good aklsdfja`,this.alignment="left",this.fontFamily="Arial",this.color="#000",this._backgroundImg=new Image,this._natureSize={width:0,height:0},this._scale=1,this._lineHeight=0,this._fontSize=0,this._backgroundImg=new Image}connectedCallback(){super.connectedCallback(),this._backgroundImg.src=this.backgroundUrl,this._backgroundImg.onload=()=>{this._natureSize={width:this._backgroundImg.naturalWidth,height:this._backgroundImg.naturalHeight}},this._canvasElement=document.createElement("canvas")}formatTextbox(t){var i;console.log({line:t==null?void 0:t.textLines,text:t==null?void 0:t.text});let e=t.textLines;if(console.log(e.length),e.length>12){const s=e.slice(0,12);t.set("text",s.join(`
628
- `)),t.setSelectionStart(t.text.length),t.setSelectionEnd(t.text.length),(i=this._canvas)==null||i.renderAll()}}firstUpdated(){const t=document.createElement("canvas");this._fabricContainer.appendChild(t),this._backgroundImg.onload=()=>{const e=new Xt(this._backgroundImg);this._canvas=new Vo(t,{backgroundImage:e,width:this._backgroundImg.naturalWidth,height:this._backgroundImg.naturalHeight}),this._lineHeight=.45*this._backgroundImg.height/12,this._fontSize=this._lineHeight/1.16;const i={fontSize:16,left:.084*this._backgroundImg.naturalWidth,top:.52*this._backgroundImg.naturalHeight,width:.832*this._backgroundImg.naturalWidth,height:.45*this._backgroundImg.naturalHeight,hasControls:!1,editable:!1,breakWords:!1,splitByGrapheme:!1,textAlign:this.alignment,lockMovementX:!0,lockMovementY:!0,selectable:!1};this._textbox=new li(this.message,i),this._textbox.set("fill",this.color),this._textbox.on("changed",()=>{var l;if(!this._textbox)return;let o=this._textbox.text.split(`
629
- `),a=[];o.forEach(c=>{if(c.length>20){const h=c.split(" ");let u="",d=0;h.forEach(f=>{d+f.length>20?(a.push(u.trim()),u=f+" ",d=f.length+1):(u+=f+" ",d+=f.length+1)}),u.trim().length>0&&a.push(u.trim())}else a.push(c)}),a.length>12&&(a=a.slice(0,12)),this._textbox.text=a.join(`
630
- `),this._textbox.setSelectionStart(this._textbox.text.length),this._textbox.setSelectionEnd(this._textbox.text.length),(l=this._canvas)==null||l.renderAll()}),this._canvas.add(this._textbox),this._canvas.centerObject(this._textbox),this._canvas.renderAll()},window.addEventListener("resize",()=>{var e;t.width=this._fabricContainer.clientWidth,t.height=this._fabricContainer.clientHeight,this.adjustCanvasElements(),(e=this._canvas)==null||e.renderAll()}),setTimeout(()=>this.adjustCanvasElements(),100)}adjustCanvasElements(){var t;if(this._canvas&&this._textbox&&this._backgroundImg&&this._backgroundImg.complete){const e=(t=this.shadowRoot)==null?void 0:t.querySelector(".fabric-container");if(!e)return;const i=e.clientWidth,s=e.clientHeight,r=this._backgroundImg.naturalWidth,o=this._backgroundImg.naturalHeight,a=s/o,l=i/r,c=Math.min(a,l);this._scale=c,console.log({parentWidth:i,parentHeight:s,naturalWidth:r,naturalHeight:o}),this._canvas.setWidth(r*c),this._canvas.setHeight(o*c);const h=this._canvas.backgroundImage;h&&(h.scaleToWidth(r*c),h.scaleToHeight(o*c)),this._textbox.set({left:.084*r*c,top:.52*o*c,width:.832*r*c,height:.45*o*c,fontSize:this._fontSize*c}),console.log(.45*o/12*.9*c),console.log(`Line height pixel: ${this._textbox.get("lineHeight")*this._textbox.get("fontSize")}px`),console.log(`Line height: ${this._textbox.get("lineHeight")}`),console.log(`Font size: ${this._textbox.get("fontSize")}px`);const u=.45*o*c/12;console.log(`desired line height: ${u}`),console.log(`scale width: ${.832*r*c} - scale height: ${.45*o*c}`),this._canvas.renderAll()}}updated(t){var e,i,s,r,o,a,l,c;console.log(t),this._textbox&&(t.has("message")&&((e=this._textbox)==null||e.set("text",this.message),this.formatTextbox(this._textbox),(i=this._canvas)==null||i.renderAll()),t.has("alignment")&&((s=this._textbox)==null||s.set("textAlign",this.alignment),(r=this._canvas)==null||r.renderAll()),t.has("fontFamily")&&((o=this._textbox)==null||o.set("fontFamily",this.fontFamily),(a=this._canvas)==null||a.renderAll()),t.has("color")&&((l=this._textbox)==null||l.set("fill",this.color),(c=this._canvas)==null||c.renderAll()))}render(){var t,e,i,s;return St`
138
+ `],t.MessageSelector.properties={giftLabel:{type:String},premiumLabel:{type:String},premiumDescription:{type:String},noteLabel:{type:String},giftSelected:{type:Boolean},premiumSelected:{type:Boolean},freeMessageSelected:{type:Boolean}},t.MessageSelector=((t,e,i,s)=>{for(var r,n=s>1?void 0:s?_t(e,i):e,o=t.length-1;o>=0;o--)(r=t[o])&&(n=r(n)||n);return n})([ct("pairbo-message-selector")],t.MessageSelector);let St=class{constructor(){bt(this,"browserShadowBlurConstant",1),bt(this,"DPI",96),bt(this,"devicePixelRatio","undefined"!=typeof window?window.devicePixelRatio:1),bt(this,"perfLimitSizeTotal",2097152),bt(this,"maxCacheSideLimit",4096),bt(this,"minCacheSideLimit",256),bt(this,"disableStyleCopyPaste",!1),bt(this,"enableGLFiltering",!0),bt(this,"textureSize",4096),bt(this,"forceGLPutImageData",!1),bt(this,"cachesBoundsOfCurve",!1),bt(this,"fontPaths",{}),bt(this,"NUM_FRACTION_DIGITS",4)}};const Tt=new class extends St{constructor(t){super(),this.configure(t)}configure(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};Object.assign(this,t)}addFonts(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.fontPaths=xt(xt({},this.fontPaths),t)}removeFonts(){(arguments.length>0&&void 0!==arguments[0]?arguments[0]:[]).forEach((t=>{delete this.fontPaths[t]}))}clearFonts(){this.fontPaths={}}restoreDefaults(t){const e=new St,i=(null==t?void 0:t.reduce(((t,i)=>(t[i]=e[i],t)),{}))||e;this.configure(i)}},Ot=function(t){for(var e=arguments.length,i=new Array(e>1?e-1:0),s=1;s<e;s++)i[s-1]=arguments[s];return console[t]("fabric",...i)};class Et extends Error{constructor(t,e){super("fabric: ".concat(t),e)}}class kt extends Et{constructor(t){super("".concat(t," 'options.signal' is in 'aborted' state"))}}let Dt=class{},At=class extends Dt{testPrecision(t,e){const i="precision ".concat(e," float;\nvoid main(){}"),s=t.createShader(t.FRAGMENT_SHADER);return!!s&&(t.shaderSource(s,i),t.compileShader(s),!!t.getShaderParameter(s,t.COMPILE_STATUS))}queryWebGL(t){const e=t.getContext("webgl");e&&(this.maxTextureSize=e.getParameter(e.MAX_TEXTURE_SIZE),this.GLPrecision=["highp","mediump","lowp"].find((t=>this.testPrecision(e,t))),e.getExtension("WEBGL_lose_context").loseContext(),Ot("log","WebGL: max texture size ".concat(this.maxTextureSize)))}isSupported(t){return!!this.maxTextureSize&&this.maxTextureSize>=t}};const Mt={};let Pt;const jt=()=>Pt||(Pt={document:document,window:window,isTouchSupported:"ontouchstart"in window||"ontouchstart"in document||window&&window.navigator&&window.navigator.maxTouchPoints>0,WebGLProbe:new At,dispose(){},copyPasteData:Mt}),Lt=()=>jt().document,Ft=()=>jt().window,It=()=>{var t;return Math.max(null!==(t=Tt.devicePixelRatio)&&void 0!==t?t:Ft().devicePixelRatio,1)},Rt=new class{constructor(){bt(this,"charWidthsCache",{}),bt(this,"boundsOfCurveCache",{})}getFontCache(t){let{fontFamily:e,fontStyle:i,fontWeight:s}=t;e=e.toLowerCase(),this.charWidthsCache[e]||(this.charWidthsCache[e]={});const r=this.charWidthsCache[e],n="".concat(i.toLowerCase(),"_").concat((s+"").toLowerCase());return r[n]||(r[n]={}),r[n]}clearFontCache(t){(t=(t||"").toLowerCase())?this.charWidthsCache[t]&&delete this.charWidthsCache[t]:this.charWidthsCache={}}limitDimsByArea(t){const{perfLimitSizeTotal:e}=Tt,i=Math.sqrt(e*t);return[Math.floor(i),Math.floor(e/i)]}},Bt="6.5.4";function Nt(){}const zt=Math.PI/2,Vt=2*Math.PI,$t=Math.PI/180,Wt=Object.freeze([1,0,0,1,0,0]),Ht=16,Xt=.4477152502,Ut="center",Yt="left",Gt="top",qt="bottom",Kt="right",Jt="none",Zt=/\r?\n/,Qt="moving",te="scaling",ee="rotating",ie="rotate",se="skewing",re="resizing",ne="modifyPoly",oe="modifyPath",ae="changed",le="scale",ce="scaleX",he="scaleY",de="skewX",ue="skewY",pe="fill",ge="stroke",fe="modified",me="json",ve="svg",_e=new class{constructor(){this[me]=new Map,this[ve]=new Map}has(t){return this[me].has(t)}getClass(t){const e=this[me].get(t);if(!e)throw new Et("No class registered for ".concat(t));return e}setClass(t,e){e?this[me].set(e,t):(this[me].set(t.type,t),this[me].set(t.type.toLowerCase(),t))}getSVGClass(t){return this[ve].get(t)}setSVGClass(t,e){this[ve].set(null!=e?e:t.type.toLowerCase(),t)}},be=new class extends Array{remove(t){const e=this.indexOf(t);e>-1&&this.splice(e,1)}cancelAll(){const t=this.splice(0);return t.forEach((t=>t.abort())),t}cancelByCanvas(t){if(!t)return[];const e=this.filter((e=>{var i;return e.target===t||"object"==typeof e.target&&(null===(i=e.target)||void 0===i?void 0:i.canvas)===t}));return e.forEach((t=>t.abort())),e}cancelByTarget(t){if(!t)return[];const e=this.filter((e=>e.target===t));return e.forEach((t=>t.abort())),e}};class ye{constructor(){bt(this,"__eventListeners",{})}on(t,e){if(this.__eventListeners||(this.__eventListeners={}),"object"==typeof t)return Object.entries(t).forEach((t=>{let[e,i]=t;this.on(e,i)})),()=>this.off(t);if(e){const i=t;return this.__eventListeners[i]||(this.__eventListeners[i]=[]),this.__eventListeners[i].push(e),()=>this.off(i,e)}return()=>!1}once(t,e){if("object"==typeof t){const e=[];return Object.entries(t).forEach((t=>{let[i,s]=t;e.push(this.once(i,s))})),()=>e.forEach((t=>t()))}if(e){const i=this.on(t,(function(){for(var t=arguments.length,s=new Array(t),r=0;r<t;r++)s[r]=arguments[r];e.call(this,...s),i()}));return i}return()=>!1}_removeEventListener(t,e){if(this.__eventListeners[t])if(e){const i=this.__eventListeners[t],s=i.indexOf(e);s>-1&&i.splice(s,1)}else this.__eventListeners[t]=[]}off(t,e){if(this.__eventListeners)if(void 0===t)for(const i in this.__eventListeners)this._removeEventListener(i);else"object"==typeof t?Object.entries(t).forEach((t=>{let[e,i]=t;this._removeEventListener(e,i)})):this._removeEventListener(t,e)}fire(t,e){var i;if(!this.__eventListeners)return;const s=null===(i=this.__eventListeners[t])||void 0===i?void 0:i.concat();if(s)for(let r=0;r<s.length;r++)s[r].call(this,e||{})}}const xe=(t,e)=>{const i=t.indexOf(e);return-1!==i&&t.splice(i,1),t},we=t=>{if(0===t)return 1;switch(Math.abs(t)/zt){case 1:case 3:return 0;case 2:return-1}return Math.cos(t)},Ce=t=>{if(0===t)return 0;const e=t/zt,i=Math.sign(t);switch(e){case 1:return i;case 2:return 0;case 3:return-i}return Math.sin(t)};class Se{constructor(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;"object"==typeof t?(this.x=t.x,this.y=t.y):(this.x=t,this.y=e)}add(t){return new Se(this.x+t.x,this.y+t.y)}addEquals(t){return this.x+=t.x,this.y+=t.y,this}scalarAdd(t){return new Se(this.x+t,this.y+t)}scalarAddEquals(t){return this.x+=t,this.y+=t,this}subtract(t){return new Se(this.x-t.x,this.y-t.y)}subtractEquals(t){return this.x-=t.x,this.y-=t.y,this}scalarSubtract(t){return new Se(this.x-t,this.y-t)}scalarSubtractEquals(t){return this.x-=t,this.y-=t,this}multiply(t){return new Se(this.x*t.x,this.y*t.y)}scalarMultiply(t){return new Se(this.x*t,this.y*t)}scalarMultiplyEquals(t){return this.x*=t,this.y*=t,this}divide(t){return new Se(this.x/t.x,this.y/t.y)}scalarDivide(t){return new Se(this.x/t,this.y/t)}scalarDivideEquals(t){return this.x/=t,this.y/=t,this}eq(t){return this.x===t.x&&this.y===t.y}lt(t){return this.x<t.x&&this.y<t.y}lte(t){return this.x<=t.x&&this.y<=t.y}gt(t){return this.x>t.x&&this.y>t.y}gte(t){return this.x>=t.x&&this.y>=t.y}lerp(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:.5;return e=Math.max(Math.min(1,e),0),new Se(this.x+(t.x-this.x)*e,this.y+(t.y-this.y)*e)}distanceFrom(t){const e=this.x-t.x,i=this.y-t.y;return Math.sqrt(e*e+i*i)}midPointFrom(t){return this.lerp(t)}min(t){return new Se(Math.min(this.x,t.x),Math.min(this.y,t.y))}max(t){return new Se(Math.max(this.x,t.x),Math.max(this.y,t.y))}toString(){return"".concat(this.x,",").concat(this.y)}setXY(t,e){return this.x=t,this.y=e,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setFromPoint(t){return this.x=t.x,this.y=t.y,this}swap(t){const e=this.x,i=this.y;this.x=t.x,this.y=t.y,t.x=e,t.y=i}clone(){return new Se(this.x,this.y)}rotate(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Te;const i=Ce(t),s=we(t),r=this.subtract(e);return new Se(r.x*s-r.y*i,r.x*i+r.y*s).add(e)}transform(t){let e=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return new Se(t[0]*this.x+t[2]*this.y+(e?0:t[4]),t[1]*this.x+t[3]*this.y+(e?0:t[5]))}}const Te=new Se(0,0),Oe=t=>!!t&&Array.isArray(t._objects);function Ee(t){class e extends t{constructor(){super(...arguments),bt(this,"_objects",[])}_onObjectAdded(t){}_onObjectRemoved(t){}_onStackOrderChanged(t){}add(){for(var t=arguments.length,e=new Array(t),i=0;i<t;i++)e[i]=arguments[i];const s=this._objects.push(...e);return e.forEach((t=>this._onObjectAdded(t))),s}insertAt(t){for(var e=arguments.length,i=new Array(e>1?e-1:0),s=1;s<e;s++)i[s-1]=arguments[s];return this._objects.splice(t,0,...i),i.forEach((t=>this._onObjectAdded(t))),this._objects.length}remove(){const t=this._objects,e=[];for(var i=arguments.length,s=new Array(i),r=0;r<i;r++)s[r]=arguments[r];return s.forEach((i=>{const s=t.indexOf(i);-1!==s&&(t.splice(s,1),e.push(i),this._onObjectRemoved(i))})),e}forEachObject(t){this.getObjects().forEach(((e,i,s)=>t(e,i,s)))}getObjects(){for(var t=arguments.length,e=new Array(t),i=0;i<t;i++)e[i]=arguments[i];return 0===e.length?[...this._objects]:this._objects.filter((t=>t.isType(...e)))}item(t){return this._objects[t]}isEmpty(){return 0===this._objects.length}size(){return this._objects.length}contains(t,i){return!!this._objects.includes(t)||!!i&&this._objects.some((i=>i instanceof e&&i.contains(t,!0)))}complexity(){return this._objects.reduce(((t,e)=>t+(e.complexity?e.complexity():0)),0)}sendObjectToBack(t){return!(!t||t===this._objects[0]||(xe(this._objects,t),this._objects.unshift(t),this._onStackOrderChanged(t),0))}bringObjectToFront(t){return!(!t||t===this._objects[this._objects.length-1]||(xe(this._objects,t),this._objects.push(t),this._onStackOrderChanged(t),0))}sendObjectBackwards(t,e){if(!t)return!1;const i=this._objects.indexOf(t);if(0!==i){const s=this.findNewLowerIndex(t,i,e);return xe(this._objects,t),this._objects.splice(s,0,t),this._onStackOrderChanged(t),!0}return!1}bringObjectForward(t,e){if(!t)return!1;const i=this._objects.indexOf(t);if(i!==this._objects.length-1){const s=this.findNewUpperIndex(t,i,e);return xe(this._objects,t),this._objects.splice(s,0,t),this._onStackOrderChanged(t),!0}return!1}moveObjectTo(t,e){return t!==this._objects[e]&&(xe(this._objects,t),this._objects.splice(e,0,t),this._onStackOrderChanged(t),!0)}findNewLowerIndex(t,e,i){let s;if(i){s=e;for(let i=e-1;i>=0;--i)if(t.isOverlapping(this._objects[i])){s=i;break}}else s=e-1;return s}findNewUpperIndex(t,e,i){let s;if(i){s=e;for(let i=e+1;i<this._objects.length;++i)if(t.isOverlapping(this._objects[i])){s=i;break}}else s=e+1;return s}collectObjects(t){let{left:e,top:i,width:s,height:r}=t,{includeIntersecting:n=!0}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const o=[],a=new Se(e,i),l=a.add(new Se(s,r));for(let c=this._objects.length-1;c>=0;c--){const t=this._objects[c];t.selectable&&t.visible&&(n&&t.intersectsWithRect(a,l)||t.isContainedWithinRect(a,l)||n&&t.containsPoint(a)||n&&t.containsPoint(l))&&o.push(t)}return o}}return e}class ke extends ye{_setOptions(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};for(const e in t)this.set(e,t[e])}_setObject(t){for(const e in t)this._set(e,t[e])}set(t,e){return"object"==typeof t?this._setObject(t):this._set(t,e),this}_set(t,e){this[t]=e}toggle(t){const e=this.get(t);return"boolean"==typeof e&&this.set(t,!e),this}get(t){return this[t]}}function De(t){return Ft().requestAnimationFrame(t)}let Ae=0;const Me=()=>Ae++,Pe=()=>{const t=Lt().createElement("canvas");if(!t||void 0===t.getContext)throw new Et("Failed to create `canvas` element");return t},je=t=>{const e=Pe();return e.width=t.width,e.height=t.height,e},Le=(t,e,i)=>t.toDataURL("image/".concat(e),i),Fe=t=>t*$t,Ie=t=>t/$t,Re=(t,e,i)=>new Se(t).transform(e,i),Be=t=>{const e=1/(t[0]*t[3]-t[1]*t[2]),i=[e*t[3],-e*t[1],-e*t[2],e*t[0],0,0],{x:s,y:r}=new Se(t[4],t[5]).transform(i,!0);return i[4]=-s,i[5]=-r,i},Ne=(t,e,i)=>[t[0]*e[0]+t[2]*e[1],t[1]*e[0]+t[3]*e[1],t[0]*e[2]+t[2]*e[3],t[1]*e[2]+t[3]*e[3],i?0:t[0]*e[4]+t[2]*e[5]+t[4],i?0:t[1]*e[4]+t[3]*e[5]+t[5]],ze=(t,e)=>t.reduceRight(((t,i)=>i&&t?Ne(i,t,e):i||t),void 0)||Wt.concat(),Ve=t=>{let[e,i]=t;return Math.atan2(i,e)},$e=t=>{const e=Ve(t),i=Math.pow(t[0],2)+Math.pow(t[1],2),s=Math.sqrt(i),r=(t[0]*t[3]-t[2]*t[1])/s,n=Math.atan2(t[0]*t[2]+t[1]*t[3],i);return{angle:Ie(e),scaleX:s,scaleY:r,skewX:Ie(n),skewY:0,translateX:t[4]||0,translateY:t[5]||0}},We=function(t){return[1,0,0,1,t,arguments.length>1&&void 0!==arguments[1]?arguments[1]:0]};function He(){let{angle:t=0}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},{x:e=0,y:i=0}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const s=Fe(t),r=we(s),n=Ce(s);return[r,n,-n,r,e?e-(r*e-n*i):0,i?i-(n*e+r*i):0]}const Xe=function(t){return[t,0,0,arguments.length>1&&void 0!==arguments[1]?arguments[1]:t,0,0]},Ue=t=>Math.tan(Fe(t)),Ye=t=>[1,0,Ue(t),1,0,0],Ge=t=>[1,Ue(t),0,1,0,0],qe=t=>{let{scaleX:e=1,scaleY:i=1,flipX:s=!1,flipY:r=!1,skewX:n=0,skewY:o=0}=t,a=Xe(s?-e:e,r?-i:i);return n&&(a=Ne(a,Ye(n),!0)),o&&(a=Ne(a,Ge(o),!0)),a},Ke=t=>{const{translateX:e=0,translateY:i=0,angle:s=0}=t;let r=We(e,i);s&&(r=Ne(r,He({angle:s})));const n=qe(t);return(t=>t.every(((t,e)=>t===Wt[e])))(n)||(r=Ne(r,n)),r},Je=function(t){let{signal:e,crossOrigin:i=null}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return new Promise((function(s,r){if(e&&e.aborted)return r(new kt("loadImage"));const n=Lt().createElement("img");let o;e&&(o=function(t){n.src="",r(t)},e.addEventListener("abort",o,{once:!0}));const a=function(){n.onload=n.onerror=null,o&&(null==e||e.removeEventListener("abort",o)),s(n)};t?(n.onload=a,n.onerror=function(){o&&(null==e||e.removeEventListener("abort",o)),r(new Et("Error loading ".concat(n.src)))},i&&(n.crossOrigin=i),n.src=t):a()}))},Ze=function(t){let{signal:e,reviver:i=Nt}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return new Promise(((s,r)=>{const n=[];e&&e.addEventListener("abort",r,{once:!0}),Promise.all(t.map((t=>_e.getClass(t.type).fromObject(t,{signal:e}).then((e=>(i(t,e),n.push(e),e)))))).then(s).catch((t=>{n.forEach((t=>{t.dispose&&t.dispose()})),r(t)})).finally((()=>{e&&e.removeEventListener("abort",r)}))}))},Qe=function(t){let{signal:e}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return new Promise(((i,s)=>{const r=[];e&&e.addEventListener("abort",s,{once:!0});const n=Object.values(t).map((t=>t&&t.type&&_e.has(t.type)?Ze([t],{signal:e}).then((t=>{let[e]=t;return r.push(e),e})):t)),o=Object.keys(t);Promise.all(n).then((t=>t.reduce(((t,e,i)=>(t[o[i]]=e,t)),{}))).then(i).catch((t=>{r.forEach((t=>{t.dispose&&t.dispose()})),s(t)})).finally((()=>{e&&e.removeEventListener("abort",s)}))}))},ti=function(t){return(arguments.length>1&&void 0!==arguments[1]?arguments[1]:[]).reduce(((e,i)=>(i in t&&(e[i]=t[i]),e)),{})},ei=(t,e)=>Object.keys(t).reduce(((i,s)=>(e(t[s],s,t)&&(i[s]=t[s]),i)),{}),ii={aliceblue:"#F0F8FF",antiquewhite:"#FAEBD7",aqua:"#0FF",aquamarine:"#7FFFD4",azure:"#F0FFFF",beige:"#F5F5DC",bisque:"#FFE4C4",black:"#000",blanchedalmond:"#FFEBCD",blue:"#00F",blueviolet:"#8A2BE2",brown:"#A52A2A",burlywood:"#DEB887",cadetblue:"#5F9EA0",chartreuse:"#7FFF00",chocolate:"#D2691E",coral:"#FF7F50",cornflowerblue:"#6495ED",cornsilk:"#FFF8DC",crimson:"#DC143C",cyan:"#0FF",darkblue:"#00008B",darkcyan:"#008B8B",darkgoldenrod:"#B8860B",darkgray:"#A9A9A9",darkgrey:"#A9A9A9",darkgreen:"#006400",darkkhaki:"#BDB76B",darkmagenta:"#8B008B",darkolivegreen:"#556B2F",darkorange:"#FF8C00",darkorchid:"#9932CC",darkred:"#8B0000",darksalmon:"#E9967A",darkseagreen:"#8FBC8F",darkslateblue:"#483D8B",darkslategray:"#2F4F4F",darkslategrey:"#2F4F4F",darkturquoise:"#00CED1",darkviolet:"#9400D3",deeppink:"#FF1493",deepskyblue:"#00BFFF",dimgray:"#696969",dimgrey:"#696969",dodgerblue:"#1E90FF",firebrick:"#B22222",floralwhite:"#FFFAF0",forestgreen:"#228B22",fuchsia:"#F0F",gainsboro:"#DCDCDC",ghostwhite:"#F8F8FF",gold:"#FFD700",goldenrod:"#DAA520",gray:"#808080",grey:"#808080",green:"#008000",greenyellow:"#ADFF2F",honeydew:"#F0FFF0",hotpink:"#FF69B4",indianred:"#CD5C5C",indigo:"#4B0082",ivory:"#FFFFF0",khaki:"#F0E68C",lavender:"#E6E6FA",lavenderblush:"#FFF0F5",lawngreen:"#7CFC00",lemonchiffon:"#FFFACD",lightblue:"#ADD8E6",lightcoral:"#F08080",lightcyan:"#E0FFFF",lightgoldenrodyellow:"#FAFAD2",lightgray:"#D3D3D3",lightgrey:"#D3D3D3",lightgreen:"#90EE90",lightpink:"#FFB6C1",lightsalmon:"#FFA07A",lightseagreen:"#20B2AA",lightskyblue:"#87CEFA",lightslategray:"#789",lightslategrey:"#789",lightsteelblue:"#B0C4DE",lightyellow:"#FFFFE0",lime:"#0F0",limegreen:"#32CD32",linen:"#FAF0E6",magenta:"#F0F",maroon:"#800000",mediumaquamarine:"#66CDAA",mediumblue:"#0000CD",mediumorchid:"#BA55D3",mediumpurple:"#9370DB",mediumseagreen:"#3CB371",mediumslateblue:"#7B68EE",mediumspringgreen:"#00FA9A",mediumturquoise:"#48D1CC",mediumvioletred:"#C71585",midnightblue:"#191970",mintcream:"#F5FFFA",mistyrose:"#FFE4E1",moccasin:"#FFE4B5",navajowhite:"#FFDEAD",navy:"#000080",oldlace:"#FDF5E6",olive:"#808000",olivedrab:"#6B8E23",orange:"#FFA500",orangered:"#FF4500",orchid:"#DA70D6",palegoldenrod:"#EEE8AA",palegreen:"#98FB98",paleturquoise:"#AFEEEE",palevioletred:"#DB7093",papayawhip:"#FFEFD5",peachpuff:"#FFDAB9",peru:"#CD853F",pink:"#FFC0CB",plum:"#DDA0DD",powderblue:"#B0E0E6",purple:"#800080",rebeccapurple:"#639",red:"#F00",rosybrown:"#BC8F8F",royalblue:"#4169E1",saddlebrown:"#8B4513",salmon:"#FA8072",sandybrown:"#F4A460",seagreen:"#2E8B57",seashell:"#FFF5EE",sienna:"#A0522D",silver:"#C0C0C0",skyblue:"#87CEEB",slateblue:"#6A5ACD",slategray:"#708090",slategrey:"#708090",snow:"#FFFAFA",springgreen:"#00FF7F",steelblue:"#4682B4",tan:"#D2B48C",teal:"#008080",thistle:"#D8BFD8",tomato:"#FF6347",turquoise:"#40E0D0",violet:"#EE82EE",wheat:"#F5DEB3",white:"#FFF",whitesmoke:"#F5F5F5",yellow:"#FF0",yellowgreen:"#9ACD32"},si=(t,e,i)=>(i<0&&(i+=1),i>1&&(i-=1),i<1/6?t+6*(e-t)*i:i<.5?e:i<2/3?t+(e-t)*(2/3-i)*6:t),ri=(t,e,i,s)=>{t/=255,e/=255,i/=255;const r=Math.max(t,e,i),n=Math.min(t,e,i);let o,a;const l=(r+n)/2;if(r===n)o=a=0;else{const s=r-n;switch(a=l>.5?s/(2-r-n):s/(r+n),r){case t:o=(e-i)/s+(e<i?6:0);break;case e:o=(i-t)/s+2;break;case i:o=(t-e)/s+4}o/=6}return[Math.round(360*o),Math.round(100*a),Math.round(100*l),s]},ni=function(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"1";return parseFloat(t)/(t.endsWith("%")?100:1)},oi=t=>Math.min(Math.round(t),255).toString(16).toUpperCase().padStart(2,"0"),ai=t=>{let[e,i,s,r=1]=t;const n=Math.round(.3*e+.59*i+.11*s);return[n,n,n,r]};class li{constructor(t){if(bt(this,"isUnrecognised",!1),t)if(t instanceof li)this.setSource([...t._source]);else if(Array.isArray(t)){const[e,i,s,r=1]=t;this.setSource([e,i,s,r])}else this.setSource(this._tryParsingColor(t));else this.setSource([0,0,0,1])}_tryParsingColor(t){return(t=t.toLowerCase())in ii&&(t=ii[t]),"transparent"===t?[255,255,255,0]:li.sourceFromHex(t)||li.sourceFromRgb(t)||li.sourceFromHsl(t)||(this.isUnrecognised=!0)&&[0,0,0,1]}getSource(){return this._source}setSource(t){this._source=t}toRgb(){const[t,e,i]=this.getSource();return"rgb(".concat(t,",").concat(e,",").concat(i,")")}toRgba(){return"rgba(".concat(this.getSource().join(","),")")}toHsl(){const[t,e,i]=ri(...this.getSource());return"hsl(".concat(t,",").concat(e,"%,").concat(i,"%)")}toHsla(){const[t,e,i,s]=ri(...this.getSource());return"hsla(".concat(t,",").concat(e,"%,").concat(i,"%,").concat(s,")")}toHex(){return this.toHexa().slice(0,6)}toHexa(){const[t,e,i,s]=this.getSource();return"".concat(oi(t)).concat(oi(e)).concat(oi(i)).concat(oi(Math.round(255*s)))}getAlpha(){return this.getSource()[3]}setAlpha(t){return this._source[3]=t,this}toGrayscale(){return this.setSource(ai(this.getSource())),this}toBlackWhite(t){const[e,,,i]=ai(this.getSource()),s=e<(t||127)?0:255;return this.setSource([s,s,s,i]),this}overlayWith(t){t instanceof li||(t=new li(t));const e=this.getSource(),i=t.getSource(),[s,r,n]=e.map(((t,e)=>Math.round(.5*t+.5*i[e])));return this.setSource([s,r,n,e[3]]),this}static fromRgb(t){return li.fromRgba(t)}static fromRgba(t){return new li(li.sourceFromRgb(t))}static sourceFromRgb(t){const e=t.match(/^rgba?\(\s*(\d{0,3}(?:\.\d+)?%?)\s*[\s|,]\s*(\d{0,3}(?:\.\d+)?%?)\s*[\s|,]\s*(\d{0,3}(?:\.\d+)?%?)\s*(?:\s*[,/]\s*(\d{0,3}(?:\.\d+)?%?)\s*)?\)$/i);if(e){const[t,i,s]=e.slice(1,4).map((t=>{const e=parseFloat(t);return t.endsWith("%")?Math.round(2.55*e):e}));return[t,i,s,ni(e[4])]}}static fromHsl(t){return li.fromHsla(t)}static fromHsla(t){return new li(li.sourceFromHsl(t))}static sourceFromHsl(t){const e=t.match(/^hsla?\(\s*([+-]?\d{0,3}(?:\.\d+)?(?:deg|turn|rad)?)\s*[\s|,]\s*(\d{0,3}(?:\.\d+)?%?)\s*[\s|,]\s*(\d{0,3}(?:\.\d+)?%?)\s*(?:\s*[,/]\s*(\d*(?:\.\d+)?%?)\s*)?\)$/i);if(!e)return;const i=(li.parseAngletoDegrees(e[1])%360+360)%360/360,s=parseFloat(e[2])/100,r=parseFloat(e[3])/100;let n,o,a;if(0===s)n=o=a=r;else{const t=r<=.5?r*(s+1):r+s-r*s,e=2*r-t;n=si(e,t,i+1/3),o=si(e,t,i),a=si(e,t,i-1/3)}return[Math.round(255*n),Math.round(255*o),Math.round(255*a),ni(e[4])]}static fromHex(t){return new li(li.sourceFromHex(t))}static sourceFromHex(t){if(t.match(/^#?(([0-9a-f]){3,4}|([0-9a-f]{2}){3,4})$/i)){const e=t.slice(t.indexOf("#")+1);let i;i=e.length<=4?e.split("").map((t=>t+t)):e.match(/.{2}/g);const[s,r,n,o=255]=i.map((t=>parseInt(t,16)));return[s,r,n,o/255]}}static parseAngletoDegrees(t){const e=t.toLowerCase(),i=parseFloat(e);return e.includes("rad")?Ie(i):e.includes("turn")?360*i:i}}const ci=(t,e)=>parseFloat(Number(t).toFixed(e)),hi=function(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Ht;const i=/\D{0,2}$/.exec(t),s=parseFloat(t),r=Tt.DPI;switch(null==i?void 0:i[0]){case"mm":return s*r/25.4;case"cm":return s*r/2.54;case"in":return s*r;case"pt":return s*r/72;case"pc":return s*r/72*12;case"em":return s*e;default:return s}},di=t=>"matrix("+t.map((t=>ci(t,Tt.NUM_FRACTION_DIGITS))).join(" ")+")",ui=function(t,e){let i,s,r=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];if(e)if(e.toLive)i="url(#SVGID_".concat(e.id,")");else{const t=new li(e),r=t.getAlpha();i=t.toRgb(),1!==r&&(s=r.toString())}else i="none";return r?"".concat(t,": ").concat(i,"; ").concat(s?"".concat(t,"-opacity: ").concat(s,"; "):""):"".concat(t,'="').concat(i,'" ').concat(s?"".concat(t,'-opacity="').concat(s,'" '):"")},pi=t=>!!t&&void 0!==t.toLive,gi=t=>!!t&&"function"==typeof t.toObject,fi=t=>!!t&&void 0!==t.offsetX&&"source"in t,mi=t=>!!t&&"multiSelectionStacking"in t;function vi(t){const e=t&&_i(t);let i=0,s=0;if(!t||!e)return{left:i,top:s};let r=t;const n=e.documentElement,o=e.body||{scrollLeft:0,scrollTop:0};for(;r&&(r.parentNode||r.host)&&(r=r.parentNode||r.host,r===e?(i=o.scrollLeft||n.scrollLeft||0,s=o.scrollTop||n.scrollTop||0):(i+=r.scrollLeft||0,s+=r.scrollTop||0),1!==r.nodeType||"fixed"!==r.style.position););return{left:i,top:s}}const _i=t=>t.ownerDocument||null,bi=t=>{var e;return(null===(e=t.ownerDocument)||void 0===e?void 0:e.defaultView)||null},yi=function(t,e,i){let{width:s,height:r}=i,n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:1;t.width=s,t.height=r,n>1&&(t.setAttribute("width",(s*n).toString()),t.setAttribute("height",(r*n).toString()),e.scale(n,n))},xi=(t,e)=>{let{width:i,height:s}=e;i&&(t.style.width="number"==typeof i?"".concat(i,"px"):i),s&&(t.style.height="number"==typeof s?"".concat(s,"px"):s)};function wi(t){return void 0!==t.onselectstart&&(t.onselectstart=()=>!1),t.style.userSelect=Jt,t}class Ci{constructor(t){bt(this,"_originalCanvasStyle",void 0),bt(this,"lower",void 0);const e=this.createLowerCanvas(t);this.lower={el:e,ctx:e.getContext("2d")}}createLowerCanvas(t){const e=(i=t)&&void 0!==i.getContext?t:t&&Lt().getElementById(t)||Pe();var i;if(e.hasAttribute("data-fabric"))throw new Et("Trying to initialize a canvas that has already been initialized. Did you forget to dispose the canvas?");return this._originalCanvasStyle=e.style.cssText,e.setAttribute("data-fabric","main"),e.classList.add("lower-canvas"),e}cleanupDOM(t){let{width:e,height:i}=t;const{el:s}=this.lower;s.classList.remove("lower-canvas"),s.removeAttribute("data-fabric"),s.setAttribute("width","".concat(e)),s.setAttribute("height","".concat(i)),s.style.cssText=this._originalCanvasStyle||"",this._originalCanvasStyle=void 0}setDimensions(t,e){const{el:i,ctx:s}=this.lower;yi(i,s,t,e)}setCSSDimensions(t){xi(this.lower.el,t)}calcOffset(){return function(t){var e;const i=t&&_i(t),s={left:0,top:0};if(!i)return s;const r=(null===(e=bi(t))||void 0===e?void 0:e.getComputedStyle(t,null))||{};s.left+=parseInt(r.borderLeftWidth,10)||0,s.top+=parseInt(r.borderTopWidth,10)||0,s.left+=parseInt(r.paddingLeft,10)||0,s.top+=parseInt(r.paddingTop,10)||0;let n={left:0,top:0};const o=i.documentElement;void 0!==t.getBoundingClientRect&&(n=t.getBoundingClientRect());const a=vi(t);return{left:n.left+a.left-(o.clientLeft||0)+s.left,top:n.top+a.top-(o.clientTop||0)+s.top}}(this.lower.el)}dispose(){jt().dispose(this.lower.el),delete this.lower}}const Si={backgroundVpt:!0,backgroundColor:"",overlayVpt:!0,overlayColor:"",includeDefaultValues:!0,svgViewportTransformation:!0,renderOnAddRemove:!0,skipOffscreen:!0,enableRetinaScaling:!0,imageSmoothingEnabled:!0,controlsAboveOverlay:!1,allowTouchScrolling:!1,viewportTransform:[...Wt]};class Ti extends(Ee(ke)){get lowerCanvasEl(){var t;return null===(t=this.elements.lower)||void 0===t?void 0:t.el}get contextContainer(){var t;return null===(t=this.elements.lower)||void 0===t?void 0:t.ctx}static getDefaults(){return Ti.ownDefaults}constructor(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};super(),Object.assign(this,this.constructor.getDefaults()),this.set(e),this.initElements(t),this._setDimensionsImpl({width:this.width||this.elements.lower.el.width||0,height:this.height||this.elements.lower.el.height||0}),this.skipControlsDrawing=!1,this.viewportTransform=[...this.viewportTransform],this.calcViewportBoundaries()}initElements(t){this.elements=new Ci(t)}add(){const t=super.add(...arguments);return arguments.length>0&&this.renderOnAddRemove&&this.requestRenderAll(),t}insertAt(t){for(var e=arguments.length,i=new Array(e>1?e-1:0),s=1;s<e;s++)i[s-1]=arguments[s];const r=super.insertAt(t,...i);return i.length>0&&this.renderOnAddRemove&&this.requestRenderAll(),r}remove(){const t=super.remove(...arguments);return t.length>0&&this.renderOnAddRemove&&this.requestRenderAll(),t}_onObjectAdded(t){t.canvas&&t.canvas!==this&&(Ot("warn","Canvas is trying to add an object that belongs to a different canvas.\nResulting to default behavior: removing object from previous canvas and adding to new canvas"),t.canvas.remove(t)),t._set("canvas",this),t.setCoords(),this.fire("object:added",{target:t}),t.fire("added",{target:this})}_onObjectRemoved(t){t._set("canvas",void 0),this.fire("object:removed",{target:t}),t.fire("removed",{target:this})}_onStackOrderChanged(){this.renderOnAddRemove&&this.requestRenderAll()}getRetinaScaling(){return this.enableRetinaScaling?It():1}calcOffset(){return this._offset=this.elements.calcOffset()}getWidth(){return this.width}getHeight(){return this.height}setWidth(t,e){return this.setDimensions({width:t},e)}setHeight(t,e){return this.setDimensions({height:t},e)}_setDimensionsImpl(t){let{cssOnly:e=!1,backstoreOnly:i=!1}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!e){const e=xt({width:this.width,height:this.height},t);this.elements.setDimensions(e,this.getRetinaScaling()),this.hasLostContext=!0,this.width=e.width,this.height=e.height}i||this.elements.setCSSDimensions(t),this.calcOffset()}setDimensions(t,e){this._setDimensionsImpl(t,e),e&&e.cssOnly||this.requestRenderAll()}getZoom(){return this.viewportTransform[0]}setViewportTransform(t){this.viewportTransform=t,this.calcViewportBoundaries(),this.renderOnAddRemove&&this.requestRenderAll()}zoomToPoint(t,e){const i=t,s=[...this.viewportTransform],r=Re(t,Be(s));s[0]=e,s[3]=e;const n=Re(r,s);s[4]+=i.x-n.x,s[5]+=i.y-n.y,this.setViewportTransform(s)}setZoom(t){this.zoomToPoint(new Se(0,0),t)}absolutePan(t){const e=[...this.viewportTransform];return e[4]=-t.x,e[5]=-t.y,this.setViewportTransform(e)}relativePan(t){return this.absolutePan(new Se(-t.x-this.viewportTransform[4],-t.y-this.viewportTransform[5]))}getElement(){return this.elements.lower.el}clearContext(t){t.clearRect(0,0,this.width,this.height)}getContext(){return this.elements.lower.ctx}clear(){this.remove(...this.getObjects()),this.backgroundImage=void 0,this.overlayImage=void 0,this.backgroundColor="",this.overlayColor="",this.clearContext(this.getContext()),this.fire("canvas:cleared"),this.renderOnAddRemove&&this.requestRenderAll()}renderAll(){this.cancelRequestedRender(),this.destroyed||this.renderCanvas(this.getContext(),this._objects)}renderAndReset(){this.nextRenderHandle=0,this.renderAll()}requestRenderAll(){this.nextRenderHandle||this.disposed||this.destroyed||(this.nextRenderHandle=De((()=>this.renderAndReset())))}calcViewportBoundaries(){const t=this.width,e=this.height,i=Be(this.viewportTransform),s=Re({x:0,y:0},i),r=Re({x:t,y:e},i),n=s.min(r),o=s.max(r);return this.vptCoords={tl:n,tr:new Se(o.x,n.y),bl:new Se(n.x,o.y),br:o}}cancelRequestedRender(){this.nextRenderHandle&&(function(t){Ft().cancelAnimationFrame(t)}(this.nextRenderHandle),this.nextRenderHandle=0)}drawControls(t){}renderCanvas(t,e){if(this.destroyed)return;const i=this.viewportTransform,s=this.clipPath;this.calcViewportBoundaries(),this.clearContext(t),t.imageSmoothingEnabled=this.imageSmoothingEnabled,t.patternQuality="best",this.fire("before:render",{ctx:t}),this._renderBackground(t),t.save(),t.transform(i[0],i[1],i[2],i[3],i[4],i[5]),this._renderObjects(t,e),t.restore(),this.controlsAboveOverlay||this.skipControlsDrawing||this.drawControls(t),s&&(s._set("canvas",this),s.shouldCache(),s._transformDone=!0,s.renderCache({forClipping:!0}),this.drawClipPathOnCanvas(t,s)),this._renderOverlay(t),this.controlsAboveOverlay&&!this.skipControlsDrawing&&this.drawControls(t),this.fire("after:render",{ctx:t}),this.__cleanupTask&&(this.__cleanupTask(),this.__cleanupTask=void 0)}drawClipPathOnCanvas(t,e){const i=this.viewportTransform;t.save(),t.transform(...i),t.globalCompositeOperation="destination-in",e.transform(t),t.scale(1/e.zoomX,1/e.zoomY),t.drawImage(e._cacheCanvas,-e.cacheTranslationX,-e.cacheTranslationY),t.restore()}_renderObjects(t,e){for(let i=0,s=e.length;i<s;++i)e[i]&&e[i].render(t)}_renderBackgroundOrOverlay(t,e){const i=this["".concat(e,"Color")],s=this["".concat(e,"Image")],r=this.viewportTransform,n=this["".concat(e,"Vpt")];if(!i&&!s)return;const o=pi(i);if(i){if(t.save(),t.beginPath(),t.moveTo(0,0),t.lineTo(this.width,0),t.lineTo(this.width,this.height),t.lineTo(0,this.height),t.closePath(),t.fillStyle=o?i.toLive(t):i,n&&t.transform(...r),o){t.transform(1,0,0,1,i.offsetX||0,i.offsetY||0);const e=i.gradientTransform||i.patternTransform;e&&t.transform(...e)}t.fill(),t.restore()}if(s){t.save();const{skipOffscreen:e}=this;this.skipOffscreen=n,n&&t.transform(...r),s.render(t),this.skipOffscreen=e,t.restore()}}_renderBackground(t){this._renderBackgroundOrOverlay(t,"background")}_renderOverlay(t){this._renderBackgroundOrOverlay(t,"overlay")}getCenter(){return{top:this.height/2,left:this.width/2}}getCenterPoint(){return new Se(this.width/2,this.height/2)}centerObjectH(t){return this._centerObject(t,new Se(this.getCenterPoint().x,t.getCenterPoint().y))}centerObjectV(t){return this._centerObject(t,new Se(t.getCenterPoint().x,this.getCenterPoint().y))}centerObject(t){return this._centerObject(t,this.getCenterPoint())}viewportCenterObject(t){return this._centerObject(t,this.getVpCenter())}viewportCenterObjectH(t){return this._centerObject(t,new Se(this.getVpCenter().x,t.getCenterPoint().y))}viewportCenterObjectV(t){return this._centerObject(t,new Se(t.getCenterPoint().x,this.getVpCenter().y))}getVpCenter(){return Re(this.getCenterPoint(),Be(this.viewportTransform))}_centerObject(t,e){t.setXY(e,Ut,Ut),t.setCoords(),this.renderOnAddRemove&&this.requestRenderAll()}toDatalessJSON(t){return this.toDatalessObject(t)}toObject(t){return this._toObjectMethod("toObject",t)}toJSON(){return this.toObject()}toDatalessObject(t){return this._toObjectMethod("toDatalessObject",t)}_toObjectMethod(t,e){const i=this.clipPath,s=i&&!i.excludeFromExport?this._toObject(i,t,e):null;return xt(xt(xt({version:Bt},ti(this,e)),{},{objects:this._objects.filter((t=>!t.excludeFromExport)).map((i=>this._toObject(i,t,e)))},this.__serializeBgOverlay(t,e)),s?{clipPath:s}:null)}_toObject(t,e,i){let s;this.includeDefaultValues||(s=t.includeDefaultValues,t.includeDefaultValues=!1);const r=t[e](i);return this.includeDefaultValues||(t.includeDefaultValues=!!s),r}__serializeBgOverlay(t,e){const i={},s=this.backgroundImage,r=this.overlayImage,n=this.backgroundColor,o=this.overlayColor;return pi(n)?n.excludeFromExport||(i.background=n.toObject(e)):n&&(i.background=n),pi(o)?o.excludeFromExport||(i.overlay=o.toObject(e)):o&&(i.overlay=o),s&&!s.excludeFromExport&&(i.backgroundImage=this._toObject(s,t,e)),r&&!r.excludeFromExport&&(i.overlayImage=this._toObject(r,t,e)),i}toSVG(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},e=arguments.length>1?arguments[1]:void 0;t.reviver=e;const i=[];return this._setSVGPreamble(i,t),this._setSVGHeader(i,t),this.clipPath&&i.push('<g clip-path="url(#'.concat(this.clipPath.clipPathId,')" >\n')),this._setSVGBgOverlayColor(i,"background"),this._setSVGBgOverlayImage(i,"backgroundImage",e),this._setSVGObjects(i,e),this.clipPath&&i.push("</g>\n"),this._setSVGBgOverlayColor(i,"overlay"),this._setSVGBgOverlayImage(i,"overlayImage",e),i.push("</svg>"),i.join("")}_setSVGPreamble(t,e){e.suppressPreamble||t.push('<?xml version="1.0" encoding="',e.encoding||"UTF-8",'" standalone="no" ?>\n','<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" ','"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">\n')}_setSVGHeader(t,e){const i=e.width||"".concat(this.width),s=e.height||"".concat(this.height),r=Tt.NUM_FRACTION_DIGITS,n=e.viewBox;let o;if(n)o='viewBox="'.concat(n.x," ").concat(n.y," ").concat(n.width," ").concat(n.height,'" ');else if(this.svgViewportTransformation){const t=this.viewportTransform;o='viewBox="'.concat(ci(-t[4]/t[0],r)," ").concat(ci(-t[5]/t[3],r)," ").concat(ci(this.width/t[0],r)," ").concat(ci(this.height/t[3],r),'" ')}else o='viewBox="0 0 '.concat(this.width," ").concat(this.height,'" ');t.push("<svg ",'xmlns="http://www.w3.org/2000/svg" ','xmlns:xlink="http://www.w3.org/1999/xlink" ','version="1.1" ','width="',i,'" ','height="',s,'" ',o,'xml:space="preserve">\n',"<desc>Created with Fabric.js ",Bt,"</desc>\n","<defs>\n",this.createSVGFontFacesMarkup(),this.createSVGRefElementsMarkup(),this.createSVGClipPathMarkup(e),"</defs>\n")}createSVGClipPathMarkup(t){const e=this.clipPath;return e?(e.clipPathId="CLIPPATH_".concat(Me()),'<clipPath id="'.concat(e.clipPathId,'" >\n').concat(e.toClipPathSVG(t.reviver),"</clipPath>\n")):""}createSVGRefElementsMarkup(){return["background","overlay"].map((t=>{const e=this["".concat(t,"Color")];if(pi(e)){const i=this["".concat(t,"Vpt")],s=this.viewportTransform,r={isType:()=>!1,width:this.width/(i?s[0]:1),height:this.height/(i?s[3]:1)};return e.toSVG(r,{additionalTransform:i?di(s):""})}})).join("")}createSVGFontFacesMarkup(){const t=[],e={},i=Tt.fontPaths;this._objects.forEach((function e(i){t.push(i),Oe(i)&&i._objects.forEach(e)})),t.forEach((t=>{if(!(s=t)||"function"!=typeof s._renderText)return;var s;const{styles:r,fontFamily:n}=t;!e[n]&&i[n]&&(e[n]=!0,r&&Object.values(r).forEach((t=>{Object.values(t).forEach((t=>{let{fontFamily:s=""}=t;!e[s]&&i[s]&&(e[s]=!0)}))})))}));const s=Object.keys(e).map((t=>"\t\t@font-face {\n\t\t\tfont-family: '".concat(t,"';\n\t\t\tsrc: url('").concat(i[t],"');\n\t\t}\n"))).join("");return s?'\t<style type="text/css"><![CDATA[\n'.concat(s,"]]></style>\n"):""}_setSVGObjects(t,e){this.forEachObject((i=>{i.excludeFromExport||this._setSVGObject(t,i,e)}))}_setSVGObject(t,e,i){t.push(e.toSVG(i))}_setSVGBgOverlayImage(t,e,i){const s=this[e];s&&!s.excludeFromExport&&s.toSVG&&t.push(s.toSVG(i))}_setSVGBgOverlayColor(t,e){const i=this["".concat(e,"Color")];if(i)if(pi(i)){const s=i.repeat||"",r=this.width,n=this.height,o=this["".concat(e,"Vpt")]?di(Be(this.viewportTransform)):"";t.push('<rect transform="'.concat(o," translate(").concat(r/2,",").concat(n/2,')" x="').concat(i.offsetX-r/2,'" y="').concat(i.offsetY-n/2,'" width="').concat("repeat-y"!==s&&"no-repeat"!==s||!fi(i)?r:i.source.width,'" height="').concat("repeat-x"!==s&&"no-repeat"!==s||!fi(i)?n:i.source.height,'" fill="url(#SVGID_').concat(i.id,')"></rect>\n'))}else t.push('<rect x="0" y="0" width="100%" height="100%" ','fill="',i,'"',"></rect>\n")}loadFromJSON(t,e){let{signal:i}=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if(!t)return Promise.reject(new Et("`json` is undefined"));const s="string"==typeof t?JSON.parse(t):t,{objects:r=[],backgroundImage:n,background:o,overlayImage:a,overlay:l,clipPath:c}=s,h=this.renderOnAddRemove;return this.renderOnAddRemove=!1,Promise.all([Ze(r,{reviver:e,signal:i}),Qe({backgroundImage:n,backgroundColor:o,overlayImage:a,overlayColor:l,clipPath:c},{signal:i})]).then((t=>{let[e,i]=t;return this.clear(),this.add(...e),this.set(s),this.set(i),this.renderOnAddRemove=h,this}))}clone(t){const e=this.toObject(t);return this.cloneWithoutData().loadFromJSON(e)}cloneWithoutData(){const t=je(this);return new this.constructor(t)}toDataURL(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const{format:e="png",quality:i=1,multiplier:s=1,enableRetinaScaling:r=!1}=t,n=s*(r?this.getRetinaScaling():1);return Le(this.toCanvasElement(n,t),e,i)}toCanvasElement(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1,{width:e,height:i,left:s,top:r,filter:n}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const o=(e||this.width)*t,a=(i||this.height)*t,l=this.getZoom(),c=this.width,h=this.height,d=this.skipControlsDrawing,u=l*t,p=this.viewportTransform,g=[u,0,0,u,(p[4]-(s||0))*t,(p[5]-(r||0))*t],f=this.enableRetinaScaling,m=je({width:o,height:a}),v=n?this._objects.filter((t=>n(t))):this._objects;return this.enableRetinaScaling=!1,this.viewportTransform=g,this.width=o,this.height=a,this.skipControlsDrawing=!0,this.calcViewportBoundaries(),this.renderCanvas(m.getContext("2d"),v),this.viewportTransform=p,this.width=c,this.height=h,this.calcViewportBoundaries(),this.enableRetinaScaling=f,this.skipControlsDrawing=d,m}dispose(){return!this.disposed&&this.elements.cleanupDOM({width:this.width,height:this.height}),be.cancelByCanvas(this),this.disposed=!0,new Promise(((t,e)=>{const i=()=>{this.destroy(),t(!0)};i.kill=e,this.__cleanupTask&&this.__cleanupTask.kill("aborted"),this.destroyed?t(!1):this.nextRenderHandle?this.__cleanupTask=i:i()}))}destroy(){this.destroyed=!0,this.cancelRequestedRender(),this.forEachObject((t=>t.dispose())),this._objects=[],this.backgroundImage&&this.backgroundImage.dispose(),this.backgroundImage=void 0,this.overlayImage&&this.overlayImage.dispose(),this.overlayImage=void 0,this.elements.dispose()}toString(){return"#<Canvas (".concat(this.complexity(),"): { objects: ").concat(this._objects.length," }>")}}bt(Ti,"ownDefaults",Si);const Oi=["touchstart","touchmove","touchend"],Ei=t=>Oi.includes(t.type)||"touch"===t.pointerType,ki=t=>{t.preventDefault(),t.stopPropagation()},Di=t=>{let e=0,i=0,s=0,r=0;for(let n=0,o=t.length;n<o;n++){const{x:o,y:a}=t[n];(o>s||!n)&&(s=o),(o<e||!n)&&(e=o),(a>r||!n)&&(r=a),(a<i||!n)&&(i=a)}return{left:e,top:i,width:s-e,height:r-i}},Ai=["translateX","translateY","scaleX","scaleY"],Mi=(t,e)=>{const i=$e(e),{translateX:s,translateY:r,scaleX:n,scaleY:o}=i,a=wt(i,Ai),l=new Se(s,r);t.flipX=!1,t.flipY=!1,Object.assign(t,a),t.set({scaleX:n,scaleY:o}),t.setPositionByOrigin(l,Ut,Ut)},Pi=t=>({scaleX:t.scaleX,scaleY:t.scaleY,skewX:t.skewX,skewY:t.skewY,angle:t.angle,left:t.left,flipX:t.flipX,flipY:t.flipY,top:t.top}),ji=(t,e,i)=>{const s=t/2,r=e/2,n=[new Se(-s,-r),new Se(s,-r),new Se(-s,r),new Se(s,r)].map((t=>t.transform(i))),o=Di(n);return new Se(o.width,o.height)},Li=function(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:Wt;return Ne(Be(arguments.length>1&&void 0!==arguments[1]?arguments[1]:Wt),t)},Fi=function(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Wt,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:Wt;return t.transform(Li(e,i))},Ii=(t,e)=>{var i;const{transform:{target:s}}=e;null===(i=s.canvas)||void 0===i||i.fire("object:".concat(t),xt(xt({},e),{},{target:s})),s.fire(t,e)},Ri={left:-.5,top:-.5,center:0,bottom:.5,right:.5},Bi=t=>"string"==typeof t?Ri[t]:t-.5,Ni="not-allowed";function zi(t){return Bi(t.originX)===Bi(Ut)&&Bi(t.originY)===Bi(Ut)}function Vi(t){return.5-Bi(t)}const $i=(t,e)=>t[e],Wi=(t,e,i,s)=>({e:t,transform:e,pointer:new Se(i,s)});function Hi(t,e){const i=t.getTotalAngle()+Ie(Math.atan2(e.y,e.x))+360;return Math.round(i%360/45)}function Xi(t,e,i,s,r){var n;let{target:o,corner:a}=t;const l=o.controls[a],c=(null===(n=o.canvas)||void 0===n?void 0:n.getZoom())||1,h=o.padding/c,d=function(t,e,i,s){const r=t.getRelativeCenterPoint(),n=void 0!==i&&void 0!==s?t.translateToGivenOrigin(r,Ut,Ut,i,s):new Se(t.left,t.top);return(t.angle?e.rotate(-Fe(t.angle),r):e).subtract(n)}(o,new Se(s,r),e,i);return d.x>=h&&(d.x-=h),d.x<=-h&&(d.x+=h),d.y>=h&&(d.y-=h),d.y<=h&&(d.y+=h),d.x-=l.offsetX,d.y-=l.offsetY,d}const Ui=(t,e,i,s)=>{const{target:r,offsetX:n,offsetY:o}=e,a=i-n,l=s-o,c=!$i(r,"lockMovementX")&&r.left!==a,h=!$i(r,"lockMovementY")&&r.top!==l;return c&&r.set(Yt,a),h&&r.set(Gt,l),(c||h)&&Ii(Qt,Wi(t,e,i,s)),c||h};class Yi{getSvgStyles(t){const e=this.fillRule?this.fillRule:"nonzero",i=this.strokeWidth?this.strokeWidth:"0",s=this.strokeDashArray?this.strokeDashArray.join(" "):Jt,r=this.strokeDashOffset?this.strokeDashOffset:"0",n=this.strokeLineCap?this.strokeLineCap:"butt",o=this.strokeLineJoin?this.strokeLineJoin:"miter",a=this.strokeMiterLimit?this.strokeMiterLimit:"4",l=void 0!==this.opacity?this.opacity:"1",c=this.visible?"":" visibility: hidden;",h=t?"":this.getSvgFilter(),d=ui(pe,this.fill);return[ui(ge,this.stroke),"stroke-width: ",i,"; ","stroke-dasharray: ",s,"; ","stroke-linecap: ",n,"; ","stroke-dashoffset: ",r,"; ","stroke-linejoin: ",o,"; ","stroke-miterlimit: ",a,"; ",d,"fill-rule: ",e,"; ","opacity: ",l,";",h,c].join("")}getSvgFilter(){return this.shadow?"filter: url(#SVGID_".concat(this.shadow.id,");"):""}getSvgCommons(){return[this.id?'id="'.concat(this.id,'" '):"",this.clipPath?'clip-path="url(#'.concat(this.clipPath.clipPathId,')" '):""].join("")}getSvgTransform(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";const i=t?this.calcTransformMatrix():this.calcOwnMatrix(),s='transform="'.concat(di(i));return"".concat(s).concat(e,'" ')}_toSVG(t){return[""]}toSVG(t){return this._createBaseSVGMarkup(this._toSVG(t),{reviver:t})}toClipPathSVG(t){return"\t"+this._createBaseClipPathSVGMarkup(this._toSVG(t),{reviver:t})}_createBaseClipPathSVGMarkup(t){let{reviver:e,additionalTransform:i=""}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const s=[this.getSvgTransform(!0,i),this.getSvgCommons()].join(""),r=t.indexOf("COMMON_PARTS");return t[r]=s,e?e(t.join("")):t.join("")}_createBaseSVGMarkup(t){let{noStyle:e,reviver:i,withShadow:s,additionalTransform:r}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const n=e?"":'style="'.concat(this.getSvgStyles(),'" '),o=s?'style="'.concat(this.getSvgFilter(),'" '):"",a=this.clipPath,l=this.strokeUniform?'vector-effect="non-scaling-stroke" ':"",c=a&&a.absolutePositioned,h=this.stroke,d=this.fill,u=this.shadow,p=[],g=t.indexOf("COMMON_PARTS");let f;a&&(a.clipPathId="CLIPPATH_".concat(Me()),f='<clipPath id="'.concat(a.clipPathId,'" >\n').concat(a.toClipPathSVG(i),"</clipPath>\n")),c&&p.push("<g ",o,this.getSvgCommons()," >\n"),p.push("<g ",this.getSvgTransform(!1),c?"":o+this.getSvgCommons()," >\n");const m=[n,l,e?"":this.addPaintOrder()," ",r?'transform="'.concat(r,'" '):""].join("");return t[g]=m,pi(d)&&p.push(d.toSVG(this)),pi(h)&&p.push(h.toSVG(this)),u&&p.push(u.toSVG(this)),a&&p.push(f),p.push(t.join("")),p.push("</g>\n"),c&&p.push("</g>\n"),i?i(p.join("")):p.join("")}addPaintOrder(){return this.paintFirst!==pe?' paint-order="'.concat(this.paintFirst,'" '):""}}function Gi(t){return new RegExp("^("+t.join("|")+")\\b","i")}var qi;const Ki=String.raw(qi||(qi=Ct(["(?:[-+]?(?:d*.d+|d+.?)(?:[eE][-+]?d+)?)"],["(?:[-+]?(?:\\d*\\.\\d+|\\d+\\.?)(?:[eE][-+]?\\d+)?)"]))),Ji=new RegExp("(normal|italic)?\\s*(normal|small-caps)?\\s*(normal|bold|bolder|lighter|100|200|300|400|500|600|700|800|900)?\\s*("+Ki+"(?:px|cm|mm|em|pt|pc|in)*)(?:\\/(normal|"+Ki+"))?\\s+(.*)"),Zi={cx:Yt,x:Yt,r:"radius",cy:Gt,y:Gt,display:"visible",visibility:"visible",transform:"transformMatrix","fill-opacity":"fillOpacity","fill-rule":"fillRule","font-family":"fontFamily","font-size":"fontSize","font-style":"fontStyle","font-weight":"fontWeight","letter-spacing":"charSpacing","paint-order":"paintFirst","stroke-dasharray":"strokeDashArray","stroke-dashoffset":"strokeDashOffset","stroke-linecap":"strokeLineCap","stroke-linejoin":"strokeLineJoin","stroke-miterlimit":"strokeMiterLimit","stroke-opacity":"strokeOpacity","stroke-width":"strokeWidth","text-decoration":"textDecoration","text-anchor":"textAnchor",opacity:"opacity","clip-path":"clipPath","clip-rule":"clipRule","vector-effect":"strokeUniform","image-rendering":"imageSmoothing"},Qi="font-size",ts="clip-path";Gi(["path","circle","polygon","polyline","ellipse","rect","line","image","text"]),Gi(["symbol","image","marker","pattern","view","svg"]);const es=Gi(["symbol","g","a","svg","clipPath","defs"]),is=new Se(1,0),ss=new Se,rs=(t,e)=>t.rotate(e),ns=(t,e)=>new Se(e).subtract(t),os=t=>t.distanceFrom(ss),as=(t,e)=>Math.atan2(hs(t,e),ds(t,e)),ls=t=>t.eq(ss)?t:t.scalarDivide(os(t)),cs=function(t){let e=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];return ls(new Se(-t.y,t.x).scalarMultiply(e?1:-1))},hs=(t,e)=>t.x*e.y-t.y*e.x,ds=(t,e)=>t.x*e.x+t.y*e.y,us=(t,e,i)=>{if(t.eq(e)||t.eq(i))return!0;const s=hs(e,i),r=hs(e,t),n=hs(i,t);return s>=0?r>=0&&n<=0:!(r<=0&&n>=0)},ps="(-?\\d+(?:\\.\\d*)?(?:px)?(?:\\s?|$))?",gs=new RegExp("(?:\\s|^)"+ps+ps+"("+Ki+"?(?:px)?)?(?:\\s?|$)(?:$|\\s)");class fs{constructor(t){const e="string"==typeof t?fs.parseShadow(t):t;Object.assign(this,fs.ownDefaults,e),this.id=Me()}static parseShadow(t){const e=t.trim(),[,i=0,s=0,r=0]=(gs.exec(e)||[]).map((t=>parseFloat(t)||0));return{color:(e.replace(gs,"")||"rgb(0,0,0)").trim(),offsetX:i,offsetY:s,blur:r}}toString(){return[this.offsetX,this.offsetY,this.blur,this.color].join("px ")}toSVG(t){const e=rs(new Se(this.offsetX,this.offsetY),Fe(-t.angle)),i=new li(this.color);let s=40,r=40;return t.width&&t.height&&(s=100*ci((Math.abs(e.x)+this.blur)/t.width,Tt.NUM_FRACTION_DIGITS)+20,r=100*ci((Math.abs(e.y)+this.blur)/t.height,Tt.NUM_FRACTION_DIGITS)+20),t.flipX&&(e.x*=-1),t.flipY&&(e.y*=-1),'<filter id="SVGID_'.concat(this.id,'" y="-').concat(r,'%" height="').concat(100+2*r,'%" x="-').concat(s,'%" width="').concat(100+2*s,'%" >\n\t<feGaussianBlur in="SourceAlpha" stdDeviation="').concat(ci(this.blur?this.blur/2:0,Tt.NUM_FRACTION_DIGITS),'"></feGaussianBlur>\n\t<feOffset dx="').concat(ci(e.x,Tt.NUM_FRACTION_DIGITS),'" dy="').concat(ci(e.y,Tt.NUM_FRACTION_DIGITS),'" result="oBlur" ></feOffset>\n\t<feFlood flood-color="').concat(i.toRgb(),'" flood-opacity="').concat(i.getAlpha(),'"/>\n\t<feComposite in2="oBlur" operator="in" />\n\t<feMerge>\n\t\t<feMergeNode></feMergeNode>\n\t\t<feMergeNode in="SourceGraphic"></feMergeNode>\n\t</feMerge>\n</filter>\n')}toObject(){const t={color:this.color,blur:this.blur,offsetX:this.offsetX,offsetY:this.offsetY,affectStroke:this.affectStroke,nonScaling:this.nonScaling,type:this.constructor.type},e=fs.ownDefaults;return this.includeDefaultValues?t:ei(t,((t,i)=>t!==e[i]))}static async fromObject(t){return new this(t)}}bt(fs,"ownDefaults",{color:"rgb(0,0,0)",blur:0,offsetX:0,offsetY:0,affectStroke:!1,includeDefaultValues:!0,nonScaling:!1}),bt(fs,"type","shadow"),_e.setClass(fs,"shadow");const ms=(t,e,i)=>Math.max(t,Math.min(e,i)),vs=[Gt,Yt,ce,he,"flipX","flipY","originX","originY","angle","opacity","globalCompositeOperation","shadow","visible",de,ue],_s=[pe,ge,"strokeWidth","strokeDashArray","width","height","paintFirst","strokeUniform","strokeLineCap","strokeDashOffset","strokeLineJoin","strokeMiterLimit","backgroundColor","clipPath"],bs={top:0,left:0,width:0,height:0,angle:0,flipX:!1,flipY:!1,scaleX:1,scaleY:1,minScaleLimit:0,skewX:0,skewY:0,originX:Yt,originY:Gt,strokeWidth:1,strokeUniform:!1,padding:0,opacity:1,paintFirst:pe,fill:"rgb(0,0,0)",fillRule:"nonzero",stroke:null,strokeDashArray:null,strokeDashOffset:0,strokeLineCap:"butt",strokeLineJoin:"miter",strokeMiterLimit:4,globalCompositeOperation:"source-over",backgroundColor:"",shadow:null,visible:!0,includeDefaultValues:!0,excludeFromExport:!1,objectCaching:!0,clipPath:void 0,inverted:!1,absolutePositioned:!1,centeredRotation:!0,centeredScaling:!1,dirty:!0},ys=(t,e,i,s)=>-i*Math.cos(t/s*zt)+i+e,xs=()=>!1;class ws{constructor(t){let{startValue:e,byValue:i,duration:s=500,delay:r=0,easing:n=ys,onStart:o=Nt,onChange:a=Nt,onComplete:l=Nt,abort:c=xs,target:h}=t;bt(this,"_state","pending"),bt(this,"durationProgress",0),bt(this,"valueProgress",0),this.tick=this.tick.bind(this),this.duration=s,this.delay=r,this.easing=n,this._onStart=o,this._onChange=a,this._onComplete=l,this._abort=c,this.target=h,this.startValue=e,this.byValue=i,this.value=this.startValue,this.endValue=Object.freeze(this.calculate(this.duration).value)}get state(){return this._state}isDone(){return"aborted"===this._state||"completed"===this._state}start(){const t=t=>{"pending"===this._state&&(this.startTime=t||+new Date,this._state="running",this._onStart(),this.tick(this.startTime))};this.register(),this.delay>0?setTimeout((()=>De(t)),this.delay):De(t)}tick(t){const e=(t||+new Date)-this.startTime,i=Math.min(e,this.duration);this.durationProgress=i/this.duration;const{value:s,valueProgress:r}=this.calculate(i);this.value=Object.freeze(s),this.valueProgress=r,"aborted"!==this._state&&(this._abort(this.value,this.valueProgress,this.durationProgress)?(this._state="aborted",this.unregister()):e>=this.duration?(this.durationProgress=this.valueProgress=1,this._onChange(this.endValue,this.valueProgress,this.durationProgress),this._state="completed",this._onComplete(this.endValue,this.valueProgress,this.durationProgress),this.unregister()):(this._onChange(this.value,this.valueProgress,this.durationProgress),De(this.tick)))}register(){be.push(this)}unregister(){be.remove(this)}abort(){this._state="aborted",this.unregister()}}const Cs=["startValue","endValue"];class Ss extends ws{constructor(t){let{startValue:e=0,endValue:i=100}=t;super(xt(xt({},wt(t,Cs)),{},{startValue:e,byValue:i-e}))}calculate(t){const e=this.easing(t,this.startValue,this.byValue,this.duration);return{value:e,valueProgress:Math.abs((e-this.startValue)/this.byValue)}}}const Ts=["startValue","endValue"];class Os extends ws{constructor(t){let{startValue:e=[0],endValue:i=[100]}=t;super(xt(xt({},wt(t,Ts)),{},{startValue:e,byValue:i.map(((t,i)=>t-e[i]))}))}calculate(t){const e=this.startValue.map(((e,i)=>this.easing(t,e,this.byValue[i],this.duration,i)));return{value:e,valueProgress:Math.abs((e[0]-this.startValue[0])/this.byValue[0])}}}const Es=["startValue","endValue","easing","onChange","onComplete","abort"],ks=(t,e,i,s)=>e+i*(1-Math.cos(t/s*zt)),Ds=t=>t&&((e,i,s)=>t(new li(e).toRgba(),i,s));class As extends ws{constructor(t){let{startValue:e,endValue:i,easing:s=ks,onChange:r,onComplete:n,abort:o}=t,a=wt(t,Es);const l=new li(e).getSource(),c=new li(i).getSource();super(xt(xt({},a),{},{startValue:l,byValue:c.map(((t,e)=>t-l[e])),easing:s,onChange:Ds(r),onComplete:Ds(n),abort:Ds(o)}))}calculate(t){const[e,i,s,r]=this.startValue.map(((e,i)=>this.easing(t,e,this.byValue[i],this.duration,i))),n=[...[e,i,s].map(Math.round),ms(0,r,1)];return{value:n,valueProgress:n.map(((t,e)=>0!==this.byValue[e]?Math.abs((t-this.startValue[e])/this.byValue[e]):0)).find((t=>0!==t))||0}}}function Ms(t){const e=(i=t,Array.isArray(i.startValue)||Array.isArray(i.endValue)?new Os(t):new Ss(t));var i;return e.start(),e}class Ps{constructor(t){this.status=t,this.points=[]}includes(t){return this.points.some((e=>e.eq(t)))}append(){for(var t=arguments.length,e=new Array(t),i=0;i<t;i++)e[i]=arguments[i];return this.points=this.points.concat(e.filter((t=>!this.includes(t)))),this}static isPointContained(t,e,i){let s=arguments.length>3&&void 0!==arguments[3]&&arguments[3];if(e.eq(i))return t.eq(e);if(e.x===i.x)return t.x===e.x&&(s||t.y>=Math.min(e.y,i.y)&&t.y<=Math.max(e.y,i.y));if(e.y===i.y)return t.y===e.y&&(s||t.x>=Math.min(e.x,i.x)&&t.x<=Math.max(e.x,i.x));{const r=ns(e,i),n=ns(e,t).divide(r);return s?Math.abs(n.x)===Math.abs(n.y):n.x===n.y&&n.x>=0&&n.x<=1}}static isPointInPolygon(t,e){const i=new Se(t).setX(Math.min(t.x-1,...e.map((t=>t.x))));let s=0;for(let r=0;r<e.length;r++){const n=this.intersectSegmentSegment(e[r],e[(r+1)%e.length],t,i);if(n.includes(t))return!0;s+=Number("Intersection"===n.status)}return s%2==1}static intersectLineLine(t,e,i,s){let r=!(arguments.length>4&&void 0!==arguments[4])||arguments[4],n=!(arguments.length>5&&void 0!==arguments[5])||arguments[5];const o=e.x-t.x,a=e.y-t.y,l=s.x-i.x,c=s.y-i.y,h=t.x-i.x,d=t.y-i.y,u=l*d-c*h,p=o*d-a*h,g=c*o-l*a;if(0!==g){const e=u/g,i=p/g;return(r||0<=e&&e<=1)&&(n||0<=i&&i<=1)?new Ps("Intersection").append(new Se(t.x+e*o,t.y+e*a)):new Ps}if(0===u||0===p){const o=r||n||Ps.isPointContained(t,i,s)||Ps.isPointContained(e,i,s)||Ps.isPointContained(i,t,e)||Ps.isPointContained(s,t,e);return new Ps(o?"Coincident":void 0)}return new Ps("Parallel")}static intersectSegmentLine(t,e,i,s){return Ps.intersectLineLine(t,e,i,s,!1,!0)}static intersectSegmentSegment(t,e,i,s){return Ps.intersectLineLine(t,e,i,s,!1,!1)}static intersectLinePolygon(t,e,i){let s=!(arguments.length>3&&void 0!==arguments[3])||arguments[3];const r=new Ps,n=i.length;for(let o,a,l,c=0;c<n;c++){if(o=i[c],a=i[(c+1)%n],l=Ps.intersectLineLine(t,e,o,a,s,!1),"Coincident"===l.status)return l;r.append(...l.points)}return r.points.length>0&&(r.status="Intersection"),r}static intersectSegmentPolygon(t,e,i){return Ps.intersectLinePolygon(t,e,i,!1)}static intersectPolygonPolygon(t,e){const i=new Ps,s=t.length,r=[];for(let n=0;n<s;n++){const o=t[n],a=t[(n+1)%s],l=Ps.intersectSegmentPolygon(o,a,e);"Coincident"===l.status?(r.push(l),i.append(o,a)):i.append(...l.points)}return r.length>0&&r.length===t.length?new Ps("Coincident"):(i.points.length>0&&(i.status="Intersection"),i)}static intersectPolygonRectangle(t,e,i){const s=e.min(i),r=e.max(i),n=new Se(r.x,s.y),o=new Se(s.x,r.y);return Ps.intersectPolygonPolygon(t,[s,n,r,o])}}class js extends ke{getX(){return this.getXY().x}setX(t){this.setXY(this.getXY().setX(t))}getY(){return this.getXY().y}setY(t){this.setXY(this.getXY().setY(t))}getRelativeX(){return this.left}setRelativeX(t){this.left=t}getRelativeY(){return this.top}setRelativeY(t){this.top=t}getXY(){const t=this.getRelativeXY();return this.group?Re(t,this.group.calcTransformMatrix()):t}setXY(t,e,i){this.group&&(t=Re(t,Be(this.group.calcTransformMatrix()))),this.setRelativeXY(t,e,i)}getRelativeXY(){return new Se(this.left,this.top)}setRelativeXY(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.originX,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:this.originY;this.setPositionByOrigin(t,e,i)}isStrokeAccountedForInDimensions(){return!1}getCoords(){const{tl:t,tr:e,br:i,bl:s}=this.aCoords||(this.aCoords=this.calcACoords()),r=[t,e,i,s];if(this.group){const t=this.group.calcTransformMatrix();return r.map((e=>Re(e,t)))}return r}intersectsWithRect(t,e){return"Intersection"===Ps.intersectPolygonRectangle(this.getCoords(),t,e).status}intersectsWithObject(t){const e=Ps.intersectPolygonPolygon(this.getCoords(),t.getCoords());return"Intersection"===e.status||"Coincident"===e.status||t.isContainedWithinObject(this)||this.isContainedWithinObject(t)}isContainedWithinObject(t){return this.getCoords().every((e=>t.containsPoint(e)))}isContainedWithinRect(t,e){const{left:i,top:s,width:r,height:n}=this.getBoundingRect();return i>=t.x&&i+r<=e.x&&s>=t.y&&s+n<=e.y}isOverlapping(t){return this.intersectsWithObject(t)||this.isContainedWithinObject(t)||t.isContainedWithinObject(this)}containsPoint(t){return Ps.isPointInPolygon(t,this.getCoords())}isOnScreen(){if(!this.canvas)return!1;const{tl:t,br:e}=this.canvas.vptCoords;return!!this.getCoords().some((i=>i.x<=e.x&&i.x>=t.x&&i.y<=e.y&&i.y>=t.y))||!!this.intersectsWithRect(t,e)||this.containsPoint(t.midPointFrom(e))}isPartiallyOnScreen(){if(!this.canvas)return!1;const{tl:t,br:e}=this.canvas.vptCoords;return!!this.intersectsWithRect(t,e)||this.getCoords().every((i=>(i.x>=e.x||i.x<=t.x)&&(i.y>=e.y||i.y<=t.y)))&&this.containsPoint(t.midPointFrom(e))}getBoundingRect(){return Di(this.getCoords())}getScaledWidth(){return this._getTransformedDimensions().x}getScaledHeight(){return this._getTransformedDimensions().y}scale(t){this._set(ce,t),this._set(he,t),this.setCoords()}scaleToWidth(t){const e=this.getBoundingRect().width/this.getScaledWidth();return this.scale(t/this.width/e)}scaleToHeight(t){const e=this.getBoundingRect().height/this.getScaledHeight();return this.scale(t/this.height/e)}getCanvasRetinaScaling(){var t;return(null===(t=this.canvas)||void 0===t?void 0:t.getRetinaScaling())||1}getTotalAngle(){return this.group?Ie(Ve(this.calcTransformMatrix())):this.angle}getViewportTransform(){var t;return(null===(t=this.canvas)||void 0===t?void 0:t.viewportTransform)||Wt.concat()}calcACoords(){const t=He({angle:this.angle}),{x:e,y:i}=this.getRelativeCenterPoint(),s=We(e,i),r=Ne(s,t),n=this._getTransformedDimensions(),o=n.x/2,a=n.y/2;return{tl:Re({x:-o,y:-a},r),tr:Re({x:o,y:-a},r),bl:Re({x:-o,y:a},r),br:Re({x:o,y:a},r)}}setCoords(){this.aCoords=this.calcACoords()}transformMatrixKey(){let t=arguments.length>0&&void 0!==arguments[0]&&arguments[0],e=[];return!t&&this.group&&(e=this.group.transformMatrixKey(t)),e.push(this.top,this.left,this.width,this.height,this.scaleX,this.scaleY,this.angle,this.strokeWidth,this.skewX,this.skewY,+this.flipX,+this.flipY,Bi(this.originX),Bi(this.originY)),e}calcTransformMatrix(){let t=arguments.length>0&&void 0!==arguments[0]&&arguments[0],e=this.calcOwnMatrix();if(t||!this.group)return e;const i=this.transformMatrixKey(t),s=this.matrixCache;return s&&s.key.every(((t,e)=>t===i[e]))?s.value:(this.group&&(e=Ne(this.group.calcTransformMatrix(!1),e)),this.matrixCache={key:i,value:e},e)}calcOwnMatrix(){const t=this.transformMatrixKey(!0),e=this.ownMatrixCache;if(e&&e.key===t)return e.value;const i=this.getRelativeCenterPoint(),s={angle:this.angle,translateX:i.x,translateY:i.y,scaleX:this.scaleX,scaleY:this.scaleY,skewX:this.skewX,skewY:this.skewY,flipX:this.flipX,flipY:this.flipY},r=Ke(s);return this.ownMatrixCache={key:t,value:r},r}_getNonTransformedDimensions(){return new Se(this.width,this.height).scalarAdd(this.strokeWidth)}_calculateCurrentDimensions(t){return this._getTransformedDimensions(t).transform(this.getViewportTransform(),!0).scalarAdd(2*this.padding)}_getTransformedDimensions(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const e=xt({scaleX:this.scaleX,scaleY:this.scaleY,skewX:this.skewX,skewY:this.skewY,width:this.width,height:this.height,strokeWidth:this.strokeWidth},t),i=e.strokeWidth;let s=i,r=0;this.strokeUniform&&(s=0,r=i);const n=e.width+s,o=e.height+s;let a;return a=0===e.skewX&&0===e.skewY?new Se(n*e.scaleX,o*e.scaleY):ji(n,o,qe(e)),a.scalarAdd(r)}translateToGivenOrigin(t,e,i,s,r){let n=t.x,o=t.y;const a=Bi(s)-Bi(e),l=Bi(r)-Bi(i);if(a||l){const t=this._getTransformedDimensions();n+=a*t.x,o+=l*t.y}return new Se(n,o)}translateToCenterPoint(t,e,i){if(e===Ut&&i===Ut)return t;const s=this.translateToGivenOrigin(t,e,i,Ut,Ut);return this.angle?s.rotate(Fe(this.angle),t):s}translateToOriginPoint(t,e,i){const s=this.translateToGivenOrigin(t,Ut,Ut,e,i);return this.angle?s.rotate(Fe(this.angle),t):s}getCenterPoint(){const t=this.getRelativeCenterPoint();return this.group?Re(t,this.group.calcTransformMatrix()):t}getRelativeCenterPoint(){return this.translateToCenterPoint(new Se(this.left,this.top),this.originX,this.originY)}getPointByOrigin(t,e){return this.translateToOriginPoint(this.getRelativeCenterPoint(),t,e)}setPositionByOrigin(t,e,i){const s=this.translateToCenterPoint(t,e,i),r=this.translateToOriginPoint(s,this.originX,this.originY);this.set({left:r.x,top:r.y})}_getLeftTopCoords(){return this.translateToOriginPoint(this.getRelativeCenterPoint(),Yt,Gt)}}const Ls=["type"],Fs=["extraParam"];let Is=class t extends js{static getDefaults(){return t.ownDefaults}get type(){const t=this.constructor.type;return"FabricObject"===t?"object":t.toLowerCase()}set type(t){Ot("warn","Setting type has no effect",t)}constructor(e){super(),bt(this,"_cacheContext",null),Object.assign(this,t.ownDefaults),this.setOptions(e)}_createCacheCanvas(){this._cacheCanvas=Pe(),this._cacheContext=this._cacheCanvas.getContext("2d"),this._updateCacheCanvas(),this.dirty=!0}_limitCacheSize(t){const e=t.width,i=t.height,s=Tt.maxCacheSideLimit,r=Tt.minCacheSideLimit;if(e<=s&&i<=s&&e*i<=Tt.perfLimitSizeTotal)return e<r&&(t.width=r),i<r&&(t.height=r),t;const n=e/i,[o,a]=Rt.limitDimsByArea(n),l=ms(r,o,s),c=ms(r,a,s);return e>l&&(t.zoomX/=e/l,t.width=l,t.capped=!0),i>c&&(t.zoomY/=i/c,t.height=c,t.capped=!0),t}_getCacheCanvasDimensions(){const t=this.getTotalObjectScaling(),e=this._getTransformedDimensions({skewX:0,skewY:0}),i=e.x*t.x/this.scaleX,s=e.y*t.y/this.scaleY;return{width:Math.ceil(i+2),height:Math.ceil(s+2),zoomX:t.x,zoomY:t.y,x:i,y:s}}_updateCacheCanvas(){const t=this._cacheCanvas,e=this._cacheContext,{width:i,height:s,zoomX:r,zoomY:n,x:o,y:a}=this._limitCacheSize(this._getCacheCanvasDimensions()),l=i!==t.width||s!==t.height,c=this.zoomX!==r||this.zoomY!==n;if(!t||!e)return!1;if(l||c){i!==t.width||s!==t.height?(t.width=i,t.height=s):(e.setTransform(1,0,0,1,0,0),e.clearRect(0,0,t.width,t.height));const l=o/2,c=a/2;return this.cacheTranslationX=Math.round(t.width/2-l)+l,this.cacheTranslationY=Math.round(t.height/2-c)+c,e.translate(this.cacheTranslationX,this.cacheTranslationY),e.scale(r,n),this.zoomX=r,this.zoomY=n,!0}return!1}setOptions(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this._setOptions(t)}transform(t){const e=this.group&&!this.group._transformDone||this.group&&this.canvas&&t===this.canvas.contextTop,i=this.calcTransformMatrix(!e);t.transform(i[0],i[1],i[2],i[3],i[4],i[5])}getObjectScaling(){if(!this.group)return new Se(Math.abs(this.scaleX),Math.abs(this.scaleY));const t=$e(this.calcTransformMatrix());return new Se(Math.abs(t.scaleX),Math.abs(t.scaleY))}getTotalObjectScaling(){const t=this.getObjectScaling();if(this.canvas){const e=this.canvas.getZoom(),i=this.getCanvasRetinaScaling();return t.scalarMultiply(e*i)}return t}getObjectOpacity(){let t=this.opacity;return this.group&&(t*=this.group.getObjectOpacity()),t}_constrainScale(t){return Math.abs(t)<this.minScaleLimit?t<0?-this.minScaleLimit:this.minScaleLimit:0===t?1e-4:t}_set(t,e){t!==ce&&t!==he||(e=this._constrainScale(e)),t===ce&&e<0?(this.flipX=!this.flipX,e*=-1):"scaleY"===t&&e<0?(this.flipY=!this.flipY,e*=-1):"shadow"!==t||!e||e instanceof fs||(e=new fs(e));const i=this[t]!==e;return this[t]=e,i&&this.constructor.cacheProperties.includes(t)&&(this.dirty=!0),this.parent&&(this.dirty||i&&this.constructor.stateProperties.includes(t))&&this.parent._set("dirty",!0),this}isNotVisible(){return 0===this.opacity||!this.width&&!this.height&&0===this.strokeWidth||!this.visible}render(t){this.isNotVisible()||this.canvas&&this.canvas.skipOffscreen&&!this.group&&!this.isOnScreen()||(t.save(),this._setupCompositeOperation(t),this.drawSelectionBackground(t),this.transform(t),this._setOpacity(t),this._setShadow(t),this.shouldCache()?(this.renderCache(),this.drawCacheOnCanvas(t)):(this._removeCacheCanvas(),this.drawObject(t,!1,{}),this.dirty=!1),t.restore())}drawSelectionBackground(t){}renderCache(t){if(t=t||{},this._cacheCanvas&&this._cacheContext||this._createCacheCanvas(),this.isCacheDirty()&&this._cacheContext){const{zoomX:e,zoomY:i,cacheTranslationX:s,cacheTranslationY:r}=this,{width:n,height:o}=this._cacheCanvas;this.drawObject(this._cacheContext,t.forClipping,{zoomX:e,zoomY:i,cacheTranslationX:s,cacheTranslationY:r,width:n,height:o,parentClipPaths:[]}),this.dirty=!1}}_removeCacheCanvas(){this._cacheCanvas=void 0,this._cacheContext=null}hasStroke(){return this.stroke&&"transparent"!==this.stroke&&0!==this.strokeWidth}hasFill(){return this.fill&&"transparent"!==this.fill}needsItsOwnCache(){return!!(this.paintFirst===ge&&this.hasFill()&&this.hasStroke()&&this.shadow)||!!this.clipPath}shouldCache(){return this.ownCaching=this.objectCaching&&(!this.parent||!this.parent.isOnACache())||this.needsItsOwnCache(),this.ownCaching}willDrawShadow(){return!!this.shadow&&(0!==this.shadow.offsetX||0!==this.shadow.offsetY)}drawClipPathOnCache(t,e,i){t.save(),e.inverted?t.globalCompositeOperation="destination-out":t.globalCompositeOperation="destination-in",t.setTransform(1,0,0,1,0,0),t.drawImage(i,0,0),t.restore()}drawObject(t,e,i){const s=this.fill,r=this.stroke;e?(this.fill="black",this.stroke="",this._setClippingProperties(t)):this._renderBackground(t),this._render(t),this._drawClipPath(t,this.clipPath,i),this.fill=s,this.stroke=r}createClipPathLayer(t,e){const i=je(e),s=i.getContext("2d");if(s.translate(e.cacheTranslationX,e.cacheTranslationY),s.scale(e.zoomX,e.zoomY),t._cacheCanvas=i,e.parentClipPaths.forEach((t=>{t.transform(s)})),e.parentClipPaths.push(t),t.absolutePositioned){const t=Be(this.calcTransformMatrix());s.transform(t[0],t[1],t[2],t[3],t[4],t[5])}return t.transform(s),t.drawObject(s,!0,e),i}_drawClipPath(t,e,i){if(!e)return;e._transformDone=!0;const s=this.createClipPathLayer(e,i);this.drawClipPathOnCache(t,e,s)}drawCacheOnCanvas(t){t.scale(1/this.zoomX,1/this.zoomY),t.drawImage(this._cacheCanvas,-this.cacheTranslationX,-this.cacheTranslationY)}isCacheDirty(){let t=arguments.length>0&&void 0!==arguments[0]&&arguments[0];if(this.isNotVisible())return!1;const e=this._cacheCanvas,i=this._cacheContext;return!(!e||!i||t||!this._updateCacheCanvas())||!!(this.dirty||this.clipPath&&this.clipPath.absolutePositioned)&&(e&&i&&!t&&(i.save(),i.setTransform(1,0,0,1,0,0),i.clearRect(0,0,e.width,e.height),i.restore()),!0)}_renderBackground(t){if(!this.backgroundColor)return;const e=this._getNonTransformedDimensions();t.fillStyle=this.backgroundColor,t.fillRect(-e.x/2,-e.y/2,e.x,e.y),this._removeShadow(t)}_setOpacity(t){this.group&&!this.group._transformDone?t.globalAlpha=this.getObjectOpacity():t.globalAlpha*=this.opacity}_setStrokeStyles(t,e){const i=e.stroke;i&&(t.lineWidth=e.strokeWidth,t.lineCap=e.strokeLineCap,t.lineDashOffset=e.strokeDashOffset,t.lineJoin=e.strokeLineJoin,t.miterLimit=e.strokeMiterLimit,pi(i)?"percentage"===i.gradientUnits||i.gradientTransform||i.patternTransform?this._applyPatternForTransformedGradient(t,i):(t.strokeStyle=i.toLive(t),this._applyPatternGradientTransform(t,i)):t.strokeStyle=e.stroke)}_setFillStyles(t,e){let{fill:i}=e;i&&(pi(i)?(t.fillStyle=i.toLive(t),this._applyPatternGradientTransform(t,i)):t.fillStyle=i)}_setClippingProperties(t){t.globalAlpha=1,t.strokeStyle="transparent",t.fillStyle="#000000"}_setLineDash(t,e){e&&0!==e.length&&t.setLineDash(e)}_setShadow(t){if(!this.shadow)return;const e=this.shadow,i=this.canvas,s=this.getCanvasRetinaScaling(),[r,,,n]=(null==i?void 0:i.viewportTransform)||Wt,o=r*s,a=n*s,l=e.nonScaling?new Se(1,1):this.getObjectScaling();t.shadowColor=e.color,t.shadowBlur=e.blur*Tt.browserShadowBlurConstant*(o+a)*(l.x+l.y)/4,t.shadowOffsetX=e.offsetX*o*l.x,t.shadowOffsetY=e.offsetY*a*l.y}_removeShadow(t){this.shadow&&(t.shadowColor="",t.shadowBlur=t.shadowOffsetX=t.shadowOffsetY=0)}_applyPatternGradientTransform(t,e){if(!pi(e))return{offsetX:0,offsetY:0};const i=e.gradientTransform||e.patternTransform,s=-this.width/2+e.offsetX||0,r=-this.height/2+e.offsetY||0;return"percentage"===e.gradientUnits?t.transform(this.width,0,0,this.height,s,r):t.transform(1,0,0,1,s,r),i&&t.transform(i[0],i[1],i[2],i[3],i[4],i[5]),{offsetX:s,offsetY:r}}_renderPaintInOrder(t){this.paintFirst===ge?(this._renderStroke(t),this._renderFill(t)):(this._renderFill(t),this._renderStroke(t))}_render(t){}_renderFill(t){this.fill&&(t.save(),this._setFillStyles(t,this),"evenodd"===this.fillRule?t.fill("evenodd"):t.fill(),t.restore())}_renderStroke(t){if(this.stroke&&0!==this.strokeWidth){if(this.shadow&&!this.shadow.affectStroke&&this._removeShadow(t),t.save(),this.strokeUniform){const e=this.getObjectScaling();t.scale(1/e.x,1/e.y)}this._setLineDash(t,this.strokeDashArray),this._setStrokeStyles(t,this),t.stroke(),t.restore()}}_applyPatternForTransformedGradient(t,e){var i;const s=this._limitCacheSize(this._getCacheCanvasDimensions()),r=this.getCanvasRetinaScaling(),n=s.x/this.scaleX/r,o=s.y/this.scaleY/r,a=je({width:Math.ceil(n),height:Math.ceil(o)}),l=a.getContext("2d");l&&(l.beginPath(),l.moveTo(0,0),l.lineTo(n,0),l.lineTo(n,o),l.lineTo(0,o),l.closePath(),l.translate(n/2,o/2),l.scale(s.zoomX/this.scaleX/r,s.zoomY/this.scaleY/r),this._applyPatternGradientTransform(l,e),l.fillStyle=e.toLive(t),l.fill(),t.translate(-this.width/2-this.strokeWidth/2,-this.height/2-this.strokeWidth/2),t.scale(r*this.scaleX/s.zoomX,r*this.scaleY/s.zoomY),t.strokeStyle=null!==(i=l.createPattern(a,"no-repeat"))&&void 0!==i?i:"")}_findCenterFromElement(){return new Se(this.left+this.width/2,this.top+this.height/2)}clone(t){const e=this.toObject(t);return this.constructor.fromObject(e)}cloneAsImage(t){const e=this.toCanvasElement(t);return new(_e.getClass("image"))(e)}toCanvasElement(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const e=Pi(this),i=this.group,s=this.shadow,r=Math.abs,n=t.enableRetinaScaling?It():1,o=(t.multiplier||1)*n,a=t.canvasProvider||(t=>new Ti(t,{enableRetinaScaling:!1,renderOnAddRemove:!1,skipOffscreen:!1}));delete this.group,t.withoutTransform&&(t=>{t.scaleX=1,t.scaleY=1,t.skewX=0,t.skewY=0,t.flipX=!1,t.flipY=!1,t.rotate(0)})(this),t.withoutShadow&&(this.shadow=null),t.viewportTransform&&((t,e,i)=>{const s=Li(e,i);Mi(t,Ne(s,t.calcOwnMatrix()))})(this,this.getViewportTransform()),this.setCoords();const l=Pe(),c=this.getBoundingRect(),h=this.shadow,d=new Se;if(h){const t=h.blur,e=h.nonScaling?new Se(1,1):this.getObjectScaling();d.x=2*Math.round(r(h.offsetX)+t)*r(e.x),d.y=2*Math.round(r(h.offsetY)+t)*r(e.y)}const u=c.width+d.x,p=c.height+d.y;l.width=Math.ceil(u),l.height=Math.ceil(p);const g=a(l);"jpeg"===t.format&&(g.backgroundColor="#fff"),this.setPositionByOrigin(new Se(g.width/2,g.height/2),Ut,Ut);const f=this.canvas;g._objects=[this],this.set("canvas",g),this.setCoords();const m=g.toCanvasElement(o||1,t);return this.set("canvas",f),this.shadow=s,i&&(this.group=i),this.set(e),this.setCoords(),g._objects=[],g.destroy(),m}toDataURL(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return Le(this.toCanvasElement(t),t.format||"png",t.quality||1)}isType(){for(var t=arguments.length,e=new Array(t),i=0;i<t;i++)e[i]=arguments[i];return e.includes(this.constructor.type)||e.includes(this.type)}complexity(){return 1}toJSON(){return this.toObject()}rotate(t){const{centeredRotation:e,originX:i,originY:s}=this;if(e){const{x:t,y:e}=this.getRelativeCenterPoint();this.originX=Ut,this.originY=Ut,this.left=t,this.top=e}if(this.set("angle",t),e){const{x:t,y:e}=this.translateToOriginPoint(this.getRelativeCenterPoint(),i,s);this.left=t,this.top=e,this.originX=i,this.originY=s}}setOnGroup(){}_setupCompositeOperation(t){this.globalCompositeOperation&&(t.globalCompositeOperation=this.globalCompositeOperation)}dispose(){be.cancelByTarget(this),this.off(),this._set("canvas",void 0),this._cacheCanvas&&jt().dispose(this._cacheCanvas),this._cacheCanvas=void 0,this._cacheContext=null}animate(t,e){return Object.entries(t).reduce(((t,i)=>{let[s,r]=i;return t[s]=this._animate(s,r,e),t}),{})}_animate(t,e){let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};const s=t.split("."),r=this.constructor.colorProperties.includes(s[s.length-1]),{abort:n,startValue:o,onChange:a,onComplete:l}=i,c=xt(xt({},i),{},{target:this,startValue:null!=o?o:s.reduce(((t,e)=>t[e]),this),endValue:e,abort:null==n?void 0:n.bind(this),onChange:(t,e,i)=>{s.reduce(((e,i,r)=>(r===s.length-1&&(e[i]=t),e[i])),this),a&&a(t,e,i)},onComplete:(t,e,i)=>{this.setCoords(),l&&l(t,e,i)}});return r?function(t){const e=new As(t);return e.start(),e}(c):Ms(c)}isDescendantOf(t){const{parent:e,group:i}=this;return e===t||i===t||!!e&&e.isDescendantOf(t)||!!i&&i!==e&&i.isDescendantOf(t)}getAncestors(){const t=[];let e=this;do{e=e.parent,e&&t.push(e)}while(e);return t}findCommonAncestors(t){if(this===t)return{fork:[],otherFork:[],common:[this,...this.getAncestors()]};const e=this.getAncestors(),i=t.getAncestors();if(0===e.length&&i.length>0&&this===i[i.length-1])return{fork:[],otherFork:[t,...i.slice(0,i.length-1)],common:[this]};for(let s,r=0;r<e.length;r++){if(s=e[r],s===t)return{fork:[this,...e.slice(0,r)],otherFork:[],common:e.slice(r)};for(let n=0;n<i.length;n++){if(this===i[n])return{fork:[],otherFork:[t,...i.slice(0,n)],common:[this,...e]};if(s===i[n])return{fork:[this,...e.slice(0,r)],otherFork:[t,...i.slice(0,n)],common:e.slice(r)}}}return{fork:[this,...e],otherFork:[t,...i],common:[]}}hasCommonAncestors(t){const e=this.findCommonAncestors(t);return e&&!!e.common.length}isInFrontOf(t){if(this===t)return;const e=this.findCommonAncestors(t);if(e.fork.includes(t))return!0;if(e.otherFork.includes(this))return!1;const i=e.common[0]||this.canvas;if(!i)return;const s=e.fork.pop(),r=e.otherFork.pop(),n=i._objects.indexOf(s),o=i._objects.indexOf(r);return n>-1&&n>o}toObject(){const e=(arguments.length>0&&void 0!==arguments[0]?arguments[0]:[]).concat(t.customProperties,this.constructor.customProperties||[]);let i;const s=Tt.NUM_FRACTION_DIGITS,{clipPath:r,fill:n,stroke:o,shadow:a,strokeDashArray:l,left:c,top:h,originX:d,originY:u,width:p,height:g,strokeWidth:f,strokeLineCap:m,strokeDashOffset:v,strokeLineJoin:_,strokeUniform:b,strokeMiterLimit:y,scaleX:x,scaleY:w,angle:C,flipX:S,flipY:T,opacity:O,visible:E,backgroundColor:k,fillRule:D,paintFirst:A,globalCompositeOperation:M,skewX:P,skewY:j}=this;r&&!r.excludeFromExport&&(i=r.toObject(e.concat("inverted","absolutePositioned")));const L=t=>ci(t,s),F=xt(xt({},ti(this,e)),{},{type:this.constructor.type,version:Bt,originX:d,originY:u,left:L(c),top:L(h),width:L(p),height:L(g),fill:gi(n)?n.toObject():n,stroke:gi(o)?o.toObject():o,strokeWidth:L(f),strokeDashArray:l?l.concat():l,strokeLineCap:m,strokeDashOffset:v,strokeLineJoin:_,strokeUniform:b,strokeMiterLimit:L(y),scaleX:L(x),scaleY:L(w),angle:L(C),flipX:S,flipY:T,opacity:L(O),shadow:a?a.toObject():a,visible:E,backgroundColor:k,fillRule:D,paintFirst:A,globalCompositeOperation:M,skewX:L(P),skewY:L(j)},i?{clipPath:i}:null);return this.includeDefaultValues?F:this._removeDefaultValues(F)}toDatalessObject(t){return this.toObject(t)}_removeDefaultValues(t){const e=this.constructor.getDefaults(),i=Object.keys(e).length>0?e:Object.getPrototypeOf(this);return ei(t,((t,e)=>{if(e===Yt||e===Gt||"type"===e)return!0;const s=i[e];return t!==s&&!(Array.isArray(t)&&Array.isArray(s)&&0===t.length&&0===s.length)}))}toString(){return"#<".concat(this.constructor.type,">")}static _fromObject(t){let e=wt(t,Ls),i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},{extraParam:s}=i,r=wt(i,Fs);return Qe(e,r).then((t=>s?(delete t[s],new this(e[s],t)):new this(t)))}static fromObject(t,e){return this._fromObject(t,e)}};bt(Is,"stateProperties",vs),bt(Is,"cacheProperties",_s),bt(Is,"ownDefaults",bs),bt(Is,"type","FabricObject"),bt(Is,"colorProperties",[pe,ge,"backgroundColor"]),bt(Is,"customProperties",[]),_e.setClass(Is),_e.setClass(Is,"object");const Rs=(t,e,i)=>(s,r,n,o)=>{const a=e(s,r,n,o);return a&&Ii(t,xt(xt({},Wi(s,r,n,o)),i)),a};function Bs(t){return(e,i,s,r)=>{const{target:n,originX:o,originY:a}=i,l=n.getRelativeCenterPoint(),c=n.translateToOriginPoint(l,o,a),h=t(e,i,s,r);return n.setPositionByOrigin(c,i.originX,i.originY),h}}const Ns=Rs(re,Bs(((t,e,i,s)=>{const r=Xi(e,e.originX,e.originY,i,s);if(Bi(e.originX)===Bi(Ut)||Bi(e.originX)===Bi(Kt)&&r.x<0||Bi(e.originX)===Bi(Yt)&&r.x>0){const{target:t}=e,i=t.strokeWidth/(t.strokeUniform?t.scaleX:1),s=zi(e)?2:1,n=t.width,o=Math.abs(r.x*s/t.scaleX)-i;return t.set("width",Math.max(o,1)),n!==t.width}return!1})));function zs(t,e,i,s,r){s=s||{};const n=this.sizeX||s.cornerSize||r.cornerSize,o=this.sizeY||s.cornerSize||r.cornerSize,a=void 0!==s.transparentCorners?s.transparentCorners:r.transparentCorners,l=a?ge:pe,c=!a&&(s.cornerStrokeColor||r.cornerStrokeColor);let h,d=e,u=i;t.save(),t.fillStyle=s.cornerColor||r.cornerColor||"",t.strokeStyle=s.cornerStrokeColor||r.cornerStrokeColor||"",n>o?(h=n,t.scale(1,o/n),u=i*n/o):o>n?(h=o,t.scale(n/o,1),d=e*o/n):h=n,t.beginPath(),t.arc(d,u,h/2,0,Vt,!1),t[l](),c&&t.stroke(),t.restore()}function Vs(t,e,i,s,r){s=s||{};const n=this.sizeX||s.cornerSize||r.cornerSize,o=this.sizeY||s.cornerSize||r.cornerSize,a=void 0!==s.transparentCorners?s.transparentCorners:r.transparentCorners,l=a?ge:pe,c=!a&&(s.cornerStrokeColor||r.cornerStrokeColor),h=n/2,d=o/2;t.save(),t.fillStyle=s.cornerColor||r.cornerColor||"",t.strokeStyle=s.cornerStrokeColor||r.cornerStrokeColor||"",t.translate(e,i);const u=r.getTotalAngle();t.rotate(Fe(u)),t["".concat(l,"Rect")](-h,-d,n,o),c&&t.strokeRect(-h,-d,n,o),t.restore()}class $s{constructor(t){bt(this,"visible",!0),bt(this,"actionName",le),bt(this,"angle",0),bt(this,"x",0),bt(this,"y",0),bt(this,"offsetX",0),bt(this,"offsetY",0),bt(this,"sizeX",0),bt(this,"sizeY",0),bt(this,"touchSizeX",0),bt(this,"touchSizeY",0),bt(this,"cursorStyle","crosshair"),bt(this,"withConnection",!1),Object.assign(this,t)}shouldActivate(t,e,i,s){var r;let{tl:n,tr:o,br:a,bl:l}=s;return(null===(r=e.canvas)||void 0===r?void 0:r.getActiveObject())===e&&e.isControlVisible(t)&&Ps.isPointInPolygon(i,[n,o,a,l])}getActionHandler(t,e,i){return this.actionHandler}getMouseDownHandler(t,e,i){return this.mouseDownHandler}getMouseUpHandler(t,e,i){return this.mouseUpHandler}cursorStyleHandler(t,e,i){return e.cursorStyle}getActionName(t,e,i){return e.actionName}getVisibility(t,e){var i,s;return null!==(i=null===(s=t._controlsVisibility)||void 0===s?void 0:s[e])&&void 0!==i?i:this.visible}setVisibility(t,e,i){this.visible=t}positionHandler(t,e,i,s){return new Se(this.x*t.x+this.offsetX,this.y*t.y+this.offsetY).transform(e)}calcCornerCoords(t,e,i,s,r,n){const o=ze([We(i,s),He({angle:t}),Xe((r?this.touchSizeX:this.sizeX)||e,(r?this.touchSizeY:this.sizeY)||e)]);return{tl:new Se(-.5,-.5).transform(o),tr:new Se(.5,-.5).transform(o),br:new Se(.5,.5).transform(o),bl:new Se(-.5,.5).transform(o)}}render(t,e,i,s,r){"circle"===((s=s||{}).cornerStyle||r.cornerStyle)?zs.call(this,t,e,i,s,r):Vs.call(this,t,e,i,s,r)}}const Ws=(t,e,i)=>i.lockRotation?Ni:e.cursorStyle,Hs=Rs(ee,Bs(((t,e,i,s)=>{let{target:r,ex:n,ey:o,theta:a,originX:l,originY:c}=e;const h=r.translateToOriginPoint(r.getRelativeCenterPoint(),l,c);if($i(r,"lockRotation"))return!1;const d=Math.atan2(o-h.y,n-h.x),u=Math.atan2(s-h.y,i-h.x);let p=Ie(u-d+a);if(r.snapAngle&&r.snapAngle>0){const t=r.snapAngle,e=r.snapThreshold||t,i=Math.ceil(p/t)*t,s=Math.floor(p/t)*t;Math.abs(p-s)<e?p=s:Math.abs(p-i)<e&&(p=i)}p<0&&(p=360+p),p%=360;const g=r.angle!==p;return r.angle=p,g})));function Xs(t,e){const i=e.canvas,s=t[i.uniScaleKey];return i.uniformScaling&&!s||!i.uniformScaling&&s}function Us(t,e,i){const s=$i(t,"lockScalingX"),r=$i(t,"lockScalingY");if(s&&r)return!0;if(!e&&(s||r)&&i)return!0;if(s&&"x"===e)return!0;if(r&&"y"===e)return!0;const{width:n,height:o,strokeWidth:a}=t;return 0===n&&0===a&&"y"!==e||0===o&&0===a&&"x"!==e}const Ys=["e","se","s","sw","w","nw","n","ne","e"],Gs=(t,e,i)=>{const s=Xs(t,i);if(Us(i,0!==e.x&&0===e.y?"x":0===e.x&&0!==e.y?"y":"",s))return Ni;const r=Hi(i,e);return"".concat(Ys[r],"-resize")};function qs(t,e,i,s){let r=arguments.length>4&&void 0!==arguments[4]?arguments[4]:{};const n=e.target,o=r.by,a=Xs(t,n);let l,c,h,d,u,p;if(Us(n,o,a))return!1;if(e.gestureScale)c=e.scaleX*e.gestureScale,h=e.scaleY*e.gestureScale;else{if(l=Xi(e,e.originX,e.originY,i,s),u="y"!==o?Math.sign(l.x||e.signX||1):1,p="x"!==o?Math.sign(l.y||e.signY||1):1,e.signX||(e.signX=u),e.signY||(e.signY=p),$i(n,"lockScalingFlip")&&(e.signX!==u||e.signY!==p))return!1;if(d=n._getTransformedDimensions(),a&&!o){const t=Math.abs(l.x)+Math.abs(l.y),{original:i}=e,s=t/(Math.abs(d.x*i.scaleX/n.scaleX)+Math.abs(d.y*i.scaleY/n.scaleY));c=i.scaleX*s,h=i.scaleY*s}else c=Math.abs(l.x*n.scaleX/d.x),h=Math.abs(l.y*n.scaleY/d.y);zi(e)&&(c*=2,h*=2),e.signX!==u&&"y"!==o&&(e.originX=Vi(e.originX),c*=-1,e.signX=u),e.signY!==p&&"x"!==o&&(e.originY=Vi(e.originY),h*=-1,e.signY=p)}const g=n.scaleX,f=n.scaleY;return o?("x"===o&&n.set(ce,c),"y"===o&&n.set(he,h)):(!$i(n,"lockScalingX")&&n.set(ce,c),!$i(n,"lockScalingY")&&n.set(he,h)),g!==n.scaleX||f!==n.scaleY}const Ks=Rs(te,Bs(((t,e,i,s)=>qs(t,e,i,s)))),Js=Rs(te,Bs(((t,e,i,s)=>qs(t,e,i,s,{by:"x"})))),Zs=Rs(te,Bs(((t,e,i,s)=>qs(t,e,i,s,{by:"y"})))),Qs=["target","ex","ey","skewingSide"],tr={x:{counterAxis:"y",scale:ce,skew:de,lockSkewing:"lockSkewingX",origin:"originX",flip:"flipX"},y:{counterAxis:"x",scale:he,skew:ue,lockSkewing:"lockSkewingY",origin:"originY",flip:"flipY"}},er=["ns","nesw","ew","nwse"];function ir(t,e,i,s,r){const{target:n}=i,{counterAxis:o,origin:a,lockSkewing:l,skew:c,flip:h}=tr[t];if($i(n,l))return!1;const{origin:d,flip:u}=tr[o],p=Bi(i[d])*(n[u]?-1:1),g=-Math.sign(p)*(n[h]?-1:1),f=-(0===n[c]&&Xi(i,Ut,Ut,s,r)[t]>0||n[c]>0?1:-1)*g*.5+.5;return Rs(se,Bs(((e,i,s,r)=>function(t,e,i){let{target:s,ex:r,ey:n,skewingSide:o}=e,a=wt(e,Qs);const{skew:l}=tr[t],c=i.subtract(new Se(r,n)).divide(new Se(s.scaleX,s.scaleY))[t],h=s[l],d=a[l],u=Math.tan(Fe(d)),p="y"===t?s._getTransformedDimensions({scaleX:1,scaleY:1,skewX:0}).x:s._getTransformedDimensions({scaleX:1,scaleY:1}).y,g=2*c*o/Math.max(p,1)+u,f=Ie(Math.atan(g));s.set(l,f);const m=h!==s[l];if(m&&"y"===t){const{skewX:t,scaleX:e}=s,i=s._getTransformedDimensions({skewY:h}),r=s._getTransformedDimensions(),n=0!==t?i.x/r.x:1;1!==n&&s.set(ce,n*e)}return m}(t,i,new Se(s,r)))))(e,xt(xt({},i),{},{[a]:f,skewingSide:g}),s,r)}function sr(t,e){return t[e.canvas.altActionKey]}const rr=(t,e,i)=>{const s=sr(t,i);return 0===e.x?s?de:he:0===e.y?s?ue:ce:""},nr=(t,e,i)=>sr(t,i)?((t,e,i)=>{if(0!==e.x&&$i(i,"lockSkewingY"))return Ni;if(0!==e.y&&$i(i,"lockSkewingX"))return Ni;const s=Hi(i,e)%4;return"".concat(er[s],"-resize")})(0,e,i):Gs(t,e,i),or=(t,e,i,s)=>sr(t,e.target)?((t,e,i,s)=>ir("y",t,e,i,s))(t,e,i,s):Js(t,e,i,s),ar=(t,e,i,s)=>sr(t,e.target)?((t,e,i,s)=>ir("x",t,e,i,s))(t,e,i,s):Zs(t,e,i,s),lr=()=>({ml:new $s({x:-.5,y:0,cursorStyleHandler:nr,actionHandler:or,getActionName:rr}),mr:new $s({x:.5,y:0,cursorStyleHandler:nr,actionHandler:or,getActionName:rr}),mb:new $s({x:0,y:.5,cursorStyleHandler:nr,actionHandler:ar,getActionName:rr}),mt:new $s({x:0,y:-.5,cursorStyleHandler:nr,actionHandler:ar,getActionName:rr}),tl:new $s({x:-.5,y:-.5,cursorStyleHandler:Gs,actionHandler:Ks}),tr:new $s({x:.5,y:-.5,cursorStyleHandler:Gs,actionHandler:Ks}),bl:new $s({x:-.5,y:.5,cursorStyleHandler:Gs,actionHandler:Ks}),br:new $s({x:.5,y:.5,cursorStyleHandler:Gs,actionHandler:Ks}),mtr:new $s({x:0,y:-.5,actionHandler:Hs,cursorStyleHandler:Ws,offsetY:-40,withConnection:!0,actionName:ie})}),cr=()=>xt(xt({},lr()),{mr:new $s({x:.5,y:0,actionHandler:Ns,cursorStyleHandler:nr,actionName:re}),ml:new $s({x:-.5,y:0,actionHandler:Ns,cursorStyleHandler:nr,actionName:re})});class hr extends Is{static getDefaults(){return xt(xt({},super.getDefaults()),hr.ownDefaults)}constructor(t){super(),Object.assign(this,this.constructor.createControls(),hr.ownDefaults),this.setOptions(t)}static createControls(){return{controls:lr()}}_updateCacheCanvas(){const t=this.canvas;if(this.noScaleCache&&t&&t._currentTransform){const e=t._currentTransform,i=e.target,s=e.action;if(this===i&&s&&s.startsWith(le))return!1}return super._updateCacheCanvas()}getActiveControl(){const t=this.__corner;return t?{key:t,control:this.controls[t],coord:this.oCoords[t]}:void 0}findControl(t){let e=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if(!this.hasControls||!this.canvas)return;this.__corner=void 0;const i=Object.entries(this.oCoords);for(let s=i.length-1;s>=0;s--){const[r,n]=i[s],o=this.controls[r];if(o.shouldActivate(r,this,t,e?n.touchCorner:n.corner))return this.__corner=r,{key:r,control:o,coord:this.oCoords[r]}}}calcOCoords(){const t=this.getViewportTransform(),e=this.getCenterPoint(),i=We(e.x,e.y),s=He({angle:this.getTotalAngle()-(this.group&&this.flipX?180:0)}),r=Ne(i,s),n=Ne(t,r),o=Ne(n,[1/t[0],0,0,1/t[3],0,0]),a=this.group?$e(this.calcTransformMatrix()):void 0;a&&(a.scaleX=Math.abs(a.scaleX),a.scaleY=Math.abs(a.scaleY));const l=this._calculateCurrentDimensions(a),c={};return this.forEachControl(((t,e)=>{const i=t.positionHandler(l,o,this,t);c[e]=Object.assign(i,this._calcCornerCoords(t,i))})),c}_calcCornerCoords(t,e){const i=this.getTotalAngle();return{corner:t.calcCornerCoords(i,this.cornerSize,e.x,e.y,!1,this),touchCorner:t.calcCornerCoords(i,this.touchCornerSize,e.x,e.y,!0,this)}}setCoords(){super.setCoords(),this.canvas&&(this.oCoords=this.calcOCoords())}forEachControl(t){for(const e in this.controls)t(this.controls[e],e,this)}drawSelectionBackground(t){if(!this.selectionBackgroundColor||this.canvas&&this.canvas._activeObject!==this)return;t.save();const e=this.getRelativeCenterPoint(),i=this._calculateCurrentDimensions(),s=this.getViewportTransform();t.translate(e.x,e.y),t.scale(1/s[0],1/s[3]),t.rotate(Fe(this.angle)),t.fillStyle=this.selectionBackgroundColor,t.fillRect(-i.x/2,-i.y/2,i.x,i.y),t.restore()}strokeBorders(t,e){t.strokeRect(-e.x/2,-e.y/2,e.x,e.y)}_drawBorders(t,e){let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};const s=xt({hasControls:this.hasControls,borderColor:this.borderColor,borderDashArray:this.borderDashArray},i);t.save(),t.strokeStyle=s.borderColor,this._setLineDash(t,s.borderDashArray),this.strokeBorders(t,e),s.hasControls&&this.drawControlsConnectingLines(t,e),t.restore()}_renderControls(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const{hasBorders:i,hasControls:s}=this,r=xt({hasBorders:i,hasControls:s},e),n=this.getViewportTransform(),o=r.hasBorders,a=r.hasControls,l=Ne(n,this.calcTransformMatrix()),c=$e(l);t.save(),t.translate(c.translateX,c.translateY),t.lineWidth=this.borderScaleFactor,this.group===this.parent&&(t.globalAlpha=this.isMoving?this.borderOpacityWhenMoving:1),this.flipX&&(c.angle-=180),t.rotate(Fe(this.group?c.angle:this.angle)),o&&this.drawBorders(t,c,e),a&&this.drawControls(t,e),t.restore()}drawBorders(t,e,i){let s;if(i&&i.forActiveSelection||this.group){const t=ji(this.width,this.height,qe(e)),i=this.isStrokeAccountedForInDimensions()?Te:(this.strokeUniform?(new Se).scalarAdd(this.canvas?this.canvas.getZoom():1):new Se(e.scaleX,e.scaleY)).scalarMultiply(this.strokeWidth);s=t.add(i).scalarAdd(this.borderScaleFactor).scalarAdd(2*this.padding)}else s=this._calculateCurrentDimensions().scalarAdd(this.borderScaleFactor);this._drawBorders(t,s,i)}drawControlsConnectingLines(t,e){let i=!1;t.beginPath(),this.forEachControl(((s,r)=>{s.withConnection&&s.getVisibility(this,r)&&(i=!0,t.moveTo(s.x*e.x,s.y*e.y),t.lineTo(s.x*e.x+s.offsetX,s.y*e.y+s.offsetY))})),i&&t.stroke()}drawControls(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};t.save();const i=this.getCanvasRetinaScaling(),{cornerStrokeColor:s,cornerDashArray:r,cornerColor:n}=this,o=xt({cornerStrokeColor:s,cornerDashArray:r,cornerColor:n},e);t.setTransform(i,0,0,i,0,0),t.strokeStyle=t.fillStyle=o.cornerColor,this.transparentCorners||(t.strokeStyle=o.cornerStrokeColor),this._setLineDash(t,o.cornerDashArray),this.forEachControl(((e,i)=>{if(e.getVisibility(this,i)){const s=this.oCoords[i];e.render(t,s.x,s.y,o,this)}})),t.restore()}isControlVisible(t){return this.controls[t]&&this.controls[t].getVisibility(this,t)}setControlVisible(t,e){this._controlsVisibility||(this._controlsVisibility={}),this._controlsVisibility[t]=e}setControlsVisibility(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};Object.entries(t).forEach((t=>{let[e,i]=t;return this.setControlVisible(e,i)}))}clearContextTop(t){if(!this.canvas)return;const e=this.canvas.contextTop;if(!e)return;const i=this.canvas.viewportTransform;e.save(),e.transform(i[0],i[1],i[2],i[3],i[4],i[5]),this.transform(e);const s=this.width+4,r=this.height+4;return e.clearRect(-s/2,-r/2,s,r),t||e.restore(),e}onDeselect(t){return!1}onSelect(t){return!1}shouldStartDragging(t){return!1}onDragStart(t){return!1}canDrop(t){return!1}renderDragSourceEffect(t){}renderDropTargetEffect(t){}}function dr(t,e){return e.forEach((e=>{Object.getOwnPropertyNames(e.prototype).forEach((i=>{"constructor"!==i&&Object.defineProperty(t.prototype,i,Object.getOwnPropertyDescriptor(e.prototype,i)||Object.create(null))}))})),t}bt(hr,"ownDefaults",{noScaleCache:!0,lockMovementX:!1,lockMovementY:!1,lockRotation:!1,lockScalingX:!1,lockScalingY:!1,lockSkewingX:!1,lockSkewingY:!1,lockScalingFlip:!1,cornerSize:13,touchCornerSize:24,transparentCorners:!0,cornerColor:"rgb(178,204,255)",cornerStrokeColor:"",cornerStyle:"rect",cornerDashArray:null,hasControls:!0,borderColor:"rgb(178,204,255)",borderDashArray:null,borderOpacityWhenMoving:.4,borderScaleFactor:1,hasBorders:!0,selectionBackgroundColor:"",selectable:!0,evented:!0,perPixelTargetFind:!1,activeOn:"down",hoverCursor:null,moveCursor:null});class ur extends hr{}dr(ur,[Yi]),_e.setClass(ur),_e.setClass(ur,"object");class pr{constructor(t){this.options=t,this.strokeProjectionMagnitude=this.options.strokeWidth/2,this.scale=new Se(this.options.scaleX,this.options.scaleY),this.strokeUniformScalar=this.options.strokeUniform?new Se(1/this.options.scaleX,1/this.options.scaleY):new Se(1,1)}createSideVector(t,e){const i=ns(t,e);return this.options.strokeUniform?i.multiply(this.scale):i}projectOrthogonally(t,e,i){return this.applySkew(t.add(this.calcOrthogonalProjection(t,e,i)))}isSkewed(){return 0!==this.options.skewX||0!==this.options.skewY}applySkew(t){const e=new Se(t);return e.y+=e.x*Math.tan(Fe(this.options.skewY)),e.x+=e.y*Math.tan(Fe(this.options.skewX)),e}scaleUnitVector(t,e){return t.multiply(this.strokeUniformScalar).scalarMultiply(e)}}const gr=new Se;class fr extends pr{static getOrthogonalRotationFactor(t,e){const i=e?as(t,e):(t=>as(is,t))(t);return Math.abs(i)<zt?-1:1}constructor(t,e,i,s){super(s),bt(this,"AB",void 0),bt(this,"AC",void 0),bt(this,"alpha",void 0),bt(this,"bisector",void 0),this.A=new Se(t),this.B=new Se(e),this.C=new Se(i),this.AB=this.createSideVector(this.A,this.B),this.AC=this.createSideVector(this.A,this.C),this.alpha=as(this.AB,this.AC),this.bisector=ls(rs(this.AB.eq(gr)?this.AC:this.AB,this.alpha/2))}calcOrthogonalProjection(t,e){let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:this.strokeProjectionMagnitude;const s=this.createSideVector(t,e),r=cs(s),n=fr.getOrthogonalRotationFactor(r,this.bisector);return this.scaleUnitVector(r,i*n)}projectBevel(){const t=[];return(this.alpha%Vt==0?[this.B]:[this.B,this.C]).forEach((e=>{t.push(this.projectOrthogonally(this.A,e)),t.push(this.projectOrthogonally(this.A,e,-this.strokeProjectionMagnitude))})),t}projectMiter(){const t=[],e=Math.abs(this.alpha),i=1/Math.sin(e/2),s=this.scaleUnitVector(this.bisector,-this.strokeProjectionMagnitude*i),r=this.options.strokeUniform?os(this.scaleUnitVector(this.bisector,this.options.strokeMiterLimit)):this.options.strokeMiterLimit;return os(s)/this.strokeProjectionMagnitude<=r&&t.push(this.applySkew(this.A.add(s))),t.push(...this.projectBevel()),t}projectRoundNoSkew(t,e){const i=[],s=new Se(fr.getOrthogonalRotationFactor(this.bisector),fr.getOrthogonalRotationFactor(new Se(this.bisector.y,this.bisector.x)));return[new Se(1,0).scalarMultiply(this.strokeProjectionMagnitude).multiply(this.strokeUniformScalar).multiply(s),new Se(0,1).scalarMultiply(this.strokeProjectionMagnitude).multiply(this.strokeUniformScalar).multiply(s)].forEach((s=>{us(s,t,e)&&i.push(this.A.add(s))})),i}projectRoundWithSkew(t,e){const i=[],{skewX:s,skewY:r,scaleX:n,scaleY:o,strokeUniform:a}=this.options,l=new Se(Math.tan(Fe(s)),Math.tan(Fe(r))),c=this.strokeProjectionMagnitude,h=a?c/o/Math.sqrt(1/o**2+1/n**2*l.y**2):c/Math.sqrt(1+l.y**2),d=new Se(Math.sqrt(Math.max(c**2-h**2,0)),h),u=a?c/Math.sqrt(1+l.x**2*(1/o)**2/(1/n+1/n*l.x*l.y)**2):c/Math.sqrt(1+l.x**2/(1+l.x*l.y)**2),p=new Se(u,Math.sqrt(Math.max(c**2-u**2,0)));return[p,p.scalarMultiply(-1),d,d.scalarMultiply(-1)].map((t=>this.applySkew(a?t.multiply(this.strokeUniformScalar):t))).forEach((s=>{us(s,t,e)&&i.push(this.applySkew(this.A).add(s))})),i}projectRound(){const t=[];t.push(...this.projectBevel());const e=this.alpha%Vt==0,i=this.applySkew(this.A),s=t[e?0:2].subtract(i),r=t[e?1:0].subtract(i),n=e?this.applySkew(this.AB.scalarMultiply(-1)):this.applySkew(this.bisector.multiply(this.strokeUniformScalar).scalarMultiply(-1)),o=hs(s,n)>0,a=o?s:r,l=o?r:s;return this.isSkewed()?t.push(...this.projectRoundWithSkew(a,l)):t.push(...this.projectRoundNoSkew(a,l)),t}projectPoints(){switch(this.options.strokeLineJoin){case"miter":return this.projectMiter();case"round":return this.projectRound();default:return this.projectBevel()}}project(){return this.projectPoints().map((t=>({originPoint:this.A,projectedPoint:t,angle:this.alpha,bisector:this.bisector})))}}class mr extends pr{constructor(t,e,i){super(i),this.A=new Se(t),this.T=new Se(e)}calcOrthogonalProjection(t,e){let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:this.strokeProjectionMagnitude;const s=this.createSideVector(t,e);return this.scaleUnitVector(cs(s),i)}projectButt(){return[this.projectOrthogonally(this.A,this.T,this.strokeProjectionMagnitude),this.projectOrthogonally(this.A,this.T,-this.strokeProjectionMagnitude)]}projectRound(){const t=[];if(!this.isSkewed()&&this.A.eq(this.T)){const e=new Se(1,1).scalarMultiply(this.strokeProjectionMagnitude).multiply(this.strokeUniformScalar);t.push(this.applySkew(this.A.add(e)),this.applySkew(this.A.subtract(e)))}else t.push(...new fr(this.A,this.T,this.T,this.options).projectRound());return t}projectSquare(){const t=[];if(this.A.eq(this.T)){const e=new Se(1,1).scalarMultiply(this.strokeProjectionMagnitude).multiply(this.strokeUniformScalar);t.push(this.A.add(e),this.A.subtract(e))}else{const e=this.calcOrthogonalProjection(this.A,this.T,this.strokeProjectionMagnitude),i=this.scaleUnitVector(ls(this.createSideVector(this.A,this.T)),-this.strokeProjectionMagnitude),s=this.A.add(i);t.push(s.add(e),s.subtract(e))}return t.map((t=>this.applySkew(t)))}projectPoints(){switch(this.options.strokeLineCap){case"round":return this.projectRound();case"square":return this.projectSquare();default:return this.projectButt()}}project(){return this.projectPoints().map((t=>({originPoint:this.A,projectedPoint:t})))}}const vr=t=>{const e={};return Object.keys(t).forEach((i=>{e[i]={},Object.keys(t[i]).forEach((s=>{e[i][s]=xt({},t[i][s])}))})),e},_r=t=>{const e=[];for(let i,s=0;s<t.length;s++)!1!==(i=br(t,s))&&e.push(i);return e},br=(t,e)=>{const i=t.charCodeAt(e);if(isNaN(i))return"";if(i<55296||i>57343)return t.charAt(e);if(55296<=i&&i<=56319){if(t.length<=e+1)throw"High surrogate without following low surrogate";const i=t.charCodeAt(e+1);if(56320>i||i>57343)throw"High surrogate without following low surrogate";return t.charAt(e)+t.charAt(e+1)}if(0===e)throw"Low surrogate without preceding high surrogate";const s=t.charCodeAt(e-1);if(55296>s||s>56319)throw"Low surrogate without preceding high surrogate";return!1},yr=function(t,e){let i=arguments.length>2&&void 0!==arguments[2]&&arguments[2];return t.fill!==e.fill||t.stroke!==e.stroke||t.strokeWidth!==e.strokeWidth||t.fontSize!==e.fontSize||t.fontFamily!==e.fontFamily||t.fontWeight!==e.fontWeight||t.fontStyle!==e.fontStyle||t.textBackgroundColor!==e.textBackgroundColor||t.deltaY!==e.deltaY||i&&(t.overline!==e.overline||t.underline!==e.underline||t.linethrough!==e.linethrough)},xr=(t,e)=>{const i=e.split("\n"),s=[];let r=-1,n={};t=vr(t);for(let o=0;o<i.length;o++){const e=_r(i[o]);if(t[o])for(let i=0;i<e.length;i++){r++;const e=t[o][i];e&&Object.keys(e).length>0&&(yr(n,e,!0)?s.push({start:r,end:r+1,style:e}):s[s.length-1].end++),n=e||{}}else r+=e.length,n={}}return s},wr=(t,e)=>{if(!Array.isArray(t))return vr(t);const i=e.split(Zt),s={};let r=-1,n=0;for(let o=0;o<i.length;o++){const e=_r(i[o]);for(let i=0;i<e.length;i++)r++,t[n]&&t[n].start<=r&&r<t[n].end&&(s[o]=s[o]||{},s[o][i]=xt({},t[n].style),r===t[n].end-1&&n++)}return s},Cr=["display","transform",pe,"fill-opacity","fill-rule","opacity",ge,"stroke-dasharray","stroke-linecap","stroke-dashoffset","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke-width","id","paint-order","vector-effect","instantiated_by_use","clip-path"];function Sr(t,e){const i=t.nodeName,s=t.getAttribute("class"),r=t.getAttribute("id"),n="(?![a-zA-Z\\-]+)";let o;if(o=new RegExp("^"+i,"i"),e=e.replace(o,""),r&&e.length&&(o=new RegExp("#"+r+n,"i"),e=e.replace(o,"")),s&&e.length){const t=s.split(" ");for(let i=t.length;i--;)o=new RegExp("\\."+t[i]+n,"i"),e=e.replace(o,"")}return 0===e.length}function Tr(t,e){let i=!0;const s=Sr(t,e.pop());return s&&e.length&&(i=function(t,e){let i,s=!0;for(;t.parentElement&&1===t.parentElement.nodeType&&e.length;)s&&(i=e.pop()),s=Sr(t=t.parentElement,i);return 0===e.length}(t,e)),s&&i&&0===e.length}const Or=t=>{var e;return null!==(e=Zi[t])&&void 0!==e?e:t},Er=new RegExp("(".concat(Ki,")"),"gi");var kr,Dr,Ar,Mr,Pr,jr,Lr;const Fr="(".concat(Ki,")"),Ir=String.raw(kr||(kr=Ct(["(skewX)(",")"],["(skewX)\\(","\\)"])),Fr),Rr=String.raw(Dr||(Dr=Ct(["(skewY)(",")"],["(skewY)\\(","\\)"])),Fr),Br=String.raw(Ar||(Ar=Ct(["(rotate)(","(?: "," ",")?)"],["(rotate)\\(","(?: "," ",")?\\)"])),Fr,Fr,Fr),Nr=String.raw(Mr||(Mr=Ct(["(scale)(","(?: ",")?)"],["(scale)\\(","(?: ",")?\\)"])),Fr,Fr),zr=String.raw(Pr||(Pr=Ct(["(translate)(","(?: ",")?)"],["(translate)\\(","(?: ",")?\\)"])),Fr,Fr),Vr=String.raw(jr||(jr=Ct(["(matrix)("," "," "," "," "," ",")"],["(matrix)\\("," "," "," "," "," ","\\)"])),Fr,Fr,Fr,Fr,Fr,Fr),$r="(?:".concat(Vr,"|").concat(zr,"|").concat(Br,"|").concat(Nr,"|").concat(Ir,"|").concat(Rr,")"),Wr="(?:".concat($r,"*)"),Hr=String.raw(Lr||(Lr=Ct(["^s*(?:","?)s*$"],["^\\s*(?:","?)\\s*$"])),Wr),Xr=new RegExp(Hr),Ur=new RegExp($r),Yr=new RegExp($r,"g");function Gr(t){const e=[];if(!(t=(t=>t.replace(Er," $1 ").replace(/,/gi," ").replace(/\s+/gi," "))(t).replace(/\s*([()])\s*/gi,"$1"))||t&&!Xr.test(t))return[...Wt];for(const i of t.matchAll(Yr)){const t=Ur.exec(i[0]);if(!t)continue;let s=Wt;const r=t.filter((t=>!!t)),[,n,...o]=r,[a,l,c,h,d,u]=o.map((t=>parseFloat(t)));switch(n){case"translate":s=We(a,l);break;case ie:s=He({angle:a},{x:l,y:c});break;case le:s=Xe(a,l);break;case de:s=Ye(a);break;case ue:s=Ge(a);break;case"matrix":s=[a,l,c,h,d,u]}e.push(s)}return ze(e)}function qr(t,e,i,s){const r=Array.isArray(e);let n,o=e;if(t!==pe&&t!==ge||e!==Jt){if("strokeUniform"===t)return"non-scaling-stroke"===e;if("strokeDashArray"===t)o=e===Jt?null:e.replace(/,/g," ").split(/\s+/).map(parseFloat);else if("transformMatrix"===t)o=i&&i.transformMatrix?Ne(i.transformMatrix,Gr(e)):Gr(e);else if("visible"===t)o=e!==Jt&&"hidden"!==e,i&&!1===i.visible&&(o=!1);else if("opacity"===t)o=parseFloat(e),i&&void 0!==i.opacity&&(o*=i.opacity);else if("textAnchor"===t)o="start"===e?Yt:"end"===e?Kt:Ut;else if("charSpacing"===t)n=hi(e,s)/s*1e3;else if("paintFirst"===t){const t=e.indexOf(pe),i=e.indexOf(ge);o=pe,(t>-1&&i>-1&&i<t||-1===t&&i>-1)&&(o=ge)}else{if("href"===t||"xlink:href"===t||"font"===t||"id"===t)return e;if("imageSmoothing"===t)return"optimizeQuality"===e;n=r?e.map(hi):hi(e,s)}}else o="";return!r&&isNaN(n)?o:n}const Kr={stroke:"strokeOpacity",fill:"fillOpacity"};function Jr(t,e,i){if(!t)return{};let s,r={},n=Ht;t.parentNode&&es.test(t.parentNode.nodeName)&&(r=Jr(t.parentElement,e,i),r.fontSize&&(s=n=hi(r.fontSize)));const o=xt(xt(xt({},e.reduce(((e,i)=>{const s=t.getAttribute(i);return s&&(e[i]=s),e}),{})),function(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},i={};for(const s in e)Tr(t,s.split(" "))&&(i=xt(xt({},i),e[s]));return i}(t,i)),function(t){const e={},i=t.getAttribute("style");return i?("string"==typeof i?function(t,e){t.replace(/;\s*$/,"").split(";").forEach((t=>{if(!t)return;const[i,s]=t.split(":");e[i.trim().toLowerCase()]=s.trim()}))}(i,e):(s=i,r=e,Object.entries(s).forEach((t=>{let[e,i]=t;void 0!==i&&(r[e.toLowerCase()]=i)}))),e):e;var s,r}(t));o[ts]&&t.setAttribute(ts,o[ts]),o[Qi]&&(s=hi(o[Qi],n),o[Qi]="".concat(s));const a={};for(const c in o){const t=Or(c),e=qr(t,o[c],r,s);a[t]=e}a&&a.font&&function(t,e){const i=t.match(Ji);if(!i)return;const s=i[1],r=i[3],n=i[4],o=i[5],a=i[6];s&&(e.fontStyle=s),r&&(e.fontWeight=isNaN(parseFloat(r))?r:parseFloat(r)),n&&(e.fontSize=hi(n)),a&&(e.fontFamily=a),o&&(e.lineHeight="normal"===o?1:o)}(a.font,a);const l=xt(xt({},r),a);return es.test(t.nodeName)?l:function(t){const e=ur.getDefaults();return Object.entries(Kr).forEach((i=>{let[s,r]=i;if(void 0===t[r]||""===t[s])return;if(void 0===t[s]){if(!e[s])return;t[s]=e[s]}if(0===t[s].indexOf("url("))return;const n=new li(t[s]);t[s]=n.setAlpha(ci(n.getAlpha()*t[r],2)).toRgba()})),t}(l)}const Zr=["left","top","width","height","visible"],Qr=["rx","ry"];class tn extends ur{static getDefaults(){return xt(xt({},super.getDefaults()),tn.ownDefaults)}constructor(t){super(),Object.assign(this,tn.ownDefaults),this.setOptions(t),this._initRxRy()}_initRxRy(){const{rx:t,ry:e}=this;t&&!e?this.ry=t:e&&!t&&(this.rx=e)}_render(t){const{width:e,height:i}=this,s=-e/2,r=-i/2,n=this.rx?Math.min(this.rx,e/2):0,o=this.ry?Math.min(this.ry,i/2):0,a=0!==n||0!==o;t.beginPath(),t.moveTo(s+n,r),t.lineTo(s+e-n,r),a&&t.bezierCurveTo(s+e-Xt*n,r,s+e,r+Xt*o,s+e,r+o),t.lineTo(s+e,r+i-o),a&&t.bezierCurveTo(s+e,r+i-Xt*o,s+e-Xt*n,r+i,s+e-n,r+i),t.lineTo(s+n,r+i),a&&t.bezierCurveTo(s+Xt*n,r+i,s,r+i-Xt*o,s,r+i-o),t.lineTo(s,r+o),a&&t.bezierCurveTo(s,r+Xt*o,s+Xt*n,r,s+n,r),t.closePath(),this._renderPaintInOrder(t)}toObject(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];return super.toObject([...Qr,...t])}_toSVG(){const{width:t,height:e,rx:i,ry:s}=this;return["<rect ","COMMON_PARTS",'x="'.concat(-t/2,'" y="').concat(-e/2,'" rx="').concat(i,'" ry="').concat(s,'" width="').concat(t,'" height="').concat(e,'" />\n')]}static async fromElement(t,e,i){const s=Jr(t,this.ATTRIBUTE_NAMES,i),{left:r=0,top:n=0,width:o=0,height:a=0,visible:l=!0}=s,c=wt(s,Zr);return new this(xt(xt(xt({},e),c),{},{left:r,top:n,width:o,height:a,visible:Boolean(l&&o&&a)}))}}bt(tn,"type","Rect"),bt(tn,"cacheProperties",[..._s,...Qr]),bt(tn,"ownDefaults",{rx:0,ry:0}),bt(tn,"ATTRIBUTE_NAMES",[...Cr,"x","y","rx","ry","width","height"]),_e.setClass(tn),_e.setSVGClass(tn);const en="initialization",sn="added",rn="removed",nn="imperative",on=(t,e)=>{const{strokeUniform:i,strokeWidth:s,width:r,height:n,group:o}=e,a=o&&o!==t?Li(o.calcTransformMatrix(),t.calcTransformMatrix()):null,l=a?e.getRelativeCenterPoint().transform(a):e.getRelativeCenterPoint(),c=!e.isStrokeAccountedForInDimensions(),h=i&&c?function(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Wt,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:Wt;return t.transform(Li(e,i),!0)}(new Se(s,s),void 0,t.calcTransformMatrix()):Te,d=!i&&c?s:0,u=ji(r+d,n+d,ze([a,e.calcOwnMatrix()],!0)).add(h).scalarDivide(2);return[l.subtract(u),l.add(u)]};class an{calcLayoutResult(t,e){if(this.shouldPerformLayout(t))return this.calcBoundingBox(e,t)}shouldPerformLayout(t){let{type:e,prevStrategy:i,strategy:s}=t;return e===en||e===nn||!!i&&s!==i}shouldLayoutClipPath(t){let{type:e,target:{clipPath:i}}=t;return e!==en&&i&&!i.absolutePositioned}getInitialSize(t,e){return e.size}calcBoundingBox(t,e){const{type:i,target:s}=e;if(i===nn&&e.overrides)return e.overrides;if(0===t.length)return;const{left:r,top:n,width:o,height:a}=Di(t.map((t=>on(s,t))).reduce(((t,e)=>t.concat(e)),[])),l=new Se(o,a),c=new Se(r,n).add(l.scalarDivide(2));if(i===en){const t=this.getInitialSize(e,{size:l,center:c});return{center:c,relativeCorrection:new Se(0,0),size:t}}return{center:c.transform(s.calcOwnMatrix()),size:l}}}bt(an,"type","strategy");class ln extends an{shouldPerformLayout(t){return!0}}bt(ln,"type","fit-content"),_e.setClass(ln);const cn=["strategy"],hn=["target","strategy","bubbles","prevStrategy"],dn="layoutManager";class un{constructor(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:new ln;bt(this,"strategy",void 0),this.strategy=t,this._subscriptions=new Map}performLayout(t){const e=xt(xt({bubbles:!0,strategy:this.strategy},t),{},{prevStrategy:this._prevLayoutStrategy,stopPropagation(){this.bubbles=!1}});this.onBeforeLayout(e);const i=this.getLayoutResult(e);i&&this.commitLayout(e,i),this.onAfterLayout(e,i),this._prevLayoutStrategy=e.strategy}attachHandlers(t,e){const{target:i}=e;return[fe,Qt,re,ee,te,se,ae,ne,oe].map((e=>t.on(e,(t=>this.performLayout(e===fe?{type:"object_modified",trigger:e,e:t,target:i}:{type:"object_modifying",trigger:e,e:t,target:i})))))}subscribe(t,e){this.unsubscribe(t,e);const i=this.attachHandlers(t,e);this._subscriptions.set(t,i)}unsubscribe(t,e){(this._subscriptions.get(t)||[]).forEach((t=>t())),this._subscriptions.delete(t)}unsubscribeTargets(t){t.targets.forEach((e=>this.unsubscribe(e,t)))}subscribeTargets(t){t.targets.forEach((e=>this.subscribe(e,t)))}onBeforeLayout(t){const{target:e,type:i}=t,{canvas:s}=e;if(i===en||i===sn?this.subscribeTargets(t):i===rn&&this.unsubscribeTargets(t),e.fire("layout:before",{context:t}),s&&s.fire("object:layout:before",{target:e,context:t}),i===nn&&t.deep){const i=wt(t,cn);e.forEachObject((t=>t.layoutManager&&t.layoutManager.performLayout(xt(xt({},i),{},{bubbles:!1,target:t}))))}}getLayoutResult(t){const{target:e,strategy:i,type:s}=t,r=i.calcLayoutResult(t,e.getObjects());if(!r)return;const n=s===en?new Se:e.getRelativeCenterPoint(),{center:o,correction:a=new Se,relativeCorrection:l=new Se}=r,c=n.subtract(o).add(a).transform(s===en?Wt:Be(e.calcOwnMatrix()),!0).add(l);return{result:r,prevCenter:n,nextCenter:o,offset:c}}commitLayout(t,e){const{target:i}=t,{result:{size:s},nextCenter:r}=e;var n,o;i.set({width:s.x,height:s.y}),this.layoutObjects(t,e),t.type===en?i.set({left:null!==(n=t.x)&&void 0!==n?n:r.x+s.x*Bi(i.originX),top:null!==(o=t.y)&&void 0!==o?o:r.y+s.y*Bi(i.originY)}):(i.setPositionByOrigin(r,Ut,Ut),i.setCoords(),i.set("dirty",!0))}layoutObjects(t,e){const{target:i}=t;i.forEachObject((s=>{s.group===i&&this.layoutObject(t,e,s)})),t.strategy.shouldLayoutClipPath(t)&&this.layoutObject(t,e,i.clipPath)}layoutObject(t,e,i){let{offset:s}=e;i.set({left:i.left+s.x,top:i.top+s.y})}onAfterLayout(t,e){const{target:i,strategy:s,bubbles:r,prevStrategy:n}=t,o=wt(t,hn),{canvas:a}=i;i.fire("layout:after",{context:t,result:e}),a&&a.fire("object:layout:after",{context:t,result:e,target:i});const l=i.parent;r&&null!=l&&l.layoutManager&&((o.path||(o.path=[])).push(i),l.layoutManager.performLayout(xt(xt({},o),{},{target:l}))),i.set("dirty",!0)}dispose(){const{_subscriptions:t}=this;t.forEach((t=>t.forEach((t=>t())))),t.clear()}toObject(){return{type:dn,strategy:this.strategy.constructor.type}}toJSON(){return this.toObject()}}_e.setClass(un,dn);const pn=["type","objects","layoutManager"];class gn extends un{performLayout(){}}class fn extends(Ee(ur)){static getDefaults(){return xt(xt({},super.getDefaults()),fn.ownDefaults)}constructor(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};super(),bt(this,"_activeObjects",[]),bt(this,"__objectSelectionTracker",void 0),bt(this,"__objectSelectionDisposer",void 0),Object.assign(this,fn.ownDefaults),this.setOptions(e),this.groupInit(t,e)}groupInit(t,e){var i;this._objects=[...t],this.__objectSelectionTracker=this.__objectSelectionMonitor.bind(this,!0),this.__objectSelectionDisposer=this.__objectSelectionMonitor.bind(this,!1),this.forEachObject((t=>{this.enterGroup(t,!1)})),this.layoutManager=null!==(i=e.layoutManager)&&void 0!==i?i:new un,this.layoutManager.performLayout({type:en,target:this,targets:[...t],x:e.left,y:e.top})}canEnterGroup(t){return t===this||this.isDescendantOf(t)?(Ot("error","Group: circular object trees are not supported, this call has no effect"),!1):-1===this._objects.indexOf(t)||(Ot("error","Group: duplicate objects are not supported inside group, this call has no effect"),!1)}_filterObjectsBeforeEnteringGroup(t){return t.filter(((t,e,i)=>this.canEnterGroup(t)&&i.indexOf(t)===e))}add(){for(var t=arguments.length,e=new Array(t),i=0;i<t;i++)e[i]=arguments[i];const s=this._filterObjectsBeforeEnteringGroup(e),r=super.add(...s);return this._onAfterObjectsChange(sn,s),r}insertAt(t){for(var e=arguments.length,i=new Array(e>1?e-1:0),s=1;s<e;s++)i[s-1]=arguments[s];const r=this._filterObjectsBeforeEnteringGroup(i),n=super.insertAt(t,...r);return this._onAfterObjectsChange(sn,r),n}remove(){const t=super.remove(...arguments);return this._onAfterObjectsChange(rn,t),t}_onObjectAdded(t){this.enterGroup(t,!0),this.fire("object:added",{target:t}),t.fire("added",{target:this})}_onObjectRemoved(t,e){this.exitGroup(t,e),this.fire("object:removed",{target:t}),t.fire("removed",{target:this})}_onAfterObjectsChange(t,e){this.layoutManager.performLayout({type:t,targets:e,target:this})}_onStackOrderChanged(){this._set("dirty",!0)}_set(t,e){const i=this[t];return super._set(t,e),"canvas"===t&&i!==e&&(this._objects||[]).forEach((i=>{i._set(t,e)})),this}_shouldSetNestedCoords(){return this.subTargetCheck}removeAll(){return this._activeObjects=[],this.remove(...this._objects)}__objectSelectionMonitor(t,e){let{target:i}=e;const s=this._activeObjects;if(t)s.push(i),this._set("dirty",!0);else if(s.length>0){const t=s.indexOf(i);t>-1&&(s.splice(t,1),this._set("dirty",!0))}}_watchObject(t,e){t&&this._watchObject(!1,e),t?(e.on("selected",this.__objectSelectionTracker),e.on("deselected",this.__objectSelectionDisposer)):(e.off("selected",this.__objectSelectionTracker),e.off("deselected",this.__objectSelectionDisposer))}enterGroup(t,e){t.group&&t.group.remove(t),t._set("parent",this),this._enterGroup(t,e)}_enterGroup(t,e){e&&Mi(t,Ne(Be(this.calcTransformMatrix()),t.calcTransformMatrix())),this._shouldSetNestedCoords()&&t.setCoords(),t._set("group",this),t._set("canvas",this.canvas),this._watchObject(!0,t);const i=this.canvas&&this.canvas.getActiveObject&&this.canvas.getActiveObject();i&&(i===t||t.isDescendantOf(i))&&this._activeObjects.push(t)}exitGroup(t,e){this._exitGroup(t,e),t._set("parent",void 0),t._set("canvas",void 0)}_exitGroup(t,e){t._set("group",void 0),e||(Mi(t,Ne(this.calcTransformMatrix(),t.calcTransformMatrix())),t.setCoords()),this._watchObject(!1,t);const i=this._activeObjects.length>0?this._activeObjects.indexOf(t):-1;i>-1&&this._activeObjects.splice(i,1)}shouldCache(){const t=ur.prototype.shouldCache.call(this);if(t)for(let e=0;e<this._objects.length;e++)if(this._objects[e].willDrawShadow())return this.ownCaching=!1,!1;return t}willDrawShadow(){if(super.willDrawShadow())return!0;for(let t=0;t<this._objects.length;t++)if(this._objects[t].willDrawShadow())return!0;return!1}isOnACache(){return this.ownCaching||!!this.parent&&this.parent.isOnACache()}drawObject(t,e,i){this._renderBackground(t);for(let r=0;r<this._objects.length;r++){var s;const e=this._objects[r];null!==(s=this.canvas)&&void 0!==s&&s.preserveObjectStacking&&e.group!==this?(t.save(),t.transform(...Be(this.calcTransformMatrix())),e.render(t),t.restore()):e.group===this&&e.render(t)}this._drawClipPath(t,this.clipPath,i)}setCoords(){super.setCoords(),this._shouldSetNestedCoords()&&this.forEachObject((t=>t.setCoords()))}triggerLayout(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.layoutManager.performLayout(xt({target:this,type:nn},t))}render(t){this._transformDone=!0,super.render(t),this._transformDone=!1}__serializeObjects(t,e){const i=this.includeDefaultValues;return this._objects.filter((function(t){return!t.excludeFromExport})).map((function(s){const r=s.includeDefaultValues;s.includeDefaultValues=i;const n=s[t||"toObject"](e);return s.includeDefaultValues=r,n}))}toObject(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];const e=this.layoutManager.toObject();return xt(xt(xt({},super.toObject(["subTargetCheck","interactive",...t])),"fit-content"!==e.strategy||this.includeDefaultValues?{layoutManager:e}:{}),{},{objects:this.__serializeObjects("toObject",t)})}toString(){return"#<Group: (".concat(this.complexity(),")>")}dispose(){this.layoutManager.unsubscribeTargets({targets:this.getObjects(),target:this}),this._activeObjects=[],this.forEachObject((t=>{this._watchObject(!1,t),t.dispose()})),super.dispose()}_createSVGBgRect(t){if(!this.backgroundColor)return"";const e=tn.prototype._toSVG.call(this),i=e.indexOf("COMMON_PARTS");e[i]='for="group" ';const s=e.join("");return t?t(s):s}_toSVG(t){const e=["<g ","COMMON_PARTS"," >\n"],i=this._createSVGBgRect(t);i&&e.push("\t\t",i);for(let s=0;s<this._objects.length;s++)e.push("\t\t",this._objects[s].toSVG(t));return e.push("</g>\n"),e}getSvgStyles(){const t=void 0!==this.opacity&&1!==this.opacity?"opacity: ".concat(this.opacity,";"):"",e=this.visible?"":" visibility: hidden;";return[t,this.getSvgFilter(),e].join("")}toClipPathSVG(t){const e=[],i=this._createSVGBgRect(t);i&&e.push("\t",i);for(let s=0;s<this._objects.length;s++)e.push("\t",this._objects[s].toClipPathSVG(t));return this._createBaseClipPathSVGMarkup(e,{reviver:t})}static fromObject(t,e){let{type:i,objects:s=[],layoutManager:r}=t,n=wt(t,pn);return Promise.all([Ze(s,e),Qe(n,e)]).then((t=>{let[e,i]=t;const s=new this(e,xt(xt(xt({},n),i),{},{layoutManager:new gn}));if(r){const t=_e.getClass(r.type),e=_e.getClass(r.strategy);s.layoutManager=new t(new e)}else s.layoutManager=new un;return s.layoutManager.subscribeTargets({type:en,target:s,targets:s.getObjects()}),s.setCoords(),s}))}}bt(fn,"type","Group"),bt(fn,"ownDefaults",{strokeWidth:0,subTargetCheck:!1,interactive:!1}),_e.setClass(fn);const mn="\\s*,?\\s*",vn="".concat(mn,"(").concat(Ki,")"),_n="".concat(vn).concat(vn).concat(vn).concat(mn,"([01])").concat(mn,"([01])").concat(vn).concat(vn),bn={m:"l",M:"L"},yn=(t,e,i,s,r,n,o,a,l,c,h)=>{const d=we(t),u=Ce(t),p=we(e),g=Ce(e),f=i*r*p-s*n*g+o,m=s*r*p+i*n*g+a;return["C",c+l*(-i*r*u-s*n*d),h+l*(-s*r*u+i*n*d),f+l*(i*r*g+s*n*p),m+l*(s*r*g-i*n*p),f,m]},xn=(t,e,i,s)=>{const r=Math.atan2(e,t),n=Math.atan2(s,i);return n>=r?n-r:2*Math.PI-(r-n)};function wn(t,e,i,s,r,n,o,a){let l;if(Tt.cachesBoundsOfCurve&&(l=[...arguments].join(),Rt.boundsOfCurveCache[l]))return Rt.boundsOfCurveCache[l];const c=Math.sqrt,h=Math.abs,d=[],u=[[0,0],[0,0]];let p=6*t-12*i+6*r,g=-3*t+9*i-9*r+3*o,f=3*i-3*t;for(let y=0;y<2;++y){if(y>0&&(p=6*e-12*s+6*n,g=-3*e+9*s-9*n+3*a,f=3*s-3*e),h(g)<1e-12){if(h(p)<1e-12)continue;const t=-f/p;0<t&&t<1&&d.push(t);continue}const t=p*p-4*f*g;if(t<0)continue;const i=c(t),r=(-p+i)/(2*g);0<r&&r<1&&d.push(r);const o=(-p-i)/(2*g);0<o&&o<1&&d.push(o)}let m=d.length;const v=m,_=Tn(t,e,i,s,r,n,o,a);for(;m--;){const{x:t,y:e}=_(d[m]);u[0][m]=t,u[1][m]=e}u[0][v]=t,u[1][v]=e,u[0][v+1]=o,u[1][v+1]=a;const b=[new Se(Math.min(...u[0]),Math.min(...u[1])),new Se(Math.max(...u[0]),Math.max(...u[1]))];return Tt.cachesBoundsOfCurve&&(Rt.boundsOfCurveCache[l]=b),b}const Cn=(t,e,i)=>{let[s,r,n,o,a,l,c,h]=i;const d=((t,e,i,s,r,n,o)=>{if(0===i||0===s)return[];let a=0,l=0,c=0;const h=Math.PI,d=o*$t,u=Ce(d),p=we(d),g=.5*(-p*t-u*e),f=.5*(-p*e+u*t),m=i**2,v=s**2,_=f**2,b=g**2,y=m*v-m*_-v*b;let x=Math.abs(i),w=Math.abs(s);if(y<0){const t=Math.sqrt(1-y/(m*v));x*=t,w*=t}else c=(r===n?-1:1)*Math.sqrt(y/(m*_+v*b));const C=c*x*f/w,S=-c*w*g/x,T=p*C-u*S+.5*t,O=u*C+p*S+.5*e;let E=xn(1,0,(g-C)/x,(f-S)/w),k=xn((g-C)/x,(f-S)/w,(-g-C)/x,(-f-S)/w);0===n&&k>0?k-=2*h:1===n&&k<0&&(k+=2*h);const D=Math.ceil(Math.abs(k/h*2)),A=[],M=k/D,P=8/3*Math.sin(M/4)*Math.sin(M/4)/Math.sin(M/2);let j=E+M;for(let L=0;L<D;L++)A[L]=yn(E,j,p,u,x,w,T,O,P,a,l),a=A[L][5],l=A[L][6],E=j,j+=M;return A})(c-t,h-e,r,n,a,l,o);for(let u=0,p=d.length;u<p;u++)d[u][1]+=t,d[u][2]+=e,d[u][3]+=t,d[u][4]+=e,d[u][5]+=t,d[u][6]+=e;return d},Sn=(t,e,i,s)=>Math.sqrt((i-t)**2+(s-e)**2),Tn=(t,e,i,s,r,n,o,a)=>l=>{const c=l**3,h=3*(p=l)**2*(1-p),d=(t=>3*t*(1-t)**2)(l),u=(t=>(1-t)**3)(l);var p;return new Se(o*c+r*h+i*d+t*u,a*c+n*h+s*d+e*u)},On=t=>t**2,En=t=>2*t*(1-t),kn=t=>(1-t)**2,Dn=(t,e,i,s,r,n,o,a)=>l=>{const c=On(l),h=En(l),d=kn(l),u=3*(d*(i-t)+h*(r-i)+c*(o-r)),p=3*(d*(s-e)+h*(n-s)+c*(a-n));return Math.atan2(p,u)},An=(t,e,i,s,r,n)=>o=>{const a=On(o),l=En(o),c=kn(o);return new Se(r*a+i*l+t*c,n*a+s*l+e*c)},Mn=(t,e,i,s,r,n)=>o=>{const a=1-o,l=2*(a*(i-t)+o*(r-i)),c=2*(a*(s-e)+o*(n-s));return Math.atan2(c,l)},Pn=(t,e,i)=>{let s=new Se(e,i),r=0;for(let n=1;n<=100;n+=1){const e=t(n/100);r+=Sn(s.x,s.y,e.x,e.y),s=e}return r},jn=t=>{let e,i,s=0,r=0,n=0,o=0,a=0;const l=[];for(const c of t){const t={x:r,y:n,command:c[0],length:0};switch(c[0]){case"M":i=t,i.x=o=r=c[1],i.y=a=n=c[2];break;case"L":i=t,i.length=Sn(r,n,c[1],c[2]),r=c[1],n=c[2];break;case"C":e=Tn(r,n,c[1],c[2],c[3],c[4],c[5],c[6]),i=t,i.iterator=e,i.angleFinder=Dn(r,n,c[1],c[2],c[3],c[4],c[5],c[6]),i.length=Pn(e,r,n),r=c[5],n=c[6];break;case"Q":e=An(r,n,c[1],c[2],c[3],c[4]),i=t,i.iterator=e,i.angleFinder=Mn(r,n,c[1],c[2],c[3],c[4]),i.length=Pn(e,r,n),r=c[3],n=c[4];break;case"Z":i=t,i.destX=o,i.destY=a,i.length=Sn(r,n,o,a),r=o,n=a}s+=i.length,l.push(i)}return l.push({length:s,x:r,y:n}),l},Ln=function(t,e){let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:jn(t),s=0;for(;e-i[s].length>0&&s<i.length-2;)e-=i[s].length,s++;const r=i[s],n=e/r.length,o=t[s];switch(r.command){case"M":return{x:r.x,y:r.y,angle:0};case"Z":return xt(xt({},new Se(r.x,r.y).lerp(new Se(r.destX,r.destY),n)),{},{angle:Math.atan2(r.destY-r.y,r.destX-r.x)});case"L":return xt(xt({},new Se(r.x,r.y).lerp(new Se(o[1],o[2]),n)),{},{angle:Math.atan2(o[2]-r.y,o[1]-r.x)});case"C":case"Q":return((t,e)=>{let i,s=0,r=0,n={x:t.x,y:t.y},o=xt({},n),a=.01,l=0;const c=t.iterator,h=t.angleFinder;for(;r<e&&a>1e-4;)o=c(s),l=s,i=Sn(n.x,n.y,o.x,o.y),i+r>e?(s-=a,a/=2):(n=o,s+=a,r+=i);return xt(xt({},o),{},{angle:h(l)})})(r,e)}},Fn=new RegExp("[mzlhvcsqta][^mzlhvcsqta]*","gi"),In=new RegExp(_n,"g"),Rn=new RegExp(Ki,"gi"),Bn={m:2,l:2,h:1,v:1,c:6,s:4,q:4,t:2,a:7};function Nn(t,e){const i=t.style;i&&e&&("string"==typeof e?i.cssText+=";"+e:Object.entries(e).forEach((t=>{let[e,s]=t;return i.setProperty(e,s)})))}class zn extends Ci{constructor(t){let{allowTouchScrolling:e=!1,containerClass:i=""}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};super(t),bt(this,"upper",void 0),bt(this,"container",void 0);const{el:s}=this.lower,r=this.createUpperCanvas();this.upper={el:r,ctx:r.getContext("2d")},this.applyCanvasStyle(s,{allowTouchScrolling:e}),this.applyCanvasStyle(r,{allowTouchScrolling:e,styles:{position:"absolute",left:"0",top:"0"}});const n=this.createContainerElement();n.classList.add(i),s.parentNode&&s.parentNode.replaceChild(n,s),n.append(s,r),this.container=n}createUpperCanvas(){const{el:t}=this.lower,e=Pe();return e.className=t.className,e.classList.remove("lower-canvas"),e.classList.add("upper-canvas"),e.setAttribute("data-fabric","top"),e.style.cssText=t.style.cssText,e.setAttribute("draggable","true"),e}createContainerElement(){const t=Lt().createElement("div");return t.setAttribute("data-fabric","wrapper"),Nn(t,{position:"relative"}),wi(t),t}applyCanvasStyle(t,e){const{styles:i,allowTouchScrolling:s}=e;Nn(t,xt(xt({},i),{},{"touch-action":s?"manipulation":Jt})),wi(t)}setDimensions(t,e){super.setDimensions(t,e);const{el:i,ctx:s}=this.upper;yi(i,s,t,e)}setCSSDimensions(t){super.setCSSDimensions(t),xi(this.upper.el,t),xi(this.container,t)}cleanupDOM(t){const e=this.container,{el:i}=this.lower,{el:s}=this.upper;super.cleanupDOM(t),e.removeChild(s),e.removeChild(i),e.parentNode&&e.parentNode.replaceChild(i,e)}dispose(){super.dispose(),jt().dispose(this.upper.el),delete this.upper,delete this.container}}class Vn extends Ti{constructor(){super(...arguments),bt(this,"targets",[]),bt(this,"_hoveredTargets",[]),bt(this,"_objectsToRender",void 0),bt(this,"_currentTransform",null),bt(this,"_groupSelector",null),bt(this,"contextTopDirty",!1)}static getDefaults(){return xt(xt({},super.getDefaults()),Vn.ownDefaults)}get upperCanvasEl(){var t;return null===(t=this.elements.upper)||void 0===t?void 0:t.el}get contextTop(){var t;return null===(t=this.elements.upper)||void 0===t?void 0:t.ctx}get wrapperEl(){return this.elements.container}initElements(t){this.elements=new zn(t,{allowTouchScrolling:this.allowTouchScrolling,containerClass:this.containerClass}),this._createCacheCanvas()}_onObjectAdded(t){this._objectsToRender=void 0,super._onObjectAdded(t)}_onObjectRemoved(t){this._objectsToRender=void 0,t===this._activeObject&&(this.fire("before:selection:cleared",{deselected:[t]}),this._discardActiveObject(),this.fire("selection:cleared",{deselected:[t]}),t.fire("deselected",{target:t})),t===this._hoveredTarget&&(this._hoveredTarget=void 0,this._hoveredTargets=[]),super._onObjectRemoved(t)}_onStackOrderChanged(){this._objectsToRender=void 0,super._onStackOrderChanged()}_chooseObjectsToRender(){const t=this._activeObject;return!this.preserveObjectStacking&&t?this._objects.filter((e=>!e.group&&e!==t)).concat(t):this._objects}renderAll(){this.cancelRequestedRender(),this.destroyed||(!this.contextTopDirty||this._groupSelector||this.isDrawingMode||(this.clearContext(this.contextTop),this.contextTopDirty=!1),this.hasLostContext&&(this.renderTopLayer(this.contextTop),this.hasLostContext=!1),!this._objectsToRender&&(this._objectsToRender=this._chooseObjectsToRender()),this.renderCanvas(this.getContext(),this._objectsToRender))}renderTopLayer(t){t.save(),this.isDrawingMode&&this._isCurrentlyDrawing&&(this.freeDrawingBrush&&this.freeDrawingBrush._render(),this.contextTopDirty=!0),this.selection&&this._groupSelector&&(this._drawSelection(t),this.contextTopDirty=!0),t.restore()}renderTop(){const t=this.contextTop;this.clearContext(t),this.renderTopLayer(t),this.fire("after:render",{ctx:t})}setTargetFindTolerance(t){t=Math.round(t),this.targetFindTolerance=t;const e=this.getRetinaScaling(),i=Math.ceil((2*t+1)*e);this.pixelFindCanvasEl.width=this.pixelFindCanvasEl.height=i,this.pixelFindContext.scale(e,e)}isTargetTransparent(t,e,i){const s=this.targetFindTolerance,r=this.pixelFindContext;this.clearContext(r),r.save(),r.translate(-e+s,-i+s),r.transform(...this.viewportTransform);const n=t.selectionBackgroundColor;t.selectionBackgroundColor="",t.render(r),t.selectionBackgroundColor=n,r.restore();const o=Math.round(s*this.getRetinaScaling());return((t,e,i,s)=>{const r=2*(s=Math.round(s))+1,{data:n}=t.getImageData(e-s,i-s,r,r);for(let o=3;o<n.length;o+=4)if(n[o]>0)return!1;return!0})(r,o,o,o)}_isSelectionKeyPressed(t){const e=this.selectionKey;return!!e&&(Array.isArray(e)?!!e.find((e=>!!e&&!0===t[e])):t[e])}_shouldClearSelection(t,e){const i=this.getActiveObjects(),s=this._activeObject;return!!(!e||e&&s&&i.length>1&&-1===i.indexOf(e)&&s!==e&&!this._isSelectionKeyPressed(t)||e&&!e.evented||e&&!e.selectable&&s&&s!==e)}_shouldCenterTransform(t,e,i){if(!t)return;let s;return e===le||e===ce||e===he||e===re?s=this.centeredScaling||t.centeredScaling:e===ie&&(s=this.centeredRotation||t.centeredRotation),s?!i:i}_getOriginFromCorner(t,e){const i={x:t.originX,y:t.originY};return e?(["ml","tl","bl"].includes(e)?i.x=Kt:["mr","tr","br"].includes(e)&&(i.x=Yt),["tl","mt","tr"].includes(e)?i.y=qt:["bl","mb","br"].includes(e)&&(i.y=Gt),i):i}_setupCurrentTransform(t,e,i){var s;const r=e.group?Fi(this.getScenePoint(t),void 0,e.group.calcTransformMatrix()):this.getScenePoint(t),{key:n="",control:o}=e.getActiveControl()||{},a=i&&o?null===(s=o.getActionHandler(t,e,o))||void 0===s?void 0:s.bind(o):Ui,l=((t,e,i,s)=>{if(!e||!t)return"drag";const r=s.controls[e];return r.getActionName(i,r,s)})(i,n,t,e),c=t[this.centeredKey],h=this._shouldCenterTransform(e,l,c)?{x:Ut,y:Ut}:this._getOriginFromCorner(e,n),d={target:e,action:l,actionHandler:a,actionPerformed:!1,corner:n,scaleX:e.scaleX,scaleY:e.scaleY,skewX:e.skewX,skewY:e.skewY,offsetX:r.x-e.left,offsetY:r.y-e.top,originX:h.x,originY:h.y,ex:r.x,ey:r.y,lastX:r.x,lastY:r.y,theta:Fe(e.angle),width:e.width,height:e.height,shiftKey:t.shiftKey,altKey:c,original:xt(xt({},Pi(e)),{},{originX:h.x,originY:h.y})};this._currentTransform=d,this.fire("before:transform",{e:t,transform:d})}setCursor(t){this.upperCanvasEl.style.cursor=t}_drawSelection(t){const{x:e,y:i,deltaX:s,deltaY:r}=this._groupSelector,n=new Se(e,i).transform(this.viewportTransform),o=new Se(e+s,i+r).transform(this.viewportTransform),a=this.selectionLineWidth/2;let l=Math.min(n.x,o.x),c=Math.min(n.y,o.y),h=Math.max(n.x,o.x),d=Math.max(n.y,o.y);this.selectionColor&&(t.fillStyle=this.selectionColor,t.fillRect(l,c,h-l,d-c)),this.selectionLineWidth&&this.selectionBorderColor&&(t.lineWidth=this.selectionLineWidth,t.strokeStyle=this.selectionBorderColor,l+=a,c+=a,h-=a,d-=a,ur.prototype._setLineDash.call(this,t,this.selectionDashArray),t.strokeRect(l,c,h-l,d-c))}findTarget(t){if(this.skipTargetFind)return;const e=this.getViewportPoint(t),i=this._activeObject,s=this.getActiveObjects();if(this.targets=[],i&&s.length>=1){if(i.findControl(e,Ei(t)))return i;if(s.length>1&&this.searchPossibleTargets([i],e))return i;if(i===this.searchPossibleTargets([i],e)){if(this.preserveObjectStacking){const s=this.targets;this.targets=[];const r=this.searchPossibleTargets(this._objects,e);return t[this.altSelectionKey]&&r&&r!==i?(this.targets=s,i):r}return i}}return this.searchPossibleTargets(this._objects,e)}_pointIsInObjectSelectionArea(t,e){let i=t.getCoords();const s=this.getZoom(),r=t.padding/s;if(r){const[t,e,s,n]=i,o=Math.atan2(e.y-t.y,e.x-t.x),a=we(o)*r,l=Ce(o)*r,c=a+l,h=a-l;i=[new Se(t.x-h,t.y-c),new Se(e.x+c,e.y-h),new Se(s.x+h,s.y+c),new Se(n.x-c,n.y+h)]}return Ps.isPointInPolygon(e,i)}_checkTarget(t,e){if(t&&t.visible&&t.evented&&this._pointIsInObjectSelectionArea(t,Fi(e,void 0,this.viewportTransform))){if(!this.perPixelTargetFind&&!t.perPixelTargetFind||t.isEditing)return!0;if(!this.isTargetTransparent(t,e.x,e.y))return!0}return!1}_searchPossibleTargets(t,e){let i=t.length;for(;i--;){const s=t[i];if(this._checkTarget(s,e)){if(Oe(s)&&s.subTargetCheck){const t=this._searchPossibleTargets(s._objects,e);t&&this.targets.push(t)}return s}}}searchPossibleTargets(t,e){const i=this._searchPossibleTargets(t,e);if(i&&Oe(i)&&i.interactive&&this.targets[0]){const t=this.targets;for(let e=t.length-1;e>0;e--){const i=t[e];if(!Oe(i)||!i.interactive)return i}return t[0]}return i}getViewportPoint(t){return this._pointer?this._pointer:this.getPointer(t,!0)}getScenePoint(t){return this._absolutePointer?this._absolutePointer:this.getPointer(t)}getPointer(t){let e=arguments.length>1&&void 0!==arguments[1]&&arguments[1];const i=this.upperCanvasEl,s=i.getBoundingClientRect();let r=(t=>{const e=vi(t.target),i=function(t){const e=t.changedTouches;return e&&e[0]?e[0]:t}(t);return new Se(i.clientX+e.left,i.clientY+e.top)})(t),n=s.width||0,o=s.height||0;n&&o||(Gt in s&&qt in s&&(o=Math.abs(s.top-s.bottom)),Kt in s&&Yt in s&&(n=Math.abs(s.right-s.left))),this.calcOffset(),r.x=r.x-this._offset.left,r.y=r.y-this._offset.top,e||(r=Fi(r,void 0,this.viewportTransform));const a=this.getRetinaScaling();1!==a&&(r.x/=a,r.y/=a);const l=0===n||0===o?new Se(1,1):new Se(i.width/n,i.height/o);return r.multiply(l)}_setDimensionsImpl(t,e){this._resetTransformEventData(),super._setDimensionsImpl(t,e),this._isCurrentlyDrawing&&this.freeDrawingBrush&&this.freeDrawingBrush._setBrushStyles(this.contextTop)}_createCacheCanvas(){this.pixelFindCanvasEl=Pe(),this.pixelFindContext=this.pixelFindCanvasEl.getContext("2d",{willReadFrequently:!0}),this.setTargetFindTolerance(this.targetFindTolerance)}getTopContext(){return this.elements.upper.ctx}getSelectionContext(){return this.elements.upper.ctx}getSelectionElement(){return this.elements.upper.el}getActiveObject(){return this._activeObject}getActiveObjects(){const t=this._activeObject;return mi(t)?t.getObjects():t?[t]:[]}_fireSelectionEvents(t,e){let i=!1,s=!1;const r=this.getActiveObjects(),n=[],o=[];t.forEach((t=>{r.includes(t)||(i=!0,t.fire("deselected",{e:e,target:t}),o.push(t))})),r.forEach((s=>{t.includes(s)||(i=!0,s.fire("selected",{e:e,target:s}),n.push(s))})),t.length>0&&r.length>0?(s=!0,i&&this.fire("selection:updated",{e:e,selected:n,deselected:o})):r.length>0?(s=!0,this.fire("selection:created",{e:e,selected:n})):t.length>0&&(s=!0,this.fire("selection:cleared",{e:e,deselected:o})),s&&(this._objectsToRender=void 0)}setActiveObject(t,e){const i=this.getActiveObjects(),s=this._setActiveObject(t,e);return this._fireSelectionEvents(i,e),s}_setActiveObject(t,e){const i=this._activeObject;return!(i===t||!this._discardActiveObject(e,t)&&this._activeObject||t.onSelect({e:e})||(this._activeObject=t,mi(t)&&i!==t&&t.set("canvas",this),t.setCoords(),0))}_discardActiveObject(t,e){const i=this._activeObject;return!!i&&!i.onDeselect({e:t,object:e})&&(this._currentTransform&&this._currentTransform.target===i&&this.endCurrentTransform(t),mi(i)&&i===this._hoveredTarget&&(this._hoveredTarget=void 0),this._activeObject=void 0,!0)}discardActiveObject(t){const e=this.getActiveObjects(),i=this.getActiveObject();e.length&&this.fire("before:selection:cleared",{e:t,deselected:[i]});const s=this._discardActiveObject(t);return this._fireSelectionEvents(e,t),s}endCurrentTransform(t){const e=this._currentTransform;this._finalizeCurrentTransform(t),e&&e.target&&(e.target.isMoving=!1),this._currentTransform=null}_finalizeCurrentTransform(t){const e=this._currentTransform,i=e.target,s={e:t,target:i,transform:e,action:e.action};i._scaling&&(i._scaling=!1),i.setCoords(),e.actionPerformed&&(this.fire("object:modified",s),i.fire(fe,s))}setViewportTransform(t){super.setViewportTransform(t);const e=this._activeObject;e&&e.setCoords()}destroy(){const t=this._activeObject;mi(t)&&(t.removeAll(),t.dispose()),delete this._activeObject,super.destroy(),this.pixelFindContext=null,this.pixelFindCanvasEl=void 0}clear(){this.discardActiveObject(),this._activeObject=void 0,this.clearContext(this.contextTop),super.clear()}drawControls(t){const e=this._activeObject;e&&e._renderControls(t)}_toObject(t,e,i){const s=this._realizeGroupTransformOnObject(t),r=super._toObject(t,e,i);return t.set(s),r}_realizeGroupTransformOnObject(t){const{group:e}=t;if(e&&mi(e)&&this._activeObject===e){const i=ti(t,["angle","flipX","flipY",Yt,ce,he,de,ue,Gt]);return((t,e)=>{Mi(t,Ne(e,t.calcOwnMatrix()))})(t,e.calcOwnMatrix()),i}return{}}_setSVGObject(t,e,i){const s=this._realizeGroupTransformOnObject(e);super._setSVGObject(t,e,i),e.set(s)}}bt(Vn,"ownDefaults",{uniformScaling:!0,uniScaleKey:"shiftKey",centeredScaling:!1,centeredRotation:!1,centeredKey:"altKey",altActionKey:"shiftKey",selection:!0,selectionKey:"shiftKey",selectionColor:"rgba(100, 100, 255, 0.3)",selectionDashArray:[],selectionBorderColor:"rgba(255, 255, 255, 0.3)",selectionLineWidth:1,selectionFullyContained:!1,hoverCursor:"move",moveCursor:"move",defaultCursor:"default",freeDrawingCursor:"crosshair",notAllowedCursor:"not-allowed",perPixelTargetFind:!1,targetFindTolerance:0,skipTargetFind:!1,stopContextMenu:!1,fireRightClick:!1,fireMiddleClick:!1,enablePointerEvents:!1,containerClass:"canvas-container",preserveObjectStacking:!1});class $n{constructor(t){bt(this,"targets",[]),bt(this,"__disposer",void 0);const e=()=>{const{hiddenTextarea:e}=t.getActiveObject()||{};e&&e.focus()},i=t.upperCanvasEl;i.addEventListener("click",e),this.__disposer=()=>i.removeEventListener("click",e)}exitTextEditing(){this.target=void 0,this.targets.forEach((t=>{t.isEditing&&t.exitEditing()}))}add(t){this.targets.push(t)}remove(t){this.unregister(t),xe(this.targets,t)}register(t){this.target=t}unregister(t){t===this.target&&(this.target=void 0)}onMouseMove(t){var e;(null===(e=this.target)||void 0===e?void 0:e.isEditing)&&this.target.updateSelectionOnMouseMove(t)}clear(){this.targets=[],this.target=void 0}dispose(){this.clear(),this.__disposer(),delete this.__disposer}}const Wn=["target","oldTarget","fireCanvas","e"],Hn={passive:!1},Xn=(t,e)=>{const i=t.getViewportPoint(e),s=t.getScenePoint(e);return{viewportPoint:i,scenePoint:s,pointer:i,absolutePointer:s}},Un=function(t){for(var e=arguments.length,i=new Array(e>1?e-1:0),s=1;s<e;s++)i[s-1]=arguments[s];return t.addEventListener(...i)},Yn=function(t){for(var e=arguments.length,i=new Array(e>1?e-1:0),s=1;s<e;s++)i[s-1]=arguments[s];return t.removeEventListener(...i)},Gn={mouse:{in:"over",out:"out",targetIn:"mouseover",targetOut:"mouseout",canvasIn:"mouse:over",canvasOut:"mouse:out"},drag:{in:"enter",out:"leave",targetIn:"dragenter",targetOut:"dragleave",canvasIn:"drag:enter",canvasOut:"drag:leave"}};class qn extends Vn{constructor(t){super(t,arguments.length>1&&void 0!==arguments[1]?arguments[1]:{}),bt(this,"_isClick",void 0),bt(this,"textEditingManager",new $n(this)),["_onMouseDown","_onTouchStart","_onMouseMove","_onMouseUp","_onTouchEnd","_onResize","_onMouseWheel","_onMouseOut","_onMouseEnter","_onContextMenu","_onDoubleClick","_onDragStart","_onDragEnd","_onDragProgress","_onDragOver","_onDragEnter","_onDragLeave","_onDrop"].forEach((t=>{this[t]=this[t].bind(this)})),this.addOrRemove(Un,"add")}_getEventPrefix(){return this.enablePointerEvents?"pointer":"mouse"}addOrRemove(t,e){const i=this.upperCanvasEl,s=this._getEventPrefix();t(bi(i),"resize",this._onResize),t(i,s+"down",this._onMouseDown),t(i,"".concat(s,"move"),this._onMouseMove,Hn),t(i,"".concat(s,"out"),this._onMouseOut),t(i,"".concat(s,"enter"),this._onMouseEnter),t(i,"wheel",this._onMouseWheel),t(i,"contextmenu",this._onContextMenu),t(i,"dblclick",this._onDoubleClick),t(i,"dragstart",this._onDragStart),t(i,"dragend",this._onDragEnd),t(i,"dragover",this._onDragOver),t(i,"dragenter",this._onDragEnter),t(i,"dragleave",this._onDragLeave),t(i,"drop",this._onDrop),this.enablePointerEvents||t(i,"touchstart",this._onTouchStart,Hn)}removeListeners(){this.addOrRemove(Yn,"remove");const t=this._getEventPrefix(),e=_i(this.upperCanvasEl);Yn(e,"".concat(t,"up"),this._onMouseUp),Yn(e,"touchend",this._onTouchEnd,Hn),Yn(e,"".concat(t,"move"),this._onMouseMove,Hn),Yn(e,"touchmove",this._onMouseMove,Hn),clearTimeout(this._willAddMouseDown)}_onMouseWheel(t){this.__onMouseWheel(t)}_onMouseOut(t){const e=this._hoveredTarget,i=xt({e:t},Xn(this,t));this.fire("mouse:out",xt(xt({},i),{},{target:e})),this._hoveredTarget=void 0,e&&e.fire("mouseout",xt({},i)),this._hoveredTargets.forEach((t=>{this.fire("mouse:out",xt(xt({},i),{},{target:t})),t&&t.fire("mouseout",xt({},i))})),this._hoveredTargets=[]}_onMouseEnter(t){this._currentTransform||this.findTarget(t)||(this.fire("mouse:over",xt({e:t},Xn(this,t))),this._hoveredTarget=void 0,this._hoveredTargets=[])}_onDragStart(t){this._isClick=!1;const e=this.getActiveObject();if(e&&e.onDragStart(t)){this._dragSource=e;const i={e:t,target:e};return this.fire("dragstart",i),e.fire("dragstart",i),void Un(this.upperCanvasEl,"drag",this._onDragProgress)}ki(t)}_renderDragEffects(t,e,i){let s=!1;const r=this._dropTarget;r&&r!==e&&r!==i&&(r.clearContextTop(),s=!0),null==e||e.clearContextTop(),i!==e&&(null==i||i.clearContextTop());const n=this.contextTop;n.save(),n.transform(...this.viewportTransform),e&&(n.save(),e.transform(n),e.renderDragSourceEffect(t),n.restore(),s=!0),i&&(n.save(),i.transform(n),i.renderDropTargetEffect(t),n.restore(),s=!0),n.restore(),s&&(this.contextTopDirty=!0)}_onDragEnd(t){const e=!!t.dataTransfer&&t.dataTransfer.dropEffect!==Jt,i=e?this._activeObject:void 0,s={e:t,target:this._dragSource,subTargets:this.targets,dragSource:this._dragSource,didDrop:e,dropTarget:i};Yn(this.upperCanvasEl,"drag",this._onDragProgress),this.fire("dragend",s),this._dragSource&&this._dragSource.fire("dragend",s),delete this._dragSource,this._onMouseUp(t)}_onDragProgress(t){const e={e:t,target:this._dragSource,dragSource:this._dragSource,dropTarget:this._draggedoverTarget};this.fire("drag",e),this._dragSource&&this._dragSource.fire("drag",e)}findDragTargets(t){return this.targets=[],{target:this._searchPossibleTargets(this._objects,this.getViewportPoint(t)),targets:[...this.targets]}}_onDragOver(t){const e="dragover",{target:i,targets:s}=this.findDragTargets(t),r=this._dragSource,n={e:t,target:i,subTargets:s,dragSource:r,canDrop:!1,dropTarget:void 0};let o;this.fire(e,n),this._fireEnterLeaveEvents(i,n),i&&(i.canDrop(t)&&(o=i),i.fire(e,n));for(let a=0;a<s.length;a++){const i=s[a];i.canDrop(t)&&(o=i),i.fire(e,n)}this._renderDragEffects(t,r,o),this._dropTarget=o}_onDragEnter(t){const{target:e,targets:i}=this.findDragTargets(t),s={e:t,target:e,subTargets:i,dragSource:this._dragSource};this.fire("dragenter",s),this._fireEnterLeaveEvents(e,s)}_onDragLeave(t){const e={e:t,target:this._draggedoverTarget,subTargets:this.targets,dragSource:this._dragSource};this.fire("dragleave",e),this._fireEnterLeaveEvents(void 0,e),this._renderDragEffects(t,this._dragSource),this._dropTarget=void 0,this.targets=[],this._hoveredTargets=[]}_onDrop(t){const{target:e,targets:i}=this.findDragTargets(t),s=this._basicEventHandler("drop:before",xt({e:t,target:e,subTargets:i,dragSource:this._dragSource},Xn(this,t)));s.didDrop=!1,s.dropTarget=void 0,this._basicEventHandler("drop",s),this.fire("drop:after",s)}_onContextMenu(t){const e=this.findTarget(t),i=this.targets||[],s=this._basicEventHandler("contextmenu:before",{e:t,target:e,subTargets:i});return this.stopContextMenu&&ki(t),this._basicEventHandler("contextmenu",s),!1}_onDoubleClick(t){this._cacheTransformEventData(t),this._handleEvent(t,"dblclick"),this._resetTransformEventData()}getPointerId(t){const e=t.changedTouches;return e?e[0]&&e[0].identifier:this.enablePointerEvents?t.pointerId:-1}_isMainEvent(t){return!0===t.isPrimary||!1!==t.isPrimary&&("touchend"===t.type&&0===t.touches.length||!t.changedTouches||t.changedTouches[0].identifier===this.mainTouchId)}_onTouchStart(t){let e=!this.allowTouchScrolling;const i=this._activeObject;void 0===this.mainTouchId&&(this.mainTouchId=this.getPointerId(t)),this.__onMouseDown(t),(this.isDrawingMode||i&&this._target===i)&&(e=!0),e&&t.preventDefault(),this._resetTransformEventData();const s=this.upperCanvasEl,r=this._getEventPrefix(),n=_i(s);Un(n,"touchend",this._onTouchEnd,Hn),e&&Un(n,"touchmove",this._onMouseMove,Hn),Yn(s,"".concat(r,"down"),this._onMouseDown)}_onMouseDown(t){this.__onMouseDown(t),this._resetTransformEventData();const e=this.upperCanvasEl,i=this._getEventPrefix();Yn(e,"".concat(i,"move"),this._onMouseMove,Hn);const s=_i(e);Un(s,"".concat(i,"up"),this._onMouseUp),Un(s,"".concat(i,"move"),this._onMouseMove,Hn)}_onTouchEnd(t){if(t.touches.length>0)return;this.__onMouseUp(t),this._resetTransformEventData(),delete this.mainTouchId;const e=this._getEventPrefix(),i=_i(this.upperCanvasEl);Yn(i,"touchend",this._onTouchEnd,Hn),Yn(i,"touchmove",this._onMouseMove,Hn),this._willAddMouseDown&&clearTimeout(this._willAddMouseDown),this._willAddMouseDown=setTimeout((()=>{Un(this.upperCanvasEl,"".concat(e,"down"),this._onMouseDown),this._willAddMouseDown=0}),400)}_onMouseUp(t){this.__onMouseUp(t),this._resetTransformEventData();const e=this.upperCanvasEl,i=this._getEventPrefix();if(this._isMainEvent(t)){const t=_i(this.upperCanvasEl);Yn(t,"".concat(i,"up"),this._onMouseUp),Yn(t,"".concat(i,"move"),this._onMouseMove,Hn),Un(e,"".concat(i,"move"),this._onMouseMove,Hn)}}_onMouseMove(t){const e=this.getActiveObject();!this.allowTouchScrolling&&(!e||!e.shouldStartDragging(t))&&t.preventDefault&&t.preventDefault(),this.__onMouseMove(t)}_onResize(){this.calcOffset(),this._resetTransformEventData()}_shouldRender(t){const e=this.getActiveObject();return!!e!=!!t||e&&t&&e!==t}__onMouseUp(t){var e;this._cacheTransformEventData(t),this._handleEvent(t,"up:before");const i=this._currentTransform,s=this._isClick,r=this._target,{button:n}=t;if(n)return(this.fireMiddleClick&&1===n||this.fireRightClick&&2===n)&&this._handleEvent(t,"up"),void this._resetTransformEventData();if(this.isDrawingMode&&this._isCurrentlyDrawing)return void this._onMouseUpInDrawingMode(t);if(!this._isMainEvent(t))return;let o,a,l=!1;if(i&&(this._finalizeCurrentTransform(t),l=i.actionPerformed),!s){const e=r===this._activeObject;this.handleSelection(t),l||(l=this._shouldRender(r)||!e&&r===this._activeObject)}if(r){const e=r.findControl(this.getViewportPoint(t),Ei(t)),{key:s,control:n}=e||{};if(a=s,r.selectable&&r!==this._activeObject&&"up"===r.activeOn)this.setActiveObject(r,t),l=!0;else if(n){const e=n.getMouseUpHandler(t,r,n);e&&(o=this.getScenePoint(t),e.call(n,t,i,o.x,o.y))}r.isMoving=!1}if(i&&(i.target!==r||i.corner!==a)){const e=i.target&&i.target.controls[i.corner],s=e&&e.getMouseUpHandler(t,i.target,e);o=o||this.getScenePoint(t),s&&s.call(e,t,i,o.x,o.y)}this._setCursorFromEvent(t,r),this._handleEvent(t,"up"),this._groupSelector=null,this._currentTransform=null,r&&(r.__corner=void 0),l?this.requestRenderAll():s||null!==(e=this._activeObject)&&void 0!==e&&e.isEditing||this.renderTop()}_basicEventHandler(t,e){const{target:i,subTargets:s=[]}=e;this.fire(t,e),i&&i.fire(t,e);for(let r=0;r<s.length;r++)s[r]!==i&&s[r].fire(t,e);return e}_handleEvent(t,e){const i=this._target,s=this.targets||[],r=xt(xt({e:t,target:i,subTargets:s},Xn(this,t)),{},{transform:this._currentTransform},"up:before"===e||"up"===e?{isClick:this._isClick,currentTarget:this.findTarget(t),currentSubTargets:this.targets}:{});this.fire("mouse:".concat(e),r),i&&i.fire("mouse".concat(e),r);for(let n=0;n<s.length;n++)s[n]!==i&&s[n].fire("mouse".concat(e),r)}_onMouseDownInDrawingMode(t){this._isCurrentlyDrawing=!0,this.getActiveObject()&&(this.discardActiveObject(t),this.requestRenderAll());const e=this.getScenePoint(t);this.freeDrawingBrush&&this.freeDrawingBrush.onMouseDown(e,{e:t,pointer:e}),this._handleEvent(t,"down")}_onMouseMoveInDrawingMode(t){if(this._isCurrentlyDrawing){const e=this.getScenePoint(t);this.freeDrawingBrush&&this.freeDrawingBrush.onMouseMove(e,{e:t,pointer:e})}this.setCursor(this.freeDrawingCursor),this._handleEvent(t,"move")}_onMouseUpInDrawingMode(t){const e=this.getScenePoint(t);this.freeDrawingBrush?this._isCurrentlyDrawing=!!this.freeDrawingBrush.onMouseUp({e:t,pointer:e}):this._isCurrentlyDrawing=!1,this._handleEvent(t,"up")}__onMouseDown(t){this._isClick=!0,this._cacheTransformEventData(t),this._handleEvent(t,"down:before");let e=this._target;const{button:i}=t;if(i)return(this.fireMiddleClick&&1===i||this.fireRightClick&&2===i)&&this._handleEvent(t,"down"),void this._resetTransformEventData();if(this.isDrawingMode)return void this._onMouseDownInDrawingMode(t);if(!this._isMainEvent(t))return;if(this._currentTransform)return;let s=this._shouldRender(e),r=!1;if(this.handleMultiSelection(t,e)?(e=this._activeObject,r=!0,s=!0):this._shouldClearSelection(t,e)&&this.discardActiveObject(t),this.selection&&(!e||!e.selectable&&!e.isEditing&&e!==this._activeObject)){const e=this.getScenePoint(t);this._groupSelector={x:e.x,y:e.y,deltaY:0,deltaX:0}}if(e){const i=e===this._activeObject;e.selectable&&"down"===e.activeOn&&this.setActiveObject(e,t);const s=e.findControl(this.getViewportPoint(t),Ei(t));if(e===this._activeObject&&(s||!r)){this._setupCurrentTransform(t,e,i);const r=s?s.control:void 0,n=this.getScenePoint(t),o=r&&r.getMouseDownHandler(t,e,r);o&&o.call(r,t,this._currentTransform,n.x,n.y)}}s&&(this._objectsToRender=void 0),this._handleEvent(t,"down"),s&&this.requestRenderAll()}_resetTransformEventData(){this._target=this._pointer=this._absolutePointer=void 0}_cacheTransformEventData(t){this._resetTransformEventData(),this._pointer=this.getViewportPoint(t),this._absolutePointer=Fi(this._pointer,void 0,this.viewportTransform),this._target=this._currentTransform?this._currentTransform.target:this.findTarget(t)}__onMouseMove(t){if(this._isClick=!1,this._cacheTransformEventData(t),this._handleEvent(t,"move:before"),this.isDrawingMode)return void this._onMouseMoveInDrawingMode(t);if(!this._isMainEvent(t))return;const e=this._groupSelector;if(e){const i=this.getScenePoint(t);e.deltaX=i.x-e.x,e.deltaY=i.y-e.y,this.renderTop()}else if(this._currentTransform)this._transformObject(t);else{const e=this.findTarget(t);this._setCursorFromEvent(t,e),this._fireOverOutEvents(t,e)}this.textEditingManager.onMouseMove(t),this._handleEvent(t,"move"),this._resetTransformEventData()}_fireOverOutEvents(t,e){const i=this._hoveredTarget,s=this._hoveredTargets,r=this.targets,n=Math.max(s.length,r.length);this.fireSyntheticInOutEvents("mouse",{e:t,target:e,oldTarget:i,fireCanvas:!0});for(let o=0;o<n;o++)this.fireSyntheticInOutEvents("mouse",{e:t,target:r[o],oldTarget:s[o]});this._hoveredTarget=e,this._hoveredTargets=this.targets.concat()}_fireEnterLeaveEvents(t,e){const i=this._draggedoverTarget,s=this._hoveredTargets,r=this.targets,n=Math.max(s.length,r.length);this.fireSyntheticInOutEvents("drag",xt(xt({},e),{},{target:t,oldTarget:i,fireCanvas:!0}));for(let o=0;o<n;o++)this.fireSyntheticInOutEvents("drag",xt(xt({},e),{},{target:r[o],oldTarget:s[o]}));this._draggedoverTarget=t}fireSyntheticInOutEvents(t,e){let{target:i,oldTarget:s,fireCanvas:r,e:n}=e,o=wt(e,Wn);const{targetIn:a,targetOut:l,canvasIn:c,canvasOut:h}=Gn[t],d=s!==i;if(s&&d){const t=xt(xt({},o),{},{e:n,target:s,nextTarget:i},Xn(this,n));r&&this.fire(h,t),s.fire(l,t)}if(i&&d){const t=xt(xt({},o),{},{e:n,target:i,previousTarget:s},Xn(this,n));r&&this.fire(c,t),i.fire(a,t)}}__onMouseWheel(t){this._cacheTransformEventData(t),this._handleEvent(t,"wheel"),this._resetTransformEventData()}_transformObject(t){const e=this.getScenePoint(t),i=this._currentTransform,s=i.target,r=s.group?Fi(e,void 0,s.group.calcTransformMatrix()):e;i.shiftKey=t.shiftKey,i.altKey=!!this.centeredKey&&t[this.centeredKey],this._performTransformAction(t,i,r),i.actionPerformed&&this.requestRenderAll()}_performTransformAction(t,e,i){const{action:s,actionHandler:r,target:n}=e,o=!!r&&r(t,e,i.x,i.y);o&&n.setCoords(),"drag"===s&&o&&(e.target.isMoving=!0,this.setCursor(e.target.moveCursor||this.moveCursor)),e.actionPerformed=e.actionPerformed||o}_setCursorFromEvent(t,e){if(!e)return void this.setCursor(this.defaultCursor);let i=e.hoverCursor||this.hoverCursor;const s=mi(this._activeObject)?this._activeObject:null,r=(!s||e.group!==s)&&e.findControl(this.getViewportPoint(t));if(r){const i=r.control;this.setCursor(i.cursorStyleHandler(t,i,e))}else e.subTargetCheck&&this.targets.concat().reverse().map((t=>{i=t.hoverCursor||i})),this.setCursor(i)}handleMultiSelection(t,e){const i=this._activeObject,s=mi(i);if(i&&this._isSelectionKeyPressed(t)&&this.selection&&e&&e.selectable&&(i!==e||s)&&(s||!e.isDescendantOf(i)&&!i.isDescendantOf(e))&&!e.onSelect({e:t})&&!i.getActiveControl()){if(s){const s=i.getObjects();if(e===i){const i=this.getViewportPoint(t);if(!(e=this.searchPossibleTargets(s,i)||this.searchPossibleTargets(this._objects,i))||!e.selectable)return!1}e.group===i?(i.remove(e),this._hoveredTarget=e,this._hoveredTargets=[...this.targets],1===i.size()&&this._setActiveObject(i.item(0),t)):(i.multiSelectAdd(e),this._hoveredTarget=i,this._hoveredTargets=[...this.targets]),this._fireSelectionEvents(s,t)}else{i.isEditing&&i.exitEditing();const s=new(_e.getClass("ActiveSelection"))([],{canvas:this});s.multiSelectAdd(i,e),this._hoveredTarget=s,this._setActiveObject(s,t),this._fireSelectionEvents([i],t)}return!0}return!1}handleSelection(t){if(!this.selection||!this._groupSelector)return!1;const{x:e,y:i,deltaX:s,deltaY:r}=this._groupSelector,n=new Se(e,i),o=n.add(new Se(s,r)),a=n.min(o),l=n.max(o).subtract(a),c=this.collectObjects({left:a.x,top:a.y,width:l.x,height:l.y},{includeIntersecting:!this.selectionFullyContained}),h=n.eq(o)?c[0]?[c[0]]:[]:c.length>1?c.filter((e=>!e.onSelect({e:t}))).reverse():c;if(1===h.length)this.setActiveObject(h[0],t);else if(h.length>1){const e=_e.getClass("ActiveSelection");this.setActiveObject(new e(h,{canvas:this}),t)}return this._groupSelector=null,!0}clear(){this.textEditingManager.clear(),super.clear()}destroy(){this.removeListeners(),this.textEditingManager.dispose(),super.destroy()}}const Kn={x1:0,y1:0,x2:0,y2:0},Jn=xt(xt({},Kn),{},{r1:0,r2:0}),Zn=(t,e)=>isNaN(t)&&"number"==typeof e?e:t,Qn=/^(\d+\.\d+)%|(\d+)%$/;function to(t){return t&&Qn.test(t)}function eo(t,e){const i="number"==typeof t?t:"string"==typeof t?parseFloat(t)/(to(t)?100:1):NaN;return ms(0,Zn(i,e),1)}const io=/\s*;\s*/,so=/\s*:\s*/;function ro(t,e){let i,s;const r=t.getAttribute("style");if(r){const t=r.split(io);""===t[t.length-1]&&t.pop();for(let e=t.length;e--;){const[r,n]=t[e].split(so).map((t=>t.trim()));"stop-color"===r?i=n:"stop-opacity"===r&&(s=n)}}const n=new li(i||t.getAttribute("stop-color")||"rgb(0,0,0)");return{offset:eo(t.getAttribute("offset"),0),color:n.toRgb(),opacity:Zn(parseFloat(s||t.getAttribute("stop-opacity")||""),1)*n.getAlpha()*e}}function no(t,e){const i=[],s=t.getElementsByTagName("stop"),r=eo(e,1);for(let n=s.length;n--;)i.push(ro(s[n],r));return i}function oo(t){return"linearGradient"===t.nodeName||"LINEARGRADIENT"===t.nodeName?"linear":"radial"}function ao(t){return"userSpaceOnUse"===t.getAttribute("gradientUnits")?"pixels":"percentage"}function lo(t,e){return t.getAttribute(e)}function co(t,e){return function(t,e){let i,{width:s,height:r,gradientUnits:n}=e;return Object.keys(t).reduce(((e,o)=>{const a=t[o];return"Infinity"===a?i=1:"-Infinity"===a?i=0:(i="string"==typeof a?parseFloat(a):a,"string"==typeof a&&to(a)&&(i*=.01,"pixels"===n&&("x1"!==o&&"x2"!==o&&"r2"!==o||(i*=s),"y1"!==o&&"y2"!==o||(i*=r)))),e[o]=i,e}),{})}("linear"===oo(t)?{x1:lo(i=t,"x1")||0,y1:lo(i,"y1")||0,x2:lo(i,"x2")||"100%",y2:lo(i,"y2")||0}:function(t){return{x1:lo(t,"fx")||lo(t,"cx")||"50%",y1:lo(t,"fy")||lo(t,"cy")||"50%",r1:0,x2:lo(t,"cx")||"50%",y2:lo(t,"cy")||"50%",r2:lo(t,"r")||"50%"}}(t),xt(xt({},e),{},{gradientUnits:ao(t)}));var i}class ho{constructor(t){const{type:e="linear",gradientUnits:i="pixels",coords:s={},colorStops:r=[],offsetX:n=0,offsetY:o=0,gradientTransform:a,id:l}=t||{};Object.assign(this,{type:e,gradientUnits:i,coords:xt(xt({},"radial"===e?Jn:Kn),s),colorStops:r,offsetX:n,offsetY:o,gradientTransform:a,id:l?"".concat(l,"_").concat(Me()):Me()})}addColorStop(t){for(const e in t){const i=new li(t[e]);this.colorStops.push({offset:parseFloat(e),color:i.toRgb(),opacity:i.getAlpha()})}return this}toObject(t){return xt(xt({},ti(this,t)),{},{type:this.type,coords:xt({},this.coords),colorStops:this.colorStops.map((t=>xt({},t))),offsetX:this.offsetX,offsetY:this.offsetY,gradientUnits:this.gradientUnits,gradientTransform:this.gradientTransform?[...this.gradientTransform]:void 0})}toSVG(t){let{additionalTransform:e}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const i=[],s=this.gradientTransform?this.gradientTransform.concat():Wt.concat(),r="pixels"===this.gradientUnits?"userSpaceOnUse":"objectBoundingBox",n=this.colorStops.map((t=>xt({},t))).sort(((t,e)=>t.offset-e.offset));let o=-this.offsetX,a=-this.offsetY;var l;"objectBoundingBox"===r?(o/=t.width,a/=t.height):(o+=t.width/2,a+=t.height/2),(l=t)&&"function"==typeof l._renderPathCommands&&"percentage"!==this.gradientUnits&&(o-=t.pathOffset.x,a-=t.pathOffset.y),s[4]-=o,s[5]-=a;const c=['id="SVGID_'.concat(this.id,'"'),'gradientUnits="'.concat(r,'"'),'gradientTransform="'.concat(e?e+" ":"").concat(di(s),'"'),""].join(" ");if("linear"===this.type){const{x1:t,y1:e,x2:s,y2:r}=this.coords;i.push("<linearGradient ",c,' x1="',t,'" y1="',e,'" x2="',s,'" y2="',r,'">\n')}else if("radial"===this.type){const{x1:t,y1:e,x2:s,y2:r,r1:o,r2:a}=this.coords,l=o>a;i.push("<radialGradient ",c,' cx="',l?t:s,'" cy="',l?e:r,'" r="',l?o:a,'" fx="',l?s:t,'" fy="',l?r:e,'">\n'),l&&(n.reverse(),n.forEach((t=>{t.offset=1-t.offset})));const h=Math.min(o,a);if(h>0){const t=h/Math.max(o,a);n.forEach((e=>{e.offset+=t*(1-e.offset)}))}}return n.forEach((t=>{let{color:e,offset:s,opacity:r}=t;i.push("<stop ",'offset="',100*s+"%",'" style="stop-color:',e,void 0!==r?";stop-opacity: "+r:";",'"/>\n')})),i.push("linear"===this.type?"</linearGradient>":"</radialGradient>","\n"),i.join("")}toLive(t){const{x1:e,y1:i,x2:s,y2:r,r1:n,r2:o}=this.coords,a="linear"===this.type?t.createLinearGradient(e,i,s,r):t.createRadialGradient(e,i,n,s,r,o);return this.colorStops.forEach((t=>{let{color:e,opacity:i,offset:s}=t;a.addColorStop(s,void 0!==i?new li(e).setAlpha(i).toRgba():e)})),a}static async fromObject(t){const{colorStops:e,gradientTransform:i}=t;return new this(xt(xt({},t),{},{colorStops:e?e.map((t=>xt({},t))):void 0,gradientTransform:i?[...i]:void 0}))}static fromElement(t,e,i){const s=ao(t),r=e._findCenterFromElement();return new this(xt({id:t.getAttribute("id")||void 0,type:oo(t),coords:co(t,{width:i.viewBoxWidth||i.width,height:i.viewBoxHeight||i.height}),colorStops:no(t,i.opacity),gradientUnits:s,gradientTransform:Gr(t.getAttribute("gradientTransform")||"")},"pixels"===s?{offsetX:e.width/2-r.x,offsetY:e.height/2-r.y}:{offsetX:0,offsetY:0}))}}bt(ho,"type","Gradient"),_e.setClass(ho,"gradient"),_e.setClass(ho,"linear"),_e.setClass(ho,"radial");const uo=["type","source","patternTransform"];class po{get type(){return"pattern"}set type(t){Ot("warn","Setting type has no effect",t)}constructor(t){bt(this,"repeat","repeat"),bt(this,"offsetX",0),bt(this,"offsetY",0),bt(this,"crossOrigin",""),this.id=Me(),Object.assign(this,t)}isImageSource(){return!!this.source&&"string"==typeof this.source.src}isCanvasSource(){return!!this.source&&!!this.source.toDataURL}sourceToString(){return this.isImageSource()?this.source.src:this.isCanvasSource()?this.source.toDataURL():""}toLive(t){return this.source&&(!this.isImageSource()||this.source.complete&&0!==this.source.naturalWidth&&0!==this.source.naturalHeight)?t.createPattern(this.source,this.repeat):null}toObject(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];const{repeat:e,crossOrigin:i}=this;return xt(xt({},ti(this,t)),{},{type:"pattern",source:this.sourceToString(),repeat:e,crossOrigin:i,offsetX:ci(this.offsetX,Tt.NUM_FRACTION_DIGITS),offsetY:ci(this.offsetY,Tt.NUM_FRACTION_DIGITS),patternTransform:this.patternTransform?[...this.patternTransform]:null})}toSVG(t){let{width:e,height:i}=t;const{source:s,repeat:r,id:n}=this,o=Zn(this.offsetX/e,0),a=Zn(this.offsetY/i,0),l="repeat-y"===r||"no-repeat"===r?1+Math.abs(o||0):Zn(s.width/e,0),c="repeat-x"===r||"no-repeat"===r?1+Math.abs(a||0):Zn(s.height/i,0);return['<pattern id="SVGID_'.concat(n,'" x="').concat(o,'" y="').concat(a,'" width="').concat(l,'" height="').concat(c,'">'),'<image x="0" y="0" width="'.concat(s.width,'" height="').concat(s.height,'" xlink:href="').concat(this.sourceToString(),'"></image>'),"</pattern>",""].join("\n")}static async fromObject(t,e){let{type:i,source:s,patternTransform:r}=t,n=wt(t,uo);const o=await Je(s,xt(xt({},e),{},{crossOrigin:n.crossOrigin}));return new this(xt(xt({},n),{},{patternTransform:r&&r.slice(0),source:o}))}}bt(po,"type","Pattern"),_e.setClass(po),_e.setClass(po,"pattern");const go=["path","left","top"],fo=["d"];class mo extends ur{constructor(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},{path:i,left:s,top:r}=e,n=wt(e,go);super(),Object.assign(this,mo.ownDefaults),this.setOptions(n),this._setPath(t||[],!0),"number"==typeof s&&this.set(Yt,s),"number"==typeof r&&this.set(Gt,r)}_setPath(t,e){this.path=(t=>{let e=0,i=0,s=0,r=0;const n=[];let o,a=0,l=0;for(const c of t){const t=[...c];let h;switch(t[0]){case"l":t[1]+=e,t[2]+=i;case"L":e=t[1],i=t[2],h=["L",e,i];break;case"h":t[1]+=e;case"H":e=t[1],h=["L",e,i];break;case"v":t[1]+=i;case"V":i=t[1],h=["L",e,i];break;case"m":t[1]+=e,t[2]+=i;case"M":e=t[1],i=t[2],s=t[1],r=t[2],h=["M",e,i];break;case"c":t[1]+=e,t[2]+=i,t[3]+=e,t[4]+=i,t[5]+=e,t[6]+=i;case"C":a=t[3],l=t[4],e=t[5],i=t[6],h=["C",t[1],t[2],a,l,e,i];break;case"s":t[1]+=e,t[2]+=i,t[3]+=e,t[4]+=i;case"S":"C"===o?(a=2*e-a,l=2*i-l):(a=e,l=i),e=t[3],i=t[4],h=["C",a,l,t[1],t[2],e,i],a=h[3],l=h[4];break;case"q":t[1]+=e,t[2]+=i,t[3]+=e,t[4]+=i;case"Q":a=t[1],l=t[2],e=t[3],i=t[4],h=["Q",a,l,e,i];break;case"t":t[1]+=e,t[2]+=i;case"T":"Q"===o?(a=2*e-a,l=2*i-l):(a=e,l=i),e=t[1],i=t[2],h=["Q",a,l,e,i];break;case"a":t[6]+=e,t[7]+=i;case"A":Cn(e,i,t).forEach((t=>n.push(t))),e=t[6],i=t[7];break;case"z":case"Z":e=s,i=r,h=["Z"]}h?(n.push(h),o=h[0]):o=""}return n})(Array.isArray(t)?t:(t=>{var e;const i=[],s=null!==(e=t.match(Fn))&&void 0!==e?e:[];for(const r of s){const t=r[0];if("z"===t||"Z"===t){i.push([t]);continue}const e=Bn[t.toLowerCase()];let s=[];if("a"===t||"A"===t){In.lastIndex=0;for(let t=null;t=In.exec(r);)s.push(...t.slice(1))}else s=r.match(Rn)||[];for(let r=0;r<s.length;r+=e){const n=new Array(e),o=bn[t];n[0]=r>0&&o?o:t;for(let t=0;t<e;t++)n[t+1]=parseFloat(s[r+t]);i.push(n)}}return i})(t)),this.setBoundingBox(e)}_findCenterFromElement(){const t=this._calcBoundsFromPath();return new Se(t.left+t.width/2,t.top+t.height/2)}_renderPathCommands(t){const e=-this.pathOffset.x,i=-this.pathOffset.y;t.beginPath();for(const s of this.path)switch(s[0]){case"L":t.lineTo(s[1]+e,s[2]+i);break;case"M":t.moveTo(s[1]+e,s[2]+i);break;case"C":t.bezierCurveTo(s[1]+e,s[2]+i,s[3]+e,s[4]+i,s[5]+e,s[6]+i);break;case"Q":t.quadraticCurveTo(s[1]+e,s[2]+i,s[3]+e,s[4]+i);break;case"Z":t.closePath()}}_render(t){this._renderPathCommands(t),this._renderPaintInOrder(t)}toString(){return"#<Path (".concat(this.complexity(),'): { "top": ').concat(this.top,', "left": ').concat(this.left," }>")}toObject(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];return xt(xt({},super.toObject(t)),{},{path:this.path.map((t=>t.slice()))})}toDatalessObject(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];const e=this.toObject(t);return this.sourcePath&&(delete e.path,e.sourcePath=this.sourcePath),e}_toSVG(){const t=((t,e)=>t.map((t=>t.map(((t,i)=>0===i||void 0===e?t:ci(t,e))).join(" "))).join(" "))(this.path,Tt.NUM_FRACTION_DIGITS);return["<path ","COMMON_PARTS",'d="'.concat(t,'" stroke-linecap="round" />\n')]}_getOffsetTransform(){const t=Tt.NUM_FRACTION_DIGITS;return" translate(".concat(ci(-this.pathOffset.x,t),", ").concat(ci(-this.pathOffset.y,t),")")}toClipPathSVG(t){const e=this._getOffsetTransform();return"\t"+this._createBaseClipPathSVGMarkup(this._toSVG(),{reviver:t,additionalTransform:e})}toSVG(t){const e=this._getOffsetTransform();return this._createBaseSVGMarkup(this._toSVG(),{reviver:t,additionalTransform:e})}complexity(){return this.path.length}setDimensions(){this.setBoundingBox()}setBoundingBox(t){const{width:e,height:i,pathOffset:s}=this._calcDimensions();this.set({width:e,height:i,pathOffset:s}),t&&this.setPositionByOrigin(s,Ut,Ut)}_calcBoundsFromPath(){const t=[];let e=0,i=0,s=0,r=0;for(const n of this.path)switch(n[0]){case"L":s=n[1],r=n[2],t.push({x:e,y:i},{x:s,y:r});break;case"M":s=n[1],r=n[2],e=s,i=r;break;case"C":t.push(...wn(s,r,n[1],n[2],n[3],n[4],n[5],n[6])),s=n[5],r=n[6];break;case"Q":t.push(...wn(s,r,n[1],n[2],n[1],n[2],n[3],n[4])),s=n[3],r=n[4];break;case"Z":s=e,r=i}return Di(t)}_calcDimensions(){const t=this._calcBoundsFromPath();return xt(xt({},t),{},{pathOffset:new Se(t.left+t.width/2,t.top+t.height/2)})}static fromObject(t){return this._fromObject(t,{extraParam:"path"})}static async fromElement(t,e,i){const s=Jr(t,this.ATTRIBUTE_NAMES,i),{d:r}=s;return new this(r,xt(xt(xt({},wt(s,fo)),e),{},{left:void 0,top:void 0}))}}bt(mo,"type","Path"),bt(mo,"cacheProperties",[..._s,"path","fillRule"]),bt(mo,"ATTRIBUTE_NAMES",[...Cr,"d"]),_e.setClass(mo),_e.setSVGClass(mo);const vo=["left","top","radius"],_o=["radius","startAngle","endAngle","counterClockwise"];class bo extends ur{static getDefaults(){return xt(xt({},super.getDefaults()),bo.ownDefaults)}constructor(t){super(),Object.assign(this,bo.ownDefaults),this.setOptions(t)}_set(t,e){return super._set(t,e),"radius"===t&&this.setRadius(e),this}_render(t){t.beginPath(),t.arc(0,0,this.radius,Fe(this.startAngle),Fe(this.endAngle),this.counterClockwise),this._renderPaintInOrder(t)}getRadiusX(){return this.get("radius")*this.get(ce)}getRadiusY(){return this.get("radius")*this.get(he)}setRadius(t){this.radius=t,this.set({width:2*t,height:2*t})}toObject(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];return super.toObject([..._o,...t])}_toSVG(){const t=(this.endAngle-this.startAngle)%360;if(0===t)return["<circle ","COMMON_PARTS",'cx="0" cy="0" ','r="',"".concat(this.radius),'" />\n'];{const{radius:e}=this,i=Fe(this.startAngle),s=Fe(this.endAngle),r=we(i)*e,n=Ce(i)*e,o=we(s)*e,a=Ce(s)*e,l=t>180?1:0,c=this.counterClockwise?0:1;return['<path d="M '.concat(r," ").concat(n," A ").concat(e," ").concat(e," 0 ").concat(l," ").concat(c," ").concat(o," ").concat(a,'" '),"COMMON_PARTS"," />\n"]}}static async fromElement(t,e,i){const s=Jr(t,this.ATTRIBUTE_NAMES,i),{left:r=0,top:n=0,radius:o=0}=s;return new this(xt(xt({},wt(s,vo)),{},{radius:o,left:r-o,top:n-o}))}static fromObject(t){return super._fromObject(t)}}bt(bo,"type","Circle"),bt(bo,"cacheProperties",[..._s,..._o]),bt(bo,"ownDefaults",{radius:0,startAngle:0,endAngle:360,counterClockwise:!1}),bt(bo,"ATTRIBUTE_NAMES",["cx","cy","r",...Cr]),_e.setClass(bo),_e.setSVGClass(bo);const yo=["x1","y1","x2","y2"],xo=["x1","y1","x2","y2"],wo=["x1","x2","y1","y2"];class Co extends ur{constructor(){let[t,e,i,s]=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[0,0,0,0],r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};super(),Object.assign(this,Co.ownDefaults),this.setOptions(r),this.x1=t,this.x2=i,this.y1=e,this.y2=s,this._setWidthHeight();const{left:n,top:o}=r;"number"==typeof n&&this.set(Yt,n),"number"==typeof o&&this.set(Gt,o)}_setWidthHeight(){const{x1:t,y1:e,x2:i,y2:s}=this;this.width=Math.abs(i-t),this.height=Math.abs(s-e);const{left:r,top:n,width:o,height:a}=Di([{x:t,y:e},{x:i,y:s}]),l=new Se(r+o/2,n+a/2);this.setPositionByOrigin(l,Ut,Ut)}_set(t,e){return super._set(t,e),wo.includes(t)&&this._setWidthHeight(),this}_render(t){t.beginPath();const e=this.calcLinePoints();t.moveTo(e.x1,e.y1),t.lineTo(e.x2,e.y2),t.lineWidth=this.strokeWidth;const i=t.strokeStyle;var s;pi(this.stroke)?t.strokeStyle=this.stroke.toLive(t):t.strokeStyle=null!==(s=this.stroke)&&void 0!==s?s:t.fillStyle,this.stroke&&this._renderStroke(t),t.strokeStyle=i}_findCenterFromElement(){return new Se((this.x1+this.x2)/2,(this.y1+this.y2)/2)}toObject(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];return xt(xt({},super.toObject(t)),this.calcLinePoints())}_getNonTransformedDimensions(){const t=super._getNonTransformedDimensions();return"butt"===this.strokeLineCap&&(0===this.width&&(t.y-=this.strokeWidth),0===this.height&&(t.x-=this.strokeWidth)),t}calcLinePoints(){const{x1:t,x2:e,y1:i,y2:s,width:r,height:n}=this,o=t<=e?-1:1,a=i<=s?-1:1;return{x1:o*r/2,x2:o*-r/2,y1:a*n/2,y2:a*-n/2}}_toSVG(){const{x1:t,x2:e,y1:i,y2:s}=this.calcLinePoints();return["<line ","COMMON_PARTS",'x1="'.concat(t,'" y1="').concat(i,'" x2="').concat(e,'" y2="').concat(s,'" />\n')]}static async fromElement(t,e,i){const s=Jr(t,this.ATTRIBUTE_NAMES,i),{x1:r=0,y1:n=0,x2:o=0,y2:a=0}=s;return new this([r,n,o,a],wt(s,yo))}static fromObject(t){let{x1:e,y1:i,x2:s,y2:r}=t,n=wt(t,xo);return this._fromObject(xt(xt({},n),{},{points:[e,i,s,r]}),{extraParam:"points"})}}bt(Co,"type","Line"),bt(Co,"cacheProperties",[..._s,...wo]),bt(Co,"ATTRIBUTE_NAMES",Cr.concat(wo)),_e.setClass(Co),_e.setSVGClass(Co);class So extends ur{static getDefaults(){return xt(xt({},super.getDefaults()),So.ownDefaults)}constructor(t){super(),Object.assign(this,So.ownDefaults),this.setOptions(t)}_render(t){const e=this.width/2,i=this.height/2;t.beginPath(),t.moveTo(-e,i),t.lineTo(0,-i),t.lineTo(e,i),t.closePath(),this._renderPaintInOrder(t)}_toSVG(){const t=this.width/2,e=this.height/2;return["<polygon ","COMMON_PARTS",'points="',"".concat(-t," ").concat(e,",0 ").concat(-e,",").concat(t," ").concat(e),'" />']}}bt(So,"type","Triangle"),bt(So,"ownDefaults",{width:100,height:100}),_e.setClass(So),_e.setSVGClass(So);const To=["rx","ry"];class Oo extends ur{static getDefaults(){return xt(xt({},super.getDefaults()),Oo.ownDefaults)}constructor(t){super(),Object.assign(this,Oo.ownDefaults),this.setOptions(t)}_set(t,e){switch(super._set(t,e),t){case"rx":this.rx=e,this.set("width",2*e);break;case"ry":this.ry=e,this.set("height",2*e)}return this}getRx(){return this.get("rx")*this.get(ce)}getRy(){return this.get("ry")*this.get(he)}toObject(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];return super.toObject([...To,...t])}_toSVG(){return["<ellipse ","COMMON_PARTS",'cx="0" cy="0" rx="'.concat(this.rx,'" ry="').concat(this.ry,'" />\n')]}_render(t){t.beginPath(),t.save(),t.transform(1,0,0,this.ry/this.rx,0,0),t.arc(0,0,this.rx,0,Vt,!1),t.restore(),this._renderPaintInOrder(t)}static async fromElement(t,e,i){const s=Jr(t,this.ATTRIBUTE_NAMES,i);return s.left=(s.left||0)-s.rx,s.top=(s.top||0)-s.ry,new this(s)}}bt(Oo,"type","Ellipse"),bt(Oo,"cacheProperties",[..._s,...To]),bt(Oo,"ownDefaults",{rx:0,ry:0}),bt(Oo,"ATTRIBUTE_NAMES",[...Cr,"cx","cy","rx","ry"]),_e.setClass(Oo),_e.setSVGClass(Oo);const Eo=["left","top"],ko={exactBoundingBox:!1};class Do extends ur{static getDefaults(){return xt(xt({},super.getDefaults()),Do.ownDefaults)}constructor(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};super(),bt(this,"strokeDiff",void 0),Object.assign(this,Do.ownDefaults),this.setOptions(e),this.points=t;const{left:i,top:s}=e;this.initialized=!0,this.setBoundingBox(!0),"number"==typeof i&&this.set(Yt,i),"number"==typeof s&&this.set(Gt,s)}isOpen(){return!0}_projectStrokeOnPoints(t){return function(t,e){let i=arguments.length>2&&void 0!==arguments[2]&&arguments[2];const s=[];if(0===t.length)return s;const r=t.reduce(((t,e)=>(t[t.length-1].eq(e)||t.push(new Se(e)),t)),[new Se(t[0])]);if(1===r.length)i=!0;else if(!i){const t=r[0],e=((t,e)=>{for(let i=t.length-1;i>=0;i--)if(e(t[i]))return i;return-1})(r,(e=>!e.eq(t)));r.splice(e+1)}return r.forEach(((t,r,n)=>{let o,a;0===r?(a=n[1],o=i?t:n[n.length-1]):r===n.length-1?(o=n[r-1],a=i?t:n[0]):(o=n[r-1],a=n[r+1]),i&&1===n.length?s.push(...new mr(t,t,e).project()):!i||0!==r&&r!==n.length-1?s.push(...new fr(t,o,a,e).project()):s.push(...new mr(t,0===r?a:o,e).project())})),s}(this.points,t,this.isOpen())}_calcDimensions(t){t=xt({scaleX:this.scaleX,scaleY:this.scaleY,skewX:this.skewX,skewY:this.skewY,strokeLineCap:this.strokeLineCap,strokeLineJoin:this.strokeLineJoin,strokeMiterLimit:this.strokeMiterLimit,strokeUniform:this.strokeUniform,strokeWidth:this.strokeWidth},t||{});const e=this.exactBoundingBox?this._projectStrokeOnPoints(t).map((t=>t.projectedPoint)):this.points;if(0===e.length)return{left:0,top:0,width:0,height:0,pathOffset:new Se,strokeOffset:new Se,strokeDiff:new Se};const i=Di(e),s=qe(xt(xt({},t),{},{scaleX:1,scaleY:1})),r=Di(this.points.map((t=>Re(t,s,!0)))),n=new Se(this.scaleX,this.scaleY);let o=i.left+i.width/2,a=i.top+i.height/2;return this.exactBoundingBox&&(o-=a*Math.tan(Fe(this.skewX)),a-=o*Math.tan(Fe(this.skewY))),xt(xt({},i),{},{pathOffset:new Se(o,a),strokeOffset:new Se(r.left,r.top).subtract(new Se(i.left,i.top)).multiply(n),strokeDiff:new Se(i.width,i.height).subtract(new Se(r.width,r.height)).multiply(n)})}_findCenterFromElement(){const t=Di(this.points);return new Se(t.left+t.width/2,t.top+t.height/2)}setDimensions(){this.setBoundingBox()}setBoundingBox(t){const{left:e,top:i,width:s,height:r,pathOffset:n,strokeOffset:o,strokeDiff:a}=this._calcDimensions();this.set({width:s,height:r,pathOffset:n,strokeOffset:o,strokeDiff:a}),t&&this.setPositionByOrigin(new Se(e+s/2,i+r/2),Ut,Ut)}isStrokeAccountedForInDimensions(){return this.exactBoundingBox}_getNonTransformedDimensions(){return this.exactBoundingBox?new Se(this.width,this.height):super._getNonTransformedDimensions()}_getTransformedDimensions(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(this.exactBoundingBox){let n;if(Object.keys(t).some((t=>this.strokeUniform||this.constructor.layoutProperties.includes(t)))){var e,i;const{width:s,height:r}=this._calcDimensions(t);n=new Se(null!==(e=t.width)&&void 0!==e?e:s,null!==(i=t.height)&&void 0!==i?i:r)}else{var s,r;n=new Se(null!==(s=t.width)&&void 0!==s?s:this.width,null!==(r=t.height)&&void 0!==r?r:this.height)}return n.multiply(new Se(t.scaleX||this.scaleX,t.scaleY||this.scaleY))}return super._getTransformedDimensions(t)}_set(t,e){const i=this.initialized&&this[t]!==e,s=super._set(t,e);return this.exactBoundingBox&&i&&((t===ce||t===he)&&this.strokeUniform&&this.constructor.layoutProperties.includes("strokeUniform")||this.constructor.layoutProperties.includes(t))&&this.setDimensions(),s}toObject(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];return xt(xt({},super.toObject(t)),{},{points:this.points.map((t=>{let{x:e,y:i}=t;return{x:e,y:i}}))})}_toSVG(){const t=[],e=this.pathOffset.x,i=this.pathOffset.y,s=Tt.NUM_FRACTION_DIGITS;for(let r=0,n=this.points.length;r<n;r++)t.push(ci(this.points[r].x-e,s),",",ci(this.points[r].y-i,s)," ");return["<".concat(this.constructor.type.toLowerCase()," "),"COMMON_PARTS",'points="'.concat(t.join(""),'" />\n')]}_render(t){const e=this.points.length,i=this.pathOffset.x,s=this.pathOffset.y;if(e&&!isNaN(this.points[e-1].y)){t.beginPath(),t.moveTo(this.points[0].x-i,this.points[0].y-s);for(let r=0;r<e;r++){const e=this.points[r];t.lineTo(e.x-i,e.y-s)}!this.isOpen()&&t.closePath(),this._renderPaintInOrder(t)}}complexity(){return this.points.length}static async fromElement(t,e,i){return new this(function(t){if(!t)return[];const e=t.replace(/,/g," ").trim().split(/\s+/),i=[];for(let s=0;s<e.length;s+=2)i.push({x:parseFloat(e[s]),y:parseFloat(e[s+1])});return i}(t.getAttribute("points")),xt(xt({},wt(Jr(t,this.ATTRIBUTE_NAMES,i),Eo)),e))}static fromObject(t){return this._fromObject(t,{extraParam:"points"})}}bt(Do,"ownDefaults",ko),bt(Do,"type","Polyline"),bt(Do,"layoutProperties",[de,ue,"strokeLineCap","strokeLineJoin","strokeMiterLimit","strokeWidth","strokeUniform","points"]),bt(Do,"cacheProperties",[..._s,"points"]),bt(Do,"ATTRIBUTE_NAMES",[...Cr]),_e.setClass(Do),_e.setSVGClass(Do);class Ao extends Do{isOpen(){return!1}}bt(Ao,"ownDefaults",ko),bt(Ao,"type","Polygon"),_e.setClass(Ao),_e.setSVGClass(Ao);const Mo=["fontSize","fontWeight","fontFamily","fontStyle"],Po=["underline","overline","linethrough"],jo=[...Mo,"lineHeight","text","charSpacing","textAlign","styles","path","pathStartOffset","pathSide","pathAlign"],Lo=[...jo,...Po,"textBackgroundColor","direction"],Fo=[...Mo,...Po,ge,"strokeWidth",pe,"deltaY","textBackgroundColor"],Io={_reNewline:Zt,_reSpacesAndTabs:/[ \t\r]/g,_reSpaceAndTab:/[ \t\r]/,_reWords:/\S+/g,fontSize:40,fontWeight:"normal",fontFamily:"Times New Roman",underline:!1,overline:!1,linethrough:!1,textAlign:Yt,fontStyle:"normal",lineHeight:1.16,superscript:{size:.6,baseline:-.35},subscript:{size:.6,baseline:.11},textBackgroundColor:"",stroke:null,shadow:null,path:void 0,pathStartOffset:0,pathSide:Yt,pathAlign:"baseline",_fontSizeFraction:.222,offsets:{underline:.1,linethrough:-.315,overline:-.88},_fontSizeMult:1.13,charSpacing:0,deltaY:0,direction:"ltr",CACHE_FONT_SIZE:400,MIN_TEXT_WIDTH:2},Ro="justify",Bo="justify-left",No="justify-right",zo="justify-center";class Vo extends ur{isEmptyStyles(t){if(!this.styles)return!0;if(void 0!==t&&!this.styles[t])return!0;const e=void 0===t?this.styles:{line:this.styles[t]};for(const i in e)for(const t in e[i])for(const s in e[i][t])return!1;return!0}styleHas(t,e){if(!this.styles)return!1;if(void 0!==e&&!this.styles[e])return!1;const i=void 0===e?this.styles:{0:this.styles[e]};for(const s in i)for(const e in i[s])if(void 0!==i[s][e][t])return!0;return!1}cleanStyle(t){if(!this.styles)return!1;const e=this.styles;let i,s,r=0,n=!0,o=0;for(const a in e){i=0;for(const o in e[a]){const l=e[a][o]||{};r++,void 0!==l[t]?(s?l[t]!==s&&(n=!1):s=l[t],l[t]===this[t]&&delete l[t]):n=!1,0!==Object.keys(l).length?i++:delete e[a][o]}0===i&&delete e[a]}for(let a=0;a<this._textLines.length;a++)o+=this._textLines[a].length;n&&r===o&&(this[t]=s,this.removeStyle(t))}removeStyle(t){if(!this.styles)return;const e=this.styles;let i,s,r;for(s in e){for(r in i=e[s],i)delete i[r][t],0===Object.keys(i[r]).length&&delete i[r];0===Object.keys(i).length&&delete e[s]}}_extendStyles(t,e){const{lineIndex:i,charIndex:s}=this.get2DCursorLocation(t);this._getLineStyle(i)||this._setLineStyle(i);const r=ei(xt(xt({},this._getStyleDeclaration(i,s)),e),(t=>void 0!==t));this._setStyleDeclaration(i,s,r)}getSelectionStyles(t,e,i){const s=[];for(let r=t;r<(e||t);r++)s.push(this.getStyleAtPosition(r,i));return s}getStyleAtPosition(t,e){const{lineIndex:i,charIndex:s}=this.get2DCursorLocation(t);return e?this.getCompleteStyleDeclaration(i,s):this._getStyleDeclaration(i,s)}setSelectionStyles(t,e,i){for(let s=e;s<(i||e);s++)this._extendStyles(s,t);this._forceClearCache=!0}_getStyleDeclaration(t,e){var i;const s=this.styles&&this.styles[t];return s&&null!==(i=s[e])&&void 0!==i?i:{}}getCompleteStyleDeclaration(t,e){return xt(xt({},ti(this,this.constructor._styleProperties)),this._getStyleDeclaration(t,e))}_setStyleDeclaration(t,e,i){this.styles[t][e]=i}_deleteStyleDeclaration(t,e){delete this.styles[t][e]}_getLineStyle(t){return!!this.styles[t]}_setLineStyle(t){this.styles[t]={}}_deleteLineStyle(t){delete this.styles[t]}}bt(Vo,"_styleProperties",Fo);const $o=/ +/g,Wo=/"/g;function Ho(t,e,i,s,r){return"\t\t".concat(function(t,e){let{left:i,top:s,width:r,height:n}=e,o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:Tt.NUM_FRACTION_DIGITS;const a=ui(pe,t,!1),[l,c,h,d]=[i,s,r,n].map((t=>ci(t,o)));return"<rect ".concat(a,' x="').concat(l,'" y="').concat(c,'" width="').concat(h,'" height="').concat(d,'"></rect>')}(t,{left:e,top:i,width:s,height:r}),"\n")}const Xo=["textAnchor","textDecoration","dx","dy","top","left","fontSize","strokeWidth"];let Uo;class Yo extends Vo{static getDefaults(){return xt(xt({},super.getDefaults()),Yo.ownDefaults)}constructor(t,e){super(),bt(this,"__charBounds",[]),Object.assign(this,Yo.ownDefaults),this.setOptions(e),this.styles||(this.styles={}),this.text=t,this.initialized=!0,this.path&&this.setPathInfo(),this.initDimensions(),this.setCoords()}setPathInfo(){const t=this.path;t&&(t.segmentsInfo=jn(t.path))}_splitText(){const t=this._splitTextIntoLines(this.text);return this.textLines=t.lines,this._textLines=t.graphemeLines,this._unwrappedTextLines=t._unwrappedLines,this._text=t.graphemeText,t}initDimensions(){this._splitText(),this._clearCache(),this.dirty=!0,this.path?(this.width=this.path.width,this.height=this.path.height):(this.width=this.calcTextWidth()||this.cursorWidth||this.MIN_TEXT_WIDTH,this.height=this.calcTextHeight()),this.textAlign.includes(Ro)&&this.enlargeSpaces()}enlargeSpaces(){let t,e,i,s,r,n,o;for(let a=0,l=this._textLines.length;a<l;a++)if((this.textAlign===Ro||a!==l-1&&!this.isEndOfWrapping(a))&&(s=0,r=this._textLines[a],e=this.getLineWidth(a),e<this.width&&(o=this.textLines[a].match(this._reSpacesAndTabs)))){i=o.length,t=(this.width-e)/i;for(let e=0;e<=r.length;e++)n=this.__charBounds[a][e],this._reSpaceAndTab.test(r[e])?(n.width+=t,n.kernedWidth+=t,n.left+=s,s+=t):n.left+=s}}isEndOfWrapping(t){return t===this._textLines.length-1}missingNewlineOffset(t){return 1}get2DCursorLocation(t,e){const i=e?this._unwrappedTextLines:this._textLines;let s;for(s=0;s<i.length;s++){if(t<=i[s].length)return{lineIndex:s,charIndex:t};t-=i[s].length+this.missingNewlineOffset(s,e)}return{lineIndex:s-1,charIndex:i[s-1].length<t?i[s-1].length:t}}toString(){return"#<Text (".concat(this.complexity(),'): { "text": "').concat(this.text,'", "fontFamily": "').concat(this.fontFamily,'" }>')}_getCacheCanvasDimensions(){const t=super._getCacheCanvasDimensions(),e=this.fontSize;return t.width+=e*t.zoomX,t.height+=e*t.zoomY,t}_render(t){const e=this.path;e&&!e.isNotVisible()&&e._render(t),this._setTextStyles(t),this._renderTextLinesBackground(t),this._renderTextDecoration(t,"underline"),this._renderText(t),this._renderTextDecoration(t,"overline"),this._renderTextDecoration(t,"linethrough")}_renderText(t){this.paintFirst===ge?(this._renderTextStroke(t),this._renderTextFill(t)):(this._renderTextFill(t),this._renderTextStroke(t))}_setTextStyles(t,e,i){if(t.textBaseline="alphabetic",this.path)switch(this.pathAlign){case Ut:t.textBaseline="middle";break;case"ascender":t.textBaseline=Gt;break;case"descender":t.textBaseline=qt}t.font=this._getFontDeclaration(e,i)}calcTextWidth(){let t=this.getLineWidth(0);for(let e=1,i=this._textLines.length;e<i;e++){const i=this.getLineWidth(e);i>t&&(t=i)}return t}_renderTextLine(t,e,i,s,r,n){this._renderChars(t,e,i,s,r,n)}_renderTextLinesBackground(t){if(!this.textBackgroundColor&&!this.styleHas("textBackgroundColor"))return;const e=t.fillStyle,i=this._getLeftOffset();let s=this._getTopOffset();for(let r=0,n=this._textLines.length;r<n;r++){const e=this.getHeightOfLine(r);if(!this.textBackgroundColor&&!this.styleHas("textBackgroundColor",r)){s+=e;continue}const n=this._textLines[r].length,o=this._getLineLeftOffset(r);let a,l,c=0,h=0,d=this.getValueOfPropertyAt(r,0,"textBackgroundColor");for(let u=0;u<n;u++){const n=this.__charBounds[r][u];l=this.getValueOfPropertyAt(r,u,"textBackgroundColor"),this.path?(t.save(),t.translate(n.renderLeft,n.renderTop),t.rotate(n.angle),t.fillStyle=l,l&&t.fillRect(-n.width/2,-e/this.lineHeight*(1-this._fontSizeFraction),n.width,e/this.lineHeight),t.restore()):l!==d?(a=i+o+h,"rtl"===this.direction&&(a=this.width-a-c),t.fillStyle=d,d&&t.fillRect(a,s,c,e/this.lineHeight),h=n.left,c=n.width,d=l):c+=n.kernedWidth}l&&!this.path&&(a=i+o+h,"rtl"===this.direction&&(a=this.width-a-c),t.fillStyle=l,t.fillRect(a,s,c,e/this.lineHeight)),s+=e}t.fillStyle=e,this._removeShadow(t)}_measureChar(t,e,i,s){const r=Rt.getFontCache(e),n=this._getFontDeclaration(e),o=i+t,a=i&&n===this._getFontDeclaration(s),l=e.fontSize/this.CACHE_FONT_SIZE;let c,h,d,u;if(i&&void 0!==r[i]&&(d=r[i]),void 0!==r[t]&&(u=c=r[t]),a&&void 0!==r[o]&&(h=r[o],u=h-d),void 0===c||void 0===d||void 0===h){const s=function(){if(!Uo){const t=je({width:0,height:0});Uo=t.getContext("2d")}return Uo}();this._setTextStyles(s,e,!0),void 0===c&&(u=c=s.measureText(t).width,r[t]=c),void 0===d&&a&&i&&(d=s.measureText(i).width,r[i]=d),a&&void 0===h&&(h=s.measureText(o).width,r[o]=h,u=h-d)}return{width:c*l,kernedWidth:u*l}}getHeightOfChar(t,e){return this.getValueOfPropertyAt(t,e,"fontSize")}measureLine(t){const e=this._measureLine(t);return 0!==this.charSpacing&&(e.width-=this._getWidthOfCharSpacing()),e.width<0&&(e.width=0),e}_measureLine(t){let e,i,s=0;const r=this.pathSide===Kt,n=this.path,o=this._textLines[t],a=o.length,l=new Array(a);this.__charBounds[t]=l;for(let c=0;c<a;c++){const r=o[c];i=this._getGraphemeBox(r,t,c,e),l[c]=i,s+=i.kernedWidth,e=r}if(l[a]={left:i?i.left+i.width:0,width:0,kernedWidth:0,height:this.fontSize,deltaY:0},n&&n.segmentsInfo){let t=0;const e=n.segmentsInfo[n.segmentsInfo.length-1].length;switch(this.textAlign){case Yt:t=r?e-s:0;break;case Ut:t=(e-s)/2;break;case Kt:t=r?0:e-s}t+=this.pathStartOffset*(r?-1:1);for(let s=r?a-1:0;r?s>=0:s<a;r?s--:s++)i=l[s],t>e?t%=e:t<0&&(t+=e),this._setGraphemeOnPath(t,i),t+=i.kernedWidth}return{width:s,numOfSpaces:0}}_setGraphemeOnPath(t,e){const i=t+e.kernedWidth/2,s=this.path,r=Ln(s.path,i,s.segmentsInfo);e.renderLeft=r.x-s.pathOffset.x,e.renderTop=r.y-s.pathOffset.y,e.angle=r.angle+(this.pathSide===Kt?Math.PI:0)}_getGraphemeBox(t,e,i,s,r){const n=this.getCompleteStyleDeclaration(e,i),o=s?this.getCompleteStyleDeclaration(e,i-1):{},a=this._measureChar(t,n,s,o);let l,c=a.kernedWidth,h=a.width;0!==this.charSpacing&&(l=this._getWidthOfCharSpacing(),h+=l,c+=l);const d={width:h,left:0,height:n.fontSize,kernedWidth:c,deltaY:n.deltaY};if(i>0&&!r){const t=this.__charBounds[e][i-1];d.left=t.left+t.width+a.kernedWidth-a.width}return d}getHeightOfLine(t){if(this.__lineHeights[t])return this.__lineHeights[t];let e=this.getHeightOfChar(t,0);for(let i=1,s=this._textLines[t].length;i<s;i++)e=Math.max(this.getHeightOfChar(t,i),e);return this.__lineHeights[t]=e*this.lineHeight*this._fontSizeMult}calcTextHeight(){let t,e=0;for(let i=0,s=this._textLines.length;i<s;i++)t=this.getHeightOfLine(i),e+=i===s-1?t/this.lineHeight:t;return e}_getLeftOffset(){return"ltr"===this.direction?-this.width/2:this.width/2}_getTopOffset(){return-this.height/2}_renderTextCommon(t,e){t.save();let i=0;const s=this._getLeftOffset(),r=this._getTopOffset();for(let n=0,o=this._textLines.length;n<o;n++){const o=this.getHeightOfLine(n),a=o/this.lineHeight,l=this._getLineLeftOffset(n);this._renderTextLine(e,t,this._textLines[n],s+l,r+i+a,n),i+=o}t.restore()}_renderTextFill(t){(this.fill||this.styleHas(pe))&&this._renderTextCommon(t,"fillText")}_renderTextStroke(t){(this.stroke&&0!==this.strokeWidth||!this.isEmptyStyles())&&(this.shadow&&!this.shadow.affectStroke&&this._removeShadow(t),t.save(),this._setLineDash(t,this.strokeDashArray),t.beginPath(),this._renderTextCommon(t,"strokeText"),t.closePath(),t.restore())}_renderChars(t,e,i,s,r,n){const o=this.getHeightOfLine(n),a=this.textAlign.includes(Ro),l=this.path,c=!a&&0===this.charSpacing&&this.isEmptyStyles(n)&&!l,h="ltr"===this.direction,d="ltr"===this.direction?1:-1,u=e.direction;let p,g,f,m,v,_="",b=0;if(e.save(),u!==this.direction&&(e.canvas.setAttribute("dir",h?"ltr":"rtl"),e.direction=h?"ltr":"rtl",e.textAlign=h?Yt:Kt),r-=o*this._fontSizeFraction/this.lineHeight,c)return this._renderChar(t,e,n,0,i.join(""),s,r),void e.restore();for(let y=0,x=i.length-1;y<=x;y++)m=y===x||this.charSpacing||l,_+=i[y],f=this.__charBounds[n][y],0===b?(s+=d*(f.kernedWidth-f.width),b+=f.width):b+=f.kernedWidth,a&&!m&&this._reSpaceAndTab.test(i[y])&&(m=!0),m||(p=p||this.getCompleteStyleDeclaration(n,y),g=this.getCompleteStyleDeclaration(n,y+1),m=yr(p,g,!1)),m&&(l?(e.save(),e.translate(f.renderLeft,f.renderTop),e.rotate(f.angle),this._renderChar(t,e,n,y,_,-b/2,0),e.restore()):(v=s,this._renderChar(t,e,n,y,_,v,r)),_="",p=g,s+=d*b,b=0);e.restore()}_applyPatternGradientTransformText(t){const e=this.width+this.strokeWidth,i=this.height+this.strokeWidth,s=je({width:e,height:i}),r=s.getContext("2d");return s.width=e,s.height=i,r.beginPath(),r.moveTo(0,0),r.lineTo(e,0),r.lineTo(e,i),r.lineTo(0,i),r.closePath(),r.translate(e/2,i/2),r.fillStyle=t.toLive(r),this._applyPatternGradientTransform(r,t),r.fill(),r.createPattern(s,"no-repeat")}handleFiller(t,e,i){let s,r;return pi(i)?"percentage"===i.gradientUnits||i.gradientTransform||i.patternTransform?(s=-this.width/2,r=-this.height/2,t.translate(s,r),t[e]=this._applyPatternGradientTransformText(i),{offsetX:s,offsetY:r}):(t[e]=i.toLive(t),this._applyPatternGradientTransform(t,i)):(t[e]=i,{offsetX:0,offsetY:0})}_setStrokeStyles(t,e){let{stroke:i,strokeWidth:s}=e;return t.lineWidth=s,t.lineCap=this.strokeLineCap,t.lineDashOffset=this.strokeDashOffset,t.lineJoin=this.strokeLineJoin,t.miterLimit=this.strokeMiterLimit,this.handleFiller(t,"strokeStyle",i)}_setFillStyles(t,e){let{fill:i}=e;return this.handleFiller(t,"fillStyle",i)}_renderChar(t,e,i,s,r,n,o){const a=this._getStyleDeclaration(i,s),l=this.getCompleteStyleDeclaration(i,s),c="fillText"===t&&l.fill,h="strokeText"===t&&l.stroke&&l.strokeWidth;if(h||c){if(e.save(),e.font=this._getFontDeclaration(l),a.textBackgroundColor&&this._removeShadow(e),a.deltaY&&(o+=a.deltaY),c){const t=this._setFillStyles(e,l);e.fillText(r,n-t.offsetX,o-t.offsetY)}if(h){const t=this._setStrokeStyles(e,l);e.strokeText(r,n-t.offsetX,o-t.offsetY)}e.restore()}}setSuperscript(t,e){this._setScript(t,e,this.superscript)}setSubscript(t,e){this._setScript(t,e,this.subscript)}_setScript(t,e,i){const s=this.get2DCursorLocation(t,!0),r=this.getValueOfPropertyAt(s.lineIndex,s.charIndex,"fontSize"),n=this.getValueOfPropertyAt(s.lineIndex,s.charIndex,"deltaY"),o={fontSize:r*i.size,deltaY:n+r*i.baseline};this.setSelectionStyles(o,t,e)}_getLineLeftOffset(t){const e=this.getLineWidth(t),i=this.width-e,s=this.textAlign,r=this.direction,n=this.isEndOfWrapping(t);let o=0;return s===Ro||s===zo&&!n||s===No&&!n||s===Bo&&!n?0:(s===Ut&&(o=i/2),s===Kt&&(o=i),s===zo&&(o=i/2),s===No&&(o=i),"rtl"===r&&(s===Kt||s===Ro||s===No?o=0:s===Yt||s===Bo?o=-i:s!==Ut&&s!==zo||(o=-i/2)),o)}_clearCache(){this._forceClearCache=!1,this.__lineWidths=[],this.__lineHeights=[],this.__charBounds=[]}getLineWidth(t){if(void 0!==this.__lineWidths[t])return this.__lineWidths[t];const{width:e}=this.measureLine(t);return this.__lineWidths[t]=e,e}_getWidthOfCharSpacing(){return 0!==this.charSpacing?this.fontSize*this.charSpacing/1e3:0}getValueOfPropertyAt(t,e,i){var s;return null!==(s=this._getStyleDeclaration(t,e)[i])&&void 0!==s?s:this[i]}_renderTextDecoration(t,e){if(!this[e]&&!this.styleHas(e))return;let i=this._getTopOffset();const s=this._getLeftOffset(),r=this.path,n=this._getWidthOfCharSpacing(),o=this.offsets[e];for(let a=0,l=this._textLines.length;a<l;a++){const l=this.getHeightOfLine(a);if(!this[e]&&!this.styleHas(e,a)){i+=l;continue}const c=this._textLines[a],h=l/this.lineHeight,d=this._getLineLeftOffset(a);let u,p,g=0,f=0,m=this.getValueOfPropertyAt(a,0,e),v=this.getValueOfPropertyAt(a,0,pe);const _=i+h*(1-this._fontSizeFraction);let b=this.getHeightOfChar(a,0),y=this.getValueOfPropertyAt(a,0,"deltaY");for(let i=0,n=c.length;i<n;i++){const n=this.__charBounds[a][i];u=this.getValueOfPropertyAt(a,i,e),p=this.getValueOfPropertyAt(a,i,pe);const l=this.getHeightOfChar(a,i),c=this.getValueOfPropertyAt(a,i,"deltaY");if(r&&u&&p)t.save(),t.fillStyle=v,t.translate(n.renderLeft,n.renderTop),t.rotate(n.angle),t.fillRect(-n.kernedWidth/2,o*l+c,n.kernedWidth,this.fontSize/15),t.restore();else if((u!==m||p!==v||l!==b||c!==y)&&f>0){let e=s+d+g;"rtl"===this.direction&&(e=this.width-e-f),m&&v&&(t.fillStyle=v,t.fillRect(e,_+o*b+y,f,this.fontSize/15)),g=n.left,f=n.width,m=u,v=p,b=l,y=c}else f+=n.kernedWidth}let x=s+d+g;"rtl"===this.direction&&(x=this.width-x-f),t.fillStyle=p,u&&p&&t.fillRect(x,_+o*b+y,f-n,this.fontSize/15),i+=l}this._removeShadow(t)}_getFontDeclaration(){let{fontFamily:t=this.fontFamily,fontStyle:e=this.fontStyle,fontWeight:i=this.fontWeight,fontSize:s=this.fontSize}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=arguments.length>1?arguments[1]:void 0;const n=t.includes("'")||t.includes('"')||t.includes(",")||Yo.genericFonts.includes(t.toLowerCase())?t:'"'.concat(t,'"');return[e,i,"".concat(r?this.CACHE_FONT_SIZE:s,"px"),n].join(" ")}render(t){this.visible&&(this.canvas&&this.canvas.skipOffscreen&&!this.group&&!this.isOnScreen()||(this._forceClearCache&&this.initDimensions(),super.render(t)))}graphemeSplit(t){return _r(t)}_splitTextIntoLines(t){const e=t.split(this._reNewline),i=new Array(e.length),s=["\n"];let r=[];for(let n=0;n<e.length;n++)i[n]=this.graphemeSplit(e[n]),r=r.concat(i[n],s);return r.pop(),{_unwrappedLines:i,lines:e,graphemeText:r,graphemeLines:i}}toObject(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];return xt(xt({},super.toObject([...Lo,...t])),{},{styles:xr(this.styles,this.text)},this.path?{path:this.path.toObject()}:{})}set(t,e){const{textLayoutProperties:i}=this.constructor;super.set(t,e);let s=!1,r=!1;if("object"==typeof t)for(const n in t)"path"===n&&this.setPathInfo(),s=s||i.includes(n),r=r||"path"===n;else s=i.includes(t),r="path"===t;return r&&this.setPathInfo(),s&&this.initialized&&(this.initDimensions(),this.setCoords()),this}complexity(){return 1}static async fromElement(t,e,i){const s=Jr(t,Yo.ATTRIBUTE_NAMES,i),r=xt(xt({},e),s),{textAnchor:n=Yt,textDecoration:o="",dx:a=0,dy:l=0,top:c=0,left:h=0,fontSize:d=Ht,strokeWidth:u=1}=r,p=wt(r,Xo),g=new this((t.textContent||"").replace(/^\s+|\s+$|\n+/g,"").replace(/\s+/g," "),xt({left:h+a,top:c+l,underline:o.includes("underline"),overline:o.includes("overline"),linethrough:o.includes("line-through"),strokeWidth:0,fontSize:d},p)),f=g.getScaledHeight()/g.height,m=((g.height+g.strokeWidth)*g.lineHeight-g.height)*f,v=g.getScaledHeight()+m;let _=0;return n===Ut&&(_=g.getScaledWidth()/2),n===Kt&&(_=g.getScaledWidth()),g.set({left:g.left-_,top:g.top-(v-g.fontSize*(.07+g._fontSizeFraction))/g.lineHeight,strokeWidth:u}),g}static fromObject(t){return this._fromObject(xt(xt({},t),{},{styles:wr(t.styles||{},t.text)}),{extraParam:"text"})}}bt(Yo,"textLayoutProperties",jo),bt(Yo,"cacheProperties",[..._s,...Lo]),bt(Yo,"ownDefaults",Io),bt(Yo,"type","Text"),bt(Yo,"genericFonts",["serif","sans-serif","monospace","cursive","fantasy","system-ui","ui-serif","ui-sans-serif","ui-monospace","ui-rounded","math","emoji","fangsong"]),bt(Yo,"ATTRIBUTE_NAMES",Cr.concat("x","y","dx","dy","font-family","font-style","font-weight","font-size","letter-spacing","text-decoration","text-anchor")),dr(Yo,[class extends Yi{_toSVG(){const t=this._getSVGLeftTopOffsets(),e=this._getSVGTextAndBg(t.textTop,t.textLeft);return this._wrapSVGTextAndBg(e)}toSVG(t){return this._createBaseSVGMarkup(this._toSVG(),{reviver:t,noStyle:!0,withShadow:!0})}_getSVGLeftTopOffsets(){return{textLeft:-this.width/2,textTop:-this.height/2,lineTop:this.getHeightOfLine(0)}}_wrapSVGTextAndBg(t){let{textBgRects:e,textSpans:i}=t;const s=this.getSvgTextDecoration(this);return[e.join(""),'\t\t<text xml:space="preserve" ',this.fontFamily?'font-family="'.concat(this.fontFamily.replace(Wo,"'"),'" '):"",this.fontSize?'font-size="'.concat(this.fontSize,'" '):"",this.fontStyle?'font-style="'.concat(this.fontStyle,'" '):"",this.fontWeight?'font-weight="'.concat(this.fontWeight,'" '):"",s?'text-decoration="'.concat(s,'" '):"","rtl"===this.direction?'direction="'.concat(this.direction,'" '):"",'style="',this.getSvgStyles(!0),'"',this.addPaintOrder()," >",i.join(""),"</text>\n"]}_getSVGTextAndBg(t,e){const i=[],s=[];let r,n=t;this.backgroundColor&&s.push(...Ho(this.backgroundColor,-this.width/2,-this.height/2,this.width,this.height));for(let o=0,a=this._textLines.length;o<a;o++)r=this._getLineLeftOffset(o),"rtl"===this.direction&&(r+=this.width),(this.textBackgroundColor||this.styleHas("textBackgroundColor",o))&&this._setSVGTextLineBg(s,o,e+r,n),this._setSVGTextLineText(i,o,e+r,n),n+=this.getHeightOfLine(o);return{textSpans:i,textBgRects:s}}_createTextCharSpan(t,e,i,s){const r=this.getSvgSpanStyles(e,t!==t.trim()||!!t.match($o)),n=r?'style="'.concat(r,'"'):"",o=e.deltaY,a=o?' dy="'.concat(ci(o,Tt.NUM_FRACTION_DIGITS),'" '):"";return'<tspan x="'.concat(ci(i,Tt.NUM_FRACTION_DIGITS),'" y="').concat(ci(s,Tt.NUM_FRACTION_DIGITS),'" ').concat(a).concat(n,">").concat((t=>t.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/'/g,"&apos;").replace(/</g,"&lt;").replace(/>/g,"&gt;"))(t),"</tspan>")}_setSVGTextLineText(t,e,i,s){const r=this.getHeightOfLine(e),n=this.textAlign.includes(Ro),o=this._textLines[e];let a,l,c,h,d,u="",p=0;s+=r*(1-this._fontSizeFraction)/this.lineHeight;for(let g=0,f=o.length-1;g<=f;g++)d=g===f||this.charSpacing,u+=o[g],c=this.__charBounds[e][g],0===p?(i+=c.kernedWidth-c.width,p+=c.width):p+=c.kernedWidth,n&&!d&&this._reSpaceAndTab.test(o[g])&&(d=!0),d||(a=a||this.getCompleteStyleDeclaration(e,g),l=this.getCompleteStyleDeclaration(e,g+1),d=yr(a,l,!0)),d&&(h=this._getStyleDeclaration(e,g),t.push(this._createTextCharSpan(u,h,i,s)),u="",a=l,"rtl"===this.direction?i-=p:i+=p,p=0)}_setSVGTextLineBg(t,e,i,s){const r=this._textLines[e],n=this.getHeightOfLine(e)/this.lineHeight;let o,a=0,l=0,c=this.getValueOfPropertyAt(e,0,"textBackgroundColor");for(let h=0;h<r.length;h++){const{left:r,width:d,kernedWidth:u}=this.__charBounds[e][h];o=this.getValueOfPropertyAt(e,h,"textBackgroundColor"),o!==c?(c&&t.push(...Ho(c,i+l,s,a,n)),l=r,a=d,c=o):a+=u}o&&t.push(...Ho(c,i+l,s,a,n))}_getSVGLineTopOffset(t){let e,i=0;for(e=0;e<t;e++)i+=this.getHeightOfLine(e);const s=this.getHeightOfLine(e);return{lineTop:i,offset:(this._fontSizeMult-this._fontSizeFraction)*s/(this.lineHeight*this._fontSizeMult)}}getSvgStyles(t){return"".concat(super.getSvgStyles(t)," white-space: pre;")}getSvgSpanStyles(t,e){const{fontFamily:i,strokeWidth:s,stroke:r,fill:n,fontSize:o,fontStyle:a,fontWeight:l,deltaY:c}=t,h=this.getSvgTextDecoration(t);return[r?ui(ge,r):"",s?"stroke-width: ".concat(s,"; "):"",i?"font-family: ".concat(i.includes("'")||i.includes('"')?i:"'".concat(i,"'"),"; "):"",o?"font-size: ".concat(o,"px; "):"",a?"font-style: ".concat(a,"; "):"",l?"font-weight: ".concat(l,"; "):"",h?"text-decoration: ".concat(h,"; "):h,n?ui(pe,n):"",c?"baseline-shift: ".concat(-c,"; "):"",e?"white-space: pre; ":""].join("")}getSvgTextDecoration(t){return["overline","underline","line-through"].filter((e=>t[e.replace("-","")])).join(" ")}}]),_e.setClass(Yo),_e.setSVGClass(Yo);class Go{constructor(t){bt(this,"target",void 0),bt(this,"__mouseDownInPlace",!1),bt(this,"__dragStartFired",!1),bt(this,"__isDraggingOver",!1),bt(this,"__dragStartSelection",void 0),bt(this,"__dragImageDisposer",void 0),bt(this,"_dispose",void 0),this.target=t;const e=[this.target.on("dragenter",this.dragEnterHandler.bind(this)),this.target.on("dragover",this.dragOverHandler.bind(this)),this.target.on("dragleave",this.dragLeaveHandler.bind(this)),this.target.on("dragend",this.dragEndHandler.bind(this)),this.target.on("drop",this.dropHandler.bind(this))];this._dispose=()=>{e.forEach((t=>t())),this._dispose=void 0}}isPointerOverSelection(t){const e=this.target,i=e.getSelectionStartFromPointer(t);return e.isEditing&&i>=e.selectionStart&&i<=e.selectionEnd&&e.selectionStart<e.selectionEnd}start(t){return this.__mouseDownInPlace=this.isPointerOverSelection(t)}isActive(){return this.__mouseDownInPlace}end(t){const e=this.isActive();return e&&!this.__dragStartFired&&(this.target.setCursorByClick(t),this.target.initDelayedCursor(!0)),this.__mouseDownInPlace=!1,this.__dragStartFired=!1,this.__isDraggingOver=!1,e}getDragStartSelection(){return this.__dragStartSelection}setDragImage(t,e){var i;let{selectionStart:s,selectionEnd:r}=e;const n=this.target,o=n.canvas,a=new Se(n.flipX?-1:1,n.flipY?-1:1),l=n._getCursorBoundaries(s),c=new Se(l.left+l.leftOffset,l.top+l.topOffset).multiply(a).transform(n.calcTransformMatrix()),h=o.getScenePoint(t).subtract(c),d=n.getCanvasRetinaScaling(),u=n.getBoundingRect(),p=c.subtract(new Se(u.left,u.top)),g=o.viewportTransform,f=p.add(h).transform(g,!0),m=n.backgroundColor,v=vr(n.styles);n.backgroundColor="";const _={stroke:"transparent",fill:"transparent",textBackgroundColor:"transparent"};n.setSelectionStyles(_,0,s),n.setSelectionStyles(_,r,n.text.length),n.dirty=!0;const b=n.toCanvasElement({enableRetinaScaling:o.enableRetinaScaling,viewportTransform:!0});n.backgroundColor=m,n.styles=v,n.dirty=!0,Nn(b,{position:"fixed",left:"".concat(-b.width,"px"),border:Jt,width:"".concat(b.width/d,"px"),height:"".concat(b.height/d,"px")}),this.__dragImageDisposer&&this.__dragImageDisposer(),this.__dragImageDisposer=()=>{b.remove()},_i(t.target||this.target.hiddenTextarea).body.appendChild(b),null===(i=t.dataTransfer)||void 0===i||i.setDragImage(b,f.x,f.y)}onDragStart(t){this.__dragStartFired=!0;const e=this.target,i=this.isActive();if(i&&t.dataTransfer){const i=this.__dragStartSelection={selectionStart:e.selectionStart,selectionEnd:e.selectionEnd},s=e._text.slice(i.selectionStart,i.selectionEnd).join(""),r=xt({text:e.text,value:s},i);t.dataTransfer.setData("text/plain",s),t.dataTransfer.setData("application/fabric",JSON.stringify({value:s,styles:e.getSelectionStyles(i.selectionStart,i.selectionEnd,!0)})),t.dataTransfer.effectAllowed="copyMove",this.setDragImage(t,r)}return e.abortCursorAnimation(),i}canDrop(t){if(this.target.editable&&!this.target.getActiveControl()&&!t.defaultPrevented){if(this.isActive()&&this.__dragStartSelection){const e=this.target.getSelectionStartFromPointer(t),i=this.__dragStartSelection;return e<i.selectionStart||e>i.selectionEnd}return!0}return!1}targetCanDrop(t){return this.target.canDrop(t)}dragEnterHandler(t){let{e:e}=t;const i=this.targetCanDrop(e);!this.__isDraggingOver&&i&&(this.__isDraggingOver=!0)}dragOverHandler(t){const{e:e}=t,i=this.targetCanDrop(e);!this.__isDraggingOver&&i?this.__isDraggingOver=!0:this.__isDraggingOver&&!i&&(this.__isDraggingOver=!1),this.__isDraggingOver&&(e.preventDefault(),t.canDrop=!0,t.dropTarget=this.target)}dragLeaveHandler(){(this.__isDraggingOver||this.isActive())&&(this.__isDraggingOver=!1)}dropHandler(t){var e;const{e:i}=t,s=i.defaultPrevented;this.__isDraggingOver=!1,i.preventDefault();let r=null===(e=i.dataTransfer)||void 0===e?void 0:e.getData("text/plain");if(r&&!s){const e=this.target,s=e.canvas;let n=e.getSelectionStartFromPointer(i);const{styles:o}=i.dataTransfer.types.includes("application/fabric")?JSON.parse(i.dataTransfer.getData("application/fabric")):{},a=r[Math.max(0,r.length-1)],l=0;if(this.__dragStartSelection){const t=this.__dragStartSelection.selectionStart,i=this.__dragStartSelection.selectionEnd;n>t&&n<=i?n=t:n>i&&(n-=i-t),e.removeChars(t,i),delete this.__dragStartSelection}e._reNewline.test(a)&&(e._reNewline.test(e._text[n])||n===e._text.length)&&(r=r.trimEnd()),t.didDrop=!0,t.dropTarget=e,e.insertChars(r,o,n),s.setActiveObject(e),e.enterEditing(i),e.selectionStart=Math.min(n+l,e._text.length),e.selectionEnd=Math.min(e.selectionStart+r.length,e._text.length),e.hiddenTextarea.value=e.text,e._updateTextarea(),e.hiddenTextarea.focus(),e.fire(ae,{index:n+l,action:"drop"}),s.fire("text:changed",{target:e}),s.contextTopDirty=!0,s.requestRenderAll()}}dragEndHandler(t){let{e:e}=t;if(this.isActive()&&this.__dragStartFired&&this.__dragStartSelection){var i;const t=this.target,s=this.target.canvas,{selectionStart:r,selectionEnd:n}=this.__dragStartSelection,o=(null===(i=e.dataTransfer)||void 0===i?void 0:i.dropEffect)||Jt;o===Jt?(t.selectionStart=r,t.selectionEnd=n,t._updateTextarea(),t.hiddenTextarea.focus()):(t.clearContextTop(),"move"===o&&(t.removeChars(r,n),t.selectionStart=t.selectionEnd=r,t.hiddenTextarea&&(t.hiddenTextarea.value=t.text),t._updateTextarea(),t.fire(ae,{index:r,action:"dragend"}),s.fire("text:changed",{target:t}),s.requestRenderAll()),t.exitEditing())}this.__dragImageDisposer&&this.__dragImageDisposer(),delete this.__dragImageDisposer,delete this.__dragStartSelection,this.__isDraggingOver=!1}dispose(){this._dispose&&this._dispose()}}const qo=/[ \n\.,;!\?\-]/;class Ko extends Yo{constructor(){super(...arguments),bt(this,"_currentCursorOpacity",1)}initBehavior(){this._tick=this._tick.bind(this),this._onTickComplete=this._onTickComplete.bind(this),this.updateSelectionOnMouseMove=this.updateSelectionOnMouseMove.bind(this)}onDeselect(t){return this.isEditing&&this.exitEditing(),this.selected=!1,super.onDeselect(t)}_animateCursor(t){let{toValue:e,duration:i,delay:s,onComplete:r}=t;return Ms({startValue:this._currentCursorOpacity,endValue:e,duration:i,delay:s,onComplete:r,abort:()=>!this.canvas||this.selectionStart!==this.selectionEnd,onChange:t=>{this._currentCursorOpacity=t,this.renderCursorOrSelection()}})}_tick(t){this._currentTickState=this._animateCursor({toValue:0,duration:this.cursorDuration/2,delay:Math.max(t||0,100),onComplete:this._onTickComplete})}_onTickComplete(){var t;null===(t=this._currentTickCompleteState)||void 0===t||t.abort(),this._currentTickCompleteState=this._animateCursor({toValue:1,duration:this.cursorDuration,onComplete:this._tick})}initDelayedCursor(t){this.abortCursorAnimation(),this._tick(t?0:this.cursorDelay)}abortCursorAnimation(){let t=!1;[this._currentTickState,this._currentTickCompleteState].forEach((e=>{e&&!e.isDone()&&(t=!0,e.abort())})),this._currentCursorOpacity=1,t&&this.clearContextTop()}restartCursorIfNeeded(){[this._currentTickState,this._currentTickCompleteState].some((t=>!t||t.isDone()))&&this.initDelayedCursor()}selectAll(){return this.selectionStart=0,this.selectionEnd=this._text.length,this._fireSelectionChanged(),this._updateTextarea(),this}getSelectedText(){return this._text.slice(this.selectionStart,this.selectionEnd).join("")}findWordBoundaryLeft(t){let e=0,i=t-1;if(this._reSpace.test(this._text[i]))for(;this._reSpace.test(this._text[i]);)e++,i--;for(;/\S/.test(this._text[i])&&i>-1;)e++,i--;return t-e}findWordBoundaryRight(t){let e=0,i=t;if(this._reSpace.test(this._text[i]))for(;this._reSpace.test(this._text[i]);)e++,i++;for(;/\S/.test(this._text[i])&&i<this._text.length;)e++,i++;return t+e}findLineBoundaryLeft(t){let e=0,i=t-1;for(;!/\n/.test(this._text[i])&&i>-1;)e++,i--;return t-e}findLineBoundaryRight(t){let e=0,i=t;for(;!/\n/.test(this._text[i])&&i<this._text.length;)e++,i++;return t+e}searchWordBoundary(t,e){const i=this._text;let s=t>0&&this._reSpace.test(i[t])&&(-1===e||!Zt.test(i[t-1]))?t-1:t,r=i[s];for(;s>0&&s<i.length&&!qo.test(r);)s+=e,r=i[s];return-1===e&&qo.test(r)&&s++,s}selectWord(t){t=t||this.selectionStart;const e=this.searchWordBoundary(t,-1),i=Math.max(e,this.searchWordBoundary(t,1));this.selectionStart=e,this.selectionEnd=i,this._fireSelectionChanged(),this._updateTextarea(),this.renderCursorOrSelection()}selectLine(t){t=t||this.selectionStart;const e=this.findLineBoundaryLeft(t),i=this.findLineBoundaryRight(t);return this.selectionStart=e,this.selectionEnd=i,this._fireSelectionChanged(),this._updateTextarea(),this}enterEditing(t){!this.isEditing&&this.editable&&(this.enterEditingImpl(),this.fire("editing:entered",t?{e:t}:void 0),this._fireSelectionChanged(),this.canvas&&(this.canvas.fire("text:editing:entered",{target:this,e:t}),this.canvas.requestRenderAll()))}enterEditingImpl(){this.canvas&&(this.canvas.calcOffset(),this.canvas.textEditingManager.exitTextEditing()),this.isEditing=!0,this.initHiddenTextarea(),this.hiddenTextarea.focus(),this.hiddenTextarea.value=this.text,this._updateTextarea(),this._saveEditingProps(),this._setEditingProps(),this._textBeforeEdit=this.text,this._tick()}updateSelectionOnMouseMove(t){if(this.getActiveControl())return;const e=this.hiddenTextarea;_i(e).activeElement!==e&&e.focus();const i=this.getSelectionStartFromPointer(t),s=this.selectionStart,r=this.selectionEnd;(i===this.__selectionStartOnMouseDown&&s!==r||s!==i&&r!==i)&&(i>this.__selectionStartOnMouseDown?(this.selectionStart=this.__selectionStartOnMouseDown,this.selectionEnd=i):(this.selectionStart=i,this.selectionEnd=this.__selectionStartOnMouseDown),this.selectionStart===s&&this.selectionEnd===r||(this._fireSelectionChanged(),this._updateTextarea(),this.renderCursorOrSelection()))}_setEditingProps(){this.hoverCursor="text",this.canvas&&(this.canvas.defaultCursor=this.canvas.moveCursor="text"),this.borderColor=this.editingBorderColor,this.hasControls=this.selectable=!1,this.lockMovementX=this.lockMovementY=!0}fromStringToGraphemeSelection(t,e,i){const s=i.slice(0,t),r=this.graphemeSplit(s).length;if(t===e)return{selectionStart:r,selectionEnd:r};const n=i.slice(t,e);return{selectionStart:r,selectionEnd:r+this.graphemeSplit(n).length}}fromGraphemeToStringSelection(t,e,i){const s=i.slice(0,t).join("").length;return t===e?{selectionStart:s,selectionEnd:s}:{selectionStart:s,selectionEnd:s+i.slice(t,e).join("").length}}_updateTextarea(){if(this.cursorOffsetCache={},this.hiddenTextarea){if(!this.inCompositionMode){const t=this.fromGraphemeToStringSelection(this.selectionStart,this.selectionEnd,this._text);this.hiddenTextarea.selectionStart=t.selectionStart,this.hiddenTextarea.selectionEnd=t.selectionEnd}this.updateTextareaPosition()}}updateFromTextArea(){if(!this.hiddenTextarea)return;this.cursorOffsetCache={};const t=this.hiddenTextarea;this.text=t.value,this.set("dirty",!0),this.initDimensions(),this.setCoords();const e=this.fromStringToGraphemeSelection(t.selectionStart,t.selectionEnd,t.value);this.selectionEnd=this.selectionStart=e.selectionEnd,this.inCompositionMode||(this.selectionStart=e.selectionStart),this.updateTextareaPosition()}updateTextareaPosition(){if(this.selectionStart===this.selectionEnd){const t=this._calcTextareaPosition();this.hiddenTextarea.style.left=t.left,this.hiddenTextarea.style.top=t.top}}_calcTextareaPosition(){if(!this.canvas)return{left:"1px",top:"1px"};const t=this.inCompositionMode?this.compositionStart:this.selectionStart,e=this._getCursorBoundaries(t),i=this.get2DCursorLocation(t),s=i.lineIndex,r=i.charIndex,n=this.getValueOfPropertyAt(s,r,"fontSize")*this.lineHeight,o=e.leftOffset,a=this.getCanvasRetinaScaling(),l=this.canvas.upperCanvasEl,c=l.width/a,h=l.height/a,d=c-n,u=h-n,p=new Se(e.left+o,e.top+e.topOffset+n).transform(this.calcTransformMatrix()).transform(this.canvas.viewportTransform).multiply(new Se(l.clientWidth/c,l.clientHeight/h));return p.x<0&&(p.x=0),p.x>d&&(p.x=d),p.y<0&&(p.y=0),p.y>u&&(p.y=u),p.x+=this.canvas._offset.left,p.y+=this.canvas._offset.top,{left:"".concat(p.x,"px"),top:"".concat(p.y,"px"),fontSize:"".concat(n,"px"),charHeight:n}}_saveEditingProps(){this._savedProps={hasControls:this.hasControls,borderColor:this.borderColor,lockMovementX:this.lockMovementX,lockMovementY:this.lockMovementY,hoverCursor:this.hoverCursor,selectable:this.selectable,defaultCursor:this.canvas&&this.canvas.defaultCursor,moveCursor:this.canvas&&this.canvas.moveCursor}}_restoreEditingProps(){this._savedProps&&(this.hoverCursor=this._savedProps.hoverCursor,this.hasControls=this._savedProps.hasControls,this.borderColor=this._savedProps.borderColor,this.selectable=this._savedProps.selectable,this.lockMovementX=this._savedProps.lockMovementX,this.lockMovementY=this._savedProps.lockMovementY,this.canvas&&(this.canvas.defaultCursor=this._savedProps.defaultCursor||this.canvas.defaultCursor,this.canvas.moveCursor=this._savedProps.moveCursor||this.canvas.moveCursor),delete this._savedProps)}_exitEditing(){const t=this.hiddenTextarea;this.selected=!1,this.isEditing=!1,t&&(t.blur&&t.blur(),t.parentNode&&t.parentNode.removeChild(t)),this.hiddenTextarea=null,this.abortCursorAnimation(),this.selectionStart!==this.selectionEnd&&this.clearContextTop()}exitEditingImpl(){this._exitEditing(),this.selectionEnd=this.selectionStart,this._restoreEditingProps(),this._forceClearCache&&(this.initDimensions(),this.setCoords())}exitEditing(){const t=this._textBeforeEdit!==this.text;return this.exitEditingImpl(),this.fire("editing:exited"),t&&this.fire(fe),this.canvas&&(this.canvas.fire("text:editing:exited",{target:this}),t&&this.canvas.fire("object:modified",{target:this})),this}_removeExtraneousStyles(){for(const t in this.styles)this._textLines[t]||delete this.styles[t]}removeStyleFromTo(t,e){const{lineIndex:i,charIndex:s}=this.get2DCursorLocation(t,!0),{lineIndex:r,charIndex:n}=this.get2DCursorLocation(e,!0);if(i!==r){if(this.styles[i])for(let t=s;t<this._unwrappedTextLines[i].length;t++)delete this.styles[i][t];if(this.styles[r])for(let t=n;t<this._unwrappedTextLines[r].length;t++){const e=this.styles[r][t];e&&(this.styles[i]||(this.styles[i]={}),this.styles[i][s+t-n]=e)}for(let t=i+1;t<=r;t++)delete this.styles[t];this.shiftLineStyles(r,i-r)}else if(this.styles[i]){const t=this.styles[i],e=n-s;for(let i=s;i<n;i++)delete t[i];for(const s in this.styles[i]){const i=parseInt(s,10);i>=n&&(t[i-e]=t[s],delete t[s])}}}shiftLineStyles(t,e){const i=Object.assign({},this.styles);for(const s in this.styles){const r=parseInt(s,10);r>t&&(this.styles[r+e]=i[r],i[r-e]||delete this.styles[r])}}insertNewlineStyleObject(t,e,i,s){const r={},n=this._unwrappedTextLines[t].length,o=n===e;let a=!1;i||(i=1),this.shiftLineStyles(t,i);const l=this.styles[t]?this.styles[t][0===e?e:e-1]:void 0;for(const h in this.styles[t]){const i=parseInt(h,10);i>=e&&(a=!0,r[i-e]=this.styles[t][h],o&&0===e||delete this.styles[t][h])}let c=!1;for(a&&!o&&(this.styles[t+i]=r,c=!0),(c||n>e)&&i--;i>0;)s&&s[i-1]?this.styles[t+i]={0:xt({},s[i-1])}:l?this.styles[t+i]={0:xt({},l)}:delete this.styles[t+i],i--;this._forceClearCache=!0}insertCharStyleObject(t,e,i,s){this.styles||(this.styles={});const r=this.styles[t],n=r?xt({},r):{};i||(i=1);for(const a in n){const t=parseInt(a,10);t>=e&&(r[t+i]=n[t],n[t-i]||delete r[t])}if(this._forceClearCache=!0,s){for(;i--;)Object.keys(s[i]).length&&(this.styles[t]||(this.styles[t]={}),this.styles[t][e+i]=xt({},s[i]));return}if(!r)return;const o=r[e?e-1:1];for(;o&&i--;)this.styles[t][e+i]=xt({},o)}insertNewStyleBlock(t,e,i){const s=this.get2DCursorLocation(e,!0),r=[0];let n,o=0;for(let a=0;a<t.length;a++)"\n"===t[a]?(o++,r[o]=0):r[o]++;for(r[0]>0&&(this.insertCharStyleObject(s.lineIndex,s.charIndex,r[0],i),i=i&&i.slice(r[0]+1)),o&&this.insertNewlineStyleObject(s.lineIndex,s.charIndex+r[0],o),n=1;n<o;n++)r[n]>0?this.insertCharStyleObject(s.lineIndex+n,0,r[n],i):i&&this.styles[s.lineIndex+n]&&i[0]&&(this.styles[s.lineIndex+n][0]=i[0]),i=i&&i.slice(r[n]+1);r[n]>0&&this.insertCharStyleObject(s.lineIndex+n,0,r[n],i)}removeChars(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:t+1;this.removeStyleFromTo(t,e),this._text.splice(t,e-t),this.text=this._text.join(""),this.set("dirty",!0),this.initDimensions(),this.setCoords(),this._removeExtraneousStyles()}insertChars(t,e,i){let s=arguments.length>3&&void 0!==arguments[3]?arguments[3]:i;s>i&&this.removeStyleFromTo(i,s);const r=this.graphemeSplit(t);this.insertNewStyleBlock(r,i,e),this._text=[...this._text.slice(0,i),...r,...this._text.slice(s)],this.text=this._text.join(""),this.set("dirty",!0),this.initDimensions(),this.setCoords(),this._removeExtraneousStyles()}setSelectionStartEndWithShift(t,e,i){i<=t?(e===t?this._selectionDirection=Yt:this._selectionDirection===Kt&&(this._selectionDirection=Yt,this.selectionEnd=t),this.selectionStart=i):i>t&&i<e?this._selectionDirection===Kt?this.selectionEnd=i:this.selectionStart=i:(e===t?this._selectionDirection=Kt:this._selectionDirection===Yt&&(this._selectionDirection=Kt,this.selectionStart=e),this.selectionEnd=i)}}class Jo extends Ko{initHiddenTextarea(){const t=this.canvas&&_i(this.canvas.getElement())||Lt(),e=t.createElement("textarea");Object.entries({autocapitalize:"off",autocorrect:"off",autocomplete:"off",spellcheck:"false","data-fabric":"textarea",wrap:"off"}).map((t=>{let[i,s]=t;return e.setAttribute(i,s)}));const{top:i,left:s,fontSize:r}=this._calcTextareaPosition();e.style.cssText="position: absolute; top: ".concat(i,"; left: ").concat(s,"; z-index: -999; opacity: 0; width: 1px; height: 1px; font-size: 1px; padding-top: ").concat(r,";"),(this.hiddenTextareaContainer||t.body).appendChild(e),Object.entries({blur:"blur",keydown:"onKeyDown",keyup:"onKeyUp",input:"onInput",copy:"copy",cut:"copy",paste:"paste",compositionstart:"onCompositionStart",compositionupdate:"onCompositionUpdate",compositionend:"onCompositionEnd"}).map((t=>{let[i,s]=t;return e.addEventListener(i,this[s].bind(this))})),this.hiddenTextarea=e}blur(){this.abortCursorAnimation()}onKeyDown(t){if(!this.isEditing)return;const e="rtl"===this.direction?this.keysMapRtl:this.keysMap;if(t.keyCode in e)this[e[t.keyCode]](t);else{if(!(t.keyCode in this.ctrlKeysMapDown)||!t.ctrlKey&&!t.metaKey)return;this[this.ctrlKeysMapDown[t.keyCode]](t)}t.stopImmediatePropagation(),t.preventDefault(),t.keyCode>=33&&t.keyCode<=40?(this.inCompositionMode=!1,this.clearContextTop(),this.renderCursorOrSelection()):this.canvas&&this.canvas.requestRenderAll()}onKeyUp(t){!this.isEditing||this._copyDone||this.inCompositionMode?this._copyDone=!1:t.keyCode in this.ctrlKeysMapUp&&(t.ctrlKey||t.metaKey)&&(this[this.ctrlKeysMapUp[t.keyCode]](t),t.stopImmediatePropagation(),t.preventDefault(),this.canvas&&this.canvas.requestRenderAll())}onInput(t){const e=this.fromPaste;if(this.fromPaste=!1,t&&t.stopPropagation(),!this.isEditing)return;const i=()=>{this.updateFromTextArea(),this.fire(ae),this.canvas&&(this.canvas.fire("text:changed",{target:this}),this.canvas.requestRenderAll())};if(""===this.hiddenTextarea.value)return this.styles={},void i();const s=this._splitTextIntoLines(this.hiddenTextarea.value).graphemeText,r=this._text.length,n=s.length,o=this.selectionStart,a=this.selectionEnd,l=o!==a;let c,h,d,u,p=n-r;const g=this.fromStringToGraphemeSelection(this.hiddenTextarea.selectionStart,this.hiddenTextarea.selectionEnd,this.hiddenTextarea.value),f=o>g.selectionStart;l?(h=this._text.slice(o,a),p+=a-o):n<r&&(h=f?this._text.slice(a+p,a):this._text.slice(o,o-p));const m=s.slice(g.selectionEnd-p,g.selectionEnd);if(h&&h.length&&(m.length&&(c=this.getSelectionStyles(o,o+1,!1),c=m.map((()=>c[0]))),l?(d=o,u=a):f?(d=a-h.length,u=a):(d=a,u=a+h.length),this.removeStyleFromTo(d,u)),m.length){const{copyPasteData:t}=jt();e&&m.join("")===t.copiedText&&!Tt.disableStyleCopyPaste&&(c=t.copiedTextStyle),this.insertNewStyleBlock(m,o,c)}i()}onCompositionStart(){this.inCompositionMode=!0}onCompositionEnd(){this.inCompositionMode=!1}onCompositionUpdate(t){let{target:e}=t;const{selectionStart:i,selectionEnd:s}=e;this.compositionStart=i,this.compositionEnd=s,this.updateTextareaPosition()}copy(){if(this.selectionStart===this.selectionEnd)return;const{copyPasteData:t}=jt();t.copiedText=this.getSelectedText(),Tt.disableStyleCopyPaste?t.copiedTextStyle=void 0:t.copiedTextStyle=this.getSelectionStyles(this.selectionStart,this.selectionEnd,!0),this._copyDone=!0}paste(){this.fromPaste=!0}_getWidthBeforeCursor(t,e){let i,s=this._getLineLeftOffset(t);return e>0&&(i=this.__charBounds[t][e-1],s+=i.left+i.width),s}getDownCursorOffset(t,e){const i=this._getSelectionForOffset(t,e),s=this.get2DCursorLocation(i),r=s.lineIndex;if(r===this._textLines.length-1||t.metaKey||34===t.keyCode)return this._text.length-i;const n=s.charIndex,o=this._getWidthBeforeCursor(r,n),a=this._getIndexOnLine(r+1,o);return this._textLines[r].slice(n).length+a+1+this.missingNewlineOffset(r)}_getSelectionForOffset(t,e){return t.shiftKey&&this.selectionStart!==this.selectionEnd&&e?this.selectionEnd:this.selectionStart}getUpCursorOffset(t,e){const i=this._getSelectionForOffset(t,e),s=this.get2DCursorLocation(i),r=s.lineIndex;if(0===r||t.metaKey||33===t.keyCode)return-i;const n=s.charIndex,o=this._getWidthBeforeCursor(r,n),a=this._getIndexOnLine(r-1,o),l=this._textLines[r].slice(0,n),c=this.missingNewlineOffset(r-1);return-this._textLines[r-1].length+a-l.length+(1-c)}_getIndexOnLine(t,e){const i=this._textLines[t];let s,r,n=this._getLineLeftOffset(t),o=0;for(let a=0,l=i.length;a<l;a++)if(s=this.__charBounds[t][a].width,n+=s,n>e){r=!0;const t=n-s,i=n,l=Math.abs(t-e);o=Math.abs(i-e)<l?a:a-1;break}return r||(o=i.length-1),o}moveCursorDown(t){this.selectionStart>=this._text.length&&this.selectionEnd>=this._text.length||this._moveCursorUpOrDown("Down",t)}moveCursorUp(t){0===this.selectionStart&&0===this.selectionEnd||this._moveCursorUpOrDown("Up",t)}_moveCursorUpOrDown(t,e){const i=this["get".concat(t,"CursorOffset")](e,this._selectionDirection===Kt);if(e.shiftKey?this.moveCursorWithShift(i):this.moveCursorWithoutShift(i),0!==i){const t=this.text.length;this.selectionStart=ms(0,this.selectionStart,t),this.selectionEnd=ms(0,this.selectionEnd,t),this.abortCursorAnimation(),this.initDelayedCursor(),this._fireSelectionChanged(),this._updateTextarea()}}moveCursorWithShift(t){const e=this._selectionDirection===Yt?this.selectionStart+t:this.selectionEnd+t;return this.setSelectionStartEndWithShift(this.selectionStart,this.selectionEnd,e),0!==t}moveCursorWithoutShift(t){return t<0?(this.selectionStart+=t,this.selectionEnd=this.selectionStart):(this.selectionEnd+=t,this.selectionStart=this.selectionEnd),0!==t}moveCursorLeft(t){0===this.selectionStart&&0===this.selectionEnd||this._moveCursorLeftOrRight("Left",t)}_move(t,e,i){let s;if(t.altKey)s=this["findWordBoundary".concat(i)](this[e]);else{if(!t.metaKey&&35!==t.keyCode&&36!==t.keyCode)return this[e]+="Left"===i?-1:1,!0;s=this["findLineBoundary".concat(i)](this[e])}return void 0!==s&&this[e]!==s&&(this[e]=s,!0)}_moveLeft(t,e){return this._move(t,e,"Left")}_moveRight(t,e){return this._move(t,e,"Right")}moveCursorLeftWithoutShift(t){let e=!0;return this._selectionDirection=Yt,this.selectionEnd===this.selectionStart&&0!==this.selectionStart&&(e=this._moveLeft(t,"selectionStart")),this.selectionEnd=this.selectionStart,e}moveCursorLeftWithShift(t){return this._selectionDirection===Kt&&this.selectionStart!==this.selectionEnd?this._moveLeft(t,"selectionEnd"):0!==this.selectionStart?(this._selectionDirection=Yt,this._moveLeft(t,"selectionStart")):void 0}moveCursorRight(t){this.selectionStart>=this._text.length&&this.selectionEnd>=this._text.length||this._moveCursorLeftOrRight("Right",t)}_moveCursorLeftOrRight(t,e){const i="moveCursor".concat(t).concat(e.shiftKey?"WithShift":"WithoutShift");this._currentCursorOpacity=1,this[i](e)&&(this.abortCursorAnimation(),this.initDelayedCursor(),this._fireSelectionChanged(),this._updateTextarea())}moveCursorRightWithShift(t){return this._selectionDirection===Yt&&this.selectionStart!==this.selectionEnd?this._moveRight(t,"selectionStart"):this.selectionEnd!==this._text.length?(this._selectionDirection=Kt,this._moveRight(t,"selectionEnd")):void 0}moveCursorRightWithoutShift(t){let e=!0;return this._selectionDirection=Kt,this.selectionStart===this.selectionEnd?(e=this._moveRight(t,"selectionStart"),this.selectionEnd=this.selectionStart):this.selectionStart=this.selectionEnd,e}}const Zo=t=>!!t.button;class Qo extends Jo{constructor(){super(...arguments),bt(this,"draggableTextDelegate",void 0)}initBehavior(){this.on("mousedown",this._mouseDownHandler),this.on("mousedown:before",this._mouseDownHandlerBefore),this.on("mouseup",this.mouseUpHandler),this.on("mousedblclick",this.doubleClickHandler),this.on("tripleclick",this.tripleClickHandler),this.__lastClickTime=+new Date,this.__lastLastClickTime=+new Date,this.__lastPointer={},this.on("mousedown",this.onMouseDown),this.draggableTextDelegate=new Go(this),super.initBehavior()}shouldStartDragging(){return this.draggableTextDelegate.isActive()}onDragStart(t){return this.draggableTextDelegate.onDragStart(t)}canDrop(t){return this.draggableTextDelegate.canDrop(t)}onMouseDown(t){if(!this.canvas)return;this.__newClickTime=+new Date;const e=t.pointer;this.isTripleClick(e)&&(this.fire("tripleclick",t),ki(t.e)),this.__lastLastClickTime=this.__lastClickTime,this.__lastClickTime=this.__newClickTime,this.__lastPointer=e,this.__lastSelected=this.selected&&!this.getActiveControl()}isTripleClick(t){return this.__newClickTime-this.__lastClickTime<500&&this.__lastClickTime-this.__lastLastClickTime<500&&this.__lastPointer.x===t.x&&this.__lastPointer.y===t.y}doubleClickHandler(t){this.isEditing&&this.selectWord(this.getSelectionStartFromPointer(t.e))}tripleClickHandler(t){this.isEditing&&this.selectLine(this.getSelectionStartFromPointer(t.e))}_mouseDownHandler(t){let{e:e}=t;this.canvas&&this.editable&&!Zo(e)&&!this.getActiveControl()&&(this.draggableTextDelegate.start(e)||(this.canvas.textEditingManager.register(this),this.selected&&(this.inCompositionMode=!1,this.setCursorByClick(e)),this.isEditing&&(this.__selectionStartOnMouseDown=this.selectionStart,this.selectionStart===this.selectionEnd&&this.abortCursorAnimation(),this.renderCursorOrSelection())))}_mouseDownHandlerBefore(t){let{e:e}=t;this.canvas&&this.editable&&!Zo(e)&&(this.selected=this===this.canvas._activeObject)}mouseUpHandler(t){let{e:e,transform:i}=t;const s=this.draggableTextDelegate.end(e);if(this.canvas){this.canvas.textEditingManager.unregister(this);const t=this.canvas._activeObject;if(t&&t!==this)return}!this.editable||this.group&&!this.group.interactive||i&&i.actionPerformed||Zo(e)||s||(this.__lastSelected&&!this.getActiveControl()?(this.selected=!1,this.__lastSelected=!1,this.enterEditing(e),this.selectionStart===this.selectionEnd?this.initDelayedCursor(!0):this.renderCursorOrSelection()):this.selected=!0)}setCursorByClick(t){const e=this.getSelectionStartFromPointer(t),i=this.selectionStart,s=this.selectionEnd;t.shiftKey?this.setSelectionStartEndWithShift(i,s,e):(this.selectionStart=e,this.selectionEnd=e),this.isEditing&&(this._fireSelectionChanged(),this._updateTextarea())}getSelectionStartFromPointer(t){const e=this.canvas.getScenePoint(t).transform(Be(this.calcTransformMatrix())).add(new Se(-this._getLeftOffset(),-this._getTopOffset()));let i=0,s=0,r=0;for(let l=0;l<this._textLines.length&&i<=e.y;l++)i+=this.getHeightOfLine(l),r=l,l>0&&(s+=this._textLines[l-1].length+this.missingNewlineOffset(l-1));let n=Math.abs(this._getLineLeftOffset(r));const o=this._textLines[r].length,a=this.__charBounds[r];for(let l=0;l<o;l++){const t=n+a[l].kernedWidth;if(e.x<=t){Math.abs(e.x-t)<=Math.abs(e.x-n)&&s++;break}n=t,s++}return Math.min(this.flipX?o-s:s,this._text.length)}}const ta="moveCursorUp",ea="moveCursorDown",ia="moveCursorLeft",sa="moveCursorRight",ra="exitEditing",na=xt({selectionStart:0,selectionEnd:0,selectionColor:"rgba(17,119,255,0.3)",isEditing:!1,editable:!0,editingBorderColor:"rgba(102,153,255,0.25)",cursorWidth:2,cursorColor:"",cursorDelay:1e3,cursorDuration:600,caching:!0,hiddenTextareaContainer:null,keysMap:{9:ra,27:ra,33:ta,34:ea,35:sa,36:ia,37:ia,38:ta,39:sa,40:ea},keysMapRtl:{9:ra,27:ra,33:ta,34:ea,35:ia,36:sa,37:sa,38:ta,39:ia,40:ea},ctrlKeysMapDown:{65:"selectAll"},ctrlKeysMapUp:{67:"copy",88:"cut"}},{_selectionDirection:null,_reSpace:/\s|\r?\n/,inCompositionMode:!1});class oa extends Qo{static getDefaults(){return xt(xt({},super.getDefaults()),oa.ownDefaults)}get type(){const t=super.type;return"itext"===t?"i-text":t}constructor(t,e){super(t,xt(xt({},oa.ownDefaults),e)),this.initBehavior()}_set(t,e){return this.isEditing&&this._savedProps&&t in this._savedProps?(this._savedProps[t]=e,this):("canvas"===t&&(this.canvas instanceof qn&&this.canvas.textEditingManager.remove(this),e instanceof qn&&e.textEditingManager.add(this)),super._set(t,e))}setSelectionStart(t){t=Math.max(t,0),this._updateAndFire("selectionStart",t)}setSelectionEnd(t){t=Math.min(t,this.text.length),this._updateAndFire("selectionEnd",t)}_updateAndFire(t,e){this[t]!==e&&(this._fireSelectionChanged(),this[t]=e),this._updateTextarea()}_fireSelectionChanged(){this.fire("selection:changed"),this.canvas&&this.canvas.fire("text:selection:changed",{target:this})}initDimensions(){this.isEditing&&this.initDelayedCursor(),super.initDimensions()}getSelectionStyles(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.selectionStart||0,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.selectionEnd,i=arguments.length>2?arguments[2]:void 0;return super.getSelectionStyles(t,e,i)}setSelectionStyles(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.selectionStart||0,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:this.selectionEnd;return super.setSelectionStyles(t,e,i)}get2DCursorLocation(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.selectionStart,e=arguments.length>1?arguments[1]:void 0;return super.get2DCursorLocation(t,e)}render(t){super.render(t),this.cursorOffsetCache={},this.renderCursorOrSelection()}toCanvasElement(t){const e=this.isEditing;this.isEditing=!1;const i=super.toCanvasElement(t);return this.isEditing=e,i}renderCursorOrSelection(){if(!this.isEditing)return;const t=this.clearContextTop(!0);if(!t)return;const e=this._getCursorBoundaries();this.selectionStart!==this.selectionEnd||this.inCompositionMode?this.renderSelection(t,e):this.renderCursor(t,e),this.canvas.contextTopDirty=!0,t.restore()}_getCursorBoundaries(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.selectionStart,e=arguments.length>1?arguments[1]:void 0;const i=this._getLeftOffset(),s=this._getTopOffset(),r=this._getCursorBoundariesOffsets(t,e);return{left:i,top:s,leftOffset:r.left,topOffset:r.top}}_getCursorBoundariesOffsets(t,e){return e?this.__getCursorBoundariesOffsets(t):this.cursorOffsetCache&&"top"in this.cursorOffsetCache?this.cursorOffsetCache:this.cursorOffsetCache=this.__getCursorBoundariesOffsets(t)}__getCursorBoundariesOffsets(t){let e=0,i=0;const{charIndex:s,lineIndex:r}=this.get2DCursorLocation(t);for(let l=0;l<r;l++)e+=this.getHeightOfLine(l);const n=this._getLineLeftOffset(r),o=this.__charBounds[r][s];o&&(i=o.left),0!==this.charSpacing&&s===this._textLines[r].length&&(i-=this._getWidthOfCharSpacing());const a={top:e,left:n+(i>0?i:0)};return"rtl"===this.direction&&(this.textAlign===Kt||this.textAlign===Ro||this.textAlign===No?a.left*=-1:this.textAlign===Yt||this.textAlign===Bo?a.left=n-(i>0?i:0):this.textAlign!==Ut&&this.textAlign!==zo||(a.left=n-(i>0?i:0))),a}renderCursorAt(t){this._renderCursor(this.canvas.contextTop,this._getCursorBoundaries(t,!0),t)}renderCursor(t,e){this._renderCursor(t,e,this.selectionStart)}getCursorRenderingData(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.selectionStart,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this._getCursorBoundaries(t);const i=this.get2DCursorLocation(t),s=i.lineIndex,r=i.charIndex>0?i.charIndex-1:0,n=this.getValueOfPropertyAt(s,r,"fontSize"),o=this.getObjectScaling().x*this.canvas.getZoom(),a=this.cursorWidth/o,l=this.getValueOfPropertyAt(s,r,"deltaY"),c=e.topOffset+(1-this._fontSizeFraction)*this.getHeightOfLine(s)/this.lineHeight-n*(1-this._fontSizeFraction);return{color:this.cursorColor||this.getValueOfPropertyAt(s,r,"fill"),opacity:this._currentCursorOpacity,left:e.left+e.leftOffset-a/2,top:c+e.top+l,width:a,height:n}}_renderCursor(t,e,i){const{color:s,opacity:r,left:n,top:o,width:a,height:l}=this.getCursorRenderingData(i,e);t.fillStyle=s,t.globalAlpha=r,t.fillRect(n,o,a,l)}renderSelection(t,e){const i={selectionStart:this.inCompositionMode?this.hiddenTextarea.selectionStart:this.selectionStart,selectionEnd:this.inCompositionMode?this.hiddenTextarea.selectionEnd:this.selectionEnd};this._renderSelection(t,i,e)}renderDragSourceEffect(){const t=this.draggableTextDelegate.getDragStartSelection();this._renderSelection(this.canvas.contextTop,t,this._getCursorBoundaries(t.selectionStart,!0))}renderDropTargetEffect(t){const e=this.getSelectionStartFromPointer(t);this.renderCursorAt(e)}_renderSelection(t,e,i){const s=e.selectionStart,r=e.selectionEnd,n=this.textAlign.includes(Ro),o=this.get2DCursorLocation(s),a=this.get2DCursorLocation(r),l=o.lineIndex,c=a.lineIndex,h=o.charIndex<0?0:o.charIndex,d=a.charIndex<0?0:a.charIndex;for(let u=l;u<=c;u++){const e=this._getLineLeftOffset(u)||0;let s=this.getHeightOfLine(u),r=0,o=0,a=0;if(u===l&&(o=this.__charBounds[l][h].left),u>=l&&u<c)a=n&&!this.isEndOfWrapping(u)?this.width:this.getLineWidth(u)||5;else if(u===c)if(0===d)a=this.__charBounds[c][d].left;else{const t=this._getWidthOfCharSpacing();a=this.__charBounds[c][d-1].left+this.__charBounds[c][d-1].width-t}r=s,(this.lineHeight<1||u===c&&this.lineHeight>1)&&(s/=this.lineHeight);let p=i.left+e+o,g=s,f=0;const m=a-o;this.inCompositionMode?(t.fillStyle=this.compositionColor||"black",g=1,f=s):t.fillStyle=this.selectionColor,"rtl"===this.direction&&(this.textAlign===Kt||this.textAlign===Ro||this.textAlign===No?p=this.width-p-m:this.textAlign===Yt||this.textAlign===Bo?p=i.left+e-a:this.textAlign!==Ut&&this.textAlign!==zo||(p=i.left+e-a)),t.fillRect(p,i.top+i.topOffset+f,m,g),i.topOffset+=r}}getCurrentCharFontSize(){const t=this._getCurrentCharIndex();return this.getValueOfPropertyAt(t.l,t.c,"fontSize")}getCurrentCharColor(){const t=this._getCurrentCharIndex();return this.getValueOfPropertyAt(t.l,t.c,pe)}_getCurrentCharIndex(){const t=this.get2DCursorLocation(this.selectionStart,!0),e=t.charIndex>0?t.charIndex-1:0;return{l:t.lineIndex,c:e}}dispose(){this.exitEditingImpl(),this.draggableTextDelegate.dispose(),super.dispose()}}bt(oa,"ownDefaults",na),bt(oa,"type","IText"),_e.setClass(oa),_e.setClass(oa,"i-text");class aa extends oa{static getDefaults(){return xt(xt({},super.getDefaults()),aa.ownDefaults)}constructor(t,e){super(t,xt(xt({},aa.ownDefaults),e))}static createControls(){return{controls:cr()}}initDimensions(){this.initialized&&(this.isEditing&&this.initDelayedCursor(),this._clearCache(),this.dynamicMinWidth=0,this._styleMap=this._generateStyleMap(this._splitText()),this.dynamicMinWidth>this.width&&this._set("width",this.dynamicMinWidth),this.textAlign.includes(Ro)&&this.enlargeSpaces(),this.height=this.calcTextHeight())}_generateStyleMap(t){let e=0,i=0,s=0;const r={};for(let n=0;n<t.graphemeLines.length;n++)"\n"===t.graphemeText[s]&&n>0?(i=0,s++,e++):!this.splitByGrapheme&&this._reSpaceAndTab.test(t.graphemeText[s])&&n>0&&(i++,s++),r[n]={line:e,offset:i},s+=t.graphemeLines[n].length,i+=t.graphemeLines[n].length;return r}styleHas(t,e){if(this._styleMap&&!this.isWrapping){const t=this._styleMap[e];t&&(e=t.line)}return super.styleHas(t,e)}isEmptyStyles(t){if(!this.styles)return!0;let e,i=0,s=t+1,r=!1;const n=this._styleMap[t],o=this._styleMap[t+1];n&&(t=n.line,i=n.offset),o&&(s=o.line,r=s===t,e=o.offset);const a=void 0===t?this.styles:{line:this.styles[t]};for(const l in a)for(const t in a[l]){const s=parseInt(t,10);if(s>=i&&(!r||s<e))for(const e in a[l][t])return!1}return!0}_getStyleDeclaration(t,e){if(this._styleMap&&!this.isWrapping){const i=this._styleMap[t];if(!i)return{};t=i.line,e=i.offset+e}return super._getStyleDeclaration(t,e)}_setStyleDeclaration(t,e,i){const s=this._styleMap[t];super._setStyleDeclaration(s.line,s.offset+e,i)}_deleteStyleDeclaration(t,e){const i=this._styleMap[t];super._deleteStyleDeclaration(i.line,i.offset+e)}_getLineStyle(t){const e=this._styleMap[t];return!!this.styles[e.line]}_setLineStyle(t){const e=this._styleMap[t];super._setLineStyle(e.line)}_wrapText(t,e){this.isWrapping=!0;const i=this.getGraphemeDataForRender(t),s=[];for(let r=0;r<i.wordsData.length;r++)s.push(...this._wrapLine(r,e,i));return this.isWrapping=!1,s}getGraphemeDataForRender(t){const e=this.splitByGrapheme,i=e?"":" ";let s=0;return{wordsData:t.map(((t,r)=>{let n=0;const o=e?this.graphemeSplit(t):this.wordSplit(t);return 0===o.length?[{word:[],width:0}]:o.map((t=>{const o=e?[t]:this.graphemeSplit(t),a=this._measureWord(o,r,n);return s=Math.max(a,s),n+=o.length+i.length,{word:o,width:a}}))})),largestWordWidth:s}}_measureWord(t,e){let i,s=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,r=0;for(let n=0,o=t.length;n<o;n++)r+=this._getGraphemeBox(t[n],e,n+s,i,!0).kernedWidth,i=t[n];return r}wordSplit(t){return t.split(this._wordJoiners)}_wrapLine(t,e,i){let{largestWordWidth:s,wordsData:r}=i,n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0;const o=this._getWidthOfCharSpacing(),a=this.splitByGrapheme,l=[],c=a?"":" ";let h=0,d=[],u=0,p=0,g=!0;e-=n;const f=Math.max(e,s,this.dynamicMinWidth),m=r[t];let v;for(u=0,v=0;v<m.length;v++){const{word:e,width:i}=m[v];u+=e.length,h+=p+i-o,h>f&&!g?(l.push(d),d=[],h=i,g=!0):h+=o,g||a||d.push(c),d=d.concat(e),p=a?0:this._measureWord([c],t,u),u++,g=!1}return v&&l.push(d),s+n>this.dynamicMinWidth&&(this.dynamicMinWidth=s-o+n),l}isEndOfWrapping(t){return!this._styleMap[t+1]||this._styleMap[t+1].line!==this._styleMap[t].line}missingNewlineOffset(t,e){return this.splitByGrapheme&&!e?this.isEndOfWrapping(t)?1:0:1}_splitTextIntoLines(t){const e=super._splitTextIntoLines(t),i=this._wrapText(e.lines,this.width),s=new Array(i.length);for(let r=0;r<i.length;r++)s[r]=i[r].join("");return e.lines=s,e.graphemeLines=i,e}getMinWidth(){return Math.max(this.minWidth,this.dynamicMinWidth)}_removeExtraneousStyles(){const t=new Map;for(const e in this._styleMap){const i=parseInt(e,10);if(this._textLines[i]){const i=this._styleMap[e].line;t.set("".concat(i),!0)}}for(const e in this.styles)t.has(e)||delete this.styles[e]}toObject(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];return super.toObject(["minWidth","splitByGrapheme",...t])}}bt(aa,"type","Textbox"),bt(aa,"textLayoutProperties",[...oa.textLayoutProperties,"width"]),bt(aa,"ownDefaults",{minWidth:20,dynamicMinWidth:2,lockScalingFlip:!0,noScaleCache:!1,_wordJoiners:/[ \t\r]/,splitByGrapheme:!1}),_e.setClass(aa);class la extends an{shouldPerformLayout(t){return!!t.target.clipPath&&super.shouldPerformLayout(t)}shouldLayoutClipPath(){return!1}calcLayoutResult(t,e){const{target:i}=t,{clipPath:s,group:r}=i;if(!s||!this.shouldPerformLayout(t))return;const{width:n,height:o}=Di(on(i,s)),a=new Se(n,o);if(s.absolutePositioned)return{center:Fi(s.getRelativeCenterPoint(),void 0,r?r.calcTransformMatrix():void 0),size:a};{const r=s.getRelativeCenterPoint().transform(i.calcOwnMatrix(),!0);if(this.shouldPerformLayout(t)){const{center:i=new Se,correction:s=new Se}=this.calcBoundingBox(e,t)||{};return{center:i.add(r),correction:s.subtract(r),size:a}}return{center:i.getRelativeCenterPoint().add(r),size:a}}}}bt(la,"type","clip-path"),_e.setClass(la);class ca extends an{getInitialSize(t,e){let{target:i}=t,{size:s}=e;return new Se(i.width||s.x,i.height||s.y)}}bt(ca,"type","fixed"),_e.setClass(ca);class ha extends un{subscribeTargets(t){const e=t.target;t.targets.reduce(((t,e)=>(e.parent&&t.add(e.parent),t)),new Set).forEach((t=>{t.layoutManager.subscribeTargets({target:t,targets:[e]})}))}unsubscribeTargets(t){const e=t.target,i=e.getObjects();t.targets.reduce(((t,e)=>(e.parent&&t.add(e.parent),t)),new Set).forEach((t=>{!i.some((e=>e.parent===t))&&t.layoutManager.unsubscribeTargets({target:t,targets:[e]})}))}}class da extends fn{static getDefaults(){return xt(xt({},super.getDefaults()),da.ownDefaults)}constructor(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};super(),Object.assign(this,da.ownDefaults),this.setOptions(e);const{left:i,top:s,layoutManager:r}=e;this.groupInit(t,{left:i,top:s,layoutManager:null!=r?r:new ha})}_shouldSetNestedCoords(){return!0}__objectSelectionMonitor(){}multiSelectAdd(){for(var t=arguments.length,e=new Array(t),i=0;i<t;i++)e[i]=arguments[i];"selection-order"===this.multiSelectionStacking?this.add(...e):e.forEach((t=>{const e=this._objects.findIndex((e=>e.isInFrontOf(t))),i=-1===e?this.size():e;this.insertAt(i,t)}))}canEnterGroup(t){return this.getObjects().some((e=>e.isDescendantOf(t)||t.isDescendantOf(e)))?(Ot("error","ActiveSelection: circular object trees are not supported, this call has no effect"),!1):super.canEnterGroup(t)}enterGroup(t,e){t.parent&&t.parent===t.group?t.parent._exitGroup(t):t.group&&t.parent!==t.group&&t.group.remove(t),this._enterGroup(t,e)}exitGroup(t,e){this._exitGroup(t,e),t.parent&&t.parent._enterGroup(t,!0)}_onAfterObjectsChange(t,e){super._onAfterObjectsChange(t,e);const i=new Set;e.forEach((t=>{const{parent:e}=t;e&&i.add(e)})),t===rn?i.forEach((t=>{t._onAfterObjectsChange(sn,e)})):i.forEach((t=>{t._set("dirty",!0)}))}onDeselect(){return this.removeAll(),!1}toString(){return"#<ActiveSelection: (".concat(this.complexity(),")>")}shouldCache(){return!1}isOnACache(){return!1}_renderControls(t,e,i){t.save(),t.globalAlpha=this.isMoving?this.borderOpacityWhenMoving:1;const s=xt(xt({hasControls:!1},i),{},{forActiveSelection:!0});for(let r=0;r<this._objects.length;r++)this._objects[r]._renderControls(t,s);super._renderControls(t,e),t.restore()}}bt(da,"type","ActiveSelection"),bt(da,"ownDefaults",{multiSelectionStacking:"canvas-stacking"}),_e.setClass(da),_e.setClass(da,"activeSelection");class ua{constructor(){bt(this,"resources",{})}applyFilters(t,e,i,s,r){const n=r.getContext("2d");if(!n)return;n.drawImage(e,0,0,i,s);const o={sourceWidth:i,sourceHeight:s,imageData:n.getImageData(0,0,i,s),originalEl:e,originalImageData:n.getImageData(0,0,i,s),canvasEl:r,ctx:n,filterBackend:this};t.forEach((t=>{t.applyTo(o)}));const{imageData:a}=o;return a.width===i&&a.height===s||(r.width=a.width,r.height=a.height),n.putImageData(a,0,0),o}}class pa{constructor(){let{tileSize:t=Tt.textureSize}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};bt(this,"aPosition",new Float32Array([0,0,0,1,1,0,1,1])),bt(this,"resources",{}),this.tileSize=t,this.setupGLContext(t,t),this.captureGPUInfo()}setupGLContext(t,e){this.dispose(),this.createWebGLCanvas(t,e)}createWebGLCanvas(t,e){const i=je({width:t,height:e}),s=i.getContext("webgl",{alpha:!0,premultipliedAlpha:!1,depth:!1,stencil:!1,antialias:!1});s&&(s.clearColor(0,0,0,0),this.canvas=i,this.gl=s)}applyFilters(t,e,i,s,r,n){const o=this.gl,a=r.getContext("2d");if(!o||!a)return;let l;n&&(l=this.getCachedTexture(n,e));const c={originalWidth:e.width||e.naturalWidth||0,originalHeight:e.height||e.naturalHeight||0,sourceWidth:i,sourceHeight:s,destinationWidth:i,destinationHeight:s,context:o,sourceTexture:this.createTexture(o,i,s,l?void 0:e),targetTexture:this.createTexture(o,i,s),originalTexture:l||this.createTexture(o,i,s,l?void 0:e),passes:t.length,webgl:!0,aPosition:this.aPosition,programCache:this.programCache,pass:0,filterBackend:this,targetCanvas:r},h=o.createFramebuffer();return o.bindFramebuffer(o.FRAMEBUFFER,h),t.forEach((t=>{t&&t.applyTo(c)})),function(t){const e=t.targetCanvas,i=e.width,s=e.height,r=t.destinationWidth,n=t.destinationHeight;i===r&&s===n||(e.width=r,e.height=n)}(c),this.copyGLTo2D(o,c),o.bindTexture(o.TEXTURE_2D,null),o.deleteTexture(c.sourceTexture),o.deleteTexture(c.targetTexture),o.deleteFramebuffer(h),a.setTransform(1,0,0,1,0,0),c}dispose(){this.canvas&&(this.canvas=null,this.gl=null),this.clearWebGLCaches()}clearWebGLCaches(){this.programCache={},this.textureCache={}}createTexture(t,e,i,s,r){const{NEAREST:n,TEXTURE_2D:o,RGBA:a,UNSIGNED_BYTE:l,CLAMP_TO_EDGE:c,TEXTURE_MAG_FILTER:h,TEXTURE_MIN_FILTER:d,TEXTURE_WRAP_S:u,TEXTURE_WRAP_T:p}=t,g=t.createTexture();return t.bindTexture(o,g),t.texParameteri(o,h,r||n),t.texParameteri(o,d,r||n),t.texParameteri(o,u,c),t.texParameteri(o,p,c),s?t.texImage2D(o,0,a,a,l,s):t.texImage2D(o,0,a,e,i,0,a,l,null),g}getCachedTexture(t,e,i){const{textureCache:s}=this;if(s[t])return s[t];{const r=this.createTexture(this.gl,e.width,e.height,e,i);return r&&(s[t]=r),r}}evictCachesForKey(t){this.textureCache[t]&&(this.gl.deleteTexture(this.textureCache[t]),delete this.textureCache[t])}copyGLTo2D(t,e){const i=t.canvas,s=e.targetCanvas,r=s.getContext("2d");if(!r)return;r.translate(0,s.height),r.scale(1,-1);const n=i.height-s.height;r.drawImage(i,0,n,s.width,s.height,0,0,s.width,s.height)}copyGLTo2DPutImageData(t,e){const i=e.targetCanvas.getContext("2d"),s=e.destinationWidth,r=e.destinationHeight,n=s*r*4;if(!i)return;const o=new Uint8Array(this.imageBuffer,0,n),a=new Uint8ClampedArray(this.imageBuffer,0,n);t.readPixels(0,0,s,r,t.RGBA,t.UNSIGNED_BYTE,o);const l=new ImageData(a,s,r);i.putImageData(l,0,0)}captureGPUInfo(){if(this.gpuInfo)return this.gpuInfo;const t=this.gl,e={renderer:"",vendor:""};if(!t)return e;const i=t.getExtension("WEBGL_debug_renderer_info");if(i){const s=t.getParameter(i.UNMASKED_RENDERER_WEBGL),r=t.getParameter(i.UNMASKED_VENDOR_WEBGL);s&&(e.renderer=s.toLowerCase()),r&&(e.vendor=r.toLowerCase())}return this.gpuInfo=e,e}}let ga;function fa(){return!ga&&(!(arguments.length>0&&void 0!==arguments[0])||arguments[0])&&(ga=function(){const{WebGLProbe:t}=jt();return t.queryWebGL(Pe()),Tt.enableGLFiltering&&t.isSupported(Tt.textureSize)?new pa({tileSize:Tt.textureSize}):new ua}()),ga}const ma=["filters","resizeFilter","src","crossOrigin","type"],va=["cropX","cropY"];class _a extends ur{static getDefaults(){return xt(xt({},super.getDefaults()),_a.ownDefaults)}constructor(t,e){super(),bt(this,"_lastScaleX",1),bt(this,"_lastScaleY",1),bt(this,"_filterScalingX",1),bt(this,"_filterScalingY",1),this.filters=[],Object.assign(this,_a.ownDefaults),this.setOptions(e),this.cacheKey="texture".concat(Me()),this.setElement("string"==typeof t?(this.canvas&&_i(this.canvas.getElement())||Lt()).getElementById(t):t,e)}getElement(){return this._element}setElement(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};this.removeTexture(this.cacheKey),this.removeTexture("".concat(this.cacheKey,"_filtered")),this._element=t,this._originalElement=t,this._setWidthHeight(e),t.classList.add(_a.CSS_CANVAS),0!==this.filters.length&&this.applyFilters(),this.resizeFilter&&this.applyResizeFilters()}removeTexture(t){const e=fa(!1);e instanceof pa&&e.evictCachesForKey(t)}dispose(){super.dispose(),this.removeTexture(this.cacheKey),this.removeTexture("".concat(this.cacheKey,"_filtered")),this._cacheContext=null,["_originalElement","_element","_filteredEl","_cacheCanvas"].forEach((t=>{const e=this[t];e&&jt().dispose(e),this[t]=void 0}))}getCrossOrigin(){return this._originalElement&&(this._originalElement.crossOrigin||null)}getOriginalSize(){const t=this.getElement();return t?{width:t.naturalWidth||t.width,height:t.naturalHeight||t.height}:{width:0,height:0}}_stroke(t){if(!this.stroke||0===this.strokeWidth)return;const e=this.width/2,i=this.height/2;t.beginPath(),t.moveTo(-e,-i),t.lineTo(e,-i),t.lineTo(e,i),t.lineTo(-e,i),t.lineTo(-e,-i),t.closePath()}toObject(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];const e=[];return this.filters.forEach((t=>{t&&e.push(t.toObject())})),xt(xt({},super.toObject([...va,...t])),{},{src:this.getSrc(),crossOrigin:this.getCrossOrigin(),filters:e},this.resizeFilter?{resizeFilter:this.resizeFilter.toObject()}:{})}hasCrop(){return!!this.cropX||!!this.cropY||this.width<this._element.width||this.height<this._element.height}_toSVG(){const t=[],e=this._element,i=-this.width/2,s=-this.height/2;let r=[],n=[],o="",a="";if(!e)return[];if(this.hasCrop()){const t=Me();r.push('<clipPath id="imageCrop_'+t+'">\n','\t<rect x="'+i+'" y="'+s+'" width="'+this.width+'" height="'+this.height+'" />\n',"</clipPath>\n"),o=' clip-path="url(#imageCrop_'+t+')" '}if(this.imageSmoothing||(a=' image-rendering="optimizeSpeed"'),t.push("\t<image ","COMMON_PARTS",'xlink:href="'.concat(this.getSvgSrc(!0),'" x="').concat(i-this.cropX,'" y="').concat(s-this.cropY,'" width="').concat(e.width||e.naturalWidth,'" height="').concat(e.height||e.naturalHeight,'"').concat(a).concat(o,"></image>\n")),this.stroke||this.strokeDashArray){const t=this.fill;this.fill=null,n=['\t<rect x="'.concat(i,'" y="').concat(s,'" width="').concat(this.width,'" height="').concat(this.height,'" style="').concat(this.getSvgStyles(),'" />\n')],this.fill=t}return r=this.paintFirst!==pe?r.concat(n,t):r.concat(t,n),r}getSrc(t){const e=t?this._element:this._originalElement;return e?e.toDataURL?e.toDataURL():this.srcFromAttribute?e.getAttribute("src")||"":e.src:this.src||""}getSvgSrc(t){return this.getSrc(t)}setSrc(t){let{crossOrigin:e,signal:i}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return Je(t,{crossOrigin:e,signal:i}).then((t=>{void 0!==e&&this.set({crossOrigin:e}),this.setElement(t)}))}toString(){return'#<Image: { src: "'.concat(this.getSrc(),'" }>')}applyResizeFilters(){const t=this.resizeFilter,e=this.minimumScaleTrigger,i=this.getTotalObjectScaling(),s=i.x,r=i.y,n=this._filteredEl||this._originalElement;if(this.group&&this.set("dirty",!0),!t||s>e&&r>e)return this._element=n,this._filterScalingX=1,this._filterScalingY=1,this._lastScaleX=s,void(this._lastScaleY=r);const o=je(n),{width:a,height:l}=n;this._element=o,this._lastScaleX=t.scaleX=s,this._lastScaleY=t.scaleY=r,fa().applyFilters([t],n,a,l,this._element),this._filterScalingX=o.width/this._originalElement.width,this._filterScalingY=o.height/this._originalElement.height}applyFilters(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.filters||[];if(t=t.filter((t=>t&&!t.isNeutralState())),this.set("dirty",!0),this.removeTexture("".concat(this.cacheKey,"_filtered")),0===t.length)return this._element=this._originalElement,this._filteredEl=void 0,this._filterScalingX=1,void(this._filterScalingY=1);const e=this._originalElement,i=e.naturalWidth||e.width,s=e.naturalHeight||e.height;if(this._element===this._originalElement){const t=je({width:i,height:s});this._element=t,this._filteredEl=t}else this._filteredEl&&(this._element=this._filteredEl,this._filteredEl.getContext("2d").clearRect(0,0,i,s),this._lastScaleX=1,this._lastScaleY=1);fa().applyFilters(t,this._originalElement,i,s,this._element),this._originalElement.width===this._element.width&&this._originalElement.height===this._element.height||(this._filterScalingX=this._element.width/this._originalElement.width,this._filterScalingY=this._element.height/this._originalElement.height)}_render(t){t.imageSmoothingEnabled=this.imageSmoothing,!0!==this.isMoving&&this.resizeFilter&&this._needsResize()&&this.applyResizeFilters(),this._stroke(t),this._renderPaintInOrder(t)}drawCacheOnCanvas(t){t.imageSmoothingEnabled=this.imageSmoothing,super.drawCacheOnCanvas(t)}shouldCache(){return this.needsItsOwnCache()}_renderFill(t){const e=this._element;if(!e)return;const i=this._filterScalingX,s=this._filterScalingY,r=this.width,n=this.height,o=Math.max(this.cropX,0),a=Math.max(this.cropY,0),l=e.naturalWidth||e.width,c=e.naturalHeight||e.height,h=o*i,d=a*s,u=Math.min(r*i,l-h),p=Math.min(n*s,c-d),g=-r/2,f=-n/2,m=Math.min(r,l/i-o),v=Math.min(n,c/s-a);e&&t.drawImage(e,h,d,u,p,g,f,m,v)}_needsResize(){const t=this.getTotalObjectScaling();return t.x!==this._lastScaleX||t.y!==this._lastScaleY}_resetWidthHeight(){this.set(this.getOriginalSize())}_setWidthHeight(){let{width:t,height:e}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const i=this.getOriginalSize();this.width=t||i.width,this.height=e||i.height}parsePreserveAspectRatioAttribute(){const t=(t=>{const[e,i]=t.trim().split(" "),[s,r]=(n=e)&&n!==Jt?[n.slice(1,4),n.slice(5,8)]:n===Jt?[n,n]:["Mid","Mid"];var n;return{meetOrSlice:i||"meet",alignX:s,alignY:r}})(this.preserveAspectRatio||""),e=this.width,i=this.height,s={width:e,height:i};let r,n=this._element.width,o=this._element.height,a=1,l=1,c=0,h=0,d=0,u=0;return!t||t.alignX===Jt&&t.alignY===Jt?(a=e/n,l=i/o):("meet"===t.meetOrSlice&&(a=l=((t,e)=>Math.min(e.width/t.width,e.height/t.height))(this._element,s),r=(e-n*a)/2,"Min"===t.alignX&&(c=-r),"Max"===t.alignX&&(c=r),r=(i-o*l)/2,"Min"===t.alignY&&(h=-r),"Max"===t.alignY&&(h=r)),"slice"===t.meetOrSlice&&(a=l=((t,e)=>Math.max(e.width/t.width,e.height/t.height))(this._element,s),r=n-e/a,"Mid"===t.alignX&&(d=r/2),"Max"===t.alignX&&(d=r),r=o-i/l,"Mid"===t.alignY&&(u=r/2),"Max"===t.alignY&&(u=r),n=e/a,o=i/l)),{width:n,height:o,scaleX:a,scaleY:l,offsetLeft:c,offsetTop:h,cropX:d,cropY:u}}static fromObject(t,e){let{filters:i,resizeFilter:s,src:r,crossOrigin:n,type:o}=t,a=wt(t,ma);return Promise.all([Je(r,xt(xt({},e),{},{crossOrigin:n})),i&&Ze(i,e),s&&Ze([s],e),Qe(a,e)]).then((t=>{let[e,i=[],[s]=[],n={}]=t;return new this(e,xt(xt({},a),{},{src:r,filters:i,resizeFilter:s},n))}))}static fromURL(t){let{crossOrigin:e=null,signal:i}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},s=arguments.length>2?arguments[2]:void 0;return Je(t,{crossOrigin:e,signal:i}).then((t=>new this(t,s)))}static async fromElement(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},i=arguments.length>2?arguments[2]:void 0;const s=Jr(t,this.ATTRIBUTE_NAMES,i);return this.fromURL(s["xlink:href"],e,s).catch((t=>(Ot("log","Unable to parse Image",t),null)))}}bt(_a,"type","Image"),bt(_a,"cacheProperties",[..._s,...va]),bt(_a,"ownDefaults",{strokeWidth:0,srcFromAttribute:!1,minimumScaleTrigger:.5,cropX:0,cropY:0,imageSmoothing:!0}),bt(_a,"CSS_CANVAS","canvas-img"),bt(_a,"ATTRIBUTE_NAMES",[...Cr,"x","y","width","height","preserveAspectRatio","xlink:href","crossOrigin","image-rendering"]),_e.setClass(_a),_e.setSVGClass(_a),Gi(["pattern","defs","symbol","metadata","clipPath","mask","desc"]);const ba=t=>void 0!==t.webgl,ya="precision highp float",xa="\n ".concat(ya,";\n varying vec2 vTexCoord;\n uniform sampler2D uTexture;\n void main() {\n gl_FragColor = texture2D(uTexture, vTexCoord);\n }"),wa=["type"],Ca=["type"],Sa=new RegExp(ya,"g");class Ta{get type(){return this.constructor.type}constructor(){let t=wt(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},wa);Object.assign(this,this.constructor.defaults,t)}getFragmentSource(){return xa}getVertexSource(){return"\n attribute vec2 aPosition;\n varying vec2 vTexCoord;\n void main() {\n vTexCoord = aPosition;\n gl_Position = vec4(aPosition * 2.0 - 1.0, 0.0, 1.0);\n }"}createProgram(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.getFragmentSource(),i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:this.getVertexSource();const{WebGLProbe:{GLPrecision:s="highp"}}=jt();"highp"!==s&&(e=e.replace(Sa,ya.replace("highp",s)));const r=t.createShader(t.VERTEX_SHADER),n=t.createShader(t.FRAGMENT_SHADER),o=t.createProgram();if(!r||!n||!o)throw new Et("Vertex, fragment shader or program creation error");if(t.shaderSource(r,i),t.compileShader(r),!t.getShaderParameter(r,t.COMPILE_STATUS))throw new Et("Vertex shader compile error for ".concat(this.type,": ").concat(t.getShaderInfoLog(r)));if(t.shaderSource(n,e),t.compileShader(n),!t.getShaderParameter(n,t.COMPILE_STATUS))throw new Et("Fragment shader compile error for ".concat(this.type,": ").concat(t.getShaderInfoLog(n)));if(t.attachShader(o,r),t.attachShader(o,n),t.linkProgram(o),!t.getProgramParameter(o,t.LINK_STATUS))throw new Et('Shader link error for "'.concat(this.type,'" ').concat(t.getProgramInfoLog(o)));const a=this.getUniformLocations(t,o)||{};return a.uStepW=t.getUniformLocation(o,"uStepW"),a.uStepH=t.getUniformLocation(o,"uStepH"),{program:o,attributeLocations:this.getAttributeLocations(t,o),uniformLocations:a}}getAttributeLocations(t,e){return{aPosition:t.getAttribLocation(e,"aPosition")}}getUniformLocations(t,e){const i=this.constructor.uniformLocations,s={};for(let r=0;r<i.length;r++)s[i[r]]=t.getUniformLocation(e,i[r]);return s}sendAttributeData(t,e,i){const s=e.aPosition,r=t.createBuffer();t.bindBuffer(t.ARRAY_BUFFER,r),t.enableVertexAttribArray(s),t.vertexAttribPointer(s,2,t.FLOAT,!1,0,0),t.bufferData(t.ARRAY_BUFFER,i,t.STATIC_DRAW)}_setupFrameBuffer(t){const e=t.context;if(t.passes>1){const i=t.destinationWidth,s=t.destinationHeight;t.sourceWidth===i&&t.sourceHeight===s||(e.deleteTexture(t.targetTexture),t.targetTexture=t.filterBackend.createTexture(e,i,s)),e.framebufferTexture2D(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,t.targetTexture,0)}else e.bindFramebuffer(e.FRAMEBUFFER,null),e.finish()}_swapTextures(t){t.passes--,t.pass++;const e=t.targetTexture;t.targetTexture=t.sourceTexture,t.sourceTexture=e}isNeutralState(t){return!1}applyTo(t){ba(t)?(this._setupFrameBuffer(t),this.applyToWebGL(t),this._swapTextures(t)):this.applyTo2d(t)}applyTo2d(t){}getCacheKey(){return this.type}retrieveShader(t){const e=this.getCacheKey();return t.programCache[e]||(t.programCache[e]=this.createProgram(t.context)),t.programCache[e]}applyToWebGL(t){const e=t.context,i=this.retrieveShader(t);0===t.pass&&t.originalTexture?e.bindTexture(e.TEXTURE_2D,t.originalTexture):e.bindTexture(e.TEXTURE_2D,t.sourceTexture),e.useProgram(i.program),this.sendAttributeData(e,i.attributeLocations,t.aPosition),e.uniform1f(i.uniformLocations.uStepW,1/t.sourceWidth),e.uniform1f(i.uniformLocations.uStepH,1/t.sourceHeight),this.sendUniformData(e,i.uniformLocations),e.viewport(0,0,t.destinationWidth,t.destinationHeight),e.drawArrays(e.TRIANGLE_STRIP,0,4)}bindAdditionalTexture(t,e,i){t.activeTexture(i),t.bindTexture(t.TEXTURE_2D,e),t.activeTexture(t.TEXTURE0)}unbindAdditionalTexture(t,e){t.activeTexture(e),t.bindTexture(t.TEXTURE_2D,null),t.activeTexture(t.TEXTURE0)}sendUniformData(t,e){}createHelpLayer(t){if(!t.helpLayer){const{sourceWidth:e,sourceHeight:i}=t,s=je({width:e,height:i});t.helpLayer=s}}toObject(){const t=Object.keys(this.constructor.defaults||{});return xt({type:this.type},t.reduce(((t,e)=>(t[e]=this[e],t)),{}))}toJSON(){return this.toObject()}static async fromObject(t,e){return new this(wt(t,Ca))}}bt(Ta,"type","BaseFilter"),bt(Ta,"uniformLocations",[]);const Oa={multiply:"gl_FragColor.rgb *= uColor.rgb;\n",screen:"gl_FragColor.rgb = 1.0 - (1.0 - gl_FragColor.rgb) * (1.0 - uColor.rgb);\n",add:"gl_FragColor.rgb += uColor.rgb;\n",difference:"gl_FragColor.rgb = abs(gl_FragColor.rgb - uColor.rgb);\n",subtract:"gl_FragColor.rgb -= uColor.rgb;\n",lighten:"gl_FragColor.rgb = max(gl_FragColor.rgb, uColor.rgb);\n",darken:"gl_FragColor.rgb = min(gl_FragColor.rgb, uColor.rgb);\n",exclusion:"gl_FragColor.rgb += uColor.rgb - 2.0 * (uColor.rgb * gl_FragColor.rgb);\n",overlay:"\n if (uColor.r < 0.5) {\n gl_FragColor.r *= 2.0 * uColor.r;\n } else {\n gl_FragColor.r = 1.0 - 2.0 * (1.0 - gl_FragColor.r) * (1.0 - uColor.r);\n }\n if (uColor.g < 0.5) {\n gl_FragColor.g *= 2.0 * uColor.g;\n } else {\n gl_FragColor.g = 1.0 - 2.0 * (1.0 - gl_FragColor.g) * (1.0 - uColor.g);\n }\n if (uColor.b < 0.5) {\n gl_FragColor.b *= 2.0 * uColor.b;\n } else {\n gl_FragColor.b = 1.0 - 2.0 * (1.0 - gl_FragColor.b) * (1.0 - uColor.b);\n }\n ",tint:"\n gl_FragColor.rgb *= (1.0 - uColor.a);\n gl_FragColor.rgb += uColor.rgb;\n "};class Ea extends Ta{getCacheKey(){return"".concat(this.type,"_").concat(this.mode)}getFragmentSource(){return"\n precision highp float;\n uniform sampler2D uTexture;\n uniform vec4 uColor;\n varying vec2 vTexCoord;\n void main() {\n vec4 color = texture2D(uTexture, vTexCoord);\n gl_FragColor = color;\n if (color.a > 0.0) {\n ".concat(Oa[this.mode],"\n }\n }\n ")}applyTo2d(t){let{imageData:{data:e}}=t;const i=new li(this.color).getSource(),s=this.alpha,r=i[0]*s,n=i[1]*s,o=i[2]*s,a=1-s;for(let l=0;l<e.length;l+=4){const t=e[l],i=e[l+1],s=e[l+2];let c,h,d;switch(this.mode){case"multiply":c=t*r/255,h=i*n/255,d=s*o/255;break;case"screen":c=255-(255-t)*(255-r)/255,h=255-(255-i)*(255-n)/255,d=255-(255-s)*(255-o)/255;break;case"add":c=t+r,h=i+n,d=s+o;break;case"difference":c=Math.abs(t-r),h=Math.abs(i-n),d=Math.abs(s-o);break;case"subtract":c=t-r,h=i-n,d=s-o;break;case"darken":c=Math.min(t,r),h=Math.min(i,n),d=Math.min(s,o);break;case"lighten":c=Math.max(t,r),h=Math.max(i,n),d=Math.max(s,o);break;case"overlay":c=r<128?2*t*r/255:255-2*(255-t)*(255-r)/255,h=n<128?2*i*n/255:255-2*(255-i)*(255-n)/255,d=o<128?2*s*o/255:255-2*(255-s)*(255-o)/255;break;case"exclusion":c=r+t-2*r*t/255,h=n+i-2*n*i/255,d=o+s-2*o*s/255;break;case"tint":c=r+t*a,h=n+i*a,d=o+s*a}e[l]=c,e[l+1]=h,e[l+2]=d}}sendUniformData(t,e){const i=new li(this.color).getSource();i[0]=this.alpha*i[0]/255,i[1]=this.alpha*i[1]/255,i[2]=this.alpha*i[2]/255,i[3]=this.alpha,t.uniform4fv(e.uColor,i)}}bt(Ea,"defaults",{color:"#F95C63",mode:"multiply",alpha:1}),bt(Ea,"type","BlendColor"),bt(Ea,"uniformLocations",["uColor"]),_e.setClass(Ea);const ka={multiply:"\n precision highp float;\n uniform sampler2D uTexture;\n uniform sampler2D uImage;\n uniform vec4 uColor;\n varying vec2 vTexCoord;\n varying vec2 vTexCoord2;\n void main() {\n vec4 color = texture2D(uTexture, vTexCoord);\n vec4 color2 = texture2D(uImage, vTexCoord2);\n color.rgba *= color2.rgba;\n gl_FragColor = color;\n }\n ",mask:"\n precision highp float;\n uniform sampler2D uTexture;\n uniform sampler2D uImage;\n uniform vec4 uColor;\n varying vec2 vTexCoord;\n varying vec2 vTexCoord2;\n void main() {\n vec4 color = texture2D(uTexture, vTexCoord);\n vec4 color2 = texture2D(uImage, vTexCoord2);\n color.a = color2.a;\n gl_FragColor = color;\n }\n "},Da=["type","image"];class Aa extends Ta{getCacheKey(){return"".concat(this.type,"_").concat(this.mode)}getFragmentSource(){return ka[this.mode]}getVertexSource(){return"\n attribute vec2 aPosition;\n varying vec2 vTexCoord;\n varying vec2 vTexCoord2;\n uniform mat3 uTransformMatrix;\n void main() {\n vTexCoord = aPosition;\n vTexCoord2 = (uTransformMatrix * vec3(aPosition, 1.0)).xy;\n gl_Position = vec4(aPosition * 2.0 - 1.0, 0.0, 1.0);\n }\n "}applyToWebGL(t){const e=t.context,i=this.createTexture(t.filterBackend,this.image);this.bindAdditionalTexture(e,i,e.TEXTURE1),super.applyToWebGL(t),this.unbindAdditionalTexture(e,e.TEXTURE1)}createTexture(t,e){return t.getCachedTexture(e.cacheKey,e.getElement())}calculateMatrix(){const t=this.image,{width:e,height:i}=t.getElement();return[1/t.scaleX,0,0,0,1/t.scaleY,0,-t.left/e,-t.top/i,1]}applyTo2d(t){let{imageData:{data:e,width:i,height:s},filterBackend:{resources:r}}=t;const n=this.image;r.blendImage||(r.blendImage=Pe());const o=r.blendImage,a=o.getContext("2d");o.width!==i||o.height!==s?(o.width=i,o.height=s):a.clearRect(0,0,i,s),a.setTransform(n.scaleX,0,0,n.scaleY,n.left,n.top),a.drawImage(n.getElement(),0,0,i,s);const l=a.getImageData(0,0,i,s).data;for(let c=0;c<e.length;c+=4){const t=e[c],i=e[c+1],s=e[c+2],r=e[c+3],n=l[c],o=l[c+1],a=l[c+2],h=l[c+3];switch(this.mode){case"multiply":e[c]=t*n/255,e[c+1]=i*o/255,e[c+2]=s*a/255,e[c+3]=r*h/255;break;case"mask":e[c+3]=h}}}sendUniformData(t,e){const i=this.calculateMatrix();t.uniform1i(e.uImage,1),t.uniformMatrix3fv(e.uTransformMatrix,!1,i)}toObject(){return xt(xt({},super.toObject()),{},{image:this.image&&this.image.toObject()})}static async fromObject(t,e){let{type:i,image:s}=t,r=wt(t,Da);return _a.fromObject(s,e).then((t=>new this(xt(xt({},r),{},{image:t}))))}}bt(Aa,"type","BlendImage"),bt(Aa,"defaults",{mode:"multiply",alpha:1}),bt(Aa,"uniformLocations",["uTransformMatrix","uImage"]),_e.setClass(Aa);class Ma extends Ta{getFragmentSource(){return"\n precision highp float;\n uniform sampler2D uTexture;\n uniform vec2 uDelta;\n varying vec2 vTexCoord;\n const float nSamples = 15.0;\n vec3 v3offset = vec3(12.9898, 78.233, 151.7182);\n float random(vec3 scale) {\n /* use the fragment position for a different seed per-pixel */\n return fract(sin(dot(gl_FragCoord.xyz, scale)) * 43758.5453);\n }\n void main() {\n vec4 color = vec4(0.0);\n float total = 0.0;\n float offset = random(v3offset);\n for (float t = -nSamples; t <= nSamples; t++) {\n float percent = (t + offset - 0.5) / nSamples;\n float weight = 1.0 - abs(percent);\n color += texture2D(uTexture, vTexCoord + uDelta * percent) * weight;\n total += weight;\n }\n gl_FragColor = color / total;\n }\n "}applyTo(t){ba(t)?(this.aspectRatio=t.sourceWidth/t.sourceHeight,t.passes++,this._setupFrameBuffer(t),this.horizontal=!0,this.applyToWebGL(t),this._swapTextures(t),this._setupFrameBuffer(t),this.horizontal=!1,this.applyToWebGL(t),this._swapTextures(t)):this.applyTo2d(t)}applyTo2d(t){t.imageData=this.simpleBlur(t)}simpleBlur(t){let{ctx:e,imageData:i,filterBackend:{resources:s}}=t;const{width:r,height:n}=i;s.blurLayer1||(s.blurLayer1=Pe(),s.blurLayer2=Pe());const o=s.blurLayer1,a=s.blurLayer2;o.width===r&&o.height===n||(a.width=o.width=r,a.height=o.height=n);const l=o.getContext("2d"),c=a.getContext("2d"),h=.06*this.blur*.5;let d,u,p,g;for(l.putImageData(i,0,0),c.clearRect(0,0,r,n),g=-15;g<=15;g++)d=(Math.random()-.5)/4,u=g/15,p=h*u*r+d,c.globalAlpha=1-Math.abs(u),c.drawImage(o,p,d),l.drawImage(a,0,0),c.globalAlpha=1,c.clearRect(0,0,a.width,a.height);for(g=-15;g<=15;g++)d=(Math.random()-.5)/4,u=g/15,p=h*u*n+d,c.globalAlpha=1-Math.abs(u),c.drawImage(o,d,p),l.drawImage(a,0,0),c.globalAlpha=1,c.clearRect(0,0,a.width,a.height);e.drawImage(o,0,0);const f=e.getImageData(0,0,o.width,o.height);return l.globalAlpha=1,l.clearRect(0,0,o.width,o.height),f}sendUniformData(t,e){const i=this.chooseRightDelta();t.uniform2fv(e.uDelta,i)}isNeutralState(){return 0===this.blur}chooseRightDelta(){let t=1;const e=[0,0];this.horizontal?this.aspectRatio>1&&(t=1/this.aspectRatio):this.aspectRatio<1&&(t=this.aspectRatio);const i=t*this.blur*.12;return this.horizontal?e[0]=i:e[1]=i,e}}bt(Ma,"type","Blur"),bt(Ma,"defaults",{blur:0}),bt(Ma,"uniformLocations",["uDelta"]),_e.setClass(Ma);class Pa extends Ta{getFragmentSource(){return"\n precision highp float;\n uniform sampler2D uTexture;\n uniform float uBrightness;\n varying vec2 vTexCoord;\n void main() {\n vec4 color = texture2D(uTexture, vTexCoord);\n color.rgb += uBrightness;\n gl_FragColor = color;\n }\n"}applyTo2d(t){let{imageData:{data:e}}=t;const i=Math.round(255*this.brightness);for(let s=0;s<e.length;s+=4)e[s]+=i,e[s+1]+=i,e[s+2]+=i}isNeutralState(){return 0===this.brightness}sendUniformData(t,e){t.uniform1f(e.uBrightness,this.brightness)}}bt(Pa,"type","Brightness"),bt(Pa,"defaults",{brightness:0}),bt(Pa,"uniformLocations",["uBrightness"]),_e.setClass(Pa);const ja={matrix:[1,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,1,0],colorsOnly:!0};class La extends Ta{getFragmentSource(){return"\n precision highp float;\n uniform sampler2D uTexture;\n varying vec2 vTexCoord;\n uniform mat4 uColorMatrix;\n uniform vec4 uConstants;\n void main() {\n vec4 color = texture2D(uTexture, vTexCoord);\n color *= uColorMatrix;\n color += uConstants;\n gl_FragColor = color;\n }"}applyTo2d(t){const e=t.imageData.data,i=this.matrix,s=this.colorsOnly;for(let r=0;r<e.length;r+=4){const t=e[r],n=e[r+1],o=e[r+2];if(e[r]=t*i[0]+n*i[1]+o*i[2]+255*i[4],e[r+1]=t*i[5]+n*i[6]+o*i[7]+255*i[9],e[r+2]=t*i[10]+n*i[11]+o*i[12]+255*i[14],!s){const s=e[r+3];e[r]+=s*i[3],e[r+1]+=s*i[8],e[r+2]+=s*i[13],e[r+3]=t*i[15]+n*i[16]+o*i[17]+s*i[18]+255*i[19]}}}sendUniformData(t,e){const i=this.matrix,s=[i[0],i[1],i[2],i[3],i[5],i[6],i[7],i[8],i[10],i[11],i[12],i[13],i[15],i[16],i[17],i[18]],r=[i[4],i[9],i[14],i[19]];t.uniformMatrix4fv(e.uColorMatrix,!1,s),t.uniform4fv(e.uConstants,r)}toObject(){return xt(xt({},super.toObject()),{},{matrix:[...this.matrix]})}}function Fa(t,e){var i;const s=(bt(i=class extends La{toObject(){return{type:this.type,colorsOnly:this.colorsOnly}}},"type",t),bt(i,"defaults",{colorsOnly:!1,matrix:e}),i);return _e.setClass(s,t),s}bt(La,"type","ColorMatrix"),bt(La,"defaults",ja),bt(La,"uniformLocations",["uColorMatrix","uConstants"]),_e.setClass(La),Fa("Brownie",[.5997,.34553,-.27082,0,.186,-.0377,.86095,.15059,0,-.1449,.24113,-.07441,.44972,0,-.02965,0,0,0,1,0]),Fa("Vintage",[.62793,.32021,-.03965,0,.03784,.02578,.64411,.03259,0,.02926,.0466,-.08512,.52416,0,.02023,0,0,0,1,0]),Fa("Kodachrome",[1.12855,-.39673,-.03992,0,.24991,-.16404,1.08352,-.05498,0,.09698,-.16786,-.56034,1.60148,0,.13972,0,0,0,1,0]),Fa("Technicolor",[1.91252,-.85453,-.09155,0,.04624,-.30878,1.76589,-.10601,0,-.27589,-.2311,-.75018,1.84759,0,.12137,0,0,0,1,0]),Fa("Polaroid",[1.438,-.062,-.062,0,0,-.122,1.378,-.122,0,0,-.016,-.016,1.483,0,0,0,0,0,1,0]),Fa("Sepia",[.393,.769,.189,0,0,.349,.686,.168,0,0,.272,.534,.131,0,0,0,0,0,1,0]),Fa("BlackWhite",[1.5,1.5,1.5,0,-1,1.5,1.5,1.5,0,-1,1.5,1.5,1.5,0,-1,0,0,0,1,0]);class Ia extends Ta{constructor(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};super(t),this.subFilters=t.subFilters||[]}applyTo(t){ba(t)&&(t.passes+=this.subFilters.length-1),this.subFilters.forEach((e=>{e.applyTo(t)}))}toObject(){return{type:this.type,subFilters:this.subFilters.map((t=>t.toObject()))}}isNeutralState(){return!this.subFilters.some((t=>!t.isNeutralState()))}static fromObject(t,e){return Promise.all((t.subFilters||[]).map((t=>_e.getClass(t.type).fromObject(t,e)))).then((t=>new this({subFilters:t})))}}bt(Ia,"type","Composed"),_e.setClass(Ia);class Ra extends Ta{getFragmentSource(){return"\n precision highp float;\n uniform sampler2D uTexture;\n uniform float uContrast;\n varying vec2 vTexCoord;\n void main() {\n vec4 color = texture2D(uTexture, vTexCoord);\n float contrastF = 1.015 * (uContrast + 1.0) / (1.0 * (1.015 - uContrast));\n color.rgb = contrastF * (color.rgb - 0.5) + 0.5;\n gl_FragColor = color;\n }"}isNeutralState(){return 0===this.contrast}applyTo2d(t){let{imageData:{data:e}}=t;const i=Math.floor(255*this.contrast),s=259*(i+255)/(255*(259-i));for(let r=0;r<e.length;r+=4)e[r]=s*(e[r]-128)+128,e[r+1]=s*(e[r+1]-128)+128,e[r+2]=s*(e[r+2]-128)+128}sendUniformData(t,e){t.uniform1f(e.uContrast,this.contrast)}}bt(Ra,"type","Contrast"),bt(Ra,"defaults",{contrast:0}),bt(Ra,"uniformLocations",["uContrast"]),_e.setClass(Ra);const Ba={Convolute_3_1:"\n precision highp float;\n uniform sampler2D uTexture;\n uniform float uMatrix[9];\n uniform float uStepW;\n uniform float uStepH;\n varying vec2 vTexCoord;\n void main() {\n vec4 color = vec4(0, 0, 0, 0);\n for (float h = 0.0; h < 3.0; h+=1.0) {\n for (float w = 0.0; w < 3.0; w+=1.0) {\n vec2 matrixPos = vec2(uStepW * (w - 1), uStepH * (h - 1));\n color += texture2D(uTexture, vTexCoord + matrixPos) * uMatrix[int(h * 3.0 + w)];\n }\n }\n gl_FragColor = color;\n }\n ",Convolute_3_0:"\n precision highp float;\n uniform sampler2D uTexture;\n uniform float uMatrix[9];\n uniform float uStepW;\n uniform float uStepH;\n varying vec2 vTexCoord;\n void main() {\n vec4 color = vec4(0, 0, 0, 1);\n for (float h = 0.0; h < 3.0; h+=1.0) {\n for (float w = 0.0; w < 3.0; w+=1.0) {\n vec2 matrixPos = vec2(uStepW * (w - 1.0), uStepH * (h - 1.0));\n color.rgb += texture2D(uTexture, vTexCoord + matrixPos).rgb * uMatrix[int(h * 3.0 + w)];\n }\n }\n float alpha = texture2D(uTexture, vTexCoord).a;\n gl_FragColor = color;\n gl_FragColor.a = alpha;\n }\n ",Convolute_5_1:"\n precision highp float;\n uniform sampler2D uTexture;\n uniform float uMatrix[25];\n uniform float uStepW;\n uniform float uStepH;\n varying vec2 vTexCoord;\n void main() {\n vec4 color = vec4(0, 0, 0, 0);\n for (float h = 0.0; h < 5.0; h+=1.0) {\n for (float w = 0.0; w < 5.0; w+=1.0) {\n vec2 matrixPos = vec2(uStepW * (w - 2.0), uStepH * (h - 2.0));\n color += texture2D(uTexture, vTexCoord + matrixPos) * uMatrix[int(h * 5.0 + w)];\n }\n }\n gl_FragColor = color;\n }\n ",Convolute_5_0:"\n precision highp float;\n uniform sampler2D uTexture;\n uniform float uMatrix[25];\n uniform float uStepW;\n uniform float uStepH;\n varying vec2 vTexCoord;\n void main() {\n vec4 color = vec4(0, 0, 0, 1);\n for (float h = 0.0; h < 5.0; h+=1.0) {\n for (float w = 0.0; w < 5.0; w+=1.0) {\n vec2 matrixPos = vec2(uStepW * (w - 2.0), uStepH * (h - 2.0));\n color.rgb += texture2D(uTexture, vTexCoord + matrixPos).rgb * uMatrix[int(h * 5.0 + w)];\n }\n }\n float alpha = texture2D(uTexture, vTexCoord).a;\n gl_FragColor = color;\n gl_FragColor.a = alpha;\n }\n ",Convolute_7_1:"\n precision highp float;\n uniform sampler2D uTexture;\n uniform float uMatrix[49];\n uniform float uStepW;\n uniform float uStepH;\n varying vec2 vTexCoord;\n void main() {\n vec4 color = vec4(0, 0, 0, 0);\n for (float h = 0.0; h < 7.0; h+=1.0) {\n for (float w = 0.0; w < 7.0; w+=1.0) {\n vec2 matrixPos = vec2(uStepW * (w - 3.0), uStepH * (h - 3.0));\n color += texture2D(uTexture, vTexCoord + matrixPos) * uMatrix[int(h * 7.0 + w)];\n }\n }\n gl_FragColor = color;\n }\n ",Convolute_7_0:"\n precision highp float;\n uniform sampler2D uTexture;\n uniform float uMatrix[49];\n uniform float uStepW;\n uniform float uStepH;\n varying vec2 vTexCoord;\n void main() {\n vec4 color = vec4(0, 0, 0, 1);\n for (float h = 0.0; h < 7.0; h+=1.0) {\n for (float w = 0.0; w < 7.0; w+=1.0) {\n vec2 matrixPos = vec2(uStepW * (w - 3.0), uStepH * (h - 3.0));\n color.rgb += texture2D(uTexture, vTexCoord + matrixPos).rgb * uMatrix[int(h * 7.0 + w)];\n }\n }\n float alpha = texture2D(uTexture, vTexCoord).a;\n gl_FragColor = color;\n gl_FragColor.a = alpha;\n }\n ",Convolute_9_1:"\n precision highp float;\n uniform sampler2D uTexture;\n uniform float uMatrix[81];\n uniform float uStepW;\n uniform float uStepH;\n varying vec2 vTexCoord;\n void main() {\n vec4 color = vec4(0, 0, 0, 0);\n for (float h = 0.0; h < 9.0; h+=1.0) {\n for (float w = 0.0; w < 9.0; w+=1.0) {\n vec2 matrixPos = vec2(uStepW * (w - 4.0), uStepH * (h - 4.0));\n color += texture2D(uTexture, vTexCoord + matrixPos) * uMatrix[int(h * 9.0 + w)];\n }\n }\n gl_FragColor = color;\n }\n ",Convolute_9_0:"\n precision highp float;\n uniform sampler2D uTexture;\n uniform float uMatrix[81];\n uniform float uStepW;\n uniform float uStepH;\n varying vec2 vTexCoord;\n void main() {\n vec4 color = vec4(0, 0, 0, 1);\n for (float h = 0.0; h < 9.0; h+=1.0) {\n for (float w = 0.0; w < 9.0; w+=1.0) {\n vec2 matrixPos = vec2(uStepW * (w - 4.0), uStepH * (h - 4.0));\n color.rgb += texture2D(uTexture, vTexCoord + matrixPos).rgb * uMatrix[int(h * 9.0 + w)];\n }\n }\n float alpha = texture2D(uTexture, vTexCoord).a;\n gl_FragColor = color;\n gl_FragColor.a = alpha;\n }\n "};class Na extends Ta{getCacheKey(){return"".concat(this.type,"_").concat(Math.sqrt(this.matrix.length),"_").concat(this.opaque?1:0)}getFragmentSource(){return Ba[this.getCacheKey()]}applyTo2d(t){const e=t.imageData,i=e.data,s=this.matrix,r=Math.round(Math.sqrt(s.length)),n=Math.floor(r/2),o=e.width,a=e.height,l=t.ctx.createImageData(o,a),c=l.data,h=this.opaque?1:0;let d,u,p,g,f,m,v,_,b,y,x,w,C;for(x=0;x<a;x++)for(y=0;y<o;y++){for(f=4*(x*o+y),d=0,u=0,p=0,g=0,C=0;C<r;C++)for(w=0;w<r;w++)v=x+C-n,m=y+w-n,v<0||v>=a||m<0||m>=o||(_=4*(v*o+m),b=s[C*r+w],d+=i[_]*b,u+=i[_+1]*b,p+=i[_+2]*b,h||(g+=i[_+3]*b));c[f]=d,c[f+1]=u,c[f+2]=p,c[f+3]=h?i[f+3]:g}t.imageData=l}sendUniformData(t,e){t.uniform1fv(e.uMatrix,this.matrix)}toObject(){return xt(xt({},super.toObject()),{},{opaque:this.opaque,matrix:[...this.matrix]})}}bt(Na,"type","Convolute"),bt(Na,"defaults",{opaque:!1,matrix:[0,0,0,0,1,0,0,0,0]}),bt(Na,"uniformLocations",["uMatrix","uOpaque","uHalfSize","uSize"]),_e.setClass(Na);const za="Gamma";class Va extends Ta{getFragmentSource(){return"\n precision highp float;\n uniform sampler2D uTexture;\n uniform vec3 uGamma;\n varying vec2 vTexCoord;\n void main() {\n vec4 color = texture2D(uTexture, vTexCoord);\n vec3 correction = (1.0 / uGamma);\n color.r = pow(color.r, correction.r);\n color.g = pow(color.g, correction.g);\n color.b = pow(color.b, correction.b);\n gl_FragColor = color;\n gl_FragColor.rgb *= color.a;\n }\n"}constructor(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};super(t),this.gamma=t.gamma||this.constructor.defaults.gamma.concat()}applyTo2d(t){let{imageData:{data:e}}=t;const i=this.gamma,s=1/i[0],r=1/i[1],n=1/i[2];this.rgbValues||(this.rgbValues={r:new Uint8Array(256),g:new Uint8Array(256),b:new Uint8Array(256)});const o=this.rgbValues;for(let a=0;a<256;a++)o.r[a]=255*Math.pow(a/255,s),o.g[a]=255*Math.pow(a/255,r),o.b[a]=255*Math.pow(a/255,n);for(let a=0;a<e.length;a+=4)e[a]=o.r[e[a]],e[a+1]=o.g[e[a+1]],e[a+2]=o.b[e[a+2]]}sendUniformData(t,e){t.uniform3fv(e.uGamma,this.gamma)}isNeutralState(){const{gamma:t}=this;return 1===t[0]&&1===t[1]&&1===t[2]}toObject(){return{type:za,gamma:this.gamma.concat()}}}bt(Va,"type",za),bt(Va,"defaults",{gamma:[1,1,1]}),bt(Va,"uniformLocations",["uGamma"]),_e.setClass(Va);const $a={average:"\n precision highp float;\n uniform sampler2D uTexture;\n varying vec2 vTexCoord;\n void main() {\n vec4 color = texture2D(uTexture, vTexCoord);\n float average = (color.r + color.b + color.g) / 3.0;\n gl_FragColor = vec4(average, average, average, color.a);\n }\n ",lightness:"\n precision highp float;\n uniform sampler2D uTexture;\n uniform int uMode;\n varying vec2 vTexCoord;\n void main() {\n vec4 col = texture2D(uTexture, vTexCoord);\n float average = (max(max(col.r, col.g),col.b) + min(min(col.r, col.g),col.b)) / 2.0;\n gl_FragColor = vec4(average, average, average, col.a);\n }\n ",luminosity:"\n precision highp float;\n uniform sampler2D uTexture;\n uniform int uMode;\n varying vec2 vTexCoord;\n void main() {\n vec4 col = texture2D(uTexture, vTexCoord);\n float average = 0.21 * col.r + 0.72 * col.g + 0.07 * col.b;\n gl_FragColor = vec4(average, average, average, col.a);\n }\n "};class Wa extends Ta{applyTo2d(t){let{imageData:{data:e}}=t;for(let i,s=0;s<e.length;s+=4){const t=e[s],r=e[s+1],n=e[s+2];switch(this.mode){case"average":i=(t+r+n)/3;break;case"lightness":i=(Math.min(t,r,n)+Math.max(t,r,n))/2;break;case"luminosity":i=.21*t+.72*r+.07*n}e[s+2]=e[s+1]=e[s]=i}}getCacheKey(){return"".concat(this.type,"_").concat(this.mode)}getFragmentSource(){return $a[this.mode]}sendUniformData(t,e){t.uniform1i(e.uMode,1)}isNeutralState(){return!1}}bt(Wa,"type","Grayscale"),bt(Wa,"defaults",{mode:"average"}),bt(Wa,"uniformLocations",["uMode"]),_e.setClass(Wa);const Ha=xt(xt({},ja),{},{rotation:0});class Xa extends La{calculateMatrix(){const t=this.rotation*Math.PI,e=we(t),i=Ce(t),s=1/3,r=Math.sqrt(s)*i,n=1-e;this.matrix=[e+n/3,s*n-r,s*n+r,0,0,s*n+r,e+s*n,s*n-r,0,0,s*n-r,s*n+r,e+s*n,0,0,0,0,0,1,0]}isNeutralState(){return 0===this.rotation}applyTo(t){this.calculateMatrix(),super.applyTo(t)}toObject(){return{type:this.type,rotation:this.rotation}}}bt(Xa,"type","HueRotation"),bt(Xa,"defaults",Ha),_e.setClass(Xa);class Ua extends Ta{applyTo2d(t){let{imageData:{data:e}}=t;for(let i=0;i<e.length;i+=4)e[i]=255-e[i],e[i+1]=255-e[i+1],e[i+2]=255-e[i+2],this.alpha&&(e[i+3]=255-e[i+3])}getFragmentSource(){return"\n precision highp float;\n uniform sampler2D uTexture;\n uniform int uInvert;\n uniform int uAlpha;\n varying vec2 vTexCoord;\n void main() {\n vec4 color = texture2D(uTexture, vTexCoord);\n if (uInvert == 1) {\n if (uAlpha == 1) {\n gl_FragColor = vec4(1.0 - color.r,1.0 -color.g,1.0 -color.b,1.0 -color.a);\n } else {\n gl_FragColor = vec4(1.0 - color.r,1.0 -color.g,1.0 -color.b,color.a);\n }\n } else {\n gl_FragColor = color;\n }\n }\n"}isNeutralState(){return!this.invert}sendUniformData(t,e){t.uniform1i(e.uInvert,Number(this.invert)),t.uniform1i(e.uAlpha,Number(this.alpha))}}bt(Ua,"type","Invert"),bt(Ua,"defaults",{alpha:!1,invert:!0}),bt(Ua,"uniformLocations",["uInvert","uAlpha"]),_e.setClass(Ua);class Ya extends Ta{getFragmentSource(){return"\n precision highp float;\n uniform sampler2D uTexture;\n uniform float uStepH;\n uniform float uNoise;\n uniform float uSeed;\n varying vec2 vTexCoord;\n float rand(vec2 co, float seed, float vScale) {\n return fract(sin(dot(co.xy * vScale ,vec2(12.9898 , 78.233))) * 43758.5453 * (seed + 0.01) / 2.0);\n }\n void main() {\n vec4 color = texture2D(uTexture, vTexCoord);\n color.rgb += (0.5 - rand(vTexCoord, uSeed, 0.1 / uStepH)) * uNoise;\n gl_FragColor = color;\n }\n"}applyTo2d(t){let{imageData:{data:e}}=t;const i=this.noise;for(let s=0;s<e.length;s+=4){const t=(.5-Math.random())*i;e[s]+=t,e[s+1]+=t,e[s+2]+=t}}sendUniformData(t,e){t.uniform1f(e.uNoise,this.noise/255),t.uniform1f(e.uSeed,Math.random())}isNeutralState(){return 0===this.noise}}bt(Ya,"type","Noise"),bt(Ya,"defaults",{noise:0}),bt(Ya,"uniformLocations",["uNoise","uSeed"]),_e.setClass(Ya);class Ga extends Ta{applyTo2d(t){let{imageData:{data:e,width:i,height:s}}=t;for(let r=0;r<s;r+=this.blocksize)for(let t=0;t<i;t+=this.blocksize){const n=4*r*i+4*t,o=e[n],a=e[n+1],l=e[n+2],c=e[n+3];for(let h=r;h<Math.min(r+this.blocksize,s);h++)for(let s=t;s<Math.min(t+this.blocksize,i);s++){const t=4*h*i+4*s;e[t]=o,e[t+1]=a,e[t+2]=l,e[t+3]=c}}}isNeutralState(){return 1===this.blocksize}getFragmentSource(){return"\n precision highp float;\n uniform sampler2D uTexture;\n uniform float uBlocksize;\n uniform float uStepW;\n uniform float uStepH;\n varying vec2 vTexCoord;\n void main() {\n float blockW = uBlocksize * uStepW;\n float blockH = uBlocksize * uStepH;\n int posX = int(vTexCoord.x / blockW);\n int posY = int(vTexCoord.y / blockH);\n float fposX = float(posX);\n float fposY = float(posY);\n vec2 squareCoords = vec2(fposX * blockW, fposY * blockH);\n vec4 color = texture2D(uTexture, squareCoords);\n gl_FragColor = color;\n }\n"}sendUniformData(t,e){t.uniform1f(e.uBlocksize,this.blocksize)}}bt(Ga,"type","Pixelate"),bt(Ga,"defaults",{blocksize:4}),bt(Ga,"uniformLocations",["uBlocksize"]),_e.setClass(Ga);class qa extends Ta{getFragmentSource(){return"\nprecision highp float;\nuniform sampler2D uTexture;\nuniform vec4 uLow;\nuniform vec4 uHigh;\nvarying vec2 vTexCoord;\nvoid main() {\n gl_FragColor = texture2D(uTexture, vTexCoord);\n if(all(greaterThan(gl_FragColor.rgb,uLow.rgb)) && all(greaterThan(uHigh.rgb,gl_FragColor.rgb))) {\n gl_FragColor.a = 0.0;\n }\n}\n"}applyTo2d(t){let{imageData:{data:e}}=t;const i=255*this.distance,s=new li(this.color).getSource(),r=[s[0]-i,s[1]-i,s[2]-i],n=[s[0]+i,s[1]+i,s[2]+i];for(let o=0;o<e.length;o+=4){const t=e[o],i=e[o+1],s=e[o+2];t>r[0]&&i>r[1]&&s>r[2]&&t<n[0]&&i<n[1]&&s<n[2]&&(e[o+3]=0)}}sendUniformData(t,e){const i=new li(this.color).getSource(),s=this.distance,r=[0+i[0]/255-s,0+i[1]/255-s,0+i[2]/255-s,1],n=[i[0]/255+s,i[1]/255+s,i[2]/255+s,1];t.uniform4fv(e.uLow,r),t.uniform4fv(e.uHigh,n)}}bt(qa,"type","RemoveColor"),bt(qa,"defaults",{color:"#FFFFFF",distance:.02,useAlpha:!1}),bt(qa,"uniformLocations",["uLow","uHigh"]),_e.setClass(qa);class Ka extends Ta{sendUniformData(t,e){t.uniform2fv(e.uDelta,this.horizontal?[1/this.width,0]:[0,1/this.height]),t.uniform1fv(e.uTaps,this.taps)}getFilterWindow(){const t=this.tempScale;return Math.ceil(this.lanczosLobes/t)}getCacheKey(){const t=this.getFilterWindow();return"".concat(this.type,"_").concat(t)}getFragmentSource(){const t=this.getFilterWindow();return this.generateShader(t)}getTaps(){const t=this.lanczosCreate(this.lanczosLobes),e=this.tempScale,i=this.getFilterWindow(),s=new Array(i);for(let r=1;r<=i;r++)s[r-1]=t(r*e);return s}generateShader(t){const e=new Array(t);for(let i=1;i<=t;i++)e[i-1]="".concat(i,".0 * uDelta");return"\n precision highp float;\n uniform sampler2D uTexture;\n uniform vec2 uDelta;\n varying vec2 vTexCoord;\n uniform float uTaps[".concat(t,"];\n void main() {\n vec4 color = texture2D(uTexture, vTexCoord);\n float sum = 1.0;\n ").concat(e.map(((t,e)=>"\n color += texture2D(uTexture, vTexCoord + ".concat(t,") * uTaps[").concat(e,"] + texture2D(uTexture, vTexCoord - ").concat(t,") * uTaps[").concat(e,"];\n sum += 2.0 * uTaps[").concat(e,"];\n "))).join("\n"),"\n gl_FragColor = color / sum;\n }\n ")}applyToForWebgl(t){t.passes++,this.width=t.sourceWidth,this.horizontal=!0,this.dW=Math.round(this.width*this.scaleX),this.dH=t.sourceHeight,this.tempScale=this.dW/this.width,this.taps=this.getTaps(),t.destinationWidth=this.dW,super.applyTo(t),t.sourceWidth=t.destinationWidth,this.height=t.sourceHeight,this.horizontal=!1,this.dH=Math.round(this.height*this.scaleY),this.tempScale=this.dH/this.height,this.taps=this.getTaps(),t.destinationHeight=this.dH,super.applyTo(t),t.sourceHeight=t.destinationHeight}applyTo(t){ba(t)?this.applyToForWebgl(t):this.applyTo2d(t)}isNeutralState(){return 1===this.scaleX&&1===this.scaleY}lanczosCreate(t){return e=>{if(e>=t||e<=-t)return 0;if(e<1.1920929e-7&&e>-1.1920929e-7)return 1;const i=(e*=Math.PI)/t;return Math.sin(e)/e*Math.sin(i)/i}}applyTo2d(t){const e=t.imageData,i=this.scaleX,s=this.scaleY;this.rcpScaleX=1/i,this.rcpScaleY=1/s;const r=e.width,n=e.height,o=Math.round(r*i),a=Math.round(n*s);let l;l="sliceHack"===this.resizeType?this.sliceByTwo(t,r,n,o,a):"hermite"===this.resizeType?this.hermiteFastResize(t,r,n,o,a):"bilinear"===this.resizeType?this.bilinearFiltering(t,r,n,o,a):"lanczos"===this.resizeType?this.lanczosResize(t,r,n,o,a):new ImageData(o,a),t.imageData=l}sliceByTwo(t,e,i,s,r){const n=t.imageData,o=.5;let a=!1,l=!1,c=e*o,h=i*o;const d=t.filterBackend.resources;let u=0,p=0;const g=e;let f=0;d.sliceByTwo||(d.sliceByTwo=Pe());const m=d.sliceByTwo;(m.width<1.5*e||m.height<i)&&(m.width=1.5*e,m.height=i);const v=m.getContext("2d");for(v.clearRect(0,0,1.5*e,i),v.putImageData(n,0,0),s=Math.floor(s),r=Math.floor(r);!a||!l;)e=c,i=h,s<Math.floor(c*o)?c=Math.floor(c*o):(c=s,a=!0),r<Math.floor(h*o)?h=Math.floor(h*o):(h=r,l=!0),v.drawImage(m,u,p,e,i,g,f,c,h),u=g,p=f,f+=h;return v.getImageData(u,p,s,r)}lanczosResize(t,e,i,s,r){const n=t.imageData.data,o=t.ctx.createImageData(s,r),a=o.data,l=this.lanczosCreate(this.lanczosLobes),c=this.rcpScaleX,h=this.rcpScaleY,d=2/this.rcpScaleX,u=2/this.rcpScaleY,p=Math.ceil(c*this.lanczosLobes/2),g=Math.ceil(h*this.lanczosLobes/2),f={},m={x:0,y:0},v={x:0,y:0};return function t(_){let b,y,x,w,C,S,T,O,E,k,D;for(m.x=(_+.5)*c,v.x=Math.floor(m.x),b=0;b<r;b++){for(m.y=(b+.5)*h,v.y=Math.floor(m.y),C=0,S=0,T=0,O=0,E=0,y=v.x-p;y<=v.x+p;y++)if(!(y<0||y>=e)){k=Math.floor(1e3*Math.abs(y-m.x)),f[k]||(f[k]={});for(let t=v.y-g;t<=v.y+g;t++)t<0||t>=i||(D=Math.floor(1e3*Math.abs(t-m.y)),f[k][D]||(f[k][D]=l(Math.sqrt(Math.pow(k*d,2)+Math.pow(D*u,2))/1e3)),x=f[k][D],x>0&&(w=4*(t*e+y),C+=x,S+=x*n[w],T+=x*n[w+1],O+=x*n[w+2],E+=x*n[w+3]))}w=4*(b*s+_),a[w]=S/C,a[w+1]=T/C,a[w+2]=O/C,a[w+3]=E/C}return++_<s?t(_):o}(0)}bilinearFiltering(t,e,i,s,r){let n,o,a,l,c,h,d,u,p,g,f,m,v,_=0;const b=this.rcpScaleX,y=this.rcpScaleY,x=4*(e-1),w=t.imageData.data,C=t.ctx.createImageData(s,r),S=C.data;for(d=0;d<r;d++)for(u=0;u<s;u++)for(c=Math.floor(b*u),h=Math.floor(y*d),p=b*u-c,g=y*d-h,v=4*(h*e+c),f=0;f<4;f++)n=w[v+f],o=w[v+4+f],a=w[v+x+f],l=w[v+x+4+f],m=n*(1-p)*(1-g)+o*p*(1-g)+a*g*(1-p)+l*p*g,S[_++]=m;return C}hermiteFastResize(t,e,i,s,r){const n=this.rcpScaleX,o=this.rcpScaleY,a=Math.ceil(n/2),l=Math.ceil(o/2),c=t.imageData.data,h=t.ctx.createImageData(s,r),d=h.data;for(let u=0;u<r;u++)for(let t=0;t<s;t++){const i=4*(t+u*s);let r=0,h=0,p=0,g=0,f=0,m=0,v=0;const _=(u+.5)*o;for(let s=Math.floor(u*o);s<(u+1)*o;s++){const i=Math.abs(_-(s+.5))/l,o=(t+.5)*n,d=i*i;for(let l=Math.floor(t*n);l<(t+1)*n;l++){let t=Math.abs(o-(l+.5))/a;const i=Math.sqrt(d+t*t);i>1&&i<-1||(r=2*i*i*i-3*i*i+1,r>0&&(t=4*(l+s*e),v+=r*c[t+3],p+=r,c[t+3]<255&&(r=r*c[t+3]/250),g+=r*c[t],f+=r*c[t+1],m+=r*c[t+2],h+=r))}}d[i]=g/h,d[i+1]=f/h,d[i+2]=m/h,d[i+3]=v/p}return h}}bt(Ka,"type","Resize"),bt(Ka,"defaults",{resizeType:"hermite",scaleX:1,scaleY:1,lanczosLobes:3}),bt(Ka,"uniformLocations",["uDelta","uTaps"]),_e.setClass(Ka);class Ja extends Ta{getFragmentSource(){return"\n precision highp float;\n uniform sampler2D uTexture;\n uniform float uSaturation;\n varying vec2 vTexCoord;\n void main() {\n vec4 color = texture2D(uTexture, vTexCoord);\n float rgMax = max(color.r, color.g);\n float rgbMax = max(rgMax, color.b);\n color.r += rgbMax != color.r ? (rgbMax - color.r) * uSaturation : 0.00;\n color.g += rgbMax != color.g ? (rgbMax - color.g) * uSaturation : 0.00;\n color.b += rgbMax != color.b ? (rgbMax - color.b) * uSaturation : 0.00;\n gl_FragColor = color;\n }\n"}applyTo2d(t){let{imageData:{data:e}}=t;const i=-this.saturation;for(let s=0;s<e.length;s+=4){const t=e[s],r=e[s+1],n=e[s+2],o=Math.max(t,r,n);e[s]+=o!==t?(o-t)*i:0,e[s+1]+=o!==r?(o-r)*i:0,e[s+2]+=o!==n?(o-n)*i:0}}sendUniformData(t,e){t.uniform1f(e.uSaturation,-this.saturation)}isNeutralState(){return 0===this.saturation}}bt(Ja,"type","Saturation"),bt(Ja,"defaults",{saturation:0}),bt(Ja,"uniformLocations",["uSaturation"]),_e.setClass(Ja);class Za extends Ta{getFragmentSource(){return"\n precision highp float;\n uniform sampler2D uTexture;\n uniform float uVibrance;\n varying vec2 vTexCoord;\n void main() {\n vec4 color = texture2D(uTexture, vTexCoord);\n float max = max(color.r, max(color.g, color.b));\n float avg = (color.r + color.g + color.b) / 3.0;\n float amt = (abs(max - avg) * 2.0) * uVibrance;\n color.r += max != color.r ? (max - color.r) * amt : 0.00;\n color.g += max != color.g ? (max - color.g) * amt : 0.00;\n color.b += max != color.b ? (max - color.b) * amt : 0.00;\n gl_FragColor = color;\n }\n"}applyTo2d(t){let{imageData:{data:e}}=t;const i=-this.vibrance;for(let s=0;s<e.length;s+=4){const t=e[s],r=e[s+1],n=e[s+2],o=Math.max(t,r,n),a=(t+r+n)/3,l=2*Math.abs(o-a)/255*i;e[s]+=o!==t?(o-t)*l:0,e[s+1]+=o!==r?(o-r)*l:0,e[s+2]+=o!==n?(o-n)*l:0}}sendUniformData(t,e){t.uniform1f(e.uVibrance,-this.vibrance)}isNeutralState(){return 0===this.vibrance}}bt(Za,"type","Vibrance"),bt(Za,"defaults",{vibrance:0}),bt(Za,"uniformLocations",["uVibrance"]),_e.setClass(Za);var Qa=Object.defineProperty,tl=Object.getOwnPropertyDescriptor,el=(t,e,i,s)=>{for(var r,n=s>1?void 0:s?tl(e,i):e,o=t.length-1;o>=0;o--)(r=t[o])&&(n=(s?r(e,i,n):r(n))||n);return s&&n&&Qa(e,i,n),n};t.FabricExample=class extends at{constructor(){super(),this.backgroundUrl="https://upload.wikimedia.org/wikipedia/commons/0/06/Daedalus_Spaceship_concept.jpg",this.message="Dear fridends,\n\nMy name is xxxxx. sadf;lkasdf\ngood aklsdfja",this.alignment="left",this.fontFamily="Arial",this.color="#000",this._backgroundImg=new Image,this._natureSize={width:0,height:0},this._scale=1,this._lineHeight=0,this._fontSize=0,this._backgroundImg=new Image}connectedCallback(){super.connectedCallback(),this._backgroundImg.src=this.backgroundUrl,this._backgroundImg.onload=()=>{this._natureSize={width:this._backgroundImg.naturalWidth,height:this._backgroundImg.naturalHeight}},this._canvasElement=document.createElement("canvas")}formatTextbox(t){var e;console.log({line:null==t?void 0:t.textLines,text:null==t?void 0:t.text});let i=t.textLines;if(console.log(i.length),i.length>12){const s=i.slice(0,12);t.set("text",s.join("\n")),t.setSelectionStart(t.text.length),t.setSelectionEnd(t.text.length),null==(e=this._canvas)||e.renderAll()}}firstUpdated(){const t=document.createElement("canvas");this._fabricContainer.appendChild(t),this._backgroundImg.onload=()=>{const e=new _a(this._backgroundImg);this._canvas=new qn(t,{backgroundImage:e,width:this._backgroundImg.naturalWidth,height:this._backgroundImg.naturalHeight}),this._lineHeight=.45*this._backgroundImg.height/12,this._fontSize=this._lineHeight/1.16;const i={fontSize:16,left:.084*this._backgroundImg.naturalWidth,top:.52*this._backgroundImg.naturalHeight,width:.832*this._backgroundImg.naturalWidth,height:.45*this._backgroundImg.naturalHeight,hasControls:!1,editable:!1,breakWords:!1,splitByGrapheme:!1,textAlign:this.alignment,lockMovementX:!0,lockMovementY:!0,selectable:!1};this._textbox=new aa(this.message,i),this._textbox.set("fill",this.color),this._textbox.on("changed",(()=>{var t;if(!this._textbox)return;let e=this._textbox.text.split("\n"),i=[];e.forEach((t=>{if(t.length>20){const e=t.split(" ");let s="",r=0;e.forEach((t=>{r+t.length>20?(i.push(s.trim()),s=t+" ",r=t.length+1):(s+=t+" ",r+=t.length+1)})),s.trim().length>0&&i.push(s.trim())}else i.push(t)})),i.length>12&&(i=i.slice(0,12)),this._textbox.text=i.join("\n"),this._textbox.setSelectionStart(this._textbox.text.length),this._textbox.setSelectionEnd(this._textbox.text.length),null==(t=this._canvas)||t.renderAll()})),this._canvas.add(this._textbox),this._canvas.centerObject(this._textbox),this._canvas.renderAll()},window.addEventListener("resize",(()=>{var e;t.width=this._fabricContainer.clientWidth,t.height=this._fabricContainer.clientHeight,this.adjustCanvasElements(),null==(e=this._canvas)||e.renderAll()})),setTimeout((()=>this.adjustCanvasElements()),100)}adjustCanvasElements(){var t;if(this._canvas&&this._textbox&&this._backgroundImg&&this._backgroundImg.complete){const e=null==(t=this.shadowRoot)?void 0:t.querySelector(".fabric-container");if(!e)return;const i=e.clientWidth,s=e.clientHeight,r=this._backgroundImg.naturalWidth,n=this._backgroundImg.naturalHeight,o=s/n,a=i/r,l=Math.min(o,a);this._scale=l,console.log({parentWidth:i,parentHeight:s,naturalWidth:r,naturalHeight:n}),this._canvas.setWidth(r*l),this._canvas.setHeight(n*l);const c=this._canvas.backgroundImage;c&&(c.scaleToWidth(r*l),c.scaleToHeight(n*l)),this._textbox.set({left:.084*r*l,top:.52*n*l,width:.832*r*l,height:.45*n*l,fontSize:this._fontSize*l}),console.log(.45*n/12*.9*l),console.log(`Line height pixel: ${this._textbox.get("lineHeight")*this._textbox.get("fontSize")}px`),console.log(`Line height: ${this._textbox.get("lineHeight")}`),console.log(`Font size: ${this._textbox.get("fontSize")}px`);const h=.45*n*l/12;console.log(`desired line height: ${h}`),console.log(`scale width: ${.832*r*l} - scale height: ${.45*n*l}`),this._canvas.renderAll()}}updated(t){var e,i,s,r,n,o,a,l;console.log(t),this._textbox&&(t.has("message")&&(null==(e=this._textbox)||e.set("text",this.message),this.formatTextbox(this._textbox),null==(i=this._canvas)||i.renderAll()),t.has("alignment")&&(null==(s=this._textbox)||s.set("textAlign",this.alignment),null==(r=this._canvas)||r.renderAll()),t.has("fontFamily")&&(null==(n=this._textbox)||n.set("fontFamily",this.fontFamily),null==(o=this._canvas)||o.renderAll()),t.has("color")&&(null==(a=this._textbox)||a.set("fill",this.color),null==(l=this._canvas)||l.renderAll()))}render(){var t,e,i,s;return H`
631
139
  <div
632
140
  style="position: fixed; top: 0; left: 0; padding: 1rem; z-index: 1000; background: rgba(255, 255, 255, 0.5); color: rgba(0, 0, 0, 0.5);"
633
141
  >
634
142
  Nature font size: ${this._fontSize} <br />
635
143
  Nature line height: ${this._lineHeight} <br />
636
- Line height: ${(t=this._textbox)==null?void 0:t.get("lineHeight")} <br />
637
- Font size: ${(e=this._textbox)==null?void 0:e.get("fontSize")} <br />
638
- real textbox width: ${this._backgroundImg.width*.382} <br />
639
- real textbox height: ${this._backgroundImg.height*.45} <br />
640
- Textbox width: ${(i=this._textbox)==null?void 0:i.width} <br />
641
- Textbox height: ${(s=this._textbox)==null?void 0:s.height} <br />
144
+ Line height: ${null==(t=this._textbox)?void 0:t.get("lineHeight")} <br />
145
+ Font size: ${null==(e=this._textbox)?void 0:e.get("fontSize")} <br />
146
+ real textbox width: ${.382*this._backgroundImg.width} <br />
147
+ real textbox height: ${.45*this._backgroundImg.height} <br />
148
+ Textbox width: ${null==(i=this._textbox)?void 0:i.width} <br />
149
+ Textbox height: ${null==(s=this._textbox)?void 0:s.height} <br />
642
150
  </div>
643
151
  <div class="fabric-container"></div>
644
- `}},z.FabricExample.styles=Ct`
152
+ `}},t.FabricExample.styles=l`
645
153
  :host {
646
154
  display: block;
647
155
  height: 100%;
@@ -666,7 +174,7 @@ good aklsdfja`,this.alignment="left",this.fontFamily="Arial",this.color="#000",t
666
174
  font-weight: 400;
667
175
  font-style: normal;
668
176
  }
669
- `,jt([H()],z.FabricExample.prototype,"backgroundUrl",2),jt([H()],z.FabricExample.prototype,"message",2),jt([H({type:String,reflect:!0})],z.FabricExample.prototype,"alignment",2),jt([H({type:String})],z.FabricExample.prototype,"fontFamily",2),jt([H({type:String})],z.FabricExample.prototype,"color",2),jt([vt(".fabric-container")],z.FabricExample.prototype,"_fabricContainer",2),jt([st()],z.FabricExample.prototype,"_canvas",2),jt([st()],z.FabricExample.prototype,"_canvasElement",2),jt([st()],z.FabricExample.prototype,"_textbox",2),jt([st()],z.FabricExample.prototype,"_backgroundImg",2),jt([st()],z.FabricExample.prototype,"_natureSize",2),jt([st()],z.FabricExample.prototype,"_scale",2),jt([st()],z.FabricExample.prototype,"_lineHeight",2),jt([st()],z.FabricExample.prototype,"_fontSize",2),z.FabricExample=jt([Mt("fabric-example")],z.FabricExample);const Vt=Ct`
177
+ `,el([ut()],t.FabricExample.prototype,"backgroundUrl",2),el([ut()],t.FabricExample.prototype,"message",2),el([ut({type:String,reflect:!0})],t.FabricExample.prototype,"alignment",2),el([ut({type:String})],t.FabricExample.prototype,"fontFamily",2),el([ut({type:String})],t.FabricExample.prototype,"color",2),el([ft(".fabric-container")],t.FabricExample.prototype,"_fabricContainer",2),el([pt()],t.FabricExample.prototype,"_canvas",2),el([pt()],t.FabricExample.prototype,"_canvasElement",2),el([pt()],t.FabricExample.prototype,"_textbox",2),el([pt()],t.FabricExample.prototype,"_backgroundImg",2),el([pt()],t.FabricExample.prototype,"_natureSize",2),el([pt()],t.FabricExample.prototype,"_scale",2),el([pt()],t.FabricExample.prototype,"_lineHeight",2),el([pt()],t.FabricExample.prototype,"_fontSize",2),t.FabricExample=el([ct("fabric-example")],t.FabricExample);const il=l`
670
178
  :host {
671
179
  box-sizing: border-box;
672
180
  }
@@ -680,14 +188,15 @@ good aklsdfja`,this.alignment="left",this.fontFamily="Arial",this.color="#000",t
680
188
  [hidden] {
681
189
  display: none !important;
682
190
  }
683
- `,jg=Ct`
191
+ `,sl=l`
684
192
  :host {
685
193
  display: block;
686
194
  }
687
195
  .is-open {
688
196
  background-color: red;
689
197
  }
690
- `;/*! choices.js v11.0.3 | © 2024 Josh Johnson | https://github.com/jshjohnson/Choices#readme */var Jo=function(n,t){return Jo=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,i){e.__proto__=i}||function(e,i){for(var s in i)Object.prototype.hasOwnProperty.call(i,s)&&(e[s]=i[s])},Jo(n,t)};function $c(n,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");Jo(n,t);function e(){this.constructor=n}n.prototype=t===null?Object.create(t):(e.prototype=t.prototype,new e)}var zt=function(){return zt=Object.assign||function(t){for(var e,i=1,s=arguments.length;i<s;i++){e=arguments[i];for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r])}return t},zt.apply(this,arguments)};function Fg(n,t,e){for(var i=0,s=t.length,r;i<s;i++)(r||!(i in t))&&(r||(r=Array.prototype.slice.call(t,0,i)),r[i]=t[i]);return n.concat(r||Array.prototype.slice.call(t))}typeof SuppressedError=="function"&&SuppressedError;var gt={ADD_CHOICE:"ADD_CHOICE",REMOVE_CHOICE:"REMOVE_CHOICE",FILTER_CHOICES:"FILTER_CHOICES",ACTIVATE_CHOICES:"ACTIVATE_CHOICES",CLEAR_CHOICES:"CLEAR_CHOICES",ADD_GROUP:"ADD_GROUP",ADD_ITEM:"ADD_ITEM",REMOVE_ITEM:"REMOVE_ITEM",HIGHLIGHT_ITEM:"HIGHLIGHT_ITEM"},Ht={showDropdown:"showDropdown",hideDropdown:"hideDropdown",change:"change",choice:"choice",search:"search",addItem:"addItem",removeItem:"removeItem",highlightItem:"highlightItem",highlightChoice:"highlightChoice",unhighlightItem:"unhighlightItem"},At={TAB_KEY:9,SHIFT_KEY:16,BACK_KEY:46,DELETE_KEY:8,ENTER_KEY:13,A_KEY:65,ESC_KEY:27,UP_KEY:38,DOWN_KEY:40,PAGE_UP_KEY:33,PAGE_DOWN_KEY:34},Rg=["fuseOptions","classNames"],ci={Text:"text",SelectOne:"select-one",SelectMultiple:"select-multiple"},Ng=function(n){return{type:gt.ADD_CHOICE,choice:n}},Vc=function(n){return{type:gt.REMOVE_CHOICE,choice:n}},Bg=function(n){return{type:gt.FILTER_CHOICES,results:n}},$g=function(n){return{type:gt.ACTIVATE_CHOICES,active:n}},Vg=function(n){return{type:gt.ADD_GROUP,group:n}},zg=function(n){return{type:gt.ADD_ITEM,item:n}},zc=function(n){return{type:gt.REMOVE_ITEM,item:n}},xn=function(n,t){return{type:gt.HIGHLIGHT_ITEM,item:n,highlighted:t}},Hg=function(n,t){return Math.floor(Math.random()*(t-n)+n)},Hc=function(n){return Array.from({length:n},function(){return Hg(0,36).toString(36)}).join("")},Wg=function(n,t){var e=n.id||n.name&&"".concat(n.name,"-").concat(Hc(2))||Hc(4);return e=e.replace(/(:|\.|\[|\]|,)/g,""),e="".concat(t,"-").concat(e),e},Yg=function(n,t,e){e===void 0&&(e=1);for(var i="".concat(e>0?"next":"previous","ElementSibling"),s=n[i];s;){if(s.matches(t))return s;s=s[i]}return null},Ug=function(n,t,e){e===void 0&&(e=1);var i;return e>0?i=t.scrollTop+t.offsetHeight>=n.offsetTop+n.offsetHeight:i=n.offsetTop>=t.scrollTop,i},Cn=function(n){if(typeof n!="string"){if(n==null)return"";if(typeof n=="object"){if("raw"in n)return Cn(n.raw);if("trusted"in n)return n.trusted}return n}return n.replace(/&/g,"&amp;").replace(/>/g,"&gt;").replace(/</g,"&lt;").replace(/'/g,"&#039;").replace(/"/g,"&quot;")},Gg=function(){var n=document.createElement("div");return function(t){n.innerHTML=t.trim();for(var e=n.children[0];n.firstChild;)n.removeChild(n.firstChild);return e}}(),Hs=function(n,t){return typeof n=="function"?n(Cn(t),t):n},Wc=function(n){return typeof n=="function"?n():n},Ii=function(n){if(typeof n=="string")return n;if(typeof n=="object"){if("trusted"in n)return n.trusted;if("raw"in n)return n.raw}return""},Xg=function(n){if(typeof n=="string")return n;if(typeof n=="object"){if("escaped"in n)return n.escaped;if("trusted"in n)return n.trusted}return""},Zo=function(n,t){return n?Xg(t):Cn(t)},He=function(n,t,e){n.innerHTML=Zo(t,e)},Kg=function(n,t){var e=n.value,i=n.label,s=i===void 0?e:i,r=t.value,o=t.label,a=o===void 0?r:o;return Ii(s).localeCompare(Ii(a),[],{sensitivity:"base",ignorePunctuation:!0,numeric:!0})},qg=function(n,t){return n.rank-t.rank},Jg=function(n,t,e){e===void 0&&(e=null);var i=new CustomEvent(t,{detail:e,bubbles:!0,cancelable:!0});return n.dispatchEvent(i)},Zg=function(n,t){var e=Object.keys(n).sort(),i=Object.keys(t).sort();return e.filter(function(s){return i.indexOf(s)<0})},Sn=function(n){return Array.isArray(n)?n:[n]},Ws=function(n){return n&&Array.isArray(n)?n.map(function(t){return".".concat(t)}).join(""):".".concat(n)},Y=function(n,t){var e;(e=n.classList).add.apply(e,Sn(t))},Te=function(n,t){var e;(e=n.classList).remove.apply(e,Sn(t))},Qg=function(n){if(typeof n<"u")try{return JSON.parse(n)}catch{return n}return{}},tp=function(n,t,e){var i=n.itemEl;i&&(Te(i,e),Y(i,t))},ep=function(){function n(t){var e=t.element,i=t.type,s=t.classNames;this.element=e,this.classNames=s,this.type=i,this.isActive=!1}return n.prototype.show=function(){return Y(this.element,this.classNames.activeState),this.element.setAttribute("aria-expanded","true"),this.isActive=!0,this},n.prototype.hide=function(){return Te(this.element,this.classNames.activeState),this.element.setAttribute("aria-expanded","false"),this.isActive=!1,this},n}(),Yc=function(){function n(t){var e=t.element,i=t.type,s=t.classNames,r=t.position;this.element=e,this.classNames=s,this.type=i,this.position=r,this.isOpen=!1,this.isFlipped=!1,this.isDisabled=!1,this.isLoading=!1}return n.prototype.shouldFlip=function(t,e){var i=!1;return this.position==="auto"?i=this.element.getBoundingClientRect().top-e>=0&&!window.matchMedia("(min-height: ".concat(t+1,"px)")).matches:this.position==="top"&&(i=!0),i},n.prototype.setActiveDescendant=function(t){this.element.setAttribute("aria-activedescendant",t)},n.prototype.removeActiveDescendant=function(){this.element.removeAttribute("aria-activedescendant")},n.prototype.open=function(t,e){Y(this.element,this.classNames.openState),this.element.setAttribute("aria-expanded","true"),this.isOpen=!0,this.shouldFlip(t,e)&&(Y(this.element,this.classNames.flippedState),this.isFlipped=!0)},n.prototype.close=function(){Te(this.element,this.classNames.openState),this.element.setAttribute("aria-expanded","false"),this.removeActiveDescendant(),this.isOpen=!1,this.isFlipped&&(Te(this.element,this.classNames.flippedState),this.isFlipped=!1)},n.prototype.addFocusState=function(){Y(this.element,this.classNames.focusState)},n.prototype.removeFocusState=function(){Te(this.element,this.classNames.focusState)},n.prototype.enable=function(){Te(this.element,this.classNames.disabledState),this.element.removeAttribute("aria-disabled"),this.type===ci.SelectOne&&this.element.setAttribute("tabindex","0"),this.isDisabled=!1},n.prototype.disable=function(){Y(this.element,this.classNames.disabledState),this.element.setAttribute("aria-disabled","true"),this.type===ci.SelectOne&&this.element.setAttribute("tabindex","-1"),this.isDisabled=!0},n.prototype.wrap=function(t){var e=this.element,i=t.parentNode;i&&(t.nextSibling?i.insertBefore(e,t.nextSibling):i.appendChild(e)),e.appendChild(t)},n.prototype.unwrap=function(t){var e=this.element,i=e.parentNode;i&&(i.insertBefore(t,e),i.removeChild(e))},n.prototype.addLoadingState=function(){Y(this.element,this.classNames.loadingState),this.element.setAttribute("aria-busy","true"),this.isLoading=!0},n.prototype.removeLoadingState=function(){Te(this.element,this.classNames.loadingState),this.element.removeAttribute("aria-busy"),this.isLoading=!1},n}(),ip=function(){function n(t){var e=t.element,i=t.type,s=t.classNames,r=t.preventPaste;this.element=e,this.type=i,this.classNames=s,this.preventPaste=r,this.isFocussed=this.element.isEqualNode(document.activeElement),this.isDisabled=e.disabled,this._onPaste=this._onPaste.bind(this),this._onInput=this._onInput.bind(this),this._onFocus=this._onFocus.bind(this),this._onBlur=this._onBlur.bind(this)}return Object.defineProperty(n.prototype,"placeholder",{set:function(t){this.element.placeholder=t},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"value",{get:function(){return this.element.value},set:function(t){this.element.value=t},enumerable:!1,configurable:!0}),n.prototype.addEventListeners=function(){var t=this.element;t.addEventListener("paste",this._onPaste),t.addEventListener("input",this._onInput,{passive:!0}),t.addEventListener("focus",this._onFocus,{passive:!0}),t.addEventListener("blur",this._onBlur,{passive:!0})},n.prototype.removeEventListeners=function(){var t=this.element;t.removeEventListener("input",this._onInput),t.removeEventListener("paste",this._onPaste),t.removeEventListener("focus",this._onFocus),t.removeEventListener("blur",this._onBlur)},n.prototype.enable=function(){var t=this.element;t.removeAttribute("disabled"),this.isDisabled=!1},n.prototype.disable=function(){var t=this.element;t.setAttribute("disabled",""),this.isDisabled=!0},n.prototype.focus=function(){this.isFocussed||this.element.focus()},n.prototype.blur=function(){this.isFocussed&&this.element.blur()},n.prototype.clear=function(t){return t===void 0&&(t=!0),this.element.value="",t&&this.setWidth(),this},n.prototype.setWidth=function(){var t=this.element;t.style.minWidth="".concat(t.placeholder.length+1,"ch"),t.style.width="".concat(t.value.length+1,"ch")},n.prototype.setActiveDescendant=function(t){this.element.setAttribute("aria-activedescendant",t)},n.prototype.removeActiveDescendant=function(){this.element.removeAttribute("aria-activedescendant")},n.prototype._onInput=function(){this.type!==ci.SelectOne&&this.setWidth()},n.prototype._onPaste=function(t){this.preventPaste&&t.preventDefault()},n.prototype._onFocus=function(){this.isFocussed=!0},n.prototype._onBlur=function(){this.isFocussed=!1},n}(),sp=4,Uc=function(){function n(t){var e=t.element;this.element=e,this.scrollPos=this.element.scrollTop,this.height=this.element.offsetHeight}return n.prototype.prepend=function(t){var e=this.element.firstElementChild;e?this.element.insertBefore(t,e):this.element.append(t)},n.prototype.scrollToTop=function(){this.element.scrollTop=0},n.prototype.scrollToChildElement=function(t,e){var i=this;if(t){var s=this.element.offsetHeight,r=this.element.scrollTop+s,o=t.offsetHeight,a=t.offsetTop+o,l=e>0?this.element.scrollTop+a-r:t.offsetTop;requestAnimationFrame(function(){i._animateScroll(l,e)})}},n.prototype._scrollDown=function(t,e,i){var s=(i-t)/e,r=s>1?s:1;this.element.scrollTop=t+r},n.prototype._scrollUp=function(t,e,i){var s=(t-i)/e,r=s>1?s:1;this.element.scrollTop=t-r},n.prototype._animateScroll=function(t,e){var i=this,s=sp,r=this.element.scrollTop,o=!1;e>0?(this._scrollDown(r,s,t),r<t&&(o=!0)):(this._scrollUp(r,s,t),r>t&&(o=!0)),o&&requestAnimationFrame(function(){i._animateScroll(t,e)})},n}(),Gc=function(){function n(t){var e=t.element,i=t.classNames;this.element=e,this.classNames=i,this.isDisabled=!1}return Object.defineProperty(n.prototype,"isActive",{get:function(){return this.element.dataset.choice==="active"},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"dir",{get:function(){return this.element.dir},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"value",{get:function(){return this.element.value},set:function(t){this.element.setAttribute("value",t),this.element.value=t},enumerable:!1,configurable:!0}),n.prototype.conceal=function(){var t=this.element;Y(t,this.classNames.input),t.hidden=!0,t.tabIndex=-1;var e=t.getAttribute("style");e&&t.setAttribute("data-choice-orig-style",e),t.setAttribute("data-choice","active")},n.prototype.reveal=function(){var t=this.element;Te(t,this.classNames.input),t.hidden=!1,t.removeAttribute("tabindex");var e=t.getAttribute("data-choice-orig-style");e?(t.removeAttribute("data-choice-orig-style"),t.setAttribute("style",e)):t.removeAttribute("style"),t.removeAttribute("data-choice")},n.prototype.enable=function(){this.element.removeAttribute("disabled"),this.element.disabled=!1,this.isDisabled=!1},n.prototype.disable=function(){this.element.setAttribute("disabled",""),this.element.disabled=!0,this.isDisabled=!0},n.prototype.triggerEvent=function(t,e){Jg(this.element,t,e||{})},n}(),rp=function(n){$c(t,n);function t(){return n!==null&&n.apply(this,arguments)||this}return t}(Gc),Ys=function(n,t){return t===void 0&&(t=!0),typeof n>"u"?t:!!n},Xc=function(n){if(typeof n=="string"&&(n=n.split(" ").filter(function(t){return t.length})),Array.isArray(n)&&n.length)return n},Ee=function(n,t,e){if(e===void 0&&(e=!0),typeof n=="string"){var i=Cn(n),s=e||i===n?n:{escaped:i,raw:n},r=Ee({value:n,label:s,selected:!0},!1);return r}var o=n;if("choices"in o){if(!t)throw new TypeError("optGroup is not allowed");var a=o,l=a.choices.map(function(d){return Ee(d,!1)}),c={id:0,label:Ii(a.label)||a.value,active:!!l.length,disabled:!!a.disabled,choices:l};return c}var h=o,u={id:0,group:null,score:0,rank:0,value:h.value,label:h.label||h.value,active:Ys(h.active),selected:Ys(h.selected,!1),disabled:Ys(h.disabled,!1),placeholder:Ys(h.placeholder,!1),highlighted:!1,labelClass:Xc(h.labelClass),labelDescription:h.labelDescription,customProperties:h.customProperties};return u},np=function(n){return n.tagName==="INPUT"},Kc=function(n){return n.tagName==="SELECT"},op=function(n){return n.tagName==="OPTION"},ap=function(n){return n.tagName==="OPTGROUP"},lp=function(n){$c(t,n);function t(e){var i=e.element,s=e.classNames,r=e.template,o=e.extractPlaceholder,a=n.call(this,{element:i,classNames:s})||this;return a.template=r,a.extractPlaceholder=o,a}return Object.defineProperty(t.prototype,"placeholderOption",{get:function(){return this.element.querySelector('option[value=""]')||this.element.querySelector("option[placeholder]")},enumerable:!1,configurable:!0}),t.prototype.addOptions=function(e){var i=this,s=document.createDocumentFragment();e.forEach(function(r){var o=r;if(!o.element){var a=i.template(o);s.appendChild(a),o.element=a}}),this.element.appendChild(s)},t.prototype.optionsAsChoices=function(){var e=this,i=[];return this.element.querySelectorAll(":scope > option, :scope > optgroup").forEach(function(s){op(s)?i.push(e._optionToChoice(s)):ap(s)&&i.push(e._optgroupToChoice(s))}),i},t.prototype._optionToChoice=function(e){return!e.hasAttribute("value")&&e.hasAttribute("placeholder")&&(e.setAttribute("value",""),e.value=""),{id:0,group:null,score:0,rank:0,value:e.value,label:e.innerText,element:e,active:!0,selected:this.extractPlaceholder?e.selected:e.hasAttribute("selected"),disabled:e.disabled,highlighted:!1,placeholder:this.extractPlaceholder&&(!e.value||e.hasAttribute("placeholder")),labelClass:typeof e.dataset.labelClass<"u"?Xc(e.dataset.labelClass):void 0,labelDescription:typeof e.dataset.labelDescription<"u"?e.dataset.labelDescription:void 0,customProperties:Qg(e.dataset.customProperties)}},t.prototype._optgroupToChoice=function(e){var i=this,s=e.querySelectorAll("option"),r=Array.from(s).map(function(o){return i._optionToChoice(o)});return{id:0,label:e.label||"",element:e,active:!!r.length,disabled:e.disabled,choices:r}},t}(Gc),cp={containerOuter:["choices"],containerInner:["choices__inner"],input:["choices__input"],inputCloned:["choices__input--cloned"],list:["choices__list"],listItems:["choices__list--multiple"],listSingle:["choices__list--single"],listDropdown:["choices__list--dropdown"],item:["choices__item"],itemSelectable:["choices__item--selectable"],itemDisabled:["choices__item--disabled"],itemChoice:["choices__item--choice"],description:["choices__description"],placeholder:["choices__placeholder"],group:["choices__group"],groupHeading:["choices__heading"],button:["choices__button"],activeState:["is-active"],focusState:["is-focused"],openState:["is-open"],disabledState:["is-disabled"],highlightedState:["is-highlighted"],selectedState:["is-selected"],flippedState:["is-flipped"],loadingState:["is-loading"],notice:["choices__notice"],addChoice:["choices__item--selectable","add-choice"],noResults:["has-no-results"],noChoices:["has-no-choices"]},qc={items:[],choices:[],silent:!1,renderChoiceLimit:-1,maxItemCount:-1,closeDropdownOnSelect:"auto",singleModeForMultiSelect:!1,addChoices:!1,addItems:!0,addItemFilter:function(n){return!!n&&n!==""},removeItems:!0,removeItemButton:!1,removeItemButtonAlignLeft:!1,editItems:!1,allowHTML:!1,allowHtmlUserInput:!1,duplicateItemsAllowed:!0,delimiter:",",paste:!0,searchEnabled:!0,searchChoices:!0,searchFloor:1,searchResultLimit:4,searchFields:["label","value"],position:"auto",resetScrollPosition:!0,shouldSort:!0,shouldSortItems:!1,sorter:Kg,shadowRoot:null,placeholder:!0,placeholderValue:null,searchPlaceholderValue:null,prependValue:null,appendValue:null,renderSelectedChoices:"auto",loadingText:"Loading...",noResultsText:"No results found",noChoicesText:"No choices to choose from",itemSelectText:"Press to select",uniqueItemText:"Only unique values can be added",customAddItemText:"Only values matching specific conditions can be added",addItemText:function(n){return'Press Enter to add <b>"'.concat(n,'"</b>')},removeItemIconText:function(){return"Remove item"},removeItemLabelText:function(n){return"Remove item: ".concat(n)},maxItemText:function(n){return"Only ".concat(n," values can be added")},valueComparer:function(n,t){return n===t},fuseOptions:{includeScore:!0},labelId:"",callbackOnInit:null,callbackOnCreateTemplates:null,classNames:cp,appendGroupInSearch:!1},Jc=function(n){var t=n.itemEl;t&&(t.remove(),n.itemEl=void 0)};function hp(n,t,e){var i=n,s=!0;switch(t.type){case gt.ADD_ITEM:{t.item.selected=!0;var r=t.item.element;r&&(r.selected=!0,r.setAttribute("selected","")),i.push(t.item);break}case gt.REMOVE_ITEM:{t.item.selected=!1;var r=t.item.element;if(r){r.selected=!1,r.removeAttribute("selected");var o=r.parentElement;o&&Kc(o)&&o.type===ci.SelectOne&&(o.value="")}Jc(t.item),i=i.filter(function(h){return h.id!==t.item.id});break}case gt.REMOVE_CHOICE:{Jc(t.choice),i=i.filter(function(c){return c.id!==t.choice.id});break}case gt.HIGHLIGHT_ITEM:{var a=t.highlighted,l=i.find(function(c){return c.id===t.item.id});l&&l.highlighted!==a&&(l.highlighted=a,e&&tp(l,a?e.classNames.highlightedState:e.classNames.selectedState,a?e.classNames.selectedState:e.classNames.highlightedState));break}default:{s=!1;break}}return{state:i,update:s}}function up(n,t){var e=n,i=!0;switch(t.type){case gt.ADD_GROUP:{e.push(t.group);break}case gt.CLEAR_CHOICES:{e=[];break}default:{i=!1;break}}return{state:e,update:i}}function dp(n,t,e){var i=n,s=!0;switch(t.type){case gt.ADD_CHOICE:{i.push(t.choice);break}case gt.REMOVE_CHOICE:{t.choice.choiceEl=void 0,t.choice.group&&(t.choice.group.choices=t.choice.group.choices.filter(function(o){return o.id!==t.choice.id})),i=i.filter(function(o){return o.id!==t.choice.id});break}case gt.ADD_ITEM:case gt.REMOVE_ITEM:{t.item.choiceEl=void 0;break}case gt.FILTER_CHOICES:{var r=[];t.results.forEach(function(o){r[o.item.id]=o}),i.forEach(function(o){var a=r[o.id];a!==void 0?(o.score=a.score,o.rank=a.rank,o.active=!0):(o.score=0,o.rank=0,o.active=!1),e&&e.appendGroupInSearch&&(o.choiceEl=void 0)});break}case gt.ACTIVATE_CHOICES:{i.forEach(function(o){o.active=t.active,e&&e.appendGroupInSearch&&(o.choiceEl=void 0)});break}case gt.CLEAR_CHOICES:{i=[];break}default:{s=!1;break}}return{state:i,update:s}}var Zc={groups:up,items:hp,choices:dp},fp=function(){function n(t){this._state=this.defaultState,this._listeners=[],this._txn=0,this._context=t}return Object.defineProperty(n.prototype,"defaultState",{get:function(){return{groups:[],items:[],choices:[]}},enumerable:!1,configurable:!0}),n.prototype.changeSet=function(t){return{groups:t,items:t,choices:t}},n.prototype.reset=function(){this._state=this.defaultState;var t=this.changeSet(!0);this._txn?this._changeSet=t:this._listeners.forEach(function(e){return e(t)})},n.prototype.subscribe=function(t){return this._listeners.push(t),this},n.prototype.dispatch=function(t){var e=this,i=this._state,s=!1,r=this._changeSet||this.changeSet(!1);Object.keys(Zc).forEach(function(o){var a=Zc[o](i[o],t,e._context);a.update&&(s=!0,r[o]=!0,i[o]=a.state)}),s&&(this._txn?this._changeSet=r:this._listeners.forEach(function(o){return o(r)}))},n.prototype.withTxn=function(t){this._txn++;try{t()}finally{if(this._txn=Math.max(0,this._txn-1),!this._txn){var e=this._changeSet;e&&(this._changeSet=void 0,this._listeners.forEach(function(i){return i(e)}))}}},Object.defineProperty(n.prototype,"state",{get:function(){return this._state},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"items",{get:function(){return this.state.items},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"highlightedActiveItems",{get:function(){return this.items.filter(function(t){return!t.disabled&&t.active&&t.highlighted})},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"choices",{get:function(){return this.state.choices},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"activeChoices",{get:function(){return this.choices.filter(function(t){return t.active})},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"searchableChoices",{get:function(){return this.choices.filter(function(t){return!t.disabled&&!t.placeholder})},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"groups",{get:function(){return this.state.groups},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"activeGroups",{get:function(){var t=this;return this.state.groups.filter(function(e){var i=e.active&&!e.disabled,s=t.state.choices.some(function(r){return r.active&&!r.disabled});return i&&s},[])},enumerable:!1,configurable:!0}),n.prototype.inTxn=function(){return this._txn>0},n.prototype.getChoiceById=function(t){return this.activeChoices.find(function(e){return e.id===t})},n.prototype.getGroupById=function(t){return this.groups.find(function(e){return e.id===t})},n}(),Dt={noChoices:"no-choices",noResults:"no-results",addChoice:"add-choice",generic:""};function gp(n,t,e){return(t=mp(t))in n?Object.defineProperty(n,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):n[t]=e,n}function Qc(n,t){var e=Object.keys(n);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(n);t&&(i=i.filter(function(s){return Object.getOwnPropertyDescriptor(n,s).enumerable})),e.push.apply(e,i)}return e}function as(n){for(var t=1;t<arguments.length;t++){var e=arguments[t]!=null?arguments[t]:{};t%2?Qc(Object(e),!0).forEach(function(i){gp(n,i,e[i])}):Object.getOwnPropertyDescriptors?Object.defineProperties(n,Object.getOwnPropertyDescriptors(e)):Qc(Object(e)).forEach(function(i){Object.defineProperty(n,i,Object.getOwnPropertyDescriptor(e,i))})}return n}function pp(n,t){if(typeof n!="object"||!n)return n;var e=n[Symbol.toPrimitive];if(e!==void 0){var i=e.call(n,t);if(typeof i!="object")return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(n)}function mp(n){var t=pp(n,"string");return typeof t=="symbol"?t:t+""}function We(n){return Array.isArray?Array.isArray(n):ih(n)==="[object Array]"}function vp(n){if(typeof n=="string")return n;let t=n+"";return t=="0"&&1/n==-1/0?"-0":t}function _p(n){return n==null?"":vp(n)}function Oe(n){return typeof n=="string"}function th(n){return typeof n=="number"}function bp(n){return n===!0||n===!1||yp(n)&&ih(n)=="[object Boolean]"}function eh(n){return typeof n=="object"}function yp(n){return eh(n)&&n!==null}function Kt(n){return n!=null}function Qo(n){return!n.trim().length}function ih(n){return n==null?n===void 0?"[object Undefined]":"[object Null]":Object.prototype.toString.call(n)}const xp="Incorrect 'index' type",Cp=n=>`Invalid value for key ${n}`,Sp=n=>`Pattern length exceeds max of ${n}.`,wp=n=>`Missing ${n} property in key`,Tp=n=>`Property 'weight' in key '${n}' must be a positive integer`,sh=Object.prototype.hasOwnProperty;class Ep{constructor(t){this._keys=[],this._keyMap={};let e=0;t.forEach(i=>{let s=rh(i);this._keys.push(s),this._keyMap[s.id]=s,e+=s.weight}),this._keys.forEach(i=>{i.weight/=e})}get(t){return this._keyMap[t]}keys(){return this._keys}toJSON(){return JSON.stringify(this._keys)}}function rh(n){let t=null,e=null,i=null,s=1,r=null;if(Oe(n)||We(n))i=n,t=nh(n),e=ta(n);else{if(!sh.call(n,"name"))throw new Error(wp("name"));const o=n.name;if(i=o,sh.call(n,"weight")&&(s=n.weight,s<=0))throw new Error(Tp(o));t=nh(o),e=ta(o),r=n.getFn}return{path:t,id:e,weight:s,src:i,getFn:r}}function nh(n){return We(n)?n:n.split(".")}function ta(n){return We(n)?n.join("."):n}function Op(n,t){let e=[],i=!1;const s=(r,o,a)=>{if(Kt(r))if(!o[a])e.push(r);else{let l=o[a];const c=r[l];if(!Kt(c))return;if(a===o.length-1&&(Oe(c)||th(c)||bp(c)))e.push(_p(c));else if(We(c)){i=!0;for(let h=0,u=c.length;h<u;h+=1)s(c[h],o,a+1)}else o.length&&s(c,o,a+1)}};return s(n,Oe(t)?t.split("."):t,0),i?e:e[0]}const Ap={includeMatches:!1,findAllMatches:!1,minMatchCharLength:1},Dp={isCaseSensitive:!1,includeScore:!1,keys:[],shouldSort:!0,sortFn:(n,t)=>n.score===t.score?n.idx<t.idx?-1:1:n.score<t.score?-1:1},kp={location:0,threshold:.6,distance:100},Mp={useExtendedSearch:!1,getFn:Op,ignoreLocation:!1,ignoreFieldNorm:!1,fieldNormWeight:1};var W=as(as(as(as({},Dp),Ap),kp),Mp);const Pp=/[^ ]+/g;function Ip(n=1,t=3){const e=new Map,i=Math.pow(10,t);return{get(s){const r=s.match(Pp).length;if(e.has(r))return e.get(r);const o=1/Math.pow(r,.5*n),a=parseFloat(Math.round(o*i)/i);return e.set(r,a),a},clear(){e.clear()}}}class ea{constructor({getFn:t=W.getFn,fieldNormWeight:e=W.fieldNormWeight}={}){this.norm=Ip(e,3),this.getFn=t,this.isCreated=!1,this.setIndexRecords()}setSources(t=[]){this.docs=t}setIndexRecords(t=[]){this.records=t}setKeys(t=[]){this.keys=t,this._keysMap={},t.forEach((e,i)=>{this._keysMap[e.id]=i})}create(){this.isCreated||!this.docs.length||(this.isCreated=!0,Oe(this.docs[0])?this.docs.forEach((t,e)=>{this._addString(t,e)}):this.docs.forEach((t,e)=>{this._addObject(t,e)}),this.norm.clear())}add(t){const e=this.size();Oe(t)?this._addString(t,e):this._addObject(t,e)}removeAt(t){this.records.splice(t,1);for(let e=t,i=this.size();e<i;e+=1)this.records[e].i-=1}getValueForItemAtKeyId(t,e){return t[this._keysMap[e]]}size(){return this.records.length}_addString(t,e){if(!Kt(t)||Qo(t))return;let i={v:t,i:e,n:this.norm.get(t)};this.records.push(i)}_addObject(t,e){let i={i:e,$:{}};this.keys.forEach((s,r)=>{let o=s.getFn?s.getFn(t):this.getFn(t,s.path);if(Kt(o)){if(We(o)){let a=[];const l=[{nestedArrIndex:-1,value:o}];for(;l.length;){const{nestedArrIndex:c,value:h}=l.pop();if(Kt(h))if(Oe(h)&&!Qo(h)){let u={v:h,i:c,n:this.norm.get(h)};a.push(u)}else We(h)&&h.forEach((u,d)=>{l.push({nestedArrIndex:d,value:u})})}i.$[r]=a}else if(Oe(o)&&!Qo(o)){let a={v:o,n:this.norm.get(o)};i.$[r]=a}}}),this.records.push(i)}toJSON(){return{keys:this.keys,records:this.records}}}function oh(n,t,{getFn:e=W.getFn,fieldNormWeight:i=W.fieldNormWeight}={}){const s=new ea({getFn:e,fieldNormWeight:i});return s.setKeys(n.map(rh)),s.setSources(t),s.create(),s}function Lp(n,{getFn:t=W.getFn,fieldNormWeight:e=W.fieldNormWeight}={}){const{keys:i,records:s}=n,r=new ea({getFn:t,fieldNormWeight:e});return r.setKeys(i),r.setIndexRecords(s),r}function wn(n,{errors:t=0,currentLocation:e=0,expectedLocation:i=0,distance:s=W.distance,ignoreLocation:r=W.ignoreLocation}={}){const o=t/n.length;if(r)return o;const a=Math.abs(i-e);return s?o+a/s:a?1:o}function jp(n=[],t=W.minMatchCharLength){let e=[],i=-1,s=-1,r=0;for(let o=n.length;r<o;r+=1){let a=n[r];a&&i===-1?i=r:!a&&i!==-1&&(s=r-1,s-i+1>=t&&e.push([i,s]),i=-1)}return n[r-1]&&r-i>=t&&e.push([i,r-1]),e}const Li=32;function Fp(n,t,e,{location:i=W.location,distance:s=W.distance,threshold:r=W.threshold,findAllMatches:o=W.findAllMatches,minMatchCharLength:a=W.minMatchCharLength,includeMatches:l=W.includeMatches,ignoreLocation:c=W.ignoreLocation}={}){if(t.length>Li)throw new Error(Sp(Li));const h=t.length,u=n.length,d=Math.max(0,Math.min(i,u));let f=r,g=d;const p=a>1||l,m=p?Array(u):[];let v;for(;(v=n.indexOf(t,g))>-1;){let S=wn(t,{currentLocation:v,expectedLocation:d,distance:s,ignoreLocation:c});if(f=Math.min(S,f),g=v+h,p){let w=0;for(;w<h;)m[v+w]=1,w+=1}}g=-1;let y=[],x=1,E=h+u;const T=1<<h-1;for(let S=0;S<h;S+=1){let w=0,L=E;for(;w<L;)wn(t,{errors:S,currentLocation:d+L,expectedLocation:d,distance:s,ignoreLocation:c})<=f?w=L:E=L,L=Math.floor((E-w)/2+w);E=L;let j=Math.max(1,d-L+1),A=o?u:Math.min(d+L,u)+h,O=Array(A+2);O[A+1]=(1<<S)-1;for(let I=A;I>=j;I-=1){let $=I-1,X=e[n.charAt($)];if(p&&(m[$]=+!!X),O[I]=(O[I+1]<<1|1)&X,S&&(O[I]|=(y[I+1]|y[I])<<1|1|y[I+1]),O[I]&T&&(x=wn(t,{errors:S,currentLocation:$,expectedLocation:d,distance:s,ignoreLocation:c}),x<=f)){if(f=x,g=$,g<=d)break;j=Math.max(1,2*d-g)}}if(wn(t,{errors:S+1,currentLocation:d,expectedLocation:d,distance:s,ignoreLocation:c})>f)break;y=O}const k={isMatch:g>=0,score:Math.max(.001,x)};if(p){const S=jp(m,a);S.length?l&&(k.indices=S):k.isMatch=!1}return k}function Rp(n){let t={};for(let e=0,i=n.length;e<i;e+=1){const s=n.charAt(e);t[s]=(t[s]||0)|1<<i-e-1}return t}class ah{constructor(t,{location:e=W.location,threshold:i=W.threshold,distance:s=W.distance,includeMatches:r=W.includeMatches,findAllMatches:o=W.findAllMatches,minMatchCharLength:a=W.minMatchCharLength,isCaseSensitive:l=W.isCaseSensitive,ignoreLocation:c=W.ignoreLocation}={}){if(this.options={location:e,threshold:i,distance:s,includeMatches:r,findAllMatches:o,minMatchCharLength:a,isCaseSensitive:l,ignoreLocation:c},this.pattern=l?t:t.toLowerCase(),this.chunks=[],!this.pattern.length)return;const h=(d,f)=>{this.chunks.push({pattern:d,alphabet:Rp(d),startIndex:f})},u=this.pattern.length;if(u>Li){let d=0;const f=u%Li,g=u-f;for(;d<g;)h(this.pattern.substr(d,Li),d),d+=Li;if(f){const p=u-Li;h(this.pattern.substr(p),p)}}else h(this.pattern,0)}searchIn(t){const{isCaseSensitive:e,includeMatches:i}=this.options;if(e||(t=t.toLowerCase()),this.pattern===t){let g={isMatch:!0,score:0};return i&&(g.indices=[[0,t.length-1]]),g}const{location:s,distance:r,threshold:o,findAllMatches:a,minMatchCharLength:l,ignoreLocation:c}=this.options;let h=[],u=0,d=!1;this.chunks.forEach(({pattern:g,alphabet:p,startIndex:m})=>{const{isMatch:v,score:y,indices:x}=Fp(t,g,p,{location:s+m,distance:r,threshold:o,findAllMatches:a,minMatchCharLength:l,includeMatches:i,ignoreLocation:c});v&&(d=!0),u+=y,v&&x&&(h=[...h,...x])});let f={isMatch:d,score:d?u/this.chunks.length:1};return d&&i&&(f.indices=h),f}}class hi{constructor(t){this.pattern=t}static isMultiMatch(t){return lh(t,this.multiRegex)}static isSingleMatch(t){return lh(t,this.singleRegex)}search(){}}function lh(n,t){const e=n.match(t);return e?e[1]:null}class Np extends hi{constructor(t){super(t)}static get type(){return"exact"}static get multiRegex(){return/^="(.*)"$/}static get singleRegex(){return/^=(.*)$/}search(t){const e=t===this.pattern;return{isMatch:e,score:e?0:1,indices:[0,this.pattern.length-1]}}}class Bp extends hi{constructor(t){super(t)}static get type(){return"inverse-exact"}static get multiRegex(){return/^!"(.*)"$/}static get singleRegex(){return/^!(.*)$/}search(t){const i=t.indexOf(this.pattern)===-1;return{isMatch:i,score:i?0:1,indices:[0,t.length-1]}}}class $p extends hi{constructor(t){super(t)}static get type(){return"prefix-exact"}static get multiRegex(){return/^\^"(.*)"$/}static get singleRegex(){return/^\^(.*)$/}search(t){const e=t.startsWith(this.pattern);return{isMatch:e,score:e?0:1,indices:[0,this.pattern.length-1]}}}class Vp extends hi{constructor(t){super(t)}static get type(){return"inverse-prefix-exact"}static get multiRegex(){return/^!\^"(.*)"$/}static get singleRegex(){return/^!\^(.*)$/}search(t){const e=!t.startsWith(this.pattern);return{isMatch:e,score:e?0:1,indices:[0,t.length-1]}}}class zp extends hi{constructor(t){super(t)}static get type(){return"suffix-exact"}static get multiRegex(){return/^"(.*)"\$$/}static get singleRegex(){return/^(.*)\$$/}search(t){const e=t.endsWith(this.pattern);return{isMatch:e,score:e?0:1,indices:[t.length-this.pattern.length,t.length-1]}}}class Hp extends hi{constructor(t){super(t)}static get type(){return"inverse-suffix-exact"}static get multiRegex(){return/^!"(.*)"\$$/}static get singleRegex(){return/^!(.*)\$$/}search(t){const e=!t.endsWith(this.pattern);return{isMatch:e,score:e?0:1,indices:[0,t.length-1]}}}class ch extends hi{constructor(t,{location:e=W.location,threshold:i=W.threshold,distance:s=W.distance,includeMatches:r=W.includeMatches,findAllMatches:o=W.findAllMatches,minMatchCharLength:a=W.minMatchCharLength,isCaseSensitive:l=W.isCaseSensitive,ignoreLocation:c=W.ignoreLocation}={}){super(t),this._bitapSearch=new ah(t,{location:e,threshold:i,distance:s,includeMatches:r,findAllMatches:o,minMatchCharLength:a,isCaseSensitive:l,ignoreLocation:c})}static get type(){return"fuzzy"}static get multiRegex(){return/^"(.*)"$/}static get singleRegex(){return/^(.*)$/}search(t){return this._bitapSearch.searchIn(t)}}class hh extends hi{constructor(t){super(t)}static get type(){return"include"}static get multiRegex(){return/^'"(.*)"$/}static get singleRegex(){return/^'(.*)$/}search(t){let e=0,i;const s=[],r=this.pattern.length;for(;(i=t.indexOf(this.pattern,e))>-1;)e=i+r,s.push([i,e-1]);const o=!!s.length;return{isMatch:o,score:o?0:1,indices:s}}}const ia=[Np,hh,$p,Vp,Hp,zp,Bp,ch],uh=ia.length,Wp=/ +(?=(?:[^\"]*\"[^\"]*\")*[^\"]*$)/,Yp="|";function Up(n,t={}){return n.split(Yp).map(e=>{let i=e.trim().split(Wp).filter(r=>r&&!!r.trim()),s=[];for(let r=0,o=i.length;r<o;r+=1){const a=i[r];let l=!1,c=-1;for(;!l&&++c<uh;){const h=ia[c];let u=h.isMultiMatch(a);u&&(s.push(new h(u,t)),l=!0)}if(!l)for(c=-1;++c<uh;){const h=ia[c];let u=h.isSingleMatch(a);if(u){s.push(new h(u,t));break}}}return s})}const Gp=new Set([ch.type,hh.type]);class Xp{constructor(t,{isCaseSensitive:e=W.isCaseSensitive,includeMatches:i=W.includeMatches,minMatchCharLength:s=W.minMatchCharLength,ignoreLocation:r=W.ignoreLocation,findAllMatches:o=W.findAllMatches,location:a=W.location,threshold:l=W.threshold,distance:c=W.distance}={}){this.query=null,this.options={isCaseSensitive:e,includeMatches:i,minMatchCharLength:s,findAllMatches:o,ignoreLocation:r,location:a,threshold:l,distance:c},this.pattern=e?t:t.toLowerCase(),this.query=Up(this.pattern,this.options)}static condition(t,e){return e.useExtendedSearch}searchIn(t){const e=this.query;if(!e)return{isMatch:!1,score:1};const{includeMatches:i,isCaseSensitive:s}=this.options;t=s?t:t.toLowerCase();let r=0,o=[],a=0;for(let l=0,c=e.length;l<c;l+=1){const h=e[l];o.length=0,r=0;for(let u=0,d=h.length;u<d;u+=1){const f=h[u],{isMatch:g,indices:p,score:m}=f.search(t);if(g){if(r+=1,a+=m,i){const v=f.constructor.type;Gp.has(v)?o=[...o,...p]:o.push(p)}}else{a=0,r=0,o.length=0;break}}if(r){let u={isMatch:!0,score:a/r};return i&&(u.indices=o),u}}return{isMatch:!1,score:1}}}const sa=[];function Kp(...n){sa.push(...n)}function ra(n,t){for(let e=0,i=sa.length;e<i;e+=1){let s=sa[e];if(s.condition(n,t))return new s(n,t)}return new ah(n,t)}const Tn={AND:"$and",OR:"$or"},na={PATH:"$path",PATTERN:"$val"},oa=n=>!!(n[Tn.AND]||n[Tn.OR]),qp=n=>!!n[na.PATH],Jp=n=>!We(n)&&eh(n)&&!oa(n),dh=n=>({[Tn.AND]:Object.keys(n).map(t=>({[t]:n[t]}))});function fh(n,t,{auto:e=!0}={}){const i=s=>{let r=Object.keys(s);const o=qp(s);if(!o&&r.length>1&&!oa(s))return i(dh(s));if(Jp(s)){const l=o?s[na.PATH]:r[0],c=o?s[na.PATTERN]:s[l];if(!Oe(c))throw new Error(Cp(l));const h={keyId:ta(l),pattern:c};return e&&(h.searcher=ra(c,t)),h}let a={children:[],operator:r[0]};return r.forEach(l=>{const c=s[l];We(c)&&c.forEach(h=>{a.children.push(i(h))})}),a};return oa(n)||(n=dh(n)),i(n)}function Zp(n,{ignoreFieldNorm:t=W.ignoreFieldNorm}){n.forEach(e=>{let i=1;e.matches.forEach(({key:s,norm:r,score:o})=>{const a=s?s.weight:null;i*=Math.pow(o===0&&a?Number.EPSILON:o,(a||1)*(t?1:r))}),e.score=i})}function Qp(n,t){const e=n.matches;t.matches=[],Kt(e)&&e.forEach(i=>{if(!Kt(i.indices)||!i.indices.length)return;const{indices:s,value:r}=i;let o={indices:s,value:r};i.key&&(o.key=i.key.src),i.idx>-1&&(o.refIndex=i.idx),t.matches.push(o)})}function tm(n,t){t.score=n.score}function em(n,t,{includeMatches:e=W.includeMatches,includeScore:i=W.includeScore}={}){const s=[];return e&&s.push(Qp),i&&s.push(tm),n.map(r=>{const{idx:o}=r,a={item:t[o],refIndex:o};return s.length&&s.forEach(l=>{l(r,a)}),a})}class ls{constructor(t,e={},i){this.options=as(as({},W),e),this.options.useExtendedSearch,this._keyStore=new Ep(this.options.keys),this.setCollection(t,i)}setCollection(t,e){if(this._docs=t,e&&!(e instanceof ea))throw new Error(xp);this._myIndex=e||oh(this.options.keys,this._docs,{getFn:this.options.getFn,fieldNormWeight:this.options.fieldNormWeight})}add(t){Kt(t)&&(this._docs.push(t),this._myIndex.add(t))}remove(t=()=>!1){const e=[];for(let i=0,s=this._docs.length;i<s;i+=1){const r=this._docs[i];t(r,i)&&(this.removeAt(i),i-=1,s-=1,e.push(r))}return e}removeAt(t){this._docs.splice(t,1),this._myIndex.removeAt(t)}getIndex(){return this._myIndex}search(t,{limit:e=-1}={}){const{includeMatches:i,includeScore:s,shouldSort:r,sortFn:o,ignoreFieldNorm:a}=this.options;let l=Oe(t)?Oe(this._docs[0])?this._searchStringList(t):this._searchObjectList(t):this._searchLogical(t);return Zp(l,{ignoreFieldNorm:a}),r&&l.sort(o),th(e)&&e>-1&&(l=l.slice(0,e)),em(l,this._docs,{includeMatches:i,includeScore:s})}_searchStringList(t){const e=ra(t,this.options),{records:i}=this._myIndex,s=[];return i.forEach(({v:r,i:o,n:a})=>{if(!Kt(r))return;const{isMatch:l,score:c,indices:h}=e.searchIn(r);l&&s.push({item:r,idx:o,matches:[{score:c,value:r,norm:a,indices:h}]})}),s}_searchLogical(t){const e=fh(t,this.options),i=(a,l,c)=>{if(!a.children){const{keyId:u,searcher:d}=a,f=this._findMatches({key:this._keyStore.get(u),value:this._myIndex.getValueForItemAtKeyId(l,u),searcher:d});return f&&f.length?[{idx:c,item:l,matches:f}]:[]}const h=[];for(let u=0,d=a.children.length;u<d;u+=1){const f=a.children[u],g=i(f,l,c);if(g.length)h.push(...g);else if(a.operator===Tn.AND)return[]}return h},s=this._myIndex.records,r={},o=[];return s.forEach(({$:a,i:l})=>{if(Kt(a)){let c=i(e,a,l);c.length&&(r[l]||(r[l]={idx:l,item:a,matches:[]},o.push(r[l])),c.forEach(({matches:h})=>{r[l].matches.push(...h)}))}}),o}_searchObjectList(t){const e=ra(t,this.options),{keys:i,records:s}=this._myIndex,r=[];return s.forEach(({$:o,i:a})=>{if(!Kt(o))return;let l=[];i.forEach((c,h)=>{l.push(...this._findMatches({key:c,value:o[h],searcher:e}))}),l.length&&r.push({idx:a,item:o,matches:l})}),r}_findMatches({key:t,value:e,searcher:i}){if(!Kt(e))return[];let s=[];if(We(e))e.forEach(({v:r,i:o,n:a})=>{if(!Kt(r))return;const{isMatch:l,score:c,indices:h}=i.searchIn(r);l&&s.push({score:c,key:t,value:r,idx:o,norm:a,indices:h})});else{const{v:r,n:o}=e,{isMatch:a,score:l,indices:c}=i.searchIn(r);a&&s.push({score:l,key:t,value:r,norm:o,indices:c})}return s}}ls.version="7.0.0",ls.createIndex=oh,ls.parseIndex=Lp,ls.config=W,ls.parseQuery=fh,Kp(Xp);var im=function(){function n(t){this._haystack=[],this._fuseOptions=zt(zt({},t.fuseOptions),{keys:Fg([],t.searchFields),includeMatches:!0})}return n.prototype.index=function(t){this._haystack=t,this._fuse&&this._fuse.setCollection(t)},n.prototype.reset=function(){this._haystack=[],this._fuse=void 0},n.prototype.isEmptyIndex=function(){return!this._haystack.length},n.prototype.search=function(t){this._fuse||(this._fuse=new ls(this._haystack,this._fuseOptions));var e=this._fuse.search(t);return e.map(function(i,s){return{item:i.item,score:i.score||0,rank:s+1}})},n}();function sm(n){return new im(n)}var rm=function(n){for(var t in n)if(Object.prototype.hasOwnProperty.call(n,t))return!1;return!0},aa=function(n,t,e){var i=n.dataset,s=t.customProperties,r=t.labelClass,o=t.labelDescription;r&&(i.labelClass=Sn(r).join(" ")),o&&(i.labelDescription=o),e&&s&&(typeof s=="string"?i.customProperties=s:typeof s=="object"&&!rm(s)&&(i.customProperties=JSON.stringify(s)))},gh=function(n,t,e){var i=t&&n.querySelector("label[for='".concat(t,"']")),s=i&&i.innerText;s&&e.setAttribute("aria-label",s)},nm={containerOuter:function(n,t,e,i,s,r,o){var a=n.classNames.containerOuter,l=document.createElement("div");return Y(l,a),l.dataset.type=r,t&&(l.dir=t),i&&(l.tabIndex=0),e&&(l.setAttribute("role",s?"combobox":"listbox"),s?l.setAttribute("aria-autocomplete","list"):o||gh(this._docRoot,this.passedElement.element.id,l),l.setAttribute("aria-haspopup","true"),l.setAttribute("aria-expanded","false")),o&&l.setAttribute("aria-labelledby",o),l},containerInner:function(n){var t=n.classNames.containerInner,e=document.createElement("div");return Y(e,t),e},itemList:function(n,t){var e=n.searchEnabled,i=n.classNames,s=i.list,r=i.listSingle,o=i.listItems,a=document.createElement("div");return Y(a,s),Y(a,t?r:o),this._isSelectElement&&e&&a.setAttribute("role","listbox"),a},placeholder:function(n,t){var e=n.allowHTML,i=n.classNames.placeholder,s=document.createElement("div");return Y(s,i),He(s,e,t),s},item:function(n,t,e){var i=n.allowHTML,s=n.removeItemButtonAlignLeft,r=n.removeItemIconText,o=n.removeItemLabelText,a=n.classNames,l=a.item,c=a.button,h=a.highlightedState,u=a.itemSelectable,d=a.placeholder,f=Ii(t.value),g=document.createElement("div");if(Y(g,l),t.labelClass){var p=document.createElement("span");He(p,i,t.label),Y(p,t.labelClass),g.appendChild(p)}else He(g,i,t.label);if(g.dataset.item="",g.dataset.id=t.id,g.dataset.value=f,aa(g,t,!0),(t.disabled||this.containerOuter.isDisabled)&&g.setAttribute("aria-disabled","true"),this._isSelectElement&&(g.setAttribute("aria-selected","true"),g.setAttribute("role","option")),t.placeholder&&(Y(g,d),g.dataset.placeholder=""),Y(g,t.highlighted?h:u),e){t.disabled&&Te(g,u),g.dataset.deletable="";var m=document.createElement("button");m.type="button",Y(m,c),He(m,!0,Hs(r,t.value));var v=Hs(o,t.value);v&&m.setAttribute("aria-label",v),m.dataset.button="",s?g.insertAdjacentElement("afterbegin",m):g.appendChild(m)}return g},choiceList:function(n,t){var e=n.classNames.list,i=document.createElement("div");return Y(i,e),t||i.setAttribute("aria-multiselectable","true"),i.setAttribute("role","listbox"),i},choiceGroup:function(n,t){var e=n.allowHTML,i=n.classNames,s=i.group,r=i.groupHeading,o=i.itemDisabled,a=t.id,l=t.label,c=t.disabled,h=Ii(l),u=document.createElement("div");Y(u,s),c&&Y(u,o),u.setAttribute("role","group"),u.dataset.group="",u.dataset.id=a,u.dataset.value=h,c&&u.setAttribute("aria-disabled","true");var d=document.createElement("div");return Y(d,r),He(d,e,l||""),u.appendChild(d),u},choice:function(n,t,e,i){var s=n.allowHTML,r=n.classNames,o=r.item,a=r.itemChoice,l=r.itemSelectable,c=r.selectedState,h=r.itemDisabled,u=r.description,d=r.placeholder,f=t.label,g=Ii(t.value),p=document.createElement("div");p.id=t.elementId,Y(p,o),Y(p,a),i&&typeof f=="string"&&(f=Zo(s,f),f+=" (".concat(i,")"),f={trusted:f});var m=p;if(t.labelClass){var v=document.createElement("span");He(v,s,f),Y(v,t.labelClass),m=v,p.appendChild(v)}else He(p,s,f);if(t.labelDescription){var y="".concat(t.elementId,"-description");m.setAttribute("aria-describedby",y);var x=document.createElement("span");He(x,s,t.labelDescription),x.id=y,Y(x,u),p.appendChild(x)}return t.selected&&Y(p,c),t.placeholder&&Y(p,d),p.setAttribute("role",t.group?"treeitem":"option"),p.dataset.choice="",p.dataset.id=t.id,p.dataset.value=g,e&&(p.dataset.selectText=e),t.group&&(p.dataset.groupId="".concat(t.group.id)),aa(p,t,!1),t.disabled?(Y(p,h),p.dataset.choiceDisabled="",p.setAttribute("aria-disabled","true")):(Y(p,l),p.dataset.choiceSelectable=""),p},input:function(n,t){var e=n.classNames,i=e.input,s=e.inputCloned,r=n.labelId,o=document.createElement("input");return o.type="search",Y(o,i),Y(o,s),o.autocomplete="off",o.autocapitalize="off",o.spellcheck=!1,o.setAttribute("role","textbox"),o.setAttribute("aria-autocomplete","list"),t?o.setAttribute("aria-label",t):r||gh(this._docRoot,this.passedElement.element.id,o),o},dropdown:function(n){var t=n.classNames,e=t.list,i=t.listDropdown,s=document.createElement("div");return Y(s,e),Y(s,i),s.setAttribute("aria-expanded","false"),s},notice:function(n,t,e){var i=n.classNames,s=i.item,r=i.itemChoice,o=i.addChoice,a=i.noResults,l=i.noChoices,c=i.notice;e===void 0&&(e=Dt.generic);var h=document.createElement("div");switch(He(h,!0,t),Y(h,s),Y(h,r),Y(h,c),e){case Dt.addChoice:Y(h,o);break;case Dt.noResults:Y(h,a);break;case Dt.noChoices:Y(h,l);break}return e===Dt.addChoice&&(h.dataset.choiceSelectable="",h.dataset.choice=""),h},option:function(n){var t=Ii(n.label),e=new Option(t,n.value,!1,n.selected);return aa(e,n,!0),e.disabled=n.disabled,n.selected&&e.setAttribute("selected",""),e}},om="-ms-scroll-limit"in document.documentElement.style&&"-ms-ime-align"in document.documentElement.style,am={},la=function(n){if(n)return n.dataset.id?parseInt(n.dataset.id,10):void 0},Us="[data-choice-selectable]",lm=function(){function n(t,e){t===void 0&&(t="[data-choice]"),e===void 0&&(e={});var i=this;this.initialisedOK=void 0,this._hasNonChoicePlaceholder=!1,this._lastAddedChoiceId=0,this._lastAddedGroupId=0;var s=n.defaults;this.config=zt(zt(zt({},s.allOptions),s.options),e),Rg.forEach(function(v){i.config[v]=zt(zt(zt({},s.allOptions[v]),s.options[v]),e[v])});var r=this.config;r.silent||this._validateConfig();var o=r.shadowRoot||document.documentElement;this._docRoot=o;var a=typeof t=="string"?o.querySelector(t):t;if(!a||typeof a!="object"||!(np(a)||Kc(a)))throw TypeError(!a&&typeof t=="string"?"Selector ".concat(t," failed to find an element"):"Expected one of the following types text|select-one|select-multiple");var l=a.type,c=l===ci.Text;(c||r.maxItemCount!==1)&&(r.singleModeForMultiSelect=!1),r.singleModeForMultiSelect&&(l=ci.SelectMultiple);var h=l===ci.SelectOne,u=l===ci.SelectMultiple,d=h||u;if(this._elementType=l,this._isTextElement=c,this._isSelectOneElement=h,this._isSelectMultipleElement=u,this._isSelectElement=h||u,this._canAddUserChoices=c&&r.addItems||d&&r.addChoices,typeof r.renderSelectedChoices!="boolean"&&(r.renderSelectedChoices=r.renderSelectedChoices==="always"||h),r.closeDropdownOnSelect==="auto"?r.closeDropdownOnSelect=c||h||r.singleModeForMultiSelect:r.closeDropdownOnSelect=Ys(r.closeDropdownOnSelect),r.placeholder&&(r.placeholderValue?this._hasNonChoicePlaceholder=!0:a.dataset.placeholder&&(this._hasNonChoicePlaceholder=!0,r.placeholderValue=a.dataset.placeholder)),e.addItemFilter&&typeof e.addItemFilter!="function"){var f=e.addItemFilter instanceof RegExp?e.addItemFilter:new RegExp(e.addItemFilter);r.addItemFilter=f.test.bind(f)}if(this._isTextElement)this.passedElement=new rp({element:a,classNames:r.classNames});else{var g=a;this.passedElement=new lp({element:g,classNames:r.classNames,template:function(v){return i._templates.option(v)},extractPlaceholder:r.placeholder&&!this._hasNonChoicePlaceholder})}if(this.initialised=!1,this._store=new fp(r),this._currentValue="",r.searchEnabled=!c&&r.searchEnabled||u,this._canSearch=r.searchEnabled,this._isScrollingOnIe=!1,this._highlightPosition=0,this._wasTap=!0,this._placeholderValue=this._generatePlaceholderValue(),this._baseId=Wg(a,"choices-"),this._direction=a.dir,!this._direction){var p=window.getComputedStyle(a).direction,m=window.getComputedStyle(document.documentElement).direction;p!==m&&(this._direction=p)}if(this._idNames={itemChoice:"item-choice"},this._templates=s.templates,this._render=this._render.bind(this),this._onFocus=this._onFocus.bind(this),this._onBlur=this._onBlur.bind(this),this._onKeyUp=this._onKeyUp.bind(this),this._onKeyDown=this._onKeyDown.bind(this),this._onInput=this._onInput.bind(this),this._onClick=this._onClick.bind(this),this._onTouchMove=this._onTouchMove.bind(this),this._onTouchEnd=this._onTouchEnd.bind(this),this._onMouseDown=this._onMouseDown.bind(this),this._onMouseOver=this._onMouseOver.bind(this),this._onFormReset=this._onFormReset.bind(this),this._onSelectKey=this._onSelectKey.bind(this),this._onEnterKey=this._onEnterKey.bind(this),this._onEscapeKey=this._onEscapeKey.bind(this),this._onDirectionKey=this._onDirectionKey.bind(this),this._onDeleteKey=this._onDeleteKey.bind(this),this.passedElement.isActive){r.silent||console.warn("Trying to initialise Choices on element already initialised",{element:t}),this.initialised=!0,this.initialisedOK=!1;return}this.init(),this._initialItems=this._store.items.map(function(v){return v.value})}return Object.defineProperty(n,"defaults",{get:function(){return Object.preventExtensions({get options(){return am},get allOptions(){return qc},get templates(){return nm}})},enumerable:!1,configurable:!0}),n.prototype.init=function(){if(!(this.initialised||this.initialisedOK!==void 0)){this._searcher=sm(this.config),this._loadChoices(),this._createTemplates(),this._createElements(),this._createStructure(),this._isTextElement&&!this.config.addItems||this.passedElement.element.hasAttribute("disabled")||this.passedElement.element.closest("fieldset:disabled")?this.disable():(this.enable(),this._addEventListeners()),this._initStore(),this.initialised=!0,this.initialisedOK=!0;var t=this.config.callbackOnInit;typeof t=="function"&&t.call(this)}},n.prototype.destroy=function(){this.initialised&&(this._removeEventListeners(),this.passedElement.reveal(),this.containerOuter.unwrap(this.passedElement.element),this._store._listeners=[],this.clearStore(!1),this._stopSearch(),this._templates=n.defaults.templates,this.initialised=!1,this.initialisedOK=void 0)},n.prototype.enable=function(){return this.passedElement.isDisabled&&this.passedElement.enable(),this.containerOuter.isDisabled&&(this._addEventListeners(),this.input.enable(),this.containerOuter.enable()),this},n.prototype.disable=function(){return this.passedElement.isDisabled||this.passedElement.disable(),this.containerOuter.isDisabled||(this._removeEventListeners(),this.input.disable(),this.containerOuter.disable()),this},n.prototype.highlightItem=function(t,e){if(e===void 0&&(e=!0),!t||!t.id)return this;var i=this._store.items.find(function(s){return s.id===t.id});return!i||i.highlighted?this:(this._store.dispatch(xn(i,!0)),e&&this.passedElement.triggerEvent(Ht.highlightItem,this._getChoiceForOutput(i)),this)},n.prototype.unhighlightItem=function(t,e){if(e===void 0&&(e=!0),!t||!t.id)return this;var i=this._store.items.find(function(s){return s.id===t.id});return!i||!i.highlighted?this:(this._store.dispatch(xn(i,!1)),e&&this.passedElement.triggerEvent(Ht.unhighlightItem,this._getChoiceForOutput(i)),this)},n.prototype.highlightAll=function(){var t=this;return this._store.withTxn(function(){t._store.items.forEach(function(e){e.highlighted||(t._store.dispatch(xn(e,!0)),t.passedElement.triggerEvent(Ht.highlightItem,t._getChoiceForOutput(e)))})}),this},n.prototype.unhighlightAll=function(){var t=this;return this._store.withTxn(function(){t._store.items.forEach(function(e){e.highlighted&&(t._store.dispatch(xn(e,!1)),t.passedElement.triggerEvent(Ht.highlightItem,t._getChoiceForOutput(e)))})}),this},n.prototype.removeActiveItemsByValue=function(t){var e=this;return this._store.withTxn(function(){e._store.items.filter(function(i){return i.value===t}).forEach(function(i){return e._removeItem(i)})}),this},n.prototype.removeActiveItems=function(t){var e=this;return this._store.withTxn(function(){e._store.items.filter(function(i){var s=i.id;return s!==t}).forEach(function(i){return e._removeItem(i)})}),this},n.prototype.removeHighlightedItems=function(t){var e=this;return t===void 0&&(t=!1),this._store.withTxn(function(){e._store.highlightedActiveItems.forEach(function(i){e._removeItem(i),t&&e._triggerChange(i.value)})}),this},n.prototype.showDropdown=function(t){var e=this;return this.dropdown.isActive?this:(t===void 0&&(t=!this._canSearch),requestAnimationFrame(function(){e.dropdown.show();var i=e.dropdown.element.getBoundingClientRect();e.containerOuter.open(i.bottom,i.height),t||e.input.focus(),e.passedElement.triggerEvent(Ht.showDropdown)}),this)},n.prototype.hideDropdown=function(t){var e=this;return this.dropdown.isActive?(requestAnimationFrame(function(){e.dropdown.hide(),e.containerOuter.close(),!t&&e._canSearch&&(e.input.removeActiveDescendant(),e.input.blur()),e.passedElement.triggerEvent(Ht.hideDropdown)}),this):this},n.prototype.getValue=function(t){var e=this,i=this._store.items.map(function(s){return t?s.value:e._getChoiceForOutput(s)});return this._isSelectOneElement||this.config.singleModeForMultiSelect?i[0]:i},n.prototype.setValue=function(t){var e=this;return this.initialisedOK?(this._store.withTxn(function(){t.forEach(function(i){i&&e._addChoice(Ee(i,!1))})}),this._searcher.reset(),this):(this._warnChoicesInitFailed("setValue"),this)},n.prototype.setChoiceByValue=function(t){var e=this;return this.initialisedOK?this._isTextElement?this:(this._store.withTxn(function(){var i=Array.isArray(t)?t:[t];i.forEach(function(s){return e._findAndSelectChoiceByValue(s)}),e.unhighlightAll()}),this._searcher.reset(),this):(this._warnChoicesInitFailed("setChoiceByValue"),this)},n.prototype.setChoices=function(t,e,i,s,r){var o=this;if(t===void 0&&(t=[]),e===void 0&&(e="value"),i===void 0&&(i="label"),s===void 0&&(s=!1),r===void 0&&(r=!0),!this.initialisedOK)return this._warnChoicesInitFailed("setChoices"),this;if(!this._isSelectElement)throw new TypeError("setChoices can't be used with INPUT based Choices");if(typeof e!="string"||!e)throw new TypeError("value parameter must be a name of 'value' field in passed objects");if(s&&this.clearChoices(),typeof t=="function"){var a=t(this);if(typeof Promise=="function"&&a instanceof Promise)return new Promise(function(l){return requestAnimationFrame(l)}).then(function(){return o._handleLoadingState(!0)}).then(function(){return a}).then(function(l){return o.setChoices(l,e,i,s)}).catch(function(l){o.config.silent||console.error(l)}).then(function(){return o._handleLoadingState(!1)}).then(function(){return o});if(!Array.isArray(a))throw new TypeError(".setChoices first argument function must return either array of choices or Promise, got: ".concat(typeof a));return this.setChoices(a,e,i,!1)}if(!Array.isArray(t))throw new TypeError(".setChoices must be called either with array of choices with a function resulting into Promise of array of choices");return this.containerOuter.removeLoadingState(),this._store.withTxn(function(){r&&(o._isSearching=!1);var l=e==="value",c=i==="label";t.forEach(function(h){if("choices"in h){var u=h;c||(u=zt(zt({},u),{label:u[i]})),o._addGroup(Ee(u,!0))}else{var d=h;(!c||!l)&&(d=zt(zt({},d),{value:d[e],label:d[i]})),o._addChoice(Ee(d,!1))}}),o.unhighlightAll()}),this._searcher.reset(),this},n.prototype.refresh=function(t,e,i){var s=this;return t===void 0&&(t=!1),e===void 0&&(e=!1),i===void 0&&(i=!1),this._isSelectElement?(this._store.withTxn(function(){var r=s.passedElement.optionsAsChoices(),o={};i||s._store.items.forEach(function(l){l.id&&l.active&&l.selected&&!l.disabled&&(o[l.value]=!0)}),s.clearStore(!1);var a=function(l){i?s._store.dispatch(zc(l)):o[l.value]&&(l.selected=!0)};r.forEach(function(l){if("choices"in l){l.choices.forEach(a);return}a(l)}),s._addPredefinedChoices(r,e,t),s._isSearching&&s._searchChoices(s.input.value)}),this):(this.config.silent||console.warn("refresh method can only be used on choices backed by a <select> element"),this)},n.prototype.removeChoice=function(t){var e=this._store.choices.find(function(i){return i.value===t});return e?(this._clearNotice(),this._store.dispatch(Vc(e)),this._searcher.reset(),e.selected&&this.passedElement.triggerEvent(Ht.removeItem,this._getChoiceForOutput(e)),this):this},n.prototype.clearChoices=function(){var t=this;return this._store.withTxn(function(){t._store.choices.forEach(function(e){e.selected||t._store.dispatch(Vc(e))})}),this._searcher.reset(),this},n.prototype.clearStore=function(t){return t===void 0&&(t=!0),this._stopSearch(),t&&this.passedElement.element.replaceChildren(""),this.itemList.element.replaceChildren(""),this.choiceList.element.replaceChildren(""),this._clearNotice(),this._store.reset(),this._lastAddedChoiceId=0,this._lastAddedGroupId=0,this._searcher.reset(),this},n.prototype.clearInput=function(){var t=!this._isSelectOneElement;return this.input.clear(t),this._stopSearch(),this},n.prototype._validateConfig=function(){var t=this.config,e=Zg(t,qc);e.length&&console.warn("Unknown config option(s) passed",e.join(", ")),t.allowHTML&&t.allowHtmlUserInput&&(t.addItems&&console.warn("Warning: allowHTML/allowHtmlUserInput/addItems all being true is strongly not recommended and may lead to XSS attacks"),t.addChoices&&console.warn("Warning: allowHTML/allowHtmlUserInput/addChoices all being true is strongly not recommended and may lead to XSS attacks"))},n.prototype._render=function(t){t===void 0&&(t={choices:!0,groups:!0,items:!0}),!this._store.inTxn()&&(this._isSelectElement&&(t.choices||t.groups)&&this._renderChoices(),t.items&&this._renderItems())},n.prototype._renderChoices=function(){var t=this;if(this._canAddItems()){var e=this,i=e.config,s=e._isSearching,r=this._store,o=r.activeGroups,a=r.activeChoices,l=0;if(s&&i.searchResultLimit>0?l=i.searchResultLimit:i.renderChoiceLimit>0&&(l=i.renderChoiceLimit),this._isSelectElement){var c=a.filter(function(g){return!g.element});c.length&&this.passedElement.addOptions(c)}var h=document.createDocumentFragment(),u=function(g){return g.filter(function(p){return!p.placeholder&&(s?!!p.rank:i.renderSelectedChoices||!p.selected)})},d=!1,f=function(g,p,m){s?g.sort(qg):i.shouldSort&&g.sort(i.sorter);var v=g.length;v=!p&&l&&v>l?l:v,v--,g.every(function(y,x){var E=y.choiceEl||t._templates.choice(i,y,i.itemSelectText,m);return y.choiceEl=E,h.appendChild(E),!y.disabled&&(s||!y.selected)&&(d=!0),x<v})};a.length&&(i.resetScrollPosition&&requestAnimationFrame(function(){return t.choiceList.scrollToTop()}),!this._hasNonChoicePlaceholder&&!s&&this._isSelectOneElement&&f(a.filter(function(g){return g.placeholder&&!g.group}),!1,void 0),o.length&&!s?(i.shouldSort&&o.sort(i.sorter),f(a.filter(function(g){return!g.placeholder&&!g.group}),!1,void 0),o.forEach(function(g){var p=u(g.choices);if(p.length){if(g.label){var m=g.groupEl||t._templates.choiceGroup(t.config,g);g.groupEl=m,m.remove(),h.appendChild(m)}f(p,!0,i.appendGroupInSearch&&s?g.label:void 0)}})):f(u(a),!1,void 0)),d||(this._notice||(this._notice={text:Wc(s?i.noResultsText:i.noChoicesText),type:s?Dt.noResults:Dt.noChoices}),h.replaceChildren("")),this._renderNotice(h),this.choiceList.element.replaceChildren(h),d&&this._highlightChoice()}},n.prototype._renderItems=function(){var t=this,e=this._store.items||[],i=this.itemList.element,s=this.config,r=document.createDocumentFragment(),o=function(u){return i.querySelector('[data-item][data-id="'.concat(u.id,'"]'))},a=function(u){var d=u.itemEl;d&&d.parentElement||(d=o(u)||t._templates.item(s,u,s.removeItemButton),u.itemEl=d,r.appendChild(d))};e.forEach(a);var l=!!r.childNodes.length;if(this._isSelectOneElement&&this._hasNonChoicePlaceholder){var c=i.children.length;if(l||c>1){var h=i.querySelector(Ws(s.classNames.placeholder));h&&h.remove()}else c||(l=!0,a(Ee({selected:!0,value:"",label:s.placeholderValue||"",placeholder:!0},!1)))}l&&(i.append(r),s.shouldSortItems&&!this._isSelectOneElement&&(e.sort(s.sorter),e.forEach(function(u){var d=o(u);d&&(d.remove(),r.append(d))}),i.append(r))),this._isTextElement&&(this.passedElement.value=e.map(function(u){var d=u.value;return d}).join(s.delimiter))},n.prototype._displayNotice=function(t,e,i){i===void 0&&(i=!0);var s=this._notice;if(s&&(s.type===e&&s.text===t||s.type===Dt.addChoice&&(e===Dt.noResults||e===Dt.noChoices))){i&&this.showDropdown(!0);return}this._clearNotice(),this._notice=t?{text:t,type:e}:void 0,this._renderNotice(),i&&t&&this.showDropdown(!0)},n.prototype._clearNotice=function(){if(this._notice){var t=this.choiceList.element.querySelector(Ws(this.config.classNames.notice));t&&t.remove(),this._notice=void 0}},n.prototype._renderNotice=function(t){var e=this._notice;if(e){var i=this._templates.notice(this.config,e.text,e.type);t?t.append(i):this.choiceList.prepend(i)}},n.prototype._getChoiceForOutput=function(t,e){return{id:t.id,highlighted:t.highlighted,labelClass:t.labelClass,labelDescription:t.labelDescription,customProperties:t.customProperties,disabled:t.disabled,active:t.active,label:t.label,placeholder:t.placeholder,value:t.value,groupValue:t.group?t.group.label:void 0,element:t.element,keyCode:e}},n.prototype._triggerChange=function(t){t!=null&&this.passedElement.triggerEvent(Ht.change,{value:t})},n.prototype._handleButtonAction=function(t){var e=this,i=this._store.items;if(!(!i.length||!this.config.removeItems||!this.config.removeItemButton)){var s=t&&la(t.parentElement),r=s&&i.find(function(o){return o.id===s});r&&this._store.withTxn(function(){if(e._removeItem(r),e._triggerChange(r.value),e._isSelectOneElement&&!e._hasNonChoicePlaceholder){var o=e._store.choices.reverse().find(function(a){return!a.disabled&&a.placeholder});o&&(e._addItem(o),e.unhighlightAll(),o.value&&e._triggerChange(o.value))}})}},n.prototype._handleItemAction=function(t,e){var i=this;e===void 0&&(e=!1);var s=this._store.items;if(!(!s.length||!this.config.removeItems||this._isSelectOneElement)){var r=la(t);r&&(s.forEach(function(o){o.id===r&&!o.highlighted?i.highlightItem(o):!e&&o.highlighted&&i.unhighlightItem(o)}),this.input.focus())}},n.prototype._handleChoiceAction=function(t){var e=this,i=la(t),s=i&&this._store.getChoiceById(i);if(!s||s.disabled)return!1;var r=this.dropdown.isActive;if(!s.selected){if(!this._canAddItems())return!0;this._store.withTxn(function(){e._addItem(s,!0,!0),e.clearInput(),e.unhighlightAll()}),this._triggerChange(s.value)}return r&&this.config.closeDropdownOnSelect&&(this.hideDropdown(!0),this.containerOuter.element.focus()),!0},n.prototype._handleBackspace=function(t){var e=this.config;if(!(!e.removeItems||!t.length)){var i=t[t.length-1],s=t.some(function(r){return r.highlighted});e.editItems&&!s&&i?(this.input.value=i.value,this.input.setWidth(),this._removeItem(i),this._triggerChange(i.value)):(s||this.highlightItem(i,!1),this.removeHighlightedItems(!0))}},n.prototype._loadChoices=function(){var t,e=this,i=this.config;if(this._isTextElement){if(this._presetChoices=i.items.map(function(o){return Ee(o,!1)}),this.passedElement.value){var s=this.passedElement.value.split(i.delimiter).map(function(o){return Ee(o,!1,e.config.allowHtmlUserInput)});this._presetChoices=this._presetChoices.concat(s)}this._presetChoices.forEach(function(o){o.selected=!0})}else if(this._isSelectElement){this._presetChoices=i.choices.map(function(o){return Ee(o,!0)});var r=this.passedElement.optionsAsChoices();r&&(t=this._presetChoices).push.apply(t,r)}},n.prototype._handleLoadingState=function(t){t===void 0&&(t=!0);var e=this.itemList.element;t?(this.disable(),this.containerOuter.addLoadingState(),this._isSelectOneElement?e.replaceChildren(this._templates.placeholder(this.config,this.config.loadingText)):this.input.placeholder=this.config.loadingText):(this.enable(),this.containerOuter.removeLoadingState(),this._isSelectOneElement?(e.replaceChildren(""),this._render()):this.input.placeholder=this._placeholderValue||"")},n.prototype._handleSearch=function(t){if(this.input.isFocussed)if(t!==null&&typeof t<"u"&&t.length>=this.config.searchFloor){var e=this.config.searchChoices?this._searchChoices(t):0;e!==null&&this.passedElement.triggerEvent(Ht.search,{value:t,resultCount:e})}else this._store.choices.some(function(i){return!i.active})&&this._stopSearch()},n.prototype._canAddItems=function(){var t=this.config,e=t.maxItemCount,i=t.maxItemText;return!t.singleModeForMultiSelect&&e>0&&e<=this._store.items.length?(this.choiceList.element.replaceChildren(""),this._notice=void 0,this._displayNotice(typeof i=="function"?i(e):i,Dt.addChoice),!1):!0},n.prototype._canCreateItem=function(t){var e=this.config,i=!0,s="";if(i&&typeof e.addItemFilter=="function"&&!e.addItemFilter(t)&&(i=!1,s=Hs(e.customAddItemText,t)),i){var r=this._store.choices.find(function(o){return e.valueComparer(o.value,t)});if(this._isSelectElement){if(r)return this._displayNotice("",Dt.addChoice),!1}else this._isTextElement&&!e.duplicateItemsAllowed&&r&&(i=!1,s=Hs(e.uniqueItemText,t))}return i&&(s=Hs(e.addItemText,t)),s&&this._displayNotice(s,Dt.addChoice),i},n.prototype._searchChoices=function(t){var e=t.trim().replace(/\s{2,}/," ");if(!e.length||e===this._currentValue)return null;var i=this._searcher;i.isEmptyIndex()&&i.index(this._store.searchableChoices);var s=i.search(e);this._currentValue=e,this._highlightPosition=0,this._isSearching=!0;var r=this._notice,o=r&&r.type;return o!==Dt.addChoice&&(s.length?this._clearNotice():this._displayNotice(Wc(this.config.noResultsText),Dt.noResults)),this._store.dispatch(Bg(s)),s.length},n.prototype._stopSearch=function(){this._isSearching&&(this._currentValue="",this._isSearching=!1,this._clearNotice(),this._store.dispatch($g(!0)),this.passedElement.triggerEvent(Ht.search,{value:"",resultCount:0}))},n.prototype._addEventListeners=function(){var t=this._docRoot,e=this.containerOuter.element,i=this.input.element;t.addEventListener("touchend",this._onTouchEnd,!0),e.addEventListener("keydown",this._onKeyDown,!0),e.addEventListener("mousedown",this._onMouseDown,!0),t.addEventListener("click",this._onClick,{passive:!0}),t.addEventListener("touchmove",this._onTouchMove,{passive:!0}),this.dropdown.element.addEventListener("mouseover",this._onMouseOver,{passive:!0}),this._isSelectOneElement&&(e.addEventListener("focus",this._onFocus,{passive:!0}),e.addEventListener("blur",this._onBlur,{passive:!0})),i.addEventListener("keyup",this._onKeyUp,{passive:!0}),i.addEventListener("input",this._onInput,{passive:!0}),i.addEventListener("focus",this._onFocus,{passive:!0}),i.addEventListener("blur",this._onBlur,{passive:!0}),i.form&&i.form.addEventListener("reset",this._onFormReset,{passive:!0}),this.input.addEventListeners()},n.prototype._removeEventListeners=function(){var t=this._docRoot,e=this.containerOuter.element,i=this.input.element;t.removeEventListener("touchend",this._onTouchEnd,!0),e.removeEventListener("keydown",this._onKeyDown,!0),e.removeEventListener("mousedown",this._onMouseDown,!0),t.removeEventListener("click",this._onClick),t.removeEventListener("touchmove",this._onTouchMove),this.dropdown.element.removeEventListener("mouseover",this._onMouseOver),this._isSelectOneElement&&(e.removeEventListener("focus",this._onFocus),e.removeEventListener("blur",this._onBlur)),i.removeEventListener("keyup",this._onKeyUp),i.removeEventListener("input",this._onInput),i.removeEventListener("focus",this._onFocus),i.removeEventListener("blur",this._onBlur),i.form&&i.form.removeEventListener("reset",this._onFormReset),this.input.removeEventListeners()},n.prototype._onKeyDown=function(t){var e=t.keyCode,i=this.dropdown.isActive,s=t.key.length===1||t.key.length===2&&t.key.charCodeAt(0)>=55296||t.key==="Unidentified";switch(!this._isTextElement&&!i&&e!==At.ESC_KEY&&e!==At.TAB_KEY&&e!==At.SHIFT_KEY&&(this.showDropdown(),!this.input.isFocussed&&s&&(this.input.value+=t.key,t.key===" "&&t.preventDefault())),e){case At.A_KEY:return this._onSelectKey(t,this.itemList.element.hasChildNodes());case At.ENTER_KEY:return this._onEnterKey(t,i);case At.ESC_KEY:return this._onEscapeKey(t,i);case At.UP_KEY:case At.PAGE_UP_KEY:case At.DOWN_KEY:case At.PAGE_DOWN_KEY:return this._onDirectionKey(t,i);case At.DELETE_KEY:case At.BACK_KEY:return this._onDeleteKey(t,this._store.items,this.input.isFocussed)}},n.prototype._onKeyUp=function(){this._canSearch=this.config.searchEnabled},n.prototype._onInput=function(){var t=this.input.value;if(!t){this._isTextElement?this.hideDropdown(!0):this._stopSearch();return}this._canAddItems()&&(this._canSearch&&this._handleSearch(t),this._canAddUserChoices&&(this._canCreateItem(t),this._isSelectElement&&(this._highlightPosition=0,this._highlightChoice())))},n.prototype._onSelectKey=function(t,e){if((t.ctrlKey||t.metaKey)&&e){this._canSearch=!1;var i=this.config.removeItems&&!this.input.value&&this.input.element===document.activeElement;i&&this.highlightAll()}},n.prototype._onEnterKey=function(t,e){var i=this,s=this.input.value,r=t.target;if(t.preventDefault(),r&&r.hasAttribute("data-button")){this._handleButtonAction(r);return}if(!e){(this._isSelectElement||this._notice)&&this.showDropdown();return}var o=this.dropdown.element.querySelector(Ws(this.config.classNames.highlightedState));if(!(o&&this._handleChoiceAction(o))){if(!r||!s){this.hideDropdown(!0);return}if(this._canAddItems()){var a=!1;this._store.withTxn(function(){if(a=i._findAndSelectChoiceByValue(s,!0),!a){if(!i._canAddUserChoices||!i._canCreateItem(s))return;i._addChoice(Ee(s,!1,i.config.allowHtmlUserInput),!0,!0),a=!0}i.clearInput(),i.unhighlightAll()}),a&&(this._triggerChange(s),this.config.closeDropdownOnSelect&&this.hideDropdown(!0))}}},n.prototype._onEscapeKey=function(t,e){e&&(t.stopPropagation(),this.hideDropdown(!0),this._stopSearch(),this.containerOuter.element.focus())},n.prototype._onDirectionKey=function(t,e){var i=t.keyCode;if(e||this._isSelectOneElement){this.showDropdown(),this._canSearch=!1;var s=i===At.DOWN_KEY||i===At.PAGE_DOWN_KEY?1:-1,r=t.metaKey||i===At.PAGE_DOWN_KEY||i===At.PAGE_UP_KEY,o=void 0;if(r)s>0?o=this.dropdown.element.querySelector("".concat(Us,":last-of-type")):o=this.dropdown.element.querySelector(Us);else{var a=this.dropdown.element.querySelector(Ws(this.config.classNames.highlightedState));a?o=Yg(a,Us,s):o=this.dropdown.element.querySelector(Us)}o&&(Ug(o,this.choiceList.element,s)||this.choiceList.scrollToChildElement(o,s),this._highlightChoice(o)),t.preventDefault()}},n.prototype._onDeleteKey=function(t,e,i){!this._isSelectOneElement&&!t.target.value&&i&&(this._handleBackspace(e),t.preventDefault())},n.prototype._onTouchMove=function(){this._wasTap&&(this._wasTap=!1)},n.prototype._onTouchEnd=function(t){var e=(t||t.touches[0]).target,i=this._wasTap&&this.containerOuter.element.contains(e);if(i){var s=e===this.containerOuter.element||e===this.containerInner.element;s&&(this._isTextElement?this.input.focus():this._isSelectMultipleElement&&this.showDropdown()),t.stopPropagation()}this._wasTap=!0},n.prototype._onMouseDown=function(t){var e=t.target;if(e instanceof HTMLElement){if(om&&this.choiceList.element.contains(e)){var i=this.choiceList.element.firstElementChild;this._isScrollingOnIe=this._direction==="ltr"?t.offsetX>=i.offsetWidth:t.offsetX<i.offsetLeft}if(e!==this.input.element){var s=e.closest("[data-button],[data-item],[data-choice]");s instanceof HTMLElement&&("button"in s.dataset?this._handleButtonAction(s):"item"in s.dataset?this._handleItemAction(s,t.shiftKey):"choice"in s.dataset&&this._handleChoiceAction(s)),t.preventDefault()}}},n.prototype._onMouseOver=function(t){var e=t.target;e instanceof HTMLElement&&"choice"in e.dataset&&this._highlightChoice(e)},n.prototype._onClick=function(t){var e=t.target,i=this.containerOuter,s=i.element.contains(e);s?!this.dropdown.isActive&&!i.isDisabled?this._isTextElement?document.activeElement!==this.input.element&&this.input.focus():(this.showDropdown(),i.element.focus()):this._isSelectOneElement&&e!==this.input.element&&!this.dropdown.element.contains(e)&&this.hideDropdown():(i.removeFocusState(),this.hideDropdown(!0),this.unhighlightAll())},n.prototype._onFocus=function(t){var e=t.target,i=this.containerOuter,s=e&&i.element.contains(e);if(s){var r=e===this.input.element;this._isTextElement?r&&i.addFocusState():this._isSelectMultipleElement?r&&(this.showDropdown(!0),i.addFocusState()):(i.addFocusState(),r&&this.showDropdown(!0))}},n.prototype._onBlur=function(t){var e=t.target,i=this.containerOuter,s=e&&i.element.contains(e);s&&!this._isScrollingOnIe?e===this.input.element?(i.removeFocusState(),this.hideDropdown(!0),(this._isTextElement||this._isSelectMultipleElement)&&this.unhighlightAll()):e===this.containerOuter.element&&i.removeFocusState():(this._isScrollingOnIe=!1,this.input.element.focus())},n.prototype._onFormReset=function(){var t=this;this._store.withTxn(function(){t.clearInput(),t.hideDropdown(),t.refresh(!1,!1,!0),t._initialItems.length&&t.setChoiceByValue(t._initialItems)})},n.prototype._highlightChoice=function(t){t===void 0&&(t=null);var e=Array.from(this.dropdown.element.querySelectorAll(Us));if(e.length){var i=t,s=this.config.classNames.highlightedState,r=Array.from(this.dropdown.element.querySelectorAll(Ws(s)));r.forEach(function(o){Te(o,s),o.setAttribute("aria-selected","false")}),i?this._highlightPosition=e.indexOf(i):(e.length>this._highlightPosition?i=e[this._highlightPosition]:i=e[e.length-1],i||(i=e[0])),Y(i,s),i.setAttribute("aria-selected","true"),this.passedElement.triggerEvent(Ht.highlightChoice,{el:i}),this.dropdown.isActive&&(this.input.setActiveDescendant(i.id),this.containerOuter.setActiveDescendant(i.id))}},n.prototype._addItem=function(t,e,i){if(e===void 0&&(e=!0),i===void 0&&(i=!1),!t.id)throw new TypeError("item.id must be set before _addItem is called for a choice/item");(this.config.singleModeForMultiSelect||this._isSelectOneElement)&&this.removeActiveItems(t.id),this._store.dispatch(zg(t)),e&&(this.passedElement.triggerEvent(Ht.addItem,this._getChoiceForOutput(t)),i&&this.passedElement.triggerEvent(Ht.choice,this._getChoiceForOutput(t)))},n.prototype._removeItem=function(t){if(t.id){this._store.dispatch(zc(t));var e=this._notice;e&&e.type===Dt.noChoices&&this._clearNotice(),this.passedElement.triggerEvent(Ht.removeItem,this._getChoiceForOutput(t))}},n.prototype._addChoice=function(t,e,i){if(e===void 0&&(e=!0),i===void 0&&(i=!1),t.id)throw new TypeError("Can not re-add a choice which has already been added");var s=this.config;if(!((this._isSelectElement||!s.duplicateItemsAllowed)&&this._store.choices.find(function(a){return s.valueComparer(a.value,t.value)}))){this._lastAddedChoiceId++,t.id=this._lastAddedChoiceId,t.elementId="".concat(this._baseId,"-").concat(this._idNames.itemChoice,"-").concat(t.id);var r=s.prependValue,o=s.appendValue;r&&(t.value=r+t.value),o&&(t.value+=o.toString()),(r||o)&&t.element&&(t.element.value=t.value),this._clearNotice(),this._store.dispatch(Ng(t)),t.selected&&this._addItem(t,e,i)}},n.prototype._addGroup=function(t,e){var i=this;if(e===void 0&&(e=!0),t.id)throw new TypeError("Can not re-add a group which has already been added");this._store.dispatch(Vg(t)),t.choices&&(this._lastAddedGroupId++,t.id=this._lastAddedGroupId,t.choices.forEach(function(s){s.group=t,t.disabled&&(s.disabled=!0),i._addChoice(s,e)}))},n.prototype._createTemplates=function(){var t=this,e=this.config.callbackOnCreateTemplates,i={};typeof e=="function"&&(i=e.call(this,Gg,Zo,Sn));var s={};Object.keys(this._templates).forEach(function(r){r in i?s[r]=i[r].bind(t):s[r]=t._templates[r].bind(t)}),this._templates=s},n.prototype._createElements=function(){var t=this._templates,e=this,i=e.config,s=e._isSelectOneElement,r=i.position,o=i.classNames,a=this._elementType;this.containerOuter=new Yc({element:t.containerOuter(i,this._direction,this._isSelectElement,s,i.searchEnabled,a,i.labelId),classNames:o,type:a,position:r}),this.containerInner=new Yc({element:t.containerInner(i),classNames:o,type:a,position:r}),this.input=new ip({element:t.input(i,this._placeholderValue),classNames:o,type:a,preventPaste:!i.paste}),this.choiceList=new Uc({element:t.choiceList(i,s)}),this.itemList=new Uc({element:t.itemList(i,s)}),this.dropdown=new ep({element:t.dropdown(i),classNames:o,type:a})},n.prototype._createStructure=function(){var t=this,e=t.containerInner,i=t.containerOuter,s=t.passedElement,r=this.dropdown.element;s.conceal(),e.wrap(s.element),i.wrap(e.element),this._isSelectOneElement?this.input.placeholder=this.config.searchPlaceholderValue||"":(this._placeholderValue&&(this.input.placeholder=this._placeholderValue),this.input.setWidth()),i.element.appendChild(e.element),i.element.appendChild(r),e.element.appendChild(this.itemList.element),r.appendChild(this.choiceList.element),this._isSelectOneElement?this.config.searchEnabled&&r.insertBefore(this.input.element,r.firstChild):e.element.appendChild(this.input.element),this._highlightPosition=0,this._isSearching=!1},n.prototype._initStore=function(){var t=this;this._store.subscribe(this._render).withTxn(function(){t._addPredefinedChoices(t._presetChoices,t._isSelectOneElement&&!t._hasNonChoicePlaceholder,!1)}),(!this._store.choices.length||this._isSelectOneElement&&this._hasNonChoicePlaceholder)&&this._render()},n.prototype._addPredefinedChoices=function(t,e,i){var s=this;if(e===void 0&&(e=!1),i===void 0&&(i=!0),e){var r=t.findIndex(function(o){return o.selected})===-1;r&&t.some(function(o){return o.disabled||"choices"in o?!1:(o.selected=!0,!0)})}t.forEach(function(o){"choices"in o?s._isSelectElement&&s._addGroup(o,i):s._addChoice(o,i)})},n.prototype._findAndSelectChoiceByValue=function(t,e){var i=this;e===void 0&&(e=!1);var s=this._store.choices.find(function(r){return i.config.valueComparer(r.value,t)});return s&&!s.disabled&&!s.selected?(this._addItem(s,!0,e),!0):!1},n.prototype._generatePlaceholderValue=function(){var t=this.config;if(!t.placeholder)return null;if(this._hasNonChoicePlaceholder)return t.placeholderValue;if(this._isSelectElement){var e=this.passedElement.placeholderOption;return e?e.text:null}return null},n.prototype._warnChoicesInitFailed=function(t){if(!this.config.silent)if(this.initialised){if(!this.initialisedOK)throw new TypeError("".concat(t," called for an element which has multiple instances of Choices initialised on it"))}else throw new TypeError("".concat(t," called on a non-initialised instance of Choices"))},n.version="11.0.3",n}();const cm='.choices{position:relative;overflow:hidden;margin-bottom:24px;font-size:16px}.choices:focus{outline:none}.choices:last-child{margin-bottom:0}.choices.is-open{overflow:visible}.choices.is-disabled .choices__inner,.choices.is-disabled .choices__input{background-color:#eaeaea;cursor:not-allowed;-webkit-user-select:none;user-select:none}.choices.is-disabled .choices__item{cursor:not-allowed}.choices [hidden]{display:none!important}.choices[data-type*=select-one]{cursor:pointer}.choices[data-type*=select-one] .choices__inner{padding-bottom:7.5px}.choices[data-type*=select-one] .choices__input{display:block;width:100%;padding:10px;border-bottom:1px solid #ddd;background-color:#fff;margin:0}.choices[data-type*=select-one] .choices__button{background-image:url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMjEiIGhlaWdodD0iMjEiIHZpZXdCb3g9IjAgMCAyMSAyMSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj48ZyBmaWxsPSIjMDAwIiBmaWxsLXJ1bGU9ImV2ZW5vZGQiPjxwYXRoIGQ9Ik0yLjU5Mi4wNDRsMTguMzY0IDE4LjM2NC0yLjU0OCAyLjU0OEwuMDQ0IDIuNTkyeiIvPjxwYXRoIGQ9Ik0wIDE4LjM2NEwxOC4zNjQgMGwyLjU0OCAyLjU0OEwyLjU0OCAyMC45MTJ6Ii8+PC9nPjwvc3ZnPg==);padding:0;background-size:8px;position:absolute;top:50%;right:0;margin-top:-10px;margin-right:25px;height:20px;width:20px;border-radius:10em;opacity:.25}.choices[data-type*=select-one] .choices__button:hover,.choices[data-type*=select-one] .choices__button:focus{opacity:1}.choices[data-type*=select-one] .choices__button:focus{box-shadow:0 0 0 2px #005f75}.choices[data-type*=select-one] .choices__item[data-placeholder] .choices__button{display:none}.choices[data-type*=select-one]:after{content:"";height:0;width:0;border-style:solid;border-color:#333 transparent transparent transparent;border-width:5px;position:absolute;right:11.5px;top:50%;margin-top:-2.5px;pointer-events:none}.choices[data-type*=select-one].is-open:after{border-color:transparent transparent #333;margin-top:-7.5px}.choices[data-type*=select-one][dir=rtl]:after{left:11.5px;right:auto}.choices[data-type*=select-one][dir=rtl] .choices__button{right:auto;left:0;margin-left:25px;margin-right:0}.choices[data-type*=select-multiple] .choices__inner,.choices[data-type*=text] .choices__inner{cursor:text}.choices[data-type*=select-multiple] .choices__button,.choices[data-type*=text] .choices__button{position:relative;display:inline-block;margin:0 -4px 0 8px;padding-left:16px;border-left:1px solid #003642;background-image:url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMjEiIGhlaWdodD0iMjEiIHZpZXdCb3g9IjAgMCAyMSAyMSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj48ZyBmaWxsPSIjRkZGIiBmaWxsLXJ1bGU9ImV2ZW5vZGQiPjxwYXRoIGQ9Ik0yLjU5Mi4wNDRsMTguMzY0IDE4LjM2NC0yLjU0OCAyLjU0OEwuMDQ0IDIuNTkyeiIvPjxwYXRoIGQ9Ik0wIDE4LjM2NEwxOC4zNjQgMGwyLjU0OCAyLjU0OEwyLjU0OCAyMC45MTJ6Ii8+PC9nPjwvc3ZnPg==);background-size:8px;width:8px;line-height:1;opacity:.75;border-radius:0}.choices[data-type*=select-multiple] .choices__button:hover,.choices[data-type*=select-multiple] .choices__button:focus,.choices[data-type*=text] .choices__button:hover,.choices[data-type*=text] .choices__button:focus{opacity:1}.choices__inner{display:inline-block;vertical-align:top;width:100%;background-color:#f9f9f9;padding:7.5px 7.5px 3.75px;border:1px solid #ddd;border-radius:2.5px;font-size:14px;min-height:44px;overflow:hidden}.is-focused .choices__inner,.is-open .choices__inner{border-color:#b7b7b7}.is-open .choices__inner{border-radius:2.5px 2.5px 0 0}.is-flipped.is-open .choices__inner{border-radius:0 0 2.5px 2.5px}.choices__list{margin:0;padding-left:0;list-style:none}.choices__list--single{display:inline-block;padding:4px 16px 4px 4px;width:100%}[dir=rtl] .choices__list--single{padding-right:4px;padding-left:16px}.choices__list--single .choices__item{width:100%}.choices__list--multiple{display:inline}.choices__list--multiple .choices__item{display:inline-block;vertical-align:middle;border-radius:20px;padding:4px 10px;font-size:12px;font-weight:500;margin-right:3.75px;margin-bottom:3.75px;background-color:#005f75;border:1px solid #004a5c;color:#fff;word-break:break-all;box-sizing:border-box}.choices__list--multiple .choices__item[data-deletable]{padding-right:5px}[dir=rtl] .choices__list--multiple .choices__item{margin-right:0;margin-left:3.75px}.choices__list--multiple .choices__item.is-highlighted{background-color:#004a5c;border:1px solid #003642}.is-disabled .choices__list--multiple .choices__item{background-color:#aaa;border:1px solid #919191}.choices__list--dropdown,.choices__list[aria-expanded]{display:none;z-index:1;position:absolute;width:100%;background-color:#fff;border:1px solid #ddd;top:100%;margin-top:-1px;border-bottom-left-radius:2.5px;border-bottom-right-radius:2.5px;overflow:hidden;word-break:break-all}.is-active.choices__list--dropdown,.is-active.choices__list[aria-expanded]{display:block}.is-open .choices__list--dropdown,.is-open .choices__list[aria-expanded]{border-color:#b7b7b7}.is-flipped .choices__list--dropdown,.is-flipped .choices__list[aria-expanded]{top:auto;bottom:100%;margin-top:0;margin-bottom:-1px;border-radius:.25rem .25rem 0 0}.choices__list--dropdown .choices__list,.choices__list[aria-expanded] .choices__list{position:relative;max-height:300px;overflow:auto;-webkit-overflow-scrolling:touch;will-change:scroll-position}.choices__list--dropdown .choices__item,.choices__list[aria-expanded] .choices__item{position:relative;padding:10px;font-size:14px}[dir=rtl] .choices__list--dropdown .choices__item,[dir=rtl] .choices__list[aria-expanded] .choices__item{text-align:right}@media (min-width: 640px){.choices__list--dropdown .choices__item--selectable[data-select-text],.choices__list[aria-expanded] .choices__item--selectable[data-select-text]{padding-right:100px}.choices__list--dropdown .choices__item--selectable[data-select-text]:after,.choices__list[aria-expanded] .choices__item--selectable[data-select-text]:after{content:attr(data-select-text);font-size:12px;opacity:0;position:absolute;right:10px;top:50%;transform:translateY(-50%)}[dir=rtl] .choices__list--dropdown .choices__item--selectable[data-select-text],[dir=rtl] .choices__list[aria-expanded] .choices__item--selectable[data-select-text]{text-align:right;padding-left:100px;padding-right:10px}[dir=rtl] .choices__list--dropdown .choices__item--selectable[data-select-text]:after,[dir=rtl] .choices__list[aria-expanded] .choices__item--selectable[data-select-text]:after{right:auto;left:10px}}.choices__list--dropdown .choices__item--selectable.is-highlighted,.choices__list[aria-expanded] .choices__item--selectable.is-highlighted{background-color:#f2f2f2}.choices__list--dropdown .choices__item--selectable.is-highlighted:after,.choices__list[aria-expanded] .choices__item--selectable.is-highlighted:after{opacity:.5}.choices__item{cursor:default}.choices__item--selectable{cursor:pointer}.choices__item--disabled{cursor:not-allowed;-webkit-user-select:none;user-select:none;opacity:.5}.choices__heading{font-weight:600;font-size:12px;padding:10px;border-bottom:1px solid #f7f7f7;color:gray}.choices__button{text-indent:-9999px;-webkit-appearance:none;-moz-appearance:none;appearance:none;border:0;background-color:transparent;background-repeat:no-repeat;background-position:center;cursor:pointer}.choices__button:focus{outline:none}.choices__input{display:inline-block;vertical-align:baseline;background-color:#f9f9f9;font-size:14px;margin-bottom:5px;border:0;border-radius:0;max-width:100%;padding:4px 0 4px 2px}.choices__input:focus{outline:0}.choices__input::-webkit-search-decoration,.choices__input::-webkit-search-cancel-button,.choices__input::-webkit-search-results-button,.choices__input::-webkit-search-results-decoration{display:none}.choices__input::-ms-clear,.choices__input::-ms-reveal{display:none;width:0;height:0}[dir=rtl] .choices__input{padding-right:2px;padding-left:0}.choices__placeholder{opacity:.5}';var hm=Object.defineProperty,um=Object.getOwnPropertyDescriptor,ca=(n,t,e,i)=>{for(var s=i>1?void 0:i?um(t,e):t,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(t,e,s):o(s))||s);return i&&s&&hm(t,e,s),s};z.PboSelector=class extends ae{constructor(){super(...arguments),this.fonts=[{value:"comic",label:"🖊️ Comic Sans",font:"'Comic Sans MS', cursive"},{value:"times",label:"🔤 Times New Roman",font:"'Times New Roman', serif"},{value:"arial",label:"📜 Arial",font:"'Arial', sans-serif"},{value:"mono",label:"💻 Monospace",font:"'Courier New', monospace"}],this.updated=t=>{t.has("fonts")&&this._initializeChoices()}}get value(){var t;return(t=this._choices)==null?void 0:t.getValue().value}firstUpdated(){this._initializeChoices()}_initializeChoices(){var t;(t=this._choices)==null||t.destroy(),this._choices=new lm(this.choiceEl,{allowHTML:!0,searchEnabled:!1,shouldSort:!1,removeItemButton:!1,shadowRoot:this.shadowRoot,choices:this.fonts.map((e,i)=>({value:e.value,label:e.label,customProperties:{font:e.font},selected:i===0})),placeholder:!1,shouldSortItems:!1}),this.choiceEl.addEventListener("change",e=>{const i=e.target;this.dispatchEvent(new CustomEvent("pbo-change",{detail:{value:i.value},bubbles:!0,composed:!0}))})}render(){return St`<select part="base" class="js-choice"></select>`}},z.PboSelector.styles=[Vt,jg,br(cm)],ca([H({type:Array})],z.PboSelector.prototype,"fonts",2),ca([vt(".js-choice")],z.PboSelector.prototype,"choiceEl",2),z.PboSelector=ca([Mt("pbo-selector")],z.PboSelector);const ha=Ct`
198
+ `
199
+ /*! choices.js v11.0.3 | © 2024 Josh Johnson | https://github.com/jshjohnson/Choices#readme */;var rl=function(t,e){return(rl=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i])})(t,e)};function nl(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function i(){this.constructor=t}rl(t,e),t.prototype=null===e?Object.create(e):(i.prototype=e.prototype,new i)}var ol=function(){return ol=Object.assign||function(t){for(var e,i=1,s=arguments.length;i<s;i++)for(var r in e=arguments[i])Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t},ol.apply(this,arguments)};function al(t,e,i){for(var s,r=0,n=e.length;r<n;r++)!s&&r in e||(s||(s=Array.prototype.slice.call(e,0,r)),s[r]=e[r]);return t.concat(s||Array.prototype.slice.call(e))}"function"==typeof SuppressedError&&SuppressedError;var ll,cl="ADD_CHOICE",hl="REMOVE_CHOICE",dl="FILTER_CHOICES",ul="ACTIVATE_CHOICES",pl="CLEAR_CHOICES",gl="ADD_GROUP",fl="ADD_ITEM",ml="REMOVE_ITEM",vl="HIGHLIGHT_ITEM",_l="showDropdown",bl="hideDropdown",yl="change",xl="choice",wl="search",Cl="addItem",Sl="removeItem",Tl="highlightItem",Ol="highlightChoice",El="unhighlightItem",kl=9,Dl=16,Al=46,Ml=8,Pl=13,jl=65,Ll=27,Fl=38,Il=40,Rl=33,Bl=34,Nl=["fuseOptions","classNames"],zl="text",Vl="select-one",$l="select-multiple",Wl=function(t){return{type:hl,choice:t}},Hl=function(t){return{type:ml,item:t}},Xl=function(t,e){return{type:vl,item:t,highlighted:e}},Ul=function(t){return Array.from({length:t},(function(){return(t=0,e=36,Math.floor(Math.random()*(e-t)+t)).toString(36);var t,e})).join("")},Yl=function(t){if("string"!=typeof t){if(null==t)return"";if("object"==typeof t){if("raw"in t)return Yl(t.raw);if("trusted"in t)return t.trusted}return t}return t.replace(/&/g,"&amp;").replace(/>/g,"&gt;").replace(/</g,"&lt;").replace(/'/g,"&#039;").replace(/"/g,"&quot;")},Gl=(ll=document.createElement("div"),function(t){ll.innerHTML=t.trim();for(var e=ll.children[0];ll.firstChild;)ll.removeChild(ll.firstChild);return e}),ql=function(t,e){return"function"==typeof t?t(Yl(e),e):t},Kl=function(t){return"function"==typeof t?t():t},Jl=function(t){if("string"==typeof t)return t;if("object"==typeof t){if("trusted"in t)return t.trusted;if("raw"in t)return t.raw}return""},Zl=function(t,e){return t?function(t){if("string"==typeof t)return t;if("object"==typeof t){if("escaped"in t)return t.escaped;if("trusted"in t)return t.trusted}return""}(e):Yl(e)},Ql=function(t,e,i){t.innerHTML=Zl(e,i)},tc=function(t,e){return t.rank-e.rank},ec=function(t){return Array.isArray(t)?t:[t]},ic=function(t){return t&&Array.isArray(t)?t.map((function(t){return".".concat(t)})).join(""):".".concat(t)},sc=function(t,e){var i;(i=t.classList).add.apply(i,ec(e))},rc=function(t,e){var i;(i=t.classList).remove.apply(i,ec(e))},nc=function(t){if(void 0!==t)try{return JSON.parse(t)}catch(e){return t}return{}},oc=function(){function t(t){var e=t.element,i=t.type,s=t.classNames;this.element=e,this.classNames=s,this.type=i,this.isActive=!1}return t.prototype.show=function(){return sc(this.element,this.classNames.activeState),this.element.setAttribute("aria-expanded","true"),this.isActive=!0,this},t.prototype.hide=function(){return rc(this.element,this.classNames.activeState),this.element.setAttribute("aria-expanded","false"),this.isActive=!1,this},t}(),ac=function(){function t(t){var e=t.element,i=t.type,s=t.classNames,r=t.position;this.element=e,this.classNames=s,this.type=i,this.position=r,this.isOpen=!1,this.isFlipped=!1,this.isDisabled=!1,this.isLoading=!1}return t.prototype.shouldFlip=function(t,e){var i=!1;return"auto"===this.position?i=this.element.getBoundingClientRect().top-e>=0&&!window.matchMedia("(min-height: ".concat(t+1,"px)")).matches:"top"===this.position&&(i=!0),i},t.prototype.setActiveDescendant=function(t){this.element.setAttribute("aria-activedescendant",t)},t.prototype.removeActiveDescendant=function(){this.element.removeAttribute("aria-activedescendant")},t.prototype.open=function(t,e){sc(this.element,this.classNames.openState),this.element.setAttribute("aria-expanded","true"),this.isOpen=!0,this.shouldFlip(t,e)&&(sc(this.element,this.classNames.flippedState),this.isFlipped=!0)},t.prototype.close=function(){rc(this.element,this.classNames.openState),this.element.setAttribute("aria-expanded","false"),this.removeActiveDescendant(),this.isOpen=!1,this.isFlipped&&(rc(this.element,this.classNames.flippedState),this.isFlipped=!1)},t.prototype.addFocusState=function(){sc(this.element,this.classNames.focusState)},t.prototype.removeFocusState=function(){rc(this.element,this.classNames.focusState)},t.prototype.enable=function(){rc(this.element,this.classNames.disabledState),this.element.removeAttribute("aria-disabled"),this.type===Vl&&this.element.setAttribute("tabindex","0"),this.isDisabled=!1},t.prototype.disable=function(){sc(this.element,this.classNames.disabledState),this.element.setAttribute("aria-disabled","true"),this.type===Vl&&this.element.setAttribute("tabindex","-1"),this.isDisabled=!0},t.prototype.wrap=function(t){var e=this.element,i=t.parentNode;i&&(t.nextSibling?i.insertBefore(e,t.nextSibling):i.appendChild(e)),e.appendChild(t)},t.prototype.unwrap=function(t){var e=this.element,i=e.parentNode;i&&(i.insertBefore(t,e),i.removeChild(e))},t.prototype.addLoadingState=function(){sc(this.element,this.classNames.loadingState),this.element.setAttribute("aria-busy","true"),this.isLoading=!0},t.prototype.removeLoadingState=function(){rc(this.element,this.classNames.loadingState),this.element.removeAttribute("aria-busy"),this.isLoading=!1},t}(),lc=function(){function t(t){var e=t.element,i=t.type,s=t.classNames,r=t.preventPaste;this.element=e,this.type=i,this.classNames=s,this.preventPaste=r,this.isFocussed=this.element.isEqualNode(document.activeElement),this.isDisabled=e.disabled,this._onPaste=this._onPaste.bind(this),this._onInput=this._onInput.bind(this),this._onFocus=this._onFocus.bind(this),this._onBlur=this._onBlur.bind(this)}return Object.defineProperty(t.prototype,"placeholder",{set:function(t){this.element.placeholder=t},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"value",{get:function(){return this.element.value},set:function(t){this.element.value=t},enumerable:!1,configurable:!0}),t.prototype.addEventListeners=function(){var t=this.element;t.addEventListener("paste",this._onPaste),t.addEventListener("input",this._onInput,{passive:!0}),t.addEventListener("focus",this._onFocus,{passive:!0}),t.addEventListener("blur",this._onBlur,{passive:!0})},t.prototype.removeEventListeners=function(){var t=this.element;t.removeEventListener("input",this._onInput),t.removeEventListener("paste",this._onPaste),t.removeEventListener("focus",this._onFocus),t.removeEventListener("blur",this._onBlur)},t.prototype.enable=function(){this.element.removeAttribute("disabled"),this.isDisabled=!1},t.prototype.disable=function(){this.element.setAttribute("disabled",""),this.isDisabled=!0},t.prototype.focus=function(){this.isFocussed||this.element.focus()},t.prototype.blur=function(){this.isFocussed&&this.element.blur()},t.prototype.clear=function(t){return void 0===t&&(t=!0),this.element.value="",t&&this.setWidth(),this},t.prototype.setWidth=function(){var t=this.element;t.style.minWidth="".concat(t.placeholder.length+1,"ch"),t.style.width="".concat(t.value.length+1,"ch")},t.prototype.setActiveDescendant=function(t){this.element.setAttribute("aria-activedescendant",t)},t.prototype.removeActiveDescendant=function(){this.element.removeAttribute("aria-activedescendant")},t.prototype._onInput=function(){this.type!==Vl&&this.setWidth()},t.prototype._onPaste=function(t){this.preventPaste&&t.preventDefault()},t.prototype._onFocus=function(){this.isFocussed=!0},t.prototype._onBlur=function(){this.isFocussed=!1},t}(),cc=function(){function t(t){var e=t.element;this.element=e,this.scrollPos=this.element.scrollTop,this.height=this.element.offsetHeight}return t.prototype.prepend=function(t){var e=this.element.firstElementChild;e?this.element.insertBefore(t,e):this.element.append(t)},t.prototype.scrollToTop=function(){this.element.scrollTop=0},t.prototype.scrollToChildElement=function(t,e){var i=this;if(t){var s=this.element.offsetHeight,r=this.element.scrollTop+s,n=t.offsetHeight,o=t.offsetTop+n,a=e>0?this.element.scrollTop+o-r:t.offsetTop;requestAnimationFrame((function(){i._animateScroll(a,e)}))}},t.prototype._scrollDown=function(t,e,i){var s=(i-t)/e,r=s>1?s:1;this.element.scrollTop=t+r},t.prototype._scrollUp=function(t,e,i){var s=(t-i)/e,r=s>1?s:1;this.element.scrollTop=t-r},t.prototype._animateScroll=function(t,e){var i=this,s=this.element.scrollTop,r=!1;e>0?(this._scrollDown(s,4,t),s<t&&(r=!0)):(this._scrollUp(s,4,t),s>t&&(r=!0)),r&&requestAnimationFrame((function(){i._animateScroll(t,e)}))},t}(),hc=function(){function t(t){var e=t.element,i=t.classNames;this.element=e,this.classNames=i,this.isDisabled=!1}return Object.defineProperty(t.prototype,"isActive",{get:function(){return"active"===this.element.dataset.choice},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"dir",{get:function(){return this.element.dir},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"value",{get:function(){return this.element.value},set:function(t){this.element.setAttribute("value",t),this.element.value=t},enumerable:!1,configurable:!0}),t.prototype.conceal=function(){var t=this.element;sc(t,this.classNames.input),t.hidden=!0,t.tabIndex=-1;var e=t.getAttribute("style");e&&t.setAttribute("data-choice-orig-style",e),t.setAttribute("data-choice","active")},t.prototype.reveal=function(){var t=this.element;rc(t,this.classNames.input),t.hidden=!1,t.removeAttribute("tabindex");var e=t.getAttribute("data-choice-orig-style");e?(t.removeAttribute("data-choice-orig-style"),t.setAttribute("style",e)):t.removeAttribute("style"),t.removeAttribute("data-choice")},t.prototype.enable=function(){this.element.removeAttribute("disabled"),this.element.disabled=!1,this.isDisabled=!1},t.prototype.disable=function(){this.element.setAttribute("disabled",""),this.element.disabled=!0,this.isDisabled=!0},t.prototype.triggerEvent=function(t,e){!function(t,e,i){void 0===i&&(i=null);var s=new CustomEvent(e,{detail:i,bubbles:!0,cancelable:!0});t.dispatchEvent(s)}(this.element,t,e||{})},t}(),dc=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return nl(e,t),e}(hc),uc=function(t,e){return void 0===e&&(e=!0),void 0===t?e:!!t},pc=function(t){if("string"==typeof t&&(t=t.split(" ").filter((function(t){return t.length}))),Array.isArray(t)&&t.length)return t},gc=function(t,e,i){if(void 0===i&&(i=!0),"string"==typeof t){var s=Yl(t);return gc({value:t,label:i||s===t?t:{escaped:s,raw:t},selected:!0},!1)}var r=t;if("choices"in r){if(!e)throw new TypeError("optGroup is not allowed");var n=r,o=n.choices.map((function(t){return gc(t,!1)}));return{id:0,label:Jl(n.label)||n.value,active:!!o.length,disabled:!!n.disabled,choices:o}}var a=r;return{id:0,group:null,score:0,rank:0,value:a.value,label:a.label||a.value,active:uc(a.active),selected:uc(a.selected,!1),disabled:uc(a.disabled,!1),placeholder:uc(a.placeholder,!1),highlighted:!1,labelClass:pc(a.labelClass),labelDescription:a.labelDescription,customProperties:a.customProperties}},fc=function(t){return"SELECT"===t.tagName},mc=function(t){function e(e){var i=e.element,s=e.classNames,r=e.template,n=e.extractPlaceholder,o=t.call(this,{element:i,classNames:s})||this;return o.template=r,o.extractPlaceholder=n,o}return nl(e,t),Object.defineProperty(e.prototype,"placeholderOption",{get:function(){return this.element.querySelector('option[value=""]')||this.element.querySelector("option[placeholder]")},enumerable:!1,configurable:!0}),e.prototype.addOptions=function(t){var e=this,i=document.createDocumentFragment();t.forEach((function(t){var s=t;if(!s.element){var r=e.template(s);i.appendChild(r),s.element=r}})),this.element.appendChild(i)},e.prototype.optionsAsChoices=function(){var t=this,e=[];return this.element.querySelectorAll(":scope > option, :scope > optgroup").forEach((function(i){!function(t){return"OPTION"===t.tagName}(i)?function(t){return"OPTGROUP"===t.tagName}(i)&&e.push(t._optgroupToChoice(i)):e.push(t._optionToChoice(i))})),e},e.prototype._optionToChoice=function(t){return!t.hasAttribute("value")&&t.hasAttribute("placeholder")&&(t.setAttribute("value",""),t.value=""),{id:0,group:null,score:0,rank:0,value:t.value,label:t.innerText,element:t,active:!0,selected:this.extractPlaceholder?t.selected:t.hasAttribute("selected"),disabled:t.disabled,highlighted:!1,placeholder:this.extractPlaceholder&&(!t.value||t.hasAttribute("placeholder")),labelClass:void 0!==t.dataset.labelClass?pc(t.dataset.labelClass):void 0,labelDescription:void 0!==t.dataset.labelDescription?t.dataset.labelDescription:void 0,customProperties:nc(t.dataset.customProperties)}},e.prototype._optgroupToChoice=function(t){var e=this,i=t.querySelectorAll("option"),s=Array.from(i).map((function(t){return e._optionToChoice(t)}));return{id:0,label:t.label||"",element:t,active:!!s.length,disabled:t.disabled,choices:s}},e}(hc),vc={items:[],choices:[],silent:!1,renderChoiceLimit:-1,maxItemCount:-1,closeDropdownOnSelect:"auto",singleModeForMultiSelect:!1,addChoices:!1,addItems:!0,addItemFilter:function(t){return!!t&&""!==t},removeItems:!0,removeItemButton:!1,removeItemButtonAlignLeft:!1,editItems:!1,allowHTML:!1,allowHtmlUserInput:!1,duplicateItemsAllowed:!0,delimiter:",",paste:!0,searchEnabled:!0,searchChoices:!0,searchFloor:1,searchResultLimit:4,searchFields:["label","value"],position:"auto",resetScrollPosition:!0,shouldSort:!0,shouldSortItems:!1,sorter:function(t,e){var i=t.value,s=t.label,r=void 0===s?i:s,n=e.value,o=e.label,a=void 0===o?n:o;return Jl(r).localeCompare(Jl(a),[],{sensitivity:"base",ignorePunctuation:!0,numeric:!0})},shadowRoot:null,placeholder:!0,placeholderValue:null,searchPlaceholderValue:null,prependValue:null,appendValue:null,renderSelectedChoices:"auto",loadingText:"Loading...",noResultsText:"No results found",noChoicesText:"No choices to choose from",itemSelectText:"Press to select",uniqueItemText:"Only unique values can be added",customAddItemText:"Only values matching specific conditions can be added",addItemText:function(t){return'Press Enter to add <b>"'.concat(t,'"</b>')},removeItemIconText:function(){return"Remove item"},removeItemLabelText:function(t){return"Remove item: ".concat(t)},maxItemText:function(t){return"Only ".concat(t," values can be added")},valueComparer:function(t,e){return t===e},fuseOptions:{includeScore:!0},labelId:"",callbackOnInit:null,callbackOnCreateTemplates:null,classNames:{containerOuter:["choices"],containerInner:["choices__inner"],input:["choices__input"],inputCloned:["choices__input--cloned"],list:["choices__list"],listItems:["choices__list--multiple"],listSingle:["choices__list--single"],listDropdown:["choices__list--dropdown"],item:["choices__item"],itemSelectable:["choices__item--selectable"],itemDisabled:["choices__item--disabled"],itemChoice:["choices__item--choice"],description:["choices__description"],placeholder:["choices__placeholder"],group:["choices__group"],groupHeading:["choices__heading"],button:["choices__button"],activeState:["is-active"],focusState:["is-focused"],openState:["is-open"],disabledState:["is-disabled"],highlightedState:["is-highlighted"],selectedState:["is-selected"],flippedState:["is-flipped"],loadingState:["is-loading"],notice:["choices__notice"],addChoice:["choices__item--selectable","add-choice"],noResults:["has-no-results"],noChoices:["has-no-choices"]},appendGroupInSearch:!1},_c=function(t){var e=t.itemEl;e&&(e.remove(),t.itemEl=void 0)};var bc={groups:function(t,e){var i=t,s=!0;switch(e.type){case gl:i.push(e.group);break;case pl:i=[];break;default:s=!1}return{state:i,update:s}},items:function(t,e,i){var s=t,r=!0;switch(e.type){case fl:e.item.selected=!0,(n=e.item.element)&&(n.selected=!0,n.setAttribute("selected","")),s.push(e.item);break;case ml:var n;if(e.item.selected=!1,n=e.item.element){n.selected=!1,n.removeAttribute("selected");var o=n.parentElement;o&&fc(o)&&o.type===Vl&&(o.value="")}_c(e.item),s=s.filter((function(t){return t.id!==e.item.id}));break;case hl:_c(e.choice),s=s.filter((function(t){return t.id!==e.choice.id}));break;case vl:var a=e.highlighted,l=s.find((function(t){return t.id===e.item.id}));l&&l.highlighted!==a&&(l.highlighted=a,i&&function(t,e,i){var s=t.itemEl;s&&(rc(s,i),sc(s,e))}(l,a?i.classNames.highlightedState:i.classNames.selectedState,a?i.classNames.selectedState:i.classNames.highlightedState));break;default:r=!1}return{state:s,update:r}},choices:function(t,e,i){var s=t,r=!0;switch(e.type){case cl:s.push(e.choice);break;case hl:e.choice.choiceEl=void 0,e.choice.group&&(e.choice.group.choices=e.choice.group.choices.filter((function(t){return t.id!==e.choice.id}))),s=s.filter((function(t){return t.id!==e.choice.id}));break;case fl:case ml:e.item.choiceEl=void 0;break;case dl:var n=[];e.results.forEach((function(t){n[t.item.id]=t})),s.forEach((function(t){var e=n[t.id];void 0!==e?(t.score=e.score,t.rank=e.rank,t.active=!0):(t.score=0,t.rank=0,t.active=!1),i&&i.appendGroupInSearch&&(t.choiceEl=void 0)}));break;case ul:s.forEach((function(t){t.active=e.active,i&&i.appendGroupInSearch&&(t.choiceEl=void 0)}));break;case pl:s=[];break;default:r=!1}return{state:s,update:r}}},yc=function(){function t(t){this._state=this.defaultState,this._listeners=[],this._txn=0,this._context=t}return Object.defineProperty(t.prototype,"defaultState",{get:function(){return{groups:[],items:[],choices:[]}},enumerable:!1,configurable:!0}),t.prototype.changeSet=function(t){return{groups:t,items:t,choices:t}},t.prototype.reset=function(){this._state=this.defaultState;var t=this.changeSet(!0);this._txn?this._changeSet=t:this._listeners.forEach((function(e){return e(t)}))},t.prototype.subscribe=function(t){return this._listeners.push(t),this},t.prototype.dispatch=function(t){var e=this,i=this._state,s=!1,r=this._changeSet||this.changeSet(!1);Object.keys(bc).forEach((function(n){var o=bc[n](i[n],t,e._context);o.update&&(s=!0,r[n]=!0,i[n]=o.state)})),s&&(this._txn?this._changeSet=r:this._listeners.forEach((function(t){return t(r)})))},t.prototype.withTxn=function(t){this._txn++;try{t()}finally{if(this._txn=Math.max(0,this._txn-1),!this._txn){var e=this._changeSet;e&&(this._changeSet=void 0,this._listeners.forEach((function(t){return t(e)})))}}},Object.defineProperty(t.prototype,"state",{get:function(){return this._state},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"items",{get:function(){return this.state.items},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"highlightedActiveItems",{get:function(){return this.items.filter((function(t){return!t.disabled&&t.active&&t.highlighted}))},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"choices",{get:function(){return this.state.choices},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"activeChoices",{get:function(){return this.choices.filter((function(t){return t.active}))},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"searchableChoices",{get:function(){return this.choices.filter((function(t){return!t.disabled&&!t.placeholder}))},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"groups",{get:function(){return this.state.groups},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"activeGroups",{get:function(){var t=this;return this.state.groups.filter((function(e){var i=e.active&&!e.disabled,s=t.state.choices.some((function(t){return t.active&&!t.disabled}));return i&&s}),[])},enumerable:!1,configurable:!0}),t.prototype.inTxn=function(){return this._txn>0},t.prototype.getChoiceById=function(t){return this.activeChoices.find((function(e){return e.id===t}))},t.prototype.getGroupById=function(t){return this.groups.find((function(e){return e.id===t}))},t}(),xc="no-choices",wc="no-results",Cc="add-choice",Sc="";function Tc(t,e,i){return(e=function(t){var e=function(t,e){if("object"!=typeof t||!t)return t;var i=t[Symbol.toPrimitive];if(void 0!==i){var s=i.call(t,e);if("object"!=typeof s)return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==typeof e?e:e+""}(e))in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}function Oc(t,e){var i=Object.keys(t);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(t);e&&(s=s.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),i.push.apply(i,s)}return i}function Ec(t){for(var e=1;e<arguments.length;e++){var i=null!=arguments[e]?arguments[e]:{};e%2?Oc(Object(i),!0).forEach((function(e){Tc(t,e,i[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(i)):Oc(Object(i)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(i,e))}))}return t}function kc(t){return Array.isArray?Array.isArray(t):"[object Array]"===Fc(t)}function Dc(t){return"string"==typeof t}function Ac(t){return"number"==typeof t}function Mc(t){return!0===t||!1===t||function(t){return Pc(t)&&null!==t}(t)&&"[object Boolean]"==Fc(t)}function Pc(t){return"object"==typeof t}function jc(t){return null!=t}function Lc(t){return!t.trim().length}function Fc(t){return null==t?void 0===t?"[object Undefined]":"[object Null]":Object.prototype.toString.call(t)}const Ic=Object.prototype.hasOwnProperty;class Rc{constructor(t){this._keys=[],this._keyMap={};let e=0;t.forEach((t=>{let i=Bc(t);this._keys.push(i),this._keyMap[i.id]=i,e+=i.weight})),this._keys.forEach((t=>{t.weight/=e}))}get(t){return this._keyMap[t]}keys(){return this._keys}toJSON(){return JSON.stringify(this._keys)}}function Bc(t){let e=null,i=null,s=null,r=1,n=null;if(Dc(t)||kc(t))s=t,e=Nc(t),i=zc(t);else{if(!Ic.call(t,"name"))throw new Error((t=>`Missing ${t} property in key`)("name"));const o=t.name;if(s=o,Ic.call(t,"weight")&&(r=t.weight,r<=0))throw new Error((t=>`Property 'weight' in key '${t}' must be a positive integer`)(o));e=Nc(o),i=zc(o),n=t.getFn}return{path:e,id:i,weight:r,src:s,getFn:n}}function Nc(t){return kc(t)?t:t.split(".")}function zc(t){return kc(t)?t.join("."):t}const Vc={useExtendedSearch:!1,getFn:function(t,e){let i=[],s=!1;const r=(t,e,n)=>{if(jc(t))if(e[n]){const o=t[e[n]];if(!jc(o))return;if(n===e.length-1&&(Dc(o)||Ac(o)||Mc(o)))i.push(function(t){return null==t?"":function(t){if("string"==typeof t)return t;let e=t+"";return"0"==e&&1/t==-1/0?"-0":e}(t)}(o));else if(kc(o)){s=!0;for(let t=0,i=o.length;t<i;t+=1)r(o[t],e,n+1)}else e.length&&r(o,e,n+1)}else i.push(t)};return r(t,Dc(e)?e.split("."):e,0),s?i:i[0]},ignoreLocation:!1,ignoreFieldNorm:!1,fieldNormWeight:1};var $c=Ec(Ec(Ec(Ec({},{isCaseSensitive:!1,includeScore:!1,keys:[],shouldSort:!0,sortFn:(t,e)=>t.score===e.score?t.idx<e.idx?-1:1:t.score<e.score?-1:1}),{includeMatches:!1,findAllMatches:!1,minMatchCharLength:1}),{location:0,threshold:.6,distance:100}),Vc);const Wc=/[^ ]+/g;class Hc{constructor({getFn:t=$c.getFn,fieldNormWeight:e=$c.fieldNormWeight}={}){this.norm=function(t=1,e=3){const i=new Map,s=Math.pow(10,e);return{get(e){const r=e.match(Wc).length;if(i.has(r))return i.get(r);const n=1/Math.pow(r,.5*t),o=parseFloat(Math.round(n*s)/s);return i.set(r,o),o},clear(){i.clear()}}}(e,3),this.getFn=t,this.isCreated=!1,this.setIndexRecords()}setSources(t=[]){this.docs=t}setIndexRecords(t=[]){this.records=t}setKeys(t=[]){this.keys=t,this._keysMap={},t.forEach(((t,e)=>{this._keysMap[t.id]=e}))}create(){!this.isCreated&&this.docs.length&&(this.isCreated=!0,Dc(this.docs[0])?this.docs.forEach(((t,e)=>{this._addString(t,e)})):this.docs.forEach(((t,e)=>{this._addObject(t,e)})),this.norm.clear())}add(t){const e=this.size();Dc(t)?this._addString(t,e):this._addObject(t,e)}removeAt(t){this.records.splice(t,1);for(let e=t,i=this.size();e<i;e+=1)this.records[e].i-=1}getValueForItemAtKeyId(t,e){return t[this._keysMap[e]]}size(){return this.records.length}_addString(t,e){if(!jc(t)||Lc(t))return;let i={v:t,i:e,n:this.norm.get(t)};this.records.push(i)}_addObject(t,e){let i={i:e,$:{}};this.keys.forEach(((e,s)=>{let r=e.getFn?e.getFn(t):this.getFn(t,e.path);if(jc(r))if(kc(r)){let t=[];const e=[{nestedArrIndex:-1,value:r}];for(;e.length;){const{nestedArrIndex:i,value:s}=e.pop();if(jc(s))if(Dc(s)&&!Lc(s)){let e={v:s,i:i,n:this.norm.get(s)};t.push(e)}else kc(s)&&s.forEach(((t,i)=>{e.push({nestedArrIndex:i,value:t})}))}i.$[s]=t}else if(Dc(r)&&!Lc(r)){let t={v:r,n:this.norm.get(r)};i.$[s]=t}})),this.records.push(i)}toJSON(){return{keys:this.keys,records:this.records}}}function Xc(t,e,{getFn:i=$c.getFn,fieldNormWeight:s=$c.fieldNormWeight}={}){const r=new Hc({getFn:i,fieldNormWeight:s});return r.setKeys(t.map(Bc)),r.setSources(e),r.create(),r}function Uc(t,{errors:e=0,currentLocation:i=0,expectedLocation:s=0,distance:r=$c.distance,ignoreLocation:n=$c.ignoreLocation}={}){const o=e/t.length;if(n)return o;const a=Math.abs(s-i);return r?o+a/r:a?1:o}const Yc=32;function Gc(t,e,i,{location:s=$c.location,distance:r=$c.distance,threshold:n=$c.threshold,findAllMatches:o=$c.findAllMatches,minMatchCharLength:a=$c.minMatchCharLength,includeMatches:l=$c.includeMatches,ignoreLocation:c=$c.ignoreLocation}={}){if(e.length>Yc)throw new Error(`Pattern length exceeds max of ${Yc}.`);const h=e.length,d=t.length,u=Math.max(0,Math.min(s,d));let p=n,g=u;const f=a>1||l,m=f?Array(d):[];let v;for(;(v=t.indexOf(e,g))>-1;){let t=Uc(e,{currentLocation:v,expectedLocation:u,distance:r,ignoreLocation:c});if(p=Math.min(t,p),g=v+h,f){let t=0;for(;t<h;)m[v+t]=1,t+=1}}g=-1;let _=[],b=1,y=h+d;const x=1<<h-1;for(let C=0;C<h;C+=1){let s=0,n=y;for(;s<n;){Uc(e,{errors:C,currentLocation:u+n,expectedLocation:u,distance:r,ignoreLocation:c})<=p?s=n:y=n,n=Math.floor((y-s)/2+s)}y=n;let a=Math.max(1,u-n+1),l=o?d:Math.min(u+n,d)+h,v=Array(l+2);v[l+1]=(1<<C)-1;for(let o=l;o>=a;o-=1){let s=o-1,n=i[t.charAt(s)];if(f&&(m[s]=+!!n),v[o]=(v[o+1]<<1|1)&n,C&&(v[o]|=(_[o+1]|_[o])<<1|1|_[o+1]),v[o]&x&&(b=Uc(e,{errors:C,currentLocation:s,expectedLocation:u,distance:r,ignoreLocation:c}),b<=p)){if(p=b,g=s,g<=u)break;a=Math.max(1,2*u-g)}}if(Uc(e,{errors:C+1,currentLocation:u,expectedLocation:u,distance:r,ignoreLocation:c})>p)break;_=v}const w={isMatch:g>=0,score:Math.max(.001,b)};if(f){const t=function(t=[],e=$c.minMatchCharLength){let i=[],s=-1,r=-1,n=0;for(let o=t.length;n<o;n+=1){let o=t[n];o&&-1===s?s=n:o||-1===s||(r=n-1,r-s+1>=e&&i.push([s,r]),s=-1)}return t[n-1]&&n-s>=e&&i.push([s,n-1]),i}(m,a);t.length?l&&(w.indices=t):w.isMatch=!1}return w}function qc(t){let e={};for(let i=0,s=t.length;i<s;i+=1){const r=t.charAt(i);e[r]=(e[r]||0)|1<<s-i-1}return e}class Kc{constructor(t,{location:e=$c.location,threshold:i=$c.threshold,distance:s=$c.distance,includeMatches:r=$c.includeMatches,findAllMatches:n=$c.findAllMatches,minMatchCharLength:o=$c.minMatchCharLength,isCaseSensitive:a=$c.isCaseSensitive,ignoreLocation:l=$c.ignoreLocation}={}){if(this.options={location:e,threshold:i,distance:s,includeMatches:r,findAllMatches:n,minMatchCharLength:o,isCaseSensitive:a,ignoreLocation:l},this.pattern=a?t:t.toLowerCase(),this.chunks=[],!this.pattern.length)return;const c=(t,e)=>{this.chunks.push({pattern:t,alphabet:qc(t),startIndex:e})},h=this.pattern.length;if(h>Yc){let t=0;const e=h%Yc,i=h-e;for(;t<i;)c(this.pattern.substr(t,Yc),t),t+=Yc;if(e){const t=h-Yc;c(this.pattern.substr(t),t)}}else c(this.pattern,0)}searchIn(t){const{isCaseSensitive:e,includeMatches:i}=this.options;if(e||(t=t.toLowerCase()),this.pattern===t){let e={isMatch:!0,score:0};return i&&(e.indices=[[0,t.length-1]]),e}const{location:s,distance:r,threshold:n,findAllMatches:o,minMatchCharLength:a,ignoreLocation:l}=this.options;let c=[],h=0,d=!1;this.chunks.forEach((({pattern:e,alphabet:u,startIndex:p})=>{const{isMatch:g,score:f,indices:m}=Gc(t,e,u,{location:s+p,distance:r,threshold:n,findAllMatches:o,minMatchCharLength:a,includeMatches:i,ignoreLocation:l});g&&(d=!0),h+=f,g&&m&&(c=[...c,...m])}));let u={isMatch:d,score:d?h/this.chunks.length:1};return d&&i&&(u.indices=c),u}}class Jc{constructor(t){this.pattern=t}static isMultiMatch(t){return Zc(t,this.multiRegex)}static isSingleMatch(t){return Zc(t,this.singleRegex)}search(){}}function Zc(t,e){const i=t.match(e);return i?i[1]:null}class Qc extends Jc{constructor(t,{location:e=$c.location,threshold:i=$c.threshold,distance:s=$c.distance,includeMatches:r=$c.includeMatches,findAllMatches:n=$c.findAllMatches,minMatchCharLength:o=$c.minMatchCharLength,isCaseSensitive:a=$c.isCaseSensitive,ignoreLocation:l=$c.ignoreLocation}={}){super(t),this._bitapSearch=new Kc(t,{location:e,threshold:i,distance:s,includeMatches:r,findAllMatches:n,minMatchCharLength:o,isCaseSensitive:a,ignoreLocation:l})}static get type(){return"fuzzy"}static get multiRegex(){return/^"(.*)"$/}static get singleRegex(){return/^(.*)$/}search(t){return this._bitapSearch.searchIn(t)}}class th extends Jc{constructor(t){super(t)}static get type(){return"include"}static get multiRegex(){return/^'"(.*)"$/}static get singleRegex(){return/^'(.*)$/}search(t){let e,i=0;const s=[],r=this.pattern.length;for(;(e=t.indexOf(this.pattern,i))>-1;)i=e+r,s.push([e,i-1]);const n=!!s.length;return{isMatch:n,score:n?0:1,indices:s}}}const eh=[class extends Jc{constructor(t){super(t)}static get type(){return"exact"}static get multiRegex(){return/^="(.*)"$/}static get singleRegex(){return/^=(.*)$/}search(t){const e=t===this.pattern;return{isMatch:e,score:e?0:1,indices:[0,this.pattern.length-1]}}},th,class extends Jc{constructor(t){super(t)}static get type(){return"prefix-exact"}static get multiRegex(){return/^\^"(.*)"$/}static get singleRegex(){return/^\^(.*)$/}search(t){const e=t.startsWith(this.pattern);return{isMatch:e,score:e?0:1,indices:[0,this.pattern.length-1]}}},class extends Jc{constructor(t){super(t)}static get type(){return"inverse-prefix-exact"}static get multiRegex(){return/^!\^"(.*)"$/}static get singleRegex(){return/^!\^(.*)$/}search(t){const e=!t.startsWith(this.pattern);return{isMatch:e,score:e?0:1,indices:[0,t.length-1]}}},class extends Jc{constructor(t){super(t)}static get type(){return"inverse-suffix-exact"}static get multiRegex(){return/^!"(.*)"\$$/}static get singleRegex(){return/^!(.*)\$$/}search(t){const e=!t.endsWith(this.pattern);return{isMatch:e,score:e?0:1,indices:[0,t.length-1]}}},class extends Jc{constructor(t){super(t)}static get type(){return"suffix-exact"}static get multiRegex(){return/^"(.*)"\$$/}static get singleRegex(){return/^(.*)\$$/}search(t){const e=t.endsWith(this.pattern);return{isMatch:e,score:e?0:1,indices:[t.length-this.pattern.length,t.length-1]}}},class extends Jc{constructor(t){super(t)}static get type(){return"inverse-exact"}static get multiRegex(){return/^!"(.*)"$/}static get singleRegex(){return/^!(.*)$/}search(t){const e=-1===t.indexOf(this.pattern);return{isMatch:e,score:e?0:1,indices:[0,t.length-1]}}},Qc],ih=eh.length,sh=/ +(?=(?:[^\"]*\"[^\"]*\")*[^\"]*$)/;const rh=new Set([Qc.type,th.type]);class nh{constructor(t,{isCaseSensitive:e=$c.isCaseSensitive,includeMatches:i=$c.includeMatches,minMatchCharLength:s=$c.minMatchCharLength,ignoreLocation:r=$c.ignoreLocation,findAllMatches:n=$c.findAllMatches,location:o=$c.location,threshold:a=$c.threshold,distance:l=$c.distance}={}){this.query=null,this.options={isCaseSensitive:e,includeMatches:i,minMatchCharLength:s,findAllMatches:n,ignoreLocation:r,location:o,threshold:a,distance:l},this.pattern=e?t:t.toLowerCase(),this.query=function(t,e={}){return t.split("|").map((t=>{let i=t.trim().split(sh).filter((t=>t&&!!t.trim())),s=[];for(let r=0,n=i.length;r<n;r+=1){const t=i[r];let n=!1,o=-1;for(;!n&&++o<ih;){const i=eh[o];let r=i.isMultiMatch(t);r&&(s.push(new i(r,e)),n=!0)}if(!n)for(o=-1;++o<ih;){const i=eh[o];let r=i.isSingleMatch(t);if(r){s.push(new i(r,e));break}}}return s}))}(this.pattern,this.options)}static condition(t,e){return e.useExtendedSearch}searchIn(t){const e=this.query;if(!e)return{isMatch:!1,score:1};const{includeMatches:i,isCaseSensitive:s}=this.options;t=s?t:t.toLowerCase();let r=0,n=[],o=0;for(let a=0,l=e.length;a<l;a+=1){const s=e[a];n.length=0,r=0;for(let e=0,a=s.length;e<a;e+=1){const a=s[e],{isMatch:l,indices:c,score:h}=a.search(t);if(!l){o=0,r=0,n.length=0;break}if(r+=1,o+=h,i){const t=a.constructor.type;rh.has(t)?n=[...n,...c]:n.push(c)}}if(r){let t={isMatch:!0,score:o/r};return i&&(t.indices=n),t}}return{isMatch:!1,score:1}}}const oh=[];function ah(t,e){for(let i=0,s=oh.length;i<s;i+=1){let s=oh[i];if(s.condition(t,e))return new s(t,e)}return new Kc(t,e)}const lh="$and",ch="$or",hh="$path",dh="$val",uh=t=>!(!t[lh]&&!t[ch]),ph=t=>({[lh]:Object.keys(t).map((e=>({[e]:t[e]})))});function gh(t,e,{auto:i=!0}={}){const s=t=>{let r=Object.keys(t);const n=(t=>!!t[hh])(t);if(!n&&r.length>1&&!uh(t))return s(ph(t));if((t=>!kc(t)&&Pc(t)&&!uh(t))(t)){const s=n?t[hh]:r[0],o=n?t[dh]:t[s];if(!Dc(o))throw new Error((t=>`Invalid value for key ${t}`)(s));const a={keyId:zc(s),pattern:o};return i&&(a.searcher=ah(o,e)),a}let o={children:[],operator:r[0]};return r.forEach((e=>{const i=t[e];kc(i)&&i.forEach((t=>{o.children.push(s(t))}))})),o};return uh(t)||(t=ph(t)),s(t)}function fh(t,e){const i=t.matches;e.matches=[],jc(i)&&i.forEach((t=>{if(!jc(t.indices)||!t.indices.length)return;const{indices:i,value:s}=t;let r={indices:i,value:s};t.key&&(r.key=t.key.src),t.idx>-1&&(r.refIndex=t.idx),e.matches.push(r)}))}function mh(t,e){e.score=t.score}class vh{constructor(t,e={},i){this.options=Ec(Ec({},$c),e),this.options.useExtendedSearch,this._keyStore=new Rc(this.options.keys),this.setCollection(t,i)}setCollection(t,e){if(this._docs=t,e&&!(e instanceof Hc))throw new Error("Incorrect 'index' type");this._myIndex=e||Xc(this.options.keys,this._docs,{getFn:this.options.getFn,fieldNormWeight:this.options.fieldNormWeight})}add(t){jc(t)&&(this._docs.push(t),this._myIndex.add(t))}remove(t=()=>!1){const e=[];for(let i=0,s=this._docs.length;i<s;i+=1){const r=this._docs[i];t(r,i)&&(this.removeAt(i),i-=1,s-=1,e.push(r))}return e}removeAt(t){this._docs.splice(t,1),this._myIndex.removeAt(t)}getIndex(){return this._myIndex}search(t,{limit:e=-1}={}){const{includeMatches:i,includeScore:s,shouldSort:r,sortFn:n,ignoreFieldNorm:o}=this.options;let a=Dc(t)?Dc(this._docs[0])?this._searchStringList(t):this._searchObjectList(t):this._searchLogical(t);return function(t,{ignoreFieldNorm:e=$c.ignoreFieldNorm}){t.forEach((t=>{let i=1;t.matches.forEach((({key:t,norm:s,score:r})=>{const n=t?t.weight:null;i*=Math.pow(0===r&&n?Number.EPSILON:r,(n||1)*(e?1:s))})),t.score=i}))}(a,{ignoreFieldNorm:o}),r&&a.sort(n),Ac(e)&&e>-1&&(a=a.slice(0,e)),function(t,e,{includeMatches:i=$c.includeMatches,includeScore:s=$c.includeScore}={}){const r=[];return i&&r.push(fh),s&&r.push(mh),t.map((t=>{const{idx:i}=t,s={item:e[i],refIndex:i};return r.length&&r.forEach((e=>{e(t,s)})),s}))}(a,this._docs,{includeMatches:i,includeScore:s})}_searchStringList(t){const e=ah(t,this.options),{records:i}=this._myIndex,s=[];return i.forEach((({v:t,i:i,n:r})=>{if(!jc(t))return;const{isMatch:n,score:o,indices:a}=e.searchIn(t);n&&s.push({item:t,idx:i,matches:[{score:o,value:t,norm:r,indices:a}]})})),s}_searchLogical(t){const e=gh(t,this.options),i=(t,e,s)=>{if(!t.children){const{keyId:i,searcher:r}=t,n=this._findMatches({key:this._keyStore.get(i),value:this._myIndex.getValueForItemAtKeyId(e,i),searcher:r});return n&&n.length?[{idx:s,item:e,matches:n}]:[]}const r=[];for(let n=0,o=t.children.length;n<o;n+=1){const o=t.children[n],a=i(o,e,s);if(a.length)r.push(...a);else if(t.operator===lh)return[]}return r},s=this._myIndex.records,r={},n=[];return s.forEach((({$:t,i:s})=>{if(jc(t)){let o=i(e,t,s);o.length&&(r[s]||(r[s]={idx:s,item:t,matches:[]},n.push(r[s])),o.forEach((({matches:t})=>{r[s].matches.push(...t)})))}})),n}_searchObjectList(t){const e=ah(t,this.options),{keys:i,records:s}=this._myIndex,r=[];return s.forEach((({$:t,i:s})=>{if(!jc(t))return;let n=[];i.forEach(((i,s)=>{n.push(...this._findMatches({key:i,value:t[s],searcher:e}))})),n.length&&r.push({idx:s,item:t,matches:n})})),r}_findMatches({key:t,value:e,searcher:i}){if(!jc(e))return[];let s=[];if(kc(e))e.forEach((({v:e,i:r,n:n})=>{if(!jc(e))return;const{isMatch:o,score:a,indices:l}=i.searchIn(e);o&&s.push({score:a,key:t,value:e,idx:r,norm:n,indices:l})}));else{const{v:r,n:n}=e,{isMatch:o,score:a,indices:l}=i.searchIn(r);o&&s.push({score:a,key:t,value:r,norm:n,indices:l})}return s}}vh.version="7.0.0",vh.createIndex=Xc,vh.parseIndex=function(t,{getFn:e=$c.getFn,fieldNormWeight:i=$c.fieldNormWeight}={}){const{keys:s,records:r}=t,n=new Hc({getFn:e,fieldNormWeight:i});return n.setKeys(s),n.setIndexRecords(r),n},vh.config=$c,vh.parseQuery=gh,function(...t){oh.push(...t)}(nh);var _h=function(){function t(t){this._haystack=[],this._fuseOptions=ol(ol({},t.fuseOptions),{keys:al([],t.searchFields),includeMatches:!0})}return t.prototype.index=function(t){this._haystack=t,this._fuse&&this._fuse.setCollection(t)},t.prototype.reset=function(){this._haystack=[],this._fuse=void 0},t.prototype.isEmptyIndex=function(){return!this._haystack.length},t.prototype.search=function(t){return this._fuse||(this._fuse=new vh(this._haystack,this._fuseOptions)),this._fuse.search(t).map((function(t,e){return{item:t.item,score:t.score||0,rank:e+1}}))},t}();var bh=function(t,e,i){var s=t.dataset,r=e.customProperties,n=e.labelClass,o=e.labelDescription;n&&(s.labelClass=ec(n).join(" ")),o&&(s.labelDescription=o),i&&r&&("string"==typeof r?s.customProperties=r:"object"!=typeof r||function(t){for(var e in t)if(Object.prototype.hasOwnProperty.call(t,e))return!1;return!0}(r)||(s.customProperties=JSON.stringify(r)))},yh=function(t,e,i){var s=e&&t.querySelector("label[for='".concat(e,"']")),r=s&&s.innerText;r&&i.setAttribute("aria-label",r)},xh={containerOuter:function(t,e,i,s,r,n,o){var a=t.classNames.containerOuter,l=document.createElement("div");return sc(l,a),l.dataset.type=n,e&&(l.dir=e),s&&(l.tabIndex=0),i&&(l.setAttribute("role",r?"combobox":"listbox"),r?l.setAttribute("aria-autocomplete","list"):o||yh(this._docRoot,this.passedElement.element.id,l),l.setAttribute("aria-haspopup","true"),l.setAttribute("aria-expanded","false")),o&&l.setAttribute("aria-labelledby",o),l},containerInner:function(t){var e=t.classNames.containerInner,i=document.createElement("div");return sc(i,e),i},itemList:function(t,e){var i=t.searchEnabled,s=t.classNames,r=s.list,n=s.listSingle,o=s.listItems,a=document.createElement("div");return sc(a,r),sc(a,e?n:o),this._isSelectElement&&i&&a.setAttribute("role","listbox"),a},placeholder:function(t,e){var i=t.allowHTML,s=t.classNames.placeholder,r=document.createElement("div");return sc(r,s),Ql(r,i,e),r},item:function(t,e,i){var s=t.allowHTML,r=t.removeItemButtonAlignLeft,n=t.removeItemIconText,o=t.removeItemLabelText,a=t.classNames,l=a.item,c=a.button,h=a.highlightedState,d=a.itemSelectable,u=a.placeholder,p=Jl(e.value),g=document.createElement("div");if(sc(g,l),e.labelClass){var f=document.createElement("span");Ql(f,s,e.label),sc(f,e.labelClass),g.appendChild(f)}else Ql(g,s,e.label);if(g.dataset.item="",g.dataset.id=e.id,g.dataset.value=p,bh(g,e,!0),(e.disabled||this.containerOuter.isDisabled)&&g.setAttribute("aria-disabled","true"),this._isSelectElement&&(g.setAttribute("aria-selected","true"),g.setAttribute("role","option")),e.placeholder&&(sc(g,u),g.dataset.placeholder=""),sc(g,e.highlighted?h:d),i){e.disabled&&rc(g,d),g.dataset.deletable="";var m=document.createElement("button");m.type="button",sc(m,c),Ql(m,!0,ql(n,e.value));var v=ql(o,e.value);v&&m.setAttribute("aria-label",v),m.dataset.button="",r?g.insertAdjacentElement("afterbegin",m):g.appendChild(m)}return g},choiceList:function(t,e){var i=t.classNames.list,s=document.createElement("div");return sc(s,i),e||s.setAttribute("aria-multiselectable","true"),s.setAttribute("role","listbox"),s},choiceGroup:function(t,e){var i=t.allowHTML,s=t.classNames,r=s.group,n=s.groupHeading,o=s.itemDisabled,a=e.id,l=e.label,c=e.disabled,h=Jl(l),d=document.createElement("div");sc(d,r),c&&sc(d,o),d.setAttribute("role","group"),d.dataset.group="",d.dataset.id=a,d.dataset.value=h,c&&d.setAttribute("aria-disabled","true");var u=document.createElement("div");return sc(u,n),Ql(u,i,l||""),d.appendChild(u),d},choice:function(t,e,i,s){var r=t.allowHTML,n=t.classNames,o=n.item,a=n.itemChoice,l=n.itemSelectable,c=n.selectedState,h=n.itemDisabled,d=n.description,u=n.placeholder,p=e.label,g=Jl(e.value),f=document.createElement("div");f.id=e.elementId,sc(f,o),sc(f,a),s&&"string"==typeof p&&(p=Zl(r,p),p={trusted:p+=" (".concat(s,")")});var m=f;if(e.labelClass){var v=document.createElement("span");Ql(v,r,p),sc(v,e.labelClass),m=v,f.appendChild(v)}else Ql(f,r,p);if(e.labelDescription){var _="".concat(e.elementId,"-description");m.setAttribute("aria-describedby",_);var b=document.createElement("span");Ql(b,r,e.labelDescription),b.id=_,sc(b,d),f.appendChild(b)}return e.selected&&sc(f,c),e.placeholder&&sc(f,u),f.setAttribute("role",e.group?"treeitem":"option"),f.dataset.choice="",f.dataset.id=e.id,f.dataset.value=g,i&&(f.dataset.selectText=i),e.group&&(f.dataset.groupId="".concat(e.group.id)),bh(f,e,!1),e.disabled?(sc(f,h),f.dataset.choiceDisabled="",f.setAttribute("aria-disabled","true")):(sc(f,l),f.dataset.choiceSelectable=""),f},input:function(t,e){var i=t.classNames,s=i.input,r=i.inputCloned,n=t.labelId,o=document.createElement("input");return o.type="search",sc(o,s),sc(o,r),o.autocomplete="off",o.autocapitalize="off",o.spellcheck=!1,o.setAttribute("role","textbox"),o.setAttribute("aria-autocomplete","list"),e?o.setAttribute("aria-label",e):n||yh(this._docRoot,this.passedElement.element.id,o),o},dropdown:function(t){var e=t.classNames,i=e.list,s=e.listDropdown,r=document.createElement("div");return sc(r,i),sc(r,s),r.setAttribute("aria-expanded","false"),r},notice:function(t,e,i){var s=t.classNames,r=s.item,n=s.itemChoice,o=s.addChoice,a=s.noResults,l=s.noChoices,c=s.notice;void 0===i&&(i=Sc);var h=document.createElement("div");switch(Ql(h,!0,e),sc(h,r),sc(h,n),sc(h,c),i){case Cc:sc(h,o);break;case wc:sc(h,a);break;case xc:sc(h,l)}return i===Cc&&(h.dataset.choiceSelectable="",h.dataset.choice=""),h},option:function(t){var e=Jl(t.label),i=new Option(e,t.value,!1,t.selected);return bh(i,t,!0),i.disabled=t.disabled,t.selected&&i.setAttribute("selected",""),i}},wh="-ms-scroll-limit"in document.documentElement.style&&"-ms-ime-align"in document.documentElement.style,Ch={},Sh=function(t){if(t)return t.dataset.id?parseInt(t.dataset.id,10):void 0},Th="[data-choice-selectable]",Oh=function(){function t(e,i){void 0===e&&(e="[data-choice]"),void 0===i&&(i={});var s=this;this.initialisedOK=void 0,this._hasNonChoicePlaceholder=!1,this._lastAddedChoiceId=0,this._lastAddedGroupId=0;var r=t.defaults;this.config=ol(ol(ol({},r.allOptions),r.options),i),Nl.forEach((function(t){s.config[t]=ol(ol(ol({},r.allOptions[t]),r.options[t]),i[t])}));var n=this.config;n.silent||this._validateConfig();var o=n.shadowRoot||document.documentElement;this._docRoot=o;var a="string"==typeof e?o.querySelector(e):e;if(!a||"object"!=typeof a||"INPUT"!==a.tagName&&!fc(a)){if(!a&&"string"==typeof e)throw TypeError("Selector ".concat(e," failed to find an element"));throw TypeError("Expected one of the following types text|select-one|select-multiple")}var l=a.type,c=l===zl;(c||1!==n.maxItemCount)&&(n.singleModeForMultiSelect=!1),n.singleModeForMultiSelect&&(l=$l);var h=l===Vl,d=l===$l,u=h||d;if(this._elementType=l,this._isTextElement=c,this._isSelectOneElement=h,this._isSelectMultipleElement=d,this._isSelectElement=h||d,this._canAddUserChoices=c&&n.addItems||u&&n.addChoices,"boolean"!=typeof n.renderSelectedChoices&&(n.renderSelectedChoices="always"===n.renderSelectedChoices||h),"auto"===n.closeDropdownOnSelect?n.closeDropdownOnSelect=c||h||n.singleModeForMultiSelect:n.closeDropdownOnSelect=uc(n.closeDropdownOnSelect),n.placeholder&&(n.placeholderValue?this._hasNonChoicePlaceholder=!0:a.dataset.placeholder&&(this._hasNonChoicePlaceholder=!0,n.placeholderValue=a.dataset.placeholder)),i.addItemFilter&&"function"!=typeof i.addItemFilter){var p=i.addItemFilter instanceof RegExp?i.addItemFilter:new RegExp(i.addItemFilter);n.addItemFilter=p.test.bind(p)}if(this._isTextElement)this.passedElement=new dc({element:a,classNames:n.classNames});else{var g=a;this.passedElement=new mc({element:g,classNames:n.classNames,template:function(t){return s._templates.option(t)},extractPlaceholder:n.placeholder&&!this._hasNonChoicePlaceholder})}if(this.initialised=!1,this._store=new yc(n),this._currentValue="",n.searchEnabled=!c&&n.searchEnabled||d,this._canSearch=n.searchEnabled,this._isScrollingOnIe=!1,this._highlightPosition=0,this._wasTap=!0,this._placeholderValue=this._generatePlaceholderValue(),this._baseId=function(t,e){var i=t.id||t.name&&"".concat(t.name,"-").concat(Ul(2))||Ul(4);return i=i.replace(/(:|\.|\[|\]|,)/g,""),"".concat(e,"-").concat(i)}(a,"choices-"),this._direction=a.dir,!this._direction){var f=window.getComputedStyle(a).direction;f!==window.getComputedStyle(document.documentElement).direction&&(this._direction=f)}if(this._idNames={itemChoice:"item-choice"},this._templates=r.templates,this._render=this._render.bind(this),this._onFocus=this._onFocus.bind(this),this._onBlur=this._onBlur.bind(this),this._onKeyUp=this._onKeyUp.bind(this),this._onKeyDown=this._onKeyDown.bind(this),this._onInput=this._onInput.bind(this),this._onClick=this._onClick.bind(this),this._onTouchMove=this._onTouchMove.bind(this),this._onTouchEnd=this._onTouchEnd.bind(this),this._onMouseDown=this._onMouseDown.bind(this),this._onMouseOver=this._onMouseOver.bind(this),this._onFormReset=this._onFormReset.bind(this),this._onSelectKey=this._onSelectKey.bind(this),this._onEnterKey=this._onEnterKey.bind(this),this._onEscapeKey=this._onEscapeKey.bind(this),this._onDirectionKey=this._onDirectionKey.bind(this),this._onDeleteKey=this._onDeleteKey.bind(this),this.passedElement.isActive)return n.silent||console.warn("Trying to initialise Choices on element already initialised",{element:e}),this.initialised=!0,void(this.initialisedOK=!1);this.init(),this._initialItems=this._store.items.map((function(t){return t.value}))}return Object.defineProperty(t,"defaults",{get:function(){return Object.preventExtensions({get options(){return Ch},get allOptions(){return vc},get templates(){return xh}})},enumerable:!1,configurable:!0}),t.prototype.init=function(){if(!this.initialised&&void 0===this.initialisedOK){var t;this._searcher=(t=this.config,new _h(t)),this._loadChoices(),this._createTemplates(),this._createElements(),this._createStructure(),this._isTextElement&&!this.config.addItems||this.passedElement.element.hasAttribute("disabled")||this.passedElement.element.closest("fieldset:disabled")?this.disable():(this.enable(),this._addEventListeners()),this._initStore(),this.initialised=!0,this.initialisedOK=!0;var e=this.config.callbackOnInit;"function"==typeof e&&e.call(this)}},t.prototype.destroy=function(){this.initialised&&(this._removeEventListeners(),this.passedElement.reveal(),this.containerOuter.unwrap(this.passedElement.element),this._store._listeners=[],this.clearStore(!1),this._stopSearch(),this._templates=t.defaults.templates,this.initialised=!1,this.initialisedOK=void 0)},t.prototype.enable=function(){return this.passedElement.isDisabled&&this.passedElement.enable(),this.containerOuter.isDisabled&&(this._addEventListeners(),this.input.enable(),this.containerOuter.enable()),this},t.prototype.disable=function(){return this.passedElement.isDisabled||this.passedElement.disable(),this.containerOuter.isDisabled||(this._removeEventListeners(),this.input.disable(),this.containerOuter.disable()),this},t.prototype.highlightItem=function(t,e){if(void 0===e&&(e=!0),!t||!t.id)return this;var i=this._store.items.find((function(e){return e.id===t.id}));return!i||i.highlighted||(this._store.dispatch(Xl(i,!0)),e&&this.passedElement.triggerEvent(Tl,this._getChoiceForOutput(i))),this},t.prototype.unhighlightItem=function(t,e){if(void 0===e&&(e=!0),!t||!t.id)return this;var i=this._store.items.find((function(e){return e.id===t.id}));return i&&i.highlighted?(this._store.dispatch(Xl(i,!1)),e&&this.passedElement.triggerEvent(El,this._getChoiceForOutput(i)),this):this},t.prototype.highlightAll=function(){var t=this;return this._store.withTxn((function(){t._store.items.forEach((function(e){e.highlighted||(t._store.dispatch(Xl(e,!0)),t.passedElement.triggerEvent(Tl,t._getChoiceForOutput(e)))}))})),this},t.prototype.unhighlightAll=function(){var t=this;return this._store.withTxn((function(){t._store.items.forEach((function(e){e.highlighted&&(t._store.dispatch(Xl(e,!1)),t.passedElement.triggerEvent(Tl,t._getChoiceForOutput(e)))}))})),this},t.prototype.removeActiveItemsByValue=function(t){var e=this;return this._store.withTxn((function(){e._store.items.filter((function(e){return e.value===t})).forEach((function(t){return e._removeItem(t)}))})),this},t.prototype.removeActiveItems=function(t){var e=this;return this._store.withTxn((function(){e._store.items.filter((function(e){return e.id!==t})).forEach((function(t){return e._removeItem(t)}))})),this},t.prototype.removeHighlightedItems=function(t){var e=this;return void 0===t&&(t=!1),this._store.withTxn((function(){e._store.highlightedActiveItems.forEach((function(i){e._removeItem(i),t&&e._triggerChange(i.value)}))})),this},t.prototype.showDropdown=function(t){var e=this;return this.dropdown.isActive||(void 0===t&&(t=!this._canSearch),requestAnimationFrame((function(){e.dropdown.show();var i=e.dropdown.element.getBoundingClientRect();e.containerOuter.open(i.bottom,i.height),t||e.input.focus(),e.passedElement.triggerEvent(_l)}))),this},t.prototype.hideDropdown=function(t){var e=this;return this.dropdown.isActive?(requestAnimationFrame((function(){e.dropdown.hide(),e.containerOuter.close(),!t&&e._canSearch&&(e.input.removeActiveDescendant(),e.input.blur()),e.passedElement.triggerEvent(bl)})),this):this},t.prototype.getValue=function(t){var e=this,i=this._store.items.map((function(i){return t?i.value:e._getChoiceForOutput(i)}));return this._isSelectOneElement||this.config.singleModeForMultiSelect?i[0]:i},t.prototype.setValue=function(t){var e=this;return this.initialisedOK?(this._store.withTxn((function(){t.forEach((function(t){t&&e._addChoice(gc(t,!1))}))})),this._searcher.reset(),this):(this._warnChoicesInitFailed("setValue"),this)},t.prototype.setChoiceByValue=function(t){var e=this;return this.initialisedOK?(this._isTextElement||(this._store.withTxn((function(){(Array.isArray(t)?t:[t]).forEach((function(t){return e._findAndSelectChoiceByValue(t)})),e.unhighlightAll()})),this._searcher.reset()),this):(this._warnChoicesInitFailed("setChoiceByValue"),this)},t.prototype.setChoices=function(t,e,i,s,r){var n=this;if(void 0===t&&(t=[]),void 0===e&&(e="value"),void 0===i&&(i="label"),void 0===s&&(s=!1),void 0===r&&(r=!0),!this.initialisedOK)return this._warnChoicesInitFailed("setChoices"),this;if(!this._isSelectElement)throw new TypeError("setChoices can't be used with INPUT based Choices");if("string"!=typeof e||!e)throw new TypeError("value parameter must be a name of 'value' field in passed objects");if(s&&this.clearChoices(),"function"==typeof t){var o=t(this);if("function"==typeof Promise&&o instanceof Promise)return new Promise((function(t){return requestAnimationFrame(t)})).then((function(){return n._handleLoadingState(!0)})).then((function(){return o})).then((function(t){return n.setChoices(t,e,i,s)})).catch((function(t){n.config.silent||console.error(t)})).then((function(){return n._handleLoadingState(!1)})).then((function(){return n}));if(!Array.isArray(o))throw new TypeError(".setChoices first argument function must return either array of choices or Promise, got: ".concat(typeof o));return this.setChoices(o,e,i,!1)}if(!Array.isArray(t))throw new TypeError(".setChoices must be called either with array of choices with a function resulting into Promise of array of choices");return this.containerOuter.removeLoadingState(),this._store.withTxn((function(){r&&(n._isSearching=!1);var s="value"===e,o="label"===i;t.forEach((function(t){if("choices"in t){var r=t;o||(r=ol(ol({},r),{label:r[i]})),n._addGroup(gc(r,!0))}else{var a=t;o&&s||(a=ol(ol({},a),{value:a[e],label:a[i]})),n._addChoice(gc(a,!1))}})),n.unhighlightAll()})),this._searcher.reset(),this},t.prototype.refresh=function(t,e,i){var s=this;return void 0===t&&(t=!1),void 0===e&&(e=!1),void 0===i&&(i=!1),this._isSelectElement?(this._store.withTxn((function(){var r=s.passedElement.optionsAsChoices(),n={};i||s._store.items.forEach((function(t){t.id&&t.active&&t.selected&&!t.disabled&&(n[t.value]=!0)})),s.clearStore(!1);var o=function(t){i?s._store.dispatch(Hl(t)):n[t.value]&&(t.selected=!0)};r.forEach((function(t){"choices"in t?t.choices.forEach(o):o(t)})),s._addPredefinedChoices(r,e,t),s._isSearching&&s._searchChoices(s.input.value)})),this):(this.config.silent||console.warn("refresh method can only be used on choices backed by a <select> element"),this)},t.prototype.removeChoice=function(t){var e=this._store.choices.find((function(e){return e.value===t}));return e?(this._clearNotice(),this._store.dispatch(Wl(e)),this._searcher.reset(),e.selected&&this.passedElement.triggerEvent(Sl,this._getChoiceForOutput(e)),this):this},t.prototype.clearChoices=function(){var t=this;return this._store.withTxn((function(){t._store.choices.forEach((function(e){e.selected||t._store.dispatch(Wl(e))}))})),this._searcher.reset(),this},t.prototype.clearStore=function(t){return void 0===t&&(t=!0),this._stopSearch(),t&&this.passedElement.element.replaceChildren(""),this.itemList.element.replaceChildren(""),this.choiceList.element.replaceChildren(""),this._clearNotice(),this._store.reset(),this._lastAddedChoiceId=0,this._lastAddedGroupId=0,this._searcher.reset(),this},t.prototype.clearInput=function(){var t=!this._isSelectOneElement;return this.input.clear(t),this._stopSearch(),this},t.prototype._validateConfig=function(){var t,e,i,s,r=this.config,n=(t=r,e=vc,i=Object.keys(t).sort(),s=Object.keys(e).sort(),i.filter((function(t){return s.indexOf(t)<0})));n.length&&console.warn("Unknown config option(s) passed",n.join(", ")),r.allowHTML&&r.allowHtmlUserInput&&(r.addItems&&console.warn("Warning: allowHTML/allowHtmlUserInput/addItems all being true is strongly not recommended and may lead to XSS attacks"),r.addChoices&&console.warn("Warning: allowHTML/allowHtmlUserInput/addChoices all being true is strongly not recommended and may lead to XSS attacks"))},t.prototype._render=function(t){void 0===t&&(t={choices:!0,groups:!0,items:!0}),this._store.inTxn()||(this._isSelectElement&&(t.choices||t.groups)&&this._renderChoices(),t.items&&this._renderItems())},t.prototype._renderChoices=function(){var t=this;if(this._canAddItems()){var e=this.config,i=this._isSearching,s=this._store,r=s.activeGroups,n=s.activeChoices,o=0;if(i&&e.searchResultLimit>0?o=e.searchResultLimit:e.renderChoiceLimit>0&&(o=e.renderChoiceLimit),this._isSelectElement){var a=n.filter((function(t){return!t.element}));a.length&&this.passedElement.addOptions(a)}var l=document.createDocumentFragment(),c=function(t){return t.filter((function(t){return!t.placeholder&&(i?!!t.rank:e.renderSelectedChoices||!t.selected)}))},h=!1,d=function(s,r,n){i?s.sort(tc):e.shouldSort&&s.sort(e.sorter);var a=s.length;a=!r&&o&&a>o?o:a,a--,s.every((function(s,r){var o=s.choiceEl||t._templates.choice(e,s,e.itemSelectText,n);return s.choiceEl=o,l.appendChild(o),s.disabled||!i&&s.selected||(h=!0),r<a}))};n.length&&(e.resetScrollPosition&&requestAnimationFrame((function(){return t.choiceList.scrollToTop()})),this._hasNonChoicePlaceholder||i||!this._isSelectOneElement||d(n.filter((function(t){return t.placeholder&&!t.group})),!1,void 0),r.length&&!i?(e.shouldSort&&r.sort(e.sorter),d(n.filter((function(t){return!t.placeholder&&!t.group})),!1,void 0),r.forEach((function(s){var r=c(s.choices);if(r.length){if(s.label){var n=s.groupEl||t._templates.choiceGroup(t.config,s);s.groupEl=n,n.remove(),l.appendChild(n)}d(r,!0,e.appendGroupInSearch&&i?s.label:void 0)}}))):d(c(n),!1,void 0)),h||(this._notice||(this._notice={text:Kl(i?e.noResultsText:e.noChoicesText),type:i?wc:xc}),l.replaceChildren("")),this._renderNotice(l),this.choiceList.element.replaceChildren(l),h&&this._highlightChoice()}},t.prototype._renderItems=function(){var t=this,e=this._store.items||[],i=this.itemList.element,s=this.config,r=document.createDocumentFragment(),n=function(t){return i.querySelector('[data-item][data-id="'.concat(t.id,'"]'))},o=function(e){var i=e.itemEl;i&&i.parentElement||(i=n(e)||t._templates.item(s,e,s.removeItemButton),e.itemEl=i,r.appendChild(i))};e.forEach(o);var a=!!r.childNodes.length;if(this._isSelectOneElement&&this._hasNonChoicePlaceholder){var l=i.children.length;if(a||l>1){var c=i.querySelector(ic(s.classNames.placeholder));c&&c.remove()}else l||(a=!0,o(gc({selected:!0,value:"",label:s.placeholderValue||"",placeholder:!0},!1)))}a&&(i.append(r),s.shouldSortItems&&!this._isSelectOneElement&&(e.sort(s.sorter),e.forEach((function(t){var e=n(t);e&&(e.remove(),r.append(e))})),i.append(r))),this._isTextElement&&(this.passedElement.value=e.map((function(t){return t.value})).join(s.delimiter))},t.prototype._displayNotice=function(t,e,i){void 0===i&&(i=!0);var s=this._notice;s&&(s.type===e&&s.text===t||s.type===Cc&&(e===wc||e===xc))?i&&this.showDropdown(!0):(this._clearNotice(),this._notice=t?{text:t,type:e}:void 0,this._renderNotice(),i&&t&&this.showDropdown(!0))},t.prototype._clearNotice=function(){if(this._notice){var t=this.choiceList.element.querySelector(ic(this.config.classNames.notice));t&&t.remove(),this._notice=void 0}},t.prototype._renderNotice=function(t){var e=this._notice;if(e){var i=this._templates.notice(this.config,e.text,e.type);t?t.append(i):this.choiceList.prepend(i)}},t.prototype._getChoiceForOutput=function(t,e){return{id:t.id,highlighted:t.highlighted,labelClass:t.labelClass,labelDescription:t.labelDescription,customProperties:t.customProperties,disabled:t.disabled,active:t.active,label:t.label,placeholder:t.placeholder,value:t.value,groupValue:t.group?t.group.label:void 0,element:t.element,keyCode:e}},t.prototype._triggerChange=function(t){null!=t&&this.passedElement.triggerEvent(yl,{value:t})},t.prototype._handleButtonAction=function(t){var e=this,i=this._store.items;if(i.length&&this.config.removeItems&&this.config.removeItemButton){var s=t&&Sh(t.parentElement),r=s&&i.find((function(t){return t.id===s}));r&&this._store.withTxn((function(){if(e._removeItem(r),e._triggerChange(r.value),e._isSelectOneElement&&!e._hasNonChoicePlaceholder){var t=e._store.choices.reverse().find((function(t){return!t.disabled&&t.placeholder}));t&&(e._addItem(t),e.unhighlightAll(),t.value&&e._triggerChange(t.value))}}))}},t.prototype._handleItemAction=function(t,e){var i=this;void 0===e&&(e=!1);var s=this._store.items;if(s.length&&this.config.removeItems&&!this._isSelectOneElement){var r=Sh(t);r&&(s.forEach((function(t){t.id!==r||t.highlighted?!e&&t.highlighted&&i.unhighlightItem(t):i.highlightItem(t)})),this.input.focus())}},t.prototype._handleChoiceAction=function(t){var e=this,i=Sh(t),s=i&&this._store.getChoiceById(i);if(!s||s.disabled)return!1;var r=this.dropdown.isActive;if(!s.selected){if(!this._canAddItems())return!0;this._store.withTxn((function(){e._addItem(s,!0,!0),e.clearInput(),e.unhighlightAll()})),this._triggerChange(s.value)}return r&&this.config.closeDropdownOnSelect&&(this.hideDropdown(!0),this.containerOuter.element.focus()),!0},t.prototype._handleBackspace=function(t){var e=this.config;if(e.removeItems&&t.length){var i=t[t.length-1],s=t.some((function(t){return t.highlighted}));e.editItems&&!s&&i?(this.input.value=i.value,this.input.setWidth(),this._removeItem(i),this._triggerChange(i.value)):(s||this.highlightItem(i,!1),this.removeHighlightedItems(!0))}},t.prototype._loadChoices=function(){var t,e=this,i=this.config;if(this._isTextElement){if(this._presetChoices=i.items.map((function(t){return gc(t,!1)})),this.passedElement.value){var s=this.passedElement.value.split(i.delimiter).map((function(t){return gc(t,!1,e.config.allowHtmlUserInput)}));this._presetChoices=this._presetChoices.concat(s)}this._presetChoices.forEach((function(t){t.selected=!0}))}else if(this._isSelectElement){this._presetChoices=i.choices.map((function(t){return gc(t,!0)}));var r=this.passedElement.optionsAsChoices();r&&(t=this._presetChoices).push.apply(t,r)}},t.prototype._handleLoadingState=function(t){void 0===t&&(t=!0);var e=this.itemList.element;t?(this.disable(),this.containerOuter.addLoadingState(),this._isSelectOneElement?e.replaceChildren(this._templates.placeholder(this.config,this.config.loadingText)):this.input.placeholder=this.config.loadingText):(this.enable(),this.containerOuter.removeLoadingState(),this._isSelectOneElement?(e.replaceChildren(""),this._render()):this.input.placeholder=this._placeholderValue||"")},t.prototype._handleSearch=function(t){if(this.input.isFocussed)if(null!=t&&t.length>=this.config.searchFloor){var e=this.config.searchChoices?this._searchChoices(t):0;null!==e&&this.passedElement.triggerEvent(wl,{value:t,resultCount:e})}else this._store.choices.some((function(t){return!t.active}))&&this._stopSearch()},t.prototype._canAddItems=function(){var t=this.config,e=t.maxItemCount,i=t.maxItemText;return!(!t.singleModeForMultiSelect&&e>0&&e<=this._store.items.length)||(this.choiceList.element.replaceChildren(""),this._notice=void 0,this._displayNotice("function"==typeof i?i(e):i,Cc),!1)},t.prototype._canCreateItem=function(t){var e=this.config,i=!0,s="";if(i&&"function"==typeof e.addItemFilter&&!e.addItemFilter(t)&&(i=!1,s=ql(e.customAddItemText,t)),i){var r=this._store.choices.find((function(i){return e.valueComparer(i.value,t)}));if(this._isSelectElement){if(r)return this._displayNotice("",Cc),!1}else this._isTextElement&&!e.duplicateItemsAllowed&&r&&(i=!1,s=ql(e.uniqueItemText,t))}return i&&(s=ql(e.addItemText,t)),s&&this._displayNotice(s,Cc),i},t.prototype._searchChoices=function(t){var e=t.trim().replace(/\s{2,}/," ");if(!e.length||e===this._currentValue)return null;var i=this._searcher;i.isEmptyIndex()&&i.index(this._store.searchableChoices);var s=i.search(e);this._currentValue=e,this._highlightPosition=0,this._isSearching=!0;var r=this._notice;return(r&&r.type)!==Cc&&(s.length?this._clearNotice():this._displayNotice(Kl(this.config.noResultsText),wc)),this._store.dispatch(function(t){return{type:dl,results:t}}(s)),s.length},t.prototype._stopSearch=function(){this._isSearching&&(this._currentValue="",this._isSearching=!1,this._clearNotice(),this._store.dispatch({type:ul,active:!0}),this.passedElement.triggerEvent(wl,{value:"",resultCount:0}))},t.prototype._addEventListeners=function(){var t=this._docRoot,e=this.containerOuter.element,i=this.input.element;t.addEventListener("touchend",this._onTouchEnd,!0),e.addEventListener("keydown",this._onKeyDown,!0),e.addEventListener("mousedown",this._onMouseDown,!0),t.addEventListener("click",this._onClick,{passive:!0}),t.addEventListener("touchmove",this._onTouchMove,{passive:!0}),this.dropdown.element.addEventListener("mouseover",this._onMouseOver,{passive:!0}),this._isSelectOneElement&&(e.addEventListener("focus",this._onFocus,{passive:!0}),e.addEventListener("blur",this._onBlur,{passive:!0})),i.addEventListener("keyup",this._onKeyUp,{passive:!0}),i.addEventListener("input",this._onInput,{passive:!0}),i.addEventListener("focus",this._onFocus,{passive:!0}),i.addEventListener("blur",this._onBlur,{passive:!0}),i.form&&i.form.addEventListener("reset",this._onFormReset,{passive:!0}),this.input.addEventListeners()},t.prototype._removeEventListeners=function(){var t=this._docRoot,e=this.containerOuter.element,i=this.input.element;t.removeEventListener("touchend",this._onTouchEnd,!0),e.removeEventListener("keydown",this._onKeyDown,!0),e.removeEventListener("mousedown",this._onMouseDown,!0),t.removeEventListener("click",this._onClick),t.removeEventListener("touchmove",this._onTouchMove),this.dropdown.element.removeEventListener("mouseover",this._onMouseOver),this._isSelectOneElement&&(e.removeEventListener("focus",this._onFocus),e.removeEventListener("blur",this._onBlur)),i.removeEventListener("keyup",this._onKeyUp),i.removeEventListener("input",this._onInput),i.removeEventListener("focus",this._onFocus),i.removeEventListener("blur",this._onBlur),i.form&&i.form.removeEventListener("reset",this._onFormReset),this.input.removeEventListeners()},t.prototype._onKeyDown=function(t){var e=t.keyCode,i=this.dropdown.isActive,s=1===t.key.length||2===t.key.length&&t.key.charCodeAt(0)>=55296||"Unidentified"===t.key;switch(this._isTextElement||i||e===Ll||e===kl||e===Dl||(this.showDropdown(),!this.input.isFocussed&&s&&(this.input.value+=t.key," "===t.key&&t.preventDefault())),e){case jl:return this._onSelectKey(t,this.itemList.element.hasChildNodes());case Pl:return this._onEnterKey(t,i);case Ll:return this._onEscapeKey(t,i);case Fl:case Rl:case Il:case Bl:return this._onDirectionKey(t,i);case Ml:case Al:return this._onDeleteKey(t,this._store.items,this.input.isFocussed)}},t.prototype._onKeyUp=function(){this._canSearch=this.config.searchEnabled},t.prototype._onInput=function(){var t=this.input.value;t?this._canAddItems()&&(this._canSearch&&this._handleSearch(t),this._canAddUserChoices&&(this._canCreateItem(t),this._isSelectElement&&(this._highlightPosition=0,this._highlightChoice()))):this._isTextElement?this.hideDropdown(!0):this._stopSearch()},t.prototype._onSelectKey=function(t,e){(t.ctrlKey||t.metaKey)&&e&&(this._canSearch=!1,this.config.removeItems&&!this.input.value&&this.input.element===document.activeElement&&this.highlightAll())},t.prototype._onEnterKey=function(t,e){var i=this,s=this.input.value,r=t.target;if(t.preventDefault(),r&&r.hasAttribute("data-button"))this._handleButtonAction(r);else if(e){var n=this.dropdown.element.querySelector(ic(this.config.classNames.highlightedState));if(!n||!this._handleChoiceAction(n))if(r&&s){if(this._canAddItems()){var o=!1;this._store.withTxn((function(){if(!(o=i._findAndSelectChoiceByValue(s,!0))){if(!i._canAddUserChoices)return;if(!i._canCreateItem(s))return;i._addChoice(gc(s,!1,i.config.allowHtmlUserInput),!0,!0),o=!0}i.clearInput(),i.unhighlightAll()})),o&&(this._triggerChange(s),this.config.closeDropdownOnSelect&&this.hideDropdown(!0))}}else this.hideDropdown(!0)}else(this._isSelectElement||this._notice)&&this.showDropdown()},t.prototype._onEscapeKey=function(t,e){e&&(t.stopPropagation(),this.hideDropdown(!0),this._stopSearch(),this.containerOuter.element.focus())},t.prototype._onDirectionKey=function(t,e){var i,s,r,n=t.keyCode;if(e||this._isSelectOneElement){this.showDropdown(),this._canSearch=!1;var o=n===Il||n===Bl?1:-1,a=void 0;if(t.metaKey||n===Bl||n===Rl)a=o>0?this.dropdown.element.querySelector("".concat(Th,":last-of-type")):this.dropdown.element.querySelector(Th);else{var l=this.dropdown.element.querySelector(ic(this.config.classNames.highlightedState));a=l?function(t,e,i){void 0===i&&(i=1);for(var s="".concat(i>0?"next":"previous","ElementSibling"),r=t[s];r;){if(r.matches(e))return r;r=r[s]}return null}(l,Th,o):this.dropdown.element.querySelector(Th)}a&&(i=a,s=this.choiceList.element,void 0===(r=o)&&(r=1),(r>0?s.scrollTop+s.offsetHeight>=i.offsetTop+i.offsetHeight:i.offsetTop>=s.scrollTop)||this.choiceList.scrollToChildElement(a,o),this._highlightChoice(a)),t.preventDefault()}},t.prototype._onDeleteKey=function(t,e,i){this._isSelectOneElement||t.target.value||!i||(this._handleBackspace(e),t.preventDefault())},t.prototype._onTouchMove=function(){this._wasTap&&(this._wasTap=!1)},t.prototype._onTouchEnd=function(t){var e=(t||t.touches[0]).target;this._wasTap&&this.containerOuter.element.contains(e)&&((e===this.containerOuter.element||e===this.containerInner.element)&&(this._isTextElement?this.input.focus():this._isSelectMultipleElement&&this.showDropdown()),t.stopPropagation());this._wasTap=!0},t.prototype._onMouseDown=function(t){var e=t.target;if(e instanceof HTMLElement){if(wh&&this.choiceList.element.contains(e)){var i=this.choiceList.element.firstElementChild;this._isScrollingOnIe="ltr"===this._direction?t.offsetX>=i.offsetWidth:t.offsetX<i.offsetLeft}if(e!==this.input.element){var s=e.closest("[data-button],[data-item],[data-choice]");s instanceof HTMLElement&&("button"in s.dataset?this._handleButtonAction(s):"item"in s.dataset?this._handleItemAction(s,t.shiftKey):"choice"in s.dataset&&this._handleChoiceAction(s)),t.preventDefault()}}},t.prototype._onMouseOver=function(t){var e=t.target;e instanceof HTMLElement&&"choice"in e.dataset&&this._highlightChoice(e)},t.prototype._onClick=function(t){var e=t.target,i=this.containerOuter;i.element.contains(e)?this.dropdown.isActive||i.isDisabled?this._isSelectOneElement&&e!==this.input.element&&!this.dropdown.element.contains(e)&&this.hideDropdown():this._isTextElement?document.activeElement!==this.input.element&&this.input.focus():(this.showDropdown(),i.element.focus()):(i.removeFocusState(),this.hideDropdown(!0),this.unhighlightAll())},t.prototype._onFocus=function(t){var e=t.target,i=this.containerOuter;if(e&&i.element.contains(e)){var s=e===this.input.element;this._isTextElement?s&&i.addFocusState():this._isSelectMultipleElement?s&&(this.showDropdown(!0),i.addFocusState()):(i.addFocusState(),s&&this.showDropdown(!0))}},t.prototype._onBlur=function(t){var e=t.target,i=this.containerOuter;e&&i.element.contains(e)&&!this._isScrollingOnIe?e===this.input.element?(i.removeFocusState(),this.hideDropdown(!0),(this._isTextElement||this._isSelectMultipleElement)&&this.unhighlightAll()):e===this.containerOuter.element&&i.removeFocusState():(this._isScrollingOnIe=!1,this.input.element.focus())},t.prototype._onFormReset=function(){var t=this;this._store.withTxn((function(){t.clearInput(),t.hideDropdown(),t.refresh(!1,!1,!0),t._initialItems.length&&t.setChoiceByValue(t._initialItems)}))},t.prototype._highlightChoice=function(t){void 0===t&&(t=null);var e=Array.from(this.dropdown.element.querySelectorAll(Th));if(e.length){var i=t,s=this.config.classNames.highlightedState;Array.from(this.dropdown.element.querySelectorAll(ic(s))).forEach((function(t){rc(t,s),t.setAttribute("aria-selected","false")})),i?this._highlightPosition=e.indexOf(i):(i=e.length>this._highlightPosition?e[this._highlightPosition]:e[e.length-1])||(i=e[0]),sc(i,s),i.setAttribute("aria-selected","true"),this.passedElement.triggerEvent(Ol,{el:i}),this.dropdown.isActive&&(this.input.setActiveDescendant(i.id),this.containerOuter.setActiveDescendant(i.id))}},t.prototype._addItem=function(t,e,i){if(void 0===e&&(e=!0),void 0===i&&(i=!1),!t.id)throw new TypeError("item.id must be set before _addItem is called for a choice/item");(this.config.singleModeForMultiSelect||this._isSelectOneElement)&&this.removeActiveItems(t.id),this._store.dispatch(function(t){return{type:fl,item:t}}(t)),e&&(this.passedElement.triggerEvent(Cl,this._getChoiceForOutput(t)),i&&this.passedElement.triggerEvent(xl,this._getChoiceForOutput(t)))},t.prototype._removeItem=function(t){if(t.id){this._store.dispatch(Hl(t));var e=this._notice;e&&e.type===xc&&this._clearNotice(),this.passedElement.triggerEvent(Sl,this._getChoiceForOutput(t))}},t.prototype._addChoice=function(t,e,i){if(void 0===e&&(e=!0),void 0===i&&(i=!1),t.id)throw new TypeError("Can not re-add a choice which has already been added");var s=this.config;if(!this._isSelectElement&&s.duplicateItemsAllowed||!this._store.choices.find((function(e){return s.valueComparer(e.value,t.value)}))){this._lastAddedChoiceId++,t.id=this._lastAddedChoiceId,t.elementId="".concat(this._baseId,"-").concat(this._idNames.itemChoice,"-").concat(t.id);var r=s.prependValue,n=s.appendValue;r&&(t.value=r+t.value),n&&(t.value+=n.toString()),(r||n)&&t.element&&(t.element.value=t.value),this._clearNotice(),this._store.dispatch(function(t){return{type:cl,choice:t}}(t)),t.selected&&this._addItem(t,e,i)}},t.prototype._addGroup=function(t,e){var i=this;if(void 0===e&&(e=!0),t.id)throw new TypeError("Can not re-add a group which has already been added");this._store.dispatch(function(t){return{type:gl,group:t}}(t)),t.choices&&(this._lastAddedGroupId++,t.id=this._lastAddedGroupId,t.choices.forEach((function(s){s.group=t,t.disabled&&(s.disabled=!0),i._addChoice(s,e)})))},t.prototype._createTemplates=function(){var t=this,e=this.config.callbackOnCreateTemplates,i={};"function"==typeof e&&(i=e.call(this,Gl,Zl,ec));var s={};Object.keys(this._templates).forEach((function(e){s[e]=e in i?i[e].bind(t):t._templates[e].bind(t)})),this._templates=s},t.prototype._createElements=function(){var t=this._templates,e=this.config,i=this._isSelectOneElement,s=e.position,r=e.classNames,n=this._elementType;this.containerOuter=new ac({element:t.containerOuter(e,this._direction,this._isSelectElement,i,e.searchEnabled,n,e.labelId),classNames:r,type:n,position:s}),this.containerInner=new ac({element:t.containerInner(e),classNames:r,type:n,position:s}),this.input=new lc({element:t.input(e,this._placeholderValue),classNames:r,type:n,preventPaste:!e.paste}),this.choiceList=new cc({element:t.choiceList(e,i)}),this.itemList=new cc({element:t.itemList(e,i)}),this.dropdown=new oc({element:t.dropdown(e),classNames:r,type:n})},t.prototype._createStructure=function(){var t=this,e=t.containerInner,i=t.containerOuter,s=t.passedElement,r=this.dropdown.element;s.conceal(),e.wrap(s.element),i.wrap(e.element),this._isSelectOneElement?this.input.placeholder=this.config.searchPlaceholderValue||"":(this._placeholderValue&&(this.input.placeholder=this._placeholderValue),this.input.setWidth()),i.element.appendChild(e.element),i.element.appendChild(r),e.element.appendChild(this.itemList.element),r.appendChild(this.choiceList.element),this._isSelectOneElement?this.config.searchEnabled&&r.insertBefore(this.input.element,r.firstChild):e.element.appendChild(this.input.element),this._highlightPosition=0,this._isSearching=!1},t.prototype._initStore=function(){var t=this;this._store.subscribe(this._render).withTxn((function(){t._addPredefinedChoices(t._presetChoices,t._isSelectOneElement&&!t._hasNonChoicePlaceholder,!1)})),(!this._store.choices.length||this._isSelectOneElement&&this._hasNonChoicePlaceholder)&&this._render()},t.prototype._addPredefinedChoices=function(t,e,i){var s=this;(void 0===e&&(e=!1),void 0===i&&(i=!0),e)&&(-1===t.findIndex((function(t){return t.selected}))&&t.some((function(t){return!t.disabled&&!("choices"in t)&&(t.selected=!0,!0)})));t.forEach((function(t){"choices"in t?s._isSelectElement&&s._addGroup(t,i):s._addChoice(t,i)}))},t.prototype._findAndSelectChoiceByValue=function(t,e){var i=this;void 0===e&&(e=!1);var s=this._store.choices.find((function(e){return i.config.valueComparer(e.value,t)}));return!(!s||s.disabled||s.selected)&&(this._addItem(s,!0,e),!0)},t.prototype._generatePlaceholderValue=function(){var t=this.config;if(!t.placeholder)return null;if(this._hasNonChoicePlaceholder)return t.placeholderValue;if(this._isSelectElement){var e=this.passedElement.placeholderOption;return e?e.text:null}return null},t.prototype._warnChoicesInitFailed=function(t){if(!this.config.silent){if(!this.initialised)throw new TypeError("".concat(t," called on a non-initialised instance of Choices"));if(!this.initialisedOK)throw new TypeError("".concat(t," called for an element which has multiple instances of Choices initialised on it"))}},t.version="11.0.3",t}();var Eh=Object.defineProperty,kh=Object.getOwnPropertyDescriptor,Dh=(t,e,i,s)=>{for(var r,n=s>1?void 0:s?kh(e,i):e,o=t.length-1;o>=0;o--)(r=t[o])&&(n=(s?r(e,i,n):r(n))||n);return s&&n&&Eh(e,i,n),n};t.PboSelector=class extends at{constructor(){super(...arguments),this.fonts=[{value:"comic",label:"🖊️ Comic Sans",font:"'Comic Sans MS', cursive"},{value:"times",label:"🔤 Times New Roman",font:"'Times New Roman', serif"},{value:"arial",label:"📜 Arial",font:"'Arial', sans-serif"},{value:"mono",label:"💻 Monospace",font:"'Courier New', monospace"}],this.updated=t=>{t.has("fonts")&&this._initializeChoices()}}get value(){var t;return null==(t=this._choices)?void 0:t.getValue().value}firstUpdated(){this._initializeChoices()}_initializeChoices(){var t;null==(t=this._choices)||t.destroy(),this._choices=new Oh(this.choiceEl,{allowHTML:!0,searchEnabled:!1,shouldSort:!1,removeItemButton:!1,shadowRoot:this.shadowRoot,choices:this.fonts.map(((t,e)=>({value:t.value,label:t.label,customProperties:{font:t.font},selected:0===e}))),placeholder:!1,shouldSortItems:!1}),this.choiceEl.addEventListener("change",(t=>{const e=t.target;this.dispatchEvent(new CustomEvent("pbo-change",{detail:{value:e.value},bubbles:!0,composed:!0}))}))}render(){return H`<select part="base" class="js-choice"></select>`}},t.PboSelector.styles=[il,sl,a('.choices{position:relative;overflow:hidden;margin-bottom:24px;font-size:16px}.choices:focus{outline:none}.choices:last-child{margin-bottom:0}.choices.is-open{overflow:visible}.choices.is-disabled .choices__inner,.choices.is-disabled .choices__input{background-color:#eaeaea;cursor:not-allowed;-webkit-user-select:none;user-select:none}.choices.is-disabled .choices__item{cursor:not-allowed}.choices [hidden]{display:none!important}.choices[data-type*=select-one]{cursor:pointer}.choices[data-type*=select-one] .choices__inner{padding-bottom:7.5px}.choices[data-type*=select-one] .choices__input{display:block;width:100%;padding:10px;border-bottom:1px solid #ddd;background-color:#fff;margin:0}.choices[data-type*=select-one] .choices__button{background-image:url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMjEiIGhlaWdodD0iMjEiIHZpZXdCb3g9IjAgMCAyMSAyMSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj48ZyBmaWxsPSIjMDAwIiBmaWxsLXJ1bGU9ImV2ZW5vZGQiPjxwYXRoIGQ9Ik0yLjU5Mi4wNDRsMTguMzY0IDE4LjM2NC0yLjU0OCAyLjU0OEwuMDQ0IDIuNTkyeiIvPjxwYXRoIGQ9Ik0wIDE4LjM2NEwxOC4zNjQgMGwyLjU0OCAyLjU0OEwyLjU0OCAyMC45MTJ6Ii8+PC9nPjwvc3ZnPg==);padding:0;background-size:8px;position:absolute;top:50%;right:0;margin-top:-10px;margin-right:25px;height:20px;width:20px;border-radius:10em;opacity:.25}.choices[data-type*=select-one] .choices__button:hover,.choices[data-type*=select-one] .choices__button:focus{opacity:1}.choices[data-type*=select-one] .choices__button:focus{box-shadow:0 0 0 2px #005f75}.choices[data-type*=select-one] .choices__item[data-placeholder] .choices__button{display:none}.choices[data-type*=select-one]:after{content:"";height:0;width:0;border-style:solid;border-color:#333 transparent transparent transparent;border-width:5px;position:absolute;right:11.5px;top:50%;margin-top:-2.5px;pointer-events:none}.choices[data-type*=select-one].is-open:after{border-color:transparent transparent #333;margin-top:-7.5px}.choices[data-type*=select-one][dir=rtl]:after{left:11.5px;right:auto}.choices[data-type*=select-one][dir=rtl] .choices__button{right:auto;left:0;margin-left:25px;margin-right:0}.choices[data-type*=select-multiple] .choices__inner,.choices[data-type*=text] .choices__inner{cursor:text}.choices[data-type*=select-multiple] .choices__button,.choices[data-type*=text] .choices__button{position:relative;display:inline-block;margin:0 -4px 0 8px;padding-left:16px;border-left:1px solid #003642;background-image:url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMjEiIGhlaWdodD0iMjEiIHZpZXdCb3g9IjAgMCAyMSAyMSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj48ZyBmaWxsPSIjRkZGIiBmaWxsLXJ1bGU9ImV2ZW5vZGQiPjxwYXRoIGQ9Ik0yLjU5Mi4wNDRsMTguMzY0IDE4LjM2NC0yLjU0OCAyLjU0OEwuMDQ0IDIuNTkyeiIvPjxwYXRoIGQ9Ik0wIDE4LjM2NEwxOC4zNjQgMGwyLjU0OCAyLjU0OEwyLjU0OCAyMC45MTJ6Ii8+PC9nPjwvc3ZnPg==);background-size:8px;width:8px;line-height:1;opacity:.75;border-radius:0}.choices[data-type*=select-multiple] .choices__button:hover,.choices[data-type*=select-multiple] .choices__button:focus,.choices[data-type*=text] .choices__button:hover,.choices[data-type*=text] .choices__button:focus{opacity:1}.choices__inner{display:inline-block;vertical-align:top;width:100%;background-color:#f9f9f9;padding:7.5px 7.5px 3.75px;border:1px solid #ddd;border-radius:2.5px;font-size:14px;min-height:44px;overflow:hidden}.is-focused .choices__inner,.is-open .choices__inner{border-color:#b7b7b7}.is-open .choices__inner{border-radius:2.5px 2.5px 0 0}.is-flipped.is-open .choices__inner{border-radius:0 0 2.5px 2.5px}.choices__list{margin:0;padding-left:0;list-style:none}.choices__list--single{display:inline-block;padding:4px 16px 4px 4px;width:100%}[dir=rtl] .choices__list--single{padding-right:4px;padding-left:16px}.choices__list--single .choices__item{width:100%}.choices__list--multiple{display:inline}.choices__list--multiple .choices__item{display:inline-block;vertical-align:middle;border-radius:20px;padding:4px 10px;font-size:12px;font-weight:500;margin-right:3.75px;margin-bottom:3.75px;background-color:#005f75;border:1px solid #004a5c;color:#fff;word-break:break-all;box-sizing:border-box}.choices__list--multiple .choices__item[data-deletable]{padding-right:5px}[dir=rtl] .choices__list--multiple .choices__item{margin-right:0;margin-left:3.75px}.choices__list--multiple .choices__item.is-highlighted{background-color:#004a5c;border:1px solid #003642}.is-disabled .choices__list--multiple .choices__item{background-color:#aaa;border:1px solid #919191}.choices__list--dropdown,.choices__list[aria-expanded]{display:none;z-index:1;position:absolute;width:100%;background-color:#fff;border:1px solid #ddd;top:100%;margin-top:-1px;border-bottom-left-radius:2.5px;border-bottom-right-radius:2.5px;overflow:hidden;word-break:break-all}.is-active.choices__list--dropdown,.is-active.choices__list[aria-expanded]{display:block}.is-open .choices__list--dropdown,.is-open .choices__list[aria-expanded]{border-color:#b7b7b7}.is-flipped .choices__list--dropdown,.is-flipped .choices__list[aria-expanded]{top:auto;bottom:100%;margin-top:0;margin-bottom:-1px;border-radius:.25rem .25rem 0 0}.choices__list--dropdown .choices__list,.choices__list[aria-expanded] .choices__list{position:relative;max-height:300px;overflow:auto;-webkit-overflow-scrolling:touch;will-change:scroll-position}.choices__list--dropdown .choices__item,.choices__list[aria-expanded] .choices__item{position:relative;padding:10px;font-size:14px}[dir=rtl] .choices__list--dropdown .choices__item,[dir=rtl] .choices__list[aria-expanded] .choices__item{text-align:right}@media (min-width: 640px){.choices__list--dropdown .choices__item--selectable[data-select-text],.choices__list[aria-expanded] .choices__item--selectable[data-select-text]{padding-right:100px}.choices__list--dropdown .choices__item--selectable[data-select-text]:after,.choices__list[aria-expanded] .choices__item--selectable[data-select-text]:after{content:attr(data-select-text);font-size:12px;opacity:0;position:absolute;right:10px;top:50%;transform:translateY(-50%)}[dir=rtl] .choices__list--dropdown .choices__item--selectable[data-select-text],[dir=rtl] .choices__list[aria-expanded] .choices__item--selectable[data-select-text]{text-align:right;padding-left:100px;padding-right:10px}[dir=rtl] .choices__list--dropdown .choices__item--selectable[data-select-text]:after,[dir=rtl] .choices__list[aria-expanded] .choices__item--selectable[data-select-text]:after{right:auto;left:10px}}.choices__list--dropdown .choices__item--selectable.is-highlighted,.choices__list[aria-expanded] .choices__item--selectable.is-highlighted{background-color:#f2f2f2}.choices__list--dropdown .choices__item--selectable.is-highlighted:after,.choices__list[aria-expanded] .choices__item--selectable.is-highlighted:after{opacity:.5}.choices__item{cursor:default}.choices__item--selectable{cursor:pointer}.choices__item--disabled{cursor:not-allowed;-webkit-user-select:none;user-select:none;opacity:.5}.choices__heading{font-weight:600;font-size:12px;padding:10px;border-bottom:1px solid #f7f7f7;color:gray}.choices__button{text-indent:-9999px;-webkit-appearance:none;-moz-appearance:none;appearance:none;border:0;background-color:transparent;background-repeat:no-repeat;background-position:center;cursor:pointer}.choices__button:focus{outline:none}.choices__input{display:inline-block;vertical-align:baseline;background-color:#f9f9f9;font-size:14px;margin-bottom:5px;border:0;border-radius:0;max-width:100%;padding:4px 0 4px 2px}.choices__input:focus{outline:0}.choices__input::-webkit-search-decoration,.choices__input::-webkit-search-cancel-button,.choices__input::-webkit-search-results-button,.choices__input::-webkit-search-results-decoration{display:none}.choices__input::-ms-clear,.choices__input::-ms-reveal{display:none;width:0;height:0}[dir=rtl] .choices__input{padding-right:2px;padding-left:0}.choices__placeholder{opacity:.5}')],Dh([ut({type:Array})],t.PboSelector.prototype,"fonts",2),Dh([ft(".js-choice")],t.PboSelector.prototype,"choiceEl",2),t.PboSelector=Dh([ct("pbo-selector")],t.PboSelector);const Ah=l`
691
200
  /* --------------------------------- default -------------------------------- */
692
201
 
693
202
  :host {
@@ -957,36 +466,33 @@ good aklsdfja`,this.alignment="left",this.fontFamily="Arial",this.color="#000",t
957
466
  width: var(--sl-input-height-large);
958
467
  border-radius: 50%;
959
468
  }
960
- `;/**
961
- * @license
962
- * Copyright 2020 Google LLC
963
- * SPDX-License-Identifier: BSD-3-Clause
964
- */const ph=Symbol.for(""),dm=n=>{if((n==null?void 0:n.r)===ph)return n==null?void 0:n._$litStatic$},mh=(n,...t)=>({_$litStatic$:t.reduce((e,i,s)=>e+(r=>{if(r._$litStatic$!==void 0)return r._$litStatic$;throw Error(`Value passed to 'literal' function must be a 'literal' result: ${r}. Use 'unsafeStatic' to pass non-literal values, but
965
- take care to ensure page security.`)})(i)+n[s+1],n[0]),r:ph}),vh=new Map,fm=n=>(t,...e)=>{const i=e.length;let s,r;const o=[],a=[];let l,c=0,h=!1;for(;c<i;){for(l=t[c];c<i&&(r=e[c],(s=dm(r))!==void 0);)l+=s+t[++c],h=!0;c!==i&&a.push(r),o.push(l),c++}if(c===i&&o.push(t[i]),h){const u=o.join("$$lit$$");(t=vh.get(u))===void 0&&(o.raw=o,vh.set(u,t=o)),e=a}return n(t,...e)},gm=fm(St);/**
966
- * @license
967
- * Copyright 2017 Google LLC
968
- * SPDX-License-Identifier: BSD-3-Clause
969
- */const ui={ATTRIBUTE:1,PROPERTY:3,BOOLEAN_ATTRIBUTE:4},ua=n=>(...t)=>({_$litDirective$:n,values:t});let da=class{constructor(t){}get _$AU(){return this._$AM._$AU}_$AT(t,e,i){this._$Ct=t,this._$AM=e,this._$Ci=i}_$AS(t,e){return this.update(t,e)}update(t,e){return this.render(...e)}};/**
970
- * @license
971
- * Copyright 2018 Google LLC
972
- * SPDX-License-Identifier: BSD-3-Clause
973
- */const cs=ua(class extends da{constructor(n){var t;if(super(n),n.type!==ui.ATTRIBUTE||n.name!=="class"||((t=n.strings)==null?void 0:t.length)>2)throw Error("`classMap()` can only be used in the `class` attribute and must be the only part in the attribute.")}render(n){return" "+Object.keys(n).filter(t=>n[t]).join(" ")+" "}update(n,[t]){var i,s;if(this.st===void 0){this.st=new Set,n.strings!==void 0&&(this.nt=new Set(n.strings.join(" ").split(/\s/).filter(r=>r!=="")));for(const r in t)t[r]&&!((i=this.nt)!=null&&i.has(r))&&this.st.add(r);return this.render(t)}const e=n.element.classList;for(const r of this.st)r in t||(e.remove(r),this.st.delete(r));for(const r in t){const o=!!t[r];o===this.st.has(r)||(s=this.nt)!=null&&s.has(r)||(o?(e.add(r),this.st.add(r)):(e.remove(r),this.st.delete(r)))}return Jt}});class fa{constructor(t,...e){this.slotNames=[],this.handleSlotChange=i=>{const s=i.target;(this.slotNames.includes("[default]")&&!s.name||s.name&&this.slotNames.includes(s.name))&&this.host.requestUpdate()},(this.host=t).addController(this),this.slotNames=e}hasDefaultSlot(){return[...this.host.childNodes].some(t=>{var e;if(t.nodeType===t.TEXT_NODE&&((e=t.textContent)==null?void 0:e.trim())!=="")return!0;if(t.nodeType===t.ELEMENT_NODE){const i=t;if(i.tagName.toLowerCase()==="pbo-visually-hidden")return!1;if(!i.hasAttribute("slot"))return!0}return!1})}hasNamedSlot(t){return this.host.querySelector(`:scope > [slot="${t}]`)!==null}test(t){return t==="[default]"?this.hasDefaultSlot():this.hasNamedSlot(t)}hostConnected(){this.host.shadowRoot.addEventListener("slotchange",this.handleSlotChange)}hostDisconnected(){this.host.shadowRoot.removeEventListener("slotchange",this.handleSlotChange)}}var pm=Object.defineProperty,mm=Object.getOwnPropertyDescriptor,di=(n,t,e,i)=>{for(var s=i>1?void 0:i?mm(t,e):t,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(t,e,s):o(s))||s);return i&&s&&pm(t,e,s),s};let ee=class extends ae{constructor(){super(...arguments),this.hasSlotController=new fa(this,"[prefix]","prefix","suffix"),this.href="",this.name="",this.value="",this.variant="default",this.outline=!1,this.size="medium",this.circle=!1}isButton(){return!this.href}isLink(){return!!this.href}firstUpdated(t){var e,i;console.log({componentStyles:Vt,styles:ha}),console.log("Has default slot:",this.hasSlotController.test("[default]")),console.log("Button classes:",(i=(e=this.shadowRoot)==null?void 0:e.querySelector(".button"))==null?void 0:i.classList)}render(){const e=this.isLink()?mh`a`:mh`button`;return gm`
974
- <${e}
469
+ `
470
+ /**
471
+ * @license
472
+ * Copyright 2020 Google LLC
473
+ * SPDX-License-Identifier: BSD-3-Clause
474
+ */,Mh=Symbol.for(""),Ph=t=>{if((null==t?void 0:t.r)===Mh)return null==t?void 0:t._$litStatic$},jh=(t,...e)=>({_$litStatic$:e.reduce(((e,i,s)=>e+(t=>{if(void 0!==t._$litStatic$)return t._$litStatic$;throw Error(`Value passed to 'literal' function must be a 'literal' result: ${t}. Use 'unsafeStatic' to pass non-literal values, but\n take care to ensure page security.`)})(i)+t[s+1]),t[0]),r:Mh}),Lh=new Map,Fh=(t=>(e,...i)=>{const s=i.length;let r,n;const o=[],a=[];let l,c=0,h=!1;for(;c<s;){for(l=e[c];c<s&&void 0!==(n=i[c],r=Ph(n));)l+=r+e[++c],h=!0;c!==s&&a.push(n),o.push(l),c++}if(c===s&&o.push(e[s]),h){const t=o.join("$$lit$$");void 0===(e=Lh.get(t))&&(o.raw=o,Lh.set(t,e=o)),i=a}return t(e,...i)})(H),Ih=1,Rh=3,Bh=4,Nh=t=>(...e)=>({_$litDirective$:t,values:e});let zh=class{constructor(t){}get _$AU(){return this._$AM._$AU}_$AT(t,e,i){this._$Ct=t,this._$AM=e,this._$Ci=i}_$AS(t,e){return this.update(t,e)}update(t,e){return this.render(...e)}};
475
+ /**
476
+ * @license
477
+ * Copyright 2018 Google LLC
478
+ * SPDX-License-Identifier: BSD-3-Clause
479
+ */const Vh=Nh(class extends zh{constructor(t){var e;if(super(t),t.type!==Ih||"class"!==t.name||(null==(e=t.strings)?void 0:e.length)>2)throw Error("`classMap()` can only be used in the `class` attribute and must be the only part in the attribute.")}render(t){return" "+Object.keys(t).filter((e=>t[e])).join(" ")+" "}update(t,[e]){var i,s;if(void 0===this.st){this.st=new Set,void 0!==t.strings&&(this.nt=new Set(t.strings.join(" ").split(/\s/).filter((t=>""!==t))));for(const t in e)e[t]&&!(null==(i=this.nt)?void 0:i.has(t))&&this.st.add(t);return this.render(e)}const r=t.element.classList;for(const n of this.st)n in e||(r.remove(n),this.st.delete(n));for(const n in e){const t=!!e[n];t===this.st.has(n)||(null==(s=this.nt)?void 0:s.has(n))||(t?(r.add(n),this.st.add(n)):(r.remove(n),this.st.delete(n)))}return X}});class $h{constructor(t,...e){this.slotNames=[],this.handleSlotChange=t=>{const e=t.target;(this.slotNames.includes("[default]")&&!e.name||e.name&&this.slotNames.includes(e.name))&&this.host.requestUpdate()},(this.host=t).addController(this),this.slotNames=e}hasDefaultSlot(){return[...this.host.childNodes].some((t=>{var e;if(t.nodeType===t.TEXT_NODE&&""!==(null==(e=t.textContent)?void 0:e.trim()))return!0;if(t.nodeType===t.ELEMENT_NODE){const e=t;if("pbo-visually-hidden"===e.tagName.toLowerCase())return!1;if(!e.hasAttribute("slot"))return!0}return!1}))}hasNamedSlot(t){return null!==this.host.querySelector(`:scope > [slot="${t}]`)}test(t){return"[default]"===t?this.hasDefaultSlot():this.hasNamedSlot(t)}hostConnected(){this.host.shadowRoot.addEventListener("slotchange",this.handleSlotChange)}hostDisconnected(){this.host.shadowRoot.removeEventListener("slotchange",this.handleSlotChange)}}var Wh=Object.defineProperty,Hh=Object.getOwnPropertyDescriptor,Xh=(t,e,i,s)=>{for(var r,n=s>1?void 0:s?Hh(e,i):e,o=t.length-1;o>=0;o--)(r=t[o])&&(n=(s?r(e,i,n):r(n))||n);return s&&n&&Wh(e,i,n),n};let Uh=class extends at{constructor(){super(...arguments),this.hasSlotController=new $h(this,"[prefix]","prefix","suffix"),this.href="",this.name="",this.value="",this.variant="default",this.outline=!1,this.size="medium",this.circle=!1}isButton(){return!this.href}isLink(){return!!this.href}firstUpdated(t){var e,i;console.log({componentStyles:il,styles:Ah}),console.log("Has default slot:",this.hasSlotController.test("[default]")),console.log("Button classes:",null==(i=null==(e=this.shadowRoot)?void 0:e.querySelector(".button"))?void 0:i.classList)}render(){const t=this.isLink()?jh`a`:jh`button`;return Fh`
480
+ <${t}
975
481
  part="base"
976
- class= ${cs({button:!0,"button--default":this.variant==="default","button--primary":this.variant==="primary","button--success":this.variant==="success","button--neutral":this.variant==="neutral","button--warning":this.variant==="warning","button--danger":this.variant==="danger","button--text":this.variant==="text","button--small":this.size==="small","button--medium":this.size==="medium","button--large":this.size==="large","button--standard":!this.outline,"button--outline":this.outline,"button--has-label":this.hasSlotController.test("[default]"),"button--has-prefix":this.hasSlotController.test("prefix"),"button--has-suffix":this.hasSlotController.test("suffix"),"button--circle":this.circle,"button--disabled":!1})}
482
+ class= ${Vh({button:!0,"button--default":"default"===this.variant,"button--primary":"primary"===this.variant,"button--success":"success"===this.variant,"button--neutral":"neutral"===this.variant,"button--warning":"warning"===this.variant,"button--danger":"danger"===this.variant,"button--text":"text"===this.variant,"button--small":"small"===this.size,"button--medium":"medium"===this.size,"button--large":"large"===this.size,"button--standard":!this.outline,"button--outline":this.outline,"button--has-label":this.hasSlotController.test("[default]"),"button--has-prefix":this.hasSlotController.test("prefix"),"button--has-suffix":this.hasSlotController.test("suffix"),"button--circle":this.circle,"button--disabled":!1})}
977
483
  href="${this.href}"
978
484
  >
979
485
  <slot name="prefix" part="prefix" class="button__prefix"></slot>
980
486
  <slot part="label" class="button__label"></slot>
981
487
  <slot name="suffix" part="suffix" class="button__suffix"></slot>
982
- </${e}>`}};ee.styles=[Vt,ha],di([H()],ee.prototype,"href",2),di([H()],ee.prototype,"name",2),di([H()],ee.prototype,"value",2),di([H({reflect:!0})],ee.prototype,"variant",2),di([H({type:Boolean,reflect:!0})],ee.prototype,"outline",2),di([H({reflect:!0})],ee.prototype,"size",2),di([H({type:Boolean,reflect:!0})],ee.prototype,"circle",2),ee=di([Mt("pbo-button")],ee);const vm=ee,_m=Ct`
488
+ </${t}>`}};Uh.styles=[il,Ah],Xh([ut()],Uh.prototype,"href",2),Xh([ut()],Uh.prototype,"name",2),Xh([ut()],Uh.prototype,"value",2),Xh([ut({reflect:!0})],Uh.prototype,"variant",2),Xh([ut({type:Boolean,reflect:!0})],Uh.prototype,"outline",2),Xh([ut({reflect:!0})],Uh.prototype,"size",2),Xh([ut({type:Boolean,reflect:!0})],Uh.prototype,"circle",2),Uh=Xh([ct("pbo-button")],Uh);const Yh=Uh,Gh=l`
983
489
  :host {
984
490
  display: block;
985
491
  }
986
- `;var bm=Object.defineProperty,ym=Object.getOwnPropertyDescriptor,_h=(n,t,e,i)=>{for(var s=i>1?void 0:i?ym(t,e):t,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(t,e,s):o(s))||s);return i&&s&&bm(t,e,s),s};let hs=class extends ae{constructor(){super(...arguments),this.attr="example"}render(){return St`<div>
492
+ `;var qh=Object.defineProperty,Kh=Object.getOwnPropertyDescriptor,Jh=(t,e,i,s)=>{for(var r,n=s>1?void 0:s?Kh(e,i):e,o=t.length-1;o>=0;o--)(r=t[o])&&(n=(s?r(e,i,n):r(n))||n);return s&&n&&qh(e,i,n),n};let Zh=class extends at{constructor(){super(...arguments),this.attr="example"}render(){return H`<div>
987
493
  <slot></slot>
988
- </div>`}};hs.styles=[Vt,_m],_h([H()],hs.prototype,"attr",2),hs=_h([Mt("pbo-button-group")],hs);const xm=hs,Cm=Ct`
989
- ${ha}
494
+ </div>`}};Zh.styles=[il,Gh],Jh([ut()],Zh.prototype,"attr",2),Zh=Jh([ct("pbo-button-group")],Zh);const Qh=Zh,td=l`
495
+ ${Ah}
990
496
 
991
497
  .button__prefix,
992
498
  .button__suffix,
@@ -995,34 +501,36 @@ good aklsdfja`,this.alignment="left",this.fontFamily="Arial",this.color="#000",t
995
501
  position: relative;
996
502
  align-items: center;
997
503
  }
998
- `;/**
999
- * @license
1000
- * Copyright 2018 Google LLC
1001
- * SPDX-License-Identifier: BSD-3-Clause
1002
- */const us=n=>n??mt;/**
1003
- * @license
1004
- * Copyright 2018 Google LLC
1005
- * SPDX-License-Identifier: BSD-3-Clause
1006
- */const bh="important",Sm=" !"+bh,yh=ua(class extends da{constructor(n){var t;if(super(n),n.type!==ui.ATTRIBUTE||n.name!=="style"||((t=n.strings)==null?void 0:t.length)>2)throw Error("The `styleMap` directive must be used in the `style` attribute and must be the only part in the attribute.")}render(n){return Object.keys(n).reduce((t,e)=>{const i=n[e];return i==null?t:t+`${e=e.includes("-")?e:e.replace(/(?:^(webkit|moz|ms|o)|)(?=[A-Z])/g,"-$&").toLowerCase()}:${i};`},"")}update(n,[t]){const{style:e}=n.element;if(this.ft===void 0)return this.ft=new Set(Object.keys(t)),this.render(t);for(const i of this.ft)t[i]==null&&(this.ft.delete(i),i.includes("-")?e.removeProperty(i):e[i]=null);for(const i in t){const s=t[i];if(s!=null){this.ft.add(i);const r=typeof s=="string"&&s.endsWith(Sm);i.includes("-")||r?e.setProperty(i,r?s.slice(0,-11):s,r?bh:""):e[i]=s}}return Jt}});var wm=Object.defineProperty,Tm=Object.getOwnPropertyDescriptor,Ye=(n,t,e,i)=>{for(var s=i>1?void 0:i?Tm(t,e):t,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(t,e,s):o(s))||s);return i&&s&&wm(t,e,s),s};let ie=class extends ae{constructor(){super(...arguments),this.hasSlotController=new fa(this,"[prefix]","prefix","suffix"),this.hasFocus=!1,this.checked=!1,this.disabled=!1,this.size="medium",this.circle=!1,this.handleClick=()=>{console.log(this.isColorString(this.value))}}connectedCallback(){super.connectedCallback(),this.setAttribute("role","presentation")}handleBlur(){}handleFocus(){}focus(t){this.input.focus(t)}blur(){this.input.blur()}isColorString(t){if(!t)return!1;if(t.startsWith("#"))return/^#([A-Fa-f0-9]{3}){1,2}$/.test(t);const e=new Option().style;return e.color=t,e.color!==""}render(){return St`
504
+ `
505
+ /**
506
+ * @license
507
+ * Copyright 2018 Google LLC
508
+ * SPDX-License-Identifier: BSD-3-Clause
509
+ */,ed=t=>t??U
510
+ /**
511
+ * @license
512
+ * Copyright 2018 Google LLC
513
+ * SPDX-License-Identifier: BSD-3-Clause
514
+ */,id="important",sd=" !"+id,rd=Nh(class extends zh{constructor(t){var e;if(super(t),t.type!==Ih||"style"!==t.name||(null==(e=t.strings)?void 0:e.length)>2)throw Error("The `styleMap` directive must be used in the `style` attribute and must be the only part in the attribute.")}render(t){return Object.keys(t).reduce(((e,i)=>{const s=t[i];return null==s?e:e+`${i=i.includes("-")?i:i.replace(/(?:^(webkit|moz|ms|o)|)(?=[A-Z])/g,"-$&").toLowerCase()}:${s};`}),"")}update(t,[e]){const{style:i}=t.element;if(void 0===this.ft)return this.ft=new Set(Object.keys(e)),this.render(e);for(const s of this.ft)null==e[s]&&(this.ft.delete(s),s.includes("-")?i.removeProperty(s):i[s]=null);for(const s in e){const t=e[s];if(null!=t){this.ft.add(s);const e="string"==typeof t&&t.endsWith(sd);s.includes("-")||e?i.setProperty(s,e?t.slice(0,-11):t,e?id:""):i[s]=t}}return X}});var nd=Object.defineProperty,od=Object.getOwnPropertyDescriptor,ad=(t,e,i,s)=>{for(var r,n=s>1?void 0:s?od(e,i):e,o=t.length-1;o>=0;o--)(r=t[o])&&(n=(s?r(e,i,n):r(n))||n);return s&&n&&nd(e,i,n),n};let ld=class extends at{constructor(){super(...arguments),this.hasSlotController=new $h(this,"[prefix]","prefix","suffix"),this.hasFocus=!1,this.checked=!1,this.disabled=!1,this.size="medium",this.circle=!1,this.handleClick=()=>{console.log(this.isColorString(this.value))}}connectedCallback(){super.connectedCallback(),this.setAttribute("role","presentation")}handleBlur(){}handleFocus(){}focus(t){this.input.focus(t)}blur(){this.input.blur()}isColorString(t){if(!t)return!1;if(t.startsWith("#"))return/^#([A-Fa-f0-9]{3}){1,2}$/.test(t);const e=(new Option).style;return e.color=t,""!==e.color}render(){return H`
1007
515
  <div part="base" role="presentation">
1008
516
  <button
1009
- part="${`button${this.checked?"button--checked":""}`}"
517
+ part="${"button"+(this.checked?"button--checked":"")}"
1010
518
  role="radio"
1011
519
  aria-checked="${this.checked}"
1012
- class=${cs({button:!0,"button--default":!0,"button--color-block":!!this.isColorString(this.value),"button--small":this.size==="small","button--medium":this.size==="medium","button--large":this.size==="large","button--checked":this.checked,"button--disabled":this.disabled,"button--outline":!0,"button--has-label":this.hasSlotController.test("[default]"),"button--has-prefix":this.hasSlotController.test("prefix"),"button--has-suffix":this.hasSlotController.test("suffix"),"button--circle":this.circle})}
520
+ class=${Vh({button:!0,"button--default":!0,"button--color-block":!!this.isColorString(this.value),"button--small":"small"===this.size,"button--medium":"medium"===this.size,"button--large":"large"===this.size,"button--checked":this.checked,"button--disabled":this.disabled,"button--outline":!0,"button--has-label":this.hasSlotController.test("[default]"),"button--has-prefix":this.hasSlotController.test("prefix"),"button--has-suffix":this.hasSlotController.test("suffix"),"button--circle":this.circle})}
1013
521
  type="button"
1014
- value=${us(this.value)}
522
+ value=${ed(this.value)}
1015
523
  @blur=${this.handleBlur}
1016
524
  @click=${this.handleClick}
1017
525
  @focus=${this.handleFocus}
1018
- style=${yh({backgroundColor:this.isColorString(this.value)?this.value:""})}
526
+ style=${rd({backgroundColor:this.isColorString(this.value)?this.value:""})}
1019
527
  >
1020
528
  <slot name="prefix" part="prefix" class="button__prefix"></slot>
1021
529
  <slot part="label" class="button__label"></slot>
1022
530
  <slot name="suffix" part="suffix" class="button__suffix"></slot>
1023
531
  </button>
1024
532
  </div>
1025
- `}};ie.styles=[Vt,Cm],Ye([vt(".button")],ie.prototype,"input",2),Ye([vt(".hidden-input")],ie.prototype,"hiddenInput",2),Ye([st()],ie.prototype,"hasFocus",2),Ye([H({type:Boolean,reflect:!0})],ie.prototype,"checked",2),Ye([H()],ie.prototype,"value",2),Ye([H({type:Boolean,reflect:!0})],ie.prototype,"disabled",2),Ye([H({reflect:!0})],ie.prototype,"size",2),Ye([H({type:Boolean,reflect:!0})],ie.prototype,"circle",2),ie=Ye([Mt("pbo-radio-button")],ie);const Em=ie,Om=Ct`
533
+ `}};ld.styles=[il,td],ad([ft(".button")],ld.prototype,"input",2),ad([ft(".hidden-input")],ld.prototype,"hiddenInput",2),ad([pt()],ld.prototype,"hasFocus",2),ad([ut({type:Boolean,reflect:!0})],ld.prototype,"checked",2),ad([ut()],ld.prototype,"value",2),ad([ut({type:Boolean,reflect:!0})],ld.prototype,"disabled",2),ad([ut({reflect:!0})],ld.prototype,"size",2),ad([ut({type:Boolean,reflect:!0})],ld.prototype,"circle",2),ld=ad([ct("pbo-radio-button")],ld);const cd=ld,hd=l`
1026
534
  :host {
1027
535
  display: block;
1028
536
  }
@@ -1038,7 +546,7 @@ good aklsdfja`,this.alignment="left",this.fontFamily="Arial",this.color="#000",t
1038
546
  white-space: nowrap;
1039
547
  border: 0;
1040
548
  }
1041
- `;class Ue extends ae{emit(t,e){const i=new CustomEvent(t,{bubbles:!0,cancelable:!0,composed:!0,detail:{},...e});return this.dispatchEvent(i),i}}const Gs=new WeakMap,Xs=new WeakMap,Ks=new WeakMap,ga=new WeakSet,qs=new WeakMap;class xh{constructor(t,e){this.handleFormData=i=>{const s=this.options.disabled(this.host),r=this.options.name(this.host),o=this.options.value(this.host);this.host.isConnected&&!s&&typeof r=="string"&&r.length>0&&typeof o<"u"&&(Array.isArray(o)?o.forEach(a=>{i.formData.append(r,a.toString())}):i.formData.append(r,o.toString()))},this.handleFormSubmit=i=>{var o;const s=this.options.disabled(this.host),r=this.options.reportValidity;this.form&&!this.form.noValidate&&((o=Gs.get(this.form))==null||o.forEach(a=>{this.setUserInteracted(a,!0)})),this.form&&!this.form.noValidate&&!s&&!r(this.host)&&(i==null||i.preventDefault(),i==null||i.stopImmediatePropagation())},this.handleFormReset=()=>{this.options.setValue(this.host,this.options.defaultValue(this.host)),this.setUserInteracted(this.host,!1),qs.set(this.host,[])},this.handleInteraction=i=>{const s=qs.get(this.host);s.includes(i.type)||s.push(i.type),s.length===this.options.assumeInteractionOn.length&&this.setUserInteracted(this.host,!0)},this.checkFormValidity=()=>{if(this.form&&!this.form.noValidate){const i=this.form.querySelectorAll("*");for(const s of i)if(typeof s.checkValidity=="function"&&!s.checkValidity())return!1}return!0},this.doAction=(i,s)=>{if(this.form){const r=document.createElement("button");r.type=i,r.style.position="absolute",r.style.width="0",r.style.height="0",r.style.clipPath="inset(50%)",r.style.overflow="hidden",r.style.whiteSpace="nowrap",s&&(r.name=s.name,r.value=s.value,["formation","formenctype","formmethod","formnovalidate","formtarget"].forEach(o=>{s.hasAttribute(o)&&r.setAttribute(o,s.getAttribute(o))})),this.form.append(r),r.click(),r.remove()}},console.log({host:t}),(this.host=t).addController(this),this.options={form:i=>{const s=i.form;if(s){const o=i.getRootNode().querySelector(`#${s}`);if(o)return o}return i.closest("form")},name:i=>i.name,value:i=>i.value,defaultValue:i=>i.defaultValue,disabled:i=>i.disabled||!1,reportValidity:i=>typeof i.reportValidity=="function"?i.reportValidity():!0,checkValidity:i=>typeof i.checkValidity=="function"?i.checkValidity():!0,setValue:(i,s)=>i.value=s,assumeInteractionOn:["pbo-input"],...e}}hostConnected(){const t=this.options.form(this.host);t&&this.attachForm(t),qs.set(this.host,[]),console.log({interactions:qs}),this.options.assumeInteractionOn.forEach(e=>{this.host.addEventListener(e,this.handleInteraction)})}hostDisconnected(){this.detachForm(),qs.delete(this.host),this.options.assumeInteractionOn.forEach(t=>{this.host.removeEventListener(t,this.handleInteraction)})}hostUpdated(){const t=this.options.form(this.host);t||this.detachForm(),t&&this.form!==t&&(this.detachForm(),this.attachForm(t)),this.host.hasUpdated&&this.setValidity(this.host.validity.valid)}attachForm(t){t?(this.form=t,Gs.has(this.form)?Gs.get(this.form).add(this.host):Gs.set(this.form,new Set([this.host])),this.form.addEventListener("formdata",this.handleFormData),this.form.addEventListener("submit",this.handleFormSubmit),this.form.addEventListener("reset",this.handleFormReset),Xs.has(this.form)||(Xs.set(this.form,this.form.reportValidity),this.form.reportValidity=()=>this.reportFormValidity()),Ks.has(this.form)||(Ks.set(this.form,this.form.checkValidity),this.form.checkValidity=()=>this.checkFormValidity())):this.form=void 0}detachForm(){if(!this.form)return;const t=Gs.get(this.form);t&&(t.delete(this.host),t.size<=0&&(this.form.removeEventListener("formdata",this.handleFormData),this.form.removeEventListener("submit",this.handleFormSubmit),this.form.removeEventListener("reset",this.handleFormReset),Xs.has(this.form)&&(this.form.reportValidity=Xs.get(this.form),Xs.delete(this.form)),Ks.has(this.form)&&(this.form.checkValidity=Ks.get(this.form),Ks.delete(this.form)),this.form=void 0))}reportFormValidity(){if(this.form&&!this.form.noValidate){const t=this.form.querySelectorAll("*");for(const e of t)if(typeof e.reportValidity=="function"&&!e.reportValidity())return!1}return!0}setUserInteracted(t,e){e?ga.add(t):ga.delete(t),t.requestUpdate()}getForm(){return this.form??null}reset(t){this.doAction("reset",t)}submit(t){this.doAction("submit",t)}setValidity(t){const e=this.host,i=!!ga.has(e),s=!!e.required;e.toggleAttribute("data-required",s),e.toggleAttribute("data-optional",!s),e.toggleAttribute("data-invalid",!t),e.toggleAttribute("data-valid",t),e.toggleAttribute("data-user-invalid",i&&!t),e.toggleAttribute("data-user-valid",i&&t)}updateValidity(){const t=this.host;this.setValidity(t.validity.valid)}emitInvalidEvent(t){const e=new CustomEvent("pbo-invalid",{bubbles:!1,composed:!1,cancelable:!0,detail:{}});t||e.preventDefault(),this.host.dispatchEvent(e)||t==null||t.preventDefault()}}const pa=Object.freeze({badInput:!1,customError:!1,patternMismatch:!1,rangeOverflow:!1,rangeUnderflow:!1,stepMismatch:!1,tooLong:!1,tooShort:!1,typeMismatch:!1,valid:!0,valueMissing:!1}),Am=Object.freeze({...pa,valid:!1,valueMissing:!1}),Dm=Object.freeze({...pa,valid:!1,customError:!0}),Ch=Ct`
549
+ `;class dd extends at{emit(t,e){const i=new CustomEvent(t,{bubbles:!0,cancelable:!0,composed:!0,detail:{},...e});return this.dispatchEvent(i),i}}const ud=new WeakMap,pd=new WeakMap,gd=new WeakMap,fd=new WeakSet,md=new WeakMap;class vd{constructor(t,e){this.handleFormData=t=>{const e=this.options.disabled(this.host),i=this.options.name(this.host),s=this.options.value(this.host);this.host.isConnected&&!e&&"string"==typeof i&&i.length>0&&void 0!==s&&(Array.isArray(s)?s.forEach((e=>{t.formData.append(i,e.toString())})):t.formData.append(i,s.toString()))},this.handleFormSubmit=t=>{var e;const i=this.options.disabled(this.host),s=this.options.reportValidity;this.form&&!this.form.noValidate&&(null==(e=ud.get(this.form))||e.forEach((t=>{this.setUserInteracted(t,!0)}))),!this.form||this.form.noValidate||i||s(this.host)||(null==t||t.preventDefault(),null==t||t.stopImmediatePropagation())},this.handleFormReset=()=>{this.options.setValue(this.host,this.options.defaultValue(this.host)),this.setUserInteracted(this.host,!1),md.set(this.host,[])},this.handleInteraction=t=>{const e=md.get(this.host);e.includes(t.type)||e.push(t.type),e.length===this.options.assumeInteractionOn.length&&this.setUserInteracted(this.host,!0)},this.checkFormValidity=()=>{if(this.form&&!this.form.noValidate){const t=this.form.querySelectorAll("*");for(const e of t)if("function"==typeof e.checkValidity&&!e.checkValidity())return!1}return!0},this.doAction=(t,e)=>{if(this.form){const i=document.createElement("button");i.type=t,i.style.position="absolute",i.style.width="0",i.style.height="0",i.style.clipPath="inset(50%)",i.style.overflow="hidden",i.style.whiteSpace="nowrap",e&&(i.name=e.name,i.value=e.value,["formation","formenctype","formmethod","formnovalidate","formtarget"].forEach((t=>{e.hasAttribute(t)&&i.setAttribute(t,e.getAttribute(t))}))),this.form.append(i),i.click(),i.remove()}},console.log({host:t}),(this.host=t).addController(this),this.options={form:t=>{const e=t.form;if(e){const i=t.getRootNode().querySelector(`#${e}`);if(i)return i}return t.closest("form")},name:t=>t.name,value:t=>t.value,defaultValue:t=>t.defaultValue,disabled:t=>t.disabled||!1,reportValidity:t=>"function"!=typeof t.reportValidity||t.reportValidity(),checkValidity:t=>"function"!=typeof t.checkValidity||t.checkValidity(),setValue:(t,e)=>t.value=e,assumeInteractionOn:["pbo-input"],...e}}hostConnected(){const t=this.options.form(this.host);t&&this.attachForm(t),md.set(this.host,[]),console.log({interactions:md}),this.options.assumeInteractionOn.forEach((t=>{this.host.addEventListener(t,this.handleInteraction)}))}hostDisconnected(){this.detachForm(),md.delete(this.host),this.options.assumeInteractionOn.forEach((t=>{this.host.removeEventListener(t,this.handleInteraction)}))}hostUpdated(){const t=this.options.form(this.host);t||this.detachForm(),t&&this.form!==t&&(this.detachForm(),this.attachForm(t)),this.host.hasUpdated&&this.setValidity(this.host.validity.valid)}attachForm(t){t?(this.form=t,ud.has(this.form)?ud.get(this.form).add(this.host):ud.set(this.form,new Set([this.host])),this.form.addEventListener("formdata",this.handleFormData),this.form.addEventListener("submit",this.handleFormSubmit),this.form.addEventListener("reset",this.handleFormReset),pd.has(this.form)||(pd.set(this.form,this.form.reportValidity),this.form.reportValidity=()=>this.reportFormValidity()),gd.has(this.form)||(gd.set(this.form,this.form.checkValidity),this.form.checkValidity=()=>this.checkFormValidity())):this.form=void 0}detachForm(){if(!this.form)return;const t=ud.get(this.form);t&&(t.delete(this.host),t.size<=0&&(this.form.removeEventListener("formdata",this.handleFormData),this.form.removeEventListener("submit",this.handleFormSubmit),this.form.removeEventListener("reset",this.handleFormReset),pd.has(this.form)&&(this.form.reportValidity=pd.get(this.form),pd.delete(this.form)),gd.has(this.form)&&(this.form.checkValidity=gd.get(this.form),gd.delete(this.form)),this.form=void 0))}reportFormValidity(){if(this.form&&!this.form.noValidate){const t=this.form.querySelectorAll("*");for(const e of t)if("function"==typeof e.reportValidity&&!e.reportValidity())return!1}return!0}setUserInteracted(t,e){e?fd.add(t):fd.delete(t),t.requestUpdate()}getForm(){return this.form??null}reset(t){this.doAction("reset",t)}submit(t){this.doAction("submit",t)}setValidity(t){const e=this.host,i=Boolean(fd.has(e)),s=Boolean(e.required);e.toggleAttribute("data-required",s),e.toggleAttribute("data-optional",!s),e.toggleAttribute("data-invalid",!t),e.toggleAttribute("data-valid",t),e.toggleAttribute("data-user-invalid",i&&!t),e.toggleAttribute("data-user-valid",i&&t)}updateValidity(){const t=this.host;this.setValidity(t.validity.valid)}emitInvalidEvent(t){const e=new CustomEvent("pbo-invalid",{bubbles:!1,composed:!1,cancelable:!0,detail:{}});t||e.preventDefault(),this.host.dispatchEvent(e)||null==t||t.preventDefault()}}const _d=Object.freeze({badInput:!1,customError:!1,patternMismatch:!1,rangeOverflow:!1,rangeUnderflow:!1,stepMismatch:!1,tooLong:!1,tooShort:!1,typeMismatch:!1,valid:!0,valueMissing:!1}),bd=Object.freeze({..._d,valid:!1,valueMissing:!1}),yd=Object.freeze({..._d,valid:!1,customError:!0}),xd=l`
1042
550
  .form-control .form-control__label {
1043
551
  display: none;
1044
552
  }
@@ -1094,11 +602,11 @@ good aklsdfja`,this.alignment="left",this.fontFamily="Arial",this.color="#000",t
1094
602
  .form-control--has-help-text.form-control--radio-group .form-control__help-text {
1095
603
  margin-top: var(--sl-spacing-2x-small);
1096
604
  }
1097
- `;var km=Object.defineProperty,Mm=Object.getOwnPropertyDescriptor,pe=(n,t,e,i)=>{for(var s=i>1?void 0:i?Mm(t,e):t,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(t,e,s):o(s))||s);return i&&s&&km(t,e,s),s};let wt=class extends Ue{constructor(){super(...arguments),this.formControlController=new xh(this),this.hasSlotController=new fa(this,"help-text","label"),this.customValidityMessage="",this._value="",this.hasButtonGroup=!0,this.errorMessage="",this.defaultValue="",this.required=!1,this.name="option",this.disabled=!1,this.form=""}get value(){return this._value}set value(t){const e=this._value;this._value=t,this.hasUpdated&&e!==t&&this.updateCheckedRadio(),this.requestUpdate("value",e)}get validity(){const t=this.required&&!this.value;return this.customValidityMessage!==""?Dm:t?Am:pa}checkValidity(){const t=this.required&&!this.value,e=this.customValidityMessage!=="";return t||e?(this.formControlController.emitInvalidEvent(),!1):!0}getForm(){return this.formControlController.getForm()}reportValidity(){const t=this.validity.valid;return this.errorMessage=this.customValidityMessage||t?"":this.validationInput.validationMessage,this.formControlController.setValidity(t),this.validationInput.hidden=!0,clearTimeout(this.validationTimeout),t||(this.validationInput.hidden=!1,this.validationInput.reportValidity(),this.validationTimeout=setTimeout(()=>this.validationInput.hidden=!0,1e4)),t}setCustomValidity(t){this.customValidityMessage=t,this.errorMessage=t,this.validationInput.setCustomValidity(t),this.formControlController.updateValidity()}getAllRadios(){return[...this.querySelectorAll("pbo-radio, pbo-radio-button")]}updateCheckedRadio(){this.getAllRadios().forEach(e=>e.checked=e.value===this.value),this.formControlController.setValidity(this.validity.valid)}handleRadioClick(t){const e=t.target.closest("pbo-radio-button"),i=this.getAllRadios(),s=this.value;!e||e.disabled||(this.value=e.value,i.forEach(r=>r.checked=r===e),this.value!==s&&(this.emit("pbo-change"),this.emit("pbo-input")))}handleKeyDown(t){}syncRadios(){}handleInvalid(t){this.formControlController.setValidity(!1),this.formControlController.emitInvalidEvent(t)}handleValueChange(){this.hasUpdated&&this.updateCheckedRadio()}render(){return St`
605
+ `;var wd=Object.defineProperty,Cd=Object.getOwnPropertyDescriptor,Sd=(t,e,i,s)=>{for(var r,n=s>1?void 0:s?Cd(e,i):e,o=t.length-1;o>=0;o--)(r=t[o])&&(n=(s?r(e,i,n):r(n))||n);return s&&n&&wd(e,i,n),n};let Td=class extends dd{constructor(){super(...arguments),this.formControlController=new vd(this),this.hasSlotController=new $h(this,"help-text","label"),this.customValidityMessage="",this._value="",this.hasButtonGroup=!0,this.errorMessage="",this.defaultValue="",this.required=!1,this.name="option",this.disabled=!1,this.form=""}get value(){return this._value}set value(t){const e=this._value;this._value=t,this.hasUpdated&&e!==t&&this.updateCheckedRadio(),this.requestUpdate("value",e)}get validity(){const t=this.required&&!this.value;return""!==this.customValidityMessage?yd:t?bd:_d}checkValidity(){const t=this.required&&!this.value,e=""!==this.customValidityMessage;return!t&&!e||(this.formControlController.emitInvalidEvent(),!1)}getForm(){return this.formControlController.getForm()}reportValidity(){const t=this.validity.valid;return this.errorMessage=this.customValidityMessage||t?"":this.validationInput.validationMessage,this.formControlController.setValidity(t),this.validationInput.hidden=!0,clearTimeout(this.validationTimeout),t||(this.validationInput.hidden=!1,this.validationInput.reportValidity(),this.validationTimeout=setTimeout((()=>this.validationInput.hidden=!0),1e4)),t}setCustomValidity(t){this.customValidityMessage=t,this.errorMessage=t,this.validationInput.setCustomValidity(t),this.formControlController.updateValidity()}getAllRadios(){return[...this.querySelectorAll("pbo-radio, pbo-radio-button")]}updateCheckedRadio(){this.getAllRadios().forEach((t=>t.checked=t.value===this.value)),this.formControlController.setValidity(this.validity.valid)}handleRadioClick(t){const e=t.target.closest("pbo-radio-button"),i=this.getAllRadios(),s=this.value;e&&!e.disabled&&(this.value=e.value,i.forEach((t=>t.checked=t===e)),this.value!==s&&(this.emit("pbo-change"),this.emit("pbo-input")))}handleKeyDown(t){}syncRadios(){}handleInvalid(t){this.formControlController.setValidity(!1),this.formControlController.emitInvalidEvent(t)}handleValueChange(){this.hasUpdated&&this.updateCheckedRadio()}render(){return H`
1098
606
  <fieldset
1099
607
  role="radiogroup"
1100
608
  part="form-control"
1101
- class=${cs({"form-control":!0})}
609
+ class=${Vh({"form-control":!0})}
1102
610
  role="radiogroup"
1103
611
  aria-labelledby="label"
1104
612
  aria-describedby="help-text"
@@ -1124,7 +632,7 @@ good aklsdfja`,this.alignment="left",this.fontFamily="Arial",this.color="#000",t
1124
632
  </div>
1125
633
  ${this._value}
1126
634
  </fieldset>
1127
- `}};wt.styles=[Vt,Om,Ch],wt.dependencies={"pbo-button-group":hs},pe([vt("slot:not([name])")],wt.prototype,"defaultSlot",2),pe([vt(".radio-group__validation-input")],wt.prototype,"validationInput",2),pe([st()],wt.prototype,"hasButtonGroup",2),pe([st()],wt.prototype,"errorMessage",2),pe([st()],wt.prototype,"defaultValue",2),pe([H({type:Boolean,reflect:!0})],wt.prototype,"required",2),pe([H()],wt.prototype,"name",2),pe([H({reflect:!0})],wt.prototype,"value",1),pe([H({type:Boolean,reflect:!0})],wt.prototype,"disabled",2),pe([H({reflect:!0})],wt.prototype,"form",2),wt=pe([Mt("pbo-radio-group")],wt);const Pm=wt,Im=Ct`
635
+ `}};Td.styles=[il,hd,xd],Td.dependencies={"pbo-button-group":Zh},Sd([ft("slot:not([name])")],Td.prototype,"defaultSlot",2),Sd([ft(".radio-group__validation-input")],Td.prototype,"validationInput",2),Sd([pt()],Td.prototype,"hasButtonGroup",2),Sd([pt()],Td.prototype,"errorMessage",2),Sd([pt()],Td.prototype,"defaultValue",2),Sd([ut({type:Boolean,reflect:!0})],Td.prototype,"required",2),Sd([ut()],Td.prototype,"name",2),Sd([ut({reflect:!0})],Td.prototype,"value",1),Sd([ut({type:Boolean,reflect:!0})],Td.prototype,"disabled",2),Sd([ut({reflect:!0})],Td.prototype,"form",2),Td=Sd([ct("pbo-radio-group")],Td);const Od=Td,Ed=l`
1128
636
  :host {
1129
637
  display: block;
1130
638
  }
@@ -1299,37 +807,39 @@ good aklsdfja`,this.alignment="left",this.fontFamily="Arial",this.color="#000",t
1299
807
  resize: none;
1300
808
  overflow-y: hidden;
1301
809
  }
1302
- `;/**
1303
- * @license
1304
- * Copyright 2020 Google LLC
1305
- * SPDX-License-Identifier: BSD-3-Clause
1306
- */const Lm=n=>n.strings===void 0,jm={},Fm=(n,t=jm)=>n._$AH=t;/**
1307
- * @license
1308
- * Copyright 2020 Google LLC
1309
- * SPDX-License-Identifier: BSD-3-Clause
1310
- */const Rm=ua(class extends da{constructor(n){if(super(n),n.type!==ui.PROPERTY&&n.type!==ui.ATTRIBUTE&&n.type!==ui.BOOLEAN_ATTRIBUTE)throw Error("The `live` directive is not allowed on child or event bindings");if(!Lm(n))throw Error("`live` bindings can only contain a single expression")}render(n){return n}update(n,[t]){if(t===Jt||t===mt)return t;const e=n.element,i=n.name;if(n.type===ui.PROPERTY){if(t===e[i])return Jt}else if(n.type===ui.BOOLEAN_ATTRIBUTE){if(!!t===e.hasAttribute(i))return Jt}else if(n.type===ui.ATTRIBUTE&&e.getAttribute(i)===t+"")return Jt;return Fm(n),t}});var Nm=Object.defineProperty,Bm=Object.getOwnPropertyDescriptor,Et=(n,t,e,i)=>{for(var s=i>1?void 0:i?Bm(t,e):t,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(t,e,s):o(s))||s);return i&&s&&Nm(t,e,s),s};let pt=class extends Ue{constructor(){super(...arguments),this.formControlController=new xh(this,{assumeInteractionOn:["pbo-input"]}),this.hasFocus=!1,this.name="",this.value="",this.size="medium",this.filled=!1,this.placeholder="",this.rows=4,this.resize="vertical",this.disabled=!1,this.readonly=!1,this.form="",this.required=!1}get validity(){return this.input.validity}get validationMessage(){return this.input.validationMessage}firstUpdated(){this.formControlController.updateValidity()}handleChange(){this.value=this.input.value,this.emit("pbo-change")}handleBlur(){this.hasFocus=!1,this.emit("pbo-blur")}handleFocus(){this.hasFocus=!0,this.emit("pbo-focus")}handleInput(){this.value=this.input.value,this.emit("pbo-input")}handleInvalid(t){this.formControlController.setValidity(!1),this.formControlController.emitInvalidEvent(t)}focus(t){this.input.focus(t)}blur(){this.input.blur()}select(){this.input.select()}scrollPosition(t){if(t){typeof t.top=="number"&&(this.input.scrollTop=t.top),typeof t.left=="number"&&(this.input.scrollLeft=t.left);return}return{top:this.input.scrollTop,left:this.input.scrollTop}}setSelectionRange(t,e,i="none"){this.input.setSelectionRange(t,e,i)}setRangeText(t,e,i,s="preserve"){const r=e??this.input.selectionStart,o=i??this.input.selectionEnd;this.input.setRangeText(t,r,o,s),this.value!==this.input.value&&(this.value=this.input.value)}checkValidity(){return this.input.checkValidity()}getForm(){return this.formControlController.getForm()}reportValidity(){return this.input.reportValidity()}setCustomValidity(t){this.input.setCustomValidity(t),this.formControlController.updateValidity()}render(){return St` <div
810
+ `
811
+ /**
812
+ * @license
813
+ * Copyright 2020 Google LLC
814
+ * SPDX-License-Identifier: BSD-3-Clause
815
+ */,kd={},Dd=Nh(class extends zh{constructor(t){if(super(t),t.type!==Rh&&t.type!==Ih&&t.type!==Bh)throw Error("The `live` directive is not allowed on child or event bindings");if(void 0!==t.strings)throw Error("`live` bindings can only contain a single expression")}render(t){return t}update(t,[e]){if(e===X||e===U)return e;const i=t.element,s=t.name;if(t.type===Rh){if(e===i[s])return X}else if(t.type===Bh){if(!!e===i.hasAttribute(s))return X}else if(t.type===Ih&&i.getAttribute(s)===e+"")return X;return((t,e=kd)=>{t._$AH=e;
816
+ /**
817
+ * @license
818
+ * Copyright 2020 Google LLC
819
+ * SPDX-License-Identifier: BSD-3-Clause
820
+ */})(t),e}});var Ad=Object.defineProperty,Md=Object.getOwnPropertyDescriptor,Pd=(t,e,i,s)=>{for(var r,n=s>1?void 0:s?Md(e,i):e,o=t.length-1;o>=0;o--)(r=t[o])&&(n=(s?r(e,i,n):r(n))||n);return s&&n&&Ad(e,i,n),n};let jd=class extends dd{constructor(){super(...arguments),this.formControlController=new vd(this,{assumeInteractionOn:["pbo-input"]}),this.hasFocus=!1,this.name="",this.value="",this.size="medium",this.filled=!1,this.placeholder="",this.rows=4,this.resize="vertical",this.disabled=!1,this.readonly=!1,this.form="",this.required=!1}get validity(){return this.input.validity}get validationMessage(){return this.input.validationMessage}firstUpdated(){this.formControlController.updateValidity()}handleChange(){this.value=this.input.value,this.emit("pbo-change")}handleBlur(){this.hasFocus=!1,this.emit("pbo-blur")}handleFocus(){this.hasFocus=!0,this.emit("pbo-focus")}handleInput(){this.value=this.input.value,this.emit("pbo-input")}handleInvalid(t){this.formControlController.setValidity(!1),this.formControlController.emitInvalidEvent(t)}focus(t){this.input.focus(t)}blur(){this.input.blur()}select(){this.input.select()}scrollPosition(t){return t?("number"==typeof t.top&&(this.input.scrollTop=t.top),void("number"==typeof t.left&&(this.input.scrollLeft=t.left))):{top:this.input.scrollTop,left:this.input.scrollTop}}setSelectionRange(t,e,i="none"){this.input.setSelectionRange(t,e,i)}setRangeText(t,e,i,s="preserve"){const r=e??this.input.selectionStart,n=i??this.input.selectionEnd;this.input.setRangeText(t,r,n,s),this.value!==this.input.value&&(this.value=this.input.value)}checkValidity(){return this.input.checkValidity()}getForm(){return this.formControlController.getForm()}reportValidity(){return this.input.reportValidity()}setCustomValidity(t){this.input.setCustomValidity(t),this.formControlController.updateValidity()}render(){return H` <div
1311
821
  part="form-control"
1312
- class=${cs({"form-control":!0,"form-control--small":this.size==="small","form-control--medium":this.size==="medium","form-control--large":this.size==="large"})}
822
+ class=${Vh({"form-control":!0,"form-control--small":"small"===this.size,"form-control--medium":"medium"===this.size,"form-control--large":"large"===this.size})}
1313
823
  >
1314
824
  <div part="form-control-input" class="form-control-input">
1315
825
  <div
1316
826
  part="base"
1317
- class=${cs({textarea:!0,"textarea--small":this.size==="small","textarea--medium":this.size==="medium","textarea--large":this.size==="large","textarea--standard":!this.filled,"textarea--filled":this.filled,"textarea--disabled":this.disabled,"textarea--focused":this.hasFocus,"textarea--empty":!this.value,"textarea--resize-none":this.resize==="none","textarea--resize-vertical":this.resize==="vertical","textarea--resize-auto":this.resize==="auto"})}
827
+ class=${Vh({textarea:!0,"textarea--small":"small"===this.size,"textarea--medium":"medium"===this.size,"textarea--large":"large"===this.size,"textarea--standard":!this.filled,"textarea--filled":this.filled,"textarea--disabled":this.disabled,"textarea--focused":this.hasFocus,"textarea--empty":!this.value,"textarea--resize-none":"none"===this.resize,"textarea--resize-vertical":"vertical"===this.resize,"textarea--resize-auto":"auto"===this.resize})}
1318
828
  >
1319
829
  <textarea
1320
830
  part="textarea"
1321
831
  id="input"
1322
832
  class="textarea__control"
1323
833
  title=${this.title}
1324
- name=${us(this.name)}
1325
- .value=${Rm(this.value)}
834
+ name=${ed(this.name)}
835
+ .value=${Dd(this.value)}
1326
836
  ?disabled=${this.disabled}
1327
837
  ?readonly=${this.readonly}
1328
838
  ?required=${this.required}
1329
- placeholder=${us(this.placeholder)}
1330
- rows=${us(this.rows)}
1331
- minlength=${us(this.minlength)}
1332
- maxlength=${us(this.maxlength)}
839
+ placeholder=${ed(this.placeholder)}
840
+ rows=${ed(this.rows)}
841
+ minlength=${ed(this.minlength)}
842
+ maxlength=${ed(this.maxlength)}
1333
843
  aria-describedby="help-text"
1334
844
  @change=${this.handleChange}
1335
845
  @input=${this.handleInput}
@@ -1338,10 +848,10 @@ good aklsdfja`,this.alignment="left",this.fontFamily="Arial",this.color="#000",t
1338
848
  @blur=${this.handleBlur}
1339
849
  ></textarea>
1340
850
  <!-- This "adjuster" exists to prevent layout shifting. https://github.com/shoelace-style/shoelace/issues/2180 -->
1341
- <div part="textarea-adjuster" class="textarea__size-adjuster" ?hidden=${this.resize!=="auto"}></div>
851
+ <div part="textarea-adjuster" class="textarea__size-adjuster" ?hidden=${"auto"!==this.resize}></div>
1342
852
  </div>
1343
853
  </div>
1344
- </div>`}};pt.styles=[Vt,Im,Ch],Et([vt(".textarea__control")],pt.prototype,"input",2),Et([vt(".textarea__size-adjuster")],pt.prototype,"sizeAdjuster",2),Et([st()],pt.prototype,"hasFocus",2),Et([H()],pt.prototype,"name",2),Et([H()],pt.prototype,"value",2),Et([H({reflect:!0})],pt.prototype,"size",2),Et([H({type:Boolean,reflect:!0})],pt.prototype,"filled",2),Et([H()],pt.prototype,"placeholder",2),Et([H({type:Number})],pt.prototype,"rows",2),Et([H()],pt.prototype,"resize",2),Et([H({type:Boolean,reflect:!0})],pt.prototype,"disabled",2),Et([H({type:Boolean,reflect:!0})],pt.prototype,"readonly",2),Et([H({reflect:!0})],pt.prototype,"form",2),Et([H({type:Boolean,reflect:!0})],pt.prototype,"required",2),Et([H({type:Number})],pt.prototype,"minlength",2),Et([H({type:Number})],pt.prototype,"maxlength",2),pt=Et([Mt("pbo-textarea")],pt);const $m=pt,Vm=Ct`
854
+ </div>`}};jd.styles=[il,Ed,xd],Pd([ft(".textarea__control")],jd.prototype,"input",2),Pd([ft(".textarea__size-adjuster")],jd.prototype,"sizeAdjuster",2),Pd([pt()],jd.prototype,"hasFocus",2),Pd([ut()],jd.prototype,"name",2),Pd([ut()],jd.prototype,"value",2),Pd([ut({reflect:!0})],jd.prototype,"size",2),Pd([ut({type:Boolean,reflect:!0})],jd.prototype,"filled",2),Pd([ut()],jd.prototype,"placeholder",2),Pd([ut({type:Number})],jd.prototype,"rows",2),Pd([ut()],jd.prototype,"resize",2),Pd([ut({type:Boolean,reflect:!0})],jd.prototype,"disabled",2),Pd([ut({type:Boolean,reflect:!0})],jd.prototype,"readonly",2),Pd([ut({reflect:!0})],jd.prototype,"form",2),Pd([ut({type:Boolean,reflect:!0})],jd.prototype,"required",2),Pd([ut({type:Number})],jd.prototype,"minlength",2),Pd([ut({type:Number})],jd.prototype,"maxlength",2),jd=Pd([ct("pbo-textarea")],jd);const Ld=jd,Fd=l`
1345
855
  :host {
1346
856
  display: block;
1347
857
  }
@@ -1351,11 +861,11 @@ good aklsdfja`,this.alignment="left",this.fontFamily="Arial",this.color="#000",t
1351
861
  grid-template-columns: 1fr 1fr;
1352
862
  gap: 1rem;
1353
863
  }
1354
- `,zm=Ct`
864
+ `,Id=l`
1355
865
  :host {
1356
866
  display: block;
1357
867
  }
1358
- `;var Hm=Object.defineProperty,Wm=Object.getOwnPropertyDescriptor,ji=(n,t,e,i)=>{for(var s=i>1?void 0:i?Wm(t,e):t,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(t,e,s):o(s))||s);return i&&s&&Hm(t,e,s),s};let se=class extends Ue{constructor(){super(...arguments),this.formData={font:"",text:"",color:"",alignment:""},this.cardInnerImageUrl="../../../public/Greeting Card from Pairbo.png"}get form(){var t,e,i,s;return{font:(t=this.fontSelector)==null?void 0:t.value,text:(e=this.greetingText)==null?void 0:e.value,color:(i=this.textColor)==null?void 0:i.value,alignment:(s=this.textAlignment)==null?void 0:s.value}}handleFormChange(t){var i;const e=t.target;e.classList.contains("font-selector")?this.formData.font=((i=e==null?void 0:e.value)==null?void 0:i.value)||" Font form control not implemented yet":e.classList.contains("greeting-text")?this.formData.text=e.value:e.classList.contains("text-color")?this.formData.color=e.value:e.classList.contains("text-alignment")&&(this.formData.alignment=e.value),this.emit("pbo-change",{detail:this.form})}hostConnected(){this.addEventListener("pbo-change",this.handleFormChange)}hostDisconnected(){this.removeEventListener("pbo-change",this.handleFormChange)}render(){return St`
868
+ `;var Rd=Object.defineProperty,Bd=Object.getOwnPropertyDescriptor,Nd=(t,e,i,s)=>{for(var r,n=s>1?void 0:s?Bd(e,i):e,o=t.length-1;o>=0;o--)(r=t[o])&&(n=(s?r(e,i,n):r(n))||n);return s&&n&&Rd(e,i,n),n};let zd=class extends dd{constructor(){super(...arguments),this.formData={font:"",text:"",color:"",alignment:""},this.cardInnerImageUrl="../../../public/Greeting Card from Pairbo.png"}get form(){var t,e,i,s;return{font:null==(t=this.fontSelector)?void 0:t.value,text:null==(e=this.greetingText)?void 0:e.value,color:null==(i=this.textColor)?void 0:i.value,alignment:null==(s=this.textAlignment)?void 0:s.value}}handleFormChange(t){var e;const i=t.target;i.classList.contains("font-selector")?this.formData.font=(null==(e=null==i?void 0:i.value)?void 0:e.value)||" Font form control not implemented yet":i.classList.contains("greeting-text")?this.formData.text=i.value:i.classList.contains("text-color")?this.formData.color=i.value:i.classList.contains("text-alignment")&&(this.formData.alignment=i.value),this.emit("pbo-change",{detail:this.form})}hostConnected(){this.addEventListener("pbo-change",this.handleFormChange)}hostDisconnected(){this.removeEventListener("pbo-change",this.handleFormChange)}render(){return H`
1359
869
  <form class="typing-form">
1360
870
  <pbo-selector
1361
871
  class="font-selector"
@@ -1377,7 +887,7 @@ good aklsdfja`,this.alignment="left",this.fontFamily="Arial",this.color="#000",t
1377
887
 
1378
888
  <pbo-button>Save and Continue</pbo-button>
1379
889
  </form>
1380
- `}};se.styles=[Vt,zm],se.dependencies={"pbo-selector":z.PboSelector,"pbo-textarea":pt,"pbo-color-radio-group":wt,"pbo-radio-group":wt,"pbo-radio-button":wt,"pbo-button":ee},ji([vt(".greeting-text")],se.prototype,"greetingText",2),ji([vt(".font-selector")],se.prototype,"fontSelector",2),ji([vt(".text-color")],se.prototype,"textColor",2),ji([vt(".text-alignment")],se.prototype,"textAlignment",2),ji([st()],se.prototype,"formData",2),ji([H({type:String,reflect:!0})],se.prototype,"cardInnerImageUrl",2),se=ji([Mt("pbo-type-form")],se);const Ym=Ct`
890
+ `}};zd.styles=[il,Id],zd.dependencies={"pbo-selector":t.PboSelector,"pbo-textarea":jd,"pbo-color-radio-group":Td,"pbo-radio-group":Td,"pbo-radio-button":Td,"pbo-button":Uh},Nd([ft(".greeting-text")],zd.prototype,"greetingText",2),Nd([ft(".font-selector")],zd.prototype,"fontSelector",2),Nd([ft(".text-color")],zd.prototype,"textColor",2),Nd([ft(".text-alignment")],zd.prototype,"textAlignment",2),Nd([pt()],zd.prototype,"formData",2),Nd([ut({type:String,reflect:!0})],zd.prototype,"cardInnerImageUrl",2),zd=Nd([ct("pbo-type-form")],zd);const Vd=l`
1381
891
  :host {
1382
892
  display: block;
1383
893
  }
@@ -1420,23 +930,24 @@ good aklsdfja`,this.alignment="left",this.fontFamily="Arial",this.color="#000",t
1420
930
  width: 100%;
1421
931
  height: auto;
1422
932
  }
1423
- `,Sh=".splide__container{box-sizing:border-box;position:relative}.splide__list{backface-visibility:hidden;display:-ms-flexbox;display:flex;height:100%;margin:0!important;padding:0!important}.splide.is-initialized:not(.is-active) .splide__list{display:block}.splide__pagination{-ms-flex-align:center;align-items:center;display:-ms-flexbox;display:flex;-ms-flex-wrap:wrap;flex-wrap:wrap;-ms-flex-pack:center;justify-content:center;margin:0;pointer-events:none}.splide__pagination li{display:inline-block;line-height:1;list-style-type:none;margin:0;pointer-events:auto}.splide:not(.is-overflow) .splide__pagination{display:none}.splide__progress__bar{width:0}.splide{position:relative;visibility:hidden}.splide.is-initialized,.splide.is-rendered{visibility:visible}.splide__slide{backface-visibility:hidden;box-sizing:border-box;-ms-flex-negative:0;flex-shrink:0;list-style-type:none!important;margin:0;position:relative}.splide__slide img{vertical-align:bottom}.splide__spinner{animation:splide-loading 1s linear infinite;border:2px solid #999;border-left-color:transparent;border-radius:50%;bottom:0;contain:strict;display:inline-block;height:20px;left:0;margin:auto;position:absolute;right:0;top:0;width:20px}.splide__sr{clip:rect(0 0 0 0);border:0;height:1px;margin:-1px;overflow:hidden;padding:0;position:absolute;width:1px}.splide__toggle.is-active .splide__toggle__play,.splide__toggle__pause{display:none}.splide__toggle.is-active .splide__toggle__pause{display:inline}.splide__track{overflow:hidden;position:relative;z-index:0}@keyframes splide-loading{0%{transform:rotate(0)}to{transform:rotate(1turn)}}.splide__track--draggable{-webkit-touch-callout:none;-webkit-user-select:none;-ms-user-select:none;user-select:none}.splide__track--fade>.splide__list>.splide__slide{margin:0!important;opacity:0;z-index:0}.splide__track--fade>.splide__list>.splide__slide.is-active{opacity:1;z-index:1}.splide--rtl{direction:rtl}.splide__track--ttb>.splide__list{display:block}.splide__arrow{-ms-flex-align:center;align-items:center;background:#ccc;border:0;border-radius:50%;cursor:pointer;display:-ms-flexbox;display:flex;height:2em;-ms-flex-pack:center;justify-content:center;opacity:.7;padding:0;position:absolute;top:50%;transform:translateY(-50%);width:2em;z-index:1}.splide__arrow svg{fill:#000;height:1.2em;width:1.2em}.splide__arrow:hover:not(:disabled){opacity:.9}.splide__arrow:disabled{opacity:.3}.splide__arrow:focus-visible{outline:3px solid #0bf;outline-offset:3px}.splide__arrow--prev{left:1em}.splide__arrow--prev svg{transform:scaleX(-1)}.splide__arrow--next{right:1em}.splide.is-focus-in .splide__arrow:focus{outline:3px solid #0bf;outline-offset:3px}.splide__pagination{bottom:.5em;left:0;padding:0 1em;position:absolute;right:0;z-index:1}.splide__pagination__page{background:#ccc;border:0;border-radius:50%;display:inline-block;height:8px;margin:3px;opacity:.7;padding:0;position:relative;transition:transform .2s linear;width:8px}.splide__pagination__page.is-active{background:#fff;transform:scale(1.4);z-index:1}.splide__pagination__page:hover{cursor:pointer;opacity:.9}.splide__pagination__page:focus-visible{outline:3px solid #0bf;outline-offset:3px}.splide.is-focus-in .splide__pagination__page:focus{outline:3px solid #0bf;outline-offset:3px}.splide__progress__bar{background:#ccc;height:3px}.splide__slide{-webkit-tap-highlight-color:rgba(0,0,0,0)}.splide__slide:focus{outline:0}@supports (outline-offset:-3px){.splide__slide:focus-visible{outline:3px solid #0bf;outline-offset:-3px}}@media screen and (-ms-high-contrast:none){.splide__slide:focus-visible{border:3px solid #0bf}}@supports (outline-offset:-3px){.splide.is-focus-in .splide__slide:focus{outline:3px solid #0bf;outline-offset:-3px}}@media screen and (-ms-high-contrast:none){.splide.is-focus-in .splide__slide:focus{border:3px solid #0bf}.splide.is-focus-in .splide__track>.splide__list>.splide__slide:focus{border-color:#0bf}}.splide__toggle{cursor:pointer}.splide__toggle:focus-visible{outline:3px solid #0bf;outline-offset:3px}.splide.is-focus-in .splide__toggle:focus{outline:3px solid #0bf;outline-offset:3px}.splide__track--nav>.splide__list>.splide__slide{border:3px solid transparent;cursor:pointer}.splide__track--nav>.splide__list>.splide__slide.is-active{border:3px solid #000}.splide__arrows--rtl .splide__arrow--prev{left:auto;right:1em}.splide__arrows--rtl .splide__arrow--prev svg{transform:scaleX(1)}.splide__arrows--rtl .splide__arrow--next{left:1em;right:auto}.splide__arrows--rtl .splide__arrow--next svg{transform:scaleX(-1)}.splide__arrows--ttb .splide__arrow{left:50%;transform:translate(-50%)}.splide__arrows--ttb .splide__arrow--prev{top:1em}.splide__arrows--ttb .splide__arrow--prev svg{transform:rotate(-90deg)}.splide__arrows--ttb .splide__arrow--next{bottom:1em;top:auto}.splide__arrows--ttb .splide__arrow--next svg{transform:rotate(90deg)}.splide__pagination--ttb{bottom:0;display:-ms-flexbox;display:flex;-ms-flex-direction:column;flex-direction:column;left:auto;padding:1em 0;right:.5em;top:0}";function Um(n,t){for(var e=0;e<t.length;e++){var i=t[e];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(n,i.key,i)}}function Gm(n,t,e){return t&&Um(n.prototype,t),Object.defineProperty(n,"prototype",{writable:!1}),n}/*!
1424
- * Splide.js
1425
- * Version : 4.1.4
1426
- * License : MIT
1427
- * Copyright: 2022 Naotoshi Fujita
1428
- */var wh="(prefers-reduced-motion: reduce)",ds=1,Xm=2,fs=3,gs=4,Js=5,En=6,On=7,Km={CREATED:ds,MOUNTED:Xm,IDLE:fs,MOVING:gs,SCROLLING:Js,DRAGGING:En,DESTROYED:On};function Ge(n){n.length=0}function fi(n,t,e){return Array.prototype.slice.call(n,t,e)}function et(n){return n.bind.apply(n,[null].concat(fi(arguments,1)))}var Th=setTimeout,ma=function(){};function Eh(n){return requestAnimationFrame(n)}function An(n,t){return typeof t===n}function Zs(n){return!_a(n)&&An("object",n)}var va=Array.isArray,Oh=et(An,"function"),gi=et(An,"string"),Qs=et(An,"undefined");function _a(n){return n===null}function Ah(n){try{return n instanceof(n.ownerDocument.defaultView||window).HTMLElement}catch{return!1}}function tr(n){return va(n)?n:[n]}function re(n,t){tr(n).forEach(t)}function ba(n,t){return n.indexOf(t)>-1}function Dn(n,t){return n.push.apply(n,tr(t)),n}function Xe(n,t,e){n&&re(t,function(i){i&&n.classList[e?"add":"remove"](i)})}function Ae(n,t){Xe(n,gi(t)?t.split(" "):t,!0)}function er(n,t){re(t,n.appendChild.bind(n))}function ya(n,t){re(n,function(e){var i=(t||e).parentNode;i&&i.insertBefore(e,t)})}function ir(n,t){return Ah(n)&&(n.msMatchesSelector||n.matches).call(n,t)}function Dh(n,t){var e=n?fi(n.children):[];return t?e.filter(function(i){return ir(i,t)}):e}function sr(n,t){return t?Dh(n,t)[0]:n.firstElementChild}var rr=Object.keys;function Fi(n,t,e){return n&&(e?rr(n).reverse():rr(n)).forEach(function(i){i!=="__proto__"&&t(n[i],i)}),n}function nr(n){return fi(arguments,1).forEach(function(t){Fi(t,function(e,i){n[i]=t[i]})}),n}function pi(n){return fi(arguments,1).forEach(function(t){Fi(t,function(e,i){va(e)?n[i]=e.slice():Zs(e)?n[i]=pi({},Zs(n[i])?n[i]:{},e):n[i]=e})}),n}function kh(n,t){re(t||rr(n),function(e){delete n[e]})}function De(n,t){re(n,function(e){re(t,function(i){e&&e.removeAttribute(i)})})}function U(n,t,e){Zs(t)?Fi(t,function(i,s){U(n,s,i)}):re(n,function(i){_a(e)||e===""?De(i,t):i.setAttribute(t,String(e))})}function ps(n,t,e){var i=document.createElement(n);return t&&(gi(t)?Ae(i,t):U(i,t)),e&&er(e,i),i}function me(n,t,e){if(Qs(e))return getComputedStyle(n)[t];_a(e)||(n.style[t]=""+e)}function or(n,t){me(n,"display",t)}function Mh(n){n.setActive&&n.setActive()||n.focus({preventScroll:!0})}function ve(n,t){return n.getAttribute(t)}function Ph(n,t){return n&&n.classList.contains(t)}function ne(n){return n.getBoundingClientRect()}function Ri(n){re(n,function(t){t&&t.parentNode&&t.parentNode.removeChild(t)})}function Ih(n){return sr(new DOMParser().parseFromString(n,"text/html").body)}function Ke(n,t){n.preventDefault(),t&&(n.stopPropagation(),n.stopImmediatePropagation())}function Lh(n,t){return n&&n.querySelector(t)}function xa(n,t){return t?fi(n.querySelectorAll(t)):[]}function qe(n,t){Xe(n,t,!1)}function Ca(n){return n.timeStamp}function Ni(n){return gi(n)?n:n?n+"px":""}var ar="splide",Sa="data-"+ar;function lr(n,t){if(!n)throw new Error("["+ar+"] "+(t||""))}var mi=Math.min,kn=Math.max,Mn=Math.floor,cr=Math.ceil,Wt=Math.abs;function jh(n,t,e){return Wt(n-t)<e}function Pn(n,t,e,i){var s=mi(t,e),r=kn(t,e);return i?s<n&&n<r:s<=n&&n<=r}function ms(n,t,e){var i=mi(t,e),s=kn(t,e);return mi(kn(i,n),s)}function wa(n){return+(n>0)-+(n<0)}function Ta(n,t){return re(t,function(e){n=n.replace("%s",""+e)}),n}function Ea(n){return n<10?"0"+n:""+n}var Fh={};function qm(n){return""+n+Ea(Fh[n]=(Fh[n]||0)+1)}function Rh(){var n=[];function t(o,a,l,c){s(o,a,function(h,u,d){var f="addEventListener"in h,g=f?h.removeEventListener.bind(h,u,l,c):h.removeListener.bind(h,l);f?h.addEventListener(u,l,c):h.addListener(l),n.push([h,u,d,l,g])})}function e(o,a,l){s(o,a,function(c,h,u){n=n.filter(function(d){return d[0]===c&&d[1]===h&&d[2]===u&&(!l||d[3]===l)?(d[4](),!1):!0})})}function i(o,a,l){var c,h=!0;return typeof CustomEvent=="function"?c=new CustomEvent(a,{bubbles:h,detail:l}):(c=document.createEvent("CustomEvent"),c.initCustomEvent(a,h,!1,l)),o.dispatchEvent(c),c}function s(o,a,l){re(o,function(c){c&&re(a,function(h){h.split(" ").forEach(function(u){var d=u.split(".");l(c,d[0],d[1])})})})}function r(){n.forEach(function(o){o[4]()}),Ge(n)}return{bind:t,unbind:e,dispatch:i,destroy:r}}var Bi="mounted",Nh="ready",vi="move",hr="moved",Bh="click",Jm="active",Zm="inactive",Qm="visible",tv="hidden",xt="refresh",Yt="updated",ur="resize",Oa="resized",ev="drag",iv="dragging",sv="dragged",Aa="scroll",vs="scrolled",rv="overflow",$h="destroy",nv="arrows:mounted",ov="arrows:updated",av="pagination:mounted",lv="pagination:updated",Vh="navigation:mounted",zh="autoplay:play",cv="autoplay:playing",Hh="autoplay:pause",Wh="lazyload:loaded",Yh="sk",Uh="sh",In="ei";function ht(n){var t=n?n.event.bus:document.createDocumentFragment(),e=Rh();function i(r,o){e.bind(t,tr(r).join(" "),function(a){o.apply(o,va(a.detail)?a.detail:[])})}function s(r){e.dispatch(t,r,fi(arguments,1))}return n&&n.event.on($h,e.destroy),nr(e,{bus:t,on:i,off:et(e.unbind,t),emit:s})}function Ln(n,t,e,i){var s=Date.now,r,o=0,a,l=!0,c=0;function h(){if(!l){if(o=n?mi((s()-r)/n,1):1,e&&e(o),o>=1&&(t(),r=s(),i&&++c>=i))return d();a=Eh(h)}}function u(v){v||g(),r=s()-(v?o*n:0),l=!1,a=Eh(h)}function d(){l=!0}function f(){r=s(),o=0,e&&e(o)}function g(){a&&cancelAnimationFrame(a),o=0,a=0,l=!0}function p(v){n=v}function m(){return l}return{start:u,rewind:f,pause:d,cancel:g,set:p,isPaused:m}}function hv(n){var t=n;function e(s){t=s}function i(s){return ba(tr(s),t)}return{set:e,is:i}}function uv(n,t){var e=Ln(0,n,null,1);return function(){e.isPaused()&&e.start()}}function dv(n,t,e){var i=n.state,s=e.breakpoints||{},r=e.reducedMotion||{},o=Rh(),a=[];function l(){var g=e.mediaQuery==="min";rr(s).sort(function(p,m){return g?+p-+m:+m-+p}).forEach(function(p){h(s[p],"("+(g?"min":"max")+"-width:"+p+"px)")}),h(r,wh),u()}function c(g){g&&o.destroy()}function h(g,p){var m=matchMedia(p);o.bind(m,"change",u),a.push([g,m])}function u(){var g=i.is(On),p=e.direction,m=a.reduce(function(v,y){return pi(v,y[1].matches?y[0]:{})},{});kh(e),f(m),e.destroy?n.destroy(e.destroy==="completely"):g?(c(!0),n.mount()):p!==e.direction&&n.refresh()}function d(g){matchMedia(wh).matches&&(g?pi(e,r):kh(e,rr(r)))}function f(g,p,m){pi(e,g),p&&pi(Object.getPrototypeOf(e),g),(m||!i.is(ds))&&n.emit(Yt,e)}return{setup:l,destroy:c,reduce:d,set:f}}var jn="Arrow",Fn=jn+"Left",Rn=jn+"Right",Gh=jn+"Up",Xh=jn+"Down",Kh="rtl",Nn="ttb",Da={width:["height"],left:["top","right"],right:["bottom","left"],x:["y"],X:["Y"],Y:["X"],ArrowLeft:[Gh,Rn],ArrowRight:[Xh,Fn]};function fv(n,t,e){function i(r,o,a){a=a||e.direction;var l=a===Kh&&!o?1:a===Nn?0:-1;return Da[r]&&Da[r][l]||r.replace(/width|left|right/i,function(c,h){var u=Da[c.toLowerCase()][l]||c;return h>0?u.charAt(0).toUpperCase()+u.slice(1):u})}function s(r){return r*(e.direction===Kh?1:-1)}return{resolve:i,orient:s}}var Je="role",_s="tabindex",gv="disabled",_e="aria-",dr=_e+"controls",qh=_e+"current",Jh=_e+"selected",oe=_e+"label",ka=_e+"labelledby",Zh=_e+"hidden",Ma=_e+"orientation",fr=_e+"roledescription",Qh=_e+"live",tu=_e+"busy",eu=_e+"atomic",Pa=[Je,_s,gv,dr,qh,oe,ka,Zh,Ma,fr],ke=ar+"__",_i="is-",Ia=ar,iu=ke+"track",pv=ke+"list",Bn=ke+"slide",su=Bn+"--clone",mv=Bn+"__container",La=ke+"arrows",$n=ke+"arrow",ru=$n+"--prev",nu=$n+"--next",Vn=ke+"pagination",ou=Vn+"__page",vv=ke+"progress",_v=vv+"__bar",bv=ke+"toggle",yv=ke+"spinner",xv=ke+"sr",Cv=_i+"initialized",$i=_i+"active",au=_i+"prev",lu=_i+"next",ja=_i+"visible",Fa=_i+"loading",cu=_i+"focus-in",hu=_i+"overflow",Sv=[$i,ja,au,lu,Fa,cu,hu],wv={slide:Bn,clone:su,arrows:La,arrow:$n,prev:ru,next:nu,pagination:Vn,page:ou,spinner:yv};function Tv(n,t){if(Oh(n.closest))return n.closest(t);for(var e=n;e&&e.nodeType===1&&!ir(e,t);)e=e.parentElement;return e}var Ev=5,uu=200,du="touchstart mousedown",Ra="touchmove mousemove",Na="touchend touchcancel mouseup click";function Ov(n,t,e){var i=ht(n),s=i.on,r=i.bind,o=n.root,a=e.i18n,l={},c=[],h=[],u=[],d,f,g;function p(){x(),E(),y()}function m(){s(xt,v),s(xt,p),s(Yt,y),r(document,du+" keydown",function(S){g=S.type==="keydown"},{capture:!0}),r(o,"focusin",function(){Xe(o,cu,!!g)})}function v(S){var w=Pa.concat("style");Ge(c),qe(o,h),qe(d,u),De([d,f],w),De(o,S?w:["style",fr])}function y(){qe(o,h),qe(d,u),h=k(Ia),u=k(iu),Ae(o,h),Ae(d,u),U(o,oe,e.label),U(o,ka,e.labelledby)}function x(){d=T("."+iu),f=sr(d,"."+pv),lr(d&&f,"A track/list element is missing."),Dn(c,Dh(f,"."+Bn+":not(."+su+")")),Fi({arrows:La,pagination:Vn,prev:ru,next:nu,bar:_v,toggle:bv},function(S,w){l[w]=T("."+S)}),nr(l,{root:o,track:d,list:f,slides:c})}function E(){var S=o.id||qm(ar),w=e.role;o.id=S,d.id=d.id||S+"-track",f.id=f.id||S+"-list",!ve(o,Je)&&o.tagName!=="SECTION"&&w&&U(o,Je,w),U(o,fr,a.carousel),U(f,Je,"presentation")}function T(S){var w=Lh(o,S);return w&&Tv(w,"."+Ia)===o?w:void 0}function k(S){return[S+"--"+e.type,S+"--"+e.direction,e.drag&&S+"--draggable",e.isNavigation&&S+"--nav",S===Ia&&$i]}return nr(l,{setup:p,mount:m,destroy:v})}var bs="slide",ys="loop",gr="fade";function Av(n,t,e,i){var s=ht(n),r=s.on,o=s.emit,a=s.bind,l=n.Components,c=n.root,h=n.options,u=h.isNavigation,d=h.updateOnMove,f=h.i18n,g=h.pagination,p=h.slideFocus,m=l.Direction.resolve,v=ve(i,"style"),y=ve(i,oe),x=e>-1,E=sr(i,"."+mv),T;function k(){x||(i.id=c.id+"-slide"+Ea(t+1),U(i,Je,g?"tabpanel":"group"),U(i,fr,f.slide),U(i,oe,y||Ta(f.slideLabel,[t+1,n.length]))),S()}function S(){a(i,"click",et(o,Bh,R)),a(i,"keydown",et(o,Yh,R)),r([hr,Uh,vs],A),r(Vh,L),d&&r(vi,j)}function w(){T=!0,s.destroy(),qe(i,Sv),De(i,Pa),U(i,"style",v),U(i,oe,y||"")}function L(){var N=n.splides.map(function(M){var V=M.splide.Components.Slides.getAt(t);return V?V.slide.id:""}).join(" ");U(i,oe,Ta(f.slideX,(x?e:t)+1)),U(i,dr,N),U(i,Je,p?"button":""),p&&De(i,fr)}function j(){T||A()}function A(){if(!T){var N=n.index;O(),D(),Xe(i,au,t===N-1),Xe(i,lu,t===N+1)}}function O(){var N=$();N!==Ph(i,$i)&&(Xe(i,$i,N),U(i,qh,u&&N||""),o(N?Jm:Zm,R))}function D(){var N=X(),M=!N&&(!$()||x);if(n.state.is([gs,Js])||U(i,Zh,M||""),U(xa(i,h.focusableNodes||""),_s,M?-1:""),p&&U(i,_s,M?-1:0),N!==Ph(i,ja)&&(Xe(i,ja,N),o(N?Qm:tv,R)),!N&&document.activeElement===i){var V=l.Slides.getAt(n.index);V&&Mh(V.slide)}}function I(N,M,V){me(V&&E||i,N,M)}function $(){var N=n.index;return N===t||h.cloneStatus&&N===e}function X(){if(n.is(gr))return $();var N=ne(l.Elements.track),M=ne(i),V=m("left",!0),q=m("right",!0);return Mn(N[V])<=cr(M[V])&&Mn(M[q])<=cr(N[q])}function K(N,M){var V=Wt(N-t);return!x&&(h.rewind||n.is(ys))&&(V=mi(V,n.length-V)),V<=M}var R={index:t,slideIndex:e,slide:i,container:E,isClone:x,mount:k,destroy:w,update:A,style:I,isWithin:K};return R}function Dv(n,t,e){var i=ht(n),s=i.on,r=i.emit,o=i.bind,a=t.Elements,l=a.slides,c=a.list,h=[];function u(){d(),s(xt,f),s(xt,d)}function d(){l.forEach(function(A,O){p(A,O,-1)})}function f(){T(function(A){A.destroy()}),Ge(h)}function g(){T(function(A){A.update()})}function p(A,O,D){var I=Av(n,O,D,A);I.mount(),h.push(I),h.sort(function($,X){return $.index-X.index})}function m(A){return A?k(function(O){return!O.isClone}):h}function v(A){var O=t.Controller,D=O.toIndex(A),I=O.hasFocus()?1:e.perPage;return k(function($){return Pn($.index,D,D+I-1)})}function y(A){return k(A)[0]}function x(A,O){re(A,function(D){if(gi(D)&&(D=Ih(D)),Ah(D)){var I=l[O];I?ya(D,I):er(c,D),Ae(D,e.classes.slide),w(D,et(r,ur))}}),r(xt)}function E(A){Ri(k(A).map(function(O){return O.slide})),r(xt)}function T(A,O){m(O).forEach(A)}function k(A){return h.filter(Oh(A)?A:function(O){return gi(A)?ir(O.slide,A):ba(tr(A),O.index)})}function S(A,O,D){T(function(I){I.style(A,O,D)})}function w(A,O){var D=xa(A,"img"),I=D.length;I?D.forEach(function($){o($,"load error",function(){--I||O()})}):O()}function L(A){return A?l.length:h.length}function j(){return h.length>e.perPage}return{mount:u,destroy:f,update:g,register:p,get:m,getIn:v,getAt:y,add:x,remove:E,forEach:T,filter:k,style:S,getLength:L,isEnough:j}}function kv(n,t,e){var i=ht(n),s=i.on,r=i.bind,o=i.emit,a=t.Slides,l=t.Direction.resolve,c=t.Elements,h=c.root,u=c.track,d=c.list,f=a.getAt,g=a.style,p,m,v;function y(){x(),r(window,"resize load",uv(et(o,ur))),s([Yt,xt],x),s(ur,E)}function x(){p=e.direction===Nn,me(h,"maxWidth",Ni(e.width)),me(u,l("paddingLeft"),T(!1)),me(u,l("paddingRight"),T(!0)),E(!0)}function E(R){var N=ne(h);(R||m.width!==N.width||m.height!==N.height)&&(me(u,"height",k()),g(l("marginRight"),Ni(e.gap)),g("width",w()),g("height",L(),!0),m=N,o(Oa),v!==(v=K())&&(Xe(h,hu,v),o(rv,v)))}function T(R){var N=e.padding,M=l(R?"right":"left");return N&&Ni(N[M]||(Zs(N)?0:N))||"0px"}function k(){var R="";return p&&(R=S(),lr(R,"height or heightRatio is missing."),R="calc("+R+" - "+T(!1)+" - "+T(!0)+")"),R}function S(){return Ni(e.height||ne(d).width*e.heightRatio)}function w(){return e.autoWidth?null:Ni(e.fixedWidth)||(p?"":j())}function L(){return Ni(e.fixedHeight)||(p?e.autoHeight?null:j():S())}function j(){var R=Ni(e.gap);return"calc((100%"+(R&&" + "+R)+")/"+(e.perPage||1)+(R&&" - "+R)+")"}function A(){return ne(d)[l("width")]}function O(R,N){var M=f(R||0);return M?ne(M.slide)[l("width")]+(N?0:$()):0}function D(R,N){var M=f(R);if(M){var V=ne(M.slide)[l("right")],q=ne(d)[l("left")];return Wt(V-q)+(N?0:$())}return 0}function I(R){return D(n.length-1)-D(0)+O(0,R)}function $(){var R=f(0);return R&&parseFloat(me(R.slide,l("marginRight")))||0}function X(R){return parseFloat(me(u,l("padding"+(R?"Right":"Left"))))||0}function K(){return n.is(gr)||I(!0)>A()}return{mount:y,resize:E,listSize:A,slideSize:O,sliderSize:I,totalSize:D,getPadding:X,isOverflow:K}}var Mv=2;function Pv(n,t,e){var i=ht(n),s=i.on,r=t.Elements,o=t.Slides,a=t.Direction.resolve,l=[],c;function h(){s(xt,u),s([Yt,ur],f),(c=m())&&(g(c),t.Layout.resize(!0))}function u(){d(),h()}function d(){Ri(l),Ge(l),i.destroy()}function f(){var v=m();c!==v&&(c<v||!v)&&i.emit(xt)}function g(v){var y=o.get().slice(),x=y.length;if(x){for(;y.length<v;)Dn(y,y);Dn(y.slice(-v),y.slice(0,v)).forEach(function(E,T){var k=T<v,S=p(E.slide,T);k?ya(S,y[0].slide):er(r.list,S),Dn(l,S),o.register(S,T-v+(k?0:x),E.index)})}}function p(v,y){var x=v.cloneNode(!0);return Ae(x,e.classes.clone),x.id=n.root.id+"-clone"+Ea(y+1),x}function m(){var v=e.clones;if(!n.is(ys))v=0;else if(Qs(v)){var y=e[a("fixedWidth")]&&t.Layout.slideSize(0),x=y&&cr(ne(r.track)[a("width")]/y);v=x||e[a("autoWidth")]&&n.length||e.perPage*Mv}return v}return{mount:h,destroy:d}}function Iv(n,t,e){var i=ht(n),s=i.on,r=i.emit,o=n.state.set,a=t.Layout,l=a.slideSize,c=a.getPadding,h=a.totalSize,u=a.listSize,d=a.sliderSize,f=t.Direction,g=f.resolve,p=f.orient,m=t.Elements,v=m.list,y=m.track,x;function E(){x=t.Transition,s([Bi,Oa,Yt,xt],T)}function T(){t.Controller.isBusy()||(t.Scroll.cancel(),S(n.index),t.Slides.update())}function k(M,V,q,ut){M!==V&&R(M>q)&&(A(),w(j(I(),M>q),!0)),o(gs),r(vi,V,q,M),x.start(V,function(){o(fs),r(hr,V,q,M),ut&&ut()})}function S(M){w(D(M,!0))}function w(M,V){if(!n.is(gr)){var q=V?M:L(M);me(v,"transform","translate"+g("X")+"("+q+"px)"),M!==q&&r(Uh)}}function L(M){if(n.is(ys)){var V=O(M),q=V>t.Controller.getEnd(),ut=V<0;(ut||q)&&(M=j(M,q))}return M}function j(M,V){var q=M-K(V),ut=d();return M-=p(ut*(cr(Wt(q)/ut)||1))*(V?1:-1),M}function A(){w(I(),!0),x.cancel()}function O(M){for(var V=t.Slides.get(),q=0,ut=1/0,it=0;it<V.length;it++){var qt=V[it].index,P=Wt(D(qt,!0)-M);if(P<=ut)ut=P,q=qt;else break}return q}function D(M,V){var q=p(h(M-1)-X(M));return V?$(q):q}function I(){var M=g("left");return ne(v)[M]-ne(y)[M]+p(c(!1))}function $(M){return e.trimSpace&&n.is(bs)&&(M=ms(M,0,p(d(!0)-u()))),M}function X(M){var V=e.focus;return V==="center"?(u()-l(M,!0))/2:+V*l(M)||0}function K(M){return D(M?t.Controller.getEnd():0,!!e.trimSpace)}function R(M){var V=p(j(I(),M));return M?V>=0:V<=v[g("scrollWidth")]-ne(y)[g("width")]}function N(M,V){V=Qs(V)?I():V;var q=M!==!0&&p(V)<p(K(!1)),ut=M!==!1&&p(V)>p(K(!0));return q||ut}return{mount:E,move:k,jump:S,translate:w,shift:j,cancel:A,toIndex:O,toPosition:D,getPosition:I,getLimit:K,exceededLimit:N,reposition:T}}function Lv(n,t,e){var i=ht(n),s=i.on,r=i.emit,o=t.Move,a=o.getPosition,l=o.getLimit,c=o.toPosition,h=t.Slides,u=h.isEnough,d=h.getLength,f=e.omitEnd,g=n.is(ys),p=n.is(bs),m=et(I,!1),v=et(I,!0),y=e.start||0,x,E=y,T,k,S;function w(){L(),s([Yt,xt,In],L),s(Oa,j)}function L(){T=d(!0),k=e.perMove,S=e.perPage,x=R();var P=ms(y,0,f?x:T-1);P!==y&&(y=P,o.reposition())}function j(){x!==R()&&r(In)}function A(P,Z,kt){if(!qt()){var nt=D(P),ot=K(nt);ot>-1&&(Z||ot!==y)&&(q(ot),o.move(nt,ot,E,kt))}}function O(P,Z,kt,nt){t.Scroll.scroll(P,Z,kt,function(){var ot=K(o.toIndex(a()));q(f?mi(ot,x):ot),nt&&nt()})}function D(P){var Z=y;if(gi(P)){var kt=P.match(/([+\-<>])(\d+)?/)||[],nt=kt[1],ot=kt[2];nt==="+"||nt==="-"?Z=$(y+ +(""+nt+(+ot||1)),y):nt===">"?Z=ot?N(+ot):m(!0):nt==="<"&&(Z=v(!0))}else Z=g?P:ms(P,0,x);return Z}function I(P,Z){var kt=k||(it()?1:S),nt=$(y+kt*(P?-1:1),y,!(k||it()));return nt===-1&&p&&!jh(a(),l(!P),1)?P?0:x:Z?nt:K(nt)}function $(P,Z,kt){if(u()||it()){var nt=X(P);nt!==P&&(Z=P,P=nt,kt=!1),P<0||P>x?!k&&(Pn(0,P,Z,!0)||Pn(x,Z,P,!0))?P=N(M(P)):g?P=kt?P<0?-(T%S||S):T:P:e.rewind?P=P<0?x:0:P=-1:kt&&P!==Z&&(P=N(M(Z)+(P<Z?-1:1)))}else P=-1;return P}function X(P){if(p&&e.trimSpace==="move"&&P!==y)for(var Z=a();Z===c(P,!0)&&Pn(P,0,n.length-1,!e.rewind);)P<y?--P:++P;return P}function K(P){return g?(P+T)%T||0:P}function R(){for(var P=T-(it()||g&&k?1:S);f&&P-- >0;)if(c(T-1,!0)!==c(P,!0)){P++;break}return ms(P,0,T-1)}function N(P){return ms(it()?P:S*P,0,x)}function M(P){return it()?mi(P,x):Mn((P>=x?T-1:P)/S)}function V(P){var Z=o.toIndex(P);return p?ms(Z,0,x):Z}function q(P){P!==y&&(E=y,y=P)}function ut(P){return P?E:y}function it(){return!Qs(e.focus)||e.isNavigation}function qt(){return n.state.is([gs,Js])&&!!e.waitForTransition}return{mount:w,go:A,scroll:O,getNext:m,getPrev:v,getAdjacent:I,getEnd:R,setIndex:q,getIndex:ut,toIndex:N,toPage:M,toDest:V,hasFocus:it,isBusy:qt}}var jv="http://www.w3.org/2000/svg",Fv="m15.5 0.932-4.3 4.38 14.5 14.6-14.5 14.5 4.3 4.4 14.6-14.6 4.4-4.3-4.4-4.4-14.6-14.6z",zn=40;function Rv(n,t,e){var i=ht(n),s=i.on,r=i.bind,o=i.emit,a=e.classes,l=e.i18n,c=t.Elements,h=t.Controller,u=c.arrows,d=c.track,f=u,g=c.prev,p=c.next,m,v,y={};function x(){T(),s(Yt,E)}function E(){k(),x()}function T(){var O=e.arrows;O&&!(g&&p)&&L(),g&&p&&(nr(y,{prev:g,next:p}),or(f,O?"":"none"),Ae(f,v=La+"--"+e.direction),O&&(S(),A(),U([g,p],dr,d.id),o(nv,g,p)))}function k(){i.destroy(),qe(f,v),m?(Ri(u?[g,p]:f),g=p=null):De([g,p],Pa)}function S(){s([Bi,hr,xt,vs,In],A),r(p,"click",et(w,">")),r(g,"click",et(w,"<"))}function w(O){h.go(O,!0)}function L(){f=u||ps("div",a.arrows),g=j(!0),p=j(!1),m=!0,er(f,[g,p]),!u&&ya(f,d)}function j(O){var D='<button class="'+a.arrow+" "+(O?a.prev:a.next)+'" type="button"><svg xmlns="'+jv+'" viewBox="0 0 '+zn+" "+zn+'" width="'+zn+'" height="'+zn+'" focusable="false"><path d="'+(e.arrowPath||Fv)+'" />';return Ih(D)}function A(){if(g&&p){var O=n.index,D=h.getPrev(),I=h.getNext(),$=D>-1&&O<D?l.last:l.prev,X=I>-1&&O>I?l.first:l.next;g.disabled=D<0,p.disabled=I<0,U(g,oe,$),U(p,oe,X),o(ov,g,p,D,I)}}return{arrows:y,mount:x,destroy:k,update:A}}var Nv=Sa+"-interval";function Bv(n,t,e){var i=ht(n),s=i.on,r=i.bind,o=i.emit,a=Ln(e.interval,n.go.bind(n,">"),S),l=a.isPaused,c=t.Elements,h=t.Elements,u=h.root,d=h.toggle,f=e.autoplay,g,p,m=f==="pause";function v(){f&&(y(),d&&U(d,dr,c.track.id),m||x(),k())}function y(){e.pauseOnHover&&r(u,"mouseenter mouseleave",function(L){g=L.type==="mouseenter",T()}),e.pauseOnFocus&&r(u,"focusin focusout",function(L){p=L.type==="focusin",T()}),d&&r(d,"click",function(){m?x():E(!0)}),s([vi,Aa,xt],a.rewind),s(vi,w)}function x(){l()&&t.Slides.isEnough()&&(a.start(!e.resetProgress),p=g=m=!1,k(),o(zh))}function E(L){L===void 0&&(L=!0),m=!!L,k(),l()||(a.pause(),o(Hh))}function T(){m||(g||p?E(!1):x())}function k(){d&&(Xe(d,$i,!m),U(d,oe,e.i18n[m?"play":"pause"]))}function S(L){var j=c.bar;j&&me(j,"width",L*100+"%"),o(cv,L)}function w(L){var j=t.Slides.getAt(L);a.set(j&&+ve(j.slide,Nv)||e.interval)}return{mount:v,destroy:a.cancel,play:x,pause:E,isPaused:l}}function $v(n,t,e){var i=ht(n),s=i.on;function r(){e.cover&&(s(Wh,et(a,!0)),s([Bi,Yt,xt],et(o,!0)))}function o(l){t.Slides.forEach(function(c){var h=sr(c.container||c.slide,"img");h&&h.src&&a(l,h,c)})}function a(l,c,h){h.style("background",l?'center/cover no-repeat url("'+c.src+'")':"",!0),or(c,l?"none":"")}return{mount:r,destroy:et(o,!1)}}var Vv=10,zv=600,Hv=.6,Wv=1.5,Yv=800;function Uv(n,t,e){var i=ht(n),s=i.on,r=i.emit,o=n.state.set,a=t.Move,l=a.getPosition,c=a.getLimit,h=a.exceededLimit,u=a.translate,d=n.is(bs),f,g,p=1;function m(){s(vi,E),s([Yt,xt],T)}function v(S,w,L,j,A){var O=l();if(E(),L&&(!d||!h())){var D=t.Layout.sliderSize(),I=wa(S)*D*Mn(Wt(S)/D)||0;S=a.toPosition(t.Controller.toDest(S%D))+I}var $=jh(O,S,1);p=1,w=$?0:w||kn(Wt(S-O)/Wv,Yv),g=j,f=Ln(w,y,et(x,O,S,A),1),o(Js),r(Aa),f.start()}function y(){o(fs),g&&g(),r(vs)}function x(S,w,L,j){var A=l(),O=S+(w-S)*k(j),D=(O-A)*p;u(A+D),d&&!L&&h()&&(p*=Hv,Wt(D)<Vv&&v(c(h(!0)),zv,!1,g,!0))}function E(){f&&f.cancel()}function T(){f&&!f.isPaused()&&(E(),y())}function k(S){var w=e.easingFunc;return w?w(S):1-Math.pow(1-S,4)}return{mount:m,destroy:E,scroll:v,cancel:T}}var xs={passive:!1,capture:!0};function Gv(n,t,e){var i=ht(n),s=i.on,r=i.emit,o=i.bind,a=i.unbind,l=n.state,c=t.Move,h=t.Scroll,u=t.Controller,d=t.Elements.track,f=t.Media.reduce,g=t.Direction,p=g.resolve,m=g.orient,v=c.getPosition,y=c.exceededLimit,x,E,T,k,S,w=!1,L,j,A;function O(){o(d,Ra,ma,xs),o(d,Na,ma,xs),o(d,du,I,xs),o(d,"click",K,{capture:!0}),o(d,"dragstart",Ke),s([Bi,Yt],D)}function D(){var B=e.drag;vu(!B),k=B==="free"}function I(B){if(L=!1,!j){var at=ot(B);nt(B.target)&&(at||!B.button)&&(u.isBusy()?Ke(B,!0):(A=at?d:window,S=l.is([gs,Js]),T=null,o(A,Ra,$,xs),o(A,Na,X,xs),c.cancel(),h.cancel(),R(B)))}}function $(B){if(l.is(En)||(l.set(En),r(ev)),B.cancelable)if(S){c.translate(x+kt(it(B)));var at=qt(B)>uu,zi=w!==(w=y());(at||zi)&&R(B),L=!0,r(iv),Ke(B)}else V(B)&&(S=M(B),Ke(B))}function X(B){l.is(En)&&(l.set(fs),r(sv)),S&&(N(B),Ke(B)),a(A,Ra,$),a(A,Na,X),S=!1}function K(B){!j&&L&&Ke(B,!0)}function R(B){T=E,E=B,x=v()}function N(B){var at=q(B),zi=ut(at),_r=e.rewind&&e.rewindByDrag;f(!1),k?u.scroll(zi,0,e.snap):n.is(gr)?u.go(m(wa(at))<0?_r?"<":"-":_r?">":"+"):n.is(bs)&&w&&_r?u.go(y(!0)?">":"<"):u.go(u.toDest(zi),!0),f(!0)}function M(B){var at=e.dragMinThreshold,zi=Zs(at),_r=zi&&at.mouse||0,j_=(zi?at.touch:+at)||10;return Wt(it(B))>(ot(B)?j_:_r)}function V(B){return Wt(it(B))>Wt(it(B,!0))}function q(B){if(n.is(ys)||!w){var at=qt(B);if(at&&at<uu)return it(B)/at}return 0}function ut(B){return v()+wa(B)*mi(Wt(B)*(e.flickPower||600),k?1/0:t.Layout.listSize()*(e.flickMaxPages||1))}function it(B,at){return Z(B,at)-Z(P(B),at)}function qt(B){return Ca(B)-Ca(P(B))}function P(B){return E===B&&T||E}function Z(B,at){return(ot(B)?B.changedTouches[0]:B)["page"+p(at?"Y":"X")]}function kt(B){return B/(w&&n.is(bs)?Ev:1)}function nt(B){var at=e.noDrag;return!ir(B,"."+ou+", ."+$n)&&(!at||!ir(B,at))}function ot(B){return typeof TouchEvent<"u"&&B instanceof TouchEvent}function L_(){return S}function vu(B){j=B}return{mount:O,disable:vu,isDragging:L_}}var Xv={Spacebar:" ",Right:Rn,Left:Fn,Up:Gh,Down:Xh};function Ba(n){return n=gi(n)?n:n.key,Xv[n]||n}var fu="keydown";function Kv(n,t,e){var i=ht(n),s=i.on,r=i.bind,o=i.unbind,a=n.root,l=t.Direction.resolve,c,h;function u(){d(),s(Yt,f),s(Yt,d),s(vi,p)}function d(){var v=e.keyboard;v&&(c=v==="global"?window:a,r(c,fu,m))}function f(){o(c,fu)}function g(v){h=v}function p(){var v=h;h=!0,Th(function(){h=v})}function m(v){if(!h){var y=Ba(v);y===l(Fn)?n.go("<"):y===l(Rn)&&n.go(">")}}return{mount:u,destroy:f,disable:g}}var pr=Sa+"-lazy",Hn=pr+"-srcset",qv="["+pr+"], ["+Hn+"]";function Jv(n,t,e){var i=ht(n),s=i.on,r=i.off,o=i.bind,a=i.emit,l=e.lazyLoad==="sequential",c=[hr,vs],h=[];function u(){e.lazyLoad&&(d(),s(xt,d))}function d(){Ge(h),f(),l?v():(r(c),s(c,g),g())}function f(){t.Slides.forEach(function(y){xa(y.slide,qv).forEach(function(x){var E=ve(x,pr),T=ve(x,Hn);if(E!==x.src||T!==x.srcset){var k=e.classes.spinner,S=x.parentElement,w=sr(S,"."+k)||ps("span",k,S);h.push([x,y,w]),x.src||or(x,"none")}})})}function g(){h=h.filter(function(y){var x=e.perPage*((e.preloadPages||1)+1)-1;return y[1].isWithin(n.index,x)?p(y):!0}),h.length||r(c)}function p(y){var x=y[0];Ae(y[1].slide,Fa),o(x,"load error",et(m,y)),U(x,"src",ve(x,pr)),U(x,"srcset",ve(x,Hn)),De(x,pr),De(x,Hn)}function m(y,x){var E=y[0],T=y[1];qe(T.slide,Fa),x.type!=="error"&&(Ri(y[2]),or(E,""),a(Wh,E,T),a(ur)),l&&v()}function v(){h.length&&p(h.shift())}return{mount:u,destroy:et(Ge,h),check:g}}function Zv(n,t,e){var i=ht(n),s=i.on,r=i.emit,o=i.bind,a=t.Slides,l=t.Elements,c=t.Controller,h=c.hasFocus,u=c.getIndex,d=c.go,f=t.Direction.resolve,g=l.pagination,p=[],m,v;function y(){x(),s([Yt,xt,In],y);var j=e.pagination;g&&or(g,j?"":"none"),j&&(s([vi,Aa,vs],L),E(),L(),r(av,{list:m,items:p},w(n.index)))}function x(){m&&(Ri(g?fi(m.children):m),qe(m,v),Ge(p),m=null),i.destroy()}function E(){var j=n.length,A=e.classes,O=e.i18n,D=e.perPage,I=h()?c.getEnd()+1:cr(j/D);m=g||ps("ul",A.pagination,l.track.parentElement),Ae(m,v=Vn+"--"+S()),U(m,Je,"tablist"),U(m,oe,O.select),U(m,Ma,S()===Nn?"vertical":"");for(var $=0;$<I;$++){var X=ps("li",null,m),K=ps("button",{class:A.page,type:"button"},X),R=a.getIn($).map(function(M){return M.slide.id}),N=!h()&&D>1?O.pageX:O.slideX;o(K,"click",et(T,$)),e.paginationKeyboard&&o(K,"keydown",et(k,$)),U(X,Je,"presentation"),U(K,Je,"tab"),U(K,dr,R.join(" ")),U(K,oe,Ta(N,$+1)),U(K,_s,-1),p.push({li:X,button:K,page:$})}}function T(j){d(">"+j,!0)}function k(j,A){var O=p.length,D=Ba(A),I=S(),$=-1;D===f(Rn,!1,I)?$=++j%O:D===f(Fn,!1,I)?$=(--j+O)%O:D==="Home"?$=0:D==="End"&&($=O-1);var X=p[$];X&&(Mh(X.button),d(">"+$),Ke(A,!0))}function S(){return e.paginationDirection||e.direction}function w(j){return p[c.toPage(j)]}function L(){var j=w(u(!0)),A=w(u());if(j){var O=j.button;qe(O,$i),De(O,Jh),U(O,_s,-1)}if(A){var D=A.button;Ae(D,$i),U(D,Jh,!0),U(D,_s,"")}r(lv,{list:m,items:p},j,A)}return{items:p,mount:y,destroy:x,getAt:w,update:L}}var Qv=[" ","Enter"];function t_(n,t,e){var i=e.isNavigation,s=e.slideFocus,r=[];function o(){n.splides.forEach(function(g){g.isParent||(c(n,g.splide),c(g.splide,n))}),i&&h()}function a(){r.forEach(function(g){g.destroy()}),Ge(r)}function l(){a(),o()}function c(g,p){var m=ht(g);m.on(vi,function(v,y,x){p.go(p.is(ys)?x:v)}),r.push(m)}function h(){var g=ht(n),p=g.on;p(Bh,d),p(Yh,f),p([Bi,Yt],u),r.push(g),g.emit(Vh,n.splides)}function u(){U(t.Elements.list,Ma,e.direction===Nn?"vertical":"")}function d(g){n.go(g.index)}function f(g,p){ba(Qv,Ba(p))&&(d(g),Ke(p))}return{setup:et(t.Media.set,{slideFocus:Qs(s)?i:s},!0),mount:o,destroy:a,remount:l}}function e_(n,t,e){var i=ht(n),s=i.bind,r=0;function o(){e.wheel&&s(t.Elements.track,"wheel",a,xs)}function a(c){if(c.cancelable){var h=c.deltaY,u=h<0,d=Ca(c),f=e.wheelMinThreshold||0,g=e.wheelSleep||0;Wt(h)>f&&d-r>g&&(n.go(u?"<":">"),r=d),l(u)&&Ke(c)}}function l(c){return!e.releaseWheel||n.state.is(gs)||t.Controller.getAdjacent(c)!==-1}return{mount:o}}var i_=90;function s_(n,t,e){var i=ht(n),s=i.on,r=t.Elements.track,o=e.live&&!e.isNavigation,a=ps("span",xv),l=Ln(i_,et(h,!1));function c(){o&&(d(!t.Autoplay.isPaused()),U(r,eu,!0),a.textContent="…",s(zh,et(d,!0)),s(Hh,et(d,!1)),s([hr,vs],et(h,!0)))}function h(f){U(r,tu,f),f?(er(r,a),l.start()):(Ri(a),l.cancel())}function u(){De(r,[Qh,eu,tu]),Ri(a)}function d(f){o&&U(r,Qh,f?"off":"polite")}return{mount:c,disable:d,destroy:u}}var r_=Object.freeze({__proto__:null,Media:dv,Direction:fv,Elements:Ov,Slides:Dv,Layout:kv,Clones:Pv,Move:Iv,Controller:Lv,Arrows:Rv,Autoplay:Bv,Cover:$v,Scroll:Uv,Drag:Gv,Keyboard:Kv,LazyLoad:Jv,Pagination:Zv,Sync:t_,Wheel:e_,Live:s_}),n_={prev:"Previous slide",next:"Next slide",first:"Go to first slide",last:"Go to last slide",slideX:"Go to slide %s",pageX:"Go to page %s",play:"Start autoplay",pause:"Pause autoplay",carousel:"carousel",slide:"slide",select:"Select a slide to show",slideLabel:"%s of %s"},o_={type:"slide",role:"region",speed:400,perPage:1,cloneStatus:!0,arrows:!0,pagination:!0,paginationKeyboard:!0,interval:5e3,pauseOnHover:!0,pauseOnFocus:!0,resetProgress:!0,easing:"cubic-bezier(0.25, 1, 0.5, 1)",drag:!0,direction:"ltr",trimSpace:!0,focusableNodes:"a, button, textarea, input, select, iframe",live:!0,classes:wv,i18n:n_,reducedMotion:{speed:0,rewindSpeed:0,autoplay:"pause"}};function a_(n,t,e){var i=t.Slides;function s(){ht(n).on([Bi,xt],r)}function r(){i.forEach(function(a){a.style("transform","translateX(-"+100*a.index+"%)")})}function o(a,l){i.style("transition","opacity "+e.speed+"ms "+e.easing),Th(l)}return{mount:s,start:o,cancel:ma}}function l_(n,t,e){var i=t.Move,s=t.Controller,r=t.Scroll,o=t.Elements.list,a=et(me,o,"transition"),l;function c(){ht(n).bind(o,"transitionend",function(f){f.target===o&&l&&(u(),l())})}function h(f,g){var p=i.toPosition(f,!0),m=i.getPosition(),v=d(f);Wt(p-m)>=1&&v>=1?e.useScroll?r.scroll(p,v,!1,g):(a("transform "+v+"ms "+e.easing),i.translate(p,!0),l=g):(i.jump(f),g())}function u(){a(""),r.cancel()}function d(f){var g=e.rewindSpeed;if(n.is(bs)&&g){var p=s.getIndex(!0),m=s.getEnd();if(p===0&&f>=m||p>=m&&f===0)return g}return e.speed}return{mount:c,start:h,cancel:u}}var c_=function(){function n(e,i){this.event=ht(),this.Components={},this.state=hv(ds),this.splides=[],this._o={},this._E={};var s=gi(e)?Lh(document,e):e;lr(s,s+" is invalid."),this.root=s,i=pi({label:ve(s,oe)||"",labelledby:ve(s,ka)||""},o_,n.defaults,i||{});try{pi(i,JSON.parse(ve(s,Sa)))}catch{lr(!1,"Invalid JSON")}this._o=Object.create(pi({},i))}var t=n.prototype;return t.mount=function(i,s){var r=this,o=this.state,a=this.Components;lr(o.is([ds,On]),"Already mounted!"),o.set(ds),this._C=a,this._T=s||this._T||(this.is(gr)?a_:l_),this._E=i||this._E;var l=nr({},r_,this._E,{Transition:this._T});return Fi(l,function(c,h){var u=c(r,a,r._o);a[h]=u,u.setup&&u.setup()}),Fi(a,function(c){c.mount&&c.mount()}),this.emit(Bi),Ae(this.root,Cv),o.set(fs),this.emit(Nh),this},t.sync=function(i){return this.splides.push({splide:i}),i.splides.push({splide:this,isParent:!0}),this.state.is(fs)&&(this._C.Sync.remount(),i.Components.Sync.remount()),this},t.go=function(i){return this._C.Controller.go(i),this},t.on=function(i,s){return this.event.on(i,s),this},t.off=function(i){return this.event.off(i),this},t.emit=function(i){var s;return(s=this.event).emit.apply(s,[i].concat(fi(arguments,1))),this},t.add=function(i,s){return this._C.Slides.add(i,s),this},t.remove=function(i){return this._C.Slides.remove(i),this},t.is=function(i){return this._o.type===i},t.refresh=function(){return this.emit(xt),this},t.destroy=function(i){i===void 0&&(i=!0);var s=this.event,r=this.state;return r.is(ds)?ht(this).on(Nh,this.destroy.bind(this,i)):(Fi(this._C,function(o){o.destroy&&o.destroy(i)},!0),s.emit($h),s.destroy(),i&&Ge(this.splides),r.set(On)),this},Gm(n,[{key:"options",get:function(){return this._o},set:function(i){this._C.Media.set(i,!0,!0)}},{key:"length",get:function(){return this._C.Slides.getLength(!0)}},{key:"index",get:function(){return this._C.Controller.getIndex()}}]),n}(),Wn=c_;Wn.defaults={},Wn.STATES=Km;var h_=Object.defineProperty,u_=Object.getOwnPropertyDescriptor,Ze=(n,t,e,i)=>{for(var s=i>1?void 0:i?u_(t,e):t,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(t,e,s):o(s))||s);return i&&s&&h_(t,e,s),s};let Ut=class extends Ue{constructor(){super(...arguments),this.card=null,this.focusIndex=0,this.livePreviewProps={font:"Monsieur La Doulaise",text:"",color:"rgb(0,0,0)",alignment:"left"}}firstUpdated(){this.mainSplide=new Wn(this.mainCarousel,{width:300,height:400,pagination:!1,arrows:!1,direction:"ttb",cover:!0});const t=(i,s)=>{i.addEventListener("click",()=>{this.mainSplide.go(s)})};console.log(this.thumbnailElements);for(let i=0;i<this.thumbnailElements.length;i++)t(this.thumbnailElements[i],i);let e=null;this.mainSplide.on("mounted move",()=>{this.focusIndex=this.mainSplide.index,e!==null&&e.classList.remove("is-active");let i=this.thumbnailElements[this.mainSplide.index];i&&(i.classList.add("is-active"),e=i)}),this.mainSplide.mount()}updated(t){t.has("focusIndex")&&this.mainSplide.go(this.focusIndex)}render(){var t,e,i,s,r,o,a,l,c,h,u;return St`
933
+ `,$d=".splide__container{box-sizing:border-box;position:relative}.splide__list{backface-visibility:hidden;display:-ms-flexbox;display:flex;height:100%;margin:0!important;padding:0!important}.splide.is-initialized:not(.is-active) .splide__list{display:block}.splide__pagination{-ms-flex-align:center;align-items:center;display:-ms-flexbox;display:flex;-ms-flex-wrap:wrap;flex-wrap:wrap;-ms-flex-pack:center;justify-content:center;margin:0;pointer-events:none}.splide__pagination li{display:inline-block;line-height:1;list-style-type:none;margin:0;pointer-events:auto}.splide:not(.is-overflow) .splide__pagination{display:none}.splide__progress__bar{width:0}.splide{position:relative;visibility:hidden}.splide.is-initialized,.splide.is-rendered{visibility:visible}.splide__slide{backface-visibility:hidden;box-sizing:border-box;-ms-flex-negative:0;flex-shrink:0;list-style-type:none!important;margin:0;position:relative}.splide__slide img{vertical-align:bottom}.splide__spinner{animation:splide-loading 1s linear infinite;border:2px solid #999;border-left-color:transparent;border-radius:50%;bottom:0;contain:strict;display:inline-block;height:20px;left:0;margin:auto;position:absolute;right:0;top:0;width:20px}.splide__sr{clip:rect(0 0 0 0);border:0;height:1px;margin:-1px;overflow:hidden;padding:0;position:absolute;width:1px}.splide__toggle.is-active .splide__toggle__play,.splide__toggle__pause{display:none}.splide__toggle.is-active .splide__toggle__pause{display:inline}.splide__track{overflow:hidden;position:relative;z-index:0}@keyframes splide-loading{0%{transform:rotate(0)}to{transform:rotate(1turn)}}.splide__track--draggable{-webkit-touch-callout:none;-webkit-user-select:none;-ms-user-select:none;user-select:none}.splide__track--fade>.splide__list>.splide__slide{margin:0!important;opacity:0;z-index:0}.splide__track--fade>.splide__list>.splide__slide.is-active{opacity:1;z-index:1}.splide--rtl{direction:rtl}.splide__track--ttb>.splide__list{display:block}.splide__arrow{-ms-flex-align:center;align-items:center;background:#ccc;border:0;border-radius:50%;cursor:pointer;display:-ms-flexbox;display:flex;height:2em;-ms-flex-pack:center;justify-content:center;opacity:.7;padding:0;position:absolute;top:50%;transform:translateY(-50%);width:2em;z-index:1}.splide__arrow svg{fill:#000;height:1.2em;width:1.2em}.splide__arrow:hover:not(:disabled){opacity:.9}.splide__arrow:disabled{opacity:.3}.splide__arrow:focus-visible{outline:3px solid #0bf;outline-offset:3px}.splide__arrow--prev{left:1em}.splide__arrow--prev svg{transform:scaleX(-1)}.splide__arrow--next{right:1em}.splide.is-focus-in .splide__arrow:focus{outline:3px solid #0bf;outline-offset:3px}.splide__pagination{bottom:.5em;left:0;padding:0 1em;position:absolute;right:0;z-index:1}.splide__pagination__page{background:#ccc;border:0;border-radius:50%;display:inline-block;height:8px;margin:3px;opacity:.7;padding:0;position:relative;transition:transform .2s linear;width:8px}.splide__pagination__page.is-active{background:#fff;transform:scale(1.4);z-index:1}.splide__pagination__page:hover{cursor:pointer;opacity:.9}.splide__pagination__page:focus-visible{outline:3px solid #0bf;outline-offset:3px}.splide.is-focus-in .splide__pagination__page:focus{outline:3px solid #0bf;outline-offset:3px}.splide__progress__bar{background:#ccc;height:3px}.splide__slide{-webkit-tap-highlight-color:rgba(0,0,0,0)}.splide__slide:focus{outline:0}@supports (outline-offset:-3px){.splide__slide:focus-visible{outline:3px solid #0bf;outline-offset:-3px}}@media screen and (-ms-high-contrast:none){.splide__slide:focus-visible{border:3px solid #0bf}}@supports (outline-offset:-3px){.splide.is-focus-in .splide__slide:focus{outline:3px solid #0bf;outline-offset:-3px}}@media screen and (-ms-high-contrast:none){.splide.is-focus-in .splide__slide:focus{border:3px solid #0bf}.splide.is-focus-in .splide__track>.splide__list>.splide__slide:focus{border-color:#0bf}}.splide__toggle{cursor:pointer}.splide__toggle:focus-visible{outline:3px solid #0bf;outline-offset:3px}.splide.is-focus-in .splide__toggle:focus{outline:3px solid #0bf;outline-offset:3px}.splide__track--nav>.splide__list>.splide__slide{border:3px solid transparent;cursor:pointer}.splide__track--nav>.splide__list>.splide__slide.is-active{border:3px solid #000}.splide__arrows--rtl .splide__arrow--prev{left:auto;right:1em}.splide__arrows--rtl .splide__arrow--prev svg{transform:scaleX(1)}.splide__arrows--rtl .splide__arrow--next{left:1em;right:auto}.splide__arrows--rtl .splide__arrow--next svg{transform:scaleX(-1)}.splide__arrows--ttb .splide__arrow{left:50%;transform:translate(-50%)}.splide__arrows--ttb .splide__arrow--prev{top:1em}.splide__arrows--ttb .splide__arrow--prev svg{transform:rotate(-90deg)}.splide__arrows--ttb .splide__arrow--next{bottom:1em;top:auto}.splide__arrows--ttb .splide__arrow--next svg{transform:rotate(90deg)}.splide__pagination--ttb{bottom:0;display:-ms-flexbox;display:flex;-ms-flex-direction:column;flex-direction:column;left:auto;padding:1em 0;right:.5em;top:0}";function Wd(t,e,i){return e&&function(t,e){for(var i=0;i<e.length;i++){var s=e[i];s.enumerable=s.enumerable||!1,s.configurable=!0,"value"in s&&(s.writable=!0),Object.defineProperty(t,s.key,s)}}(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t}
934
+ /*!
935
+ * Splide.js
936
+ * Version : 4.1.4
937
+ * License : MIT
938
+ * Copyright: 2022 Naotoshi Fujita
939
+ */var Hd="(prefers-reduced-motion: reduce)",Xd={CREATED:1,MOUNTED:2,IDLE:3,MOVING:4,SCROLLING:5,DRAGGING:6,DESTROYED:7};function Ud(t){t.length=0}function Yd(t,e,i){return Array.prototype.slice.call(t,e,i)}function Gd(t){return t.bind.apply(t,[null].concat(Yd(arguments,1)))}var qd=setTimeout,Kd=function(){};function Jd(t){return requestAnimationFrame(t)}function Zd(t,e){return typeof e===t}function Qd(t){return!ru(t)&&Zd("object",t)}var tu=Array.isArray,eu=Gd(Zd,"function"),iu=Gd(Zd,"string"),su=Gd(Zd,"undefined");function ru(t){return null===t}function nu(t){try{return t instanceof(t.ownerDocument.defaultView||window).HTMLElement}catch(e){return!1}}function ou(t){return tu(t)?t:[t]}function au(t,e){ou(t).forEach(e)}function lu(t,e){return t.indexOf(e)>-1}function cu(t,e){return t.push.apply(t,ou(e)),t}function hu(t,e,i){t&&au(e,(function(e){e&&t.classList[i?"add":"remove"](e)}))}function du(t,e){hu(t,iu(e)?e.split(" "):e,!0)}function uu(t,e){au(e,t.appendChild.bind(t))}function pu(t,e){au(t,(function(t){var i=(e||t).parentNode;i&&i.insertBefore(t,e)}))}function gu(t,e){return nu(t)&&(t.msMatchesSelector||t.matches).call(t,e)}function fu(t,e){var i=t?Yd(t.children):[];return e?i.filter((function(t){return gu(t,e)})):i}function mu(t,e){return e?fu(t,e)[0]:t.firstElementChild}var vu=Object.keys;function _u(t,e,i){return t&&(i?vu(t).reverse():vu(t)).forEach((function(i){"__proto__"!==i&&e(t[i],i)})),t}function bu(t){return Yd(arguments,1).forEach((function(e){_u(e,(function(i,s){t[s]=e[s]}))})),t}function yu(t){return Yd(arguments,1).forEach((function(e){_u(e,(function(e,i){tu(e)?t[i]=e.slice():Qd(e)?t[i]=yu({},Qd(t[i])?t[i]:{},e):t[i]=e}))})),t}function xu(t,e){au(e||vu(t),(function(e){delete t[e]}))}function wu(t,e){au(t,(function(t){au(e,(function(e){t&&t.removeAttribute(e)}))}))}function Cu(t,e,i){Qd(e)?_u(e,(function(e,i){Cu(t,i,e)})):au(t,(function(t){ru(i)||""===i?wu(t,e):t.setAttribute(e,String(i))}))}function Su(t,e,i){var s=document.createElement(t);return e&&(iu(e)?du(s,e):Cu(s,e)),i&&uu(i,s),s}function Tu(t,e,i){if(su(i))return getComputedStyle(t)[e];ru(i)||(t.style[e]=""+i)}function Ou(t,e){Tu(t,"display",e)}function Eu(t){t.setActive&&t.setActive()||t.focus({preventScroll:!0})}function ku(t,e){return t.getAttribute(e)}function Du(t,e){return t&&t.classList.contains(e)}function Au(t){return t.getBoundingClientRect()}function Mu(t){au(t,(function(t){t&&t.parentNode&&t.parentNode.removeChild(t)}))}function Pu(t){return mu((new DOMParser).parseFromString(t,"text/html").body)}function ju(t,e){t.preventDefault(),e&&(t.stopPropagation(),t.stopImmediatePropagation())}function Lu(t,e){return t&&t.querySelector(e)}function Fu(t,e){return e?Yd(t.querySelectorAll(e)):[]}function Iu(t,e){hu(t,e,!1)}function Ru(t){return t.timeStamp}function Bu(t){return iu(t)?t:t?t+"px":""}var Nu="splide",zu="data-"+Nu;function Vu(t,e){if(!t)throw new Error("["+Nu+"] "+(e||""))}var $u=Math.min,Wu=Math.max,Hu=Math.floor,Xu=Math.ceil,Uu=Math.abs;function Yu(t,e,i){return Uu(t-e)<i}function Gu(t,e,i,s){var r=$u(e,i),n=Wu(e,i);return s?r<t&&t<n:r<=t&&t<=n}function qu(t,e,i){var s=$u(e,i),r=Wu(e,i);return $u(Wu(s,t),r)}function Ku(t){return+(t>0)-+(t<0)}function Ju(t,e){return au(e,(function(e){t=t.replace("%s",""+e)})),t}function Zu(t){return t<10?"0"+t:""+t}var Qu={};function tp(){var t=[];function e(t,e,i){au(t,(function(t){t&&au(e,(function(e){e.split(" ").forEach((function(e){var s=e.split(".");i(t,s[0],s[1])}))}))}))}return{bind:function(i,s,r,n){e(i,s,(function(e,i,s){var o="addEventListener"in e,a=o?e.removeEventListener.bind(e,i,r,n):e.removeListener.bind(e,r);o?e.addEventListener(i,r,n):e.addListener(r),t.push([e,i,s,r,a])}))},unbind:function(i,s,r){e(i,s,(function(e,i,s){t=t.filter((function(t){return!!(t[0]!==e||t[1]!==i||t[2]!==s||r&&t[3]!==r)||(t[4](),!1)}))}))},dispatch:function(t,e,i){var s,r=!0;return"function"==typeof CustomEvent?s=new CustomEvent(e,{bubbles:r,detail:i}):(s=document.createEvent("CustomEvent")).initCustomEvent(e,r,!1,i),t.dispatchEvent(s),s},destroy:function(){t.forEach((function(t){t[4]()})),Ud(t)}}}var ep="mounted",ip="ready",sp="move",rp="moved",np="click",op="active",ap="inactive",lp="visible",cp="hidden",hp="refresh",dp="updated",up="resize",pp="resized",gp="scroll",fp="scrolled",mp="destroy",vp="arrows:mounted",_p="navigation:mounted",bp="autoplay:play",yp="autoplay:pause",xp="lazyload:loaded",wp="sk",Cp="sh",Sp="ei";function Tp(t){var e=t?t.event.bus:document.createDocumentFragment(),i=tp();return t&&t.event.on(mp,i.destroy),bu(i,{bus:e,on:function(t,s){i.bind(e,ou(t).join(" "),(function(t){s.apply(s,tu(t.detail)?t.detail:[])}))},off:Gd(i.unbind,e),emit:function(t){i.dispatch(e,t,Yd(arguments,1))}})}function Op(t,e,i,s){var r,n,o=Date.now,a=0,l=!0,c=0;function h(){if(!l){if(a=t?$u((o()-r)/t,1):1,i&&i(a),a>=1&&(e(),r=o(),s&&++c>=s))return d();n=Jd(h)}}function d(){l=!0}function u(){n&&cancelAnimationFrame(n),a=0,n=0,l=!0}return{start:function(e){e||u(),r=o()-(e?a*t:0),l=!1,n=Jd(h)},rewind:function(){r=o(),a=0,i&&i(a)},pause:d,cancel:u,set:function(e){t=e},isPaused:function(){return l}}}var Ep="Arrow",kp=Ep+"Left",Dp=Ep+"Right",Ap=Ep+"Up",Mp=Ep+"Down",Pp="ttb",jp={width:["height"],left:["top","right"],right:["bottom","left"],x:["y"],X:["Y"],Y:["X"],ArrowLeft:[Ap,Dp],ArrowRight:[Mp,kp]};var Lp="role",Fp="tabindex",Ip="aria-",Rp=Ip+"controls",Bp=Ip+"current",Np=Ip+"selected",zp=Ip+"label",Vp=Ip+"labelledby",$p=Ip+"hidden",Wp=Ip+"orientation",Hp=Ip+"roledescription",Xp=Ip+"live",Up=Ip+"busy",Yp=Ip+"atomic",Gp=[Lp,Fp,"disabled",Rp,Bp,zp,Vp,$p,Wp,Hp],qp=Nu+"__",Kp="is-",Jp=Nu,Zp=qp+"track",Qp=qp+"list",tg=qp+"slide",eg=tg+"--clone",ig=tg+"__container",sg=qp+"arrows",rg=qp+"arrow",ng=rg+"--prev",og=rg+"--next",ag=qp+"pagination",lg=ag+"__page",cg=qp+"progress"+"__bar",hg=qp+"toggle",dg=qp+"sr",ug=Kp+"initialized",pg=Kp+"active",gg=Kp+"prev",fg=Kp+"next",mg=Kp+"visible",vg=Kp+"loading",_g=Kp+"focus-in",bg=Kp+"overflow",yg=[pg,mg,gg,fg,vg,_g,bg],xg={slide:tg,clone:eg,arrows:sg,arrow:rg,prev:ng,next:og,pagination:ag,page:lg,spinner:qp+"spinner"};var wg="touchstart mousedown",Cg="touchmove mousemove",Sg="touchend touchcancel mouseup click";var Tg="slide",Og="loop",Eg="fade";function kg(t,e,i,s){var r,n=Tp(t),o=n.on,a=n.emit,l=n.bind,c=t.Components,h=t.root,d=t.options,u=d.isNavigation,p=d.updateOnMove,g=d.i18n,f=d.pagination,m=d.slideFocus,v=c.Direction.resolve,_=ku(s,"style"),b=ku(s,zp),y=i>-1,x=mu(s,"."+ig);function w(){var r=t.splides.map((function(t){var i=t.splide.Components.Slides.getAt(e);return i?i.slide.id:""})).join(" ");Cu(s,zp,Ju(g.slideX,(y?i:e)+1)),Cu(s,Rp,r),Cu(s,Lp,m?"button":""),m&&wu(s,Hp)}function C(){r||S()}function S(){if(!r){var i=t.index;(n=T())!==Du(s,pg)&&(hu(s,pg,n),Cu(s,Bp,u&&n||""),a(n?op:ap,O)),function(){var e=function(){if(t.is(Eg))return T();var e=Au(c.Elements.track),i=Au(s),r=v("left",!0),n=v("right",!0);return Hu(e[r])<=Xu(i[r])&&Hu(i[n])<=Xu(e[n])}(),i=!e&&(!T()||y);t.state.is([4,5])||Cu(s,$p,i||"");Cu(Fu(s,d.focusableNodes||""),Fp,i?-1:""),m&&Cu(s,Fp,i?-1:0);e!==Du(s,mg)&&(hu(s,mg,e),a(e?lp:cp,O));if(!e&&document.activeElement===s){var r=c.Slides.getAt(t.index);r&&Eu(r.slide)}}(),hu(s,gg,e===i-1),hu(s,fg,e===i+1)}var n}function T(){var s=t.index;return s===e||d.cloneStatus&&s===i}var O={index:e,slideIndex:i,slide:s,container:x,isClone:y,mount:function(){y||(s.id=h.id+"-slide"+Zu(e+1),Cu(s,Lp,f?"tabpanel":"group"),Cu(s,Hp,g.slide),Cu(s,zp,b||Ju(g.slideLabel,[e+1,t.length]))),l(s,"click",Gd(a,np,O)),l(s,"keydown",Gd(a,wp,O)),o([rp,Cp,fp],S),o(_p,w),p&&o(sp,C)},destroy:function(){r=!0,n.destroy(),Iu(s,yg),wu(s,Gp),Cu(s,"style",_),Cu(s,zp,b||"")},update:S,style:function(t,e,i){Tu(i&&x||s,t,e)},isWithin:function(i,s){var r=Uu(i-e);return y||!d.rewind&&!t.is(Og)||(r=$u(r,t.length-r)),r<=s}};return O}var Dg=zu+"-interval";var Ag={passive:!1,capture:!0};var Mg={Spacebar:" ",Right:Dp,Left:kp,Up:Ap,Down:Mp};function Pg(t){return t=iu(t)?t:t.key,Mg[t]||t}var jg="keydown";var Lg=zu+"-lazy",Fg=Lg+"-srcset",Ig="["+Lg+"], ["+Fg+"]";var Rg=[" ","Enter"];var Bg=Object.freeze({__proto__:null,Media:function(t,e,i){var s=t.state,r=i.breakpoints||{},n=i.reducedMotion||{},o=tp(),a=[];function l(t){t&&o.destroy()}function c(t,e){var i=matchMedia(e);o.bind(i,"change",h),a.push([t,i])}function h(){var e=s.is(7),r=i.direction,n=a.reduce((function(t,e){return yu(t,e[1].matches?e[0]:{})}),{});xu(i),d(n),i.destroy?t.destroy("completely"===i.destroy):e?(l(!0),t.mount()):r!==i.direction&&t.refresh()}function d(e,r,n){yu(i,e),r&&yu(Object.getPrototypeOf(i),e),!n&&s.is(1)||t.emit(dp,i)}return{setup:function(){var t="min"===i.mediaQuery;vu(r).sort((function(e,i){return t?+e-+i:+i-+e})).forEach((function(e){c(r[e],"("+(t?"min":"max")+"-width:"+e+"px)")})),c(n,Hd),h()},destroy:l,reduce:function(t){matchMedia(Hd).matches&&(t?yu(i,n):xu(i,vu(n)))},set:d}},Direction:function(t,e,i){return{resolve:function(t,e,s){var r="rtl"!==(s=s||i.direction)||e?s===Pp?0:-1:1;return jp[t]&&jp[t][r]||t.replace(/width|left|right/i,(function(t,e){var i=jp[t.toLowerCase()][r]||t;return e>0?i.charAt(0).toUpperCase()+i.slice(1):i}))},orient:function(t){return t*("rtl"===i.direction?1:-1)}}},Elements:function(t,e,i){var s,r,n,o=Tp(t),a=o.on,l=o.bind,c=t.root,h=i.i18n,d={},u=[],p=[],g=[];function f(){s=_("."+Zp),r=mu(s,"."+Qp),Vu(s&&r,"A track/list element is missing."),cu(u,fu(r,"."+tg+":not(."+eg+")")),_u({arrows:sg,pagination:ag,prev:ng,next:og,bar:cg,toggle:hg},(function(t,e){d[e]=_("."+t)})),bu(d,{root:c,track:s,list:r,slides:u}),function(){var t=c.id||(n=Nu,""+n+Zu(Qu[n]=(Qu[n]||0)+1)),e=i.role;var n;c.id=t,s.id=s.id||t+"-track",r.id=r.id||t+"-list",!ku(c,Lp)&&"SECTION"!==c.tagName&&e&&Cu(c,Lp,e);Cu(c,Hp,h.carousel),Cu(r,Lp,"presentation")}(),v()}function m(t){var e=Gp.concat("style");Ud(u),Iu(c,p),Iu(s,g),wu([s,r],e),wu(c,t?e:["style",Hp])}function v(){Iu(c,p),Iu(s,g),p=b(Jp),g=b(Zp),du(c,p),du(s,g),Cu(c,zp,i.label),Cu(c,Vp,i.labelledby)}function _(t){var e=Lu(c,t);return e&&function(t,e){if(eu(t.closest))return t.closest(e);for(var i=t;i&&1===i.nodeType&&!gu(i,e);)i=i.parentElement;return i}(e,"."+Jp)===c?e:void 0}function b(t){return[t+"--"+i.type,t+"--"+i.direction,i.drag&&t+"--draggable",i.isNavigation&&t+"--nav",t===Jp&&pg]}return bu(d,{setup:f,mount:function(){a(hp,m),a(hp,f),a(dp,v),l(document,wg+" keydown",(function(t){n="keydown"===t.type}),{capture:!0}),l(c,"focusin",(function(){hu(c,_g,!!n)}))},destroy:m})},Slides:function(t,e,i){var s=Tp(t),r=s.on,n=s.emit,o=s.bind,a=e.Elements,l=a.slides,c=a.list,h=[];function d(){l.forEach((function(t,e){p(t,e,-1)}))}function u(){f((function(t){t.destroy()})),Ud(h)}function p(e,i,s){var r=kg(t,i,s,e);r.mount(),h.push(r),h.sort((function(t,e){return t.index-e.index}))}function g(t){return t?m((function(t){return!t.isClone})):h}function f(t,e){g(e).forEach(t)}function m(t){return h.filter(eu(t)?t:function(e){return iu(t)?gu(e.slide,t):lu(ou(t),e.index)})}return{mount:function(){d(),r(hp,u),r(hp,d)},destroy:u,update:function(){f((function(t){t.update()}))},register:p,get:g,getIn:function(t){var s=e.Controller,r=s.toIndex(t),n=s.hasFocus()?1:i.perPage;return m((function(t){return Gu(t.index,r,r+n-1)}))},getAt:function(t){return m(t)[0]},add:function(t,e){au(t,(function(t){if(iu(t)&&(t=Pu(t)),nu(t)){var s=l[e];s?pu(t,s):uu(c,t),du(t,i.classes.slide),r=t,a=Gd(n,up),h=Fu(r,"img"),(d=h.length)?h.forEach((function(t){o(t,"load error",(function(){--d||a()}))})):a()}var r,a,h,d})),n(hp)},remove:function(t){Mu(m(t).map((function(t){return t.slide}))),n(hp)},forEach:f,filter:m,style:function(t,e,i){f((function(s){s.style(t,e,i)}))},getLength:function(t){return t?l.length:h.length},isEnough:function(){return h.length>i.perPage}}},Layout:function(t,e,i){var s,r,n,o=Tp(t),a=o.on,l=o.bind,c=o.emit,h=e.Slides,d=e.Direction.resolve,u=e.Elements,p=u.root,g=u.track,f=u.list,m=h.getAt,v=h.style;function _(){s=i.direction===Pp,Tu(p,"maxWidth",Bu(i.width)),Tu(g,d("paddingLeft"),y(!1)),Tu(g,d("paddingRight"),y(!0)),b(!0)}function b(t){var e=Au(p);(t||r.width!==e.width||r.height!==e.height)&&(Tu(g,"height",function(){var t="";s&&(Vu(t=x(),"height or heightRatio is missing."),t="calc("+t+" - "+y(!1)+" - "+y(!0)+")");return t}()),v(d("marginRight"),Bu(i.gap)),v("width",i.autoWidth?null:Bu(i.fixedWidth)||(s?"":w())),v("height",Bu(i.fixedHeight)||(s?i.autoHeight?null:w():x()),!0),r=e,c(pp),n!==(n=k())&&(hu(p,bg,n),c("overflow",n)))}function y(t){var e=i.padding,s=d(t?"right":"left");return e&&Bu(e[s]||(Qd(e)?0:e))||"0px"}function x(){return Bu(i.height||Au(f).width*i.heightRatio)}function w(){var t=Bu(i.gap);return"calc((100%"+(t&&" + "+t)+")/"+(i.perPage||1)+(t&&" - "+t)+")"}function C(){return Au(f)[d("width")]}function S(t,e){var i=m(t||0);return i?Au(i.slide)[d("width")]+(e?0:E()):0}function T(t,e){var i=m(t);if(i){var s=Au(i.slide)[d("right")],r=Au(f)[d("left")];return Uu(s-r)+(e?0:E())}return 0}function O(e){return T(t.length-1)-T(0)+S(0,e)}function E(){var t=m(0);return t&&parseFloat(Tu(t.slide,d("marginRight")))||0}function k(){return t.is(Eg)||O(!0)>C()}return{mount:function(){var t,e;_(),l(window,"resize load",(t=Gd(c,up),e=Op(0,t,null,1),function(){e.isPaused()&&e.start()})),a([dp,hp],_),a(up,b)},resize:b,listSize:C,slideSize:S,sliderSize:O,totalSize:T,getPadding:function(t){return parseFloat(Tu(g,d("padding"+(t?"Right":"Left"))))||0},isOverflow:k}},Clones:function(t,e,i){var s,r=Tp(t),n=r.on,o=e.Elements,a=e.Slides,l=e.Direction.resolve,c=[];function h(){n(hp,d),n([dp,up],p),(s=g())&&(!function(e){var s=a.get().slice(),r=s.length;if(r){for(;s.length<e;)cu(s,s);cu(s.slice(-e),s.slice(0,e)).forEach((function(n,l){var h=l<e,d=function(e,s){var r=e.cloneNode(!0);return du(r,i.classes.clone),r.id=t.root.id+"-clone"+Zu(s+1),r}(n.slide,l);h?pu(d,s[0].slide):uu(o.list,d),cu(c,d),a.register(d,l-e+(h?0:r),n.index)}))}}(s),e.Layout.resize(!0))}function d(){u(),h()}function u(){Mu(c),Ud(c),r.destroy()}function p(){var t=g();s!==t&&(s<t||!t)&&r.emit(hp)}function g(){var s=i.clones;if(t.is(Og)){if(su(s)){var r=i[l("fixedWidth")]&&e.Layout.slideSize(0);s=r&&Xu(Au(o.track)[l("width")]/r)||i[l("autoWidth")]&&t.length||2*i.perPage}}else s=0;return s}return{mount:h,destroy:u}},Move:function(t,e,i){var s,r=Tp(t),n=r.on,o=r.emit,a=t.state.set,l=e.Layout,c=l.slideSize,h=l.getPadding,d=l.totalSize,u=l.listSize,p=l.sliderSize,g=e.Direction,f=g.resolve,m=g.orient,v=e.Elements,_=v.list,b=v.track;function y(){e.Controller.isBusy()||(e.Scroll.cancel(),x(t.index),e.Slides.update())}function x(t){w(O(t,!0))}function w(i,s){if(!t.is(Eg)){var r=s?i:function(i){if(t.is(Og)){var s=T(i),r=s>e.Controller.getEnd();(s<0||r)&&(i=C(i,r))}return i}(i);Tu(_,"transform","translate"+f("X")+"("+r+"px)"),i!==r&&o(Cp)}}function C(t,e){var i=t-k(e),s=p();return t-=m(s*(Xu(Uu(i)/s)||1))*(e?1:-1)}function S(){w(E(),!0),s.cancel()}function T(t){for(var i=e.Slides.get(),s=0,r=1/0,n=0;n<i.length;n++){var o=i[n].index,a=Uu(O(o,!0)-t);if(!(a<=r))break;r=a,s=o}return s}function O(e,s){var r=m(d(e-1)-function(t){var e=i.focus;return"center"===e?(u()-c(t,!0))/2:+e*c(t)||0}(e));return s?function(e){i.trimSpace&&t.is(Tg)&&(e=qu(e,0,m(p(!0)-u())));return e}(r):r}function E(){var t=f("left");return Au(_)[t]-Au(b)[t]+m(h(!1))}function k(t){return O(t?e.Controller.getEnd():0,!!i.trimSpace)}return{mount:function(){s=e.Transition,n([ep,pp,dp,hp],y)},move:function(t,e,i,r){var n,l;t!==e&&(n=t>i,l=m(C(E(),n)),n?l>=0:l<=_[f("scrollWidth")]-Au(b)[f("width")])&&(S(),w(C(E(),t>i),!0)),a(4),o(sp,e,i,t),s.start(e,(function(){a(3),o(rp,e,i,t),r&&r()}))},jump:x,translate:w,shift:C,cancel:S,toIndex:T,toPosition:O,getPosition:E,getLimit:k,exceededLimit:function(t,e){e=su(e)?E():e;var i=!0!==t&&m(e)<m(k(!1)),s=!1!==t&&m(e)>m(k(!0));return i||s},reposition:y}},Controller:function(t,e,i){var s,r,n,o,a=Tp(t),l=a.on,c=a.emit,h=e.Move,d=h.getPosition,u=h.getLimit,p=h.toPosition,g=e.Slides,f=g.isEnough,m=g.getLength,v=i.omitEnd,_=t.is(Og),b=t.is(Tg),y=Gd(O,!1),x=Gd(O,!0),w=i.start||0,C=w;function S(){r=m(!0),n=i.perMove,o=i.perPage,s=D();var t=qu(w,0,v?s:r-1);t!==w&&(w=t,h.reposition())}function T(){s!==D()&&c(Sp)}function O(t,e){var i=n||(j()?1:o),r=E(w+i*(t?-1:1),w,!(n||j()));return-1===r&&b&&!Yu(d(),u(!t),1)?t?0:s:e?r:k(r)}function E(e,a,l){if(f()||j()){var c=function(e){if(b&&"move"===i.trimSpace&&e!==w)for(var s=d();s===p(e,!0)&&Gu(e,0,t.length-1,!i.rewind);)e<w?--e:++e;return e}(e);c!==e&&(a=e,e=c,l=!1),e<0||e>s?e=n||!Gu(0,e,a,!0)&&!Gu(s,a,e,!0)?_?l?e<0?-(r%o||o):r:e:i.rewind?e<0?s:0:-1:A(M(e)):l&&e!==a&&(e=A(M(a)+(e<a?-1:1)))}else e=-1;return e}function k(t){return _?(t+r)%r||0:t}function D(){for(var t=r-(j()||_&&n?1:o);v&&t-- >0;)if(p(r-1,!0)!==p(t,!0)){t++;break}return qu(t,0,r-1)}function A(t){return qu(j()?t:o*t,0,s)}function M(t){return j()?$u(t,s):Hu((t>=s?r-1:t)/o)}function P(t){t!==w&&(C=w,w=t)}function j(){return!su(i.focus)||i.isNavigation}function L(){return t.state.is([4,5])&&!!i.waitForTransition}return{mount:function(){S(),l([dp,hp,Sp],S),l(pp,T)},go:function(t,e,i){if(!L()){var r=function(t){var e=w;if(iu(t)){var i=t.match(/([+\-<>])(\d+)?/)||[],r=i[1],n=i[2];"+"===r||"-"===r?e=E(w+ +(""+r+(+n||1)),w):">"===r?e=n?A(+n):y(!0):"<"===r&&(e=x(!0))}else e=_?t:qu(t,0,s);return e}(t),n=k(r);n>-1&&(e||n!==w)&&(P(n),h.move(r,n,C,i))}},scroll:function(t,i,r,n){e.Scroll.scroll(t,i,r,(function(){var t=k(h.toIndex(d()));P(v?$u(t,s):t),n&&n()}))},getNext:y,getPrev:x,getAdjacent:O,getEnd:D,setIndex:P,getIndex:function(t){return t?C:w},toIndex:A,toPage:M,toDest:function(t){var e=h.toIndex(t);return b?qu(e,0,s):e},hasFocus:j,isBusy:L}},Arrows:function(t,e,i){var s,r,n=Tp(t),o=n.on,a=n.bind,l=n.emit,c=i.classes,h=i.i18n,d=e.Elements,u=e.Controller,p=d.arrows,g=d.track,f=p,m=d.prev,v=d.next,_={};function b(){!function(){var t=i.arrows;!t||m&&v||(f=p||Su("div",c.arrows),m=C(!0),v=C(!1),s=!0,uu(f,[m,v]),!p&&pu(f,g));m&&v&&(bu(_,{prev:m,next:v}),Ou(f,t?"":"none"),du(f,r=sg+"--"+i.direction),t&&(o([ep,rp,hp,fp,Sp],S),a(v,"click",Gd(w,">")),a(m,"click",Gd(w,"<")),S(),Cu([m,v],Rp,g.id),l(vp,m,v)))}(),o(dp,y)}function y(){x(),b()}function x(){n.destroy(),Iu(f,r),s?(Mu(p?[m,v]:f),m=v=null):wu([m,v],Gp)}function w(t){u.go(t,!0)}function C(t){return Pu('<button class="'+c.arrow+" "+(t?c.prev:c.next)+'" type="button"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 40 40" width="40" height="40" focusable="false"><path d="'+(i.arrowPath||"m15.5 0.932-4.3 4.38 14.5 14.6-14.5 14.5 4.3 4.4 14.6-14.6 4.4-4.3-4.4-4.4-14.6-14.6z")+'" />')}function S(){if(m&&v){var e=t.index,i=u.getPrev(),s=u.getNext(),r=i>-1&&e<i?h.last:h.prev,n=s>-1&&e>s?h.first:h.next;m.disabled=i<0,v.disabled=s<0,Cu(m,zp,r),Cu(v,zp,n),l("arrows:updated",m,v,i,s)}}return{arrows:_,mount:b,destroy:x,update:S}},Autoplay:function(t,e,i){var s,r,n=Tp(t),o=n.on,a=n.bind,l=n.emit,c=Op(i.interval,t.go.bind(t,">"),(function(t){var e=d.bar;e&&Tu(e,"width",100*t+"%"),l("autoplay:playing",t)})),h=c.isPaused,d=e.Elements,u=e.Elements,p=u.root,g=u.toggle,f=i.autoplay,m="pause"===f;function v(){h()&&e.Slides.isEnough()&&(c.start(!i.resetProgress),r=s=m=!1,y(),l(bp))}function _(t){void 0===t&&(t=!0),m=!!t,y(),h()||(c.pause(),l(yp))}function b(){m||(s||r?_(!1):v())}function y(){g&&(hu(g,pg,!m),Cu(g,zp,i.i18n[m?"play":"pause"]))}function x(t){var s=e.Slides.getAt(t);c.set(s&&+ku(s.slide,Dg)||i.interval)}return{mount:function(){f&&(!function(){i.pauseOnHover&&a(p,"mouseenter mouseleave",(function(t){s="mouseenter"===t.type,b()}));i.pauseOnFocus&&a(p,"focusin focusout",(function(t){r="focusin"===t.type,b()}));g&&a(g,"click",(function(){m?v():_(!0)}));o([sp,gp,hp],c.rewind),o(sp,x)}(),g&&Cu(g,Rp,d.track.id),m||v(),y())},destroy:c.cancel,play:v,pause:_,isPaused:h}},Cover:function(t,e,i){var s=Tp(t).on;function r(t){e.Slides.forEach((function(e){var i=mu(e.container||e.slide,"img");i&&i.src&&n(t,i,e)}))}function n(t,e,i){i.style("background",t?'center/cover no-repeat url("'+e.src+'")':"",!0),Ou(e,t?"none":"")}return{mount:function(){i.cover&&(s(xp,Gd(n,!0)),s([ep,dp,hp],Gd(r,!0)))},destroy:Gd(r,!1)}},Scroll:function(t,e,i){var s,r,n=Tp(t),o=n.on,a=n.emit,l=t.state.set,c=e.Move,h=c.getPosition,d=c.getLimit,u=c.exceededLimit,p=c.translate,g=t.is(Tg),f=1;function m(t,i,n,o,d){var p=h();if(b(),n&&(!g||!u())){var m=e.Layout.sliderSize(),y=Ku(t)*m*Hu(Uu(t)/m)||0;t=c.toPosition(e.Controller.toDest(t%m))+y}var x=Yu(p,t,1);f=1,i=x?0:i||Wu(Uu(t-p)/1.5,800),r=o,s=Op(i,v,Gd(_,p,t,d),1),l(5),a(gp),s.start()}function v(){l(3),r&&r(),a(fp)}function _(t,e,s,n){var o=h(),a=t+(e-t)*function(t){var e=i.easingFunc;return e?e(t):1-Math.pow(1-t,4)}(n),l=(a-o)*f;p(o+l),g&&!s&&u()&&(f*=.6,Uu(l)<10&&m(d(u(!0)),600,!1,r,!0))}function b(){s&&s.cancel()}function y(){s&&!s.isPaused()&&(b(),v())}return{mount:function(){o(sp,b),o([dp,hp],y)},destroy:b,scroll:m,cancel:y}},Drag:function(t,e,i){var s,r,n,o,a,l,c,h,d=Tp(t),u=d.on,p=d.emit,g=d.bind,f=d.unbind,m=t.state,v=e.Move,_=e.Scroll,b=e.Controller,y=e.Elements.track,x=e.Media.reduce,w=e.Direction,C=w.resolve,S=w.orient,T=v.getPosition,O=v.exceededLimit,E=!1;function k(){var t=i.drag;N(!t),o="free"===t}function D(t){if(l=!1,!c){var e=B(t);s=t.target,r=i.noDrag,gu(s,"."+lg+", ."+rg)||r&&gu(s,r)||!e&&t.button||(b.isBusy()?ju(t,!0):(h=e?y:window,a=m.is([4,5]),n=null,g(h,Cg,A,Ag),g(h,Sg,M,Ag),v.cancel(),_.cancel(),j(t)))}var s,r}function A(e){if(m.is(6)||(m.set(6),p("drag")),e.cancelable)if(a){v.translate(s+L(e)/(E&&t.is(Tg)?5:1));var r=F(e)>200,n=E!==(E=O());(r||n)&&j(e),l=!0,p("dragging"),ju(e)}else(function(t){return Uu(L(t))>Uu(L(t,!0))})(e)&&(a=function(t){var e=i.dragMinThreshold,s=Qd(e),r=s&&e.mouse||0,n=(s?e.touch:+e)||10;return Uu(L(t))>(B(t)?n:r)}(e),ju(e))}function M(s){m.is(6)&&(m.set(3),p("dragged")),a&&(!function(s){var r=function(e){if(t.is(Og)||!E){var i=F(e);if(i&&i<200)return L(e)/i}return 0}(s),n=function(t){return T()+Ku(t)*$u(Uu(t)*(i.flickPower||600),o?1/0:e.Layout.listSize()*(i.flickMaxPages||1))}(r),a=i.rewind&&i.rewindByDrag;x(!1),o?b.scroll(n,0,i.snap):t.is(Eg)?b.go(S(Ku(r))<0?a?"<":"-":a?">":"+"):t.is(Tg)&&E&&a?b.go(O(!0)?">":"<"):b.go(b.toDest(n),!0);x(!0)}(s),ju(s)),f(h,Cg,A),f(h,Sg,M),a=!1}function P(t){!c&&l&&ju(t,!0)}function j(t){n=r,r=t,s=T()}function L(t,e){return R(t,e)-R(I(t),e)}function F(t){return Ru(t)-Ru(I(t))}function I(t){return r===t&&n||r}function R(t,e){return(B(t)?t.changedTouches[0]:t)["page"+C(e?"Y":"X")]}function B(t){return"undefined"!=typeof TouchEvent&&t instanceof TouchEvent}function N(t){c=t}return{mount:function(){g(y,Cg,Kd,Ag),g(y,Sg,Kd,Ag),g(y,wg,D,Ag),g(y,"click",P,{capture:!0}),g(y,"dragstart",ju),u([ep,dp],k)},disable:N,isDragging:function(){return a}}},Keyboard:function(t,e,i){var s,r,n=Tp(t),o=n.on,a=n.bind,l=n.unbind,c=t.root,h=e.Direction.resolve;function d(){var t=i.keyboard;t&&(s="global"===t?window:c,a(s,jg,g))}function u(){l(s,jg)}function p(){var t=r;r=!0,qd((function(){r=t}))}function g(e){if(!r){var i=Pg(e);i===h(kp)?t.go("<"):i===h(Dp)&&t.go(">")}}return{mount:function(){d(),o(dp,u),o(dp,d),o(sp,p)},destroy:u,disable:function(t){r=t}}},LazyLoad:function(t,e,i){var s=Tp(t),r=s.on,n=s.off,o=s.bind,a=s.emit,l="sequential"===i.lazyLoad,c=[rp,fp],h=[];function d(){Ud(h),e.Slides.forEach((function(t){Fu(t.slide,Ig).forEach((function(e){var s=ku(e,Lg),r=ku(e,Fg);if(s!==e.src||r!==e.srcset){var n=i.classes.spinner,o=e.parentElement,a=mu(o,"."+n)||Su("span",n,o);h.push([e,t,a]),e.src||Ou(e,"none")}}))})),l?f():(n(c),r(c,u),u())}function u(){(h=h.filter((function(e){var s=i.perPage*((i.preloadPages||1)+1)-1;return!e[1].isWithin(t.index,s)||p(e)}))).length||n(c)}function p(t){var e=t[0];du(t[1].slide,vg),o(e,"load error",Gd(g,t)),Cu(e,"src",ku(e,Lg)),Cu(e,"srcset",ku(e,Fg)),wu(e,Lg),wu(e,Fg)}function g(t,e){var i=t[0],s=t[1];Iu(s.slide,vg),"error"!==e.type&&(Mu(t[2]),Ou(i,""),a(xp,i,s),a(up)),l&&f()}function f(){h.length&&p(h.shift())}return{mount:function(){i.lazyLoad&&(d(),r(hp,d))},destroy:Gd(Ud,h),check:u}},Pagination:function(t,e,i){var s,r,n=Tp(t),o=n.on,a=n.emit,l=n.bind,c=e.Slides,h=e.Elements,d=e.Controller,u=d.hasFocus,p=d.getIndex,g=d.go,f=e.Direction.resolve,m=h.pagination,v=[];function _(){s&&(Mu(m?Yd(s.children):s),Iu(s,r),Ud(v),s=null),n.destroy()}function b(t){g(">"+t,!0)}function y(t,e){var i=v.length,s=Pg(e),r=x(),n=-1;s===f(Dp,!1,r)?n=++t%i:s===f(kp,!1,r)?n=(--t+i)%i:"Home"===s?n=0:"End"===s&&(n=i-1);var o=v[n];o&&(Eu(o.button),g(">"+n),ju(e,!0))}function x(){return i.paginationDirection||i.direction}function w(t){return v[d.toPage(t)]}function C(){var t=w(p(!0)),e=w(p());if(t){var i=t.button;Iu(i,pg),wu(i,Np),Cu(i,Fp,-1)}if(e){var r=e.button;du(r,pg),Cu(r,Np,!0),Cu(r,Fp,"")}a("pagination:updated",{list:s,items:v},t,e)}return{items:v,mount:function e(){_(),o([dp,hp,Sp],e);var n=i.pagination;m&&Ou(m,n?"":"none"),n&&(o([sp,gp,fp],C),function(){var e=t.length,n=i.classes,o=i.i18n,a=i.perPage,p=u()?d.getEnd()+1:Xu(e/a);du(s=m||Su("ul",n.pagination,h.track.parentElement),r=ag+"--"+x()),Cu(s,Lp,"tablist"),Cu(s,zp,o.select),Cu(s,Wp,x()===Pp?"vertical":"");for(var g=0;g<p;g++){var f=Su("li",null,s),_=Su("button",{class:n.page,type:"button"},f),w=c.getIn(g).map((function(t){return t.slide.id})),C=!u()&&a>1?o.pageX:o.slideX;l(_,"click",Gd(b,g)),i.paginationKeyboard&&l(_,"keydown",Gd(y,g)),Cu(f,Lp,"presentation"),Cu(_,Lp,"tab"),Cu(_,Rp,w.join(" ")),Cu(_,zp,Ju(C,g+1)),Cu(_,Fp,-1),v.push({li:f,button:_,page:g})}}(),C(),a("pagination:mounted",{list:s,items:v},w(t.index)))},destroy:_,getAt:w,update:C}},Sync:function(t,e,i){var s=i.isNavigation,r=i.slideFocus,n=[];function o(){var e,i;t.splides.forEach((function(e){e.isParent||(l(t,e.splide),l(e.splide,t))})),s&&(e=Tp(t),(i=e.on)(np,h),i(wp,d),i([ep,dp],c),n.push(e),e.emit(_p,t.splides))}function a(){n.forEach((function(t){t.destroy()})),Ud(n)}function l(t,e){var i=Tp(t);i.on(sp,(function(t,i,s){e.go(e.is(Og)?s:t)})),n.push(i)}function c(){Cu(e.Elements.list,Wp,i.direction===Pp?"vertical":"")}function h(e){t.go(e.index)}function d(t,e){lu(Rg,Pg(e))&&(h(t),ju(e))}return{setup:Gd(e.Media.set,{slideFocus:su(r)?s:r},!0),mount:o,destroy:a,remount:function(){a(),o()}}},Wheel:function(t,e,i){var s=Tp(t).bind,r=0;function n(s){if(s.cancelable){var n=s.deltaY,o=n<0,a=Ru(s),l=i.wheelMinThreshold||0,c=i.wheelSleep||0;Uu(n)>l&&a-r>c&&(t.go(o?"<":">"),r=a),function(s){return!i.releaseWheel||t.state.is(4)||-1!==e.Controller.getAdjacent(s)}(o)&&ju(s)}}return{mount:function(){i.wheel&&s(e.Elements.track,"wheel",n,Ag)}}},Live:function(t,e,i){var s=Tp(t).on,r=e.Elements.track,n=i.live&&!i.isNavigation,o=Su("span",dg),a=Op(90,Gd(l,!1));function l(t){Cu(r,Up,t),t?(uu(r,o),a.start()):(Mu(o),a.cancel())}function c(t){n&&Cu(r,Xp,t?"off":"polite")}return{mount:function(){n&&(c(!e.Autoplay.isPaused()),Cu(r,Yp,!0),o.textContent="…",s(bp,Gd(c,!0)),s(yp,Gd(c,!1)),s([rp,fp],Gd(l,!0)))},disable:c,destroy:function(){wu(r,[Xp,Yp,Up]),Mu(o)}}}}),Ng={type:"slide",role:"region",speed:400,perPage:1,cloneStatus:!0,arrows:!0,pagination:!0,paginationKeyboard:!0,interval:5e3,pauseOnHover:!0,pauseOnFocus:!0,resetProgress:!0,easing:"cubic-bezier(0.25, 1, 0.5, 1)",drag:!0,direction:"ltr",trimSpace:!0,focusableNodes:"a, button, textarea, input, select, iframe",live:!0,classes:xg,i18n:{prev:"Previous slide",next:"Next slide",first:"Go to first slide",last:"Go to last slide",slideX:"Go to slide %s",pageX:"Go to page %s",play:"Start autoplay",pause:"Pause autoplay",carousel:"carousel",slide:"slide",select:"Select a slide to show",slideLabel:"%s of %s"},reducedMotion:{speed:0,rewindSpeed:0,autoplay:"pause"}};function zg(t,e,i){var s=e.Slides;function r(){s.forEach((function(t){t.style("transform","translateX(-"+100*t.index+"%)")}))}return{mount:function(){Tp(t).on([ep,hp],r)},start:function(t,e){s.style("transition","opacity "+i.speed+"ms "+i.easing),qd(e)},cancel:Kd}}function Vg(t,e,i){var s,r=e.Move,n=e.Controller,o=e.Scroll,a=e.Elements.list,l=Gd(Tu,a,"transition");function c(){l(""),o.cancel()}return{mount:function(){Tp(t).bind(a,"transitionend",(function(t){t.target===a&&s&&(c(),s())}))},start:function(e,a){var c=r.toPosition(e,!0),h=r.getPosition(),d=function(e){var s=i.rewindSpeed;if(t.is(Tg)&&s){var r=n.getIndex(!0),o=n.getEnd();if(0===r&&e>=o||r>=o&&0===e)return s}return i.speed}(e);Uu(c-h)>=1&&d>=1?i.useScroll?o.scroll(c,d,!1,a):(l("transform "+d+"ms "+i.easing),r.translate(c,!0),s=a):(r.jump(e),a())},cancel:c}}var $g=function(){function t(e,i){var s;this.event=Tp(),this.Components={},this.state=(s=1,{set:function(t){s=t},is:function(t){return lu(ou(t),s)}}),this.splides=[],this._o={},this._E={};var r=iu(e)?Lu(document,e):e;Vu(r,r+" is invalid."),this.root=r,i=yu({label:ku(r,zp)||"",labelledby:ku(r,Vp)||""},Ng,t.defaults,i||{});try{yu(i,JSON.parse(ku(r,zu)))}catch(n){Vu(!1,"Invalid JSON")}this._o=Object.create(yu({},i))}var e=t.prototype;return e.mount=function(t,e){var i=this,s=this.state,r=this.Components;return Vu(s.is([1,7]),"Already mounted!"),s.set(1),this._C=r,this._T=e||this._T||(this.is(Eg)?zg:Vg),this._E=t||this._E,_u(bu({},Bg,this._E,{Transition:this._T}),(function(t,e){var s=t(i,r,i._o);r[e]=s,s.setup&&s.setup()})),_u(r,(function(t){t.mount&&t.mount()})),this.emit(ep),du(this.root,ug),s.set(3),this.emit(ip),this},e.sync=function(t){return this.splides.push({splide:t}),t.splides.push({splide:this,isParent:!0}),this.state.is(3)&&(this._C.Sync.remount(),t.Components.Sync.remount()),this},e.go=function(t){return this._C.Controller.go(t),this},e.on=function(t,e){return this.event.on(t,e),this},e.off=function(t){return this.event.off(t),this},e.emit=function(t){var e;return(e=this.event).emit.apply(e,[t].concat(Yd(arguments,1))),this},e.add=function(t,e){return this._C.Slides.add(t,e),this},e.remove=function(t){return this._C.Slides.remove(t),this},e.is=function(t){return this._o.type===t},e.refresh=function(){return this.emit(hp),this},e.destroy=function(t){void 0===t&&(t=!0);var e=this.event,i=this.state;return i.is(1)?Tp(this).on(ip,this.destroy.bind(this,t)):(_u(this._C,(function(e){e.destroy&&e.destroy(t)}),!0),e.emit(mp),e.destroy(),t&&Ud(this.splides),i.set(7)),this},Wd(t,[{key:"options",get:function(){return this._o},set:function(t){this._C.Media.set(t,!0,!0)}},{key:"length",get:function(){return this._C.Slides.getLength(!0)}},{key:"index",get:function(){return this._C.Controller.getIndex()}}]),t}(),Wg=$g;Wg.defaults={},Wg.STATES=Xd;var Hg=Object.defineProperty,Xg=Object.getOwnPropertyDescriptor,Ug=(t,e,i,s)=>{for(var r,n=s>1?void 0:s?Xg(e,i):e,o=t.length-1;o>=0;o--)(r=t[o])&&(n=(s?r(e,i,n):r(n))||n);return s&&n&&Hg(e,i,n),n};let Yg=class extends dd{constructor(){super(...arguments),this.card=null,this.focusIndex=0,this.livePreviewProps={font:"Monsieur La Doulaise",text:"",color:"rgb(0,0,0)",alignment:"left"}}firstUpdated(){this.mainSplide=new Wg(this.mainCarousel,{width:300,height:400,pagination:!1,arrows:!1,direction:"ttb",cover:!0});const t=(t,e)=>{t.addEventListener("click",(()=>{this.mainSplide.go(e)}))};console.log(this.thumbnailElements);for(let i=0;i<this.thumbnailElements.length;i++)t(this.thumbnailElements[i],i);let e=null;this.mainSplide.on("mounted move",(()=>{this.focusIndex=this.mainSplide.index,null!==e&&e.classList.remove("is-active");let t=this.thumbnailElements[this.mainSplide.index];t&&(t.classList.add("is-active"),e=t)})),this.mainSplide.mount()}updated(t){t.has("focusIndex")&&this.mainSplide.go(this.focusIndex)}render(){var t,e,i,s,r,n,o,a,l,c,h;return H`
1429
940
  ${JSON.stringify(this.card)}
1430
941
  <div class="card--slider--wrapper">
1431
942
  <ul id="thumbnails" class="thumbnails">
1432
943
  <li class="thumbnail">
1433
- <img src="${((t=this.card)==null?void 0:t.medias.cover.url)||"https://picsum.photos/id/1/300/400"}" alt="" />
944
+ <img src="${(null==(t=this.card)?void 0:t.medias.cover.url)||"https://picsum.photos/id/1/300/400"}" alt="" />
1434
945
  </li>
1435
946
  <li class="thumbnail">
1436
- <img src="${((e=this.card)==null?void 0:e.medias.render_1.url)||"https://picsum.photos/id/10/300/400"}" alt="" />
947
+ <img src="${(null==(e=this.card)?void 0:e.medias.render_1.url)||"https://picsum.photos/id/10/300/400"}" alt="" />
1437
948
  </li>
1438
949
  <li class="thumbnail">
1439
- <img src="${((i=this.card)==null?void 0:i.medias.render_2.url)||"https://picsum.photos/id/10/300/400"}" alt="" />
950
+ <img src="${(null==(i=this.card)?void 0:i.medias.render_2.url)||"https://picsum.photos/id/10/300/400"}" alt="" />
1440
951
  </li>
1441
952
  </ul>
1442
953
 
@@ -1444,38 +955,38 @@ good aklsdfja`,this.alignment="left",this.fontFamily="Arial",this.color="#000",t
1444
955
  <div class="splide__track">
1445
956
  <ul class="splide__list">
1446
957
  <li class="splide__slide">
1447
- ${(s=this.card)==null?void 0:s.medias.cover.url}
1448
- <img src="${((r=this.card)==null?void 0:r.medias.cover.url)||"https://picsum.photos/id/1/300/400"}" alt="" />
958
+ ${null==(s=this.card)?void 0:s.medias.cover.url}
959
+ <img src="${(null==(r=this.card)?void 0:r.medias.cover.url)||"https://picsum.photos/id/1/300/400"}" alt="" />
1449
960
  </li>
1450
961
  <li class="splide__slide">
1451
962
  <fabric-example
1452
- backgroundUrl="${((o=this.card)==null?void 0:o.medias.render_1.url)||"https://picsum.photos/id/10/300/400"}"
1453
- alignment=${((a=this.livePreviewProps)==null?void 0:a.alignment)||"left"}
1454
- message=${(l=this.livePreviewProps)==null?void 0:l.text}
1455
- color=${(c=this.livePreviewProps)==null?void 0:c.color}
1456
- fontFamily=${(h=this.livePreviewProps)==null?void 0:h.font}
963
+ backgroundUrl="${(null==(n=this.card)?void 0:n.medias.render_1.url)||"https://picsum.photos/id/10/300/400"}"
964
+ alignment=${(null==(o=this.livePreviewProps)?void 0:o.alignment)||"left"}
965
+ message=${null==(a=this.livePreviewProps)?void 0:a.text}
966
+ color=${null==(l=this.livePreviewProps)?void 0:l.color}
967
+ fontFamily=${null==(c=this.livePreviewProps)?void 0:c.font}
1457
968
  ></fabric-example>
1458
969
  </li>
1459
970
  <li class="splide__slide">
1460
- <img src="${((u=this.card)==null?void 0:u.medias.render_2.url)||"https://picsum.photos/id/10/300/400"}" alt="" />
971
+ <img src="${(null==(h=this.card)?void 0:h.medias.render_2.url)||"https://picsum.photos/id/10/300/400"}" alt="" />
1461
972
  </li>
1462
973
  </ul>
1463
974
  </div>
1464
975
  </section>
1465
976
  </div>
1466
- `}};Ut.styles=[Vt,Ym,br(Sh)],Ut.dependencies={"fabric-example":z.FabricExample},Ze([H({type:Object})],Ut.prototype,"card",2),Ze([H({type:Number,reflect:!0})],Ut.prototype,"focusIndex",2),Ze([H({type:Object})],Ut.prototype,"livePreviewProps",2),Ze([vt("#thumbnails")],Ut.prototype,"thumbnailCarousel",2),Ze([vt("#main-carousel")],Ut.prototype,"mainCarousel",2),Ze([Vu(".thumbnail")],Ut.prototype,"thumbnailElements",2),Ze([st()],Ut.prototype,"thumbnailSplide",2),Ze([st()],Ut.prototype,"mainSplide",2),Ut=Ze([Mt("pbo-editor-card-slider")],Ut);var d_=Object.defineProperty,f_=Object.getOwnPropertyDescriptor,Cs=(n,t,e,i)=>{for(var s=i>1?void 0:i?f_(t,e):t,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(t,e,s):o(s))||s);return i&&s&&d_(t,e,s),s};let Me=class extends Ue{constructor(){super(...arguments),this.cardInnerImageUrl="../../../public/Greeting Card from Pairbo.png",this.card=null,this.formData={font:"Monsieur La Doulaise",text:"",color:"rgb(0,0,0)",alignment:"left"}}handleTypingFormChange(){console.log(this.typingForm.form)}firstUpdated(){this.typingForm.addEventListener("pbo-change",t=>{this.formData=this.typingForm.form})}isCardType(t){return t&&typeof t=="object"&&"id"in t&&"name"in t&&"category"in t&&"medias"in t&&typeof t.medias=="object"&&"cover"in t.medias&&"render_1"in t.medias&&"render_2"in t.medias&&"inner"in t.medias}updated(t){t.has("cardInnerImageUrl")&&this.requestUpdate(),t.has("card")&&(this.slider.card=this.card,this.requestUpdate())}disconnectedCallback(){this.typingForm.removeEventListener("pbo-change",this.handleTypingFormChange)}render(){var t,e,i,s;return St`
977
+ `}};var Gg;Yg.styles=[il,Vd,a($d)],Yg.dependencies={"fabric-example":t.FabricExample},Ug([ut({type:Object})],Yg.prototype,"card",2),Ug([ut({type:Number,reflect:!0})],Yg.prototype,"focusIndex",2),Ug([ut({type:Object})],Yg.prototype,"livePreviewProps",2),Ug([ft("#thumbnails")],Yg.prototype,"thumbnailCarousel",2),Ug([ft("#main-carousel")],Yg.prototype,"mainCarousel",2),Ug([(Gg=".thumbnail",(t,e)=>gt(t,e,{get(){return(this.renderRoot??mt??(mt=document.createDocumentFragment())).querySelectorAll(Gg)}}))],Yg.prototype,"thumbnailElements",2),Ug([pt()],Yg.prototype,"thumbnailSplide",2),Ug([pt()],Yg.prototype,"mainSplide",2),Yg=Ug([ct("pbo-editor-card-slider")],Yg);var qg=Object.defineProperty,Kg=Object.getOwnPropertyDescriptor,Jg=(t,e,i,s)=>{for(var r,n=s>1?void 0:s?Kg(e,i):e,o=t.length-1;o>=0;o--)(r=t[o])&&(n=(s?r(e,i,n):r(n))||n);return s&&n&&qg(e,i,n),n};let Zg=class extends dd{constructor(){super(...arguments),this.cardInnerImageUrl="../../../public/Greeting Card from Pairbo.png",this.card=null,this.formData={font:"Monsieur La Doulaise",text:"",color:"rgb(0,0,0)",alignment:"left"}}handleTypingFormChange(){console.log(this.typingForm.form)}firstUpdated(){this.typingForm.addEventListener("pbo-change",(t=>{this.formData=this.typingForm.form}))}isCardType(t){return t&&"object"==typeof t&&"id"in t&&"name"in t&&"category"in t&&"medias"in t&&"object"==typeof t.medias&&"cover"in t.medias&&"render_1"in t.medias&&"render_2"in t.medias&&"inner"in t.medias}updated(t){t.has("cardInnerImageUrl")&&this.requestUpdate(),t.has("card")&&(this.slider.card=this.card,this.requestUpdate())}disconnectedCallback(){this.typingForm.removeEventListener("pbo-change",this.handleTypingFormChange)}render(){var t,e,i,s;return H`
1467
978
  ${JSON.stringify(this.card)} In the editor
1468
979
  <div class="editor">
1469
980
  <div
1470
- style=${yh({maxWidth:"500px"})}
981
+ style=${rd({maxWidth:"500px"})}
1471
982
  >
1472
983
  <!--
1473
984
  <fabric-example
1474
985
  backgroundUrl=${this.cardInnerImageUrl}
1475
- alignment=${((t=this.formData)==null?void 0:t.alignment)||""}
1476
- message=${((e=this.formData)==null?void 0:e.text)||""}
1477
- color=${((i=this.formData)==null?void 0:i.color)||""}
1478
- fontFamily=${((s=this.formData)==null?void 0:s.font)||""}
986
+ alignment=${(null==(t=this.formData)?void 0:t.alignment)||""}
987
+ message=${(null==(e=this.formData)?void 0:e.text)||""}
988
+ color=${(null==(i=this.formData)?void 0:i.color)||""}
989
+ fontFamily=${(null==(s=this.formData)?void 0:s.font)||""}
1479
990
  ></fabric-example>
1480
991
  -->
1481
992
  <pbo-editor-card-slider focusIndex="0" .livePreviewProps=${this.formData}></pbo-editor-card-slider>
@@ -1487,11 +998,11 @@ good aklsdfja`,this.alignment="left",this.fontFamily="Arial",this.color="#000",t
1487
998
  </div>
1488
999
  </div>
1489
1000
  <button
1490
- @click=${()=>{var o;const r=(o=this.shadowRoot)==null?void 0:o.querySelector("pbo-editor-card-slider");r&&r.getAttribute("focusIndex")!=="1"&&r.setAttribute("focusIndex","1")}}
1001
+ @click=${()=>{var t;const e=null==(t=this.shadowRoot)?void 0:t.querySelector("pbo-editor-card-slider");e&&"1"!==e.getAttribute("focusIndex")&&e.setAttribute("focusIndex","1")}}
1491
1002
  >
1492
1003
  Set main image to canvas
1493
1004
  </button>
1494
- `}};Me.styles=[Vt,Vm],Me.dependencies={"editor-card-slider":Ut,"fabric-example":z.FabricExample,"pbo-type-form":se},Cs([H({type:String,reflect:!0})],Me.prototype,"cardInnerImageUrl",2),Cs([vt("pbo-type-form")],Me.prototype,"typingForm",2),Cs([vt("pbo-editor-card-slider")],Me.prototype,"slider",2),Cs([H({type:Object})],Me.prototype,"card",2),Cs([st()],Me.prototype,"formData",2),Me=Cs([Mt("pbo-editor")],Me);const g_=Me,p_=se,m_=Ut,v_=Ct`
1005
+ `}};Zg.styles=[il,Fd],Zg.dependencies={"editor-card-slider":Yg,"fabric-example":t.FabricExample,"pbo-type-form":zd},Jg([ut({type:String,reflect:!0})],Zg.prototype,"cardInnerImageUrl",2),Jg([ft("pbo-type-form")],Zg.prototype,"typingForm",2),Jg([ft("pbo-editor-card-slider")],Zg.prototype,"slider",2),Jg([ut({type:Object})],Zg.prototype,"card",2),Jg([pt()],Zg.prototype,"formData",2),Zg=Jg([ct("pbo-editor")],Zg);const Qg=Zg,tf=zd,ef=Yg,sf=l`
1495
1006
  :host {
1496
1007
  display: block;
1497
1008
  }
@@ -1515,11 +1026,12 @@ good aklsdfja`,this.alignment="left",this.fontFamily="Arial",this.color="#000",t
1515
1026
  width: 100%;
1516
1027
  height: auto;
1517
1028
  }
1518
- `;/**
1519
- * @license
1520
- * Copyright 2021 Google LLC
1521
- * SPDX-License-Identifier: BSD-3-Clause
1522
- */function*gu(n,t){if(n!==void 0){let e=0;for(const i of n)yield t(i,e++)}}var __=Object.defineProperty,b_=Object.getOwnPropertyDescriptor,mr=(n,t,e,i)=>{for(var s=i>1?void 0:i?b_(t,e):t,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(t,e,s):o(s))||s);return i&&s&&__(t,e,s),s};let bi=class extends Ue{constructor(){super(...arguments),this.slides=[],this.cards=[],this.firstUpdated=()=>{this.imageSplide=new Wn(this.imageCarousel,{fixedWidth:"24.5%",heightRatio:.3,gap:"2%",rewind:!1,pagination:!1,isNavigation:!1,perPage:2}),this.imageSplide.mount()},this.disconnectedCallback=()=>{var t;super.disconnectedCallback(),(t=this.imageSplide)==null||t.destroy()},this.clickHandler=t=>{const e=t.target;this.emit("pbo-category-card-selected",{detail:{cardId:e.dataset.cardId}})}}render(){return St`
1029
+ `
1030
+ /**
1031
+ * @license
1032
+ * Copyright 2021 Google LLC
1033
+ * SPDX-License-Identifier: BSD-3-Clause
1034
+ */;function*rf(t,e){if(void 0!==t){let i=0;for(const s of t)yield e(s,i++)}}var nf=Object.defineProperty,of=Object.getOwnPropertyDescriptor,af=(t,e,i,s)=>{for(var r,n=s>1?void 0:s?of(e,i):e,o=t.length-1;o>=0;o--)(r=t[o])&&(n=(s?r(e,i,n):r(n))||n);return s&&n&&nf(e,i,n),n};let lf=class extends dd{constructor(){super(...arguments),this.slides=[],this.cards=[],this.firstUpdated=()=>{this.imageSplide=new Wg(this.imageCarousel,{fixedWidth:"24.5%",heightRatio:.3,gap:"2%",rewind:!1,pagination:!1,isNavigation:!1,perPage:2}),this.imageSplide.mount()},this.disconnectedCallback=()=>{var t;super.disconnectedCallback(),null==(t=this.imageSplide)||t.destroy()},this.clickHandler=t=>{const e=t.target;this.emit("pbo-category-card-selected",{detail:{cardId:e.dataset.cardId}})}}render(){return H`
1523
1035
  <div class="category-container">
1524
1036
  <slot name="title"></slot>
1525
1037
  <section
@@ -1529,7 +1041,7 @@ good aklsdfja`,this.alignment="left",this.fontFamily="Arial",this.color="#000",t
1529
1041
  >
1530
1042
  <div class="splide__track">
1531
1043
  <ul class="splide__list">
1532
- ${gu(this.cards,t=>St`
1044
+ ${rf(this.cards,(t=>H`
1533
1045
  <li class="splide__slide">
1534
1046
  <img
1535
1047
  src=${t.medias.cover.url}
@@ -1538,17 +1050,17 @@ good aklsdfja`,this.alignment="left",this.fontFamily="Arial",this.color="#000",t
1538
1050
  data-card-id="${t.id}"
1539
1051
  />
1540
1052
  </li>
1541
- `)}
1053
+ `))}
1542
1054
  </ul>
1543
1055
  </div>
1544
1056
  </section>
1545
1057
  </div>
1546
- `}};bi.styles=[Vt,v_,br(Sh)],mr([vt("#category-carousel")],bi.prototype,"imageCarousel",2),mr([st()],bi.prototype,"imageSplide",2),mr([st()],bi.prototype,"slides",2),mr([H({type:Array,converter:{fromAttribute(n){try{return JSON.parse(n||"[]")}catch{return console.error("Invalid JSON for 'cards':",n),[]}},toAttribute(n){return JSON.stringify(n)}}})],bi.prototype,"cards",2),bi=mr([Mt("pbo-category")],bi);const y_=bi,x_=Ct`
1058
+ `}};lf.styles=[il,sf,a($d)],af([ft("#category-carousel")],lf.prototype,"imageCarousel",2),af([pt()],lf.prototype,"imageSplide",2),af([pt()],lf.prototype,"slides",2),af([ut({type:Array,converter:{fromAttribute(t){try{return JSON.parse(t||"[]")}catch(e){return console.error("Invalid JSON for 'cards':",t),[]}},toAttribute:t=>JSON.stringify(t)}})],lf.prototype,"cards",2),lf=af([ct("pbo-category")],lf);const cf=lf,hf=l`
1547
1059
  :host {
1548
1060
  --size: 30rem;
1549
- --header-spacing: var(--sl-spacing-large);
1550
- --body-spacing: var(--sl-spacing-large);
1551
- --footer-spacing: var(--sl-spacing-large);
1061
+ --header-spacing: var(--pbo-spacing-l);
1062
+ --body-spacing: var(--pbo-spacing-l);
1063
+ --footer-spacing: var(--pbo-spacing-l);
1552
1064
 
1553
1065
  display: contents;
1554
1066
  }
@@ -1569,7 +1081,7 @@ good aklsdfja`,this.alignment="left",this.fontFamily="Arial",this.color="#000",t
1569
1081
  right: 0;
1570
1082
  bottom: 0;
1571
1083
  left: 0;
1572
- background-color: var(--sl-overlay-background-color);
1084
+ background-color: var(--pbo-overlay-background-color);
1573
1085
  pointer-events: all;
1574
1086
  }
1575
1087
 
@@ -1580,8 +1092,8 @@ good aklsdfja`,this.alignment="left",this.fontFamily="Arial",this.color="#000",t
1580
1092
  z-index: 2;
1581
1093
  max-width: 100%;
1582
1094
  max-height: 100%;
1583
- background-color: var(--sl-panel-background-color);
1584
- box-shadow: var(--sl-shadow-x-large);
1095
+ background-color: var(--pbo-panel-background-color);
1096
+ box-shadow: var(--pbo-shadow-x-large);
1585
1097
  overflow: auto;
1586
1098
  pointer-events: all;
1587
1099
  }
@@ -1594,10 +1106,10 @@ good aklsdfja`,this.alignment="left",this.fontFamily="Arial",this.color="#000",t
1594
1106
  width: 100%;
1595
1107
  height: var(--size);
1596
1108
  }
1597
- `;function C_(n,t){const e={waitUntilFirstUpdate:!1,...t};return function(i,s){const r=Array.isArray(n)?n:[n],{update:o}=i;i.update=function(a){r.forEach(l=>{const c=l;if(a.has(c)){const h=a.get(c),u=this[c];h!==u&&(!e.waitUntilFirstUpdate||this.hasUpdated)&&this[s](h,u)}}),o.call(this,a)}}}var S_=Object.defineProperty,w_=Object.getOwnPropertyDescriptor,Yn=(n,t,e,i)=>{for(var s=i>1?void 0:i?w_(t,e):t,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(t,e,s):o(s))||s);return i&&s&&S_(t,e,s),s};let Vi=class extends Ue{constructor(){super(...arguments),this.open=!1}requestClose(n){this.hide()}async hide(){this.open=!1}async show(){this.open||(this.open=!0)}handleOpenChange(){this.open?this.drawer.hidden=!1:this.drawer.hidden=!0}firstUpdated(){this.drawer.hidden=!this.open}render(){return St`
1109
+ `;var df=Object.defineProperty,uf=Object.getOwnPropertyDescriptor,pf=(t,e,i,s)=>{for(var r,n=s>1?void 0:s?uf(e,i):e,o=t.length-1;o>=0;o--)(r=t[o])&&(n=(s?r(e,i,n):r(n))||n);return s&&n&&df(e,i,n),n};let gf=class extends dd{constructor(){super(...arguments),this.open=!1}requestClose(t){this.hide()}async hide(){this.open=!1}async show(){this.open||(this.open=!0)}handleOpenChange(){this.open?this.drawer.hidden=!1:this.drawer.hidden=!0}firstUpdated(){this.drawer.hidden=!this.open}render(){return H`
1598
1110
  <div
1599
1111
  part="base"
1600
- class=${cs({drawer:!0,"drawer--bottom":!0,"drawer--open":this.open})}
1112
+ class=${Vh({drawer:!0,"drawer--bottom":!0,"drawer--open":this.open})}
1601
1113
  >
1602
1114
  <div part="overlay" class="drawer__overlay" @click=${()=>this.requestClose("overlay")}></div>
1603
1115
  <div
@@ -1611,23 +1123,23 @@ good aklsdfja`,this.alignment="left",this.fontFamily="Arial",this.color="#000",t
1611
1123
  <slot part="body" class="drawer__body"></slot>
1612
1124
  </div>
1613
1125
  </div>
1614
- `}};Vi.styles=[Vt,x_],Yn([vt(".drawer")],Vi.prototype,"drawer",2),Yn([H({type:Boolean,reflect:!0})],Vi.prototype,"open",2),Yn([C_("open",{waitUntilFirstUpdate:!0})],Vi.prototype,"handleOpenChange",1),Vi=Yn([Mt("pbo-drawer")],Vi);const T_=Vi,E_=Ct`
1126
+ `}};gf.styles=[il,hf],pf([ft(".drawer")],gf.prototype,"drawer",2),pf([ut({type:Boolean,reflect:!0})],gf.prototype,"open",2),pf([function(t,e){const i={waitUntilFirstUpdate:!1,...e};return function(e,s){const r=Array.isArray(t)?t:[t],{update:n}=e;e.update=function(t){r.forEach((e=>{const r=e;if(t.has(r)){const e=t.get(r),n=this[r];e!==n&&(i.waitUntilFirstUpdate&&!this.hasUpdated||this[s](e,n))}})),n.call(this,t)}}}("open",{waitUntilFirstUpdate:!0})],gf.prototype,"handleOpenChange",1),gf=pf([ct("pbo-drawer")],gf);const ff=gf,mf=l`
1615
1127
  :host {
1616
1128
  display: block;
1617
1129
  width: 100%;
1618
1130
  height: 100%;
1619
1131
  }
1620
- `;var O_=Object.defineProperty,A_=Object.getOwnPropertyDescriptor,yi=(n,t,e,i)=>{for(var s=i>1?void 0:i?A_(t,e):t,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(t,e,s):o(s))||s);return i&&s&&O_(t,e,s),s};let be=class extends Ue{constructor(){super(...arguments),this.currentPage="selection",this.selectedCard=null,this.categories=[{id:"birthday",name:"Birthday",cards:[{id:"birthday-1",name:"Card 1",category:"birthday",medias:{cover:{url:"https://picsum.photos/id/10/300/400",alt:"Cover image"},back:{url:"https://picsum.photos/id/30/300/400",alt:"Back image"},inner:{url:"https://picsum.photos/id/40/300/400",alt:"Inner image"},render_1:{url:"https://picsum.photos/id/55/300/400",alt:"Render 1"},render_2:{url:"https://picsum.photos/id/12/300/400",alt:"Render 2"}}},{id:"birthday-2",name:"Card 2",category:"birthday",medias:{cover:{url:"https://picsum.photos/id/43/300/400",alt:"Cover image"},back:{url:"https://picsum.photos/id/38/300/400",alt:"Back image"},inner:{url:"https://picsum.photos/id/16/300/400",alt:"Inner image"},render_1:{url:"https://picsum.photos/id/90/300/400",alt:"Render 1"},render_2:{url:"https://picsum.photos/id/17/300/400",alt:"Render 2"}}},{id:"birthday-3",name:"Card 3",category:"birthday",medias:{cover:{url:"https://picsum.photos/id/51/300/400",alt:"Cover image"},back:{url:"https://picsum.photos/id/32/300/400",alt:"Back image"},inner:{url:"https://picsum.photos/id/12/300/400",alt:"Inner image"},render_1:{url:"https://picsum.photos/id/65/300/400",alt:"Render 1"},render_2:{url:"https://picsum.photos/id/98/300/400",alt:"Render 2"}}},{id:"birthday-4",name:"Card 4",category:"birthday",medias:{cover:{url:"https://picsum.photos/id/100/300/400",alt:"Cover image"},back:{url:"https://picsum.photos/id/80/300/400",alt:"Back image"},inner:{url:"https://picsum.photos/id/70/300/400",alt:"Inner image"},render_1:{url:"https://picsum.photos/id/35/300/400",alt:"Render 1"},render_2:{url:"https://picsum.photos/id/59/300/400",alt:"Render 2"}}},{id:"birthday-5",name:"Card 5",category:"birthday",medias:{cover:{url:"https://picsum.photos/id/87/300/400",alt:"Cover image"},back:{url:"https://picsum.photos/id/16/300/400",alt:"Back image"},inner:{url:"https://picsum.photos/id/5/300/400",alt:"Inner image"},render_1:{url:"https://picsum.photos/id/14/300/400",alt:"Render 1"},render_2:{url:"https://picsum.photos/id/83/300/400",alt:"Render 2"}}}]},{id:"anniversary",name:"Anniversary",cards:[{id:"anniversary-1",name:"Card 1",category:"anniversary",medias:{cover:{url:"https://picsum.photos/id/10/300/400",alt:"Cover image"},back:{url:"https://picsum.photos/id/30/300/400",alt:"Back image"},inner:{url:"https://picsum.photos/id/40/300/400",alt:"Inner image"},render_1:{url:"https://picsum.photos/id/55/300/400",alt:"Render 1"},render_2:{url:"https://picsum.photos/id/12/300/400",alt:"Render 2"}}},{id:"anniversary-2",name:"Card 2",category:"anniversary",medias:{cover:{url:"https://picsum.photos/id/43/300/400",alt:"Cover image"},back:{url:"https://picsum.photos/id/38/300/400",alt:"Back image"},inner:{url:"https://picsum.photos/id/16/300/400",alt:"Inner image"},render_1:{url:"https://picsum.photos/id/90/300/400",alt:"Render 1"},render_2:{url:"https://picsum.photos/id/17/300/400",alt:"Render 2"}}},{id:"anniversary-3",name:"Card 3",category:"anniversary",medias:{cover:{url:"https://picsum.photos/id/51/300/400",alt:"Cover image"},back:{url:"https://picsum.photos/id/32/300/400",alt:"Back image"},inner:{url:"https://picsum.photos/id/12/300/400",alt:"Inner image"},render_1:{url:"https://picsum.photos/id/65/300/400",alt:"Render 1"},render_2:{url:"https://picsum.photos/id/98/300/400",alt:"Render 2"}}},{id:"anniversary-4",name:"Card 4",category:"anniversary",medias:{cover:{url:"https://picsum.photos/id/100/300/400",alt:"Cover image"},back:{url:"https://picsum.photos/id/80/300/400",alt:"Back image"},inner:{url:"https://picsum.photos/id/70/300/400",alt:"Inner image"},render_1:{url:"https://picsum.photos/id/35/300/400",alt:"Render 1"},render_2:{url:"https://picsum.photos/id/59/300/400",alt:"Render 2"}}},{id:"anniversary-5",name:"Card 5",category:"anniversary",medias:{cover:{url:"https://picsum.photos/id/87/300/400",alt:"Cover image"},back:{url:"https://picsum.photos/id/16/300/400",alt:"Back image"},inner:{url:"https://picsum.photos/id/5/300/400",alt:"Inner image"},render_1:{url:"https://picsum.photos/id/14/300/400",alt:"Render 1"},render_2:{url:"https://picsum.photos/id/83/300/400",alt:"Render 2"}}}]}],this.selectedCardId=null,this.selectedCardDetails=null,this.handleCardSelected=t=>{const{cardId:e}=t.detail,i=this.findCardInCategoryById(e);this.editorEl.card=i,this.goToEditor()}}goToEditor(){this.currentPage="editor"}goToSelector(){this.currentPage="selection"}connectedCallback(){var t;super.connectedCallback(),(t=this.shadowRoot)==null||t.addEventListener("pbo-category-card-selected",this.handleCardSelected)}disconnectedCallback(){var t;super.disconnectedCallback(),(t=this.shadowRoot)==null||t.removeEventListener("pbo-category-card-selected",this.handleCardSelected)}firstUpdated(){this.cardSelectionEl.categories=this.categories}updated(t){this.cardSelectionEl.categories=this.categories}findCardInCategoryById(t){for(const e of this.categories){const i=e.cards.find(s=>s.id===t);if(i)return i}return null}render(){return St`
1132
+ `;var vf=Object.defineProperty,_f=Object.getOwnPropertyDescriptor,bf=(t,e,i,s)=>{for(var r,n=s>1?void 0:s?_f(e,i):e,o=t.length-1;o>=0;o--)(r=t[o])&&(n=(s?r(e,i,n):r(n))||n);return s&&n&&vf(e,i,n),n};let yf=class extends dd{constructor(){super(...arguments),this.currentPage="selection",this.selectedCard=null,this.categories=[{id:"birthday",name:"Birthday",cards:[{id:"birthday-1",name:"Card 1",category:"birthday",medias:{cover:{url:"https://picsum.photos/id/10/300/400",alt:"Cover image"},back:{url:"https://picsum.photos/id/30/300/400",alt:"Back image"},inner:{url:"https://picsum.photos/id/40/300/400",alt:"Inner image"},render_1:{url:"https://picsum.photos/id/55/300/400",alt:"Render 1"},render_2:{url:"https://picsum.photos/id/12/300/400",alt:"Render 2"}}},{id:"birthday-2",name:"Card 2",category:"birthday",medias:{cover:{url:"https://picsum.photos/id/43/300/400",alt:"Cover image"},back:{url:"https://picsum.photos/id/38/300/400",alt:"Back image"},inner:{url:"https://picsum.photos/id/16/300/400",alt:"Inner image"},render_1:{url:"https://picsum.photos/id/90/300/400",alt:"Render 1"},render_2:{url:"https://picsum.photos/id/17/300/400",alt:"Render 2"}}},{id:"birthday-3",name:"Card 3",category:"birthday",medias:{cover:{url:"https://picsum.photos/id/51/300/400",alt:"Cover image"},back:{url:"https://picsum.photos/id/32/300/400",alt:"Back image"},inner:{url:"https://picsum.photos/id/12/300/400",alt:"Inner image"},render_1:{url:"https://picsum.photos/id/65/300/400",alt:"Render 1"},render_2:{url:"https://picsum.photos/id/98/300/400",alt:"Render 2"}}},{id:"birthday-4",name:"Card 4",category:"birthday",medias:{cover:{url:"https://picsum.photos/id/100/300/400",alt:"Cover image"},back:{url:"https://picsum.photos/id/80/300/400",alt:"Back image"},inner:{url:"https://picsum.photos/id/70/300/400",alt:"Inner image"},render_1:{url:"https://picsum.photos/id/35/300/400",alt:"Render 1"},render_2:{url:"https://picsum.photos/id/59/300/400",alt:"Render 2"}}},{id:"birthday-5",name:"Card 5",category:"birthday",medias:{cover:{url:"https://picsum.photos/id/87/300/400",alt:"Cover image"},back:{url:"https://picsum.photos/id/16/300/400",alt:"Back image"},inner:{url:"https://picsum.photos/id/5/300/400",alt:"Inner image"},render_1:{url:"https://picsum.photos/id/14/300/400",alt:"Render 1"},render_2:{url:"https://picsum.photos/id/83/300/400",alt:"Render 2"}}}]},{id:"anniversary",name:"Anniversary",cards:[{id:"anniversary-1",name:"Card 1",category:"anniversary",medias:{cover:{url:"https://picsum.photos/id/10/300/400",alt:"Cover image"},back:{url:"https://picsum.photos/id/30/300/400",alt:"Back image"},inner:{url:"https://picsum.photos/id/40/300/400",alt:"Inner image"},render_1:{url:"https://picsum.photos/id/55/300/400",alt:"Render 1"},render_2:{url:"https://picsum.photos/id/12/300/400",alt:"Render 2"}}},{id:"anniversary-2",name:"Card 2",category:"anniversary",medias:{cover:{url:"https://picsum.photos/id/43/300/400",alt:"Cover image"},back:{url:"https://picsum.photos/id/38/300/400",alt:"Back image"},inner:{url:"https://picsum.photos/id/16/300/400",alt:"Inner image"},render_1:{url:"https://picsum.photos/id/90/300/400",alt:"Render 1"},render_2:{url:"https://picsum.photos/id/17/300/400",alt:"Render 2"}}},{id:"anniversary-3",name:"Card 3",category:"anniversary",medias:{cover:{url:"https://picsum.photos/id/51/300/400",alt:"Cover image"},back:{url:"https://picsum.photos/id/32/300/400",alt:"Back image"},inner:{url:"https://picsum.photos/id/12/300/400",alt:"Inner image"},render_1:{url:"https://picsum.photos/id/65/300/400",alt:"Render 1"},render_2:{url:"https://picsum.photos/id/98/300/400",alt:"Render 2"}}},{id:"anniversary-4",name:"Card 4",category:"anniversary",medias:{cover:{url:"https://picsum.photos/id/100/300/400",alt:"Cover image"},back:{url:"https://picsum.photos/id/80/300/400",alt:"Back image"},inner:{url:"https://picsum.photos/id/70/300/400",alt:"Inner image"},render_1:{url:"https://picsum.photos/id/35/300/400",alt:"Render 1"},render_2:{url:"https://picsum.photos/id/59/300/400",alt:"Render 2"}}},{id:"anniversary-5",name:"Card 5",category:"anniversary",medias:{cover:{url:"https://picsum.photos/id/87/300/400",alt:"Cover image"},back:{url:"https://picsum.photos/id/16/300/400",alt:"Back image"},inner:{url:"https://picsum.photos/id/5/300/400",alt:"Inner image"},render_1:{url:"https://picsum.photos/id/14/300/400",alt:"Render 1"},render_2:{url:"https://picsum.photos/id/83/300/400",alt:"Render 2"}}}]}],this.selectedCardId=null,this.selectedCardDetails=null,this.handleCardSelected=t=>{const{cardId:e}=t.detail,i=this.findCardInCategoryById(e);this.editorEl.card=i,this.goToEditor()}}goToEditor(){this.currentPage="editor"}goToSelector(){this.currentPage="selection"}connectedCallback(){var t;super.connectedCallback(),null==(t=this.shadowRoot)||t.addEventListener("pbo-category-card-selected",this.handleCardSelected)}disconnectedCallback(){var t;super.disconnectedCallback(),null==(t=this.shadowRoot)||t.removeEventListener("pbo-category-card-selected",this.handleCardSelected)}firstUpdated(){this.cardSelectionEl.categories=this.categories}updated(t){this.cardSelectionEl.categories=this.categories}findCardInCategoryById(t){for(const e of this.categories){const i=e.cards.find((e=>e.id===t));if(i)return i}return null}render(){return H`
1621
1133
  <button @click=${this.goToSelector}>Prev</button>
1622
1134
  <button @click=${this.goToEditor}>Next</button>
1623
- <pbo-card-selection name="selection" ?hidden=${this.currentPage!=="selection"}></pbo-card-selection>
1624
- <pbo-editor name="editor" ?hidden=${this.currentPage!=="editor"}></pbo-editor>
1625
- `}};be.styles=[Vt,E_],yi([vt("pbo-card-selection")],be.prototype,"cardSelectionEl",2),yi([vt("pbo-editor")],be.prototype,"editorEl",2),yi([st()],be.prototype,"currentPage",2),yi([st()],be.prototype,"selectedCard",2),yi([st()],be.prototype,"categories",2),yi([st()],be.prototype,"selectedCardId",2),yi([st()],be.prototype,"selectedCardDetails",2),be=yi([Mt("pbo-page-manager")],be);const D_=be,k_=Ct`
1135
+ <pbo-card-selection name="selection" ?hidden=${"selection"!==this.currentPage}></pbo-card-selection>
1136
+ <pbo-editor name="editor" ?hidden=${"editor"!==this.currentPage}></pbo-editor>
1137
+ `}};yf.styles=[il,mf],bf([ft("pbo-card-selection")],yf.prototype,"cardSelectionEl",2),bf([ft("pbo-editor")],yf.prototype,"editorEl",2),bf([pt()],yf.prototype,"currentPage",2),bf([pt()],yf.prototype,"selectedCard",2),bf([pt()],yf.prototype,"categories",2),bf([pt()],yf.prototype,"selectedCardId",2),bf([pt()],yf.prototype,"selectedCardDetails",2),yf=bf([ct("pbo-page-manager")],yf);const xf=yf,wf=l`
1626
1138
  :host {
1627
1139
  display: block;
1628
1140
  }
1629
- `;var M_=Object.defineProperty,P_=Object.getOwnPropertyDescriptor,pu=(n,t,e,i)=>{for(var s=i>1?void 0:i?P_(t,e):t,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(t,e,s):o(s))||s);return i&&s&&M_(t,e,s),s};let vr=class extends Ue{constructor(){super(...arguments),this.categories=[]}firstUpdated(t){console.log(this.categories)}render(){return St`
1630
- ${gu(this.categories,t=>St`<pbo-category .cards=${t.cards} .name=${t.name}>
1141
+ `;var Cf=Object.defineProperty,Sf=Object.getOwnPropertyDescriptor,Tf=(t,e,i,s)=>{for(var r,n=s>1?void 0:s?Sf(e,i):e,o=t.length-1;o>=0;o--)(r=t[o])&&(n=(s?r(e,i,n):r(n))||n);return s&&n&&Cf(e,i,n),n};let Of=class extends dd{constructor(){super(...arguments),this.categories=[]}firstUpdated(t){console.log(this.categories)}render(){return H`
1142
+ ${rf(this.categories,(t=>H`<pbo-category .cards=${t.cards} .name=${t.name}>
1631
1143
  <h3 slot="title">${t.name}</h3>
1632
- </pbo-category>`)}
1633
- `}};vr.styles=[Vt,k_],pu([H({type:Array})],vr.prototype,"categories",2),vr=pu([Mt("pbo-card-selection")],vr);const I_=vr;z.PboButton=vm,z.PboButtonGroup=xm,z.PboCardSelection=I_,z.PboCategory=y_,z.PboDrawer=T_,z.PboEditor=g_,z.PboEditorCardSlider=m_,z.PboPageManager=D_,z.PboRadioButton=Em,z.PboRadioGroup=Pm,z.PboTextarea=$m,z.PboTypeForm=p_,Object.defineProperty(z,Symbol.toStringTag,{value:"Module"})});
1144
+ </pbo-category>`))}
1145
+ `}};Of.styles=[il,wf],Tf([ut({type:Array})],Of.prototype,"categories",2),Of=Tf([ct("pbo-card-selection")],Of);const Ef=Of;t.PboButton=Yh,t.PboButtonGroup=Qh,t.PboCardSelection=Ef,t.PboCategory=cf,t.PboDrawer=ff,t.PboEditor=Qg,t.PboEditorCardSlider=ef,t.PboPageManager=xf,t.PboRadioButton=cd,t.PboRadioGroup=Od,t.PboTextarea=Ld,t.PboTypeForm=tf,Object.defineProperty(t,Symbol.toStringTag,{value:"Module"})}));