@pairbo/ui-kit 0.2.6 → 0.2.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/ui-kit.js CHANGED
@@ -1,8 +1,46 @@
1
- import{e as ou,i as vt,r as Xo,x as X,t as Ot,c as Pt,n as O,a as q,b as $,w as et,d as kn,f as ni,E as Ko,P as Bt,g as qo,h as Zo,j as Fi,T as Rr,Z as au,B as lu,k as cu,l as hu}from"./assets/page-manager.component-Dzd6xKY5.js";/**
1
+ /**
2
+ * @license
3
+ * Copyright 2019 Google LLC
4
+ * SPDX-License-Identifier: BSD-3-Clause
5
+ */const yn=globalThis,Sa=yn.ShadowRoot&&(yn.ShadyCSS===void 0||yn.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,Ta=Symbol(),fl=new WeakMap;let Wc=class{constructor(t,e,i){if(this._$cssResult$=!0,i!==Ta)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(Sa&&t===void 0){const i=e!==void 0&&e.length===1;i&&(t=fl.get(e)),t===void 0&&((this.o=t=new CSSStyleSheet).replaceSync(this.cssText),i&&fl.set(e,t))}return t}toString(){return this.cssText}};const Or=n=>new Wc(typeof n=="string"?n:n+"",void 0,Ta),at=(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 Wc(e,n,Ta)},id=(n,t)=>{if(Sa)n.adoptedStyleSheets=t.map(e=>e instanceof CSSStyleSheet?e:e.styleSheet);else for(const e of t){const i=document.createElement("style"),s=yn.litNonce;s!==void 0&&i.setAttribute("nonce",s),i.textContent=e.cssText,n.appendChild(i)}},gl=Sa?n=>n:n=>n instanceof CSSStyleSheet?(t=>{let e="";for(const i of t.cssRules)e+=i.cssText;return Or(e)})(n):n;/**
6
+ * @license
7
+ * Copyright 2017 Google LLC
8
+ * SPDX-License-Identifier: BSD-3-Clause
9
+ */const{is:sd,defineProperty:rd,getOwnPropertyDescriptor:nd,getOwnPropertyNames:od,getOwnPropertySymbols:ad,getPrototypeOf:ld}=Object,Ei=globalThis,ml=Ei.trustedTypes,cd=ml?ml.emptyScript:"",So=Ei.reactiveElementPolyfillSupport,tr=(n,t)=>n,Pn={toAttribute(n,t){switch(t){case Boolean:n=n?cd: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}},Ea=(n,t)=>!sd(n,t),vl={attribute:!0,type:String,converter:Pn,reflect:!1,hasChanged:Ea};Symbol.metadata??(Symbol.metadata=Symbol("metadata")),Ei.litPropertyMetadata??(Ei.litPropertyMetadata=new WeakMap);let ds=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=vl){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&&rd(this.prototype,t,s)}}static getPropertyDescriptor(t,e,i){const{get:s,set:r}=nd(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)??vl}static _$Ei(){if(this.hasOwnProperty(tr("elementProperties")))return;const t=ld(this);t.finalize(),t.l!==void 0&&(this.l=[...t.l]),this.elementProperties=new Map(t.elementProperties)}static finalize(){if(this.hasOwnProperty(tr("finalized")))return;if(this.finalized=!0,this._$Ei(),this.hasOwnProperty(tr("properties"))){const e=this.properties,i=[...od(e),...ad(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(gl(s))}else t!==void 0&&e.push(gl(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 id(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:Pn).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:Pn;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??Ea)(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){}};ds.elementStyles=[],ds.shadowRootOptions={mode:"open"},ds[tr("elementProperties")]=new Map,ds[tr("finalized")]=new Map,So==null||So({ReactiveElement:ds}),(Ei.reactiveElementVersions??(Ei.reactiveElementVersions=[])).push("2.0.4");/**
10
+ * @license
11
+ * Copyright 2017 Google LLC
12
+ * SPDX-License-Identifier: BSD-3-Clause
13
+ */const er=globalThis,Dn=er.trustedTypes,bl=Dn?Dn.createPolicy("lit-html",{createHTML:n=>n}):void 0,Gc="$lit$",wi=`lit$${Math.random().toFixed(9).slice(2)}$`,Yc="?"+wi,hd=`<${Yc}>`,ts=document,cr=()=>ts.createComment(""),hr=n=>n===null||typeof n!="object"&&typeof n!="function",Oa=Array.isArray,ud=n=>Oa(n)||typeof(n==null?void 0:n[Symbol.iterator])=="function",To=`[
14
+ \f\r]`,Vs=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,_l=/-->/g,yl=/>/g,Vi=RegExp(`>|${To}(?:([^\\s"'>=/]+)(${To}*=${To}*(?:[^
15
+ \f\r"'\`<>=]|("|')|))|$)`,"g"),xl=/'/g,wl=/"/g,Xc=/^(?:script|style|textarea|title)$/i,dd=n=>(t,...e)=>({_$litType$:n,strings:t,values:e}),W=dd(1),Ce=Symbol.for("lit-noChange"),Tt=Symbol.for("lit-nothing"),Cl=new WeakMap,Ki=ts.createTreeWalker(ts,129);function Kc(n,t){if(!Oa(n)||!n.hasOwnProperty("raw"))throw Error("invalid template strings array");return bl!==void 0?bl.createHTML(t):t}const pd=(n,t)=>{const e=n.length-1,i=[];let s,r=t===2?"<svg>":t===3?"<math>":"",o=Vs;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===Vs?h[1]==="!--"?o=_l:h[1]!==void 0?o=yl:h[2]!==void 0?(Xc.test(h[2])&&(s=RegExp("</"+h[2],"g")),o=Vi):h[3]!==void 0&&(o=Vi):o===Vi?h[0]===">"?(o=s??Vs,u=-1):h[1]===void 0?u=-2:(u=o.lastIndex-h[2].length,c=h[1],o=h[3]===void 0?Vi:h[3]==='"'?wl:xl):o===wl||o===xl?o=Vi:o===_l||o===yl?o=Vs:(o=Vi,s=void 0);const p=o===Vi&&n[a+1].startsWith("/>")?" ":"";r+=o===Vs?l+hd:u>=0?(i.push(c),l.slice(0,u)+Gc+l.slice(u)+wi+p):l+wi+(u===-2?a:p)}return[Kc(n,r+(n[e]||"<?>")+(t===2?"</svg>":t===3?"</math>":"")),i]};let qo=class qc{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]=pd(t,e);if(this.el=qc.createElement(c,i),Ki.currentNode=this.el.content,e===2||e===3){const u=this.el.content.firstChild;u.replaceWith(...u.childNodes)}for(;(s=Ki.nextNode())!==null&&l.length<a;){if(s.nodeType===1){if(s.hasAttributes())for(const u of s.getAttributeNames())if(u.endsWith(Gc)){const d=h[o++],p=s.getAttribute(u).split(wi),f=/([.?@])?(.*)/.exec(d);l.push({type:1,index:r,name:f[2],strings:p,ctor:f[1]==="."?gd:f[1]==="?"?md:f[1]==="@"?vd:Zn}),s.removeAttribute(u)}else u.startsWith(wi)&&(l.push({type:6,index:r}),s.removeAttribute(u));if(Xc.test(s.tagName)){const u=s.textContent.split(wi),d=u.length-1;if(d>0){s.textContent=Dn?Dn.emptyScript:"";for(let p=0;p<d;p++)s.append(u[p],cr()),Ki.nextNode(),l.push({type:2,index:++r});s.append(u[d],cr())}}}else if(s.nodeType===8)if(s.data===Yc)l.push({type:2,index:r});else{let u=-1;for(;(u=s.data.indexOf(wi,u+1))!==-1;)l.push({type:7,index:r}),u+=wi.length-1}r++}}static createElement(t,e){const i=ts.createElement("template");return i.innerHTML=t,i}};function Os(n,t,e=n,i){var o,a;if(t===Ce)return t;let s=i!==void 0?(o=e._$Co)==null?void 0:o[i]:e._$Cl;const r=hr(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=Os(n,s._$AS(n,t.values),s,i)),t}let fd=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)??ts).importNode(e,!0);Ki.currentNode=s;let r=Ki.nextNode(),o=0,a=0,l=i[0];for(;l!==void 0;){if(o===l.index){let c;l.type===2?c=new qn(r,r.nextSibling,this,t):l.type===1?c=new l.ctor(r,l.name,l.strings,this,t):l.type===6&&(c=new bd(r,this,t)),this._$AV.push(c),l=i[++a]}o!==(l==null?void 0:l.index)&&(r=Ki.nextNode(),o++)}return Ki.currentNode=ts,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++}},qn=class Zc{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=Tt,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=Os(this,t,e),hr(t)?t===Tt||t==null||t===""?(this._$AH!==Tt&&this._$AR(),this._$AH=Tt):t!==this._$AH&&t!==Ce&&this._(t):t._$litType$!==void 0?this.$(t):t.nodeType!==void 0?this.T(t):ud(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!==Tt&&hr(this._$AH)?this._$AA.nextSibling.data=t:this.T(ts.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=qo.createElement(Kc(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 fd(s,this),a=o.u(this.options);o.p(e),this.T(a),this._$AH=o}}_$AC(t){let e=Cl.get(t.strings);return e===void 0&&Cl.set(t.strings,e=new qo(t)),e}k(t){Oa(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 Zc(this.O(cr()),this.O(cr()),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))}},Zn=class{get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}constructor(t,e,i,s,r){this.type=1,this._$AH=Tt,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=Tt}_$AI(t,e=this,i,s){const r=this.strings;let o=!1;if(r===void 0)t=Os(this,t,e,0),o=!hr(t)||t!==this._$AH&&t!==Ce,o&&(this._$AH=t);else{const a=t;let l,c;for(t=r[0],l=0;l<r.length-1;l++)c=Os(this,a[i+l],e,l),c===Ce&&(c=this._$AH[l]),o||(o=!hr(c)||c!==this._$AH[l]),c===Tt?t=Tt:t!==Tt&&(t+=(c??"")+r[l+1]),this._$AH[l]=c}o&&!s&&this.j(t)}j(t){t===Tt?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,t??"")}},gd=class extends Zn{constructor(){super(...arguments),this.type=3}j(t){this.element[this.name]=t===Tt?void 0:t}},md=class extends Zn{constructor(){super(...arguments),this.type=4}j(t){this.element.toggleAttribute(this.name,!!t&&t!==Tt)}},vd=class extends Zn{constructor(t,e,i,s,r){super(t,e,i,s,r),this.type=5}_$AI(t,e=this){if((t=Os(this,t,e,0)??Tt)===Ce)return;const i=this._$AH,s=t===Tt&&i!==Tt||t.capture!==i.capture||t.once!==i.once||t.passive!==i.passive,r=t!==Tt&&(i===Tt||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)}},bd=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){Os(this,t)}};const _d={I:qn},Eo=er.litHtmlPolyfillSupport;Eo==null||Eo(qo,qn),(er.litHtmlVersions??(er.litHtmlVersions=[])).push("3.2.1");const Jc=(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 qn(t.insertBefore(cr(),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 Oi=class extends ds{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=Jc(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 Ce}};var Uc;Oi._$litElement$=!0,Oi.finalized=!0,(Uc=globalThis.litElementHydrateSupport)==null||Uc.call(globalThis,{LitElement:Oi});const Oo=globalThis.litElementPolyfillSupport;Oo==null||Oo({LitElement:Oi});(globalThis.litElementVersions??(globalThis.litElementVersions=[])).push("4.1.1");/**
2
20
  * @license
3
21
  * Copyright 2017 Google LLC
4
22
  * SPDX-License-Identifier: BSD-3-Clause
5
- */let uu;function Jo(n){return(t,e)=>ou(t,e,{get(){return(this.renderRoot??uu??(uu=document.createDocumentFragment())).querySelectorAll(n)}})}const du=vt`
23
+ */const bt=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 yd={attribute:!0,type:String,converter:Pn,reflect:!1,hasChanged:Ea},xd=(n=yd,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 T(n){return(t,e)=>typeof e=="object"?xd(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 V(n){return T({...n,state:!0,attribute:!1})}/**
32
+ * @license
33
+ * Copyright 2017 Google LLC
34
+ * SPDX-License-Identifier: BSD-3-Clause
35
+ */const Qc=(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 q(n,t){return(e,i,s)=>{const r=o=>{var a;return((a=o.renderRoot)==null?void 0:a.querySelector(n))??null};return Qc(e,i,{get(){return r(this)}})}}/**
40
+ * @license
41
+ * Copyright 2017 Google LLC
42
+ * SPDX-License-Identifier: BSD-3-Clause
43
+ */let wd;function ka(n){return(t,e)=>Qc(t,e,{get(){return(this.renderRoot??wd??(wd=document.createDocumentFragment())).querySelectorAll(n)}})}const Cd=at`
6
44
  :host {
7
45
  display: block;
8
46
  font-family: Arial, sans-serif;
@@ -14,7 +52,7 @@ import{e as ou,i as vt,r as Xo,x as X,t as Ot,c as Pt,n as O,a as q,b as $,w as
14
52
  background-color: #fff;
15
53
  color: black;
16
54
  }
17
- `;var pu=Object.getOwnPropertyDescriptor,fu=(n,t,e,i)=>{for(var r=i>1?void 0:i?pu(t,e):t,s=n.length-1,o;s>=0;s--)(o=n[s])&&(r=o(r)||r);return r};let hn=class extends Xo{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 n=(t=this.shadowRoot)==null?void 0:t.querySelector(".message-selector");n&&n.classList.toggle("message-selector-hidden")}_onGiftChange(n){const t=n.target;this.giftSelected=t.checked,this.giftSelected||(this.premiumSelected=!1,this.freeMessageSelected=!1)}_onPremiumChange(n){n.target.checked?(this.premiumSelected=!0,this.freeMessageSelected=!1):this.premiumSelected=!1}_onFreeMessageChange(n){n.target.checked?(this.freeMessageSelected=!0,this.premiumSelected=!1):this.freeMessageSelected=!1}render(){return X`
55
+ `;var Sd=Object.getOwnPropertyDescriptor,Td=(n,t,e,i)=>{for(var s=i>1?void 0:i?Sd(t,e):t,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=o(s)||s);return s};let Mn=class extends Oi{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 n=(t=this.shadowRoot)==null?void 0:t.querySelector(".message-selector");n&&n.classList.toggle("message-selector-hidden")}_onGiftChange(n){const t=n.target;this.giftSelected=t.checked,this.giftSelected||(this.premiumSelected=!1,this.freeMessageSelected=!1)}_onPremiumChange(n){n.target.checked?(this.premiumSelected=!0,this.freeMessageSelected=!1):this.premiumSelected=!1}_onFreeMessageChange(n){n.target.checked?(this.freeMessageSelected=!0,this.premiumSelected=!1):this.freeMessageSelected=!1}render(){return W`
18
56
  <div class="message-selector">
19
57
  <!-- Gift Checkbox: Always visible -->
20
58
  <div>
@@ -29,7 +67,7 @@ import{e as ou,i as vt,r as Xo,x as X,t as Ot,c as Pt,n as O,a as q,b as $,w as
29
67
  </div>
30
68
 
31
69
  <!-- Premium and Free Message Options: Only visible if gift is selected -->
32
- ${this.giftSelected?X`
70
+ ${this.giftSelected?W`
33
71
  <div>
34
72
  <input
35
73
  type="checkbox"
@@ -65,7 +103,7 @@ import{e as ou,i as vt,r as Xo,x as X,t as Ot,c as Pt,n as O,a as q,b as $,w as
65
103
  </ul>
66
104
  </div>
67
105
  </div>
68
- `}};hn.styles=[du,vt`
106
+ `}};Mn.styles=[Cd,at`
69
107
  .message-selector {
70
108
  text-align: left;
71
109
  }
@@ -86,35 +124,35 @@ import{e as ou,i as vt,r as Xo,x as X,t as Ot,c as Pt,n as O,a as q,b as $,w as
86
124
  code {
87
125
  font-family: monospace;
88
126
  }
89
- `];hn.properties={giftLabel:{type:String},premiumLabel:{type:String},premiumDescription:{type:String},noteLabel:{type:String},giftSelected:{type:Boolean},premiumSelected:{type:Boolean},freeMessageSelected:{type:Boolean}};hn=fu([Ot("pairbo-message-selector")],hn);function b(n,t,e){return(t=function(i){var r=function(s,o){if(typeof s!="object"||!s)return s;var a=s[Symbol.toPrimitive];if(a!==void 0){var l=a.call(s,o);if(typeof l!="object")return l;throw new TypeError("@@toPrimitive must return a primitive value.")}return(o==="string"?String:Number)(s)}(i,"string");return typeof r=="symbol"?r:r+""}(t))in n?Object.defineProperty(n,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):n[t]=e,n}function Ba(n,t){var e=Object.keys(n);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(n);t&&(i=i.filter(function(r){return Object.getOwnPropertyDescriptor(n,r).enumerable})),e.push.apply(e,i)}return e}function _(n){for(var t=1;t<arguments.length;t++){var e=arguments[t]!=null?arguments[t]:{};t%2?Ba(Object(e),!0).forEach(function(i){b(n,i,e[i])}):Object.getOwnPropertyDescriptors?Object.defineProperties(n,Object.getOwnPropertyDescriptors(e)):Ba(Object(e)).forEach(function(i){Object.defineProperty(n,i,Object.getOwnPropertyDescriptor(e,i))})}return n}function ht(n,t){if(n==null)return{};var e,i,r=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 s=Object.getOwnPropertySymbols(n);for(i=0;i<s.length;i++)e=s[i],t.indexOf(e)>=0||{}.propertyIsEnumerable.call(n,e)&&(r[e]=n[e])}return r}function ki(n,t){return t||(t=n.slice(0)),Object.freeze(Object.defineProperties(n,{raw:{value:Object.freeze(t)}}))}let Na=class{constructor(){b(this,"browserShadowBlurConstant",1),b(this,"DPI",96),b(this,"devicePixelRatio",typeof window<"u"?window.devicePixelRatio:1),b(this,"perfLimitSizeTotal",2097152),b(this,"maxCacheSideLimit",4096),b(this,"minCacheSideLimit",256),b(this,"disableStyleCopyPaste",!1),b(this,"enableGLFiltering",!0),b(this,"textureSize",4096),b(this,"forceGLPutImageData",!1),b(this,"cachesBoundsOfCurve",!1),b(this,"fontPaths",{}),b(this,"NUM_FRACTION_DIGITS",4)}};const Q=new class extends Na{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=_(_({},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 Na,e=(n==null?void 0:n.reduce((i,r)=>(i[r]=t[r],i),{}))||t;this.configure(e)}},yi=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)};let je=class extends Error{constructor(t,e){super("fabric: ".concat(t),e)}};class gu extends je{constructor(t){super("".concat(t," 'options.signal' is in 'aborted' state"))}}let mu=class{},vu=class extends mu{testPrecision(t,e){const i="precision ".concat(e,` float;
90
- void main(){}`),r=t.createShader(t.FRAGMENT_SHADER);return!!r&&(t.shaderSource(r,i),t.compileShader(r),!!t.getShaderParameter(r,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(),yi("log","WebGL: max texture size ".concat(this.maxTextureSize)))}isSupported(t){return!!this.maxTextureSize&&this.maxTextureSize>=t}};const bu={};let za;const Be=()=>za||(za={document,window,isTouchSupported:"ontouchstart"in window||"ontouchstart"in document||window&&window.navigator&&window.navigator.maxTouchPoints>0,WebGLProbe:new vu,dispose(){},copyPasteData:bu}),vr=()=>Be().document,Qo=()=>Be().window,sc=()=>{var n;return Math.max((n=Q.devicePixelRatio)!==null&&n!==void 0?n:Qo().devicePixelRatio,1)},zr=new class{constructor(){b(this,"charWidthsCache",{}),b(this,"boundsOfCurveCache",{})}getFontCache(n){let{fontFamily:t,fontStyle:e,fontWeight:i}=n;t=t.toLowerCase(),this.charWidthsCache[t]||(this.charWidthsCache[t]={});const r=this.charWidthsCache[t],s="".concat(e.toLowerCase(),"_").concat((i+"").toLowerCase());return r[s]||(r[s]={}),r[s]}clearFontCache(n){(n=(n||"").toLowerCase())?this.charWidthsCache[n]&&delete this.charWidthsCache[n]:this.charWidthsCache={}}limitDimsByArea(n){const{perfLimitSizeTotal:t}=Q,e=Math.sqrt(t*n);return[Math.floor(e),Math.floor(t/e)]}},xo="6.5.4";function tn(){}const cs=Math.PI/2,un=2*Math.PI,ta=Math.PI/180,Qt=Object.freeze([1,0,0,1,0,0]),ea=16,fi=.4477152502,K="center",it="left",ne="top",wo="bottom",xt="right",oe="none",ia=/\r?\n/,nc="moving",Dn="scaling",oc="rotating",ra="rotate",ac="skewing",Yr="resizing",_u="modifyPoly",yu="modifyPath",dn="changed",Pn="scale",le="scaleX",xe="scaleY",br="skewX",_r="skewY",It="fill",ae="stroke",pn="modified",Ji="json",Jn="svg",R=new class{constructor(){this[Ji]=new Map,this[Jn]=new Map}has(n){return this[Ji].has(n)}getClass(n){const t=this[Ji].get(n);if(!t)throw new je("No class registered for ".concat(n));return t}setClass(n,t){t?this[Ji].set(t,n):(this[Ji].set(n.type,n),this[Ji].set(n.type.toLowerCase(),n))}getSVGClass(n){return this[Jn].get(n)}setSVGClass(n,t){this[Jn].set(t??n.type.toLowerCase(),n)}},fn=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 xu{constructor(){b(this,"__eventListeners",{})}on(t,e){if(this.__eventListeners||(this.__eventListeners={}),typeof t=="object")return Object.entries(t).forEach(i=>{let[r,s]=i;this.on(r,s)}),()=>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(r=>{let[s,o]=r;i.push(this.once(s,o))}),()=>i.forEach(r=>r())}if(e){const i=this.on(t,function(){for(var r=arguments.length,s=new Array(r),o=0;o<r;o++)s[o]=arguments[o];e.call(this,...s),i()});return i}return()=>!1}_removeEventListener(t,e){if(this.__eventListeners[t])if(e){const i=this.__eventListeners[t],r=i.indexOf(e);r>-1&&i.splice(r,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[r,s]=i;this._removeEventListener(r,s)}):this._removeEventListener(t,e)}fire(t,e){var i;if(!this.__eventListeners)return;const r=(i=this.__eventListeners[t])===null||i===void 0?void 0:i.concat();if(r)for(let s=0;s<r.length;s++)r[s].call(this,e||{})}}const tr=(n,t)=>{const e=n.indexOf(t);return e!==-1&&n.splice(e,1),n},oi=n=>{if(n===0)return 1;switch(Math.abs(n)/cs){case 1:case 3:return 0;case 2:return-1}return Math.cos(n)},ai=n=>{if(n===0)return 0;const t=n/cs,e=Math.sign(n);switch(t){case 1:return e;case 2:return 0;case 3:return-e}return Math.sin(n)};class w{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 w(this.x+t.x,this.y+t.y)}addEquals(t){return this.x+=t.x,this.y+=t.y,this}scalarAdd(t){return new w(this.x+t,this.y+t)}scalarAddEquals(t){return this.x+=t,this.y+=t,this}subtract(t){return new w(this.x-t.x,this.y-t.y)}subtractEquals(t){return this.x-=t.x,this.y-=t.y,this}scalarSubtract(t){return new w(this.x-t,this.y-t)}scalarSubtractEquals(t){return this.x-=t,this.y-=t,this}multiply(t){return new w(this.x*t.x,this.y*t.y)}scalarMultiply(t){return new w(this.x*t,this.y*t)}scalarMultiplyEquals(t){return this.x*=t,this.y*=t,this}divide(t){return new w(this.x/t.x,this.y/t.y)}scalarDivide(t){return new w(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 w(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 w(Math.min(this.x,t.x),Math.min(this.y,t.y))}max(t){return new w(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 w(this.x,this.y)}rotate(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:sa;const i=ai(t),r=oi(t),s=this.subtract(e);return new w(s.x*r-s.y*i,s.x*i+s.y*r).add(e)}transform(t){let e=arguments.length>1&&arguments[1]!==void 0&&arguments[1];return new w(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 sa=new w(0,0),en=n=>!!n&&Array.isArray(n._objects);function lc(n){class t extends n{constructor(){super(...arguments),b(this,"_objects",[])}_onObjectAdded(i){}_onObjectRemoved(i){}_onStackOrderChanged(i){}add(){for(var i=arguments.length,r=new Array(i),s=0;s<i;s++)r[s]=arguments[s];const o=this._objects.push(...r);return r.forEach(a=>this._onObjectAdded(a)),o}insertAt(i){for(var r=arguments.length,s=new Array(r>1?r-1:0),o=1;o<r;o++)s[o-1]=arguments[o];return this._objects.splice(i,0,...s),s.forEach(a=>this._onObjectAdded(a)),this._objects.length}remove(){const i=this._objects,r=[];for(var s=arguments.length,o=new Array(s),a=0;a<s;a++)o[a]=arguments[a];return o.forEach(l=>{const c=i.indexOf(l);c!==-1&&(i.splice(c,1),r.push(l),this._onObjectRemoved(l))}),r}forEachObject(i){this.getObjects().forEach((r,s,o)=>i(r,s,o))}getObjects(){for(var i=arguments.length,r=new Array(i),s=0;s<i;s++)r[s]=arguments[s];return r.length===0?[...this._objects]:this._objects.filter(o=>o.isType(...r))}item(i){return this._objects[i]}isEmpty(){return this._objects.length===0}size(){return this._objects.length}contains(i,r){return!!this._objects.includes(i)||!!r&&this._objects.some(s=>s instanceof t&&s.contains(i,!0))}complexity(){return this._objects.reduce((i,r)=>i+=r.complexity?r.complexity():0,0)}sendObjectToBack(i){return!(!i||i===this._objects[0])&&(tr(this._objects,i),this._objects.unshift(i),this._onStackOrderChanged(i),!0)}bringObjectToFront(i){return!(!i||i===this._objects[this._objects.length-1])&&(tr(this._objects,i),this._objects.push(i),this._onStackOrderChanged(i),!0)}sendObjectBackwards(i,r){if(!i)return!1;const s=this._objects.indexOf(i);if(s!==0){const o=this.findNewLowerIndex(i,s,r);return tr(this._objects,i),this._objects.splice(o,0,i),this._onStackOrderChanged(i),!0}return!1}bringObjectForward(i,r){if(!i)return!1;const s=this._objects.indexOf(i);if(s!==this._objects.length-1){const o=this.findNewUpperIndex(i,s,r);return tr(this._objects,i),this._objects.splice(o,0,i),this._onStackOrderChanged(i),!0}return!1}moveObjectTo(i,r){return i!==this._objects[r]&&(tr(this._objects,i),this._objects.splice(r,0,i),this._onStackOrderChanged(i),!0)}findNewLowerIndex(i,r,s){let o;if(s){o=r;for(let a=r-1;a>=0;--a)if(i.isOverlapping(this._objects[a])){o=a;break}}else o=r-1;return o}findNewUpperIndex(i,r,s){let o;if(s){o=r;for(let a=r+1;a<this._objects.length;++a)if(i.isOverlapping(this._objects[a])){o=a;break}}else o=r+1;return o}collectObjects(i){let{left:r,top:s,width:o,height:a}=i,{includeIntersecting:l=!0}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};const c=[],h=new w(r,s),u=h.add(new w(o,a));for(let d=this._objects.length-1;d>=0;d--){const p=this._objects[d];p.selectable&&p.visible&&(l&&p.intersectsWithRect(h,u)||p.isContainedWithinRect(h,u)||l&&p.containsPoint(h)||l&&p.containsPoint(u))&&c.push(p)}return c}}return t}class cc extends xu{_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 rn(n){return Qo().requestAnimationFrame(n)}function wu(n){return Qo().cancelAnimationFrame(n)}let Cu=0;const xi=()=>Cu++,Ae=()=>{const n=vr().createElement("canvas");if(!n||n.getContext===void 0)throw new je("Failed to create `canvas` element");return n},Su=()=>vr().createElement("img"),Ne=n=>{const t=Ae();return t.width=n.width,t.height=n.height,t},hc=(n,t,e)=>n.toDataURL("image/".concat(t),e),Ct=n=>n*ta,Wi=n=>n/ta,Tu=n=>n.every((t,e)=>t===Qt[e]),re=(n,t,e)=>new w(n).transform(t,e),ke=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:r}=new w(n[4],n[5]).transform(e,!0);return e[4]=-i,e[5]=-r,e},Ht=(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]],na=(n,t)=>n.reduceRight((e,i)=>i&&e?Ht(i,e,t):i||e,void 0)||Qt.concat(),uc=n=>{let[t,e]=n;return Math.atan2(e,t)},gn=n=>{const t=uc(n),e=Math.pow(n[0],2)+Math.pow(n[1],2),i=Math.sqrt(e),r=(n[0]*n[3]-n[2]*n[1])/i,s=Math.atan2(n[0]*n[2]+n[1]*n[3],e);return{angle:Wi(t),scaleX:i,scaleY:r,skewX:Wi(s),skewY:0,translateX:n[4]||0,translateY:n[5]||0}},hs=function(n){return[1,0,0,1,n,arguments.length>1&&arguments[1]!==void 0?arguments[1]:0]};function us(){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=Ct(n),r=oi(i),s=ai(i);return[r,s,-s,r,t?t-(r*t-s*e):0,e?e-(s*t+r*e):0]}const oa=function(n){return[n,0,0,arguments.length>1&&arguments[1]!==void 0?arguments[1]:n,0,0]},dc=n=>Math.tan(Ct(n)),pc=n=>[1,0,dc(n),1,0,0],fc=n=>[1,dc(n),0,1,0,0],An=n=>{let{scaleX:t=1,scaleY:e=1,flipX:i=!1,flipY:r=!1,skewX:s=0,skewY:o=0}=n,a=oa(i?-t:t,r?-e:e);return s&&(a=Ht(a,pc(s),!0)),o&&(a=Ht(a,fc(o),!0)),a},Eu=n=>{const{translateX:t=0,translateY:e=0,angle:i=0}=n;let r=hs(t,e);i&&(r=Ht(r,us({angle:i})));const s=An(n);return Tu(s)||(r=Ht(r,s)),r},sn=function(n){let{signal:t,crossOrigin:e=null}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return new Promise(function(i,r){if(t&&t.aborted)return r(new gu("loadImage"));const s=Su();let o;t&&(o=function(l){s.src="",r(l)},t.addEventListener("abort",o,{once:!0}));const a=function(){s.onload=s.onerror=null,o&&(t==null||t.removeEventListener("abort",o)),i(s)};n?(s.onload=a,s.onerror=function(){o&&(t==null||t.removeEventListener("abort",o)),r(new je("Error loading ".concat(s.src)))},e&&(s.crossOrigin=e),s.src=n):a()})},Xr=function(n){let{signal:t,reviver:e=tn}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return new Promise((i,r)=>{const s=[];t&&t.addEventListener("abort",r,{once:!0}),Promise.all(n.map(o=>R.getClass(o.type).fromObject(o,{signal:t}).then(a=>(e(o,a),s.push(a),a)))).then(i).catch(o=>{s.forEach(a=>{a.dispose&&a.dispose()}),r(o)}).finally(()=>{t&&t.removeEventListener("abort",r)})})},Mn=function(n){let{signal:t}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return new Promise((e,i)=>{const r=[];t&&t.addEventListener("abort",i,{once:!0});const s=Object.values(n).map(a=>a&&a.type&&R.has(a.type)?Xr([a],{signal:t}).then(l=>{let[c]=l;return r.push(c),c}):a),o=Object.keys(n);Promise.all(s).then(a=>a.reduce((l,c,h)=>(l[o[h]]=c,l),{})).then(e).catch(a=>{r.forEach(l=>{l.dispose&&l.dispose()}),i(a)}).finally(()=>{t&&t.removeEventListener("abort",i)})})},yr=function(n){return(arguments.length>1&&arguments[1]!==void 0?arguments[1]:[]).reduce((t,e)=>(e in n&&(t[e]=n[e]),t),{})},aa=(n,t)=>Object.keys(n).reduce((e,i)=>(t(n[i],i,n)&&(e[i]=n[i]),e),{}),Va={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"},Qn=(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),Ha=(n,t,e,i)=>{n/=255,t/=255,e/=255;const r=Math.max(n,t,e),s=Math.min(n,t,e);let o,a;const l=(r+s)/2;if(r===s)o=a=0;else{const c=r-s;switch(a=l>.5?c/(2-r-s):c/(r+s),r){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]},$a=function(){let n=arguments.length>0&&arguments[0]!==void 0?arguments[0]:"1";return parseFloat(n)/(n.endsWith("%")?100:1)},Ts=n=>Math.min(Math.round(n),255).toString(16).toUpperCase().padStart(2,"0"),Wa=n=>{let[t,e,i,r=1]=n;const s=Math.round(.3*t+.59*e+.11*i);return[s,s,s,r]};class rt{constructor(t){if(b(this,"isUnrecognised",!1),t)if(t instanceof rt)this.setSource([...t._source]);else if(Array.isArray(t)){const[e,i,r,s=1]=t;this.setSource([e,i,r,s])}else this.setSource(this._tryParsingColor(t));else this.setSource([0,0,0,1])}_tryParsingColor(t){return(t=t.toLowerCase())in Va&&(t=Va[t]),t==="transparent"?[255,255,255,0]:rt.sourceFromHex(t)||rt.sourceFromRgb(t)||rt.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]=Ha(...this.getSource());return"hsl(".concat(t,",").concat(e,"%,").concat(i,"%)")}toHsla(){const[t,e,i,r]=Ha(...this.getSource());return"hsla(".concat(t,",").concat(e,"%,").concat(i,"%,").concat(r,")")}toHex(){return this.toHexa().slice(0,6)}toHexa(){const[t,e,i,r]=this.getSource();return"".concat(Ts(t)).concat(Ts(e)).concat(Ts(i)).concat(Ts(Math.round(255*r)))}getAlpha(){return this.getSource()[3]}setAlpha(t){return this._source[3]=t,this}toGrayscale(){return this.setSource(Wa(this.getSource())),this}toBlackWhite(t){const[e,,,i]=Wa(this.getSource()),r=e<(t||127)?0:255;return this.setSource([r,r,r,i]),this}overlayWith(t){t instanceof rt||(t=new rt(t));const e=this.getSource(),i=t.getSource(),[r,s,o]=e.map((a,l)=>Math.round(.5*a+.5*i[l]));return this.setSource([r,s,o,e[3]]),this}static fromRgb(t){return rt.fromRgba(t)}static fromRgba(t){return new rt(rt.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,r,s]=e.slice(1,4).map(o=>{const a=parseFloat(o);return o.endsWith("%")?Math.round(2.55*a):a});return[i,r,s,$a(e[4])]}}static fromHsl(t){return rt.fromHsla(t)}static fromHsla(t){return new rt(rt.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=(rt.parseAngletoDegrees(e[1])%360+360)%360/360,r=parseFloat(e[2])/100,s=parseFloat(e[3])/100;let o,a,l;if(r===0)o=a=l=s;else{const c=s<=.5?s*(r+1):s+r-s*r,h=2*s-c;o=Qn(h,c,i+1/3),a=Qn(h,c,i),l=Qn(h,c,i-1/3)}return[Math.round(255*o),Math.round(255*a),Math.round(255*l),$a(e[4])]}static fromHex(t){return new rt(rt.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[r,s,o,a=255]=i.map(l=>parseInt(l,16));return[r,s,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 ft=(n,t)=>parseFloat(Number(n).toFixed(t)),cr=function(n){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:ea;const e=/\D{0,2}$/.exec(n),i=parseFloat(n),r=Q.DPI;switch(e==null?void 0:e[0]){case"mm":return i*r/25.4;case"cm":return i*r/2.54;case"in":return i*r;case"pt":return i*r/72;case"pc":return i*r/72*12;case"em":return i*t;default:return i}},Ou=n=>{const[t,e]=n.trim().split(" "),[i,r]=(s=t)&&s!==oe?[s.slice(1,4),s.slice(5,8)]:s===oe?[s,s]:["Mid","Mid"];var s;return{meetOrSlice:e||"meet",alignX:i,alignY:r}},mn=n=>"matrix("+n.map(t=>ft(t,Q.NUM_FRACTION_DIGITS)).join(" ")+")",Kr=function(n,t){let e,i,r=!(arguments.length>2&&arguments[2]!==void 0)||arguments[2];if(t)if(t.toLive)e="url(#SVGID_".concat(t.id,")");else{const s=new rt(t),o=s.getAlpha();e=s.toRgb(),o!==1&&(i=o.toString())}else e="none";return r?"".concat(n,": ").concat(e,"; ").concat(i?"".concat(n,"-opacity: ").concat(i,"; "):""):"".concat(n,'="').concat(e,'" ').concat(i?"".concat(n,'-opacity="').concat(i,'" '):"")},_e=n=>!!n&&n.toLive!==void 0,Ga=n=>!!n&&typeof n.toObject=="function",Ua=n=>!!n&&n.offsetX!==void 0&&"source"in n,ji=n=>!!n&&"multiSelectionStacking"in n;function gc(n){const t=n&&Oe(n);let e=0,i=0;if(!n||!t)return{left:e,top:i};let r=n;const s=t.documentElement,o=t.body||{scrollLeft:0,scrollTop:0};for(;r&&(r.parentNode||r.host)&&(r=r.parentNode||r.host,r===t?(e=o.scrollLeft||s.scrollLeft||0,i=o.scrollTop||s.scrollTop||0):(e+=r.scrollLeft||0,i+=r.scrollTop||0),r.nodeType!==1||r.style.position!=="fixed"););return{left:e,top:i}}const Oe=n=>n.ownerDocument||null,mc=n=>{var t;return((t=n.ownerDocument)===null||t===void 0?void 0:t.defaultView)||null},vc=function(n,t,e){let{width:i,height:r}=e,s=arguments.length>3&&arguments[3]!==void 0?arguments[3]:1;n.width=i,n.height=r,s>1&&(n.setAttribute("width",(i*s).toString()),n.setAttribute("height",(r*s).toString()),t.scale(s,s))},Co=(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 Ya(n){return n.onselectstart!==void 0&&(n.onselectstart=()=>!1),n.style.userSelect=oe,n}class bc{constructor(t){b(this,"_originalCanvasStyle",void 0),b(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&&vr().getElementById(t)||Ae();var i;if(e.hasAttribute("data-fabric"))throw new je("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:r}=this.lower;r.classList.remove("lower-canvas"),r.removeAttribute("data-fabric"),r.setAttribute("width","".concat(e)),r.setAttribute("height","".concat(i)),r.style.cssText=this._originalCanvasStyle||"",this._originalCanvasStyle=void 0}setDimensions(t,e){const{el:i,ctx:r}=this.lower;vc(i,r,t,e)}setCSSDimensions(t){Co(this.lower.el,t)}calcOffset(){return function(t){var e;const i=t&&Oe(t),r={left:0,top:0};if(!i)return r;const s=((e=mc(t))===null||e===void 0?void 0:e.getComputedStyle(t,null))||{};r.left+=parseInt(s.borderLeftWidth,10)||0,r.top+=parseInt(s.borderTopWidth,10)||0,r.left+=parseInt(s.paddingLeft,10)||0,r.top+=parseInt(s.paddingTop,10)||0;let o={left:0,top:0};const a=i.documentElement;t.getBoundingClientRect!==void 0&&(o=t.getBoundingClientRect());const l=gc(t);return{left:o.left+l.left-(a.clientLeft||0)+r.left,top:o.top+l.top-(a.clientTop||0)+r.top}}(this.lower.el)}dispose(){Be().dispose(this.lower.el),delete this.lower}}const ku={backgroundVpt:!0,backgroundColor:"",overlayVpt:!0,overlayColor:"",includeDefaultValues:!0,svgViewportTransformation:!0,renderOnAddRemove:!0,skipOffscreen:!0,enableRetinaScaling:!0,imageSmoothingEnabled:!0,controlsAboveOverlay:!1,allowTouchScrolling:!1,viewportTransform:[...Qt]};class ds extends lc(cc){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 ds.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 bc(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),r=1;r<e;r++)i[r-1]=arguments[r];const s=super.insertAt(t,...i);return i.length>0&&this.renderOnAddRemove&&this.requestRenderAll(),s}remove(){const t=super.remove(...arguments);return t.length>0&&this.renderOnAddRemove&&this.requestRenderAll(),t}_onObjectAdded(t){t.canvas&&t.canvas!==this&&(yi("warn",`Canvas is trying to add an object that belongs to a different canvas.
91
- 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?sc():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 r=_({width:this.width,height:this.height},t);this.elements.setDimensions(r,this.getRetinaScaling()),this.hasLostContext=!0,this.width=r.width,this.height=r.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,r=[...this.viewportTransform],s=re(t,ke(r));r[0]=e,r[3]=e;const o=re(s,r);r[4]+=i.x-o.x,r[5]+=i.y-o.y,this.setViewportTransform(r)}setZoom(t){this.zoomToPoint(new w(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 w(-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=rn(()=>this.renderAndReset()))}calcViewportBoundaries(){const t=this.width,e=this.height,i=ke(this.viewportTransform),r=re({x:0,y:0},i),s=re({x:t,y:e},i),o=r.min(s),a=r.max(s);return this.vptCoords={tl:o,tr:new w(a.x,o.y),bl:new w(o.x,a.y),br:a}}cancelRequestedRender(){this.nextRenderHandle&&(wu(this.nextRenderHandle),this.nextRenderHandle=0)}drawControls(t){}renderCanvas(t,e){if(this.destroyed)return;const i=this.viewportTransform,r=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),r&&(r._set("canvas",this),r.shouldCache(),r._transformDone=!0,r.renderCache({forClipping:!0}),this.drawClipPathOnCanvas(t,r)),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,r=e.length;i<r;++i)e[i]&&e[i].render(t)}_renderBackgroundOrOverlay(t,e){const i=this["".concat(e,"Color")],r=this["".concat(e,"Image")],s=this.viewportTransform,o=this["".concat(e,"Vpt")];if(!i&&!r)return;const a=_e(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(...s),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(r){t.save();const{skipOffscreen:l}=this;this.skipOffscreen=o,o&&t.transform(...s),r.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 w(this.width/2,this.height/2)}centerObjectH(t){return this._centerObject(t,new w(this.getCenterPoint().x,t.getCenterPoint().y))}centerObjectV(t){return this._centerObject(t,new w(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 w(this.getVpCenter().x,t.getCenterPoint().y))}viewportCenterObjectV(t){return this._centerObject(t,new w(t.getCenterPoint().x,this.getVpCenter().y))}getVpCenter(){return re(this.getCenterPoint(),ke(this.viewportTransform))}_centerObject(t,e){t.setXY(e,K,K),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,r=i&&!i.excludeFromExport?this._toObject(i,t,e):null;return _(_(_({version:xo},yr(this,e)),{},{objects:this._objects.filter(s=>!s.excludeFromExport).map(s=>this._toObject(s,t,e))},this.__serializeBgOverlay(t,e)),r?{clipPath:r}:null)}_toObject(t,e,i){let r;this.includeDefaultValues||(r=t.includeDefaultValues,t.includeDefaultValues=!1);const s=t[e](i);return this.includeDefaultValues||(t.includeDefaultValues=!!r),s}__serializeBgOverlay(t,e){const i={},r=this.backgroundImage,s=this.overlayImage,o=this.backgroundColor,a=this.overlayColor;return _e(o)?o.excludeFromExport||(i.background=o.toObject(e)):o&&(i.background=o),_e(a)?a.excludeFromExport||(i.overlay=a.toObject(e)):a&&(i.overlay=a),r&&!r.excludeFromExport&&(i.backgroundImage=this._toObject(r,t,e)),s&&!s.excludeFromExport&&(i.overlayImage=this._toObject(s,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,`)" >
127
+ `];Mn.properties={giftLabel:{type:String},premiumLabel:{type:String},premiumDescription:{type:String},noteLabel:{type:String},giftSelected:{type:Boolean},premiumSelected:{type:Boolean},freeMessageSelected:{type:Boolean}};Mn=Td([bt("pairbo-message-selector")],Mn);function b(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 Sl(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 _(n){for(var t=1;t<arguments.length;t++){var e=arguments[t]!=null?arguments[t]:{};t%2?Sl(Object(e),!0).forEach(function(i){b(n,i,e[i])}):Object.getOwnPropertyDescriptors?Object.defineProperties(n,Object.getOwnPropertyDescriptors(e)):Sl(Object(e)).forEach(function(i){Object.defineProperty(n,i,Object.getOwnPropertyDescriptor(e,i))})}return n}function ut(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 Ri(n,t){return t||(t=n.slice(0)),Object.freeze(Object.defineProperties(n,{raw:{value:Object.freeze(t)}}))}let Tl=class{constructor(){b(this,"browserShadowBlurConstant",1),b(this,"DPI",96),b(this,"devicePixelRatio",typeof window<"u"?window.devicePixelRatio:1),b(this,"perfLimitSizeTotal",2097152),b(this,"maxCacheSideLimit",4096),b(this,"minCacheSideLimit",256),b(this,"disableStyleCopyPaste",!1),b(this,"enableGLFiltering",!0),b(this,"textureSize",4096),b(this,"forceGLPutImageData",!1),b(this,"cachesBoundsOfCurve",!1),b(this,"fontPaths",{}),b(this,"NUM_FRACTION_DIGITS",4)}};const tt=new class extends Tl{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=_(_({},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 Tl,e=(n==null?void 0:n.reduce((i,s)=>(i[s]=t[s],i),{}))||t;this.configure(e)}},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 console[n]("fabric",...e)};let ze=class extends Error{constructor(t,e){super("fabric: ".concat(t),e)}};class Ed extends ze{constructor(t){super("".concat(t," 'options.signal' is in 'aborted' state"))}}let Od=class{},kd=class extends Od{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(),Ai("log","WebGL: max texture size ".concat(this.maxTextureSize)))}isSupported(t){return!!this.maxTextureSize&&this.maxTextureSize>=t}};const Ad={};let El;const Ve=()=>El||(El={document,window,isTouchSupported:"ontouchstart"in window||"ontouchstart"in document||window&&window.navigator&&window.navigator.maxTouchPoints>0,WebGLProbe:new kd,dispose(){},copyPasteData:Ad}),Ds=()=>Ve().document,Aa=()=>Ve().window,th=()=>{var n;return Math.max((n=tt.devicePixelRatio)!==null&&n!==void 0?n:Aa().devicePixelRatio,1)},ir=new class{constructor(){b(this,"charWidthsCache",{}),b(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}=tt,e=Math.sqrt(t*n);return[Math.floor(e),Math.floor(t/e)]}},Zo="6.5.4";function xn(){}const kr=Math.PI/2,In=2*Math.PI,Pa=Math.PI/180,ie=Object.freeze([1,0,0,1,0,0]),Da=16,_i=.4477152502,K="center",it="left",le="top",Jo="bottom",Ct="right",ce="none",Ma=/\r?\n/,eh="moving",Jn="scaling",ih="rotating",Ia="rotate",sh="skewing",ur="resizing",Pd="modifyPoly",Dd="modifyPath",Ln="changed",Qn="scale",ue="scaleX",Te="scaleY",Ms="skewX",Is="skewY",Ft="fill",he="stroke",Fn="modified",hs="json",ko="svg",R=new class{constructor(){this[hs]=new Map,this[ko]=new Map}has(n){return this[hs].has(n)}getClass(n){const t=this[hs].get(n);if(!t)throw new ze("No class registered for ".concat(n));return t}setClass(n,t){t?this[hs].set(t,n):(this[hs].set(n.type,n),this[hs].set(n.type.toLowerCase(),n))}getSVGClass(n){return this[ko].get(n)}setSVGClass(n,t){this[ko].set(t??n.type.toLowerCase(),n)}},jn=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 Md{constructor(){b(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 ps=(n,t)=>{const e=n.indexOf(t);return e!==-1&&n.splice(e,1),n},ui=n=>{if(n===0)return 1;switch(Math.abs(n)/kr){case 1:case 3:return 0;case 2:return-1}return Math.cos(n)},di=n=>{if(n===0)return 0;const t=n/kr,e=Math.sign(n);switch(t){case 1:return e;case 2:return 0;case 3:return-e}return Math.sin(n)};class w{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 w(this.x+t.x,this.y+t.y)}addEquals(t){return this.x+=t.x,this.y+=t.y,this}scalarAdd(t){return new w(this.x+t,this.y+t)}scalarAddEquals(t){return this.x+=t,this.y+=t,this}subtract(t){return new w(this.x-t.x,this.y-t.y)}subtractEquals(t){return this.x-=t.x,this.y-=t.y,this}scalarSubtract(t){return new w(this.x-t,this.y-t)}scalarSubtractEquals(t){return this.x-=t,this.y-=t,this}multiply(t){return new w(this.x*t.x,this.y*t.y)}scalarMultiply(t){return new w(this.x*t,this.y*t)}scalarMultiplyEquals(t){return this.x*=t,this.y*=t,this}divide(t){return new w(this.x/t.x,this.y/t.y)}scalarDivide(t){return new w(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 w(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 w(Math.min(this.x,t.x),Math.min(this.y,t.y))}max(t){return new w(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 w(this.x,this.y)}rotate(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:La;const i=di(t),s=ui(t),r=this.subtract(e);return new w(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 w(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 La=new w(0,0),wn=n=>!!n&&Array.isArray(n._objects);function rh(n){class t extends n{constructor(){super(...arguments),b(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])&&(ps(this._objects,i),this._objects.unshift(i),this._onStackOrderChanged(i),!0)}bringObjectToFront(i){return!(!i||i===this._objects[this._objects.length-1])&&(ps(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 ps(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 ps(this._objects,i),this._objects.splice(o,0,i),this._onStackOrderChanged(i),!0}return!1}moveObjectTo(i,s){return i!==this._objects[s]&&(ps(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 w(s,r),u=h.add(new w(o,a));for(let d=this._objects.length-1;d>=0;d--){const p=this._objects[d];p.selectable&&p.visible&&(l&&p.intersectsWithRect(h,u)||p.isContainedWithinRect(h,u)||l&&p.containsPoint(h)||l&&p.containsPoint(u))&&c.push(p)}return c}}return t}class nh extends Md{_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 Cn(n){return Aa().requestAnimationFrame(n)}function Id(n){return Aa().cancelAnimationFrame(n)}let Ld=0;const Pi=()=>Ld++,Fe=()=>{const n=Ds().createElement("canvas");if(!n||n.getContext===void 0)throw new ze("Failed to create `canvas` element");return n},Fd=()=>Ds().createElement("img"),Ue=n=>{const t=Fe();return t.width=n.width,t.height=n.height,t},oh=(n,t,e)=>n.toDataURL("image/".concat(t),e),Et=n=>n*Pa,es=n=>n/Pa,jd=n=>n.every((t,e)=>t===ie[e]),oe=(n,t,e)=>new w(n).transform(t,e),Me=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 w(n[4],n[5]).transform(e,!0);return e[4]=-i,e[5]=-s,e},Ut=(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]],Fa=(n,t)=>n.reduceRight((e,i)=>i&&e?Ut(i,e,t):i||e,void 0)||ie.concat(),ah=n=>{let[t,e]=n;return Math.atan2(e,t)},Rn=n=>{const t=ah(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:es(t),scaleX:i,scaleY:s,skewX:es(r),skewY:0,translateX:n[4]||0,translateY:n[5]||0}},Ar=function(n){return[1,0,0,1,n,arguments.length>1&&arguments[1]!==void 0?arguments[1]:0]};function Pr(){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=Et(n),s=ui(i),r=di(i);return[s,r,-r,s,t?t-(s*t-r*e):0,e?e-(r*t+s*e):0]}const ja=function(n){return[n,0,0,arguments.length>1&&arguments[1]!==void 0?arguments[1]:n,0,0]},lh=n=>Math.tan(Et(n)),ch=n=>[1,0,lh(n),1,0,0],hh=n=>[1,lh(n),0,1,0,0],to=n=>{let{scaleX:t=1,scaleY:e=1,flipX:i=!1,flipY:s=!1,skewX:r=0,skewY:o=0}=n,a=ja(i?-t:t,s?-e:e);return r&&(a=Ut(a,ch(r),!0)),o&&(a=Ut(a,hh(o),!0)),a},Rd=n=>{const{translateX:t=0,translateY:e=0,angle:i=0}=n;let s=Ar(t,e);i&&(s=Ut(s,Pr({angle:i})));const r=to(n);return jd(r)||(s=Ut(s,r)),s},Sn=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 Ed("loadImage"));const r=Fd();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 ze("Error loading ".concat(r.src)))},e&&(r.crossOrigin=e),r.src=n):a()})},dr=function(n){let{signal:t,reviver:e=xn}=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=>R.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)})})},eo=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&&R.has(a.type)?dr([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)})})},Ls=function(n){return(arguments.length>1&&arguments[1]!==void 0?arguments[1]:[]).reduce((t,e)=>(e in n&&(t[e]=n[e]),t),{})},Ra=(n,t)=>Object.keys(n).reduce((e,i)=>(t(n[i],i,n)&&(e[i]=n[i]),e),{}),Ol={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"},Ao=(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),kl=(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]},Al=function(){let n=arguments.length>0&&arguments[0]!==void 0?arguments[0]:"1";return parseFloat(n)/(n.endsWith("%")?100:1)},Ur=n=>Math.min(Math.round(n),255).toString(16).toUpperCase().padStart(2,"0"),Pl=n=>{let[t,e,i,s=1]=n;const r=Math.round(.3*t+.59*e+.11*i);return[r,r,r,s]};class st{constructor(t){if(b(this,"isUnrecognised",!1),t)if(t instanceof st)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 Ol&&(t=Ol[t]),t==="transparent"?[255,255,255,0]:st.sourceFromHex(t)||st.sourceFromRgb(t)||st.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]=kl(...this.getSource());return"hsl(".concat(t,",").concat(e,"%,").concat(i,"%)")}toHsla(){const[t,e,i,s]=kl(...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(Ur(t)).concat(Ur(e)).concat(Ur(i)).concat(Ur(Math.round(255*s)))}getAlpha(){return this.getSource()[3]}setAlpha(t){return this._source[3]=t,this}toGrayscale(){return this.setSource(Pl(this.getSource())),this}toBlackWhite(t){const[e,,,i]=Pl(this.getSource()),s=e<(t||127)?0:255;return this.setSource([s,s,s,i]),this}overlayWith(t){t instanceof st||(t=new st(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 st.fromRgba(t)}static fromRgba(t){return new st(st.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,Al(e[4])]}}static fromHsl(t){return st.fromHsla(t)}static fromHsla(t){return new st(st.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=(st.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=Ao(h,c,i+1/3),a=Ao(h,c,i),l=Ao(h,c,i-1/3)}return[Math.round(255*o),Math.round(255*a),Math.round(255*l),Al(e[4])]}static fromHex(t){return new st(st.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")?es(i):e.includes("turn")?360*i:i}}const gt=(n,t)=>parseFloat(Number(n).toFixed(t)),ws=function(n){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:Da;const e=/\D{0,2}$/.exec(n),i=parseFloat(n),s=tt.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}},$d=n=>{const[t,e]=n.trim().split(" "),[i,s]=(r=t)&&r!==ce?[r.slice(1,4),r.slice(5,8)]:r===ce?[r,r]:["Mid","Mid"];var r;return{meetOrSlice:e||"meet",alignX:i,alignY:s}},$n=n=>"matrix("+n.map(t=>gt(t,tt.NUM_FRACTION_DIGITS)).join(" ")+")",pr=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 st(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,'" '):"")},we=n=>!!n&&n.toLive!==void 0,Dl=n=>!!n&&typeof n.toObject=="function",Ml=n=>!!n&&n.offsetX!==void 0&&"source"in n,Wi=n=>!!n&&"multiSelectionStacking"in n;function uh(n){const t=n&&De(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 De=n=>n.ownerDocument||null,dh=n=>{var t;return((t=n.ownerDocument)===null||t===void 0?void 0:t.defaultView)||null},ph=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))},Qo=(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 Il(n){return n.onselectstart!==void 0&&(n.onselectstart=()=>!1),n.style.userSelect=ce,n}class fh{constructor(t){b(this,"_originalCanvasStyle",void 0),b(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&&Ds().getElementById(t)||Fe();var i;if(e.hasAttribute("data-fabric"))throw new ze("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;ph(i,s,t,e)}setCSSDimensions(t){Qo(this.lower.el,t)}calcOffset(){return function(t){var e;const i=t&&De(t),s={left:0,top:0};if(!i)return s;const r=((e=dh(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=uh(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(){Ve().dispose(this.lower.el),delete this.lower}}const Bd={backgroundVpt:!0,backgroundColor:"",overlayVpt:!0,overlayColor:"",includeDefaultValues:!0,svgViewportTransformation:!0,renderOnAddRemove:!0,skipOffscreen:!0,enableRetinaScaling:!0,imageSmoothingEnabled:!0,controlsAboveOverlay:!1,allowTouchScrolling:!1,viewportTransform:[...ie]};class Dr extends rh(nh){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 Dr.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 fh(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&&(Ai("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?th():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=_({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=oe(t,Me(s));s[0]=e,s[3]=e;const o=oe(r,s);s[4]+=i.x-o.x,s[5]+=i.y-o.y,this.setViewportTransform(s)}setZoom(t){this.zoomToPoint(new w(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 w(-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=Cn(()=>this.renderAndReset()))}calcViewportBoundaries(){const t=this.width,e=this.height,i=Me(this.viewportTransform),s=oe({x:0,y:0},i),r=oe({x:t,y:e},i),o=s.min(r),a=s.max(r);return this.vptCoords={tl:o,tr:new w(a.x,o.y),bl:new w(o.x,a.y),br:a}}cancelRequestedRender(){this.nextRenderHandle&&(Id(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=we(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 w(this.width/2,this.height/2)}centerObjectH(t){return this._centerObject(t,new w(this.getCenterPoint().x,t.getCenterPoint().y))}centerObjectV(t){return this._centerObject(t,new w(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 w(this.getVpCenter().x,t.getCenterPoint().y))}viewportCenterObjectV(t){return this._centerObject(t,new w(t.getCenterPoint().x,this.getVpCenter().y))}getVpCenter(){return oe(this.getCenterPoint(),Me(this.viewportTransform))}_centerObject(t,e){t.setXY(e,K,K),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 _(_(_({version:Zo},Ls(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 we(o)?o.excludeFromExport||(i.background=o.toObject(e)):o&&(i.background=o),we(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,`)" >
92
130
  `)),this._setSVGBgOverlayColor(i,"background"),this._setSVGBgOverlayImage(i,"backgroundImage",e),this._setSVGObjects(i,e),this.clipPath&&i.push(`</g>
93
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" ?>
94
132
  `,'<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" ',`"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
95
- `)}_setSVGHeader(t,e){const i=e.width||"".concat(this.width),r=e.height||"".concat(this.height),s=Q.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(ft(-l[4]/l[0],s)," ").concat(ft(-l[5]/l[3],s)," ").concat(ft(this.width/l[0],s)," ").concat(ft(this.height/l[3],s),'" ')}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="',r,'" ',a,`xml:space="preserve">
96
- `,"<desc>Created with Fabric.js ",xo,`</desc>
133
+ `)}_setSVGHeader(t,e){const i=e.width||"".concat(this.width),s=e.height||"".concat(this.height),r=tt.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(gt(-l[4]/l[0],r)," ").concat(gt(-l[5]/l[3],r)," ").concat(gt(this.width/l[0],r)," ").concat(gt(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 ",Zo,`</desc>
97
135
  `,`<defs>
98
136
  `,this.createSVGFontFacesMarkup(),this.createSVGRefElementsMarkup(),this.createSVGClipPathMarkup(e),`</defs>
99
- `)}createSVGClipPathMarkup(t){const e=this.clipPath;return e?(e.clipPathId="CLIPPATH_".concat(xi()),'<clipPath id="'.concat(e.clipPathId,`" >
137
+ `)}createSVGClipPathMarkup(t){const e=this.clipPath;return e?(e.clipPathId="CLIPPATH_".concat(Pi()),'<clipPath id="'.concat(e.clipPathId,`" >
100
138
  `).concat(e.toClipPathSVG(t.reviver),`</clipPath>
101
- `)):""}createSVGRefElementsMarkup(){return["background","overlay"].map(t=>{const e=this["".concat(t,"Color")];if(_e(e)){const i=this["".concat(t,"Vpt")],r=this.viewportTransform,s={isType:()=>!1,width:this.width/(i?r[0]:1),height:this.height/(i?r[3]:1)};return e.toSVG(s,{additionalTransform:i?mn(r):""})}}).join("")}createSVGFontFacesMarkup(){const t=[],e={},i=Q.fontPaths;this._objects.forEach(function s(o){t.push(o),en(o)&&o._objects.forEach(s)}),t.forEach(s=>{if(!(o=s)||typeof o._renderText!="function")return;var o;const{styles:a,fontFamily:l}=s;!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 r=Object.keys(e).map(s=>` @font-face {
102
- font-family: '`.concat(s,`';
103
- src: url('`).concat(i[s],`');
139
+ `)):""}createSVGRefElementsMarkup(){return["background","overlay"].map(t=>{const e=this["".concat(t,"Color")];if(we(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?$n(s):""})}}).join("")}createSVGFontFacesMarkup(){const t=[],e={},i=tt.fontPaths;this._objects.forEach(function r(o){t.push(o),wn(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],`');
104
142
  }
105
- `)).join("");return r?` <style type="text/css"><![CDATA[
106
- `.concat(r,`]]></style>
107
- `):""}_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 r=this[e];r&&!r.excludeFromExport&&r.toSVG&&t.push(r.toSVG(i))}_setSVGBgOverlayColor(t,e){const i=this["".concat(e,"Color")];if(i)if(_e(i)){const r=i.repeat||"",s=this.width,o=this.height,a=this["".concat(e,"Vpt")]?mn(ke(this.viewportTransform)):"";t.push('<rect transform="'.concat(a," translate(").concat(s/2,",").concat(o/2,')" x="').concat(i.offsetX-s/2,'" y="').concat(i.offsetY-o/2,'" width="').concat(r!=="repeat-y"&&r!=="no-repeat"||!Ua(i)?s:i.source.width,'" height="').concat(r!=="repeat-x"&&r!=="no-repeat"||!Ua(i)?o:i.source.height,'" fill="url(#SVGID_').concat(i.id,`)"></rect>
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(we(i)){const s=i.repeat||"",r=this.width,o=this.height,a=this["".concat(e,"Vpt")]?$n(Me(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"||!Ml(i)?r:i.source.width,'" height="').concat(s!=="repeat-x"&&s!=="no-repeat"||!Ml(i)?o:i.source.height,'" fill="url(#SVGID_').concat(i.id,`)"></rect>
108
146
  `))}else t.push('<rect x="0" y="0" width="100%" height="100%" ','fill="',i,'"',`></rect>
109
- `)}loadFromJSON(t,e){let{signal:i}=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};if(!t)return Promise.reject(new je("`json` is undefined"));const r=typeof t=="string"?JSON.parse(t):t,{objects:s=[],backgroundImage:o,background:a,overlayImage:l,overlay:c,clipPath:h}=r,u=this.renderOnAddRemove;return this.renderOnAddRemove=!1,Promise.all([Xr(s,{reviver:e,signal:i}),Mn({backgroundImage:o,backgroundColor:a,overlayImage:l,overlayColor:c,clipPath:h},{signal:i})]).then(d=>{let[p,f]=d;return this.clear(),this.add(...p),this.set(r),this.set(f),this.renderOnAddRemove=u,this})}clone(t){const e=this.toObject(t);return this.cloneWithoutData().loadFromJSON(e)}cloneWithoutData(){const t=Ne(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:r=1,enableRetinaScaling:s=!1}=t,o=r*(s?this.getRetinaScaling():1);return hc(this.toCanvasElement(o,t),e,i)}toCanvasElement(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:1,{width:e,height:i,left:r,top:s,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,p=c*t,f=this.viewportTransform,g=[p,0,0,p,(f[4]-(r||0))*t,(f[5]-(s||0))*t],m=this.enableRetinaScaling,v=Ne({width:a,height:l}),y=o?this._objects.filter(x=>o(x)):this._objects;return this.enableRetinaScaling=!1,this.viewportTransform=g,this.width=a,this.height=l,this.skipControlsDrawing=!0,this.calcViewportBoundaries(),this.renderCanvas(v.getContext("2d"),y),this.viewportTransform=f,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}),fn.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," }>")}}b(ds,"ownDefaults",ku);const Du=["touchstart","touchmove","touchend"],Pu=n=>{const t=gc(n.target),e=function(i){const r=i.changedTouches;return r&&r[0]?r[0]:i}(n);return new w(e.clientX+t.left,e.clientY+t.top)},So=n=>Du.includes(n.type)||n.pointerType==="touch",To=n=>{n.preventDefault(),n.stopPropagation()},ii=n=>{let t=0,e=0,i=0,r=0;for(let s=0,o=n.length;s<o;s++){const{x:a,y:l}=n[s];(a>i||!s)&&(i=a),(a<t||!s)&&(t=a),(l>r||!s)&&(r=l),(l<e||!s)&&(e=l)}return{left:t,top:e,width:i-t,height:r-e}},Au=["translateX","translateY","scaleX","scaleY"],Mu=(n,t)=>vn(n,Ht(t,n.calcOwnMatrix())),vn=(n,t)=>{const e=gn(t),{translateX:i,translateY:r,scaleX:s,scaleY:o}=e,a=ht(e,Au),l=new w(i,r);n.flipX=!1,n.flipY=!1,Object.assign(n,a),n.set({scaleX:s,scaleY:o}),n.setPositionByOrigin(l,K,K)},Iu=n=>{n.scaleX=1,n.scaleY=1,n.skewX=0,n.skewY=0,n.flipX=!1,n.flipY=!1,n.rotate(0)},_c=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}),la=(n,t,e)=>{const i=n/2,r=t/2,s=[new w(-i,-r),new w(i,-r),new w(-i,r),new w(i,r)].map(a=>a.transform(e)),o=ii(s);return new w(o.width,o.height)},In=function(){let n=arguments.length>0&&arguments[0]!==void 0?arguments[0]:Qt;return Ht(ke(arguments.length>1&&arguments[1]!==void 0?arguments[1]:Qt),n)},hr=function(n){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:Qt,e=arguments.length>2&&arguments[2]!==void 0?arguments[2]:Qt;return n.transform(In(t,e))},Lu=function(n){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:Qt,e=arguments.length>2&&arguments[2]!==void 0?arguments[2]:Qt;return n.transform(In(t,e),!0)},Fu=(n,t,e)=>{const i=In(t,e);return vn(n,Ht(i,n.calcOwnMatrix())),i},yc=(n,t)=>{var e;const{transform:{target:i}}=t;(e=i.canvas)===null||e===void 0||e.fire("object:".concat(n),_(_({},t),{},{target:i})),i.fire(n,t)},ju={left:-.5,top:-.5,center:0,bottom:.5,right:.5},Dt=n=>typeof n=="string"?ju[n]:n-.5,bn="not-allowed";function xc(n){return Dt(n.originX)===Dt(K)&&Dt(n.originY)===Dt(K)}function Xa(n){return .5-Dt(n)}const Pe=(n,t)=>n[t],wc=(n,t,e,i)=>({e:n,transform:t,pointer:new w(e,i)});function Cc(n,t){const e=n.getTotalAngle()+Wi(Math.atan2(t.y,t.x))+360;return Math.round(e%360/45)}function ca(n,t,e,i,r){var s;let{target:o,corner:a}=n;const l=o.controls[a],c=((s=o.canvas)===null||s===void 0?void 0:s.getZoom())||1,h=o.padding/c,u=function(d,p,f,g){const m=d.getRelativeCenterPoint(),v=f!==void 0&&g!==void 0?d.translateToGivenOrigin(m,K,K,f,g):new w(d.left,d.top);return(d.angle?p.rotate(-Ct(d.angle),m):p).subtract(v)}(o,new w(i,r),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 Ru=(n,t,e,i)=>{const{target:r,offsetX:s,offsetY:o}=t,a=e-s,l=i-o,c=!Pe(r,"lockMovementX")&&r.left!==a,h=!Pe(r,"lockMovementY")&&r.top!==l;return c&&r.set(it,a),h&&r.set(ne,l),(c||h)&&yc(nc,wc(n,t,e,i)),c||h};class Sc{getSvgStyles(t){const e=this.fillRule?this.fillRule:"nonzero",i=this.strokeWidth?this.strokeWidth:"0",r=this.strokeDashArray?this.strokeDashArray.join(" "):oe,s=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=Kr(It,this.fill);return[Kr(ae,this.stroke),"stroke-width: ",i,"; ","stroke-dasharray: ",r,"; ","stroke-linecap: ",o,"; ","stroke-dashoffset: ",s,"; ","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(),r='transform="'.concat(mn(i));return"".concat(r).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 r=[this.getSvgTransform(!0,i),this.getSvgCommons()].join(""),s=t.indexOf("COMMON_PARTS");return t[s]=r,e?e(t.join("")):t.join("")}_createBaseSVGMarkup(t){let{noStyle:e,reviver:i,withShadow:r,additionalTransform:s}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};const o=e?"":'style="'.concat(this.getSvgStyles(),'" '),a=r?'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,p=this.shadow,f=[],g=t.indexOf("COMMON_PARTS");let m;l&&(l.clipPathId="CLIPPATH_".concat(xi()),m='<clipPath id="'.concat(l.clipPathId,`" >
147
+ `)}loadFromJSON(t,e){let{signal:i}=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};if(!t)return Promise.reject(new ze("`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([dr(r,{reviver:e,signal:i}),eo({backgroundImage:o,backgroundColor:a,overlayImage:l,overlayColor:c,clipPath:h},{signal:i})]).then(d=>{let[p,f]=d;return this.clear(),this.add(...p),this.set(s),this.set(f),this.renderOnAddRemove=u,this})}clone(t){const e=this.toObject(t);return this.cloneWithoutData().loadFromJSON(e)}cloneWithoutData(){const t=Ue(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 oh(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,p=c*t,f=this.viewportTransform,g=[p,0,0,p,(f[4]-(s||0))*t,(f[5]-(r||0))*t],m=this.enableRetinaScaling,v=Ue({width:a,height:l}),y=o?this._objects.filter(x=>o(x)):this._objects;return this.enableRetinaScaling=!1,this.viewportTransform=g,this.width=a,this.height=l,this.skipControlsDrawing=!0,this.calcViewportBoundaries(),this.renderCanvas(v.getContext("2d"),y),this.viewportTransform=f,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}),jn.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," }>")}}b(Dr,"ownDefaults",Bd);const Nd=["touchstart","touchmove","touchend"],zd=n=>{const t=uh(n.target),e=function(i){const s=i.changedTouches;return s&&s[0]?s[0]:i}(n);return new w(e.clientX+t.left,e.clientY+t.top)},ta=n=>Nd.includes(n.type)||n.pointerType==="touch",ea=n=>{n.preventDefault(),n.stopPropagation()},li=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}},Hd=["translateX","translateY","scaleX","scaleY"],Vd=(n,t)=>Bn(n,Ut(t,n.calcOwnMatrix())),Bn=(n,t)=>{const e=Rn(t),{translateX:i,translateY:s,scaleX:r,scaleY:o}=e,a=ut(e,Hd),l=new w(i,s);n.flipX=!1,n.flipY=!1,Object.assign(n,a),n.set({scaleX:r,scaleY:o}),n.setPositionByOrigin(l,K,K)},Ud=n=>{n.scaleX=1,n.scaleY=1,n.skewX=0,n.skewY=0,n.flipX=!1,n.flipY=!1,n.rotate(0)},gh=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}),$a=(n,t,e)=>{const i=n/2,s=t/2,r=[new w(-i,-s),new w(i,-s),new w(-i,s),new w(i,s)].map(a=>a.transform(e)),o=li(r);return new w(o.width,o.height)},io=function(){let n=arguments.length>0&&arguments[0]!==void 0?arguments[0]:ie;return Ut(Me(arguments.length>1&&arguments[1]!==void 0?arguments[1]:ie),n)},Cs=function(n){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:ie,e=arguments.length>2&&arguments[2]!==void 0?arguments[2]:ie;return n.transform(io(t,e))},Wd=function(n){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:ie,e=arguments.length>2&&arguments[2]!==void 0?arguments[2]:ie;return n.transform(io(t,e),!0)},Gd=(n,t,e)=>{const i=io(t,e);return Bn(n,Ut(i,n.calcOwnMatrix())),i},mh=(n,t)=>{var e;const{transform:{target:i}}=t;(e=i.canvas)===null||e===void 0||e.fire("object:".concat(n),_(_({},t),{},{target:i})),i.fire(n,t)},Yd={left:-.5,top:-.5,center:0,bottom:.5,right:.5},Dt=n=>typeof n=="string"?Yd[n]:n-.5,Nn="not-allowed";function vh(n){return Dt(n.originX)===Dt(K)&&Dt(n.originY)===Dt(K)}function Ll(n){return .5-Dt(n)}const Le=(n,t)=>n[t],bh=(n,t,e,i)=>({e:n,transform:t,pointer:new w(e,i)});function _h(n,t){const e=n.getTotalAngle()+es(Math.atan2(t.y,t.x))+360;return Math.round(e%360/45)}function Ba(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,p,f,g){const m=d.getRelativeCenterPoint(),v=f!==void 0&&g!==void 0?d.translateToGivenOrigin(m,K,K,f,g):new w(d.left,d.top);return(d.angle?p.rotate(-Et(d.angle),m):p).subtract(v)}(o,new w(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 Xd=(n,t,e,i)=>{const{target:s,offsetX:r,offsetY:o}=t,a=e-r,l=i-o,c=!Le(s,"lockMovementX")&&s.left!==a,h=!Le(s,"lockMovementY")&&s.top!==l;return c&&s.set(it,a),h&&s.set(le,l),(c||h)&&mh(eh,bh(n,t,e,i)),c||h};class yh{getSvgStyles(t){const e=this.fillRule?this.fillRule:"nonzero",i=this.strokeWidth?this.strokeWidth:"0",s=this.strokeDashArray?this.strokeDashArray.join(" "):ce,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=pr(Ft,this.fill);return[pr(he,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($n(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,p=this.shadow,f=[],g=t.indexOf("COMMON_PARTS");let m;l&&(l.clipPathId="CLIPPATH_".concat(Pi()),m='<clipPath id="'.concat(l.clipPathId,`" >
110
148
  `).concat(l.toClipPathSVG(i),`</clipPath>
111
149
  `)),h&&f.push("<g ",a,this.getSvgCommons(),` >
112
150
  `),f.push("<g ",this.getSvgTransform(!1),h?"":a+this.getSvgCommons(),` >
113
- `);const v=[o,c,e?"":this.addPaintOrder()," ",s?'transform="'.concat(s,'" '):""].join("");return t[g]=v,_e(d)&&f.push(d.toSVG(this)),_e(u)&&f.push(u.toSVG(this)),p&&f.push(p.toSVG(this)),l&&f.push(m),f.push(t.join("")),f.push(`</g>
151
+ `);const v=[o,c,e?"":this.addPaintOrder()," ",r?'transform="'.concat(r,'" '):""].join("");return t[g]=v,we(d)&&f.push(d.toSVG(this)),we(u)&&f.push(u.toSVG(this)),p&&f.push(p.toSVG(this)),l&&f.push(m),f.push(t.join("")),f.push(`</g>
114
152
  `),h&&f.push(`</g>
115
- `),i?i(f.join("")):f.join("")}addPaintOrder(){return this.paintFirst!==It?' paint-order="'.concat(this.paintFirst,'" '):""}}function Ln(n){return new RegExp("^("+n.join("|")+")\\b","i")}var Ka;const Gi=String.raw(Ka||(Ka=ki(["(?:[-+]?(?:d*.d+|d+.?)(?:[eE][-+]?d+)?)"],["(?:[-+]?(?:\\d*\\.\\d+|\\d+\\.?)(?:[eE][-+]?\\d+)?)"]))),Bu=new RegExp("(normal|italic)?\\s*(normal|small-caps)?\\s*(normal|bold|bolder|lighter|100|200|300|400|500|600|700|800|900)?\\s*("+Gi+"(?:px|cm|mm|em|pt|pc|in)*)(?:\\/(normal|"+Gi+"))?\\s+(.*)"),Nu={cx:it,x:it,r:"radius",cy:ne,y:ne,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"},to="font-size",eo="clip-path";Ln(["path","circle","polygon","polyline","ellipse","rect","line","image","text"]);Ln(["symbol","image","marker","pattern","view","svg"]);const qa=Ln(["symbol","g","a","svg","clipPath","defs"]),zu=new w(1,0),Tc=new w,Ec=(n,t)=>n.rotate(t),Eo=(n,t)=>new w(t).subtract(n),Oo=n=>n.distanceFrom(Tc),ko=(n,t)=>Math.atan2(Vr(n,t),Hu(n,t)),Vu=n=>ko(zu,n),ha=n=>n.eq(Tc)?n:n.scalarDivide(Oo(n)),Oc=function(n){let t=!(arguments.length>1&&arguments[1]!==void 0)||arguments[1];return ha(new w(-n.y,n.x).scalarMultiply(t?1:-1))},Vr=(n,t)=>n.x*t.y-n.y*t.x,Hu=(n,t)=>n.x*t.x+n.y*t.y,Za=(n,t,e)=>{if(n.eq(t)||n.eq(e))return!0;const i=Vr(t,e),r=Vr(t,n),s=Vr(e,n);return i>=0?r>=0&&s<=0:!(r<=0&&s>=0)},Ja="(-?\\d+(?:\\.\\d*)?(?:px)?(?:\\s?|$))?",Qa=new RegExp("(?:\\s|^)"+Ja+Ja+"("+Gi+"?(?:px)?)?(?:\\s?|$)(?:$|\\s)");class ri{constructor(t){const e=typeof t=="string"?ri.parseShadow(t):t;Object.assign(this,ri.ownDefaults,e),this.id=xi()}static parseShadow(t){const e=t.trim(),[,i=0,r=0,s=0]=(Qa.exec(e)||[]).map(o=>parseFloat(o)||0);return{color:(e.replace(Qa,"")||"rgb(0,0,0)").trim(),offsetX:i,offsetY:r,blur:s}}toString(){return[this.offsetX,this.offsetY,this.blur,this.color].join("px ")}toSVG(t){const e=Ec(new w(this.offsetX,this.offsetY),Ct(-t.angle)),i=new rt(this.color);let r=40,s=40;return t.width&&t.height&&(r=100*ft((Math.abs(e.x)+this.blur)/t.width,Q.NUM_FRACTION_DIGITS)+20,s=100*ft((Math.abs(e.y)+this.blur)/t.height,Q.NUM_FRACTION_DIGITS)+20),t.flipX&&(e.x*=-1),t.flipY&&(e.y*=-1),'<filter id="SVGID_'.concat(this.id,'" y="-').concat(s,'%" height="').concat(100+2*s,'%" x="-').concat(r,'%" width="').concat(100+2*r,`%" >
116
- <feGaussianBlur in="SourceAlpha" stdDeviation="`).concat(ft(this.blur?this.blur/2:0,Q.NUM_FRACTION_DIGITS),`"></feGaussianBlur>
117
- <feOffset dx="`).concat(ft(e.x,Q.NUM_FRACTION_DIGITS),'" dy="').concat(ft(e.y,Q.NUM_FRACTION_DIGITS),`" result="oBlur" ></feOffset>
153
+ `),i?i(f.join("")):f.join("")}addPaintOrder(){return this.paintFirst!==Ft?' paint-order="'.concat(this.paintFirst,'" '):""}}function so(n){return new RegExp("^("+n.join("|")+")\\b","i")}var Fl;const is=String.raw(Fl||(Fl=Ri(["(?:[-+]?(?:d*.d+|d+.?)(?:[eE][-+]?d+)?)"],["(?:[-+]?(?:\\d*\\.\\d+|\\d+\\.?)(?:[eE][-+]?\\d+)?)"]))),Kd=new RegExp("(normal|italic)?\\s*(normal|small-caps)?\\s*(normal|bold|bolder|lighter|100|200|300|400|500|600|700|800|900)?\\s*("+is+"(?:px|cm|mm|em|pt|pc|in)*)(?:\\/(normal|"+is+"))?\\s+(.*)"),qd={cx:it,x:it,r:"radius",cy:le,y:le,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"},Po="font-size",Do="clip-path";so(["path","circle","polygon","polyline","ellipse","rect","line","image","text"]);so(["symbol","image","marker","pattern","view","svg"]);const jl=so(["symbol","g","a","svg","clipPath","defs"]),Zd=new w(1,0),xh=new w,wh=(n,t)=>n.rotate(t),ia=(n,t)=>new w(t).subtract(n),sa=n=>n.distanceFrom(xh),ra=(n,t)=>Math.atan2(sr(n,t),Qd(n,t)),Jd=n=>ra(Zd,n),Na=n=>n.eq(xh)?n:n.scalarDivide(sa(n)),Ch=function(n){let t=!(arguments.length>1&&arguments[1]!==void 0)||arguments[1];return Na(new w(-n.y,n.x).scalarMultiply(t?1:-1))},sr=(n,t)=>n.x*t.y-n.y*t.x,Qd=(n,t)=>n.x*t.x+n.y*t.y,Rl=(n,t,e)=>{if(n.eq(t)||n.eq(e))return!0;const i=sr(t,e),s=sr(t,n),r=sr(e,n);return i>=0?s>=0&&r<=0:!(s<=0&&r>=0)},$l="(-?\\d+(?:\\.\\d*)?(?:px)?(?:\\s?|$))?",Bl=new RegExp("(?:\\s|^)"+$l+$l+"("+is+"?(?:px)?)?(?:\\s?|$)(?:$|\\s)");class ci{constructor(t){const e=typeof t=="string"?ci.parseShadow(t):t;Object.assign(this,ci.ownDefaults,e),this.id=Pi()}static parseShadow(t){const e=t.trim(),[,i=0,s=0,r=0]=(Bl.exec(e)||[]).map(o=>parseFloat(o)||0);return{color:(e.replace(Bl,"")||"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=wh(new w(this.offsetX,this.offsetY),Et(-t.angle)),i=new st(this.color);let s=40,r=40;return t.width&&t.height&&(s=100*gt((Math.abs(e.x)+this.blur)/t.width,tt.NUM_FRACTION_DIGITS)+20,r=100*gt((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,`%" >
154
+ <feGaussianBlur in="SourceAlpha" stdDeviation="`).concat(gt(this.blur?this.blur/2:0,tt.NUM_FRACTION_DIGITS),`"></feGaussianBlur>
155
+ <feOffset dx="`).concat(gt(e.x,tt.NUM_FRACTION_DIGITS),'" dy="').concat(gt(e.y,tt.NUM_FRACTION_DIGITS),`" result="oBlur" ></feOffset>
118
156
  <feFlood flood-color="`).concat(i.toRgb(),'" flood-opacity="').concat(i.getAlpha(),`"/>
119
157
  <feComposite in2="oBlur" operator="in" />
120
158
  <feMerge>
@@ -122,44 +160,44 @@ Resulting to default behavior: removing object from previous canvas and adding t
122
160
  <feMergeNode in="SourceGraphic"></feMergeNode>
123
161
  </feMerge>
124
162
  </filter>
125
- `)}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=ri.ownDefaults;return this.includeDefaultValues?t:aa(t,(i,r)=>i!==e[r])}static async fromObject(t){return new this(t)}}b(ri,"ownDefaults",{color:"rgb(0,0,0)",blur:0,offsetX:0,offsetY:0,affectStroke:!1,includeDefaultValues:!0,nonScaling:!1}),b(ri,"type","shadow"),R.setClass(ri,"shadow");const fr=(n,t,e)=>Math.max(n,Math.min(t,e)),$u=[ne,it,le,xe,"flipX","flipY","originX","originY","angle","opacity","globalCompositeOperation","shadow","visible",br,_r],ui=[It,ae,"strokeWidth","strokeDashArray","width","height","paintFirst","strokeUniform","strokeLineCap","strokeDashOffset","strokeLineJoin","strokeMiterLimit","backgroundColor","clipPath"],Wu={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:it,originY:ne,strokeWidth:1,strokeUniform:!1,padding:0,opacity:1,paintFirst:It,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},Gu=(n,t,e,i)=>-e*Math.cos(n/i*cs)+e+t,Uu=()=>!1;class ua{constructor(t){let{startValue:e,byValue:i,duration:r=500,delay:s=0,easing:o=Gu,onStart:a=tn,onChange:l=tn,onComplete:c=tn,abort:h=Uu,target:u}=t;b(this,"_state","pending"),b(this,"durationProgress",0),b(this,"valueProgress",0),this.tick=this.tick.bind(this),this.duration=r,this.delay=s,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(()=>rn(t),this.delay):rn(t)}tick(t){const e=(t||+new Date)-this.startTime,i=Math.min(e,this.duration);this.durationProgress=i/this.duration;const{value:r,valueProgress:s}=this.calculate(i);this.value=Object.freeze(r),this.valueProgress=s,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),rn(this.tick)))}register(){fn.push(this)}unregister(){fn.remove(this)}abort(){this._state="aborted",this.unregister()}}const Yu=["startValue","endValue"];class Xu extends ua{constructor(t){let{startValue:e=0,endValue:i=100}=t;super(_(_({},ht(t,Yu)),{},{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 Ku=["startValue","endValue"];class qu extends ua{constructor(t){let{startValue:e=[0],endValue:i=[100]}=t;super(_(_({},ht(t,Ku)),{},{startValue:e,byValue:i.map((r,s)=>r-e[s])}))}calculate(t){const e=this.startValue.map((i,r)=>this.easing(t,i,this.byValue[r],this.duration,r));return{value:e,valueProgress:Math.abs((e[0]-this.startValue[0])/this.byValue[0])}}}const Zu=["startValue","endValue","easing","onChange","onComplete","abort"],Ju=(n,t,e,i)=>t+e*(1-Math.cos(n/i*cs)),io=n=>n&&((t,e,i)=>n(new rt(t).toRgba(),e,i));class Qu extends ua{constructor(t){let{startValue:e,endValue:i,easing:r=Ju,onChange:s,onComplete:o,abort:a}=t,l=ht(t,Zu);const c=new rt(e).getSource(),h=new rt(i).getSource();super(_(_({},l),{},{startValue:c,byValue:h.map((u,d)=>u-c[d]),easing:r,onChange:io(s),onComplete:io(o),abort:io(a)}))}calculate(t){const[e,i,r,s]=this.startValue.map((a,l)=>this.easing(t,a,this.byValue[l],this.duration,l)),o=[...[e,i,r].map(Math.round),fr(0,s,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 kc(n){const t=(e=>Array.isArray(e.startValue)||Array.isArray(e.endValue))(n)?new qu(n):new Xu(n);return t.start(),t}function td(n){const t=new Qu(n);return t.start(),t}class pt{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(r=>!this.includes(r))),this}static isPointContained(t,e,i){let r=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&&(r||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&&(r||t.x>=Math.min(e.x,i.x)&&t.x<=Math.max(e.x,i.x));{const s=Eo(e,i),o=Eo(e,t).divide(s);return r?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 w(t).setX(Math.min(t.x-1,...e.map(s=>s.x)));let r=0;for(let s=0;s<e.length;s++){const o=this.intersectSegmentSegment(e[s],e[(s+1)%e.length],t,i);if(o.includes(t))return!0;r+=+(o.status==="Intersection")}return r%2==1}static intersectLineLine(t,e,i,r){let s=!(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=r.x-i.x,h=r.y-i.y,u=t.x-i.x,d=t.y-i.y,p=c*d-h*u,f=a*d-l*u,g=h*a-c*l;if(g!==0){const m=p/g,v=f/g;return(s||0<=m&&m<=1)&&(o||0<=v&&v<=1)?new pt("Intersection").append(new w(t.x+m*a,t.y+m*l)):new pt}if(p===0||f===0){const m=s||o||pt.isPointContained(t,i,r)||pt.isPointContained(e,i,r)||pt.isPointContained(i,t,e)||pt.isPointContained(r,t,e);return new pt(m?"Coincident":void 0)}return new pt("Parallel")}static intersectSegmentLine(t,e,i,r){return pt.intersectLineLine(t,e,i,r,!1,!0)}static intersectSegmentSegment(t,e,i,r){return pt.intersectLineLine(t,e,i,r,!1,!1)}static intersectLinePolygon(t,e,i){let r=!(arguments.length>3&&arguments[3]!==void 0)||arguments[3];const s=new pt,o=i.length;for(let a,l,c,h=0;h<o;h++){if(a=i[h],l=i[(h+1)%o],c=pt.intersectLineLine(t,e,a,l,r,!1),c.status==="Coincident")return c;s.append(...c.points)}return s.points.length>0&&(s.status="Intersection"),s}static intersectSegmentPolygon(t,e,i){return pt.intersectLinePolygon(t,e,i,!1)}static intersectPolygonPolygon(t,e){const i=new pt,r=t.length,s=[];for(let o=0;o<r;o++){const a=t[o],l=t[(o+1)%r],c=pt.intersectSegmentPolygon(a,l,e);c.status==="Coincident"?(s.push(c),i.append(a,l)):i.append(...c.points)}return s.length>0&&s.length===t.length?new pt("Coincident"):(i.points.length>0&&(i.status="Intersection"),i)}static intersectPolygonRectangle(t,e,i){const r=e.min(i),s=e.max(i),o=new w(s.x,r.y),a=new w(r.x,s.y);return pt.intersectPolygonPolygon(t,[r,o,s,a])}}class ed extends cc{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,ke(this.group.calcTransformMatrix()))),this.setRelativeXY(t,e,i)}getRelativeXY(){return new w(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:r}=this.aCoords||(this.aCoords=this.calcACoords()),s=[t,e,i,r];if(this.group){const o=this.group.calcTransformMatrix();return s.map(a=>re(a,o))}return s}intersectsWithRect(t,e){return pt.intersectPolygonRectangle(this.getCoords(),t,e).status==="Intersection"}intersectsWithObject(t){const e=pt.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:r,width:s,height:o}=this.getBoundingRect();return i>=t.x&&i+s<=e.x&&r>=t.y&&r+o<=e.y}isOverlapping(t){return this.intersectsWithObject(t)||this.isContainedWithinObject(t)||t.isContainedWithinObject(this)}containsPoint(t){return pt.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 ii(this.getCoords())}getScaledWidth(){return this._getTransformedDimensions().x}getScaledHeight(){return this._getTransformedDimensions().y}scale(t){this._set(le,t),this._set(xe,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(uc(this.calcTransformMatrix())):this.angle}getViewportTransform(){var t;return((t=this.canvas)===null||t===void 0?void 0:t.viewportTransform)||Qt.concat()}calcACoords(){const t=us({angle:this.angle}),{x:e,y:i}=this.getRelativeCenterPoint(),r=hs(e,i),s=Ht(r,t),o=this._getTransformedDimensions(),a=o.x/2,l=o.y/2;return{tl:re({x:-a,y:-l},s),tr:re({x:a,y:-l},s),bl:re({x:-a,y:l},s),br:re({x:a,y:l},s)}}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,Dt(this.originX),Dt(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),r=this.matrixCache;return r&&r.key.every((s,o)=>s===i[o])?r.value:(this.group&&(e=Ht(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(),r={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},s=Eu(r);return this.ownMatrixCache={key:t,value:s},s}_getNonTransformedDimensions(){return new w(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=_({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 r=i,s=0;this.strokeUniform&&(r=0,s=i);const o=e.width+r,a=e.height+r;let l;return l=e.skewX===0&&e.skewY===0?new w(o*e.scaleX,a*e.scaleY):la(o,a,An(e)),l.scalarAdd(s)}translateToGivenOrigin(t,e,i,r,s){let o=t.x,a=t.y;const l=Dt(r)-Dt(e),c=Dt(s)-Dt(i);if(l||c){const h=this._getTransformedDimensions();o+=l*h.x,a+=c*h.y}return new w(o,a)}translateToCenterPoint(t,e,i){if(e===K&&i===K)return t;const r=this.translateToGivenOrigin(t,e,i,K,K);return this.angle?r.rotate(Ct(this.angle),t):r}translateToOriginPoint(t,e,i){const r=this.translateToGivenOrigin(t,K,K,e,i);return this.angle?r.rotate(Ct(this.angle),t):r}getCenterPoint(){const t=this.getRelativeCenterPoint();return this.group?re(t,this.group.calcTransformMatrix()):t}getRelativeCenterPoint(){return this.translateToCenterPoint(new w(this.left,this.top),this.originX,this.originY)}getPointByOrigin(t,e){return this.translateToOriginPoint(this.getRelativeCenterPoint(),t,e)}setPositionByOrigin(t,e,i){const r=this.translateToCenterPoint(t,e,i),s=this.translateToOriginPoint(r,this.originX,this.originY);this.set({left:s.x,top:s.y})}_getLeftTopCoords(){return this.translateToOriginPoint(this.getRelativeCenterPoint(),it,ne)}}const id=["type"],rd=["extraParam"];let Ye=class nn extends ed{static getDefaults(){return nn.ownDefaults}get type(){const t=this.constructor.type;return t==="FabricObject"?"object":t.toLowerCase()}set type(t){yi("warn","Setting type has no effect",t)}constructor(t){super(),b(this,"_cacheContext",null),Object.assign(this,nn.ownDefaults),this.setOptions(t)}_createCacheCanvas(){this._cacheCanvas=Ae(),this._cacheContext=this._cacheCanvas.getContext("2d"),this._updateCacheCanvas(),this.dirty=!0}_limitCacheSize(t){const e=t.width,i=t.height,r=Q.maxCacheSideLimit,s=Q.minCacheSideLimit;if(e<=r&&i<=r&&e*i<=Q.perfLimitSizeTotal)return e<s&&(t.width=s),i<s&&(t.height=s),t;const o=e/i,[a,l]=zr.limitDimsByArea(o),c=fr(s,a,r),h=fr(s,l,r);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,r=e.y*t.y/this.scaleY;return{width:Math.ceil(i+2),height:Math.ceil(r+2),zoomX:t.x,zoomY:t.y,x:i,y:r}}_updateCacheCanvas(){const t=this._cacheCanvas,e=this._cacheContext,{width:i,height:r,zoomX:s,zoomY:o,x:a,y:l}=this._limitCacheSize(this._getCacheCanvasDimensions()),c=i!==t.width||r!==t.height,h=this.zoomX!==s||this.zoomY!==o;if(!t||!e)return!1;if(c||h){i!==t.width||r!==t.height?(t.width=i,t.height=r):(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(s,o),this.zoomX=s,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 w(Math.abs(this.scaleX),Math.abs(this.scaleY));const t=gn(this.calcTransformMatrix());return new w(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!==le&&t!==xe||(e=this._constrainScale(e)),t===le&&e<0?(this.flipX=!this.flipX,e*=-1):t==="scaleY"&&e<0?(this.flipY=!this.flipY,e*=-1):t!=="shadow"||!e||e instanceof ri||(e=new ri(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:r,cacheTranslationY:s}=this,{width:o,height:a}=this._cacheCanvas;this.drawObject(this._cacheContext,t.forClipping,{zoomX:e,zoomY:i,cacheTranslationX:r,cacheTranslationY:s,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===ae&&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 r=this.fill,s=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=r,this.stroke=s}createClipPathLayer(t,e){const i=Ne(e),r=i.getContext("2d");if(r.translate(e.cacheTranslationX,e.cacheTranslationY),r.scale(e.zoomX,e.zoomY),t._cacheCanvas=i,e.parentClipPaths.forEach(s=>{s.transform(r)}),e.parentClipPaths.push(t),t.absolutePositioned){const s=ke(this.calcTransformMatrix());r.transform(s[0],s[1],s[2],s[3],s[4],s[5])}return t.transform(r),t.drawObject(r,!0,e),i}_drawClipPath(t,e,i){if(!e)return;e._transformDone=!0;const r=this.createClipPathLayer(e,i);this.drawClipPathOnCache(t,e,r)}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,_e(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&&(_e(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,r=this.getCanvasRetinaScaling(),[s,,,o]=(i==null?void 0:i.viewportTransform)||Qt,a=s*r,l=o*r,c=e.nonScaling?new w(1,1):this.getObjectScaling();t.shadowColor=e.color,t.shadowBlur=e.blur*Q.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(!_e(e))return{offsetX:0,offsetY:0};const i=e.gradientTransform||e.patternTransform,r=-this.width/2+e.offsetX||0,s=-this.height/2+e.offsetY||0;return e.gradientUnits==="percentage"?t.transform(this.width,0,0,this.height,r,s):t.transform(1,0,0,1,r,s),i&&t.transform(i[0],i[1],i[2],i[3],i[4],i[5]),{offsetX:r,offsetY:s}}_renderPaintInOrder(t){this.paintFirst===ae?(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 r=this._limitCacheSize(this._getCacheCanvasDimensions()),s=this.getCanvasRetinaScaling(),o=r.x/this.scaleX/s,a=r.y/this.scaleY/s,l=Ne({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(r.zoomX/this.scaleX/s,r.zoomY/this.scaleY/s),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(s*this.scaleX/r.zoomX,s*this.scaleY/r.zoomY),t.strokeStyle=(i=c.createPattern(l,"no-repeat"))!==null&&i!==void 0?i:"")}_findCenterFromElement(){return new w(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(R.getClass("image"))(e)}toCanvasElement(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};const e=_c(this),i=this.group,r=this.shadow,s=Math.abs,o=t.enableRetinaScaling?sc():1,a=(t.multiplier||1)*o,l=t.canvasProvider||(y=>new ds(y,{enableRetinaScaling:!1,renderOnAddRemove:!1,skipOffscreen:!1}));delete this.group,t.withoutTransform&&Iu(this),t.withoutShadow&&(this.shadow=null),t.viewportTransform&&Fu(this,this.getViewportTransform()),this.setCoords();const c=Ae(),h=this.getBoundingRect(),u=this.shadow,d=new w;if(u){const y=u.blur,x=u.nonScaling?new w(1,1):this.getObjectScaling();d.x=2*Math.round(s(u.offsetX)+y)*s(x.x),d.y=2*Math.round(s(u.offsetY)+y)*s(x.y)}const p=h.width+d.x,f=h.height+d.y;c.width=Math.ceil(p),c.height=Math.ceil(f);const g=l(c);t.format==="jpeg"&&(g.backgroundColor="#fff"),this.setPositionByOrigin(new w(g.width/2,g.height/2),K,K);const m=this.canvas;g._objects=[this],this.set("canvas",g),this.setCoords();const v=g.toCanvasElement(a||1,t);return this.set("canvas",m),this.shadow=r,i&&(this.group=i),this.set(e),this.setCoords(),g._objects=[],g.destroy(),v}toDataURL(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};return hc(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:r}=this;if(e){const{x:s,y:o}=this.getRelativeCenterPoint();this.originX=K,this.originY=K,this.left=s,this.top=o}if(this.set("angle",t),e){const{x:s,y:o}=this.translateToOriginPoint(this.getRelativeCenterPoint(),i,r);this.left=s,this.top=o,this.originX=i,this.originY=r}}setOnGroup(){}_setupCompositeOperation(t){this.globalCompositeOperation&&(t.globalCompositeOperation=this.globalCompositeOperation)}dispose(){fn.cancelByTarget(this),this.off(),this._set("canvas",void 0),this._cacheCanvas&&Be().dispose(this._cacheCanvas),this._cacheCanvas=void 0,this._cacheContext=null}animate(t,e){return Object.entries(t).reduce((i,r)=>{let[s,o]=r;return i[s]=this._animate(s,o,e),i},{})}_animate(t,e){let i=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};const r=t.split("."),s=this.constructor.colorProperties.includes(r[r.length-1]),{abort:o,startValue:a,onChange:l,onComplete:c}=i,h=_(_({},i),{},{target:this,startValue:a??r.reduce((u,d)=>u[d],this),endValue:e,abort:o==null?void 0:o.bind(this),onChange:(u,d,p)=>{r.reduce((f,g,m)=>(m===r.length-1&&(f[g]=u),f[g]),this),l&&l(u,d,p)},onComplete:(u,d,p)=>{this.setCoords(),c&&c(u,d,p)}});return s?td(h):kc(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 r,s=0;s<e.length;s++){if(r=e[s],r===t)return{fork:[this,...e.slice(0,s)],otherFork:[],common:e.slice(s)};for(let o=0;o<i.length;o++){if(this===i[o])return{fork:[],otherFork:[t,...i.slice(0,o)],common:[this,...e]};if(r===i[o])return{fork:[this,...e.slice(0,s)],otherFork:[t,...i.slice(0,o)],common:e.slice(s)}}}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 r=e.fork.pop(),s=e.otherFork.pop(),o=i._objects.indexOf(r),a=i._objects.indexOf(s);return o>-1&&o>a}toObject(){const t=(arguments.length>0&&arguments[0]!==void 0?arguments[0]:[]).concat(nn.customProperties,this.constructor.customProperties||[]);let e;const i=Q.NUM_FRACTION_DIGITS,{clipPath:r,fill:s,stroke:o,shadow:a,strokeDashArray:l,left:c,top:h,originX:u,originY:d,width:p,height:f,strokeWidth:g,strokeLineCap:m,strokeDashOffset:v,strokeLineJoin:y,strokeUniform:x,strokeMiterLimit:T,scaleX:E,scaleY:A,angle:C,flipX:S,flipY:F,opacity:j,visible:D,backgroundColor:k,fillRule:P,paintFirst:L,globalCompositeOperation:V,skewX:Y,skewY:Z}=this;r&&!r.excludeFromExport&&(e=r.toObject(t.concat("inverted","absolutePositioned")));const B=M=>ft(M,i),N=_(_({},yr(this,t)),{},{type:this.constructor.type,version:xo,originX:u,originY:d,left:B(c),top:B(h),width:B(p),height:B(f),fill:Ga(s)?s.toObject():s,stroke:Ga(o)?o.toObject():o,strokeWidth:B(g),strokeDashArray:l&&l.concat(),strokeLineCap:m,strokeDashOffset:v,strokeLineJoin:y,strokeUniform:x,strokeMiterLimit:B(T),scaleX:B(E),scaleY:B(A),angle:B(C),flipX:S,flipY:F,opacity:B(j),shadow:a&&a.toObject(),visible:D,backgroundColor:k,fillRule:P,paintFirst:L,globalCompositeOperation:V,skewX:B(Y),skewY:B(Z)},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 aa(t,(r,s)=>{if(s===it||s===ne||s==="type")return!0;const o=i[s];return r!==o&&!(Array.isArray(r)&&Array.isArray(o)&&r.length===0&&o.length===0)})}toString(){return"#<".concat(this.constructor.type,">")}static _fromObject(t){let e=ht(t,id),i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},{extraParam:r}=i,s=ht(i,rd);return Mn(e,s).then(o=>r?(delete o[r],new this(e[r],o)):new this(o))}static fromObject(t,e){return this._fromObject(t,e)}};b(Ye,"stateProperties",$u),b(Ye,"cacheProperties",ui),b(Ye,"ownDefaults",Wu),b(Ye,"type","FabricObject"),b(Ye,"colorProperties",[It,ae,"backgroundColor"]),b(Ye,"customProperties",[]),R.setClass(Ye),R.setClass(Ye,"object");const xr=(n,t,e)=>(i,r,s,o)=>{const a=t(i,r,s,o);return a&&yc(n,_(_({},wc(i,r,s,o)),e)),a};function wr(n){return(t,e,i,r)=>{const{target:s,originX:o,originY:a}=e,l=s.getRelativeCenterPoint(),c=s.translateToOriginPoint(l,o,a),h=n(t,e,i,r);return s.setPositionByOrigin(c,e.originX,e.originY),h}}const tl=xr(Yr,wr((n,t,e,i)=>{const r=ca(t,t.originX,t.originY,e,i);if(Dt(t.originX)===Dt(K)||Dt(t.originX)===Dt(xt)&&r.x<0||Dt(t.originX)===Dt(it)&&r.x>0){const{target:s}=t,o=s.strokeWidth/(s.strokeUniform?s.scaleX:1),a=xc(t)?2:1,l=s.width,c=Math.abs(r.x*a/s.scaleX)-o;return s.set("width",Math.max(c,1)),l!==s.width}return!1}));function sd(n,t,e,i,r){i=i||{};const s=this.sizeX||i.cornerSize||r.cornerSize,o=this.sizeY||i.cornerSize||r.cornerSize,a=i.transparentCorners!==void 0?i.transparentCorners:r.transparentCorners,l=a?ae:It,c=!a&&(i.cornerStrokeColor||r.cornerStrokeColor);let h,u=t,d=e;n.save(),n.fillStyle=i.cornerColor||r.cornerColor||"",n.strokeStyle=i.cornerStrokeColor||r.cornerStrokeColor||"",s>o?(h=s,n.scale(1,o/s),d=e*s/o):o>s?(h=o,n.scale(s/o,1),u=t*o/s):h=s,n.beginPath(),n.arc(u,d,h/2,0,un,!1),n[l](),c&&n.stroke(),n.restore()}function nd(n,t,e,i,r){i=i||{};const s=this.sizeX||i.cornerSize||r.cornerSize,o=this.sizeY||i.cornerSize||r.cornerSize,a=i.transparentCorners!==void 0?i.transparentCorners:r.transparentCorners,l=a?ae:It,c=!a&&(i.cornerStrokeColor||r.cornerStrokeColor),h=s/2,u=o/2;n.save(),n.fillStyle=i.cornerColor||r.cornerColor||"",n.strokeStyle=i.cornerStrokeColor||r.cornerStrokeColor||"",n.translate(t,e);const d=r.getTotalAngle();n.rotate(Ct(d)),n["".concat(l,"Rect")](-h,-u,s,o),c&&n.strokeRect(-h,-u,s,o),n.restore()}class Se{constructor(t){b(this,"visible",!0),b(this,"actionName",Pn),b(this,"angle",0),b(this,"x",0),b(this,"y",0),b(this,"offsetX",0),b(this,"offsetY",0),b(this,"sizeX",0),b(this,"sizeY",0),b(this,"touchSizeX",0),b(this,"touchSizeY",0),b(this,"cursorStyle","crosshair"),b(this,"withConnection",!1),Object.assign(this,t)}shouldActivate(t,e,i,r){var s;let{tl:o,tr:a,br:l,bl:c}=r;return((s=e.canvas)===null||s===void 0?void 0:s.getActiveObject())===e&&e.isControlVisible(t)&&pt.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,r;return(i=(r=t._controlsVisibility)===null||r===void 0?void 0:r[e])!==null&&i!==void 0?i:this.visible}setVisibility(t,e,i){this.visible=t}positionHandler(t,e,i,r){return new w(this.x*t.x+this.offsetX,this.y*t.y+this.offsetY).transform(e)}calcCornerCoords(t,e,i,r,s,o){const a=na([hs(i,r),us({angle:t}),oa((s?this.touchSizeX:this.sizeX)||e,(s?this.touchSizeY:this.sizeY)||e)]);return{tl:new w(-.5,-.5).transform(a),tr:new w(.5,-.5).transform(a),br:new w(.5,.5).transform(a),bl:new w(-.5,.5).transform(a)}}render(t,e,i,r,s){((r=r||{}).cornerStyle||s.cornerStyle)==="circle"?sd.call(this,t,e,i,r,s):nd.call(this,t,e,i,r,s)}}const od=(n,t,e)=>e.lockRotation?bn:t.cursorStyle,ad=xr(oc,wr((n,t,e,i)=>{let{target:r,ex:s,ey:o,theta:a,originX:l,originY:c}=t;const h=r.translateToOriginPoint(r.getRelativeCenterPoint(),l,c);if(Pe(r,"lockRotation"))return!1;const u=Math.atan2(o-h.y,s-h.x),d=Math.atan2(i-h.y,e-h.x);let p=Wi(d-u+a);if(r.snapAngle&&r.snapAngle>0){const g=r.snapAngle,m=r.snapThreshold||g,v=Math.ceil(p/g)*g,y=Math.floor(p/g)*g;Math.abs(p-y)<m?p=y:Math.abs(p-v)<m&&(p=v)}p<0&&(p=360+p),p%=360;const f=r.angle!==p;return r.angle=p,f}));function Dc(n,t){const e=t.canvas,i=n[e.uniScaleKey];return e.uniformScaling&&!i||!e.uniformScaling&&i}function Pc(n,t,e){const i=Pe(n,"lockScalingX"),r=Pe(n,"lockScalingY");if(i&&r||!t&&(i||r)&&e||i&&t==="x"||r&&t==="y")return!0;const{width:s,height:o,strokeWidth:a}=n;return s===0&&a===0&&t!=="y"||o===0&&a===0&&t!=="x"}const ld=["e","se","s","sw","w","nw","n","ne","e"],Br=(n,t,e)=>{const i=Dc(n,e);if(Pc(e,t.x!==0&&t.y===0?"x":t.x===0&&t.y!==0?"y":"",i))return bn;const r=Cc(e,t);return"".concat(ld[r],"-resize")};function da(n,t,e,i){let r=arguments.length>4&&arguments[4]!==void 0?arguments[4]:{};const s=t.target,o=r.by,a=Dc(n,s);let l,c,h,u,d,p;if(Pc(s,o,a))return!1;if(t.gestureScale)c=t.scaleX*t.gestureScale,h=t.scaleY*t.gestureScale;else{if(l=ca(t,t.originX,t.originY,e,i),d=o!=="y"?Math.sign(l.x||t.signX||1):1,p=o!=="x"?Math.sign(l.y||t.signY||1):1,t.signX||(t.signX=d),t.signY||(t.signY=p),Pe(s,"lockScalingFlip")&&(t.signX!==d||t.signY!==p))return!1;if(u=s._getTransformedDimensions(),a&&!o){const m=Math.abs(l.x)+Math.abs(l.y),{original:v}=t,y=m/(Math.abs(u.x*v.scaleX/s.scaleX)+Math.abs(u.y*v.scaleY/s.scaleY));c=v.scaleX*y,h=v.scaleY*y}else c=Math.abs(l.x*s.scaleX/u.x),h=Math.abs(l.y*s.scaleY/u.y);xc(t)&&(c*=2,h*=2),t.signX!==d&&o!=="y"&&(t.originX=Xa(t.originX),c*=-1,t.signX=d),t.signY!==p&&o!=="x"&&(t.originY=Xa(t.originY),h*=-1,t.signY=p)}const f=s.scaleX,g=s.scaleY;return o?(o==="x"&&s.set(le,c),o==="y"&&s.set(xe,h)):(!Pe(s,"lockScalingX")&&s.set(le,c),!Pe(s,"lockScalingY")&&s.set(xe,h)),f!==s.scaleX||g!==s.scaleY}const Es=xr(Dn,wr((n,t,e,i)=>da(n,t,e,i))),cd=xr(Dn,wr((n,t,e,i)=>da(n,t,e,i,{by:"x"}))),hd=xr(Dn,wr((n,t,e,i)=>da(n,t,e,i,{by:"y"}))),ud=["target","ex","ey","skewingSide"],ro={x:{counterAxis:"y",scale:le,skew:br,lockSkewing:"lockSkewingX",origin:"originX",flip:"flipX"},y:{counterAxis:"x",scale:xe,skew:_r,lockSkewing:"lockSkewingY",origin:"originY",flip:"flipY"}},dd=["ns","nesw","ew","nwse"],pd=(n,t,e)=>{if(t.x!==0&&Pe(e,"lockSkewingY")||t.y!==0&&Pe(e,"lockSkewingX"))return bn;const i=Cc(e,t)%4;return"".concat(dd[i],"-resize")};function Ac(n,t,e,i,r){const{target:s}=e,{counterAxis:o,origin:a,lockSkewing:l,skew:c,flip:h}=ro[n];if(Pe(s,l))return!1;const{origin:u,flip:d}=ro[o],p=Dt(e[u])*(s[d]?-1:1),f=-Math.sign(p)*(s[h]?-1:1),g=.5*-((s[c]===0&&ca(e,K,K,i,r)[n]>0||s[c]>0?1:-1)*f)+.5;return xr(ac,wr((v,y,x,T)=>function(E,A,C){let{target:S,ex:F,ey:j,skewingSide:D}=A,k=ht(A,ud);const{skew:P}=ro[E],L=C.subtract(new w(F,j)).divide(new w(S.scaleX,S.scaleY))[E],V=S[P],Y=k[P],Z=Math.tan(Ct(Y)),B=E==="y"?S._getTransformedDimensions({scaleX:1,scaleY:1,skewX:0}).x:S._getTransformedDimensions({scaleX:1,scaleY:1}).y,N=2*L*D/Math.max(B,1)+Z,M=Wi(Math.atan(N));S.set(P,M);const H=V!==S[P];if(H&&E==="y"){const{skewX:J,scaleX:bt}=S,nt=S._getTransformedDimensions({skewY:V}),he=S._getTransformedDimensions(),I=J!==0?nt.x/he.x:1;I!==1&&S.set(le,I*bt)}return H}(n,y,new w(x,T))))(t,_(_({},e),{},{[a]:g,skewingSide:f}),i,r)}const fd=(n,t,e,i)=>Ac("x",n,t,e,i),gd=(n,t,e,i)=>Ac("y",n,t,e,i);function Fn(n,t){return n[t.canvas.altActionKey]}const Os=(n,t,e)=>{const i=Fn(n,e);return t.x===0?i?br:xe:t.y===0?i?_r:le:""},rr=(n,t,e)=>Fn(n,e)?pd(0,t,e):Br(n,t,e),el=(n,t,e,i)=>Fn(n,t.target)?gd(n,t,e,i):cd(n,t,e,i),il=(n,t,e,i)=>Fn(n,t.target)?fd(n,t,e,i):hd(n,t,e,i),Mc=()=>({ml:new Se({x:-.5,y:0,cursorStyleHandler:rr,actionHandler:el,getActionName:Os}),mr:new Se({x:.5,y:0,cursorStyleHandler:rr,actionHandler:el,getActionName:Os}),mb:new Se({x:0,y:.5,cursorStyleHandler:rr,actionHandler:il,getActionName:Os}),mt:new Se({x:0,y:-.5,cursorStyleHandler:rr,actionHandler:il,getActionName:Os}),tl:new Se({x:-.5,y:-.5,cursorStyleHandler:Br,actionHandler:Es}),tr:new Se({x:.5,y:-.5,cursorStyleHandler:Br,actionHandler:Es}),bl:new Se({x:-.5,y:.5,cursorStyleHandler:Br,actionHandler:Es}),br:new Se({x:.5,y:.5,cursorStyleHandler:Br,actionHandler:Es}),mtr:new Se({x:0,y:-.5,actionHandler:ad,cursorStyleHandler:od,offsetY:-40,withConnection:!0,actionName:ra})}),md=()=>({mr:new Se({x:.5,y:0,actionHandler:tl,cursorStyleHandler:rr,actionName:Yr}),ml:new Se({x:-.5,y:0,actionHandler:tl,cursorStyleHandler:rr,actionName:Yr})}),vd=()=>_(_({},Mc()),md());class qr extends Ye{static getDefaults(){return _(_({},super.getDefaults()),qr.ownDefaults)}constructor(t){super(),Object.assign(this,this.constructor.createControls(),qr.ownDefaults),this.setOptions(t)}static createControls(){return{controls:Mc()}}_updateCacheCanvas(){const t=this.canvas;if(this.noScaleCache&&t&&t._currentTransform){const e=t._currentTransform,i=e.target,r=e.action;if(this===i&&r&&r.startsWith(Pn))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 r=i.length-1;r>=0;r--){const[s,o]=i[r],a=this.controls[s];if(a.shouldActivate(s,this,t,e?o.touchCorner:o.corner))return this.__corner=s,{key:s,control:a,coord:this.oCoords[s]}}}calcOCoords(){const t=this.getViewportTransform(),e=this.getCenterPoint(),i=hs(e.x,e.y),r=us({angle:this.getTotalAngle()-(this.group&&this.flipX?180:0)}),s=Ht(i,r),o=Ht(t,s),a=Ht(o,[1/t[0],0,0,1/t[3],0,0]),l=this.group?gn(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 p=u.positionHandler(c,a,this,u);h[d]=Object.assign(p,this._calcCornerCoords(u,p))}),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(),r=this.getViewportTransform();t.translate(e.x,e.y),t.scale(1/r[0],1/r[3]),t.rotate(Ct(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 r=_({hasControls:this.hasControls,borderColor:this.borderColor,borderDashArray:this.borderDashArray},i);t.save(),t.strokeStyle=r.borderColor,this._setLineDash(t,r.borderDashArray),this.strokeBorders(t,e),r.hasControls&&this.drawControlsConnectingLines(t,e),t.restore()}_renderControls(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};const{hasBorders:i,hasControls:r}=this,s=_({hasBorders:i,hasControls:r},e),o=this.getViewportTransform(),a=s.hasBorders,l=s.hasControls,c=Ht(o,this.calcTransformMatrix()),h=gn(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(Ct(this.group?h.angle:this.angle)),a&&this.drawBorders(t,h,e),l&&this.drawControls(t,e),t.restore()}drawBorders(t,e,i){let r;if(i&&i.forActiveSelection||this.group){const s=la(this.width,this.height,An(e)),o=this.isStrokeAccountedForInDimensions()?sa:(this.strokeUniform?new w().scalarAdd(this.canvas?this.canvas.getZoom():1):new w(e.scaleX,e.scaleY)).scalarMultiply(this.strokeWidth);r=s.add(o).scalarAdd(this.borderScaleFactor).scalarAdd(2*this.padding)}else r=this._calculateCurrentDimensions().scalarAdd(this.borderScaleFactor);this._drawBorders(t,r,i)}drawControlsConnectingLines(t,e){let i=!1;t.beginPath(),this.forEachControl((r,s)=>{r.withConnection&&r.getVisibility(this,s)&&(i=!0,t.moveTo(r.x*e.x,r.y*e.y),t.lineTo(r.x*e.x+r.offsetX,r.y*e.y+r.offsetY))}),i&&t.stroke()}drawControls(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};t.save();const i=this.getCanvasRetinaScaling(),{cornerStrokeColor:r,cornerDashArray:s,cornerColor:o}=this,a=_({cornerStrokeColor:r,cornerDashArray:s,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,r]=e;return this.setControlVisible(i,r)})}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 r=this.width+4,s=this.height+4;return e.clearRect(-r/2,-s/2,r,s),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 Ic(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}b(qr,"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 Yt extends qr{}Ic(Yt,[Sc]),R.setClass(Yt),R.setClass(Yt,"object");const bd=(n,t,e,i)=>{const r=2*(i=Math.round(i))+1,{data:s}=n.getImageData(t-i,e-i,r,r);for(let o=3;o<s.length;o+=4)if(s[o]>0)return!1;return!0};class Lc{constructor(t){this.options=t,this.strokeProjectionMagnitude=this.options.strokeWidth/2,this.scale=new w(this.options.scaleX,this.options.scaleY),this.strokeUniformScalar=this.options.strokeUniform?new w(1/this.options.scaleX,1/this.options.scaleY):new w(1,1)}createSideVector(t,e){const i=Eo(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 w(t);return e.y+=e.x*Math.tan(Ct(this.options.skewY)),e.x+=e.y*Math.tan(Ct(this.options.skewX)),e}scaleUnitVector(t,e){return t.multiply(this.strokeUniformScalar).scalarMultiply(e)}}const _d=new w;class ur extends Lc{static getOrthogonalRotationFactor(t,e){const i=e?ko(t,e):Vu(t);return Math.abs(i)<cs?-1:1}constructor(t,e,i,r){super(r),b(this,"AB",void 0),b(this,"AC",void 0),b(this,"alpha",void 0),b(this,"bisector",void 0),this.A=new w(t),this.B=new w(e),this.C=new w(i),this.AB=this.createSideVector(this.A,this.B),this.AC=this.createSideVector(this.A,this.C),this.alpha=ko(this.AB,this.AC),this.bisector=ha(Ec(this.AB.eq(_d)?this.AC:this.AB,this.alpha/2))}calcOrthogonalProjection(t,e){let i=arguments.length>2&&arguments[2]!==void 0?arguments[2]:this.strokeProjectionMagnitude;const r=this.createSideVector(t,e),s=Oc(r),o=ur.getOrthogonalRotationFactor(s,this.bisector);return this.scaleUnitVector(s,i*o)}projectBevel(){const t=[];return(this.alpha%un==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),r=this.scaleUnitVector(this.bisector,-this.strokeProjectionMagnitude*i),s=this.options.strokeUniform?Oo(this.scaleUnitVector(this.bisector,this.options.strokeMiterLimit)):this.options.strokeMiterLimit;return Oo(r)/this.strokeProjectionMagnitude<=s&&t.push(this.applySkew(this.A.add(r))),t.push(...this.projectBevel()),t}projectRoundNoSkew(t,e){const i=[],r=new w(ur.getOrthogonalRotationFactor(this.bisector),ur.getOrthogonalRotationFactor(new w(this.bisector.y,this.bisector.x)));return[new w(1,0).scalarMultiply(this.strokeProjectionMagnitude).multiply(this.strokeUniformScalar).multiply(r),new w(0,1).scalarMultiply(this.strokeProjectionMagnitude).multiply(this.strokeUniformScalar).multiply(r)].forEach(s=>{Za(s,t,e)&&i.push(this.A.add(s))}),i}projectRoundWithSkew(t,e){const i=[],{skewX:r,skewY:s,scaleX:o,scaleY:a,strokeUniform:l}=this.options,c=new w(Math.tan(Ct(r)),Math.tan(Ct(s))),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 w(Math.sqrt(Math.max(h**2-u**2,0)),u),p=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),f=new w(p,Math.sqrt(Math.max(h**2-p**2,0)));return[f,f.scalarMultiply(-1),d,d.scalarMultiply(-1)].map(g=>this.applySkew(l?g.multiply(this.strokeUniformScalar):g)).forEach(g=>{Za(g,t,e)&&i.push(this.applySkew(this.A).add(g))}),i}projectRound(){const t=[];t.push(...this.projectBevel());const e=this.alpha%un==0,i=this.applySkew(this.A),r=t[e?0:2].subtract(i),s=t[e?1:0].subtract(i),o=e?this.applySkew(this.AB.scalarMultiply(-1)):this.applySkew(this.bisector.multiply(this.strokeUniformScalar).scalarMultiply(-1)),a=Vr(r,o)>0,l=a?r:s,c=a?s:r;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 rl extends Lc{constructor(t,e,i){super(i),this.A=new w(t),this.T=new w(e)}calcOrthogonalProjection(t,e){let i=arguments.length>2&&arguments[2]!==void 0?arguments[2]:this.strokeProjectionMagnitude;const r=this.createSideVector(t,e);return this.scaleUnitVector(Oc(r),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 w(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 ur(this.A,this.T,this.T,this.options).projectRound());return t}projectSquare(){const t=[];if(this.A.eq(this.T)){const e=new w(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(ha(this.createSideVector(this.A,this.T)),-this.strokeProjectionMagnitude),r=this.A.add(i);t.push(r.add(e),r.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 yd=function(n,t){let e=arguments.length>2&&arguments[2]!==void 0&&arguments[2];const i=[];if(n.length===0)return i;const r=n.reduce((s,o)=>(s[s.length-1].eq(o)||s.push(new w(o)),s),[new w(n[0])]);if(r.length===1)e=!0;else if(!e){const s=r[0],o=((a,l)=>{for(let c=a.length-1;c>=0;c--)if(l(a[c],c,a))return c;return-1})(r,a=>!a.eq(s));r.splice(o+1)}return r.forEach((s,o,a)=>{let l,c;o===0?(c=a[1],l=e?s:a[a.length-1]):o===a.length-1?(l=a[o-1],c=e?s:a[0]):(l=a[o-1],c=a[o+1]),e&&a.length===1?i.push(...new rl(s,s,t).project()):!e||o!==0&&o!==a.length-1?i.push(...new ur(s,l,c,t).project()):i.push(...new rl(s,o===0?c:l,t).project())}),i},pa=n=>{const t={};return Object.keys(n).forEach(e=>{t[e]={},Object.keys(n[e]).forEach(i=>{t[e][i]=_({},n[e][i])})}),t},xd=n=>n.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/'/g,"&apos;").replace(/</g,"&lt;").replace(/>/g,"&gt;"),fa=n=>{const t=[];for(let e,i=0;i<n.length;i++)(e=wd(n,i))!==!1&&t.push(e);return t},wd=(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 r=n.charCodeAt(t+1);if(56320>r||r>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},ga=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)},Cd=(n,t)=>{const e=t.split(`
126
- `),i=[];let r=-1,s={};n=pa(n);for(let o=0;o<e.length;o++){const a=fa(e[o]);if(n[o])for(let l=0;l<a.length;l++){r++;const c=n[o][l];c&&Object.keys(c).length>0&&(ga(s,c,!0)?i.push({start:r,end:r+1,style:c}):i[i.length-1].end++),s=c||{}}else r+=a.length,s={}}return i},Sd=(n,t)=>{if(!Array.isArray(n))return pa(n);const e=t.split(ia),i={};let r=-1,s=0;for(let o=0;o<e.length;o++){const a=fa(e[o]);for(let l=0;l<a.length;l++)r++,n[s]&&n[s].start<=r&&r<n[s].end&&(i[o]=i[o]||{},i[o][l]=_({},n[s].style),r===n[s].end-1&&s++)}return i},Di=["display","transform",It,"fill-opacity","fill-rule","opacity",ae,"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 sl(n,t){const e=n.nodeName,i=n.getAttribute("class"),r=n.getAttribute("id"),s="(?![a-zA-Z\\-]+)";let o;if(o=new RegExp("^"+e,"i"),t=t.replace(o,""),r&&t.length&&(o=new RegExp("#"+r+s,"i"),t=t.replace(o,"")),i&&t.length){const a=i.split(" ");for(let l=a.length;l--;)o=new RegExp("\\."+a[l]+s,"i"),t=t.replace(o,"")}return t.length===0}function Td(n,t){let e=!0;const i=sl(n,t.pop());return i&&t.length&&(e=function(r,s){let o,a=!0;for(;r.parentElement&&r.parentElement.nodeType===1&&s.length;)a&&(o=s.pop()),a=sl(r=r.parentElement,o);return s.length===0}(n,t)),i&&e&&t.length===0}const Ed=n=>{var t;return(t=Nu[n])!==null&&t!==void 0?t:n},Od=new RegExp("(".concat(Gi,")"),"gi"),kd=n=>n.replace(Od," $1 ").replace(/,/gi," ").replace(/\s+/gi," ");var nl,ol,al,ll,cl,hl,ul;const Jt="(".concat(Gi,")"),Dd=String.raw(nl||(nl=ki(["(skewX)(",")"],["(skewX)\\(","\\)"])),Jt),Pd=String.raw(ol||(ol=ki(["(skewY)(",")"],["(skewY)\\(","\\)"])),Jt),Ad=String.raw(al||(al=ki(["(rotate)(","(?: "," ",")?)"],["(rotate)\\(","(?: "," ",")?\\)"])),Jt,Jt,Jt),Md=String.raw(ll||(ll=ki(["(scale)(","(?: ",")?)"],["(scale)\\(","(?: ",")?\\)"])),Jt,Jt),Id=String.raw(cl||(cl=ki(["(translate)(","(?: ",")?)"],["(translate)\\(","(?: ",")?\\)"])),Jt,Jt),Ld=String.raw(hl||(hl=ki(["(matrix)("," "," "," "," "," ",")"],["(matrix)\\("," "," "," "," "," ","\\)"])),Jt,Jt,Jt,Jt,Jt,Jt),ma="(?:".concat(Ld,"|").concat(Id,"|").concat(Ad,"|").concat(Md,"|").concat(Dd,"|").concat(Pd,")"),Fd="(?:".concat(ma,"*)"),jd=String.raw(ul||(ul=ki(["^s*(?:","?)s*$"],["^\\s*(?:","?)\\s*$"])),Fd),Rd=new RegExp(jd),Bd=new RegExp(ma),Nd=new RegExp(ma,"g");function Do(n){const t=[];if(!(n=kd(n).replace(/\s*([()])\s*/gi,"$1"))||n&&!Rd.test(n))return[...Qt];for(const e of n.matchAll(Nd)){const i=Bd.exec(e[0]);if(!i)continue;let r=Qt;const s=i.filter(f=>!!f),[,o,...a]=s,[l,c,h,u,d,p]=a.map(f=>parseFloat(f));switch(o){case"translate":r=hs(l,c);break;case ra:r=us({angle:l},{x:c,y:h});break;case Pn:r=oa(l,c);break;case br:r=pc(l);break;case _r:r=fc(l);break;case"matrix":r=[l,c,h,u,d,p]}t.push(r)}return na(t)}function zd(n,t,e,i){const r=Array.isArray(t);let s,o=t;if(n!==It&&n!==ae||t!==oe){if(n==="strokeUniform")return t==="non-scaling-stroke";if(n==="strokeDashArray")o=t===oe?null:t.replace(/,/g," ").split(/\s+/).map(parseFloat);else if(n==="transformMatrix")o=e&&e.transformMatrix?Ht(e.transformMatrix,Do(t)):Do(t);else if(n==="visible")o=t!==oe&&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"?it:t==="end"?xt:K;else if(n==="charSpacing")s=cr(t,i)/i*1e3;else if(n==="paintFirst"){const a=t.indexOf(It),l=t.indexOf(ae);o=It,(a>-1&&l>-1&&l<a||a===-1&&l>-1)&&(o=ae)}else{if(n==="href"||n==="xlink:href"||n==="font"||n==="id")return t;if(n==="imageSmoothing")return t==="optimizeQuality";s=r?t.map(cr):cr(t,i)}}else o="";return!r&&isNaN(s)?o:s}function Vd(n,t){const e=n.match(Bu);if(!e)return;const i=e[1],r=e[3],s=e[4],o=e[5],a=e[6];i&&(t.fontStyle=i),r&&(t.fontWeight=isNaN(parseFloat(r))?r:parseFloat(r)),s&&(t.fontSize=cr(s)),a&&(t.fontFamily=a),o&&(t.lineHeight=o==="normal"?1:o)}function Hd(n,t){n.replace(/;\s*$/,"").split(";").forEach(e=>{if(!e)return;const[i,r]=e.split(":");t[i.trim().toLowerCase()]=r.trim()})}function $d(n){const t={},e=n.getAttribute("style");return e&&(typeof e=="string"?Hd(e,t):function(i,r){Object.entries(i).forEach(s=>{let[o,a]=s;a!==void 0&&(r[o.toLowerCase()]=a)})}(e,t)),t}const Wd={stroke:"strokeOpacity",fill:"fillOpacity"};function di(n,t,e){if(!n)return{};let i,r={},s=ea;n.parentNode&&qa.test(n.parentNode.nodeName)&&(r=di(n.parentElement,t,e),r.fontSize&&(i=s=cr(r.fontSize)));const o=_(_(_({},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)Td(c,d.split(" "))&&(u=_(_({},u),h[d]));return u}(n,e)),$d(n));o[eo]&&n.setAttribute(eo,o[eo]),o[to]&&(i=cr(o[to],s),o[to]="".concat(i));const a={};for(const c in o){const h=Ed(c),u=zd(h,o[c],r,i);a[h]=u}a&&a.font&&Vd(a.font,a);const l=_(_({},r),a);return qa.test(n.nodeName)?l:function(c){const h=Yt.getDefaults();return Object.entries(Wd).forEach(u=>{let[d,p]=u;if(c[p]===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 f=new rt(c[d]);c[d]=f.setAlpha(ft(f.getAlpha()*c[p],2)).toRgba()}),c}(l)}const Gd=["left","top","width","height","visible"],Fc=["rx","ry"];class Rt extends Yt{static getDefaults(){return _(_({},super.getDefaults()),Rt.ownDefaults)}constructor(t){super(),Object.assign(this,Rt.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,r=-e/2,s=-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(r+o,s),t.lineTo(r+e-o,s),l&&t.bezierCurveTo(r+e-fi*o,s,r+e,s+fi*a,r+e,s+a),t.lineTo(r+e,s+i-a),l&&t.bezierCurveTo(r+e,s+i-fi*a,r+e-fi*o,s+i,r+e-o,s+i),t.lineTo(r+o,s+i),l&&t.bezierCurveTo(r+fi*o,s+i,r,s+i-fi*a,r,s+i-a),t.lineTo(r,s+a),l&&t.bezierCurveTo(r,s+fi*a,r+fi*o,s,r+o,s),t.closePath(),this._renderPaintInOrder(t)}toObject(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[];return super.toObject([...Fc,...t])}_toSVG(){const{width:t,height:e,rx:i,ry:r}=this;return["<rect ","COMMON_PARTS",'x="'.concat(-t/2,'" y="').concat(-e/2,'" rx="').concat(i,'" ry="').concat(r,'" width="').concat(t,'" height="').concat(e,`" />
127
- `)]}static async fromElement(t,e,i){const r=di(t,this.ATTRIBUTE_NAMES,i),{left:s=0,top:o=0,width:a=0,height:l=0,visible:c=!0}=r,h=ht(r,Gd);return new this(_(_(_({},e),h),{},{left:s,top:o,width:a,height:l,visible:!!(c&&a&&l)}))}}b(Rt,"type","Rect"),b(Rt,"cacheProperties",[...ui,...Fc]),b(Rt,"ownDefaults",{rx:0,ry:0}),b(Rt,"ATTRIBUTE_NAMES",[...Di,"x","y","rx","ry","width","height"]),R.setClass(Rt),R.setSVGClass(Rt);const Ze="initialization",_n="added",va="removed",yn="imperative",jc=(n,t)=>{const{strokeUniform:e,strokeWidth:i,width:r,height:s,group:o}=t,a=o&&o!==n?In(o.calcTransformMatrix(),n.calcTransformMatrix()):null,l=a?t.getRelativeCenterPoint().transform(a):t.getRelativeCenterPoint(),c=!t.isStrokeAccountedForInDimensions(),h=e&&c?Lu(new w(i,i),void 0,n.calcTransformMatrix()):sa,u=!e&&c?i:0,d=la(r+u,s+u,na([a,t.calcOwnMatrix()],!0)).add(h).scalarDivide(2);return[l.subtract(d),l.add(d)]};class jn{calcLayoutResult(t,e){if(this.shouldPerformLayout(t))return this.calcBoundingBox(e,t)}shouldPerformLayout(t){let{type:e,prevStrategy:i,strategy:r}=t;return e===Ze||e===yn||!!i&&r!==i}shouldLayoutClipPath(t){let{type:e,target:{clipPath:i}}=t;return e!==Ze&&i&&!i.absolutePositioned}getInitialSize(t,e){return e.size}calcBoundingBox(t,e){const{type:i,target:r}=e;if(i===yn&&e.overrides)return e.overrides;if(t.length===0)return;const{left:s,top:o,width:a,height:l}=ii(t.map(u=>jc(r,u)).reduce((u,d)=>u.concat(d),[])),c=new w(a,l),h=new w(s,o).add(c.scalarDivide(2));if(i===Ze){const u=this.getInitialSize(e,{size:c,center:h});return{center:h,relativeCorrection:new w(0,0),size:u}}return{center:h.transform(r.calcOwnMatrix()),size:c}}}b(jn,"type","strategy");class Po extends jn{shouldPerformLayout(t){return!0}}b(Po,"type","fit-content"),R.setClass(Po);const Ud=["strategy"],Yd=["target","strategy","bubbles","prevStrategy"],Rc="layoutManager";class Zr{constructor(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:new Po;b(this,"strategy",void 0),this.strategy=t,this._subscriptions=new Map}performLayout(t){const e=_(_({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[pn,nc,Yr,oc,Dn,ac,dn,_u,yu].map(r=>t.on(r,s=>this.performLayout(r===pn?{type:"object_modified",trigger:r,e:s,target:i}:{type:"object_modifying",trigger:r,e:s,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:r}=e;if(i===Ze||i===_n?this.subscribeTargets(t):i===va&&this.unsubscribeTargets(t),e.fire("layout:before",{context:t}),r&&r.fire("object:layout:before",{target:e,context:t}),i===yn&&t.deep){const s=ht(t,Ud);e.forEachObject(o=>o.layoutManager&&o.layoutManager.performLayout(_(_({},s),{},{bubbles:!1,target:o})))}}getLayoutResult(t){const{target:e,strategy:i,type:r}=t,s=i.calcLayoutResult(t,e.getObjects());if(!s)return;const o=r===Ze?new w:e.getRelativeCenterPoint(),{center:a,correction:l=new w,relativeCorrection:c=new w}=s,h=o.subtract(a).add(l).transform(r===Ze?Qt:ke(e.calcOwnMatrix()),!0).add(c);return{result:s,prevCenter:o,nextCenter:a,offset:h}}commitLayout(t,e){const{target:i}=t,{result:{size:r},nextCenter:s}=e;var o,a;i.set({width:r.x,height:r.y}),this.layoutObjects(t,e),t.type===Ze?i.set({left:(o=t.x)!==null&&o!==void 0?o:s.x+r.x*Dt(i.originX),top:(a=t.y)!==null&&a!==void 0?a:s.y+r.y*Dt(i.originY)}):(i.setPositionByOrigin(s,K,K),i.setCoords(),i.set("dirty",!0))}layoutObjects(t,e){const{target:i}=t;i.forEachObject(r=>{r.group===i&&this.layoutObject(t,e,r)}),t.strategy.shouldLayoutClipPath(t)&&this.layoutObject(t,e,i.clipPath)}layoutObject(t,e,i){let{offset:r}=e;i.set({left:i.left+r.x,top:i.top+r.y})}onAfterLayout(t,e){const{target:i,strategy:r,bubbles:s,prevStrategy:o}=t,a=ht(t,Yd),{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;s&&c!=null&&c.layoutManager&&((a.path||(a.path=[])).push(i),c.layoutManager.performLayout(_(_({},a),{},{target:c}))),i.set("dirty",!0)}dispose(){const{_subscriptions:t}=this;t.forEach(e=>e.forEach(i=>i())),t.clear()}toObject(){return{type:Rc,strategy:this.strategy.constructor.type}}toJSON(){return this.toObject()}}R.setClass(Zr,Rc);const Xd=["type","objects","layoutManager"];class Kd extends Zr{performLayout(){}}class _i extends lc(Yt){static getDefaults(){return _(_({},super.getDefaults()),_i.ownDefaults)}constructor(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[],e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};super(),b(this,"_activeObjects",[]),b(this,"__objectSelectionTracker",void 0),b(this,"__objectSelectionDisposer",void 0),Object.assign(this,_i.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(r=>{this.enterGroup(r,!1)}),this.layoutManager=(i=e.layoutManager)!==null&&i!==void 0?i:new Zr,this.layoutManager.performLayout({type:Ze,target:this,targets:[...t],x:e.left,y:e.top})}canEnterGroup(t){return t===this||this.isDescendantOf(t)?(yi("error","Group: circular object trees are not supported, this call has no effect"),!1):this._objects.indexOf(t)===-1||(yi("error","Group: duplicate objects are not supported inside group, this call has no effect"),!1)}_filterObjectsBeforeEnteringGroup(t){return t.filter((e,i,r)=>this.canEnterGroup(e)&&r.indexOf(e)===i)}add(){for(var t=arguments.length,e=new Array(t),i=0;i<t;i++)e[i]=arguments[i];const r=this._filterObjectsBeforeEnteringGroup(e),s=super.add(...r);return this._onAfterObjectsChange(_n,r),s}insertAt(t){for(var e=arguments.length,i=new Array(e>1?e-1:0),r=1;r<e;r++)i[r-1]=arguments[r];const s=this._filterObjectsBeforeEnteringGroup(i),o=super.insertAt(t,...s);return this._onAfterObjectsChange(_n,s),o}remove(){const t=super.remove(...arguments);return this._onAfterObjectsChange(va,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(r=>{r._set(t,e)}),this}_shouldSetNestedCoords(){return this.subTargetCheck}removeAll(){return this._activeObjects=[],this.remove(...this._objects)}__objectSelectionMonitor(t,e){let{target:i}=e;const r=this._activeObjects;if(t)r.push(i),this._set("dirty",!0);else if(r.length>0){const s=r.indexOf(i);s>-1&&(r.splice(s,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&&vn(t,Ht(ke(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||(vn(t,Ht(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=Yt.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 s=0;s<this._objects.length;s++){var r;const o=this._objects[s];(r=this.canvas)!==null&&r!==void 0&&r.preserveObjectStacking&&o.group!==this?(t.save(),t.transform(...ke(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(_({target:this,type:yn},t))}render(t){this._transformDone=!0,super.render(t),this._transformDone=!1}__serializeObjects(t,e){const i=this.includeDefaultValues;return this._objects.filter(function(r){return!r.excludeFromExport}).map(function(r){const s=r.includeDefaultValues;r.includeDefaultValues=i;const o=r[t||"toObject"](e);return r.includeDefaultValues=s,o})}toObject(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[];const e=this.layoutManager.toObject();return _(_(_({},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=Rt.prototype._toSVG.call(this),i=e.indexOf("COMMON_PARTS");e[i]='for="group" ';const r=e.join("");return t?t(r):r}_toSVG(t){const e=["<g ","COMMON_PARTS",` >
128
- `],i=this._createSVGBgRect(t);i&&e.push(" ",i);for(let r=0;r<this._objects.length;r++)e.push(" ",this._objects[r].toSVG(t));return e.push(`</g>
129
- `),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 r=0;r<this._objects.length;r++)e.push(" ",this._objects[r].toClipPathSVG(t));return this._createBaseClipPathSVGMarkup(e,{reviver:t})}static fromObject(t,e){let{type:i,objects:r=[],layoutManager:s}=t,o=ht(t,Xd);return Promise.all([Xr(r,e),Mn(o,e)]).then(a=>{let[l,c]=a;const h=new this(l,_(_(_({},o),c),{},{layoutManager:new Kd}));if(s){const u=R.getClass(s.type),d=R.getClass(s.strategy);h.layoutManager=new u(new d)}else h.layoutManager=new Zr;return h.layoutManager.subscribeTargets({type:Ze,target:h,targets:h.getObjects()}),h.setCoords(),h})}}b(_i,"type","Group"),b(_i,"ownDefaults",{strokeWidth:0,subTargetCheck:!1,interactive:!1}),R.setClass(_i);const qd=(n,t)=>Math.min(t.width/n.width,t.height/n.height),Zd=(n,t)=>Math.max(t.width/n.width,t.height/n.height),Ao="\\s*,?\\s*",Dr="".concat(Ao,"(").concat(Gi,")"),Jd="".concat(Dr).concat(Dr).concat(Dr).concat(Ao,"([01])").concat(Ao,"([01])").concat(Dr).concat(Dr),Qd={m:"l",M:"L"},tp=(n,t,e,i,r,s,o,a,l,c,h)=>{const u=oi(n),d=ai(n),p=oi(t),f=ai(t),g=e*r*p-i*s*f+o,m=i*r*p+e*s*f+a;return["C",c+l*(-e*r*d-i*s*u),h+l*(-i*r*d+e*s*u),g+l*(e*r*f+i*s*p),m+l*(i*r*f-e*s*p),g,m]},dl=(n,t,e,i)=>{const r=Math.atan2(t,n),s=Math.atan2(i,e);return s>=r?s-r:2*Math.PI-(r-s)};function pl(n,t,e,i,r,s,o,a){let l;if(Q.cachesBoundsOfCurve&&(l=[...arguments].join(),zr.boundsOfCurveCache[l]))return zr.boundsOfCurveCache[l];const c=Math.sqrt,h=Math.abs,u=[],d=[[0,0],[0,0]];let p=6*n-12*e+6*r,f=-3*n+9*e-9*r+3*o,g=3*e-3*n;for(let T=0;T<2;++T){if(T>0&&(p=6*t-12*i+6*s,f=-3*t+9*i-9*s+3*a,g=3*i-3*t),h(f)<1e-12){if(h(p)<1e-12)continue;const F=-g/p;0<F&&F<1&&u.push(F);continue}const E=p*p-4*g*f;if(E<0)continue;const A=c(E),C=(-p+A)/(2*f);0<C&&C<1&&u.push(C);const S=(-p-A)/(2*f);0<S&&S<1&&u.push(S)}let m=u.length;const v=m,y=Bc(n,t,e,i,r,s,o,a);for(;m--;){const{x:T,y:E}=y(u[m]);d[0][m]=T,d[1][m]=E}d[0][v]=n,d[1][v]=t,d[0][v+1]=o,d[1][v+1]=a;const x=[new w(Math.min(...d[0]),Math.min(...d[1])),new w(Math.max(...d[0]),Math.max(...d[1]))];return Q.cachesBoundsOfCurve&&(zr.boundsOfCurveCache[l]=x),x}const ep=(n,t,e)=>{let[i,r,s,o,a,l,c,h]=e;const u=((d,p,f,g,m,v,y)=>{if(f===0||g===0)return[];let x=0,T=0,E=0;const A=Math.PI,C=y*ta,S=ai(C),F=oi(C),j=.5*(-F*d-S*p),D=.5*(-F*p+S*d),k=f**2,P=g**2,L=D**2,V=j**2,Y=k*P-k*L-P*V;let Z=Math.abs(f),B=Math.abs(g);if(Y<0){const lt=Math.sqrt(1-Y/(k*P));Z*=lt,B*=lt}else E=(m===v?-1:1)*Math.sqrt(Y/(k*L+P*V));const N=E*Z*D/B,M=-E*B*j/Z,H=F*N-S*M+.5*d,J=S*N+F*M+.5*p;let bt=dl(1,0,(j-N)/Z,(D-M)/B),nt=dl((j-N)/Z,(D-M)/B,(-j-N)/Z,(-D-M)/B);v===0&&nt>0?nt-=2*A:v===1&&nt<0&&(nt+=2*A);const he=Math.ceil(Math.abs(nt/A*2)),I=[],tt=nt/he,$t=8/3*Math.sin(tt/4)*Math.sin(tt/4)/Math.sin(tt/2);let at=bt+tt;for(let lt=0;lt<he;lt++)I[lt]=tp(bt,at,F,S,Z,B,H,J,$t,x,T),x=I[lt][5],T=I[lt][6],bt=at,at+=tt;return I})(c-n,h-t,r,s,a,l,o);for(let d=0,p=u.length;d<p;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},ip=n=>{let t=0,e=0,i=0,r=0;const s=[];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],r=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":ep(t,e,h).forEach(d=>s.push(d)),t=h[6],e=h[7];break;case"z":case"Z":t=i,e=r,u=["Z"]}u?(s.push(u),o=u[0]):o=""}return s},xn=(n,t,e,i)=>Math.sqrt((e-n)**2+(i-t)**2),Bc=(n,t,e,i,r,s,o,a)=>l=>{const c=l**3,h=(p=>3*p**2*(1-p))(l),u=(p=>3*p*(1-p)**2)(l),d=(p=>(1-p)**3)(l);return new w(o*c+r*h+e*u+n*d,a*c+s*h+i*u+t*d)},Nc=n=>n**2,zc=n=>2*n*(1-n),Vc=n=>(1-n)**2,rp=(n,t,e,i,r,s,o,a)=>l=>{const c=Nc(l),h=zc(l),u=Vc(l),d=3*(u*(e-n)+h*(r-e)+c*(o-r)),p=3*(u*(i-t)+h*(s-i)+c*(a-s));return Math.atan2(p,d)},sp=(n,t,e,i,r,s)=>o=>{const a=Nc(o),l=zc(o),c=Vc(o);return new w(r*a+e*l+n*c,s*a+i*l+t*c)},np=(n,t,e,i,r,s)=>o=>{const a=1-o,l=2*(a*(e-n)+o*(r-e)),c=2*(a*(i-t)+o*(s-i));return Math.atan2(c,l)},fl=(n,t,e)=>{let i=new w(t,e),r=0;for(let s=1;s<=100;s+=1){const o=n(s/100);r+=xn(i.x,i.y,o.x,o.y),i=o}return r},op=(n,t)=>{let e,i=0,r=0,s={x:n.x,y:n.y},o=_({},s),a=.01,l=0;const c=n.iterator,h=n.angleFinder;for(;r<t&&a>1e-4;)o=c(i),l=i,e=xn(s.x,s.y,o.x,o.y),e+r>t?(i-=a,a/=2):(s=o,i+=a,r+=e);return _(_({},o),{},{angle:h(l)})},Hc=n=>{let t,e,i=0,r=0,s=0,o=0,a=0;const l=[];for(const c of n){const h={x:r,y:s,command:c[0],length:0};switch(c[0]){case"M":e=h,e.x=o=r=c[1],e.y=a=s=c[2];break;case"L":e=h,e.length=xn(r,s,c[1],c[2]),r=c[1],s=c[2];break;case"C":t=Bc(r,s,c[1],c[2],c[3],c[4],c[5],c[6]),e=h,e.iterator=t,e.angleFinder=rp(r,s,c[1],c[2],c[3],c[4],c[5],c[6]),e.length=fl(t,r,s),r=c[5],s=c[6];break;case"Q":t=sp(r,s,c[1],c[2],c[3],c[4]),e=h,e.iterator=t,e.angleFinder=np(r,s,c[1],c[2],c[3],c[4]),e.length=fl(t,r,s),r=c[3],s=c[4];break;case"Z":e=h,e.destX=o,e.destY=a,e.length=xn(r,s,o,a),r=o,s=a}i+=e.length,l.push(e)}return l.push({length:i,x:r,y:s}),l},ap=function(n,t){let e=arguments.length>2&&arguments[2]!==void 0?arguments[2]:Hc(n),i=0;for(;t-e[i].length>0&&i<e.length-2;)t-=e[i].length,i++;const r=e[i],s=t/r.length,o=n[i];switch(r.command){case"M":return{x:r.x,y:r.y,angle:0};case"Z":return _(_({},new w(r.x,r.y).lerp(new w(r.destX,r.destY),s)),{},{angle:Math.atan2(r.destY-r.y,r.destX-r.x)});case"L":return _(_({},new w(r.x,r.y).lerp(new w(o[1],o[2]),s)),{},{angle:Math.atan2(o[2]-r.y,o[1]-r.x)});case"C":case"Q":return op(r,t)}},lp=new RegExp("[mzlhvcsqta][^mzlhvcsqta]*","gi"),gl=new RegExp(Jd,"g"),cp=new RegExp(Gi,"gi"),hp={m:2,l:2,h:1,v:1,c:6,s:4,q:4,t:2,a:7},up=n=>{var t;const e=[],i=(t=n.match(lp))!==null&&t!==void 0?t:[];for(const r of i){const s=r[0];if(s==="z"||s==="Z"){e.push([s]);continue}const o=hp[s.toLowerCase()];let a=[];if(s==="a"||s==="A"){gl.lastIndex=0;for(let l=null;l=gl.exec(r);)a.push(...l.slice(1))}else a=r.match(cp)||[];for(let l=0;l<a.length;l+=o){const c=new Array(o),h=Qd[s];c[0]=l>0&&h?h:s;for(let u=0;u<o;u++)c[u+1]=parseFloat(a[l+u]);e.push(c)}}return e},dp=(n,t)=>n.map(e=>e.map((i,r)=>r===0||t===void 0?i:ft(i,t)).join(" ")).join(" ");function Mo(n,t){const e=n.style;e&&t&&(typeof t=="string"?e.cssText+=";"+t:Object.entries(t).forEach(i=>{let[r,s]=i;return e.setProperty(r,s)}))}class pp extends bc{constructor(t){let{allowTouchScrolling:e=!1,containerClass:i=""}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};super(t),b(this,"upper",void 0),b(this,"container",void 0);const{el:r}=this.lower,s=this.createUpperCanvas();this.upper={el:s,ctx:s.getContext("2d")},this.applyCanvasStyle(r,{allowTouchScrolling:e}),this.applyCanvasStyle(s,{allowTouchScrolling:e,styles:{position:"absolute",left:"0",top:"0"}});const o=this.createContainerElement();o.classList.add(i),r.parentNode&&r.parentNode.replaceChild(o,r),o.append(r,s),this.container=o}createUpperCanvas(){const{el:t}=this.lower,e=Ae();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=vr().createElement("div");return t.setAttribute("data-fabric","wrapper"),Mo(t,{position:"relative"}),Ya(t),t}applyCanvasStyle(t,e){const{styles:i,allowTouchScrolling:r}=e;Mo(t,_(_({},i),{},{"touch-action":r?"manipulation":oe})),Ya(t)}setDimensions(t,e){super.setDimensions(t,e);const{el:i,ctx:r}=this.upper;vc(i,r,t,e)}setCSSDimensions(t){super.setCSSDimensions(t),Co(this.upper.el,t),Co(this.container,t)}cleanupDOM(t){const e=this.container,{el:i}=this.lower,{el:r}=this.upper;super.cleanupDOM(t),e.removeChild(r),e.removeChild(i),e.parentNode&&e.parentNode.replaceChild(i,e)}dispose(){super.dispose(),Be().dispose(this.upper.el),delete this.upper,delete this.container}}class Rn extends ds{constructor(){super(...arguments),b(this,"targets",[]),b(this,"_hoveredTargets",[]),b(this,"_objectsToRender",void 0),b(this,"_currentTransform",null),b(this,"_groupSelector",null),b(this,"contextTopDirty",!1)}static getDefaults(){return _(_({},super.getDefaults()),Rn.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 pp(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 r=this.targetFindTolerance,s=this.pixelFindContext;this.clearContext(s),s.save(),s.translate(-e+r,-i+r),s.transform(...this.viewportTransform);const o=t.selectionBackgroundColor;t.selectionBackgroundColor="",t.render(s),t.selectionBackgroundColor=o,s.restore();const a=Math.round(r*this.getRetinaScaling());return bd(s,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(),r=this._activeObject;return!!(!e||e&&r&&i.length>1&&i.indexOf(e)===-1&&r!==e&&!this._isSelectionKeyPressed(t)||e&&!e.evented||e&&!e.selectable&&r&&r!==e)}_shouldCenterTransform(t,e,i){if(!t)return;let r;return e===Pn||e===le||e===xe||e===Yr?r=this.centeredScaling||t.centeredScaling:e===ra&&(r=this.centeredRotation||t.centeredRotation),r?!i:i}_getOriginFromCorner(t,e){const i={x:t.originX,y:t.originY};return e&&(["ml","tl","bl"].includes(e)?i.x=xt:["mr","tr","br"].includes(e)&&(i.x=it),["tl","mt","tr"].includes(e)?i.y=wo:["bl","mb","br"].includes(e)&&(i.y=ne)),i}_setupCurrentTransform(t,e,i){var r;const s=e.group?hr(this.getScenePoint(t),void 0,e.group.calcTransformMatrix()):this.getScenePoint(t),{key:o="",control:a}=e.getActiveControl()||{},l=i&&a?(r=a.getActionHandler(t,e,a))===null||r===void 0?void 0:r.bind(a):Ru,c=((p,f,g,m)=>{if(!f||!p)return"drag";const v=m.controls[f];return v.getActionName(g,v,m)})(i,o,t,e),h=t[this.centeredKey],u=this._shouldCenterTransform(e,c,h)?{x:K,y:K}: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:s.x-e.left,offsetY:s.y-e.top,originX:u.x,originY:u.y,ex:s.x,ey:s.y,lastX:s.x,lastY:s.y,theta:Ct(e.angle),width:e.width,height:e.height,shiftKey:t.shiftKey,altKey:h,original:_(_({},_c(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:r,deltaY:s}=this._groupSelector,o=new w(e,i).transform(this.viewportTransform),a=new w(e+r,i+s).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,Yt.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,r=this.getActiveObjects();if(this.targets=[],i&&r.length>=1){if(i.findControl(e,So(t))||r.length>1&&this.searchPossibleTargets([i],e))return i;if(i===this.searchPossibleTargets([i],e)){if(this.preserveObjectStacking){const s=this.targets;this.targets=[];const o=this.searchPossibleTargets(this._objects,e);return t[this.altSelectionKey]&&o&&o!==i?(this.targets=s,i):o}return i}}return this.searchPossibleTargets(this._objects,e)}_pointIsInObjectSelectionArea(t,e){let i=t.getCoords();const r=this.getZoom(),s=t.padding/r;if(s){const[o,a,l,c]=i,h=Math.atan2(a.y-o.y,a.x-o.x),u=oi(h)*s,d=ai(h)*s,p=u+d,f=u-d;i=[new w(o.x-f,o.y-p),new w(a.x+p,a.y-f),new w(l.x+f,l.y+p),new w(c.x-p,c.y+f)]}return pt.isPointInPolygon(e,i)}_checkTarget(t,e){return!!(t&&t.visible&&t.evented&&this._pointIsInObjectSelectionArea(t,hr(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 r=t[i];if(this._checkTarget(r,e)){if(en(r)&&r.subTargetCheck){const s=this._searchPossibleTargets(r._objects,e);s&&this.targets.push(s)}return r}}}searchPossibleTargets(t,e){const i=this._searchPossibleTargets(t,e);if(i&&en(i)&&i.interactive&&this.targets[0]){const r=this.targets;for(let s=r.length-1;s>0;s--){const o=r[s];if(!en(o)||!o.interactive)return o}return r[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,r=i.getBoundingClientRect();let s=Pu(t),o=r.width||0,a=r.height||0;o&&a||(ne in r&&wo in r&&(a=Math.abs(r.top-r.bottom)),xt in r&&it in r&&(o=Math.abs(r.right-r.left))),this.calcOffset(),s.x=s.x-this._offset.left,s.y=s.y-this._offset.top,e||(s=hr(s,void 0,this.viewportTransform));const l=this.getRetinaScaling();l!==1&&(s.x/=l,s.y/=l);const c=o===0||a===0?new w(1,1):new w(i.width/o,i.height/a);return s.multiply(c)}_setDimensionsImpl(t,e){this._resetTransformEventData(),super._setDimensionsImpl(t,e),this._isCurrentlyDrawing&&this.freeDrawingBrush&&this.freeDrawingBrush._setBrushStyles(this.contextTop)}_createCacheCanvas(){this.pixelFindCanvasEl=Ae(),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 ji(t)?t.getObjects():t?[t]:[]}_fireSelectionEvents(t,e){let i=!1,r=!1;const s=this.getActiveObjects(),o=[],a=[];t.forEach(l=>{s.includes(l)||(i=!0,l.fire("deselected",{e,target:l}),a.push(l))}),s.forEach(l=>{t.includes(l)||(i=!0,l.fire("selected",{e,target:l}),o.push(l))}),t.length>0&&s.length>0?(r=!0,i&&this.fire("selection:updated",{e,selected:o,deselected:a})):s.length>0?(r=!0,this.fire("selection:created",{e,selected:o})):t.length>0&&(r=!0,this.fire("selection:cleared",{e,deselected:a})),r&&(this._objectsToRender=void 0)}setActiveObject(t,e){const i=this.getActiveObjects(),r=this._setActiveObject(t,e);return this._fireSelectionEvents(i,e),r}_setActiveObject(t,e){const i=this._activeObject;return i!==t&&!(!this._discardActiveObject(e,t)&&this._activeObject)&&!t.onSelect({e})&&(this._activeObject=t,ji(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),ji(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 r=this._discardActiveObject(t);return this._fireSelectionEvents(e,t),r}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,r={e:t,target:i,transform:e,action:e.action};i._scaling&&(i._scaling=!1),i.setCoords(),e.actionPerformed&&(this.fire("object:modified",r),i.fire(pn,r))}setViewportTransform(t){super.setViewportTransform(t);const e=this._activeObject;e&&e.setCoords()}destroy(){const t=this._activeObject;ji(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 r=this._realizeGroupTransformOnObject(t),s=super._toObject(t,e,i);return t.set(r),s}_realizeGroupTransformOnObject(t){const{group:e}=t;if(e&&ji(e)&&this._activeObject===e){const i=yr(t,["angle","flipX","flipY",it,le,xe,br,_r,ne]);return Mu(t,e.calcOwnMatrix()),i}return{}}_setSVGObject(t,e,i){const r=this._realizeGroupTransformOnObject(e);super._setSVGObject(t,e,i),e.set(r)}}b(Rn,"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 fp{constructor(t){b(this,"targets",[]),b(this,"__disposer",void 0);const e=()=>{const{hiddenTextarea:r}=t.getActiveObject()||{};r&&r.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),tr(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 gp=["target","oldTarget","fireCanvas","e"],ue={passive:!1},Qi=(n,t)=>{const e=n.getViewportPoint(t),i=n.getScenePoint(t);return{viewportPoint:e,scenePoint:i,pointer:e,absolutePointer:i}},gi=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)},ve=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)},mp={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 Jr extends Rn{constructor(t){super(t,arguments.length>1&&arguments[1]!==void 0?arguments[1]:{}),b(this,"_isClick",void 0),b(this,"textEditingManager",new fp(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(gi,"add")}_getEventPrefix(){return this.enablePointerEvents?"pointer":"mouse"}addOrRemove(t,e){const i=this.upperCanvasEl,r=this._getEventPrefix();t(mc(i),"resize",this._onResize),t(i,r+"down",this._onMouseDown),t(i,"".concat(r,"move"),this._onMouseMove,ue),t(i,"".concat(r,"out"),this._onMouseOut),t(i,"".concat(r,"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,ue)}removeListeners(){this.addOrRemove(ve,"remove");const t=this._getEventPrefix(),e=Oe(this.upperCanvasEl);ve(e,"".concat(t,"up"),this._onMouseUp),ve(e,"touchend",this._onTouchEnd,ue),ve(e,"".concat(t,"move"),this._onMouseMove,ue),ve(e,"touchmove",this._onMouseMove,ue),clearTimeout(this._willAddMouseDown)}_onMouseWheel(t){this.__onMouseWheel(t)}_onMouseOut(t){const e=this._hoveredTarget,i=_({e:t},Qi(this,t));this.fire("mouse:out",_(_({},i),{},{target:e})),this._hoveredTarget=void 0,e&&e.fire("mouseout",_({},i)),this._hoveredTargets.forEach(r=>{this.fire("mouse:out",_(_({},i),{},{target:r})),r&&r.fire("mouseout",_({},i))}),this._hoveredTargets=[]}_onMouseEnter(t){this._currentTransform||this.findTarget(t)||(this.fire("mouse:over",_({e:t},Qi(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 gi(this.upperCanvasEl,"drag",this._onDragProgress)}To(t)}_renderDragEffects(t,e,i){let r=!1;const s=this._dropTarget;s&&s!==e&&s!==i&&(s.clearContextTop(),r=!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(),r=!0),i&&(o.save(),i.transform(o),i.renderDropTargetEffect(t),o.restore(),r=!0),o.restore(),r&&(this.contextTopDirty=!0)}_onDragEnd(t){const e=!!t.dataTransfer&&t.dataTransfer.dropEffect!==oe,i=e?this._activeObject:void 0,r={e:t,target:this._dragSource,subTargets:this.targets,dragSource:this._dragSource,didDrop:e,dropTarget:i};ve(this.upperCanvasEl,"drag",this._onDragProgress),this.fire("dragend",r),this._dragSource&&this._dragSource.fire("dragend",r),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:r}=this.findDragTargets(t),s=this._dragSource,o={e:t,target:i,subTargets:r,dragSource:s,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<r.length;l++){const c=r[l];c.canDrop(t)&&(a=c),c.fire(e,o)}this._renderDragEffects(t,s,a),this._dropTarget=a}_onDragEnter(t){const{target:e,targets:i}=this.findDragTargets(t),r={e:t,target:e,subTargets:i,dragSource:this._dragSource};this.fire("dragenter",r),this._fireEnterLeaveEvents(e,r)}_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),r=this._basicEventHandler("drop:before",_({e:t,target:e,subTargets:i,dragSource:this._dragSource},Qi(this,t)));r.didDrop=!1,r.dropTarget=void 0,this._basicEventHandler("drop",r),this.fire("drop:after",r)}_onContextMenu(t){const e=this.findTarget(t),i=this.targets||[],r=this._basicEventHandler("contextmenu:before",{e:t,target:e,subTargets:i});return this.stopContextMenu&&To(t),this._basicEventHandler("contextmenu",r),!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 r=this.upperCanvasEl,s=this._getEventPrefix(),o=Oe(r);gi(o,"touchend",this._onTouchEnd,ue),e&&gi(o,"touchmove",this._onMouseMove,ue),ve(r,"".concat(s,"down"),this._onMouseDown)}_onMouseDown(t){this.__onMouseDown(t),this._resetTransformEventData();const e=this.upperCanvasEl,i=this._getEventPrefix();ve(e,"".concat(i,"move"),this._onMouseMove,ue);const r=Oe(e);gi(r,"".concat(i,"up"),this._onMouseUp),gi(r,"".concat(i,"move"),this._onMouseMove,ue)}_onTouchEnd(t){if(t.touches.length>0)return;this.__onMouseUp(t),this._resetTransformEventData(),delete this.mainTouchId;const e=this._getEventPrefix(),i=Oe(this.upperCanvasEl);ve(i,"touchend",this._onTouchEnd,ue),ve(i,"touchmove",this._onMouseMove,ue),this._willAddMouseDown&&clearTimeout(this._willAddMouseDown),this._willAddMouseDown=setTimeout(()=>{gi(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 r=Oe(this.upperCanvasEl);ve(r,"".concat(i,"up"),this._onMouseUp),ve(r,"".concat(i,"move"),this._onMouseMove,ue),gi(e,"".concat(i,"move"),this._onMouseMove,ue)}}_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,r=this._isClick,s=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),!r){const h=s===this._activeObject;this.handleSelection(t),c||(c=this._shouldRender(s)||!h&&s===this._activeObject)}if(s){const h=s.findControl(this.getViewportPoint(t),So(t)),{key:u,control:d}=h||{};if(l=u,s.selectable&&s!==this._activeObject&&s.activeOn==="up")this.setActiveObject(s,t),c=!0;else if(d){const p=d.getMouseUpHandler(t,s,d);p&&(a=this.getScenePoint(t),p.call(d,t,i,a.x,a.y))}s.isMoving=!1}if(i&&(i.target!==s||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,s),this._handleEvent(t,"up"),this._groupSelector=null,this._currentTransform=null,s&&(s.__corner=void 0),c?this.requestRenderAll():r||(e=this._activeObject)!==null&&e!==void 0&&e.isEditing||this.renderTop()}_basicEventHandler(t,e){const{target:i,subTargets:r=[]}=e;this.fire(t,e),i&&i.fire(t,e);for(let s=0;s<r.length;s++)r[s]!==i&&r[s].fire(t,e);return e}_handleEvent(t,e){const i=this._target,r=this.targets||[],s=_(_({e:t,target:i,subTargets:r},Qi(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),s),i&&i.fire("mouse".concat(e),s);for(let o=0;o<r.length;o++)r[o]!==i&&r[o].fire("mouse".concat(e),s)}_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 r=this._shouldRender(e),s=!1;if(this.handleMultiSelection(t,e)?(e=this._activeObject,s=!0,r=!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),So(t));if(e===this._activeObject&&(a||!s)){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)}}r&&(this._objectsToRender=void 0),this._handleEvent(t,"down"),r&&this.requestRenderAll()}_resetTransformEventData(){this._target=this._pointer=this._absolutePointer=void 0}_cacheTransformEventData(t){this._resetTransformEventData(),this._pointer=this.getViewportPoint(t),this._absolutePointer=hr(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,r=this._hoveredTargets,s=this.targets,o=Math.max(r.length,s.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:s[a],oldTarget:r[a]});this._hoveredTarget=e,this._hoveredTargets=this.targets.concat()}_fireEnterLeaveEvents(t,e){const i=this._draggedoverTarget,r=this._hoveredTargets,s=this.targets,o=Math.max(r.length,s.length);this.fireSyntheticInOutEvents("drag",_(_({},e),{},{target:t,oldTarget:i,fireCanvas:!0}));for(let a=0;a<o;a++)this.fireSyntheticInOutEvents("drag",_(_({},e),{},{target:s[a],oldTarget:r[a]}));this._draggedoverTarget=t}fireSyntheticInOutEvents(t,e){let{target:i,oldTarget:r,fireCanvas:s,e:o}=e,a=ht(e,gp);const{targetIn:l,targetOut:c,canvasIn:h,canvasOut:u}=mp[t],d=r!==i;if(r&&d){const p=_(_({},a),{},{e:o,target:r,nextTarget:i},Qi(this,o));s&&this.fire(u,p),r.fire(c,p)}if(i&&d){const p=_(_({},a),{},{e:o,target:i,previousTarget:r},Qi(this,o));s&&this.fire(h,p),i.fire(l,p)}}__onMouseWheel(t){this._cacheTransformEventData(t),this._handleEvent(t,"wheel"),this._resetTransformEventData()}_transformObject(t){const e=this.getScenePoint(t),i=this._currentTransform,r=i.target,s=r.group?hr(e,void 0,r.group.calcTransformMatrix()):e;i.shiftKey=t.shiftKey,i.altKey=!!this.centeredKey&&t[this.centeredKey],this._performTransformAction(t,i,s),i.actionPerformed&&this.requestRenderAll()}_performTransformAction(t,e,i){const{action:r,actionHandler:s,target:o}=e,a=!!s&&s(t,e,i.x,i.y);a&&o.setCoords(),r==="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 r=ji(this._activeObject)?this._activeObject:null,s=(!r||e.group!==r)&&e.findControl(this.getViewportPoint(t));if(s){const o=s.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,r=ji(i);if(i&&this._isSelectionKeyPressed(t)&&this.selection&&e&&e.selectable&&(i!==e||r)&&(r||!e.isDescendantOf(i)&&!i.isDescendantOf(e))&&!e.onSelect({e:t})&&!i.getActiveControl()){if(r){const s=i.getObjects();if(e===i){const o=this.getViewportPoint(t);if(!(e=this.searchPossibleTargets(s,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(s,t)}else{i.isEditing&&i.exitEditing();const s=new(R.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:r,deltaY:s}=this._groupSelector,o=new w(e,i),a=o.add(new w(r,s)),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=R.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 $c={x1:0,y1:0,x2:0,y2:0},vp=_(_({},$c),{},{r1:0,r2:0}),sr=(n,t)=>isNaN(n)&&typeof t=="number"?t:n,bp=/^(\d+\.\d+)%|(\d+)%$/;function Wc(n){return n&&bp.test(n)}function Gc(n,t){const e=typeof n=="number"?n:typeof n=="string"?parseFloat(n)/(Wc(n)?100:1):NaN;return fr(0,sr(e,t),1)}const _p=/\s*;\s*/,yp=/\s*:\s*/;function xp(n,t){let e,i;const r=n.getAttribute("style");if(r){const o=r.split(_p);o[o.length-1]===""&&o.pop();for(let a=o.length;a--;){const[l,c]=o[a].split(yp).map(h=>h.trim());l==="stop-color"?e=c:l==="stop-opacity"&&(i=c)}}const s=new rt(e||n.getAttribute("stop-color")||"rgb(0,0,0)");return{offset:Gc(n.getAttribute("offset"),0),color:s.toRgb(),opacity:sr(parseFloat(i||n.getAttribute("stop-opacity")||""),1)*s.getAlpha()*t}}function wp(n,t){const e=[],i=n.getElementsByTagName("stop"),r=Gc(t,1);for(let s=i.length;s--;)e.push(xp(i[s],r));return e}function Uc(n){return n.nodeName==="linearGradient"||n.nodeName==="LINEARGRADIENT"?"linear":"radial"}function Yc(n){return n.getAttribute("gradientUnits")==="userSpaceOnUse"?"pixels":"percentage"}function Ce(n,t){return n.getAttribute(t)}function Cp(n,t){return function(e,i){let r,{width:s,height:o,gradientUnits:a}=i;return Object.keys(e).reduce((l,c)=>{const h=e[c];return h==="Infinity"?r=1:h==="-Infinity"?r=0:(r=typeof h=="string"?parseFloat(h):h,typeof h=="string"&&Wc(h)&&(r*=.01,a==="pixels"&&(c!=="x1"&&c!=="x2"&&c!=="r2"||(r*=s),c!=="y1"&&c!=="y2"||(r*=o)))),l[c]=r,l},{})}(Uc(n)==="linear"?function(e){return{x1:Ce(e,"x1")||0,y1:Ce(e,"y1")||0,x2:Ce(e,"x2")||"100%",y2:Ce(e,"y2")||0}}(n):function(e){return{x1:Ce(e,"fx")||Ce(e,"cx")||"50%",y1:Ce(e,"fy")||Ce(e,"cy")||"50%",r1:0,x2:Ce(e,"cx")||"50%",y2:Ce(e,"cy")||"50%",r2:Ce(e,"r")||"50%"}}(n),_(_({},t),{},{gradientUnits:Yc(n)}))}class ks{constructor(t){const{type:e="linear",gradientUnits:i="pixels",coords:r={},colorStops:s=[],offsetX:o=0,offsetY:a=0,gradientTransform:l,id:c}=t||{};Object.assign(this,{type:e,gradientUnits:i,coords:_(_({},e==="radial"?vp:$c),r),colorStops:s,offsetX:o,offsetY:a,gradientTransform:l,id:c?"".concat(c,"_").concat(xi()):xi()})}addColorStop(t){for(const e in t){const i=new rt(t[e]);this.colorStops.push({offset:parseFloat(e),color:i.toRgb(),opacity:i.getAlpha()})}return this}toObject(t){return _(_({},yr(this,t)),{},{type:this.type,coords:_({},this.coords),colorStops:this.colorStops.map(e=>_({},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=[],r=this.gradientTransform?this.gradientTransform.concat():Qt.concat(),s=this.gradientUnits==="pixels"?"userSpaceOnUse":"objectBoundingBox",o=this.colorStops.map(u=>_({},u)).sort((u,d)=>u.offset-d.offset);let a=-this.offsetX,l=-this.offsetY;var c;s==="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),r[4]-=a,r[5]-=l;const h=['id="SVGID_'.concat(this.id,'"'),'gradientUnits="'.concat(s,'"'),'gradientTransform="'.concat(e?e+" ":"").concat(mn(r),'"'),""].join(" ");if(this.type==="linear"){const{x1:u,y1:d,x2:p,y2:f}=this.coords;i.push("<linearGradient ",h,' x1="',u,'" y1="',d,'" x2="',p,'" y2="',f,`">
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=ci.ownDefaults;return this.includeDefaultValues?t:Ra(t,(i,s)=>i!==e[s])}static async fromObject(t){return new this(t)}}b(ci,"ownDefaults",{color:"rgb(0,0,0)",blur:0,offsetX:0,offsetY:0,affectStroke:!1,includeDefaultValues:!0,nonScaling:!1}),b(ci,"type","shadow"),R.setClass(ci,"shadow");const ks=(n,t,e)=>Math.max(n,Math.min(t,e)),tp=[le,it,ue,Te,"flipX","flipY","originX","originY","angle","opacity","globalCompositeOperation","shadow","visible",Ms,Is],mi=[Ft,he,"strokeWidth","strokeDashArray","width","height","paintFirst","strokeUniform","strokeLineCap","strokeDashOffset","strokeLineJoin","strokeMiterLimit","backgroundColor","clipPath"],ep={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:it,originY:le,strokeWidth:1,strokeUniform:!1,padding:0,opacity:1,paintFirst:Ft,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},ip=(n,t,e,i)=>-e*Math.cos(n/i*kr)+e+t,sp=()=>!1;class za{constructor(t){let{startValue:e,byValue:i,duration:s=500,delay:r=0,easing:o=ip,onStart:a=xn,onChange:l=xn,onComplete:c=xn,abort:h=sp,target:u}=t;b(this,"_state","pending"),b(this,"durationProgress",0),b(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(()=>Cn(t),this.delay):Cn(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),Cn(this.tick)))}register(){jn.push(this)}unregister(){jn.remove(this)}abort(){this._state="aborted",this.unregister()}}const rp=["startValue","endValue"];class np extends za{constructor(t){let{startValue:e=0,endValue:i=100}=t;super(_(_({},ut(t,rp)),{},{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 op=["startValue","endValue"];class ap extends za{constructor(t){let{startValue:e=[0],endValue:i=[100]}=t;super(_(_({},ut(t,op)),{},{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 lp=["startValue","endValue","easing","onChange","onComplete","abort"],cp=(n,t,e,i)=>t+e*(1-Math.cos(n/i*kr)),Mo=n=>n&&((t,e,i)=>n(new st(t).toRgba(),e,i));class hp extends za{constructor(t){let{startValue:e,endValue:i,easing:s=cp,onChange:r,onComplete:o,abort:a}=t,l=ut(t,lp);const c=new st(e).getSource(),h=new st(i).getSource();super(_(_({},l),{},{startValue:c,byValue:h.map((u,d)=>u-c[d]),easing:s,onChange:Mo(r),onComplete:Mo(o),abort:Mo(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),ks(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 Sh(n){const t=(e=>Array.isArray(e.startValue)||Array.isArray(e.endValue))(n)?new ap(n):new np(n);return t.start(),t}function up(n){const t=new hp(n);return t.start(),t}class ft{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=ia(e,i),o=ia(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 w(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,p=c*d-h*u,f=a*d-l*u,g=h*a-c*l;if(g!==0){const m=p/g,v=f/g;return(r||0<=m&&m<=1)&&(o||0<=v&&v<=1)?new ft("Intersection").append(new w(t.x+m*a,t.y+m*l)):new ft}if(p===0||f===0){const m=r||o||ft.isPointContained(t,i,s)||ft.isPointContained(e,i,s)||ft.isPointContained(i,t,e)||ft.isPointContained(s,t,e);return new ft(m?"Coincident":void 0)}return new ft("Parallel")}static intersectSegmentLine(t,e,i,s){return ft.intersectLineLine(t,e,i,s,!1,!0)}static intersectSegmentSegment(t,e,i,s){return ft.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 ft,o=i.length;for(let a,l,c,h=0;h<o;h++){if(a=i[h],l=i[(h+1)%o],c=ft.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 ft.intersectLinePolygon(t,e,i,!1)}static intersectPolygonPolygon(t,e){const i=new ft,s=t.length,r=[];for(let o=0;o<s;o++){const a=t[o],l=t[(o+1)%s],c=ft.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 ft("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 w(r.x,s.y),a=new w(s.x,r.y);return ft.intersectPolygonPolygon(t,[s,o,r,a])}}class dp extends nh{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?oe(t,this.group.calcTransformMatrix()):t}setXY(t,e,i){this.group&&(t=oe(t,Me(this.group.calcTransformMatrix()))),this.setRelativeXY(t,e,i)}getRelativeXY(){return new w(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=>oe(a,o))}return r}intersectsWithRect(t,e){return ft.intersectPolygonRectangle(this.getCoords(),t,e).status==="Intersection"}intersectsWithObject(t){const e=ft.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 ft.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 li(this.getCoords())}getScaledWidth(){return this._getTransformedDimensions().x}getScaledHeight(){return this._getTransformedDimensions().y}scale(t){this._set(ue,t),this._set(Te,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?es(ah(this.calcTransformMatrix())):this.angle}getViewportTransform(){var t;return((t=this.canvas)===null||t===void 0?void 0:t.viewportTransform)||ie.concat()}calcACoords(){const t=Pr({angle:this.angle}),{x:e,y:i}=this.getRelativeCenterPoint(),s=Ar(e,i),r=Ut(s,t),o=this._getTransformedDimensions(),a=o.x/2,l=o.y/2;return{tl:oe({x:-a,y:-l},r),tr:oe({x:a,y:-l},r),bl:oe({x:-a,y:l},r),br:oe({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,Dt(this.originX),Dt(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=Ut(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=Rd(s);return this.ownMatrixCache={key:t,value:r},r}_getNonTransformedDimensions(){return new w(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=_({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 w(o*e.scaleX,a*e.scaleY):$a(o,a,to(e)),l.scalarAdd(r)}translateToGivenOrigin(t,e,i,s,r){let o=t.x,a=t.y;const l=Dt(s)-Dt(e),c=Dt(r)-Dt(i);if(l||c){const h=this._getTransformedDimensions();o+=l*h.x,a+=c*h.y}return new w(o,a)}translateToCenterPoint(t,e,i){if(e===K&&i===K)return t;const s=this.translateToGivenOrigin(t,e,i,K,K);return this.angle?s.rotate(Et(this.angle),t):s}translateToOriginPoint(t,e,i){const s=this.translateToGivenOrigin(t,K,K,e,i);return this.angle?s.rotate(Et(this.angle),t):s}getCenterPoint(){const t=this.getRelativeCenterPoint();return this.group?oe(t,this.group.calcTransformMatrix()):t}getRelativeCenterPoint(){return this.translateToCenterPoint(new w(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(),it,le)}}const pp=["type"],fp=["extraParam"];let Qe=class Tn extends dp{static getDefaults(){return Tn.ownDefaults}get type(){const t=this.constructor.type;return t==="FabricObject"?"object":t.toLowerCase()}set type(t){Ai("warn","Setting type has no effect",t)}constructor(t){super(),b(this,"_cacheContext",null),Object.assign(this,Tn.ownDefaults),this.setOptions(t)}_createCacheCanvas(){this._cacheCanvas=Fe(),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 o=e/i,[a,l]=ir.limitDimsByArea(o),c=ks(r,a,s),h=ks(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 w(Math.abs(this.scaleX),Math.abs(this.scaleY));const t=Rn(this.calcTransformMatrix());return new w(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!==ue&&t!==Te||(e=this._constrainScale(e)),t===ue&&e<0?(this.flipX=!this.flipX,e*=-1):t==="scaleY"&&e<0?(this.flipY=!this.flipY,e*=-1):t!=="shadow"||!e||e instanceof ci||(e=new ci(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===he&&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=Ue(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=Me(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,we(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&&(we(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)||ie,a=r*s,l=o*s,c=e.nonScaling?new w(1,1):this.getObjectScaling();t.shadowColor=e.color,t.shadowBlur=e.blur*tt.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(!we(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===he?(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=Ue({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 w(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(R.getClass("image"))(e)}toCanvasElement(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};const e=gh(this),i=this.group,s=this.shadow,r=Math.abs,o=t.enableRetinaScaling?th():1,a=(t.multiplier||1)*o,l=t.canvasProvider||(y=>new Dr(y,{enableRetinaScaling:!1,renderOnAddRemove:!1,skipOffscreen:!1}));delete this.group,t.withoutTransform&&Ud(this),t.withoutShadow&&(this.shadow=null),t.viewportTransform&&Gd(this,this.getViewportTransform()),this.setCoords();const c=Fe(),h=this.getBoundingRect(),u=this.shadow,d=new w;if(u){const y=u.blur,x=u.nonScaling?new w(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 p=h.width+d.x,f=h.height+d.y;c.width=Math.ceil(p),c.height=Math.ceil(f);const g=l(c);t.format==="jpeg"&&(g.backgroundColor="#fff"),this.setPositionByOrigin(new w(g.width/2,g.height/2),K,K);const m=this.canvas;g._objects=[this],this.set("canvas",g),this.setCoords();const v=g.toCanvasElement(a||1,t);return this.set("canvas",m),this.shadow=s,i&&(this.group=i),this.set(e),this.setCoords(),g._objects=[],g.destroy(),v}toDataURL(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};return oh(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=K,this.originY=K,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(){jn.cancelByTarget(this),this.off(),this._set("canvas",void 0),this._cacheCanvas&&Ve().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=_(_({},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,p)=>{s.reduce((f,g,m)=>(m===s.length-1&&(f[g]=u),f[g]),this),l&&l(u,d,p)},onComplete:(u,d,p)=>{this.setCoords(),c&&c(u,d,p)}});return r?up(h):Sh(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(Tn.customProperties,this.constructor.customProperties||[]);let e;const i=tt.NUM_FRACTION_DIGITS,{clipPath:s,fill:r,stroke:o,shadow:a,strokeDashArray:l,left:c,top:h,originX:u,originY:d,width:p,height:f,strokeWidth:g,strokeLineCap:m,strokeDashOffset:v,strokeLineJoin:y,strokeUniform:x,strokeMiterLimit:E,scaleX:O,scaleY:D,angle:C,flipX:S,flipY:F,opacity:j,visible:A,backgroundColor:k,fillRule:P,paintFirst:L,globalCompositeOperation:z,skewX:X,skewY:Z}=this;s&&!s.excludeFromExport&&(e=s.toObject(t.concat("inverted","absolutePositioned")));const $=M=>gt(M,i),B=_(_({},Ls(this,t)),{},{type:this.constructor.type,version:Zo,originX:u,originY:d,left:$(c),top:$(h),width:$(p),height:$(f),fill:Dl(r)?r.toObject():r,stroke:Dl(o)?o.toObject():o,strokeWidth:$(g),strokeDashArray:l&&l.concat(),strokeLineCap:m,strokeDashOffset:v,strokeLineJoin:y,strokeUniform:x,strokeMiterLimit:$(E),scaleX:$(O),scaleY:$(D),angle:$(C),flipX:S,flipY:F,opacity:$(j),shadow:a&&a.toObject(),visible:A,backgroundColor:k,fillRule:P,paintFirst:L,globalCompositeOperation:z,skewX:$(X),skewY:$(Z)},e?{clipPath:e}:null);return this.includeDefaultValues?B:this._removeDefaultValues(B)}toDatalessObject(t){return this.toObject(t)}_removeDefaultValues(t){const e=this.constructor.getDefaults(),i=Object.keys(e).length>0?e:Object.getPrototypeOf(this);return Ra(t,(s,r)=>{if(r===it||r===le||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=ut(t,pp),i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},{extraParam:s}=i,r=ut(i,fp);return eo(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)}};b(Qe,"stateProperties",tp),b(Qe,"cacheProperties",mi),b(Qe,"ownDefaults",ep),b(Qe,"type","FabricObject"),b(Qe,"colorProperties",[Ft,he,"backgroundColor"]),b(Qe,"customProperties",[]),R.setClass(Qe),R.setClass(Qe,"object");const Fs=(n,t,e)=>(i,s,r,o)=>{const a=t(i,s,r,o);return a&&mh(n,_(_({},bh(i,s,r,o)),e)),a};function js(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 Nl=Fs(ur,js((n,t,e,i)=>{const s=Ba(t,t.originX,t.originY,e,i);if(Dt(t.originX)===Dt(K)||Dt(t.originX)===Dt(Ct)&&s.x<0||Dt(t.originX)===Dt(it)&&s.x>0){const{target:r}=t,o=r.strokeWidth/(r.strokeUniform?r.scaleX:1),a=vh(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 gp(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?he:Ft,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,In,!1),n[l](),c&&n.stroke(),n.restore()}function mp(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?he:Ft,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(Et(d)),n["".concat(l,"Rect")](-h,-u,r,o),c&&n.strokeRect(-h,-u,r,o),n.restore()}class ke{constructor(t){b(this,"visible",!0),b(this,"actionName",Qn),b(this,"angle",0),b(this,"x",0),b(this,"y",0),b(this,"offsetX",0),b(this,"offsetY",0),b(this,"sizeX",0),b(this,"sizeY",0),b(this,"touchSizeX",0),b(this,"touchSizeY",0),b(this,"cursorStyle","crosshair"),b(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)&&ft.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 w(this.x*t.x+this.offsetX,this.y*t.y+this.offsetY).transform(e)}calcCornerCoords(t,e,i,s,r,o){const a=Fa([Ar(i,s),Pr({angle:t}),ja((r?this.touchSizeX:this.sizeX)||e,(r?this.touchSizeY:this.sizeY)||e)]);return{tl:new w(-.5,-.5).transform(a),tr:new w(.5,-.5).transform(a),br:new w(.5,.5).transform(a),bl:new w(-.5,.5).transform(a)}}render(t,e,i,s,r){((s=s||{}).cornerStyle||r.cornerStyle)==="circle"?gp.call(this,t,e,i,s,r):mp.call(this,t,e,i,s,r)}}const vp=(n,t,e)=>e.lockRotation?Nn:t.cursorStyle,bp=Fs(ih,js((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(Le(s,"lockRotation"))return!1;const u=Math.atan2(o-h.y,r-h.x),d=Math.atan2(i-h.y,e-h.x);let p=es(d-u+a);if(s.snapAngle&&s.snapAngle>0){const g=s.snapAngle,m=s.snapThreshold||g,v=Math.ceil(p/g)*g,y=Math.floor(p/g)*g;Math.abs(p-y)<m?p=y:Math.abs(p-v)<m&&(p=v)}p<0&&(p=360+p),p%=360;const f=s.angle!==p;return s.angle=p,f}));function Th(n,t){const e=t.canvas,i=n[e.uniScaleKey];return e.uniformScaling&&!i||!e.uniformScaling&&i}function Eh(n,t,e){const i=Le(n,"lockScalingX"),s=Le(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 _p=["e","se","s","sw","w","nw","n","ne","e"],Js=(n,t,e)=>{const i=Th(n,e);if(Eh(e,t.x!==0&&t.y===0?"x":t.x===0&&t.y!==0?"y":"",i))return Nn;const s=_h(e,t);return"".concat(_p[s],"-resize")};function Ha(n,t,e,i){let s=arguments.length>4&&arguments[4]!==void 0?arguments[4]:{};const r=t.target,o=s.by,a=Th(n,r);let l,c,h,u,d,p;if(Eh(r,o,a))return!1;if(t.gestureScale)c=t.scaleX*t.gestureScale,h=t.scaleY*t.gestureScale;else{if(l=Ba(t,t.originX,t.originY,e,i),d=o!=="y"?Math.sign(l.x||t.signX||1):1,p=o!=="x"?Math.sign(l.y||t.signY||1):1,t.signX||(t.signX=d),t.signY||(t.signY=p),Le(r,"lockScalingFlip")&&(t.signX!==d||t.signY!==p))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);vh(t)&&(c*=2,h*=2),t.signX!==d&&o!=="y"&&(t.originX=Ll(t.originX),c*=-1,t.signX=d),t.signY!==p&&o!=="x"&&(t.originY=Ll(t.originY),h*=-1,t.signY=p)}const f=r.scaleX,g=r.scaleY;return o?(o==="x"&&r.set(ue,c),o==="y"&&r.set(Te,h)):(!Le(r,"lockScalingX")&&r.set(ue,c),!Le(r,"lockScalingY")&&r.set(Te,h)),f!==r.scaleX||g!==r.scaleY}const Wr=Fs(Jn,js((n,t,e,i)=>Ha(n,t,e,i))),yp=Fs(Jn,js((n,t,e,i)=>Ha(n,t,e,i,{by:"x"}))),xp=Fs(Jn,js((n,t,e,i)=>Ha(n,t,e,i,{by:"y"}))),wp=["target","ex","ey","skewingSide"],Io={x:{counterAxis:"y",scale:ue,skew:Ms,lockSkewing:"lockSkewingX",origin:"originX",flip:"flipX"},y:{counterAxis:"x",scale:Te,skew:Is,lockSkewing:"lockSkewingY",origin:"originY",flip:"flipY"}},Cp=["ns","nesw","ew","nwse"],Sp=(n,t,e)=>{if(t.x!==0&&Le(e,"lockSkewingY")||t.y!==0&&Le(e,"lockSkewingX"))return Nn;const i=_h(e,t)%4;return"".concat(Cp[i],"-resize")};function Oh(n,t,e,i,s){const{target:r}=e,{counterAxis:o,origin:a,lockSkewing:l,skew:c,flip:h}=Io[n];if(Le(r,l))return!1;const{origin:u,flip:d}=Io[o],p=Dt(e[u])*(r[d]?-1:1),f=-Math.sign(p)*(r[h]?-1:1),g=.5*-((r[c]===0&&Ba(e,K,K,i,s)[n]>0||r[c]>0?1:-1)*f)+.5;return Fs(sh,js((v,y,x,E)=>function(O,D,C){let{target:S,ex:F,ey:j,skewingSide:A}=D,k=ut(D,wp);const{skew:P}=Io[O],L=C.subtract(new w(F,j)).divide(new w(S.scaleX,S.scaleY))[O],z=S[P],X=k[P],Z=Math.tan(Et(X)),$=O==="y"?S._getTransformedDimensions({scaleX:1,scaleY:1,skewX:0}).x:S._getTransformedDimensions({scaleX:1,scaleY:1}).y,B=2*L*A/Math.max($,1)+Z,M=es(Math.atan(B));S.set(P,M);const H=z!==S[P];if(H&&O==="y"){const{skewX:J,scaleX:_t}=S,nt=S._getTransformedDimensions({skewY:z}),pe=S._getTransformedDimensions(),I=J!==0?nt.x/pe.x:1;I!==1&&S.set(ue,I*_t)}return H}(n,y,new w(x,E))))(t,_(_({},e),{},{[a]:g,skewingSide:f}),i,s)}const Tp=(n,t,e,i)=>Oh("x",n,t,e,i),Ep=(n,t,e,i)=>Oh("y",n,t,e,i);function ro(n,t){return n[t.canvas.altActionKey]}const Gr=(n,t,e)=>{const i=ro(n,e);return t.x===0?i?Ms:Te:t.y===0?i?Is:ue:""},ms=(n,t,e)=>ro(n,e)?Sp(0,t,e):Js(n,t,e),zl=(n,t,e,i)=>ro(n,t.target)?Ep(n,t,e,i):yp(n,t,e,i),Hl=(n,t,e,i)=>ro(n,t.target)?Tp(n,t,e,i):xp(n,t,e,i),kh=()=>({ml:new ke({x:-.5,y:0,cursorStyleHandler:ms,actionHandler:zl,getActionName:Gr}),mr:new ke({x:.5,y:0,cursorStyleHandler:ms,actionHandler:zl,getActionName:Gr}),mb:new ke({x:0,y:.5,cursorStyleHandler:ms,actionHandler:Hl,getActionName:Gr}),mt:new ke({x:0,y:-.5,cursorStyleHandler:ms,actionHandler:Hl,getActionName:Gr}),tl:new ke({x:-.5,y:-.5,cursorStyleHandler:Js,actionHandler:Wr}),tr:new ke({x:.5,y:-.5,cursorStyleHandler:Js,actionHandler:Wr}),bl:new ke({x:-.5,y:.5,cursorStyleHandler:Js,actionHandler:Wr}),br:new ke({x:.5,y:.5,cursorStyleHandler:Js,actionHandler:Wr}),mtr:new ke({x:0,y:-.5,actionHandler:bp,cursorStyleHandler:vp,offsetY:-40,withConnection:!0,actionName:Ia})}),Op=()=>({mr:new ke({x:.5,y:0,actionHandler:Nl,cursorStyleHandler:ms,actionName:ur}),ml:new ke({x:-.5,y:0,actionHandler:Nl,cursorStyleHandler:ms,actionName:ur})}),kp=()=>_(_({},kh()),Op());class fr extends Qe{static getDefaults(){return _(_({},super.getDefaults()),fr.ownDefaults)}constructor(t){super(),Object.assign(this,this.constructor.createControls(),fr.ownDefaults),this.setOptions(t)}static createControls(){return{controls:kh()}}_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(Qn))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=Ar(e.x,e.y),s=Pr({angle:this.getTotalAngle()-(this.group&&this.flipX?180:0)}),r=Ut(i,s),o=Ut(t,r),a=Ut(o,[1/t[0],0,0,1/t[3],0,0]),l=this.group?Rn(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 p=u.positionHandler(c,a,this,u);h[d]=Object.assign(p,this._calcCornerCoords(u,p))}),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(Et(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=_({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=_({hasBorders:i,hasControls:s},e),o=this.getViewportTransform(),a=r.hasBorders,l=r.hasControls,c=Ut(o,this.calcTransformMatrix()),h=Rn(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(Et(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=$a(this.width,this.height,to(e)),o=this.isStrokeAccountedForInDimensions()?La:(this.strokeUniform?new w().scalarAdd(this.canvas?this.canvas.getZoom():1):new w(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=_({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 Ah(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}b(fr,"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 Kt extends fr{}Ah(Kt,[yh]),R.setClass(Kt),R.setClass(Kt,"object");const Ap=(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 Ph{constructor(t){this.options=t,this.strokeProjectionMagnitude=this.options.strokeWidth/2,this.scale=new w(this.options.scaleX,this.options.scaleY),this.strokeUniformScalar=this.options.strokeUniform?new w(1/this.options.scaleX,1/this.options.scaleY):new w(1,1)}createSideVector(t,e){const i=ia(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 w(t);return e.y+=e.x*Math.tan(Et(this.options.skewY)),e.x+=e.y*Math.tan(Et(this.options.skewX)),e}scaleUnitVector(t,e){return t.multiply(this.strokeUniformScalar).scalarMultiply(e)}}const Pp=new w;class Ss extends Ph{static getOrthogonalRotationFactor(t,e){const i=e?ra(t,e):Jd(t);return Math.abs(i)<kr?-1:1}constructor(t,e,i,s){super(s),b(this,"AB",void 0),b(this,"AC",void 0),b(this,"alpha",void 0),b(this,"bisector",void 0),this.A=new w(t),this.B=new w(e),this.C=new w(i),this.AB=this.createSideVector(this.A,this.B),this.AC=this.createSideVector(this.A,this.C),this.alpha=ra(this.AB,this.AC),this.bisector=Na(wh(this.AB.eq(Pp)?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=Ch(s),o=Ss.getOrthogonalRotationFactor(r,this.bisector);return this.scaleUnitVector(r,i*o)}projectBevel(){const t=[];return(this.alpha%In==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?sa(this.scaleUnitVector(this.bisector,this.options.strokeMiterLimit)):this.options.strokeMiterLimit;return sa(s)/this.strokeProjectionMagnitude<=r&&t.push(this.applySkew(this.A.add(s))),t.push(...this.projectBevel()),t}projectRoundNoSkew(t,e){const i=[],s=new w(Ss.getOrthogonalRotationFactor(this.bisector),Ss.getOrthogonalRotationFactor(new w(this.bisector.y,this.bisector.x)));return[new w(1,0).scalarMultiply(this.strokeProjectionMagnitude).multiply(this.strokeUniformScalar).multiply(s),new w(0,1).scalarMultiply(this.strokeProjectionMagnitude).multiply(this.strokeUniformScalar).multiply(s)].forEach(r=>{Rl(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 w(Math.tan(Et(s)),Math.tan(Et(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 w(Math.sqrt(Math.max(h**2-u**2,0)),u),p=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),f=new w(p,Math.sqrt(Math.max(h**2-p**2,0)));return[f,f.scalarMultiply(-1),d,d.scalarMultiply(-1)].map(g=>this.applySkew(l?g.multiply(this.strokeUniformScalar):g)).forEach(g=>{Rl(g,t,e)&&i.push(this.applySkew(this.A).add(g))}),i}projectRound(){const t=[];t.push(...this.projectBevel());const e=this.alpha%In==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=sr(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 Vl extends Ph{constructor(t,e,i){super(i),this.A=new w(t),this.T=new w(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(Ch(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 w(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 w(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(Na(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 Dp=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 w(o)),r),[new w(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 Vl(r,r,t).project()):!e||o!==0&&o!==a.length-1?i.push(...new Ss(r,l,c,t).project()):i.push(...new Vl(r,o===0?c:l,t).project())}),i},Va=n=>{const t={};return Object.keys(n).forEach(e=>{t[e]={},Object.keys(n[e]).forEach(i=>{t[e][i]=_({},n[e][i])})}),t},Mp=n=>n.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/'/g,"&apos;").replace(/</g,"&lt;").replace(/>/g,"&gt;"),Ua=n=>{const t=[];for(let e,i=0;i<n.length;i++)(e=Ip(n,i))!==!1&&t.push(e);return t},Ip=(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},Wa=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)},Lp=(n,t)=>{const e=t.split(`
164
+ `),i=[];let s=-1,r={};n=Va(n);for(let o=0;o<e.length;o++){const a=Ua(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&&(Wa(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},Fp=(n,t)=>{if(!Array.isArray(n))return Va(n);const e=t.split(Ma),i={};let s=-1,r=0;for(let o=0;o<e.length;o++){const a=Ua(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]=_({},n[r].style),s===n[r].end-1&&r++)}return i},$i=["display","transform",Ft,"fill-opacity","fill-rule","opacity",he,"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 Ul(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 jp(n,t){let e=!0;const i=Ul(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=Ul(s=s.parentElement,o);return r.length===0}(n,t)),i&&e&&t.length===0}const Rp=n=>{var t;return(t=qd[n])!==null&&t!==void 0?t:n},$p=new RegExp("(".concat(is,")"),"gi"),Bp=n=>n.replace($p," $1 ").replace(/,/gi," ").replace(/\s+/gi," ");var Wl,Gl,Yl,Xl,Kl,ql,Zl;const ee="(".concat(is,")"),Np=String.raw(Wl||(Wl=Ri(["(skewX)(",")"],["(skewX)\\(","\\)"])),ee),zp=String.raw(Gl||(Gl=Ri(["(skewY)(",")"],["(skewY)\\(","\\)"])),ee),Hp=String.raw(Yl||(Yl=Ri(["(rotate)(","(?: "," ",")?)"],["(rotate)\\(","(?: "," ",")?\\)"])),ee,ee,ee),Vp=String.raw(Xl||(Xl=Ri(["(scale)(","(?: ",")?)"],["(scale)\\(","(?: ",")?\\)"])),ee,ee),Up=String.raw(Kl||(Kl=Ri(["(translate)(","(?: ",")?)"],["(translate)\\(","(?: ",")?\\)"])),ee,ee),Wp=String.raw(ql||(ql=Ri(["(matrix)("," "," "," "," "," ",")"],["(matrix)\\("," "," "," "," "," ","\\)"])),ee,ee,ee,ee,ee,ee),Ga="(?:".concat(Wp,"|").concat(Up,"|").concat(Hp,"|").concat(Vp,"|").concat(Np,"|").concat(zp,")"),Gp="(?:".concat(Ga,"*)"),Yp=String.raw(Zl||(Zl=Ri(["^s*(?:","?)s*$"],["^\\s*(?:","?)\\s*$"])),Gp),Xp=new RegExp(Yp),Kp=new RegExp(Ga),qp=new RegExp(Ga,"g");function na(n){const t=[];if(!(n=Bp(n).replace(/\s*([()])\s*/gi,"$1"))||n&&!Xp.test(n))return[...ie];for(const e of n.matchAll(qp)){const i=Kp.exec(e[0]);if(!i)continue;let s=ie;const r=i.filter(f=>!!f),[,o,...a]=r,[l,c,h,u,d,p]=a.map(f=>parseFloat(f));switch(o){case"translate":s=Ar(l,c);break;case Ia:s=Pr({angle:l},{x:c,y:h});break;case Qn:s=ja(l,c);break;case Ms:s=ch(l);break;case Is:s=hh(l);break;case"matrix":s=[l,c,h,u,d,p]}t.push(s)}return Fa(t)}function Zp(n,t,e,i){const s=Array.isArray(t);let r,o=t;if(n!==Ft&&n!==he||t!==ce){if(n==="strokeUniform")return t==="non-scaling-stroke";if(n==="strokeDashArray")o=t===ce?null:t.replace(/,/g," ").split(/\s+/).map(parseFloat);else if(n==="transformMatrix")o=e&&e.transformMatrix?Ut(e.transformMatrix,na(t)):na(t);else if(n==="visible")o=t!==ce&&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"?it:t==="end"?Ct:K;else if(n==="charSpacing")r=ws(t,i)/i*1e3;else if(n==="paintFirst"){const a=t.indexOf(Ft),l=t.indexOf(he);o=Ft,(a>-1&&l>-1&&l<a||a===-1&&l>-1)&&(o=he)}else{if(n==="href"||n==="xlink:href"||n==="font"||n==="id")return t;if(n==="imageSmoothing")return t==="optimizeQuality";r=s?t.map(ws):ws(t,i)}}else o="";return!s&&isNaN(r)?o:r}function Jp(n,t){const e=n.match(Kd);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=ws(r)),a&&(t.fontFamily=a),o&&(t.lineHeight=o==="normal"?1:o)}function Qp(n,t){n.replace(/;\s*$/,"").split(";").forEach(e=>{if(!e)return;const[i,s]=e.split(":");t[i.trim().toLowerCase()]=s.trim()})}function tf(n){const t={},e=n.getAttribute("style");return e&&(typeof e=="string"?Qp(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 ef={stroke:"strokeOpacity",fill:"fillOpacity"};function vi(n,t,e){if(!n)return{};let i,s={},r=Da;n.parentNode&&jl.test(n.parentNode.nodeName)&&(s=vi(n.parentElement,t,e),s.fontSize&&(i=r=ws(s.fontSize)));const o=_(_(_({},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)jp(c,d.split(" "))&&(u=_(_({},u),h[d]));return u}(n,e)),tf(n));o[Do]&&n.setAttribute(Do,o[Do]),o[Po]&&(i=ws(o[Po],r),o[Po]="".concat(i));const a={};for(const c in o){const h=Rp(c),u=Zp(h,o[c],s,i);a[h]=u}a&&a.font&&Jp(a.font,a);const l=_(_({},s),a);return jl.test(n.nodeName)?l:function(c){const h=Kt.getDefaults();return Object.entries(ef).forEach(u=>{let[d,p]=u;if(c[p]===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 f=new st(c[d]);c[d]=f.setAlpha(gt(f.getAlpha()*c[p],2)).toRgba()}),c}(l)}const sf=["left","top","width","height","visible"],Dh=["rx","ry"];class Nt extends Kt{static getDefaults(){return _(_({},super.getDefaults()),Nt.ownDefaults)}constructor(t){super(),Object.assign(this,Nt.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-_i*o,r,s+e,r+_i*a,s+e,r+a),t.lineTo(s+e,r+i-a),l&&t.bezierCurveTo(s+e,r+i-_i*a,s+e-_i*o,r+i,s+e-o,r+i),t.lineTo(s+o,r+i),l&&t.bezierCurveTo(s+_i*o,r+i,s,r+i-_i*a,s,r+i-a),t.lineTo(s,r+a),l&&t.bezierCurveTo(s,r+_i*a,s+_i*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([...Dh,...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=vi(t,this.ATTRIBUTE_NAMES,i),{left:r=0,top:o=0,width:a=0,height:l=0,visible:c=!0}=s,h=ut(s,sf);return new this(_(_(_({},e),h),{},{left:r,top:o,width:a,height:l,visible:!!(c&&a&&l)}))}}b(Nt,"type","Rect"),b(Nt,"cacheProperties",[...mi,...Dh]),b(Nt,"ownDefaults",{rx:0,ry:0}),b(Nt,"ATTRIBUTE_NAMES",[...$i,"x","y","rx","ry","width","height"]),R.setClass(Nt),R.setSVGClass(Nt);const si="initialization",zn="added",Ya="removed",Hn="imperative",Mh=(n,t)=>{const{strokeUniform:e,strokeWidth:i,width:s,height:r,group:o}=t,a=o&&o!==n?io(o.calcTransformMatrix(),n.calcTransformMatrix()):null,l=a?t.getRelativeCenterPoint().transform(a):t.getRelativeCenterPoint(),c=!t.isStrokeAccountedForInDimensions(),h=e&&c?Wd(new w(i,i),void 0,n.calcTransformMatrix()):La,u=!e&&c?i:0,d=$a(s+u,r+u,Fa([a,t.calcOwnMatrix()],!0)).add(h).scalarDivide(2);return[l.subtract(d),l.add(d)]};class no{calcLayoutResult(t,e){if(this.shouldPerformLayout(t))return this.calcBoundingBox(e,t)}shouldPerformLayout(t){let{type:e,prevStrategy:i,strategy:s}=t;return e===si||e===Hn||!!i&&s!==i}shouldLayoutClipPath(t){let{type:e,target:{clipPath:i}}=t;return e!==si&&i&&!i.absolutePositioned}getInitialSize(t,e){return e.size}calcBoundingBox(t,e){const{type:i,target:s}=e;if(i===Hn&&e.overrides)return e.overrides;if(t.length===0)return;const{left:r,top:o,width:a,height:l}=li(t.map(u=>Mh(s,u)).reduce((u,d)=>u.concat(d),[])),c=new w(a,l),h=new w(r,o).add(c.scalarDivide(2));if(i===si){const u=this.getInitialSize(e,{size:c,center:h});return{center:h,relativeCorrection:new w(0,0),size:u}}return{center:h.transform(s.calcOwnMatrix()),size:c}}}b(no,"type","strategy");class oa extends no{shouldPerformLayout(t){return!0}}b(oa,"type","fit-content"),R.setClass(oa);const rf=["strategy"],nf=["target","strategy","bubbles","prevStrategy"],Ih="layoutManager";class gr{constructor(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:new oa;b(this,"strategy",void 0),this.strategy=t,this._subscriptions=new Map}performLayout(t){const e=_(_({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[Fn,eh,ur,ih,Jn,sh,Ln,Pd,Dd].map(s=>t.on(s,r=>this.performLayout(s===Fn?{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===si||i===zn?this.subscribeTargets(t):i===Ya&&this.unsubscribeTargets(t),e.fire("layout:before",{context:t}),s&&s.fire("object:layout:before",{target:e,context:t}),i===Hn&&t.deep){const r=ut(t,rf);e.forEachObject(o=>o.layoutManager&&o.layoutManager.performLayout(_(_({},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===si?new w:e.getRelativeCenterPoint(),{center:a,correction:l=new w,relativeCorrection:c=new w}=r,h=o.subtract(a).add(l).transform(s===si?ie:Me(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===si?i.set({left:(o=t.x)!==null&&o!==void 0?o:r.x+s.x*Dt(i.originX),top:(a=t.y)!==null&&a!==void 0?a:r.y+s.y*Dt(i.originY)}):(i.setPositionByOrigin(r,K,K),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=ut(t,nf),{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(_(_({},a),{},{target:c}))),i.set("dirty",!0)}dispose(){const{_subscriptions:t}=this;t.forEach(e=>e.forEach(i=>i())),t.clear()}toObject(){return{type:Ih,strategy:this.strategy.constructor.type}}toJSON(){return this.toObject()}}R.setClass(gr,Ih);const of=["type","objects","layoutManager"];class af extends gr{performLayout(){}}class ki extends rh(Kt){static getDefaults(){return _(_({},super.getDefaults()),ki.ownDefaults)}constructor(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[],e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};super(),b(this,"_activeObjects",[]),b(this,"__objectSelectionTracker",void 0),b(this,"__objectSelectionDisposer",void 0),Object.assign(this,ki.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 gr,this.layoutManager.performLayout({type:si,target:this,targets:[...t],x:e.left,y:e.top})}canEnterGroup(t){return t===this||this.isDescendantOf(t)?(Ai("error","Group: circular object trees are not supported, this call has no effect"),!1):this._objects.indexOf(t)===-1||(Ai("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(zn,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(zn,r),o}remove(){const t=super.remove(...arguments);return this._onAfterObjectsChange(Ya,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&&Bn(t,Ut(Me(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||(Bn(t,Ut(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=Kt.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(...Me(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(_({target:this,type:Hn},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 _(_(_({},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=Nt.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=ut(t,of);return Promise.all([dr(s,e),eo(o,e)]).then(a=>{let[l,c]=a;const h=new this(l,_(_(_({},o),c),{},{layoutManager:new af}));if(r){const u=R.getClass(r.type),d=R.getClass(r.strategy);h.layoutManager=new u(new d)}else h.layoutManager=new gr;return h.layoutManager.subscribeTargets({type:si,target:h,targets:h.getObjects()}),h.setCoords(),h})}}b(ki,"type","Group"),b(ki,"ownDefaults",{strokeWidth:0,subTargetCheck:!1,interactive:!1}),R.setClass(ki);const lf=(n,t)=>Math.min(t.width/n.width,t.height/n.height),cf=(n,t)=>Math.max(t.width/n.width,t.height/n.height),aa="\\s*,?\\s*",Us="".concat(aa,"(").concat(is,")"),hf="".concat(Us).concat(Us).concat(Us).concat(aa,"([01])").concat(aa,"([01])").concat(Us).concat(Us),uf={m:"l",M:"L"},df=(n,t,e,i,s,r,o,a,l,c,h)=>{const u=ui(n),d=di(n),p=ui(t),f=di(t),g=e*s*p-i*r*f+o,m=i*s*p+e*r*f+a;return["C",c+l*(-e*s*d-i*r*u),h+l*(-i*s*d+e*r*u),g+l*(e*s*f+i*r*p),m+l*(i*s*f-e*r*p),g,m]},Jl=(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 Ql(n,t,e,i,s,r,o,a){let l;if(tt.cachesBoundsOfCurve&&(l=[...arguments].join(),ir.boundsOfCurveCache[l]))return ir.boundsOfCurveCache[l];const c=Math.sqrt,h=Math.abs,u=[],d=[[0,0],[0,0]];let p=6*n-12*e+6*s,f=-3*n+9*e-9*s+3*o,g=3*e-3*n;for(let E=0;E<2;++E){if(E>0&&(p=6*t-12*i+6*r,f=-3*t+9*i-9*r+3*a,g=3*i-3*t),h(f)<1e-12){if(h(p)<1e-12)continue;const F=-g/p;0<F&&F<1&&u.push(F);continue}const O=p*p-4*g*f;if(O<0)continue;const D=c(O),C=(-p+D)/(2*f);0<C&&C<1&&u.push(C);const S=(-p-D)/(2*f);0<S&&S<1&&u.push(S)}let m=u.length;const v=m,y=Lh(n,t,e,i,s,r,o,a);for(;m--;){const{x:E,y:O}=y(u[m]);d[0][m]=E,d[1][m]=O}d[0][v]=n,d[1][v]=t,d[0][v+1]=o,d[1][v+1]=a;const x=[new w(Math.min(...d[0]),Math.min(...d[1])),new w(Math.max(...d[0]),Math.max(...d[1]))];return tt.cachesBoundsOfCurve&&(ir.boundsOfCurveCache[l]=x),x}const pf=(n,t,e)=>{let[i,s,r,o,a,l,c,h]=e;const u=((d,p,f,g,m,v,y)=>{if(f===0||g===0)return[];let x=0,E=0,O=0;const D=Math.PI,C=y*Pa,S=di(C),F=ui(C),j=.5*(-F*d-S*p),A=.5*(-F*p+S*d),k=f**2,P=g**2,L=A**2,z=j**2,X=k*P-k*L-P*z;let Z=Math.abs(f),$=Math.abs(g);if(X<0){const ct=Math.sqrt(1-X/(k*P));Z*=ct,$*=ct}else O=(m===v?-1:1)*Math.sqrt(X/(k*L+P*z));const B=O*Z*A/$,M=-O*$*j/Z,H=F*B-S*M+.5*d,J=S*B+F*M+.5*p;let _t=Jl(1,0,(j-B)/Z,(A-M)/$),nt=Jl((j-B)/Z,(A-M)/$,(-j-B)/Z,(-A-M)/$);v===0&&nt>0?nt-=2*D:v===1&&nt<0&&(nt+=2*D);const pe=Math.ceil(Math.abs(nt/D*2)),I=[],et=nt/pe,Wt=8/3*Math.sin(et/4)*Math.sin(et/4)/Math.sin(et/2);let lt=_t+et;for(let ct=0;ct<pe;ct++)I[ct]=df(_t,lt,F,S,Z,$,H,J,Wt,x,E),x=I[ct][5],E=I[ct][6],_t=lt,lt+=et;return I})(c-n,h-t,s,r,a,l,o);for(let d=0,p=u.length;d<p;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},ff=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},Vn=(n,t,e,i)=>Math.sqrt((e-n)**2+(i-t)**2),Lh=(n,t,e,i,s,r,o,a)=>l=>{const c=l**3,h=(p=>3*p**2*(1-p))(l),u=(p=>3*p*(1-p)**2)(l),d=(p=>(1-p)**3)(l);return new w(o*c+s*h+e*u+n*d,a*c+r*h+i*u+t*d)},Fh=n=>n**2,jh=n=>2*n*(1-n),Rh=n=>(1-n)**2,gf=(n,t,e,i,s,r,o,a)=>l=>{const c=Fh(l),h=jh(l),u=Rh(l),d=3*(u*(e-n)+h*(s-e)+c*(o-s)),p=3*(u*(i-t)+h*(r-i)+c*(a-r));return Math.atan2(p,d)},mf=(n,t,e,i,s,r)=>o=>{const a=Fh(o),l=jh(o),c=Rh(o);return new w(s*a+e*l+n*c,r*a+i*l+t*c)},vf=(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)},tc=(n,t,e)=>{let i=new w(t,e),s=0;for(let r=1;r<=100;r+=1){const o=n(r/100);s+=Vn(i.x,i.y,o.x,o.y),i=o}return s},bf=(n,t)=>{let e,i=0,s=0,r={x:n.x,y:n.y},o=_({},r),a=.01,l=0;const c=n.iterator,h=n.angleFinder;for(;s<t&&a>1e-4;)o=c(i),l=i,e=Vn(r.x,r.y,o.x,o.y),e+s>t?(i-=a,a/=2):(r=o,i+=a,s+=e);return _(_({},o),{},{angle:h(l)})},$h=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=Vn(s,r,c[1],c[2]),s=c[1],r=c[2];break;case"C":t=Lh(s,r,c[1],c[2],c[3],c[4],c[5],c[6]),e=h,e.iterator=t,e.angleFinder=gf(s,r,c[1],c[2],c[3],c[4],c[5],c[6]),e.length=tc(t,s,r),s=c[5],r=c[6];break;case"Q":t=mf(s,r,c[1],c[2],c[3],c[4]),e=h,e.iterator=t,e.angleFinder=vf(s,r,c[1],c[2],c[3],c[4]),e.length=tc(t,s,r),s=c[3],r=c[4];break;case"Z":e=h,e.destX=o,e.destY=a,e.length=Vn(s,r,o,a),s=o,r=a}i+=e.length,l.push(e)}return l.push({length:i,x:s,y:r}),l},_f=function(n,t){let e=arguments.length>2&&arguments[2]!==void 0?arguments[2]:$h(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 _(_({},new w(s.x,s.y).lerp(new w(s.destX,s.destY),r)),{},{angle:Math.atan2(s.destY-s.y,s.destX-s.x)});case"L":return _(_({},new w(s.x,s.y).lerp(new w(o[1],o[2]),r)),{},{angle:Math.atan2(o[2]-s.y,o[1]-s.x)});case"C":case"Q":return bf(s,t)}},yf=new RegExp("[mzlhvcsqta][^mzlhvcsqta]*","gi"),ec=new RegExp(hf,"g"),xf=new RegExp(is,"gi"),wf={m:2,l:2,h:1,v:1,c:6,s:4,q:4,t:2,a:7},Cf=n=>{var t;const e=[],i=(t=n.match(yf))!==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=wf[r.toLowerCase()];let a=[];if(r==="a"||r==="A"){ec.lastIndex=0;for(let l=null;l=ec.exec(s);)a.push(...l.slice(1))}else a=s.match(xf)||[];for(let l=0;l<a.length;l+=o){const c=new Array(o),h=uf[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},Sf=(n,t)=>n.map(e=>e.map((i,s)=>s===0||t===void 0?i:gt(i,t)).join(" ")).join(" ");function la(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 Tf extends fh{constructor(t){let{allowTouchScrolling:e=!1,containerClass:i=""}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};super(t),b(this,"upper",void 0),b(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=Fe();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=Ds().createElement("div");return t.setAttribute("data-fabric","wrapper"),la(t,{position:"relative"}),Il(t),t}applyCanvasStyle(t,e){const{styles:i,allowTouchScrolling:s}=e;la(t,_(_({},i),{},{"touch-action":s?"manipulation":ce})),Il(t)}setDimensions(t,e){super.setDimensions(t,e);const{el:i,ctx:s}=this.upper;ph(i,s,t,e)}setCSSDimensions(t){super.setCSSDimensions(t),Qo(this.upper.el,t),Qo(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(),Ve().dispose(this.upper.el),delete this.upper,delete this.container}}class oo extends Dr{constructor(){super(...arguments),b(this,"targets",[]),b(this,"_hoveredTargets",[]),b(this,"_objectsToRender",void 0),b(this,"_currentTransform",null),b(this,"_groupSelector",null),b(this,"contextTopDirty",!1)}static getDefaults(){return _(_({},super.getDefaults()),oo.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 Tf(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 Ap(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===Qn||e===ue||e===Te||e===ur?s=this.centeredScaling||t.centeredScaling:e===Ia&&(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=Ct:["mr","tr","br"].includes(e)&&(i.x=it),["tl","mt","tr"].includes(e)?i.y=Jo:["bl","mb","br"].includes(e)&&(i.y=le)),i}_setupCurrentTransform(t,e,i){var s;const r=e.group?Cs(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):Xd,c=((p,f,g,m)=>{if(!f||!p)return"drag";const v=m.controls[f];return v.getActionName(g,v,m)})(i,o,t,e),h=t[this.centeredKey],u=this._shouldCenterTransform(e,c,h)?{x:K,y:K}: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:Et(e.angle),width:e.width,height:e.height,shiftKey:t.shiftKey,altKey:h,original:_(_({},gh(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 w(e,i).transform(this.viewportTransform),a=new w(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,Kt.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,ta(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=ui(h)*r,d=di(h)*r,p=u+d,f=u-d;i=[new w(o.x-f,o.y-p),new w(a.x+p,a.y-f),new w(l.x+f,l.y+p),new w(c.x-p,c.y+f)]}return ft.isPointInPolygon(e,i)}_checkTarget(t,e){return!!(t&&t.visible&&t.evented&&this._pointIsInObjectSelectionArea(t,Cs(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(wn(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&&wn(i)&&i.interactive&&this.targets[0]){const s=this.targets;for(let r=s.length-1;r>0;r--){const o=s[r];if(!wn(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=zd(t),o=s.width||0,a=s.height||0;o&&a||(le in s&&Jo in s&&(a=Math.abs(s.top-s.bottom)),Ct in s&&it 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=Cs(r,void 0,this.viewportTransform));const l=this.getRetinaScaling();l!==1&&(r.x/=l,r.y/=l);const c=o===0||a===0?new w(1,1):new w(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=Fe(),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 Wi(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,Wi(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),Wi(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(Fn,s))}setViewportTransform(t){super.setViewportTransform(t);const e=this._activeObject;e&&e.setCoords()}destroy(){const t=this._activeObject;Wi(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&&Wi(e)&&this._activeObject===e){const i=Ls(t,["angle","flipX","flipY",it,ue,Te,Ms,Is,le]);return Vd(t,e.calcOwnMatrix()),i}return{}}_setSVGObject(t,e,i){const s=this._realizeGroupTransformOnObject(e);super._setSVGObject(t,e,i),e.set(s)}}b(oo,"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 Ef{constructor(t){b(this,"targets",[]),b(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),ps(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 Of=["target","oldTarget","fireCanvas","e"],fe={passive:!1},us=(n,t)=>{const e=n.getViewportPoint(t),i=n.getScenePoint(t);return{viewportPoint:e,scenePoint:i,pointer:e,absolutePointer:i}},yi=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)},ye=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)},kf={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 mr extends oo{constructor(t){super(t,arguments.length>1&&arguments[1]!==void 0?arguments[1]:{}),b(this,"_isClick",void 0),b(this,"textEditingManager",new Ef(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(yi,"add")}_getEventPrefix(){return this.enablePointerEvents?"pointer":"mouse"}addOrRemove(t,e){const i=this.upperCanvasEl,s=this._getEventPrefix();t(dh(i),"resize",this._onResize),t(i,s+"down",this._onMouseDown),t(i,"".concat(s,"move"),this._onMouseMove,fe),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,fe)}removeListeners(){this.addOrRemove(ye,"remove");const t=this._getEventPrefix(),e=De(this.upperCanvasEl);ye(e,"".concat(t,"up"),this._onMouseUp),ye(e,"touchend",this._onTouchEnd,fe),ye(e,"".concat(t,"move"),this._onMouseMove,fe),ye(e,"touchmove",this._onMouseMove,fe),clearTimeout(this._willAddMouseDown)}_onMouseWheel(t){this.__onMouseWheel(t)}_onMouseOut(t){const e=this._hoveredTarget,i=_({e:t},us(this,t));this.fire("mouse:out",_(_({},i),{},{target:e})),this._hoveredTarget=void 0,e&&e.fire("mouseout",_({},i)),this._hoveredTargets.forEach(s=>{this.fire("mouse:out",_(_({},i),{},{target:s})),s&&s.fire("mouseout",_({},i))}),this._hoveredTargets=[]}_onMouseEnter(t){this._currentTransform||this.findTarget(t)||(this.fire("mouse:over",_({e:t},us(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 yi(this.upperCanvasEl,"drag",this._onDragProgress)}ea(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!==ce,i=e?this._activeObject:void 0,s={e:t,target:this._dragSource,subTargets:this.targets,dragSource:this._dragSource,didDrop:e,dropTarget:i};ye(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",_({e:t,target:e,subTargets:i,dragSource:this._dragSource},us(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&&ea(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=De(s);yi(o,"touchend",this._onTouchEnd,fe),e&&yi(o,"touchmove",this._onMouseMove,fe),ye(s,"".concat(r,"down"),this._onMouseDown)}_onMouseDown(t){this.__onMouseDown(t),this._resetTransformEventData();const e=this.upperCanvasEl,i=this._getEventPrefix();ye(e,"".concat(i,"move"),this._onMouseMove,fe);const s=De(e);yi(s,"".concat(i,"up"),this._onMouseUp),yi(s,"".concat(i,"move"),this._onMouseMove,fe)}_onTouchEnd(t){if(t.touches.length>0)return;this.__onMouseUp(t),this._resetTransformEventData(),delete this.mainTouchId;const e=this._getEventPrefix(),i=De(this.upperCanvasEl);ye(i,"touchend",this._onTouchEnd,fe),ye(i,"touchmove",this._onMouseMove,fe),this._willAddMouseDown&&clearTimeout(this._willAddMouseDown),this._willAddMouseDown=setTimeout(()=>{yi(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=De(this.upperCanvasEl);ye(s,"".concat(i,"up"),this._onMouseUp),ye(s,"".concat(i,"move"),this._onMouseMove,fe),yi(e,"".concat(i,"move"),this._onMouseMove,fe)}}_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),ta(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 p=d.getMouseUpHandler(t,r,d);p&&(a=this.getScenePoint(t),p.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=_(_({e:t,target:i,subTargets:s},us(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),ta(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=Cs(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",_(_({},e),{},{target:t,oldTarget:i,fireCanvas:!0}));for(let a=0;a<o;a++)this.fireSyntheticInOutEvents("drag",_(_({},e),{},{target:r[a],oldTarget:s[a]}));this._draggedoverTarget=t}fireSyntheticInOutEvents(t,e){let{target:i,oldTarget:s,fireCanvas:r,e:o}=e,a=ut(e,Of);const{targetIn:l,targetOut:c,canvasIn:h,canvasOut:u}=kf[t],d=s!==i;if(s&&d){const p=_(_({},a),{},{e:o,target:s,nextTarget:i},us(this,o));r&&this.fire(u,p),s.fire(c,p)}if(i&&d){const p=_(_({},a),{},{e:o,target:i,previousTarget:s},us(this,o));r&&this.fire(h,p),i.fire(l,p)}}__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?Cs(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=Wi(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=Wi(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(R.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 w(e,i),a=o.add(new w(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=R.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 Bh={x1:0,y1:0,x2:0,y2:0},Af=_(_({},Bh),{},{r1:0,r2:0}),vs=(n,t)=>isNaN(n)&&typeof t=="number"?t:n,Pf=/^(\d+\.\d+)%|(\d+)%$/;function Nh(n){return n&&Pf.test(n)}function zh(n,t){const e=typeof n=="number"?n:typeof n=="string"?parseFloat(n)/(Nh(n)?100:1):NaN;return ks(0,vs(e,t),1)}const Df=/\s*;\s*/,Mf=/\s*:\s*/;function If(n,t){let e,i;const s=n.getAttribute("style");if(s){const o=s.split(Df);o[o.length-1]===""&&o.pop();for(let a=o.length;a--;){const[l,c]=o[a].split(Mf).map(h=>h.trim());l==="stop-color"?e=c:l==="stop-opacity"&&(i=c)}}const r=new st(e||n.getAttribute("stop-color")||"rgb(0,0,0)");return{offset:zh(n.getAttribute("offset"),0),color:r.toRgb(),opacity:vs(parseFloat(i||n.getAttribute("stop-opacity")||""),1)*r.getAlpha()*t}}function Lf(n,t){const e=[],i=n.getElementsByTagName("stop"),s=zh(t,1);for(let r=i.length;r--;)e.push(If(i[r],s));return e}function Hh(n){return n.nodeName==="linearGradient"||n.nodeName==="LINEARGRADIENT"?"linear":"radial"}function Vh(n){return n.getAttribute("gradientUnits")==="userSpaceOnUse"?"pixels":"percentage"}function Oe(n,t){return n.getAttribute(t)}function Ff(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"&&Nh(h)&&(s*=.01,a==="pixels"&&(c!=="x1"&&c!=="x2"&&c!=="r2"||(s*=r),c!=="y1"&&c!=="y2"||(s*=o)))),l[c]=s,l},{})}(Hh(n)==="linear"?function(e){return{x1:Oe(e,"x1")||0,y1:Oe(e,"y1")||0,x2:Oe(e,"x2")||"100%",y2:Oe(e,"y2")||0}}(n):function(e){return{x1:Oe(e,"fx")||Oe(e,"cx")||"50%",y1:Oe(e,"fy")||Oe(e,"cy")||"50%",r1:0,x2:Oe(e,"cx")||"50%",y2:Oe(e,"cy")||"50%",r2:Oe(e,"r")||"50%"}}(n),_(_({},t),{},{gradientUnits:Vh(n)}))}class Yr{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:_(_({},e==="radial"?Af:Bh),s),colorStops:r,offsetX:o,offsetY:a,gradientTransform:l,id:c?"".concat(c,"_").concat(Pi()):Pi()})}addColorStop(t){for(const e in t){const i=new st(t[e]);this.colorStops.push({offset:parseFloat(e),color:i.toRgb(),opacity:i.getAlpha()})}return this}toObject(t){return _(_({},Ls(this,t)),{},{type:this.type,coords:_({},this.coords),colorStops:this.colorStops.map(e=>_({},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():ie.concat(),r=this.gradientUnits==="pixels"?"userSpaceOnUse":"objectBoundingBox",o=this.colorStops.map(u=>_({},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($n(s),'"'),""].join(" ");if(this.type==="linear"){const{x1:u,y1:d,x2:p,y2:f}=this.coords;i.push("<linearGradient ",h,' x1="',u,'" y1="',d,'" x2="',p,'" y2="',f,`">
130
168
  `)}else if(this.type==="radial"){const{x1:u,y1:d,x2:p,y2:f,r1:g,r2:m}=this.coords,v=g>m;i.push("<radialGradient ",h,' cx="',v?u:p,'" cy="',v?d:f,'" r="',v?g:m,'" fx="',v?p:u,'" fy="',v?f:d,`">
131
- `),v&&(o.reverse(),o.forEach(x=>{x.offset=1-x.offset}));const y=Math.min(g,m);if(y>0){const x=y/Math.max(g,m);o.forEach(T=>{T.offset+=x*(1-T.offset)})}}return o.forEach(u=>{let{color:d,offset:p,opacity:f}=u;i.push("<stop ",'offset="',100*p+"%",'" style="stop-color:',d,f!==void 0?";stop-opacity: "+f:";",`"/>
169
+ `),v&&(o.reverse(),o.forEach(x=>{x.offset=1-x.offset}));const y=Math.min(g,m);if(y>0){const x=y/Math.max(g,m);o.forEach(E=>{E.offset+=x*(1-E.offset)})}}return o.forEach(u=>{let{color:d,offset:p,opacity:f}=u;i.push("<stop ",'offset="',100*p+"%",'" style="stop-color:',d,f!==void 0?";stop-opacity: "+f:";",`"/>
132
170
  `)}),i.push(this.type==="linear"?"</linearGradient>":"</radialGradient>",`
133
- `),i.join("")}toLive(t){const{x1:e,y1:i,x2:r,y2:s,r1:o,r2:a}=this.coords,l=this.type==="linear"?t.createLinearGradient(e,i,r,s):t.createRadialGradient(e,i,o,r,s,a);return this.colorStops.forEach(c=>{let{color:h,opacity:u,offset:d}=c;l.addColorStop(d,u!==void 0?new rt(h).setAlpha(u).toRgba():h)}),l}static async fromObject(t){const{colorStops:e,gradientTransform:i}=t;return new this(_(_({},t),{},{colorStops:e?e.map(r=>_({},r)):void 0,gradientTransform:i?[...i]:void 0}))}static fromElement(t,e,i){const r=Yc(t),s=e._findCenterFromElement();return new this(_({id:t.getAttribute("id")||void 0,type:Uc(t),coords:Cp(t,{width:i.viewBoxWidth||i.width,height:i.viewBoxHeight||i.height}),colorStops:wp(t,i.opacity),gradientUnits:r,gradientTransform:Do(t.getAttribute("gradientTransform")||"")},r==="pixels"?{offsetX:e.width/2-s.x,offsetY:e.height/2-s.y}:{offsetX:0,offsetY:0}))}}b(ks,"type","Gradient"),R.setClass(ks,"gradient"),R.setClass(ks,"linear"),R.setClass(ks,"radial");const Sp=["type","source","patternTransform"];class so{get type(){return"pattern"}set type(t){yi("warn","Setting type has no effect",t)}constructor(t){b(this,"repeat","repeat"),b(this,"offsetX",0),b(this,"offsetY",0),b(this,"crossOrigin",""),this.id=xi(),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 _(_({},yr(this,t)),{},{type:"pattern",source:this.sourceToString(),repeat:e,crossOrigin:i,offsetX:ft(this.offsetX,Q.NUM_FRACTION_DIGITS),offsetY:ft(this.offsetY,Q.NUM_FRACTION_DIGITS),patternTransform:this.patternTransform?[...this.patternTransform]:null})}toSVG(t){let{width:e,height:i}=t;const{source:r,repeat:s,id:o}=this,a=sr(this.offsetX/e,0),l=sr(this.offsetY/i,0),c=s==="repeat-y"||s==="no-repeat"?1+Math.abs(a||0):sr(r.width/e,0),h=s==="repeat-x"||s==="no-repeat"?1+Math.abs(l||0):sr(r.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(r.width,'" height="').concat(r.height,'" xlink:href="').concat(this.sourceToString(),'"></image>'),"</pattern>",""].join(`
134
- `)}static async fromObject(t,e){let{type:i,source:r,patternTransform:s}=t,o=ht(t,Sp);const a=await sn(r,_(_({},e),{},{crossOrigin:o.crossOrigin}));return new this(_(_({},o),{},{patternTransform:s&&s.slice(0),source:a}))}}b(so,"type","Pattern"),R.setClass(so),R.setClass(so,"pattern");const Tp=["path","left","top"],Ep=["d"];class Ri extends Yt{constructor(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},{path:i,left:r,top:s}=e,o=ht(e,Tp);super(),Object.assign(this,Ri.ownDefaults),this.setOptions(o),this._setPath(t||[],!0),typeof r=="number"&&this.set(it,r),typeof s=="number"&&this.set(ne,s)}_setPath(t,e){this.path=ip(Array.isArray(t)?t:up(t)),this.setBoundingBox(e)}_findCenterFromElement(){const t=this._calcBoundsFromPath();return new w(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 r of this.path)switch(r[0]){case"L":t.lineTo(r[1]+e,r[2]+i);break;case"M":t.moveTo(r[1]+e,r[2]+i);break;case"C":t.bezierCurveTo(r[1]+e,r[2]+i,r[3]+e,r[4]+i,r[5]+e,r[6]+i);break;case"Q":t.quadraticCurveTo(r[1]+e,r[2]+i,r[3]+e,r[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 _(_({},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=dp(this.path,Q.NUM_FRACTION_DIGITS);return["<path ","COMMON_PARTS",'d="'.concat(t,`" stroke-linecap="round" />
135
- `)]}_getOffsetTransform(){const t=Q.NUM_FRACTION_DIGITS;return" translate(".concat(ft(-this.pathOffset.x,t),", ").concat(ft(-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:r}=this._calcDimensions();this.set({width:e,height:i,pathOffset:r}),t&&this.setPositionByOrigin(r,K,K)}_calcBoundsFromPath(){const t=[];let e=0,i=0,r=0,s=0;for(const o of this.path)switch(o[0]){case"L":r=o[1],s=o[2],t.push({x:e,y:i},{x:r,y:s});break;case"M":r=o[1],s=o[2],e=r,i=s;break;case"C":t.push(...pl(r,s,o[1],o[2],o[3],o[4],o[5],o[6])),r=o[5],s=o[6];break;case"Q":t.push(...pl(r,s,o[1],o[2],o[1],o[2],o[3],o[4])),r=o[3],s=o[4];break;case"Z":r=e,s=i}return ii(t)}_calcDimensions(){const t=this._calcBoundsFromPath();return _(_({},t),{},{pathOffset:new w(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 r=di(t,this.ATTRIBUTE_NAMES,i),{d:s}=r;return new this(s,_(_(_({},ht(r,Ep)),e),{},{left:void 0,top:void 0}))}}b(Ri,"type","Path"),b(Ri,"cacheProperties",[...ui,"path","fillRule"]),b(Ri,"ATTRIBUTE_NAMES",[...Di,"d"]),R.setClass(Ri),R.setSVGClass(Ri);const Op=["left","top","radius"],Xc=["radius","startAngle","endAngle","counterClockwise"];class Xe extends Yt{static getDefaults(){return _(_({},super.getDefaults()),Xe.ownDefaults)}constructor(t){super(),Object.assign(this,Xe.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,Ct(this.startAngle),Ct(this.endAngle),this.counterClockwise),this._renderPaintInOrder(t)}getRadiusX(){return this.get("radius")*this.get(le)}getRadiusY(){return this.get("radius")*this.get(xe)}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([...Xc,...t])}_toSVG(){const t=(this.endAngle-this.startAngle)%360;if(t===0)return["<circle ","COMMON_PARTS",'cx="0" cy="0" ','r="',"".concat(this.radius),`" />
136
- `];{const{radius:e}=this,i=Ct(this.startAngle),r=Ct(this.endAngle),s=oi(i)*e,o=ai(i)*e,a=oi(r)*e,l=ai(r)*e,c=t>180?1:0,h=this.counterClockwise?0:1;return['<path d="M '.concat(s," ").concat(o," A ").concat(e," ").concat(e," 0 ").concat(c," ").concat(h," ").concat(a," ").concat(l,'" '),"COMMON_PARTS",` />
137
- `]}}static async fromElement(t,e,i){const r=di(t,this.ATTRIBUTE_NAMES,i),{left:s=0,top:o=0,radius:a=0}=r;return new this(_(_({},ht(r,Op)),{},{radius:a,left:s-a,top:o-a}))}static fromObject(t){return super._fromObject(t)}}b(Xe,"type","Circle"),b(Xe,"cacheProperties",[...ui,...Xc]),b(Xe,"ownDefaults",{radius:0,startAngle:0,endAngle:360,counterClockwise:!1}),b(Xe,"ATTRIBUTE_NAMES",["cx","cy","r",...Di]),R.setClass(Xe),R.setSVGClass(Xe);const kp=["x1","y1","x2","y2"],Dp=["x1","y1","x2","y2"],Io=["x1","x2","y1","y2"];class Bi extends Yt{constructor(){let[t,e,i,r]=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[0,0,0,0],s=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};super(),Object.assign(this,Bi.ownDefaults),this.setOptions(s),this.x1=t,this.x2=i,this.y1=e,this.y2=r,this._setWidthHeight();const{left:o,top:a}=s;typeof o=="number"&&this.set(it,o),typeof a=="number"&&this.set(ne,a)}_setWidthHeight(){const{x1:t,y1:e,x2:i,y2:r}=this;this.width=Math.abs(i-t),this.height=Math.abs(r-e);const{left:s,top:o,width:a,height:l}=ii([{x:t,y:e},{x:i,y:r}]),c=new w(s+a/2,o+l/2);this.setPositionByOrigin(c,K,K)}_set(t,e){return super._set(t,e),Io.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 r;_e(this.stroke)?t.strokeStyle=this.stroke.toLive(t):t.strokeStyle=(r=this.stroke)!==null&&r!==void 0?r:t.fillStyle,this.stroke&&this._renderStroke(t),t.strokeStyle=i}_findCenterFromElement(){return new w((this.x1+this.x2)/2,(this.y1+this.y2)/2)}toObject(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[];return _(_({},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:r,width:s,height:o}=this,a=t<=e?-1:1,l=i<=r?-1:1;return{x1:a*s/2,x2:a*-s/2,y1:l*o/2,y2:l*-o/2}}_toSVG(){const{x1:t,x2:e,y1:i,y2:r}=this.calcLinePoints();return["<line ","COMMON_PARTS",'x1="'.concat(t,'" y1="').concat(i,'" x2="').concat(e,'" y2="').concat(r,`" />
138
- `)]}static async fromElement(t,e,i){const r=di(t,this.ATTRIBUTE_NAMES,i),{x1:s=0,y1:o=0,x2:a=0,y2:l=0}=r;return new this([s,o,a,l],ht(r,kp))}static fromObject(t){let{x1:e,y1:i,x2:r,y2:s}=t,o=ht(t,Dp);return this._fromObject(_(_({},o),{},{points:[e,i,r,s]}),{extraParam:"points"})}}b(Bi,"type","Line"),b(Bi,"cacheProperties",[...ui,...Io]),b(Bi,"ATTRIBUTE_NAMES",Di.concat(Io)),R.setClass(Bi),R.setSVGClass(Bi);class zi extends Yt{static getDefaults(){return _(_({},super.getDefaults()),zi.ownDefaults)}constructor(t){super(),Object.assign(this,zi.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),'" />']}}b(zi,"type","Triangle"),b(zi,"ownDefaults",{width:100,height:100}),R.setClass(zi),R.setSVGClass(zi);const Kc=["rx","ry"];class Ke extends Yt{static getDefaults(){return _(_({},super.getDefaults()),Ke.ownDefaults)}constructor(t){super(),Object.assign(this,Ke.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(le)}getRy(){return this.get("ry")*this.get(xe)}toObject(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[];return super.toObject([...Kc,...t])}_toSVG(){return["<ellipse ","COMMON_PARTS",'cx="0" cy="0" rx="'.concat(this.rx,'" ry="').concat(this.ry,`" />
139
- `)]}_render(t){t.beginPath(),t.save(),t.transform(1,0,0,this.ry/this.rx,0,0),t.arc(0,0,this.rx,0,un,!1),t.restore(),this._renderPaintInOrder(t)}static async fromElement(t,e,i){const r=di(t,this.ATTRIBUTE_NAMES,i);return r.left=(r.left||0)-r.rx,r.top=(r.top||0)-r.ry,new this(r)}}function Pp(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}b(Ke,"type","Ellipse"),b(Ke,"cacheProperties",[...ui,...Kc]),b(Ke,"ownDefaults",{rx:0,ry:0}),b(Ke,"ATTRIBUTE_NAMES",[...Di,"cx","cy","rx","ry"]),R.setClass(Ke),R.setSVGClass(Ke);const Ap=["left","top"],qc={exactBoundingBox:!1};class Te extends Yt{static getDefaults(){return _(_({},super.getDefaults()),Te.ownDefaults)}constructor(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[],e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};super(),b(this,"strokeDiff",void 0),Object.assign(this,Te.ownDefaults),this.setOptions(e),this.points=t;const{left:i,top:r}=e;this.initialized=!0,this.setBoundingBox(!0),typeof i=="number"&&this.set(it,i),typeof r=="number"&&this.set(ne,r)}isOpen(){return!0}_projectStrokeOnPoints(t){return yd(this.points,t,this.isOpen())}_calcDimensions(t){t=_({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 w,strokeOffset:new w,strokeDiff:new w};const i=ii(e),r=An(_(_({},t),{},{scaleX:1,scaleY:1})),s=ii(this.points.map(c=>re(c,r,!0))),o=new w(this.scaleX,this.scaleY);let a=i.left+i.width/2,l=i.top+i.height/2;return this.exactBoundingBox&&(a-=l*Math.tan(Ct(this.skewX)),l-=a*Math.tan(Ct(this.skewY))),_(_({},i),{},{pathOffset:new w(a,l),strokeOffset:new w(s.left,s.top).subtract(new w(i.left,i.top)).multiply(o),strokeDiff:new w(i.width,i.height).subtract(new w(s.width,s.height)).multiply(o)})}_findCenterFromElement(){const t=ii(this.points);return new w(t.left+t.width/2,t.top+t.height/2)}setDimensions(){this.setBoundingBox()}setBoundingBox(t){const{left:e,top:i,width:r,height:s,pathOffset:o,strokeOffset:a,strokeDiff:l}=this._calcDimensions();this.set({width:r,height:s,pathOffset:o,strokeOffset:a,strokeDiff:l}),t&&this.setPositionByOrigin(new w(e+r/2,i+s/2),K,K)}isStrokeAccountedForInDimensions(){return this.exactBoundingBox}_getNonTransformedDimensions(){return this.exactBoundingBox?new w(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 w((e=t.width)!==null&&e!==void 0?e:a,(i=t.height)!==null&&i!==void 0?i:l)}else{var r,s;o=new w((r=t.width)!==null&&r!==void 0?r:this.width,(s=t.height)!==null&&s!==void 0?s:this.height)}return o.multiply(new w(t.scaleX||this.scaleX,t.scaleY||this.scaleY))}return super._getTransformedDimensions(t)}_set(t,e){const i=this.initialized&&this[t]!==e,r=super._set(t,e);return this.exactBoundingBox&&i&&((t===le||t===xe)&&this.strokeUniform&&this.constructor.layoutProperties.includes("strokeUniform")||this.constructor.layoutProperties.includes(t))&&this.setDimensions(),r}toObject(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[];return _(_({},super.toObject(t)),{},{points:this.points.map(e=>{let{x:i,y:r}=e;return{x:i,y:r}})})}_toSVG(){const t=[],e=this.pathOffset.x,i=this.pathOffset.y,r=Q.NUM_FRACTION_DIGITS;for(let s=0,o=this.points.length;s<o;s++)t.push(ft(this.points[s].x-e,r),",",ft(this.points[s].y-i,r)," ");return["<".concat(this.constructor.type.toLowerCase()," "),"COMMON_PARTS",'points="'.concat(t.join(""),`" />
140
- `)]}_render(t){const e=this.points.length,i=this.pathOffset.x,r=this.pathOffset.y;if(e&&!isNaN(this.points[e-1].y)){t.beginPath(),t.moveTo(this.points[0].x-i,this.points[0].y-r);for(let s=0;s<e;s++){const o=this.points[s];t.lineTo(o.x-i,o.y-r)}!this.isOpen()&&t.closePath(),this._renderPaintInOrder(t)}}complexity(){return this.points.length}static async fromElement(t,e,i){return new this(Pp(t.getAttribute("points")),_(_({},ht(di(t,this.ATTRIBUTE_NAMES,i),Ap)),e))}static fromObject(t){return this._fromObject(t,{extraParam:"points"})}}b(Te,"ownDefaults",qc),b(Te,"type","Polyline"),b(Te,"layoutProperties",[br,_r,"strokeLineCap","strokeLineJoin","strokeMiterLimit","strokeWidth","strokeUniform","points"]),b(Te,"cacheProperties",[...ui,"points"]),b(Te,"ATTRIBUTE_NAMES",[...Di]),R.setClass(Te),R.setSVGClass(Te);class Ds extends Te{isOpen(){return!1}}b(Ds,"ownDefaults",qc),b(Ds,"type","Polygon"),R.setClass(Ds),R.setSVGClass(Ds);const Zc=["fontSize","fontWeight","fontFamily","fontStyle"],Jc=["underline","overline","linethrough"],Qc=[...Zc,"lineHeight","text","charSpacing","textAlign","styles","path","pathStartOffset","pathSide","pathAlign"],th=[...Qc,...Jc,"textBackgroundColor","direction"],Mp=[...Zc,...Jc,ae,"strokeWidth",It,"deltaY","textBackgroundColor"],Ip={_reNewline:ia,_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:it,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:it,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},Le="justify",wn="justify-left",Hr="justify-right",$r="justify-center";class eh extends Yt{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 r in e[i])for(const s in e[i][r])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 r in i)for(const s in i[r])if(i[r][s][t]!==void 0)return!0;return!1}cleanStyle(t){if(!this.styles)return!1;const e=this.styles;let i,r,s=0,o=!0,a=0;for(const l in e){i=0;for(const c in e[l]){const h=e[l][c]||{};s++,h[t]!==void 0?(r?h[t]!==r&&(o=!1):r=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&&s===a&&(this[t]=r,this.removeStyle(t))}removeStyle(t){if(!this.styles)return;const e=this.styles;let i,r,s;for(r in e){for(s in i=e[r],i)delete i[s][t],Object.keys(i[s]).length===0&&delete i[s];Object.keys(i).length===0&&delete e[r]}}_extendStyles(t,e){const{lineIndex:i,charIndex:r}=this.get2DCursorLocation(t);this._getLineStyle(i)||this._setLineStyle(i);const s=aa(_(_({},this._getStyleDeclaration(i,r)),e),o=>o!==void 0);this._setStyleDeclaration(i,r,s)}getSelectionStyles(t,e,i){const r=[];for(let s=t;s<(e||t);s++)r.push(this.getStyleAtPosition(s,i));return r}getStyleAtPosition(t,e){const{lineIndex:i,charIndex:r}=this.get2DCursorLocation(t);return e?this.getCompleteStyleDeclaration(i,r):this._getStyleDeclaration(i,r)}setSelectionStyles(t,e,i){for(let r=e;r<(i||e);r++)this._extendStyles(r,t);this._forceClearCache=!0}_getStyleDeclaration(t,e){var i;const r=this.styles&&this.styles[t];return r&&(i=r[e])!==null&&i!==void 0?i:{}}getCompleteStyleDeclaration(t,e){return _(_({},yr(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]}}b(eh,"_styleProperties",Mp);const Lp=/ +/g,Fp=/"/g;function no(n,t,e,i,r){return" ".concat(function(s,o){let{left:a,top:l,width:c,height:h}=o,u=arguments.length>2&&arguments[2]!==void 0?arguments[2]:Q.NUM_FRACTION_DIGITS;const d=Kr(It,s,!1),[p,f,g,m]=[a,l,c,h].map(v=>ft(v,u));return"<rect ".concat(d,' x="').concat(p,'" y="').concat(f,'" width="').concat(g,'" height="').concat(m,'"></rect>')}(n,{left:t,top:e,width:i,height:r}),`
141
- `)}const jp=["textAnchor","textDecoration","dx","dy","top","left","fontSize","strokeWidth"];let oo;class Zt extends eh{static getDefaults(){return _(_({},super.getDefaults()),Zt.ownDefaults)}constructor(t,e){super(),b(this,"__charBounds",[]),Object.assign(this,Zt.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=Hc(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(Le)&&this.enlargeSpaces()}enlargeSpaces(){let t,e,i,r,s,o,a;for(let l=0,c=this._textLines.length;l<c;l++)if((this.textAlign===Le||l!==c-1&&!this.isEndOfWrapping(l))&&(r=0,s=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<=s.length;h++)o=this.__charBounds[l][h],this._reSpaceAndTab.test(s[h])?(o.width+=t,o.kernedWidth+=t,o.left+=r,r+=t):o.left+=r}}isEndOfWrapping(t){return t===this._textLines.length-1}missingNewlineOffset(t){return 1}get2DCursorLocation(t,e){const i=e?this._unwrappedTextLines:this._textLines;let r;for(r=0;r<i.length;r++){if(t<=i[r].length)return{lineIndex:r,charIndex:t};t-=i[r].length+this.missingNewlineOffset(r,e)}return{lineIndex:r-1,charIndex:i[r-1].length<t?i[r-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===ae?(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 K:t.textBaseline="middle";break;case"ascender":t.textBaseline=ne;break;case"descender":t.textBaseline=wo}t.font=this._getFontDeclaration(e,i)}calcTextWidth(){let t=this.getLineWidth(0);for(let e=1,i=this._textLines.length;e<i;e++){const r=this.getLineWidth(e);r>t&&(t=r)}return t}_renderTextLine(t,e,i,r,s,o){this._renderChars(t,e,i,r,s,o)}_renderTextLinesBackground(t){if(!this.textBackgroundColor&&!this.styleHas("textBackgroundColor"))return;const e=t.fillStyle,i=this._getLeftOffset();let r=this._getTopOffset();for(let s=0,o=this._textLines.length;s<o;s++){const a=this.getHeightOfLine(s);if(!this.textBackgroundColor&&!this.styleHas("textBackgroundColor",s)){r+=a;continue}const l=this._textLines[s].length,c=this._getLineLeftOffset(s);let h,u,d=0,p=0,f=this.getValueOfPropertyAt(s,0,"textBackgroundColor");for(let g=0;g<l;g++){const m=this.__charBounds[s][g];u=this.getValueOfPropertyAt(s,g,"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!==f?(h=i+c+p,this.direction==="rtl"&&(h=this.width-h-d),t.fillStyle=f,f&&t.fillRect(h,r,d,a/this.lineHeight),p=m.left,d=m.width,f=u):d+=m.kernedWidth}u&&!this.path&&(h=i+c+p,this.direction==="rtl"&&(h=this.width-h-d),t.fillStyle=u,t.fillRect(h,r,d,a/this.lineHeight)),r+=a}t.fillStyle=e,this._removeShadow(t)}_measureChar(t,e,i,r){const s=zr.getFontCache(e),o=this._getFontDeclaration(e),a=i+t,l=i&&o===this._getFontDeclaration(r),c=e.fontSize/this.CACHE_FONT_SIZE;let h,u,d,p;if(i&&s[i]!==void 0&&(d=s[i]),s[t]!==void 0&&(p=h=s[t]),l&&s[a]!==void 0&&(u=s[a],p=u-d),h===void 0||d===void 0||u===void 0){const f=function(){return oo||(oo=Ne({width:0,height:0}).getContext("2d")),oo}();this._setTextStyles(f,e,!0),h===void 0&&(p=h=f.measureText(t).width,s[t]=h),d===void 0&&l&&i&&(d=f.measureText(i).width,s[i]=d),l&&u===void 0&&(u=f.measureText(a).width,s[a]=u,p=u-d)}return{width:h*c,kernedWidth:p*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,r=0;const s=this.pathSide===xt,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,r+=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 it:h=s?u-r:0;break;case K:h=(u-r)/2;break;case xt:h=s?0:u-r}h+=this.pathStartOffset*(s?-1:1);for(let d=s?l-1:0;s?d>=0:d<l;s?d--:d++)i=c[d],h>u?h%=u:h<0&&(h+=u),this._setGraphemeOnPath(h,i),h+=i.kernedWidth}return{width:r,numOfSpaces:0}}_setGraphemeOnPath(t,e){const i=t+e.kernedWidth/2,r=this.path,s=ap(r.path,i,r.segmentsInfo);e.renderLeft=s.x-r.pathOffset.x,e.renderTop=s.y-r.pathOffset.y,e.angle=s.angle+(this.pathSide===xt?Math.PI:0)}_getGraphemeBox(t,e,i,r,s){const o=this.getCompleteStyleDeclaration(e,i),a=r?this.getCompleteStyleDeclaration(e,i-1):{},l=this._measureChar(t,o,r,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&&!s){const p=this.__charBounds[e][i-1];d.left=p.left+p.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,r=this._textLines[t].length;i<r;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,r=this._textLines.length;i<r;i++)t=this.getHeightOfLine(i),e+=i===r-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 r=this._getLeftOffset(),s=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],r+h,s+i+c,o),i+=l}t.restore()}_renderTextFill(t){(this.fill||this.styleHas(It))&&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,r,s,o){const a=this.getHeightOfLine(o),l=this.textAlign.includes(Le),c=this.path,h=!l&&this.charSpacing===0&&this.isEmptyStyles(o)&&!c,u=this.direction==="ltr",d=this.direction==="ltr"?1:-1,p=e.direction;let f,g,m,v,y,x="",T=0;if(e.save(),p!==this.direction&&(e.canvas.setAttribute("dir",u?"ltr":"rtl"),e.direction=u?"ltr":"rtl",e.textAlign=u?it:xt),s-=a*this._fontSizeFraction/this.lineHeight,h)return this._renderChar(t,e,o,0,i.join(""),r,s),void e.restore();for(let E=0,A=i.length-1;E<=A;E++)v=E===A||this.charSpacing||c,x+=i[E],m=this.__charBounds[o][E],T===0?(r+=d*(m.kernedWidth-m.width),T+=m.width):T+=m.kernedWidth,l&&!v&&this._reSpaceAndTab.test(i[E])&&(v=!0),v||(f=f||this.getCompleteStyleDeclaration(o,E),g=this.getCompleteStyleDeclaration(o,E+1),v=ga(f,g,!1)),v&&(c?(e.save(),e.translate(m.renderLeft,m.renderTop),e.rotate(m.angle),this._renderChar(t,e,o,E,x,-T/2,0),e.restore()):(y=r,this._renderChar(t,e,o,E,x,y,s)),x="",f=g,r+=d*T,T=0);e.restore()}_applyPatternGradientTransformText(t){const e=this.width+this.strokeWidth,i=this.height+this.strokeWidth,r=Ne({width:e,height:i}),s=r.getContext("2d");return r.width=e,r.height=i,s.beginPath(),s.moveTo(0,0),s.lineTo(e,0),s.lineTo(e,i),s.lineTo(0,i),s.closePath(),s.translate(e/2,i/2),s.fillStyle=t.toLive(s),this._applyPatternGradientTransform(s,t),s.fill(),s.createPattern(r,"no-repeat")}handleFiller(t,e,i){let r,s;return _e(i)?i.gradientUnits==="percentage"||i.gradientTransform||i.patternTransform?(r=-this.width/2,s=-this.height/2,t.translate(r,s),t[e]=this._applyPatternGradientTransformText(i),{offsetX:r,offsetY:s}):(t[e]=i.toLive(t),this._applyPatternGradientTransform(t,i)):(t[e]=i,{offsetX:0,offsetY:0})}_setStrokeStyles(t,e){let{stroke:i,strokeWidth:r}=e;return t.lineWidth=r,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,r,s,o,a){const l=this._getStyleDeclaration(i,r),c=this.getCompleteStyleDeclaration(i,r),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(s,o-d.offsetX,a-d.offsetY)}if(u){const d=this._setStrokeStyles(e,c);e.strokeText(s,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 r=this.get2DCursorLocation(t,!0),s=this.getValueOfPropertyAt(r.lineIndex,r.charIndex,"fontSize"),o=this.getValueOfPropertyAt(r.lineIndex,r.charIndex,"deltaY"),a={fontSize:s*i.size,deltaY:o+s*i.baseline};this.setSelectionStyles(a,t,e)}_getLineLeftOffset(t){const e=this.getLineWidth(t),i=this.width-e,r=this.textAlign,s=this.direction,o=this.isEndOfWrapping(t);let a=0;return r===Le||r===$r&&!o||r===Hr&&!o||r===wn&&!o?0:(r===K&&(a=i/2),r===xt&&(a=i),r===$r&&(a=i/2),r===Hr&&(a=i),s==="rtl"&&(r===xt||r===Le||r===Hr?a=0:r===it||r===wn?a=-i:r!==K&&r!==$r||(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 r;return(r=this._getStyleDeclaration(t,e)[i])!==null&&r!==void 0?r:this[i]}_renderTextDecoration(t,e){if(!this[e]&&!this.styleHas(e))return;let i=this._getTopOffset();const r=this._getLeftOffset(),s=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,p=this._getLineLeftOffset(l);let f,g,m=0,v=0,y=this.getValueOfPropertyAt(l,0,e),x=this.getValueOfPropertyAt(l,0,It);const T=i+d*(1-this._fontSizeFraction);let E=this.getHeightOfChar(l,0),A=this.getValueOfPropertyAt(l,0,"deltaY");for(let S=0,F=u.length;S<F;S++){const j=this.__charBounds[l][S];f=this.getValueOfPropertyAt(l,S,e),g=this.getValueOfPropertyAt(l,S,It);const D=this.getHeightOfChar(l,S),k=this.getValueOfPropertyAt(l,S,"deltaY");if(s&&f&&g)t.save(),t.fillStyle=x,t.translate(j.renderLeft,j.renderTop),t.rotate(j.angle),t.fillRect(-j.kernedWidth/2,a*D+k,j.kernedWidth,this.fontSize/15),t.restore();else if((f!==y||g!==x||D!==E||k!==A)&&v>0){let P=r+p+m;this.direction==="rtl"&&(P=this.width-P-v),y&&x&&(t.fillStyle=x,t.fillRect(P,T+a*E+A,v,this.fontSize/15)),m=j.left,v=j.width,y=f,x=g,E=D,A=k}else v+=j.kernedWidth}let C=r+p+m;this.direction==="rtl"&&(C=this.width-C-v),t.fillStyle=g,f&&g&&t.fillRect(C,T+a*E+A,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:r=this.fontSize}=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},s=arguments.length>1?arguments[1]:void 0;const o=t.includes("'")||t.includes('"')||t.includes(",")||Zt.genericFonts.includes(t.toLowerCase())?t:'"'.concat(t,'"');return[e,i,"".concat(s?this.CACHE_FONT_SIZE:r,"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 fa(t)}_splitTextIntoLines(t){const e=t.split(this._reNewline),i=new Array(e.length),r=[`
142
- `];let s=[];for(let o=0;o<e.length;o++)i[o]=this.graphemeSplit(e[o]),s=s.concat(i[o],r);return s.pop(),{_unwrappedLines:i,lines:e,graphemeText:s,graphemeLines:i}}toObject(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[];return _(_({},super.toObject([...th,...t])),{},{styles:Cd(this.styles,this.text)},this.path?{path:this.path.toObject()}:{})}set(t,e){const{textLayoutProperties:i}=this.constructor;super.set(t,e);let r=!1,s=!1;if(typeof t=="object")for(const o in t)o==="path"&&this.setPathInfo(),r=r||i.includes(o),s=s||o==="path";else r=i.includes(t),s=t==="path";return s&&this.setPathInfo(),r&&this.initialized&&(this.initDimensions(),this.setCoords()),this}complexity(){return 1}static async fromElement(t,e,i){const r=di(t,Zt.ATTRIBUTE_NAMES,i),s=_(_({},e),r),{textAnchor:o=it,textDecoration:a="",dx:l=0,dy:c=0,top:h=0,left:u=0,fontSize:d=ea,strokeWidth:p=1}=s,f=ht(s,jp),g=new this((t.textContent||"").replace(/^\s+|\s+$|\n+/g,"").replace(/\s+/g," "),_({left:u+l,top:h+c,underline:a.includes("underline"),overline:a.includes("overline"),linethrough:a.includes("line-through"),strokeWidth:0,fontSize:d},f)),m=g.getScaledHeight()/g.height,v=((g.height+g.strokeWidth)*g.lineHeight-g.height)*m,y=g.getScaledHeight()+v;let x=0;return o===K&&(x=g.getScaledWidth()/2),o===xt&&(x=g.getScaledWidth()),g.set({left:g.left-x,top:g.top-(y-g.fontSize*(.07+g._fontSizeFraction))/g.lineHeight,strokeWidth:p}),g}static fromObject(t){return this._fromObject(_(_({},t),{},{styles:Sd(t.styles||{},t.text)}),{extraParam:"text"})}}b(Zt,"textLayoutProperties",Qc),b(Zt,"cacheProperties",[...ui,...th]),b(Zt,"ownDefaults",Ip),b(Zt,"type","Text"),b(Zt,"genericFonts",["serif","sans-serif","monospace","cursive","fantasy","system-ui","ui-serif","ui-sans-serif","ui-monospace","ui-rounded","math","emoji","fangsong"]),b(Zt,"ATTRIBUTE_NAMES",Di.concat("x","y","dx","dy","font-family","font-style","font-weight","font-size","letter-spacing","text-decoration","text-anchor")),Ic(Zt,[class extends Sc{_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(Fp,"'"),'" '):"",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>
143
- `]}_getSVGTextAndBg(n,t){const e=[],i=[];let r,s=n;this.backgroundColor&&i.push(...no(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),this.direction==="rtl"&&(r+=this.width),(this.textBackgroundColor||this.styleHas("textBackgroundColor",o))&&this._setSVGTextLineBg(i,o,t+r,s),this._setSVGTextLineText(e,o,t+r,s),s+=this.getHeightOfLine(o);return{textSpans:e,textBgRects:i}}_createTextCharSpan(n,t,e,i){const r=this.getSvgSpanStyles(t,n!==n.trim()||!!n.match(Lp)),s=r?'style="'.concat(r,'"'):"",o=t.deltaY,a=o?' dy="'.concat(ft(o,Q.NUM_FRACTION_DIGITS),'" '):"";return'<tspan x="'.concat(ft(e,Q.NUM_FRACTION_DIGITS),'" y="').concat(ft(i,Q.NUM_FRACTION_DIGITS),'" ').concat(a).concat(s,">").concat(xd(n),"</tspan>")}_setSVGTextLineText(n,t,e,i){const r=this.getHeightOfLine(t),s=this.textAlign.includes(Le),o=this._textLines[t];let a,l,c,h,u,d="",p=0;i+=r*(1-this._fontSizeFraction)/this.lineHeight;for(let f=0,g=o.length-1;f<=g;f++)u=f===g||this.charSpacing,d+=o[f],c=this.__charBounds[t][f],p===0?(e+=c.kernedWidth-c.width,p+=c.width):p+=c.kernedWidth,s&&!u&&this._reSpaceAndTab.test(o[f])&&(u=!0),u||(a=a||this.getCompleteStyleDeclaration(t,f),l=this.getCompleteStyleDeclaration(t,f+1),u=ga(a,l,!0)),u&&(h=this._getStyleDeclaration(t,f),n.push(this._createTextCharSpan(d,h,e,i)),d="",a=l,this.direction==="rtl"?e-=p:e+=p,p=0)}_setSVGTextLineBg(n,t,e,i){const r=this._textLines[t],s=this.getHeightOfLine(t)/this.lineHeight;let o,a=0,l=0,c=this.getValueOfPropertyAt(t,0,"textBackgroundColor");for(let h=0;h<r.length;h++){const{left:u,width:d,kernedWidth:p}=this.__charBounds[t][h];o=this.getValueOfPropertyAt(t,h,"textBackgroundColor"),o!==c?(c&&n.push(...no(c,e+l,i,a,s)),l=u,a=d,c=o):a+=p}o&&n.push(...no(c,e+l,i,a,s))}_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:r,fill:s,fontSize:o,fontStyle:a,fontWeight:l,deltaY:c}=n,h=this.getSvgTextDecoration(n);return[r?Kr(ae,r):"",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,"; "),s?Kr(It,s):"",c?"baseline-shift: ".concat(-c,"; "):"",t?"white-space: pre; ":""].join("")}getSvgTextDecoration(n){return["overline","underline","line-through"].filter(t=>n[t.replace("-","")]).join(" ")}}]),R.setClass(Zt),R.setSVGClass(Zt);class Rp{constructor(t){b(this,"target",void 0),b(this,"__mouseDownInPlace",!1),b(this,"__dragStartFired",!1),b(this,"__isDraggingOver",!1),b(this,"__dragStartSelection",void 0),b(this,"__dragImageDisposer",void 0),b(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:r,selectionEnd:s}=e;const o=this.target,a=o.canvas,l=new w(o.flipX?-1:1,o.flipY?-1:1),c=o._getCursorBoundaries(r),h=new w(c.left+c.leftOffset,c.top+c.topOffset).multiply(l).transform(o.calcTransformMatrix()),u=a.getScenePoint(t).subtract(h),d=o.getCanvasRetinaScaling(),p=o.getBoundingRect(),f=h.subtract(new w(p.left,p.top)),g=a.viewportTransform,m=f.add(u).transform(g,!0),v=o.backgroundColor,y=pa(o.styles);o.backgroundColor="";const x={stroke:"transparent",fill:"transparent",textBackgroundColor:"transparent"};o.setSelectionStyles(x,0,r),o.setSelectionStyles(x,s,o.text.length),o.dirty=!0;const T=o.toCanvasElement({enableRetinaScaling:a.enableRetinaScaling,viewportTransform:!0});o.backgroundColor=v,o.styles=y,o.dirty=!0,Mo(T,{position:"fixed",left:"".concat(-T.width,"px"),border:oe,width:"".concat(T.width/d,"px"),height:"".concat(T.height/d,"px")}),this.__dragImageDisposer&&this.__dragImageDisposer(),this.__dragImageDisposer=()=>{T.remove()},Oe(t.target||this.target.hiddenTextarea).body.appendChild(T),(i=t.dataTransfer)===null||i===void 0||i.setDragImage(T,m.x,m.y)}onDragStart(t){this.__dragStartFired=!0;const e=this.target,i=this.isActive();if(i&&t.dataTransfer){const r=this.__dragStartSelection={selectionStart:e.selectionStart,selectionEnd:e.selectionEnd},s=e._text.slice(r.selectionStart,r.selectionEnd).join(""),o=_({text:e.text,value:s},r);t.dataTransfer.setData("text/plain",s),t.dataTransfer.setData("application/fabric",JSON.stringify({value:s,styles:e.getSelectionStyles(r.selectionStart,r.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,r=i.defaultPrevented;this.__isDraggingOver=!1,i.preventDefault();let s=(e=i.dataTransfer)===null||e===void 0?void 0:e.getData("text/plain");if(s&&!r){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=s[Math.max(0,s.length-1)],u=0;if(this.__dragStartSelection){const d=this.__dragStartSelection.selectionStart,p=this.__dragStartSelection.selectionEnd;l>d&&l<=p?l=d:l>p&&(l-=p-d),o.removeChars(d,p),delete this.__dragStartSelection}o._reNewline.test(h)&&(o._reNewline.test(o._text[l])||l===o._text.length)&&(s=s.trimEnd()),t.didDrop=!0,t.dropTarget=o,o.insertChars(s,c,l),a.setActiveObject(o),o.enterEditing(i),o.selectionStart=Math.min(l+u,o._text.length),o.selectionEnd=Math.min(o.selectionStart+s.length,o._text.length),o.hiddenTextarea.value=o.text,o._updateTextarea(),o.hiddenTextarea.focus(),o.fire(dn,{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 r=this.target,s=this.target.canvas,{selectionStart:o,selectionEnd:a}=this.__dragStartSelection,l=((i=e.dataTransfer)===null||i===void 0?void 0:i.dropEffect)||oe;l===oe?(r.selectionStart=o,r.selectionEnd=a,r._updateTextarea(),r.hiddenTextarea.focus()):(r.clearContextTop(),l==="move"&&(r.removeChars(o,a),r.selectionStart=r.selectionEnd=o,r.hiddenTextarea&&(r.hiddenTextarea.value=r.text),r._updateTextarea(),r.fire(dn,{index:o,action:"dragend"}),s.fire("text:changed",{target:r}),s.requestRenderAll()),r.exitEditing())}this.__dragImageDisposer&&this.__dragImageDisposer(),delete this.__dragImageDisposer,delete this.__dragStartSelection,this.__isDraggingOver=!1}dispose(){this._dispose&&this._dispose()}}const ml=/[ \n\.,;!\?\-]/;class Bp extends Zt{constructor(){super(...arguments),b(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:r,onComplete:s}=t;return kc({startValue:this._currentCursorOpacity,endValue:e,duration:i,delay:r,onComplete:s,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 r=t>0&&this._reSpace.test(i[t])&&(e===-1||!ia.test(i[t-1]))?t-1:t,s=i[r];for(;r>0&&r<i.length&&!ml.test(s);)r+=e,s=i[r];return e===-1&&ml.test(s)&&r++,r}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;Oe(e).activeElement!==e&&e.focus();const i=this.getSelectionStartFromPointer(t),r=this.selectionStart,s=this.selectionEnd;(i===this.__selectionStartOnMouseDown&&r!==s||r!==i&&s!==i)&&(i>this.__selectionStartOnMouseDown?(this.selectionStart=this.__selectionStartOnMouseDown,this.selectionEnd=i):(this.selectionStart=i,this.selectionEnd=this.__selectionStartOnMouseDown),this.selectionStart===r&&this.selectionEnd===s||(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 r=i.slice(0,t),s=this.graphemeSplit(r).length;if(t===e)return{selectionStart:s,selectionEnd:s};const o=i.slice(t,e);return{selectionStart:s,selectionEnd:s+this.graphemeSplit(o).length}}fromGraphemeToStringSelection(t,e,i){const r=i.slice(0,t).join("").length;return t===e?{selectionStart:r,selectionEnd:r}:{selectionStart:r,selectionEnd:r+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),r=i.lineIndex,s=i.charIndex,o=this.getValueOfPropertyAt(r,s,"fontSize")*this.lineHeight,a=e.leftOffset,l=this.getCanvasRetinaScaling(),c=this.canvas.upperCanvasEl,h=c.width/l,u=c.height/l,d=h-o,p=u-o,f=new w(e.left+a,e.top+e.topOffset+o).transform(this.calcTransformMatrix()).transform(this.canvas.viewportTransform).multiply(new w(c.clientWidth/h,c.clientHeight/u));return f.x<0&&(f.x=0),f.x>d&&(f.x=d),f.y<0&&(f.y=0),f.y>p&&(f.y=p),f.x+=this.canvas._offset.left,f.y+=this.canvas._offset.top,{left:"".concat(f.x,"px"),top:"".concat(f.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(pn),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:r}=this.get2DCursorLocation(t,!0),{lineIndex:s,charIndex:o}=this.get2DCursorLocation(e,!0);if(i!==s){if(this.styles[i])for(let a=r;a<this._unwrappedTextLines[i].length;a++)delete this.styles[i][a];if(this.styles[s])for(let a=o;a<this._unwrappedTextLines[s].length;a++){const l=this.styles[s][a];l&&(this.styles[i]||(this.styles[i]={}),this.styles[i][r+a-o]=l)}for(let a=i+1;a<=s;a++)delete this.styles[a];this.shiftLineStyles(s,i-s)}else if(this.styles[i]){const a=this.styles[i],l=o-r;for(let c=r;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 r in this.styles){const s=parseInt(r,10);s>t&&(this.styles[s+e]=i[s],i[s-e]||delete this.styles[s])}}insertNewlineStyleObject(t,e,i,r){const s={},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,s[d-e]=this.styles[t][u],a&&e===0||delete this.styles[t][u])}let h=!1;for(l&&!a&&(this.styles[t+i]=s,h=!0),(h||o>e)&&i--;i>0;)r&&r[i-1]?this.styles[t+i]={0:_({},r[i-1])}:c?this.styles[t+i]={0:_({},c)}:delete this.styles[t+i],i--;this._forceClearCache=!0}insertCharStyleObject(t,e,i,r){this.styles||(this.styles={});const s=this.styles[t],o=s?_({},s):{};i||(i=1);for(const l in o){const c=parseInt(l,10);c>=e&&(s[c+i]=o[c],o[c-i]||delete s[c])}if(this._forceClearCache=!0,r){for(;i--;)Object.keys(r[i]).length&&(this.styles[t]||(this.styles[t]={}),this.styles[t][e+i]=_({},r[i]));return}if(!s)return;const a=s[e?e-1:1];for(;a&&i--;)this.styles[t][e+i]=_({},a)}insertNewStyleBlock(t,e,i){const r=this.get2DCursorLocation(e,!0),s=[0];let o,a=0;for(let l=0;l<t.length;l++)t[l]===`
144
- `?(a++,s[a]=0):s[a]++;for(s[0]>0&&(this.insertCharStyleObject(r.lineIndex,r.charIndex,s[0],i),i=i&&i.slice(s[0]+1)),a&&this.insertNewlineStyleObject(r.lineIndex,r.charIndex+s[0],a),o=1;o<a;o++)s[o]>0?this.insertCharStyleObject(r.lineIndex+o,0,s[o],i):i&&this.styles[r.lineIndex+o]&&i[0]&&(this.styles[r.lineIndex+o][0]=i[0]),i=i&&i.slice(s[o]+1);s[o]>0&&this.insertCharStyleObject(r.lineIndex+o,0,s[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 r=arguments.length>3&&arguments[3]!==void 0?arguments[3]:i;r>i&&this.removeStyleFromTo(i,r);const s=this.graphemeSplit(t);this.insertNewStyleBlock(s,i,e),this._text=[...this._text.slice(0,i),...s,...this._text.slice(r)],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=it:this._selectionDirection===xt&&(this._selectionDirection=it,this.selectionEnd=t),this.selectionStart=i):i>t&&i<e?this._selectionDirection===xt?this.selectionEnd=i:this.selectionStart=i:(e===t?this._selectionDirection=xt:this._selectionDirection===it&&(this._selectionDirection=xt,this.selectionStart=e),this.selectionEnd=i)}}class Np extends Bp{initHiddenTextarea(){const t=this.canvas&&Oe(this.canvas.getElement())||vr(),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:r,fontSize:s}=this._calcTextareaPosition();e.style.cssText="position: absolute; top: ".concat(i,"; left: ").concat(r,"; z-index: -999; opacity: 0; width: 1px; height: 1px; font-size: 1px; padding-top: ").concat(s,";"),(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(dn),this.canvas&&(this.canvas.fire("text:changed",{target:this}),this.canvas.requestRenderAll())};if(this.hiddenTextarea.value==="")return this.styles={},void i();const r=this._splitTextIntoLines(this.hiddenTextarea.value).graphemeText,s=this._text.length,o=r.length,a=this.selectionStart,l=this.selectionEnd,c=a!==l;let h,u,d,p,f=o-s;const g=this.fromStringToGraphemeSelection(this.hiddenTextarea.selectionStart,this.hiddenTextarea.selectionEnd,this.hiddenTextarea.value),m=a>g.selectionStart;c?(u=this._text.slice(a,l),f+=l-a):o<s&&(u=m?this._text.slice(l+f,l):this._text.slice(a,a-f));const v=r.slice(g.selectionEnd-f,g.selectionEnd);if(u&&u.length&&(v.length&&(h=this.getSelectionStyles(a,a+1,!1),h=v.map(()=>h[0])),c?(d=a,p=l):m?(d=l-u.length,p=l):(d=l,p=l+u.length),this.removeStyleFromTo(d,p)),v.length){const{copyPasteData:y}=Be();e&&v.join("")===y.copiedText&&!Q.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:r}=e;this.compositionStart=i,this.compositionEnd=r,this.updateTextareaPosition()}copy(){if(this.selectionStart===this.selectionEnd)return;const{copyPasteData:t}=Be();t.copiedText=this.getSelectedText(),Q.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,r=this._getLineLeftOffset(t);return e>0&&(i=this.__charBounds[t][e-1],r+=i.left+i.width),r}getDownCursorOffset(t,e){const i=this._getSelectionForOffset(t,e),r=this.get2DCursorLocation(i),s=r.lineIndex;if(s===this._textLines.length-1||t.metaKey||t.keyCode===34)return this._text.length-i;const o=r.charIndex,a=this._getWidthBeforeCursor(s,o),l=this._getIndexOnLine(s+1,a);return this._textLines[s].slice(o).length+l+1+this.missingNewlineOffset(s)}_getSelectionForOffset(t,e){return t.shiftKey&&this.selectionStart!==this.selectionEnd&&e?this.selectionEnd:this.selectionStart}getUpCursorOffset(t,e){const i=this._getSelectionForOffset(t,e),r=this.get2DCursorLocation(i),s=r.lineIndex;if(s===0||t.metaKey||t.keyCode===33)return-i;const o=r.charIndex,a=this._getWidthBeforeCursor(s,o),l=this._getIndexOnLine(s-1,a),c=this._textLines[s].slice(0,o),h=this.missingNewlineOffset(s-1);return-this._textLines[s-1].length+l-c.length+(1-h)}_getIndexOnLine(t,e){const i=this._textLines[t];let r,s,o=this._getLineLeftOffset(t),a=0;for(let l=0,c=i.length;l<c;l++)if(r=this.__charBounds[t][l].width,o+=r,o>e){s=!0;const h=o-r,u=o,d=Math.abs(h-e);a=Math.abs(u-e)<d?l:l-1;break}return s||(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===xt);if(e.shiftKey?this.moveCursorWithShift(i):this.moveCursorWithoutShift(i),i!==0){const r=this.text.length;this.selectionStart=fr(0,this.selectionStart,r),this.selectionEnd=fr(0,this.selectionEnd,r),this.abortCursorAnimation(),this.initDelayedCursor(),this._fireSelectionChanged(),this._updateTextarea()}}moveCursorWithShift(t){const e=this._selectionDirection===it?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 r;if(t.altKey)r=this["findWordBoundary".concat(i)](this[e]);else{if(!t.metaKey&&t.keyCode!==35&&t.keyCode!==36)return this[e]+=i==="Left"?-1:1,!0;r=this["findLineBoundary".concat(i)](this[e])}return r!==void 0&&this[e]!==r&&(this[e]=r,!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=it,this.selectionEnd===this.selectionStart&&this.selectionStart!==0&&(e=this._moveLeft(t,"selectionStart")),this.selectionEnd=this.selectionStart,e}moveCursorLeftWithShift(t){return this._selectionDirection===xt&&this.selectionStart!==this.selectionEnd?this._moveLeft(t,"selectionEnd"):this.selectionStart!==0?(this._selectionDirection=it,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===it&&this.selectionStart!==this.selectionEnd?this._moveRight(t,"selectionStart"):this.selectionEnd!==this._text.length?(this._selectionDirection=xt,this._moveRight(t,"selectionEnd")):void 0}moveCursorRightWithoutShift(t){let e=!0;return this._selectionDirection=xt,this.selectionStart===this.selectionEnd?(e=this._moveRight(t,"selectionStart"),this.selectionEnd=this.selectionStart):this.selectionStart=this.selectionEnd,e}}const ao=n=>!!n.button;class zp extends Np{constructor(){super(...arguments),b(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 Rp(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),To(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&&!ao(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&&!ao(e)&&(this.selected=this===this.canvas._activeObject)}mouseUpHandler(t){let{e,transform:i}=t;const r=this.draggableTextDelegate.end(e);if(this.canvas){this.canvas.textEditingManager.unregister(this);const s=this.canvas._activeObject;if(s&&s!==this)return}!this.editable||this.group&&!this.group.interactive||i&&i.actionPerformed||ao(e)||r||(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,r=this.selectionEnd;t.shiftKey?this.setSelectionStartEndWithShift(i,r,e):(this.selectionStart=e,this.selectionEnd=e),this.isEditing&&(this._fireSelectionChanged(),this._updateTextarea())}getSelectionStartFromPointer(t){const e=this.canvas.getScenePoint(t).transform(ke(this.calcTransformMatrix())).add(new w(-this._getLeftOffset(),-this._getTopOffset()));let i=0,r=0,s=0;for(let c=0;c<this._textLines.length&&i<=e.y;c++)i+=this.getHeightOfLine(c),s=c,c>0&&(r+=this._textLines[c-1].length+this.missingNewlineOffset(c-1));let o=Math.abs(this._getLineLeftOffset(s));const a=this._textLines[s].length,l=this.__charBounds[s];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)&&r++;break}o=h,r++}return Math.min(this.flipX?a-r:r,this._text.length)}}const Ps="moveCursorUp",As="moveCursorDown",Ms="moveCursorLeft",Is="moveCursorRight",Ls="exitEditing",Vp=_({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:Ls,27:Ls,33:Ps,34:As,35:Is,36:Ms,37:Ms,38:Ps,39:Is,40:As},keysMapRtl:{9:Ls,27:Ls,33:Ps,34:As,35:Ms,36:Is,37:Is,38:Ps,39:Ms,40:As},ctrlKeysMapDown:{65:"selectAll"},ctrlKeysMapUp:{67:"copy",88:"cut"}},{_selectionDirection:null,_reSpace:/\s|\r?\n/,inCompositionMode:!1});class Je extends zp{static getDefaults(){return _(_({},super.getDefaults()),Je.ownDefaults)}get type(){const t=super.type;return t==="itext"?"i-text":t}constructor(t,e){super(t,_(_({},Je.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 Jr&&this.canvas.textEditingManager.remove(this),e instanceof Jr&&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(),r=this._getTopOffset(),s=this._getCursorBoundariesOffsets(t,e);return{left:i,top:r,leftOffset:s.left,topOffset:s.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:r,lineIndex:s}=this.get2DCursorLocation(t);for(let c=0;c<s;c++)e+=this.getHeightOfLine(c);const o=this._getLineLeftOffset(s),a=this.__charBounds[s][r];a&&(i=a.left),this.charSpacing!==0&&r===this._textLines[s].length&&(i-=this._getWidthOfCharSpacing());const l={top:e,left:o+(i>0?i:0)};return this.direction==="rtl"&&(this.textAlign===xt||this.textAlign===Le||this.textAlign===Hr?l.left*=-1:this.textAlign===it||this.textAlign===wn?l.left=o-(i>0?i:0):this.textAlign!==K&&this.textAlign!==$r||(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),r=i.lineIndex,s=i.charIndex>0?i.charIndex-1:0,o=this.getValueOfPropertyAt(r,s,"fontSize"),a=this.getObjectScaling().x*this.canvas.getZoom(),l=this.cursorWidth/a,c=this.getValueOfPropertyAt(r,s,"deltaY"),h=e.topOffset+(1-this._fontSizeFraction)*this.getHeightOfLine(r)/this.lineHeight-o*(1-this._fontSizeFraction);return{color:this.cursorColor||this.getValueOfPropertyAt(r,s,"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:r,opacity:s,left:o,top:a,width:l,height:c}=this.getCursorRenderingData(i,e);t.fillStyle=r,t.globalAlpha=s,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 r=e.selectionStart,s=e.selectionEnd,o=this.textAlign.includes(Le),a=this.get2DCursorLocation(r),l=this.get2DCursorLocation(s),c=a.lineIndex,h=l.lineIndex,u=a.charIndex<0?0:a.charIndex,d=l.charIndex<0?0:l.charIndex;for(let p=c;p<=h;p++){const f=this._getLineLeftOffset(p)||0;let g=this.getHeightOfLine(p),m=0,v=0,y=0;if(p===c&&(v=this.__charBounds[c][u].left),p>=c&&p<h)y=o&&!this.isEndOfWrapping(p)?this.width:this.getLineWidth(p)||5;else if(p===h)if(d===0)y=this.__charBounds[h][d].left;else{const C=this._getWidthOfCharSpacing();y=this.__charBounds[h][d-1].left+this.__charBounds[h][d-1].width-C}m=g,(this.lineHeight<1||p===h&&this.lineHeight>1)&&(g/=this.lineHeight);let x=i.left+f+v,T=g,E=0;const A=y-v;this.inCompositionMode?(t.fillStyle=this.compositionColor||"black",T=1,E=g):t.fillStyle=this.selectionColor,this.direction==="rtl"&&(this.textAlign===xt||this.textAlign===Le||this.textAlign===Hr?x=this.width-x-A:this.textAlign===it||this.textAlign===wn?x=i.left+f-y:this.textAlign!==K&&this.textAlign!==$r||(x=i.left+f-y)),t.fillRect(x,i.top+i.topOffset+E,A,T),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,It)}_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()}}b(Je,"ownDefaults",Vp),b(Je,"type","IText"),R.setClass(Je),R.setClass(Je,"i-text");class Qe extends Je{static getDefaults(){return _(_({},super.getDefaults()),Qe.ownDefaults)}constructor(t,e){super(t,_(_({},Qe.ownDefaults),e))}static createControls(){return{controls:vd()}}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(Le)&&this.enlargeSpaces(),this.height=this.calcTextHeight())}_generateStyleMap(t){let e=0,i=0,r=0;const s={};for(let o=0;o<t.graphemeLines.length;o++)t.graphemeText[r]===`
145
- `&&o>0?(i=0,r++,e++):!this.splitByGrapheme&&this._reSpaceAndTab.test(t.graphemeText[r])&&o>0&&(i++,r++),s[o]={line:e,offset:i},r+=t.graphemeLines[o].length,i+=t.graphemeLines[o].length;return s}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,r=t+1,s=!1;const o=this._styleMap[t],a=this._styleMap[t+1];o&&(t=o.line,i=o.offset),a&&(r=a.line,s=r===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&&(!s||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 r=this._styleMap[t];super._setStyleDeclaration(r.line,r.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),r=[];for(let s=0;s<i.wordsData.length;s++)r.push(...this._wrapLine(s,e,i));return this.isWrapping=!1,r}getGraphemeDataForRender(t){const e=this.splitByGrapheme,i=e?"":" ";let r=0;return{wordsData:t.map((s,o)=>{let a=0;const l=e?this.graphemeSplit(s):this.wordSplit(s);return l.length===0?[{word:[],width:0}]:l.map(c=>{const h=e?[c]:this.graphemeSplit(c),u=this._measureWord(h,o,a);return r=Math.max(u,r),a+=h.length+i.length,{word:h,width:u}})}),largestWordWidth:r}}_measureWord(t,e){let i,r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:0,s=0;for(let o=0,a=t.length;o<a;o++)s+=this._getGraphemeBox(t[o],e,o+r,i,!0).kernedWidth,i=t[o];return s}wordSplit(t){return t.split(this._wordJoiners)}_wrapLine(t,e,i){let{largestWordWidth:r,wordsData:s}=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=[],p=0,f=0,g=!0;e-=o;const m=Math.max(e,r,this.dynamicMinWidth),v=s[t];let y;for(p=0,y=0;y<v.length;y++){const{word:x,width:T}=v[y];p+=x.length,u+=f+T-a,u>m&&!g?(c.push(d),d=[],u=T,g=!0):u+=a,g||l||d.push(h),d=d.concat(x),f=l?0:this._measureWord([h],t,p),p++,g=!1}return y&&c.push(d),r+o>this.dynamicMinWidth&&(this.dynamicMinWidth=r-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),r=new Array(i.length);for(let s=0;s<i.length;s++)r[s]=i[s].join("");return e.lines=r,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 r=this._styleMap[e].line;t.set("".concat(r),!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])}}b(Qe,"type","Textbox"),b(Qe,"textLayoutProperties",[...Je.textLayoutProperties,"width"]),b(Qe,"ownDefaults",{minWidth:20,dynamicMinWidth:2,lockScalingFlip:!0,noScaleCache:!1,_wordJoiners:/[ \t\r]/,splitByGrapheme:!1}),R.setClass(Qe);class vl extends jn{shouldPerformLayout(t){return!!t.target.clipPath&&super.shouldPerformLayout(t)}shouldLayoutClipPath(){return!1}calcLayoutResult(t,e){const{target:i}=t,{clipPath:r,group:s}=i;if(!r||!this.shouldPerformLayout(t))return;const{width:o,height:a}=ii(jc(i,r)),l=new w(o,a);if(r.absolutePositioned)return{center:hr(r.getRelativeCenterPoint(),void 0,s?s.calcTransformMatrix():void 0),size:l};{const c=r.getRelativeCenterPoint().transform(i.calcOwnMatrix(),!0);if(this.shouldPerformLayout(t)){const{center:h=new w,correction:u=new w}=this.calcBoundingBox(e,t)||{};return{center:h.add(c),correction:u.subtract(c),size:l}}return{center:i.getRelativeCenterPoint().add(c),size:l}}}}b(vl,"type","clip-path"),R.setClass(vl);class bl extends jn{getInitialSize(t,e){let{target:i}=t,{size:r}=e;return new w(i.width||r.x,i.height||r.y)}}b(bl,"type","fixed"),R.setClass(bl);class Hp extends Zr{subscribeTargets(t){const e=t.target;t.targets.reduce((i,r)=>(r.parent&&i.add(r.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((r,s)=>(s.parent&&r.add(s.parent),r),new Set).forEach(r=>{!i.some(s=>s.parent===r)&&r.layoutManager.unsubscribeTargets({target:r,targets:[e]})})}}class Vi extends _i{static getDefaults(){return _(_({},super.getDefaults()),Vi.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,Vi.ownDefaults),this.setOptions(e);const{left:i,top:r,layoutManager:s}=e;this.groupInit(t,{left:i,top:r,layoutManager:s??new Hp})}_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(r=>{const s=this._objects.findIndex(a=>a.isInFrontOf(r)),o=s===-1?this.size():s;this.insertAt(o,r)})}canEnterGroup(t){return this.getObjects().some(e=>e.isDescendantOf(t)||t.isDescendantOf(e))?(yi("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(r=>{const{parent:s}=r;s&&i.add(s)}),t===va?i.forEach(r=>{r._onAfterObjectsChange(_n,e)}):i.forEach(r=>{r._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 r=_(_({hasControls:!1},i),{},{forActiveSelection:!0});for(let s=0;s<this._objects.length;s++)this._objects[s]._renderControls(t,r);super._renderControls(t,e),t.restore()}}b(Vi,"type","ActiveSelection"),b(Vi,"ownDefaults",{multiSelectionStacking:"canvas-stacking"}),R.setClass(Vi),R.setClass(Vi,"activeSelection");class $p{constructor(){b(this,"resources",{})}applyFilters(t,e,i,r,s){const o=s.getContext("2d");if(!o)return;o.drawImage(e,0,0,i,r);const a={sourceWidth:i,sourceHeight:r,imageData:o.getImageData(0,0,i,r),originalEl:e,originalImageData:o.getImageData(0,0,i,r),canvasEl:s,ctx:o,filterBackend:this};t.forEach(c=>{c.applyTo(a)});const{imageData:l}=a;return l.width===i&&l.height===r||(s.width=l.width,s.height=l.height),o.putImageData(l,0,0),a}}class ih{constructor(){let{tileSize:t=Q.textureSize}=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};b(this,"aPosition",new Float32Array([0,0,0,1,1,0,1,1])),b(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=Ne({width:t,height:e}),r=i.getContext("webgl",{alpha:!0,premultipliedAlpha:!1,depth:!1,stencil:!1,antialias:!1});r&&(r.clearColor(0,0,0,0),this.canvas=i,this.gl=r)}applyFilters(t,e,i,r,s,o){const a=this.gl,l=s.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:r,destinationWidth:i,destinationHeight:r,context:a,sourceTexture:this.createTexture(a,i,r,c?void 0:e),targetTexture:this.createTexture(a,i,r),originalTexture:c||this.createTexture(a,i,r,c?void 0:e),passes:t.length,webgl:!0,aPosition:this.aPosition,programCache:this.programCache,pass:0,filterBackend:this,targetCanvas:s},u=a.createFramebuffer();return a.bindFramebuffer(a.FRAMEBUFFER,u),t.forEach(d=>{d&&d.applyTo(h)}),function(d){const p=d.targetCanvas,f=p.width,g=p.height,m=d.destinationWidth,v=d.destinationHeight;f===m&&g===v||(p.width=m,p.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,r,s){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:p,TEXTURE_WRAP_T:f}=t,g=t.createTexture();return t.bindTexture(a,g),t.texParameteri(a,u,s||o),t.texParameteri(a,d,s||o),t.texParameteri(a,p,h),t.texParameteri(a,f,h),r?t.texImage2D(a,0,l,l,c,r):t.texImage2D(a,0,l,e,i,0,l,c,null),g}getCachedTexture(t,e,i){const{textureCache:r}=this;if(r[t])return r[t];{const s=this.createTexture(this.gl,e.width,e.height,e,i);return s&&(r[t]=s),s}}evictCachesForKey(t){this.textureCache[t]&&(this.gl.deleteTexture(this.textureCache[t]),delete this.textureCache[t])}copyGLTo2D(t,e){const i=t.canvas,r=e.targetCanvas,s=r.getContext("2d");if(!s)return;s.translate(0,r.height),s.scale(1,-1);const o=i.height-r.height;s.drawImage(i,0,o,r.width,r.height,0,0,r.width,r.height)}copyGLTo2DPutImageData(t,e){const i=e.targetCanvas.getContext("2d"),r=e.destinationWidth,s=e.destinationHeight,o=r*s*4;if(!i)return;const a=new Uint8Array(this.imageBuffer,0,o),l=new Uint8ClampedArray(this.imageBuffer,0,o);t.readPixels(0,0,r,s,t.RGBA,t.UNSIGNED_BYTE,a);const c=new ImageData(l,r,s);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 r=t.getParameter(i.UNMASKED_RENDERER_WEBGL),s=t.getParameter(i.UNMASKED_VENDOR_WEBGL);r&&(e.renderer=r.toLowerCase()),s&&(e.vendor=s.toLowerCase())}return this.gpuInfo=e,e}}let lo;function Wp(){const{WebGLProbe:n}=Be();return n.queryWebGL(Ae()),Q.enableGLFiltering&&n.isSupported(Q.textureSize)?new ih({tileSize:Q.textureSize}):new $p}function co(){return!lo&&(!(arguments.length>0&&arguments[0]!==void 0)||arguments[0])&&(lo=Wp()),lo}const Gp=["filters","resizeFilter","src","crossOrigin","type"],rh=["cropX","cropY"];class Ut extends Yt{static getDefaults(){return _(_({},super.getDefaults()),Ut.ownDefaults)}constructor(t,e){super(),b(this,"_lastScaleX",1),b(this,"_lastScaleY",1),b(this,"_filterScalingX",1),b(this,"_filterScalingY",1),this.filters=[],Object.assign(this,Ut.ownDefaults),this.setOptions(e),this.cacheKey="texture".concat(xi()),this.setElement(typeof t=="string"?(this.canvas&&Oe(this.canvas.getElement())||vr()).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(Ut.CSS_CANVAS),this.filters.length!==0&&this.applyFilters(),this.resizeFilter&&this.applyResizeFilters()}removeTexture(t){const e=co(!1);e instanceof ih&&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&&Be().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())}),_(_({},super.toObject([...rh,...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,r=-this.height/2;let s=[],o=[],a="",l="";if(!e)return[];if(this.hasCrop()){const c=xi();s.push('<clipPath id="imageCrop_'+c+`">
146
- `,' <rect x="'+i+'" y="'+r+'" width="'+this.width+'" height="'+this.height+`" />
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 st(h).setAlpha(u).toRgba():h)}),l}static async fromObject(t){const{colorStops:e,gradientTransform:i}=t;return new this(_(_({},t),{},{colorStops:e?e.map(s=>_({},s)):void 0,gradientTransform:i?[...i]:void 0}))}static fromElement(t,e,i){const s=Vh(t),r=e._findCenterFromElement();return new this(_({id:t.getAttribute("id")||void 0,type:Hh(t),coords:Ff(t,{width:i.viewBoxWidth||i.width,height:i.viewBoxHeight||i.height}),colorStops:Lf(t,i.opacity),gradientUnits:s,gradientTransform:na(t.getAttribute("gradientTransform")||"")},s==="pixels"?{offsetX:e.width/2-r.x,offsetY:e.height/2-r.y}:{offsetX:0,offsetY:0}))}}b(Yr,"type","Gradient"),R.setClass(Yr,"gradient"),R.setClass(Yr,"linear"),R.setClass(Yr,"radial");const jf=["type","source","patternTransform"];class Lo{get type(){return"pattern"}set type(t){Ai("warn","Setting type has no effect",t)}constructor(t){b(this,"repeat","repeat"),b(this,"offsetX",0),b(this,"offsetY",0),b(this,"crossOrigin",""),this.id=Pi(),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 _(_({},Ls(this,t)),{},{type:"pattern",source:this.sourceToString(),repeat:e,crossOrigin:i,offsetX:gt(this.offsetX,tt.NUM_FRACTION_DIGITS),offsetY:gt(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:o}=this,a=vs(this.offsetX/e,0),l=vs(this.offsetY/i,0),c=r==="repeat-y"||r==="no-repeat"?1+Math.abs(a||0):vs(s.width/e,0),h=r==="repeat-x"||r==="no-repeat"?1+Math.abs(l||0):vs(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=ut(t,jf);const a=await Sn(s,_(_({},e),{},{crossOrigin:o.crossOrigin}));return new this(_(_({},o),{},{patternTransform:r&&r.slice(0),source:a}))}}b(Lo,"type","Pattern"),R.setClass(Lo),R.setClass(Lo,"pattern");const Rf=["path","left","top"],$f=["d"];class Gi extends Kt{constructor(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},{path:i,left:s,top:r}=e,o=ut(e,Rf);super(),Object.assign(this,Gi.ownDefaults),this.setOptions(o),this._setPath(t||[],!0),typeof s=="number"&&this.set(it,s),typeof r=="number"&&this.set(le,r)}_setPath(t,e){this.path=ff(Array.isArray(t)?t:Cf(t)),this.setBoundingBox(e)}_findCenterFromElement(){const t=this._calcBoundsFromPath();return new w(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 _(_({},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=Sf(this.path,tt.NUM_FRACTION_DIGITS);return["<path ","COMMON_PARTS",'d="'.concat(t,`" stroke-linecap="round" />
173
+ `)]}_getOffsetTransform(){const t=tt.NUM_FRACTION_DIGITS;return" translate(".concat(gt(-this.pathOffset.x,t),", ").concat(gt(-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,K,K)}_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(...Ql(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(...Ql(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 li(t)}_calcDimensions(){const t=this._calcBoundsFromPath();return _(_({},t),{},{pathOffset:new w(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=vi(t,this.ATTRIBUTE_NAMES,i),{d:r}=s;return new this(r,_(_(_({},ut(s,$f)),e),{},{left:void 0,top:void 0}))}}b(Gi,"type","Path"),b(Gi,"cacheProperties",[...mi,"path","fillRule"]),b(Gi,"ATTRIBUTE_NAMES",[...$i,"d"]),R.setClass(Gi),R.setSVGClass(Gi);const Bf=["left","top","radius"],Uh=["radius","startAngle","endAngle","counterClockwise"];class ti extends Kt{static getDefaults(){return _(_({},super.getDefaults()),ti.ownDefaults)}constructor(t){super(),Object.assign(this,ti.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,Et(this.startAngle),Et(this.endAngle),this.counterClockwise),this._renderPaintInOrder(t)}getRadiusX(){return this.get("radius")*this.get(ue)}getRadiusY(){return this.get("radius")*this.get(Te)}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([...Uh,...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=Et(this.startAngle),s=Et(this.endAngle),r=ui(i)*e,o=di(i)*e,a=ui(s)*e,l=di(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=vi(t,this.ATTRIBUTE_NAMES,i),{left:r=0,top:o=0,radius:a=0}=s;return new this(_(_({},ut(s,Bf)),{},{radius:a,left:r-a,top:o-a}))}static fromObject(t){return super._fromObject(t)}}b(ti,"type","Circle"),b(ti,"cacheProperties",[...mi,...Uh]),b(ti,"ownDefaults",{radius:0,startAngle:0,endAngle:360,counterClockwise:!1}),b(ti,"ATTRIBUTE_NAMES",["cx","cy","r",...$i]),R.setClass(ti),R.setSVGClass(ti);const Nf=["x1","y1","x2","y2"],zf=["x1","y1","x2","y2"],ca=["x1","x2","y1","y2"];class Yi extends Kt{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,Yi.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(it,o),typeof a=="number"&&this.set(le,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}=li([{x:t,y:e},{x:i,y:s}]),c=new w(r+a/2,o+l/2);this.setPositionByOrigin(c,K,K)}_set(t,e){return super._set(t,e),ca.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;we(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 w((this.x1+this.x2)/2,(this.y1+this.y2)/2)}toObject(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[];return _(_({},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=vi(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],ut(s,Nf))}static fromObject(t){let{x1:e,y1:i,x2:s,y2:r}=t,o=ut(t,zf);return this._fromObject(_(_({},o),{},{points:[e,i,s,r]}),{extraParam:"points"})}}b(Yi,"type","Line"),b(Yi,"cacheProperties",[...mi,...ca]),b(Yi,"ATTRIBUTE_NAMES",$i.concat(ca)),R.setClass(Yi),R.setSVGClass(Yi);class qi extends Kt{static getDefaults(){return _(_({},super.getDefaults()),qi.ownDefaults)}constructor(t){super(),Object.assign(this,qi.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),'" />']}}b(qi,"type","Triangle"),b(qi,"ownDefaults",{width:100,height:100}),R.setClass(qi),R.setSVGClass(qi);const Wh=["rx","ry"];class ei extends Kt{static getDefaults(){return _(_({},super.getDefaults()),ei.ownDefaults)}constructor(t){super(),Object.assign(this,ei.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(ue)}getRy(){return this.get("ry")*this.get(Te)}toObject(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[];return super.toObject([...Wh,...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,In,!1),t.restore(),this._renderPaintInOrder(t)}static async fromElement(t,e,i){const s=vi(t,this.ATTRIBUTE_NAMES,i);return s.left=(s.left||0)-s.rx,s.top=(s.top||0)-s.ry,new this(s)}}function Hf(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}b(ei,"type","Ellipse"),b(ei,"cacheProperties",[...mi,...Wh]),b(ei,"ownDefaults",{rx:0,ry:0}),b(ei,"ATTRIBUTE_NAMES",[...$i,"cx","cy","rx","ry"]),R.setClass(ei),R.setSVGClass(ei);const Vf=["left","top"],Gh={exactBoundingBox:!1};class Ae extends Kt{static getDefaults(){return _(_({},super.getDefaults()),Ae.ownDefaults)}constructor(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[],e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};super(),b(this,"strokeDiff",void 0),Object.assign(this,Ae.ownDefaults),this.setOptions(e),this.points=t;const{left:i,top:s}=e;this.initialized=!0,this.setBoundingBox(!0),typeof i=="number"&&this.set(it,i),typeof s=="number"&&this.set(le,s)}isOpen(){return!0}_projectStrokeOnPoints(t){return Dp(this.points,t,this.isOpen())}_calcDimensions(t){t=_({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 w,strokeOffset:new w,strokeDiff:new w};const i=li(e),s=to(_(_({},t),{},{scaleX:1,scaleY:1})),r=li(this.points.map(c=>oe(c,s,!0))),o=new w(this.scaleX,this.scaleY);let a=i.left+i.width/2,l=i.top+i.height/2;return this.exactBoundingBox&&(a-=l*Math.tan(Et(this.skewX)),l-=a*Math.tan(Et(this.skewY))),_(_({},i),{},{pathOffset:new w(a,l),strokeOffset:new w(r.left,r.top).subtract(new w(i.left,i.top)).multiply(o),strokeDiff:new w(i.width,i.height).subtract(new w(r.width,r.height)).multiply(o)})}_findCenterFromElement(){const t=li(this.points);return new w(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 w(e+s/2,i+r/2),K,K)}isStrokeAccountedForInDimensions(){return this.exactBoundingBox}_getNonTransformedDimensions(){return this.exactBoundingBox?new w(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 w((e=t.width)!==null&&e!==void 0?e:a,(i=t.height)!==null&&i!==void 0?i:l)}else{var s,r;o=new w((s=t.width)!==null&&s!==void 0?s:this.width,(r=t.height)!==null&&r!==void 0?r:this.height)}return o.multiply(new w(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===ue||t===Te)&&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 _(_({},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=tt.NUM_FRACTION_DIGITS;for(let r=0,o=this.points.length;r<o;r++)t.push(gt(this.points[r].x-e,s),",",gt(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(Hf(t.getAttribute("points")),_(_({},ut(vi(t,this.ATTRIBUTE_NAMES,i),Vf)),e))}static fromObject(t){return this._fromObject(t,{extraParam:"points"})}}b(Ae,"ownDefaults",Gh),b(Ae,"type","Polyline"),b(Ae,"layoutProperties",[Ms,Is,"strokeLineCap","strokeLineJoin","strokeMiterLimit","strokeWidth","strokeUniform","points"]),b(Ae,"cacheProperties",[...mi,"points"]),b(Ae,"ATTRIBUTE_NAMES",[...$i]),R.setClass(Ae),R.setSVGClass(Ae);class Xr extends Ae{isOpen(){return!1}}b(Xr,"ownDefaults",Gh),b(Xr,"type","Polygon"),R.setClass(Xr),R.setSVGClass(Xr);const Yh=["fontSize","fontWeight","fontFamily","fontStyle"],Xh=["underline","overline","linethrough"],Kh=[...Yh,"lineHeight","text","charSpacing","textAlign","styles","path","pathStartOffset","pathSide","pathAlign"],qh=[...Kh,...Xh,"textBackgroundColor","direction"],Uf=[...Yh,...Xh,he,"strokeWidth",Ft,"deltaY","textBackgroundColor"],Wf={_reNewline:Ma,_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:it,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:it,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},Be="justify",Un="justify-left",rr="justify-right",nr="justify-center";class Zh extends Kt{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=Ra(_(_({},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 _(_({},Ls(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]}}b(Zh,"_styleProperties",Uf);const Gf=/ +/g,Yf=/"/g;function Fo(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]:tt.NUM_FRACTION_DIGITS;const d=pr(Ft,r,!1),[p,f,g,m]=[a,l,c,h].map(v=>gt(v,u));return"<rect ".concat(d,' x="').concat(p,'" y="').concat(f,'" width="').concat(g,'" height="').concat(m,'"></rect>')}(n,{left:t,top:e,width:i,height:s}),`
179
+ `)}const Xf=["textAnchor","textDecoration","dx","dy","top","left","fontSize","strokeWidth"];let jo;class te extends Zh{static getDefaults(){return _(_({},super.getDefaults()),te.ownDefaults)}constructor(t,e){super(),b(this,"__charBounds",[]),Object.assign(this,te.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=$h(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(Be)&&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===Be||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===he?(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 K:t.textBaseline="middle";break;case"ascender":t.textBaseline=le;break;case"descender":t.textBaseline=Jo}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,p=0,f=this.getValueOfPropertyAt(r,0,"textBackgroundColor");for(let g=0;g<l;g++){const m=this.__charBounds[r][g];u=this.getValueOfPropertyAt(r,g,"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!==f?(h=i+c+p,this.direction==="rtl"&&(h=this.width-h-d),t.fillStyle=f,f&&t.fillRect(h,s,d,a/this.lineHeight),p=m.left,d=m.width,f=u):d+=m.kernedWidth}u&&!this.path&&(h=i+c+p,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=ir.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,p;if(i&&r[i]!==void 0&&(d=r[i]),r[t]!==void 0&&(p=h=r[t]),l&&r[a]!==void 0&&(u=r[a],p=u-d),h===void 0||d===void 0||u===void 0){const f=function(){return jo||(jo=Ue({width:0,height:0}).getContext("2d")),jo}();this._setTextStyles(f,e,!0),h===void 0&&(p=h=f.measureText(t).width,r[t]=h),d===void 0&&l&&i&&(d=f.measureText(i).width,r[i]=d),l&&u===void 0&&(u=f.measureText(a).width,r[a]=u,p=u-d)}return{width:h*c,kernedWidth:p*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===Ct,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 it:h=r?u-s:0;break;case K:h=(u-s)/2;break;case Ct: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=_f(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===Ct?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 p=this.__charBounds[e][i-1];d.left=p.left+p.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(Ft))&&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(Be),c=this.path,h=!l&&this.charSpacing===0&&this.isEmptyStyles(o)&&!c,u=this.direction==="ltr",d=this.direction==="ltr"?1:-1,p=e.direction;let f,g,m,v,y,x="",E=0;if(e.save(),p!==this.direction&&(e.canvas.setAttribute("dir",u?"ltr":"rtl"),e.direction=u?"ltr":"rtl",e.textAlign=u?it:Ct),r-=a*this._fontSizeFraction/this.lineHeight,h)return this._renderChar(t,e,o,0,i.join(""),s,r),void e.restore();for(let O=0,D=i.length-1;O<=D;O++)v=O===D||this.charSpacing||c,x+=i[O],m=this.__charBounds[o][O],E===0?(s+=d*(m.kernedWidth-m.width),E+=m.width):E+=m.kernedWidth,l&&!v&&this._reSpaceAndTab.test(i[O])&&(v=!0),v||(f=f||this.getCompleteStyleDeclaration(o,O),g=this.getCompleteStyleDeclaration(o,O+1),v=Wa(f,g,!1)),v&&(c?(e.save(),e.translate(m.renderLeft,m.renderTop),e.rotate(m.angle),this._renderChar(t,e,o,O,x,-E/2,0),e.restore()):(y=s,this._renderChar(t,e,o,O,x,y,r)),x="",f=g,s+=d*E,E=0);e.restore()}_applyPatternGradientTransformText(t){const e=this.width+this.strokeWidth,i=this.height+this.strokeWidth,s=Ue({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 we(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===Be||s===nr&&!o||s===rr&&!o||s===Un&&!o?0:(s===K&&(a=i/2),s===Ct&&(a=i),s===nr&&(a=i/2),s===rr&&(a=i),r==="rtl"&&(s===Ct||s===Be||s===rr?a=0:s===it||s===Un?a=-i:s!==K&&s!==nr||(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,p=this._getLineLeftOffset(l);let f,g,m=0,v=0,y=this.getValueOfPropertyAt(l,0,e),x=this.getValueOfPropertyAt(l,0,Ft);const E=i+d*(1-this._fontSizeFraction);let O=this.getHeightOfChar(l,0),D=this.getValueOfPropertyAt(l,0,"deltaY");for(let S=0,F=u.length;S<F;S++){const j=this.__charBounds[l][S];f=this.getValueOfPropertyAt(l,S,e),g=this.getValueOfPropertyAt(l,S,Ft);const A=this.getHeightOfChar(l,S),k=this.getValueOfPropertyAt(l,S,"deltaY");if(r&&f&&g)t.save(),t.fillStyle=x,t.translate(j.renderLeft,j.renderTop),t.rotate(j.angle),t.fillRect(-j.kernedWidth/2,a*A+k,j.kernedWidth,this.fontSize/15),t.restore();else if((f!==y||g!==x||A!==O||k!==D)&&v>0){let P=s+p+m;this.direction==="rtl"&&(P=this.width-P-v),y&&x&&(t.fillStyle=x,t.fillRect(P,E+a*O+D,v,this.fontSize/15)),m=j.left,v=j.width,y=f,x=g,O=A,D=k}else v+=j.kernedWidth}let C=s+p+m;this.direction==="rtl"&&(C=this.width-C-v),t.fillStyle=g,f&&g&&t.fillRect(C,E+a*O+D,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(",")||te.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 Ua(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 _(_({},super.toObject([...qh,...t])),{},{styles:Lp(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=vi(t,te.ATTRIBUTE_NAMES,i),r=_(_({},e),s),{textAnchor:o=it,textDecoration:a="",dx:l=0,dy:c=0,top:h=0,left:u=0,fontSize:d=Da,strokeWidth:p=1}=r,f=ut(r,Xf),g=new this((t.textContent||"").replace(/^\s+|\s+$|\n+/g,"").replace(/\s+/g," "),_({left:u+l,top:h+c,underline:a.includes("underline"),overline:a.includes("overline"),linethrough:a.includes("line-through"),strokeWidth:0,fontSize:d},f)),m=g.getScaledHeight()/g.height,v=((g.height+g.strokeWidth)*g.lineHeight-g.height)*m,y=g.getScaledHeight()+v;let x=0;return o===K&&(x=g.getScaledWidth()/2),o===Ct&&(x=g.getScaledWidth()),g.set({left:g.left-x,top:g.top-(y-g.fontSize*(.07+g._fontSizeFraction))/g.lineHeight,strokeWidth:p}),g}static fromObject(t){return this._fromObject(_(_({},t),{},{styles:Fp(t.styles||{},t.text)}),{extraParam:"text"})}}b(te,"textLayoutProperties",Kh),b(te,"cacheProperties",[...mi,...qh]),b(te,"ownDefaults",Wf),b(te,"type","Text"),b(te,"genericFonts",["serif","sans-serif","monospace","cursive","fantasy","system-ui","ui-serif","ui-sans-serif","ui-monospace","ui-rounded","math","emoji","fangsong"]),b(te,"ATTRIBUTE_NAMES",$i.concat("x","y","dx","dy","font-family","font-style","font-weight","font-size","letter-spacing","text-decoration","text-anchor")),Ah(te,[class extends yh{_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(Yf,"'"),'" '):"",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(...Fo(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(Gf)),r=s?'style="'.concat(s,'"'):"",o=t.deltaY,a=o?' dy="'.concat(gt(o,tt.NUM_FRACTION_DIGITS),'" '):"";return'<tspan x="'.concat(gt(e,tt.NUM_FRACTION_DIGITS),'" y="').concat(gt(i,tt.NUM_FRACTION_DIGITS),'" ').concat(a).concat(r,">").concat(Mp(n),"</tspan>")}_setSVGTextLineText(n,t,e,i){const s=this.getHeightOfLine(t),r=this.textAlign.includes(Be),o=this._textLines[t];let a,l,c,h,u,d="",p=0;i+=s*(1-this._fontSizeFraction)/this.lineHeight;for(let f=0,g=o.length-1;f<=g;f++)u=f===g||this.charSpacing,d+=o[f],c=this.__charBounds[t][f],p===0?(e+=c.kernedWidth-c.width,p+=c.width):p+=c.kernedWidth,r&&!u&&this._reSpaceAndTab.test(o[f])&&(u=!0),u||(a=a||this.getCompleteStyleDeclaration(t,f),l=this.getCompleteStyleDeclaration(t,f+1),u=Wa(a,l,!0)),u&&(h=this._getStyleDeclaration(t,f),n.push(this._createTextCharSpan(d,h,e,i)),d="",a=l,this.direction==="rtl"?e-=p:e+=p,p=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:p}=this.__charBounds[t][h];o=this.getValueOfPropertyAt(t,h,"textBackgroundColor"),o!==c?(c&&n.push(...Fo(c,e+l,i,a,r)),l=u,a=d,c=o):a+=p}o&&n.push(...Fo(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?pr(he,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?pr(Ft,r):"",c?"baseline-shift: ".concat(-c,"; "):"",t?"white-space: pre; ":""].join("")}getSvgTextDecoration(n){return["overline","underline","line-through"].filter(t=>n[t.replace("-","")]).join(" ")}}]),R.setClass(te),R.setSVGClass(te);class Kf{constructor(t){b(this,"target",void 0),b(this,"__mouseDownInPlace",!1),b(this,"__dragStartFired",!1),b(this,"__isDraggingOver",!1),b(this,"__dragStartSelection",void 0),b(this,"__dragImageDisposer",void 0),b(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 w(o.flipX?-1:1,o.flipY?-1:1),c=o._getCursorBoundaries(s),h=new w(c.left+c.leftOffset,c.top+c.topOffset).multiply(l).transform(o.calcTransformMatrix()),u=a.getScenePoint(t).subtract(h),d=o.getCanvasRetinaScaling(),p=o.getBoundingRect(),f=h.subtract(new w(p.left,p.top)),g=a.viewportTransform,m=f.add(u).transform(g,!0),v=o.backgroundColor,y=Va(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,la(E,{position:"fixed",left:"".concat(-E.width,"px"),border:ce,width:"".concat(E.width/d,"px"),height:"".concat(E.height/d,"px")}),this.__dragImageDisposer&&this.__dragImageDisposer(),this.__dragImageDisposer=()=>{E.remove()},De(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=_({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,p=this.__dragStartSelection.selectionEnd;l>d&&l<=p?l=d:l>p&&(l-=p-d),o.removeChars(d,p),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(Ln,{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)||ce;l===ce?(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(Ln,{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 ic=/[ \n\.,;!\?\-]/;class qf extends te{constructor(){super(...arguments),b(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 Sh({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||!Ma.test(i[t-1]))?t-1:t,r=i[s];for(;s>0&&s<i.length&&!ic.test(r);)s+=e,r=i[s];return e===-1&&ic.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;De(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,p=u-o,f=new w(e.left+a,e.top+e.topOffset+o).transform(this.calcTransformMatrix()).transform(this.canvas.viewportTransform).multiply(new w(c.clientWidth/h,c.clientHeight/u));return f.x<0&&(f.x=0),f.x>d&&(f.x=d),f.y<0&&(f.y=0),f.y>p&&(f.y=p),f.x+=this.canvas._offset.left,f.y+=this.canvas._offset.top,{left:"".concat(f.x,"px"),top:"".concat(f.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(Fn),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:_({},s[i-1])}:c?this.styles[t+i]={0:_({},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?_({},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]=_({},s[i]));return}if(!r)return;const a=r[e?e-1:1];for(;a&&i--;)this.styles[t][e+i]=_({},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=it:this._selectionDirection===Ct&&(this._selectionDirection=it,this.selectionEnd=t),this.selectionStart=i):i>t&&i<e?this._selectionDirection===Ct?this.selectionEnd=i:this.selectionStart=i:(e===t?this._selectionDirection=Ct:this._selectionDirection===it&&(this._selectionDirection=Ct,this.selectionStart=e),this.selectionEnd=i)}}class Zf extends qf{initHiddenTextarea(){const t=this.canvas&&De(this.canvas.getElement())||Ds(),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(Ln),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,p,f=o-r;const g=this.fromStringToGraphemeSelection(this.hiddenTextarea.selectionStart,this.hiddenTextarea.selectionEnd,this.hiddenTextarea.value),m=a>g.selectionStart;c?(u=this._text.slice(a,l),f+=l-a):o<r&&(u=m?this._text.slice(l+f,l):this._text.slice(a,a-f));const v=s.slice(g.selectionEnd-f,g.selectionEnd);if(u&&u.length&&(v.length&&(h=this.getSelectionStyles(a,a+1,!1),h=v.map(()=>h[0])),c?(d=a,p=l):m?(d=l-u.length,p=l):(d=l,p=l+u.length),this.removeStyleFromTo(d,p)),v.length){const{copyPasteData:y}=Ve();e&&v.join("")===y.copiedText&&!tt.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}=Ve();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||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===Ct);if(e.shiftKey?this.moveCursorWithShift(i):this.moveCursorWithoutShift(i),i!==0){const s=this.text.length;this.selectionStart=ks(0,this.selectionStart,s),this.selectionEnd=ks(0,this.selectionEnd,s),this.abortCursorAnimation(),this.initDelayedCursor(),this._fireSelectionChanged(),this._updateTextarea()}}moveCursorWithShift(t){const e=this._selectionDirection===it?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=it,this.selectionEnd===this.selectionStart&&this.selectionStart!==0&&(e=this._moveLeft(t,"selectionStart")),this.selectionEnd=this.selectionStart,e}moveCursorLeftWithShift(t){return this._selectionDirection===Ct&&this.selectionStart!==this.selectionEnd?this._moveLeft(t,"selectionEnd"):this.selectionStart!==0?(this._selectionDirection=it,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===it&&this.selectionStart!==this.selectionEnd?this._moveRight(t,"selectionStart"):this.selectionEnd!==this._text.length?(this._selectionDirection=Ct,this._moveRight(t,"selectionEnd")):void 0}moveCursorRightWithoutShift(t){let e=!0;return this._selectionDirection=Ct,this.selectionStart===this.selectionEnd?(e=this._moveRight(t,"selectionStart"),this.selectionEnd=this.selectionStart):this.selectionStart=this.selectionEnd,e}}const Ro=n=>!!n.button;class Jf extends Zf{constructor(){super(...arguments),b(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 Kf(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),ea(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&&!Ro(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&&!Ro(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||Ro(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(Me(this.calcTransformMatrix())).add(new w(-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 Kr="moveCursorUp",qr="moveCursorDown",Zr="moveCursorLeft",Jr="moveCursorRight",Qr="exitEditing",Qf=_({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:Qr,27:Qr,33:Kr,34:qr,35:Jr,36:Zr,37:Zr,38:Kr,39:Jr,40:qr},keysMapRtl:{9:Qr,27:Qr,33:Kr,34:qr,35:Zr,36:Jr,37:Jr,38:Kr,39:Zr,40:qr},ctrlKeysMapDown:{65:"selectAll"},ctrlKeysMapUp:{67:"copy",88:"cut"}},{_selectionDirection:null,_reSpace:/\s|\r?\n/,inCompositionMode:!1});class ri extends Jf{static getDefaults(){return _(_({},super.getDefaults()),ri.ownDefaults)}get type(){const t=super.type;return t==="itext"?"i-text":t}constructor(t,e){super(t,_(_({},ri.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 mr&&this.canvas.textEditingManager.remove(this),e instanceof mr&&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===Ct||this.textAlign===Be||this.textAlign===rr?l.left*=-1:this.textAlign===it||this.textAlign===Un?l.left=o-(i>0?i:0):this.textAlign!==K&&this.textAlign!==nr||(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(Be),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 p=c;p<=h;p++){const f=this._getLineLeftOffset(p)||0;let g=this.getHeightOfLine(p),m=0,v=0,y=0;if(p===c&&(v=this.__charBounds[c][u].left),p>=c&&p<h)y=o&&!this.isEndOfWrapping(p)?this.width:this.getLineWidth(p)||5;else if(p===h)if(d===0)y=this.__charBounds[h][d].left;else{const C=this._getWidthOfCharSpacing();y=this.__charBounds[h][d-1].left+this.__charBounds[h][d-1].width-C}m=g,(this.lineHeight<1||p===h&&this.lineHeight>1)&&(g/=this.lineHeight);let x=i.left+f+v,E=g,O=0;const D=y-v;this.inCompositionMode?(t.fillStyle=this.compositionColor||"black",E=1,O=g):t.fillStyle=this.selectionColor,this.direction==="rtl"&&(this.textAlign===Ct||this.textAlign===Be||this.textAlign===rr?x=this.width-x-D:this.textAlign===it||this.textAlign===Un?x=i.left+f-y:this.textAlign!==K&&this.textAlign!==nr||(x=i.left+f-y)),t.fillRect(x,i.top+i.topOffset+O,D,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,Ft)}_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()}}b(ri,"ownDefaults",Qf),b(ri,"type","IText"),R.setClass(ri),R.setClass(ri,"i-text");class ni extends ri{static getDefaults(){return _(_({},super.getDefaults()),ni.ownDefaults)}constructor(t,e){super(t,_(_({},ni.ownDefaults),e))}static createControls(){return{controls:kp()}}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(Be)&&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=[],p=0,f=0,g=!0;e-=o;const m=Math.max(e,s,this.dynamicMinWidth),v=r[t];let y;for(p=0,y=0;y<v.length;y++){const{word:x,width:E}=v[y];p+=x.length,u+=f+E-a,u>m&&!g?(c.push(d),d=[],u=E,g=!0):u+=a,g||l||d.push(h),d=d.concat(x),f=l?0:this._measureWord([h],t,p),p++,g=!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])}}b(ni,"type","Textbox"),b(ni,"textLayoutProperties",[...ri.textLayoutProperties,"width"]),b(ni,"ownDefaults",{minWidth:20,dynamicMinWidth:2,lockScalingFlip:!0,noScaleCache:!1,_wordJoiners:/[ \t\r]/,splitByGrapheme:!1}),R.setClass(ni);class sc extends no{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}=li(Mh(i,s)),l=new w(o,a);if(s.absolutePositioned)return{center:Cs(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 w,correction:u=new w}=this.calcBoundingBox(e,t)||{};return{center:h.add(c),correction:u.subtract(c),size:l}}return{center:i.getRelativeCenterPoint().add(c),size:l}}}}b(sc,"type","clip-path"),R.setClass(sc);class rc extends no{getInitialSize(t,e){let{target:i}=t,{size:s}=e;return new w(i.width||s.x,i.height||s.y)}}b(rc,"type","fixed"),R.setClass(rc);class tg extends gr{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 Zi extends ki{static getDefaults(){return _(_({},super.getDefaults()),Zi.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,Zi.ownDefaults),this.setOptions(e);const{left:i,top:s,layoutManager:r}=e;this.groupInit(t,{left:i,top:s,layoutManager:r??new tg})}_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))?(Ai("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===Ya?i.forEach(s=>{s._onAfterObjectsChange(zn,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=_(_({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()}}b(Zi,"type","ActiveSelection"),b(Zi,"ownDefaults",{multiSelectionStacking:"canvas-stacking"}),R.setClass(Zi),R.setClass(Zi,"activeSelection");class eg{constructor(){b(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 Jh{constructor(){let{tileSize:t=tt.textureSize}=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};b(this,"aPosition",new Float32Array([0,0,0,1,1,0,1,1])),b(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=Ue({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 p=d.targetCanvas,f=p.width,g=p.height,m=d.destinationWidth,v=d.destinationHeight;f===m&&g===v||(p.width=m,p.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:p,TEXTURE_WRAP_T:f}=t,g=t.createTexture();return t.bindTexture(a,g),t.texParameteri(a,u,r||o),t.texParameteri(a,d,r||o),t.texParameteri(a,p,h),t.texParameteri(a,f,h),s?t.texImage2D(a,0,l,l,c,s):t.texImage2D(a,0,l,e,i,0,l,c,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 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 $o;function ig(){const{WebGLProbe:n}=Ve();return n.queryWebGL(Fe()),tt.enableGLFiltering&&n.isSupported(tt.textureSize)?new Jh({tileSize:tt.textureSize}):new eg}function Bo(){return!$o&&(!(arguments.length>0&&arguments[0]!==void 0)||arguments[0])&&($o=ig()),$o}const sg=["filters","resizeFilter","src","crossOrigin","type"],Qh=["cropX","cropY"];class Xt extends Kt{static getDefaults(){return _(_({},super.getDefaults()),Xt.ownDefaults)}constructor(t,e){super(),b(this,"_lastScaleX",1),b(this,"_lastScaleY",1),b(this,"_filterScalingX",1),b(this,"_filterScalingY",1),this.filters=[],Object.assign(this,Xt.ownDefaults),this.setOptions(e),this.cacheKey="texture".concat(Pi()),this.setElement(typeof t=="string"?(this.canvas&&De(this.canvas.getElement())||Ds()).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=Bo(!1);e instanceof Jh&&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&&Ve().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())}),_(_({},super.toObject([...Qh,...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=Pi();r.push('<clipPath id="imageCrop_'+c+`">
184
+ `,' <rect x="'+i+'" y="'+s+'" width="'+this.width+'" height="'+this.height+`" />
147
185
  `,`</clipPath>
148
- `),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(r-this.cropY,'" width="').concat(e.width||e.naturalWidth,'" height="').concat(e.height||e.naturalHeight,'"').concat(l).concat(a,`></image>
149
- `)),this.stroke||this.strokeDashArray){const c=this.fill;this.fill=null,o=[' <rect x="'.concat(i,'" y="').concat(r,'" width="').concat(this.width,'" height="').concat(this.height,'" style="').concat(this.getSvgStyles(),`" />
150
- `)],this.fill=c}return s=this.paintFirst!==It?s.concat(o,t):s.concat(t,o),s}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 sn(t,{crossOrigin:e,signal:i}).then(r=>{e!==void 0&&this.set({crossOrigin:e}),this.setElement(r)})}toString(){return'#<Image: { src: "'.concat(this.getSrc(),'" }>')}applyResizeFilters(){const t=this.resizeFilter,e=this.minimumScaleTrigger,i=this.getTotalObjectScaling(),r=i.x,s=i.y,o=this._filteredEl||this._originalElement;if(this.group&&this.set("dirty",!0),!t||r>e&&s>e)return this._element=o,this._filterScalingX=1,this._filterScalingY=1,this._lastScaleX=r,void(this._lastScaleY=s);const a=Ne(o),{width:l,height:c}=o;this._element=a,this._lastScaleX=t.scaleX=r,this._lastScaleY=t.scaleY=s,co().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(s=>s&&!s.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,r=e.naturalHeight||e.height;if(this._element===this._originalElement){const s=Ne({width:i,height:r});this._element=s,this._filteredEl=s}else this._filteredEl&&(this._element=this._filteredEl,this._filteredEl.getContext("2d").clearRect(0,0,i,r),this._lastScaleX=1,this._lastScaleY=1);co().applyFilters(t,this._originalElement,i,r,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,r=this._filterScalingY,s=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*r,p=Math.min(s*i,c-u),f=Math.min(o*r,h-d),g=-s/2,m=-o/2,v=Math.min(s,c/i-a),y=Math.min(o,h/r-l);e&&t.drawImage(e,u,d,p,f,g,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=Ou(this.preserveAspectRatio||""),e=this.width,i=this.height,r={width:e,height:i};let s,o=this._element.width,a=this._element.height,l=1,c=1,h=0,u=0,d=0,p=0;return!t||t.alignX===oe&&t.alignY===oe?(l=e/o,c=i/a):(t.meetOrSlice==="meet"&&(l=c=qd(this._element,r),s=(e-o*l)/2,t.alignX==="Min"&&(h=-s),t.alignX==="Max"&&(h=s),s=(i-a*c)/2,t.alignY==="Min"&&(u=-s),t.alignY==="Max"&&(u=s)),t.meetOrSlice==="slice"&&(l=c=Zd(this._element,r),s=o-e/l,t.alignX==="Mid"&&(d=s/2),t.alignX==="Max"&&(d=s),s=a-i/c,t.alignY==="Mid"&&(p=s/2),t.alignY==="Max"&&(p=s),o=e/l,a=i/c)),{width:o,height:a,scaleX:l,scaleY:c,offsetLeft:h,offsetTop:u,cropX:d,cropY:p}}static fromObject(t,e){let{filters:i,resizeFilter:r,src:s,crossOrigin:o,type:a}=t,l=ht(t,Gp);return Promise.all([sn(s,_(_({},e),{},{crossOrigin:o})),i&&Xr(i,e),r&&Xr([r],e),Mn(l,e)]).then(c=>{let[h,u=[],[d]=[],p={}]=c;return new this(h,_(_({},l),{},{src:s,filters:u,resizeFilter:d},p))})}static fromURL(t){let{crossOrigin:e=null,signal:i}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},r=arguments.length>2?arguments[2]:void 0;return sn(t,{crossOrigin:e,signal:i}).then(s=>new this(s,r))}static async fromElement(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},i=arguments.length>2?arguments[2]:void 0;const r=di(t,this.ATTRIBUTE_NAMES,i);return this.fromURL(r["xlink:href"],e,r).catch(s=>(yi("log","Unable to parse Image",s),null))}}b(Ut,"type","Image"),b(Ut,"cacheProperties",[...ui,...rh]),b(Ut,"ownDefaults",{strokeWidth:0,srcFromAttribute:!1,minimumScaleTrigger:.5,cropX:0,cropY:0,imageSmoothing:!0}),b(Ut,"CSS_CANVAS","canvas-img"),b(Ut,"ATTRIBUTE_NAMES",[...Di,"x","y","width","height","preserveAspectRatio","xlink:href","crossOrigin","image-rendering"]),R.setClass(Ut),R.setSVGClass(Ut);Ln(["pattern","defs","symbol","metadata","clipPath","mask","desc"]);const Bn=n=>n.webgl!==void 0,ba="precision highp float",Up=`
151
- `.concat(ba,`;
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!==Ft?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 Sn(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=Ue(o),{width:l,height:c}=o;this._element=a,this._lastScaleX=t.scaleX=s,this._lastScaleY=t.scaleY=r,Bo().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=Ue({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);Bo().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,p=Math.min(r*i,c-u),f=Math.min(o*s,h-d),g=-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,p,f,g,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=$d(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,p=0;return!t||t.alignX===ce&&t.alignY===ce?(l=e/o,c=i/a):(t.meetOrSlice==="meet"&&(l=c=lf(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=cf(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"&&(p=r/2),t.alignY==="Max"&&(p=r),o=e/l,a=i/c)),{width:o,height:a,scaleX:l,scaleY:c,offsetLeft:h,offsetTop:u,cropX:d,cropY:p}}static fromObject(t,e){let{filters:i,resizeFilter:s,src:r,crossOrigin:o,type:a}=t,l=ut(t,sg);return Promise.all([Sn(r,_(_({},e),{},{crossOrigin:o})),i&&dr(i,e),s&&dr([s],e),eo(l,e)]).then(c=>{let[h,u=[],[d]=[],p={}]=c;return new this(h,_(_({},l),{},{src:r,filters:u,resizeFilter:d},p))})}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 Sn(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=vi(t,this.ATTRIBUTE_NAMES,i);return this.fromURL(s["xlink:href"],e,s).catch(r=>(Ai("log","Unable to parse Image",r),null))}}b(Xt,"type","Image"),b(Xt,"cacheProperties",[...mi,...Qh]),b(Xt,"ownDefaults",{strokeWidth:0,srcFromAttribute:!1,minimumScaleTrigger:.5,cropX:0,cropY:0,imageSmoothing:!0}),b(Xt,"CSS_CANVAS","canvas-img"),b(Xt,"ATTRIBUTE_NAMES",[...$i,"x","y","width","height","preserveAspectRatio","xlink:href","crossOrigin","image-rendering"]),R.setClass(Xt),R.setSVGClass(Xt);so(["pattern","defs","symbol","metadata","clipPath","mask","desc"]);const ao=n=>n.webgl!==void 0,Xa="precision highp float",rg=`
189
+ `.concat(Xa,`;
152
190
  varying vec2 vTexCoord;
153
191
  uniform sampler2D uTexture;
154
192
  void main() {
155
193
  gl_FragColor = texture2D(uTexture, vTexCoord);
156
- }`),Yp=["type"],Xp=["type"],Kp=new RegExp(ba,"g");class Lt{get type(){return this.constructor.type}constructor(){let t=ht(arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},Yp);Object.assign(this,this.constructor.defaults,t)}getFragmentSource(){return Up}getVertexSource(){return`
194
+ }`),ng=["type"],og=["type"],ag=new RegExp(Xa,"g");class jt{get type(){return this.constructor.type}constructor(){let t=ut(arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},ng);Object.assign(this,this.constructor.defaults,t)}getFragmentSource(){return rg}getVertexSource(){return`
157
195
  attribute vec2 aPosition;
158
196
  varying vec2 vTexCoord;
159
197
  void main() {
160
198
  vTexCoord = aPosition;
161
199
  gl_Position = vec4(aPosition * 2.0 - 1.0, 0.0, 1.0);
162
- }`}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:r="highp"}}=Be();r!=="highp"&&(e=e.replace(Kp,ba.replace("highp",r)));const s=t.createShader(t.VERTEX_SHADER),o=t.createShader(t.FRAGMENT_SHADER),a=t.createProgram();if(!s||!o||!a)throw new je("Vertex, fragment shader or program creation error");if(t.shaderSource(s,i),t.compileShader(s),!t.getShaderParameter(s,t.COMPILE_STATUS))throw new je("Vertex shader compile error for ".concat(this.type,": ").concat(t.getShaderInfoLog(s)));if(t.shaderSource(o,e),t.compileShader(o),!t.getShaderParameter(o,t.COMPILE_STATUS))throw new je("Fragment shader compile error for ".concat(this.type,": ").concat(t.getShaderInfoLog(o)));if(t.attachShader(a,s),t.attachShader(a,o),t.linkProgram(a),!t.getProgramParameter(a,t.LINK_STATUS))throw new je('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,r={};for(let s=0;s<i.length;s++)r[i[s]]=t.getUniformLocation(e,i[s]);return r}sendAttributeData(t,e,i){const r=e.aPosition,s=t.createBuffer();t.bindBuffer(t.ARRAY_BUFFER,s),t.enableVertexAttribArray(r),t.vertexAttribPointer(r,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,r=t.destinationHeight;t.sourceWidth===i&&t.sourceHeight===r||(e.deleteTexture(t.targetTexture),t.targetTexture=t.filterBackend.createTexture(e,i,r)),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){Bn(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,r=Ne({width:e,height:i});t.helpLayer=r}}toObject(){const t=Object.keys(this.constructor.defaults||{});return _({type:this.type},t.reduce((e,i)=>(e[i]=this[i],e),{}))}toJSON(){return this.toObject()}static async fromObject(t,e){return new this(ht(t,Xp))}}b(Lt,"type","BaseFilter"),b(Lt,"uniformLocations",[]);const qp={multiply:`gl_FragColor.rgb *= uColor.rgb;
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"}}=Ve();s!=="highp"&&(e=e.replace(ag,Xa.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 ze("Vertex, fragment shader or program creation error");if(t.shaderSource(r,i),t.compileShader(r),!t.getShaderParameter(r,t.COMPILE_STATUS))throw new ze("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 ze("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 ze('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){ao(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=Ue({width:e,height:i});t.helpLayer=s}}toObject(){const t=Object.keys(this.constructor.defaults||{});return _({type:this.type},t.reduce((e,i)=>(e[i]=this[i],e),{}))}toJSON(){return this.toObject()}static async fromObject(t,e){return new this(ut(t,og))}}b(jt,"type","BaseFilter"),b(jt,"uniformLocations",[]);const lg={multiply:`gl_FragColor.rgb *= uColor.rgb;
163
201
  `,screen:`gl_FragColor.rgb = 1.0 - (1.0 - gl_FragColor.rgb) * (1.0 - uColor.rgb);
164
202
  `,add:`gl_FragColor.rgb += uColor.rgb;
165
203
  `,difference:`gl_FragColor.rgb = abs(gl_FragColor.rgb - uColor.rgb);
@@ -186,7 +224,7 @@ Resulting to default behavior: removing object from previous canvas and adding t
186
224
  `,tint:`
187
225
  gl_FragColor.rgb *= (1.0 - uColor.a);
188
226
  gl_FragColor.rgb += uColor.rgb;
189
- `};class Fs extends Lt{getCacheKey(){return"".concat(this.type,"_").concat(this.mode)}getFragmentSource(){return`
227
+ `};class tn extends jt{getCacheKey(){return"".concat(this.type,"_").concat(this.mode)}getFragmentSource(){return`
190
228
  precision highp float;
191
229
  uniform sampler2D uTexture;
192
230
  uniform vec4 uColor;
@@ -195,10 +233,10 @@ Resulting to default behavior: removing object from previous canvas and adding t
195
233
  vec4 color = texture2D(uTexture, vTexCoord);
196
234
  gl_FragColor = color;
197
235
  if (color.a > 0.0) {
198
- `.concat(qp[this.mode],`
236
+ `.concat(lg[this.mode],`
199
237
  }
200
238
  }
201
- `)}applyTo2d(t){let{imageData:{data:e}}=t;const i=new rt(this.color).getSource(),r=this.alpha,s=i[0]*r,o=i[1]*r,a=i[2]*r,l=1-r;for(let c=0;c<e.length;c+=4){const h=e[c],u=e[c+1],d=e[c+2];let p,f,g;switch(this.mode){case"multiply":p=h*s/255,f=u*o/255,g=d*a/255;break;case"screen":p=255-(255-h)*(255-s)/255,f=255-(255-u)*(255-o)/255,g=255-(255-d)*(255-a)/255;break;case"add":p=h+s,f=u+o,g=d+a;break;case"difference":p=Math.abs(h-s),f=Math.abs(u-o),g=Math.abs(d-a);break;case"subtract":p=h-s,f=u-o,g=d-a;break;case"darken":p=Math.min(h,s),f=Math.min(u,o),g=Math.min(d,a);break;case"lighten":p=Math.max(h,s),f=Math.max(u,o),g=Math.max(d,a);break;case"overlay":p=s<128?2*h*s/255:255-2*(255-h)*(255-s)/255,f=o<128?2*u*o/255:255-2*(255-u)*(255-o)/255,g=a<128?2*d*a/255:255-2*(255-d)*(255-a)/255;break;case"exclusion":p=s+h-2*s*h/255,f=o+u-2*o*u/255,g=a+d-2*a*d/255;break;case"tint":p=s+h*l,f=o+u*l,g=a+d*l}e[c]=p,e[c+1]=f,e[c+2]=g}}sendUniformData(t,e){const i=new rt(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)}}b(Fs,"defaults",{color:"#F95C63",mode:"multiply",alpha:1}),b(Fs,"type","BlendColor"),b(Fs,"uniformLocations",["uColor"]),R.setClass(Fs);const Zp={multiply:`
239
+ `)}applyTo2d(t){let{imageData:{data:e}}=t;const i=new st(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 p,f,g;switch(this.mode){case"multiply":p=h*r/255,f=u*o/255,g=d*a/255;break;case"screen":p=255-(255-h)*(255-r)/255,f=255-(255-u)*(255-o)/255,g=255-(255-d)*(255-a)/255;break;case"add":p=h+r,f=u+o,g=d+a;break;case"difference":p=Math.abs(h-r),f=Math.abs(u-o),g=Math.abs(d-a);break;case"subtract":p=h-r,f=u-o,g=d-a;break;case"darken":p=Math.min(h,r),f=Math.min(u,o),g=Math.min(d,a);break;case"lighten":p=Math.max(h,r),f=Math.max(u,o),g=Math.max(d,a);break;case"overlay":p=r<128?2*h*r/255:255-2*(255-h)*(255-r)/255,f=o<128?2*u*o/255:255-2*(255-u)*(255-o)/255,g=a<128?2*d*a/255:255-2*(255-d)*(255-a)/255;break;case"exclusion":p=r+h-2*r*h/255,f=o+u-2*o*u/255,g=a+d-2*a*d/255;break;case"tint":p=r+h*l,f=o+u*l,g=a+d*l}e[c]=p,e[c+1]=f,e[c+2]=g}}sendUniformData(t,e){const i=new st(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)}}b(tn,"defaults",{color:"#F95C63",mode:"multiply",alpha:1}),b(tn,"type","BlendColor"),b(tn,"uniformLocations",["uColor"]),R.setClass(tn);const cg={multiply:`
202
240
  precision highp float;
203
241
  uniform sampler2D uTexture;
204
242
  uniform sampler2D uImage;
@@ -224,7 +262,7 @@ Resulting to default behavior: removing object from previous canvas and adding t
224
262
  color.a = color2.a;
225
263
  gl_FragColor = color;
226
264
  }
227
- `},Jp=["type","image"];class js extends Lt{getCacheKey(){return"".concat(this.type,"_").concat(this.mode)}getFragmentSource(){return Zp[this.mode]}getVertexSource(){return`
265
+ `},hg=["type","image"];class en extends jt{getCacheKey(){return"".concat(this.type,"_").concat(this.mode)}getFragmentSource(){return cg[this.mode]}getVertexSource(){return`
228
266
  attribute vec2 aPosition;
229
267
  varying vec2 vTexCoord;
230
268
  varying vec2 vTexCoord2;
@@ -234,7 +272,7 @@ Resulting to default behavior: removing object from previous canvas and adding t
234
272
  vTexCoord2 = (uTransformMatrix * vec3(aPosition, 1.0)).xy;
235
273
  gl_Position = vec4(aPosition * 2.0 - 1.0, 0.0, 1.0);
236
274
  }
237
- `}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:r},filterBackend:{resources:s}}=t;const o=this.image;s.blendImage||(s.blendImage=Ae());const a=s.blendImage,l=a.getContext("2d");a.width!==i||a.height!==r?(a.width=i,a.height=r):l.clearRect(0,0,i,r),l.setTransform(o.scaleX,0,0,o.scaleY,o.left,o.top),l.drawImage(o.getElement(),0,0,i,r);const c=l.getImageData(0,0,i,r).data;for(let h=0;h<e.length;h+=4){const u=e[h],d=e[h+1],p=e[h+2],f=e[h+3],g=c[h],m=c[h+1],v=c[h+2],y=c[h+3];switch(this.mode){case"multiply":e[h]=u*g/255,e[h+1]=d*m/255,e[h+2]=p*v/255,e[h+3]=f*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 _(_({},super.toObject()),{},{image:this.image&&this.image.toObject()})}static async fromObject(t,e){let{type:i,image:r}=t,s=ht(t,Jp);return Ut.fromObject(r,e).then(o=>new this(_(_({},s),{},{image:o})))}}b(js,"type","BlendImage"),b(js,"defaults",{mode:"multiply",alpha:1}),b(js,"uniformLocations",["uTransformMatrix","uImage"]),R.setClass(js);class Rs extends Lt{getFragmentSource(){return`
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=Fe());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],p=e[h+2],f=e[h+3],g=c[h],m=c[h+1],v=c[h+2],y=c[h+3];switch(this.mode){case"multiply":e[h]=u*g/255,e[h+1]=d*m/255,e[h+2]=p*v/255,e[h+3]=f*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 _(_({},super.toObject()),{},{image:this.image&&this.image.toObject()})}static async fromObject(t,e){let{type:i,image:s}=t,r=ut(t,hg);return Xt.fromObject(s,e).then(o=>new this(_(_({},r),{},{image:o})))}}b(en,"type","BlendImage"),b(en,"defaults",{mode:"multiply",alpha:1}),b(en,"uniformLocations",["uTransformMatrix","uImage"]),R.setClass(en);class sn extends jt{getFragmentSource(){return`
238
276
  precision highp float;
239
277
  uniform sampler2D uTexture;
240
278
  uniform vec2 uDelta;
@@ -257,7 +295,7 @@ Resulting to default behavior: removing object from previous canvas and adding t
257
295
  }
258
296
  gl_FragColor = color / total;
259
297
  }
260
- `}applyTo(t){Bn(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:r}}=t;const{width:s,height:o}=i;r.blurLayer1||(r.blurLayer1=Ae(),r.blurLayer2=Ae());const a=r.blurLayer1,l=r.blurLayer2;a.width===s&&a.height===o||(l.width=a.width=s,l.height=a.height=o);const c=a.getContext("2d"),h=l.getContext("2d"),u=15,d=.06*this.blur*.5;let p,f,g,m;for(c.putImageData(i,0,0),h.clearRect(0,0,s,o),m=-15;m<=u;m++)p=(Math.random()-.5)/4,f=m/u,g=d*f*s+p,h.globalAlpha=1-Math.abs(f),h.drawImage(a,g,p),c.drawImage(l,0,0),h.globalAlpha=1,h.clearRect(0,0,l.width,l.height);for(m=-15;m<=u;m++)p=(Math.random()-.5)/4,f=m/u,g=d*f*o+p,h.globalAlpha=1-Math.abs(f),h.drawImage(a,p,g),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}}b(Rs,"type","Blur"),b(Rs,"defaults",{blur:0}),b(Rs,"uniformLocations",["uDelta"]),R.setClass(Rs);class Bs extends Lt{getFragmentSource(){return`
298
+ `}applyTo(t){ao(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=Fe(),s.blurLayer2=Fe());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 p,f,g,m;for(c.putImageData(i,0,0),h.clearRect(0,0,r,o),m=-15;m<=u;m++)p=(Math.random()-.5)/4,f=m/u,g=d*f*r+p,h.globalAlpha=1-Math.abs(f),h.drawImage(a,g,p),c.drawImage(l,0,0),h.globalAlpha=1,h.clearRect(0,0,l.width,l.height);for(m=-15;m<=u;m++)p=(Math.random()-.5)/4,f=m/u,g=d*f*o+p,h.globalAlpha=1-Math.abs(f),h.drawImage(a,p,g),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}}b(sn,"type","Blur"),b(sn,"defaults",{blur:0}),b(sn,"uniformLocations",["uDelta"]),R.setClass(sn);class rn extends jt{getFragmentSource(){return`
261
299
  precision highp float;
262
300
  uniform sampler2D uTexture;
263
301
  uniform float uBrightness;
@@ -267,7 +305,7 @@ Resulting to default behavior: removing object from previous canvas and adding t
267
305
  color.rgb += uBrightness;
268
306
  gl_FragColor = color;
269
307
  }
270
- `}applyTo2d(t){let{imageData:{data:e}}=t;const i=Math.round(255*this.brightness);for(let r=0;r<e.length;r+=4)e[r]+=i,e[r+1]+=i,e[r+2]+=i}isNeutralState(){return this.brightness===0}sendUniformData(t,e){t.uniform1f(e.uBrightness,this.brightness)}}b(Bs,"type","Brightness"),b(Bs,"defaults",{brightness:0}),b(Bs,"uniformLocations",["uBrightness"]),R.setClass(Bs);const sh={matrix:[1,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,1,0],colorsOnly:!0};class nr extends Lt{getFragmentSource(){return`
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)}}b(rn,"type","Brightness"),b(rn,"defaults",{brightness:0}),b(rn,"uniformLocations",["uBrightness"]),R.setClass(rn);const tu={matrix:[1,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,1,0],colorsOnly:!0};class bs extends jt{getFragmentSource(){return`
271
309
  precision highp float;
272
310
  uniform sampler2D uTexture;
273
311
  varying vec2 vTexCoord;
@@ -278,7 +316,7 @@ Resulting to default behavior: removing object from previous canvas and adding t
278
316
  color *= uColorMatrix;
279
317
  color += uConstants;
280
318
  gl_FragColor = color;
281
- }`}applyTo2d(t){const e=t.imageData.data,i=this.matrix,r=this.colorsOnly;for(let s=0;s<e.length;s+=4){const o=e[s],a=e[s+1],l=e[s+2];if(e[s]=o*i[0]+a*i[1]+l*i[2]+255*i[4],e[s+1]=o*i[5]+a*i[6]+l*i[7]+255*i[9],e[s+2]=o*i[10]+a*i[11]+l*i[12]+255*i[14],!r){const c=e[s+3];e[s]+=c*i[3],e[s+1]+=c*i[8],e[s+2]+=c*i[13],e[s+3]=o*i[15]+a*i[16]+l*i[17]+c*i[18]+255*i[19]}}}sendUniformData(t,e){const i=this.matrix,r=[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]],s=[i[4],i[9],i[14],i[19]];t.uniformMatrix4fv(e.uColorMatrix,!1,r),t.uniform4fv(e.uConstants,s)}toObject(){return _(_({},super.toObject()),{},{matrix:[...this.matrix]})}}function Xi(n,t){var e;const i=(b(e=class extends nr{toObject(){return{type:this.type,colorsOnly:this.colorsOnly}}},"type",n),b(e,"defaults",{colorsOnly:!1,matrix:t}),e);return R.setClass(i,n),i}b(nr,"type","ColorMatrix"),b(nr,"defaults",sh),b(nr,"uniformLocations",["uColorMatrix","uConstants"]),R.setClass(nr);Xi("Brownie",[.5997,.34553,-.27082,0,.186,-.0377,.86095,.15059,0,-.1449,.24113,-.07441,.44972,0,-.02965,0,0,0,1,0]);Xi("Vintage",[.62793,.32021,-.03965,0,.03784,.02578,.64411,.03259,0,.02926,.0466,-.08512,.52416,0,.02023,0,0,0,1,0]);Xi("Kodachrome",[1.12855,-.39673,-.03992,0,.24991,-.16404,1.08352,-.05498,0,.09698,-.16786,-.56034,1.60148,0,.13972,0,0,0,1,0]);Xi("Technicolor",[1.91252,-.85453,-.09155,0,.04624,-.30878,1.76589,-.10601,0,-.27589,-.2311,-.75018,1.84759,0,.12137,0,0,0,1,0]);Xi("Polaroid",[1.438,-.062,-.062,0,0,-.122,1.378,-.122,0,0,-.016,-.016,1.483,0,0,0,0,0,1,0]);Xi("Sepia",[.393,.769,.189,0,0,.349,.686,.168,0,0,.272,.534,.131,0,0,0,0,0,1,0]);Xi("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 _l extends Lt{constructor(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};super(t),this.subFilters=t.subFilters||[]}applyTo(t){Bn(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=>R.getClass(i.type).fromObject(i,e))).then(i=>new this({subFilters:i}))}}b(_l,"type","Composed"),R.setClass(_l);class Ns extends Lt{getFragmentSource(){return`
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 _(_({},super.toObject()),{},{matrix:[...this.matrix]})}}function ns(n,t){var e;const i=(b(e=class extends bs{toObject(){return{type:this.type,colorsOnly:this.colorsOnly}}},"type",n),b(e,"defaults",{colorsOnly:!1,matrix:t}),e);return R.setClass(i,n),i}b(bs,"type","ColorMatrix"),b(bs,"defaults",tu),b(bs,"uniformLocations",["uColorMatrix","uConstants"]),R.setClass(bs);ns("Brownie",[.5997,.34553,-.27082,0,.186,-.0377,.86095,.15059,0,-.1449,.24113,-.07441,.44972,0,-.02965,0,0,0,1,0]);ns("Vintage",[.62793,.32021,-.03965,0,.03784,.02578,.64411,.03259,0,.02926,.0466,-.08512,.52416,0,.02023,0,0,0,1,0]);ns("Kodachrome",[1.12855,-.39673,-.03992,0,.24991,-.16404,1.08352,-.05498,0,.09698,-.16786,-.56034,1.60148,0,.13972,0,0,0,1,0]);ns("Technicolor",[1.91252,-.85453,-.09155,0,.04624,-.30878,1.76589,-.10601,0,-.27589,-.2311,-.75018,1.84759,0,.12137,0,0,0,1,0]);ns("Polaroid",[1.438,-.062,-.062,0,0,-.122,1.378,-.122,0,0,-.016,-.016,1.483,0,0,0,0,0,1,0]);ns("Sepia",[.393,.769,.189,0,0,.349,.686,.168,0,0,.272,.534,.131,0,0,0,0,0,1,0]);ns("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 jt{constructor(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};super(t),this.subFilters=t.subFilters||[]}applyTo(t){ao(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=>R.getClass(i.type).fromObject(i,e))).then(i=>new this({subFilters:i}))}}b(nc,"type","Composed"),R.setClass(nc);class nn extends jt{getFragmentSource(){return`
282
320
  precision highp float;
283
321
  uniform sampler2D uTexture;
284
322
  uniform float uContrast;
@@ -288,7 +326,7 @@ Resulting to default behavior: removing object from previous canvas and adding t
288
326
  float contrastF = 1.015 * (uContrast + 1.0) / (1.0 * (1.015 - uContrast));
289
327
  color.rgb = contrastF * (color.rgb - 0.5) + 0.5;
290
328
  gl_FragColor = color;
291
- }`}isNeutralState(){return this.contrast===0}applyTo2d(t){let{imageData:{data:e}}=t;const i=Math.floor(255*this.contrast),r=259*(i+255)/(255*(259-i));for(let s=0;s<e.length;s+=4)e[s]=r*(e[s]-128)+128,e[s+1]=r*(e[s+1]-128)+128,e[s+2]=r*(e[s+2]-128)+128}sendUniformData(t,e){t.uniform1f(e.uContrast,this.contrast)}}b(Ns,"type","Contrast"),b(Ns,"defaults",{contrast:0}),b(Ns,"uniformLocations",["uContrast"]),R.setClass(Ns);const Qp={Convolute_3_1:`
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)}}b(nn,"type","Contrast"),b(nn,"defaults",{contrast:0}),b(nn,"uniformLocations",["uContrast"]),R.setClass(nn);const ug={Convolute_3_1:`
292
330
  precision highp float;
293
331
  uniform sampler2D uTexture;
294
332
  uniform float uMatrix[9];
@@ -432,7 +470,7 @@ Resulting to default behavior: removing object from previous canvas and adding t
432
470
  gl_FragColor = color;
433
471
  gl_FragColor.a = alpha;
434
472
  }
435
- `};class zs extends Lt{getCacheKey(){return"".concat(this.type,"_").concat(Math.sqrt(this.matrix.length),"_").concat(this.opaque?1:0)}getFragmentSource(){return Qp[this.getCacheKey()]}applyTo2d(t){const e=t.imageData,i=e.data,r=this.matrix,s=Math.round(Math.sqrt(r.length)),o=Math.floor(s/2),a=e.width,l=e.height,c=t.ctx.createImageData(a,l),h=c.data,u=this.opaque?1:0;let d,p,f,g,m,v,y,x,T,E,A,C,S;for(A=0;A<l;A++)for(E=0;E<a;E++){for(m=4*(A*a+E),d=0,p=0,f=0,g=0,S=0;S<s;S++)for(C=0;C<s;C++)y=A+S-o,v=E+C-o,y<0||y>=l||v<0||v>=a||(x=4*(y*a+v),T=r[S*s+C],d+=i[x]*T,p+=i[x+1]*T,f+=i[x+2]*T,u||(g+=i[x+3]*T));h[m]=d,h[m+1]=p,h[m+2]=f,h[m+3]=u?i[m+3]:g}t.imageData=c}sendUniformData(t,e){t.uniform1fv(e.uMatrix,this.matrix)}toObject(){return _(_({},super.toObject()),{},{opaque:this.opaque,matrix:[...this.matrix]})}}b(zs,"type","Convolute"),b(zs,"defaults",{opaque:!1,matrix:[0,0,0,0,1,0,0,0,0]}),b(zs,"uniformLocations",["uMatrix","uOpaque","uHalfSize","uSize"]),R.setClass(zs);const nh="Gamma";class Vs extends Lt{getFragmentSource(){return`
473
+ `};class on extends jt{getCacheKey(){return"".concat(this.type,"_").concat(Math.sqrt(this.matrix.length),"_").concat(this.opaque?1:0)}getFragmentSource(){return ug[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,p,f,g,m,v,y,x,E,O,D,C,S;for(D=0;D<l;D++)for(O=0;O<a;O++){for(m=4*(D*a+O),d=0,p=0,f=0,g=0,S=0;S<r;S++)for(C=0;C<r;C++)y=D+S-o,v=O+C-o,y<0||y>=l||v<0||v>=a||(x=4*(y*a+v),E=s[S*r+C],d+=i[x]*E,p+=i[x+1]*E,f+=i[x+2]*E,u||(g+=i[x+3]*E));h[m]=d,h[m+1]=p,h[m+2]=f,h[m+3]=u?i[m+3]:g}t.imageData=c}sendUniformData(t,e){t.uniform1fv(e.uMatrix,this.matrix)}toObject(){return _(_({},super.toObject()),{},{opaque:this.opaque,matrix:[...this.matrix]})}}b(on,"type","Convolute"),b(on,"defaults",{opaque:!1,matrix:[0,0,0,0,1,0,0,0,0]}),b(on,"uniformLocations",["uMatrix","uOpaque","uHalfSize","uSize"]),R.setClass(on);const eu="Gamma";class an extends jt{getFragmentSource(){return`
436
474
  precision highp float;
437
475
  uniform sampler2D uTexture;
438
476
  uniform vec3 uGamma;
@@ -446,7 +484,7 @@ Resulting to default behavior: removing object from previous canvas and adding t
446
484
  gl_FragColor = color;
447
485
  gl_FragColor.rgb *= color.a;
448
486
  }
449
- `}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,r=1/i[0],s=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,r),a.g[l]=255*Math.pow(l/255,s),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:nh,gamma:this.gamma.concat()}}}b(Vs,"type",nh),b(Vs,"defaults",{gamma:[1,1,1]}),b(Vs,"uniformLocations",["uGamma"]),R.setClass(Vs);const tf={average:`
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:eu,gamma:this.gamma.concat()}}}b(an,"type",eu),b(an,"defaults",{gamma:[1,1,1]}),b(an,"uniformLocations",["uGamma"]),R.setClass(an);const dg={average:`
450
488
  precision highp float;
451
489
  uniform sampler2D uTexture;
452
490
  varying vec2 vTexCoord;
@@ -475,7 +513,7 @@ Resulting to default behavior: removing object from previous canvas and adding t
475
513
  float average = 0.21 * col.r + 0.72 * col.g + 0.07 * col.b;
476
514
  gl_FragColor = vec4(average, average, average, col.a);
477
515
  }
478
- `};class Hs extends Lt{applyTo2d(t){let{imageData:{data:e}}=t;for(let i,r=0;r<e.length;r+=4){const s=e[r],o=e[r+1],a=e[r+2];switch(this.mode){case"average":i=(s+o+a)/3;break;case"lightness":i=(Math.min(s,o,a)+Math.max(s,o,a))/2;break;case"luminosity":i=.21*s+.72*o+.07*a}e[r+2]=e[r+1]=e[r]=i}}getCacheKey(){return"".concat(this.type,"_").concat(this.mode)}getFragmentSource(){return tf[this.mode]}sendUniformData(t,e){t.uniform1i(e.uMode,1)}isNeutralState(){return!1}}b(Hs,"type","Grayscale"),b(Hs,"defaults",{mode:"average"}),b(Hs,"uniformLocations",["uMode"]),R.setClass(Hs);const ef=_(_({},sh),{},{rotation:0});class ho extends nr{calculateMatrix(){const t=this.rotation*Math.PI,e=oi(t),i=ai(t),r=1/3,s=Math.sqrt(r)*i,o=1-e;this.matrix=[e+o/3,r*o-s,r*o+s,0,0,r*o+s,e+r*o,r*o-s,0,0,r*o-s,r*o+s,e+r*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}}}b(ho,"type","HueRotation"),b(ho,"defaults",ef),R.setClass(ho);class $s extends Lt{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`
516
+ `};class ln extends jt{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 dg[this.mode]}sendUniformData(t,e){t.uniform1i(e.uMode,1)}isNeutralState(){return!1}}b(ln,"type","Grayscale"),b(ln,"defaults",{mode:"average"}),b(ln,"uniformLocations",["uMode"]),R.setClass(ln);const pg=_(_({},tu),{},{rotation:0});class No extends bs{calculateMatrix(){const t=this.rotation*Math.PI,e=ui(t),i=di(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}}}b(No,"type","HueRotation"),b(No,"defaults",pg),R.setClass(No);class cn extends jt{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`
479
517
  precision highp float;
480
518
  uniform sampler2D uTexture;
481
519
  uniform int uInvert;
@@ -493,7 +531,7 @@ Resulting to default behavior: removing object from previous canvas and adding t
493
531
  gl_FragColor = color;
494
532
  }
495
533
  }
496
- `}isNeutralState(){return!this.invert}sendUniformData(t,e){t.uniform1i(e.uInvert,Number(this.invert)),t.uniform1i(e.uAlpha,Number(this.alpha))}}b($s,"type","Invert"),b($s,"defaults",{alpha:!1,invert:!0}),b($s,"uniformLocations",["uInvert","uAlpha"]),R.setClass($s);class Ws extends Lt{getFragmentSource(){return`
534
+ `}isNeutralState(){return!this.invert}sendUniformData(t,e){t.uniform1i(e.uInvert,Number(this.invert)),t.uniform1i(e.uAlpha,Number(this.alpha))}}b(cn,"type","Invert"),b(cn,"defaults",{alpha:!1,invert:!0}),b(cn,"uniformLocations",["uInvert","uAlpha"]),R.setClass(cn);class hn extends jt{getFragmentSource(){return`
497
535
  precision highp float;
498
536
  uniform sampler2D uTexture;
499
537
  uniform float uStepH;
@@ -508,7 +546,7 @@ Resulting to default behavior: removing object from previous canvas and adding t
508
546
  color.rgb += (0.5 - rand(vTexCoord, uSeed, 0.1 / uStepH)) * uNoise;
509
547
  gl_FragColor = color;
510
548
  }
511
- `}applyTo2d(t){let{imageData:{data:e}}=t;const i=this.noise;for(let r=0;r<e.length;r+=4){const s=(.5-Math.random())*i;e[r]+=s,e[r+1]+=s,e[r+2]+=s}}sendUniformData(t,e){t.uniform1f(e.uNoise,this.noise/255),t.uniform1f(e.uSeed,Math.random())}isNeutralState(){return this.noise===0}}b(Ws,"type","Noise"),b(Ws,"defaults",{noise:0}),b(Ws,"uniformLocations",["uNoise","uSeed"]),R.setClass(Ws);class Gs extends Lt{applyTo2d(t){let{imageData:{data:e,width:i,height:r}}=t;for(let s=0;s<r;s+=this.blocksize)for(let o=0;o<i;o+=this.blocksize){const a=4*s*i+4*o,l=e[a],c=e[a+1],h=e[a+2],u=e[a+3];for(let d=s;d<Math.min(s+this.blocksize,r);d++)for(let p=o;p<Math.min(o+this.blocksize,i);p++){const f=4*d*i+4*p;e[f]=l,e[f+1]=c,e[f+2]=h,e[f+3]=u}}}isNeutralState(){return this.blocksize===1}getFragmentSource(){return`
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}}b(hn,"type","Noise"),b(hn,"defaults",{noise:0}),b(hn,"uniformLocations",["uNoise","uSeed"]),R.setClass(hn);class un extends jt{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 p=o;p<Math.min(o+this.blocksize,i);p++){const f=4*d*i+4*p;e[f]=l,e[f+1]=c,e[f+2]=h,e[f+3]=u}}}isNeutralState(){return this.blocksize===1}getFragmentSource(){return`
512
550
  precision highp float;
513
551
  uniform sampler2D uTexture;
514
552
  uniform float uBlocksize;
@@ -526,7 +564,7 @@ Resulting to default behavior: removing object from previous canvas and adding t
526
564
  vec4 color = texture2D(uTexture, squareCoords);
527
565
  gl_FragColor = color;
528
566
  }
529
- `}sendUniformData(t,e){t.uniform1f(e.uBlocksize,this.blocksize)}}b(Gs,"type","Pixelate"),b(Gs,"defaults",{blocksize:4}),b(Gs,"uniformLocations",["uBlocksize"]),R.setClass(Gs);class Us extends Lt{getFragmentSource(){return`
567
+ `}sendUniformData(t,e){t.uniform1f(e.uBlocksize,this.blocksize)}}b(un,"type","Pixelate"),b(un,"defaults",{blocksize:4}),b(un,"uniformLocations",["uBlocksize"]),R.setClass(un);class dn extends jt{getFragmentSource(){return`
530
568
  precision highp float;
531
569
  uniform sampler2D uTexture;
532
570
  uniform vec4 uLow;
@@ -538,7 +576,7 @@ void main() {
538
576
  gl_FragColor.a = 0.0;
539
577
  }
540
578
  }
541
- `}applyTo2d(t){let{imageData:{data:e}}=t;const i=255*this.distance,r=new rt(this.color).getSource(),s=[r[0]-i,r[1]-i,r[2]-i],o=[r[0]+i,r[1]+i,r[2]+i];for(let a=0;a<e.length;a+=4){const l=e[a],c=e[a+1],h=e[a+2];l>s[0]&&c>s[1]&&h>s[2]&&l<o[0]&&c<o[1]&&h<o[2]&&(e[a+3]=0)}}sendUniformData(t,e){const i=new rt(this.color).getSource(),r=this.distance,s=[0+i[0]/255-r,0+i[1]/255-r,0+i[2]/255-r,1],o=[i[0]/255+r,i[1]/255+r,i[2]/255+r,1];t.uniform4fv(e.uLow,s),t.uniform4fv(e.uHigh,o)}}b(Us,"type","RemoveColor"),b(Us,"defaults",{color:"#FFFFFF",distance:.02,useAlpha:!1}),b(Us,"uniformLocations",["uLow","uHigh"]),R.setClass(Us);class Ys extends Lt{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(),r=new Array(i);for(let s=1;s<=i;s++)r[s-1]=t(s*e);return r}generateShader(t){const e=new Array(t);for(let i=1;i<=t;i++)e[i-1]="".concat(i,".0 * uDelta");return`
579
+ `}applyTo2d(t){let{imageData:{data:e}}=t;const i=255*this.distance,s=new st(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 st(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)}}b(dn,"type","RemoveColor"),b(dn,"defaults",{color:"#FFFFFF",distance:.02,useAlpha:!1}),b(dn,"uniformLocations",["uLow","uHigh"]),R.setClass(dn);class pn extends jt{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`
542
580
  precision highp float;
543
581
  uniform sampler2D uTexture;
544
582
  uniform vec2 uDelta;
@@ -547,14 +585,14 @@ void main() {
547
585
  void main() {
548
586
  vec4 color = texture2D(uTexture, vTexCoord);
549
587
  float sum = 1.0;
550
- `).concat(e.map((i,r)=>`
551
- color += texture2D(uTexture, vTexCoord + `.concat(i,") * uTaps[").concat(r,"] + texture2D(uTexture, vTexCoord - ").concat(i,") * uTaps[").concat(r,`];
552
- sum += 2.0 * uTaps[`).concat(r,`];
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,`];
553
591
  `)).join(`
554
592
  `),`
555
593
  gl_FragColor = color / sum;
556
594
  }
557
- `)}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){Bn(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,r=this.scaleY;this.rcpScaleX=1/i,this.rcpScaleY=1/r;const s=e.width,o=e.height,a=Math.round(s*i),l=Math.round(o*r);let c;c=this.resizeType==="sliceHack"?this.sliceByTwo(t,s,o,a,l):this.resizeType==="hermite"?this.hermiteFastResize(t,s,o,a,l):this.resizeType==="bilinear"?this.bilinearFiltering(t,s,o,a,l):this.resizeType==="lanczos"?this.lanczosResize(t,s,o,a,l):new ImageData(a,l),t.imageData=c}sliceByTwo(t,e,i,r,s){const o=t.imageData,a=.5;let l=!1,c=!1,h=e*a,u=i*a;const d=t.filterBackend.resources;let p=0,f=0;const g=e;let m=0;d.sliceByTwo||(d.sliceByTwo=Ae());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),r=Math.floor(r),s=Math.floor(s);!l||!c;)e=h,i=u,r<Math.floor(h*a)?h=Math.floor(h*a):(h=r,l=!0),s<Math.floor(u*a)?u=Math.floor(u*a):(u=s,c=!0),y.drawImage(v,p,f,e,i,g,m,h,u),p=g,f=m,m+=u;return y.getImageData(p,f,r,s)}lanczosResize(t,e,i,r,s){const o=t.imageData.data,a=t.ctx.createImageData(r,s),l=a.data,c=this.lanczosCreate(this.lanczosLobes),h=this.rcpScaleX,u=this.rcpScaleY,d=2/this.rcpScaleX,p=2/this.rcpScaleY,f=Math.ceil(h*this.lanczosLobes/2),g=Math.ceil(u*this.lanczosLobes/2),m={},v={x:0,y:0},y={x:0,y:0};return function x(T){let E,A,C,S,F,j,D,k,P,L,V;for(v.x=(T+.5)*h,y.x=Math.floor(v.x),E=0;E<s;E++){for(v.y=(E+.5)*u,y.y=Math.floor(v.y),F=0,j=0,D=0,k=0,P=0,A=y.x-f;A<=y.x+f;A++)if(!(A<0||A>=e)){L=Math.floor(1e3*Math.abs(A-v.x)),m[L]||(m[L]={});for(let Y=y.y-g;Y<=y.y+g;Y++)Y<0||Y>=i||(V=Math.floor(1e3*Math.abs(Y-v.y)),m[L][V]||(m[L][V]=c(Math.sqrt(Math.pow(L*d,2)+Math.pow(V*p,2))/1e3)),C=m[L][V],C>0&&(S=4*(Y*e+A),F+=C,j+=C*o[S],D+=C*o[S+1],k+=C*o[S+2],P+=C*o[S+3]))}S=4*(E*r+T),l[S]=j/F,l[S+1]=D/F,l[S+2]=k/F,l[S+3]=P/F}return++T<r?x(T):a}(0)}bilinearFiltering(t,e,i,r,s){let o,a,l,c,h,u,d,p,f,g,m,v,y,x=0;const T=this.rcpScaleX,E=this.rcpScaleY,A=4*(e-1),C=t.imageData.data,S=t.ctx.createImageData(r,s),F=S.data;for(d=0;d<s;d++)for(p=0;p<r;p++)for(h=Math.floor(T*p),u=Math.floor(E*d),f=T*p-h,g=E*d-u,y=4*(u*e+h),m=0;m<4;m++)o=C[y+m],a=C[y+4+m],l=C[y+A+m],c=C[y+A+4+m],v=o*(1-f)*(1-g)+a*f*(1-g)+l*g*(1-f)+c*f*g,F[x++]=v;return S}hermiteFastResize(t,e,i,r,s){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(r,s),d=u.data;for(let p=0;p<s;p++)for(let f=0;f<r;f++){const g=4*(f+p*r);let m=0,v=0,y=0,x=0,T=0,E=0,A=0;const C=(p+.5)*a;for(let S=Math.floor(p*a);S<(p+1)*a;S++){const F=Math.abs(C-(S+.5))/c,j=(f+.5)*o,D=F*F;for(let k=Math.floor(f*o);k<(f+1)*o;k++){let P=Math.abs(j-(k+.5))/l;const L=Math.sqrt(D+P*P);L>1&&L<-1||(m=2*L*L*L-3*L*L+1,m>0&&(P=4*(k+S*e),A+=m*h[P+3],y+=m,h[P+3]<255&&(m=m*h[P+3]/250),x+=m*h[P],T+=m*h[P+1],E+=m*h[P+2],v+=m))}}d[g]=x/v,d[g+1]=T/v,d[g+2]=E/v,d[g+3]=A/y}return u}}b(Ys,"type","Resize"),b(Ys,"defaults",{resizeType:"hermite",scaleX:1,scaleY:1,lanczosLobes:3}),b(Ys,"uniformLocations",["uDelta","uTaps"]),R.setClass(Ys);class Xs extends Lt{getFragmentSource(){return`
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){ao(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 p=0,f=0;const g=e;let m=0;d.sliceByTwo||(d.sliceByTwo=Fe());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,p,f,e,i,g,m,h,u),p=g,f=m,m+=u;return y.getImageData(p,f,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,p=2/this.rcpScaleY,f=Math.ceil(h*this.lanczosLobes/2),g=Math.ceil(u*this.lanczosLobes/2),m={},v={x:0,y:0},y={x:0,y:0};return function x(E){let O,D,C,S,F,j,A,k,P,L,z;for(v.x=(E+.5)*h,y.x=Math.floor(v.x),O=0;O<r;O++){for(v.y=(O+.5)*u,y.y=Math.floor(v.y),F=0,j=0,A=0,k=0,P=0,D=y.x-f;D<=y.x+f;D++)if(!(D<0||D>=e)){L=Math.floor(1e3*Math.abs(D-v.x)),m[L]||(m[L]={});for(let X=y.y-g;X<=y.y+g;X++)X<0||X>=i||(z=Math.floor(1e3*Math.abs(X-v.y)),m[L][z]||(m[L][z]=c(Math.sqrt(Math.pow(L*d,2)+Math.pow(z*p,2))/1e3)),C=m[L][z],C>0&&(S=4*(X*e+D),F+=C,j+=C*o[S],A+=C*o[S+1],k+=C*o[S+2],P+=C*o[S+3]))}S=4*(O*s+E),l[S]=j/F,l[S+1]=A/F,l[S+2]=k/F,l[S+3]=P/F}return++E<s?x(E):a}(0)}bilinearFiltering(t,e,i,s,r){let o,a,l,c,h,u,d,p,f,g,m,v,y,x=0;const E=this.rcpScaleX,O=this.rcpScaleY,D=4*(e-1),C=t.imageData.data,S=t.ctx.createImageData(s,r),F=S.data;for(d=0;d<r;d++)for(p=0;p<s;p++)for(h=Math.floor(E*p),u=Math.floor(O*d),f=E*p-h,g=O*d-u,y=4*(u*e+h),m=0;m<4;m++)o=C[y+m],a=C[y+4+m],l=C[y+D+m],c=C[y+D+4+m],v=o*(1-f)*(1-g)+a*f*(1-g)+l*g*(1-f)+c*f*g,F[x++]=v;return S}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 p=0;p<r;p++)for(let f=0;f<s;f++){const g=4*(f+p*s);let m=0,v=0,y=0,x=0,E=0,O=0,D=0;const C=(p+.5)*a;for(let S=Math.floor(p*a);S<(p+1)*a;S++){const F=Math.abs(C-(S+.5))/c,j=(f+.5)*o,A=F*F;for(let k=Math.floor(f*o);k<(f+1)*o;k++){let P=Math.abs(j-(k+.5))/l;const L=Math.sqrt(A+P*P);L>1&&L<-1||(m=2*L*L*L-3*L*L+1,m>0&&(P=4*(k+S*e),D+=m*h[P+3],y+=m,h[P+3]<255&&(m=m*h[P+3]/250),x+=m*h[P],E+=m*h[P+1],O+=m*h[P+2],v+=m))}}d[g]=x/v,d[g+1]=E/v,d[g+2]=O/v,d[g+3]=D/y}return u}}b(pn,"type","Resize"),b(pn,"defaults",{resizeType:"hermite",scaleX:1,scaleY:1,lanczosLobes:3}),b(pn,"uniformLocations",["uDelta","uTaps"]),R.setClass(pn);class fn extends jt{getFragmentSource(){return`
558
596
  precision highp float;
559
597
  uniform sampler2D uTexture;
560
598
  uniform float uSaturation;
@@ -568,7 +606,7 @@ void main() {
568
606
  color.b += rgbMax != color.b ? (rgbMax - color.b) * uSaturation : 0.00;
569
607
  gl_FragColor = color;
570
608
  }
571
- `}applyTo2d(t){let{imageData:{data:e}}=t;const i=-this.saturation;for(let r=0;r<e.length;r+=4){const s=e[r],o=e[r+1],a=e[r+2],l=Math.max(s,o,a);e[r]+=l!==s?(l-s)*i:0,e[r+1]+=l!==o?(l-o)*i:0,e[r+2]+=l!==a?(l-a)*i:0}}sendUniformData(t,e){t.uniform1f(e.uSaturation,-this.saturation)}isNeutralState(){return this.saturation===0}}b(Xs,"type","Saturation"),b(Xs,"defaults",{saturation:0}),b(Xs,"uniformLocations",["uSaturation"]),R.setClass(Xs);class Ks extends Lt{getFragmentSource(){return`
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}}b(fn,"type","Saturation"),b(fn,"defaults",{saturation:0}),b(fn,"uniformLocations",["uSaturation"]),R.setClass(fn);class gn extends jt{getFragmentSource(){return`
572
610
  precision highp float;
573
611
  uniform sampler2D uTexture;
574
612
  uniform float uVibrance;
@@ -583,7 +621,21 @@ void main() {
583
621
  color.b += max != color.b ? (max - color.b) * amt : 0.00;
584
622
  gl_FragColor = color;
585
623
  }
586
- `}applyTo2d(t){let{imageData:{data:e}}=t;const i=-this.vibrance;for(let r=0;r<e.length;r+=4){const s=e[r],o=e[r+1],a=e[r+2],l=Math.max(s,o,a),c=(s+o+a)/3,h=2*Math.abs(l-c)/255*i;e[r]+=l!==s?(l-s)*h:0,e[r+1]+=l!==o?(l-o)*h:0,e[r+2]+=l!==a?(l-a)*h:0}}sendUniformData(t,e){t.uniform1f(e.uVibrance,-this.vibrance)}isNeutralState(){return this.vibrance===0}}b(Ks,"type","Vibrance"),b(Ks,"defaults",{vibrance:0}),b(Ks,"uniformLocations",["uVibrance"]),R.setClass(Ks);const rf=vt`
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}}b(gn,"type","Vibrance"),b(gn,"defaults",{vibrance:0}),b(gn,"uniformLocations",["uVibrance"]),R.setClass(gn);function Q(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)}}}const wt=at`
625
+ :host {
626
+ box-sizing: border-box;
627
+ }
628
+
629
+ :host *,
630
+ :host *::before,
631
+ :host *::after {
632
+ box-sizing: inherit;
633
+ }
634
+
635
+ [hidden] {
636
+ display: none !important;
637
+ }
638
+ `,fg=at`
587
639
  :host {
588
640
  display: block;
589
641
  }
@@ -605,13 +657,13 @@ void main() {
605
657
  display: block;
606
658
  object-fit: contain;
607
659
  }
608
- `;var sf=Object.defineProperty,nf=Object.getOwnPropertyDescriptor,At=(n,t,e,i)=>{for(var r=i>1?void 0:i?nf(t,e):t,s=n.length-1,o;s>=0;s--)(o=n[s])&&(r=(i?o(t,e,r):o(r))||r);return i&&r&&sf(t,e,r),r};let ut=class extends Xo{constructor(){super(),this.backgroundUrl="https://upload.wikimedia.org/wikipedia/commons/0/06/Daedalus_Spaceship_concept.jpg",this.message=`Dear fridends,
660
+ `;var gg=Object.defineProperty,mg=Object.getOwnPropertyDescriptor,Mt=(n,t,e,i)=>{for(var s=i>1?void 0:i?mg(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&&gg(t,e,s),s};let dt=class extends Oi{constructor(){super(),this.backgroundUrl="https://upload.wikimedia.org/wikipedia/commons/0/06/Daedalus_Spaceship_concept.jpg",this.message=`Dear fridends,
609
661
 
610
662
  My name is xxxxx. sadf;lkasdf
611
663
  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(),new ResizeObserver(()=>{this.adjustCanvasElements()}).observe(this),this._backgroundImg.src="https://cdn.shopify.com/s/files/1/1956/2323/files/insert_86e8bcd5-3e82-4910-b350-485fa6958502.png?v=1726598821",this._backgroundImg.onload=()=>{this._natureSize={width:this._backgroundImg.naturalWidth,height:this._backgroundImg.naturalHeight}},this._canvasElement=document.createElement("canvas")}disconnectedCallback(){super.disconnectedCallback()}formatTextbox(n){var e;let t=n.textLines;if(t.length>12){const i=t.slice(0,12);n.set("text",i.join(`
612
- `)),n.setSelectionStart(n.text.length),n.setSelectionEnd(n.text.length),(e=this._canvas)==null||e.renderAll()}}firstUpdated(){var t;const n=document.createElement("canvas");(t=this.shadowRoot)==null||t.appendChild(n),this._backgroundImg.onload=()=>{const e=new Ut(this._backgroundImg);this._canvas=new Jr(n,{backgroundImage:e,containerClass:"fabric-container"}),this._canvas.setDimensions({width:this._backgroundImg.width,height:this._backgroundImg.height}),this._lineHeight=.45*this._backgroundImg.height/12,this._fontSize=this._lineHeight/1.16;const i={fontSize:(this._canvas.width-.4874*this._canvas.width-.084*this._canvas.width)/12*.8,left:.084*this._canvas.width,top:.4874*this._canvas.height,width:.832*this._canvas.width,height:this._canvas.width-.4874*this._canvas.width-.084*this._canvas.width,hasControls:!1,editable:!1,breakWords:!1,splitByGrapheme:!1,textAlign:this.alignment,lockMovementX:!0,lockMovementY:!0};this._textbox=new Qe(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(`
664
+ `)),n.setSelectionStart(n.text.length),n.setSelectionEnd(n.text.length),(e=this._canvas)==null||e.renderAll()}}firstUpdated(){var t;const n=document.createElement("canvas");(t=this.shadowRoot)==null||t.appendChild(n),this._backgroundImg.onload=()=>{const e=new Xt(this._backgroundImg);this._canvas=new mr(n,{backgroundImage:e,containerClass:"fabric-container"}),this._canvas.setDimensions({width:this._backgroundImg.width,height:this._backgroundImg.height}),this._lineHeight=.45*this._backgroundImg.height/12,this._fontSize=this._lineHeight/1.16;const i={fontSize:(this._canvas.width-.4874*this._canvas.width-.084*this._canvas.width)/12*.8,left:.084*this._canvas.width,top:.4874*this._canvas.height,width:.832*this._canvas.width,height:this._canvas.width-.4874*this._canvas.width-.084*this._canvas.width,hasControls:!1,editable:!1,breakWords:!1,splitByGrapheme:!1,textAlign:this.alignment,lockMovementX:!0,lockMovementY:!0};this._textbox=new ni(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(`
613
665
  `),a=[];o.forEach(c=>{if(c.length>20){const h=c.split(" ");let u="",d=0;h.forEach(p=>{d+p.length>20?(a.push(u.trim()),u=p+" ",d=p.length+1):(u+=p+" ",d+=p.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(`
614
- `),this._textbox.setSelectionStart(this._textbox.text.length),this._textbox.setSelectionEnd(this._textbox.text.length),(l=this._canvas)==null||l.renderAll()}),this._rect=new Rt({left:.084*this._canvas.width,top:.4874*this._canvas.height,width:.832*this._canvas.width,height:this._canvas.width-.4874*this._canvas.width-.084*this._canvas.width,fill:"red",selectable:!1}),this._canvas.add(this._textbox),this._canvas.centerObject(this._textbox),this._canvas.add(this._rect),this._canvas.renderAll()},window.addEventListener("resize",()=>{var e;n.width=this._fabricContainer.clientWidth,n.height=this._fabricContainer.clientHeight,this.adjustCanvasElements(),(e=this._canvas)==null||e.renderAll()}),setTimeout(()=>this.adjustCanvasElements(),100)}adjustCanvasElements(){var h,u;if(!this._canvas||!this._textbox||!this._backgroundImg||!this._backgroundImg.complete)return;const n=(h=this.shadowRoot)==null?void 0:h.querySelector(".fabric-container");if(!n)return;const t=n.clientWidth,e=n.clientHeight,i=this._backgroundImg.naturalWidth,r=this._backgroundImg.naturalHeight;let s;const o=t/e,a=i/r;e===0||t===0?s=t/i:o>a?s=e/r:s=t/i;const l=i*s,c=r*s;this._canvas.setDimensions({width:l,height:c}),this._canvas.backgroundImage&&(this._canvas.backgroundImage.scaleToWidth(l),this._canvas.backgroundImage.scaleToHeight(c)),this._textbox.set({left:.084*l,top:.4874*c,width:.832*l,height:c-.4874*c-.084*l,fontSize:(c-.4874*c-.084*l)/12*.8,lineHeight:this._lineHeight*s}),(u=this._rect)==null||u.set({left:.084*l,top:.4874*c,width:.832*l,height:c-.4874*c-.084*l}),this._canvas.renderAll()}handleMessageChange(n,t){var e;this._textbox&&(this._textbox.set("text",t),this.formatTextbox(this._textbox),(e=this._canvas)==null||e.renderAll())}handleAlignmentChange(n,t){var e,i;this._textbox&&((e=this._textbox)==null||e.set("textAlign",t),(i=this._canvas)==null||i.renderAll())}handleFontFamilyChange(n,t){var e,i;this._textbox&&((e=this._textbox)==null||e.set("fontFamily",t),(i=this._canvas)==null||i.renderAll())}handleColorChange(n,t){var e,i;this._textbox&&((e=this._textbox)==null||e.set("fill",t),(i=this._canvas)==null||i.renderAll())}render(){var n,t,e,i;return X` <div
666
+ `),this._textbox.setSelectionStart(this._textbox.text.length),this._textbox.setSelectionEnd(this._textbox.text.length),(l=this._canvas)==null||l.renderAll()}),this._rect=new Nt({left:.084*this._canvas.width,top:.4874*this._canvas.height,width:.832*this._canvas.width,height:this._canvas.width-.4874*this._canvas.width-.084*this._canvas.width,fill:"red",selectable:!1}),this._canvas.add(this._textbox),this._canvas.centerObject(this._textbox),this._canvas.add(this._rect),this._canvas.renderAll()},window.addEventListener("resize",()=>{var e;n.width=this._fabricContainer.clientWidth,n.height=this._fabricContainer.clientHeight,this.adjustCanvasElements(),(e=this._canvas)==null||e.renderAll()}),setTimeout(()=>this.adjustCanvasElements(),100)}adjustCanvasElements(){var h,u;if(!this._canvas||!this._textbox||!this._backgroundImg||!this._backgroundImg.complete)return;const n=(h=this.shadowRoot)==null?void 0:h.querySelector(".fabric-container");if(!n)return;const t=n.clientWidth,e=n.clientHeight,i=this._backgroundImg.naturalWidth,s=this._backgroundImg.naturalHeight;let r;const o=t/e,a=i/s;e===0||t===0?r=t/i:o>a?r=e/s:r=t/i;const l=i*r,c=s*r;this._canvas.setDimensions({width:l,height:c}),this._canvas.backgroundImage&&(this._canvas.backgroundImage.scaleToWidth(l),this._canvas.backgroundImage.scaleToHeight(c)),this._textbox.set({left:.084*l,top:.4874*c,width:.832*l,height:c-.4874*c-.084*l,fontSize:(c-.4874*c-.084*l)/12*.8,lineHeight:this._lineHeight*r}),(u=this._rect)==null||u.set({left:.084*l,top:.4874*c,width:.832*l,height:c-.4874*c-.084*l}),this._canvas.renderAll()}handleMessageChange(n,t){var e;this._textbox&&(this._textbox.set("text",t),this.formatTextbox(this._textbox),(e=this._canvas)==null||e.renderAll())}handleAlignmentChange(n,t){var e,i;this._textbox&&((e=this._textbox)==null||e.set("textAlign",t),(i=this._canvas)==null||i.renderAll())}handleFontFamilyChange(n,t){var e,i;this._textbox&&((e=this._textbox)==null||e.set("fontFamily",t),(i=this._canvas)==null||i.renderAll())}handleColorChange(n,t){var e,i;this._textbox&&((e=this._textbox)==null||e.set("fill",t),(i=this._canvas)==null||i.renderAll())}render(){var n,t,e,i;return W` <div
615
667
  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);"
616
668
  >
617
669
  background image url: ${this.backgroundUrl} <br />
@@ -623,7 +675,7 @@ good aklsdfja`,this.alignment="left",this.fontFamily="Arial",this.color="#000",t
623
675
  real textbox height: ${this._backgroundImg.height*.45} <br />
624
676
  Textbox width: ${(e=this._textbox)==null?void 0:e.width} <br />
625
677
  Textbox height: ${(i=this._textbox)==null?void 0:i.height} <br />
626
- </div>`}};ut.styles=[Pt,rf];At([O()],ut.prototype,"backgroundUrl",2);At([O()],ut.prototype,"message",2);At([O({type:String,reflect:!0})],ut.prototype,"alignment",2);At([O({type:String})],ut.prototype,"fontFamily",2);At([O({type:String})],ut.prototype,"color",2);At([q(".fabric-container")],ut.prototype,"_fabricContainer",2);At([$()],ut.prototype,"_canvas",2);At([$()],ut.prototype,"_canvasElement",2);At([$()],ut.prototype,"_textbox",2);At([$()],ut.prototype,"_backgroundImg",2);At([$()],ut.prototype,"_natureSize",2);At([$()],ut.prototype,"_scale",2);At([$()],ut.prototype,"_lineHeight",2);At([$()],ut.prototype,"_fontSize",2);At([$()],ut.prototype,"_rect",2);At([et("message")],ut.prototype,"handleMessageChange",1);At([et("alignment")],ut.prototype,"handleAlignmentChange",1);At([et("fontFamily")],ut.prototype,"handleFontFamilyChange",1);At([et("color")],ut.prototype,"handleColorChange",1);ut=At([Ot("fabric-example")],ut);const of=vt`
678
+ </div>`}};dt.styles=[wt,fg];Mt([T()],dt.prototype,"backgroundUrl",2);Mt([T()],dt.prototype,"message",2);Mt([T({type:String,reflect:!0})],dt.prototype,"alignment",2);Mt([T({type:String})],dt.prototype,"fontFamily",2);Mt([T({type:String})],dt.prototype,"color",2);Mt([q(".fabric-container")],dt.prototype,"_fabricContainer",2);Mt([V()],dt.prototype,"_canvas",2);Mt([V()],dt.prototype,"_canvasElement",2);Mt([V()],dt.prototype,"_textbox",2);Mt([V()],dt.prototype,"_backgroundImg",2);Mt([V()],dt.prototype,"_natureSize",2);Mt([V()],dt.prototype,"_scale",2);Mt([V()],dt.prototype,"_lineHeight",2);Mt([V()],dt.prototype,"_fontSize",2);Mt([V()],dt.prototype,"_rect",2);Mt([Q("message")],dt.prototype,"handleMessageChange",1);Mt([Q("alignment")],dt.prototype,"handleAlignmentChange",1);Mt([Q("fontFamily")],dt.prototype,"handleFontFamilyChange",1);Mt([Q("color")],dt.prototype,"handleColorChange",1);dt=Mt([bt("fabric-example")],dt);const vg=at`
627
679
  :host {
628
680
  display: block;
629
681
  }
@@ -633,7 +685,15 @@ good aklsdfja`,this.alignment="left",this.fontFamily="Arial",this.color="#000",t
633
685
  .choices__item {
634
686
  font-size: 1rem;
635
687
  }
636
- `;/*! choices.js v11.0.3 | © 2024 Josh Johnson | https://github.com/jshjohnson/Choices#readme */var Lo=function(n,t){return Lo=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,i){e.__proto__=i}||function(e,i){for(var r in i)Object.prototype.hasOwnProperty.call(i,r)&&(e[r]=i[r])},Lo(n,t)};function oh(n,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");Lo(n,t);function e(){this.constructor=n}n.prototype=t===null?Object.create(t):(e.prototype=t.prototype,new e)}var ie=function(){return ie=Object.assign||function(t){for(var e,i=1,r=arguments.length;i<r;i++){e=arguments[i];for(var s in e)Object.prototype.hasOwnProperty.call(e,s)&&(t[s]=e[s])}return t},ie.apply(this,arguments)};function af(n,t,e){for(var i=0,r=t.length,s;i<r;i++)(s||!(i in t))&&(s||(s=Array.prototype.slice.call(t,0,i)),s[i]=t[i]);return n.concat(s||Array.prototype.slice.call(t))}var wt={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"},ee={showDropdown:"showDropdown",hideDropdown:"hideDropdown",change:"change",choice:"choice",search:"search",addItem:"addItem",removeItem:"removeItem",highlightItem:"highlightItem",highlightChoice:"highlightChoice",unhighlightItem:"unhighlightItem"},Wt={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},lf=["fuseOptions","classNames"],vi={Text:"text",SelectOne:"select-one",SelectMultiple:"select-multiple"},cf=function(n){return{type:wt.ADD_CHOICE,choice:n}},yl=function(n){return{type:wt.REMOVE_CHOICE,choice:n}},hf=function(n){return{type:wt.FILTER_CHOICES,results:n}},uf=function(n){return{type:wt.ACTIVATE_CHOICES,active:n}},df=function(n){return{type:wt.ADD_GROUP,group:n}},pf=function(n){return{type:wt.ADD_ITEM,item:n}},xl=function(n){return{type:wt.REMOVE_ITEM,item:n}},qs=function(n,t){return{type:wt.HIGHLIGHT_ITEM,item:n,highlighted:t}},ff=function(n,t){return Math.floor(Math.random()*(t-n)+n)},wl=function(n){return Array.from({length:n},function(){return ff(0,36).toString(36)}).join("")},gf=function(n,t){var e=n.id||n.name&&"".concat(n.name,"-").concat(wl(2))||wl(4);return e=e.replace(/(:|\.|\[|\]|,)/g,""),e="".concat(t,"-").concat(e),e},mf=function(n,t,e){e===void 0&&(e=1);for(var i="".concat(e>0?"next":"previous","ElementSibling"),r=n[i];r;){if(r.matches(t))return r;r=r[i]}return null},vf=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},Nn=function(n){if(typeof n!="string"){if(n==null)return"";if(typeof n=="object"){if("raw"in n)return Nn(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;")},bf=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}}(),Wr=function(n,t){return typeof n=="function"?n(Nn(t),t):n},Cl=function(n){return typeof n=="function"?n():n},Hi=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""},_f=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""},_a=function(n,t){return n?_f(t):Nn(t)},Ue=function(n,t,e){n.innerHTML=_a(t,e)},yf=function(n,t){var e=n.value,i=n.label,r=i===void 0?e:i,s=t.value,o=t.label,a=o===void 0?s:o;return Hi(r).localeCompare(Hi(a),[],{sensitivity:"base",ignorePunctuation:!0,numeric:!0})},xf=function(n,t){return n.rank-t.rank},wf=function(n,t,e){e===void 0&&(e=null);var i=new CustomEvent(t,{detail:e,bubbles:!0,cancelable:!0});return n.dispatchEvent(i)},Cf=function(n,t){var e=Object.keys(n).sort(),i=Object.keys(t).sort();return e.filter(function(r){return i.indexOf(r)<0})},zn=function(n){return Array.isArray(n)?n:[n]},Pr=function(n){return n&&Array.isArray(n)?n.map(function(t){return".".concat(t)}).join(""):".".concat(n)},G=function(n,t){var e;(e=n.classList).add.apply(e,zn(t))},Fe=function(n,t){var e;(e=n.classList).remove.apply(e,zn(t))},Sf=function(n){if(typeof n<"u")try{return JSON.parse(n)}catch{return n}return{}},Tf=function(n,t,e){var i=n.itemEl;i&&(Fe(i,e),G(i,t))},Ef=function(){function n(t){var e=t.element,i=t.type,r=t.classNames;this.element=e,this.classNames=r,this.type=i,this.isActive=!1}return n.prototype.show=function(){return G(this.element,this.classNames.activeState),this.element.setAttribute("aria-expanded","true"),this.isActive=!0,this},n.prototype.hide=function(){return Fe(this.element,this.classNames.activeState),this.element.setAttribute("aria-expanded","false"),this.isActive=!1,this},n}(),Sl=function(){function n(t){var e=t.element,i=t.type,r=t.classNames,s=t.position;this.element=e,this.classNames=r,this.type=i,this.position=s,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){G(this.element,this.classNames.openState),this.element.setAttribute("aria-expanded","true"),this.isOpen=!0,this.shouldFlip(t,e)&&(G(this.element,this.classNames.flippedState),this.isFlipped=!0)},n.prototype.close=function(){Fe(this.element,this.classNames.openState),this.element.setAttribute("aria-expanded","false"),this.removeActiveDescendant(),this.isOpen=!1,this.isFlipped&&(Fe(this.element,this.classNames.flippedState),this.isFlipped=!1)},n.prototype.addFocusState=function(){G(this.element,this.classNames.focusState)},n.prototype.removeFocusState=function(){Fe(this.element,this.classNames.focusState)},n.prototype.enable=function(){Fe(this.element,this.classNames.disabledState),this.element.removeAttribute("aria-disabled"),this.type===vi.SelectOne&&this.element.setAttribute("tabindex","0"),this.isDisabled=!1},n.prototype.disable=function(){G(this.element,this.classNames.disabledState),this.element.setAttribute("aria-disabled","true"),this.type===vi.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(){G(this.element,this.classNames.loadingState),this.element.setAttribute("aria-busy","true"),this.isLoading=!0},n.prototype.removeLoadingState=function(){Fe(this.element,this.classNames.loadingState),this.element.removeAttribute("aria-busy"),this.isLoading=!1},n}(),Of=function(){function n(t){var e=t.element,i=t.type,r=t.classNames,s=t.preventPaste;this.element=e,this.type=i,this.classNames=r,this.preventPaste=s,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!==vi.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}(),kf=4,Tl=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 r=this.element.offsetHeight,s=this.element.scrollTop+r,o=t.offsetHeight,a=t.offsetTop+o,l=e>0?this.element.scrollTop+a-s:t.offsetTop;requestAnimationFrame(function(){i._animateScroll(l,e)})}},n.prototype._scrollDown=function(t,e,i){var r=(i-t)/e,s=r>1?r:1;this.element.scrollTop=t+s},n.prototype._scrollUp=function(t,e,i){var r=(t-i)/e,s=r>1?r:1;this.element.scrollTop=t-s},n.prototype._animateScroll=function(t,e){var i=this,r=kf,s=this.element.scrollTop,o=!1;e>0?(this._scrollDown(s,r,t),s<t&&(o=!0)):(this._scrollUp(s,r,t),s>t&&(o=!0)),o&&requestAnimationFrame(function(){i._animateScroll(t,e)})},n}(),ah=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;G(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;Fe(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){wf(this.element,t,e||{})},n}(),Df=function(n){oh(t,n);function t(){return n!==null&&n.apply(this,arguments)||this}return t}(ah),Nr=function(n,t){return t===void 0&&(t=!0),typeof n>"u"?t:!!n},lh=function(n){if(typeof n=="string"&&(n=n.split(" ").filter(function(t){return t.length})),Array.isArray(n)&&n.length)return n},Ie=function(n,t,e){if(e===void 0&&(e=!0),typeof n=="string"){var i=Nn(n),r=e||i===n?n:{escaped:i,raw:n},s=Ie({value:n,label:r,selected:!0},!1);return s}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 Ie(d,!1)}),c={id:0,label:Hi(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:Nr(h.active),selected:Nr(h.selected,!1),disabled:Nr(h.disabled,!1),placeholder:Nr(h.placeholder,!1),highlighted:!1,labelClass:lh(h.labelClass),labelDescription:h.labelDescription,customProperties:h.customProperties};return u},Pf=function(n){return n.tagName==="INPUT"},ch=function(n){return n.tagName==="SELECT"},Af=function(n){return n.tagName==="OPTION"},Mf=function(n){return n.tagName==="OPTGROUP"},If=function(n){oh(t,n);function t(e){var i=e.element,r=e.classNames,s=e.template,o=e.extractPlaceholder,a=n.call(this,{element:i,classNames:r})||this;return a.template=s,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,r=document.createDocumentFragment();e.forEach(function(s){var o=s;if(!o.element){var a=i.template(o);r.appendChild(a),o.element=a}}),this.element.appendChild(r)},t.prototype.optionsAsChoices=function(){var e=this,i=[];return this.element.querySelectorAll(":scope > option, :scope > optgroup").forEach(function(r){Af(r)?i.push(e._optionToChoice(r)):Mf(r)&&i.push(e._optgroupToChoice(r))}),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"?lh(e.dataset.labelClass):void 0,labelDescription:typeof e.dataset.labelDescription<"u"?e.dataset.labelDescription:void 0,customProperties:Sf(e.dataset.customProperties)}},t.prototype._optgroupToChoice=function(e){var i=this,r=e.querySelectorAll("option"),s=Array.from(r).map(function(o){return i._optionToChoice(o)});return{id:0,label:e.label||"",element:e,active:!!s.length,disabled:e.disabled,choices:s}},t}(ah),Lf={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"]},El={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:yf,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:Lf,appendGroupInSearch:!1},Ol=function(n){var t=n.itemEl;t&&(t.remove(),n.itemEl=void 0)};function Ff(n,t,e){var i=n,r=!0;switch(t.type){case wt.ADD_ITEM:{t.item.selected=!0;var s=t.item.element;s&&(s.selected=!0,s.setAttribute("selected","")),i.push(t.item);break}case wt.REMOVE_ITEM:{t.item.selected=!1;var s=t.item.element;if(s){s.selected=!1,s.removeAttribute("selected");var o=s.parentElement;o&&ch(o)&&o.type===vi.SelectOne&&(o.value="")}Ol(t.item),i=i.filter(function(h){return h.id!==t.item.id});break}case wt.REMOVE_CHOICE:{Ol(t.choice),i=i.filter(function(c){return c.id!==t.choice.id});break}case wt.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&&Tf(l,a?e.classNames.highlightedState:e.classNames.selectedState,a?e.classNames.selectedState:e.classNames.highlightedState));break}default:{r=!1;break}}return{state:i,update:r}}function jf(n,t){var e=n,i=!0;switch(t.type){case wt.ADD_GROUP:{e.push(t.group);break}case wt.CLEAR_CHOICES:{e=[];break}default:{i=!1;break}}return{state:e,update:i}}function Rf(n,t,e){var i=n,r=!0;switch(t.type){case wt.ADD_CHOICE:{i.push(t.choice);break}case wt.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 wt.ADD_ITEM:case wt.REMOVE_ITEM:{t.item.choiceEl=void 0;break}case wt.FILTER_CHOICES:{var s=[];t.results.forEach(function(o){s[o.item.id]=o}),i.forEach(function(o){var a=s[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 wt.ACTIVATE_CHOICES:{i.forEach(function(o){o.active=t.active,e&&e.appendGroupInSearch&&(o.choiceEl=void 0)});break}case wt.CLEAR_CHOICES:{i=[];break}default:{r=!1;break}}return{state:i,update:r}}var kl={groups:jf,items:Ff,choices:Rf},Bf=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,r=!1,s=this._changeSet||this.changeSet(!1);Object.keys(kl).forEach(function(o){var a=kl[o](i[o],t,e._context);a.update&&(r=!0,s[o]=!0,i[o]=a.state)}),r&&(this._txn?this._changeSet=s:this._listeners.forEach(function(o){return o(s)}))},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,r=t.state.choices.some(function(s){return s.active&&!s.disabled});return i&&r},[])},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}(),Gt={noChoices:"no-choices",noResults:"no-results",addChoice:"add-choice",generic:""};function Nf(n,t,e){return(t=Vf(t))in n?Object.defineProperty(n,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):n[t]=e,n}function Dl(n,t){var e=Object.keys(n);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(n);t&&(i=i.filter(function(r){return Object.getOwnPropertyDescriptor(n,r).enumerable})),e.push.apply(e,i)}return e}function or(n){for(var t=1;t<arguments.length;t++){var e=arguments[t]!=null?arguments[t]:{};t%2?Dl(Object(e),!0).forEach(function(i){Nf(n,i,e[i])}):Object.getOwnPropertyDescriptors?Object.defineProperties(n,Object.getOwnPropertyDescriptors(e)):Dl(Object(e)).forEach(function(i){Object.defineProperty(n,i,Object.getOwnPropertyDescriptor(e,i))})}return n}function zf(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 Vf(n){var t=zf(n,"string");return typeof t=="symbol"?t:t+""}function li(n){return Array.isArray?Array.isArray(n):dh(n)==="[object Array]"}function Hf(n){if(typeof n=="string")return n;let t=n+"";return t=="0"&&1/n==-1/0?"-0":t}function $f(n){return n==null?"":Hf(n)}function Re(n){return typeof n=="string"}function hh(n){return typeof n=="number"}function Wf(n){return n===!0||n===!1||Gf(n)&&dh(n)=="[object Boolean]"}function uh(n){return typeof n=="object"}function Gf(n){return uh(n)&&n!==null}function de(n){return n!=null}function uo(n){return!n.trim().length}function dh(n){return n==null?n===void 0?"[object Undefined]":"[object Null]":Object.prototype.toString.call(n)}const Uf="Incorrect 'index' type",Yf=n=>`Invalid value for key ${n}`,Xf=n=>`Pattern length exceeds max of ${n}.`,Kf=n=>`Missing ${n} property in key`,qf=n=>`Property 'weight' in key '${n}' must be a positive integer`,Pl=Object.prototype.hasOwnProperty;class Zf{constructor(t){this._keys=[],this._keyMap={};let e=0;t.forEach(i=>{let r=ph(i);this._keys.push(r),this._keyMap[r.id]=r,e+=r.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 ph(n){let t=null,e=null,i=null,r=1,s=null;if(Re(n)||li(n))i=n,t=Al(n),e=Fo(n);else{if(!Pl.call(n,"name"))throw new Error(Kf("name"));const o=n.name;if(i=o,Pl.call(n,"weight")&&(r=n.weight,r<=0))throw new Error(qf(o));t=Al(o),e=Fo(o),s=n.getFn}return{path:t,id:e,weight:r,src:i,getFn:s}}function Al(n){return li(n)?n:n.split(".")}function Fo(n){return li(n)?n.join("."):n}function Jf(n,t){let e=[],i=!1;const r=(s,o,a)=>{if(de(s))if(!o[a])e.push(s);else{let l=o[a];const c=s[l];if(!de(c))return;if(a===o.length-1&&(Re(c)||hh(c)||Wf(c)))e.push($f(c));else if(li(c)){i=!0;for(let h=0,u=c.length;h<u;h+=1)r(c[h],o,a+1)}else o.length&&r(c,o,a+1)}};return r(n,Re(t)?t.split("."):t,0),i?e:e[0]}const Qf={includeMatches:!1,findAllMatches:!1,minMatchCharLength:1},tg={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},eg={location:0,threshold:.6,distance:100},ig={useExtendedSearch:!1,getFn:Jf,ignoreLocation:!1,ignoreFieldNorm:!1,fieldNormWeight:1};var W=or(or(or(or({},tg),Qf),eg),ig);const rg=/[^ ]+/g;function sg(n=1,t=3){const e=new Map,i=Math.pow(10,t);return{get(r){const s=r.match(rg).length;if(e.has(s))return e.get(s);const o=1/Math.pow(s,.5*n),a=parseFloat(Math.round(o*i)/i);return e.set(s,a),a},clear(){e.clear()}}}class ya{constructor({getFn:t=W.getFn,fieldNormWeight:e=W.fieldNormWeight}={}){this.norm=sg(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,Re(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();Re(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(!de(t)||uo(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((r,s)=>{let o=r.getFn?r.getFn(t):this.getFn(t,r.path);if(de(o)){if(li(o)){let a=[];const l=[{nestedArrIndex:-1,value:o}];for(;l.length;){const{nestedArrIndex:c,value:h}=l.pop();if(de(h))if(Re(h)&&!uo(h)){let u={v:h,i:c,n:this.norm.get(h)};a.push(u)}else li(h)&&h.forEach((u,d)=>{l.push({nestedArrIndex:d,value:u})})}i.$[s]=a}else if(Re(o)&&!uo(o)){let a={v:o,n:this.norm.get(o)};i.$[s]=a}}}),this.records.push(i)}toJSON(){return{keys:this.keys,records:this.records}}}function fh(n,t,{getFn:e=W.getFn,fieldNormWeight:i=W.fieldNormWeight}={}){const r=new ya({getFn:e,fieldNormWeight:i});return r.setKeys(n.map(ph)),r.setSources(t),r.create(),r}function ng(n,{getFn:t=W.getFn,fieldNormWeight:e=W.fieldNormWeight}={}){const{keys:i,records:r}=n,s=new ya({getFn:t,fieldNormWeight:e});return s.setKeys(i),s.setIndexRecords(r),s}function Zs(n,{errors:t=0,currentLocation:e=0,expectedLocation:i=0,distance:r=W.distance,ignoreLocation:s=W.ignoreLocation}={}){const o=t/n.length;if(s)return o;const a=Math.abs(i-e);return r?o+a/r:a?1:o}function og(n=[],t=W.minMatchCharLength){let e=[],i=-1,r=-1,s=0;for(let o=n.length;s<o;s+=1){let a=n[s];a&&i===-1?i=s:!a&&i!==-1&&(r=s-1,r-i+1>=t&&e.push([i,r]),i=-1)}return n[s-1]&&s-i>=t&&e.push([i,s-1]),e}const Ni=32;function ag(n,t,e,{location:i=W.location,distance:r=W.distance,threshold:s=W.threshold,findAllMatches:o=W.findAllMatches,minMatchCharLength:a=W.minMatchCharLength,includeMatches:l=W.includeMatches,ignoreLocation:c=W.ignoreLocation}={}){if(t.length>Ni)throw new Error(Xf(Ni));const h=t.length,u=n.length,d=Math.max(0,Math.min(i,u));let p=s,f=d;const g=a>1||l,m=g?Array(u):[];let v;for(;(v=n.indexOf(t,f))>-1;){let C=Zs(t,{currentLocation:v,expectedLocation:d,distance:r,ignoreLocation:c});if(p=Math.min(C,p),f=v+h,g){let S=0;for(;S<h;)m[v+S]=1,S+=1}}f=-1;let y=[],x=1,T=h+u;const E=1<<h-1;for(let C=0;C<h;C+=1){let S=0,F=T;for(;S<F;)Zs(t,{errors:C,currentLocation:d+F,expectedLocation:d,distance:r,ignoreLocation:c})<=p?S=F:T=F,F=Math.floor((T-S)/2+S);T=F;let j=Math.max(1,d-F+1),D=o?u:Math.min(d+F,u)+h,k=Array(D+2);k[D+1]=(1<<C)-1;for(let L=D;L>=j;L-=1){let V=L-1,Y=e[n.charAt(V)];if(g&&(m[V]=+!!Y),k[L]=(k[L+1]<<1|1)&Y,C&&(k[L]|=(y[L+1]|y[L])<<1|1|y[L+1]),k[L]&E&&(x=Zs(t,{errors:C,currentLocation:V,expectedLocation:d,distance:r,ignoreLocation:c}),x<=p)){if(p=x,f=V,f<=d)break;j=Math.max(1,2*d-f)}}if(Zs(t,{errors:C+1,currentLocation:d,expectedLocation:d,distance:r,ignoreLocation:c})>p)break;y=k}const A={isMatch:f>=0,score:Math.max(.001,x)};if(g){const C=og(m,a);C.length?l&&(A.indices=C):A.isMatch=!1}return A}function lg(n){let t={};for(let e=0,i=n.length;e<i;e+=1){const r=n.charAt(e);t[r]=(t[r]||0)|1<<i-e-1}return t}class gh{constructor(t,{location:e=W.location,threshold:i=W.threshold,distance:r=W.distance,includeMatches:s=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:r,includeMatches:s,findAllMatches:o,minMatchCharLength:a,isCaseSensitive:l,ignoreLocation:c},this.pattern=l?t:t.toLowerCase(),this.chunks=[],!this.pattern.length)return;const h=(d,p)=>{this.chunks.push({pattern:d,alphabet:lg(d),startIndex:p})},u=this.pattern.length;if(u>Ni){let d=0;const p=u%Ni,f=u-p;for(;d<f;)h(this.pattern.substr(d,Ni),d),d+=Ni;if(p){const g=u-Ni;h(this.pattern.substr(g),g)}}else h(this.pattern,0)}searchIn(t){const{isCaseSensitive:e,includeMatches:i}=this.options;if(e||(t=t.toLowerCase()),this.pattern===t){let f={isMatch:!0,score:0};return i&&(f.indices=[[0,t.length-1]]),f}const{location:r,distance:s,threshold:o,findAllMatches:a,minMatchCharLength:l,ignoreLocation:c}=this.options;let h=[],u=0,d=!1;this.chunks.forEach(({pattern:f,alphabet:g,startIndex:m})=>{const{isMatch:v,score:y,indices:x}=ag(t,f,g,{location:r+m,distance:s,threshold:o,findAllMatches:a,minMatchCharLength:l,includeMatches:i,ignoreLocation:c});v&&(d=!0),u+=y,v&&x&&(h=[...h,...x])});let p={isMatch:d,score:d?u/this.chunks.length:1};return d&&i&&(p.indices=h),p}}class Pi{constructor(t){this.pattern=t}static isMultiMatch(t){return Ml(t,this.multiRegex)}static isSingleMatch(t){return Ml(t,this.singleRegex)}search(){}}function Ml(n,t){const e=n.match(t);return e?e[1]:null}class cg extends Pi{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 hg extends Pi{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 ug extends Pi{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 dg extends Pi{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 pg extends Pi{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 fg extends Pi{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 mh extends Pi{constructor(t,{location:e=W.location,threshold:i=W.threshold,distance:r=W.distance,includeMatches:s=W.includeMatches,findAllMatches:o=W.findAllMatches,minMatchCharLength:a=W.minMatchCharLength,isCaseSensitive:l=W.isCaseSensitive,ignoreLocation:c=W.ignoreLocation}={}){super(t),this._bitapSearch=new gh(t,{location:e,threshold:i,distance:r,includeMatches:s,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 vh extends Pi{constructor(t){super(t)}static get type(){return"include"}static get multiRegex(){return/^'"(.*)"$/}static get singleRegex(){return/^'(.*)$/}search(t){let e=0,i;const r=[],s=this.pattern.length;for(;(i=t.indexOf(this.pattern,e))>-1;)e=i+s,r.push([i,e-1]);const o=!!r.length;return{isMatch:o,score:o?0:1,indices:r}}}const jo=[cg,vh,ug,dg,fg,pg,hg,mh],Il=jo.length,gg=/ +(?=(?:[^\"]*\"[^\"]*\")*[^\"]*$)/,mg="|";function vg(n,t={}){return n.split(mg).map(e=>{let i=e.trim().split(gg).filter(s=>s&&!!s.trim()),r=[];for(let s=0,o=i.length;s<o;s+=1){const a=i[s];let l=!1,c=-1;for(;!l&&++c<Il;){const h=jo[c];let u=h.isMultiMatch(a);u&&(r.push(new h(u,t)),l=!0)}if(!l)for(c=-1;++c<Il;){const h=jo[c];let u=h.isSingleMatch(a);if(u){r.push(new h(u,t));break}}}return r})}const bg=new Set([mh.type,vh.type]);class _g{constructor(t,{isCaseSensitive:e=W.isCaseSensitive,includeMatches:i=W.includeMatches,minMatchCharLength:r=W.minMatchCharLength,ignoreLocation:s=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:r,findAllMatches:o,ignoreLocation:s,location:a,threshold:l,distance:c},this.pattern=e?t:t.toLowerCase(),this.query=vg(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:r}=this.options;t=r?t:t.toLowerCase();let s=0,o=[],a=0;for(let l=0,c=e.length;l<c;l+=1){const h=e[l];o.length=0,s=0;for(let u=0,d=h.length;u<d;u+=1){const p=h[u],{isMatch:f,indices:g,score:m}=p.search(t);if(f){if(s+=1,a+=m,i){const v=p.constructor.type;bg.has(v)?o=[...o,...g]:o.push(g)}}else{a=0,s=0,o.length=0;break}}if(s){let u={isMatch:!0,score:a/s};return i&&(u.indices=o),u}}return{isMatch:!1,score:1}}}const Ro=[];function yg(...n){Ro.push(...n)}function Bo(n,t){for(let e=0,i=Ro.length;e<i;e+=1){let r=Ro[e];if(r.condition(n,t))return new r(n,t)}return new gh(n,t)}const Cn={AND:"$and",OR:"$or"},No={PATH:"$path",PATTERN:"$val"},zo=n=>!!(n[Cn.AND]||n[Cn.OR]),xg=n=>!!n[No.PATH],wg=n=>!li(n)&&uh(n)&&!zo(n),Ll=n=>({[Cn.AND]:Object.keys(n).map(t=>({[t]:n[t]}))});function bh(n,t,{auto:e=!0}={}){const i=r=>{let s=Object.keys(r);const o=xg(r);if(!o&&s.length>1&&!zo(r))return i(Ll(r));if(wg(r)){const l=o?r[No.PATH]:s[0],c=o?r[No.PATTERN]:r[l];if(!Re(c))throw new Error(Yf(l));const h={keyId:Fo(l),pattern:c};return e&&(h.searcher=Bo(c,t)),h}let a={children:[],operator:s[0]};return s.forEach(l=>{const c=r[l];li(c)&&c.forEach(h=>{a.children.push(i(h))})}),a};return zo(n)||(n=Ll(n)),i(n)}function Cg(n,{ignoreFieldNorm:t=W.ignoreFieldNorm}){n.forEach(e=>{let i=1;e.matches.forEach(({key:r,norm:s,score:o})=>{const a=r?r.weight:null;i*=Math.pow(o===0&&a?Number.EPSILON:o,(a||1)*(t?1:s))}),e.score=i})}function Sg(n,t){const e=n.matches;t.matches=[],de(e)&&e.forEach(i=>{if(!de(i.indices)||!i.indices.length)return;const{indices:r,value:s}=i;let o={indices:r,value:s};i.key&&(o.key=i.key.src),i.idx>-1&&(o.refIndex=i.idx),t.matches.push(o)})}function Tg(n,t){t.score=n.score}function Eg(n,t,{includeMatches:e=W.includeMatches,includeScore:i=W.includeScore}={}){const r=[];return e&&r.push(Sg),i&&r.push(Tg),n.map(s=>{const{idx:o}=s,a={item:t[o],refIndex:o};return r.length&&r.forEach(l=>{l(s,a)}),a})}class Cr{constructor(t,e={},i){this.options=or(or({},W),e),this.options.useExtendedSearch,this._keyStore=new Zf(this.options.keys),this.setCollection(t,i)}setCollection(t,e){if(this._docs=t,e&&!(e instanceof ya))throw new Error(Uf);this._myIndex=e||fh(this.options.keys,this._docs,{getFn:this.options.getFn,fieldNormWeight:this.options.fieldNormWeight})}add(t){de(t)&&(this._docs.push(t),this._myIndex.add(t))}remove(t=()=>!1){const e=[];for(let i=0,r=this._docs.length;i<r;i+=1){const s=this._docs[i];t(s,i)&&(this.removeAt(i),i-=1,r-=1,e.push(s))}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:r,shouldSort:s,sortFn:o,ignoreFieldNorm:a}=this.options;let l=Re(t)?Re(this._docs[0])?this._searchStringList(t):this._searchObjectList(t):this._searchLogical(t);return Cg(l,{ignoreFieldNorm:a}),s&&l.sort(o),hh(e)&&e>-1&&(l=l.slice(0,e)),Eg(l,this._docs,{includeMatches:i,includeScore:r})}_searchStringList(t){const e=Bo(t,this.options),{records:i}=this._myIndex,r=[];return i.forEach(({v:s,i:o,n:a})=>{if(!de(s))return;const{isMatch:l,score:c,indices:h}=e.searchIn(s);l&&r.push({item:s,idx:o,matches:[{score:c,value:s,norm:a,indices:h}]})}),r}_searchLogical(t){const e=bh(t,this.options),i=(a,l,c)=>{if(!a.children){const{keyId:u,searcher:d}=a,p=this._findMatches({key:this._keyStore.get(u),value:this._myIndex.getValueForItemAtKeyId(l,u),searcher:d});return p&&p.length?[{idx:c,item:l,matches:p}]:[]}const h=[];for(let u=0,d=a.children.length;u<d;u+=1){const p=a.children[u],f=i(p,l,c);if(f.length)h.push(...f);else if(a.operator===Cn.AND)return[]}return h},r=this._myIndex.records,s={},o=[];return r.forEach(({$:a,i:l})=>{if(de(a)){let c=i(e,a,l);c.length&&(s[l]||(s[l]={idx:l,item:a,matches:[]},o.push(s[l])),c.forEach(({matches:h})=>{s[l].matches.push(...h)}))}}),o}_searchObjectList(t){const e=Bo(t,this.options),{keys:i,records:r}=this._myIndex,s=[];return r.forEach(({$:o,i:a})=>{if(!de(o))return;let l=[];i.forEach((c,h)=>{l.push(...this._findMatches({key:c,value:o[h],searcher:e}))}),l.length&&s.push({idx:a,item:o,matches:l})}),s}_findMatches({key:t,value:e,searcher:i}){if(!de(e))return[];let r=[];if(li(e))e.forEach(({v:s,i:o,n:a})=>{if(!de(s))return;const{isMatch:l,score:c,indices:h}=i.searchIn(s);l&&r.push({score:c,key:t,value:s,idx:o,norm:a,indices:h})});else{const{v:s,n:o}=e,{isMatch:a,score:l,indices:c}=i.searchIn(s);a&&r.push({score:l,key:t,value:s,norm:o,indices:c})}return r}}Cr.version="7.0.0";Cr.createIndex=fh;Cr.parseIndex=ng;Cr.config=W;Cr.parseQuery=bh;yg(_g);var Og=function(){function n(t){this._haystack=[],this._fuseOptions=ie(ie({},t.fuseOptions),{keys:af([],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 Cr(this._haystack,this._fuseOptions));var e=this._fuse.search(t);return e.map(function(i,r){return{item:i.item,score:i.score||0,rank:r+1}})},n}();function kg(n){return new Og(n)}var Dg=function(n){for(var t in n)if(Object.prototype.hasOwnProperty.call(n,t))return!1;return!0},po=function(n,t,e){var i=n.dataset,r=t.customProperties,s=t.labelClass,o=t.labelDescription;s&&(i.labelClass=zn(s).join(" ")),o&&(i.labelDescription=o),e&&r&&(typeof r=="string"?i.customProperties=r:typeof r=="object"&&!Dg(r)&&(i.customProperties=JSON.stringify(r)))},Fl=function(n,t,e){var i=t&&n.querySelector("label[for='".concat(t,"']")),r=i&&i.innerText;r&&e.setAttribute("aria-label",r)},Pg={containerOuter:function(n,t,e,i,r,s,o){var a=n.classNames.containerOuter,l=document.createElement("div");return G(l,a),l.dataset.type=s,t&&(l.dir=t),i&&(l.tabIndex=0),e&&(l.setAttribute("role",r?"combobox":"listbox"),r?l.setAttribute("aria-autocomplete","list"):o||Fl(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 G(e,t),e},itemList:function(n,t){var e=n.searchEnabled,i=n.classNames,r=i.list,s=i.listSingle,o=i.listItems,a=document.createElement("div");return G(a,r),G(a,t?s:o),this._isSelectElement&&e&&a.setAttribute("role","listbox"),a},placeholder:function(n,t){var e=n.allowHTML,i=n.classNames.placeholder,r=document.createElement("div");return G(r,i),Ue(r,e,t),r},item:function(n,t,e){var i=n.allowHTML,r=n.removeItemButtonAlignLeft,s=n.removeItemIconText,o=n.removeItemLabelText,a=n.classNames,l=a.item,c=a.button,h=a.highlightedState,u=a.itemSelectable,d=a.placeholder,p=Hi(t.value),f=document.createElement("div");if(G(f,l),t.labelClass){var g=document.createElement("span");Ue(g,i,t.label),G(g,t.labelClass),f.appendChild(g)}else Ue(f,i,t.label);if(f.dataset.item="",f.dataset.id=t.id,f.dataset.value=p,po(f,t,!0),(t.disabled||this.containerOuter.isDisabled)&&f.setAttribute("aria-disabled","true"),this._isSelectElement&&(f.setAttribute("aria-selected","true"),f.setAttribute("role","option")),t.placeholder&&(G(f,d),f.dataset.placeholder=""),G(f,t.highlighted?h:u),e){t.disabled&&Fe(f,u),f.dataset.deletable="";var m=document.createElement("button");m.type="button",G(m,c),Ue(m,!0,Wr(s,t.value));var v=Wr(o,t.value);v&&m.setAttribute("aria-label",v),m.dataset.button="",r?f.insertAdjacentElement("afterbegin",m):f.appendChild(m)}return f},choiceList:function(n,t){var e=n.classNames.list,i=document.createElement("div");return G(i,e),t||i.setAttribute("aria-multiselectable","true"),i.setAttribute("role","listbox"),i},choiceGroup:function(n,t){var e=n.allowHTML,i=n.classNames,r=i.group,s=i.groupHeading,o=i.itemDisabled,a=t.id,l=t.label,c=t.disabled,h=Hi(l),u=document.createElement("div");G(u,r),c&&G(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 G(d,s),Ue(d,e,l||""),u.appendChild(d),u},choice:function(n,t,e,i){var r=n.allowHTML,s=n.classNames,o=s.item,a=s.itemChoice,l=s.itemSelectable,c=s.selectedState,h=s.itemDisabled,u=s.description,d=s.placeholder,p=t.label,f=Hi(t.value),g=document.createElement("div");g.id=t.elementId,G(g,o),G(g,a),i&&typeof p=="string"&&(p=_a(r,p),p+=" (".concat(i,")"),p={trusted:p});var m=g;if(t.labelClass){var v=document.createElement("span");Ue(v,r,p),G(v,t.labelClass),m=v,g.appendChild(v)}else Ue(g,r,p);if(t.labelDescription){var y="".concat(t.elementId,"-description");m.setAttribute("aria-describedby",y);var x=document.createElement("span");Ue(x,r,t.labelDescription),x.id=y,G(x,u),g.appendChild(x)}return t.selected&&G(g,c),t.placeholder&&G(g,d),g.setAttribute("role",t.group?"treeitem":"option"),g.dataset.choice="",g.dataset.id=t.id,g.dataset.value=f,e&&(g.dataset.selectText=e),t.group&&(g.dataset.groupId="".concat(t.group.id)),po(g,t,!1),t.disabled?(G(g,h),g.dataset.choiceDisabled="",g.setAttribute("aria-disabled","true")):(G(g,l),g.dataset.choiceSelectable=""),g},input:function(n,t){var e=n.classNames,i=e.input,r=e.inputCloned,s=n.labelId,o=document.createElement("input");return o.type="search",G(o,i),G(o,r),o.autocomplete="off",o.autocapitalize="off",o.spellcheck=!1,o.setAttribute("role","textbox"),o.setAttribute("aria-autocomplete","list"),t?o.setAttribute("aria-label",t):s||Fl(this._docRoot,this.passedElement.element.id,o),o},dropdown:function(n){var t=n.classNames,e=t.list,i=t.listDropdown,r=document.createElement("div");return G(r,e),G(r,i),r.setAttribute("aria-expanded","false"),r},notice:function(n,t,e){var i=n.classNames,r=i.item,s=i.itemChoice,o=i.addChoice,a=i.noResults,l=i.noChoices,c=i.notice;e===void 0&&(e=Gt.generic);var h=document.createElement("div");switch(Ue(h,!0,t),G(h,r),G(h,s),G(h,c),e){case Gt.addChoice:G(h,o);break;case Gt.noResults:G(h,a);break;case Gt.noChoices:G(h,l);break}return e===Gt.addChoice&&(h.dataset.choiceSelectable="",h.dataset.choice=""),h},option:function(n){var t=Hi(n.label),e=new Option(t,n.value,!1,n.selected);return po(e,n,!0),e.disabled=n.disabled,n.selected&&e.setAttribute("selected",""),e}},Ag="-ms-scroll-limit"in document.documentElement.style&&"-ms-ime-align"in document.documentElement.style,Mg={},fo=function(n){if(n)return n.dataset.id?parseInt(n.dataset.id,10):void 0},Ar="[data-choice-selectable]",_h=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 r=n.defaults;this.config=ie(ie(ie({},r.allOptions),r.options),e),lf.forEach(function(v){i.config[v]=ie(ie(ie({},r.allOptions[v]),r.options[v]),e[v])});var s=this.config;s.silent||this._validateConfig();var o=s.shadowRoot||document.documentElement;this._docRoot=o;var a=typeof t=="string"?o.querySelector(t):t;if(!a||typeof a!="object"||!(Pf(a)||ch(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===vi.Text;(c||s.maxItemCount!==1)&&(s.singleModeForMultiSelect=!1),s.singleModeForMultiSelect&&(l=vi.SelectMultiple);var h=l===vi.SelectOne,u=l===vi.SelectMultiple,d=h||u;if(this._elementType=l,this._isTextElement=c,this._isSelectOneElement=h,this._isSelectMultipleElement=u,this._isSelectElement=h||u,this._canAddUserChoices=c&&s.addItems||d&&s.addChoices,typeof s.renderSelectedChoices!="boolean"&&(s.renderSelectedChoices=s.renderSelectedChoices==="always"||h),s.closeDropdownOnSelect==="auto"?s.closeDropdownOnSelect=c||h||s.singleModeForMultiSelect:s.closeDropdownOnSelect=Nr(s.closeDropdownOnSelect),s.placeholder&&(s.placeholderValue?this._hasNonChoicePlaceholder=!0:a.dataset.placeholder&&(this._hasNonChoicePlaceholder=!0,s.placeholderValue=a.dataset.placeholder)),e.addItemFilter&&typeof e.addItemFilter!="function"){var p=e.addItemFilter instanceof RegExp?e.addItemFilter:new RegExp(e.addItemFilter);s.addItemFilter=p.test.bind(p)}if(this._isTextElement)this.passedElement=new Df({element:a,classNames:s.classNames});else{var f=a;this.passedElement=new If({element:f,classNames:s.classNames,template:function(v){return i._templates.option(v)},extractPlaceholder:s.placeholder&&!this._hasNonChoicePlaceholder})}if(this.initialised=!1,this._store=new Bf(s),this._currentValue="",s.searchEnabled=!c&&s.searchEnabled||u,this._canSearch=s.searchEnabled,this._isScrollingOnIe=!1,this._highlightPosition=0,this._wasTap=!0,this._placeholderValue=this._generatePlaceholderValue(),this._baseId=gf(a,"choices-"),this._direction=a.dir,!this._direction){var g=window.getComputedStyle(a).direction,m=window.getComputedStyle(document.documentElement).direction;g!==m&&(this._direction=g)}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){s.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 Mg},get allOptions(){return El},get templates(){return Pg}})},enumerable:!1,configurable:!0}),n.prototype.init=function(){if(!(this.initialised||this.initialisedOK!==void 0)){this._searcher=kg(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(r){return r.id===t.id});return!i||i.highlighted?this:(this._store.dispatch(qs(i,!0)),e&&this.passedElement.triggerEvent(ee.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(r){return r.id===t.id});return!i||!i.highlighted?this:(this._store.dispatch(qs(i,!1)),e&&this.passedElement.triggerEvent(ee.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(qs(e,!0)),t.passedElement.triggerEvent(ee.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(qs(e,!1)),t.passedElement.triggerEvent(ee.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 r=i.id;return r!==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(ee.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(ee.hideDropdown)}),this):this},n.prototype.getValue=function(t){var e=this,i=this._store.items.map(function(r){return t?r.value:e._getChoiceForOutput(r)});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(Ie(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(r){return e._findAndSelectChoiceByValue(r)}),e.unhighlightAll()}),this._searcher.reset(),this):(this._warnChoicesInitFailed("setChoiceByValue"),this)},n.prototype.setChoices=function(t,e,i,r,s){var o=this;if(t===void 0&&(t=[]),e===void 0&&(e="value"),i===void 0&&(i="label"),r===void 0&&(r=!1),s===void 0&&(s=!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(r&&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,r)}).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(){s&&(o._isSearching=!1);var l=e==="value",c=i==="label";t.forEach(function(h){if("choices"in h){var u=h;c||(u=ie(ie({},u),{label:u[i]})),o._addGroup(Ie(u,!0))}else{var d=h;(!c||!l)&&(d=ie(ie({},d),{value:d[e],label:d[i]})),o._addChoice(Ie(d,!1))}}),o.unhighlightAll()}),this._searcher.reset(),this},n.prototype.refresh=function(t,e,i){var r=this;return t===void 0&&(t=!1),e===void 0&&(e=!1),i===void 0&&(i=!1),this._isSelectElement?(this._store.withTxn(function(){var s=r.passedElement.optionsAsChoices(),o={};i||r._store.items.forEach(function(l){l.id&&l.active&&l.selected&&!l.disabled&&(o[l.value]=!0)}),r.clearStore(!1);var a=function(l){i?r._store.dispatch(xl(l)):o[l.value]&&(l.selected=!0)};s.forEach(function(l){if("choices"in l){l.choices.forEach(a);return}a(l)}),r._addPredefinedChoices(s,e,t),r._isSearching&&r._searchChoices(r.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(yl(e)),this._searcher.reset(),e.selected&&this.passedElement.triggerEvent(ee.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(yl(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=Cf(t,El);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,r=e._isSearching,s=this._store,o=s.activeGroups,a=s.activeChoices,l=0;if(r&&i.searchResultLimit>0?l=i.searchResultLimit:i.renderChoiceLimit>0&&(l=i.renderChoiceLimit),this._isSelectElement){var c=a.filter(function(f){return!f.element});c.length&&this.passedElement.addOptions(c)}var h=document.createDocumentFragment(),u=function(f){return f.filter(function(g){return!g.placeholder&&(r?!!g.rank:i.renderSelectedChoices||!g.selected)})},d=!1,p=function(f,g,m){r?f.sort(xf):i.shouldSort&&f.sort(i.sorter);var v=f.length;v=!g&&l&&v>l?l:v,v--,f.every(function(y,x){var T=y.choiceEl||t._templates.choice(i,y,i.itemSelectText,m);return y.choiceEl=T,h.appendChild(T),!y.disabled&&(r||!y.selected)&&(d=!0),x<v})};a.length&&(i.resetScrollPosition&&requestAnimationFrame(function(){return t.choiceList.scrollToTop()}),!this._hasNonChoicePlaceholder&&!r&&this._isSelectOneElement&&p(a.filter(function(f){return f.placeholder&&!f.group}),!1,void 0),o.length&&!r?(i.shouldSort&&o.sort(i.sorter),p(a.filter(function(f){return!f.placeholder&&!f.group}),!1,void 0),o.forEach(function(f){var g=u(f.choices);if(g.length){if(f.label){var m=f.groupEl||t._templates.choiceGroup(t.config,f);f.groupEl=m,m.remove(),h.appendChild(m)}p(g,!0,i.appendGroupInSearch&&r?f.label:void 0)}})):p(u(a),!1,void 0)),d||(this._notice||(this._notice={text:Cl(r?i.noResultsText:i.noChoicesText),type:r?Gt.noResults:Gt.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,r=this.config,s=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(r,u,r.removeItemButton),u.itemEl=d,s.appendChild(d))};e.forEach(a);var l=!!s.childNodes.length;if(this._isSelectOneElement&&this._hasNonChoicePlaceholder){var c=i.children.length;if(l||c>1){var h=i.querySelector(Pr(r.classNames.placeholder));h&&h.remove()}else c||(l=!0,a(Ie({selected:!0,value:"",label:r.placeholderValue||"",placeholder:!0},!1)))}l&&(i.append(s),r.shouldSortItems&&!this._isSelectOneElement&&(e.sort(r.sorter),e.forEach(function(u){var d=o(u);d&&(d.remove(),s.append(d))}),i.append(s))),this._isTextElement&&(this.passedElement.value=e.map(function(u){var d=u.value;return d}).join(r.delimiter))},n.prototype._displayNotice=function(t,e,i){i===void 0&&(i=!0);var r=this._notice;if(r&&(r.type===e&&r.text===t||r.type===Gt.addChoice&&(e===Gt.noResults||e===Gt.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(Pr(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(ee.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 r=t&&fo(t.parentElement),s=r&&i.find(function(o){return o.id===r});s&&this._store.withTxn(function(){if(e._removeItem(s),e._triggerChange(s.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 r=this._store.items;if(!(!r.length||!this.config.removeItems||this._isSelectOneElement)){var s=fo(t);s&&(r.forEach(function(o){o.id===s&&!o.highlighted?i.highlightItem(o):!e&&o.highlighted&&i.unhighlightItem(o)}),this.input.focus())}},n.prototype._handleChoiceAction=function(t){var e=this,i=fo(t),r=i&&this._store.getChoiceById(i);if(!r||r.disabled)return!1;var s=this.dropdown.isActive;if(!r.selected){if(!this._canAddItems())return!0;this._store.withTxn(function(){e._addItem(r,!0,!0),e.clearInput(),e.unhighlightAll()}),this._triggerChange(r.value)}return s&&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],r=t.some(function(s){return s.highlighted});e.editItems&&!r&&i?(this.input.value=i.value,this.input.setWidth(),this._removeItem(i),this._triggerChange(i.value)):(r||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 Ie(o,!1)}),this.passedElement.value){var r=this.passedElement.value.split(i.delimiter).map(function(o){return Ie(o,!1,e.config.allowHtmlUserInput)});this._presetChoices=this._presetChoices.concat(r)}this._presetChoices.forEach(function(o){o.selected=!0})}else if(this._isSelectElement){this._presetChoices=i.choices.map(function(o){return Ie(o,!0)});var s=this.passedElement.optionsAsChoices();s&&(t=this._presetChoices).push.apply(t,s)}},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(ee.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,Gt.addChoice),!1):!0},n.prototype._canCreateItem=function(t){var e=this.config,i=!0,r="";if(i&&typeof e.addItemFilter=="function"&&!e.addItemFilter(t)&&(i=!1,r=Wr(e.customAddItemText,t)),i){var s=this._store.choices.find(function(o){return e.valueComparer(o.value,t)});if(this._isSelectElement){if(s)return this._displayNotice("",Gt.addChoice),!1}else this._isTextElement&&!e.duplicateItemsAllowed&&s&&(i=!1,r=Wr(e.uniqueItemText,t))}return i&&(r=Wr(e.addItemText,t)),r&&this._displayNotice(r,Gt.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 r=i.search(e);this._currentValue=e,this._highlightPosition=0,this._isSearching=!0;var s=this._notice,o=s&&s.type;return o!==Gt.addChoice&&(r.length?this._clearNotice():this._displayNotice(Cl(this.config.noResultsText),Gt.noResults)),this._store.dispatch(hf(r)),r.length},n.prototype._stopSearch=function(){this._isSearching&&(this._currentValue="",this._isSearching=!1,this._clearNotice(),this._store.dispatch(uf(!0)),this.passedElement.triggerEvent(ee.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,r=t.key.length===1||t.key.length===2&&t.key.charCodeAt(0)>=55296||t.key==="Unidentified";switch(!this._isTextElement&&!i&&e!==Wt.ESC_KEY&&e!==Wt.TAB_KEY&&e!==Wt.SHIFT_KEY&&(this.showDropdown(),!this.input.isFocussed&&r&&(this.input.value+=t.key,t.key===" "&&t.preventDefault())),e){case Wt.A_KEY:return this._onSelectKey(t,this.itemList.element.hasChildNodes());case Wt.ENTER_KEY:return this._onEnterKey(t,i);case Wt.ESC_KEY:return this._onEscapeKey(t,i);case Wt.UP_KEY:case Wt.PAGE_UP_KEY:case Wt.DOWN_KEY:case Wt.PAGE_DOWN_KEY:return this._onDirectionKey(t,i);case Wt.DELETE_KEY:case Wt.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,r=this.input.value,s=t.target;if(t.preventDefault(),s&&s.hasAttribute("data-button")){this._handleButtonAction(s);return}if(!e){(this._isSelectElement||this._notice)&&this.showDropdown();return}var o=this.dropdown.element.querySelector(Pr(this.config.classNames.highlightedState));if(!(o&&this._handleChoiceAction(o))){if(!s||!r){this.hideDropdown(!0);return}if(this._canAddItems()){var a=!1;this._store.withTxn(function(){if(a=i._findAndSelectChoiceByValue(r,!0),!a){if(!i._canAddUserChoices||!i._canCreateItem(r))return;i._addChoice(Ie(r,!1,i.config.allowHtmlUserInput),!0,!0),a=!0}i.clearInput(),i.unhighlightAll()}),a&&(this._triggerChange(r),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 r=i===Wt.DOWN_KEY||i===Wt.PAGE_DOWN_KEY?1:-1,s=t.metaKey||i===Wt.PAGE_DOWN_KEY||i===Wt.PAGE_UP_KEY,o=void 0;if(s)r>0?o=this.dropdown.element.querySelector("".concat(Ar,":last-of-type")):o=this.dropdown.element.querySelector(Ar);else{var a=this.dropdown.element.querySelector(Pr(this.config.classNames.highlightedState));a?o=mf(a,Ar,r):o=this.dropdown.element.querySelector(Ar)}o&&(vf(o,this.choiceList.element,r)||this.choiceList.scrollToChildElement(o,r),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 r=e===this.containerOuter.element||e===this.containerInner.element;r&&(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(Ag&&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 r=e.closest("[data-button],[data-item],[data-choice]");r instanceof HTMLElement&&("button"in r.dataset?this._handleButtonAction(r):"item"in r.dataset?this._handleItemAction(r,t.shiftKey):"choice"in r.dataset&&this._handleChoiceAction(r)),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,r=i.element.contains(e);r?!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,r=e&&i.element.contains(e);if(r){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))}},n.prototype._onBlur=function(t){var e=t.target,i=this.containerOuter,r=e&&i.element.contains(e);r&&!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(Ar));if(e.length){var i=t,r=this.config.classNames.highlightedState,s=Array.from(this.dropdown.element.querySelectorAll(Pr(r)));s.forEach(function(o){Fe(o,r),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])),G(i,r),i.setAttribute("aria-selected","true"),this.passedElement.triggerEvent(ee.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(pf(t)),e&&(this.passedElement.triggerEvent(ee.addItem,this._getChoiceForOutput(t)),i&&this.passedElement.triggerEvent(ee.choice,this._getChoiceForOutput(t)))},n.prototype._removeItem=function(t){if(t.id){this._store.dispatch(xl(t));var e=this._notice;e&&e.type===Gt.noChoices&&this._clearNotice(),this.passedElement.triggerEvent(ee.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 r=this.config;if(!((this._isSelectElement||!r.duplicateItemsAllowed)&&this._store.choices.find(function(a){return r.valueComparer(a.value,t.value)}))){this._lastAddedChoiceId++,t.id=this._lastAddedChoiceId,t.elementId="".concat(this._baseId,"-").concat(this._idNames.itemChoice,"-").concat(t.id);var s=r.prependValue,o=r.appendValue;s&&(t.value=s+t.value),o&&(t.value+=o.toString()),(s||o)&&t.element&&(t.element.value=t.value),this._clearNotice(),this._store.dispatch(cf(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(df(t)),t.choices&&(this._lastAddedGroupId++,t.id=this._lastAddedGroupId,t.choices.forEach(function(r){r.group=t,t.disabled&&(r.disabled=!0),i._addChoice(r,e)}))},n.prototype._createTemplates=function(){var t=this,e=this.config.callbackOnCreateTemplates,i={};typeof e=="function"&&(i=e.call(this,bf,_a,zn));var r={};Object.keys(this._templates).forEach(function(s){s in i?r[s]=i[s].bind(t):r[s]=t._templates[s].bind(t)}),this._templates=r},n.prototype._createElements=function(){var t=this._templates,e=this,i=e.config,r=e._isSelectOneElement,s=i.position,o=i.classNames,a=this._elementType;this.containerOuter=new Sl({element:t.containerOuter(i,this._direction,this._isSelectElement,r,i.searchEnabled,a,i.labelId),classNames:o,type:a,position:s}),this.containerInner=new Sl({element:t.containerInner(i),classNames:o,type:a,position:s}),this.input=new Of({element:t.input(i,this._placeholderValue),classNames:o,type:a,preventPaste:!i.paste}),this.choiceList=new Tl({element:t.choiceList(i,r)}),this.itemList=new Tl({element:t.itemList(i,r)}),this.dropdown=new Ef({element:t.dropdown(i),classNames:o,type:a})},n.prototype._createStructure=function(){var t=this,e=t.containerInner,i=t.containerOuter,r=t.passedElement,s=this.dropdown.element;r.conceal(),e.wrap(r.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(s),e.element.appendChild(this.itemList.element),s.appendChild(this.choiceList.element),this._isSelectOneElement?this.config.searchEnabled&&s.insertBefore(this.input.element,s.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 r=this;if(e===void 0&&(e=!1),i===void 0&&(i=!0),e){var s=t.findIndex(function(o){return o.selected})===-1;s&&t.some(function(o){return o.disabled||"choices"in o?!1:(o.selected=!0,!0)})}t.forEach(function(o){"choices"in o?r._isSelectElement&&r._addGroup(o,i):r._addChoice(o,i)})},n.prototype._findAndSelectChoiceByValue=function(t,e){var i=this;e===void 0&&(e=!1);var r=this._store.choices.find(function(s){return i.config.valueComparer(s.value,t)});return r&&!r.disabled&&!r.selected?(this._addItem(r,!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 yh='.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}';class Ki{constructor(t,...e){this.slotNames=[],this.handleSlotChange=i=>{const r=i.target;(this.slotNames.includes("[default]")&&!r.name||r.name&&this.slotNames.includes(r.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)}}const ps=vt`
688
+ `;/*! choices.js v11.0.3 | © 2024 Josh Johnson | https://github.com/jshjohnson/Choices#readme */var ha=function(n,t){return ha=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])},ha(n,t)};function iu(n,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");ha(n,t);function e(){this.constructor=n}n.prototype=t===null?Object.create(t):(e.prototype=t.prototype,new e)}var ne=function(){return ne=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},ne.apply(this,arguments)};function bg(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))}var St={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"},re={showDropdown:"showDropdown",hideDropdown:"hideDropdown",change:"change",choice:"choice",search:"search",addItem:"addItem",removeItem:"removeItem",highlightItem:"highlightItem",highlightChoice:"highlightChoice",unhighlightItem:"unhighlightItem"},Gt={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},_g=["fuseOptions","classNames"],Si={Text:"text",SelectOne:"select-one",SelectMultiple:"select-multiple"},yg=function(n){return{type:St.ADD_CHOICE,choice:n}},oc=function(n){return{type:St.REMOVE_CHOICE,choice:n}},xg=function(n){return{type:St.FILTER_CHOICES,results:n}},wg=function(n){return{type:St.ACTIVATE_CHOICES,active:n}},Cg=function(n){return{type:St.ADD_GROUP,group:n}},Sg=function(n){return{type:St.ADD_ITEM,item:n}},ac=function(n){return{type:St.REMOVE_ITEM,item:n}},mn=function(n,t){return{type:St.HIGHLIGHT_ITEM,item:n,highlighted:t}},Tg=function(n,t){return Math.floor(Math.random()*(t-n)+n)},lc=function(n){return Array.from({length:n},function(){return Tg(0,36).toString(36)}).join("")},Eg=function(n,t){var e=n.id||n.name&&"".concat(n.name,"-").concat(lc(2))||lc(4);return e=e.replace(/(:|\.|\[|\]|,)/g,""),e="".concat(t,"-").concat(e),e},Og=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},kg=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},lo=function(n){if(typeof n!="string"){if(n==null)return"";if(typeof n=="object"){if("raw"in n)return lo(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;")},Ag=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}}(),or=function(n,t){return typeof n=="function"?n(lo(t),t):n},cc=function(n){return typeof n=="function"?n():n},Ji=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""},Pg=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""},Ka=function(n,t){return n?Pg(t):lo(t)},Je=function(n,t,e){n.innerHTML=Ka(t,e)},Dg=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 Ji(s).localeCompare(Ji(a),[],{sensitivity:"base",ignorePunctuation:!0,numeric:!0})},Mg=function(n,t){return n.rank-t.rank},Ig=function(n,t,e){e===void 0&&(e=null);var i=new CustomEvent(t,{detail:e,bubbles:!0,cancelable:!0});return n.dispatchEvent(i)},Lg=function(n,t){var e=Object.keys(n).sort(),i=Object.keys(t).sort();return e.filter(function(s){return i.indexOf(s)<0})},co=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)},G=function(n,t){var e;(e=n.classList).add.apply(e,co(t))},Ne=function(n,t){var e;(e=n.classList).remove.apply(e,co(t))},Fg=function(n){if(typeof n<"u")try{return JSON.parse(n)}catch{return n}return{}},jg=function(n,t,e){var i=n.itemEl;i&&(Ne(i,e),G(i,t))},Rg=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 G(this.element,this.classNames.activeState),this.element.setAttribute("aria-expanded","true"),this.isActive=!0,this},n.prototype.hide=function(){return Ne(this.element,this.classNames.activeState),this.element.setAttribute("aria-expanded","false"),this.isActive=!1,this},n}(),hc=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){G(this.element,this.classNames.openState),this.element.setAttribute("aria-expanded","true"),this.isOpen=!0,this.shouldFlip(t,e)&&(G(this.element,this.classNames.flippedState),this.isFlipped=!0)},n.prototype.close=function(){Ne(this.element,this.classNames.openState),this.element.setAttribute("aria-expanded","false"),this.removeActiveDescendant(),this.isOpen=!1,this.isFlipped&&(Ne(this.element,this.classNames.flippedState),this.isFlipped=!1)},n.prototype.addFocusState=function(){G(this.element,this.classNames.focusState)},n.prototype.removeFocusState=function(){Ne(this.element,this.classNames.focusState)},n.prototype.enable=function(){Ne(this.element,this.classNames.disabledState),this.element.removeAttribute("aria-disabled"),this.type===Si.SelectOne&&this.element.setAttribute("tabindex","0"),this.isDisabled=!1},n.prototype.disable=function(){G(this.element,this.classNames.disabledState),this.element.setAttribute("aria-disabled","true"),this.type===Si.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(){G(this.element,this.classNames.loadingState),this.element.setAttribute("aria-busy","true"),this.isLoading=!0},n.prototype.removeLoadingState=function(){Ne(this.element,this.classNames.loadingState),this.element.removeAttribute("aria-busy"),this.isLoading=!1},n}(),$g=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!==Si.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}(),Bg=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=Bg,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}(),su=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;G(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;Ne(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){Ig(this.element,t,e||{})},n}(),Ng=function(n){iu(t,n);function t(){return n!==null&&n.apply(this,arguments)||this}return t}(su),Qs=function(n,t){return t===void 0&&(t=!0),typeof n>"u"?t:!!n},ru=function(n){if(typeof n=="string"&&(n=n.split(" ").filter(function(t){return t.length})),Array.isArray(n)&&n.length)return n},$e=function(n,t,e){if(e===void 0&&(e=!0),typeof n=="string"){var i=lo(n),s=e||i===n?n:{escaped:i,raw:n},r=$e({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 $e(d,!1)}),c={id:0,label:Ji(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:Qs(h.active),selected:Qs(h.selected,!1),disabled:Qs(h.disabled,!1),placeholder:Qs(h.placeholder,!1),highlighted:!1,labelClass:ru(h.labelClass),labelDescription:h.labelDescription,customProperties:h.customProperties};return u},zg=function(n){return n.tagName==="INPUT"},nu=function(n){return n.tagName==="SELECT"},Hg=function(n){return n.tagName==="OPTION"},Vg=function(n){return n.tagName==="OPTGROUP"},Ug=function(n){iu(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){Hg(s)?i.push(e._optionToChoice(s)):Vg(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"?ru(e.dataset.labelClass):void 0,labelDescription:typeof e.dataset.labelDescription<"u"?e.dataset.labelDescription:void 0,customProperties:Fg(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}(su),Wg={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"]},dc={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:Dg,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:Wg,appendGroupInSearch:!1},pc=function(n){var t=n.itemEl;t&&(t.remove(),n.itemEl=void 0)};function Gg(n,t,e){var i=n,s=!0;switch(t.type){case St.ADD_ITEM:{t.item.selected=!0;var r=t.item.element;r&&(r.selected=!0,r.setAttribute("selected","")),i.push(t.item);break}case St.REMOVE_ITEM:{t.item.selected=!1;var r=t.item.element;if(r){r.selected=!1,r.removeAttribute("selected");var o=r.parentElement;o&&nu(o)&&o.type===Si.SelectOne&&(o.value="")}pc(t.item),i=i.filter(function(h){return h.id!==t.item.id});break}case St.REMOVE_CHOICE:{pc(t.choice),i=i.filter(function(c){return c.id!==t.choice.id});break}case St.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&&jg(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 Yg(n,t){var e=n,i=!0;switch(t.type){case St.ADD_GROUP:{e.push(t.group);break}case St.CLEAR_CHOICES:{e=[];break}default:{i=!1;break}}return{state:e,update:i}}function Xg(n,t,e){var i=n,s=!0;switch(t.type){case St.ADD_CHOICE:{i.push(t.choice);break}case St.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 St.ADD_ITEM:case St.REMOVE_ITEM:{t.item.choiceEl=void 0;break}case St.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 St.ACTIVATE_CHOICES:{i.forEach(function(o){o.active=t.active,e&&e.appendGroupInSearch&&(o.choiceEl=void 0)});break}case St.CLEAR_CHOICES:{i=[];break}default:{s=!1;break}}return{state:i,update:s}}var fc={groups:Yg,items:Gg,choices:Xg},Kg=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(fc).forEach(function(o){var a=fc[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}(),Yt={noChoices:"no-choices",noResults:"no-results",addChoice:"add-choice",generic:""};function qg(n,t,e){return(t=Jg(t))in n?Object.defineProperty(n,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):n[t]=e,n}function gc(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 _s(n){for(var t=1;t<arguments.length;t++){var e=arguments[t]!=null?arguments[t]:{};t%2?gc(Object(e),!0).forEach(function(i){qg(n,i,e[i])}):Object.getOwnPropertyDescriptors?Object.defineProperties(n,Object.getOwnPropertyDescriptors(e)):gc(Object(e)).forEach(function(i){Object.defineProperty(n,i,Object.getOwnPropertyDescriptor(e,i))})}return n}function Zg(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 Jg(n){var t=Zg(n,"string");return typeof t=="symbol"?t:t+""}function pi(n){return Array.isArray?Array.isArray(n):lu(n)==="[object Array]"}function Qg(n){if(typeof n=="string")return n;let t=n+"";return t=="0"&&1/n==-1/0?"-0":t}function tm(n){return n==null?"":Qg(n)}function He(n){return typeof n=="string"}function ou(n){return typeof n=="number"}function em(n){return n===!0||n===!1||im(n)&&lu(n)=="[object Boolean]"}function au(n){return typeof n=="object"}function im(n){return au(n)&&n!==null}function ge(n){return n!=null}function zo(n){return!n.trim().length}function lu(n){return n==null?n===void 0?"[object Undefined]":"[object Null]":Object.prototype.toString.call(n)}const sm="Incorrect 'index' type",rm=n=>`Invalid value for key ${n}`,nm=n=>`Pattern length exceeds max of ${n}.`,om=n=>`Missing ${n} property in key`,am=n=>`Property 'weight' in key '${n}' must be a positive integer`,mc=Object.prototype.hasOwnProperty;class lm{constructor(t){this._keys=[],this._keyMap={};let e=0;t.forEach(i=>{let s=cu(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 cu(n){let t=null,e=null,i=null,s=1,r=null;if(He(n)||pi(n))i=n,t=vc(n),e=ua(n);else{if(!mc.call(n,"name"))throw new Error(om("name"));const o=n.name;if(i=o,mc.call(n,"weight")&&(s=n.weight,s<=0))throw new Error(am(o));t=vc(o),e=ua(o),r=n.getFn}return{path:t,id:e,weight:s,src:i,getFn:r}}function vc(n){return pi(n)?n:n.split(".")}function ua(n){return pi(n)?n.join("."):n}function cm(n,t){let e=[],i=!1;const s=(r,o,a)=>{if(ge(r))if(!o[a])e.push(r);else{let l=o[a];const c=r[l];if(!ge(c))return;if(a===o.length-1&&(He(c)||ou(c)||em(c)))e.push(tm(c));else if(pi(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,He(t)?t.split("."):t,0),i?e:e[0]}const hm={includeMatches:!1,findAllMatches:!1,minMatchCharLength:1},um={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},dm={location:0,threshold:.6,distance:100},pm={useExtendedSearch:!1,getFn:cm,ignoreLocation:!1,ignoreFieldNorm:!1,fieldNormWeight:1};var U=_s(_s(_s(_s({},um),hm),dm),pm);const fm=/[^ ]+/g;function gm(n=1,t=3){const e=new Map,i=Math.pow(10,t);return{get(s){const r=s.match(fm).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 qa{constructor({getFn:t=U.getFn,fieldNormWeight:e=U.fieldNormWeight}={}){this.norm=gm(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,He(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();He(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(!ge(t)||zo(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(ge(o)){if(pi(o)){let a=[];const l=[{nestedArrIndex:-1,value:o}];for(;l.length;){const{nestedArrIndex:c,value:h}=l.pop();if(ge(h))if(He(h)&&!zo(h)){let u={v:h,i:c,n:this.norm.get(h)};a.push(u)}else pi(h)&&h.forEach((u,d)=>{l.push({nestedArrIndex:d,value:u})})}i.$[r]=a}else if(He(o)&&!zo(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 hu(n,t,{getFn:e=U.getFn,fieldNormWeight:i=U.fieldNormWeight}={}){const s=new qa({getFn:e,fieldNormWeight:i});return s.setKeys(n.map(cu)),s.setSources(t),s.create(),s}function mm(n,{getFn:t=U.getFn,fieldNormWeight:e=U.fieldNormWeight}={}){const{keys:i,records:s}=n,r=new qa({getFn:t,fieldNormWeight:e});return r.setKeys(i),r.setIndexRecords(s),r}function vn(n,{errors:t=0,currentLocation:e=0,expectedLocation:i=0,distance:s=U.distance,ignoreLocation:r=U.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 vm(n=[],t=U.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 Xi=32;function bm(n,t,e,{location:i=U.location,distance:s=U.distance,threshold:r=U.threshold,findAllMatches:o=U.findAllMatches,minMatchCharLength:a=U.minMatchCharLength,includeMatches:l=U.includeMatches,ignoreLocation:c=U.ignoreLocation}={}){if(t.length>Xi)throw new Error(nm(Xi));const h=t.length,u=n.length,d=Math.max(0,Math.min(i,u));let p=r,f=d;const g=a>1||l,m=g?Array(u):[];let v;for(;(v=n.indexOf(t,f))>-1;){let C=vn(t,{currentLocation:v,expectedLocation:d,distance:s,ignoreLocation:c});if(p=Math.min(C,p),f=v+h,g){let S=0;for(;S<h;)m[v+S]=1,S+=1}}f=-1;let y=[],x=1,E=h+u;const O=1<<h-1;for(let C=0;C<h;C+=1){let S=0,F=E;for(;S<F;)vn(t,{errors:C,currentLocation:d+F,expectedLocation:d,distance:s,ignoreLocation:c})<=p?S=F:E=F,F=Math.floor((E-S)/2+S);E=F;let j=Math.max(1,d-F+1),A=o?u:Math.min(d+F,u)+h,k=Array(A+2);k[A+1]=(1<<C)-1;for(let L=A;L>=j;L-=1){let z=L-1,X=e[n.charAt(z)];if(g&&(m[z]=+!!X),k[L]=(k[L+1]<<1|1)&X,C&&(k[L]|=(y[L+1]|y[L])<<1|1|y[L+1]),k[L]&O&&(x=vn(t,{errors:C,currentLocation:z,expectedLocation:d,distance:s,ignoreLocation:c}),x<=p)){if(p=x,f=z,f<=d)break;j=Math.max(1,2*d-f)}}if(vn(t,{errors:C+1,currentLocation:d,expectedLocation:d,distance:s,ignoreLocation:c})>p)break;y=k}const D={isMatch:f>=0,score:Math.max(.001,x)};if(g){const C=vm(m,a);C.length?l&&(D.indices=C):D.isMatch=!1}return D}function _m(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 uu{constructor(t,{location:e=U.location,threshold:i=U.threshold,distance:s=U.distance,includeMatches:r=U.includeMatches,findAllMatches:o=U.findAllMatches,minMatchCharLength:a=U.minMatchCharLength,isCaseSensitive:l=U.isCaseSensitive,ignoreLocation:c=U.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,p)=>{this.chunks.push({pattern:d,alphabet:_m(d),startIndex:p})},u=this.pattern.length;if(u>Xi){let d=0;const p=u%Xi,f=u-p;for(;d<f;)h(this.pattern.substr(d,Xi),d),d+=Xi;if(p){const g=u-Xi;h(this.pattern.substr(g),g)}}else h(this.pattern,0)}searchIn(t){const{isCaseSensitive:e,includeMatches:i}=this.options;if(e||(t=t.toLowerCase()),this.pattern===t){let f={isMatch:!0,score:0};return i&&(f.indices=[[0,t.length-1]]),f}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:f,alphabet:g,startIndex:m})=>{const{isMatch:v,score:y,indices:x}=bm(t,f,g,{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 p={isMatch:d,score:d?u/this.chunks.length:1};return d&&i&&(p.indices=h),p}}class Bi{constructor(t){this.pattern=t}static isMultiMatch(t){return bc(t,this.multiRegex)}static isSingleMatch(t){return bc(t,this.singleRegex)}search(){}}function bc(n,t){const e=n.match(t);return e?e[1]:null}class ym extends Bi{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 xm extends Bi{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 wm extends Bi{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 Cm extends Bi{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 Sm extends Bi{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 Tm extends Bi{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 du extends Bi{constructor(t,{location:e=U.location,threshold:i=U.threshold,distance:s=U.distance,includeMatches:r=U.includeMatches,findAllMatches:o=U.findAllMatches,minMatchCharLength:a=U.minMatchCharLength,isCaseSensitive:l=U.isCaseSensitive,ignoreLocation:c=U.ignoreLocation}={}){super(t),this._bitapSearch=new uu(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 pu extends Bi{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 da=[ym,pu,wm,Cm,Tm,Sm,xm,du],_c=da.length,Em=/ +(?=(?:[^\"]*\"[^\"]*\")*[^\"]*$)/,Om="|";function km(n,t={}){return n.split(Om).map(e=>{let i=e.trim().split(Em).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<_c;){const h=da[c];let u=h.isMultiMatch(a);u&&(s.push(new h(u,t)),l=!0)}if(!l)for(c=-1;++c<_c;){const h=da[c];let u=h.isSingleMatch(a);if(u){s.push(new h(u,t));break}}}return s})}const Am=new Set([du.type,pu.type]);class Pm{constructor(t,{isCaseSensitive:e=U.isCaseSensitive,includeMatches:i=U.includeMatches,minMatchCharLength:s=U.minMatchCharLength,ignoreLocation:r=U.ignoreLocation,findAllMatches:o=U.findAllMatches,location:a=U.location,threshold:l=U.threshold,distance:c=U.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=km(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 p=h[u],{isMatch:f,indices:g,score:m}=p.search(t);if(f){if(r+=1,a+=m,i){const v=p.constructor.type;Am.has(v)?o=[...o,...g]:o.push(g)}}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 pa=[];function Dm(...n){pa.push(...n)}function fa(n,t){for(let e=0,i=pa.length;e<i;e+=1){let s=pa[e];if(s.condition(n,t))return new s(n,t)}return new uu(n,t)}const Wn={AND:"$and",OR:"$or"},ga={PATH:"$path",PATTERN:"$val"},ma=n=>!!(n[Wn.AND]||n[Wn.OR]),Mm=n=>!!n[ga.PATH],Im=n=>!pi(n)&&au(n)&&!ma(n),yc=n=>({[Wn.AND]:Object.keys(n).map(t=>({[t]:n[t]}))});function fu(n,t,{auto:e=!0}={}){const i=s=>{let r=Object.keys(s);const o=Mm(s);if(!o&&r.length>1&&!ma(s))return i(yc(s));if(Im(s)){const l=o?s[ga.PATH]:r[0],c=o?s[ga.PATTERN]:s[l];if(!He(c))throw new Error(rm(l));const h={keyId:ua(l),pattern:c};return e&&(h.searcher=fa(c,t)),h}let a={children:[],operator:r[0]};return r.forEach(l=>{const c=s[l];pi(c)&&c.forEach(h=>{a.children.push(i(h))})}),a};return ma(n)||(n=yc(n)),i(n)}function Lm(n,{ignoreFieldNorm:t=U.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 Fm(n,t){const e=n.matches;t.matches=[],ge(e)&&e.forEach(i=>{if(!ge(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 jm(n,t){t.score=n.score}function Rm(n,t,{includeMatches:e=U.includeMatches,includeScore:i=U.includeScore}={}){const s=[];return e&&s.push(Fm),i&&s.push(jm),n.map(r=>{const{idx:o}=r,a={item:t[o],refIndex:o};return s.length&&s.forEach(l=>{l(r,a)}),a})}class Rs{constructor(t,e={},i){this.options=_s(_s({},U),e),this.options.useExtendedSearch,this._keyStore=new lm(this.options.keys),this.setCollection(t,i)}setCollection(t,e){if(this._docs=t,e&&!(e instanceof qa))throw new Error(sm);this._myIndex=e||hu(this.options.keys,this._docs,{getFn:this.options.getFn,fieldNormWeight:this.options.fieldNormWeight})}add(t){ge(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=He(t)?He(this._docs[0])?this._searchStringList(t):this._searchObjectList(t):this._searchLogical(t);return Lm(l,{ignoreFieldNorm:a}),r&&l.sort(o),ou(e)&&e>-1&&(l=l.slice(0,e)),Rm(l,this._docs,{includeMatches:i,includeScore:s})}_searchStringList(t){const e=fa(t,this.options),{records:i}=this._myIndex,s=[];return i.forEach(({v:r,i:o,n:a})=>{if(!ge(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=fu(t,this.options),i=(a,l,c)=>{if(!a.children){const{keyId:u,searcher:d}=a,p=this._findMatches({key:this._keyStore.get(u),value:this._myIndex.getValueForItemAtKeyId(l,u),searcher:d});return p&&p.length?[{idx:c,item:l,matches:p}]:[]}const h=[];for(let u=0,d=a.children.length;u<d;u+=1){const p=a.children[u],f=i(p,l,c);if(f.length)h.push(...f);else if(a.operator===Wn.AND)return[]}return h},s=this._myIndex.records,r={},o=[];return s.forEach(({$:a,i:l})=>{if(ge(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=fa(t,this.options),{keys:i,records:s}=this._myIndex,r=[];return s.forEach(({$:o,i:a})=>{if(!ge(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(!ge(e))return[];let s=[];if(pi(e))e.forEach(({v:r,i:o,n:a})=>{if(!ge(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}}Rs.version="7.0.0";Rs.createIndex=hu;Rs.parseIndex=mm;Rs.config=U;Rs.parseQuery=fu;Dm(Pm);var $m=function(){function n(t){this._haystack=[],this._fuseOptions=ne(ne({},t.fuseOptions),{keys:bg([],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 Rs(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 Bm(n){return new $m(n)}var Nm=function(n){for(var t in n)if(Object.prototype.hasOwnProperty.call(n,t))return!1;return!0},Ho=function(n,t,e){var i=n.dataset,s=t.customProperties,r=t.labelClass,o=t.labelDescription;r&&(i.labelClass=co(r).join(" ")),o&&(i.labelDescription=o),e&&s&&(typeof s=="string"?i.customProperties=s:typeof s=="object"&&!Nm(s)&&(i.customProperties=JSON.stringify(s)))},xc=function(n,t,e){var i=t&&n.querySelector("label[for='".concat(t,"']")),s=i&&i.innerText;s&&e.setAttribute("aria-label",s)},zm={containerOuter:function(n,t,e,i,s,r,o){var a=n.classNames.containerOuter,l=document.createElement("div");return G(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||xc(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 G(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 G(a,s),G(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 G(s,i),Je(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,p=Ji(t.value),f=document.createElement("div");if(G(f,l),t.labelClass){var g=document.createElement("span");Je(g,i,t.label),G(g,t.labelClass),f.appendChild(g)}else Je(f,i,t.label);if(f.dataset.item="",f.dataset.id=t.id,f.dataset.value=p,Ho(f,t,!0),(t.disabled||this.containerOuter.isDisabled)&&f.setAttribute("aria-disabled","true"),this._isSelectElement&&(f.setAttribute("aria-selected","true"),f.setAttribute("role","option")),t.placeholder&&(G(f,d),f.dataset.placeholder=""),G(f,t.highlighted?h:u),e){t.disabled&&Ne(f,u),f.dataset.deletable="";var m=document.createElement("button");m.type="button",G(m,c),Je(m,!0,or(r,t.value));var v=or(o,t.value);v&&m.setAttribute("aria-label",v),m.dataset.button="",s?f.insertAdjacentElement("afterbegin",m):f.appendChild(m)}return f},choiceList:function(n,t){var e=n.classNames.list,i=document.createElement("div");return G(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=Ji(l),u=document.createElement("div");G(u,s),c&&G(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 G(d,r),Je(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,p=t.label,f=Ji(t.value),g=document.createElement("div");g.id=t.elementId,G(g,o),G(g,a),i&&typeof p=="string"&&(p=Ka(s,p),p+=" (".concat(i,")"),p={trusted:p});var m=g;if(t.labelClass){var v=document.createElement("span");Je(v,s,p),G(v,t.labelClass),m=v,g.appendChild(v)}else Je(g,s,p);if(t.labelDescription){var y="".concat(t.elementId,"-description");m.setAttribute("aria-describedby",y);var x=document.createElement("span");Je(x,s,t.labelDescription),x.id=y,G(x,u),g.appendChild(x)}return t.selected&&G(g,c),t.placeholder&&G(g,d),g.setAttribute("role",t.group?"treeitem":"option"),g.dataset.choice="",g.dataset.id=t.id,g.dataset.value=f,e&&(g.dataset.selectText=e),t.group&&(g.dataset.groupId="".concat(t.group.id)),Ho(g,t,!1),t.disabled?(G(g,h),g.dataset.choiceDisabled="",g.setAttribute("aria-disabled","true")):(G(g,l),g.dataset.choiceSelectable=""),g},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",G(o,i),G(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||xc(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 G(s,e),G(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=Yt.generic);var h=document.createElement("div");switch(Je(h,!0,t),G(h,s),G(h,r),G(h,c),e){case Yt.addChoice:G(h,o);break;case Yt.noResults:G(h,a);break;case Yt.noChoices:G(h,l);break}return e===Yt.addChoice&&(h.dataset.choiceSelectable="",h.dataset.choice=""),h},option:function(n){var t=Ji(n.label),e=new Option(t,n.value,!1,n.selected);return Ho(e,n,!0),e.disabled=n.disabled,n.selected&&e.setAttribute("selected",""),e}},Hm="-ms-scroll-limit"in document.documentElement.style&&"-ms-ime-align"in document.documentElement.style,Vm={},Vo=function(n){if(n)return n.dataset.id?parseInt(n.dataset.id,10):void 0},Gs="[data-choice-selectable]",gu=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=ne(ne(ne({},s.allOptions),s.options),e),_g.forEach(function(v){i.config[v]=ne(ne(ne({},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"||!(zg(a)||nu(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===Si.Text;(c||r.maxItemCount!==1)&&(r.singleModeForMultiSelect=!1),r.singleModeForMultiSelect&&(l=Si.SelectMultiple);var h=l===Si.SelectOne,u=l===Si.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=Qs(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 p=e.addItemFilter instanceof RegExp?e.addItemFilter:new RegExp(e.addItemFilter);r.addItemFilter=p.test.bind(p)}if(this._isTextElement)this.passedElement=new Ng({element:a,classNames:r.classNames});else{var f=a;this.passedElement=new Ug({element:f,classNames:r.classNames,template:function(v){return i._templates.option(v)},extractPlaceholder:r.placeholder&&!this._hasNonChoicePlaceholder})}if(this.initialised=!1,this._store=new Kg(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=Eg(a,"choices-"),this._direction=a.dir,!this._direction){var g=window.getComputedStyle(a).direction,m=window.getComputedStyle(document.documentElement).direction;g!==m&&(this._direction=g)}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 Vm},get allOptions(){return dc},get templates(){return zm}})},enumerable:!1,configurable:!0}),n.prototype.init=function(){if(!(this.initialised||this.initialisedOK!==void 0)){this._searcher=Bm(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(mn(i,!0)),e&&this.passedElement.triggerEvent(re.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(mn(i,!1)),e&&this.passedElement.triggerEvent(re.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(mn(e,!0)),t.passedElement.triggerEvent(re.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(mn(e,!1)),t.passedElement.triggerEvent(re.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(re.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(re.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($e(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=ne(ne({},u),{label:u[i]})),o._addGroup($e(u,!0))}else{var d=h;(!c||!l)&&(d=ne(ne({},d),{value:d[e],label:d[i]})),o._addChoice($e(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(ac(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(oc(e)),this._searcher.reset(),e.selected&&this.passedElement.triggerEvent(re.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(oc(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=Lg(t,dc);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(f){return!f.element});c.length&&this.passedElement.addOptions(c)}var h=document.createDocumentFragment(),u=function(f){return f.filter(function(g){return!g.placeholder&&(s?!!g.rank:i.renderSelectedChoices||!g.selected)})},d=!1,p=function(f,g,m){s?f.sort(Mg):i.shouldSort&&f.sort(i.sorter);var v=f.length;v=!g&&l&&v>l?l:v,v--,f.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&&p(a.filter(function(f){return f.placeholder&&!f.group}),!1,void 0),o.length&&!s?(i.shouldSort&&o.sort(i.sorter),p(a.filter(function(f){return!f.placeholder&&!f.group}),!1,void 0),o.forEach(function(f){var g=u(f.choices);if(g.length){if(f.label){var m=f.groupEl||t._templates.choiceGroup(t.config,f);f.groupEl=m,m.remove(),h.appendChild(m)}p(g,!0,i.appendGroupInSearch&&s?f.label:void 0)}})):p(u(a),!1,void 0)),d||(this._notice||(this._notice={text:cc(s?i.noResultsText:i.noChoicesText),type:s?Yt.noResults:Yt.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($e({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===Yt.addChoice&&(e===Yt.noResults||e===Yt.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(re.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&&Vo(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=Vo(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=Vo(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 $e(o,!1)}),this.passedElement.value){var s=this.passedElement.value.split(i.delimiter).map(function(o){return $e(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 $e(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(re.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,Yt.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=or(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("",Yt.addChoice),!1}else this._isTextElement&&!e.duplicateItemsAllowed&&r&&(i=!1,s=or(e.uniqueItemText,t))}return i&&(s=or(e.addItemText,t)),s&&this._displayNotice(s,Yt.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!==Yt.addChoice&&(s.length?this._clearNotice():this._displayNotice(cc(this.config.noResultsText),Yt.noResults)),this._store.dispatch(xg(s)),s.length},n.prototype._stopSearch=function(){this._isSearching&&(this._currentValue="",this._isSearching=!1,this._clearNotice(),this._store.dispatch(wg(!0)),this.passedElement.triggerEvent(re.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!==Gt.ESC_KEY&&e!==Gt.TAB_KEY&&e!==Gt.SHIFT_KEY&&(this.showDropdown(),!this.input.isFocussed&&s&&(this.input.value+=t.key,t.key===" "&&t.preventDefault())),e){case Gt.A_KEY:return this._onSelectKey(t,this.itemList.element.hasChildNodes());case Gt.ENTER_KEY:return this._onEnterKey(t,i);case Gt.ESC_KEY:return this._onEscapeKey(t,i);case Gt.UP_KEY:case Gt.PAGE_UP_KEY:case Gt.DOWN_KEY:case Gt.PAGE_DOWN_KEY:return this._onDirectionKey(t,i);case Gt.DELETE_KEY:case Gt.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($e(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===Gt.DOWN_KEY||i===Gt.PAGE_DOWN_KEY?1:-1,r=t.metaKey||i===Gt.PAGE_DOWN_KEY||i===Gt.PAGE_UP_KEY,o=void 0;if(r)s>0?o=this.dropdown.element.querySelector("".concat(Gs,":last-of-type")):o=this.dropdown.element.querySelector(Gs);else{var a=this.dropdown.element.querySelector(Ws(this.config.classNames.highlightedState));a?o=Og(a,Gs,s):o=this.dropdown.element.querySelector(Gs)}o&&(kg(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(Hm&&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(Gs));if(e.length){var i=t,s=this.config.classNames.highlightedState,r=Array.from(this.dropdown.element.querySelectorAll(Ws(s)));r.forEach(function(o){Ne(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])),G(i,s),i.setAttribute("aria-selected","true"),this.passedElement.triggerEvent(re.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(Sg(t)),e&&(this.passedElement.triggerEvent(re.addItem,this._getChoiceForOutput(t)),i&&this.passedElement.triggerEvent(re.choice,this._getChoiceForOutput(t)))},n.prototype._removeItem=function(t){if(t.id){this._store.dispatch(ac(t));var e=this._notice;e&&e.type===Yt.noChoices&&this._clearNotice(),this.passedElement.triggerEvent(re.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(yg(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(Cg(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,Ag,Ka,co));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 hc({element:t.containerOuter(i,this._direction,this._isSelectElement,s,i.searchEnabled,a,i.labelId),classNames:o,type:a,position:r}),this.containerInner=new hc({element:t.containerInner(i),classNames:o,type:a,position:r}),this.input=new $g({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 Rg({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 mu='.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}';class os{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)}}/**
689
+ * @license
690
+ * Copyright 2017 Google LLC
691
+ * SPDX-License-Identifier: BSD-3-Clause
692
+ */const xi={ATTRIBUTE:1,PROPERTY:3,BOOLEAN_ATTRIBUTE:4},ho=n=>(...t)=>({_$litDirective$:n,values:t});let uo=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)}};/**
693
+ * @license
694
+ * Copyright 2018 Google LLC
695
+ * SPDX-License-Identifier: BSD-3-Clause
696
+ */const je=ho(class extends uo{constructor(n){var t;if(super(n),n.type!==xi.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 Ce}}),Mr=at`
637
697
  .form-control .form-control__label {
638
698
  display: none;
639
699
  }
@@ -689,31 +749,31 @@ good aklsdfja`,this.alignment="left",this.fontFamily="Arial",this.color="#000",t
689
749
  .form-control--has-help-text.form-control--radio-group .form-control__help-text {
690
750
  margin-top: var(--pbo-spacing-2x);
691
751
  }
692
- `;var Ig=Object.defineProperty,Lg=Object.getOwnPropertyDescriptor,qi=(n,t,e,i)=>{for(var r=i>1?void 0:i?Lg(t,e):t,s=n.length-1,o;s>=0;s--)(o=n[s])&&(r=(i?o(t,e,r):o(r))||r);return i&&r&&Ig(t,e,r),r};let ze=class extends Xo{constructor(){super(...arguments),this.hasSlotController=new Ki(this,"help-text","label"),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.disabled=!1,this.size="medium",this.label=""}get value(){var n;return(n=this._choices)==null?void 0:n.getValue().value}handleDisabledChanged(){var n;this._choices&&this.disabled?this._choices.disable():(n=this._choices)==null||n.enable()}firstUpdated(){this._initializeChoices(),this.handleDisabledChanged()}_initializeChoices(){var n;(n=this._choices)==null||n.destroy(),this._choices=new _h(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:e===0})),placeholder:!1,shouldSortItems:!1,itemSelectText:"",callbackOnCreateTemplates:function(t,e,i){return{item:({classNames:r},s)=>{var a;const o=[i(r.item).join(" "),i(s.highlighted?r.highlightedState:r.itemSelectable).join(" ")].join(" ");return t(`
752
+ `;var Um=Object.defineProperty,Wm=Object.getOwnPropertyDescriptor,as=(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&&Um(t,e,s),s};let We=class extends Oi{constructor(){super(...arguments),this.hasSlotController=new os(this,"help-text","label"),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.disabled=!1,this.size="medium",this.label=""}get value(){var n;return(n=this._choices)==null?void 0:n.getValue().value}handleDisabledChanged(){var n;this._choices&&this.disabled?this._choices.disable():(n=this._choices)==null||n.enable()}firstUpdated(){this._initializeChoices(),this.handleDisabledChanged()}_initializeChoices(){var n;(n=this._choices)==null||n.destroy(),this._choices=new gu(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:e===0})),placeholder:!1,shouldSortItems:!1,itemSelectText:"",callbackOnCreateTemplates:function(t,e,i){return{item:({classNames:s},r)=>{var a;const o=[i(s.item).join(" "),i(r.highlighted?s.highlightedState:s.itemSelectable).join(" ")].join(" ");return t(`
693
753
  <div
694
754
  class="${o}"
695
755
  data-item
696
- data-id="${s.id}"
697
- data-value="${e(s.value)}"
698
- ${s.active?'aria-selected="true"':""}
699
- ${s.disabled?'aria-disabled="true"':""}
700
- style="font-family: ${((a=s.customProperties)==null?void 0:a.font)||"inherit"}"
756
+ data-id="${r.id}"
757
+ data-value="${e(r.value)}"
758
+ ${r.active?'aria-selected="true"':""}
759
+ ${r.disabled?'aria-disabled="true"':""}
760
+ style="font-family: ${((a=r.customProperties)==null?void 0:a.font)||"inherit"}"
701
761
  >
702
- ${s.label}
762
+ ${r.label}
703
763
  </div>
704
- `)},choice:({classNames:r},s)=>{var a;const o=[i(r.item).join(" "),i(r.itemChoice).join(" "),i(s.disabled?r.itemDisabled:r.itemSelectable).join(" ")].join(" ");return t(`
764
+ `)},choice:({classNames:s},r)=>{var a;const o=[i(s.item).join(" "),i(s.itemChoice).join(" "),i(r.disabled?s.itemDisabled:s.itemSelectable).join(" ")].join(" ");return t(`
705
765
  <div class="${o}"
706
766
  data-select-text="${this.config.itemSelectText}"
707
- data-choice ${s.disabled?'data-choice-disabled aria-disabled="true"':"data-choice-selectable"}
708
- data-id="${s.id}"
709
- data-value="${e(s.value)}"
710
- ${s.groupId>0?'role="treeitem"':'role="option"'}
711
- style="font-family: ${((a=s.customProperties)==null?void 0:a.font)||"inherit"}"
767
+ data-choice ${r.disabled?'data-choice-disabled aria-disabled="true"':"data-choice-selectable"}
768
+ data-id="${r.id}"
769
+ data-value="${e(r.value)}"
770
+ ${r.groupId>0?'role="treeitem"':'role="option"'}
771
+ style="font-family: ${((a=r.customProperties)==null?void 0:a.font)||"inherit"}"
712
772
  >
713
- ${s.label}
773
+ ${r.label}
714
774
  </div>
715
- `)}}}}),this.choiceEl.addEventListener("change",t=>{const e=t.target;this.dispatchEvent(new CustomEvent("pbo-change",{detail:{value:e.value},bubbles:!0,composed:!0}))})}render(){const n=this.hasSlotController.test("label"),t=this.label?!0:!!n;return X` <div
716
- class=${ni({"form-control":!0,"form-control--small":this.size==="small","form-control--medium":this.size==="medium","form-control--large":this.size==="large","form-control--radio-group":!0,"form-control--has-label":t})}
775
+ `)}}}}),this.choiceEl.addEventListener("change",t=>{const e=t.target;this.dispatchEvent(new CustomEvent("pbo-change",{detail:{value:e.value},bubbles:!0,composed:!0}))})}render(){const n=this.hasSlotController.test("label"),t=this.label?!0:!!n;return W` <div
776
+ class=${je({"form-control":!0,"form-control--small":this.size==="small","form-control--medium":this.size==="medium","form-control--large":this.size==="large","form-control--radio-group":!0,"form-control--has-label":t})}
717
777
  >
718
778
  <label
719
779
  part="form-control-label"
@@ -724,7 +784,7 @@ good aklsdfja`,this.alignment="left",this.fontFamily="Arial",this.color="#000",t
724
784
  <slot name="label">${this.label}</slot>
725
785
  </label>
726
786
  </div>
727
- <select part="base" class="js-choice"></select>`}};ze.styles=[Pt,of,ps,kn(yh)];qi([O({type:Array})],ze.prototype,"fonts",2);qi([O({type:Boolean,reflect:!0})],ze.prototype,"disabled",2);qi([O()],ze.prototype,"size",2);qi([O()],ze.prototype,"label",2);qi([q(".js-choice")],ze.prototype,"choiceEl",2);qi([et("disabled",{waitUntilFirstUpdate:!0})],ze.prototype,"handleDisabledChanged",1);ze=qi([Ot("pbo-selector")],ze);const xh=vt`
787
+ <select part="base" class="js-choice"></select>`}};We.styles=[wt,vg,Mr,Or(mu)];as([T({type:Array})],We.prototype,"fonts",2);as([T({type:Boolean,reflect:!0})],We.prototype,"disabled",2);as([T()],We.prototype,"size",2);as([T()],We.prototype,"label",2);as([q(".js-choice")],We.prototype,"choiceEl",2);as([Q("disabled",{waitUntilFirstUpdate:!0})],We.prototype,"handleDisabledChanged",1);We=as([bt("pbo-selector")],We);const vu=at`
728
788
  :host {
729
789
  display: inline-block;
730
790
  position: relative;
@@ -1386,12 +1446,12 @@ good aklsdfja`,this.alignment="left",this.fontFamily="Arial",this.color="#000",t
1386
1446
  * @license
1387
1447
  * Copyright 2020 Google LLC
1388
1448
  * SPDX-License-Identifier: BSD-3-Clause
1389
- */const wh=Symbol.for(""),Fg=n=>{if((n==null?void 0:n.r)===wh)return n==null?void 0:n._$litStatic$},jl=(n,...t)=>({_$litStatic$:t.reduce((e,i,r)=>e+(s=>{if(s._$litStatic$!==void 0)return s._$litStatic$;throw Error(`Value passed to 'literal' function must be a 'literal' result: ${s}. Use 'unsafeStatic' to pass non-literal values, but
1390
- take care to ensure page security.`)})(i)+n[r+1],n[0]),r:wh}),Rl=new Map,jg=n=>(t,...e)=>{const i=e.length;let r,s;const o=[],a=[];let l,c=0,h=!1;for(;c<i;){for(l=t[c];c<i&&(s=e[c],(r=Fg(s))!==void 0);)l+=r+t[++c],h=!0;c!==i&&a.push(s),o.push(l),c++}if(c===i&&o.push(t[i]),h){const u=o.join("$$lit$$");(t=Rl.get(u))===void 0&&(o.raw=o,Rl.set(u,t=o)),e=a}return n(t,...e)},Bl=jg(X),Mr=new WeakMap,Ir=new WeakMap,Lr=new WeakMap,go=new WeakSet,Js=new WeakMap;class xa{constructor(t,e){this.handleFormData=i=>{const r=this.options.disabled(this.host),s=this.options.name(this.host),o=this.options.value(this.host),a=this.host.tagName.toLowerCase()==="pbo-button";this.host.isConnected&&!r&&!a&&typeof s=="string"&&s.length>0&&typeof o<"u"&&(Array.isArray(o)?o.forEach(l=>{i.formData.append(s,l.toString())}):i.formData.append(s,o.toString()))},this.handleFormSubmit=i=>{var o;const r=this.options.disabled(this.host),s=this.options.reportValidity;this.form&&!this.form.noValidate&&((o=Mr.get(this.form))==null||o.forEach(a=>{this.setUserInteracted(a,!0)})),this.form&&!this.form.noValidate&&!r&&!s(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),Js.set(this.host,[])},this.handleInteraction=i=>{const r=Js.get(this.host);r.includes(i.type)||r.push(i.type),r.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 r of i)if(typeof r.checkValidity=="function"&&!r.checkValidity())return!1}return!0},this.doAction=(i,r)=>{if(this.form){const s=document.createElement("button");s.type=i,s.style.position="absolute",s.style.width="0",s.style.height="0",s.style.clipPath="inset(50%)",s.style.overflow="hidden",s.style.whiteSpace="nowrap",r&&(s.name=r.name,s.value=r.value,["formation","formenctype","formmethod","formnovalidate","formtarget"].forEach(o=>{r.hasAttribute(o)&&s.setAttribute(o,r.getAttribute(o))})),this.form.append(s),s.click(),s.remove()}},(this.host=t).addController(this),this.options={form:i=>{const r=i.form;if(r){const o=i.getRootNode().querySelector(`#${r}`);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,r)=>i.value=r,assumeInteractionOn:["pbo-input"],...e}}hostConnected(){const t=this.options.form(this.host);t&&this.attachForm(t),Js.set(this.host,[]),this.options.assumeInteractionOn.forEach(e=>{this.host.addEventListener(e,this.handleInteraction)})}hostDisconnected(){this.detachForm(),Js.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,Mr.has(this.form)?Mr.get(this.form).add(this.host):Mr.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),Ir.has(this.form)||(Ir.set(this.form,this.form.reportValidity),this.form.reportValidity=()=>this.reportFormValidity()),Lr.has(this.form)||(Lr.set(this.form,this.form.checkValidity),this.form.checkValidity=()=>this.checkFormValidity())):this.form=void 0}detachForm(){if(!this.form)return;const t=Mr.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),Ir.has(this.form)&&(this.form.reportValidity=Ir.get(this.form),Ir.delete(this.form)),Lr.has(this.form)&&(this.form.checkValidity=Lr.get(this.form),Lr.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?go.add(t):go.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=!!go.has(e),r=!!e.required;e.toggleAttribute("data-required",r),e.toggleAttribute("data-optional",!r),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 Vn=Object.freeze({badInput:!1,customError:!1,patternMismatch:!1,rangeOverflow:!1,rangeUnderflow:!1,stepMismatch:!1,tooLong:!1,tooShort:!1,typeMismatch:!1,valid:!0,valueMissing:!1}),Rg=Object.freeze({...Vn,valid:!1,valueMissing:!1}),Bg=Object.freeze({...Vn,valid:!1,customError:!0});/**
1449
+ */const bu=Symbol.for(""),Gm=n=>{if((n==null?void 0:n.r)===bu)return n==null?void 0:n._$litStatic$},wc=(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
1450
+ take care to ensure page security.`)})(i)+n[s+1],n[0]),r:bu}),Cc=new Map,Ym=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=Gm(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=Cc.get(u))===void 0&&(o.raw=o,Cc.set(u,t=o)),e=a}return n(t,...e)},Sc=Ym(W);class It extends Oi{emit(t,e){const i=new CustomEvent(t,{bubbles:!0,cancelable:!0,composed:!0,detail:{},...e});return this.dispatchEvent(i),i}}const Ys=new WeakMap,Xs=new WeakMap,Ks=new WeakMap,Uo=new WeakSet,bn=new WeakMap;class Za{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),a=this.host.tagName.toLowerCase()==="pbo-button";this.host.isConnected&&!s&&!a&&typeof r=="string"&&r.length>0&&typeof o<"u"&&(Array.isArray(o)?o.forEach(l=>{i.formData.append(r,l.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=Ys.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),bn.set(this.host,[])},this.handleInteraction=i=>{const s=bn.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()}},(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),bn.set(this.host,[]),this.options.assumeInteractionOn.forEach(e=>{this.host.addEventListener(e,this.handleInteraction)})}hostDisconnected(){this.detachForm(),bn.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,Ys.has(this.form)?Ys.get(this.form).add(this.host):Ys.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=Ys.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?Uo.add(t):Uo.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=!!Uo.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 po=Object.freeze({badInput:!1,customError:!1,patternMismatch:!1,rangeOverflow:!1,rangeUnderflow:!1,stepMismatch:!1,tooLong:!1,tooShort:!1,typeMismatch:!1,valid:!0,valueMissing:!1}),Xm=Object.freeze({...po,valid:!1,valueMissing:!1}),Km=Object.freeze({...po,valid:!1,customError:!0});/**
1391
1451
  * @license
1392
1452
  * Copyright 2018 Google LLC
1393
1453
  * SPDX-License-Identifier: BSD-3-Clause
1394
- */const mi=n=>n??Ko,Ng=vt`
1454
+ */const Ci=n=>n??Tt,qm=at`
1395
1455
  :host {
1396
1456
  --track-width: 2px;
1397
1457
  --track-color: rgb(128 128 128 / 25%);
@@ -1448,19 +1508,19 @@ good aklsdfja`,this.alignment="left",this.fontFamily="Arial",this.color="#000",t
1448
1508
  stroke-dasharray: 0.05em, 3em;
1449
1509
  }
1450
1510
  }
1451
- `;var zg=Object.getOwnPropertyDescriptor,Vg=(n,t,e,i)=>{for(var r=i>1?void 0:i?zg(t,e):t,s=n.length-1,o;s>=0;s--)(o=n[s])&&(r=o(r)||r);return r};let Qr=class extends Bt{render(){return X`
1511
+ `;var Zm=Object.getOwnPropertyDescriptor,Jm=(n,t,e,i)=>{for(var s=i>1?void 0:i?Zm(t,e):t,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=o(s)||s);return s};let vr=class extends It{render(){return W`
1452
1512
  <svg part="base" class="spinner" role="progressbar" aria-label="loading">
1453
1513
  <circle class="spinner__track"></circle>
1454
1514
  <circle class="spinner__indicator"></circle>
1455
1515
  </svg>
1456
- `}};Qr.styles=[Pt,Ng];Qr=Vg([Ot("pbo-spinner")],Qr);var Hg=Object.defineProperty,$g=Object.getOwnPropertyDescriptor,Xt=(n,t,e,i)=>{for(var r=i>1?void 0:i?$g(t,e):t,s=n.length-1,o;s>=0;s--)(o=n[s])&&(r=(i?o(t,e,r):o(r))||r);return i&&r&&Hg(t,e,r),r};let St=class extends Bt{constructor(){super(...arguments),this.formControlController=new xa(this,{assumeInteractionOn:["click"]}),this.hasSlotController=new Ki(this,"[prefix]","prefix","suffix"),this.disabled=!1,this.href="",this.name="",this.value="",this.variant="default",this.outline=!1,this.size="medium",this.circle=!1,this.type="button",this.colorBlock=!1,this.loading=!1,this.isIconButton=!1,this.hasFocus=!1}get validity(){return this.isButton()?this.button.validity:Vn}get validationMessage(){return this.isButton()?this.button.validationMessage:""}handleBlur(){this.hasFocus=!1,this.emit("pbo-blur")}handleFocus(){this.hasFocus=!0,this.emit("pbo-focus")}handleInvalid(){}handleClick(){this.type==="submit"&&this.formControlController.submit(this),this.type==="reset"&&this.formControlController.reset(this)}isButton(){return!this.href}isLink(){return!!this.href}doAction(t,e){}click(){this.button.click()}focus(){this.button.focus()}blur(){this.button.blur()}checkValidity(){return this.isButton()?this.button.checkValidity():!0}getForm(){return this.formControlController.getForm()}reset(t){this.doAction("reset",t)}submit(t){this.doAction("submit",t)}render(){const t=this.isLink(),e=t?jl`a`:jl`button`;return Bl`
1516
+ `}};vr.styles=[wt,qm];vr=Jm([bt("pbo-spinner")],vr);var Qm=Object.defineProperty,tv=Object.getOwnPropertyDescriptor,qt=(n,t,e,i)=>{for(var s=i>1?void 0:i?tv(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&&Qm(t,e,s),s};let Ot=class extends It{constructor(){super(...arguments),this.formControlController=new Za(this,{assumeInteractionOn:["click"]}),this.hasSlotController=new os(this,"[prefix]","prefix","suffix"),this.disabled=!1,this.href="",this.name="",this.value="",this.variant="default",this.outline=!1,this.size="medium",this.circle=!1,this.type="button",this.colorBlock=!1,this.loading=!1,this.isIconButton=!1,this.hasFocus=!1}get validity(){return this.isButton()?this.button.validity:po}get validationMessage(){return this.isButton()?this.button.validationMessage:""}handleBlur(){this.hasFocus=!1,this.emit("pbo-blur")}handleFocus(){this.hasFocus=!0,this.emit("pbo-focus")}handleInvalid(){}handleClick(){this.type==="submit"&&this.formControlController.submit(this),this.type==="reset"&&this.formControlController.reset(this)}isButton(){return!this.href}isLink(){return!!this.href}doAction(t,e){}click(){this.button.click()}focus(){this.button.focus()}blur(){this.button.blur()}checkValidity(){return this.isButton()?this.button.checkValidity():!0}getForm(){return this.formControlController.getForm()}reset(t){this.doAction("reset",t)}submit(t){this.doAction("submit",t)}render(){const t=this.isLink(),e=t?wc`a`:wc`button`;return Sc`
1457
1517
  <${e}
1458
1518
  part="base"
1459
- class= ${ni({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--focused":this.hasFocus,"button--loading":this.loading,"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":this.disabled})}
1460
- ?disabled=${mi(t?void 0:this.disabled)}
1519
+ class= ${je({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--focused":this.hasFocus,"button--loading":this.loading,"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":this.disabled})}
1520
+ ?disabled=${Ci(t?void 0:this.disabled)}
1461
1521
  tabindex=${this.disabled?"-1":"0"}
1462
1522
  href="${this.href}"
1463
- name=${mi(t?void 0:this.name)}
1523
+ name=${Ci(t?void 0:this.name)}
1464
1524
  @blur=${this.handleBlur}
1465
1525
  @focus=${this.handleFocus}
1466
1526
  @invalid=${this.isButton()?this.handleInvalid:null}
@@ -1469,8 +1529,8 @@ good aklsdfja`,this.alignment="left",this.fontFamily="Arial",this.color="#000",t
1469
1529
  <slot name="prefix" part="prefix" class="button__prefix"></slot>
1470
1530
  <slot part="label" class="button__label"></slot>
1471
1531
  <slot name="suffix" part="suffix" class="button__suffix"></slot>
1472
- ${this.loading?Bl`<pbo-spinner part="spinner"></pbo-spinner>`:""}
1473
- </${e}>`}};St.styles=[Pt,xh];St.dependencies={"pbo-spinner":Qr};Xt([q(".button")],St.prototype,"button",2);Xt([q(".button--loading pbo-spinner")],St.prototype,"spinner",2);Xt([O({type:Boolean,reflect:!0})],St.prototype,"disabled",2);Xt([O()],St.prototype,"href",2);Xt([O()],St.prototype,"name",2);Xt([O()],St.prototype,"value",2);Xt([O({reflect:!0})],St.prototype,"variant",2);Xt([O({type:Boolean,reflect:!0})],St.prototype,"outline",2);Xt([O({reflect:!0})],St.prototype,"size",2);Xt([O({type:Boolean,reflect:!0})],St.prototype,"circle",2);Xt([O({reflect:!0})],St.prototype,"type",2);Xt([O({type:Boolean,reflect:!0,attribute:"color-block"})],St.prototype,"colorBlock",2);Xt([O({type:Boolean,reflect:!0})],St.prototype,"loading",2);Xt([$()],St.prototype,"isIconButton",2);Xt([$()],St.prototype,"hasFocus",2);St=Xt([Ot("pbo-button")],St);const mb=St,Wg=vt`
1532
+ ${this.loading?Sc`<pbo-spinner part="spinner"></pbo-spinner>`:""}
1533
+ </${e}>`}};Ot.styles=[wt,vu];Ot.dependencies={"pbo-spinner":vr};qt([q(".button")],Ot.prototype,"button",2);qt([q(".button--loading pbo-spinner")],Ot.prototype,"spinner",2);qt([T({type:Boolean,reflect:!0})],Ot.prototype,"disabled",2);qt([T()],Ot.prototype,"href",2);qt([T()],Ot.prototype,"name",2);qt([T()],Ot.prototype,"value",2);qt([T({reflect:!0})],Ot.prototype,"variant",2);qt([T({type:Boolean,reflect:!0})],Ot.prototype,"outline",2);qt([T({reflect:!0})],Ot.prototype,"size",2);qt([T({type:Boolean,reflect:!0})],Ot.prototype,"circle",2);qt([T({reflect:!0})],Ot.prototype,"type",2);qt([T({type:Boolean,reflect:!0,attribute:"color-block"})],Ot.prototype,"colorBlock",2);qt([T({type:Boolean,reflect:!0})],Ot.prototype,"loading",2);qt([V()],Ot.prototype,"isIconButton",2);qt([V()],Ot.prototype,"hasFocus",2);Ot=qt([bt("pbo-button")],Ot);const H_=Ot,ev=at`
1474
1534
  :host {
1475
1535
  display: inline-block;
1476
1536
  }
@@ -1479,10 +1539,10 @@ good aklsdfja`,this.alignment="left",this.fontFamily="Arial",this.color="#000",t
1479
1539
  /* display: flex; */
1480
1540
  /* flex-wrap: nowrap; */
1481
1541
  }
1482
- `;var Gg=Object.defineProperty,Ug=Object.getOwnPropertyDescriptor,Hn=(n,t,e,i)=>{for(var r=i>1?void 0:i?Ug(t,e):t,s=n.length-1,o;s>=0;s--)(o=n[s])&&(r=(i?o(t,e,r):o(r))||r);return i&&r&&Gg(t,e,r),r};let wi=class extends Bt{constructor(){super(...arguments),this.disableRole=!1,this.label=""}handleFocus(t){const e=Fr(t.target);e==null||e.toggleAttribute("data-pbo-button-group__button--focus",!0)}handleBlur(t){const e=Fr(t.target);e==null||e.toggleAttribute("data-pbo-button-group__button--focus",!1)}handleMouseOver(t){const e=Fr(t.target);e==null||e.toggleAttribute("data-pbo-button-group__button--hover",!0)}handleMouseOut(t){const e=Fr(t.target);e==null||e.toggleAttribute("data-pbo-button-group__button--hover",!1)}handleSlotChange(){const t=[...this.defaultSlot.assignedElements({flatten:!0})];t.forEach(e=>{const i=t.indexOf(e),r=Fr(e);r&&(r.toggleAttribute("data-pbo-button-group__button",!0),r.toggleAttribute("data-pbo-button-group__button--first",i===0),r.toggleAttribute("data-pbo-button-group__button--inner",i>0&&i<t.length-1),r.toggleAttribute("data-pbo-button-group__button--last",i===t.length-1),r.toggleAttribute("data-pbo-button-group__button--radio",r.tagName.toLowerCase()==="pbo-radio-button"))})}render(){return X`
1542
+ `;var iv=Object.defineProperty,sv=Object.getOwnPropertyDescriptor,fo=(n,t,e,i)=>{for(var s=i>1?void 0:i?sv(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&&iv(t,e,s),s};let Di=class extends It{constructor(){super(...arguments),this.disableRole=!1,this.label=""}handleFocus(t){const e=qs(t.target);e==null||e.toggleAttribute("data-pbo-button-group__button--focus",!0)}handleBlur(t){const e=qs(t.target);e==null||e.toggleAttribute("data-pbo-button-group__button--focus",!1)}handleMouseOver(t){const e=qs(t.target);e==null||e.toggleAttribute("data-pbo-button-group__button--hover",!0)}handleMouseOut(t){const e=qs(t.target);e==null||e.toggleAttribute("data-pbo-button-group__button--hover",!1)}handleSlotChange(){const t=[...this.defaultSlot.assignedElements({flatten:!0})];t.forEach(e=>{const i=t.indexOf(e),s=qs(e);s&&(s.toggleAttribute("data-pbo-button-group__button",!0),s.toggleAttribute("data-pbo-button-group__button--first",i===0),s.toggleAttribute("data-pbo-button-group__button--inner",i>0&&i<t.length-1),s.toggleAttribute("data-pbo-button-group__button--last",i===t.length-1),s.toggleAttribute("data-pbo-button-group__button--radio",s.tagName.toLowerCase()==="pbo-radio-button"))})}render(){return W`
1483
1543
  <div
1484
1544
  part="base"
1485
- class=${ni({"button-group":!0})}
1545
+ class=${je({"button-group":!0})}
1486
1546
  role="${this.disableRole?"presentation":"group"}"
1487
1547
  aria-label=${this.label}
1488
1548
  @focusout=${this.handleBlur}
@@ -1492,8 +1552,8 @@ good aklsdfja`,this.alignment="left",this.fontFamily="Arial",this.color="#000",t
1492
1552
  >
1493
1553
  <slot @slotchange=${this.handleSlotChange}></slot>
1494
1554
  </div>
1495
- `}};wi.styles=[Pt,Wg];Hn([q("slot")],wi.prototype,"defaultSlot",2);Hn([$()],wi.prototype,"disableRole",2);Hn([O()],wi.prototype,"label",2);wi=Hn([Ot("pbo-button-group")],wi);function Fr(n){const t="pbo-button, pbo-radio-button";return n.closest(t)??n.querySelector(t)}const bb=wi,Yg=vt`
1496
- ${xh}
1555
+ `}};Di.styles=[wt,ev];fo([q("slot")],Di.prototype,"defaultSlot",2);fo([V()],Di.prototype,"disableRole",2);fo([T()],Di.prototype,"label",2);Di=fo([bt("pbo-button-group")],Di);function qs(n){const t="pbo-button, pbo-radio-button";return n.closest(t)??n.querySelector(t)}const U_=Di,rv=at`
1556
+ ${vu}
1497
1557
 
1498
1558
  .button__prefix,
1499
1559
  .button__suffix,
@@ -1513,26 +1573,26 @@ good aklsdfja`,this.alignment="left",this.fontFamily="Arial",this.color="#000",t
1513
1573
  * @license
1514
1574
  * Copyright 2018 Google LLC
1515
1575
  * SPDX-License-Identifier: BSD-3-Clause
1516
- */const Ch="important",Xg=" !"+Ch,pe=qo(class extends Zo{constructor(n){var t;if(super(n),n.type!==Fi.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 r=t[i];if(r!=null){this.ft.add(i);const s=typeof r=="string"&&r.endsWith(Xg);i.includes("-")||s?e.setProperty(i,s?r.slice(0,-11):r,s?Ch:""):e[i]=r}}return Rr}});var Kg=Object.defineProperty,qg=Object.getOwnPropertyDescriptor,$e=(n,t,e,i)=>{for(var r=i>1?void 0:i?qg(t,e):t,s=n.length-1,o;s>=0;s--)(o=n[s])&&(r=(i?o(t,e,r):o(r))||r);return i&&r&&Kg(t,e,r),r};let fe=class extends Bt{constructor(){super(...arguments),this.hasSlotController=new Ki(this,"[prefix]","prefix","suffix"),this.checked=!1,this.disabled=!1,this.size="medium",this.circle=!1,this.iconOnly=!1,this.hasFocus=!1,this.handleClick=t=>{if(this.disabled){t.preventDefault(),t.stopPropagation();return}this.checked=!0}}connectedCallback(){super.connectedCallback(),this.setAttribute("role","presentation")}handleBlur(){this.hasFocus=!1,this.emit("pbo-blur")}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 X`
1576
+ */const _u="important",nv=" !"+_u,me=ho(class extends uo{constructor(n){var t;if(super(n),n.type!==xi.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(nv);i.includes("-")||r?e.setProperty(i,r?s.slice(0,-11):s,r?_u:""):e[i]=s}}return Ce}});var ov=Object.defineProperty,av=Object.getOwnPropertyDescriptor,Ke=(n,t,e,i)=>{for(var s=i>1?void 0:i?av(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&&ov(t,e,s),s};let ve=class extends It{constructor(){super(...arguments),this.hasSlotController=new os(this,"[prefix]","prefix","suffix"),this.checked=!1,this.disabled=!1,this.size="medium",this.circle=!1,this.iconOnly=!1,this.hasFocus=!1,this.handleClick=t=>{if(this.disabled){t.preventDefault(),t.stopPropagation();return}this.checked=!0}}connectedCallback(){super.connectedCallback(),this.setAttribute("role","presentation")}handleBlur(){this.hasFocus=!1,this.emit("pbo-blur")}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 W`
1517
1577
  <div part="base" role="presentation">
1518
1578
  <button
1519
1579
  part="${`button${this.checked?"button--checked":""}`}"
1520
1580
  role="radio"
1521
1581
  aria-checked="${this.checked}"
1522
- class=${ni({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,"button--icon":this.iconOnly})}
1582
+ class=${je({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,"button--icon":this.iconOnly})}
1523
1583
  type="button"
1524
- value=${mi(this.value)}
1584
+ value=${Ci(this.value)}
1525
1585
  @blur=${this.handleBlur}
1526
1586
  @click=${this.handleClick}
1527
1587
  @focus=${this.handleFocus}
1528
- style=${pe({backgroundColor:this.isColorString(this.value)?this.value:""})}
1588
+ style=${me({backgroundColor:this.isColorString(this.value)?this.value:""})}
1529
1589
  >
1530
1590
  <slot name="prefix" part="prefix" class="button__prefix"></slot>
1531
1591
  <slot part="label" class="button__label"></slot>
1532
1592
  <slot name="suffix" part="suffix" class="button__suffix"></slot>
1533
1593
  </button>
1534
1594
  </div>
1535
- `}};fe.styles=[Pt,Yg];$e([q(".button")],fe.prototype,"input",2);$e([q(".hidden-input")],fe.prototype,"hiddenInput",2);$e([O({type:Boolean,reflect:!0})],fe.prototype,"checked",2);$e([O()],fe.prototype,"value",2);$e([O({type:Boolean,reflect:!0})],fe.prototype,"disabled",2);$e([O({reflect:!0})],fe.prototype,"size",2);$e([O({type:Boolean,reflect:!0})],fe.prototype,"circle",2);$e([O({type:Boolean,reflect:!0,attribute:"icon-only"})],fe.prototype,"iconOnly",2);$e([$()],fe.prototype,"hasFocus",2);fe=$e([Ot("pbo-radio-button")],fe);const yb=fe,Zg=vt`
1595
+ `}};ve.styles=[wt,rv];Ke([q(".button")],ve.prototype,"input",2);Ke([q(".hidden-input")],ve.prototype,"hiddenInput",2);Ke([T({type:Boolean,reflect:!0})],ve.prototype,"checked",2);Ke([T()],ve.prototype,"value",2);Ke([T({type:Boolean,reflect:!0})],ve.prototype,"disabled",2);Ke([T({reflect:!0})],ve.prototype,"size",2);Ke([T({type:Boolean,reflect:!0})],ve.prototype,"circle",2);Ke([T({type:Boolean,reflect:!0,attribute:"icon-only"})],ve.prototype,"iconOnly",2);Ke([V()],ve.prototype,"hasFocus",2);ve=Ke([bt("pbo-radio-button")],ve);const G_=ve,lv=at`
1536
1596
  :host {
1537
1597
  display: block;
1538
1598
  }
@@ -1564,11 +1624,11 @@ good aklsdfja`,this.alignment="left",this.fontFamily="Arial",this.color="#000",t
1564
1624
  padding: 0.25rem;
1565
1625
  border-radius: 1rem;
1566
1626
  }
1567
- `;var Jg=Object.defineProperty,Qg=Object.getOwnPropertyDescriptor,Kt=(n,t,e,i)=>{for(var r=i>1?void 0:i?Qg(t,e):t,s=n.length-1,o;s>=0;s--)(o=n[s])&&(r=(i?o(t,e,r):o(r))||r);return i&&r&&Jg(t,e,r),r};let gt=class extends Bt{constructor(){super(...arguments),this.formControlController=new xa(this),this.hasSlotController=new Ki(this,"help-text","label"),this.customValidityMessage="",this._value="",this.hasButtonGroup=!0,this.errorMessage="",this.defaultValue="",this.required=!1,this.name="option",this.value="",this.helpText="",this.label="",this.iconGroup=!1,this.size="medium",this.disabled=!1,this.form=""}handleValueChange(){this.hasUpdated&&this.updateCheckedRadio()}get validity(){const t=this.required&&!this.value;return this.customValidityMessage!==""?Bg:t?Rg:Vn}get validationMessage(){const t=this.required&&!this.value;return this.customValidityMessage!==""?this.customValidityMessage:t?this.validationInput.validationMessage:""}connectedCallback(){super.connectedCallback(),this.defaultValue=this.value}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(),r=this.value;!e||e.disabled||(this.value=e.value,i.forEach(s=>s.checked=s===e),this.value!==r&&(this.emit("pbo-change"),this.emit("pbo-input")))}handleLabelClick(){this.focus()}handleKeyDown(t){}syncRadios(){if(customElements.get("pbo-radio")&&customElements.get("pbo-radio-button")){this.syncRadioElements();return}if(customElements.get("pbo-radio")){this.syncRadioElements();return}else customElements.whenDefined("pbo-radio").then(()=>{this.syncRadios()});if(customElements.get("pbo-radio-button")){this.syncRadioElements();return}else customElements.whenDefined("pbo-radio-button").then(()=>{this.syncRadios()})}async syncRadioElements(){var e;const t=this.getAllRadios();if(await Promise.all(t.map(async i=>{await i.updateComplete,i.checked=i.value===this.value})),this.hasButtonGroup=t.some(i=>i.tagName.toLowerCase()==="pbo-radio-button"),t.length>0&&!t.some(i=>i.checked))if(this.hasButtonGroup){const i=(e=t[0].shadowRoot)==null?void 0:e.querySelector("button");i&&i.setAttribute("tabindex","0")}else t[0].setAttribute("tabindex","0")}handleInvalid(t){this.formControlController.setValidity(!1),this.formControlController.emitInvalidEvent(t)}render(){const t=this.hasSlotController.test("label"),e=this.hasSlotController.test("help-text"),i=this.helpText?!0:!!e,r=this.label?!0:!!t;return X`
1627
+ `;var cv=Object.defineProperty,hv=Object.getOwnPropertyDescriptor,Zt=(n,t,e,i)=>{for(var s=i>1?void 0:i?hv(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&&cv(t,e,s),s};let mt=class extends It{constructor(){super(...arguments),this.formControlController=new Za(this),this.hasSlotController=new os(this,"help-text","label"),this.customValidityMessage="",this._value="",this.hasButtonGroup=!0,this.errorMessage="",this.defaultValue="",this.required=!1,this.name="option",this.value="",this.helpText="",this.label="",this.iconGroup=!1,this.size="medium",this.disabled=!1,this.form=""}handleValueChange(){this.hasUpdated&&this.updateCheckedRadio()}get validity(){const t=this.required&&!this.value;return this.customValidityMessage!==""?Km:t?Xm:po}get validationMessage(){const t=this.required&&!this.value;return this.customValidityMessage!==""?this.customValidityMessage:t?this.validationInput.validationMessage:""}connectedCallback(){super.connectedCallback(),this.defaultValue=this.value}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")))}handleLabelClick(){this.focus()}handleKeyDown(t){}syncRadios(){if(customElements.get("pbo-radio")&&customElements.get("pbo-radio-button")){this.syncRadioElements();return}if(customElements.get("pbo-radio")){this.syncRadioElements();return}else customElements.whenDefined("pbo-radio").then(()=>{this.syncRadios()});if(customElements.get("pbo-radio-button")){this.syncRadioElements();return}else customElements.whenDefined("pbo-radio-button").then(()=>{this.syncRadios()})}async syncRadioElements(){var e;const t=this.getAllRadios();if(await Promise.all(t.map(async i=>{await i.updateComplete,i.checked=i.value===this.value})),this.hasButtonGroup=t.some(i=>i.tagName.toLowerCase()==="pbo-radio-button"),t.length>0&&!t.some(i=>i.checked))if(this.hasButtonGroup){const i=(e=t[0].shadowRoot)==null?void 0:e.querySelector("button");i&&i.setAttribute("tabindex","0")}else t[0].setAttribute("tabindex","0")}handleInvalid(t){this.formControlController.setValidity(!1),this.formControlController.emitInvalidEvent(t)}render(){const t=this.hasSlotController.test("label"),e=this.hasSlotController.test("help-text"),i=this.helpText?!0:!!e,s=this.label?!0:!!t;return W`
1568
1628
  <fieldset
1569
1629
  role="radiogroup"
1570
1630
  part="form-control"
1571
- class=${ni({"form-control":!0,"form-control--small":this.size==="small","form-control--medium":this.size==="medium","form-control--large":this.size==="large","form-control--radio-group":!0,"form-control--has-label":r,"form-control--has-help-text":i,"radio-icon-group":this.iconGroup})}
1631
+ class=${je({"form-control":!0,"form-control--small":this.size==="small","form-control--medium":this.size==="medium","form-control--large":this.size==="large","form-control--radio-group":!0,"form-control--has-label":s,"form-control--has-help-text":i,"radio-icon-group":this.iconGroup})}
1572
1632
  role="radiogroup"
1573
1633
  aria-labelledby="label"
1574
1634
  aria-describedby="help-text"
@@ -1578,7 +1638,7 @@ good aklsdfja`,this.alignment="left",this.fontFamily="Arial",this.color="#000",t
1578
1638
  part="form-control-label"
1579
1639
  id="label"
1580
1640
  class="form-control__label"
1581
- aria-hidden=${r?"false":"true"}
1641
+ aria-hidden=${s?"false":"true"}
1582
1642
  @click=${this.handleLabelClick}
1583
1643
  >
1584
1644
  <slot name="label">${this.label}</slot>
@@ -1611,7 +1671,7 @@ good aklsdfja`,this.alignment="left",this.fontFamily="Arial",this.color="#000",t
1611
1671
  <slot name="help-text">${this.helpText}</slot>
1612
1672
  </div>
1613
1673
  </fieldset>
1614
- `}};gt.styles=[Pt,Zg,ps];gt.dependencies={"pbo-button-group":wi};Kt([q("slot:not([name])")],gt.prototype,"defaultSlot",2);Kt([q(".radio-group__validation-input")],gt.prototype,"validationInput",2);Kt([$()],gt.prototype,"hasButtonGroup",2);Kt([$()],gt.prototype,"errorMessage",2);Kt([$()],gt.prototype,"defaultValue",2);Kt([O({type:Boolean,reflect:!0})],gt.prototype,"required",2);Kt([O()],gt.prototype,"name",2);Kt([O({reflect:!0})],gt.prototype,"value",2);Kt([O({attribute:"help-text"})],gt.prototype,"helpText",2);Kt([O()],gt.prototype,"label",2);Kt([O({type:Boolean,reflect:!0,attribute:"icon-group"})],gt.prototype,"iconGroup",2);Kt([O()],gt.prototype,"size",2);Kt([O({type:Boolean,reflect:!0})],gt.prototype,"disabled",2);Kt([O({reflect:!0})],gt.prototype,"form",2);Kt([et("value")],gt.prototype,"handleValueChange",1);gt=Kt([Ot("pbo-radio-group")],gt);const wb=gt,tm=vt`
1674
+ `}};mt.styles=[wt,lv,Mr];mt.dependencies={"pbo-button-group":Di};Zt([q("slot:not([name])")],mt.prototype,"defaultSlot",2);Zt([q(".radio-group__validation-input")],mt.prototype,"validationInput",2);Zt([V()],mt.prototype,"hasButtonGroup",2);Zt([V()],mt.prototype,"errorMessage",2);Zt([V()],mt.prototype,"defaultValue",2);Zt([T({type:Boolean,reflect:!0})],mt.prototype,"required",2);Zt([T()],mt.prototype,"name",2);Zt([T({reflect:!0})],mt.prototype,"value",2);Zt([T({attribute:"help-text"})],mt.prototype,"helpText",2);Zt([T()],mt.prototype,"label",2);Zt([T({type:Boolean,reflect:!0,attribute:"icon-group"})],mt.prototype,"iconGroup",2);Zt([T()],mt.prototype,"size",2);Zt([T({type:Boolean,reflect:!0})],mt.prototype,"disabled",2);Zt([T({reflect:!0})],mt.prototype,"form",2);Zt([Q("value")],mt.prototype,"handleValueChange",1);mt=Zt([bt("pbo-radio-group")],mt);const X_=mt,uv=at`
1615
1675
  :host {
1616
1676
  display: block;
1617
1677
  position: relative;
@@ -1800,33 +1860,33 @@ good aklsdfja`,this.alignment="left",this.fontFamily="Arial",this.color="#000",t
1800
1860
  * @license
1801
1861
  * Copyright 2020 Google LLC
1802
1862
  * SPDX-License-Identifier: BSD-3-Clause
1803
- */const{I:em}=au,Nl=(n,t)=>(n==null?void 0:n._$litType$)!==void 0,im=n=>{var t;return((t=n==null?void 0:n._$litType$)==null?void 0:t.h)!=null},rm=n=>n.strings===void 0,zl=()=>document.createComment(""),Vl=(n,t,e)=>{var s;const i=n._$AA.parentNode,r=n._$AB;if(e===void 0){const o=i.insertBefore(zl(),r),a=i.insertBefore(zl(),r);e=new em(o,a,n,n.options)}else{const o=e._$AB.nextSibling,a=e._$AM,l=a!==n;if(l){let c;(s=e._$AQ)==null||s.call(e,n),e._$AM=n,e._$AP!==void 0&&(c=n._$AU)!==a._$AU&&e._$AP(c)}if(o!==r||l){let c=e._$AA;for(;c!==o;){const h=c.nextSibling;i.insertBefore(c,r),c=h}}}return e},sm={},Vo=(n,t=sm)=>n._$AH=t,Hl=n=>n._$AH,nm=n=>{n._$AR()};/**
1863
+ */const{I:dv}=_d,Tc=(n,t)=>(n==null?void 0:n._$litType$)!==void 0,pv=n=>{var t;return((t=n==null?void 0:n._$litType$)==null?void 0:t.h)!=null},fv=n=>n.strings===void 0,Ec=()=>document.createComment(""),Oc=(n,t,e)=>{var r;const i=n._$AA.parentNode,s=n._$AB;if(e===void 0){const o=i.insertBefore(Ec(),s),a=i.insertBefore(Ec(),s);e=new dv(o,a,n,n.options)}else{const o=e._$AB.nextSibling,a=e._$AM,l=a!==n;if(l){let c;(r=e._$AQ)==null||r.call(e,n),e._$AM=n,e._$AP!==void 0&&(c=n._$AU)!==a._$AU&&e._$AP(c)}if(o!==s||l){let c=e._$AA;for(;c!==o;){const h=c.nextSibling;i.insertBefore(c,s),c=h}}}return e},gv={},va=(n,t=gv)=>n._$AH=t,kc=n=>n._$AH,mv=n=>{n._$AR()};/**
1804
1864
  * @license
1805
1865
  * Copyright 2020 Google LLC
1806
1866
  * SPDX-License-Identifier: BSD-3-Clause
1807
- */const om=qo(class extends Zo{constructor(n){if(super(n),n.type!==Fi.PROPERTY&&n.type!==Fi.ATTRIBUTE&&n.type!==Fi.BOOLEAN_ATTRIBUTE)throw Error("The `live` directive is not allowed on child or event bindings");if(!rm(n))throw Error("`live` bindings can only contain a single expression")}render(n){return n}update(n,[t]){if(t===Rr||t===Ko)return t;const e=n.element,i=n.name;if(n.type===Fi.PROPERTY){if(t===e[i])return Rr}else if(n.type===Fi.BOOLEAN_ATTRIBUTE){if(!!t===e.hasAttribute(i))return Rr}else if(n.type===Fi.ATTRIBUTE&&e.getAttribute(i)===t+"")return Rr;return Vo(n),t}});var am=Object.defineProperty,lm=Object.getOwnPropertyDescriptor,Nt=(n,t,e,i)=>{for(var r=i>1?void 0:i?lm(t,e):t,s=n.length-1,o;s>=0;s--)(o=n[s])&&(r=(i?o(t,e,r):o(r))||r);return i&&r&&am(t,e,r),r};let _t=class extends Bt{constructor(){super(...arguments),this.formControlController=new xa(this,{assumeInteractionOn:["pbo-input"]}),this.hasSlotController=new Ki(this,"help-text"),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,this.helpText=""}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,r="preserve"){const s=e??this.input.selectionStart,o=i??this.input.selectionEnd;this.input.setRangeText(t,s,o,r),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(){const t=this.hasSlotController.test("help-text"),e=this.helpText?!0:!!t;return X` <div
1867
+ */const vv=ho(class extends uo{constructor(n){if(super(n),n.type!==xi.PROPERTY&&n.type!==xi.ATTRIBUTE&&n.type!==xi.BOOLEAN_ATTRIBUTE)throw Error("The `live` directive is not allowed on child or event bindings");if(!fv(n))throw Error("`live` bindings can only contain a single expression")}render(n){return n}update(n,[t]){if(t===Ce||t===Tt)return t;const e=n.element,i=n.name;if(n.type===xi.PROPERTY){if(t===e[i])return Ce}else if(n.type===xi.BOOLEAN_ATTRIBUTE){if(!!t===e.hasAttribute(i))return Ce}else if(n.type===xi.ATTRIBUTE&&e.getAttribute(i)===t+"")return Ce;return va(n),t}});var bv=Object.defineProperty,_v=Object.getOwnPropertyDescriptor,zt=(n,t,e,i)=>{for(var s=i>1?void 0:i?_v(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&&bv(t,e,s),s};let yt=class extends It{constructor(){super(...arguments),this.formControlController=new Za(this,{assumeInteractionOn:["pbo-input"]}),this.hasSlotController=new os(this,"help-text"),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,this.helpText=""}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(){const t=this.hasSlotController.test("help-text"),e=this.helpText?!0:!!t;return W` <div
1808
1868
  part="form-control"
1809
- class=${ni({"form-control":!0,"form-control--small":this.size==="small","form-control--medium":this.size==="medium","form-control--large":this.size==="large","form-control--has-help-text":e,invalid:!0})}
1869
+ class=${je({"form-control":!0,"form-control--small":this.size==="small","form-control--medium":this.size==="medium","form-control--large":this.size==="large","form-control--has-help-text":e,invalid:!0})}
1810
1870
  >
1811
1871
  <div part="form-control-input" class="form-control-input">
1812
1872
  <div
1813
1873
  part="base"
1814
- class=${ni({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"})}
1874
+ class=${je({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"})}
1815
1875
  >
1816
1876
  <textarea
1817
1877
  part="textarea"
1818
1878
  id="input"
1819
1879
  class="textarea__control"
1820
1880
  title=${this.title}
1821
- name=${mi(this.name)}
1822
- .value=${om(this.value)}
1881
+ name=${Ci(this.name)}
1882
+ .value=${vv(this.value)}
1823
1883
  ?disabled=${this.disabled}
1824
1884
  ?readonly=${this.readonly}
1825
1885
  ?required=${this.required}
1826
- placeholder=${mi(this.placeholder)}
1827
- rows=${mi(this.rows)}
1828
- minlength=${mi(this.minlength)}
1829
- maxlength=${mi(this.maxlength)}
1886
+ placeholder=${Ci(this.placeholder)}
1887
+ rows=${Ci(this.rows)}
1888
+ minlength=${Ci(this.minlength)}
1889
+ maxlength=${Ci(this.maxlength)}
1830
1890
  aria-describedby="help-text"
1831
1891
  @change=${this.handleChange}
1832
1892
  @input=${this.handleInput}
@@ -1846,7 +1906,7 @@ good aklsdfja`,this.alignment="left",this.fontFamily="Arial",this.color="#000",t
1846
1906
  >
1847
1907
  <slot name="help-text">${this.helpText}</slot>
1848
1908
  </div>
1849
- </div>`}};_t.styles=[Pt,tm,ps];Nt([q(".textarea__control")],_t.prototype,"input",2);Nt([q(".textarea__size-adjuster")],_t.prototype,"sizeAdjuster",2);Nt([$()],_t.prototype,"hasFocus",2);Nt([O()],_t.prototype,"name",2);Nt([O()],_t.prototype,"value",2);Nt([O({reflect:!0})],_t.prototype,"size",2);Nt([O({type:Boolean,reflect:!0})],_t.prototype,"filled",2);Nt([O()],_t.prototype,"placeholder",2);Nt([O({type:Number})],_t.prototype,"rows",2);Nt([O()],_t.prototype,"resize",2);Nt([O({type:Boolean,reflect:!0})],_t.prototype,"disabled",2);Nt([O({type:Boolean,reflect:!0})],_t.prototype,"readonly",2);Nt([O({reflect:!0})],_t.prototype,"form",2);Nt([O({type:Boolean,reflect:!0})],_t.prototype,"required",2);Nt([O({type:Number})],_t.prototype,"minlength",2);Nt([O({type:Number})],_t.prototype,"maxlength",2);Nt([O({attribute:"help-text"})],_t.prototype,"helpText",2);_t=Nt([Ot("pbo-textarea")],_t);const Sb=_t,cm=vt`
1909
+ </div>`}};yt.styles=[wt,uv,Mr];zt([q(".textarea__control")],yt.prototype,"input",2);zt([q(".textarea__size-adjuster")],yt.prototype,"sizeAdjuster",2);zt([V()],yt.prototype,"hasFocus",2);zt([T()],yt.prototype,"name",2);zt([T()],yt.prototype,"value",2);zt([T({reflect:!0})],yt.prototype,"size",2);zt([T({type:Boolean,reflect:!0})],yt.prototype,"filled",2);zt([T()],yt.prototype,"placeholder",2);zt([T({type:Number})],yt.prototype,"rows",2);zt([T()],yt.prototype,"resize",2);zt([T({type:Boolean,reflect:!0})],yt.prototype,"disabled",2);zt([T({type:Boolean,reflect:!0})],yt.prototype,"readonly",2);zt([T({reflect:!0})],yt.prototype,"form",2);zt([T({type:Boolean,reflect:!0})],yt.prototype,"required",2);zt([T({type:Number})],yt.prototype,"minlength",2);zt([T({type:Number})],yt.prototype,"maxlength",2);zt([T({attribute:"help-text"})],yt.prototype,"helpText",2);yt=zt([bt("pbo-textarea")],yt);const q_=yt,yv=at`
1850
1910
  :host {
1851
1911
  display: block;
1852
1912
  width: 100%;
@@ -1909,7 +1969,7 @@ good aklsdfja`,this.alignment="left",this.fontFamily="Arial",this.color="#000",t
1909
1969
  grid-column: 7 / 11;
1910
1970
  }
1911
1971
  }
1912
- `,hm=vt`
1972
+ `,xv=at`
1913
1973
  :host {
1914
1974
  display: block;
1915
1975
  }
@@ -1932,7 +1992,7 @@ good aklsdfja`,this.alignment="left",this.fontFamily="Arial",this.color="#000",t
1932
1992
  .cta-buttons pbo-button::part(base) {
1933
1993
  font-size: var(--pbo-font-size-medium);
1934
1994
  }
1935
- `,ar=()=>/Mobi|Android|iPhone|iPad|iPod/i.test(navigator.userAgent),jr=n=>n!=null,Sh=n=>Object.entries(n).reduce((t,[e,i])=>(i==null||(t[e]=i),t),{});var um=Object.defineProperty,dm=Object.getOwnPropertyDescriptor,zt=(n,t,e,i)=>{for(var r=i>1?void 0:i?dm(t,e):t,s=n.length-1,o;s>=0;s--)(o=n[s])&&(r=(i?o(t,e,r):o(r))||r);return i&&r&&um(t,e,r),r};let st=class extends Bt{constructor(){super(...arguments),this.resizeTimeout=null,this.cardInnerImageUrl="../../../public/Greeting Card from Pairbo.png",this.card=null,this.submitTypeForm=async t=>{console.error("submitTypingForm function not implemented",t)},this.loading=!1,this.disabled=!1,this.windowHeight=window.innerHeight,this.charsNum=0,this.ctaButtonState=st.CTA_STATES.primary,this.handleResize=()=>{this.resizeTimeout&&window.clearTimeout(this.resizeTimeout),this.resizeTimeout=window.setTimeout(()=>{this.windowHeight=window.innerHeight},50)}}isLoadingChanged(){this.ctaButtons.forEach(t=>{t.loading=this.loading})}disabledChanged(){this.greetingText.disabled=this.disabled,this.fontSelector.disabled=this.disabled,this.textColor.childNodes.forEach(t=>{t.disabled=this.disabled}),this.textAlignment.childNodes.forEach(t=>{t.disabled=this.disabled}),this.ctaButtons.forEach(t=>{t.disabled=this.disabled})}firstUpdated(){this.disabledChanged(),this.isLoadingChanged(),this.textArea.addEventListener("invalid",()=>{alert("Please add a message to continue")})}get formData(){var e,i,r,s,o,a,l,c;const t={pboCardId:((e=this.card)==null?void 0:e.pboId)||"Unknown",productId:(i=this.card)==null?void 0:i.productId,sku:(r=this.card)==null?void 0:r.sku,variantId:(s=this.card)==null?void 0:s.variantId,font:((o=this.fontSelector)==null?void 0:o.value)||"",text:((a=this.greetingText)==null?void 0:a.value)||"",color:((l=this.textColor)==null?void 0:l.value)||"",alignment:((c=this.textAlignment)==null?void 0:c.value)||""};return Sh(t)}handleFormChange(t){this.ctaButtonState=st.CTA_STATES.primary,this.emit("pbo-change",{detail:this.formData})}hostConnected(){this.addEventListener("pbo-change",this.handleFormChange)}hostDisconnected(){this.removeEventListener("pbo-change",this.handleFormChange)}submitFormHandler(t){var i;t.preventDefault();const e=(i=t.submitter)==null?void 0:i.name;if(this.ctaButtonState.type==="danger"){e==="skip"&&this.submitTypeForm(this.formData);return}if(this.greetingText.value===""||this.greetingText.value===null||this.greetingText.value===void 0){this.ctaButtonState=st.CTA_STATES.danger,this.greetingText.focus();return}this.submitTypeForm(this.formData)}connectedCallback(){super.connectedCallback(),window.addEventListener("resize",this.handleResize)}disconnectedCallback(){super.disconnectedCallback(),window.removeEventListener("resize",this.handleResize),this.resizeTimeout&&window.clearTimeout(this.resizeTimeout)}render(){const t=223-this.formData.text.length;return X`
1995
+ `,ys=()=>/Mobi|Android|iPhone|iPad|iPod/i.test(navigator.userAgent),Zs=n=>n!=null,yu=n=>Object.entries(n).reduce((t,[e,i])=>(i==null||(t[e]=i),t),{});var wv=Object.defineProperty,Cv=Object.getOwnPropertyDescriptor,Ht=(n,t,e,i)=>{for(var s=i>1?void 0:i?Cv(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&&wv(t,e,s),s};let rt=class extends It{constructor(){super(...arguments),this.resizeTimeout=null,this.cardInnerImageUrl="../../../public/Greeting Card from Pairbo.png",this.card=null,this.submitTypeForm=async t=>{console.error("submitTypingForm function not implemented",t)},this.loading=!1,this.disabled=!1,this.windowHeight=window.innerHeight,this.charsNum=0,this.ctaButtonState=rt.CTA_STATES.primary,this.handleResize=()=>{this.resizeTimeout&&window.clearTimeout(this.resizeTimeout),this.resizeTimeout=window.setTimeout(()=>{this.windowHeight=window.innerHeight},50)}}isLoadingChanged(){this.ctaButtons.forEach(t=>{t.loading=this.loading})}disabledChanged(){this.greetingText.disabled=this.disabled,this.fontSelector.disabled=this.disabled,this.textColor.childNodes.forEach(t=>{t.disabled=this.disabled}),this.textAlignment.childNodes.forEach(t=>{t.disabled=this.disabled}),this.ctaButtons.forEach(t=>{t.disabled=this.disabled})}firstUpdated(){this.disabledChanged(),this.isLoadingChanged(),this.textArea.addEventListener("invalid",()=>{alert("Please add a message to continue")})}get formData(){var e,i,s,r,o,a,l,c;const t={pboCardId:((e=this.card)==null?void 0:e.pboId)||"Unknown",productId:(i=this.card)==null?void 0:i.productId,sku:(s=this.card)==null?void 0:s.sku,variantId:(r=this.card)==null?void 0:r.variantId,font:((o=this.fontSelector)==null?void 0:o.value)||"",text:((a=this.greetingText)==null?void 0:a.value)||"",color:((l=this.textColor)==null?void 0:l.value)||"",alignment:((c=this.textAlignment)==null?void 0:c.value)||""};return yu(t)}handleFormChange(t){this.ctaButtonState=rt.CTA_STATES.primary,this.emit("pbo-change",{detail:this.formData})}hostConnected(){this.addEventListener("pbo-change",this.handleFormChange)}hostDisconnected(){this.removeEventListener("pbo-change",this.handleFormChange)}submitFormHandler(t){var i;t.preventDefault();const e=(i=t.submitter)==null?void 0:i.name;if(this.ctaButtonState.type==="danger"){e==="skip"&&this.submitTypeForm(this.formData);return}if(this.greetingText.value===""||this.greetingText.value===null||this.greetingText.value===void 0){this.ctaButtonState=rt.CTA_STATES.danger,this.greetingText.focus();return}this.submitTypeForm(this.formData)}connectedCallback(){super.connectedCallback(),window.addEventListener("resize",this.handleResize)}disconnectedCallback(){super.disconnectedCallback(),window.removeEventListener("resize",this.handleResize),this.resizeTimeout&&window.clearTimeout(this.resizeTimeout)}render(){const t=223-this.formData.text.length;return W`
1936
1996
  <form class="typing-form" @submit=${this.submitFormHandler}>
1937
1997
  <pbo-textarea
1938
1998
  class="greeting-text"
@@ -2024,14 +2084,14 @@ good aklsdfja`,this.alignment="left",this.fontFamily="Arial",this.color="#000",t
2024
2084
  >
2025
2085
  ${this.ctaButtonState.message}
2026
2086
  </pbo-button>
2027
- ${this.ctaButtonState.type==="danger"?X`<pbo-button name="skip" type="submit" variant="text" size="small" class="skip">Skip</pbo-button>`:""}
2087
+ ${this.ctaButtonState.type==="danger"?W`<pbo-button name="skip" type="submit" variant="text" size="small" class="skip">Skip</pbo-button>`:""}
2028
2088
  </div>
2029
2089
  </form>
2030
- `}};st.styles=[Pt,ps,hm];st.dependencies={"pbo-selector":ze,"pbo-textarea":_t,"pbo-color-radio-group":gt,"pbo-radio-group":gt,"pbo-radio-button":gt,"pbo-button":St};st.CTA_STATES={danger:{type:"danger",message:"Add a message to Continue"},primary:{type:"primary",message:"Save and Continue"}};zt([O({type:String,reflect:!0})],st.prototype,"cardInnerImageUrl",2);zt([O()],st.prototype,"card",2);zt([O()],st.prototype,"submitTypeForm",2);zt([O({type:Boolean,reflect:!0})],st.prototype,"loading",2);zt([O({type:Boolean,reflect:!0})],st.prototype,"disabled",2);zt([q(".greeting-text")],st.prototype,"greetingText",2);zt([q(".font-selector")],st.prototype,"fontSelector",2);zt([q(".text-color")],st.prototype,"textColor",2);zt([q(".text-alignment")],st.prototype,"textAlignment",2);zt([q(".typing-form")],st.prototype,"typingForm",2);zt([q("pbo-textarea")],st.prototype,"textArea",2);zt([Jo(".cta-buttons pbo-button")],st.prototype,"ctaButtons",2);zt([$()],st.prototype,"windowHeight",2);zt([$()],st.prototype,"charsNum",2);zt([$()],st.prototype,"ctaButtonState",2);zt([et("loading",{waitUntilFirstUpdate:!0})],st.prototype,"isLoadingChanged",1);zt([et("disabled",{waitUntilFirstUpdate:!0})],st.prototype,"disabledChanged",1);st=zt([Ot("pbo-type-form")],st);/**
2090
+ `}};rt.styles=[wt,Mr,xv];rt.dependencies={"pbo-selector":We,"pbo-textarea":yt,"pbo-color-radio-group":mt,"pbo-radio-group":mt,"pbo-radio-button":mt,"pbo-button":Ot};rt.CTA_STATES={danger:{type:"danger",message:"Add a message to Continue"},primary:{type:"primary",message:"Save and Continue"}};Ht([T({type:String,reflect:!0})],rt.prototype,"cardInnerImageUrl",2);Ht([T()],rt.prototype,"card",2);Ht([T()],rt.prototype,"submitTypeForm",2);Ht([T({type:Boolean,reflect:!0})],rt.prototype,"loading",2);Ht([T({type:Boolean,reflect:!0})],rt.prototype,"disabled",2);Ht([q(".greeting-text")],rt.prototype,"greetingText",2);Ht([q(".font-selector")],rt.prototype,"fontSelector",2);Ht([q(".text-color")],rt.prototype,"textColor",2);Ht([q(".text-alignment")],rt.prototype,"textAlignment",2);Ht([q(".typing-form")],rt.prototype,"typingForm",2);Ht([q("pbo-textarea")],rt.prototype,"textArea",2);Ht([ka(".cta-buttons pbo-button")],rt.prototype,"ctaButtons",2);Ht([V()],rt.prototype,"windowHeight",2);Ht([V()],rt.prototype,"charsNum",2);Ht([V()],rt.prototype,"ctaButtonState",2);Ht([Q("loading",{waitUntilFirstUpdate:!0})],rt.prototype,"isLoadingChanged",1);Ht([Q("disabled",{waitUntilFirstUpdate:!0})],rt.prototype,"disabledChanged",1);rt=Ht([bt("pbo-type-form")],rt);/**
2031
2091
  * @license
2032
2092
  * Copyright 2017 Google LLC
2033
2093
  * SPDX-License-Identifier: BSD-3-Clause
2034
- */const $l=n=>im(n)?n._$litType$.h:n.strings,mo=qo(class extends Zo{constructor(n){super(n),this.et=new WeakMap}render(n){return[n]}update(n,[t]){const e=Nl(this.it)?$l(this.it):null,i=Nl(t)?$l(t):null;if(e!==null&&(i===null||e!==i)){const r=Hl(n).pop();let s=this.et.get(e);if(s===void 0){const o=document.createDocumentFragment();s=lu(Ko,o),s.setConnected(!1),this.et.set(e,s)}Vo(s,[r]),Vl(s,void 0,r)}if(i!==null){if(e===null||e!==i){const r=this.et.get(i);if(r!==void 0){const s=Hl(r).pop();nm(n),Vl(n,void 0,s),Vo(n,[s])}}this.it=t}else this.it=void 0;return this.render(t)}}),pm=vt`
2094
+ */const Ac=n=>pv(n)?n._$litType$.h:n.strings,Wo=ho(class extends uo{constructor(n){super(n),this.et=new WeakMap}render(n){return[n]}update(n,[t]){const e=Tc(this.it)?Ac(this.it):null,i=Tc(t)?Ac(t):null;if(e!==null&&(i===null||e!==i)){const s=kc(n).pop();let r=this.et.get(e);if(r===void 0){const o=document.createDocumentFragment();r=Jc(Tt,o),r.setConnected(!1),this.et.set(e,r)}va(r,[s]),Oc(r,void 0,s)}if(i!==null){if(e===null||e!==i){const s=this.et.get(i);if(s!==void 0){const r=kc(s).pop();mv(n),Oc(n,void 0,r),va(n,[r])}}this.it=t}else this.it=void 0;return this.render(t)}}),Sv=at`
2035
2095
  :host {
2036
2096
  display: block;
2037
2097
  width: 100%;
@@ -2134,7 +2194,7 @@ good aklsdfja`,this.alignment="left",this.fontFamily="Arial",this.color="#000",t
2134
2194
  width: 100%;
2135
2195
  height: auto;
2136
2196
  }
2137
- `,Th=".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}",fm=vt`
2197
+ `,xu=".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}",Tv=at`
2138
2198
  :host,
2139
2199
  :host * {
2140
2200
  max-height: 100%;
@@ -2182,29 +2242,29 @@ good aklsdfja`,this.alignment="left",this.fontFamily="Arial",this.color="#000",t
2182
2242
  background-color: #f3f3f3;
2183
2243
  }
2184
2244
  }
2185
- `;var gm=Object.defineProperty,mm=Object.getOwnPropertyDescriptor,pi=(n,t,e,i)=>{for(var r=i>1?void 0:i?mm(t,e):t,s=n.length-1,o;s>=0;s--)(o=n[s])&&(r=(i?o(t,e,r):o(r))||r);return i&&r&&gm(t,e,r),r};let ge=class extends Bt{constructor(){super(...arguments),this.skeletonHeight="2000px",this.skeletonWidth="1429px",this.src="",this.alt="",this.placeholder="",this.loaded=!1}handleSrcChange(){this.loaded=!1}handleError(){this.loaded=!0,this.placeholder&&(this.src=this.placeholder)}handleOnLoad(){this.loaded=!0}firstUpdated(){this.imgEl.onload=()=>this.handleOnLoad()}render(){return X`
2186
- ${this.loaded?"":X` <div class="skeleton"></div>`}
2245
+ `;var Ev=Object.defineProperty,Ov=Object.getOwnPropertyDescriptor,bi=(n,t,e,i)=>{for(var s=i>1?void 0:i?Ov(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&&Ev(t,e,s),s};let be=class extends It{constructor(){super(...arguments),this.skeletonHeight="2000px",this.skeletonWidth="1429px",this.src="",this.alt="",this.placeholder="",this.loaded=!1}handleSrcChange(){this.loaded=!1}handleError(){this.loaded=!0,this.placeholder&&(this.src=this.placeholder)}handleOnLoad(){this.loaded=!0}firstUpdated(){this.imgEl.onload=()=>this.handleOnLoad()}render(){return W`
2246
+ ${this.loaded?"":W` <div class="skeleton"></div>`}
2187
2247
  <img
2188
2248
  src=${this.src}
2189
2249
  alt=${this.alt}
2190
- class=${ni({loaded:this.loaded,hidden:!this.loaded})}
2250
+ class=${je({loaded:this.loaded,hidden:!this.loaded})}
2191
2251
  @error=${()=>this.handleError()}
2192
2252
  />
2193
- `}};ge.styles=[Pt,fm];pi([O()],ge.prototype,"skeletonHeight",2);pi([O()],ge.prototype,"skeletonWidth",2);pi([O()],ge.prototype,"src",2);pi([O()],ge.prototype,"alt",2);pi([O()],ge.prototype,"placeholder",2);pi([$()],ge.prototype,"loaded",2);pi([q("img")],ge.prototype,"imgEl",2);pi([et("src")],ge.prototype,"handleSrcChange",1);ge=pi([Ot("pbo-image")],ge);var vm=Object.defineProperty,bm=Object.getOwnPropertyDescriptor,qt=(n,t,e,i)=>{for(var r=i>1?void 0:i?bm(t,e):t,s=n.length-1,o;s>=0;s--)(o=n[s])&&(r=(i?o(t,e,r):o(r))||r);return i&&r&&vm(t,e,r),r};let Tt=class extends Bt{constructor(){super(...arguments),this.card=null,this.focusIndex=0,this.livePreviewProps={font:"Monsieur La Doulaise",text:"",color:"rgb(0,0,0)",alignment:"left"},this.handwrittenPreviewProps={isLoading:!1,processedFileUrl:null},this.type="type",this.mainImageTemplates=[],this.closeZoomedPreview=()=>{this.zoomedPreview&&(this.zoomedPreview.open=!1)},this.openZoomedPreview=()=>{this.zoomedPreview&&(this.zoomedPreview.open=!0)},this.handleOpenZoomedClick=t=>{if(!ar()){t.preventDefault(),t.stopPropagation();return}this.openZoomedPreview()}}firstUpdated(){this.addEventListener("handwritten-image-dimensions-changed",e=>{var o,a;const{detail:i}=e,r=(o=this.shadowRoot)==null?void 0:o.querySelector("#handwritten-main-canvas"),s=(a=this.shadowRoot)==null?void 0:a.querySelector("#handwritten-zoomed-preview-canvas");r&&s&&(r.imageWidth=i.width,r.imageHeight=i.height,r.imageTop=i.top,r.imageLeft=i.left,s.imageWidth=i.width,s.imageHeight=i.height,s.imageTop=i.top,s.imageLeft=i.left)}),this.updateComplete,this.thumbnailElements[this.focusIndex].classList.add("active"),this.mainSlideElements[this.focusIndex].classList.add("active");const t=(e,i)=>{e.addEventListener("click",()=>{this.focusOn(i)})};for(let e=0;e<this.thumbnailElements.length;e++)t(this.thumbnailElements[e],e)}handleCardChange(t,e){var i,r,s,o;e&&(this.mainImageTemplates=[X`<pbo-image src="${e.medias.cover.url||"https://picsum.photos/id/1/300/400"}" alt="" />`,X`<pbo-type-canvas
2253
+ `}};be.styles=[wt,Tv];bi([T()],be.prototype,"skeletonHeight",2);bi([T()],be.prototype,"skeletonWidth",2);bi([T()],be.prototype,"src",2);bi([T()],be.prototype,"alt",2);bi([T()],be.prototype,"placeholder",2);bi([V()],be.prototype,"loaded",2);bi([q("img")],be.prototype,"imgEl",2);bi([Q("src")],be.prototype,"handleSrcChange",1);be=bi([bt("pbo-image")],be);var kv=Object.defineProperty,Av=Object.getOwnPropertyDescriptor,Jt=(n,t,e,i)=>{for(var s=i>1?void 0:i?Av(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&&kv(t,e,s),s};let kt=class extends It{constructor(){super(...arguments),this.card=null,this.focusIndex=0,this.livePreviewProps={font:"Monsieur La Doulaise",text:"",color:"rgb(0,0,0)",alignment:"left"},this.handwrittenPreviewProps={isLoading:!1,processedFileUrl:null},this.type="type",this.mainImageTemplates=[],this.closeZoomedPreview=()=>{this.zoomedPreview&&(this.zoomedPreview.open=!1)},this.openZoomedPreview=()=>{this.zoomedPreview&&(this.zoomedPreview.open=!0)},this.handleOpenZoomedClick=t=>{if(!ys()){t.preventDefault(),t.stopPropagation();return}this.openZoomedPreview()}}firstUpdated(){this.addEventListener("handwritten-image-dimensions-changed",e=>{var o,a;const{detail:i}=e,s=(o=this.shadowRoot)==null?void 0:o.querySelector("#handwritten-main-canvas"),r=(a=this.shadowRoot)==null?void 0:a.querySelector("#handwritten-zoomed-preview-canvas");s&&r&&(s.imageWidth=i.width,s.imageHeight=i.height,s.imageTop=i.top,s.imageLeft=i.left,r.imageWidth=i.width,r.imageHeight=i.height,r.imageTop=i.top,r.imageLeft=i.left)}),this.updateComplete,this.thumbnailElements[this.focusIndex].classList.add("active"),this.mainSlideElements[this.focusIndex].classList.add("active");const t=(e,i)=>{e.addEventListener("click",()=>{this.focusOn(i)})};for(let e=0;e<this.thumbnailElements.length;e++)t(this.thumbnailElements[e],e)}handleCardChange(t,e){var i,s,r,o;e&&(this.mainImageTemplates=[W`<pbo-image src="${e.medias.cover.url||"https://picsum.photos/id/1/300/400"}" alt="" />`,W`<pbo-type-canvas
2194
2254
  background-url=${e.medias.insert.url}
2195
2255
  message=${(i=this.livePreviewProps)==null?void 0:i.text}
2196
- alignment=${((r=this.livePreviewProps)==null?void 0:r.alignment)||"left"}
2197
- color=${(s=this.livePreviewProps)==null?void 0:s.color}
2256
+ alignment=${((s=this.livePreviewProps)==null?void 0:s.alignment)||"left"}
2257
+ color=${(r=this.livePreviewProps)==null?void 0:r.color}
2198
2258
  font=${(o=this.livePreviewProps)==null?void 0:o.font}
2199
2259
  @click="${this.handleOpenZoomedClick}"
2200
- ></pbo-type-canvas>`,X`<pbo-image src="${e.medias.rendered_2.url||"https://picsum.photos/id/10/300/400"}" alt="" />`])}handleFocusIndexChange(t,e){var i,r,s,o;this.thumbnailElements.length!==0&&t!==e&&((i=this.thumbnailElements[t])==null||i.classList.remove("active"),(r=this.thumbnailElements[e])==null||r.classList.add("active"),(s=this.mainSlideElements[t])==null||s.classList.remove("active"),(o=this.mainSlideElements[e])==null||o.classList.add("active"),this.requestUpdate())}focusOn(t){if(t<0||t>=this.thumbnailElements.length){console.warn("Invalid index:",t);return}this.focusIndex=t}get mainSlides(){return this.card?[X`<pbo-image src="${this.card.medias.cover.url}" alt="" />`,X`<pbo-type-canvas
2260
+ ></pbo-type-canvas>`,W`<pbo-image src="${e.medias.rendered_2.url||"https://picsum.photos/id/10/300/400"}" alt="" />`])}handleFocusIndexChange(t,e){var i,s,r,o;this.thumbnailElements.length!==0&&t!==e&&((i=this.thumbnailElements[t])==null||i.classList.remove("active"),(s=this.thumbnailElements[e])==null||s.classList.add("active"),(r=this.mainSlideElements[t])==null||r.classList.remove("active"),(o=this.mainSlideElements[e])==null||o.classList.add("active"),this.requestUpdate())}focusOn(t){if(t<0||t>=this.thumbnailElements.length){console.warn("Invalid index:",t);return}this.focusIndex=t}get mainSlides(){return this.card?[W`<pbo-image src="${this.card.medias.cover.url}" alt="" />`,W`<pbo-type-canvas
2201
2261
  background-url=${this.card.medias.insert.url}
2202
2262
  message=${this.livePreviewProps.text}
2203
2263
  alignment=${this.livePreviewProps.alignment}
2204
2264
  color=${this.livePreviewProps.color}
2205
2265
  font=${this.livePreviewProps.font}
2206
2266
  @click="${this.handleOpenZoomedClick}"
2207
- ></pbo-type-canvas>`,X`<img src="${this.card.medias.rendered_2.url}" alt="" />`][this.focusIndex]:[]}render(){var t,e,i,r,s,o,a,l,c,h,u,d,p,f,g,m,v,y,x,T;return X`
2267
+ ></pbo-type-canvas>`,W`<img src="${this.card.medias.rendered_2.url}" alt="" />`][this.focusIndex]:[]}render(){var t,e,i,s,r,o,a,l,c,h,u,d,p,f,g,m,v,y,x,E;return W`
2208
2268
  <div class="card--slider--wrapper">
2209
2269
  <div id="thumbnails" class="thumbnails">
2210
2270
  <div class="thumbnail">
@@ -2221,8 +2281,8 @@ good aklsdfja`,this.alignment="left",this.fontFamily="Arial",this.color="#000",t
2221
2281
  <div class="main-slide-container">
2222
2282
  <div>
2223
2283
  <div class="main-slide" @click="${this.handleOpenZoomedClick}">
2224
- <pbo-image src="${((r=this.card)==null?void 0:r.medias.cover.url)||"https://picsum.photos/id/1/300/400"}" alt="" />
2225
- ${ar()?X`<div class="zoomed-preview-open-button" @click="${this.handleOpenZoomedClick}">
2284
+ <pbo-image src="${((s=this.card)==null?void 0:s.medias.cover.url)||"https://picsum.photos/id/1/300/400"}" alt="" />
2285
+ ${ys()?W`<div class="zoomed-preview-open-button" @click="${this.handleOpenZoomedClick}">
2226
2286
  <svg
2227
2287
  stroke="currentColor"
2228
2288
  fill="none"
@@ -2243,20 +2303,20 @@ good aklsdfja`,this.alignment="left",this.fontFamily="Arial",this.color="#000",t
2243
2303
  </div>`:""}
2244
2304
  </div>
2245
2305
  <div class="main-slide" @click="${this.handleOpenZoomedClick}">
2246
- ${mo(this.type==="type"?X`<pbo-type-canvas
2247
- background-url=${(s=this.card)==null?void 0:s.medias.insert.url}
2306
+ ${Wo(this.type==="type"?W`<pbo-type-canvas
2307
+ background-url=${(r=this.card)==null?void 0:r.medias.insert.url}
2248
2308
  message=${(o=this.livePreviewProps)==null?void 0:o.text}
2249
2309
  alignment=${((a=this.livePreviewProps)==null?void 0:a.alignment)||"left"}
2250
2310
  color=${(l=this.livePreviewProps)==null?void 0:l.color}
2251
2311
  font=${(c=this.livePreviewProps)==null?void 0:c.font}
2252
2312
  @click="${this.handleOpenZoomedClick}"
2253
- ></pbo-type-canvas>`:X`<pbo-handwritten-canvas
2313
+ ></pbo-type-canvas>`:W`<pbo-handwritten-canvas
2254
2314
  id="handwritten-main-canvas"
2255
2315
  background-url=${(h=this.card)==null?void 0:h.medias.insert.url}
2256
2316
  handwritten-url=${this.handwrittenPreviewProps.processedFileUrl}
2257
2317
  @click="${this.handleOpenZoomedClick}"
2258
2318
  ></pbo-handwritten-canvas>`)}
2259
- ${ar()?X`<div class="zoomed-preview-open-button">
2319
+ ${ys()?W`<div class="zoomed-preview-open-button">
2260
2320
  <svg
2261
2321
  stroke="currentColor"
2262
2322
  fill="none"
@@ -2278,7 +2338,7 @@ good aklsdfja`,this.alignment="left",this.fontFamily="Arial",this.color="#000",t
2278
2338
  </div>
2279
2339
  <div class="main-slide" @click=${this.handleOpenZoomedClick}>
2280
2340
  <pbo-image src="${((u=this.card)==null?void 0:u.medias.rendered_2.url)||"https://picsum.photos/id/10/300/400"}" alt="" />
2281
- ${ar()?X`<div class="zoomed-preview-open-button" @click="${this.handleOpenZoomedClick}">
2341
+ ${ys()?W`<div class="zoomed-preview-open-button" @click="${this.handleOpenZoomedClick}">
2282
2342
  <svg
2283
2343
  stroke="currentColor"
2284
2344
  fill="none"
@@ -2303,7 +2363,7 @@ good aklsdfja`,this.alignment="left",this.fontFamily="Arial",this.color="#000",t
2303
2363
  </div>
2304
2364
  <pbo-drawer
2305
2365
  placement="bottom"
2306
- style="${pe({"--size":"100%","--panel-background-color":"#454545ca"})}"
2366
+ style="${me({"--size":"100%","--panel-background-color":"#454545ca"})}"
2307
2367
  contained
2308
2368
  class="editor__zoomed"
2309
2369
  >
@@ -2315,32 +2375,32 @@ good aklsdfja`,this.alignment="left",this.fontFamily="Arial",this.color="#000",t
2315
2375
  <img
2316
2376
  src="${((p=this.card)==null?void 0:p.medias.cover.url)||"https://picsum.photos/id/1/300/400"}"
2317
2377
  alt=""
2318
- style=${pe({display:this.focusIndex===0?"block":"none"})}
2378
+ style=${me({display:this.focusIndex===0?"block":"none"})}
2319
2379
  />
2320
- ${mo(this.type==="type"?X`<pbo-type-canvas
2380
+ ${Wo(this.type==="type"?W`<pbo-type-canvas
2321
2381
  background-url=${(f=this.card)==null?void 0:f.medias.insert.url}
2322
2382
  message=${(g=this.livePreviewProps)==null?void 0:g.text}
2323
2383
  alignment=${((m=this.livePreviewProps)==null?void 0:m.alignment)||"left"}
2324
2384
  color=${(v=this.livePreviewProps)==null?void 0:v.color}
2325
2385
  font=${(y=this.livePreviewProps)==null?void 0:y.font}
2326
2386
  @click="${this.handleOpenZoomedClick}"
2327
- style=${pe({display:this.focusIndex===1?"block":"none"})}
2387
+ style=${me({display:this.focusIndex===1?"block":"none"})}
2328
2388
  ></pbo-type-canvas>`:"")}
2329
- ${mo(this.type==="handwritten"?X`<pbo-handwritten-canvas
2389
+ ${Wo(this.type==="handwritten"?W`<pbo-handwritten-canvas
2330
2390
  id="handwritten-zoomed-preview-canvas"
2331
2391
  background-url=${(x=this.card)==null?void 0:x.medias.insert.url}
2332
2392
  handwritten-url=${this.handwrittenPreviewProps.processedFileUrl}
2333
2393
  @click="${this.handleOpenZoomedClick}"
2334
- style=${pe({display:this.focusIndex===1?"block":"none"})}
2394
+ style=${me({display:this.focusIndex===1?"block":"none"})}
2335
2395
  ></pbo-handwritten-canvas>`:"")}
2336
2396
  <img
2337
- src="${((T=this.card)==null?void 0:T.medias.rendered_2.url)||"https://picsum.photos/id/10/300/400"}"
2397
+ src="${((E=this.card)==null?void 0:E.medias.rendered_2.url)||"https://picsum.photos/id/10/300/400"}"
2338
2398
  alt=""
2339
- style=${pe({display:this.focusIndex===2?"block":"none"})}
2399
+ style=${me({display:this.focusIndex===2?"block":"none"})}
2340
2400
  />
2341
2401
  </pbo-zoomed-preview>
2342
2402
  </pbo-drawer>
2343
- `}};Tt.styles=[Pt,pm,kn(Th)];Tt.dependencies={"fabric-example":ut,"pbo-image":ge};qt([O({type:Object})],Tt.prototype,"card",2);qt([O({type:Number,reflect:!0})],Tt.prototype,"focusIndex",2);qt([O({type:Object})],Tt.prototype,"livePreviewProps",2);qt([O()],Tt.prototype,"handwrittenPreviewProps",2);qt([O()],Tt.prototype,"type",2);qt([q("#thumbnails")],Tt.prototype,"thumbnailCarousel",2);qt([q("#main-carousel")],Tt.prototype,"mainCarousel",2);qt([q(".editor__zoomed")],Tt.prototype,"zoomedPreview",2);qt([q(".main-slide.active")],Tt.prototype,"activeMainSlide",2);qt([q("pbo-type-canvas")],Tt.prototype,"typeCanvas",2);qt([Jo(".thumbnail")],Tt.prototype,"thumbnailElements",2);qt([Jo(".main-slide")],Tt.prototype,"mainSlideElements",2);qt([$()],Tt.prototype,"mainImageTemplates",2);qt([et("card")],Tt.prototype,"handleCardChange",1);qt([et("focusIndex")],Tt.prototype,"handleFocusIndexChange",1);Tt=qt([Ot("pbo-editor-card-slider")],Tt);var _m=Object.defineProperty,ym=Object.getOwnPropertyDescriptor,te=(n,t,e,i)=>{for(var r=i>1?void 0:i?ym(t,e):t,s=n.length-1,o;s>=0;s--)(o=n[s])&&(r=(i?o(t,e,r):o(r))||r);return i&&r&&_m(t,e,r),r};let Ft=class extends Bt{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"},this.handwrittenFormState={isLoading:!1,processedFileUrl:""},this.editorType="type",this.handleTypingFormChange=()=>{this.formData=this.typeForm.formData,this.slider.focusOn(1)},this.handelHandwrittenFormChange=t=>{this.handwrittenFormState=t.detail,this.slider.focusOn(1)},this.openZoomedPreview=()=>{this.zoomedPreview&&(this.zoomedPreview.open=!0)},this.closeZoomedPreview=()=>{this.zoomedPreview&&(this.zoomedPreview.open=!1)},this.handleEditorChange=t=>{this.editorType=t.detail.value}}firstUpdated(){this.addEventListener("handwritten-image-dimensions-changed",t=>{this.handwrittenForm.setDimensions(t.detail)}),this.typeForm.addEventListener("pbo-change",this.handleTypingFormChange),this.handwrittenForm.addEventListener("pbo-change",this.handelHandwrittenFormChange),document.addEventListener("pbo-zoomed-preview-open",()=>{this.openZoomedPreview()})}handleCardInnerImageUrlChange(){this.requestUpdate()}handleCardChange(){this.card&&(this.slider.card=this.card,this.requestUpdate(),this.typeForm.card=this.card,this.handwrittenForm.card=this.card)}disconnectedCallback(){this.typeForm.removeEventListener("pbo-change",this.handleTypingFormChange),this.handwrittenForm.removeEventListener("pbo-change",this.handelHandwrittenFormChange)}render(){var t;return X`
2403
+ `}};kt.styles=[wt,Sv,Or(xu)];kt.dependencies={"fabric-example":dt,"pbo-image":be};Jt([T({type:Object})],kt.prototype,"card",2);Jt([T({type:Number,reflect:!0})],kt.prototype,"focusIndex",2);Jt([T({type:Object})],kt.prototype,"livePreviewProps",2);Jt([T()],kt.prototype,"handwrittenPreviewProps",2);Jt([T()],kt.prototype,"type",2);Jt([q("#thumbnails")],kt.prototype,"thumbnailCarousel",2);Jt([q("#main-carousel")],kt.prototype,"mainCarousel",2);Jt([q(".editor__zoomed")],kt.prototype,"zoomedPreview",2);Jt([q(".main-slide.active")],kt.prototype,"activeMainSlide",2);Jt([q("pbo-type-canvas")],kt.prototype,"typeCanvas",2);Jt([ka(".thumbnail")],kt.prototype,"thumbnailElements",2);Jt([ka(".main-slide")],kt.prototype,"mainSlideElements",2);Jt([V()],kt.prototype,"mainImageTemplates",2);Jt([Q("card")],kt.prototype,"handleCardChange",1);Jt([Q("focusIndex")],kt.prototype,"handleFocusIndexChange",1);kt=Jt([bt("pbo-editor-card-slider")],kt);var Pv=Object.defineProperty,Dv=Object.getOwnPropertyDescriptor,se=(n,t,e,i)=>{for(var s=i>1?void 0:i?Dv(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&&Pv(t,e,s),s};let Rt=class extends It{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"},this.handwrittenFormState={isLoading:!1,processedFileUrl:""},this.editorType="type",this.handleTypingFormChange=()=>{this.formData=this.typeForm.formData,this.slider.focusOn(1)},this.handelHandwrittenFormChange=t=>{this.handwrittenFormState=t.detail,this.slider.focusOn(1)},this.openZoomedPreview=()=>{this.zoomedPreview&&(this.zoomedPreview.open=!0)},this.closeZoomedPreview=()=>{this.zoomedPreview&&(this.zoomedPreview.open=!1)},this.handleEditorChange=t=>{this.editorType=t.detail.value}}firstUpdated(){this.addEventListener("handwritten-image-dimensions-changed",t=>{this.handwrittenForm.setDimensions(t.detail)}),this.typeForm.addEventListener("pbo-change",this.handleTypingFormChange),this.handwrittenForm.addEventListener("pbo-change",this.handelHandwrittenFormChange),document.addEventListener("pbo-zoomed-preview-open",()=>{this.openZoomedPreview()})}handleCardInnerImageUrlChange(){this.requestUpdate()}handleCardChange(){this.card&&(this.slider.card=this.card,this.requestUpdate(),this.typeForm.card=this.card,this.handwrittenForm.card=this.card)}disconnectedCallback(){this.typeForm.removeEventListener("pbo-change",this.handleTypingFormChange),this.handwrittenForm.removeEventListener("pbo-change",this.handelHandwrittenFormChange)}render(){var t;return W`
2344
2404
  <div class="editor">
2345
2405
  <div class="editor__card">
2346
2406
  <pbo-editor-card-slider
@@ -2355,10 +2415,10 @@ good aklsdfja`,this.alignment="left",this.fontFamily="Arial",this.color="#000",t
2355
2415
  <pbo-editor-selector @pbo-change=${this.handleEditorChange}></pbo-editor-selector>
2356
2416
  <pbo-type-form
2357
2417
  .submitTypeForm=${this.submitTypeForm}
2358
- style=${pe({display:this.editorType==="type"?"block":"none"})}
2418
+ style=${me({display:this.editorType==="type"?"block":"none"})}
2359
2419
  ></pbo-type-form>
2360
2420
  <pbo-handwritten-form
2361
- style=${pe({display:this.editorType==="handwritten"?"block":"none"})}
2421
+ style=${me({display:this.editorType==="handwritten"?"block":"none"})}
2362
2422
  .submitHandwrittenForm=${this.submitHandwrittenForm}
2363
2423
  .getProcessedImg=${this.getProcessedImg}
2364
2424
  ></pbo-handwritten-form>
@@ -2367,7 +2427,7 @@ good aklsdfja`,this.alignment="left",this.fontFamily="Arial",this.color="#000",t
2367
2427
 
2368
2428
  <pbo-drawer
2369
2429
  placement="bottom"
2370
- style="${pe({"--size":"100%","--panel-background-color":"#454545ca"})}"
2430
+ style="${me({"--size":"100%","--panel-background-color":"#454545ca"})}"
2371
2431
  contained
2372
2432
  class="editor__zoomed"
2373
2433
  >
@@ -2378,7 +2438,7 @@ good aklsdfja`,this.alignment="left",this.fontFamily="Arial",this.color="#000",t
2378
2438
  .close=${this.closeZoomedPreview}
2379
2439
  ></pbo-zoomed-preview>
2380
2440
  </pbo-drawer>
2381
- `}};Ft.styles=[Pt,cm];Ft.dependencies={"editor-card-slider":Tt,"fabric-example":ut,"pbo-type-form":st};te([O({type:String,reflect:!0})],Ft.prototype,"cardInnerImageUrl",2);te([O({type:Object})],Ft.prototype,"card",2);te([O()],Ft.prototype,"submitTypeForm",2);te([O()],Ft.prototype,"submitHandwrittenForm",2);te([O()],Ft.prototype,"getProcessedImg",2);te([q("pbo-type-form")],Ft.prototype,"typeForm",2);te([q("pbo-handwritten-form")],Ft.prototype,"handwrittenForm",2);te([q("pbo-editor-card-slider")],Ft.prototype,"slider",2);te([q(".editor__zoomed")],Ft.prototype,"zoomedPreview",2);te([$()],Ft.prototype,"formData",2);te([$()],Ft.prototype,"handwrittenFormState",2);te([$()],Ft.prototype,"editorType",2);te([et("cardInnerImageUrl")],Ft.prototype,"handleCardInnerImageUrlChange",1);te([et("card")],Ft.prototype,"handleCardChange",1);Ft=te([Ot("pbo-editor")],Ft);const Db=Ft,Pb=st,Ab=Tt,xm=vt`
2441
+ `}};Rt.styles=[wt,yv];Rt.dependencies={"editor-card-slider":kt,"fabric-example":dt,"pbo-type-form":rt};se([T({type:String,reflect:!0})],Rt.prototype,"cardInnerImageUrl",2);se([T({type:Object})],Rt.prototype,"card",2);se([T()],Rt.prototype,"submitTypeForm",2);se([T()],Rt.prototype,"submitHandwrittenForm",2);se([T()],Rt.prototype,"getProcessedImg",2);se([q("pbo-type-form")],Rt.prototype,"typeForm",2);se([q("pbo-handwritten-form")],Rt.prototype,"handwrittenForm",2);se([q("pbo-editor-card-slider")],Rt.prototype,"slider",2);se([q(".editor__zoomed")],Rt.prototype,"zoomedPreview",2);se([V()],Rt.prototype,"formData",2);se([V()],Rt.prototype,"handwrittenFormState",2);se([V()],Rt.prototype,"editorType",2);se([Q("cardInnerImageUrl")],Rt.prototype,"handleCardInnerImageUrlChange",1);se([Q("card")],Rt.prototype,"handleCardChange",1);Rt=se([bt("pbo-editor")],Rt);const e0=Rt,i0=rt,s0=kt,Mv=at`
2382
2442
  :host {
2383
2443
  display: block;
2384
2444
  }
@@ -2442,16 +2502,16 @@ good aklsdfja`,this.alignment="left",this.fontFamily="Arial",this.color="#000",t
2442
2502
  .splide__slide img:hover {
2443
2503
  transform: scale(1.1);
2444
2504
  }
2445
- `;function wm(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 Cm(n,t,e){return t&&wm(n.prototype,t),Object.defineProperty(n,"prototype",{writable:!1}),n}/*!
2505
+ `;function Iv(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 Lv(n,t,e){return t&&Iv(n.prototype,t),Object.defineProperty(n,"prototype",{writable:!1}),n}/*!
2446
2506
  * Splide.js
2447
2507
  * Version : 4.1.4
2448
2508
  * License : MIT
2449
2509
  * Copyright: 2022 Naotoshi Fujita
2450
- */var Wl="(prefers-reduced-motion: reduce)",lr=1,Sm=2,gr=3,Sr=4,fs=5,on=6,Sn=7,Tm={CREATED:lr,MOUNTED:Sm,IDLE:gr,MOVING:Sr,SCROLLING:fs,DRAGGING:on,DESTROYED:Sn};function ci(n){n.length=0}function Ai(n,t,e){return Array.prototype.slice.call(n,t,e)}function ot(n){return n.bind.apply(n,[null].concat(Ai(arguments,1)))}var Eh=setTimeout,Ho=function(){};function Gl(n){return requestAnimationFrame(n)}function $n(n,t){return typeof t===n}function ts(n){return!Ca(n)&&$n("object",n)}var wa=Array.isArray,Oh=ot($n,"function"),Ci=ot($n,"string"),gs=ot($n,"undefined");function Ca(n){return n===null}function kh(n){try{return n instanceof(n.ownerDocument.defaultView||window).HTMLElement}catch{return!1}}function ms(n){return wa(n)?n:[n]}function we(n,t){ms(n).forEach(t)}function Sa(n,t){return n.indexOf(t)>-1}function an(n,t){return n.push.apply(n,ms(t)),n}function ti(n,t,e){n&&we(t,function(i){i&&n.classList[e?"add":"remove"](i)})}function Ve(n,t){ti(n,Ci(t)?t.split(" "):t,!0)}function vs(n,t){we(t,n.appendChild.bind(n))}function Ta(n,t){we(n,function(e){var i=(t||e).parentNode;i&&i.insertBefore(e,t)})}function es(n,t){return kh(n)&&(n.msMatchesSelector||n.matches).call(n,t)}function Dh(n,t){var e=n?Ai(n.children):[];return t?e.filter(function(i){return es(i,t)}):e}function bs(n,t){return t?Dh(n,t)[0]:n.firstElementChild}var is=Object.keys;function $i(n,t,e){return n&&(e?is(n).reverse():is(n)).forEach(function(i){i!=="__proto__"&&t(n[i],i)}),n}function rs(n){return Ai(arguments,1).forEach(function(t){$i(t,function(e,i){n[i]=t[i]})}),n}function bi(n){return Ai(arguments,1).forEach(function(t){$i(t,function(e,i){wa(e)?n[i]=e.slice():ts(e)?n[i]=bi({},ts(n[i])?n[i]:{},e):n[i]=e})}),n}function Ul(n,t){we(t||is(n),function(e){delete n[e]})}function He(n,t){we(n,function(e){we(t,function(i){e&&e.removeAttribute(i)})})}function U(n,t,e){ts(t)?$i(t,function(i,r){U(n,r,i)}):we(n,function(i){Ca(e)||e===""?He(i,t):i.setAttribute(t,String(e))})}function dr(n,t,e){var i=document.createElement(n);return t&&(Ci(t)?Ve(i,t):U(i,t)),e&&vs(e,i),i}function Ee(n,t,e){if(gs(e))return getComputedStyle(n)[t];Ca(e)||(n.style[t]=""+e)}function ss(n,t){Ee(n,"display",t)}function Ph(n){n.setActive&&n.setActive()||n.focus({preventScroll:!0})}function De(n,t){return n.getAttribute(t)}function Yl(n,t){return n&&n.classList.contains(t)}function be(n){return n.getBoundingClientRect()}function Ui(n){we(n,function(t){t&&t.parentNode&&t.parentNode.removeChild(t)})}function Ah(n){return bs(new DOMParser().parseFromString(n,"text/html").body)}function qe(n,t){n.preventDefault(),t&&(n.stopPropagation(),n.stopImmediatePropagation())}function Mh(n,t){return n&&n.querySelector(t)}function Ea(n,t){return t?Ai(n.querySelectorAll(t)):[]}function ei(n,t){ti(n,t,!1)}function $o(n){return n.timeStamp}function Li(n){return Ci(n)?n:n?n+"px":""}var _s="splide",Oa="data-"+_s;function Gr(n,t){if(!n)throw new Error("["+_s+"] "+(t||""))}var Si=Math.min,Tn=Math.max,En=Math.floor,ns=Math.ceil,se=Math.abs;function Ih(n,t,e){return se(n-t)<e}function ln(n,t,e,i){var r=Si(t,e),s=Tn(t,e);return i?r<n&&n<s:r<=n&&n<=s}function er(n,t,e){var i=Si(t,e),r=Tn(t,e);return Si(Tn(i,n),r)}function Wo(n){return+(n>0)-+(n<0)}function Go(n,t){return we(t,function(e){n=n.replace("%s",""+e)}),n}function ka(n){return n<10?"0"+n:""+n}var Xl={};function Em(n){return""+n+ka(Xl[n]=(Xl[n]||0)+1)}function Lh(){var n=[];function t(o,a,l,c){r(o,a,function(h,u,d){var p="addEventListener"in h,f=p?h.removeEventListener.bind(h,u,l,c):h.removeListener.bind(h,l);p?h.addEventListener(u,l,c):h.addListener(l),n.push([h,u,d,l,f])})}function e(o,a,l){r(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 r(o,a,l){we(o,function(c){c&&we(a,function(h){h.split(" ").forEach(function(u){var d=u.split(".");l(c,d[0],d[1])})})})}function s(){n.forEach(function(o){o[4]()}),ci(n)}return{bind:t,unbind:e,dispatch:i,destroy:s}}var Zi="mounted",Kl="ready",Ti="move",ys="moved",Fh="click",Om="active",km="inactive",Dm="visible",Pm="hidden",Mt="refresh",ce="updated",os="resize",Da="resized",Am="drag",Mm="dragging",Im="dragged",Pa="scroll",Tr="scrolled",Lm="overflow",jh="destroy",Fm="arrows:mounted",jm="arrows:updated",Rm="pagination:mounted",Bm="pagination:updated",Rh="navigation:mounted",Bh="autoplay:play",Nm="autoplay:playing",Nh="autoplay:pause",zh="lazyload:loaded",Vh="sk",Hh="sh",On="ei";function mt(n){var t=n?n.event.bus:document.createDocumentFragment(),e=Lh();function i(s,o){e.bind(t,ms(s).join(" "),function(a){o.apply(o,wa(a.detail)?a.detail:[])})}function r(s){e.dispatch(t,s,Ai(arguments,1))}return n&&n.event.on(jh,e.destroy),rs(e,{bus:t,on:i,off:ot(e.unbind,t),emit:r})}function Wn(n,t,e,i){var r=Date.now,s,o=0,a,l=!0,c=0;function h(){if(!l){if(o=n?Si((r()-s)/n,1):1,e&&e(o),o>=1&&(t(),s=r(),i&&++c>=i))return d();a=Gl(h)}}function u(v){v||f(),s=r()-(v?o*n:0),l=!1,a=Gl(h)}function d(){l=!0}function p(){s=r(),o=0,e&&e(o)}function f(){a&&cancelAnimationFrame(a),o=0,a=0,l=!0}function g(v){n=v}function m(){return l}return{start:u,rewind:p,pause:d,cancel:f,set:g,isPaused:m}}function zm(n){var t=n;function e(r){t=r}function i(r){return Sa(ms(r),t)}return{set:e,is:i}}function Vm(n,t){var e=Wn(0,n,null,1);return function(){e.isPaused()&&e.start()}}function Hm(n,t,e){var i=n.state,r=e.breakpoints||{},s=e.reducedMotion||{},o=Lh(),a=[];function l(){var f=e.mediaQuery==="min";is(r).sort(function(g,m){return f?+g-+m:+m-+g}).forEach(function(g){h(r[g],"("+(f?"min":"max")+"-width:"+g+"px)")}),h(s,Wl),u()}function c(f){f&&o.destroy()}function h(f,g){var m=matchMedia(g);o.bind(m,"change",u),a.push([f,m])}function u(){var f=i.is(Sn),g=e.direction,m=a.reduce(function(v,y){return bi(v,y[1].matches?y[0]:{})},{});Ul(e),p(m),e.destroy?n.destroy(e.destroy==="completely"):f?(c(!0),n.mount()):g!==e.direction&&n.refresh()}function d(f){matchMedia(Wl).matches&&(f?bi(e,s):Ul(e,is(s)))}function p(f,g,m){bi(e,f),g&&bi(Object.getPrototypeOf(e),f),(m||!i.is(lr))&&n.emit(ce,e)}return{setup:l,destroy:c,reduce:d,set:p}}var Gn="Arrow",Un=Gn+"Left",Yn=Gn+"Right",$h=Gn+"Up",Wh=Gn+"Down",ql="rtl",Xn="ttb",vo={width:["height"],left:["top","right"],right:["bottom","left"],x:["y"],X:["Y"],Y:["X"],ArrowLeft:[$h,Yn],ArrowRight:[Wh,Un]};function $m(n,t,e){function i(s,o,a){a=a||e.direction;var l=a===ql&&!o?1:a===Xn?0:-1;return vo[s]&&vo[s][l]||s.replace(/width|left|right/i,function(c,h){var u=vo[c.toLowerCase()][l]||c;return h>0?u.charAt(0).toUpperCase()+u.slice(1):u})}function r(s){return s*(e.direction===ql?1:-1)}return{resolve:i,orient:r}}var si="role",pr="tabindex",Wm="disabled",Me="aria-",xs=Me+"controls",Gh=Me+"current",Zl=Me+"selected",ye=Me+"label",Aa=Me+"labelledby",Uh=Me+"hidden",Ma=Me+"orientation",as=Me+"roledescription",Jl=Me+"live",Ql=Me+"busy",tc=Me+"atomic",Ia=[si,pr,Wm,xs,Gh,ye,Aa,Uh,Ma,as],We=_s+"__",Mi="is-",bo=_s,ec=We+"track",Gm=We+"list",Kn=We+"slide",Yh=Kn+"--clone",Um=Kn+"__container",La=We+"arrows",qn=We+"arrow",Xh=qn+"--prev",Kh=qn+"--next",Zn=We+"pagination",qh=Zn+"__page",Ym=We+"progress",Xm=Ym+"__bar",Km=We+"toggle",qm=We+"spinner",Zm=We+"sr",Jm=Mi+"initialized",Yi=Mi+"active",Zh=Mi+"prev",Jh=Mi+"next",Uo=Mi+"visible",Yo=Mi+"loading",Qh=Mi+"focus-in",tu=Mi+"overflow",Qm=[Yi,Uo,Zh,Jh,Yo,Qh,tu],tv={slide:Kn,clone:Yh,arrows:La,arrow:qn,prev:Xh,next:Kh,pagination:Zn,page:qh,spinner:qm};function ev(n,t){if(Oh(n.closest))return n.closest(t);for(var e=n;e&&e.nodeType===1&&!es(e,t);)e=e.parentElement;return e}var iv=5,ic=200,eu="touchstart mousedown",_o="touchmove mousemove",yo="touchend touchcancel mouseup click";function rv(n,t,e){var i=mt(n),r=i.on,s=i.bind,o=n.root,a=e.i18n,l={},c=[],h=[],u=[],d,p,f;function g(){x(),T(),y()}function m(){r(Mt,v),r(Mt,g),r(ce,y),s(document,eu+" keydown",function(C){f=C.type==="keydown"},{capture:!0}),s(o,"focusin",function(){ti(o,Qh,!!f)})}function v(C){var S=Ia.concat("style");ci(c),ei(o,h),ei(d,u),He([d,p],S),He(o,C?S:["style",as])}function y(){ei(o,h),ei(d,u),h=A(bo),u=A(ec),Ve(o,h),Ve(d,u),U(o,ye,e.label),U(o,Aa,e.labelledby)}function x(){d=E("."+ec),p=bs(d,"."+Gm),Gr(d&&p,"A track/list element is missing."),an(c,Dh(p,"."+Kn+":not(."+Yh+")")),$i({arrows:La,pagination:Zn,prev:Xh,next:Kh,bar:Xm,toggle:Km},function(C,S){l[S]=E("."+C)}),rs(l,{root:o,track:d,list:p,slides:c})}function T(){var C=o.id||Em(_s),S=e.role;o.id=C,d.id=d.id||C+"-track",p.id=p.id||C+"-list",!De(o,si)&&o.tagName!=="SECTION"&&S&&U(o,si,S),U(o,as,a.carousel),U(p,si,"presentation")}function E(C){var S=Mh(o,C);return S&&ev(S,"."+bo)===o?S:void 0}function A(C){return[C+"--"+e.type,C+"--"+e.direction,e.drag&&C+"--draggable",e.isNavigation&&C+"--nav",C===bo&&Yi]}return rs(l,{setup:g,mount:m,destroy:v})}var mr="slide",Er="loop",ws="fade";function sv(n,t,e,i){var r=mt(n),s=r.on,o=r.emit,a=r.bind,l=n.Components,c=n.root,h=n.options,u=h.isNavigation,d=h.updateOnMove,p=h.i18n,f=h.pagination,g=h.slideFocus,m=l.Direction.resolve,v=De(i,"style"),y=De(i,ye),x=e>-1,T=bs(i,"."+Um),E;function A(){x||(i.id=c.id+"-slide"+ka(t+1),U(i,si,f?"tabpanel":"group"),U(i,as,p.slide),U(i,ye,y||Go(p.slideLabel,[t+1,n.length]))),C()}function C(){a(i,"click",ot(o,Fh,B)),a(i,"keydown",ot(o,Vh,B)),s([ys,Hh,Tr],D),s(Rh,F),d&&s(Ti,j)}function S(){E=!0,r.destroy(),ei(i,Qm),He(i,Ia),U(i,"style",v),U(i,ye,y||"")}function F(){var N=n.splides.map(function(M){var H=M.splide.Components.Slides.getAt(t);return H?H.slide.id:""}).join(" ");U(i,ye,Go(p.slideX,(x?e:t)+1)),U(i,xs,N),U(i,si,g?"button":""),g&&He(i,as)}function j(){E||D()}function D(){if(!E){var N=n.index;k(),P(),ti(i,Zh,t===N-1),ti(i,Jh,t===N+1)}}function k(){var N=V();N!==Yl(i,Yi)&&(ti(i,Yi,N),U(i,Gh,u&&N||""),o(N?Om:km,B))}function P(){var N=Y(),M=!N&&(!V()||x);if(n.state.is([Sr,fs])||U(i,Uh,M||""),U(Ea(i,h.focusableNodes||""),pr,M?-1:""),g&&U(i,pr,M?-1:0),N!==Yl(i,Uo)&&(ti(i,Uo,N),o(N?Dm:Pm,B)),!N&&document.activeElement===i){var H=l.Slides.getAt(n.index);H&&Ph(H.slide)}}function L(N,M,H){Ee(H&&T||i,N,M)}function V(){var N=n.index;return N===t||h.cloneStatus&&N===e}function Y(){if(n.is(ws))return V();var N=be(l.Elements.track),M=be(i),H=m("left",!0),J=m("right",!0);return En(N[H])<=ns(M[H])&&En(M[J])<=ns(N[J])}function Z(N,M){var H=se(N-t);return!x&&(h.rewind||n.is(Er))&&(H=Si(H,n.length-H)),H<=M}var B={index:t,slideIndex:e,slide:i,container:T,isClone:x,mount:A,destroy:S,update:D,style:L,isWithin:Z};return B}function nv(n,t,e){var i=mt(n),r=i.on,s=i.emit,o=i.bind,a=t.Elements,l=a.slides,c=a.list,h=[];function u(){d(),r(Mt,p),r(Mt,d)}function d(){l.forEach(function(D,k){g(D,k,-1)})}function p(){E(function(D){D.destroy()}),ci(h)}function f(){E(function(D){D.update()})}function g(D,k,P){var L=sv(n,k,P,D);L.mount(),h.push(L),h.sort(function(V,Y){return V.index-Y.index})}function m(D){return D?A(function(k){return!k.isClone}):h}function v(D){var k=t.Controller,P=k.toIndex(D),L=k.hasFocus()?1:e.perPage;return A(function(V){return ln(V.index,P,P+L-1)})}function y(D){return A(D)[0]}function x(D,k){we(D,function(P){if(Ci(P)&&(P=Ah(P)),kh(P)){var L=l[k];L?Ta(P,L):vs(c,P),Ve(P,e.classes.slide),S(P,ot(s,os))}}),s(Mt)}function T(D){Ui(A(D).map(function(k){return k.slide})),s(Mt)}function E(D,k){m(k).forEach(D)}function A(D){return h.filter(Oh(D)?D:function(k){return Ci(D)?es(k.slide,D):Sa(ms(D),k.index)})}function C(D,k,P){E(function(L){L.style(D,k,P)})}function S(D,k){var P=Ea(D,"img"),L=P.length;L?P.forEach(function(V){o(V,"load error",function(){--L||k()})}):k()}function F(D){return D?l.length:h.length}function j(){return h.length>e.perPage}return{mount:u,destroy:p,update:f,register:g,get:m,getIn:v,getAt:y,add:x,remove:T,forEach:E,filter:A,style:C,getLength:F,isEnough:j}}function ov(n,t,e){var i=mt(n),r=i.on,s=i.bind,o=i.emit,a=t.Slides,l=t.Direction.resolve,c=t.Elements,h=c.root,u=c.track,d=c.list,p=a.getAt,f=a.style,g,m,v;function y(){x(),s(window,"resize load",Vm(ot(o,os))),r([ce,Mt],x),r(os,T)}function x(){g=e.direction===Xn,Ee(h,"maxWidth",Li(e.width)),Ee(u,l("paddingLeft"),E(!1)),Ee(u,l("paddingRight"),E(!0)),T(!0)}function T(B){var N=be(h);(B||m.width!==N.width||m.height!==N.height)&&(Ee(u,"height",A()),f(l("marginRight"),Li(e.gap)),f("width",S()),f("height",F(),!0),m=N,o(Da),v!==(v=Z())&&(ti(h,tu,v),o(Lm,v)))}function E(B){var N=e.padding,M=l(B?"right":"left");return N&&Li(N[M]||(ts(N)?0:N))||"0px"}function A(){var B="";return g&&(B=C(),Gr(B,"height or heightRatio is missing."),B="calc("+B+" - "+E(!1)+" - "+E(!0)+")"),B}function C(){return Li(e.height||be(d).width*e.heightRatio)}function S(){return e.autoWidth?null:Li(e.fixedWidth)||(g?"":j())}function F(){return Li(e.fixedHeight)||(g?e.autoHeight?null:j():C())}function j(){var B=Li(e.gap);return"calc((100%"+(B&&" + "+B)+")/"+(e.perPage||1)+(B&&" - "+B)+")"}function D(){return be(d)[l("width")]}function k(B,N){var M=p(B||0);return M?be(M.slide)[l("width")]+(N?0:V()):0}function P(B,N){var M=p(B);if(M){var H=be(M.slide)[l("right")],J=be(d)[l("left")];return se(H-J)+(N?0:V())}return 0}function L(B){return P(n.length-1)-P(0)+k(0,B)}function V(){var B=p(0);return B&&parseFloat(Ee(B.slide,l("marginRight")))||0}function Y(B){return parseFloat(Ee(u,l("padding"+(B?"Right":"Left"))))||0}function Z(){return n.is(ws)||L(!0)>D()}return{mount:y,resize:T,listSize:D,slideSize:k,sliderSize:L,totalSize:P,getPadding:Y,isOverflow:Z}}var av=2;function lv(n,t,e){var i=mt(n),r=i.on,s=t.Elements,o=t.Slides,a=t.Direction.resolve,l=[],c;function h(){r(Mt,u),r([ce,os],p),(c=m())&&(f(c),t.Layout.resize(!0))}function u(){d(),h()}function d(){Ui(l),ci(l),i.destroy()}function p(){var v=m();c!==v&&(c<v||!v)&&i.emit(Mt)}function f(v){var y=o.get().slice(),x=y.length;if(x){for(;y.length<v;)an(y,y);an(y.slice(-v),y.slice(0,v)).forEach(function(T,E){var A=E<v,C=g(T.slide,E);A?Ta(C,y[0].slide):vs(s.list,C),an(l,C),o.register(C,E-v+(A?0:x),T.index)})}}function g(v,y){var x=v.cloneNode(!0);return Ve(x,e.classes.clone),x.id=n.root.id+"-clone"+ka(y+1),x}function m(){var v=e.clones;if(!n.is(Er))v=0;else if(gs(v)){var y=e[a("fixedWidth")]&&t.Layout.slideSize(0),x=y&&ns(be(s.track)[a("width")]/y);v=x||e[a("autoWidth")]&&n.length||e.perPage*av}return v}return{mount:h,destroy:d}}function cv(n,t,e){var i=mt(n),r=i.on,s=i.emit,o=n.state.set,a=t.Layout,l=a.slideSize,c=a.getPadding,h=a.totalSize,u=a.listSize,d=a.sliderSize,p=t.Direction,f=p.resolve,g=p.orient,m=t.Elements,v=m.list,y=m.track,x;function T(){x=t.Transition,r([Zi,Da,ce,Mt],E)}function E(){t.Controller.isBusy()||(t.Scroll.cancel(),C(n.index),t.Slides.update())}function A(M,H,J,bt){M!==H&&B(M>J)&&(D(),S(j(L(),M>J),!0)),o(Sr),s(Ti,H,J,M),x.start(H,function(){o(gr),s(ys,H,J,M),bt&&bt()})}function C(M){S(P(M,!0))}function S(M,H){if(!n.is(ws)){var J=H?M:F(M);Ee(v,"transform","translate"+f("X")+"("+J+"px)"),M!==J&&s(Hh)}}function F(M){if(n.is(Er)){var H=k(M),J=H>t.Controller.getEnd(),bt=H<0;(bt||J)&&(M=j(M,J))}return M}function j(M,H){var J=M-Z(H),bt=d();return M-=g(bt*(ns(se(J)/bt)||1))*(H?1:-1),M}function D(){S(L(),!0),x.cancel()}function k(M){for(var H=t.Slides.get(),J=0,bt=1/0,nt=0;nt<H.length;nt++){var he=H[nt].index,I=se(P(he,!0)-M);if(I<=bt)bt=I,J=he;else break}return J}function P(M,H){var J=g(h(M-1)-Y(M));return H?V(J):J}function L(){var M=f("left");return be(v)[M]-be(y)[M]+g(c(!1))}function V(M){return e.trimSpace&&n.is(mr)&&(M=er(M,0,g(d(!0)-u()))),M}function Y(M){var H=e.focus;return H==="center"?(u()-l(M,!0))/2:+H*l(M)||0}function Z(M){return P(M?t.Controller.getEnd():0,!!e.trimSpace)}function B(M){var H=g(j(L(),M));return M?H>=0:H<=v[f("scrollWidth")]-be(y)[f("width")]}function N(M,H){H=gs(H)?L():H;var J=M!==!0&&g(H)<g(Z(!1)),bt=M!==!1&&g(H)>g(Z(!0));return J||bt}return{mount:T,move:A,jump:C,translate:S,shift:j,cancel:D,toIndex:k,toPosition:P,getPosition:L,getLimit:Z,exceededLimit:N,reposition:E}}function hv(n,t,e){var i=mt(n),r=i.on,s=i.emit,o=t.Move,a=o.getPosition,l=o.getLimit,c=o.toPosition,h=t.Slides,u=h.isEnough,d=h.getLength,p=e.omitEnd,f=n.is(Er),g=n.is(mr),m=ot(L,!1),v=ot(L,!0),y=e.start||0,x,T=y,E,A,C;function S(){F(),r([ce,Mt,On],F),r(Da,j)}function F(){E=d(!0),A=e.perMove,C=e.perPage,x=B();var I=er(y,0,p?x:E-1);I!==y&&(y=I,o.reposition())}function j(){x!==B()&&s(On)}function D(I,tt,$t){if(!he()){var at=P(I),lt=Z(at);lt>-1&&(tt||lt!==y)&&(J(lt),o.move(at,lt,T,$t))}}function k(I,tt,$t,at){t.Scroll.scroll(I,tt,$t,function(){var lt=Z(o.toIndex(a()));J(p?Si(lt,x):lt),at&&at()})}function P(I){var tt=y;if(Ci(I)){var $t=I.match(/([+\-<>])(\d+)?/)||[],at=$t[1],lt=$t[2];at==="+"||at==="-"?tt=V(y+ +(""+at+(+lt||1)),y):at===">"?tt=lt?N(+lt):m(!0):at==="<"&&(tt=v(!0))}else tt=f?I:er(I,0,x);return tt}function L(I,tt){var $t=A||(nt()?1:C),at=V(y+$t*(I?-1:1),y,!(A||nt()));return at===-1&&g&&!Ih(a(),l(!I),1)?I?0:x:tt?at:Z(at)}function V(I,tt,$t){if(u()||nt()){var at=Y(I);at!==I&&(tt=I,I=at,$t=!1),I<0||I>x?!A&&(ln(0,I,tt,!0)||ln(x,tt,I,!0))?I=N(M(I)):f?I=$t?I<0?-(E%C||C):E:I:e.rewind?I=I<0?x:0:I=-1:$t&&I!==tt&&(I=N(M(tt)+(I<tt?-1:1)))}else I=-1;return I}function Y(I){if(g&&e.trimSpace==="move"&&I!==y)for(var tt=a();tt===c(I,!0)&&ln(I,0,n.length-1,!e.rewind);)I<y?--I:++I;return I}function Z(I){return f?(I+E)%E||0:I}function B(){for(var I=E-(nt()||f&&A?1:C);p&&I-- >0;)if(c(E-1,!0)!==c(I,!0)){I++;break}return er(I,0,E-1)}function N(I){return er(nt()?I:C*I,0,x)}function M(I){return nt()?Si(I,x):En((I>=x?E-1:I)/C)}function H(I){var tt=o.toIndex(I);return g?er(tt,0,x):tt}function J(I){I!==y&&(T=y,y=I)}function bt(I){return I?T:y}function nt(){return!gs(e.focus)||e.isNavigation}function he(){return n.state.is([Sr,fs])&&!!e.waitForTransition}return{mount:S,go:D,scroll:k,getNext:m,getPrev:v,getAdjacent:L,getEnd:B,setIndex:J,getIndex:bt,toIndex:N,toPage:M,toDest:H,hasFocus:nt,isBusy:he}}var uv="http://www.w3.org/2000/svg",dv="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",Qs=40;function pv(n,t,e){var i=mt(n),r=i.on,s=i.bind,o=i.emit,a=e.classes,l=e.i18n,c=t.Elements,h=t.Controller,u=c.arrows,d=c.track,p=u,f=c.prev,g=c.next,m,v,y={};function x(){E(),r(ce,T)}function T(){A(),x()}function E(){var k=e.arrows;k&&!(f&&g)&&F(),f&&g&&(rs(y,{prev:f,next:g}),ss(p,k?"":"none"),Ve(p,v=La+"--"+e.direction),k&&(C(),D(),U([f,g],xs,d.id),o(Fm,f,g)))}function A(){i.destroy(),ei(p,v),m?(Ui(u?[f,g]:p),f=g=null):He([f,g],Ia)}function C(){r([Zi,ys,Mt,Tr,On],D),s(g,"click",ot(S,">")),s(f,"click",ot(S,"<"))}function S(k){h.go(k,!0)}function F(){p=u||dr("div",a.arrows),f=j(!0),g=j(!1),m=!0,vs(p,[f,g]),!u&&Ta(p,d)}function j(k){var P='<button class="'+a.arrow+" "+(k?a.prev:a.next)+'" type="button"><svg xmlns="'+uv+'" viewBox="0 0 '+Qs+" "+Qs+'" width="'+Qs+'" height="'+Qs+'" focusable="false"><path d="'+(e.arrowPath||dv)+'" />';return Ah(P)}function D(){if(f&&g){var k=n.index,P=h.getPrev(),L=h.getNext(),V=P>-1&&k<P?l.last:l.prev,Y=L>-1&&k>L?l.first:l.next;f.disabled=P<0,g.disabled=L<0,U(f,ye,V),U(g,ye,Y),o(jm,f,g,P,L)}}return{arrows:y,mount:x,destroy:A,update:D}}var fv=Oa+"-interval";function gv(n,t,e){var i=mt(n),r=i.on,s=i.bind,o=i.emit,a=Wn(e.interval,n.go.bind(n,">"),C),l=a.isPaused,c=t.Elements,h=t.Elements,u=h.root,d=h.toggle,p=e.autoplay,f,g,m=p==="pause";function v(){p&&(y(),d&&U(d,xs,c.track.id),m||x(),A())}function y(){e.pauseOnHover&&s(u,"mouseenter mouseleave",function(F){f=F.type==="mouseenter",E()}),e.pauseOnFocus&&s(u,"focusin focusout",function(F){g=F.type==="focusin",E()}),d&&s(d,"click",function(){m?x():T(!0)}),r([Ti,Pa,Mt],a.rewind),r(Ti,S)}function x(){l()&&t.Slides.isEnough()&&(a.start(!e.resetProgress),g=f=m=!1,A(),o(Bh))}function T(F){F===void 0&&(F=!0),m=!!F,A(),l()||(a.pause(),o(Nh))}function E(){m||(f||g?T(!1):x())}function A(){d&&(ti(d,Yi,!m),U(d,ye,e.i18n[m?"play":"pause"]))}function C(F){var j=c.bar;j&&Ee(j,"width",F*100+"%"),o(Nm,F)}function S(F){var j=t.Slides.getAt(F);a.set(j&&+De(j.slide,fv)||e.interval)}return{mount:v,destroy:a.cancel,play:x,pause:T,isPaused:l}}function mv(n,t,e){var i=mt(n),r=i.on;function s(){e.cover&&(r(zh,ot(a,!0)),r([Zi,ce,Mt],ot(o,!0)))}function o(l){t.Slides.forEach(function(c){var h=bs(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),ss(c,l?"none":"")}return{mount:s,destroy:ot(o,!1)}}var vv=10,bv=600,_v=.6,yv=1.5,xv=800;function wv(n,t,e){var i=mt(n),r=i.on,s=i.emit,o=n.state.set,a=t.Move,l=a.getPosition,c=a.getLimit,h=a.exceededLimit,u=a.translate,d=n.is(mr),p,f,g=1;function m(){r(Ti,T),r([ce,Mt],E)}function v(C,S,F,j,D){var k=l();if(T(),F&&(!d||!h())){var P=t.Layout.sliderSize(),L=Wo(C)*P*En(se(C)/P)||0;C=a.toPosition(t.Controller.toDest(C%P))+L}var V=Ih(k,C,1);g=1,S=V?0:S||Tn(se(C-k)/yv,xv),f=j,p=Wn(S,y,ot(x,k,C,D),1),o(fs),s(Pa),p.start()}function y(){o(gr),f&&f(),s(Tr)}function x(C,S,F,j){var D=l(),k=C+(S-C)*A(j),P=(k-D)*g;u(D+P),d&&!F&&h()&&(g*=_v,se(P)<vv&&v(c(h(!0)),bv,!1,f,!0))}function T(){p&&p.cancel()}function E(){p&&!p.isPaused()&&(T(),y())}function A(C){var S=e.easingFunc;return S?S(C):1-Math.pow(1-C,4)}return{mount:m,destroy:T,scroll:v,cancel:E}}var ir={passive:!1,capture:!0};function Cv(n,t,e){var i=mt(n),r=i.on,s=i.emit,o=i.bind,a=i.unbind,l=n.state,c=t.Move,h=t.Scroll,u=t.Controller,d=t.Elements.track,p=t.Media.reduce,f=t.Direction,g=f.resolve,m=f.orient,v=c.getPosition,y=c.exceededLimit,x,T,E,A,C,S=!1,F,j,D;function k(){o(d,_o,Ho,ir),o(d,yo,Ho,ir),o(d,eu,L,ir),o(d,"click",Z,{capture:!0}),o(d,"dragstart",qe),r([Zi,ce],P)}function P(){var z=e.drag;Ra(!z),A=z==="free"}function L(z){if(F=!1,!j){var ct=lt(z);at(z.target)&&(ct||!z.button)&&(u.isBusy()?qe(z,!0):(D=ct?d:window,C=l.is([Sr,fs]),E=null,o(D,_o,V,ir),o(D,yo,Y,ir),c.cancel(),h.cancel(),B(z)))}}function V(z){if(l.is(on)||(l.set(on),s(Am)),z.cancelable)if(C){c.translate(x+$t(nt(z)));var ct=he(z)>ic,Ii=S!==(S=y());(ct||Ii)&&B(z),F=!0,s(Mm),qe(z)}else H(z)&&(C=M(z),qe(z))}function Y(z){l.is(on)&&(l.set(gr),s(Im)),C&&(N(z),qe(z)),a(D,_o,V),a(D,yo,Y),C=!1}function Z(z){!j&&F&&qe(z,!0)}function B(z){E=T,T=z,x=v()}function N(z){var ct=J(z),Ii=bt(ct),kr=e.rewind&&e.rewindByDrag;p(!1),A?u.scroll(Ii,0,e.snap):n.is(ws)?u.go(m(Wo(ct))<0?kr?"<":"-":kr?">":"+"):n.is(mr)&&S&&kr?u.go(y(!0)?">":"<"):u.go(u.toDest(Ii),!0),p(!0)}function M(z){var ct=e.dragMinThreshold,Ii=ts(ct),kr=Ii&&ct.mouse||0,nu=(Ii?ct.touch:+ct)||10;return se(nt(z))>(lt(z)?nu:kr)}function H(z){return se(nt(z))>se(nt(z,!0))}function J(z){if(n.is(Er)||!S){var ct=he(z);if(ct&&ct<ic)return nt(z)/ct}return 0}function bt(z){return v()+Wo(z)*Si(se(z)*(e.flickPower||600),A?1/0:t.Layout.listSize()*(e.flickMaxPages||1))}function nt(z,ct){return tt(z,ct)-tt(I(z),ct)}function he(z){return $o(z)-$o(I(z))}function I(z){return T===z&&E||T}function tt(z,ct){return(lt(z)?z.changedTouches[0]:z)["page"+g(ct?"Y":"X")]}function $t(z){return z/(S&&n.is(mr)?iv:1)}function at(z){var ct=e.noDrag;return!es(z,"."+qh+", ."+qn)&&(!ct||!es(z,ct))}function lt(z){return typeof TouchEvent<"u"&&z instanceof TouchEvent}function su(){return C}function Ra(z){j=z}return{mount:k,disable:Ra,isDragging:su}}var Sv={Spacebar:" ",Right:Yn,Left:Un,Up:$h,Down:Wh};function Fa(n){return n=Ci(n)?n:n.key,Sv[n]||n}var rc="keydown";function Tv(n,t,e){var i=mt(n),r=i.on,s=i.bind,o=i.unbind,a=n.root,l=t.Direction.resolve,c,h;function u(){d(),r(ce,p),r(ce,d),r(Ti,g)}function d(){var v=e.keyboard;v&&(c=v==="global"?window:a,s(c,rc,m))}function p(){o(c,rc)}function f(v){h=v}function g(){var v=h;h=!0,Eh(function(){h=v})}function m(v){if(!h){var y=Fa(v);y===l(Un)?n.go("<"):y===l(Yn)&&n.go(">")}}return{mount:u,destroy:p,disable:f}}var Ur=Oa+"-lazy",cn=Ur+"-srcset",Ev="["+Ur+"], ["+cn+"]";function Ov(n,t,e){var i=mt(n),r=i.on,s=i.off,o=i.bind,a=i.emit,l=e.lazyLoad==="sequential",c=[ys,Tr],h=[];function u(){e.lazyLoad&&(d(),r(Mt,d))}function d(){ci(h),p(),l?v():(s(c),r(c,f),f())}function p(){t.Slides.forEach(function(y){Ea(y.slide,Ev).forEach(function(x){var T=De(x,Ur),E=De(x,cn);if(T!==x.src||E!==x.srcset){var A=e.classes.spinner,C=x.parentElement,S=bs(C,"."+A)||dr("span",A,C);h.push([x,y,S]),x.src||ss(x,"none")}})})}function f(){h=h.filter(function(y){var x=e.perPage*((e.preloadPages||1)+1)-1;return y[1].isWithin(n.index,x)?g(y):!0}),h.length||s(c)}function g(y){var x=y[0];Ve(y[1].slide,Yo),o(x,"load error",ot(m,y)),U(x,"src",De(x,Ur)),U(x,"srcset",De(x,cn)),He(x,Ur),He(x,cn)}function m(y,x){var T=y[0],E=y[1];ei(E.slide,Yo),x.type!=="error"&&(Ui(y[2]),ss(T,""),a(zh,T,E),a(os)),l&&v()}function v(){h.length&&g(h.shift())}return{mount:u,destroy:ot(ci,h),check:f}}function kv(n,t,e){var i=mt(n),r=i.on,s=i.emit,o=i.bind,a=t.Slides,l=t.Elements,c=t.Controller,h=c.hasFocus,u=c.getIndex,d=c.go,p=t.Direction.resolve,f=l.pagination,g=[],m,v;function y(){x(),r([ce,Mt,On],y);var j=e.pagination;f&&ss(f,j?"":"none"),j&&(r([Ti,Pa,Tr],F),T(),F(),s(Rm,{list:m,items:g},S(n.index)))}function x(){m&&(Ui(f?Ai(m.children):m),ei(m,v),ci(g),m=null),i.destroy()}function T(){var j=n.length,D=e.classes,k=e.i18n,P=e.perPage,L=h()?c.getEnd()+1:ns(j/P);m=f||dr("ul",D.pagination,l.track.parentElement),Ve(m,v=Zn+"--"+C()),U(m,si,"tablist"),U(m,ye,k.select),U(m,Ma,C()===Xn?"vertical":"");for(var V=0;V<L;V++){var Y=dr("li",null,m),Z=dr("button",{class:D.page,type:"button"},Y),B=a.getIn(V).map(function(M){return M.slide.id}),N=!h()&&P>1?k.pageX:k.slideX;o(Z,"click",ot(E,V)),e.paginationKeyboard&&o(Z,"keydown",ot(A,V)),U(Y,si,"presentation"),U(Z,si,"tab"),U(Z,xs,B.join(" ")),U(Z,ye,Go(N,V+1)),U(Z,pr,-1),g.push({li:Y,button:Z,page:V})}}function E(j){d(">"+j,!0)}function A(j,D){var k=g.length,P=Fa(D),L=C(),V=-1;P===p(Yn,!1,L)?V=++j%k:P===p(Un,!1,L)?V=(--j+k)%k:P==="Home"?V=0:P==="End"&&(V=k-1);var Y=g[V];Y&&(Ph(Y.button),d(">"+V),qe(D,!0))}function C(){return e.paginationDirection||e.direction}function S(j){return g[c.toPage(j)]}function F(){var j=S(u(!0)),D=S(u());if(j){var k=j.button;ei(k,Yi),He(k,Zl),U(k,pr,-1)}if(D){var P=D.button;Ve(P,Yi),U(P,Zl,!0),U(P,pr,"")}s(Bm,{list:m,items:g},j,D)}return{items:g,mount:y,destroy:x,getAt:S,update:F}}var Dv=[" ","Enter"];function Pv(n,t,e){var i=e.isNavigation,r=e.slideFocus,s=[];function o(){n.splides.forEach(function(f){f.isParent||(c(n,f.splide),c(f.splide,n))}),i&&h()}function a(){s.forEach(function(f){f.destroy()}),ci(s)}function l(){a(),o()}function c(f,g){var m=mt(f);m.on(Ti,function(v,y,x){g.go(g.is(Er)?x:v)}),s.push(m)}function h(){var f=mt(n),g=f.on;g(Fh,d),g(Vh,p),g([Zi,ce],u),s.push(f),f.emit(Rh,n.splides)}function u(){U(t.Elements.list,Ma,e.direction===Xn?"vertical":"")}function d(f){n.go(f.index)}function p(f,g){Sa(Dv,Fa(g))&&(d(f),qe(g))}return{setup:ot(t.Media.set,{slideFocus:gs(r)?i:r},!0),mount:o,destroy:a,remount:l}}function Av(n,t,e){var i=mt(n),r=i.bind,s=0;function o(){e.wheel&&r(t.Elements.track,"wheel",a,ir)}function a(c){if(c.cancelable){var h=c.deltaY,u=h<0,d=$o(c),p=e.wheelMinThreshold||0,f=e.wheelSleep||0;se(h)>p&&d-s>f&&(n.go(u?"<":">"),s=d),l(u)&&qe(c)}}function l(c){return!e.releaseWheel||n.state.is(Sr)||t.Controller.getAdjacent(c)!==-1}return{mount:o}}var Mv=90;function Iv(n,t,e){var i=mt(n),r=i.on,s=t.Elements.track,o=e.live&&!e.isNavigation,a=dr("span",Zm),l=Wn(Mv,ot(h,!1));function c(){o&&(d(!t.Autoplay.isPaused()),U(s,tc,!0),a.textContent="…",r(Bh,ot(d,!0)),r(Nh,ot(d,!1)),r([ys,Tr],ot(h,!0)))}function h(p){U(s,Ql,p),p?(vs(s,a),l.start()):(Ui(a),l.cancel())}function u(){He(s,[Jl,tc,Ql]),Ui(a)}function d(p){o&&U(s,Jl,p?"off":"polite")}return{mount:c,disable:d,destroy:u}}var Lv=Object.freeze({__proto__:null,Media:Hm,Direction:$m,Elements:rv,Slides:nv,Layout:ov,Clones:lv,Move:cv,Controller:hv,Arrows:pv,Autoplay:gv,Cover:mv,Scroll:wv,Drag:Cv,Keyboard:Tv,LazyLoad:Ov,Pagination:kv,Sync:Pv,Wheel:Av,Live:Iv}),Fv={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"},jv={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:tv,i18n:Fv,reducedMotion:{speed:0,rewindSpeed:0,autoplay:"pause"}};function Rv(n,t,e){var i=t.Slides;function r(){mt(n).on([Zi,Mt],s)}function s(){i.forEach(function(a){a.style("transform","translateX(-"+100*a.index+"%)")})}function o(a,l){i.style("transition","opacity "+e.speed+"ms "+e.easing),Eh(l)}return{mount:r,start:o,cancel:Ho}}function Bv(n,t,e){var i=t.Move,r=t.Controller,s=t.Scroll,o=t.Elements.list,a=ot(Ee,o,"transition"),l;function c(){mt(n).bind(o,"transitionend",function(p){p.target===o&&l&&(u(),l())})}function h(p,f){var g=i.toPosition(p,!0),m=i.getPosition(),v=d(p);se(g-m)>=1&&v>=1?e.useScroll?s.scroll(g,v,!1,f):(a("transform "+v+"ms "+e.easing),i.translate(g,!0),l=f):(i.jump(p),f())}function u(){a(""),s.cancel()}function d(p){var f=e.rewindSpeed;if(n.is(mr)&&f){var g=r.getIndex(!0),m=r.getEnd();if(g===0&&p>=m||g>=m&&p===0)return f}return e.speed}return{mount:c,start:h,cancel:u}}var Nv=function(){function n(e,i){this.event=mt(),this.Components={},this.state=zm(lr),this.splides=[],this._o={},this._E={};var r=Ci(e)?Mh(document,e):e;Gr(r,r+" is invalid."),this.root=r,i=bi({label:De(r,ye)||"",labelledby:De(r,Aa)||""},jv,n.defaults,i||{});try{bi(i,JSON.parse(De(r,Oa)))}catch{Gr(!1,"Invalid JSON")}this._o=Object.create(bi({},i))}var t=n.prototype;return t.mount=function(i,r){var s=this,o=this.state,a=this.Components;Gr(o.is([lr,Sn]),"Already mounted!"),o.set(lr),this._C=a,this._T=r||this._T||(this.is(ws)?Rv:Bv),this._E=i||this._E;var l=rs({},Lv,this._E,{Transition:this._T});return $i(l,function(c,h){var u=c(s,a,s._o);a[h]=u,u.setup&&u.setup()}),$i(a,function(c){c.mount&&c.mount()}),this.emit(Zi),Ve(this.root,Jm),o.set(gr),this.emit(Kl),this},t.sync=function(i){return this.splides.push({splide:i}),i.splides.push({splide:this,isParent:!0}),this.state.is(gr)&&(this._C.Sync.remount(),i.Components.Sync.remount()),this},t.go=function(i){return this._C.Controller.go(i),this},t.on=function(i,r){return this.event.on(i,r),this},t.off=function(i){return this.event.off(i),this},t.emit=function(i){var r;return(r=this.event).emit.apply(r,[i].concat(Ai(arguments,1))),this},t.add=function(i,r){return this._C.Slides.add(i,r),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(Mt),this},t.destroy=function(i){i===void 0&&(i=!0);var r=this.event,s=this.state;return s.is(lr)?mt(this).on(Kl,this.destroy.bind(this,i)):($i(this._C,function(o){o.destroy&&o.destroy(i)},!0),r.emit(jh),r.destroy(),i&&ci(this.splides),s.set(Sn)),this},Cm(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}(),ja=Nv;ja.defaults={};ja.STATES=Tm;/**
2510
+ */var Pc="(prefers-reduced-motion: reduce)",xs=1,Fv=2,As=3,$s=4,Ir=5,En=6,Gn=7,jv={CREATED:xs,MOUNTED:Fv,IDLE:As,MOVING:$s,SCROLLING:Ir,DRAGGING:En,DESTROYED:Gn};function fi(n){n.length=0}function Ni(n,t,e){return Array.prototype.slice.call(n,t,e)}function ot(n){return n.bind.apply(n,[null].concat(Ni(arguments,1)))}var wu=setTimeout,ba=function(){};function Dc(n){return requestAnimationFrame(n)}function go(n,t){return typeof t===n}function br(n){return!Qa(n)&&go("object",n)}var Ja=Array.isArray,Cu=ot(go,"function"),Mi=ot(go,"string"),Lr=ot(go,"undefined");function Qa(n){return n===null}function Su(n){try{return n instanceof(n.ownerDocument.defaultView||window).HTMLElement}catch{return!1}}function Fr(n){return Ja(n)?n:[n]}function Ee(n,t){Fr(n).forEach(t)}function tl(n,t){return n.indexOf(t)>-1}function On(n,t){return n.push.apply(n,Fr(t)),n}function oi(n,t,e){n&&Ee(t,function(i){i&&n.classList[e?"add":"remove"](i)})}function Ge(n,t){oi(n,Mi(t)?t.split(" "):t,!0)}function jr(n,t){Ee(t,n.appendChild.bind(n))}function el(n,t){Ee(n,function(e){var i=(t||e).parentNode;i&&i.insertBefore(e,t)})}function _r(n,t){return Su(n)&&(n.msMatchesSelector||n.matches).call(n,t)}function Tu(n,t){var e=n?Ni(n.children):[];return t?e.filter(function(i){return _r(i,t)}):e}function Rr(n,t){return t?Tu(n,t)[0]:n.firstElementChild}var yr=Object.keys;function Qi(n,t,e){return n&&(e?yr(n).reverse():yr(n)).forEach(function(i){i!=="__proto__"&&t(n[i],i)}),n}function xr(n){return Ni(arguments,1).forEach(function(t){Qi(t,function(e,i){n[i]=t[i]})}),n}function Ti(n){return Ni(arguments,1).forEach(function(t){Qi(t,function(e,i){Ja(e)?n[i]=e.slice():br(e)?n[i]=Ti({},br(n[i])?n[i]:{},e):n[i]=e})}),n}function Mc(n,t){Ee(t||yr(n),function(e){delete n[e]})}function Ye(n,t){Ee(n,function(e){Ee(t,function(i){e&&e.removeAttribute(i)})})}function Y(n,t,e){br(t)?Qi(t,function(i,s){Y(n,s,i)}):Ee(n,function(i){Qa(e)||e===""?Ye(i,t):i.setAttribute(t,String(e))})}function Ts(n,t,e){var i=document.createElement(n);return t&&(Mi(t)?Ge(i,t):Y(i,t)),e&&jr(e,i),i}function Pe(n,t,e){if(Lr(e))return getComputedStyle(n)[t];Qa(e)||(n.style[t]=""+e)}function wr(n,t){Pe(n,"display",t)}function Eu(n){n.setActive&&n.setActive()||n.focus({preventScroll:!0})}function Ie(n,t){return n.getAttribute(t)}function Ic(n,t){return n&&n.classList.contains(t)}function xe(n){return n.getBoundingClientRect()}function ss(n){Ee(n,function(t){t&&t.parentNode&&t.parentNode.removeChild(t)})}function Ou(n){return Rr(new DOMParser().parseFromString(n,"text/html").body)}function ii(n,t){n.preventDefault(),t&&(n.stopPropagation(),n.stopImmediatePropagation())}function ku(n,t){return n&&n.querySelector(t)}function il(n,t){return t?Ni(n.querySelectorAll(t)):[]}function ai(n,t){oi(n,t,!1)}function _a(n){return n.timeStamp}function Ui(n){return Mi(n)?n:n?n+"px":""}var $r="splide",sl="data-"+$r;function ar(n,t){if(!n)throw new Error("["+$r+"] "+(t||""))}var Ii=Math.min,Yn=Math.max,Xn=Math.floor,Cr=Math.ceil,ae=Math.abs;function Au(n,t,e){return ae(n-t)<e}function kn(n,t,e,i){var s=Ii(t,e),r=Yn(t,e);return i?s<n&&n<r:s<=n&&n<=r}function fs(n,t,e){var i=Ii(t,e),s=Yn(t,e);return Ii(Yn(i,n),s)}function ya(n){return+(n>0)-+(n<0)}function xa(n,t){return Ee(t,function(e){n=n.replace("%s",""+e)}),n}function rl(n){return n<10?"0"+n:""+n}var Lc={};function Rv(n){return""+n+rl(Lc[n]=(Lc[n]||0)+1)}function Pu(){var n=[];function t(o,a,l,c){s(o,a,function(h,u,d){var p="addEventListener"in h,f=p?h.removeEventListener.bind(h,u,l,c):h.removeListener.bind(h,l);p?h.addEventListener(u,l,c):h.addListener(l),n.push([h,u,d,l,f])})}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){Ee(o,function(c){c&&Ee(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]()}),fi(n)}return{bind:t,unbind:e,dispatch:i,destroy:r}}var ls="mounted",Fc="ready",Li="move",Br="moved",Du="click",$v="active",Bv="inactive",Nv="visible",zv="hidden",Lt="refresh",de="updated",Sr="resize",nl="resized",Hv="drag",Vv="dragging",Uv="dragged",ol="scroll",Bs="scrolled",Wv="overflow",Mu="destroy",Gv="arrows:mounted",Yv="arrows:updated",Xv="pagination:mounted",Kv="pagination:updated",Iu="navigation:mounted",Lu="autoplay:play",qv="autoplay:playing",Fu="autoplay:pause",ju="lazyload:loaded",Ru="sk",$u="sh",Kn="ei";function vt(n){var t=n?n.event.bus:document.createDocumentFragment(),e=Pu();function i(r,o){e.bind(t,Fr(r).join(" "),function(a){o.apply(o,Ja(a.detail)?a.detail:[])})}function s(r){e.dispatch(t,r,Ni(arguments,1))}return n&&n.event.on(Mu,e.destroy),xr(e,{bus:t,on:i,off:ot(e.unbind,t),emit:s})}function mo(n,t,e,i){var s=Date.now,r,o=0,a,l=!0,c=0;function h(){if(!l){if(o=n?Ii((s()-r)/n,1):1,e&&e(o),o>=1&&(t(),r=s(),i&&++c>=i))return d();a=Dc(h)}}function u(v){v||f(),r=s()-(v?o*n:0),l=!1,a=Dc(h)}function d(){l=!0}function p(){r=s(),o=0,e&&e(o)}function f(){a&&cancelAnimationFrame(a),o=0,a=0,l=!0}function g(v){n=v}function m(){return l}return{start:u,rewind:p,pause:d,cancel:f,set:g,isPaused:m}}function Zv(n){var t=n;function e(s){t=s}function i(s){return tl(Fr(s),t)}return{set:e,is:i}}function Jv(n,t){var e=mo(0,n,null,1);return function(){e.isPaused()&&e.start()}}function Qv(n,t,e){var i=n.state,s=e.breakpoints||{},r=e.reducedMotion||{},o=Pu(),a=[];function l(){var f=e.mediaQuery==="min";yr(s).sort(function(g,m){return f?+g-+m:+m-+g}).forEach(function(g){h(s[g],"("+(f?"min":"max")+"-width:"+g+"px)")}),h(r,Pc),u()}function c(f){f&&o.destroy()}function h(f,g){var m=matchMedia(g);o.bind(m,"change",u),a.push([f,m])}function u(){var f=i.is(Gn),g=e.direction,m=a.reduce(function(v,y){return Ti(v,y[1].matches?y[0]:{})},{});Mc(e),p(m),e.destroy?n.destroy(e.destroy==="completely"):f?(c(!0),n.mount()):g!==e.direction&&n.refresh()}function d(f){matchMedia(Pc).matches&&(f?Ti(e,r):Mc(e,yr(r)))}function p(f,g,m){Ti(e,f),g&&Ti(Object.getPrototypeOf(e),f),(m||!i.is(xs))&&n.emit(de,e)}return{setup:l,destroy:c,reduce:d,set:p}}var vo="Arrow",bo=vo+"Left",_o=vo+"Right",Bu=vo+"Up",Nu=vo+"Down",jc="rtl",yo="ttb",Go={width:["height"],left:["top","right"],right:["bottom","left"],x:["y"],X:["Y"],Y:["X"],ArrowLeft:[Bu,_o],ArrowRight:[Nu,bo]};function tb(n,t,e){function i(r,o,a){a=a||e.direction;var l=a===jc&&!o?1:a===yo?0:-1;return Go[r]&&Go[r][l]||r.replace(/width|left|right/i,function(c,h){var u=Go[c.toLowerCase()][l]||c;return h>0?u.charAt(0).toUpperCase()+u.slice(1):u})}function s(r){return r*(e.direction===jc?1:-1)}return{resolve:i,orient:s}}var hi="role",Es="tabindex",eb="disabled",Re="aria-",Nr=Re+"controls",zu=Re+"current",Rc=Re+"selected",Se=Re+"label",al=Re+"labelledby",Hu=Re+"hidden",ll=Re+"orientation",Tr=Re+"roledescription",$c=Re+"live",Bc=Re+"busy",Nc=Re+"atomic",cl=[hi,Es,eb,Nr,zu,Se,al,Hu,ll,Tr],qe=$r+"__",zi="is-",Yo=$r,zc=qe+"track",ib=qe+"list",xo=qe+"slide",Vu=xo+"--clone",sb=xo+"__container",hl=qe+"arrows",wo=qe+"arrow",Uu=wo+"--prev",Wu=wo+"--next",Co=qe+"pagination",Gu=Co+"__page",rb=qe+"progress",nb=rb+"__bar",ob=qe+"toggle",ab=qe+"spinner",lb=qe+"sr",cb=zi+"initialized",rs=zi+"active",Yu=zi+"prev",Xu=zi+"next",wa=zi+"visible",Ca=zi+"loading",Ku=zi+"focus-in",qu=zi+"overflow",hb=[rs,wa,Yu,Xu,Ca,Ku,qu],ub={slide:xo,clone:Vu,arrows:hl,arrow:wo,prev:Uu,next:Wu,pagination:Co,page:Gu,spinner:ab};function db(n,t){if(Cu(n.closest))return n.closest(t);for(var e=n;e&&e.nodeType===1&&!_r(e,t);)e=e.parentElement;return e}var pb=5,Hc=200,Zu="touchstart mousedown",Xo="touchmove mousemove",Ko="touchend touchcancel mouseup click";function fb(n,t,e){var i=vt(n),s=i.on,r=i.bind,o=n.root,a=e.i18n,l={},c=[],h=[],u=[],d,p,f;function g(){x(),E(),y()}function m(){s(Lt,v),s(Lt,g),s(de,y),r(document,Zu+" keydown",function(C){f=C.type==="keydown"},{capture:!0}),r(o,"focusin",function(){oi(o,Ku,!!f)})}function v(C){var S=cl.concat("style");fi(c),ai(o,h),ai(d,u),Ye([d,p],S),Ye(o,C?S:["style",Tr])}function y(){ai(o,h),ai(d,u),h=D(Yo),u=D(zc),Ge(o,h),Ge(d,u),Y(o,Se,e.label),Y(o,al,e.labelledby)}function x(){d=O("."+zc),p=Rr(d,"."+ib),ar(d&&p,"A track/list element is missing."),On(c,Tu(p,"."+xo+":not(."+Vu+")")),Qi({arrows:hl,pagination:Co,prev:Uu,next:Wu,bar:nb,toggle:ob},function(C,S){l[S]=O("."+C)}),xr(l,{root:o,track:d,list:p,slides:c})}function E(){var C=o.id||Rv($r),S=e.role;o.id=C,d.id=d.id||C+"-track",p.id=p.id||C+"-list",!Ie(o,hi)&&o.tagName!=="SECTION"&&S&&Y(o,hi,S),Y(o,Tr,a.carousel),Y(p,hi,"presentation")}function O(C){var S=ku(o,C);return S&&db(S,"."+Yo)===o?S:void 0}function D(C){return[C+"--"+e.type,C+"--"+e.direction,e.drag&&C+"--draggable",e.isNavigation&&C+"--nav",C===Yo&&rs]}return xr(l,{setup:g,mount:m,destroy:v})}var Ps="slide",Ns="loop",zr="fade";function gb(n,t,e,i){var s=vt(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,p=h.i18n,f=h.pagination,g=h.slideFocus,m=l.Direction.resolve,v=Ie(i,"style"),y=Ie(i,Se),x=e>-1,E=Rr(i,"."+sb),O;function D(){x||(i.id=c.id+"-slide"+rl(t+1),Y(i,hi,f?"tabpanel":"group"),Y(i,Tr,p.slide),Y(i,Se,y||xa(p.slideLabel,[t+1,n.length]))),C()}function C(){a(i,"click",ot(o,Du,$)),a(i,"keydown",ot(o,Ru,$)),r([Br,$u,Bs],A),r(Iu,F),d&&r(Li,j)}function S(){O=!0,s.destroy(),ai(i,hb),Ye(i,cl),Y(i,"style",v),Y(i,Se,y||"")}function F(){var B=n.splides.map(function(M){var H=M.splide.Components.Slides.getAt(t);return H?H.slide.id:""}).join(" ");Y(i,Se,xa(p.slideX,(x?e:t)+1)),Y(i,Nr,B),Y(i,hi,g?"button":""),g&&Ye(i,Tr)}function j(){O||A()}function A(){if(!O){var B=n.index;k(),P(),oi(i,Yu,t===B-1),oi(i,Xu,t===B+1)}}function k(){var B=z();B!==Ic(i,rs)&&(oi(i,rs,B),Y(i,zu,u&&B||""),o(B?$v:Bv,$))}function P(){var B=X(),M=!B&&(!z()||x);if(n.state.is([$s,Ir])||Y(i,Hu,M||""),Y(il(i,h.focusableNodes||""),Es,M?-1:""),g&&Y(i,Es,M?-1:0),B!==Ic(i,wa)&&(oi(i,wa,B),o(B?Nv:zv,$)),!B&&document.activeElement===i){var H=l.Slides.getAt(n.index);H&&Eu(H.slide)}}function L(B,M,H){Pe(H&&E||i,B,M)}function z(){var B=n.index;return B===t||h.cloneStatus&&B===e}function X(){if(n.is(zr))return z();var B=xe(l.Elements.track),M=xe(i),H=m("left",!0),J=m("right",!0);return Xn(B[H])<=Cr(M[H])&&Xn(M[J])<=Cr(B[J])}function Z(B,M){var H=ae(B-t);return!x&&(h.rewind||n.is(Ns))&&(H=Ii(H,n.length-H)),H<=M}var $={index:t,slideIndex:e,slide:i,container:E,isClone:x,mount:D,destroy:S,update:A,style:L,isWithin:Z};return $}function mb(n,t,e){var i=vt(n),s=i.on,r=i.emit,o=i.bind,a=t.Elements,l=a.slides,c=a.list,h=[];function u(){d(),s(Lt,p),s(Lt,d)}function d(){l.forEach(function(A,k){g(A,k,-1)})}function p(){O(function(A){A.destroy()}),fi(h)}function f(){O(function(A){A.update()})}function g(A,k,P){var L=gb(n,k,P,A);L.mount(),h.push(L),h.sort(function(z,X){return z.index-X.index})}function m(A){return A?D(function(k){return!k.isClone}):h}function v(A){var k=t.Controller,P=k.toIndex(A),L=k.hasFocus()?1:e.perPage;return D(function(z){return kn(z.index,P,P+L-1)})}function y(A){return D(A)[0]}function x(A,k){Ee(A,function(P){if(Mi(P)&&(P=Ou(P)),Su(P)){var L=l[k];L?el(P,L):jr(c,P),Ge(P,e.classes.slide),S(P,ot(r,Sr))}}),r(Lt)}function E(A){ss(D(A).map(function(k){return k.slide})),r(Lt)}function O(A,k){m(k).forEach(A)}function D(A){return h.filter(Cu(A)?A:function(k){return Mi(A)?_r(k.slide,A):tl(Fr(A),k.index)})}function C(A,k,P){O(function(L){L.style(A,k,P)})}function S(A,k){var P=il(A,"img"),L=P.length;L?P.forEach(function(z){o(z,"load error",function(){--L||k()})}):k()}function F(A){return A?l.length:h.length}function j(){return h.length>e.perPage}return{mount:u,destroy:p,update:f,register:g,get:m,getIn:v,getAt:y,add:x,remove:E,forEach:O,filter:D,style:C,getLength:F,isEnough:j}}function vb(n,t,e){var i=vt(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,p=a.getAt,f=a.style,g,m,v;function y(){x(),r(window,"resize load",Jv(ot(o,Sr))),s([de,Lt],x),s(Sr,E)}function x(){g=e.direction===yo,Pe(h,"maxWidth",Ui(e.width)),Pe(u,l("paddingLeft"),O(!1)),Pe(u,l("paddingRight"),O(!0)),E(!0)}function E($){var B=xe(h);($||m.width!==B.width||m.height!==B.height)&&(Pe(u,"height",D()),f(l("marginRight"),Ui(e.gap)),f("width",S()),f("height",F(),!0),m=B,o(nl),v!==(v=Z())&&(oi(h,qu,v),o(Wv,v)))}function O($){var B=e.padding,M=l($?"right":"left");return B&&Ui(B[M]||(br(B)?0:B))||"0px"}function D(){var $="";return g&&($=C(),ar($,"height or heightRatio is missing."),$="calc("+$+" - "+O(!1)+" - "+O(!0)+")"),$}function C(){return Ui(e.height||xe(d).width*e.heightRatio)}function S(){return e.autoWidth?null:Ui(e.fixedWidth)||(g?"":j())}function F(){return Ui(e.fixedHeight)||(g?e.autoHeight?null:j():C())}function j(){var $=Ui(e.gap);return"calc((100%"+($&&" + "+$)+")/"+(e.perPage||1)+($&&" - "+$)+")"}function A(){return xe(d)[l("width")]}function k($,B){var M=p($||0);return M?xe(M.slide)[l("width")]+(B?0:z()):0}function P($,B){var M=p($);if(M){var H=xe(M.slide)[l("right")],J=xe(d)[l("left")];return ae(H-J)+(B?0:z())}return 0}function L($){return P(n.length-1)-P(0)+k(0,$)}function z(){var $=p(0);return $&&parseFloat(Pe($.slide,l("marginRight")))||0}function X($){return parseFloat(Pe(u,l("padding"+($?"Right":"Left"))))||0}function Z(){return n.is(zr)||L(!0)>A()}return{mount:y,resize:E,listSize:A,slideSize:k,sliderSize:L,totalSize:P,getPadding:X,isOverflow:Z}}var bb=2;function _b(n,t,e){var i=vt(n),s=i.on,r=t.Elements,o=t.Slides,a=t.Direction.resolve,l=[],c;function h(){s(Lt,u),s([de,Sr],p),(c=m())&&(f(c),t.Layout.resize(!0))}function u(){d(),h()}function d(){ss(l),fi(l),i.destroy()}function p(){var v=m();c!==v&&(c<v||!v)&&i.emit(Lt)}function f(v){var y=o.get().slice(),x=y.length;if(x){for(;y.length<v;)On(y,y);On(y.slice(-v),y.slice(0,v)).forEach(function(E,O){var D=O<v,C=g(E.slide,O);D?el(C,y[0].slide):jr(r.list,C),On(l,C),o.register(C,O-v+(D?0:x),E.index)})}}function g(v,y){var x=v.cloneNode(!0);return Ge(x,e.classes.clone),x.id=n.root.id+"-clone"+rl(y+1),x}function m(){var v=e.clones;if(!n.is(Ns))v=0;else if(Lr(v)){var y=e[a("fixedWidth")]&&t.Layout.slideSize(0),x=y&&Cr(xe(r.track)[a("width")]/y);v=x||e[a("autoWidth")]&&n.length||e.perPage*bb}return v}return{mount:h,destroy:d}}function yb(n,t,e){var i=vt(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,p=t.Direction,f=p.resolve,g=p.orient,m=t.Elements,v=m.list,y=m.track,x;function E(){x=t.Transition,s([ls,nl,de,Lt],O)}function O(){t.Controller.isBusy()||(t.Scroll.cancel(),C(n.index),t.Slides.update())}function D(M,H,J,_t){M!==H&&$(M>J)&&(A(),S(j(L(),M>J),!0)),o($s),r(Li,H,J,M),x.start(H,function(){o(As),r(Br,H,J,M),_t&&_t()})}function C(M){S(P(M,!0))}function S(M,H){if(!n.is(zr)){var J=H?M:F(M);Pe(v,"transform","translate"+f("X")+"("+J+"px)"),M!==J&&r($u)}}function F(M){if(n.is(Ns)){var H=k(M),J=H>t.Controller.getEnd(),_t=H<0;(_t||J)&&(M=j(M,J))}return M}function j(M,H){var J=M-Z(H),_t=d();return M-=g(_t*(Cr(ae(J)/_t)||1))*(H?1:-1),M}function A(){S(L(),!0),x.cancel()}function k(M){for(var H=t.Slides.get(),J=0,_t=1/0,nt=0;nt<H.length;nt++){var pe=H[nt].index,I=ae(P(pe,!0)-M);if(I<=_t)_t=I,J=pe;else break}return J}function P(M,H){var J=g(h(M-1)-X(M));return H?z(J):J}function L(){var M=f("left");return xe(v)[M]-xe(y)[M]+g(c(!1))}function z(M){return e.trimSpace&&n.is(Ps)&&(M=fs(M,0,g(d(!0)-u()))),M}function X(M){var H=e.focus;return H==="center"?(u()-l(M,!0))/2:+H*l(M)||0}function Z(M){return P(M?t.Controller.getEnd():0,!!e.trimSpace)}function $(M){var H=g(j(L(),M));return M?H>=0:H<=v[f("scrollWidth")]-xe(y)[f("width")]}function B(M,H){H=Lr(H)?L():H;var J=M!==!0&&g(H)<g(Z(!1)),_t=M!==!1&&g(H)>g(Z(!0));return J||_t}return{mount:E,move:D,jump:C,translate:S,shift:j,cancel:A,toIndex:k,toPosition:P,getPosition:L,getLimit:Z,exceededLimit:B,reposition:O}}function xb(n,t,e){var i=vt(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,p=e.omitEnd,f=n.is(Ns),g=n.is(Ps),m=ot(L,!1),v=ot(L,!0),y=e.start||0,x,E=y,O,D,C;function S(){F(),s([de,Lt,Kn],F),s(nl,j)}function F(){O=d(!0),D=e.perMove,C=e.perPage,x=$();var I=fs(y,0,p?x:O-1);I!==y&&(y=I,o.reposition())}function j(){x!==$()&&r(Kn)}function A(I,et,Wt){if(!pe()){var lt=P(I),ct=Z(lt);ct>-1&&(et||ct!==y)&&(J(ct),o.move(lt,ct,E,Wt))}}function k(I,et,Wt,lt){t.Scroll.scroll(I,et,Wt,function(){var ct=Z(o.toIndex(a()));J(p?Ii(ct,x):ct),lt&&lt()})}function P(I){var et=y;if(Mi(I)){var Wt=I.match(/([+\-<>])(\d+)?/)||[],lt=Wt[1],ct=Wt[2];lt==="+"||lt==="-"?et=z(y+ +(""+lt+(+ct||1)),y):lt===">"?et=ct?B(+ct):m(!0):lt==="<"&&(et=v(!0))}else et=f?I:fs(I,0,x);return et}function L(I,et){var Wt=D||(nt()?1:C),lt=z(y+Wt*(I?-1:1),y,!(D||nt()));return lt===-1&&g&&!Au(a(),l(!I),1)?I?0:x:et?lt:Z(lt)}function z(I,et,Wt){if(u()||nt()){var lt=X(I);lt!==I&&(et=I,I=lt,Wt=!1),I<0||I>x?!D&&(kn(0,I,et,!0)||kn(x,et,I,!0))?I=B(M(I)):f?I=Wt?I<0?-(O%C||C):O:I:e.rewind?I=I<0?x:0:I=-1:Wt&&I!==et&&(I=B(M(et)+(I<et?-1:1)))}else I=-1;return I}function X(I){if(g&&e.trimSpace==="move"&&I!==y)for(var et=a();et===c(I,!0)&&kn(I,0,n.length-1,!e.rewind);)I<y?--I:++I;return I}function Z(I){return f?(I+O)%O||0:I}function $(){for(var I=O-(nt()||f&&D?1:C);p&&I-- >0;)if(c(O-1,!0)!==c(I,!0)){I++;break}return fs(I,0,O-1)}function B(I){return fs(nt()?I:C*I,0,x)}function M(I){return nt()?Ii(I,x):Xn((I>=x?O-1:I)/C)}function H(I){var et=o.toIndex(I);return g?fs(et,0,x):et}function J(I){I!==y&&(E=y,y=I)}function _t(I){return I?E:y}function nt(){return!Lr(e.focus)||e.isNavigation}function pe(){return n.state.is([$s,Ir])&&!!e.waitForTransition}return{mount:S,go:A,scroll:k,getNext:m,getPrev:v,getAdjacent:L,getEnd:$,setIndex:J,getIndex:_t,toIndex:B,toPage:M,toDest:H,hasFocus:nt,isBusy:pe}}var wb="http://www.w3.org/2000/svg",Cb="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",_n=40;function Sb(n,t,e){var i=vt(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,p=u,f=c.prev,g=c.next,m,v,y={};function x(){O(),s(de,E)}function E(){D(),x()}function O(){var k=e.arrows;k&&!(f&&g)&&F(),f&&g&&(xr(y,{prev:f,next:g}),wr(p,k?"":"none"),Ge(p,v=hl+"--"+e.direction),k&&(C(),A(),Y([f,g],Nr,d.id),o(Gv,f,g)))}function D(){i.destroy(),ai(p,v),m?(ss(u?[f,g]:p),f=g=null):Ye([f,g],cl)}function C(){s([ls,Br,Lt,Bs,Kn],A),r(g,"click",ot(S,">")),r(f,"click",ot(S,"<"))}function S(k){h.go(k,!0)}function F(){p=u||Ts("div",a.arrows),f=j(!0),g=j(!1),m=!0,jr(p,[f,g]),!u&&el(p,d)}function j(k){var P='<button class="'+a.arrow+" "+(k?a.prev:a.next)+'" type="button"><svg xmlns="'+wb+'" viewBox="0 0 '+_n+" "+_n+'" width="'+_n+'" height="'+_n+'" focusable="false"><path d="'+(e.arrowPath||Cb)+'" />';return Ou(P)}function A(){if(f&&g){var k=n.index,P=h.getPrev(),L=h.getNext(),z=P>-1&&k<P?l.last:l.prev,X=L>-1&&k>L?l.first:l.next;f.disabled=P<0,g.disabled=L<0,Y(f,Se,z),Y(g,Se,X),o(Yv,f,g,P,L)}}return{arrows:y,mount:x,destroy:D,update:A}}var Tb=sl+"-interval";function Eb(n,t,e){var i=vt(n),s=i.on,r=i.bind,o=i.emit,a=mo(e.interval,n.go.bind(n,">"),C),l=a.isPaused,c=t.Elements,h=t.Elements,u=h.root,d=h.toggle,p=e.autoplay,f,g,m=p==="pause";function v(){p&&(y(),d&&Y(d,Nr,c.track.id),m||x(),D())}function y(){e.pauseOnHover&&r(u,"mouseenter mouseleave",function(F){f=F.type==="mouseenter",O()}),e.pauseOnFocus&&r(u,"focusin focusout",function(F){g=F.type==="focusin",O()}),d&&r(d,"click",function(){m?x():E(!0)}),s([Li,ol,Lt],a.rewind),s(Li,S)}function x(){l()&&t.Slides.isEnough()&&(a.start(!e.resetProgress),g=f=m=!1,D(),o(Lu))}function E(F){F===void 0&&(F=!0),m=!!F,D(),l()||(a.pause(),o(Fu))}function O(){m||(f||g?E(!1):x())}function D(){d&&(oi(d,rs,!m),Y(d,Se,e.i18n[m?"play":"pause"]))}function C(F){var j=c.bar;j&&Pe(j,"width",F*100+"%"),o(qv,F)}function S(F){var j=t.Slides.getAt(F);a.set(j&&+Ie(j.slide,Tb)||e.interval)}return{mount:v,destroy:a.cancel,play:x,pause:E,isPaused:l}}function Ob(n,t,e){var i=vt(n),s=i.on;function r(){e.cover&&(s(ju,ot(a,!0)),s([ls,de,Lt],ot(o,!0)))}function o(l){t.Slides.forEach(function(c){var h=Rr(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),wr(c,l?"none":"")}return{mount:r,destroy:ot(o,!1)}}var kb=10,Ab=600,Pb=.6,Db=1.5,Mb=800;function Ib(n,t,e){var i=vt(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(Ps),p,f,g=1;function m(){s(Li,E),s([de,Lt],O)}function v(C,S,F,j,A){var k=l();if(E(),F&&(!d||!h())){var P=t.Layout.sliderSize(),L=ya(C)*P*Xn(ae(C)/P)||0;C=a.toPosition(t.Controller.toDest(C%P))+L}var z=Au(k,C,1);g=1,S=z?0:S||Yn(ae(C-k)/Db,Mb),f=j,p=mo(S,y,ot(x,k,C,A),1),o(Ir),r(ol),p.start()}function y(){o(As),f&&f(),r(Bs)}function x(C,S,F,j){var A=l(),k=C+(S-C)*D(j),P=(k-A)*g;u(A+P),d&&!F&&h()&&(g*=Pb,ae(P)<kb&&v(c(h(!0)),Ab,!1,f,!0))}function E(){p&&p.cancel()}function O(){p&&!p.isPaused()&&(E(),y())}function D(C){var S=e.easingFunc;return S?S(C):1-Math.pow(1-C,4)}return{mount:m,destroy:E,scroll:v,cancel:O}}var gs={passive:!1,capture:!0};function Lb(n,t,e){var i=vt(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,p=t.Media.reduce,f=t.Direction,g=f.resolve,m=f.orient,v=c.getPosition,y=c.exceededLimit,x,E,O,D,C,S=!1,F,j,A;function k(){o(d,Xo,ba,gs),o(d,Ko,ba,gs),o(d,Zu,L,gs),o(d,"click",Z,{capture:!0}),o(d,"dragstart",ii),s([ls,de],P)}function P(){var N=e.drag;pl(!N),D=N==="free"}function L(N){if(F=!1,!j){var ht=ct(N);lt(N.target)&&(ht||!N.button)&&(u.isBusy()?ii(N,!0):(A=ht?d:window,C=l.is([$s,Ir]),O=null,o(A,Xo,z,gs),o(A,Ko,X,gs),c.cancel(),h.cancel(),$(N)))}}function z(N){if(l.is(En)||(l.set(En),r(Hv)),N.cancelable)if(C){c.translate(x+Wt(nt(N)));var ht=pe(N)>Hc,Hi=S!==(S=y());(ht||Hi)&&$(N),F=!0,r(Vv),ii(N)}else H(N)&&(C=M(N),ii(N))}function X(N){l.is(En)&&(l.set(As),r(Uv)),C&&(B(N),ii(N)),a(A,Xo,z),a(A,Ko,X),C=!1}function Z(N){!j&&F&&ii(N,!0)}function $(N){O=E,E=N,x=v()}function B(N){var ht=J(N),Hi=_t(ht),Hs=e.rewind&&e.rewindByDrag;p(!1),D?u.scroll(Hi,0,e.snap):n.is(zr)?u.go(m(ya(ht))<0?Hs?"<":"-":Hs?">":"+"):n.is(Ps)&&S&&Hs?u.go(y(!0)?">":"<"):u.go(u.toDest(Hi),!0),p(!0)}function M(N){var ht=e.dragMinThreshold,Hi=br(ht),Hs=Hi&&ht.mouse||0,ed=(Hi?ht.touch:+ht)||10;return ae(nt(N))>(ct(N)?ed:Hs)}function H(N){return ae(nt(N))>ae(nt(N,!0))}function J(N){if(n.is(Ns)||!S){var ht=pe(N);if(ht&&ht<Hc)return nt(N)/ht}return 0}function _t(N){return v()+ya(N)*Ii(ae(N)*(e.flickPower||600),D?1/0:t.Layout.listSize()*(e.flickMaxPages||1))}function nt(N,ht){return et(N,ht)-et(I(N),ht)}function pe(N){return _a(N)-_a(I(N))}function I(N){return E===N&&O||E}function et(N,ht){return(ct(N)?N.changedTouches[0]:N)["page"+g(ht?"Y":"X")]}function Wt(N){return N/(S&&n.is(Ps)?pb:1)}function lt(N){var ht=e.noDrag;return!_r(N,"."+Gu+", ."+wo)&&(!ht||!_r(N,ht))}function ct(N){return typeof TouchEvent<"u"&&N instanceof TouchEvent}function td(){return C}function pl(N){j=N}return{mount:k,disable:pl,isDragging:td}}var Fb={Spacebar:" ",Right:_o,Left:bo,Up:Bu,Down:Nu};function ul(n){return n=Mi(n)?n:n.key,Fb[n]||n}var Vc="keydown";function jb(n,t,e){var i=vt(n),s=i.on,r=i.bind,o=i.unbind,a=n.root,l=t.Direction.resolve,c,h;function u(){d(),s(de,p),s(de,d),s(Li,g)}function d(){var v=e.keyboard;v&&(c=v==="global"?window:a,r(c,Vc,m))}function p(){o(c,Vc)}function f(v){h=v}function g(){var v=h;h=!0,wu(function(){h=v})}function m(v){if(!h){var y=ul(v);y===l(bo)?n.go("<"):y===l(_o)&&n.go(">")}}return{mount:u,destroy:p,disable:f}}var lr=sl+"-lazy",An=lr+"-srcset",Rb="["+lr+"], ["+An+"]";function $b(n,t,e){var i=vt(n),s=i.on,r=i.off,o=i.bind,a=i.emit,l=e.lazyLoad==="sequential",c=[Br,Bs],h=[];function u(){e.lazyLoad&&(d(),s(Lt,d))}function d(){fi(h),p(),l?v():(r(c),s(c,f),f())}function p(){t.Slides.forEach(function(y){il(y.slide,Rb).forEach(function(x){var E=Ie(x,lr),O=Ie(x,An);if(E!==x.src||O!==x.srcset){var D=e.classes.spinner,C=x.parentElement,S=Rr(C,"."+D)||Ts("span",D,C);h.push([x,y,S]),x.src||wr(x,"none")}})})}function f(){h=h.filter(function(y){var x=e.perPage*((e.preloadPages||1)+1)-1;return y[1].isWithin(n.index,x)?g(y):!0}),h.length||r(c)}function g(y){var x=y[0];Ge(y[1].slide,Ca),o(x,"load error",ot(m,y)),Y(x,"src",Ie(x,lr)),Y(x,"srcset",Ie(x,An)),Ye(x,lr),Ye(x,An)}function m(y,x){var E=y[0],O=y[1];ai(O.slide,Ca),x.type!=="error"&&(ss(y[2]),wr(E,""),a(ju,E,O),a(Sr)),l&&v()}function v(){h.length&&g(h.shift())}return{mount:u,destroy:ot(fi,h),check:f}}function Bb(n,t,e){var i=vt(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,p=t.Direction.resolve,f=l.pagination,g=[],m,v;function y(){x(),s([de,Lt,Kn],y);var j=e.pagination;f&&wr(f,j?"":"none"),j&&(s([Li,ol,Bs],F),E(),F(),r(Xv,{list:m,items:g},S(n.index)))}function x(){m&&(ss(f?Ni(m.children):m),ai(m,v),fi(g),m=null),i.destroy()}function E(){var j=n.length,A=e.classes,k=e.i18n,P=e.perPage,L=h()?c.getEnd()+1:Cr(j/P);m=f||Ts("ul",A.pagination,l.track.parentElement),Ge(m,v=Co+"--"+C()),Y(m,hi,"tablist"),Y(m,Se,k.select),Y(m,ll,C()===yo?"vertical":"");for(var z=0;z<L;z++){var X=Ts("li",null,m),Z=Ts("button",{class:A.page,type:"button"},X),$=a.getIn(z).map(function(M){return M.slide.id}),B=!h()&&P>1?k.pageX:k.slideX;o(Z,"click",ot(O,z)),e.paginationKeyboard&&o(Z,"keydown",ot(D,z)),Y(X,hi,"presentation"),Y(Z,hi,"tab"),Y(Z,Nr,$.join(" ")),Y(Z,Se,xa(B,z+1)),Y(Z,Es,-1),g.push({li:X,button:Z,page:z})}}function O(j){d(">"+j,!0)}function D(j,A){var k=g.length,P=ul(A),L=C(),z=-1;P===p(_o,!1,L)?z=++j%k:P===p(bo,!1,L)?z=(--j+k)%k:P==="Home"?z=0:P==="End"&&(z=k-1);var X=g[z];X&&(Eu(X.button),d(">"+z),ii(A,!0))}function C(){return e.paginationDirection||e.direction}function S(j){return g[c.toPage(j)]}function F(){var j=S(u(!0)),A=S(u());if(j){var k=j.button;ai(k,rs),Ye(k,Rc),Y(k,Es,-1)}if(A){var P=A.button;Ge(P,rs),Y(P,Rc,!0),Y(P,Es,"")}r(Kv,{list:m,items:g},j,A)}return{items:g,mount:y,destroy:x,getAt:S,update:F}}var Nb=[" ","Enter"];function zb(n,t,e){var i=e.isNavigation,s=e.slideFocus,r=[];function o(){n.splides.forEach(function(f){f.isParent||(c(n,f.splide),c(f.splide,n))}),i&&h()}function a(){r.forEach(function(f){f.destroy()}),fi(r)}function l(){a(),o()}function c(f,g){var m=vt(f);m.on(Li,function(v,y,x){g.go(g.is(Ns)?x:v)}),r.push(m)}function h(){var f=vt(n),g=f.on;g(Du,d),g(Ru,p),g([ls,de],u),r.push(f),f.emit(Iu,n.splides)}function u(){Y(t.Elements.list,ll,e.direction===yo?"vertical":"")}function d(f){n.go(f.index)}function p(f,g){tl(Nb,ul(g))&&(d(f),ii(g))}return{setup:ot(t.Media.set,{slideFocus:Lr(s)?i:s},!0),mount:o,destroy:a,remount:l}}function Hb(n,t,e){var i=vt(n),s=i.bind,r=0;function o(){e.wheel&&s(t.Elements.track,"wheel",a,gs)}function a(c){if(c.cancelable){var h=c.deltaY,u=h<0,d=_a(c),p=e.wheelMinThreshold||0,f=e.wheelSleep||0;ae(h)>p&&d-r>f&&(n.go(u?"<":">"),r=d),l(u)&&ii(c)}}function l(c){return!e.releaseWheel||n.state.is($s)||t.Controller.getAdjacent(c)!==-1}return{mount:o}}var Vb=90;function Ub(n,t,e){var i=vt(n),s=i.on,r=t.Elements.track,o=e.live&&!e.isNavigation,a=Ts("span",lb),l=mo(Vb,ot(h,!1));function c(){o&&(d(!t.Autoplay.isPaused()),Y(r,Nc,!0),a.textContent="…",s(Lu,ot(d,!0)),s(Fu,ot(d,!1)),s([Br,Bs],ot(h,!0)))}function h(p){Y(r,Bc,p),p?(jr(r,a),l.start()):(ss(a),l.cancel())}function u(){Ye(r,[$c,Nc,Bc]),ss(a)}function d(p){o&&Y(r,$c,p?"off":"polite")}return{mount:c,disable:d,destroy:u}}var Wb=Object.freeze({__proto__:null,Media:Qv,Direction:tb,Elements:fb,Slides:mb,Layout:vb,Clones:_b,Move:yb,Controller:xb,Arrows:Sb,Autoplay:Eb,Cover:Ob,Scroll:Ib,Drag:Lb,Keyboard:jb,LazyLoad:$b,Pagination:Bb,Sync:zb,Wheel:Hb,Live:Ub}),Gb={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"},Yb={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:ub,i18n:Gb,reducedMotion:{speed:0,rewindSpeed:0,autoplay:"pause"}};function Xb(n,t,e){var i=t.Slides;function s(){vt(n).on([ls,Lt],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),wu(l)}return{mount:s,start:o,cancel:ba}}function Kb(n,t,e){var i=t.Move,s=t.Controller,r=t.Scroll,o=t.Elements.list,a=ot(Pe,o,"transition"),l;function c(){vt(n).bind(o,"transitionend",function(p){p.target===o&&l&&(u(),l())})}function h(p,f){var g=i.toPosition(p,!0),m=i.getPosition(),v=d(p);ae(g-m)>=1&&v>=1?e.useScroll?r.scroll(g,v,!1,f):(a("transform "+v+"ms "+e.easing),i.translate(g,!0),l=f):(i.jump(p),f())}function u(){a(""),r.cancel()}function d(p){var f=e.rewindSpeed;if(n.is(Ps)&&f){var g=s.getIndex(!0),m=s.getEnd();if(g===0&&p>=m||g>=m&&p===0)return f}return e.speed}return{mount:c,start:h,cancel:u}}var qb=function(){function n(e,i){this.event=vt(),this.Components={},this.state=Zv(xs),this.splides=[],this._o={},this._E={};var s=Mi(e)?ku(document,e):e;ar(s,s+" is invalid."),this.root=s,i=Ti({label:Ie(s,Se)||"",labelledby:Ie(s,al)||""},Yb,n.defaults,i||{});try{Ti(i,JSON.parse(Ie(s,sl)))}catch{ar(!1,"Invalid JSON")}this._o=Object.create(Ti({},i))}var t=n.prototype;return t.mount=function(i,s){var r=this,o=this.state,a=this.Components;ar(o.is([xs,Gn]),"Already mounted!"),o.set(xs),this._C=a,this._T=s||this._T||(this.is(zr)?Xb:Kb),this._E=i||this._E;var l=xr({},Wb,this._E,{Transition:this._T});return Qi(l,function(c,h){var u=c(r,a,r._o);a[h]=u,u.setup&&u.setup()}),Qi(a,function(c){c.mount&&c.mount()}),this.emit(ls),Ge(this.root,cb),o.set(As),this.emit(Fc),this},t.sync=function(i){return this.splides.push({splide:i}),i.splides.push({splide:this,isParent:!0}),this.state.is(As)&&(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(Ni(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(Lt),this},t.destroy=function(i){i===void 0&&(i=!0);var s=this.event,r=this.state;return r.is(xs)?vt(this).on(Fc,this.destroy.bind(this,i)):(Qi(this._C,function(o){o.destroy&&o.destroy(i)},!0),s.emit(Mu),s.destroy(),i&&fi(this.splides),r.set(Gn)),this},Lv(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}(),dl=qb;dl.defaults={};dl.STATES=jv;/**
2451
2511
  * @license
2452
2512
  * Copyright 2021 Google LLC
2453
2513
  * SPDX-License-Identifier: BSD-3-Clause
2454
- */function*iu(n,t){if(n!==void 0){let e=0;for(const i of n)yield t(i,e++)}}var zv=Object.defineProperty,Vv=Object.getOwnPropertyDescriptor,Cs=(n,t,e,i)=>{for(var r=i>1?void 0:i?Vv(t,e):t,s=n.length-1,o;s>=0;s--)(o=n[s])&&(r=(i?o(t,e,r):o(r))||r);return i&&r&&zv(t,e,r),r};let Ei=class extends Bt{constructor(){super(...arguments),this.slides=[],this.cards=[],this.firstUpdated=()=>{this.imageSplide=new ja(this.imageCarousel,{perPage:2,perMove:1,autoHeight:!0,gap:"0.6%",rewind:!1,pagination:!1,isNavigation:!1,mediaQuery:"min",breakpoints:{640:{perPage:4,gap:"1rem"}}}),this.imageSplide.on("arrows:mounted arrows:updated",()=>{this.updateArrowVisibility()}),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}})}}updateArrowVisibility(){const t=this.imageCarousel.querySelector(".splide__arrow--next"),e=this.imageCarousel.querySelector(".splide__arrow--prev");t.style.visibility=t.disabled?"hidden":"visible",e.style.visibility=e.disabled?"hidden":"visible"}render(){return X`
2514
+ */function*Ju(n,t){if(n!==void 0){let e=0;for(const i of n)yield t(i,e++)}}var Zb=Object.defineProperty,Jb=Object.getOwnPropertyDescriptor,Hr=(n,t,e,i)=>{for(var s=i>1?void 0:i?Jb(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&&Zb(t,e,s),s};let Fi=class extends It{constructor(){super(...arguments),this.slides=[],this.cards=[],this.firstUpdated=()=>{this.imageSplide=new dl(this.imageCarousel,{perPage:2,perMove:1,autoHeight:!0,gap:"0.6%",rewind:!1,pagination:!1,isNavigation:!1,mediaQuery:"min",breakpoints:{640:{perPage:4,gap:"1rem"}}}),this.imageSplide.on("arrows:mounted arrows:updated",()=>{this.updateArrowVisibility()}),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}})}}updateArrowVisibility(){const t=this.imageCarousel.querySelector(".splide__arrow--next"),e=this.imageCarousel.querySelector(".splide__arrow--prev");t.style.visibility=t.disabled?"hidden":"visible",e.style.visibility=e.disabled?"hidden":"visible"}render(){return W`
2455
2515
  <div class="category-container">
2456
2516
  <slot name="title"></slot>
2457
2517
  <div
@@ -2461,7 +2521,7 @@ good aklsdfja`,this.alignment="left",this.fontFamily="Arial",this.color="#000",t
2461
2521
  >
2462
2522
  <div class="splide__track">
2463
2523
  <ul class="splide__list">
2464
- ${iu(this.cards,t=>X`
2524
+ ${Ju(this.cards,t=>W`
2465
2525
  <li class="splide__slide">
2466
2526
  <img
2467
2527
  src=${t.medias.cover.url}
@@ -2475,15 +2535,261 @@ good aklsdfja`,this.alignment="left",this.fontFamily="Arial",this.color="#000",t
2475
2535
  </div>
2476
2536
  </div>
2477
2537
  </div>
2478
- `}};Ei.styles=[Pt,xm,kn(Th)];Cs([q("#category-carousel")],Ei.prototype,"imageCarousel",2);Cs([$()],Ei.prototype,"imageSplide",2);Cs([$()],Ei.prototype,"slides",2);Cs([O({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)}}})],Ei.prototype,"cards",2);Ei=Cs([Ot("pbo-category")],Ei);const Ib=Ei,Lb=cu,Fb=hu,Hv=vt`
2538
+ `}};Fi.styles=[wt,Mv,Or(xu)];Hr([q("#category-carousel")],Fi.prototype,"imageCarousel",2);Hr([V()],Fi.prototype,"imageSplide",2);Hr([V()],Fi.prototype,"slides",2);Hr([T({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)}}})],Fi.prototype,"cards",2);Fi=Hr([bt("pbo-category")],Fi);const n0=Fi,Qb=at`
2539
+ :host {
2540
+ --size: 70%;
2541
+ --header-spacing: var(--pbo-spacing-large);
2542
+ --body-spacing: var(--pbo-spacing-large);
2543
+ --footer-spacing: var(--pbo-spacing-large);
2544
+ --panel-background-color: var(--pbo-panel-background-color);
2545
+ --overlay-background-color: var(--pbo-overlay-background-color);
2546
+ display: contents;
2547
+ }
2548
+
2549
+ .drawer {
2550
+ top: 0;
2551
+ inset-inline-start: 0;
2552
+ width: 100%;
2553
+ height: 100%;
2554
+ pointer-events: none;
2555
+ overflow: hidden;
2556
+ }
2557
+
2558
+ .drawer__overlay {
2559
+ display: block;
2560
+ position: fixed;
2561
+ top: 0;
2562
+ right: 0;
2563
+ bottom: 0;
2564
+ left: 0;
2565
+ background-color: var(--overlay-background-color);
2566
+ pointer-events: all;
2567
+ backdrop-filter: blur(1px);
2568
+ -webkit-backdrop-filter: blur(1px);
2569
+ }
2570
+
2571
+ .drawer--contained .drawer__overlay {
2572
+ display: none;
2573
+ }
2574
+
2575
+ .drawer__panel {
2576
+ position: absolute;
2577
+ flex-direction: column;
2578
+ z-index: 2;
2579
+ max-width: 100%;
2580
+ max-height: 100%;
2581
+ background-color: var(--panel-background-color);
2582
+ box-shadow: var(--pbo-shadow-x-large);
2583
+ overflow: auto;
2584
+ pointer-events: all;
2585
+ }
2586
+
2587
+ .drawer--bottom .drawer__panel {
2588
+ top: auto;
2589
+ inset-inline-end: auto;
2590
+ bottom: 0;
2591
+ inset-inline-start: 0;
2592
+ width: 100%;
2593
+ height: var(--size);
2594
+ border-radius: var(--pbo-border-radius-large) var(--pbo-border-radius-large) 0 0;
2595
+ }
2596
+
2597
+ .drawer--left .drawer__panel {
2598
+ top: auto;
2599
+ inset-inline-end: auto;
2600
+ left: 0;
2601
+ inset-inline-start: 0;
2602
+ height: 100%;
2603
+ width: var(--size);
2604
+ }
2605
+
2606
+ .drawer--right .drawer__panel {
2607
+ top: auto;
2608
+ inset-inline-end: auto;
2609
+ right: 0;
2610
+ inset-inline-start: 0;
2611
+ height: 100%;
2612
+ width: var(--size);
2613
+ }
2614
+
2615
+ .drawer--top .drawer__panel {
2616
+ top: auto;
2617
+ inset-inline-end: auto;
2618
+ top: 0;
2619
+ inset-inline-start: 0;
2620
+ width: 100%;
2621
+ height: var(--size);
2622
+ }
2623
+ `;var t_=Object.defineProperty,e_=Object.getOwnPropertyDescriptor,cs=(n,t,e,i)=>{for(var s=i>1?void 0:i?e_(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_(t,e,s),s};let Xe=class extends It{constructor(){super(...arguments),this.open=!1,this.placement="bottom",this.radius=!0,this.contained=!1}requestClose(n){this.hide()}async hide(){this.open=!1,this.emit("pbo-after-drawer-closed")}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 W`
2624
+ <div
2625
+ part="base"
2626
+ class=${je({drawer:!0,"drawer--bottom":this.placement==="bottom","drawer--top":this.placement==="top","drawer--left":this.placement==="left","drawer--right":this.placement==="right","drawer--open":this.open,"drawer--contained":this.contained})}
2627
+ >
2628
+ <div part="overlay" class="drawer__overlay" @click=${()=>this.requestClose("overlay")}></div>
2629
+ <div
2630
+ part="panel"
2631
+ class="${je({drawer__panel:!0})}"
2632
+ role="dialog"
2633
+ aria-modal="true"
2634
+ aria-hidden=${this.open?"false":"true"}
2635
+ tabindex="0"
2636
+ >
2637
+ <slot part="body" class="drawer__body"></slot>
2638
+ </div>
2639
+ </div>
2640
+ `}};Xe.styles=[wt,Qb];cs([q(".drawer")],Xe.prototype,"drawer",2);cs([T({type:Boolean,reflect:!0})],Xe.prototype,"open",2);cs([T({reflect:!0})],Xe.prototype,"placement",2);cs([T({type:Boolean,reflect:!0})],Xe.prototype,"radius",2);cs([T({type:Boolean,reflect:!0})],Xe.prototype,"contained",2);cs([Q("open",{waitUntilFirstUpdate:!0})],Xe.prototype,"handleOpenChange",1);Xe=cs([bt("pbo-drawer")],Xe);const o0=Xe,i_=at`
2641
+ :host {
2642
+ display: block;
2643
+ width: 100%;
2644
+ height: 100%;
2645
+ }
2646
+
2647
+ .body {
2648
+ overflow: scroll;
2649
+ }
2650
+
2651
+ .back-button {
2652
+ display: flex;
2653
+ justify-content: start;
2654
+ }
2655
+
2656
+ .close-button {
2657
+ display: flex;
2658
+ justify-content: end;
2659
+ }
2660
+
2661
+ .header {
2662
+ height: 2.5rem;
2663
+ padding: 0 var(--pbo-spacing-large);
2664
+ user-select: none;
2665
+ position: sticky;
2666
+ top: 0;
2667
+ background-color: var(--pbo-color-gray-100);
2668
+ display: grid;
2669
+ grid-template-columns: 1fr auto 1fr;
2670
+ align-items: center;
2671
+ font-size: var(--pbo-font-size-2xl);
2672
+ }
2673
+
2674
+ .title {
2675
+ font-size: var(--pbo-font-size-x-large);
2676
+ }
2677
+
2678
+ .icon-button {
2679
+ all: unset; /* Removes default button styles (border, background, padding, etc.) */
2680
+ display: flex;
2681
+ align-items: center;
2682
+ justify-content: center;
2683
+ cursor: pointer;
2684
+ color: var(--pbo-color-gray-500); /* Default icon color */
2685
+ transition:
2686
+ transform 0.2s ease-in-out,
2687
+ color 0.2s ease-in-out;
2688
+ }
2689
+
2690
+ /* Apply hover effect */
2691
+ .icon-button:hover {
2692
+ transform: scale(1.1); /* Slightly enlarges the icon */
2693
+ color: var(--pbo-color-gray-700); /* Changes icon color on hover */
2694
+ }
2695
+
2696
+ .page-manager {
2697
+ position: relative;
2698
+ height: 100%;
2699
+ width: 100%;
2700
+ display: grid;
2701
+ grid-template-rows: min-content auto;
2702
+ grid-gap: 0;
2703
+ }
2704
+
2705
+ .category-selection {
2706
+ display: grid;
2707
+ height: 100%;
2708
+ grid-template-columns: repeat(12, 1fr);
2709
+ padding: var(--pbo-spacing-small);
2710
+ }
2711
+ @media screen and (min-width: 640px) {
2712
+ .category-selection {
2713
+ padding: var(--pbo-spacing-medium);
2714
+ }
2715
+ }
2716
+
2717
+ .category-selection pbo-card-selection {
2718
+ grid-column: 1 / span 12;
2719
+ }
2720
+
2721
+ .editor {
2722
+ padding: var(--pbo-spacing-small);
2723
+ }
2724
+
2725
+ @media screen and (min-width: 640px) {
2726
+ .editor {
2727
+ padding: var(--pbo-spacing-medium);
2728
+ }
2729
+ }
2730
+
2731
+ @media screen and (min-width: 768px) {
2732
+ .category-selection pbo-card-selection {
2733
+ grid-column: 2 / span 10;
2734
+ }
2735
+ }
2736
+
2737
+ @media screen and (min-width: 1280px) {
2738
+ .category-selection pbo-card-selection {
2739
+ grid-column: 4 / span 7;
2740
+ }
2741
+ }
2742
+ `;var s_=Object.defineProperty,r_=Object.getOwnPropertyDescriptor,Qt=(n,t,e,i)=>{for(var s=i>1?void 0:i?r_(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 $t=class extends It{constructor(){super(...arguments),this.onClose=()=>{},this.currentPage="selection",this.categories=[],this.selectedCard=null,this.selectedCardId=null,this.selectedCardDetails=null,this.handleCardSelected=t=>{const{cardId:e}=t.detail,i=this.findCardInCategoryById(e);console.log(t),this.editorEl.card=i,this.goToEditor()}}handleSubmitTypeFormUpdate(){this.editorEl.submitTypeForm=async t=>{this.submitTypeForm&&(this.editorEl.typeForm.disabled=!0,this.editorEl.typeForm.loading=!0,await this.submitTypeForm(t),this.editorEl.typeForm.disabled=!1,this.editorEl.typeForm.loading=!1)}}handleSubmitHandwrittenFormUpdate(){this.editorEl.submitHandwrittenForm=async t=>{this.submitHandwrittenForm&&(this.editorEl.handwrittenForm.isSubmitDisabled=!0,this.editorEl.handwrittenForm.isSubmitLoading=!0,await this.submitHandwrittenForm(t),this.editorEl.handwrittenForm.isSubmitDisabled=!1,this.editorEl.handwrittenForm.isSubmitLoading=!1)}}handleGetProcessedImgUpdate(){this.editorEl.getProcessedImg=this.getProcessedImg}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}handleCategoriesUpdate(){console.log(this.categories),this.cardSelectionEl&&this.categories!==void 0&&this.categories.length>0&&(this.cardSelectionEl.categories=this.categories,this.requestUpdate())}findCardInCategoryById(t){console.log("Categories from findCardInCategoryById",this.categories);for(const e of this.categories){const i=e.cards.find(s=>s.pboId===t);if(console.log("card from findCardInCategoryById",i),i)return i}return null}render(){return W`
2743
+ <div part="base" class="page-manager">
2744
+ <div class="header">
2745
+ <div class="back-button">
2746
+ ${this.currentPage!=="selection"?W`<button @click=${this.goToSelector} class="icon-button">
2747
+ <svg
2748
+ xmlns="http://www.w3.org/2000/svg"
2749
+ height="24px"
2750
+ viewBox="0 -960 960 960"
2751
+ width="24px"
2752
+ fill="currentColor"
2753
+ >
2754
+ <path d="m313-440 224 224-57 56-320-320 320-320 57 56-224 224h487v80H313Z" />
2755
+ </svg>
2756
+ </button>`:""}
2757
+ </div>
2758
+ <div class="title">${this.currentPage==="selection"?"SELECT CARD":"PERSONALIZE"}</div>
2759
+ <div class="close-button">
2760
+ <button @click=${this.onClose} class="icon-button">
2761
+ <svg
2762
+ xmlns="http://www.w3.org/2000/svg"
2763
+ height="24px"
2764
+ viewBox="0 -960 960 960"
2765
+ width="24px"
2766
+ fill="currentColor"
2767
+ >
2768
+ <path
2769
+ d="m256-200-56-56 224-224-224-224 56-56 224 224 224-224 56 56-224 224 224 224-56 56-224-224-224 224Z"
2770
+ />
2771
+ </svg>
2772
+ </button>
2773
+ </div>
2774
+ </div>
2775
+ <div class="body">
2776
+ <div class="category-selection" ?hidden=${this.currentPage!=="selection"}>
2777
+ <pbo-card-selection name="selection"></pbo-card-selection>
2778
+ </div>
2779
+ <div class="editor" ?hidden=${this.currentPage!=="editor"}>
2780
+ <pbo-editor name="editor" ?hidden=${this.currentPage!=="editor"}></pbo-editor>
2781
+ </div>
2782
+ </div>
2783
+ </div>
2784
+ `}};$t.styles=[wt,i_];Qt([q("pbo-card-selection")],$t.prototype,"cardSelectionEl",2);Qt([q("pbo-editor")],$t.prototype,"editorEl",2);Qt([T({type:Function})],$t.prototype,"onClose",2);Qt([T({type:String,reflect:!0})],$t.prototype,"currentPage",2);Qt([T()],$t.prototype,"categories",2);Qt([T()],$t.prototype,"submitTypeForm",2);Qt([T()],$t.prototype,"submitHandwrittenForm",2);Qt([T()],$t.prototype,"getProcessedImg",2);Qt([V()],$t.prototype,"selectedCard",2);Qt([V()],$t.prototype,"selectedCardId",2);Qt([V()],$t.prototype,"selectedCardDetails",2);Qt([Q("submitTypeForm")],$t.prototype,"handleSubmitTypeFormUpdate",1);Qt([Q("submitHandwrittenForm")],$t.prototype,"handleSubmitHandwrittenFormUpdate",1);Qt([Q("getProcessedImg")],$t.prototype,"handleGetProcessedImgUpdate",1);Qt([Q("categories")],$t.prototype,"handleCategoriesUpdate",1);$t=Qt([bt("pbo-page-manager")],$t);const l0=$t,n_=at`
2479
2785
  :host {
2480
2786
  display: block;
2481
2787
  }
2482
- `;var $v=Object.defineProperty,Wv=Object.getOwnPropertyDescriptor,ru=(n,t,e,i)=>{for(var r=i>1?void 0:i?Wv(t,e):t,s=n.length-1,o;s>=0;s--)(o=n[s])&&(r=(i?o(t,e,r):o(r))||r);return i&&r&&$v(t,e,r),r};let ls=class extends Bt{constructor(){super(...arguments),this.categories=[]}render(){return X`
2483
- ${iu(this.categories,t=>X`<pbo-category .cards=${t.cards} .name=${t.name}>
2788
+ `;var o_=Object.defineProperty,a_=Object.getOwnPropertyDescriptor,Qu=(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 Er=class extends It{constructor(){super(...arguments),this.categories=[]}render(){return W`
2789
+ ${Ju(this.categories,t=>W`<pbo-category .cards=${t.cards} .name=${t.name}>
2484
2790
  <h3 slot="title">${t.name}</h3>
2485
2791
  </pbo-category>`)}
2486
- `}};ls.styles=[Pt,Hv];ru([O({type:Array})],ls.prototype,"categories",2);ls=ru([Ot("pbo-card-selection")],ls);const Rb=ls,Gv=vt`
2792
+ `}};Er.styles=[wt,n_];Qu([T({type:Array})],Er.prototype,"categories",2);Er=Qu([bt("pbo-card-selection")],Er);const h0=Er,l_=at`
2487
2793
  :host {
2488
2794
  display: block;
2489
2795
  width: 100%;
@@ -2511,8 +2817,8 @@ good aklsdfja`,this.alignment="left",this.fontFamily="Arial",this.color="#000",t
2511
2817
  display: block;
2512
2818
  object-fit: contain;
2513
2819
  }
2514
- `;var Uv=Object.defineProperty,Yv=Object.getOwnPropertyDescriptor,jt=(n,t,e,i)=>{for(var r=i>1?void 0:i?Yv(t,e):t,s=n.length-1,o;s>=0;s--)(o=n[s])&&(r=(i?o(t,e,r):o(r))||r);return i&&r&&Uv(t,e,r),r};let yt=class extends Bt{constructor(){super(...arguments),this.backgroundImageUrl=void 0,this.message="",this.font="Arial",this.color="#000",this.alignment="left",this.backgroundImage=void 0,this.backgroundFabImg=void 0,this.rect=void 0,this.textBox=void 0,this.areaPosition={left:0,top:0},this.areaSize={width:0,height:0}}handleAlignmentChange(t,e){t!==e&&this.textBox&&(this.textBox.set("textAlign",e),this.canvas.renderAll())}handleColorChange(t,e){t!==e&&this.textBox&&(this.textBox.set("fill",e),this.canvas.renderAll())}handleFontChange(t,e){t!==e&&this.textBox&&(this.textBox.set("fontFamily",e),this.canvas.renderAll())}handleMessageChange(t,e){if(this.textBox){this.textBox.set("text",e);const i=this.textBox.textLines;i.length>12&&this.textBox.set("text",i.slice(0,12).join(`
2515
- `)),this.updateTextAreaPosition(),this.canvas.renderAll()}}async handleBackgroundImageUrlChange(){this.canvas&&(this.backgroundFabImg&&this.canvas.remove(this.backgroundFabImg),await this.appendBackgroundImageToCanvas(this.backgroundImageUrl||"https://cdn.shopify.com/s/files/1/1956/2323/files/insert_86e8bcd5-3e82-4910-b350-485fa6958502.png?v=1726598821"),this.updateTextAreaPosition(),this.canvas.renderAll())}updateTextAreaPosition(){this.areaPosition={left:.084*this.canvas.getWidth(),top:.4874*this.canvas.getHeight()},this.areaSize={width:.832*this.canvas.getWidth(),height:this.canvas.getHeight()-this.areaPosition.top-this.areaPosition.left},this.rect?(this.rect.set("left",this.areaPosition.left),this.rect.set("top",this.areaPosition.top),this.rect.set("width",this.areaSize.width),this.rect.set("height",this.areaSize.height)):(this.rect=new Rt({left:this.areaPosition.left,top:this.areaPosition.top,width:this.areaSize.width,height:this.areaSize.height,selectable:!1,fill:"rgba(255, 255, 255, 0)"}),this.canvas.add(this.rect)),this.textBox?(this.textBox.set("left",this.areaPosition.left),this.textBox.set("top",this.areaPosition.top),this.textBox.set("width",this.areaSize.width),this.textBox.set("height",this.areaSize.height),this.textBox.set("lineHeight",1.1),this.textBox.set("fontSize",this.areaSize.height/13/1.1)):(this.textBox=new Qe(this.message,{left:this.areaPosition.left,top:this.areaPosition.top,width:this.areaSize.width,height:this.areaSize.height,lineHeight:1.1,fontSize:this.areaSize.height/13/1.1,alignment:"left",selectable:!1,objectCaching:!1,paintFirst:"stroke",strokeWidth:.5}),this.canvas.add(this.textBox))}async firstUpdated(){this.canvas=new Jr(this.baseCanvas,{width:500,height:500,containerClass:"fabric-container",selection:!1}),this.backgroundImageUrl&&await this.appendBackgroundImageToCanvas(this.backgroundImageUrl,()=>{}),this.updateTextAreaPosition(),this.canvas.renderAll()}async appendBackgroundImageToCanvas(t,e){const i=await Ut.fromURL(t);i.selectable=!1,this.backgroundFabImg=i,this.canvas.setDimensions({width:i.width,height:i.height}),this.canvas.add(i),this.canvas.sendObjectToBack(i),await this.canvas.renderAll(),e&&e()}render(){return X`<canvas class="base-canvas"></canvas> `}};yt.styles=[Pt,Gv];jt([O({attribute:"background-url"})],yt.prototype,"backgroundImageUrl",2);jt([O()],yt.prototype,"message",2);jt([O()],yt.prototype,"font",2);jt([O()],yt.prototype,"color",2);jt([O()],yt.prototype,"alignment",2);jt([q(".base-canvas")],yt.prototype,"baseCanvas",2);jt([$()],yt.prototype,"canvas",2);jt([$()],yt.prototype,"backgroundImage",2);jt([$()],yt.prototype,"backgroundFabImg",2);jt([$()],yt.prototype,"rect",2);jt([$()],yt.prototype,"textBox",2);jt([$()],yt.prototype,"areaPosition",2);jt([$()],yt.prototype,"areaSize",2);jt([et("alignment")],yt.prototype,"handleAlignmentChange",1);jt([et("color")],yt.prototype,"handleColorChange",1);jt([et("font")],yt.prototype,"handleFontChange",1);jt([et("message")],yt.prototype,"handleMessageChange",1);jt([et("backgroundImageUrl")],yt.prototype,"handleBackgroundImageUrlChange",1);yt=jt([Ot("pbo-type-canvas")],yt);const Nb=yt,Xv=vt`
2820
+ `;var c_=Object.defineProperty,h_=Object.getOwnPropertyDescriptor,Bt=(n,t,e,i)=>{for(var s=i>1?void 0:i?h_(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&&c_(t,e,s),s};let xt=class extends It{constructor(){super(...arguments),this.backgroundImageUrl=void 0,this.message="",this.font="Arial",this.color="#000",this.alignment="left",this.backgroundImage=void 0,this.backgroundFabImg=void 0,this.rect=void 0,this.textBox=void 0,this.areaPosition={left:0,top:0},this.areaSize={width:0,height:0}}handleAlignmentChange(t,e){t!==e&&this.textBox&&(this.textBox.set("textAlign",e),this.canvas.renderAll())}handleColorChange(t,e){t!==e&&this.textBox&&(this.textBox.set("fill",e),this.canvas.renderAll())}handleFontChange(t,e){t!==e&&this.textBox&&(this.textBox.set("fontFamily",e),this.canvas.renderAll())}handleMessageChange(t,e){if(this.textBox){this.textBox.set("text",e);const i=this.textBox.textLines;i.length>12&&this.textBox.set("text",i.slice(0,12).join(`
2821
+ `)),this.updateTextAreaPosition(),this.canvas.renderAll()}}async handleBackgroundImageUrlChange(){this.canvas&&(this.backgroundFabImg&&this.canvas.remove(this.backgroundFabImg),await this.appendBackgroundImageToCanvas(this.backgroundImageUrl||"https://cdn.shopify.com/s/files/1/1956/2323/files/insert_86e8bcd5-3e82-4910-b350-485fa6958502.png?v=1726598821"),this.updateTextAreaPosition(),this.canvas.renderAll())}updateTextAreaPosition(){this.areaPosition={left:.084*this.canvas.getWidth(),top:.4874*this.canvas.getHeight()},this.areaSize={width:.832*this.canvas.getWidth(),height:this.canvas.getHeight()-this.areaPosition.top-this.areaPosition.left},this.rect?(this.rect.set("left",this.areaPosition.left),this.rect.set("top",this.areaPosition.top),this.rect.set("width",this.areaSize.width),this.rect.set("height",this.areaSize.height)):(this.rect=new Nt({left:this.areaPosition.left,top:this.areaPosition.top,width:this.areaSize.width,height:this.areaSize.height,selectable:!1,fill:"rgba(255, 255, 255, 0)"}),this.canvas.add(this.rect)),this.textBox?(this.textBox.set("left",this.areaPosition.left),this.textBox.set("top",this.areaPosition.top),this.textBox.set("width",this.areaSize.width),this.textBox.set("height",this.areaSize.height),this.textBox.set("lineHeight",1.1),this.textBox.set("fontSize",this.areaSize.height/13/1.1)):(this.textBox=new ni(this.message,{left:this.areaPosition.left,top:this.areaPosition.top,width:this.areaSize.width,height:this.areaSize.height,lineHeight:1.1,fontSize:this.areaSize.height/13/1.1,alignment:"left",selectable:!1,objectCaching:!1,paintFirst:"stroke",strokeWidth:.5}),this.canvas.add(this.textBox))}async firstUpdated(){this.canvas=new mr(this.baseCanvas,{width:500,height:500,containerClass:"fabric-container",selection:!1}),this.backgroundImageUrl&&await this.appendBackgroundImageToCanvas(this.backgroundImageUrl,()=>{}),this.updateTextAreaPosition(),this.canvas.renderAll()}async appendBackgroundImageToCanvas(t,e){const i=await Xt.fromURL(t);i.selectable=!1,this.backgroundFabImg=i,this.canvas.setDimensions({width:i.width,height:i.height}),this.canvas.add(i),this.canvas.sendObjectToBack(i),await this.canvas.renderAll(),e&&e()}render(){return W`<canvas class="base-canvas"></canvas> `}};xt.styles=[wt,l_];Bt([T({attribute:"background-url"})],xt.prototype,"backgroundImageUrl",2);Bt([T()],xt.prototype,"message",2);Bt([T()],xt.prototype,"font",2);Bt([T()],xt.prototype,"color",2);Bt([T()],xt.prototype,"alignment",2);Bt([q(".base-canvas")],xt.prototype,"baseCanvas",2);Bt([V()],xt.prototype,"canvas",2);Bt([V()],xt.prototype,"backgroundImage",2);Bt([V()],xt.prototype,"backgroundFabImg",2);Bt([V()],xt.prototype,"rect",2);Bt([V()],xt.prototype,"textBox",2);Bt([V()],xt.prototype,"areaPosition",2);Bt([V()],xt.prototype,"areaSize",2);Bt([Q("alignment")],xt.prototype,"handleAlignmentChange",1);Bt([Q("color")],xt.prototype,"handleColorChange",1);Bt([Q("font")],xt.prototype,"handleFontChange",1);Bt([Q("message")],xt.prototype,"handleMessageChange",1);Bt([Q("backgroundImageUrl")],xt.prototype,"handleBackgroundImageUrlChange",1);xt=Bt([bt("pbo-type-canvas")],xt);const d0=xt,u_=at`
2516
2822
  :host {
2517
2823
  display: block;
2518
2824
  height: 100%;
@@ -2553,11 +2859,11 @@ good aklsdfja`,this.alignment="left",this.fontFamily="Arial",this.color="#000",t
2553
2859
  fill: #fff9f9;
2554
2860
  scale: 1.1;
2555
2861
  }
2556
- `;var Kv=Object.defineProperty,qv=Object.getOwnPropertyDescriptor,Ss=(n,t,e,i)=>{for(var r=i>1?void 0:i?qv(t,e):t,s=n.length-1,o;s>=0;s--)(o=n[s])&&(r=(i?o(t,e,r):o(r))||r);return i&&r&&Kv(t,e,r),r};let Oi=class extends Bt{constructor(){super(...arguments),this.formData={font:"Monsieur La Doulaise",text:"",color:"rgb(0,0,0)",alignment:"left"},this.cardUrl="",this.handwrittenPreviewProps={isLoading:!1,url:""}}render(){return X`
2862
+ `;var d_=Object.defineProperty,p_=Object.getOwnPropertyDescriptor,Vr=(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&&d_(t,e,s),s};let ji=class extends It{constructor(){super(...arguments),this.formData={font:"Monsieur La Doulaise",text:"",color:"rgb(0,0,0)",alignment:"left"},this.cardUrl="",this.handwrittenPreviewProps={isLoading:!1,url:""}}render(){return W`
2557
2863
  <div class="panel">
2558
2864
  <div class="zoomed-preview">
2559
2865
  <div
2560
- style=${pe({display:"flex","justify-content":"center",flexDirection:"column",height:"100%"})}
2866
+ style=${me({display:"flex","justify-content":"center",flexDirection:"column",height:"100%"})}
2561
2867
  >
2562
2868
  <slot part="base"></slot>
2563
2869
  </div>
@@ -2571,7 +2877,7 @@ good aklsdfja`,this.alignment="left",this.fontFamily="Arial",this.color="#000",t
2571
2877
  </svg>
2572
2878
  </div>
2573
2879
  </div>
2574
- `}};Oi.styles=[Pt,Xv];Ss([O()],Oi.prototype,"formData",2);Ss([O()],Oi.prototype,"cardUrl",2);Ss([O()],Oi.prototype,"close",2);Ss([O()],Oi.prototype,"handwrittenPreviewProps",2);Oi=Ss([Ot("pbo-zoomed-preview")],Oi);const Vb=Oi,Zv=vt`
2880
+ `}};ji.styles=[wt,u_];Vr([T()],ji.prototype,"formData",2);Vr([T()],ji.prototype,"cardUrl",2);Vr([T()],ji.prototype,"close",2);Vr([T()],ji.prototype,"handwrittenPreviewProps",2);ji=Vr([bt("pbo-zoomed-preview")],ji);const f0=ji,f_=at`
2575
2881
  :host {
2576
2882
  display: block;
2577
2883
  }
@@ -2590,7 +2896,7 @@ good aklsdfja`,this.alignment="left",this.fontFamily="Arial",this.color="#000",t
2590
2896
  .choice-wrapper {
2591
2897
  display: inline-flex;
2592
2898
  }
2593
- `;var Jv=Object.defineProperty,Qv=Object.getOwnPropertyDescriptor,Or=(n,t,e,i)=>{for(var r=i>1?void 0:i?Qv(t,e):t,s=n.length-1,o;s>=0;s--)(o=n[s])&&(r=(i?o(t,e,r):o(r))||r);return i&&r&&Jv(t,e,r),r};let hi=class extends Bt{constructor(){super(...arguments),this.hasSlotController=new Ki(this,"help-text","label"),this.size="medium",this.label="",this.disabled=!1}handleDisabledChanged(){var t;this._choices&&this.disabled?this._choices.disable():(t=this._choices)==null||t.enable()}get value(){var t;return(t=this._choices)==null?void 0:t.getValue().value}firstUpdated(){this._initializeChoices(),this.handleDisabledChanged()}_initializeChoices(){var t;(t=this._choices)==null||t.destroy(),this._choices=new _h(this.choiceEl,{allowHTML:!0,searchEnabled:!1,shouldSort:!1,removeItemButton:!1,shadowRoot:this.shadowRoot,choices:[{value:"type",label:`
2899
+ `;var g_=Object.defineProperty,m_=Object.getOwnPropertyDescriptor,zs=(n,t,e,i)=>{for(var s=i>1?void 0:i?m_(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&&g_(t,e,s),s};let gi=class extends It{constructor(){super(...arguments),this.hasSlotController=new os(this,"help-text","label"),this.size="medium",this.label="",this.disabled=!1}handleDisabledChanged(){var t;this._choices&&this.disabled?this._choices.disable():(t=this._choices)==null||t.enable()}get value(){var t;return(t=this._choices)==null?void 0:t.getValue().value}firstUpdated(){this._initializeChoices(),this.handleDisabledChanged()}_initializeChoices(){var t;(t=this._choices)==null||t.destroy(),this._choices=new gu(this.choiceEl,{allowHTML:!0,searchEnabled:!1,shouldSort:!1,removeItemButton:!1,shadowRoot:this.shadowRoot,choices:[{value:"type",label:`
2594
2900
  <div class="choice-wrapper">
2595
2901
  <span class="label">Type message
2596
2902
  <svg
@@ -2667,8 +2973,8 @@ good aklsdfja`,this.alignment="left",this.fontFamily="Arial",this.color="#000",t
2667
2973
  d="M336 192h40a40 40 0 0 1 40 40v192a40 40 0 0 1-40 40H136a40 40 0 0 1-40-40V232a40 40 0 0 1 40-40h40m160-64-80-80-80 80m80 193V48"
2668
2974
  ></path>
2669
2975
  </svg>
2670
- </span>`}],placeholder:!1,shouldSortItems:!1,itemSelectText:""}),this.choiceEl.addEventListener("change",e=>{const i=e.target;this.dispatchEvent(new CustomEvent("pbo-change",{detail:{value:i.value},bubbles:!0,composed:!0}))})}render(){const t=this.hasSlotController.test("label"),e=this.label?!0:!!t;return X` <div
2671
- class=${ni({"form-control":!0,"form-control--small":this.size==="small","form-control--medium":this.size==="medium","form-control--large":this.size==="large","form-control--radio-group":!0,"form-control--has-label":e})}
2976
+ </span>`}],placeholder:!1,shouldSortItems:!1,itemSelectText:""}),this.choiceEl.addEventListener("change",e=>{const i=e.target;this.dispatchEvent(new CustomEvent("pbo-change",{detail:{value:i.value},bubbles:!0,composed:!0}))})}render(){const t=this.hasSlotController.test("label"),e=this.label?!0:!!t;return W` <div
2977
+ class=${je({"form-control":!0,"form-control--small":this.size==="small","form-control--medium":this.size==="medium","form-control--large":this.size==="large","form-control--radio-group":!0,"form-control--has-label":e})}
2672
2978
  >
2673
2979
  <label
2674
2980
  part="form-control-label"
@@ -2679,7 +2985,7 @@ good aklsdfja`,this.alignment="left",this.fontFamily="Arial",this.color="#000",t
2679
2985
  <slot name="label">${this.label}</slot>
2680
2986
  </label>
2681
2987
  </div>
2682
- <select part="base" class="js-choice"></select>`}};hi.styles=[Pt,Zv,ps,kn(yh)];Or([O()],hi.prototype,"size",2);Or([O()],hi.prototype,"label",2);Or([O({type:Boolean,reflect:!0})],hi.prototype,"disabled",2);Or([et("disabled",{waitUntilFirstUpdate:!0})],hi.prototype,"handleDisabledChanged",1);Or([q(".js-choice")],hi.prototype,"choiceEl",2);hi=Or([Ot("pbo-editor-selector")],hi);const $b=hi,tb=vt`
2988
+ <select part="base" class="js-choice"></select>`}};gi.styles=[wt,f_,Mr,Or(mu)];zs([T()],gi.prototype,"size",2);zs([T()],gi.prototype,"label",2);zs([T({type:Boolean,reflect:!0})],gi.prototype,"disabled",2);zs([Q("disabled",{waitUntilFirstUpdate:!0})],gi.prototype,"handleDisabledChanged",1);zs([q(".js-choice")],gi.prototype,"choiceEl",2);gi=zs([bt("pbo-editor-selector")],gi);const m0=gi,v_=at`
2683
2989
  :host {
2684
2990
  display: block;
2685
2991
  }
@@ -2716,7 +3022,7 @@ good aklsdfja`,this.alignment="left",this.fontFamily="Arial",this.color="#000",t
2716
3022
  margin-top: var(--pbo-spacing-2x-small);
2717
3023
  font-size: var(--pbo-font-size-medium);
2718
3024
  }
2719
- `;var eb=Object.defineProperty,ib=Object.getOwnPropertyDescriptor,kt=(n,t,e,i)=>{for(var r=i>1?void 0:i?ib(t,e):t,s=n.length-1,o;s>=0;s--)(o=n[s])&&(r=(i?o(t,e,r):o(r))||r);return i&&r&&eb(t,e,r),r};let dt=class extends Bt{constructor(){super(...arguments),this.card=null,this.submitHandwrittenForm=async t=>{console.warn("submitHandwrittenForm not implemented",t)},this.getProcessedImg=async t=>(console.warn("getProcessedImg not implemented",t.name),{pred_image_uid:"",masked_img:""}),this.isSubmitLoading=!1,this.isSubmitDisabled=!1,this.isImageProcessing=!1,this.sourceImg=null,this.processedImg={fileUrl:null,imgId:null},this.processedFileUrl=null,this.handwrittenDimensions={top:null,left:null,width:null,height:null,cardHeight:null,cardWidth:null}}showPicker(){this.imageInput.showPicker()}setButtonsDisabled(t){this.uploadButton&&this.saveButton&&this.reuploadButton&&(this.uploadButton.disabled=t,this.saveButton.disabled=t,this.reuploadButton.disabled=t)}setButtonsLoading(t){this.uploadButton&&this.saveButton&&(this.uploadButton.loading=t,this.saveButton.loading=t)}handleSubmitLoadingChange(){this.setButtonsLoading(this.isSubmitLoading)}handleSubmitDisabledChange(){this.setButtonsDisabled(this.isSubmitDisabled)}handleSourceImgChange(t,e){this.processedFileUrl=null,t!==e&&this.emit("pbo-change",{detail:{isLoading:!0,processedFileUrl:null}})}handleProcessImageChange(t,e){!e||t===e||this.emit("pbo-change",{detail:{isLoading:!1,processedFileUrl:e}})}handleImageProcessingChange(){this.setButtonsDisabled(this.isImageProcessing),this.setButtonsLoading(this.isImageProcessing)}get formData(){var r,s,o,a;const t=177.8/this.handwrittenDimensions.cardHeight,e=127/this.handwrittenDimensions.cardWidth,i={pboCardId:((r=this.card)==null?void 0:r.pboId)||"Unknown",productId:(s=this.card)==null?void 0:s.productId,sku:(o=this.card)==null?void 0:o.sku,variantId:(a=this.card)==null?void 0:a.variantId,pred_image_uid:this.processedImg.imgId||"",position_x:this.handwrittenDimensions.top*e,position_y:this.handwrittenDimensions.left*t,height:this.handwrittenDimensions.height*t,width:this.handwrittenDimensions.width*e};return Sh(i)}setDimensions(t){this.handwrittenDimensions=t}get form(){return{isLoading:this.sourceImg&&!this.processedFileUrl,processedFileUrl:this.processedFileUrl}}async handleFileChange(t){var r,s;const e=(s=(r=t.target)==null?void 0:r.files)==null?void 0:s[0];if(e==null)return;this.sourceImg=e,this.isImageProcessing=!0;const i=await this.getProcessedImg(e);this.isImageProcessing=!1,this.processedFileUrl=`data:image/png;base64,${i.masked_img}`}handleSubmit(t){t.preventDefault(),this.submitHandwrittenForm(this.formData)}render(){return X`
3025
+ `;var b_=Object.defineProperty,__=Object.getOwnPropertyDescriptor,Pt=(n,t,e,i)=>{for(var s=i>1?void 0:i?__(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&&b_(t,e,s),s};let pt=class extends It{constructor(){super(...arguments),this.card=null,this.submitHandwrittenForm=async t=>{console.warn("submitHandwrittenForm not implemented",t)},this.getProcessedImg=async t=>(console.warn("getProcessedImg not implemented",t.name),{pred_image_uid:"",masked_img:""}),this.isSubmitLoading=!1,this.isSubmitDisabled=!1,this.isImageProcessing=!1,this.sourceImg=null,this.processedImg={fileUrl:null,imgId:null},this.processedFileUrl=null,this.handwrittenDimensions={top:null,left:null,width:null,height:null,cardHeight:null,cardWidth:null}}showPicker(){this.imageInput.showPicker()}setButtonsDisabled(t){this.uploadButton&&this.saveButton&&this.reuploadButton&&(this.uploadButton.disabled=t,this.saveButton.disabled=t,this.reuploadButton.disabled=t)}setButtonsLoading(t){this.uploadButton&&this.saveButton&&(this.uploadButton.loading=t,this.saveButton.loading=t)}handleSubmitLoadingChange(){this.setButtonsLoading(this.isSubmitLoading)}handleSubmitDisabledChange(){this.setButtonsDisabled(this.isSubmitDisabled)}handleSourceImgChange(t,e){this.processedFileUrl=null,t!==e&&this.emit("pbo-change",{detail:{isLoading:!0,processedFileUrl:null}})}handleProcessImageChange(t,e){!e||t===e||this.emit("pbo-change",{detail:{isLoading:!1,processedFileUrl:e}})}handleImageProcessingChange(){this.setButtonsDisabled(this.isImageProcessing),this.setButtonsLoading(this.isImageProcessing)}get formData(){var s,r,o,a;const t=177.8/this.handwrittenDimensions.cardHeight,e=127/this.handwrittenDimensions.cardWidth,i={pboCardId:((s=this.card)==null?void 0:s.pboId)||"Unknown",productId:(r=this.card)==null?void 0:r.productId,sku:(o=this.card)==null?void 0:o.sku,variantId:(a=this.card)==null?void 0:a.variantId,pred_image_uid:this.processedImg.imgId||"",position_x:this.handwrittenDimensions.top*e,position_y:this.handwrittenDimensions.left*t,height:this.handwrittenDimensions.height*t,width:this.handwrittenDimensions.width*e};return yu(i)}setDimensions(t){this.handwrittenDimensions=t}get form(){return{isLoading:this.sourceImg&&!this.processedFileUrl,processedFileUrl:this.processedFileUrl}}async handleFileChange(t){var s,r;const e=(r=(s=t.target)==null?void 0:s.files)==null?void 0:r[0];if(e==null)return;this.sourceImg=e,this.isImageProcessing=!0;const i=await this.getProcessedImg(e);this.isImageProcessing=!1,this.processedFileUrl=`data:image/png;base64,${i.masked_img}`}handleSubmit(t){t.preventDefault(),this.submitHandwrittenForm(this.formData)}render(){return W`
2720
3026
  <form name="handwritten-form" class="handwritten-form" @submit=${this.handleSubmit}>
2721
3027
  <section>
2722
3028
  <h1>Step 1</h1>
@@ -2747,7 +3053,7 @@ good aklsdfja`,this.alignment="left",this.fontFamily="Arial",this.color="#000",t
2747
3053
  size="medium"
2748
3054
  variant="primary"
2749
3055
  @click=${this.showPicker}
2750
- style=${pe({display:this.processedFileUrl?"none":"block"})}
3056
+ style=${me({display:this.processedFileUrl?"none":"block"})}
2751
3057
  >
2752
3058
  Upload Handwritten Image
2753
3059
  </pbo-button>
@@ -2757,7 +3063,7 @@ good aklsdfja`,this.alignment="left",this.fontFamily="Arial",this.color="#000",t
2757
3063
  type="submit"
2758
3064
  variant="primary"
2759
3065
  class="submit-cta"
2760
- style=${pe({display:this.sourceImg&&this.processedFileUrl&&!this.isImageProcessing?"block":"none"})}
3066
+ style=${me({display:this.sourceImg&&this.processedFileUrl&&!this.isImageProcessing?"block":"none"})}
2761
3067
  >
2762
3068
  Save and Continue
2763
3069
  </pbo-button>
@@ -2767,13 +3073,13 @@ good aklsdfja`,this.alignment="left",this.fontFamily="Arial",this.color="#000",t
2767
3073
  class="submit-cta"
2768
3074
  @click=${this.showPicker}
2769
3075
  size="small"
2770
- style=${pe({display:this.sourceImg&&this.processedFileUrl?"block":"none"})}
3076
+ style=${me({display:this.sourceImg&&this.processedFileUrl?"block":"none"})}
2771
3077
  >
2772
3078
  reupload image
2773
3079
  </pbo-button>
2774
3080
  </div>
2775
3081
  </form>
2776
- `}};dt.styles=[Pt,tb];kt([O()],dt.prototype,"card",2);kt([O()],dt.prototype,"submitHandwrittenForm",2);kt([O()],dt.prototype,"getProcessedImg",2);kt([O({type:Boolean,reflect:!0,attribute:"loading"})],dt.prototype,"isSubmitLoading",2);kt([O({type:Boolean,reflect:!0,attribute:"disabled"})],dt.prototype,"isSubmitDisabled",2);kt([q(".pixel-input")],dt.prototype,"imageInput",2);kt([q(".handwritten-form")],dt.prototype,"handwrittenForm",2);kt([q("pbo-button[name='upload']")],dt.prototype,"uploadButton",2);kt([q("pbo-button[name='save']")],dt.prototype,"saveButton",2);kt([q("pbo-button[name='reupload']")],dt.prototype,"reuploadButton",2);kt([$()],dt.prototype,"isImageProcessing",2);kt([$()],dt.prototype,"sourceImg",2);kt([$()],dt.prototype,"processedImg",2);kt([$()],dt.prototype,"processedFileUrl",2);kt([$()],dt.prototype,"handwrittenDimensions",2);kt([et("isSubmitLoading")],dt.prototype,"handleSubmitLoadingChange",1);kt([et("isSubmitDisabled")],dt.prototype,"handleSubmitDisabledChange",1);kt([et("sourceImg")],dt.prototype,"handleSourceImgChange",1);kt([et("processedFileUrl")],dt.prototype,"handleProcessImageChange",1);kt([et("isImageProcessing")],dt.prototype,"handleImageProcessingChange",1);dt=kt([Ot("pbo-handwritten-form")],dt);const Gb=dt,rb=vt`
3082
+ `}};pt.styles=[wt,v_];Pt([T()],pt.prototype,"card",2);Pt([T()],pt.prototype,"submitHandwrittenForm",2);Pt([T()],pt.prototype,"getProcessedImg",2);Pt([T({type:Boolean,reflect:!0,attribute:"loading"})],pt.prototype,"isSubmitLoading",2);Pt([T({type:Boolean,reflect:!0,attribute:"disabled"})],pt.prototype,"isSubmitDisabled",2);Pt([q(".pixel-input")],pt.prototype,"imageInput",2);Pt([q(".handwritten-form")],pt.prototype,"handwrittenForm",2);Pt([q("pbo-button[name='upload']")],pt.prototype,"uploadButton",2);Pt([q("pbo-button[name='save']")],pt.prototype,"saveButton",2);Pt([q("pbo-button[name='reupload']")],pt.prototype,"reuploadButton",2);Pt([V()],pt.prototype,"isImageProcessing",2);Pt([V()],pt.prototype,"sourceImg",2);Pt([V()],pt.prototype,"processedImg",2);Pt([V()],pt.prototype,"processedFileUrl",2);Pt([V()],pt.prototype,"handwrittenDimensions",2);Pt([Q("isSubmitLoading")],pt.prototype,"handleSubmitLoadingChange",1);Pt([Q("isSubmitDisabled")],pt.prototype,"handleSubmitDisabledChange",1);Pt([Q("sourceImg")],pt.prototype,"handleSourceImgChange",1);Pt([Q("processedFileUrl")],pt.prototype,"handleProcessImageChange",1);Pt([Q("isImageProcessing")],pt.prototype,"handleImageProcessingChange",1);pt=Pt([bt("pbo-handwritten-form")],pt);const b0=pt,y_=at`
2777
3083
  :host {
2778
3084
  display: block;
2779
3085
  width: 100%;
@@ -2801,7 +3107,7 @@ good aklsdfja`,this.alignment="left",this.fontFamily="Arial",this.color="#000",t
2801
3107
  display: block;
2802
3108
  object-fit: contain;
2803
3109
  }
2804
- `;var sb=Object.defineProperty,nb=Object.getOwnPropertyDescriptor,Vt=(n,t,e,i)=>{for(var r=i>1?void 0:i?nb(t,e):t,s=n.length-1,o;s>=0;s--)(o=n[s])&&(r=(i?o(t,e,r):o(r))||r);return i&&r&&sb(t,e,r),r};let Et=class extends Bt{constructor(){super(...arguments),this.backgroundImageUrl=void 0,this.handwrittenImageUrl=void 0,this.imageHeight=null,this.imageWidth=null,this.imageLeft=null,this.imageTop=null,this.backgroundFabImg=void 0,this.rect=void 0,this.areaPosition={left:0,top:0},this.handwrittenImage=void 0,this.clipMaskOverlay=void 0,this.areaSize={width:0,height:0},this._dimensionsUpdateTimeout=void 0}async handleBackgroundImageUrlChange(){this.canvas&&(this.backgroundFabImg&&this.canvas.remove(this.backgroundFabImg),await this.appendBackgroundImageToCanvas(this.backgroundImageUrl||"https://cdn.shopify.com/s/files/1/1956/2323/files/insert_86e8bcd5-3e82-4910-b350-485fa6958502.png?v=1726598821"),this.updateProcessedImgAreaPosition(),this.canvas.renderAll())}async handleHandwrittenImageUrlChange(t,e){if(this.canvas){if(this.handwrittenImage&&this.canvas.remove(this.handwrittenImage),e){this.handwrittenImage=await Ut.fromURL(e),this.handwrittenImage.selectable=!0,this.handwrittenImage.lockRotation=!0,this.handwrittenImage.lockScalingFlip=!0,this.handwrittenImage.noScaleCache=!1;const i=this.areaSize.width/this.handwrittenImage.width,r=this.areaSize.height/this.handwrittenImage.height,s=Math.min(i,r);this.handwrittenImage.set({transparentCorners:!1,cornerColor:"#4287f5",cornerStyle:"circle",cornerSize:this.areaSize.width*(ar()?.06:.03),cornerStrokeWidth:2,cornerStrokeColor:"#2563eb",touchCornerSize:this.areaSize.width*(ar()?.2:.06),scalingLimitations:"preserveAspectRatio",left:this.areaPosition.left,top:this.areaPosition.top,scaleX:s,scaleY:s,bringToFrontOnSelect:!1,borderColor:"#4287f5",borderScaleFactor:10}),this.setHandwrittenImageDimensions({top:this.areaPosition.top,left:this.areaPosition.left,height:this.handwrittenImage.height*s,width:this.handwrittenImage.width*s}),this.handwrittenImage.setControlsVisibility({tl:!0,tr:!0,bl:!0,br:!0,mt:!1,mb:!1,ml:!1,mr:!1,mtr:!1});const o=new Rt({width:this.areaSize.width,height:this.areaSize.height,left:this.areaPosition.left,top:this.areaPosition.top,absolutePositioned:!0});this.handwrittenImage.set({clipPath:o}),this.handwrittenImage.on("scaling",a=>{const{top:l,left:c,height:h,width:u,scaleX:d,scaleY:p}=a.transform.target;this.setHandwrittenImageDimensions({top:l,left:c,height:h*p,width:u*d})}),this.handwrittenImage.on("moving",a=>{const{top:l,left:c}=a.transform.target;this.setHandwrittenImageDimensions({top:l,left:c})}),this.handwrittenImage.on("selected",()=>{var a,l;(a=this.rect)==null||a.set("visible",!0),(l=this.handwrittenImage)==null||l.set("clipPath",null),this.clipMaskOverlay?this.clipMaskOverlay.set("visible",!0):(this.clipMaskOverlay=this.createClipMaskOverlay(),this.canvas.add(this.clipMaskOverlay)),this.canvas.bringObjectToFront(this.clipMaskOverlay),this.canvas.renderAll()}),this.handwrittenImage.on("deselected",()=>{var a,l,c;(a=this.rect)==null||a.set("visible",!1),(l=this.handwrittenImage)==null||l.set({clipPath:o}),(c=this.clipMaskOverlay)==null||c.set("visible",!1)}),this.canvas.add(this.handwrittenImage),this.canvas.renderAll()}this.updateProcessedImgAreaPosition(),this.canvas.renderAll()}}createClipMaskOverlay(){const t=this.canvas.getWidth(),e=this.canvas.getHeight(),{left:i,top:r}=this.areaPosition,{width:s,height:o}=this.areaSize,a="rgba(0,0,0,0.1)",l=new Rt({left:0,top:0,width:t,height:r,fill:a,selectable:!1,evented:!1}),c=new Rt({left:0,top:r+o,width:t,height:e-(r+o),fill:a,selectable:!1,evented:!1}),h=new Rt({left:0,top:r,width:i,height:o,fill:a,selectable:!1,evented:!1}),u=new Rt({left:i+s,top:r,width:t-(i+s),height:o,fill:a,selectable:!1,evented:!1});return new _i([l,c,h,u],{selectable:!1,evented:!1})}updateProcessedImgAreaPosition(){this.areaPosition={left:.084*this.canvas.getWidth(),top:.4874*this.canvas.getHeight()},this.areaSize={width:.832*this.canvas.getWidth(),height:this.canvas.getHeight()-this.areaPosition.top-this.areaPosition.left},this.rect?(this.rect.set("left",this.areaPosition.left),this.rect.set("top",this.areaPosition.top),this.rect.set("width",this.areaSize.width),this.rect.set("height",this.areaSize.height)):(this.rect=new Rt({left:this.areaPosition.left,top:this.areaPosition.top,width:this.areaSize.width,height:this.areaSize.height,selectable:!1,fill:"rgba(255, 255, 255, 0.5)",visible:!1,evented:!1}),this.canvas.add(this.rect))}handleHandwrittenImageDimensionsChange(t,e){this._dimensionsUpdateTimeout&&clearTimeout(this._dimensionsUpdateTimeout),this._dimensionsUpdateTimeout=setTimeout(()=>{var i,r,s;this.applyHandwrittenImageDimensions(),(i=this.canvas)==null||i.renderAll(),this.emit("handwritten-image-dimensions-changed",{detail:{left:this.imageLeft,top:this.imageTop,width:this.imageWidth,height:this.imageHeight,cardHeight:((r=this.backgroundFabImg)==null?void 0:r.height)||0,cardWidth:((s=this.backgroundFabImg)==null?void 0:s.width)||0}})},300)}applyHandwrittenImageDimensions(){!jr(this.handwrittenImage)||!jr(this.imageLeft)||!jr(this.imageTop)||!jr(this.imageWidth)||!jr(this.imageHeight)||(this.handwrittenImage.set({left:this.imageLeft,top:this.imageTop}),this.handwrittenImage.scaleToHeight(this.imageHeight),this.handwrittenImage.scaleToWidth(this.imageWidth))}setHandwrittenImageDimensions(t){const{top:e=null,left:i=null,height:r=null,width:s=null}=t;if(!e&&!i&&!r&&!s){console.warn("Invalid dimensions provided for handwritten image");return}i&&this.imageLeft!==i&&(this.imageLeft=i),e&&this.imageTop!==e&&(this.imageTop=e),r&&this.imageHeight!==r&&(this.imageHeight=r),s&&this.imageWidth!==s&&(this.imageWidth=s)}async firstUpdated(){this.canvas=new Jr(this.baseCanvas,{width:500,height:500,containerClass:"fabric-container",preserveObjectStacking:!0}),this.backgroundImageUrl&&await this.appendBackgroundImageToCanvas(this.backgroundImageUrl,()=>{}),this.updateProcessedImgAreaPosition(),this.canvas.renderAll()}async appendBackgroundImageToCanvas(t,e){const i=await Ut.fromURL(t);i.selectable=!1,this.backgroundFabImg=i,this.canvas.setDimensions({width:i.width,height:i.height}),this.canvas.add(i),this.canvas.sendObjectToBack(i),await this.canvas.renderAll(),e&&e()}render(){return X`<canvas class="base-canvas"></canvas> `}};Et.styles=[Pt,rb];Vt([O({attribute:"background-url"})],Et.prototype,"backgroundImageUrl",2);Vt([O({attribute:"handwritten-url"})],Et.prototype,"handwrittenImageUrl",2);Vt([O({type:Number,reflect:!0,attribute:"height"})],Et.prototype,"imageHeight",2);Vt([O({type:Number,reflect:!0,attribute:"width"})],Et.prototype,"imageWidth",2);Vt([O({type:Number,reflect:!0,attribute:"left"})],Et.prototype,"imageLeft",2);Vt([O({type:Number,reflect:!0,attribute:"top"})],Et.prototype,"imageTop",2);Vt([q(".base-canvas")],Et.prototype,"baseCanvas",2);Vt([$()],Et.prototype,"canvas",2);Vt([$()],Et.prototype,"backgroundFabImg",2);Vt([$()],Et.prototype,"rect",2);Vt([$()],Et.prototype,"areaPosition",2);Vt([$()],Et.prototype,"handwrittenImage",2);Vt([$()],Et.prototype,"clipMaskOverlay",2);Vt([$()],Et.prototype,"areaSize",2);Vt([et("backgroundImageUrl")],Et.prototype,"handleBackgroundImageUrlChange",1);Vt([et("handwrittenImageUrl")],Et.prototype,"handleHandwrittenImageUrlChange",1);Vt([et("imageLeft"),et("imageTop"),et("imageWidth"),et("imageHeight")],Et.prototype,"handleHandwrittenImageDimensionsChange",1);Et=Vt([Ot("pbo-handwritten-canvas")],Et);const Yb=Et,ob=vt`
3110
+ `;var x_=Object.defineProperty,w_=Object.getOwnPropertyDescriptor,Vt=(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&&x_(t,e,s),s};let At=class extends It{constructor(){super(...arguments),this.backgroundImageUrl=void 0,this.handwrittenImageUrl=void 0,this.imageHeight=null,this.imageWidth=null,this.imageLeft=null,this.imageTop=null,this.backgroundFabImg=void 0,this.rect=void 0,this.areaPosition={left:0,top:0},this.handwrittenImage=void 0,this.clipMaskOverlay=void 0,this.areaSize={width:0,height:0},this._dimensionsUpdateTimeout=void 0}async handleBackgroundImageUrlChange(){this.canvas&&(this.backgroundFabImg&&this.canvas.remove(this.backgroundFabImg),await this.appendBackgroundImageToCanvas(this.backgroundImageUrl||"https://cdn.shopify.com/s/files/1/1956/2323/files/insert_86e8bcd5-3e82-4910-b350-485fa6958502.png?v=1726598821"),this.updateProcessedImgAreaPosition(),this.canvas.renderAll())}async handleHandwrittenImageUrlChange(t,e){if(this.canvas){if(this.handwrittenImage&&this.canvas.remove(this.handwrittenImage),e){this.handwrittenImage=await Xt.fromURL(e),this.handwrittenImage.selectable=!0,this.handwrittenImage.lockRotation=!0,this.handwrittenImage.lockScalingFlip=!0,this.handwrittenImage.noScaleCache=!1;const i=this.areaSize.width/this.handwrittenImage.width,s=this.areaSize.height/this.handwrittenImage.height,r=Math.min(i,s);this.handwrittenImage.set({transparentCorners:!1,cornerColor:"#4287f5",cornerStyle:"circle",cornerSize:this.areaSize.width*(ys()?.06:.03),cornerStrokeWidth:2,cornerStrokeColor:"#2563eb",touchCornerSize:this.areaSize.width*(ys()?.2:.06),scalingLimitations:"preserveAspectRatio",left:this.areaPosition.left,top:this.areaPosition.top,scaleX:r,scaleY:r,bringToFrontOnSelect:!1,borderColor:"#4287f5",borderScaleFactor:10}),this.setHandwrittenImageDimensions({top:this.areaPosition.top,left:this.areaPosition.left,height:this.handwrittenImage.height*r,width:this.handwrittenImage.width*r}),this.handwrittenImage.setControlsVisibility({tl:!0,tr:!0,bl:!0,br:!0,mt:!1,mb:!1,ml:!1,mr:!1,mtr:!1});const o=new Nt({width:this.areaSize.width,height:this.areaSize.height,left:this.areaPosition.left,top:this.areaPosition.top,absolutePositioned:!0});this.handwrittenImage.set({clipPath:o}),this.handwrittenImage.on("scaling",a=>{const{top:l,left:c,height:h,width:u,scaleX:d,scaleY:p}=a.transform.target;this.setHandwrittenImageDimensions({top:l,left:c,height:h*p,width:u*d})}),this.handwrittenImage.on("moving",a=>{const{top:l,left:c}=a.transform.target;this.setHandwrittenImageDimensions({top:l,left:c})}),this.handwrittenImage.on("selected",()=>{var a,l;(a=this.rect)==null||a.set("visible",!0),(l=this.handwrittenImage)==null||l.set("clipPath",null),this.clipMaskOverlay?this.clipMaskOverlay.set("visible",!0):(this.clipMaskOverlay=this.createClipMaskOverlay(),this.canvas.add(this.clipMaskOverlay)),this.canvas.bringObjectToFront(this.clipMaskOverlay),this.canvas.renderAll()}),this.handwrittenImage.on("deselected",()=>{var a,l,c;(a=this.rect)==null||a.set("visible",!1),(l=this.handwrittenImage)==null||l.set({clipPath:o}),(c=this.clipMaskOverlay)==null||c.set("visible",!1)}),this.canvas.add(this.handwrittenImage),this.canvas.renderAll()}this.updateProcessedImgAreaPosition(),this.canvas.renderAll()}}createClipMaskOverlay(){const t=this.canvas.getWidth(),e=this.canvas.getHeight(),{left:i,top:s}=this.areaPosition,{width:r,height:o}=this.areaSize,a="rgba(0,0,0,0.1)",l=new Nt({left:0,top:0,width:t,height:s,fill:a,selectable:!1,evented:!1}),c=new Nt({left:0,top:s+o,width:t,height:e-(s+o),fill:a,selectable:!1,evented:!1}),h=new Nt({left:0,top:s,width:i,height:o,fill:a,selectable:!1,evented:!1}),u=new Nt({left:i+r,top:s,width:t-(i+r),height:o,fill:a,selectable:!1,evented:!1});return new ki([l,c,h,u],{selectable:!1,evented:!1})}updateProcessedImgAreaPosition(){this.areaPosition={left:.084*this.canvas.getWidth(),top:.4874*this.canvas.getHeight()},this.areaSize={width:.832*this.canvas.getWidth(),height:this.canvas.getHeight()-this.areaPosition.top-this.areaPosition.left},this.rect?(this.rect.set("left",this.areaPosition.left),this.rect.set("top",this.areaPosition.top),this.rect.set("width",this.areaSize.width),this.rect.set("height",this.areaSize.height)):(this.rect=new Nt({left:this.areaPosition.left,top:this.areaPosition.top,width:this.areaSize.width,height:this.areaSize.height,selectable:!1,fill:"rgba(255, 255, 255, 0.5)",visible:!1,evented:!1}),this.canvas.add(this.rect))}handleHandwrittenImageDimensionsChange(t,e){this._dimensionsUpdateTimeout&&clearTimeout(this._dimensionsUpdateTimeout),this._dimensionsUpdateTimeout=setTimeout(()=>{var i,s,r;this.applyHandwrittenImageDimensions(),(i=this.canvas)==null||i.renderAll(),this.emit("handwritten-image-dimensions-changed",{detail:{left:this.imageLeft,top:this.imageTop,width:this.imageWidth,height:this.imageHeight,cardHeight:((s=this.backgroundFabImg)==null?void 0:s.height)||0,cardWidth:((r=this.backgroundFabImg)==null?void 0:r.width)||0}})},300)}applyHandwrittenImageDimensions(){!Zs(this.handwrittenImage)||!Zs(this.imageLeft)||!Zs(this.imageTop)||!Zs(this.imageWidth)||!Zs(this.imageHeight)||(this.handwrittenImage.set({left:this.imageLeft,top:this.imageTop}),this.handwrittenImage.scaleToHeight(this.imageHeight),this.handwrittenImage.scaleToWidth(this.imageWidth))}setHandwrittenImageDimensions(t){const{top:e=null,left:i=null,height:s=null,width:r=null}=t;if(!e&&!i&&!s&&!r){console.warn("Invalid dimensions provided for handwritten image");return}i&&this.imageLeft!==i&&(this.imageLeft=i),e&&this.imageTop!==e&&(this.imageTop=e),s&&this.imageHeight!==s&&(this.imageHeight=s),r&&this.imageWidth!==r&&(this.imageWidth=r)}async firstUpdated(){this.canvas=new mr(this.baseCanvas,{width:500,height:500,containerClass:"fabric-container",preserveObjectStacking:!0}),this.backgroundImageUrl&&await this.appendBackgroundImageToCanvas(this.backgroundImageUrl,()=>{}),this.updateProcessedImgAreaPosition(),this.canvas.renderAll()}async appendBackgroundImageToCanvas(t,e){const i=await Xt.fromURL(t);i.selectable=!1,this.backgroundFabImg=i,this.canvas.setDimensions({width:i.width,height:i.height}),this.canvas.add(i),this.canvas.sendObjectToBack(i),await this.canvas.renderAll(),e&&e()}render(){return W`<canvas class="base-canvas"></canvas> `}};At.styles=[wt,y_];Vt([T({attribute:"background-url"})],At.prototype,"backgroundImageUrl",2);Vt([T({attribute:"handwritten-url"})],At.prototype,"handwrittenImageUrl",2);Vt([T({type:Number,reflect:!0,attribute:"height"})],At.prototype,"imageHeight",2);Vt([T({type:Number,reflect:!0,attribute:"width"})],At.prototype,"imageWidth",2);Vt([T({type:Number,reflect:!0,attribute:"left"})],At.prototype,"imageLeft",2);Vt([T({type:Number,reflect:!0,attribute:"top"})],At.prototype,"imageTop",2);Vt([q(".base-canvas")],At.prototype,"baseCanvas",2);Vt([V()],At.prototype,"canvas",2);Vt([V()],At.prototype,"backgroundFabImg",2);Vt([V()],At.prototype,"rect",2);Vt([V()],At.prototype,"areaPosition",2);Vt([V()],At.prototype,"handwrittenImage",2);Vt([V()],At.prototype,"clipMaskOverlay",2);Vt([V()],At.prototype,"areaSize",2);Vt([Q("backgroundImageUrl")],At.prototype,"handleBackgroundImageUrlChange",1);Vt([Q("handwrittenImageUrl")],At.prototype,"handleHandwrittenImageUrlChange",1);Vt([Q("imageLeft"),Q("imageTop"),Q("imageWidth"),Q("imageHeight")],At.prototype,"handleHandwrittenImageDimensionsChange",1);At=Vt([bt("pbo-handwritten-canvas")],At);const y0=At,C_=at`
2805
3111
  :host {
2806
3112
  display: block;
2807
3113
  width: auto;
@@ -2849,7 +3155,7 @@ good aklsdfja`,this.alignment="left",this.fontFamily="Arial",this.color="#000",t
2849
3155
  resize: vertical;
2850
3156
  min-height: 6rem;
2851
3157
  }
2852
- `;var ab=Object.defineProperty,lb=Object.getOwnPropertyDescriptor,Ge=(n,t,e,i)=>{for(var r=i>1?void 0:i?lb(t,e):t,s=n.length-1,o;s>=0;s--)(o=n[s])&&(r=(i?o(t,e,r):o(r))||r);return i&&r&&ab(t,e,r),r};let me=class extends Bt{constructor(){super(...arguments),this.hasSlotController=new Ki(this,"is-gift-label","premium-card-label","free-message-label"),this.freeMessage="",this.hidden=!1,this.expand=!1,this.isGift=!0,this.isPremiumChecked=!1,this.isFreeMessageChecked=!1}setGiftOptionEnabled(t){var e;this.isGift=t,this.isGift||(this.isPremiumChecked=!1,this.isFreeMessageChecked=!1,this.freeMessage="",(e=this.onFreeMessageClear)==null||e.call(this))}firstUpdated(t){}setPremiumEnabled(t){var e;this.isPremiumChecked=t,this.isPremiumChecked&&(this.isFreeMessageChecked=!1,(e=this.onFreeMessageClear)==null||e.call(this)),this.isPremiumChecked?this.emit("pbo-open-drawer"):this.emit("pbo-close-drawer"),this.onPremiumSelected&&this.onPremiumSelected(t)}setFreeMessageEnabled(t){var e;this.isFreeMessageChecked=t,this.isFreeMessageChecked||(this.freeMessage="",(e=this.onFreeMessageClear)==null||e.call(this))}handlePremiumChange(t){const e=t.target.checked;this.setPremiumEnabled(e)}render(){const t=this.hasSlotController.test("is-gift-label"),e=this.hasSlotController.test("premium-card-label"),i=this.hasSlotController.test("free-message-label");return X`
3158
+ `;var S_=Object.defineProperty,T_=Object.getOwnPropertyDescriptor,Ze=(n,t,e,i)=>{for(var s=i>1?void 0:i?T_(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 _e=class extends It{constructor(){super(...arguments),this.hasSlotController=new os(this,"is-gift-label","premium-card-label","free-message-label"),this.freeMessage="",this.hidden=!1,this.expand=!1,this.isGift=!0,this.isPremiumChecked=!1,this.isFreeMessageChecked=!1}setGiftOptionEnabled(t){var e;this.isGift=t,this.isGift||(this.isPremiumChecked=!1,this.isFreeMessageChecked=!1,this.freeMessage="",(e=this.onFreeMessageClear)==null||e.call(this))}firstUpdated(t){}setPremiumEnabled(t){var e;this.isPremiumChecked=t,this.isPremiumChecked&&(this.isFreeMessageChecked=!1,(e=this.onFreeMessageClear)==null||e.call(this)),this.isPremiumChecked?this.emit("pbo-open-drawer"):this.emit("pbo-close-drawer"),this.onPremiumSelected&&this.onPremiumSelected(t)}setFreeMessageEnabled(t){var e;this.isFreeMessageChecked=t,this.isFreeMessageChecked||(this.freeMessage="",(e=this.onFreeMessageClear)==null||e.call(this))}handlePremiumChange(t){const e=t.target.checked;this.setPremiumEnabled(e)}render(){const t=this.hasSlotController.test("is-gift-label"),e=this.hasSlotController.test("premium-card-label"),i=this.hasSlotController.test("free-message-label");return W`
2853
3159
  <div part="base" class="gift-options" ?hidden=${this.hidden}>
2854
3160
  <!-- 🎁 Is this a gift -->
2855
3161
  <div class="is-gift" part="is-gift" ?hidden=${!t}>
@@ -2857,7 +3163,7 @@ good aklsdfja`,this.alignment="left",this.fontFamily="Arial",this.color="#000",t
2857
3163
  <input
2858
3164
  type="checkbox"
2859
3165
  ?checked=${this.isGift}
2860
- @change=${r=>{const s=r.target.checked;this.isGift=s,this.isGift||(this.isPremiumChecked=!1,this.isFreeMessageChecked=!1,this.freeMessage="")}}
3166
+ @change=${s=>{const r=s.target.checked;this.isGift=r,this.isGift||(this.isPremiumChecked=!1,this.isFreeMessageChecked=!1,this.freeMessage="")}}
2861
3167
  />
2862
3168
  <slot name="is-gift-label" part="is-gift-label"></slot>
2863
3169
  <span class="is-gift-icon">
@@ -2883,7 +3189,7 @@ good aklsdfja`,this.alignment="left",this.fontFamily="Arial",this.color="#000",t
2883
3189
  <input
2884
3190
  type="checkbox"
2885
3191
  .checked=${this.isFreeMessageChecked}
2886
- @change=${()=>{var r;this.isFreeMessageChecked=!this.isFreeMessageChecked,this.isFreeMessageChecked?this.isPremiumChecked=!1:(this.freeMessage="",(r=this.onFreeMessageClear)==null||r.call(this))}}
3192
+ @change=${()=>{var s;this.isFreeMessageChecked=!this.isFreeMessageChecked,this.isFreeMessageChecked?this.isPremiumChecked=!1:(this.freeMessage="",(s=this.onFreeMessageClear)==null||s.call(this))}}
2887
3193
  />
2888
3194
  <slot name="free-message-label"></slot>
2889
3195
  </label>
@@ -2894,9 +3200,9 @@ good aklsdfja`,this.alignment="left",this.fontFamily="Arial",this.color="#000",t
2894
3200
  placeholder="Leave your message"
2895
3201
  .value=${this.freeMessage}
2896
3202
  ?hidden=${!this.isFreeMessageChecked}
2897
- @input=${r=>{var s;this.freeMessage=r.target.value,(s=this.onFreeMessageChange)==null||s.call(this,this.freeMessage)}}
3203
+ @input=${s=>{var r;this.freeMessage=s.target.value,(r=this.onFreeMessageChange)==null||r.call(this,this.freeMessage)}}
2898
3204
  ></pbo-textarea>
2899
3205
  <div></div>
2900
3206
  </div>
2901
3207
  </div>
2902
- `}clear(){this.isPremiumChecked=!1,this.isFreeMessageChecked=!1,this.freeMessage=""}};me.styles=[Pt,ob];Ge([O()],me.prototype,"freeMessage",2);Ge([O({type:Function})],me.prototype,"onPremiumSelected",2);Ge([O({type:Function})],me.prototype,"onFreeMessageChange",2);Ge([O({type:Function})],me.prototype,"onFreeMessageClear",2);Ge([O({type:Boolean,reflect:!0})],me.prototype,"hidden",2);Ge([O({type:Boolean,reflect:!0})],me.prototype,"expand",2);Ge([$()],me.prototype,"isGift",2);Ge([$()],me.prototype,"isPremiumChecked",2);Ge([$()],me.prototype,"isFreeMessageChecked",2);me=Ge([Ot("pbo-gift-options")],me);const Kb=me,qb=Qr,Zb=ge;export{ut as FabricExample,hn as MessageSelector,mb as PboButton,bb as PboButtonGroup,Rb as PboCardSelection,Ib as PboCategory,Lb as PboDrawer,Db as PboEditor,Ab as PboEditorCardSlider,$b as PboEditorSelector,Kb as PboGiftOption,Yb as PboHandwrittenCanvas,Gb as PboHandwrittenForm,Zb as PboImage,Fb as PboPageManager,yb as PboRadioButton,wb as PboRadioGroup,ze as PboSelector,qb as PboSpinner,Sb as PboTextarea,Nb as PboTypeCanvas,Pb as PboTypeForm,Vb as PboZoomedPreview};
3208
+ `}clear(){this.isPremiumChecked=!1,this.isFreeMessageChecked=!1,this.freeMessage=""}};_e.styles=[wt,C_];Ze([T()],_e.prototype,"freeMessage",2);Ze([T({type:Function})],_e.prototype,"onPremiumSelected",2);Ze([T({type:Function})],_e.prototype,"onFreeMessageChange",2);Ze([T({type:Function})],_e.prototype,"onFreeMessageClear",2);Ze([T({type:Boolean,reflect:!0})],_e.prototype,"hidden",2);Ze([T({type:Boolean,reflect:!0})],_e.prototype,"expand",2);Ze([V()],_e.prototype,"isGift",2);Ze([V()],_e.prototype,"isPremiumChecked",2);Ze([V()],_e.prototype,"isFreeMessageChecked",2);_e=Ze([bt("pbo-gift-options")],_e);const w0=_e,C0=vr,S0=be;export{dt as FabricExample,Mn as MessageSelector,H_ as PboButton,U_ as PboButtonGroup,h0 as PboCardSelection,n0 as PboCategory,o0 as PboDrawer,e0 as PboEditor,s0 as PboEditorCardSlider,m0 as PboEditorSelector,w0 as PboGiftOption,y0 as PboHandwrittenCanvas,b0 as PboHandwrittenForm,S0 as PboImage,l0 as PboPageManager,G_ as PboRadioButton,X_ as PboRadioGroup,We as PboSelector,C0 as PboSpinner,q_ as PboTextarea,d0 as PboTypeCanvas,i0 as PboTypeForm,f0 as PboZoomedPreview};