@pacem/pacem 1.0.0-abel
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +191 -0
- package/NOTICE +4 -0
- package/dist/browser/pacem-2d.js +2755 -0
- package/dist/browser/pacem-2d.js.map +6 -0
- package/dist/browser/pacem-2d.min.js +7 -0
- package/dist/browser/pacem-2d.min.js.map +6 -0
- package/dist/browser/pacem-3d.js +7723 -0
- package/dist/browser/pacem-3d.js.map +6 -0
- package/dist/browser/pacem-3d.min.js +7 -0
- package/dist/browser/pacem-3d.min.js.map +6 -0
- package/dist/browser/pacem-charts.js +1628 -0
- package/dist/browser/pacem-charts.js.map +6 -0
- package/dist/browser/pacem-charts.min.js +7 -0
- package/dist/browser/pacem-charts.min.js.map +6 -0
- package/dist/browser/pacem-cms.js +2220 -0
- package/dist/browser/pacem-cms.js.map +6 -0
- package/dist/browser/pacem-cms.min.js +7 -0
- package/dist/browser/pacem-cms.min.js.map +6 -0
- package/dist/browser/pacem-core.js +9104 -0
- package/dist/browser/pacem-core.js.map +6 -0
- package/dist/browser/pacem-core.min.js +7 -0
- package/dist/browser/pacem-core.min.js.map +6 -0
- package/dist/browser/pacem-foundation.js +2138 -0
- package/dist/browser/pacem-foundation.js.map +6 -0
- package/dist/browser/pacem-foundation.min.js +7 -0
- package/dist/browser/pacem-foundation.min.js.map +6 -0
- package/dist/browser/pacem-fx.js +870 -0
- package/dist/browser/pacem-fx.js.map +6 -0
- package/dist/browser/pacem-fx.min.js +7 -0
- package/dist/browser/pacem-fx.min.js.map +6 -0
- package/dist/browser/pacem-logging.js +175 -0
- package/dist/browser/pacem-logging.js.map +6 -0
- package/dist/browser/pacem-logging.min.js +7 -0
- package/dist/browser/pacem-logging.min.js.map +6 -0
- package/dist/browser/pacem-maps.js +3642 -0
- package/dist/browser/pacem-maps.js.map +6 -0
- package/dist/browser/pacem-maps.min.js +7 -0
- package/dist/browser/pacem-maps.min.js.map +6 -0
- package/dist/browser/pacem-media.js +284 -0
- package/dist/browser/pacem-media.js.map +6 -0
- package/dist/browser/pacem-media.min.js +7 -0
- package/dist/browser/pacem-media.min.js.map +6 -0
- package/dist/browser/pacem-networking.js +434 -0
- package/dist/browser/pacem-networking.js.map +6 -0
- package/dist/browser/pacem-networking.min.js +7 -0
- package/dist/browser/pacem-networking.min.js.map +6 -0
- package/dist/browser/pacem-numerical.js +2627 -0
- package/dist/browser/pacem-numerical.js.map +6 -0
- package/dist/browser/pacem-numerical.min.js +7 -0
- package/dist/browser/pacem-numerical.min.js.map +6 -0
- package/dist/browser/pacem-plus.js +2373 -0
- package/dist/browser/pacem-plus.js.map +6 -0
- package/dist/browser/pacem-plus.min.js +7 -0
- package/dist/browser/pacem-plus.min.js.map +6 -0
- package/dist/browser/pacem-scaffolding.js +10435 -0
- package/dist/browser/pacem-scaffolding.js.map +6 -0
- package/dist/browser/pacem-scaffolding.min.js +7 -0
- package/dist/browser/pacem-scaffolding.min.js.map +6 -0
- package/dist/browser/pacem-ui.js +6348 -0
- package/dist/browser/pacem-ui.js.map +6 -0
- package/dist/browser/pacem-ui.min.js +7 -0
- package/dist/browser/pacem-ui.min.js.map +6 -0
- package/dist/bundle/pacem.min.mjs +997 -0
- package/dist/bundle/pacem.mjs +47067 -0
- package/dist/bundle/pacem.mjs.map +12 -0
- package/dist/typings/index.d.ts +9757 -0
- package/package.json +130 -0
|
@@ -0,0 +1,997 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @pacem/pacem v1.0.0-abel (https://js.pacem.it)
|
|
3
|
+
* Copyright 2026 Pacem (https://pacem.it)
|
|
4
|
+
* Licensed under Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
var Sk=Object.defineProperty;var nR=Object.getOwnPropertyDescriptor;var Lk=a=>{throw TypeError(a)};var tt=(a,r)=>{for(var e in r)Sk(a,e,{get:r[e],enumerable:!0})};var l=(a,r,e,t)=>{for(var n=t>1?void 0:t?nR(r,e):r,i=a.length-1,s;i>=0;i--)(s=a[i])&&(n=(t?s(r,e,n):s(n))||n);return t&&n&&Sk(r,e,n),n};var Nk=(a,r,e)=>r.has(a)||Lk("Cannot "+e);var x=(a,r,e)=>(Nk(a,r,"read from private field"),e?e.call(a):r.get(a)),$=(a,r,e)=>r.has(a)?Lk("Cannot add the same private member more than once"):r instanceof WeakSet?r.add(a):r.set(a,e),A=(a,r,e,t)=>(Nk(a,r,"write to private field"),t?t.call(a,e):r.set(a,e),e);Number.prototype.isCloseTo=function(a,r=14){let e=+`1e-${r}`;return this>a-e&&this<a+e};Number.prototype.roundoff=function(a=14){return parseFloat(this.toFixed(a))};Number.prototype.clamp=function(a,r){let e=this;return a!=null&&!isNaN(a)&&(e=Math.max(e,a)),r!=null&&!isNaN(r)&&(e=Math.min(e,r)),e};Number.prototype.toBase62=function(){for(var a="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",r=this,e="";r!=0;){var t=r%62;e=a.charAt(t)+e,r=Math.floor(r/62)}return e};Number.prototype.toBase36=function(){return this.toString(36)};var iR=/^\/Date\([\d]+\)\/$/i,Jv=class a{static parse(r){let e;return typeof r=="string"?(iR.test(r)?e=parseInt(r.substring(6)):e=Date.parse(r),new Date(e)):typeof r=="number"?new Date(r):r}static isLeapYear(r){return r%4===0&&r%100!==0||r%400===0}static daysInMonth(r,e){return[31,a.isLeapYear(r)?29:28,31,30,31,30,31,31,30,31,30,31][e]}static isDate(r){return r instanceof Date&&!isNaN(r.valueOf())}static dateOnly(r){return new Date(r.getFullYear(),r.getMonth(),r.getDate())}static addMonths(r,e){let t=r.getDate(),n=new Date(r),i=n.getMonth()+e,s=0;for(;i<0;)i+=12,s--;return n.setDate(1),n.setMonth(i%12),n.setFullYear(n.getFullYear()+s+Math.floor(i/12)),n.setDate(Math.min(t,a.daysInMonth(n.getFullYear(),n.getMonth()))),n}static addDays(r,e){return new Date(r.valueOf()+e*864e5)}static daysBetween(r,e){return(e.valueOf()-r.valueOf())/864e5}};var We=class a{static isNull(r){return r==null}static isEmpty(r){try{return Array.isArray(r)&&r.length===0||typeof r=="string"&&r===""||typeof r=="object"&&Object.keys(r).length===0&&!Jv.isDate(r)&&!(r instanceof RegExp)&&!(r instanceof FileSystemDirectoryHandle)&&!(r instanceof FileSystemFileHandle)}catch{return!1}}static isNullOrEmpty(r){return a.isNull(r)||a.isEmpty(r)}};Array.prototype.distinct=function(){return Array.from(new Set(this))};Array.prototype.union=function(a){let r=We.isNullOrEmpty(this),e=We.isNullOrEmpty(a);return r&&e?[]:e?this.slice():r?a.slice():this.concat(a).distinct()};Array.prototype.moveWithin=function(a,r){let e="Index must be greater or equal than 0 and less or equal than the length of the array.";var t=this;if(a<0||a>t.length)throw new Error(e);if(r<0||r>t.length)throw new Error(e);t.splice(r,0,Array.prototype.splice.apply(t,[a,1])[0])};Array.prototype.equalsContent=function(a){if(a==null||this.length!==a.length)return!1;for(let r=0;r<this.length;r++)if(this[r]!==a[r])return!1;return!0};Array.prototype.cloneFrom=function(a){if(a==null)throw"Cannot clone array from null object.";let r=a.length;var e=this.length!==a.length;for(let t=0;t<r;t++){let n=a[t];this.length>t?this[t]!==n&&(this[t]=n,e=!0):(Array.prototype.push.apply(this,[n]),e=!0)}e&&this.splice(r)};function Tk(a){return a!=null&&typeof a=="object"&&!Array.isArray(a)&&(a.constructor===Object||a.constructor===void 0)}function Dk(a,r){let e=a;for(let t of Object.keys(r)){let n=r[t],i=e[t];Tk(n)?e[t]=Dk(Tk(i)?i:{},n):Array.isArray(n)?e[t]=n.slice():e[t]=n}return e}var Ak=class{constructor(){}static merge(r,e){return e??=globalThis.Pacem??={},Dk(e,r)}};var Rk=class{static range(r,e,t=2){let n=r;We.isNull(e)&&(e=t=r,r=1);let i=(e-r)/(t-1),s=[];if(i>0)for(;s.length<t;)s.push(n.roundoff()),n+=i;return s}static chunkify(r,e){if(We.isNullOrEmpty(r))return[];if(e<=0||e%1!==0)throw new Error("Provide a positive integer number.");let t=Math.ceil(r.length/e);return Array.from({length:t},(n,i)=>{let s=i*e,o=s+e;return r.slice(s,o)})}};var Ok=class a{static blobToDataURL(r){return new Promise((e,t)=>{let n=new FileReader;n.onload=i=>{e(i.target.result)},n.readAsDataURL(r)})}static _b64ToUint8Array(r){let e=r.length,t=new Uint8Array(e);for(;e--;)t[e]=r.charCodeAt(e);return t}static base64ToBlob(r,e){let t=a._b64ToUint8Array(atob(r));return new Blob([t],e)}static dataURLToBlob(r){let e=r.indexOf(",");if(e===-1)return a.base64ToBlob(r);{let t=r.substring(e+1),i=r.substring(0,e).match(/:(.*?);/)[1];return a.base64ToBlob(t,{type:i})}}static async blobToText(r,e){let t=await r.arrayBuffer();return new TextDecoder(e,{fatal:!1}).decode(t)}static textToBlob(r,e="text/plain",t="utf-8",n,i=63){let s=t.toLowerCase(),o=()=>`${e};charset=${s}`;switch(s){case"utf-8":{let d=new TextEncoder().encode(r),p=n?[new Uint8Array([239,187,191]),d]:[d];return new Blob(p,{type:o()})}case"utf-16":s="utf-16le",n??=!0;case"utf-16le":case"utf-16be":{let c=s!=="utf-16be",d=n?1:0,p=new ArrayBuffer((r.length+d)*2),u=new DataView(p);n&&u.setUint16(0,65279,c);for(let h=0;h<r.length;h++)u.setUint16((h+d)*2,r.charCodeAt(h),c);return new Blob([p],{type:o()})}case"ascii":case"iso-8859-1":case"latin1":{let c=s==="ascii"?127:255,d=new Uint8Array(r.length),p=i>0;for(let u=0;u<r.length;u++){let h=r.charCodeAt(u);if(h>c)if(p)d[u]=i;else throw new Error(`Character "${r[u]}" cannot be encoded in ${t}.`);else d[u]=h}return new Blob([d],{type:o()})}default:throw new Error(`Encoding "${t}" is not supported safely in the browser. Use UTF-8 or any supported encoding.`)}}};var Ta=(a,r)=>{let e=a.match(r);return e?e[2]:null};function AF(a=navigator.userAgent){let r="unknown",e=null;switch(/ucbrowser/i.test(a)?r="UCBrowser":/edg/i.test(a)?r="Edge":/googlebot/i.test(a)?r="GoogleBot":/chromium/i.test(a)?r="Chromium":/firefox|fxios/i.test(a)&&!/seamonkey/i.test(a)?r="Firefox":/; msie|trident/i.test(a)&&!/ucbrowser/i.test(a)?r="IE":/chrome|crios/i.test(a)&&!/opr|opera|chromium|edg|ucbrowser|googlebot/i.test(a)?r="Chrome":/safari/i.test(a)&&!/chromium|edg|ucbrowser|chrome|crios|opr|opera|fxios|firefox/i.test(a)?r="Safari":/opr|opera/i.test(a)&&(r="Opera"),r){case"UCBrowser":e=Ta(a,/(ucbrowser)\/([\d\.]+)/i);break;case"Edge":e=Ta(a,/(edge|edga|edgios|edg)\/([\d\.]+)/i);break;case"GoogleBot":e=Ta(a,/(googlebot)\/([\d\.]+)/i);break;case"Chromium":e=Ta(a,/(chromium)\/([\d\.]+)/i);break;case"Firefox":e=Ta(a,/(firefox|fxios)\/([\d\.]+)/i);break;case"Chrome":e=Ta(a,/(chrome|crios)\/([\d\.]+)/i);break;case"Safari":e=Ta(a,/(safari)\/([\d\.]+)/i);break;case"Opera":e=Ta(a,/(opera|opr)\/([\d\.]+)/i);break;case"IE":{let t=Ta(a,/(trident)\/([\d\.]+)/i);e=t?`${parseFloat(t)+4}`:"7.0";break}default:e="0.0.0.0";break}return{name:r,version:e}}var Pk=/^hsl\s*\(\s*([\d\.]+)\s*,\s*([\d\.]+)%\s*,\s*([\d\.]+)%\s*\)$/,Ik=/^hsla\s*\(\s*([\d\.]+)\s*,\s*([\d\.]+)%\s*,\s*([\d\.]+)%\s*,\s*([\d\.]+)\)$/,$k=/^rgb\s*\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\)$/,Hk=/^rgba\s*\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*,\s*([\d\.]+)\)$/,Bk=/^#[a-f0-9]{6}$/,Vk=/^#[a-f0-9]{3}$/;function jm(a){return!We.isNullOrEmpty(a)&&typeof a=="object"&&"r"in a&&"g"in a&&"b"in a&&typeof a.r=="number"&&typeof a.b=="number"&&typeof a.g=="number"?(a.a??=1,a.r>=0&&a.r<=1&&a.g>=0&&a.g<=1&&a.b>=0&&a.b<=1&&a.a>=0&&a.a<=1):!1}function Es(a){return!We.isNullOrEmpty(a)&&typeof a=="object"&&"h"in a&&"s"in a&&"l"in a&&typeof a.h=="number"&&typeof a.s=="number"&&typeof a.l=="number"?(a.a??=1,a.h>=0&&a.h<=360&&a.s>=0&&a.s<=1&&a.l>=0&&a.l<=1&&a.a>=0&&a.a<=1):!1}function sR(a){let r=a.r,e=a.g,t=a.b;return(.5*(Math.max(r,e,t)+Math.min(r,e,t))).clamp(0,1)}var jt={adjustRgbChannel:a=>a<=.03928?a/12.92:Math.pow((a+.055)/1.055,2.4),adjustRgbChannelInv:a=>a<=.00304?a*12.92:1.055*(Math.pow(a,1/2.4)-.055),adjustRgb:a=>({r:jt.adjustRgbChannel(a.r),g:jt.adjustRgbChannel(a.g),b:jt.adjustRgbChannel(a.b),a:a.a}),adjustRgbInv:a=>({r:jt.adjustRgbChannelInv(a.r),g:jt.adjustRgbChannelInv(a.g),b:jt.adjustRgbChannelInv(a.b),a:a.a}),X:a=>.4125*a.r+.3576*a.g+.1804*a.b,Y:a=>.2126*a.r+.7152*a.g+.0722*a.b,Z:a=>.0193*a.r+.1191*a.g+.9503*a.b,relativeLuminance:a=>{let r=jt.adjustRgb(a);return jt.Y(r)},rgbToCieXYZ:a=>{let r=jt.adjustRgb(a);return{x:jt.X(r),y:jt.Y(r),z:jt.Z(r),a:a.a}},cieXYZToRgb:a=>{let r=3.241*a.x-1.5374*a.y-.4986*a.z,e=-.9692*a.x+1.876*a.y+.0416*a.z,t=.0556*a.x-.204*a.y+1.057*a.z;return jt.adjustRgbInv({r,g:e,b:t,a:a.a})},contrastRatio:(a,r)=>{let e=jt.relativeLuminance(a)+.05,t=jt.relativeLuminance(r)+.05;return e>t?e/t:t/e}};function aR(a,r){let e=a.r,t=a.g,n=a.b,i=Math.max(e,t,n),s=Math.min(e,t,n);return(r===0||r===1?0:(i-s)/(1-Math.abs(2*r-1))).clamp(0,1)}function oR(a){let r=a.r,e=a.g,t=a.b,n=Math.max(r,e,t),i=Math.min(r,e,t),s=0;return n!==i&&(n===r?s=(60*((e-t)/(n-i))+360)%360:n===e?s=(60*((t-r)/(n-i))+120)%360:s=(60*((r-e)/(n-i))+240)%360),s.clamp(0,360)}function Rx(a){return a.toString(16).padStart(2,"0")}var Uk=class a{static{this.WCAG_MINIMUM_CONTRAST=3}static{this.WCAG_NORMAL_TEXT_CONTRAST=4.5}static{this.WCAG_SAFE_CONTRAST=7}static _clampRGB(r){let e=t=>Math.min(1,Math.max(0,t));return r[3]==null&&(r[3]=1),{r:e(r[0]),g:e(r[1]),b:e(r[2]),a:Math.min(1,Math.max(0,r[3]))}}static _normalize(r){return[r[0]/255,r[1]/255,r[2]/255,r[3]]}static parse(r){if(r=(r||"").toLowerCase(),$k.test(r)){let e=$k.exec(r);return this._clampRGB(this._normalize([parseInt(e[1]),parseInt(e[2]),parseInt(e[3]),1]))}if(Hk.test(r)){let e=Hk.exec(r);return this._clampRGB(this._normalize([parseInt(e[1]),parseInt(e[2]),parseInt(e[3]),parseFloat(e[4])]))}if(Bk.test(r)){let e=Bk.exec(r)[0];return this._clampRGB(this._normalize([parseInt("0x"+e.substr(1,2)),parseInt("0x"+e.substr(3,2)),parseInt("0x"+e.substr(5,2)),1]))}if(Vk.test(r)){let e=Vk.exec(r)[0],t=e.substr(1,1),n=e.substr(2,1),i=e.substr(3,1);return this._clampRGB(this._normalize([parseInt("0x"+t+t),parseInt("0x"+n+n),parseInt("0x"+i+i),1]))}if(Pk.test(r)){let e=Pk.exec(r),t={h:parseFloat(e[1]),s:parseFloat(e[2])*.01,l:parseFloat(e[3])*.01};return this.rgb(t)}if(Ik.test(r)){let e=Ik.exec(r),t={h:parseFloat(e[1]),s:parseFloat(e[2])*.01,l:parseFloat(e[3])*.01,a:parseFloat(e[4])};return this.rgb(t)}}static hsl(r){let e=sR(r),t=aR(r,e);return{h:oR(r),s:t,l:e,a:r.a}}static cieXYZ(r){return Es(r)&&(r=this.rgb(r)),jt.rgbToCieXYZ(r)}static rgb(r){if(Es(r)){let e=r.h,t=r.s,n=r.l,i=e/60,s=(1-Math.abs(2*n-1))*t,o=s*(1-Math.abs(i%2-1)),c=n-s/2,d=(p,u,h)=>this._clampRGB([p+c,u+c,h+c,r.a]);if(i<=1)return d(s,o,0);if(i<=2)return d(o,s,0);if(i<=3)return d(0,s,o);if(i<=4)return d(0,o,s);if(i<=5)return d(o,0,s);if(i<=6)return d(s,0,o)}else{let e=jt.cieXYZToRgb(r);return this._clampRGB([e.r,e.g,e.b,e.a])}}static stringify(r,e=1){if(Es(r)){e??=1,r.a??=1;let t=typeof e=="number"?e:1;return`hsla(${r.h.roundoff(t)},${(r.s*100).roundoff(t)}%,${(r.l*100).roundoff(t)}%,${r.a.roundoff()})`}else if(jm(r)){e??=!0,r.a??=1;let t=typeof e=="boolean"?e:!!e,n=Math.round(r.r*255),i=Math.round(r.g*255),s=Math.round(r.b*255),o=r.a.roundoff();return o===1?t?("#"+Rx(n)+Rx(i)+Rx(s)).toUpperCase():`rgb(${n},${i},${s})`:`rgba(${n},${i},${s},${o})`}}static contrastRatio(r,e){return Es(r)&&(r=this.rgb(r)),Es(e)&&(e=this.rgb(e)),jt.contrastRatio(r,e)}static luminance(r){return Es(r)&&(r=a.rgb(r)),jt.relativeLuminance(r)}static lighten(r,e=.1){if(e||=0,Es(r)){let t=Math.min(1,Math.max(0,r.l+e));return Object.assign({},r,{l:t})}if(jm(r)){let t=this.lighten(this.hsl(r),e);return this.rgb(t)}return r}static darken(r,e=.1){return this.lighten(r,-e)}static saturate(r,e=.1){if(e||=0,Es(r)){let t=Math.min(1,Math.max(0,r.s+e));return Object.assign({},r,{s:t})}if(jm(r)){let t=this.saturate(this.hsl(r),e);return this.rgb(t)}return r}static desaturate(r,e=.1){return this.saturate(r,-e)}static interpolate(r,e,t,n){t??=.5,n??=t;let i=(t+n).roundoff(),s=(t/i).roundoff(),o=(n/i).roundoff(),c=jm(r),d=Es(r),p=h=>jm(h)||Es(h)?a.cieXYZ(h):h;r=p(r),e=p(e);let u={x:(r.x*s+e.x*o).roundoff(),y:(r.y*s+e.y*o).roundoff(),z:(r.z*s+e.z*o).roundoff(),a:(r.a*s+e.a*o).roundoff()};return c?a.rgb(u):d?a.hsl(a.rgb(u)):u}};var lR=/[-+]?([\d]+(\.[\d]+(e-[\d]+)?)?|[\d]*(\.[\d]+(e-[\d]+)?))/g;function Qv(a){let r=[],e=a.match(lR);return e&&e.length>0&&e.forEach(t=>r.push(parseFloat(t))),r}var zk=class a{static isAngle(r){return typeof r=="object"&&"vertex"in r&&td.isPoint(r.vertex)&&"start"in r&&td.isPoint(r.start)&&"end"in r&&td.isPoint(r.end)}static value(r){if(We.isNullOrEmpty(r)||!a.isAngle(r))return Number.NaN;let{vertex:e,start:t,end:n}=r;return a.angleBetween(e,t,n)}static angleBetween(r,e,t){let n={x:e.x-r.x,y:e.y-r.y},i={x:t.x-r.x,y:t.y-r.y},s=n.x*i.x+n.y*i.y,o=n.x*i.y-n.y*i.x;return-Math.atan2(o,s)}},Zv=class{static parse(r){let e=Qv(r);if(e&&e.length===2)return{width:e[0],height:e[1]};throw new Error(`Cannot parse "${r}" as a valid Size.`)}static isSize(r){return typeof r=="object"&&"width"in r&&typeof r.width=="number"&&"height"in r&&typeof r.height=="number"}},td=class{static parse(r){let e=Qv(r);if(e&&e.length===2)return{x:e[0],y:e[1]};throw new Error(`Cannot parse "${r}" as a valid Point.`)}static isPoint(r){return typeof r=="object"&&"x"in r&&typeof r.x=="number"&&"y"in r&&typeof r.y=="number"}static distance(r,e){return Math.sqrt(Math.pow(r.x-e.x,2)+Math.pow(r.y-e.y,2))}static subtract(r,e){return{x:e.x-r.x,y:e.y-r.y}}static add(...r){var e={x:0,y:0};for(var t of r)e.x+=t.x,e.y+=t.y;return e}static multiply(r,e){return{x:r.x*e,y:r.y*e}}};var Ym=class a{static isIdentity(r){return r.a===1&&r.d===1&&r.b===0&&r.f===0&&r.c===0&&r.e===0}static get identity(){return{a:1,b:0,c:0,d:1,e:0,f:0}}static copy(r){return{a:r.a,b:r.b,c:r.c,d:r.d,e:r.e,f:r.f}}static scale(r,e,t=e){return{a:r.a*e,b:r.b,c:r.c,d:r.d*t,e:r.e,f:r.f}}static translate(r,e){return{a:r.a,b:r.b,c:r.c,d:r.d,e:r.e+e.x,f:r.f+e.y}}static rotate(r,e){let t=Math.cos(e),n=Math.sin(e);return a.multiply(r,{a:t,b:n,c:-n,d:t,e:0,f:0})}static multiply(r,e){return"x"in r&&"y"in r?typeof e=="number"?{x:r.x*e,y:r.y*e}:{x:r.x*e.a+r.y*e.c+e.e,y:r.x*e.b+r.y*e.d+e.f}:typeof e=="number"?{a:r.a*e,b:r.b*e,c:r.c*e,d:r.d*e,e:r.e*e,f:r.f*e}:{a:r.a*e.a+r.b*e.c,b:r.a*e.b+r.b*e.d,c:r.c*e.a+r.d*e.c,d:r.c*e.b+r.d*e.d,e:r.e*e.a+r.f*e.c+e.e,f:r.e*e.b+r.f*e.d+e.f}}static det(r){return r.a*r.d-r.c*r.b}static invert(r){let e=this.det(r);if(e===0)return null;let t=1/e;return this.multiply({a:r.d,b:-r.b,c:-r.c,d:r.a,e:-r.e*r.d+r.c*r.f,f:r.e*r.b-r.a*r.f},t)}static toComponents(r,e={x:0,y:0}){let t=Math.sqrt(r.a*r.a+r.c*r.c),n=Math.sqrt(r.b*r.b+r.d*r.d),i=t!=0?r.a/t:0,s=t!=0?r.c/t:0,o=Math.atan2(s,i),{x:c,y:d}=e,p={x:r.e-c*(t*i-1)+d*t*s,y:r.f-d*(n*i-1)-c*n*s};return{scaleX:t,scaleY:n,rotation:o,translation:p}}static fromTransform([r,e,t],[n,i,s]){let o=r.x*(e.y-t.y)-r.y*(e.x-t.x)+(e.x*t.y-t.x*e.y);if(Math.abs(o)<1e-10)throw new Error("Points are collinear; matrix is singular and cannot be solved.");let c=1/o;return{a:c*(n.x*(e.y-t.y)+i.x*(t.y-r.y)+s.x*(r.y-e.y)),b:c*(n.y*(e.y-t.y)+i.y*(t.y-r.y)+s.y*(r.y-e.y)),c:c*(n.x*(t.x-e.x)+i.x*(r.x-t.x)+s.x*(e.x-r.x)),d:c*(n.y*(t.x-e.x)+i.y*(r.x-t.x)+s.y*(e.x-r.x)),e:c*(n.x*(e.x*t.y-t.x*e.y)+i.x*(t.x*r.y-r.x*t.y)+s.x*(r.x*e.y-e.x*r.y)),f:c*(n.y*(e.x*t.y-t.x*e.y)+i.y*(t.x*r.y-r.x*t.y)+s.y*(r.x*e.y-e.x*r.y))}}static areClose(r,e,t=12){return r.a.isCloseTo(e.a,t)&&r.b.isCloseTo(e.b,t)&&r.c.isCloseTo(e.c,t)&&r.d.isCloseTo(e.d,t)&&r.e.isCloseTo(e.e,t)&&r.f.isCloseTo(e.f,t)}};var eb=class a{static parse(r){let e=Qv(r);if(e&&e.length===4)return{x:e[0],y:e[1],width:e[2],height:e[3]};throw new Error(`Cannot parse "${r}" as a valid Rect.`)}static isRect(r){return td.isPoint(r)&&Zv.isSize(r)}static _stretch(r,e){return{a:e.width/r.width,b:0,c:0,d:e.height/r.height,e:e.x-r.x,f:e.y-r.y}}static _contain(r,e,t,n){let i=1,s=r.width/r.height,o=e.width/e.height;s>=o?i=e.width/r.width:i=e.height/r.height;let c=r.width*i,d=r.height*i,p=this._align({x:r.x,y:r.y,width:c,height:d},e,t,n);return Ym.translate({a:i,b:0,c:0,d:i,e:0,f:0},p)}static _cover(r,e,t,n){let i=1,s=r.width/r.height,o=e.width/e.height;s<o?i=e.width/r.width:i=e.height/r.height;let c=r.width*i,d=r.height*i,p=this._align({x:r.x,y:r.y,width:c,height:d},e,t,n);return Ym.translate({a:i,b:0,c:0,d:i,e:0,f:0},p)}static _align(r,e,t,n){let i=0,s=0;switch(t){case"left":i=e.x-r.x;break;case"right":i=e.x+e.width-r.width-r.x;break;default:i=e.x+e.width*.5-r.width*.5-r.x;break}switch(n){case"top":s=e.y-r.y;break;case"bottom":s=e.y+e.height-r.height-r.y;break;default:s=e.y+e.height*.5-r.height*.5-r.y;break}return{x:i,y:s}}static findTransform(r,e,t="stretch",n="center",i="middle"){switch(t){case"contain":return this._contain(r,e,n,i);case"cover":return this._cover(r,e,n,i);default:return this._stretch(r,e)}}static intersect(...r){let e={x:0,y:0,height:0,width:0},t=Array.from(r||[]);if(t.length<=0)return e;for(var n=t[0],i=1;i<t.length;i++){let s=t[i],o=Math.max(s.x,n.x),c=Math.max(s.y,n.y),d=Math.min(s.x+s.width,n.x+n.width),p=Math.min(s.y+s.height,n.y+n.height),u=d-o,h=p-c;if(u<0||h<=0)return e;n={x:o,y:c,width:u,height:h}}return n}static expand(r,...e){let t=Array.from(e||[]),n=r.x,i=r.y,s=n,o=i;a.isRect(r)&&(s+=r.width,o+=r.height);for(let c of t)n=Math.min(c.x,n),i=Math.min(c.y,i),s=Math.max(c.x,s),o=Math.max(c.y,o);return{x:n,y:i,width:s-n,height:o-i}}};var Gk=class{constructor(r,e){this.#n=r,this.#r=e}#e=[];#t=[];#r;#n;get current(){return this.#n}get canUndo(){return this.#e.length>0}get canRedo(){return this.#t.length>0}set maxlength(r){this.#r=r}undo(){if(this.canUndo){let r=this.#e,e=this.#t,t=this.#n;e.unshift(t),this.#n=r.pop()}}redo(){if(this.canRedo){let r=this.#e,e=this.#t,t=this.#n;r.push(t),this.#n=e.shift()}}push(r){this.#t.splice(0),this.#e.push(this.#n),this.#n=r;let e=this.#r,t=this.#e;e>0&&t.length>e&&t.splice(0,t.length-e)}reset(){this.#t.splice(0),this.#e.splice(0)}};var cR={mode:"stretch",align:"center",valign:"middle",quality:1,type:"image/jpeg"},Fk=class a{static async loadImage(r){let e=await fetch(r);return e.ok?await e.blob():null}static async resizeImage(r,e,t,n){if(e<=0||t<=0||isNaN(e)||isNaN(t))throw new Error("Invalid target size");typeof r=="string"&&(r=await a.loadImage(r));let i=await self.createImageBitmap(r),s=i.width,o=i.height,c=new OffscreenCanvas(s,o),d=c.getContext("2d");d.imageSmoothingEnabled=d.mozImageSmoothingEnabled=d.oImageSmoothingEnabled=d.webkitImageSmoothingEnabled=!0;let{quality:p,type:u,mode:h,align:m,valign:f,background:g}=Object.assign({},cR,n??{}),v={width:s,height:o,x:0,y:0},b={x:0,y:0,width:e,height:t},_=eb.findTransform(v,b,h,m,f);return c.width=e,c.height=t,g&&(d.fillStyle=g,d.fillRect(0,0,c.width,c.height)),d.setTransform(_),d.drawImage(i,0,0),await c.convertToBlob({quality:p,type:u})}};var Wk=class a{static#e;static uniqueId(){let r=a.#e||Date.now();return a.#e=++r}static uniqueCode(){return a.uniqueId().toBase62()}static randomString(r){let e="";do e+=(Math.random()*62).toBase62();while(e.length<r);return e}};var jk=class{static round(r,e=1){return Math.round(r/e)*e}static log(r,e){return Math.log10(r)/Math.log10(e)}static rebase(r,e,t){let n=r.toString(),i=parseInt(n,e);return n.endsWith(i.toString(e))?parseInt(r.toString(),e).toString(t):Number.NaN.toString()}};function Ox(a,r){let e=a.length,t=r.length,n=Array.from({length:e+1},()=>Array(t+1).fill(0));for(let i=1;i<=e;i++)for(let s=1;s<=t;s++)a[i-1]===r[s-1]?n[i][s]=n[i-1][s-1]+1:n[i][s]=Math.max(n[i-1][s],n[i][s-1]);return n}function Px(a,r,e,t=""){let n=a.length,i=r.length,s=[],o=n,c=i,d=null,p=()=>{d&&(s.push(d),d=null)};for(;o>0||c>0;){var u=null;let h=null;o>0&&c>0&&a[o-1]===r[c-1]?(u="=",h=a[o-1],o--,c--):c>0&&(o===0||e[o][c-1]>=e[o-1][c])?(u="+",h=r[c-1],c--):o>0&&(c===0||e[o-1][c]>e[o][c-1])&&(u="-",h=a[o-1],o--),u&&h!==null?d&&d.type===u?d.value=h+(d.value?t:"")+d.value:(p(),d={type:u,value:h}):p()}return p(),s.reverse()}function dR(a,r){let e=a.split(""),t=r.split(""),n=Ox(e,t);return Px(e,t,n,"")}function pR(a,r){let e=/(\S+|\s+)/g,t=a.match(e)||[],n=r.match(e)||[],i=Ox(t,n);return Px(t,n,i,"")}function uR(a,r){let e=/\r?\n/,t=a.split(e),n=r.split(e),i=Ox(t,n);return Px(t,n,i,`
|
|
7
|
+
`)}var Yk=class{static leftPad(r,e,t){return r.toString().padStart(e,t)}static format(r,...e){let t=Array.from(e),n=r;for(let s=0;s<t.length;s++){let o=new RegExp("(^|[^\\{])\\{"+s+"\\}($|[^\\}])","g");n=n.replaceAll(o,(c,...d)=>c.replace("{"+s+"}",t[s]))}let i=/(^|[^\{}])\{(\d+)\}($|[^\}])/.exec(n);if(!We.isNullOrEmpty(i))throw new Error(`Missing argument at index ${i[2]}.`);return n}static diff(r,e,t="char"){switch(t){case"line":return uR(r,e);case"word":return pR(r,e);default:return dR(r,e)}}static async hash(r,e="SHA-256"){let t=await crypto.subtle.digest(e,new TextEncoder().encode(r));return Array.from(new Uint8Array(t)).map(n=>n.toString(16).padStart(2,"0")).join("")}};var qk={};tt(qk,{Markdown:()=>Ux,Parser:()=>Xm});var Ux={};tt(Ux,{Parser:()=>Vx});var Ix=class{tokenize(r,e){let t=[];for(;r;){let n=r.length;for(let i of e){let s=i.exec(r,this),o=s?.length;if(o>0){Array.prototype.push.apply(t,s);let c=s[o-1];r=r.substr((c.index||0)+c.raw.length);break}}if(r.length>=n)throw new Error(`Cannot parse
|
|
8
|
+
"${r}"
|
|
9
|
+
using the provided grammar.`)}return t}},Xm=class{constructor(r=new Ix){this._lexer=r}parse(r,e,t){let n=this._lexer.tokenize(r,e);return t.render(n)}};function $x(a){return(a??"").replace(/</g,"<")}function mR(a){if(!We.isNullOrEmpty(a)&&!(/^\(/.test(a)&&/\)$/.test(a)))return/^\[/.test(a)&&/\]$/.test(a)&&(a=a.substr(1,a.length-2)),a}function ws(a){return a?.index||void 0}function fR(a){if(!We.isNullOrEmpty(a)&&!(/^\[/.test(a)&&/\]$/.test(a)))return/^\(/.test(a)&&/\)$/.test(a)&&(a=a.substr(1,a.length-2)),a}function tb(a){return a?.replace(/[^\w]+/g," ").trim().replace(/ +/g,"-").toLowerCase()}function Wr(a,r,e){let t=r.exec(a);return t&&t.length?e(t):null}var gR=/(<!--)([\s\S]*?)(-->|$)/,vR=/^ {0,3}(={3,}|_{3,}|-{3,})(\r?\n|$)/,bR=/^ {0,3}(#{1,6})\s+([^\n]+)(\r?\n|$)+/,yR=/^ {0,3}([^\n]+)(\r?\n=+(\r?\n|$))+/,_R=/^ {0,3}([^\n]+)(\r?\n-+(\r?\n|$))+/,xR=/^ {4,}.+(\r?\n {4,}.+)*(\r?\n|$)+/,CR=/^ {0,3}``` *([^\n]*)\r?\n(([\s\S](?!\r?\n {0,3}```))*.(\r?\n)+) {0,3}```(\r?\n|$)+/,ER=/^ {0,3}> *([^\n]+)(\r?\n {0,3}> *([^\n]*))*(\r?\n|$)+/,wR=/^( {0,3}([-+]).*\r?\n|$)((?!(?: {0,3}(?:\d+[.\)]|\r?\n\S))).*(\r?\n|$))*/,kR=/^( {0,3}(\d+[.\)]).*\r?\n|$)((?!(?: {0,3}(?:[+-]|\r?\n\S))).*(\r?\n|$))*/,Xk=/^(?:[-+*]|\d+[.\)])/m,MR=/^(?! {4,})(.+(\n(?! {0,3}```)(?! {0,3}([-+]|\d+[.\)]))(?! {4,})(?! {0,3}>).+)*)/,SR=/^ {0,3}(!?)\[([^\]]+)\]: +(\S+)(?: +['"\(](.+)['"\)])?(\r?\n|$)+/,LR=/!?\[(?!\s*\])((?:\[[^\[\]]*\]|\\[\[\]]|[^\[\]])*)\](?:\[\])?(\[[^\[\]]*\]|\([^\(\)]*\))?/,NR=/(\*\*?|__?)(\[[^\]]*]\([^\)]+\))\1/,Hx=/(?:(?<!\\)`)(.+?)(?:(?<!\\)`)/,TR=/(\*\*?|__?)((?!\1\s?)(?:(?!\1)[\S\s])*[^\s])\1/,AR=/(~~?|__?)(?!\1\s?)([^\s][\s\S]*?(?!\1)[^\s])\1/,DR=/(:")(?!":\s?)([^\s][\s\S]*?(?!":)[^\s])":/,RR=/^\s+/,OR=/ {2,}\r?\n/,PR=/^[^\r\n]+/;function rb(a=[]){let r={0:{exec:(g,v)=>Wr(g,gR,b=>{let _=ws(b),E=[{type:"html",index:_,raw:b[0],text:b[2]}];if(_>0){let C=g.substr(0,_),k=v.tokenize(C,f);Array.prototype.unshift.apply(E,k)}return E})},1:{exec:g=>Wr(g,SR,v=>{let b=ws(v),_=v[0],E=_,C=v[1]==="!",k=v[2],w=v[3],T=v[4];return[{type:"ref",index:b,raw:_,text:E,id:k,image:C,url:w,title:T}]})}},e=[],t=[],n={};for(let g of a){let v,b="inline";switch("type"in g?(b=g.type,v=g.rule):v=g,b){case"block":e.push(v);break;case"code":if("lang"in g){let E=g.lang.toLowerCase();(n[E]=n[E]||[]).push(v)}break;default:let _={exec:(E,C)=>{let k=v.exec(E,C);return o(E,k,C),k}};t.push(_);break}}let i={254:{exec:g=>Wr(g,PR,v=>{let b=v[0],_=b;return[{index:ws(v),raw:b,text:_,type:"text"}]})},255:{exec:g=>Wr(g,RR,v=>{let b=v[0];return[{type:"space",raw:b,text:b}]})}},s={13:{exec:(g,v)=>c(g,LR,v,b=>{let _=ws(b),E=b[0],C=E.charAt(0)==="!",k=b[1],w=fR(b[2]),T=tb(mR(b[2])??k);return C?[{index:_,type:w?"img":"imglike",raw:E,text:k,src:w,ref:T,tokens:v.tokenize(k,d)}]:[{index:_,type:w?"link":"linklike",raw:E,text:k,href:w,ref:T,tokens:v.tokenize(k,d)}]})},17:{exec:(g,v)=>c(g,Hx,v,b=>{let _=$x(b[1]);return[{type:"code",raw:b[0],text:_,index:ws(b)}]})},12:{exec:(g,v)=>c(g,NR,v,b=>{if(b.length<3||We.isNullOrEmpty(b[2]))return null;let _=b[1].length>1?"bold":"italic",E=b[2];return[{index:ws(b),type:_,raw:b[0],text:E,tokens:v.tokenize(E,d)}]})},14:{exec:(g,v)=>c(g,TR,v,b=>{if(b.length<3||We.isNullOrEmpty(b[2]))return null;let _=b[1].length>1?"bold":"italic",E=b[2];return[{index:ws(b),type:_,raw:b[0],text:E,tokens:v.tokenize(E,d)}]})},15:{exec:(g,v)=>c(g,AR,v,b=>{if(b.length<3||We.isNullOrEmpty(b[2]))return null;let _="strike",E=b[2];return[{index:ws(b),type:_,raw:b[0],text:E,tokens:v.tokenize(E,d)}]})},16:{exec:(g,v)=>c(g,DR,v,b=>{if(b.length<3||We.isNullOrEmpty(b[2]))return null;let _="quote",E=b[2];return[{index:ws(b),type:_,raw:b[0],text:E,tokens:v.tokenize(E,d)}]})},18:{exec:(g,v)=>c(g,OR,v,b=>{let _=b[0],E=_;return[{index:ws(b),raw:_,text:E,type:"br"}]})}},o=(g,v,b)=>{let _=v?.length>0&&v[0].index;if(_>0){let E=g.substr(0,_),C=b.tokenize(E,d)||[];Array.prototype.unshift.apply(v,C)}},c=(g,v,b,_)=>{let E=Wr(g,v,C=>{if(v!=Hx){let k=Hx.exec(g);if(k&&k.length&&k.index<C.index)return null}return _(C)});return o(g,E,b),E},d=Object.values(s);Array.prototype.push.apply(d,t),d.push(i[254],i[255]);let p=g=>{let v=[i[254],i[255]],b=g?.toLowerCase()||"";return b&&b in n&&Array.prototype.unshift.apply(v,n[b]),v},u={11:{exec:(g,v)=>Wr(g,MR,b=>{let _=b[0],E=_;return[{type:"paragraph",raw:_,text:E,tokens:v.tokenize(E,d)}]})},255:i[255]},h=(g,v)=>{let b=/^ {0,3}(`{3,}|$|>|[+-]\s|\d+[.\)])/m.test(g)?f:d;return v.tokenize(g,b)},f=Object.values({2:{exec:(g,v)=>Wr(g,vR,b=>{let _=b[0];return[{type:"hr",raw:_,text:_}]})},3:{exec:(g,v)=>Wr(g,bR,b=>{let _=b[2];return[{type:"heading",raw:b[0],text:_,level:b[1].length,ref:tb(_),tokens:v.tokenize(_,d)}]})},4:{exec:(g,v)=>Wr(g,yR,b=>{let _=b[1];return[{type:"heading",raw:b[0],text:_,level:1,ref:tb(_),tokens:v.tokenize(_,d)}]})},5:{exec:(g,v)=>Wr(g,_R,b=>{let _=b[1];return[{type:"heading",raw:b[0],text:_,level:2,ref:tb(_),tokens:v.tokenize(_,d)}]})},6:{exec:(g,v)=>Wr(g,xR,b=>{let _=b[0],E=$x(_);return[{type:"codeblock",raw:_,text:E,tokens:v.tokenize(E,[])}]})},7:{exec:(g,v)=>Wr(g,CR,b=>{let _=$x(b[2]),E=b[1]?.toLowerCase();return[{type:"codeblock",raw:b[0],text:_,lang:E,tokens:v.tokenize(_,p(E))}]})},8:{exec:(g,v)=>Wr(g,ER,b=>{let _=b[0],E=_.replace(/^ {0,3}> */gm,"");return[{type:"blockquote",raw:_,text:E,tokens:v.tokenize(E,[u[11],u[255]])}]})},9:{exec:(g,v)=>Wr(g,kR,b=>{let _=b[0],E=_.replace(/^ {0,3}/gm,"").split(Xk).filter(C=>!We.isNullOrEmpty(C)).map(C=>C.trim());return[{type:"ol",start:parseInt(/\d/.exec(b[0])[0]),raw:_,text:_,tokens:E.map(C=>({type:"listitem",raw:C,text:C,tokens:h(C,v)}))}]})},10:{exec:(g,v)=>Wr(g,wR,b=>{let _=b[0],E=_.replace(/^ {0,3}/gm,"").split(Xk).filter(C=>!We.isNullOrEmpty(C)).map(C=>C.trim());return[{type:"ul",raw:_,text:_,tokens:E.map(C=>({type:"listitem",raw:C,text:C,tokens:h(C,v)}))}]})}});return Array.prototype.push.apply(f,e),f.push(u[11],u[255]),[r[0],r[1]].concat(f)}var IR="\0",$R=/[ \r\n]*\0+[ \r\n]*/g;function HR(a){return a?.replace($R,`
|
|
10
|
+
`).trim()}var nb=class{constructor(r=(e,t)=>e?.text||""){this._extraItemRender=r;this._renderContent=r=>{let e=r.tokens;return We.isNullOrEmpty(e)?r.text:this._render(e)}}_rendeItem(r,e){let t=this._renderContent,n=IR;switch(r?.type){case"ref":return"";case"html":return r.raw;case"blockquote":return`<blockquote>
|
|
11
|
+
${t(r)}</blockquote>${n}`;case"bold":return`<b>${t(r)}</b>`;case"codeblock":let i=r.lang;return`<pre>${n}<code${i?' class="'+i+'"':""}>${t(r)}</code>${n}</pre>${n}`;case"code":return`<code>${t(r)}</code>`;case"hr":return`<hr />${n}`;case"heading":let s=r.level,o=r.ref;return`<h${s} id="${o}">${t(r)}</h${s}>${n}`;case"img":case"imglike":let c=r,d=c.src,p="",u=c.text,h=c.ref;if(!d&&h){let b=e.find(_=>_.type==="ref"&&_.image===!0&&_.id?.toLowerCase()===h.toLowerCase());b&&(d=b.url,p=b.title??"")}return d?`<img src="${d}" alt="${u}"${p?' title="'+p+'"':""} />`:`![${t(r)}]`;case"italic":return`<i>${t(r)}</i>`;case"strike":return`<s>${t(r)}</s>`;case"quote":return`<q>${t(r)}</q>`;case"br":return"<br />"+n;case"ol":return`<ol start="${r.start}">
|
|
12
|
+
${t(r)}</ol>${n}`;case"ul":return`<ul>
|
|
13
|
+
${t(r)}</ul>${n}`;case"listitem":return` <li>${t(r)}</li>${n}`;case"link":case"linklike":let m=r,f=m.href,g="",v=m.ref;if(!f&&v){let b=e.find(_=>_.type==="ref"&&_.image!==!0&&_.id?.toLowerCase()===v.toLowerCase());b&&(f=b.url,g=b.title??"")}return f?`<a href="${f}"${g?' title="'+g+'"':""}>${t(r)}</a>`:`[${t(r)}]`;case"paragraph":return`<p>${t(r)}</p>${n}`;case"text":case"space":return r.text}return this._extraItemRender(r,e)}_render(r){let e="";for(let t of r||[])e+=this._rendeItem(t,r);return e}render(r){return HR(this._render(r))}},Bx=class{_render(r){return We.isNullOrEmpty(r)?"":JSON.stringify(r)}render(r){return"["+r.filter(e=>!We.isNullOrEmpty(e)).map(this._render).join(",")+"]"}};function BR(a){return a&&typeof a=="object"&&typeof a.render=="function"}var Vx=class extends Xm{toHtml(r,e,t){let n=new nb(t);return We.isNullOrEmpty(e)?this.parse(r,n):this.parse(r,rb(e),n)}tokenize(r,e){let t=this.parse(r,rb(e),new Bx);return JSON.parse(t)}parse(r,e=rb(),t=new nb){return BR(e)?super.parse(r,rb(),e):super.parse(r,e,t)}};var Jk={};tt(Jk,{LinearAlgebra:()=>Kx,Polygon:()=>Wx,Utils:()=>ks,Utils3D:()=>qx});import{Point as Km,Rect as zx,NullChecker as qm}from"@pacem/pacem-foundation";import{Point as VR}from"@pacem/pacem-foundation";var ii=class a{static unit(r){let e={x:r.x,y:r.y};return this.normalize(e),e}static magSqr(r){return r.x*r.x+r.y*r.y}static mag(r){return Math.sqrt(a.magSqr(r))}static normalize(r){let e=a.mag(r);if(e<=0)throw"Cannot normalize a vector of length 0.";let t=1/e;r.x*=t,r.y*=t}static from(r,e){return VR.subtract(r,e)}static dot(r,e){return r.x*e.x+r.y*e.y}static cross(r,e){return r.x*e.y-r.y*e.x}static areClose(r,e){return(e.x-r.x).isCloseTo(0)&&(e.y-r.y).isCloseTo(0)}};var tu=class{constructor(r,e,t=-1){this.x=r;this.y=e;this.index=t}equals(r){return this.x===r.x&&this.y===r.y}};function zR(a,r,e){let t=a.x,n=a.y,i=r.x,s=r.y,o=e.x,c=e.y,d=2*(t*(s-c)+i*(c-n)+o*(n-s));if(Math.abs(d)<1e-12)return{c:{x:0,y:0},r:1/0};let p=((t*t+n*n)*(s-c)+(i*i+s*s)*(c-n)+(o*o+c*c)*(n-s))/d,u=((t*t+n*n)*(o-i)+(i*i+s*s)*(t-o)+(o*o+c*c)*(i-t))/d,h=Math.hypot(p-t,u-n);return{c:{x:p,y:u},r:h}}var ib=class{constructor(r,e,t){this.v0=r;this.v1=e;this.v2=t;this.circumCirc=zR(r,e,t)}inCircumcircle(r){let e=this.circumCirc.c.x-r.x,t=this.circumCirc.c.y-r.y;return Math.hypot(e,t)<=this.circumCirc.r+1e-9}};function GR(a){let r=1/0,e=1/0,t=-1/0,n=-1/0;for(let p of a)r=Math.min(r,p.x),e=Math.min(e,p.y),t=Math.max(t,p.x),n=Math.max(n,p.y);let i=(t-r)*10,s=(n-e)*10,o=new tu(r-i,e-s*3),c=new tu(r-i,n+s),d=new tu(t+i*3,n+s);return new ib(o,c,d)}function FR(a){let r=[];for(let e=0;e<a.length;++e){let t=!0;for(let n=0;n<a.length;++n)if(e!==n){let i=a[e],s=a[n];if(i.v0.equals(s.v0)&&i.v1.equals(s.v1)||i.v0.equals(s.v1)&&i.v1.equals(s.v0)){t=!1;break}}t&&r.push(a[e])}return r}function WR(a,r){let e=[];r=r.filter(n=>n.inCircumcircle(a)?(e.push({v0:n.v0,v1:n.v1}),e.push({v0:n.v1,v1:n.v2}),e.push({v0:n.v2,v1:n.v0}),!1):!0);let t=FR(e);for(let n of t)r.push(new ib(n.v0,n.v1,a));return r}function jR(a){if(a.length<3)return[];let r=GR(a),e=[r];for(let t of a)e=WR(t,e);return e=e.filter(t=>!(t.v0===r.v0||t.v0===r.v1||t.v0===r.v2||t.v1===r.v0||t.v1===r.v1||t.v1===r.v2||t.v2===r.v0||t.v2===r.v1||t.v2===r.v2)),e}function YR(a){if(a.length<3)return[];let r=a.map((n,i)=>new tu(n.x,n.y,i)),e=jR(r),t=[];for(let n of e)t.push(n.v0.index,n.v1.index,n.v2.index);return t}var sb=class{static triangulate(r){return YR(r)}};var XR=180/Math.PI,Kk=2*Math.PI,rd=12;function ab(a){return Km.isPoint(a)}function qR(a){return a!=null&&Array.isArray(a)&&a.length===2&&ab(a[0])&&ab(a[1])}var ks=class a{static slopeRad(r,e){return Math.atan2(e.y-r.y,e.x-r.x)}static slopeRad2(r,e){return(Kk+a.slopeRad(r,e))%Kk}static slopeDeg(r,e){return a.slopeRad(r,e)*XR}static slopeDeg2(r,e){return(360+a.slopeDeg(r,e))%360}static intersect(r,e,...t){return Array.isArray(r)&&Array.isArray(e)?a._intersectSegments(r,e,!0):zx.isRect(r)?a._intersectRects(...arguments):"vertices"in r?a._mergePolygons(r,e,"intersect")?.polygons??null:null}static boundingBox(r){let e=Number.MAX_VALUE,t=Number.MAX_VALUE,n=-Number.MAX_VALUE,i=-Number.MAX_VALUE,s=r.length;for(let o of r)e=Math.min(e,o.x),t=Math.min(t,o.y),n=Math.max(n,o.x),i=Math.max(i,o.y);return{x:e,y:t,width:n-e,height:i-t}}static combinePolygons(r,e,t){return a._mergePolygons(r,e,t)}static _mergePolygons(r,e,t){if(qm.isNullOrEmpty(r?.vertices)||qm.isNullOrEmpty(e?.vertices))return null;let n=r.vertices.filter(R=>a.inPolygon(R,e.vertices));if(r.vertices.length==n.length)return{polygons:t==="intersect"?[r]:[e]};let i=e.vertices.filter(R=>a.inPolygon(R,r.vertices));if(e.vertices.length===i.length)return{polygons:t==="intersect"?[e]:[r]};let s=a.boundingBox(r.vertices),o=a.boundingBox(e.vertices),c=a.intersect(s,o);if(t!=="union"&&(!zx.isRect(c)||!(c.width>0)||!(c.height>0)))return null;let{vertices:d}=r,{vertices:p}=e;if(d.length<3||p.length<3)return null;let u=(R,U,z)=>[R,z[(U+1)%z.length]],h=(R,U)=>R.x===U.x?R.y-U.y:R.x-U.x,m=d.map(u),f=p.map(u),g=d.concat(p),v=new Map,b=R=>{if(!v.has(R)){let U=[];v.set(R,U)}return v.get(R)},_=!1;for(let R of m){let U=b(R);for(let z of f){let G=b(z),Z=a.intersect(R,z);qm.isNull(Z)||(_=!0,g.push(Z),U.push(Z),G.push(Z))}}if(n.length===0&&i.length===0&&!_)return t==="union"?{polygons:[r,e]}:null;let E=[];for(let R of m.concat(f)){let U=b(R);if(qm.isNullOrEmpty(U))E.push(R);else{let z=R.concat(U).sort(h);for(let G=0;G<z.length-1;G++)E.push([z[G],z[G+1]])}}var C=!1,k;do{g.sort(h),g.filter((z,G,Z)=>G===0||!a.areClose(z,Z[G-1])),k=a.mesh(g);let{vertices:R,triangleIndices:U}=k;C=!1;for(let z=0;z<U.length;z+=3){let G=U[z],Z=U[z+1],q=U[z+2],Q=R[G],Ne=R[Z],ne=R[q],pe=[[Q,Ne],[Ne,ne],[ne,Q]];for(let ee of E)for(let J of pe){let ue=a.areClose(J[0],ee[0])||a.areClose(J[1],ee[1])||a.areClose(J[0],ee[1])||a.areClose(J[1],ee[0])?null:a.intersect(J,ee);!qm.isNull(ue)&&g.findIndex(Te=>a.areClose(Te,ue,4))===-1&&(C=!0,g.push(ue))}}}while(C);let{vertices:w,triangleIndices:T}=k,I=[];for(let R=0;R<T.length;R+=3){let U=R,z=R+1,G=R+2,Z=w[T[U]],q=w[T[z]],Q=w[T[G]],Ne={x:(Z.x+q.x+Q.x)/3,y:(Z.y+q.y+Q.y)/3},ne=a.inPolygon(Ne,d),pe=a.inPolygon(Ne,p);(ne&&pe&&t==="intersect"||(ne||pe)&&t==="union"||(ne&&!pe||!ne&&pe)&&t==="difference")&&I.push([Z,q,Q])}let O=I.flatMap(([R,U,z])=>[[R,U],[U,z],[z,R]]),D=[];for(let R=0;R<O.length;R++){let U=O[R];if(R==0){D.push(U);continue}let z=D.findIndex(G=>a.areClose(G[0],U[0])&&a.areClose(G[1],U[1])||a.areClose(G[0],U[1])&&a.areClose(G[1],U[0]));z===-1?D.push(U):D.splice(z,1)}if(D.length<3)return null;let P=[],N=R=>{let{length:U}=R,z=a.areClose(R[0],R[U-1]),G=R.slice(0,z?U-1:U);return G.length>3&&a.inSegment(G[0],[G[1],G[G.length-1]])&&G.shift(),G},[H,V]=D.shift(),B=[H,V];for(;D.length>1;){let R=B[B.length-1],U=D.findIndex(z=>a.areClose(z[0],R)||a.areClose(z[1],R));if(U===-1){P.push({vertices:N(B.splice(0))});let[z,G]=D.shift();B.push(z,G)}else{let[z]=D.splice(U,1),G=a.areClose(z[0],R)?z[1]:a.areClose(z[1],R)?z[0]:null;B.length>1&&a.inSegment(B[B.length-1],[B[B.length-2],G])?B.splice(B.length-1,1,G):B.push(G)}}return P.push({vertices:N(B)}),{polygons:P,mesh:k,triangles:I.map(R=>({vertices:R}))}}static mesh(r,...e){let t=[].concat(r).concat(e),n=sb.triangulate(t);return{vertices:t,triangleIndices:n}}static intersectLines(r,e,t,n){let i,s;if(Array.isArray(r)&&Array.isArray(e)&&r.length===2&&e.length===2&&typeof r[0]=="number"&&typeof e[0]=="number"&&typeof r[1]=="number"&&typeof e[1]=="number"&&(t=e[0],n=e[1],e=r[1],r=r[0]),typeof r=="number"&&typeof e=="number"){let o=r,c=e;i=[{x:0,y:c},{x:1,y:o+c}],s=[{x:0,y:n},{x:1,y:t+n}]}else i=r,s=e;return a._intersectSegments(i,s,!1)}static cramer(r,e){Array.isArray(r)&&(r={a:r[0],b:r[1],c:r[2]}),Array.isArray(e)&&(e={a:e[0],b:e[1],c:e[2]});let t=(r.b*e.c-r.c*e.b)/(r.b*e.a-r.a*e.b),n=(r.c*e.a-r.a*e.c)/(r.b*e.a-r.a*e.b);return{x:-t.roundoff(),y:-n.roundoff()}}static mq(r,e){let t;if(ab(r)?t=r:(t=r[0],e=r[1]),t.x===e.x)return[Number.NaN,Number.NaN];let n=(e.y-t.y)/(e.x-t.x),i=t.y-n*t.x;return[n,i]}static _intersectSegments(r,e,t){let n=r[0],i=r[1],s=e[0],o=e[1],c=Math.min(n.x,i.x),d=Math.min(n.y,i.y),p=Math.max(n.x,i.x),u=p-c,h=Math.max(n.y,i.y),m=h-d,f=Math.min(s.x,o.x),g=Math.min(s.y,o.y),v=Math.max(s.x,o.x),b=v-f,_=Math.max(s.y,o.y),E=_-g;if(u===0&&b===0||m===0&&E===0)return null;let C=T=>T.x<f||T.x>v||T.x<c||T.x>p,k=T=>T.y<g||T.y>_||T.y<d||T.y>h;var w=null;if(u===0){if(t&&(f>c||v<p))return null;let T=a.mq(s,o);w=a.cramer([1,0,-c],[T[0],-1,T[1]]),t&&k(w)&&(w=null)}else if(b===0){if(t&&(c>f||p<v))return null;let T=a.mq(n,i);w=a.cramer([T[0],-1,T[1]],[1,0,-f]),t&&k(w)&&(w=null)}else if(m===0){if(t&&(g>d||_<h))return null;let T=a.mq(s,o);w=a.cramer([0,1,-d],[T[0],-1,T[1]]),t&&C(w)&&(w=null)}else if(E===0){if(t&&(d>g||h<_))return null;let T=a.mq(n,i);w=a.cramer([T[0],-1,T[1]],[0,1,-g]),t&&C(w)&&(w=null)}else{let T;if(!t||(T=a._intersectRects({x:c,y:d,width:u,height:m},{x:f,y:g,width:b,height:E}))&&T.width>0&&T.height>0){let I=a.mq(n,i),O=a.mq(s,o),D=I[0],P=O[0],N=I[1],H=O[1];if(D!==P){w=a.cramer([D,-1,N],[P,-1,H]);let V=w.x,B=w.y;t&&(V<T.x||V>T.x+T.width||B<T.y||B>T.y+T.height)&&(w=null)}}}return w===null?null:{x:w.x,y:w.y}}static _intersectRects(...r){return zx.intersect(...r)}static _areClose(r,e,t=rd){return Math.abs(r.x-e.x).isCloseTo(0,t)&&Math.abs(r.y-e.y).isCloseTo(0,t)}static areClose(r,e,t=rd){return a._areClose(r,e,t)}static dot(r,e){return ii.dot(r,e)}static cross(r,e){return ii.cross(r,e)}static distance(r,e){if(qR(r))return Km.distance(r[0],r[1]);if(ab(e))return Km.distance(r,e);{let t=e[0],n=e[1];return Math.abs(t*r.x-r.y+n)/Math.sqrt(Math.pow(t,2)+1)}}static _pointSegmentDistance(r,e){let t=ii.from(e[0],e[1]),n=ii.from(e[0],r);return a.cross(t,n)}static isWithin(r,e,t,n=rd){let i=a._pointSegmentDistance(r,e);return i.isCloseTo(0,n)?!1:t?i<0:i>0}static isBeyond(r,e,t,n=rd){return a.isWithin(r,e,!t,n)}static inLine(r,e,t=rd){return a._pointSegmentDistance(r,e).isCloseTo(0,t)}static inSegment(r,e,t=rd){let n=Math.min(e[0].x,e[1].x),i=Math.max(e[0].x,e[1].x),s=Math.min(e[0].y,e[1].y),o=Math.max(e[0].y,e[1].y);return r.x>=n&&r.x<=i&&r.y>=s&&r.y<=o&&a.inLine(r,e,t)}static inTriangle(r,e){let t;for(let n=0;n<3;n++){let i=e[n],s=e[(n+1)%3],o=Km.subtract(s,r),c=Km.subtract(i,r),d=a.cross(o,c);if(n>0&&d*t<=0)return!1;t=d}return!0}static inPolygon(r,e,t=rd){if(!(e?.length>=3))throw"Not enough vertices";let n=e.length;if(n===3)return a.inTriangle(r,[e[0],e[1],e[2]]);t>0&&(e=e.map(h=>({x:h.x.roundoff(t),y:h.y.roundoff(t)})),r={x:r.x.roundoff(t),y:r.y.roundoff(t)});let i=Number.MAX_VALUE,s=Number.MAX_VALUE,o=Number.MIN_VALUE,c=Number.MIN_VALUE;for(let h=0;h<n;h++){let m=e[h];i=Math.min(i,m.x),s=Math.min(s,m.y),o=Math.max(o,m.x),c=Math.max(c,m.y)}if(r.x<i||r.x>o||r.y<s||r.y>c)return!1;let d={x:i-1,y:r.y},p=[d,r],u=0;for(let h=0;h<n;h++){let m=e[h],f=e[(h+1)%n],g=[m,f];if(m.y===r.y){let v=e[(h-1+n)%n];r.x>m.x&&(v.y-r.y)*(f.y-r.y)<0&&u++}else{if(f.y===r.y)continue;a.intersect(g,p)!=null&&u++}}return u%2===1}static area(r,...e){let t=[].concat(r).concat(e),n=0,i=t.length;if(i>=3){for(let s=0;s<t.length;s++){let{x:o,y:c}=t[s],d=s===i-1?0:s+1,{x:p,y:u}=t[d];n+=o*u-c*p}n*=.5}return Math.abs(n.roundoff())}static convexHull(r,...e){let t=[].concat(r).concat(e);if(!(t?.length>1))return t?.slice()??[];let n=t.map(d=>({x:d.x,y:d.y})).sort((d,p)=>d.x===p.x?d.y-p.y:d.x-p.x),i=[];for(let d of n){let p=i[i.length-1];(!p||p.x!==d.x||p.y!==d.y)&&i.push(d)}if(i.length<=2)return i;let s=(d,p,u)=>(p.x-d.x)*(u.y-d.y)-(p.y-d.y)*(u.x-d.x),o=[];for(let d of i){for(;o.length>=2&&s(o[o.length-2],o[o.length-1],d)<=0;)o.pop();o.push(d)}let c=[];for(let d=i.length-1;d>=0;d--){let p=i[d];for(;c.length>=2&&s(c[c.length-2],c[c.length-1],p)<=0;)c.pop();c.push(p)}return o.pop(),c.pop(),o.concat(c)}};import{Point as Jm,Matrix2D as Gx,Angle as Fx,NullChecker as KR}from"@pacem/pacem-foundation";function JR(a){let r;return"vertices"in a&&Array.isArray(a.vertices)&&(r=a.vertices).length>=3&&r.every(e=>Jm.isPoint(e))}var Wx=class a{static{this._eps=1e-12}static isPolygon(r){return JR(r)}static from(...r){return{vertices:Array.from(r)}}static contains(r,e){return ks.inPolygon(e,r.vertices,12)}static centroid(r){let e=a.boundingBox(r);return{x:e.x+e.width/2,y:e.y+e.height/2}}static boundingBox(r){return ks.boundingBox(r.vertices)}static sides(r){let{vertices:e}=r,t=[];for(let n=1;n<=e.length;n++){let i=e[n%e.length],s=e[n-1];t.push([s,i])}return t}static isConvex(r){let{vertices:e}=r,t=e.length;if(t<=3)return!0;let n=0;for(let i=0;i<e.length;i++){let s=e[(i-1+t)%t],o=e[i],c=e[(i+1)%t],d=Fx.angleBetween(o,s,c);if(n===0){n=Math.sign(d);continue}if(n!=Math.sign(d))return!1}return!0}static isSelfIntersecting(r){let{vertices:e}=r;if(e.length<=3)return!1;let t=a.sides(r);for(let n of t)for(let i of t){if(i===n||i[0]===n[1]||n[0]===i[1])continue;let s=ks.intersect(i,n);if(!KR.isNull(s))return!0}return!1}static isCounterClockwise(r){let{vertices:[e,t,n]}=r;return Fx.angleBetween(t,e,n)>0}static expand(r,e){let{vertices:t}=r,n=t.length,i=[];for(let s=0;s<t.length;s++){let o=t[(s-1+n)%n],c=t[s],d=t[(s+1)%n],p=Fx.angleBetween(c,o,d),u=-e/Math.sin(Math.abs(p)/2),h=Gx.scale(Gx.identity,u),m=Jm.subtract(c,o);ii.normalize(m);let f=Jm.subtract(c,d);ii.normalize(f);let g=Jm.add(m,f);ii.normalize(g);let v=Gx.multiply(g,h);i.push(Jm.add(c,{x:v.x.roundoff(),y:v.y.roundoff()}))}return{vertices:i}}static area(r){return ks.area(r.vertices)}static intersect(r,e){return ks.intersect(r,e)}static convexHull(r){return{vertices:ks.convexHull(r.vertices)}}};import{parseAsNumericalArray as Xx}from"@pacem/pacem-foundation";var ob=180/Math.PI,Zm=1/ob,Je=class a{static from(...r){if(r.length!==3)throw new RangeError("Must provide exactly 3 numbers");return{x:r[0],y:r[1],z:r[2]}}static parse(r){let e=Xx(r);if(e&&e.length===3)return a.from.apply(null,e);throw new Error(`Cannot parse "${r}" as a valid Vector3D.`)}static i(){return{x:1,y:0,z:0}}static j(){return{x:0,y:1,z:0}}static k(){return{x:0,y:0,z:1}}static zero(){return{x:0,y:0,z:0}}static subtract(r,e){return{x:e.x-r.x,y:e.y-r.y,z:e.z-r.z}}static add(...r){var e={x:0,y:0,z:0};for(var t of r)e.x+=t.x,e.y+=t.y,e.z+=t.z;return e}static dot(r,e){return r.x*e.x+r.y*e.y+r.z*e.z}static cross(r,e){return{x:r.y*e.z-r.z*e.y,y:r.z*e.x-r.x*e.z,z:r.x*e.y-r.y*e.x}}static scale(r,e,t=e,n=e){return{x:r.x*e,y:r.y*t,z:r.z*n}}static magSqr(r){return r.x*r.x+r.y*r.y+r.z*r.z}static areClose(r,e){return(e.x-r.x).isCloseTo(0)&&(e.y-r.y).isCloseTo(0)&&(e.z-r.z).isCloseTo(0)}static mag(r){return Math.sqrt(a.magSqr(r))}static negate(r){return{x:-r.x,y:-r.y,z:-r.z}}static unit(r){let e={x:r.x,y:r.y,z:r.z};return this.normalize(e),e}static normalize(r){let e=a.mag(r);if(e<=0)throw"Cannot normalize a vector of length 0.";let t=1/e;r.x*=t,r.y*=t,r.z*=t}static angleBetween(r,e){let t,n=a.unit(r),i=a.unit(e);if(a.dot(n,i)<0){let o={x:-n.x-i.x,y:-n.y-i.y,z:-n.z-i.z},c=a.mag(o);t=Math.PI-2*Math.asin(c/2)}else{let o={x:n.x-i.x,y:n.y-i.y,z:n.z-i.z},c=a.mag(o);t=2*Math.asin(c/2)}return ob*t}},jx=class a{static from(r,e,t){return{rho:r.clamp(0,1/0),theta:e.clamp(-180,180),phi:t.clamp(0,360)}}static fromVector(r,e,t){typeof r=="number"&&(r=Je.from(r,e,t));let n=Je.mag(r);if(n.isCloseTo(0))return a.from(0,0,0);let i=Math.atan2(r.x,r.z),s=Math.acos((r.y/n).clamp(-1,1));return a.from(n,i*ob,s*ob)}static toVector(r){let{rho:e,theta:t,phi:n}=r,i=n*Zm,s=t*Zm,o=Math.sin(i)*e;return{x:o*Math.sin(s),y:Math.cos(i)*e,z:o*Math.cos(s)}}static toRotationMatrix(r){let{theta:e,phi:t}=r,n=Zm*e,i=Math.sin(n),s=Math.cos(n),o=Zm*t,c=Math.sin(o),d=Math.cos(o);return bl.from(i*d,i*c,s,0,s*d,s*c,-i,0,-c,d,0,0,0,0,0,1)}},nd=class a{static modify(r,e){let{m11:t,m12:n,m13:i,m14:s,m21:o,m22:c,m23:d,m24:p,m31:u,m32:h,m33:m,m34:f,offsetX:g,offsetY:v,offsetZ:b,m44:_}=r,E={m11:t,m12:n,m13:i,m14:s,m21:o,m22:c,m23:d,m24:p,m31:u,m32:h,m33:m,m34:f,offsetX:g,offsetY:v,offsetZ:b,m44:_};return e(E),E}static clone(r){return a.modify(r,e=>{})}static multiply(r,e){return bl.isIdentity(r)?e:bl.isIdentity(e)?r:bl.from(r.m11*e.m11+r.m12*e.m21+r.m13*e.m31+r.m14*e.offsetX,r.m11*e.m12+r.m12*e.m22+r.m13*e.m32+r.m14*e.offsetY,r.m11*e.m13+r.m12*e.m23+r.m13*e.m33+r.m14*e.offsetZ,r.m11*e.m14+r.m12*e.m24+r.m13*e.m34+r.m14*e.m44,r.m21*e.m11+r.m22*e.m21+r.m23*e.m31+r.m24*e.offsetX,r.m21*e.m12+r.m22*e.m22+r.m23*e.m32+r.m24*e.offsetY,r.m21*e.m13+r.m22*e.m23+r.m23*e.m33+r.m24*e.offsetZ,r.m21*e.m14+r.m22*e.m24+r.m23*e.m34+r.m24*e.m44,r.m31*e.m11+r.m32*e.m21+r.m33*e.m31+r.m34*e.offsetX,r.m31*e.m12+r.m32*e.m22+r.m33*e.m32+r.m34*e.offsetY,r.m31*e.m13+r.m32*e.m23+r.m33*e.m33+r.m34*e.offsetZ,r.m31*e.m14+r.m32*e.m24+r.m33*e.m34+r.m34*e.m44,r.offsetX*e.m11+r.offsetY*e.m21+r.offsetZ*e.m31+r.m44*e.offsetX,r.offsetX*e.m12+r.offsetY*e.m22+r.offsetZ*e.m32+r.m44*e.offsetY,r.offsetX*e.m13+r.offsetY*e.m23+r.offsetZ*e.m33+r.m44*e.offsetZ,r.offsetX*e.m14+r.offsetY*e.m24+r.offsetZ*e.m34+r.m44*e.m44)}},bl=class a{static identity(){return{m11:1,m12:0,m13:0,m14:0,m21:0,m22:1,m23:0,m24:0,m31:0,m32:0,m33:1,m34:0,offsetX:0,offsetY:0,offsetZ:0,m44:1}}static from(...r){if(r.length!==16)throw new RangeError("Must provide exactly 16 numbers");return{m11:r[0],m12:r[1],m13:r[2],m14:r[3],m21:r[4],m22:r[5],m23:r[6],m24:r[7],m31:r[8],m32:r[9],m33:r[10],m34:r[11],offsetX:r[12],offsetY:r[13],offsetZ:r[14],m44:r[15]}}static transpose(r){return a.from(r.m11,r.m21,r.m31,r.offsetX,r.m12,r.m22,r.m32,r.offsetY,r.m13,r.m23,r.m33,r.offsetZ,r.m14,r.m24,r.m34,r.m44)}static toArray(r){return[r.m11,r.m12,r.m13,r.m14,r.m21,r.m22,r.m23,r.m24,r.m31,r.m32,r.m33,r.m34,r.offsetX,r.offsetY,r.offsetZ,r.m44]}static clone(r,e){return typeof e=="function"?nd.modify(r,e):nd.clone(r)}static scale(r,e,t,n){return typeof e=="number"?(t??=e,n??=e):(n=e.z,t=e.y,e=e.x),nd.modify(r,i=>{i.m11*=e,i.m22*=t,i.m33*=n})}static translate(r,e){return nd.modify(r,t=>{t.offsetX+=e.x,t.offsetY+=e.y,t.offsetZ+=e.z})}static parse(r){let e=Xx(r);if(e&&e.length===16)return a.from.apply(null,e);throw new Error(`Cannot parse "${r}" as a valid Matrix3D.`)}static isIdentity(r){return r.m11==1&&r.m12==0&&r.m13==0&&r.m14==0&&r.m21==0&&r.m22==1&&r.m23==0&&r.m24==0&&r.m31==0&&r.m32==0&&r.m33==1&&r.m34==0&&r.offsetX==0&&r.offsetY==0&&r.offsetZ==0&&r.m44==1}static isAffine(r){return r.m14==0&&r.m24==0&&r.m34==0&&r.m44==1}static determinant(r){if(a.isIdentity(r))return 1;if(a.isAffine(r))return r.m11*(r.m22*r.m33-r.m32*r.m23)-r.m12*(r.m21*r.m33-r.m31*r.m23)+r.m13*(r.m21*r.m32-r.m31*r.m22);{let e=r.m13*r.m24-r.m23*r.m14,t=r.m13*r.m34-r.m33*r.m14,n=r.m13*r.m44-r.offsetZ*r.m14,i=r.m23*r.m34-r.m33*r.m24,s=r.m23*r.m44-r.offsetZ*r.m24,o=r.m33*r.m44-r.offsetZ*r.m34,c=r.m22*t-r.m32*e-r.m12*i,d=r.m12*s-r.m22*n+r.offsetY*e,p=r.m32*n-r.offsetY*t-r.m12*o,u=r.m22*o-r.m32*s+r.offsetY*i;return r.offsetX*c+r.m31*d+r.m21*p+r.m11*u}}static multiply(...r){if(r.length===0)throw new ReferenceError("Matrix not provided.");let e=Array.from(r),t=e[0];for(let n=1;n<e.length;n++)t=nd.multiply(t,e[n]);return t}static invert(r){if(a.isAffine(r)){let e=a.determinant(r);if(e==0)return null;let t=r.m12*r.m23-r.m22*r.m13,n=r.m32*r.m13-r.m12*r.m33,i=r.m22*r.m33-r.m32*r.m23,s=r.m21*r.m13-r.m11*r.m23,o=r.m11*r.m33-r.m31*r.m13,c=r.m31*r.m23-r.m21*r.m33,d=r.m11*r.m22-r.m21*r.m12,p=r.m11*r.m32-r.m31*r.m12,u=r.m11*r.offsetY-r.offsetX*r.m12,h=r.m21*r.m32-r.m31*r.m22,m=r.m21*r.offsetY-r.offsetX*r.m22,f=r.m31*r.offsetY-r.offsetX*r.m32,g=r.m23*u-r.offsetZ*d-r.m13*m,v=r.m13*f-r.m33*u+r.offsetZ*p,b=r.m33*m-r.offsetZ*h-r.m23*f,_=d,E=-p,C=h,k=1/e;return a.from(i*k,n*k,t*k,0,c*k,o*k,s*k,0,C*k,E*k,_*k,0,b*k,v*k,g*k,1)}else{let e=a.determinant(r);if(e==0)return null;let t=r.m33*r.m44-r.m34*r.offsetZ,n=r.m32*r.m44-r.m34*r.offsetY,i=r.m31*r.m44-r.m34*r.offsetX,s=r.m32*r.offsetZ-r.m33*r.offsetY,o=r.m31*r.offsetZ-r.m33*r.offsetX,c=r.m31*r.offsetY-r.m32*r.offsetX,d=r.m33*r.m44-r.m34*r.offsetZ,p=r.m32*r.m44-r.m34*r.offsetY,u=r.m31*r.m44-r.m34*r.offsetX,h=r.m32*r.offsetZ-r.m33*r.offsetY,m=r.m31*r.offsetZ-r.m33*r.offsetX,f=r.m31*r.offsetY-r.m32*r.offsetX,g=r.m23*r.m44-r.m24*r.offsetZ,v=r.m22*r.m44-r.m24*r.offsetY,b=r.m21*r.m44-r.m24*r.offsetX,_=r.m22*r.offsetZ-r.m23*r.offsetY,E=r.m21*r.offsetZ-r.m23*r.offsetX,C=r.m21*r.offsetY-r.m22*r.offsetX,k=r.m23*r.m34-r.m24*r.m33,w=r.m22*r.m34-r.m24*r.m32,T=r.m21*r.m34-r.m24*r.m31,I=r.m22*r.m33-r.m23*r.m32,O=r.m21*r.m33-r.m23*r.m31,D=r.m21*r.m32-r.m22*r.m31,P=r.m22*t-r.m23*n+r.m24*s,N=-(r.m21*t-r.m23*i+r.m24*o),H=r.m21*n-r.m22*i+r.m24*c,V=-(r.m21*s-r.m22*o+r.m23*c),B=-(r.m12*d-r.m13*p+r.m14*h),R=r.m11*d-r.m13*u+r.m14*m,U=-(r.m11*p-r.m12*u+r.m14*f),z=r.m11*h-r.m12*m+r.m13*f,G=r.m12*g-r.m13*v+r.m14*_,Z=-(r.m11*g-r.m13*b+r.m14*E),q=r.m11*v-r.m12*b+r.m14*C,Q=-(r.m11*_-r.m12*E+r.m13*C),Ne=-(r.m12*k-r.m13*w+r.m14*I),ne=r.m11*k-r.m13*T+r.m14*O,pe=-(r.m11*w-r.m12*T+r.m14*D),ee=r.m11*I-r.m12*O+r.m13*D,J=1/e;return a.from(P*J,B*J,G*J,Ne*J,N*J,R*J,Z*J,ne*J,H*J,U*J,q*J,pe*J,V*J,z*J,Q*J,ee*J)}}static transform(r,e){var t={x:r.x,y:r.y,z:r.z};if(!a.isIdentity(e)){var n=t.x,i=t.y,s=t.z;if(t.x=n*e.m11+i*e.m21+s*e.m31+e.offsetX,t.y=n*e.m12+i*e.m22+s*e.m32+e.offsetY,t.z=n*e.m13+i*e.m23+s*e.m33+e.offsetZ,!a.isAffine(e)){var o=n*e.m14+i*e.m24+s*e.m34+e.m44;o!=0&&(t.x/=o,t.y/=o,t.z/=o)}}return t}},Yx=class a{static identity(){return a.from(0,0,0,1)}static from(...r){if(r.length!==4)throw new RangeError("Must provide exactly 4 numbers");return{x:r[0],y:r[1],z:r[2],w:r[3]}}static parse(r){let e=Xx(r);if(e&&e.length===4)return a.from.apply(null,e);throw new Error(`Cannot parse "${r}" as a valid Quaternion.`)}static fromVectors(r,e){Je.normalize(r),Je.normalize(e);let t=(i,s,o,c)=>{let d=a.from(i,s,o,c);return a.normalize(d),d},n=Je.dot(r,e)+1;return n.isCloseTo(0)?Math.abs(r.x)>Math.abs(r.z)?t(-r.y,r.x,0,0):t(0,-r.z,r.y,0):t(r.y*e.z-r.z*e.y,r.z*e.x-r.x*e.z,r.x*e.y-r.y*e.x,n)}static normalize(r){let e=a.mag(r);if(e.isCloseTo(0))r.x=r.y=r.z=0,r.w=1;else{let t=1/e;r.x*=t,r.y*=t,r.z*=t,r.w*=t}}static unit(r){let e=a.from(r.x,r.y,r.z,r.w);return a.normalize(e),e}static fromAxisAngle(r,e){e%=360;var t=Zm*e,n=Je.mag(r);if(n==0)throw new RangeError("Invalid argument");var i=Math.sin(.5*t)/n,s=r.x*i,o=r.y*i,c=r.z*i;return a.from(s,o,c,Math.cos(.5*t))}static fromRotationMatrix(r){let e=r.m11+r.m22+r.m33+r.m44;if(e>0){let t=.5/Math.sqrt(e),n=.25/t,i=(r.m23-r.m32)*t,s=(r.m31-r.m13)*t,o=(r.m12-r.m21)*t;return a.from(i,s,o,n)}else if(r.m11>r.m22&&r.m11>r.m22){let t=.5/Math.sqrt(r.m44+r.m11-r.m22-r.m33),n=(r.m23-r.m32)*t,i=.25/t,s=(r.m12+r.m21)*t,o=(r.m31+r.m13)*t;return a.from(i,s,o,n)}else if(r.m22>r.m33){let t=.5/Math.sqrt(r.m44+r.m22-r.m11-r.m33),n=(r.m23+r.m32)*t,i=.25/t,s=(r.m12+r.m21)*t,o=(r.m31-r.m13)*t;return a.from(s,i,n,o)}else{let t=.5/Math.sqrt(r.m44+r.m33-r.m11-r.m22),n=(r.m23+r.m32)*t,i=.25/t,s=(r.m12-r.m21)*t,o=(r.m31-r.m13)*t;return a.from(o,n,i,s)}}static conjugate(r){return a.from(-r.x,-r.y,-r.z,r.w)}static mag(r){return Math.sqrt(r.x*r.x+r.y*r.y+r.z*r.z+r.w*r.w)}static norm(r){return r.x*r.x+r.y*r.y+r.z*r.z}static axis(r){return r.x==0&&r.y==0&&r.z==0?Je.j():Je.unit(r)}static transform(r,e){a.normalize(e);let t=Je.cross(e,r),n=Je.scale(t,2),i=Je.cross(e,n);return{x:r.x+e.w*n.x+i.x,y:r.y+e.w*n.y+i.y,z:r.z+e.w*n.z+i.z}}static angle(r){let e=Math.sqrt(r.x*r.x+r.y*r.y+r.z*r.z),t=r.w;if(e>Number.MAX_VALUE){let n=Math.max(Math.abs(r.x),Math.max(Math.abs(r.y),Math.abs(r.z))),i=r.x/n,s=r.y/n,o=r.z/n;e=Math.sqrt(i*i+s*s+o*o),t/=n}return Math.atan2(e,t)*114.59155902616465}static toRotationMatrix(r){var e=bl.identity(),t=r.x,n=r.y,i=r.z,s=r.w;return e.m11=1-2*n*n-2*i*i,e.m12=2*t*n+2*s*i,e.m13=2*t*i-2*s*n,e.m21=2*t*n-2*s*i,e.m22=1-2*t*t-2*i*i,e.m23=2*n*i+2*s*t,e.m31=2*s*n+2*t*i,e.m32=2*n*i-2*s*t,e.m33=1-2*t*t-2*n*n,e}static invert(r){let e=a.unit(r);return a.conjugate(e)}static multiply(r,e){return a.from(r.w*e.x+r.x+e.w+r.y*e.z-r.z*e.y,r.w*e.y-r.x*e.z+r.y*e.w+r.z*e.x,r.w*e.z+r.x*e.y-r.y*e.x+r.z*e.w,r.w*e.w-r.x*e.x-r.y*e.y-r.z*e.z)}static dot(r,e){var t=a.multiply(r,a.conjugate(e));return t.w}};var qx=class{static intersect(r,e){let[t,n]=r,i=Je.subtract(t,n),[s,o,c]=e,d=Je.subtract(s,o),p=Je.subtract(s,c),u=Je.cross(i,p),h=Je.dot(d,u);if(h.isCloseTo(0))return null;let m=1/h,f=Je.subtract(t,s),g=m*Je.dot(f,u);if(g<0||g>1)return null;let v=Je.cross(f,d),b=m*Je.dot(i,v);if(b<0||g+b>1)return null;let _=m*Je.dot(p,v);return _<0||_.isCloseTo(0)?null:Je.add(t,Je.scale(i,_))}};var Kx={};tt(Kx,{Matrix3D:()=>bl,Quaternion:()=>Yx,Spherical:()=>jx,Vector:()=>ii,Vector3D:()=>Je});var iM={};tt(iM,{Complex:()=>jr,DataAnalysis:()=>aC,NumberTheory:()=>cC});function Ms(a){return typeof a=="number"&&(a={real:a,img:0}),a}var Zk;function id(a,r){let e={};return Object.defineProperty(e,"real",{value:a,writable:!1}),Object.defineProperty(e,"img",{value:r,writable:!1}),e}function Jx(){return Zk||(Zk=id(Number.NaN,Number.NaN))}var jr=class{static build(r,e){return this.isComplex(r)?r:(e??=0,typeof r!="number"||typeof e!="number"?Jx():id(r,e||0))}static add(r,e){let t=Ms(r),n=Ms(e);return id(t.real+n.real,t.img+n.img)}static subtract(r,e){let t=Ms(r),n=Ms(e);return id(t.real-n.real,t.img-n.img)}static multiply(r,e){let t=Ms(r),n=Ms(e);return id(t.real*n.real-t.img*n.img,t.real*n.img+t.img*n.real)}static divide(r,e){let t=Ms(r),n=Ms(e),i=this.absSquare(n).roundoff();if(i===0)return Jx();let s=1/i;return id(s*(t.real*n.real+t.img*n.img),s*(t.img*n.real-t.real*n.img))}static absSquare(r){let e=Ms(r);return Math.pow(e.real,2)+Math.pow(e.img,2)}static modulus(r){return Math.sqrt(this.absSquare(r))}static isComplex(r){return r!=null&&typeof r=="object"&&"real"in r&&"img"in r&&typeof r.real=="number"&&typeof r.img=="number"}static conjugate(r){return r=Ms(r),id(r.real,Math.abs(r.img)==0?0:-r.img)}static equals(r,e){let t=this.build(r),n=this.build(e);return!this.isComplex(r)||!this.isComplex(e)?!1:t.real===n.real&&t.img===n.img}static get NaC(){return Jx()}};var aC={};tt(aC,{Fourier:()=>Qx,Gaussian:()=>ru,Lagrange:()=>lb,Lagrangian:()=>nO,Newton:()=>tC,Pchip:()=>eC,SearchFunctions:()=>pO,Utils:()=>nC});function ZR(a,r){let e=2*Math.PI*a/r;return jr.build(Math.cos(e),Math.sin(e))}var Qk={};function eM(a,r){let e=Qk[r]=Qk[r]||{};return e[a]=e[a]||ZR(a,r)}function QR(a){return a>0&&(a&a-1)===0}function Zx(a){let r=[],e=a.length;if(e===1)return[jr.build(a[0])];let t=Zx(a.filter((s,o)=>o%2===0)),n=Zx(a.filter((s,o)=>o%2===1));for(var i=0;i<e/2;i++){let s=t[i],o=jr.multiply(eM(i,e),n[i]);r[i]=jr.add(s,o),r[i+e/2]=jr.subtract(s,o)}return r}var Qx=class{static transform(r,e=!0){return r=r||[],QR(r.length)?this.fft(r,e):this.dft(r,e)}static invert(r,e=!0){return this.idft(r||[],e)}static dft(r,e=!0){let t=(r||[])?.length,n=e?1/Math.sqrt(t):1,i=[];for(let s=0;s<t;s++){i.push({real:0,img:0});for(let o=0;o<t;o++){let c=eM(s*o,t),d=jr.multiply(r[o],c),p=jr.multiply(d,n);i[s]=jr.add(i[s],p)}}return i}static idft(r,e=!0){let t=r.map(i=>jr.build(i.img,i.real));return this.transform(t,e).map(i=>jr.build(i.img,i.real))}static fft(r,e=!0){let t=Zx(r);if(!e)return t;let n=1/Math.sqrt(r.length);return t.map(i=>jr.multiply(i,n))}};var eO=Math.sqrt(Math.PI);function tO(a){let r=Math.abs(a),e=1/(1+.5*r),t=e*Math.exp(-r*r-1.26551223+e*(1.00002368+e*(.37409196+e*(.09678418+e*(-.18628806+e*(.27886807+e*(-1.13520398+e*(1.48851587+e*(-.82215223+e*.17087277)))))))));return a>=0?t:2-t}var ru=class{constructor(r,e){this.mean=r,this.stdev=Math.abs(e),this.variance=Math.pow(e,2)}static get normal(){return rO}weight(r){return Math.exp(-.5*Math.pow(this._z(r),2))}probabilityDensity(r){let e=this.stdev*Math.SQRT2*eO;return this.weight(r)/e}_z(r){return(r-this.mean)/this.stdev}probability(r){return .5*tO(-this._z(r)/Math.SQRT2)}},rO=new ru(0,1);var lb=class a{constructor(r){this.#e=r}#e;#t=null;_prepareBarycentric(){if(this.#t)return;let r=this.#e||[],e=r.length;if(e===0){this.#t=[];return}let t=new Array(e),n=new Array(e);for(let o=0;o<e;o++){let c=0,d=1,p=r[o].x;for(let u=0;u<e;u++){if(u===o)continue;let h=p-r[u].x;if(h===0)throw new Error("Invalid function provided.");h<0&&(d=-d),c+=Math.log(Math.abs(h))}t[o]=-c,n[o]=d}let i=t[0];for(let o=1;o<e;o++)t[o]>i&&(i=t[o]);let s=new Array(e);for(let o=0;o<e;o++){let c=Math.exp(t[o]-i);s[o]=n[o]*c}this.#t=s}_computeBarycentric(r){let e=this.#e||[];this.#t||this._prepareBarycentric();let t=this.#t||[],n=0,i=0;for(let s=0;s<e.length;s++){let o=e[s].x;if(r===o)return e[s].y;let c=t[s]/(r-o);n+=c*e[s].y,i+=c}return n/i}interpolate(r){return this._computeBarycentric(r)}static create(...r){var e=[];arguments.length>0&&Array.isArray(arguments[0])?e=arguments[0]:e=Array.from(r);let t=e.map((n,i)=>typeof n=="number"?{x:i,y:n}:n);return new a(t)}},nO={create:lb.create},eC=class a{constructor(r){if(!r||r.length<2)throw new Error("Need at least 2 points");let e=r.slice().sort((t,n)=>t.x-n.x);this.xs=e.map(t=>t.x),this.ys=e.map(t=>t.y),this.ms=this.computeDerivatives()}computeDerivatives(){let r=this.xs.length,e=new Array(r-1),t=new Array(r-1);for(let i=0;i<r-1;i++)e[i]=this.xs[i+1]-this.xs[i],t[i]=(this.ys[i+1]-this.ys[i])/e[i];let n=new Array(r).fill(0);n[0]=t[0],n[r-1]=t[r-2];for(let i=1;i<r-1;i++){let s=t[i-1],o=t[i];if(s===0||o===0||s*o<=0)n[i]=0;else{let c=2*e[i]+e[i-1],d=e[i]+2*e[i-1];n[i]=(c+d)/(c/s+d/o)}}for(let i=0;i<r-1;i++)if(t[i]===0)n[i]=0,n[i+1]=0;else{let s=n[i]/t[i],o=n[i+1]/t[i],c=s*s+o*o;if(c>9){let d=3/Math.sqrt(c);n[i]=d*s*t[i],n[i+1]=d*o*t[i]}}return n}interpolate(r){let e=this.xs,t=this.ys,n=this.ms,i=e.length;if(r<=e[0]){let v=n[0];return t[0]+v*(r-e[0])}if(r>=e[i-1]){let v=n[i-1];return t[i-1]+v*(r-e[i-1])}let s=0,o=i-1;for(;o-s>1;){let v=s+o>>1;e[v]<=r?s=v:o=v}let c=e[s+1]-e[s],d=(r-e[s])/c,p=d*d,u=p*d,h=2*u-3*p+1,m=u-2*p+d,f=-2*u+3*p,g=u-p;return h*t[s]+m*(n[s]*c)+f*t[s+1]+g*(n[s+1]*c)}static create(...r){var e=[];arguments.length>0&&Array.isArray(arguments[0])?e=arguments[0]:e=Array.from(r);let t=e.map((n,i)=>typeof n=="number"?{x:i,y:n}:n);return new a(t)}},tC=class a{constructor(r){if(!r||r.length===0)throw new Error("Need at least 1 point");let e=r.slice().sort((i,s)=>i.x-s.x);this.xs=e.map(i=>i.x);let t=e.length,n=e.map(i=>i.y);for(let i=1;i<t;i++)for(let s=t-1;s>=i;s--){let o=this.xs[s]-this.xs[s-i];if(o===0)throw new Error("Invalid function provided.");n[s]=(n[s]-n[s-1])/o}this.coeffs=n}interpolate(r){let e=this.xs,t=this.coeffs,n=t.length;if(n===0)return NaN;let i=t[n-1];for(let s=n-2;s>=0;s--)i=i*(r-e[s])+t[s];return i}static create(...r){var e=[];arguments.length>0&&Array.isArray(arguments[0])?e=arguments[0]:e=Array.from(r);let t=e.map((n,i)=>typeof n=="number"?{x:i,y:n}:n);return new a(t)}};var Ss=(a,r)=>a;function iO(a,r=Ss){let e=Object.groupBy(a,r),t,n=0;for(let i in e){let s=e[i].length;s>n&&(t=parseInt(i),n=s)}return t}function sO(a,r=Ss){let e=a.slice(0),t=e.length;e.sort((i,s)=>{let o=r(i),c=r(s);return o-c});let n=Math.ceil(e.length/2)-1;return t%2==1?e[n]:.5*(e[n+1]+e[n])}function rM(a,r=Ss){return a.reduce((e,t,n)=>e+r(t,n),0)}function cb(a,r=Ss){return rM(a,r)/a.length}function rC(a,r=Ss,e=!1){let t=cb(a,r);return a.reduce((n,i)=>Math.pow(i-t,2)+n,0)/(a.length-(e?1:0))}function tM(a,r=Ss,e=!1){let t=rC(a,r,e);return Math.sqrt(t)}function aO(a,r,e=Ss,t=Ss){let n=Array.isArray(r);if(n&&r.length!==a.length)throw new Error("Sets must be of the same length.");let i=a.length,s=a,o=n?r:a,c=n?e:r,d=n?t:e,p=cb(s,c),u=cb(o,d),h=0,m=0,f=0;for(let g=0;g<i;g++){let v=s[g],b=o[g],_=c(v,g)-p,E=d(b,g)-u;h+=_*E,m+=_*_,f+=E*E}return h/Math.sqrt(m*f)}function oO(a,r,e=Ss,t=Ss){let n=Array.isArray(r);if(n&&r.length!==a.length)throw new Error("Sets must be of the same length.");let i=a,s=n?r:a,o=n?e:r,c=n?t:o,d=o??(E=>E.x),p=c??(E=>E.y),u=a.length,h=0,m=0,f=0,g=0,v=0;for(let E=0;E<u;E++){let C=i[E],k=s[E],w=d(C,E),T=p(k,E);h+=w*T,m+=w,f+=T,g+=w*w,v+=T*T}let b=(u*h-m*f)/(u*g-Math.pow(m,2)),_=(f-b*m)/u;return[b,_]}var nC=class{static sum(r,e){return rM(r,e)}static mean(r,e){return cb(r,e)}static median(r,e){return sO(r,e)}static mode(r,e){return iO(r,e)}static var(r,e){return rC(r,e,!0)}static varp(r,e){return rC(r,e,!1)}static stdevp(r,e){return tM(r,e,!1)}static stdev(r,e){return tM(r,e,!0)}static correlation(r,e,t,n){return aO(r,e,t,n)}static linearRegression(r,e,t,n){return oO(r,e,t,n)}static gaussian(r,e){return new ru(r,e)}};function iC(a,r){return(t,n,i,s)=>{let o=t,c=n,d=a(o,c),p=r(o,c),u=i(d),h=i(p);for(;c-o>s;)u<h?(c=p,p=d,h=u,d=a(o,c),u=i(d)):(o=d,d=p,u=h,p=r(o,c),h=i(p));return .5*(d+p)}}var sC=.001,lO=(a,r,e,t=sC)=>iC((c,d)=>d-(d-c)/1.618,(c,d)=>c+(d-c)/1.618)(a,r,e,t);function cO(a){if(a<=1)throw new RangeError("segments must be a number grater than 1.");return(r,e,t,n=sC)=>iC((c,d)=>c+(d-c)/a,(c,d)=>d-(d-c)/a)(r,e,t,n)}var dO=(a,r,e,t=sC)=>{var n=null,i=null;let s=(p,u)=>(i??=u-p,n??=i/Math.sqrt(12),n*(u-p)/i);return iC((p,u)=>Math.max(p,(u+p)/2-s(p,u)),(p,u)=>Math.min(u,(u+p)/2+s(p,u)))(a,r,e,t)},pO={linear:(a=2)=>cO(a),goldenRatio:lO,gaussian:dO};var cC={};tt(cC,{Utils:()=>lC});import{Numbers as nM,NullChecker as uO}from"@pacem/pacem-foundation";var db="0123456789abcdefghijklmnopqrstuvwxyz",oC=`Radix out of range: possible values go between positive 1 exclusive and ${db.length} inclusive`,lC=class a{static lcd(...r){if(uO.isNullOrEmpty(r)||r.length<=1)throw"Insufficient set of numbers.";function e(i,s){return s?e(s,i%s):s===0?i:NaN}function t(i,s){return i*s/e(i,s)}let n=Math.round(r[0]);for(let i=1;i<r.length;i++)n=t(n,Math.round(r[i]));return n}static gcd(r,e){return r=Math.round(r),e=Math.round(e),r===0?e:a.gcd(e%r,r)}static rebaseInt(r,e,t){return nM.rebase(r,e,t)}static rebaseFloat(r,e,t,n=12){let i=a.rebaseFloat10ToN,s=a.rebaseFloatNTo10;if(e===10){let c=parseFloat(r.toString());return t%1===0?a.rebaseFloat10ToNIntBase(c,t,n):i(c,t,n)}if(t===10)return s(r.toString(),e,n);let o=s(r.toString(),e,n+1);return i(o,t,n)}static rebaseFloatNTo10(r,e,t=12){let n=db;if(e<=1||e>n.length)throw new Error(oC);let i=(r??"0").toString().toLowerCase(),s=Number.NaN;if(i==="0")return 0;let o=/^([-+]?) *([\da-z]+)?(.[\da-z]+)?$/.exec(i);if(o.length<2)return s;let c=o[1]==="-"?-1:1,d=o[2]||"0",p=o[3]||".0",u=0,h=0;for(let m of d+p.substr(1)){let f=n.indexOf(m);if(f===-1||f>=e)return s;u+=f*Math.pow(e,d.length-h-1),h++}return c*u}static rebaseFloat10ToNIntBase(r,e,t=12){let n=db;if(e<=1||e>n.length)throw new Error(oC);let i=e,s=Math.abs(r??0);if(s===0||Number.isNaN(s))return r.toString();let o=(s%1).roundoff(),c="";do{let p=s/i,u=Math.floor(p),h=(s-u*i).roundoff(),m=Math.floor(h);if(m>=n.length?c=`[${m}]`+c:c=n[m]+c,u<=0)break;s=u}while(!0);if(c=c.replace(/^0+/,""),c||="0",o===0)return c;let d="";do{s=(o*i).roundoff();let p=Math.floor(s),u=(s-p).roundoff();p>=n.length?d=`[${p}]`:d+=n[p],o=u}while(!o.isCloseTo(0)&&d.length<t);return/^0*$/.test(d)?c:(Math.sign(r)<0?"-":"")+c+"."+d.replace(/0+$/,"")}static rebaseFloat10ToN(r,e,t=12){let n=db;if(e<=1||e>n.length)throw new Error(oC);let i=e,s=Math.abs(r??0);if(s===0||Number.isNaN(s))return r.toString();let o=Math.sign(r)<0?"-":"",c=[],d=[];for(let m=0;m<20;m++)c.push("0"),d.push("0");let p=i%1===0?i:Math.ceil(i);function u(m,f,g){let v=m?c:d,b=v[f]=v[f]||"0",_=n.indexOf(b)+g,E=_%p,C=Math.floor(_/p);return v[f]=n[E],C>0&&(m?u(m,f+1,C):f===0?u(!0,0,C):u(!1,f-1,C)),C}let h=0;do{let m=Math.floor(nM.log(s,i)),f=m>=0,g=f?m:Math.abs(1+m);if(u(f,g,1),s=(s-Math.pow(i,m).roundoff()).roundoff(),f||h++,s===0||h>=100){let v=o+(c.reverse().map(_=>_||"0").join("").replace(/^0+/,"")||"0"),b=d.map(_=>_||"0").join("").substr(0,t).replace(/0+$/,"");return/^0*$/.test(b)?v:v+"."+b}}while(!0)}};var sM={};tt(sM,{FieldChangeEvent:()=>Qm,FieldChangeEventName:()=>nu,L10n:()=>hC,OpenApi:()=>pC});import{CustomTypedEvent as hO}from"@pacem/pacem-core";var nu="change",Qm=class extends hO{constructor(r){super(nu,r,{bubbles:!0,cancelable:!1})}};var pC={};tt(pC,{ApiParameterType:()=>pb,ApiParserBase:()=>Aa,OpenApi3Parser:()=>tf,OpenApiParser:()=>dC,SwaggerParser:()=>ef,getOpenApiDefinition:()=>fO});import{Net as gO}from"@pacem/pacem-core";var pb=(s=>(s.String="string",s.Number="number",s.Datetime="datetime",s.Boolean="boolean",s.Binary="binary",s.Object="object",s))(pb||{}),Aa=class{async load(r,e){let t=await fetch(r,{mode:"cors",credentials:"omit",headers:e});try{let n=await t.json();return this.parse(n,r)}catch{return null}}},mO=/^#\/(definitions|components\/schemas)\/(.+)$/;function fO(a,r){var e=mO.exec(r);return e&&e.length>2?{name:e[2],schema:a.definitions[e[2]]}:null}var ub=gO.HttpMethod,ef=class extends Aa{_findDefinitionName(r){var e=/#\/definitions\/(.+)/,t=e.exec(r);return t==null||t.length<2?r:t[1]}parse(r,e){let t=r;typeof t=="string"&&(t=JSON.parse(t));let n=t,i={};for(let c in n.definitions){let d=this._findDefinitionName(c);i[d]=n.definitions[c]}let s="";if(n.host&&n.schemes.length>0)s=n.schemes[0]+"://"+n.host+n.basePath;else if(e){let c=/^(https?):\/\/([^\/]+)/.exec(e);c&&c.length&&(!n.schemes&&c.length>1&&(n.schemes=[c[1]]),!n.host&&c.length>2&&(n.host=c[2],n.basePath=""),s=c[0])}else console.warn("Not able to find a base url from the OpenApi specs.");let o={endpoints:[],definitions:i,baseUrl:s};for(let c in n.paths){let d=n.paths[c];for(let p of[ub.Get,ub.Delete,ub.Post,ub.Put]){let u=d[p.toLowerCase()];if(u){let h=this._tryGetEndpoint(n,u,c,p);o.endpoints.push(h)}}}return o}_tryGetEndpoint(r,e,t,n){return{response:this._tryGetResponse(r,e),path:t,method:n,parameters:this._tryGetParameters(r,e)}}_translateType(r,e){switch(r){case"number":case"integer":return"number";case"boolean":return"boolean";case"string":switch(e){case"date":case"date-time":return"datetime";case"byte":return"binary";case"binary":throw"Binary octets not supported."}return"string"}return"string"}_tryGetParameters(r,e){return(e.parameters||[]).map(t=>{let n=t,i={name:n.name,required:n.required||!1},s=t.type;if(t.schema){let o=t;i.type="object";let c=i.fullType=this._findDefinitionName(o.schema.$ref);i.meta=r.definitions[c]}else s&&(i.type=this._translateType(s,t.format));return i})}_tryGetResponse(r,e){let t=e.responses[200];if(!t||!t.schema)return null;let n=t.schema.type||"object",i,s;return t.schema.$ref?(s=this._findDefinitionName(t.schema.$ref),i=r.definitions[s]):(i=t.schema,t.schema.items&&(t.schema.items.hasOwnProperty("$ref")?(s=this._findDefinitionName(t.schema.items.$ref),i=r.definitions[s]):i=t.schema.items)),{type:n,fullType:s,meta:i}}};import{Utils as vO}from"@pacem/pacem-core";var tf=class extends Aa{parse(r,e){let t=r;typeof t=="string"&&(t=JSON.parse(t));let n=t,i=[],s=this._gatherDefinitions(new Map,n.components.schemas);for(let o in n.paths)for(let c in n.paths[o]){let d=n.paths[o][c];i.push({path:o,method:c.toUpperCase(),parameters:this._convertToApiParameters(d.parameters),response:this._tryGetResponse(s,d.responses)})}return{endpoints:i,definitions:s,baseUrl:e}}_convertToApiParameters(r=[]){let e=[];for(let t of r){let n=t.schema;"type"in n&&e.push({name:t.name,required:t.required,type:this._translateType(n.type,n.format)})}return e}_translateType(r,e){switch(r){case"number":case"integer":return"number";case"boolean":return"boolean";case"string":switch(e){case"date":case"date-time":return"datetime";case"byte":return"binary";case"binary":throw"Binary octets not supported."}return"string"}return"string"}_gatherDefinitions(r,e){let t={};for(let n in e)t[n]=this._findDefinition(r,e,n);return t}_findDefinition(r,e,t){if(r.has(t))return r.get(t);if(t in e){let n=e[t];return r.set(t,n),n}return null}_findDefinitionName(r){var e=/#\/components\/schemas\/(.+)/,t=e.exec(r);return t==null||t.length<2?r:t[1]}_tryGetResponse(r,e){let n={responses:e}.responses[200];if(vO.isNullOrEmpty(n&&n.content))return null;let i;for(let d in n.content){i=n.content[d].schema;break}let s="object",o,c;return"$ref"in i?(c=this._findDefinitionName(i.$ref),o=r[c]):(s=i.type,o=i,i.type==="array"&&("$ref"in i.items?(c=this._findDefinitionName(i.items.$ref),o=r[c]):o=i.items)),{type:s,fullType:c,meta:o}}};var dC=class extends Aa{constructor(e=new tf,t=new ef){super();this._openApi3=e;this._swagger=t}parse(e,t){let n=e;typeof n=="string"&&(n=JSON.parse(n));let i=n;return"openapi"in i?this._openApi3.parse(i,t):this._swagger.parse(i,t)}};var hC={};tt(hC,{Forms:()=>uC});import{Utils as iu,Transformer as bO}from"@pacem/pacem-core";var yO={display:(a,r,e)=>e[`${a}_${r}`],validator:(a,r,e,t)=>t["validator_"+a+"_"+e]??t["validator_"+a+r+"_"+e],commandTooltip:(a,r)=>r["command_tooltip_"+a]},rf=class rf{static localizeMetadata(r,e,t){return rf._localizeMetadata(r,e,t)}static _localizeMetadata(r,e,t,n=""){t=iu.extend({},yO,t);for(let i of r.props){if("props"in i&&typeof i.props=="object"&&!iu.isArray(i.props)){let c=n+i.prop+".";i.props=rf._localizeMetadata(i.props,e,t,c)}let s=i.display=i.display??{},o=n+i.prop;if(s.name=t.display("name",o,e)??s.name,s.watermark=t.display("watermark",o,e)??s.watermark,s.description=t.display("description",o,e)??s.description,!iu.isNullOrEmpty(i.commands))for(let c of i.commands){let d=t.commandTooltip(c.name,e);iu.isNullOrEmpty(d)||(c.tooltip=d)}if(!iu.isNullOrEmpty(i.validators)){let c={};for(let d of i.validators){let p=d.type;if(typeof p=="string"){let u=c[p]=(c[p]??-1)+1,h=t.validator(p,u,o,e);iu.isNullOrEmpty(h)||(d.errorMessage=h)}}}}return r}};l([bO("forms.localizeMetadata")],rf,"localizeMetadata",1);var uC=rf;var lM={};tt(lM,{DragEvent:()=>au,DrawableEvent:()=>Ui,PresentationState:()=>nf,Shape:()=>Da,StageEvent:()=>sf,UI2DEvent:()=>su,isDrawable:()=>ou,isGroup:()=>sd,isImage:()=>pu,isLinearGradient:()=>af,isPresentationObject:()=>of,isRadialGradient:()=>lu,isShape:()=>cu,isText:()=>du,isUiObject:()=>Sn});import{Utils as fC,CustomUIEvent as _O}from"@pacem/pacem-core";import{Point as mC,Matrix2D as aM}from"@pacem/pacem-foundation";function ou(a){return!fC.isNull(a)&&"stage"in a}function Sn(a){return ou(a)}function oM(a){return"stops"in a&&fC.isArray(a.stops)}function af(a){return oM(a)&&"start"in a&&mC.isPoint(a.start)&&"end"in a&&mC.isPoint(a.end)}function lu(a){return oM(a)&&"center"in a&&mC.isPoint(a.center)&&"radius"in a&&typeof a.radius=="number"}var nf=class{static combine(r,e,t=null){return{opacity:(r.opacity??1)*(e.opacity??1),transformMatrix:t??aM.multiply(e.transformMatrix,r.transformMatrix),dashArray:r.dashArray??e.dashArray,fill:r.fill??e.fill,lineCap:r.lineCap??e.lineCap,lineJoin:r.lineJoin??e.lineJoin,lineWidth:r.lineWidth??e.lineWidth,stroke:r.stroke??e.stroke}}};function of(a){return Sn(a)&&("fill"in a||"transformMatrix"in a||"stroke"in a||"lineJoin"in a||"dashArray"in a||"lineWidth"in a||"opacity"in a||"lineCap"in a)}function cu(a){return Sn(a)&&"pathData"in a}function sd(a){return Sn(a)&&"childDrawables"in a&&!fC.isNullOrEmpty(a.childDrawables)}function du(a){return Sn(a)&&"text"in a&&typeof a.text=="string"}function pu(a){return Sn(a)&&"src"in a&&typeof a.src=="string"}var su=class extends _O{constructor(r,e,t,n){super(r,e,t),this.#e=n}#e;get transformMatrix(){return this.#e}project(r={x:this.screenX,y:this.screenY}){return aM.multiply(r,this.#e)}},Da=class{static empty(){return{pathData:"",vertices:[],boundingRect:{x:0,y:0,width:0,height:0}}}},au=class extends su{},Ui=class extends su{constructor(r,e,t,n){super(r,{detail:e,bubbles:!0,cancelable:!0},t,n)}},sf=class extends su{constructor(r,e,t,n=e.transformMatrix){super(r,{detail:e,bubbles:!0,cancelable:!0},t,n)}};var vM={};tt(vM,{BooleanOrNumberConverter:()=>vC,DragEvent:()=>ad,KnownShader:()=>Fi,LineGeometry:()=>_l,MaterialElement:()=>Ot,MeshGeometry:()=>je,NodeGeometry:()=>pd,NotifyChange:()=>dd,Pacem3DAdapterElement:()=>yl,Pacem3DCameraElement:()=>ai,Pacem3DGroupElement:()=>Ts,Pacem3DLightElement:()=>Ln,Pacem3DMeshElement:()=>zi,Pacem3DObjectElement:()=>Gi,Pacem3DOrthographicCameraElement:()=>si,Pacem3DPerspectiveCameraElement:()=>Ns,Point3DConverter:()=>Ra,Point3DOrNumberConverter:()=>mb,QuaternionConverter:()=>gC,RenderableElement:()=>Ls,RenderableEvent:()=>od,StalePropertyFlag:()=>Os,UI3DEvent:()=>bu,Ui3DElement:()=>_r,computePlaneNormal:()=>yC,computeSharpVertexNormals:()=>xr,isBasicMaterial:()=>yb,isCamera:()=>Pr,isGeometry:()=>df,isGroup:()=>cd,isInteraction:()=>bb,isLambertMaterial:()=>_b,isLight:()=>Rs,isLineMaterial:()=>xl,isMaterial:()=>oi,isMesh:()=>Nn,isMeshGeometry:()=>xu,isOrthographicCamera:()=>vb,isPerspectiveCamera:()=>gb,isPhongMaterial:()=>xb,isRenderable:()=>cf,isShaderMaterial:()=>gM,isStage:()=>bC,isStandardMaterial:()=>Cb,isUi3DObject:()=>_u});import{Watch as Ae,PropertyConverters as bt,CustomElement as yu,PacemEventTarget as MO,PropertyChangeEvent as SO,CustomElementUtils as mM,CustomUIEvent as LO,P as ld,Utils as Ds,Components as NO}from"@pacem/pacem-core";import{Geometry as As}from"@pacem/pacem-numerical";import{Utils as xO}from"@pacem/pacem-core";import{parseAsNumericalArray as cM}from"@pacem/pacem-foundation";import{Geometry as hb}from"@pacem/pacem-numerical";var Ra={convert:a=>hb.LinearAlgebra.Vector3D.parse(a),convertBack:a=>`${a.x||0} ${a.y||0} ${a.z||0}`},mb={convert:a=>{let r=cM(a),e=()=>{throw new Error(`Cannot parse "${a}" as a valid Vector3D.`)};if(xO.isNullOrEmpty(r)&&e(),r.length===3)return hb.LinearAlgebra.Vector3D.from(...r);if(r.length===1){let t=r[0];return hb.LinearAlgebra.Vector3D.from(t,t,t)}e()},convertBack:a=>`${a.x||0} ${a.y||0} ${a.z||0}`},gC={convert:a=>hb.LinearAlgebra.Quaternion.parse(a),convertBack:a=>`${a.x||0} ${a.y||0} ${a.z||0} ${a.w||0}`},vC={convert:a=>a==="true"?!0:a==="false"?!1:cM(a)[0],convertBack:a=>a.toString()};import{CustomElement as CO,P as uu,PCSS as dM,Defaults as EO,ViewChild as pM,Watch as hu,PropertyConverters as mu,Utils as Yr,Components as uM,PropertyChangeEventName as hM,Logging as wO,Animations as kO,UI as fb}from"@pacem/pacem-core";var Oa=Math.PI/180;var fu,gu,Xr=class extends uM.PacemItemsContainerElement{constructor(){super(...arguments);this._itemPropertyChangeHandler=e=>{let t=e.target;this.adapter&&this.adapter.updateItem(this,t),t.flags.splice(0)};this._clickHandler=e=>{let t=this;if(!t.interactive||Yr.isNull(t._lastHitResult))return;let n=e.type.replace(/^mouse/,""),i=t._lastHitResult,s=i.object,o=i.point;this._itemDispatch(s,o,n,e)};this._hitTestCallback=(e,t)=>{let n=this;if(e!=n._lastHitResult){if(e?.object!=n._lastHitResult?.object){let i=e?.object,s=n._lastHitResult?.object,o=e?.point;Yr.isNull(s)||this._itemDispatch(s,o,"out",t),Yr.isNull(i)||this._itemDispatch(i,o,"over",t)}n._lastHitResult=e}};this._moveHandler=e=>{let t=this;if(!t.adapter||!t.interactive)return;let n=t._resizer.currentSize,i=o=>t._hitTestCallback(o,e),s=e.type==="mousemove"?{x:e.pageX-n.left,y:e.pageY-n.top}:{x:-1,y:-1};t.adapter.raycast(this,s,n,i)};$(this,fu);this._resizeHandler=e=>{let t=x(this,fu),n=e.detail;if(!Yr.isNull(t)&&t.height===n.height&&t.width===n.width)return;A(this,fu,n);let i=this.adapter;Yr.isNull(i)||(this.adapter.invalidateSize(this,n),this.dispatchEvent(new uM.ResizeEvent(n)))};$(this,gu)}validate(e){return e instanceof Ls}get stage(){return this._container}get scene(){return this.adapter&&this.adapter.getScene(this)}register(e){let t=super.register(e);return t&&(this._add(e),e.addEventListener(hM,this._itemPropertyChangeHandler,!1)),t}unregister(e){let t=super.unregister(e);return t&&(e.removeEventListener(hM,this._itemPropertyChangeHandler,!1),this._erase(e)),t}_refreshDatasource(e=this.datasource){this.adapter?.updateItem(this,void 0)}_buildUpDatasourceFromDOM(e=this.items){Yr.isNullOrEmpty(e)||(this.datasource=e.slice())}_add(e){this.adapter&&this.adapter.addItem(this,e)}_erase(e){this.adapter&&this.adapter.removeItem(this,e)}_initializeAdapter(e,t){return new Promise((n,i)=>{let s=this.datasource||[];Yr.isNull(e)||s.forEach(o=>e.removeItem(this,o)),!Yr.isNull(this._container)&&!Yr.isNull(t)?t.initialize(this).then(o=>{(s||[]).forEach(c=>this._add(c)),n()},o=>{this.log(wO.LogLevel.Error,o?.toString()),i(o)}):n()})}propertyChangedCallback(e,t,n,i){if(super.propertyChangedCallback(e,t,n,i),!i)switch(e){case"adapter":this._initializeAdapter(t,n);break;case"items":this._buildUpDatasourceFromDOM(n);break;case"transparent":this.adapter?.invalidateSize(this,this.size);break;case"datasource":this._refreshDatasource(n);case"disabled":case"background":this.render();break}}viewActivatedCallback(){super.viewActivatedCallback();let e=this._container,t=this._resizer;t.addEventListener("resize",this._resizeHandler,!1),t.target=e,this._initializeAdapter(null,this.adapter).then(n=>{e.addEventListener("mousemove",this._moveHandler,!1),e.addEventListener("click",this._clickHandler,!1),e.addEventListener("mouseup",this._clickHandler,!1),e.addEventListener("mousedown",this._clickHandler,!1),e.addEventListener("mouseout",this._moveHandler,!1),this._buildUpDatasourceFromDOM(),this.render()})}_itemDispatch(e,t,n,i){if(!Yr.isNull(e)){var s,o,c;i instanceof Event?o=i:s={item:e,offset:i},typeof n=="string"?c=n:(c=n.type,o=n.originalEvent);let p=t,u=()=>i instanceof Event?new od(c,e,o,p):new ad(c,{detail:s,cancelable:c===fb.DragDropEventType.Init||c===fb.DragDropEventType.Drag},o,p),h=i instanceof Event?new od("item"+c,e,o,p):new ad("item"+c,{detail:s,cancelable:c===fb.DragDropEventType.Init||c===fb.DragDropEventType.Drag},o,p);var d=!1;if(e instanceof EventTarget){let m=u();e.dispatchEvent(m),d=m.defaultPrevented}return e.stage.dispatchEvent(h),d||h.defaultPrevented}return!1}disconnectedCallback(){x(this,gu)?.stop();let e=this._resizer,t=this._container;Yr.isNull(t)||(t.removeEventListener("click",this._clickHandler,!1),t.removeEventListener("mouseup",this._clickHandler,!1),t.removeEventListener("mousedown",this._clickHandler,!1),t.removeEventListener("mousemove",this._moveHandler,!1),t.removeEventListener("mouseout",this._moveHandler,!1)),Yr.isNull(e)||e.removeEventListener("resize",this._resizeHandler,!1),super.disconnectedCallback()}get size(){return x(this,fu)}render(e,t,n=performance.now()){if(Yr.isNull(e))x(this,gu)?.stop(),A(this,gu,kO.Timer.run(i=>this._doRender()));else{let i=this.adapter;Yr.isNull(i)||i.updateItem(this,e)}}_doRender(){if(!this.disabled&&!Yr.isNull(this.adapter)){let e=this.adapter.getScene(this),t=new CustomEvent("prerender",{detail:{scene:e},cancelable:!0});this.dispatchEvent(t),t.defaultPrevented||(this.adapter.render(this),this.dispatchEvent(new CustomEvent("render",{detail:{scene:e}})))}}};fu=new WeakMap,gu=new WeakMap,l([pM(`.${dM}-3d`)],Xr.prototype,"_container",2),l([pM(uu+"-resize")],Xr.prototype,"_resizer",2),l([hu({emit:!1,converter:mu.Boolean})],Xr.prototype,"interactive",2),l([hu({emit:!1,converter:mu.Boolean})],Xr.prototype,"transparent",2),l([hu({emit:!1,converter:mu.String})],Xr.prototype,"background",2),l([hu({emit:!1,converter:mu.Element})],Xr.prototype,"adapter",2),l([hu({emit:!1,converter:mu.Json})],Xr.prototype,"datasource",2),l([hu({emit:!1,converter:mu.Boolean})],Xr.prototype,"orbit",2),Xr=l([CO({tagName:uu+"-"+"3d",shadow:EO.USE_SHADOW_ROOT,template:`<${uu}-resize watch-position="true"></${uu}-resize><div class="${dM}-3d"></div><${uu}-content></${uu}-content>`})],Xr);function bC(a){return!Ds.isNull(a)&&"render"in a&&typeof a.render=="function"}function cf(a){return bC(a?.stage)}function _u(a){return"transformMatrix"in a&&cf(a)}function Pr(a){return"type"in a&&"up"in a&&"lookAt"in a&&cf(a)}function gb(a){return Pr(a)&&"type"in a&&a.type==="perspective"}function vb(a){return Pr(a)&&"type"in a&&a.type==="orthographic"}function Rs(a){return"type"in a&&(a.type==="ambient"||a.type==="omni"||a.type==="direction"||a.type=="spot")&&cf(a)}function Nn(a){return"geometry"in a&&_u(a)}function df(a){return"positions"in a&&Ds.isArray(a.positions)}function xu(a){return("triangleIndices"in a&&Ds.isArray(a.triangleIndices)||"normals"in a&&Ds.isArray(a.normals)||"textureCoordinates"in a&&Ds.isArray(a.textureCoordinates))&&df(a)}function cd(a){return"childRenderables"in a&&Ds.isArray(a.childRenderables)&&_u(a)}function xr(a){let r=[];if(!Ds.isNullOrEmpty(a)){let e=a.triangleIndices;if(e.length%3!==0)throw new RangeError(`Invalid mesh geometry: ${e.length} is not multiple of 3.`);for(let t=2;t<e.length;t+=3){let n=e[t-2],i=e[t-1],s=e[t],o=a.positions[n],c=a.positions[i],d=a.positions[s],p=yC(o,c,d);r.push(p,p,p)}}a.normals=r}function yC(a,r,e){let t=As.LinearAlgebra.Vector3D.subtract(a,r),n=As.LinearAlgebra.Vector3D.subtract(a,e),i=As.LinearAlgebra.Vector3D.cross(t,n);return As.LinearAlgebra.Vector3D.unit(i)}var bu=class extends LO{constructor(r,e,t,n){super(r,e,t),this.#e=n}#e;get point(){return this.#e}},ad=class extends bu{},od=class extends bu{constructor(r,e,t,n){super(r,{detail:e,bubbles:!0,cancelable:!0},t,n)}},Os=(c=>(c.Position="position",c.Transform="transform",c.Geometry="geometry",c.Children="children",c.Material="material",c.Light="light",c.Camera="camera",c.Visibility="visibility",c))(Os||{});function bb(a){return typeof a=="object"&&"time"in a&&typeof a.time=="number"}var Pa={OBJECT_SELECTOR:ld+"-"+"3d"+"-object",LIGHT_SELECTOR:ld+"-"+"3d"+"-light",PERSPECTIVE_CAMERA_SELECTOR:ld+"-"+"3d"+"-perspective-camera",ORTHO_CAMERA_SELECTOR:ld+"-"+"3d"+"-orthographic-camera",LINE_SELECTOR:ld+"-"+"3d"+"-line",MESH_SELECTOR:ld+"-"+"3d"+"-mesh",GROUP_SELECTOR:ld+"-"+"3d"+"-group",DEFAULT_COORDS:{x:0,y:0,z:0}},vu=class vu extends NO.PacemCrossItemsContainerElement{constructor(){super(...arguments);this.position=Pa.DEFAULT_COORDS;this.#e=[]}validate(e){return!1}findContainer(){return this.parent||this.stage}get stage(){return this._scene=this._scene||mM.findAncestorOfType(this,Xr)}get parent(){return this._drawableParent=this._drawableParent||mM.findAncestor(this,e=>e instanceof vu)}disconnectedCallback(){delete this._scene,delete this._drawableParent,super.disconnectedCallback()}propertyChangedCallback(e,t,n,i){switch(super.propertyChangedCallback(e,t,n,i),e){case"hide":this.setAsDirty("visibility");break;case"items":this.setAsDirty("children");break;case"position":this.setAsDirty("position");break}}#e;get flags(){return this.#e}setAsDirty(...e){for(let t of e)this.flags.includes(t)||this.flags.push(t);this.stage?.render(this)}};l([Ae({emit:!1,converter:Ra})],vu.prototype,"position",2),l([Ae({emit:!1,reflectBack:!0,converter:bt.String})],vu.prototype,"tag",2),l([Ae({emit:!1,converter:bt.Boolean})],vu.prototype,"inert",2);var Ls=vu,_r=class extends Ls{propertyChangedCallback(r,e,t,n){switch(super.propertyChangedCallback(r,e,t,n),r){case"transformMatrix":this.setAsDirty("transform");break;case"translateZ":case"translateX":case"translateY":this.offset={x:this.translateX,y:this.translateY,z:this.translateZ};break;case"scaleX":case"scaleY":case"scaleZ":this.scale={x:this.scaleX,y:this.scaleY,z:this.scaleZ};break;case"scale":case"offset":case"rotate":this._computeTransformMatrix();break}}_computeTransformMatrix(){let r=As.LinearAlgebra.Matrix3D,e=As.LinearAlgebra.Vector3D,t=As.LinearAlgebra.Quaternion,n=this.scale??e.from(1,1,1),i=r.scale(r.identity(),n);if(!Ds.isNull(this.rotate)){let o=t.toRotationMatrix(this.rotate);i=r.multiply(i,o)}let s=this.offset??e.from(0,0,0);i=r.translate(i,s),this.transformMatrix=i}};l([Ae({emit:!1,converter:gC})],_r.prototype,"rotate",2),l([Ae({emit:!1,converter:mb})],_r.prototype,"scale",2),l([Ae({emit:!1,converter:mb})],_r.prototype,"offset",2),l([Ae({emit:!1})],_r.prototype,"transformMatrix",2),l([Ae({emit:!1,converter:bt.Number})],_r.prototype,"scaleX",2),l([Ae({emit:!1,converter:bt.Number})],_r.prototype,"scaleY",2),l([Ae({emit:!1,converter:bt.Number})],_r.prototype,"scaleZ",2),l([Ae({emit:!1,converter:bt.Number})],_r.prototype,"translateX",2),l([Ae({emit:!1,converter:bt.Number})],_r.prototype,"translateY",2),l([Ae({emit:!1,converter:bt.Number})],_r.prototype,"translateZ",2);var lf,Ts=class extends _r{constructor(){super(...arguments);$(this,lf,[])}validate(e){return e instanceof Ls}get childRenderables(){return x(this,lf)}propertyChangedCallback(e,t,n,i){switch(super.propertyChangedCallback(e,t,n,i),e){case"items":case"datasource":A(this,lf,n||[]),this.setAsDirty("children");break}}};lf=new WeakMap,l([Ae({emit:!1})],Ts.prototype,"datasource",2),Ts=l([yu({tagName:Pa.GROUP_SELECTOR})],Ts);var zi=class extends _r{propertyChangedCallback(r,e,t,n){switch(super.propertyChangedCallback(r,e,t,n),r){case"geometry":this.setAsDirty("geometry");break;case"material":case"backMaterial":this.setAsDirty("material");break}}};l([Ae({emit:!1,converter:bt.Json})],zi.prototype,"geometry",2),l([Ae({emit:!1,converter:bt.Json})],zi.prototype,"material",2),l([Ae({emit:!1,converter:bt.Json})],zi.prototype,"backMaterial",2),zi=l([yu({tagName:Pa.MESH_SELECTOR})],zi);var Gi=class extends _r{propertyChangedCallback(r,e,t,n){super.propertyChangedCallback(r,e,t,n),(r==="content"||r==="type")&&this.setAsDirty("geometry","material")}};l([Ae({emit:!1})],Gi.prototype,"content",2),l([Ae({emit:!1,converter:bt.String})],Gi.prototype,"type",2),Gi=l([yu({tagName:Pa.OBJECT_SELECTOR})],Gi);var Ln=class extends Ls{constructor(){super(...arguments);this.intensity=.85;this.target=Pa.DEFAULT_COORDS;this.color="#fff";this.type="omni"}propertyChangedCallback(e,t,n,i){switch(super.propertyChangedCallback(e,t,n,i),e){case"type":case"color":case"intensity":case"target":this.setAsDirty("light");break}}};l([Ae({emit:!1,converter:bt.Number})],Ln.prototype,"intensity",2),l([Ae({emit:!1,converter:Ra})],Ln.prototype,"target",2),l([Ae({emit:!1,converter:bt.String})],Ln.prototype,"color",2),l([Ae({emit:!1,converter:bt.String})],Ln.prototype,"type",2),Ln=l([yu({tagName:Pa.LIGHT_SELECTOR})],Ln);var ai=class extends Ls{constructor(){super(...arguments);this.near=.1;this.far=1e3;this.up=As.LinearAlgebra.Vector3D.j();this.lookAt=Pa.DEFAULT_COORDS}#e;_resetBoundingSphere(){let e=this.#e,t=this.position,n=this.lookAt,i=Ds.isNullOrEmpty(t)||Ds.isNullOrEmpty(n)?0:As.LinearAlgebra.Vector3D.mag(As.LinearAlgebra.Vector3D.subtract(t,n)),s=this.#e={center:n,radius:i};this.dispatchEvent(new SO({currentValue:s,propertyName:"boundingSphere",oldValue:e}))}get boundingSphere(){return this.#e}propertyChangedCallback(e,t,n,i){switch(super.propertyChangedCallback(e,t,n,i),e){case"lookAt":case"position":this._resetBoundingSphere();case"near":case"far":case"up":this.setAsDirty("camera");break}}};l([Ae({emit:!1,converter:bt.Number})],ai.prototype,"near",2),l([Ae({emit:!1,converter:bt.Number})],ai.prototype,"far",2),l([Ae({emit:!1,converter:Ra})],ai.prototype,"up",2),l([Ae({emit:!1,converter:Ra})],ai.prototype,"lookAt",2);var Ns=class extends ai{constructor(){super(...arguments);this.fov=45;this.aspect=1}get type(){return"perspective"}get aspectRatio(){return this.aspect}propertyChangedCallback(e,t,n,i){switch(super.propertyChangedCallback(e,t,n,i),e){case"fov":case"aspect":this.setAsDirty("camera");break}}};l([Ae({emit:!1,converter:bt.Number})],Ns.prototype,"fov",2),l([Ae({emit:!1,converter:bt.Number})],Ns.prototype,"aspect",2),Ns=l([yu({tagName:Pa.PERSPECTIVE_CAMERA_SELECTOR})],Ns);var si=class extends ai{constructor(){super(...arguments);this.top=1;this.left=-1;this.bottom=-1;this.right=1}get type(){return"orthographic"}propertyChangedCallback(e,t,n,i){switch(super.propertyChangedCallback(e,t,n,i),e){case"top":case"left":case"bottom":case"right":this.setAsDirty("camera");break}}};l([Ae({emit:!1,converter:bt.Number})],si.prototype,"top",2),l([Ae({emit:!1,converter:bt.Number})],si.prototype,"left",2),l([Ae({emit:!1,converter:bt.Number})],si.prototype,"bottom",2),l([Ae({emit:!1,converter:bt.Number})],si.prototype,"right",2),si=l([yu({tagName:Pa.ORTHO_CAMERA_SELECTOR})],si);var yl=class extends MO{};import{Utils as fM}from"@pacem/pacem-core";import{Utils as TO}from"@pacem/pacem-core";function dd(a){return(r,e,t)=>{let n=`_${e}_${TO.uniqueCode()}_backingField`;function i(){return this[n]}function s(o){if(o!==this[n]){let c=this[n];this[n]=o,a.call(this,e,c,o)}}Object.defineProperty(r,e,{get:function(){return i.call(this)},set:function(o){s.call(this,o)},enumerable:!0,configurable:!1})}}var pd=class{constructor(r=[]){this.positions=r}static barycenter(r){var e={x:0,y:0,z:0};if(!fM.isNullOrEmpty(r)){for(var t=r.length,n=0;n<r.length;n++){var i=r[n];e.x+=i.x,e.y+=i.y,e.z+=i.z}var s=1*t;e.x/=s,e.y/=s,e.z/=s}return e}static boundingBox(r){let e={minX:1/0,minY:1/0,minZ:1/0,maxX:-1/0,maxY:-1/0,maxZ:-1/0};if(!fM.isNullOrEmpty(r))for(var t=0;t<r.length;t++){var n=r[t];e.minX=Math.min(e.minX,n.x),e.minY=Math.min(e.minY,n.y),e.minZ=Math.min(e.minZ,n.z),e.maxX=Math.max(e.maxX,n.x),e.maxY=Math.max(e.maxY,n.y),e.maxZ=Math.max(e.maxZ,n.z)}return e}setAsDirty(){Cu.call(this)}};function Cu(){let a=this;a.flags=["geometry"]}var _l=class extends pd{};l([dd(Cu)],_l.prototype,"positions",2);var je=class extends pd{#e;#t;#r;get barycenter(){return this.#r??=pd.barycenter(this.positions)}set barycenter(r){this.#r=r}get boundingBox(){return this.#e??=pd.boundingBox(this.positions)}set boundingBox(r){this.#e=r}get boundingSphere(){return this.#t}set boundingSphere(r){this.#t=r}constructor(r,e,t=[],n=[]){super(r),this.triangleIndices=e,this.textureCoordinates=t,this.normals=n}};l([dd(Cu)],je.prototype,"positions",2),l([dd(Cu)],je.prototype,"triangleIndices",2),l([dd(Cu)],je.prototype,"textureCoordinates",2),l([dd(Cu)],je.prototype,"normals",2);import{PacemEventTarget as AO,Utils as pf,Watch as Eu,PropertyConverters as uf,PCSS as DO}from"@pacem/pacem-core";import{Imaging as RO}from"@pacem/pacem-foundation";var Fi=(s=>(s.Basic="basic",s.Lambert="lambert",s.Phong="phong",s.Standard="standard",s.Line="line",s.Custom="custom",s))(Fi||{});function oi(a){return"shader"in a}function yb(a){return oi(a)&&a.shader==="basic"}function xl(a){return oi(a)&&a.shader==="line"}function _b(a){return oi(a)&&a.shader==="lambert"}function xb(a){return oi(a)&&a.shader==="phong"}function Cb(a){return oi(a)&&a.shader==="standard"}function gM(a){return oi(a)&&a.shader==="custom"}var Ot=class extends AO{constructor(r){super(),this.#e=r}#e;get shader(){return this.#e}async _loadMap(r,e=this.material?.texture){if(pf.isNull(e)||e.close(),pf.isNullOrEmpty(r))return null;let t=await RO.loadImage(r);return pf.isNull(t)?null:await createImageBitmap(t)}propertyChangedCallback(r,e,t,n){if(super.propertyChangedCallback(r,e,t,n),!n)switch(r){case"map":case"opacity":case"wireframe":case"color":case"hide":this.updateMaterial();break}}viewActivatedCallback(){super.viewActivatedCallback(),this.updateMaterial()}updateMaterial(){this.createMaterial().then(r=>{this.material=pf.extend(r,{flags:["material"]})})}async createMaterial(){return{opacity:this.opacity??1,wireframe:this.wireframe??!1,color:this.color||pf.Css.getVariableValue(`--${DO}-color-primary`),visible:!(this.hide??!1),map:this.map,texture:await this._loadMap(this.map),shader:this.shader,flags:[]}}};l([Eu()],Ot.prototype,"material",2),l([Eu({emit:!1,converter:uf.Number})],Ot.prototype,"opacity",2),l([Eu({emit:!1,converter:uf.Boolean})],Ot.prototype,"wireframe",2),l([Eu({emit:!1,converter:uf.String})],Ot.prototype,"color",2),l([Eu({emit:!1,converter:uf.Boolean})],Ot.prototype,"hide",2),l([Eu({emit:!1,converter:uf.String})],Ot.prototype,"map",2);import{Transformer as OO}from"@pacem/pacem-core";import{Point as PO}from"@pacem/pacem-foundation";var xC=class{static parse(r){let e=[],t=/^v((\s+-?[\d\.]+){3})/gm,n=t.exec(r);for(;n&&n.length;)e.push(Ra.convert(n[1])),n=t.exec(r);let i=[],s=/^vt((\s+-?[\d\.]+){2})/gm;for(n=s.exec(r);n&&n.length;)i.push(PO.parse(n[1])),n=s.exec(r);let o=[],c=/^vn((\s+-?[\d\.]+){3})/gm;for(n=c.exec(r);n&&n.length;)o.push(Ra.convert(n[1])),n=c.exec(r);let d=[],p=[],u=[],h=/^f((\s+([\d]+\/[\d]+\/[\d]+)){3,})/gm;for(n=h.exec(r);n&&n.length;){let E=/([\d]+)\/([\d]+)\/([\d]+)/g,C=n[1],k=E.exec(C),w=0;for(var m,f,g,v,b,_;k&&k.length;)w>2&&(u.push(m),p.push(i[f]),d.push(o[g]),u.push(v),p.push(i[b]),d.push(o[_])),v=parseInt(k[1])-1,b=parseInt(k[2])-1,_=parseInt(k[3])-1,u.push(v),p.push(i[b]),d.push(o[_]),w===0&&(m=v,f=b,g=_),w++,k=E.exec(C);n=h.exec(r)}return new je(e,u,p,d)}},_C=class{static parseGeometry(r,e){if(e.toLowerCase()==="obj")return xC.parse(r);throw new Error(`Type '${e}' is not supported.`)}};l([OO("parse3D")],_C,"parseGeometry",1);var _M={};tt(_M,{LatLng:()=>yt,LatLngBounds:()=>Et,MapProjection:()=>CC});import{Transformer as Eb}from"@pacem/pacem-core";var bM={lat:Number.NaN,lng:Number.NaN},yt=class{static get Empty(){return bM}static isEmpty(r){return r===bM||isNaN(r.lat)&&isNaN(r.lng)}static isLatLng(r){return"lat"in r&&typeof r.lat=="number"&&"lng"in r&&typeof r.lng=="number"}static translate(r,e){return{lat:r.lat+e.lat,lng:r.lng+e.lng}}static equals(r,e){return r===e||r.lat===e.lat&&r.lng===e.lng}},yM={ne:yt.Empty,sw:yt.Empty},Et=class a{static get Empty(){return yM}static isEmpty(r){return r===yM||yt.isEmpty(r.ne)&&yt.isEmpty(r.sw)}static isPoint(r){return!this.isEmpty(r)&&(r.ne===r.sw||r.ne.lat===r.sw.lat&&r.ne.lng===r.sw.lng)}static isLatLngBounds(r){return typeof r=="object"&&"ne"in r&&yt.isLatLng(r.ne)&&"sw"in r&&yt.isLatLng(r.sw)}static union(r,e){if(a.isEmpty(r))return a.isLatLngBounds(e)?e:{ne:e,sw:e};if(a.isLatLngBounds(e)){if(a.isEmpty(e))return r;let t=Math.max(r.ne.lat,e.ne.lat),n=Math.max(r.ne.lng,e.ne.lng),i=Math.min(r.sw.lat,e.sw.lat),s=Math.min(r.sw.lng,e.sw.lng);return{ne:{lat:t,lng:n},sw:{lat:i,lng:s}}}if(yt.isLatLng(e)){if(yt.isEmpty(e))return r;let t=Math.max(r.ne.lat,e.lat),n=Math.max(r.ne.lng,e.lng),i=Math.min(r.sw.lat,e.lat),s=Math.min(r.sw.lng,e.lng);return{ne:{lat:t,lng:n},sw:{lat:i,lng:s}}}return r}static equals(r,e){return r===e||yt.equals(r.ne,e.ne)&&yt.equals(r.sw,e.sw)}},Cl={SIZE:256,RAD:Math.PI/180,DEG:180/Math.PI,EPSILON:1e-15,SIN_LIMIT:1-1e-15,EARTH_RADIUS:6378137},wb={TRANSFORMERS_NS:"maps"},Ps=class Ps{constructor(r,e,t=Cl.SIZE){this._pixelSize=r;this._bounds=e;this._normalizedSize=t;let n=t/2;this.#e={x:n,y:n},this.#n=t/360,this.#i=n/Math.PI,this.#t=this._latLngToWorldNormalizedPoint(e.sw),this.#r=this._latLngToWorldNormalizedPoint(e.ne)}#e;#t;#r;#n;#i;_latLngToWorldNormalizedPoint(r){let e=this.#e.x+r.lng*this.#i,t=r.lat*Cl.RAD,n=Cl.SIN_LIMIT,i=Math.sin(t).clamp(-n,n),s=this.#e.y+.5*Math.log((1+i)/(1-i))*-this.#n;return{x:e,y:s}}_worldNormalizedPointToLatLng(r){let e=Cl.DEG*(2*Math.atan(Math.exp((r.y-this.#e.y)/-this.#n))-Math.PI/2),t=(r.x-this.#e.x)/this.#i;return{lat:e,lng:t}}_latLngToPoint(r){let e=this.#r,t=this.#t,n=-e.y+t.y,i=e.x-t.x,s=this._latLngToWorldNormalizedPoint(r),{width:o,height:c}=this._pixelSize,d=(s.x-t.x)*(o/i),p=(s.y-e.y)*(c/n);return{x:d,y:p}}_pointToLatLng(r){let e=this.#r,t=this.#t,n=-e.y+t.y,i=e.x-t.x,{width:s,height:o}=this._pixelSize,c=r.x/(s/i)+this.#t.x,d=r.y/(o/n)+this.#r.y;return this._worldNormalizedPointToLatLng({x:c,y:d})}static _haversine(r,e){let t=Cl.RAD,n=r.lng*t,i=e.lng*t,s=r.lat*t,o=e.lat*t;return 2*Math.asin(Math.sqrt(Math.pow(Math.sin((s-o)/2),2)+Math.cos(s)*Math.cos(o)*Math.pow(Math.sin((n-i)/2),2)))}static _offsetByMeters(r,e,t,n){let{RAD:i,DEG:s}=Cl,o=r.lat*i,c=r.lng*i,d=e/n,p=t/(n*Math.cos(o)),u=o+d,h=c+p;return{lat:u*s,lng:h*s}}static offsetBy(r,e,t,n=Cl.EARTH_RADIUS){return Ps._offsetByMeters(r,e,t,n)}static distanceBetween(r,e,t=Cl.EARTH_RADIUS){return Ps._haversine(r,e)*t}static latLngToPoint(r,e,t){return new Ps(t,e)._latLngToPoint(r)}static pointToLatLng(r,e,t){return new Ps(e,t)._pointToLatLng(r)}};l([Eb(wb.TRANSFORMERS_NS+".")],Ps,"offsetBy",1),l([Eb(wb.TRANSFORMERS_NS+".")],Ps,"distanceBetween",1),l([Eb(wb.TRANSFORMERS_NS+".")],Ps,"latLngToPoint",1),l([Eb(wb.TRANSFORMERS_NS+".")],Ps,"pointToLatLng",1);var CC=Ps;var xM={};tt(xM,{L10n:()=>kC,PacemBaseCellElement:()=>Wi});import{Watch as EC,PropertyConverters as wC,Components as IO}from"@pacem/pacem-core";var Wi=class extends IO.PacemSafeContentElement{viewActivatedCallback(){super.viewActivatedCallback(),this.updateColumnPosition(),this.updateLayout(this.metadata)}updateColumnPosition(r=this.metadata,e=this.gridState){this.style.gridColumn=(e.orderedColumns.indexOf(r.prop)+1).toString()}updateVisibility(r=this.state){this.hide=!!r.hidden}propertyChangedCallback(r,e,t,n){if(super.propertyChangedCallback(r,e,t,n),!n)switch(r){case"metadata":this.updateLayout(t);break;case"gridState":this.updateColumnPosition();break;case"state":this.updateVisibility();break}}};l([EC({converter:wC.Json})],Wi.prototype,"metadata",2),l([EC({converter:wC.Json})],Wi.prototype,"state",2),l([EC({converter:wC.Json})],Wi.prototype,"gridState",2);var kC={};tt(kC,{DataGrids:()=>kb});import{Utils as $O,Transformer as HO}from"@pacem/pacem-core";var BO={headCell:(a,r,e)=>{switch(a){case"name":return e["column_name_"+r]??e["name_"+r];case"description":return e["column_description_"+r]??e["description_"+r]}return null}},kb=class{static localizeMetadata(r,e,t){t=$O.extend({},BO,t??{});for(let n of r){let i=n.headCell=n.headCell??{};i.name=t.headCell("name",n.prop,e)??i.name,i.description=t.headCell("description",n.prop,e)??i.description}return r}};l([HO("datagrids.localizeMetadata")],kb,"localizeMetadata",1);var eR={};tt(eR,{AnimationElement:()=>Dn,Charts:()=>Uw,CustomItemCommandEvent:()=>jb,DataCellUIEvent:()=>Yv,DataColumnRescaleEvent:()=>Wm,DataColumnRescaleEventName:()=>Ax,DataColumnSortEvent:()=>Fm,DataColumnSortEventName:()=>Tx,DataGridBindEvent:()=>Dx,DataRowSelectChangeEvent:()=>Gv,DataRowSelectChangeEventName:()=>qD,DockMode:()=>zM,Drawing:()=>E0,Drawing3D:()=>dk,EditMode:()=>zD,Fx:()=>l0,ItemCommandEvent:()=>Wb,ItemRegisterEvent:()=>Vb,ItemRegisterEventName:()=>FM,ItemUnregisterEvent:()=>Ub,ItemUnregisterEventName:()=>WM,KeyboardShortcutExecuteEventName:()=>eS,Logging:()=>eE,Maps:()=>i0,Media:()=>m0,Networking:()=>p0,PacemAdapter:()=>PC,PacemAnnihilatorElement:()=>yf,PacemBaseCellElement:()=>Wi,PacemBeforeunloadElement:()=>gd,PacemBodyProxyElement:()=>Cf,PacemBroadcastChannelProxyElement:()=>Ha,PacemBrowserDetectElement:()=>Du,PacemCarouselElement:()=>ll,PacemColorAnimationElement:()=>Md,PacemContentElement:()=>Tu,PacemContextMenuElement:()=>Ma,PacemContextMenuItemCommandElement:()=>ti,PacemContextMenuItemElement:()=>Vm,PacemContextMenuItemSeparatorElement:()=>$v,PacemCrossItemsContainerElement:()=>kf,PacemDataCellElement:()=>ml,PacemDataColumnElement:()=>Rr,PacemDataElement:()=>Ba,PacemDataGridElement:()=>kn,PacemDockElement:()=>$s,PacemDragDropElement:()=>pi,PacemEditElement:()=>ri,PacemElement:()=>Xt,PacemElementProxyElement:()=>Ru,PacemEventProxyElement:()=>Ll,PacemFetchElement:()=>Pt,PacemGalleryElement:()=>cn,PacemHeadCellElement:()=>Wv,PacemHistoryElement:()=>Va,PacemHtmlProxyElement:()=>yd,PacemIfElement:()=>Pu,PacemItemElement:()=>Tl,PacemItemsContainerElement:()=>Bs,PacemIterableElement:()=>HC,PacemIterativeElement:()=>$u,PacemLayoutProxyElement:()=>_d,PacemMetaProxyElement:()=>Ua,PacemModalFormElement:()=>Dt,PacemNumberAnimationElement:()=>Sd,PacemOnlineStatusElement:()=>Hu,PacemPanelElement:()=>Sf,PacemPointAnimationElement:()=>Ld,PacemRepeaterElement:()=>Xi,PacemRescaleElement:()=>qi,PacemResizeElement:()=>xd,PacemRotateElement:()=>Wa,PacemRouterElement:()=>Al,PacemRouterHashStateElement:()=>ul,PacemSafeContentElement:()=>fd,PacemScrollAwareElement:()=>wd,PacemSearchElement:()=>_s,PacemServiceWorkerProxyElement:()=>za,PacemShellProxyElement:()=>Ef,PacemShortcutElement:()=>kd,PacemSpanElement:()=>Vu,PacemStoryboardElement:()=>Xa,PacemStyleProxyElement:()=>Dl,PacemSwipeElement:()=>ja,PacemTemplateProxyElement:()=>Vs,PacemTextElement:()=>Uu,PacemTimerElement:()=>zu,PacemTitleProxyElement:()=>Gu,PacemTransferProxyElement:()=>Ou,PacemTweenElement:()=>di,PacemUnsafeContentElement:()=>OC,PacemViewportAwareElement:()=>Rl,PacemWebWorkerProxyElement:()=>Ga,RepeaterItem:()=>Bu,RepeaterItemCreateEvent:()=>vf,RepeaterItemCreateEventName:()=>VM,RepeaterItemEvent:()=>gf,RepeaterItemRemoveEvent:()=>bf,RepeaterItemRemoveEventName:()=>UM,ResizeEvent:()=>Yb,ResizeEventName:()=>XM,RouterNavigateEvent:()=>Xb,RouterNavigateEventName:()=>KM,RouterNavigatingEvent:()=>qb,RouterNavigatingEventName:()=>qM,Scaffolding:()=>Iw,ScrollEvent:()=>Kb,ScrollEventName:()=>ZM,StateEvent:()=>Bb,TweenAnimationElement:()=>Ya,UI:()=>$E,isItemsContainer:()=>wP});import{Keys as MC,Dates as El,Colors as CM,Strings as ku,Blobs as Sb,Imaging as EM,NullChecker as wM,detect as zO}from"@pacem/pacem-foundation";var wu=class a{constructor(){}static clone(r){return new a()._clone(r)}_clone(r){let e=new WeakMap;function t(n){if(typeof n=="object"&&n!==null&&!(n instanceof Element)&&!(n instanceof FileSystemHandle)&&!(n instanceof File)){if(Array.isArray(n))return n.map(t);if(n instanceof Date)return new Date(n.valueOf());if(n instanceof RegExp)return new RegExp(n);if(e.has(n))return e.get(n);{let i=Object.assign({},n);return e.set(n,i),Object.keys(i).forEach(s=>{i[s]=t(n[s])}),i}}return n}return t(r)}};import{Keys as VO}from"@pacem/pacem-foundation";var ud="$refId",UO=(t=>(t[t.Ignore=0]="Ignore",t.Reference="reference",t.Plain="plain",t))(UO||{}),Mb=class{static{this._jsonFnWeakMap=new WeakMap}static{this._jsonFnMap=new Map}static store(r){let e=this._jsonFnWeakMap;if(!e.has(r)){let t=VO.uniqueCode();e.set(r,t),this._jsonFnMap.set(t,r)}return e.get(r)}static retrieve(r){return this._jsonFnMap.get(r)}static remove(r){let e=this.retrieve(r);this._jsonFnMap.delete(r),this._jsonFnWeakMap.delete(e)}},hf=class _Json{constructor(a){this._options=a}static serialize(a,r){return new _Json(r)._serialize(a)}static deserialize(a){return new _Json()._deserialize(a)}_serialize(a){let r=wu.clone(a),e=[ud],t=this._flatten(r,0,null,e);return JSON.stringify(t,e.sort())}_deserialize(json){let hasRefs=!1,obj=JSON.parse(json,(key,value)=>{let elPattern=/^\$<#(.+)>$/,fnPattern=/^\$<fn:([^\x05]+)>$/,regexPattern=/^\$<regex:(.+)>$/,fnRefPattern=/^\$<fn#(.+)>$/,arr;if(key===ud)hasRefs=!0;else if(typeof value=="string")if((arr=regexPattern.exec(value))&&arr.length>1){let a=arr[1],r=a.lastIndexOf("|");return new RegExp(a.substr(0,r),a.substr(r+1))}else{if((arr=elPattern.exec(value))&&arr.length>1)return document.getElementById(arr[1]);if((arr=fnPattern.exec(value))&&arr.length>1)return eval(arr[1]);if((arr=fnRefPattern.exec(value))&&arr.length>1)return Mb.retrieve(arr[1])}return value});return hasRefs?this._revive(obj):obj}_flatten(a,r=0,e,t){if(e=e||new WeakSet,t=t||[],a instanceof Element)return a.id?`$<#${a.id}>`:void 0;if(a instanceof RegExp)return`$<regex:${a.source}|${a.flags}>`;if(typeof a=="object"&&a!=null&&!(a instanceof Date))return Array.isArray(a)?a.map(n=>this._flatten(n,r,e,t)):e.has(a)?a[ud]=a[ud]||"$#ref_"+r++:(e.add(a),Object.keys(a).forEach(n=>{t.indexOf(n)===-1&&t.push(n),a[n]=this._flatten(a[n],r,e,t)}),a);if(typeof a=="function")switch(this._options?.functions){case"reference":return"$<fn#"+Mb.store(a)+">";case"plain":return"$<fn:"+a+">";default:return}return a}_revive(a){let r={},e=/^\$#ref_(.+)$/;function t(n){if(typeof n=="object"&&n!==null){if(Array.isArray(n))return n.map(t);ud in n&&(r[n[ud]]=n,delete n[ud]),Object.keys(n).forEach(i=>{n[i]=t(n[i])})}else if(typeof n=="string"&&e.test(n)){let i=e.exec(n);return r[i[0]]}return n}return t(a)}};var li=class a{constructor(){this.deferred=null;var r=this;r.promise=new Promise(function(e,t){r.deferred={resolve:e,reject:t,promise:r}})}then(r,e){return this.promise.then(r,e)}finally(r){return this.promise.then(r,r),this}success(r){return this.promise.then(r,null),this}error(r){return this.promise.then(null,r),this}static defer(){var r=new a;return r.deferred}};var GO="pacem",kM="download";var Is=a=>{a.preventDefault(),a.stopPropagation()},MM=/^\/[^\/]+/,FO=/\/\{([a-z\$_][\w]*)\??\}/,y=class a{static get core(){let r=window.Pacem;var e=r&&r.Configuration&&r.Configuration.core||GO;return window[e]=window[e]||{}}static get customElements(){return window.customElements}static uniqueId(){return MC.uniqueId()}static uniqueCode(){return MC.uniqueCode()}static randomString(r){return MC.randomString(r)}static parseDate(r){return El.parse(r)}static copyToClipboard(r){return navigator.clipboard?navigator.clipboard.writeText(r):new Promise((e,t)=>{let n=document.createElement("textarea");n.value=r,n.style.opacity="0",document.body.appendChild(n);try{n.select(),document.execCommand("copy"),n.remove(),e()}catch(i){t(i)}})}static{this.Json={stringify:hf.serialize,parse:hf.deserialize}}static{this.Dates={now:()=>a.parseDate(Date.now()),parse:a.parseDate,isLeapYear:El.isLeapYear,daysInMonth:El.daysInMonth,isDate:El.isDate,dateOnly:El.dateOnly,addMonths:El.addMonths,addDays:El.addDays,daysBetween:El.daysBetween}}static colorize(r,e){let t={h:38,s:.245,l:.6};var n,i,s,o;r instanceof HTMLElement?n=e:n=r,typeof n=="string"?i=CM.parse(n):i={r:n[0],g:n[1],b:n[2]};let c=CM.hsl(i);if(s=`brightness(50%) sepia(1) hue-rotate(${c.h-t.h}deg) saturate(${1+(c.s-t.s)}) brightness(${1+(c.l-t.l)})`,n===e)o.style.filter=s;else return s}static cssEscape(r){return escape(r).replace("%","\\")}static{this.Css={colorize:a.colorize,escape:a.cssEscape,getVariableValue(r){return getComputedStyle(document.documentElement).getPropertyValue(r)},setVariable(r,e){getComputedStyle(document.documentElement).setProperty(r,e)},isClassDefined(r){let e=new RegExp("."+r+"($|[s.,])");for(let t=0;t<document.styleSheets.length;t++){let n=document.styleSheets.item(t);try{let i=n.cssRules;for(let s=0;s<i.length;s++){let o=n.cssRules.item(s);if(e.test(o.selectorText))return!0}}catch(i){i instanceof DOMException&&console.warn(`Couldn't access cssRules of stylesheet "`+n.href+'".')}}return!1},deserializeTransform(r){let e=r instanceof Element?getComputedStyle(r):r,t=1,n=0,i=0,s=1,o=0,c=0,d=/^matrix\((.*)\)$/.exec(e.transform),p;return d&&d.length>1&&(p=d[1].split(",")).length==6&&(t=parseFloat(p[0]),n=parseFloat(p[1]),i=parseFloat(p[2]),s=parseFloat(p[3]),o+=parseFloat(p[4]),c+=parseFloat(p[5])),{a:t,b:n,c:i,d:s,e:o,f:c}}}}static{this.leftPad=ku.leftPad}static{this.formatString=ku.format}static{this.diff=ku.diff}static{this.Strings={leftPad:ku.leftPad,format:ku.format,diff:ku.diff,stripHTML:r=>new DOMParser().parseFromString(r,"text/html").body.textContent||""}}static{this.Blobs={toDataURL:Sb.blobToDataURL,fromDataURL:Sb.dataURLToBlob,toText:Sb.blobToText,fromText:Sb.textToBlob}}static{this.Images={load:EM.loadImage,resize:EM.resizeImage}}static loadImage(r){return new Promise((e,t)=>{let n=new Image;n.src=r,n.complete?e(n):(n.onload=i=>{e(n)},n.onerror=i=>{t()})})}static blobToDataURL(r){return a.Blobs.toDataURL(r)}static dataURLToBlob(r){return a.Blobs.fromDataURL(r)}static blobToText(r,e){return a.Blobs.toText(r,e)}static textToBlob(r,e="text/plain"){return a.Blobs.fromText(r,e)}static resizeImage(r,e,t,n){var i=li.defer();return a.blobToDataURL(r).then(a.loadImage).then(s=>{let o=s.width,c=s.height,d=document.createElement("canvas");d.width=o,d.height=c;let p=d.getContext("2d");if(o>e||c>t){let u=o/c,h=e/t,m,f;h<u?(f=e,m=e/u):(m=t,f=t*u),d.width=f,d.height=m;let g=n>0&&n<=1;g&&(p.fillStyle="#000",p.fillRect(0,0,d.width,d.height)),a.cropImageOntoCanvas(s,p);let v;g?v=p.canvas.toDataURL("image/jpeg",n):v=p.canvas.toDataURL(),i.resolve(a.dataURLToBlob(v))}else i.resolve(r)},s=>{}),i.promise}static cropImage(r,e,t,n){var i=li.defer();let s=new Image;return s.crossOrigin="anonymous",s.onload=function(o){let c=document.createElement("canvas"),d=c.getContext("2d");e&&(c.width=e),t&&(c.height=t);let p=n>0&&n<=1;p&&(d.fillStyle="#000",d.fillRect(0,0,c.width,c.height)),a.cropImageOntoCanvas(s,d),i.resolve(p?c.toDataURL("image/jpeg",n):c.toDataURL())},s.src=r,i.promise}static getUserMediaFunctions(){var r=[];let t=[navigator.getUserMedia,navigator.webkitGetUserMedia,navigator.msGetUserMedia,navigator.mozGetUserMedia].filter(function(n,i){return typeof n=="function"});return t.length&&(r=t),r}static cropImageOntoCanvas(r,e,t,n){e.imageSmoothingEnabled=e.mozImageSmoothingEnabled=e.oImageSmoothingEnabled=e.webkitImageSmoothingEnabled=!0;let i=e.canvas.width,s=e.canvas.height,o=i,c=s,d=t||1*r.width,p=n||1*r.height;var u=d/p,h=i/s;if(h>u){var m=i/d;s=m*p,e.drawImage(r,0,.5*(-s+c),o,s)}else{var m=s/p;i=m*d,e.drawImage(r,-Math.abs(.5*(-i+o)),0,i,c)}}static get _domURL(){return window.URL||window.webkitURL||window}static snapshotElement(r,e,t="image/png",n){function i(s){return new Promise((o,c)=>{let d=document.createElement("canvas"),p=s.width,u=s.height;if(!(p>0))c("Image has width zero.");else if(!(u>0))c("Image has height zero.");else{d.width=p,d.height=u;let h=d.getContext("2d");a.isNullOrEmpty(e)||(h.fillStyle=e,h.fillRect(0,0,p,u)),h.drawImage(s,0,0),d.toBlob(m=>{o(m)},t,n)}})}return r instanceof HTMLCanvasElement?i(r):new Promise((s,o)=>{let c=[];function d(v){let b=new Promise((_,E)=>{let C=()=>v instanceof HTMLImageElement?v.src:v.href.baseVal,k=w=>{v instanceof HTMLImageElement?v.src=w:v.setAttribute("href",w)};fetch(C()).then(w=>w.blob()).then(w=>a.blobToDataURL(w)).then(w=>{k(w),_()})});c.push(b)}function p(v,b){let _=new Promise((E,C)=>{let k=new Image;k.crossOrigin="anonymous",k.width=b.width,k.height=b.height,k.style.cssText=v.style.cssText,k.onload=()=>{v.replaceWith(k),E()},k.src=b.toDataURL()});c.push(_)}function u(v,b){let _=getComputedStyle(b);for(let E=0;E<_.length;E++){let C=_.item(E);v.style[C]=_[C]}}function h(v,b){u(v,b),v instanceof HTMLImageElement||v instanceof SVGImageElement?d(v):v instanceof HTMLCanvasElement&&p(v,b);let _=v.children.length;for(let E=0;E<_;E++){let C=v.children.item(E),k=b.children.item(E);C.tagName===k.tagName&&h(C,k)}}if(r instanceof SVGElement){let v=r.cloneNode(!0);h(v,r),Promise.all(c).then(b=>{r=v,g()})}else{var f=document.implementation.createHTMLDocument("");f.write(r.outerHTML),f.documentElement.setAttribute("xmlns",f.documentElement.namespaceURI);let b=document.evaluate(".//"+r.localName,f.body,null,XPathResult.FIRST_ORDERED_NODE_TYPE,null).singleNodeValue;b.setAttribute("xmlns",f.documentElement.namespaceURI),h(b,r),Promise.all(c).then(_=>{let E=document.createElementNS("http://www.w3.org/2000/svg","svg"),C=a.offset(r);E.setAttribute("viewBox",`0 0 ${C.width} ${C.height}`),E.setAttribute("width",C.width.toString()),E.setAttribute("height",C.height.toString()),E.innerHTML=`<foreignObject width="${C.width}" height="${C.height}">${b.outerHTML}</foreignObject>`,r=E,g()})}function g(){let v=new XMLSerializer().serializeToString(r),b=new Image;b.crossOrigin="anonymous";let _="data:image/svg+xml;charset=utf8,"+encodeURIComponent(v);b.onload=()=>{i(b).then(s)},b.src=_}})}static async download(r,e,t="application/download"){if(typeof r=="string"){let o=r,c={},d;a.isNullOrEmpty(e)||(typeof e=="object"?(c={credentials:e.credentials,headers:e.headers},d=e.filename||d,t=e.mime||t):d=e);var n=await fetch(o,c);if(n.ok){if(a.isNullOrEmpty(d)){let u="Content-Disposition";if(n.headers.has(u)){let h=n.headers.get(u),m=/^attachment; filename=\"?([^;\"]+)\"?(;|$)/.exec(h);m.length>1&&(d=m[1])}else d=kM}var i=await n.blob();let p=d.split(/[\\\/]/g).join("_");return a.download(i,p)}{let p=await n.text();throw new Error(p)}}else{let o=r,c=typeof e=="string"&&e||kM,d=document.createElement("a");if(d.setAttribute("href",a._domURL.createObjectURL(o)),d.setAttribute("download",c),document.createEvent){var s=document.createEvent("MouseEvents");s.initEvent("click",!0,!0),d.dispatchEvent(s)}else d.click()}}static isDOMReady(){return document.readyState==="complete"}static onDOMReady(r){window.addEventListener("load",r,!1)}static moveChildren(r,e){return a.moveItems(r.childNodes,e)}static moveItems(r,e){let t=[],n;for(let i=r.length-1;i>=0;i--){let s=r instanceof NodeList?r.item(i):r[i];e.insertBefore(s,n),t.unshift(s),n=s}return t}static is(r,e){return(r.matches||r.matchesSelector||r.msMatchesSelector||r.mozMatchesSelector||r.webkitMatchesSelector||r.oMatchesSelector).call(r,e)}static lang(r){return r.lang||document.documentElement.lang||navigator.language}static jsonSortStringify(r){return a.isNull(r)?r:a.Json.stringify(r)}static{this.Browsers={detect:zO}}static cookies(r){let e=(r??document.cookie).split(";"),t={};for(var n of e){let i=n.split("=");if(i.length<2)continue;let s=(i[0]||"").trim(),o=(i[1]||"").trim();Object.defineProperty(t,s,{configurable:!1,enumerable:!0,writable:!1,value:decodeURIComponent(o.split("+").join(" "))})}return t}static{this.Cookies={getAll:async r=>{let e="cookieStore"in window?window.cookieStore:null,t=[];if(a.isNull(e)){let n=a.cookies();for(let i in n)!a.isNullOrEmpty(r)&&r!==i||t.push({name:i,value:n[i]});return t}else return await e.getAll(r)},stringify:r=>{let e=`${r.name}=${encodeURIComponent(r.value??"")}`;return a.isNullOrEmpty(r.domain)||(e+=`; domain=${encodeURIComponent(r.domain)}`),a.isNullOrEmpty(r.path)||(e+=`; path=${encodeURIComponent(r.path)}`),r.maxAge>0&&(e+=`; max-age=${r.maxAge.toFixed(0)}`),a.isNullOrEmpty(r.expires)||(e+=`; expires=${r.expires}`),r.partitioned&&(e+="; Partitioned"),a.isNullOrEmpty(r.sameSite)||(e+=`; SameSite=${encodeURIComponent(r.sameSite)}`),r.secure&&(e+="; Secure"),e}}}static isVisible(r){return"checkVisibility"in r?r.checkVisibility({checkOpacity:!0,checkVisibilityCSS:!0}):getComputedStyle(r).visibility!=="hidden"&&(r.clientWidth>0||r.clientHeight>0)}static hasClass(r,e){return r.classList?r.classList.contains(e):new RegExp("(^| )"+e+"( |$)","gi").test(r.className)}static addClass(r,e){let t=e.trim();r.classList?DOMTokenList.prototype.add.apply(r.classList,t.split(" ")):r.setAttribute("class",r.className+" "+t)}static removeClass(r,e){let t=e.trim();r.classList?DOMTokenList.prototype.remove.apply(r.classList,t.split(" ")):r.setAttribute("class",r.className.replace(new RegExp("(^|\\b)"+t.split(" ").join("|")+"(\\b|$)","gi")," "))}static toggleClass(r,e,t){t?a.addClass(r,e):a.removeClass(r,e)}static hasPart(r,e){return r.part.contains(e)}static addPart(r,e){DOMTokenList.prototype.add.apply(r.part,e.trim().split(" "))}static removePart(r,e){DOMTokenList.prototype.remove.apply(r.part,e.trim().split(" "))}static togglePart(r,e,t){t?a.addPart(r,e):a.removePart(r,e)}static offset(r){var e=r.getBoundingClientRect();return{top:Math.round(e.top)+a.scrollTop,left:Math.round(e.left)+a.scrollLeft,width:Math.round(e.width),height:Math.round(e.height)}}static offsetRect(r){var e=this.offset(r);return{y:e.top,x:e.left,width:e.width,height:e.height}}static naturalOffsetTop(r){return(r?.offsetTop??0)+(r?.offsetParent&&r.offsetParent instanceof HTMLElement?this.naturalOffsetTop(r.offsetParent):0)}static naturalOffsetLeft(r){return(r?.offsetTop??0)+(r?.offsetParent&&r.offsetParent instanceof HTMLElement?this.naturalOffsetLeft(r.offsetParent):0)}static naturalOffset(r){return{left:this.naturalOffsetLeft(r),top:this.naturalOffsetTop(r),width:r?.offsetWidth??0,height:r?.offsetHeight??0}}static naturalOffsetRect(r){var e=this.naturalOffset(r);return{y:e.top,x:e.left,width:e.width,height:e.height}}static deserializeTransform(r){return a.Css.deserializeTransform(r)}static set scrollTop(r){window.scrollTo(a.scrollLeft,r)}static set scrollLeft(r){window.scrollTo(r,a.scrollTop)}static get scrollTop(){return window.scrollY||document.documentElement.scrollTop||document.body.scrollTop||0}static get scrollLeft(){return window.scrollX||document.documentElement.scrollLeft||document.body.scrollLeft||0}static get windowSize(){let r=window;return{width:r.innerWidth||r.document.documentElement.clientWidth||r.document.body.clientWidth||0,height:r.innerHeight||r.document.documentElement.clientHeight||r.document.body.clientHeight||0}}static addAnimationEndCallback(r,e,t=500){let n=s=>{(!s||s.target==r)&&(clearTimeout(i),r.removeEventListener("animationend",n,!1),r.removeEventListener("transitionend",n,!1),e.apply(this,[r]))};r.addEventListener("animationend",n,!1),r.addEventListener("transitionend",n,!1);let i=setTimeout(n,t)}static waitForAnimationEnd(r,e=500){return new Promise((t,n)=>{a.addAnimationEndCallback(r,()=>{t()},e)})}static idle(r){return new Promise((e,t)=>{setTimeout(()=>e(),r)})}static accelerateCallback(r,e=500,t=5,n=20){let i={cancel:!1},s=e,o=t+n,c=()=>{r(i),i.cancel||(setTimeout(c,s),s<o?s=n:s-=t)};c()}static isEmpty(r){return wM.isEmpty(r)&&!(r instanceof Node)}static isNull(r){return wM.isNull(r)}static isArray(r){return Array.isArray(r)}static isNullOrEmpty(r){return a.isNull(r)||a.isEmpty(r)}static areSemanticallyEqual(r,e){r??=null,e??=null;let t=r&&r.valueOf&&r.valueOf(),n=e&&e.valueOf&&e.valueOf();return t===n}static{this.extend=Object.assign}static clone(r){if(r!==void 0)return wu.clone(r)}static fromResult(r){return Promise.resolve(r)}static fromResultAsync(r){return new Promise(e=>requestAnimationFrame(()=>e(r())))}static readonlyCopy(r){if(a.isNull(r))return null;if(a.isArray(r)){let e=r.slice(0);return Object.freeze(e),e}else{let e={};for(let t in r)e[t]=r[t];return Object.freeze(e),e}}static{this.URIs={format:function(r,e,t){for(let s in e||{}){let c=new RegExp("(^|\\/)\\{"+s+"\\??\\}(\\/|$)").exec(r);if(c&&c.length){let d=new RegExp("\\{"+s+"\\??\\}"),p=c.index;r=r.substring(0,p)+r.substring(p).replace(d,encodeURIComponent(e[s])),t&&delete e[s]}}let n=/(^|\/)\{[\w]+\?\}(\/|$)/;for(var i;(i=n.exec(r))&&i.length>0;){let s=i[0];r=r.replace(s,s.endsWith("/")?"/":"")}return r},appendQuery:function(r,e,t=!1,n=!1){let i=n?"#":"?",o=((n?/#/:/\?/).test(r)?"&":i)+Object.keys(e).filter(c=>!a.isNull(e[c])||!t).map(c=>encodeURIComponent(c)+"="+encodeURIComponent(e[c]??"")).join("&");return r+(o.length>1?o:"")},parseQuery:(r=window.location)=>{typeof r!="string"&&(r=r.search);let e={};return new URLSearchParams(r).forEach((t,n)=>{Object.defineProperty(e,n,{enumerable:!0,value:t})}),e},hasMandatoryTemplateSegments:function(r){return/(^|\/)\{\.*\}(\/|$)/.test(r)},parseRoute:function(r){let e=r,t=[];if(!a.isNullOrEmpty(e)){let n,i=0;for(;(n=MM.exec(e))!=null;){let s=n[0],o=FO.exec(s);if(!a.isNullOrEmpty(o)){let c=o[1];t.push({name:c,optional:s.charAt(s.length-2)==="?",index:i})}e=e.substring(n.index+s.length),i++}}return t},split:function(r){let t=/^((https?:)?\/\/[^\/]+)?([^\?#]+)(\?[^#]*)?(#[^#]*)?$/.exec(r);return t?{domain:t[2]??"",protocol:t[1]??"",path:t[3]??"",query:t[4]??"",hash:t[5]??""}:null},parseState:function(r,e,t,n,i){let s=e;if(a.isNullOrEmpty(t)){let h=a.URIs.split(e);t=h.path,a.isNullOrEmpty(n)&&(n=h.query??""),a.isNullOrEmpty(i)&&(i=h.hash??""),s=t+n+i}let o=h=>{let m=h.indexOf("#");return m!==0?null:h.substring(m+1)},c=h=>{let m=h.indexOf("?");return m===0?a.URIs.parseQuery(h.substring(m+1)):{}},d={$path:s,$pathname:t,$querystring:n.length>0?n.substring(1):n,$query:c(n),$hash:o(i)},p=0,u=r.slice();if(!a.isNullOrEmpty(u)){let h;for(;(h=MM.exec(t))!=null;){let m=h[0],f=u.findIndex(g=>g.index===p);if(f>=0){let g=u[f],{name:v}=g;Object.defineProperty(d,v,{enumerable:!0,value:m.substring(1)}),u.splice(f,1)}p++,t=t.substring(h.index+m.length)}}for(let h=0;h<u.length;h++)if(!u[h].optional)throw`Must provide "${u[h].name}" route value.`;return d}}}static getApiResult(r){if(typeof r=="object"&&!a.isNull(r)&&r.hasOwnProperty("success"))switch(r.success){case!0:if(r.hasOwnProperty("result"))return r.result;break;case!1:if(r.hasOwnProperty("error"))return null;break}return r}};var Yt=class{static isInstanceOf(r,e){return r instanceof e}static getEventCoordinates(r){var e;return"touches"in r?y.isNullOrEmpty(r.touches)?y.isNullOrEmpty(r.changedTouches)||(e=r.changedTouches[0]):e=r.touches[0]:e=r,{page:{x:e.pageX,y:e.pageY},screen:{x:e.screenX,y:e.screenY},client:{x:e.clientX,y:e.clientY}}}static getEventKeyModifiers(r){var e=r.which;return r instanceof MouseEvent&&(e=r.button),{which:e,shiftKey:r.shiftKey,altKey:r.altKey,ctrlKey:r.ctrlKey,metaKey:r.metaKey}}static matchModifiers(r,...e){let t=!y.isNull(e)&&(e.length===1&&y.isArray(e[0])?e[0]:Array.from(e).filter(d=>!y.isNullOrEmpty(d))),n=(t||[]).map(d=>d.toLowerCase()),i=n.indexOf("alt")>=0||n.indexOf("option")>=0,s=n.indexOf("shift")>=0,o=n.indexOf("ctrl")>=0,c=n.indexOf("win")>=0||n.indexOf("cmd")>=0;return!(i!==r.altKey||s!==r.shiftKey||c!==r.metaKey||o!==r.ctrlKey)}static fixEdgeCustomEventSubClassInstance(r,e){r instanceof e||Object.setPrototypeOf(r,e)}};var st=class extends CustomEvent{constructor(r,e,t){super(r,y.extend({detail:e},t||{})),Yt.fixEdgeCustomEventSubClassInstance(this,this.constructor)}};function WO(a){if("detail"in a){for(let r in a)if(r!=="bubbles"&&r!=="cancelable"&&r!=="composed"&&r!=="detail")return!1;return!0}return!1}var wl=class extends CustomEvent{constructor(r,e,t,n){super(r,y.extend(WO(e||{})?e:{detail:e},!(t instanceof Event)&&t||{}));let i=n||t;i instanceof Event&&(this.#e=i,this.#t=Yt.getEventKeyModifiers(i),(i instanceof MouseEvent||i instanceof TouchEvent)&&(this.#r=Yt.getEventCoordinates(i))),Yt.fixEdgeCustomEventSubClassInstance(this,this.constructor)}#e;#t;#r;get originalEvent(){return this.#e}get which(){return this.#t?.which}get altKey(){return this.#t?.altKey}get shiftKey(){return this.#t?.shiftKey}get ctrlKey(){return this.#t?.ctrlKey}get metaKey(){return this.#t?.metaKey}get pageX(){return this.#r?.page.x}get pageY(){return this.#r?.page.y}get clientX(){return this.#r?.client.x}get clientY(){return this.#r?.client.y}get screenX(){return this.#r?.screen.x}get screenY(){return this.#r?.screen.y}},jO="attributechange",Lb=class extends st{constructor(r){super(jO,r)}},hd="propertychange",ji=class extends st{constructor(r){super(hd,r)}};var Nb=class extends st{constructor(r){super("currentindexchange",r)}};var Tb="pacem:properties",Mu="pacem:custom-element:bindings",md="pacem:custom-element:host",mf="pacem:custom-element:scope";var SM,F=(SM=window.Pacem)?.Configuration?.prefix??"pacem",re=SM?.Configuration?.css??F;var Su=class extends HTMLElement{};var Ab="__pacem__",YO=/^\{\{(.|\n)+\}\}$/,j=class a{static get polyfilling(){return customElements instanceof window.CustomElementRegistry}static camelToKebab(r){return r&&r.replace(/([A-Z])/g,"-$1").toLowerCase()}static kebabToCamel(r){return r&&r.replace(/(-[a-z])/g,e=>e[1].toUpperCase())}static getWatchedProperties(r,e=!0){var t=[],n=r instanceof HTMLElement?r.constructor:r;do{let s=(this.getAttachedPropertyValue(n,Tb)||[]).filter(o=>!o.name.startsWith("_"));Array.prototype.splice.apply(t,[0,0].concat(s))}while(e&&(n=Object.getPrototypeOf(n)));return t}static getWatchedProperty(r,e){return this.getWatchedProperties(r,!0).find(t=>t.name===e)}static importjs(r,e=null,t=!1){var n={type:"text/javascript",src:r};return y.isNullOrEmpty(e)||y.extend(n,{integrity:e}),t&&y.extend(n,{crossorigin:""}),a.import(r,"script",n,document.head||document.getElementsByTagName("head")[0])}static importcss(r,e=null,t=!1){var n={rel:"stylesheet",href:r};return y.isNullOrEmpty(e)||y.extend(n,{integrity:e}),t&&y.extend(n,{crossorigin:"anonymous"}),a.import(r,"link",n,document.head||document.getElementsByTagName("head")[0])}static import(r,e,t,n=document.body){let i=y.core;var s=i.imports=i.imports||{};return s[r]=s[r]||new Promise((o,c)=>{var d=e;for(let h in t||{})d+=`[${h}="${t[h]}"]`;var p=document.querySelector(d);if(!y.isNull(p))o(p);else{p=document.createElement(e),p.onerror=h=>{c(h)},p.onload=()=>{o(p)};for(var u in t||{})p.setAttribute(u,t[u]);n.appendChild(p)}})}static{this.Theme={importWebFonts(){function r(i){return/^('|").*\1$/.test(i)?i.substring(1,i.length-1):i}function e(i){return y.isNullOrEmpty(i)?Promise.resolve():document.fonts.load("1rem "+i)}let t=["icons","std","main","tech","btn"].map(i=>{let s=y.Css.getVariableValue(`--${re}-font-${i}`).split(",")[0],o=r(y.Css.getVariableValue(`--${re}-font-${i}-api-url`));return y.isNullOrEmpty(o)?e(s):a.importcss(o).then(c=>e(s))}),n=new Promise(i=>{function s(o=0){o>4||!("size"in document.fonts)||typeof document.fonts.size=="number"&&document.fonts.size>0?document.fonts.ready.then(i):setTimeout(s,250,o++)}s()});return t.push(n),Promise.all(t)}}}static setAttachedPropertyValue(r,e,t){if(y.isNull(r))return;let n=Object.getOwnPropertyDescriptor(r,Ab),i=n&&n.value||Object.defineProperty(r,Ab,{value:{},enumerable:!1,writable:!1,configurable:!1})[Ab];y.isNull(t)?delete i[e]:i[e]=t}static deleteAttachedPropertyValue(r,e){a.setAttachedPropertyValue(r,e,void 0)}static getAttachedPropertyValue(r,e,t){let n=Object.getOwnPropertyDescriptor(r,Ab),i=n&&n.value;return y.isNull(i&&i[e])&&!y.isNull(t)?(a.setAttachedPropertyValue(r,e,t),t):i&&i[e]}static resolvePath(r,e){if(!r||!e)return;if(/[\(\)\{\}]/.test(r))throw`Security alert: not allowed to process paths like ${r}.`;let t=r.split(".");var n=e,i=n,s,o=t[0];t.forEach((p,u)=>{var h=p.split("[");h.forEach((m,f)=>{s=i,/\]$/.test(m)&&(m=m.substring(0,m.length-1),/^('|").+[^\\]\1$/.test(m)&&(m=m.substr(1,m.length-2))),i=i[m]})});var c,d;return/\]$/.test(r)?(d=r.lastIndexOf("["),c=r.substring(d+1),c=c.substring(0,c.length-1)):(d=r.lastIndexOf("."),c=r.substring(d+1)),{target:{value:i,name:c},parent:{value:s||e,path:r.substring(0,d)},root:{value:n,property:o}}}static set(r,e,t){var n=a.resolvePath(e,r),i=n.target.value;if(i!==t)if(n.parent.value!=n.root.value&&!(n.parent.value instanceof HTMLElement)){n.parent.value[n.target.name]=t;let s=y.clone(n.root.value[n.root.property]);n.parent.value[n.target.name]=i;let o;n.root.property==="item"&&!y.isNull(o=Ia.getRepeaterItem(n.root.value))?o.repeater&&o.repeater.datasource&&o.repeater.datasource.splice(o.index,1,o.item=s):n.root.value[n.root.property]=s}else n.parent.value[n.target.name]=t}static get(r,e){var t=a.resolvePath(e,r);return t&&t.target&&t.target.value}static _findScopeContextLegacy(r){let e=r,t;do e=e.parentNode;while(e!=null&&(e!=(t=r.ownerDocument)||e instanceof HTMLElement&&(t=e.shadowRoot)!=null));return t}static findScopeContext(r){return(r.isConnected?r.getRootNode():a.getAttachedPropertyValue(r,mf))??a._findScopeContextLegacy(r)}static findAncestor(r,e){let t=r,n;for(;t&&(t=t.parentNode||t.getRootNode()?.host)!=null;)if(t.host instanceof HTMLElement&&(t=t.host),e.apply(t,[t])){n=t;break}return n}static findAncestorShell(r){return a.findAncestor(r,e=>y.is(e,`.${re}-body`)||e===document.body)}static findAncestorOfType(r,e){return a.findAncestor(r,t=>t instanceof e)}static findDescendants(r,e,t=!1){let n=document.createTreeWalker(r,NodeFilter.SHOW_ELEMENT);for(var i=[];n.nextNode();){let s=n.currentNode;if(e(s)===!0&&(i.push(s),t))return i}return i}static findFirstDescendant(r,e){let t=a.findDescendants(r,e,!0);return y.isNullOrEmpty(t)?void 0:t[0]}static findAll(r="[pacem]",e=t=>!0){let t=[];return document.querySelectorAll(r).forEach((n,i,s)=>{e(n)===!0&&t.push(n)}),t}static findPreviousSiblingOrAncestorOfType(r,e,t=0){let n=r,i=null,s=0;do if(n=n.previousSibling||n.parentNode,n instanceof e){if(s>=t){i=n;break}else n=n.parentNode;s++}while(n!=null);return i}static findPreviousSiblingOrAncestor(r,e,t=0){let n=r,i=null,s=0;do if(n=n.previousSibling||n.parentNode,n&&e.apply(n,[n])){if(s>=t){i=n;break}else n=n.parentNode;s++}while(n!=null);return i}static assignHostContext(r,e){let t=document.createTreeWalker(e.content,NodeFilter.SHOW_ELEMENT+NodeFilter.SHOW_DOCUMENT_FRAGMENT);for(;t.nextNode();){var n=t.currentNode;y.isNull(a.getAttachedPropertyValue(n,md))&&a.setAttachedPropertyValue(n,md,r)}}static findHostContext(r){let e=r,t;if(!e.isConnected)return t;for(;e!=null&&(t=a.getAttachedPropertyValue(e,md),!(t instanceof HTMLElement));)e=e.parentElement;let n;return t==null&&console&&(n=console.warn)&&n(`Element "${r.constructor.name}" isn't a descendant of a templated component.`),t}static isBindingAttribute(r){return YO.test(r)}static extractBindingAttributeExpression(r){if(a.isBindingAttribute(r))return r.substr(2,r.length-4);throw"Invalid attribute: incorrect binding syntax."}static parseBindingAttribute(r,e){let t=a.extractBindingAttributeExpression(r),n=/,\s*(twoway|once)\s*$/.exec(t),i=n&&n.length>1&&n[1];y.isNullOrEmpty(i)||(t=t.substr(0,t.lastIndexOf(",")));var s=Ml.parse(t,e);return(s&&s.dependencies).forEach(o=>{switch(i){case"twoway":o.mode=o.twowayAllowed&&s.dependencies.length==1?"twoway":void 0;break;case"once":o.mode=i;break}}),s}static ensureMember(r,e,t){let n=Object.getOwnPropertyDescriptor(r,e);return n??(Object.defineProperty(r,e,t),Object.getOwnPropertyDescriptor(r,e))}static stripObservedAttributes(r){LM(r,!1)}static freezeObservedAttributes(r){LM(r)}};function LM(a,r=!0){let e=document.createTreeWalker(a,NodeFilter.SHOW_ELEMENT);do{var t=e.currentNode;if(t instanceof HTMLElement){let i=t.constructor.observedAttributes;if(!y.isNull(i)){j.deleteAttachedPropertyValue(t,Mu);let s=function(o){return y.isArray(o)?"["+o.map(s).join(",")+"]":o instanceof Element?`#${o.id=o.id||"_"+y.uniqueCode()}`:`${y.Json.stringify(o)}`};for(var n of i)if(n in t.attributes){let o,c;if(r&&!y.isNull(c=t[o=j.kebabToCamel(n)])){let d=s(c);t.setAttribute(n,`{{ ${d} }}`)}else t.removeAttribute(n)}}}}while(e.nextNode())}var NM=j.getAttachedPropertyValue,XO=j.setAttachedPropertyValue,SC="pacem:repeater-item",kl=class{static findItemContext(r,e=0,t=console.warn){let n=Ia.findUpwards(r,e,t);return n==null&&t&&r instanceof HTMLElement&&r.isConnected&&t(`Couldn't find a ${Ia.name} up ${e} level${e===1?"":"s"} from element "${r.constructor.name}".`),n}},Ia=class a{constructor(r){this._placeholder=r;XO(r,SC,this)}static findUpwards(r,e=0,t=console.warn){if(y.isNull(r)||r.localName==="template"||r instanceof Su)return null;let n=null,i=o=>!y.isNull(n=a.getRepeaterItem(o));return j.findPreviousSiblingOrAncestor(r,i,e)==null&&t&&r instanceof HTMLElement&&r.isConnected&&t(`Couldn't find a ${a.name} up ${e} level${e===1?"":"s"} from element "${r.constructor.name}".`),n}static isRepeaterItem(r){return!y.isNull(NM(r,SC))}static getRepeaterItem(r){return NM(r,SC)}get placeholder(){return this._placeholder}};var $a="__context_pacem",qO=/'(\\'|[^'])*[^\\]?'|"(\\"|[^"])*[^\\]?"/g,KO=/[^\w]new\s|[^\w]window\s*[\.\[]|[^\w]document\s*\.|[^\w]eval\s*\(/,TM=/(^|[\s\(\[\+\-\*\/!])(:host\.|\^+item[\s\.,;\)\]]|\^+item$|\^+index[^\w\.]|\^+index$|\$?this[\.\s$]?|#[a-zA-Z_][\w]*|::[a-zA-Z_][\w]*)/g,Ml=class a{constructor(){this._pending=!1;this._independent=!1}get dependencies(){return this._dependencies}get functionBody(){return this._fnBody}get voidBody(){return this._voidBody}get pending(){return this._pending}get independent(){return this._independent}evaluate(){return this._fn||(this._fn=new Function("$pacem",$a,this._fnBody)),this._fn.apply(null,[y.core,this._args])}evaluateAsync(){let r=li.defer();return this._fn||(this._fn=new Function("$pacem",$a,this._fnBody)),r.resolve(this._fn.apply(null,[y.core,this._args])),r.promise}evaluatePlus(r={}){if(!this._fn){let n=[$a];for(var e in r)n.push(e);n.push("$pacem"),this._fn=new Function(n.join(", "),this._voidBody)}let t=[].concat(this._args);for(var e in r)t.push(r[e]);return t.push(y.core),this._fn.apply(null,t)}static{this._pendingExpression=null}static _getPendingExpressionSingleton(){if(a._pendingExpression==null){let r=new a;r._pending=!0,r._dependencies=[],a._pendingExpression=r}return a._pendingExpression}static parse(r,e){for(var t=j.findScopeContext(e),n={$this:e},i=[],s="",o=!0,c=[],d,p=0,u=[];(d=qO.exec(r))!=null;){u.push(r.substr(p,d.index-p));let v=d[0].length;c.push({start:d.index,length:v}),p=d.index+v}p<r.length&&u.push(r.substr(p,r.length-p));for(var h=0;h<u.length;h++){let v=u[h];if(KO.test(v))throw`Unsafe expression detected: "${v}".`;if(t==null){if(new RegExp(TM).test(v)===!0){o=!1;break}}else{let b=v.replace(TM,(_,E,C,k,w)=>{o=!1;let T="__host_pacem",I=$a+".$this"+(C.endsWith(".")?".":""),O=e,D=w.indexOf(".",k),P=D>k?w.substr(D+1).trim():"",N=/^[\w\.\$]+/.exec(P),H=N&&N.length>0&&N[0],V,B=H&&(V=H.split(".")).length>0&&V[0];if(C===":host.")O=n[T]=n[T]||j.findHostContext(e),I=`${$a}.${T}.`;else if(C.endsWith("^item")||C.substr(0,C.length-1).endsWith("^item")){let R=C.endsWith("^item")?"":C.substr(C.length-1,1),U=C.length-(R.length>0?6:5),z=`__item_${U}_up_pacem`,G=kl.findItemContext(e,U);O=n[z]=n[z]||G&&G.placeholder,H="item"+(H?"."+H:""),B="item",I=`${$a}.${z}.item${R}`}else if(C.endsWith("^index")||C.substr(0,C.length-1).endsWith("^index")){let R=C.endsWith("^index")?"":C.substr(C.length-1,1),U=C.length-(R.length>0?7:6),z=`__item_${U}_up_pacem`,G=kl.findItemContext(e,U);O=n[z]=n[z]||G&&G.placeholder,H="index",B="index",I=`${$a}.${z}.index${R}`}else if(C.startsWith("::")){let R=C.substr(2,C.length-2),U=n[T]=n[T]||j.findHostContext(e);y.isNull(U)?O=null:O=U[R],I=`${$a}.${T}.${R}`}else if(C.startsWith("#")){let R=C.substr(1,C.length-1);O=n[R]=n[R]||t.querySelector("#"+R),I=`${$a}.${R}`}return B&&O&&B in O&&typeof O[B]!="function"&&i.find(R=>R.element===O&&R.property==B)==null&&i.push({element:O,property:B,path:H,twowayAllowed:!1}),E+I});if(s+=b,h<c.length){let _=c[h];s+=r.substr(_.start,_.length)}}}if(o){var m=new a;return m._independent=!0,m._fnBody=`return ${r};`,m._voidBody=r,m._dependencies=[],m}if(t==null)return this._getPendingExpressionSingleton();for(var f in n)if(n[f]==null)return a._getPendingExpressionSingleton();i.length==1&&/[^\w\.\$]+/.test(s.trim())!==!0&&(i[0].twowayAllowed=!0);var g=new a;return g._args=n,g._fnBody=`try{ var ___$$$r = ${s}; return ___$$$r; }catch(e){ }`,g._voidBody=`try{ ${s} }catch(e){ }`,g._dependencies=i,g}};var AM="fetchresult",DM="error",RM="success",Db=class{static isEmpty(r){return r.status===204||r.headers.get("Content-Length")==="0"}};var ZO=()=>{},Rb=class extends Error{constructor(e,t){super(t);this.statusCode=e}get status(){return this.statusCode}},LC=class{constructor(r,e){r&&(this._status=r.status,this._body=r.response,this._text=r.responseText,this._type=r.responseType,this._allHeadersRaw=r.getAllResponseHeaders(),this._processTime=e)}get processTime(){return this._processTime}get headers(){return this._headers===void 0&&this._allHeadersRaw&&this._parseHeaders(),this._headers}get size(){return+this.headers["Content-Length"]}get mime(){return this.headers["Content-Type"]}get date(){return new Date(Date.parse(this.headers.Date))}_parseHeaders(){let r={};this._allHeadersRaw.split(`\r
|
|
14
|
+
`).forEach(t=>{if(t&&t.length){let n=t.indexOf(":"),i=t.substr(0,n).trim(),s=t.substr(n+1).trim();r[i]=s}}),this._headers=r}get status(){return this._status}get text(){return this._text}get content(){return this._body}get type(){return this._type}get json(){if(this._type==="json")return this._body;try{return JSON.parse(this._text)}catch{return}}},Ob=class{constructor(){}request(r,e){var t=this;let n=li.defer();e=e||{method:"GET"};var i=e.method||"GET",s=e.data||{},o=e.progress||ZO,c=e.headers||{};t.accessToken&&(c.Authorization="Bearer "+t.accessToken);var d=new XMLHttpRequest;d.withCredentials=!1,d.addEventListener("progress",m=>{if(m.lengthComputable){var f=m.loaded/m.total;typeof o=="function"&&o.apply(t,[f])}},!1),d.addEventListener("error",m=>{n.reject(new Rb(500,m.message||"Unknown error"))},!1);var p;d.addEventListener("load",()=>{if(d.status>=200&&d.status<300){var m=new LC(d,Date.now()-p);n.resolve(m)}else n.reject(new Rb(d.status,d.statusText))},!1);var u;switch(i.toUpperCase()){case"GET":r+=(/\?/.test(r)?"&":"?")+(typeof s=="string"?s:Object.keys(s).map(function(m){return encodeURIComponent(m)+"="+encodeURIComponent(s[m])}).join("&"));break;case"POST":u=JSON.stringify(s)}switch(d.open(i,r,!0),i.toUpperCase()){case"GET":d.setRequestHeader("X-Requested-With","XMLHttpRequest");break;case"POST":d.setRequestHeader("X-Requested-With","XMLHttpRequest"),d.setRequestHeader("Content-Type","application/json");break}for(var h in c)d.setRequestHeader(h,c[h]);return p=Date.now(),d.send(u),n.promise}get(r,e,t){return this.request(r,{method:"GET",data:e,headers:t||{}})}post(r,e,t){return this.request(r,{method:"POST",data:e,headers:t||{}})}};import{Point as QO,Size as eP,Rect as tP}from"@pacem/pacem-foundation";var rP={convert:a=>{}},nP={convert:a=>a,convertBack:a=>a},iP={convert:a=>a&&a.trim().split(/[ ,]+/),convertBack:a=>y.isArray(a)&&a.join(" ")||""},sP={convert:a=>parseFloat(a),convertBack:a=>a.toString()},aP={convert:a=>!y.isNullOrEmpty(a)&&a!=="0"&&a!=="false",convertBack:a=>(!!a).toString()},oP={convert:a=>a==="true"||a==="1",convertBack:a=>(!!a).toString()},OM={convert:a=>y.parseDate(a),convertBack:a=>y.parseDate(a).toISOString()},lP=OM,cP={convert:a=>y.Json.parse(a),convertBack:a=>y.Json.stringify(a)},dP={convert:a=>Function(`return ${a};`).apply(null),convertBack:a=>{}},pP={convert:a=>document.querySelector(a),convertBack:a=>a instanceof Element&&a.id?"#"+a.id:void 0,retryConversionWhenReady:!0},uP={convert:a=>QO.parse(a),convertBack:a=>`${a.x||0} ${a.y||0}`},hP={convert:a=>eP.parse(a),convertBack:a=>`${a.width||0} ${a.height||0}`},mP={convert:a=>tP.parse(a),convertBack:a=>`${a.x||0} ${a.y||0} ${a.width||0} ${a.height||0}`},S={None:rP,String:nP,StringArray:iP,Number:sP,Boolean:aP,BooleanStrict:oP,Date:lP,Datetime:OM,Json:cP,Eval:dP,Element:pP,Point:uP,Rect:mP,Size:hP};var Pb=(a,r)=>y.areSemanticallyEqual(a,r);var rt=j.getAttachedPropertyValue,Tn=j.setAttachedPropertyValue,NC=j.deleteAttachedPropertyValue,fP="pacem:property:",PM="pacem:version",ff="pacem:binding:",gP="pacem:view-children",TC="pacem:has-binding:",HM="pacem:custom-element:has-template",IM="pacem:custom-element:has-templated",BM="pacem:custom-element:promise",Nu="pacem:custom-element:ready",$M="pacem:custom-element:startup";function Lu(a,r,e){var t=a;let n=r,i=e;var s=rt(t,ff+n);if(s&&s.forEach(o=>{o.dep.element.removeEventListener(hd,o.callback,!1)}),y.isNull(i)||rt(a,Nu)!==!0)NC(t,ff+n),NC(t,TC+n);else if(i.pending)Tn(t,ff+n,[]);else{let o="oneway";switch(i.dependencies&&i.dependencies.length&&i.dependencies[0].mode){case"twoway":i.dependencies.length==1&&(o="twoway");break;case"once":o="once"}Tn(t,TC+n,o);let c=i.dependencies.map(d=>{var p={dep:d,callback:function(u){u.detail.propertyName===d.property&&(t[n]=i.evaluate())}};return d.element.addEventListener(hd,p.callback,!1),p});Tn(t,ff+n,c),t[n]=i.evaluate()}}function vP(a){var r=li.defer();let e=t=>{y.isDOMReady()?r.resolve(t):y.onDOMReady(n=>{r.resolve(t)})};return a.template?e(a.template):a.templateUrl?new Ob().get(a.templateUrl).success(n=>{let i=a.template=n.text;return e(i),n}).error(n=>{console.error(n.message),e(null)}):e(null),r.promise}function bP(a,r){let e=document.createTreeWalker(r,NodeFilter.SHOW_ELEMENT);for(var t=[];e.nextNode();){var n=e.currentNode;if(rt(n.constructor,HM)===!0){var i=rt(n,BM,li.defer());t.push(i.promise)}}return t}var W=a=>r=>{if(y.customElements.get(a.tagName)){console.warn(`${a.tagName} registration skipped, since already defined.`);return}var e=j.getWatchedProperties(r,!0);if(Tn(r,HM,!(y.isNullOrEmpty(a.template)&&y.isNullOrEmpty(a.templateUrl))),e&&e.length>0){let i="observedAttributes";var t=[];r.hasOwnProperty(i)&&(t=r[i].slice(),delete r[i]);let s=t;for(var n of e){let o=j.camelToKebab(n.name);s.unshift(o)}Object.defineProperty(r,i,{get:function(){return s},enumerable:!0,configurable:!1})}{let i=r.prototype,s=Object.getOwnPropertyDescriptor(i,"connectedCallback")||i.connectedCallback,o=Object.getOwnPropertyDescriptor(i,"viewActivatedCallback")||i.viewActivatedCallback;Object.defineProperty(i,"connectedCallback",{value:function(){let h=this;h.setAttribute("pacem",""),h.setAttribute("cloak",""),NC(h,gP),s&&s.value?s.value.apply(h,[]):typeof s=="function"&&s.apply(h),vP(a).then(m=>{if(!h.isConnected)return;var f=[];if(rt(h,Nu)!==!0&&!y.isNullOrEmpty(m)&&rt(h,IM)!=!0){Tn(h,IM,!0);let w=h,T=a.shadow,I=document.createElement("template").content,O=document.createElement("template");if(!T)for(var g=w.childNodes.length-1;g>=0;g--)I.insertBefore(w.childNodes.item(g),I.firstChild);O.innerHTML=m;let D=O.content.querySelectorAll(F+"-content");if(j.assignHostContext(h,O),D.length==1){let P=D.item(0);var v=P.nextSibling;let N=P.parentElement||O.content,H=I.childNodes;for(N.removeChild(P);H.length>0;)try{let V=H.item(0);N.insertBefore(V,v)}catch(V){console.error(V.toString())}}else if(D.length>1)throw"There can only be at most 1 content placeholder inside a template.";var b;if(a.shadow)b=w.attachShadow({mode:"open"}),b.appendChild(O.content);else{b=w;for(var _=O.content.children;_.length>0;)b.append(_.item(0))}f=bP(h,b)}Tn(h,Nu,!0);for(let w of e){let T=w.name,I=w.config;if(!I.converter.retryConversionWhenReady||!y.isNull(h[T]))continue;let O=j.camelToKebab(T),D=h.getAttribute(O);!y.isNullOrEmpty(D)&&!j.isBindingAttribute(D)&&(h[T]=I.converter.convert(D,h))}(rt(h,$M)||[]).forEach(w=>{w.apply(h)}),(w=>{var T=rt(h,Mu)||[];T.forEach(I=>{let O=I;if(!(O in h.attributes))throw`Howcome? ${O} not in ${h.constructor.name} attributes!?...`;let D=h.attributes[O].value;if(j.isBindingAttribute(D)){var P=j.parseBindingAttribute(D,h);Lu(h,j.kebabToCamel(I),P)}})})();let k=w=>{o&&o.value?o.value.apply(h,[]):typeof o=="function"&&o.apply(h);var T=rt(h,BM);y.isNull(T)||T.resolve()};h.removeAttribute("cloak"),Promise.all(f).then(w=>k())})},configurable:!0,enumerable:!0});let c=Object.getOwnPropertyDescriptor(i,"disconnectedCallback")||i.disconnectedCallback;Object.defineProperty(i,"disconnectedCallback",{value:function(){let h=this;c&&c.value?c.value.apply(h,[]):typeof c=="function"&&c.apply(h,[]),Tn(h,Nu,!1),(rt(h,Mu)||[]).forEach(f=>{Lu(h,j.kebabToCamel(f))})},configurable:!0,enumerable:!0});let d=Object.getOwnPropertyDescriptor(i,"attributeChangedCallback")||i.attributeChangedCallback;Object.defineProperty(i,"attributeChangedCallback",{value:function(h,m,f){let g=this,v=rt(g,Nu)===!0;d&&d.value?d.value.apply(g,[h,m,f]):typeof d=="function"&&d.apply(g,[h,m,f]);let b=new Lb({attributeName:h,oldValue:m,currentValue:f,firstChange:!v});g.dispatchEvent(b);let _=j.isBindingAttribute(f),E=h,C=j.kebabToCamel(E),k=!1;if(_){let I=j.parseBindingAttribute(f,g);if(I instanceof Ml)if(I.independent&&!k)g[C]=I.evaluate(),Lu(g,C);else{var w=rt(g,Mu,[]);w.push(E),I.pending||Lu(g,C,I)}else throw`Howcome? ${f} misinterpreted as ${E} binding...`}else{var T=e.find(I=>I.name===C);y.isNull(T)||(Lu(g,C),g[C]=T.config.converter.convert(f,g))}},configurable:!0,enumerable:!0});let p=Object.getOwnPropertyDescriptor(i,"propertyChangedCallback")||i.propertyChangedCallback;Object.defineProperty(i,"propertyChangedCallback",{value:function(h,m,f,g,v){let b=this,_=rt(b,Nu)===!0,E=()=>{let k=rt(b,TC+h);if(p&&p.value?p.value.apply(b,[h,m,f,!_]):typeof p=="function"&&p.apply(b,[h,m,f,!_]),!v||v.emit!==!1){let D=new ji({propertyName:h,oldValue:m,currentValue:f,firstChange:!_});b.dispatchEvent(D)}if(y.isNullOrEmpty(k)){var w=e.find(D=>D.name===h);if(v&&v.reflectBack===!0&&!j.polyfilling){var T=j.camelToKebab(h),I=b.attributes.getNamedItem(T);if(_||y.isNullOrEmpty(I)){var O;if(f==null)b.removeAttribute(T);else if(w&&(O=w.config)&&typeof O.converter.convertBack=="function"){let D=O.converter.convertBack(f,b);(I==null||D!==I.value)&&b.setAttribute(T,D)}}}}else if(k==="twoway"){let D=rt(b,ff+h)[0].dep;j.set(D.element,D.path,f)}else k==="once"&&Lu(b,h)};if(_)E.apply(b);else{var C=rt(b,$M,[]);C.push(E)}},configurable:!0,enumerable:!0})}y.customElements.define(a.tagName,r,a.options),y.customElements.whenDefined(a.tagName).then(()=>{})},yP=S.None;function M(a){return(r,e,t)=>{var n=rt(r.constructor,Tb,[]);n.push({name:e,config:y.extend({emit:!0,converter:yP},a)});let i=Pb,s=t&&t.set,o=fP+e,c=PM,d=PM+":"+e;function p(){return rt(this,o)}function u(f,g,v){let b=this,_=a&&a.debounce,E;if(typeof(E=b.propertyChangedCallback)=="function"){let C=()=>E.apply(b,[f,g,rt(b,o),!1,a]);typeof _=="number"&&_>0?(clearTimeout(this["_handle_"+e]),this["_handle_"+e]=setTimeout(C,_)):_===!0?(cancelAnimationFrame(this["_handle_"+e]),this["_handle_"+e]=requestAnimationFrame(C)):C()}}function h(f){let g=this;if(f=f||g[e],rt(f,"pacem:array:decorated")===!0)return;Tn(f,"pacem:array:decorated",!0);let v=Array.prototype,b={splice:v.splice,pop:v.pop,copyWithin:v.copyWithin,push:v.push,shift:v.shift,unshift:v.unshift};for(let _ in b){let E=_;f[E]=function(...C){let k=b[E].apply(this,C);return Tn(this,c,Date.now()),u.call(g,e,this,this),k}}}function m(f,g){let v=this,b=y.isArray(g);(!i(f,g)||b&&rt(g,c)!==rt(v,d))&&(Tn(v,o,g),b&&(Tn(v,d,rt(g,c)),h.call(v,g)),u.call(v,e,f,g))}if(s)t.set=function(f){let g=this,v=g[e];s.call(g,f);let b=g[e];m.call(g,v,b)};else{try{r.ownerDocument&&(r[o]=r[e])}catch{}delete r[e]&&Object.defineProperty(r,e,{get:function(){return p.call(this)},set:function(f){let g=this,v=rt(g,o);m.call(g,v,f)},enumerable:!0,configurable:!0})}}}function Ib(a=50,r=(e,...t)=>`pacem:debouncer:${e}`){return function(e,t,n){let i=n.value;a===!0?n.value=function(...s){let o=r(t,...s);var c=this;cancelAnimationFrame(rt(c,o)),Tn(c,o,requestAnimationFrame(()=>{i.apply(c,s)}))}:a>0&&(n.value=function(...s){let o=r(t,...s);var c=this;clearTimeout(rt(c,o,0)),Tn(c,o,setTimeout(()=>{i.apply(c,s)},a))})}}var K=class extends HTMLElement{constructor(){super();this._isReady=!1;this.emitHandler=e=>{this.disabled||this.emit(e)}}emit(e){e.defaultPrevented||this._emitCore(e)}_emitCore(e){var t=`on-${e.type.toLowerCase()}`;if(t in this.attributes){this.log("debug",`Calling ${t} handler for event ${e.type}`);var n=this.attributes[t].value,i=Ml.parse(n,this);!y.isNull(i)&&i.pending!==!0&&i.evaluatePlus({$event:e})}}handle(e,t){typeof e=="string"&&(e=y.isNull(t)?new Event(e,{cancelable:!1}):new CustomEvent(e,{cancelable:!1,detail:t})),this.emit(e)}get isReady(){return this._isReady}connectedCallback(){j.setAttachedPropertyValue(this,mf,j.findScopeContext(this)),this.log("debug","Connected.")}disconnectedCallback(){this._isReady=!1,this.dispatchEvent(new Event("unload")),j.deleteAttachedPropertyValue(this,mf),this.log("debug","Disconnected.")}viewActivatedCallback(){this._isReady=!0,this.log("debug","Loaded (view activated)."),this.dispatchEvent(new Event("load"))}propertyChangedCallback(e,t,n,i){i?this.log("log",`Property "${e}" changed at start-up`):this.log("log",`Property "${e}" changed from ${t} to ${n}`)}dispatchEvent(e){if(this.disabled)return!1;this.log("log",`Dispatching event "${e.type}"`);let t=super.dispatchEvent(e);return this.emit(e),t}log(e,t,n=this.localName+(this.id?"#"+this.id:"")){this.logger&&typeof this.logger.log=="function"&&this.logger.log(e,t,n)}refreshBindings(){for(let e=0;e<this.attributes.length;e++){let t=this.attributes.item(e);if(!j.isBindingAttribute(t.value))continue;let i=j.kebabToCamel(t.name),s=j.parseBindingAttribute(t.value,this);this[i]=s.evaluate()}}};l([M({reflectBack:!0,converter:S.Boolean})],K.prototype,"disabled",2),l([M({emit:!1,converter:S.Element})],K.prototype,"logger",2);var VM="repeateritemcreate",UM="repeateritemremove",gf=class extends st{constructor(r,e){super(r,e)}},vf=class extends gf{constructor(r){super(VM,r)}},bf=class extends gf{constructor(r){super(UM,r)}},AC=["keydown","keyup","click","focus","blur","dblclick","mouseover","mouseout","mouseenter","mouseleave","mousedown","mouseup","mousemove","contextmenu","wheel"],DC=class{constructor(r,e){this._element=r;this._aria=y.extend({},e||{})}toObject(){return y.extend({},this._aria)}set(r,e){this._aria[r]=e;let t=this._element;t.isConnected&&t.setAttribute("aria-"+r,e)}remove(r){delete this._aria[r];let e=this._element;e.isConnected&&e.removeAttribute("aria-"+r)}},RC=class{constructor(r,e,t){this._element=r;this._aria={role:e,attrs:new DC(r,t)}}get role(){return this._aria.role}set role(r){this._aria.role=r;let e=this._element;e.isConnected&&(y.isNullOrEmpty(r)?e.removeAttribute("role"):e.setAttribute("role",r))}get attributes(){return this._aria.attrs}},Xt=class extends K{constructor(e,t){super();this.#t=[];this.#r=[];this._tabIndex=-1;this.behaviors=[];this._aria=new RC(this,e,t)}get aria(){return this._aria}static#e=null;static get emittedEventTypes(){return this.#e??=y.readonlyCopy(AC)}#t;#r;connectedCallback(){super.connectedCallback(),y.isNullOrEmpty(this._aria.role)||this.setAttribute("role",this._aria.role);let e=this._aria.attributes.toObject();if(!y.isNullOrEmpty(e))for(let t in e)this.setAttribute("aria-"+t,e[t])}viewActivatedCallback(){super.viewActivatedCallback(),AC.forEach(t=>{this.addEventListener(t,this.emitHandler,!1)});for(var e of this.behaviors||[])e.register(this)}disconnectedCallback(){for(var e of this.behaviors||[])e.unregister(this);AC.forEach(t=>{this.removeEventListener(t,this.emitHandler,!1)}),super.disconnectedCallback()}propertyChangedCallback(e,t,n,i){switch(super.propertyChangedCallback(e,t,n,i),e){case"css":for(var s in this.css)this.style.setProperty(s,this.css[s]);break;case"cssClass":if(y.isArray(this.cssClass)){let u=this.cssClass;for(let h of this.#t.splice(0))y.removeClass(this,h);for(let h of u)this.#t.push(h),y.addClass(this,h)}else for(let u in this.cssClass)y.toggleClass(this,u,this.cssClass[u]);break;case"cssPart":let o=this.cssPart,c=this.#r;if(y.isArray(o)){let u=o;for(let h of c.splice(0))y.removePart(this,h);for(let h of u)c.push(h),y.addPart(this,h)}else for(let u in o)y.togglePart(this,u,o[u]);break;case"hide":let d=re+"-hiding";if(n){let u=this,h=re+"-anim",m=()=>{u.setAttribute("hidden",""),u.aria.attributes.set("hidden","true")};y.hasClass(u,h)&&!y.isNull(t)?(y.removeClass(u,h),requestAnimationFrame(()=>{y.addClass(u,d),y.addClass(u,h),y.waitForAnimationEnd(u,250).then(f=>{u.hide&&m(),y.removeClass(u,d)})})):m()}else y.removeClass(this,d),this.removeAttribute("hidden"),this.aria.attributes.remove("hidden");break;case"tooltip":this.title=n,y.isNullOrEmpty(n)?this.aria.attributes.remove("label"):this.aria.attributes.set("label",n);break;case"tabOrder":this._tabIndex=n,this.disabled||(this.tabIndex=n);break;case"behaviors":if(!y.isNullOrEmpty(t))for(let u of t)u.unregister(this);if(!y.isNullOrEmpty(n)&&!i)for(let u of n)u.register(this);break;case"disabled":let p=re+"-"+e;n?(this._tabIndex=this.tabIndex,this.tabIndex=-1,y.addClass(this,p)):(this.tabIndex=this._tabIndex,y.removeClass(this,p));break;case"culture":y.isNullOrEmpty(n)?this.removeAttribute("lang"):this.setAttribute("lang",n),i||this.refreshBindings();break}}};l([M({emit:!1,converter:S.Json})],Xt.prototype,"cssClass",2),l([M({emit:!1,converter:S.Json})],Xt.prototype,"cssPart",2),l([M({emit:!1,converter:S.Json})],Xt.prototype,"css",2),l([M({emit:!1,converter:S.Boolean})],Xt.prototype,"hide",2),l([M({emit:!1,converter:S.String})],Xt.prototype,"tooltip",2),l([M({emit:!1,converter:S.Number})],Xt.prototype,"tabOrder",2),l([M({converter:S.String})],Xt.prototype,"culture",2),l([M({emit:!1})],Xt.prototype,"behaviors",2);var Tu=class extends Xt{propertyChangedCallback(r,e,t,n){super.propertyChangedCallback(r,e,t,n),r==="content"&&!n&&this._fillContent(t)}_isContentNullOrEmpty(r=this.content){return y.isNullOrEmpty(r)||r instanceof DocumentFragment&&r.childElementCount===0}viewActivatedCallback(){super.viewActivatedCallback(),this._original=Array.from(this.children),this._isContentNullOrEmpty()||this._fillContent()}disconnectedCallback(){y.isNullOrEmpty(this._original)||(this.innerHTML="",Element.prototype.append.apply(this,this._original)),super.disconnectedCallback()}_fillContent(r=this.content){let e=this.sanitize(r);y.isNullOrEmpty(e)?this.innerHTML="":e instanceof Node?(this.innerHTML="",this.append(e)):this.innerHTML=e}};l([M({emit:!1,converter:S.String})],Tu.prototype,"content",2);var OC=class extends Tu{sanitize(r){return r}},fd=class extends Tu{_sanitizeLegacy(r){if(y.isNullOrEmpty(r))return r;if(r instanceof Node){for(let e=r.childNodes.length-1;e>=0;e--){let t=r.childNodes.item(e);t instanceof HTMLScriptElement?t.remove():this.sanitize(t)}return r}else{let e=/<script.+<\/script>/g;return(r||"").toString().replace(e,"")}}sanitize(r){return this._sanitizeLegacy(r)}};var PC=class extends Xt{constructor(){super(...arguments);this._propertyChangeHandler=e=>{this.masterPropertyChangedCallback(e.detail.propertyName,e.detail.oldValue,e.detail.currentValue,e.detail.firstChange)}}get master(){return this._element}get initialized(){return!y.isNull(this._element)}masterPropertyChangedCallback(e,t,n,i){switch(e){case"items":this._adjustFocusIndex();break;case"index":this._element.dispatchEvent(new Nb({currentIndex:n,previousIndex:t}));break}}itemPropertyChangedCallback(e,t,n,i,s){}initializeCallback(){}destroyCallback(){}initialize(e){this._element!=null&&this.destroy(),e!=null&&(this._element=e,this._element.addEventListener(hd,this._propertyChangeHandler,!1)),this.initializeCallback()}destroy(){this._element!=null&&this._element.removeEventListener(hd,this._propertyChangeHandler,!1),this.destroyCallback()}disconnectedCallback(){this.destroy(),super.disconnectedCallback()}_adjustFocusIndex(){let e=this._element.items,t=this._element.index,n=e&&e.length,i=n?Math.max(0,Math.min(n-1,t)):-1,s=this._getAvailable(i);this._element.index=s}_getNextAvailable(e){return this._getAvailable(e,1)}_getPreviousAvailable(e){return this._getAvailable(Math.max(0,e),-1)}_getAvailable(e=this._element&&this._element.index,t=0){let n=this._element.items,i;if(!(n&&(i=n.length)>0))return-1;e=e%i;let s=(e+t+i)%i,o;for(t=t||-1;(o=n[s])instanceof K&&o.disabled===!0||o instanceof Xt&&o.hide===!0;)if(s=(s+t+i)%i,s==e)return-1;return s}isClose(e){let t=this._getAvailable();return e===t||e===this._getPreviousAvailable(t)||e===this._getNextAvailable(t)}isPrevious(e){let t=this._getAvailable();return e===this._getPreviousAvailable(t)}isNext(e){let t=this._getAvailable();return e===this._getNextAvailable(t)}select(e){this._element.index=this._getAvailable(e)}previous(e=!0){var t=this._getPreviousAvailable(this._element.index);t>=0&&(e||this._element.index>t)&&(this._element.index=t)}next(e=!0){var t=this._getNextAvailable(this._element.index);t>=0&&(e||this._element.index<t)&&(this._element.index=t)}};var yf=class extends HTMLElement{constructor(){super()}connectedCallback(){this.remove()}};yf=l([W({tagName:F+"-annihilator"})],yf);var gd=class extends K{constructor(){super(...arguments);this._unloadingHandler=e=>{let t=this.message;!this.active||this.disabled||(e.type==="beforeunload"?(e.preventDefault(),e.returnValue=t||""):confirm(t||"Leave page?")||e.preventDefault())}}viewActivatedCallback(){super.viewActivatedCallback(),window.addEventListener("navigating",this._unloadingHandler,!1),window.addEventListener("beforeunload",this._unloadingHandler,!1)}disconnectedCallback(){window.removeEventListener("navigating",this._unloadingHandler,!1),window.removeEventListener("beforeunload",this._unloadingHandler,!1),super.disconnectedCallback()}};l([M({emit:!1,converter:S.String})],gd.prototype,"message",2),l([M({emit:!1,converter:S.Boolean})],gd.prototype,"active",2),gd=l([W({tagName:F+"-beforeunload"})],gd);var Au,Ha=class extends K{constructor(){super(...arguments);this.autosend=!0;this._messageHandler=e=>{this.result=e.data,this.dispatchEvent(new CustomEvent("receive",{detail:e.data,bubbles:!1,cancelable:!1}))};this._errorHandler=e=>{this.dispatchEvent(new CustomEvent("error",{detail:e.data,bubbles:!1,cancelable:!1}))};$(this,Au)}viewActivatedCallback(){super.viewActivatedCallback(),this._initializeChannel()}propertyChangedCallback(e,t,n,i){if(super.propertyChangedCallback(e,t,n,i),!i)switch(e){case"src":this._disposeChannel(),this._initializeChannel(n);break;case"autosend":case"disabled":case"message":this.autosend&&this.send(this.message);break}}disconnectedCallback(){this._disposeChannel(),super.disconnectedCallback()}send(e=this.message){if(this.disabled)return;let t=x(this,Au);y.isNull(t)||t.postMessage(e)}_initializeChannel(e=this.channelName){if(!y.isNullOrEmpty(e)){let t=A(this,Au,new BroadcastChannel(e));t.addEventListener("message",this._messageHandler,!1),t.addEventListener("messageerror",this._errorHandler,!1),this.autosend&&!y.isNull(this.message)&&this.send()}}_disposeChannel(e=x(this,Au)){y.isNull(e)||(e.removeEventListener("messageerror",this._errorHandler,!1),e.removeEventListener("message",this._messageHandler,!1),e.close())}};Au=new WeakMap,l([M({emit:!1,converter:S.String})],Ha.prototype,"message",2),l([M({converter:S.String})],Ha.prototype,"result",2),l([M({emit:!1,converter:S.String})],Ha.prototype,"channelName",2),l([M({emit:!1,reflectBack:!0,converter:S.Boolean})],Ha.prototype,"autosend",2),Ha=l([W({tagName:F+"-broadcastchannel-proxy"})],Ha);import{detect as xP}from"@pacem/pacem-foundation";var _f,xf,Du=class extends K{constructor(){super(...arguments);$(this,_f);$(this,xf)}viewActivatedCallback(){super.viewActivatedCallback(),this._detect()}propertyChangedCallback(e,t,n,i){super.propertyChangedCallback(e,t,n,i),e==="userAgent"&&this._detect(n)}get browser(){return x(this,_f)}get version(){return x(this,xf)}_detect(e=this.userAgent){let{version:t,name:n}=xP(e),{browser:i,version:s}=this;n!=i&&(A(this,_f,n),this.dispatchEvent(new ji({propertyName:"browser",currentValue:n,oldValue:i}))),t!=s&&(A(this,xf,t),this.dispatchEvent(new ji({propertyName:"version",currentValue:t,oldValue:s})))}};_f=new WeakMap,xf=new WeakMap,l([M({emit:!1,converter:S.String})],Du.prototype,"userAgent",2),Du=l([W({tagName:F+"-browser-detect"})],Du);var IC="_exp",$b=class{_getStorage(r){return r?window.localStorage:window.sessionStorage}_parseValue(r,e){let t=r.getItem(e);if(y.isNullOrEmpty(t))return null;let n=y.Json.parse(t);return Object.hasOwnProperty(IC)?n[IC]<Date.now()?(r.removeItem(e),null):n.value:n}setPropertyValue(r,e,t){var n=this._getStorage(t===!0||typeof t=="number"&&t>0),i=e;if(typeof t=="number"&&t>0){let s=Date.now()+1e3*t;i={value:e},i[IC]=s}n.setItem(r,y.Json.stringify(i)),n=this._getStorage(!t),n.removeItem(r)}getPropertyValue(r){return this._parseValue(this._getStorage(!1),r)||this._parseValue(this._getStorage(!0),r)}clear(){var r=this._getStorage(!0);r.clear(),r=this._getStorage(!1),r.clear()}removeProperty(r){var e=this._getStorage(!0);e.removeItem(r),e=this._getStorage(!1),e.removeItem(r)}};var Ba=class extends K{constructor(e=new $b){super();this.storage=e;this._handle=0;this._flag=!1}propertyChangedCallback(e,t,n,i){switch(super.propertyChangedCallback(e,t,n,i),e){case"persistAs":y.isNullOrEmpty(t)||this.storage.removeProperty(t),i===!0&&!y.isNullOrEmpty(n)&&(this.model=this.storage.getPropertyValue(n)??this.model);break;case"model":let s=this.debounce,o=this.throttle,c=()=>{this.dispatchEvent(new ji({propertyName:e,oldValue:t,currentValue:n,firstChange:i}))};if(s>0&&!i)if(o){if(this._flag)return;this._flag=!0,c(),this._handle=window.setTimeout(()=>{this._flag=!1},s)}else clearTimeout(this._handle),this._handle=window.setTimeout(c,s);else c();!i&&!y.isNullOrEmpty(this.persistAs)&&(y.isNull(n)?this.storage.removeProperty(this.persistAs):this.storage.setPropertyValue(this.persistAs,n,!0));break}}};l([M({emit:!1,converter:S.Eval})],Ba.prototype,"model",2),l([M({emit:!1,converter:S.String})],Ba.prototype,"persistAs",2),l([M({emit:!1,converter:S.Number})],Ba.prototype,"debounce",2),l([M({emit:!1,converter:S.BooleanStrict})],Ba.prototype,"throttle",2),Ba=l([W({tagName:F+"-data"})],Ba);var Hb=Math.PI*.5,vd={linear:a=>a,sineIn:a=>Math.sin(a*Hb-Hb)+1,sineOut:a=>Math.sin(a*Hb),sineInOut:a=>.5*Math.sin(a*Math.PI-Hb)+.5,expoIn:a=>(Math.pow(Math.E,a)-1)/(Math.E-1),expoOut:a=>Math.log(a*(Math.E-1)+1),expoInOut:a=>a<.5?.5*Yi.expoIn(a*2):.5*(1+Yi.expoOut(a*2-1))};function bd(a,r){let e=t=>a(t);return e.css=r,e}var Yi={linear:bd(vd.linear,"linear"),sineIn:bd(vd.sineIn,"cubic-bezier(0.12, 0, 0.39, 0)"),sineOut:bd(vd.sineOut,"cubic-bezier(0.61, 1, 0.88, 1)"),sineInOut:bd(vd.sineInOut,"cubic-bezier(0.37, 0, 0.63, 1)"),expoIn:bd(vd.expoIn,"cubic-bezier(0.7, 0, 0.84, 0)"),expoOut:bd(vd.expoOut,"cubic-bezier(0.16, 1, 0.3, 1)"),expoInOut:bd(vd.expoInOut,"cubic-bezier(0.87, 0, 0.13, 1)")};var Sl=class{run(r,e,t,n=0,i=Yi.linear,s=null){return new Promise((o,c)=>{let p=(performance&&performance.now()||Date.now())+Math.abs(n||0),u=p+Math.abs(t||0),h=()=>{let m=performance&&performance.now()||Date.now();if(m>=p&&m<u){let f=(m-p)/t,g=r+(i||Yi.linear)(f)*(e-r);s&&s(f,g)}m<u?requestAnimationFrame(h):(s&&s(1,e),o())};h()})}};var zM=(e=>(e.Top="top",e.Bottom="bottom",e))(zM||{}),$s=class extends K{constructor(e=new Sl){super();this._tweener=e;this.mode="top";this.transitionDuration=300}propertyChangedCallback(e,t,n,i){super.propertyChangedCallback(e,t,n,i),e==="dock"&&(!y.isNull(t)||n!=!1)?this._doDock():e==="mode"&&this.dock===!0&&this._doDock()}_animate(e,t){var n=this.transitionDuration;return n>0||(n=300),this._tweener.run(e,t,n,this.delay,Yi.sineInOut,(i,s)=>{this._setOffset(s)}).then(()=>{this._resetOffset()})}_setOffset(e){this.style.transform="translateY("+e+"px)"}_resetOffset(){this.style.transform=""}_compute(){let e=y.offset(this),t=getComputedStyle(this),n=y.scrollTop;switch(this.mode){case"bottom":let i=parseInt(t.marginBottom),s=e.top;return{delta:y.windowSize.height-(s-n+this.offsetHeight)+i};case"top":let c=parseInt(t.marginTop);return{delta:-(e.top-n+c)}}}_doDock(){if(this.dock){let t=this._compute();if(y.isNull(t))return;switch(y.addClass(this,re+"-dock"),this.mode){case"bottom":y.removeClass(this,re+"-dock-top"),y.addClass(this,re+"-dock-bottom");break;case"top":y.removeClass(this,re+"-dock-bottom"),y.addClass(this,re+"-dock-top");break}let n=-t.delta,i=0,s=j.getAttachedPropertyValue(this,"pacem-dock:state")||0;j.setAttachedPropertyValue(this,"pacem-dock:state",-n+s),this.log("info",`animating from ${n}px to ${i}px`),this._animate(n,i)}else{let t=j.getAttachedPropertyValue(this,"pacem-dock:state");j.deleteAttachedPropertyValue(this,"pacem-dock:state");let n=0;this.log("info",`animating back from ${t}px to ${n}px`),y.removeClass(this,`${re}-dock ${re}-dock-top ${re}-dock-bottom`),this._animate(t,n)}}};l([M({emit:!1,converter:S.String})],$s.prototype,"mode",2),l([M({converter:S.Boolean})],$s.prototype,"dock",2),l([M({emit:!1,converter:S.Element})],$s.prototype,"target",2),l([M({emit:!1,converter:S.Number})],$s.prototype,"delay",2),l([M({emit:!1,converter:S.Number})],$s.prototype,"transitionDuration",2),$s=l([W({tagName:F+"-dock"})],$s);var Ou=class extends K{constructor(){super(...arguments);this._dom=[];this._children=[]}get dom(){return this._children}viewActivatedCallback(){super.viewActivatedCallback(),this.moveContent(this.proxy)}moveContent(e){y.isNull(e)||(y.isNullOrEmpty(this._dom)?(this._dom=y.moveItems(this.childNodes,e),this._children=this._dom.filter(t=>t instanceof Element)):y.moveItems(this._children,e))}disconnectedCallback(){for(let e of(this._dom||[]).splice(0))e.remove();super.disconnectedCallback()}},Cf=class extends Ou{get proxy(){return document.body}};Cf=l([W({tagName:F+"-body-proxy"})],Cf);var Ef=class extends Ou{get proxy(){return j.findAncestorShell(this)}};Ef=l([W({tagName:F+"-shell-proxy"})],Ef);var Ru=class extends Ou{get proxy(){return this.target}propertyChangedCallback(r,e,t,n){super.propertyChangedCallback(r,e,t,n),r==="target"&&!n&&this.moveContent(this.proxy)}};l([M({converter:S.Element})],Ru.prototype,"target",2),Ru=l([W({tagName:F+"-element-proxy"})],Ru);var $C=class extends Event{constructor(e){super("emit");this._originalEvent=e}get originalEvent(){return this._originalEvent}},CP={convert:function(a,r){return a==="$window"?window:S.Element.convert(a,r)},convertBack:(a,r)=>a===window?"$window":S.Element.convertBack(a,r)},Ll=class extends K{constructor(){super(...arguments);this._emitHandler=e=>{var t=new $C(e);this.dispatchEvent(t)}}viewActivatedCallback(){super.viewActivatedCallback(),this._observe()}propertyChangedCallback(e,t,n,i){if(super.propertyChangedCallback(e,t,n,i),!i)switch(e){case"target":this._unobserve(t,this.event,this.capture),this._observe();break;case"event":this._unobserve(this.target,t,this.capture),this._observe();break;case"capture":this._unobserve(this.target,this.event,t),this._observe();break}}disconnectedCallback(){this._unobserve(),super.disconnectedCallback()}_unobserve(e=this.target,t=this.event,n=this.capture){y.isNull(e)||y.isNullOrEmpty(t)||e.removeEventListener(t,this._emitHandler,{capture:n})}_observe(e=this.target,t=this.event,n=this.capture){y.isNull(e)||y.isNullOrEmpty(t)||e.addEventListener(t,this._emitHandler,{capture:n})}};l([M({emit:!1,converter:CP})],Ll.prototype,"target",2),l([M({emit:!1,converter:S.String})],Ll.prototype,"event",2),l([M({emit:!1,converter:S.Boolean})],Ll.prototype,"capture",2),Ll=l([W({tagName:F+"-event-proxy"})],Ll);var GM="New incoming request overrides the ongoing one. Aborting.",Nl,wf,Pt=class extends K{constructor(){super(...arguments);this.autofetch=!0;this.debounce=100;$(this,Nl);$(this,wf)}viewActivatedCallback(){super.viewActivatedCallback(),this._delayAndConditionallyFetch()}propertyChangedCallback(e,t,n,i){switch(super.propertyChangedCallback(e,t,n,i),e){case"url":case"method":case"type":case"as":case"mode":case"credentials":case"disabled":case"autofetch":this._delayAndConditionallyFetch();break;case"parameters":case"headers":(!this.diffByValues||y.jsonSortStringify(t)!=y.jsonSortStringify(n))&&this._delayAndConditionallyFetch();break}}_delayAndConditionallyFetch(){clearTimeout(this._handle),this.disabled?this._abortPending():this.autofetch&&(this._handle=setTimeout(()=>{this.fetch()},this.debounce||0))}_abortPending(){x(this,Nl)&&(x(this,Nl).abort(GM),A(this,Nl,null))}fetch(){return this.throttle&&this.fetching?x(this,wf):A(this,wf,new Promise((e,t)=>{var n=this.url;if(!this.isReady||y.isNullOrEmpty(n)||this.disabled){e(null);return}let i=this;i.fetching=!0;let s=i.type||"json",o="application/json";s==="raw"&&(o="application/x-www-form-urlencoded");let c=(i.method||"GET").toUpperCase(),d={headers:y.extend({"Content-Type":o},i.headers),method:c,mode:i.mode||"cors",credentials:i.credentials||"same-origin",cache:i.cache||"default"},p=y.clone(i.parameters??{});if(n=y.URIs.format(n,p,c=="GET"),!y.isNullOrEmpty(p))switch(c){case"GET":n=y.URIs.appendQuery(n,p);break;case"PUT":case"POST":case"PATCH":switch(i.type){case"raw":let h=new URLSearchParams;for(let m in p)h.set(m,p[m]);d.body=h;break;default:d.body=y.Json.stringify(p);break}break}if(y.URIs.hasMandatoryTemplateSegments(n)){e(null);return}this._abortPending();let{signal:u}=A(this,Nl,new AbortController);d.signal=u,fetch(n,d).then(h=>{if(A(this,Nl,null),i.fetching=!1,h.ok)if(this.dispatchEvent(new CustomEvent(RM,{detail:h})),Db.isEmpty(h)){switch(i.as){case"blob":case"image":i.result=null;break;case"text":i.result=null;break;default:i.result=null;break}e(h)}else switch(i.as){case"blob":case"image":h.blob().then(f=>{i.as==="image"?y.blobToDataURL(f).then(g=>{i._acceptFetchResult(g)}):i._acceptFetchResult(f),e(h)},f=>{this.log("warn",`Couldn't parse a ${i.as}. ${f}`),e(null)});break;case"text":h.text().then(f=>{i._acceptFetchResult(f),e(h)});break;default:h.json().then(f=>{i._acceptFetchResult(f),e(h)},f=>{this.log("warn",`Couldn't parse a ${i.as}. ${f}`),e(null)});break}else this.dispatchEvent(new CustomEvent(DM,{detail:h})),t(h)},h=>{typeof h=="string"&&h===GM?(this.log("info",h),e(null)):t(h)})}))}_acceptFetchResult(e){this.dispatchEvent(new CustomEvent(AM,{detail:e})),this.result=e}};Nl=new WeakMap,wf=new WeakMap,l([M({emit:!1,reflectBack:!0,converter:S.String})],Pt.prototype,"url",2),l([M({emit:!1,reflectBack:!0,converter:S.String})],Pt.prototype,"method",2),l([M({emit:!1,converter:S.Json})],Pt.prototype,"parameters",2),l([M({emit:!1,converter:S.Json})],Pt.prototype,"headers",2),l([M({emit:!1,converter:S.String})],Pt.prototype,"credentials",2),l([M({emit:!1,converter:S.String})],Pt.prototype,"mode",2),l([M({emit:!1,converter:S.String})],Pt.prototype,"cache",2),l([M({converter:S.BooleanStrict})],Pt.prototype,"fetching",2),l([M({reflectBack:!0,converter:S.Boolean})],Pt.prototype,"autofetch",2),l([M({emit:!1,converter:S.String})],Pt.prototype,"as",2),l([M({emit:!1,converter:S.String})],Pt.prototype,"type",2),l([M({reflectBack:!0,converter:S.Number})],Pt.prototype,"debounce",2),l([M({emit:!1,reflectBack:!0,converter:S.Number})],Pt.prototype,"throttle",2),l([M({emit:!1,reflectBack:!0,converter:S.Boolean})],Pt.prototype,"diffByValues",2),l([M()],Pt.prototype,"result",2),Pt=l([W({tagName:F+"-fetch"})],Pt);import{HistoryService as EP}from"@pacem/pacem-foundation";var Bb=class extends CustomEvent{constructor(r,e){super(r,{detail:e})}},Hs,Va=class extends K{constructor(){super(...arguments);$(this,Hs)}propertyChangedCallback(e,t,n,i){switch(super.propertyChangedCallback(e,t,n,i),e){case"state":this._handleStateChange(n);break;case"maxlength":let s=x(this,Hs);y.isNull(s)||(s.maxlength=n);break}}viewActivatedCallback(){super.viewActivatedCallback(),this._handleStateChange()}_handleStateChange(e=this.state){let t=x(this,Hs);y.isNull(t)?A(this,Hs,new EP(e,this.maxlength)):Pb(t.current,e)!==!0&&(t.push(e),this.log("log","Pushed state."),this._synchronize("push"))}redo(){let e=x(this,Hs);y.isNull(e)||(e.redo(),this.log("log","Redone state."),this._synchronize("redo"))}reset(){let e=x(this,Hs);y.isNull(e)||(e.reset(),this.log("log","Reset state."),this._synchronize("reset"))}undo(){let e=x(this,Hs);y.isNull(e)||(e.undo(),this.log("log","Undone state."),this._synchronize("undo"))}_synchronize(e){let t=x(this,Hs);this.canUndo=t.canUndo,this.canRedo=t.canRedo,this.state=t.current;let{canRedo:n,canUndo:i,current:s}=t;this.dispatchEvent(new Bb(e,{canRedo:n,canUndo:i,state:s}))}};Hs=new WeakMap,l([M({emit:!0,converter:S.Json})],Va.prototype,"state",2),l([M({emit:!1,converter:S.Number})],Va.prototype,"maxlength",2),l([M({emit:!0,converter:S.Boolean})],Va.prototype,"canUndo",2),l([M({emit:!0,converter:S.Boolean})],Va.prototype,"canRedo",2),Va=l([W({tagName:F+"-history"})],Va);var yd=class extends K{constructor(){super(...arguments);this._html=document.documentElement}propertyChangedCallback(e,t,n,i){super.propertyChangedCallback(e,t,n,i),e==="attr"&&t&&this._html.removeAttribute(t),this._update()}_update(){let e=this.attr;if(y.isNullOrEmpty(e)||this.disabled)return;let t=this.value,n=this._html;y.isNullOrEmpty(t)?n.removeAttribute(e):n.setAttribute(e,t)}};l([M({emit:!1,converter:S.String})],yd.prototype,"attr",2),l([M({emit:!1,converter:S.String})],yd.prototype,"value",2),yd=l([W({tagName:F+"-html-proxy"})],yd);var Iu,Pu=class extends HTMLElement{constructor(){super(...arguments);$(this,Iu)}propertyChangedCallback(e,t,n,i){y.isNullOrEmpty(x(this,Iu))&&A(this,Iu,this.innerHTML),n?this.innerHTML=x(this,Iu):this.innerHTML=""}};Iu=new WeakMap,l([M({emit:!1,converter:S.Boolean})],Pu.prototype,"match",2),Pu=l([W({tagName:F+"-if"})],Pu);var Tl=class extends Xt{get container(){return this._container}findContainer(){return j.findAncestor(this,r=>r instanceof Bs)}viewActivatedCallback(){super.viewActivatedCallback();let r=this._container=this.findContainer();y.isNull(r)||r.register(this)}disconnectedCallback(){y.isNull(this._container)||this._container.unregister(this),super.disconnectedCallback()}};function wP(a){return"items"in a&&(y.isNull(a.items)||y.isArray(a.items))&&typeof a.register=="function"&&typeof a.unregister=="function"}var FM="itemregister",WM="itemunregister",Vb=class extends st{constructor(r,e){super(FM,r,e)}},Ub=class extends st{constructor(r,e){super(WM,r,e)}},zb=class{constructor(r){this._container=r;if(r==null||!(r instanceof Bs||r instanceof kf))throw"Must provide a valid itemscontainer."}register(r){let e=this._container;var t=!1;return e.validate(r)?y.isNull(e.items)?(e.items=[r],t=!0):e.items.indexOf(r)===-1&&(e.items.push(r),t=!0):e.logger&&e.logger.log("debug",`${r&&r.localName} element couldn't be registered in a ${e.localName} element.`),t&&e.dispatchEvent(new Vb(r)),t}unregister(r){let e=this._container;if(!y.isNull(e.items)){let t=e.items.indexOf(r);if(t>=0){let n=e.items.splice(t,1);return e.dispatchEvent(new Ub(n[0])),!0}}return!1}},kf=class extends Tl{constructor(r,e){super(r,e),this._registrar=new zb(this)}register(r){return this._registrar.register(r)}unregister(r){return this._registrar.unregister(r)}};l([M()],kf.prototype,"items",2);var Bs=class extends Xt{constructor(r,e){super(r,e),this._registrar=new zb(this)}register(r){return this._registrar.register(r)}unregister(r){return this._registrar.unregister(r)}};l([M()],Bs.prototype,"items",2);var HC=class extends Tl{findContainer(){return j.findAncestor(this,r=>r instanceof $u)}propertyChangedCallback(r,e,t,n){super.propertyChangedCallback(r,e,t,n);let i=this.container,s=(i&&i.items||[]).indexOf(this);s>=0&&i&&i.adapter&&i.adapter.itemPropertyChangedCallback(s,r,e,t,n)}},$u=class extends Bs{propertyChangedCallback(r,e,t,n){switch(super.propertyChangedCallback(r,e,t,n),this.adapter&&this.adapter.masterPropertyChangedCallback(r,e,t,n),r){case"adapter":y.isNull(e)||e.destroy(),y.isNull(t)||this.adapter.initialize(this);break;case"items":this.isReady&&this._checkIndex();break}}viewActivatedCallback(){super.viewActivatedCallback(),this._checkIndex()}_checkIndex(){let r=0;y.isNullOrEmpty(this.items)||this.index<this.items.length&&(r=this.index),this.index=r}disconnectedCallback(){y.isNull(this.adapter)||this.adapter.destroy(),super.disconnectedCallback()}};l([M({emit:!1,converter:S.Element})],$u.prototype,"adapter",2),l([M({converter:S.Number})],$u.prototype,"index",2);var jM="false",kP="true",Mf,_d=class extends K{constructor(){super(...arguments);$(this,Mf)}connectedCallback(){super.connectedCallback(),A(this,Mf,j.findAncestorShell(this))}propertyChangedCallback(e,t,n,i){super.propertyChangedCallback(e,t,n,i),this._update()}disconnectedCallback(){let e=this.attr;y.isNullOrEmpty(e)||this._update(e,jM,!1),super.disconnectedCallback()}_update(e=this.attr,t=this.value?.toString(),n=this.disabled){if(y.isNullOrEmpty(e)||n)return;let i=x(this,Mf);y.isNull(i)||(y.isNullOrEmpty(t)||t===jM?i.removeAttribute(e):i.setAttribute(e,t===kP?"":t))}};Mf=new WeakMap,l([M({emit:!1,converter:S.String})],_d.prototype,"attr",2),l([M({emit:!1,converter:S.String})],_d.prototype,"value",2),_d=l([W({tagName:F+"-layout-proxy"})],_d);var Ua=class extends K{propertyChangedCallback(r,e,t,n){super.propertyChangedCallback(r,e,t,n),this._update()}viewActivatedCallback(){super.viewActivatedCallback(),this._update()}_update(){let r=this.content,e=!y.isNullOrEmpty(this.name),t=e?this.name:this.itemprop;if(y.isNullOrEmpty(t)||this.disabled)return;let n=y.cssEscape(t),i=e?`meta[name='${n}']`:`meta[itemprop='${n}']`;var s=document.head.querySelector(i);if(y.isNull(s))s=document.createElement("meta"),document.head.appendChild(s);else if(y.isNullOrEmpty(r)){s.remove();return}s.setAttribute("content",r),s.setAttribute(e?"name":"itemprop",t),s.removeAttribute(e?"itemprop":"name")}};l([M({emit:!1,converter:S.String})],Ua.prototype,"name",2),l([M({emit:!1,converter:S.String})],Ua.prototype,"itemprop",2),l([M({emit:!1,converter:S.String})],Ua.prototype,"content",2),l([Ib(!0)],Ua.prototype,"_update",1),Ua=l([W({tagName:F+"-meta-proxy"})],Ua);var Hu=class extends K{constructor(){super(...arguments);this._onlineHandler=e=>{y.isNull(e)?this.online=navigator.onLine||!1:this.online=e.type==="online"}}connectedCallback(){super.connectedCallback(),window.addEventListener("online",this._onlineHandler,!1),window.addEventListener("offline",this._onlineHandler,!1)}viewActivatedCallback(){super.viewActivatedCallback(),this._onlineHandler()}disconnectedCallback(){window.removeEventListener("online",this._onlineHandler,!1),window.removeEventListener("offline",this._onlineHandler,!1),super.disconnectedCallback()}};l([M({converter:S.Boolean})],Hu.prototype,"online",2),Hu=l([W({tagName:F+"-online-status"})],Hu);var Sf=class extends fd{};Sf=l([W({tagName:F+"-panel"})],Sf);var Gb="command";var Vs=class extends Su{propertyChangedCallback(r,e,t,n){r==="target"&&this.dispatchEvent(new Event("templatechange"))}addEventListener(r,e,t){super.addEventListener(r,e,t)}removeEventListener(r,e,t){super.removeEventListener(r,e,t)}};l([M({emit:!1,converter:S.Element})],Vs.prototype,"target",2),Vs=l([W({tagName:F+"-template-proxy"})],Vs);var MP=j.getAttachedPropertyValue,RY=j.setAttachedPropertyValue,Fb=class extends st{constructor(e,t,n){super(e,t,{bubbles:!1,cancelable:!0});this._originalEvent=n}get srcEvent(){return this._originalEvent}},Wb=class extends Fb{constructor(r){super("item"+Gb,r.detail,r)}},jb=class extends Fb{constructor(r){super("item"+r.detail.commandName.toLowerCase(),r.detail.commandArgument,r)}},Xi=class extends K{constructor(){super(...arguments);this._childItems=[];this._fragment=document.createDocumentFragment();this._setupItem=(e,t,n)=>{e.index=t,e.item=n};this._refreshItemTemplateHandler=e=>{let t=e.target;this._itemTemplate=t.target,this._databind()}}removeItem(e){this._removeItems(e,e)}_setItem(e,t,n){let i=this._childItems,s;t>=i.length?(s=new Bu(this,this._itemTemplate,n,this._childTemplatePlaceholder),this._setupItem(s,t,e),i.push(s),s.append()):(s=i[t],this._setupItem(s,t,e),s.redrawEventually(this._itemTemplate,n)),this.dispatchEvent(new vf(s))}_removeItems(e,t){let i=this._childItems.splice(e,t+1-e);for(var s=i.length-1;s>=0;s--){let o=i[s];this.dispatchEvent(new bf(o)),o.remove()}}databind(){this._databind()}_databind(e=this.datasource){if(!this.isConnected)return;let t=this._itemTemplate,n=this._childTemplatePlaceholder;if(t==null)throw`Missing template element in ${Xi.name}.`;let i=this._childItems,s=0;try{for(var o of e||[])this._setItem(o,s,this._fragment),s++}catch(c){this.log("error",c)}s<i.length?this._removeItems(s,i.length-1):y.isNull(n&&n.parentNode)||n.parentNode.insertBefore(this._fragment,n)}_onCommand(e){this.dispatchEvent(new Wb(e)),this.dispatchEvent(new jb(e))}_buildupItemTemplate(){let e=j.findFirstDescendant(this,t=>t instanceof HTMLTemplateElement||t instanceof Vs);return e instanceof Vs?(e.addEventListener("templatechange",this._refreshItemTemplateHandler,!1),this._childTemplatePlaceholder=e,this._itemTemplate=e.target):this._itemTemplate=this._childTemplatePlaceholder=e}viewActivatedCallback(){super.viewActivatedCallback(),this.addEventListener(Gb,this._onCommand,!1),this._buildupItemTemplate()&&this._databind()}disconnectedCallback(){let e=this._childTemplatePlaceholder;!y.isNull(e)&&e instanceof Vs&&e.removeEventListener("templatechange",this._refreshItemTemplateHandler,!1),this.removeEventListener(Gb,this._onCommand,!1),this.datasource=[],super.disconnectedCallback()}propertyChangedCallback(e,t,n,i){super.propertyChangedCallback(e,t,n,i),e==="datasource"&&(y.isNull(this._itemTemplate)||this._databind(n))}};l([M({emit:!1,converter:S.Eval})],Xi.prototype,"datasource",2),Xi=l([W({tagName:F+"-repeater"})],Xi);var Bu=class extends Ia{constructor(e,t,n,i){super(document.createComment("pacem-repeater-item"));this._repeater=e;this._template=t;this._fragment=n;this._holder=i;this._alterEgos=[];let s="_";function o(d,p){var u=this,h=s+d;if(p!==u[h]){var m=u[h];u[h]=p;var f=new ji({propertyName:d,oldValue:m,currentValue:p});u.dispatchEvent(f)}}let c=this.placeholder;Object.defineProperties(c,{item:{get:function(){return this[s+"item"]},set:function(d){o.apply(c,["item",d])},configurable:!0},index:{get:function(){let d=this[s+"index"];return y.isNull(d)?-1:d},set:function(d){o.apply(c,["index",d])},configurable:!0}})}append(){let e=this._template,t=this._fragment;this._alterEgos.push(t.appendChild(this.placeholder));let n=e.cloneNode(!0);var i;y.isNull(i=MP(this._repeater,md))||j.assignHostContext(i,n);var s=n.content.childNodes;Array.prototype.push.apply(this._alterEgos,s),t.appendChild(n.content)}redrawEventually(e,t){if(e===this._template)return;this._fragment=t,this._template=e;let n=this._holder.parentElement,i=this._alterEgos;for(;i.length>0;)n.removeChild(i.pop());this.append()}get dom(){return this._alterEgos.filter(e=>!(e instanceof Comment||e instanceof Text))}get repeater(){return this._repeater}remove(){let e=this._holder.parentElement;for(var t of this._alterEgos)t.parentElement===e&&!y.isNull(e)&&e.removeChild(t)}get index(){return this.placeholder.index}set index(e){this.placeholder.index=e}get item(){return this.placeholder.item}set item(e){this.placeholder.item=e}};var XM="resize",Yb=class extends st{constructor(r){super(XM,r)}},YM={box:"border-box"},xd=class extends K{constructor(){super(...arguments);this._checkSizeHandler=()=>{this._assignSizeDebounced()}}get _target(){return this.target||this}propertyChangedCallback(e,t,n,i){switch(super.propertyChangedCallback(e,t,n,i),e){case"disabled":this._start();break;case"target":if(!y.isNull(this._observer)){var s=t||this;this._observer.unobserve(s)}case"watchPosition":var o=this.target||this;y.isNull(this._observer)||this._observer.observe(o,YM);break}}_start(){if(this.disabled){this._stop();return}this.watchPosition?this._startWatchIntensively():(this._observer=new ResizeObserver(e=>{var t=!1;for(let n of e)if(n.target===this._target&&n.contentRect){t=!0;break}t&&this._assignSizeDebounced()}),this._observer.observe(this._target,YM)),window.addEventListener("resize",this._checkSizeHandler,!1)}_stop(){window.cancelAnimationFrame(this._handle),window.removeEventListener("resize",this._checkSizeHandler,!1),y.isNull(this._observer)||(this._observer.disconnect(),this._observer=null)}_startWatchIntensively(){this._checkSize(),this._handle=window.requestAnimationFrame(()=>{this._startWatchIntensively()})}_assignSizeDebounced(){this._checkSize()}_checkSize(){this.log("log","Resize flow triggered.");let e=this._target,t=y.offset(e),n=t.height,i=t.width;(n!=this._previousHeight||i!=this._previousWidth||this.watchPosition&&(t.left!=this._previousLeft||t.top!=this._previousTop))&&(this._previousHeight=n,this._previousWidth=i,this._previousLeft=t.left,this._previousTop=t.top,this._dispatchResize())}get currentSize(){var e={height:this._previousHeight,width:this._previousWidth};return this.watchPosition&&(e.left=this._previousLeft,e.top=this._previousTop),e}_dispatchResize(){this.dispatchEvent(new Yb(this.currentSize))}connectedCallback(){super.connectedCallback(),this._start()}disconnectedCallback(){this._stop(),super.disconnectedCallback()}};l([M({emit:!1,converter:S.Element})],xd.prototype,"target",2),l([M({emit:!1,converter:S.Boolean})],xd.prototype,"watchPosition",2),xd=l([W({tagName:F+"-resize"})],xd);var qM="navigating",KM="navigate",Xb=class extends st{constructor(r){super(KM,typeof r=="string"?{path:r}:r,{cancelable:!1,bubbles:!1})}},qb=class extends st{constructor(r){super(qM,r,{cancelable:!0,bubbles:!1})}},SP=/^([\w\.]:)?\/\/[^\/]+/,Cd,Ed,Al=class extends K{constructor(){super(...arguments);$(this,Cd);$(this,Ed);this._onPopState=e=>{!y.isNull(e.state)&&!x(this,Cd)&&(this.path=e.state.$path)}}parseState(e={}){let t=this._stringifyMergedState(e),n=this._segmentateUrl(t);return this._parseState(n.path+n.query+n.hash,n.path,n.query,n.hash)}navigate(e,t){if(this.disabled||y.isNullOrEmpty(e))return;if(typeof e=="object"?e=this._stringifyMergedState(e):e=y.URIs.format(e,this.state),e!=this.path){this.path=e;return}let n=document.location;if(SP.test(e)&&!e.startsWith(n.protocol+"//"+n.host))throw`Only same-origin navigation is currently supported. "${e}" is not a valid path.`;if(!x(this,Cd)){let i=this.state&&this.state.$path||void 0,s=this._segmentateUrl(e),o=this._parseState(s.path+s.query+s.hash,s.path,s.query,s.hash),c=n.pathname+n.search+n.hash===s.path+s.query+s.hash,d=new qb(e);if(window.dispatchEvent(d),A(this,Cd,d.defaultPrevented)){c&&window.history.pushState(this.state,t,i),this.path=i;return}this.state=o,c?(window.history.scrollRestoration="manual",window.history.replaceState(o,t)):window.history.pushState(o,t,e),y.isNullOrEmpty(t)||(document.title=t),window.dispatchEvent(new Xb({path:e,referrer:i,title:t}))}A(this,Cd,!1)}propertyChangedCallback(e,t,n,i){if(super.propertyChangedCallback(e,t,n,i),!i)switch(e){case"template":A(this,Ed,null);break;case"path":this.navigate(n);break}}connectedCallback(){super.connectedCallback(),window.addEventListener("popstate",this._onPopState,!1)}viewActivatedCallback(){super.viewActivatedCallback();let e=this.path;y.isNullOrEmpty(e)||this.navigate(e)}disconnectedCallback(){window.removeEventListener("popstate",this._onPopState,!1),super.disconnectedCallback()}_stringifyMergedState(e){let t=y.extend({},e),n=y.extend({},this.state,t),i=this.template,s=""+i;for(let d of this._parseTemplate(i)){let p=d.name,u=new RegExp("/{"+p+"\\??}"),h=n[p];delete t[p],s=s.replace(u,y.isNullOrEmpty(h)?"":"/"+h)}let o=y.extend({},this.state.$query);for(let d in t)o[d]=t[d];let{hash:c}=this._segmentateUrl(this.path);return y.URIs.appendQuery(s,o,!0)+c}_parseTemplate(e=this.template){return y.isNullOrEmpty(x(this,Ed))?A(this,Ed,y.URIs.parseRoute(e)):x(this,Ed)}_segmentateUrl(e){let t=y.URIs.split(e);return y.isNullOrEmpty(t.path)?null:t}_parseState(e,t,n,i){let s=this._parseTemplate();return y.URIs.parseState(s,e,t,n,i)}};Cd=new WeakMap,Ed=new WeakMap,l([M({emit:!1,converter:S.String})],Al.prototype,"template",2),l([M({converter:S.Eval})],Al.prototype,"state",2),l([M({emit:!1,converter:S.String})],Al.prototype,"path",2),Al=l([W({tagName:F+"-router"})],Al);var ZM="scroll",Kb=class extends st{constructor(r){super(ZM,r)}},BC=class{constructor(r){this.global=r;this.scrollers=[];this.scrollHandler=r=>{this._scroll(r)}}register(r){let e=this.scrollers;e.indexOf(r)===-1&&(e.push(r),e.length===1&&this.global.addEventListener("scroll",this.scrollHandler,!1),this._scroll())}unregister(r){var e;let t=this.scrollers;(e=t.indexOf(r))!==-1&&(t.splice(e,1),t.length===0&&this.global.removeEventListener("scroll",this.scrollHandler,!1))}_scroll(r){for(var e of this.scrollers){if(y.isNull(e.target)){let t=y.scrollTop,n=y.scrollLeft;e.offset={top:t,left:n}}else{let t=e.target.scrollTop,n=e.target.scrollLeft;e.offset={top:t,left:n}}e.dispatchEvent(new Kb(e.offset))}}},JM=new BC(window),wd=class extends K{viewActivatedCallback(){super.viewActivatedCallback(),JM.register(this)}disconnectedCallback(){JM.unregister(this),super.disconnectedCallback()}};l([M({converter:S.Element})],wd.prototype,"target",2),l([M({converter:S.Json})],wd.prototype,"offset",2),wd=l([W({tagName:F+"-scroll-aware"})],wd);function LP(a){let r="=".repeat((4-a.length%4)%4);a=(a+r).replace(/\-/g,"+").replace(/_/g,"/");let e=window.atob(a),t=new Uint8Array(e.length);for(var n=0;n<e.length;n++)t[n]=e.charCodeAt(n);return t}var za=class extends K{viewActivatedCallback(){super.viewActivatedCallback(),this._tryRegister()}disconnectedCallback(){this._tryUnregister(),super.disconnectedCallback()}propertyChangedCallback(r,e,t,n){switch(super.propertyChangedCallback(r,e,t,n),r){case"pushSubscription":y.isNull(e)||this.dispatchEvent(new CustomEvent("unsubscribe",{detail:e})),y.isNull(t)||this.dispatchEvent(new CustomEvent("subscribe",{detail:t}));break;case"registration":y.isNull(e)||this.dispatchEvent(new CustomEvent("unregister",{detail:e})),y.isNull(t)||this.dispatchEvent(new CustomEvent("register",{detail:t}));break}}_tryUnregister(r=this.registration){return y.isNull(r)?Promise.resolve(!0):r.unregister()}_tryRegister(r=this.src){this._tryUnregister().then(e=>{!y.isNullOrEmpty(r)&&"serviceWorker"in navigator&&navigator.serviceWorker.register(r).then(t=>{this.registration=t,"PushManager"in window&&t.pushManager.getSubscription().then(n=>{this.pushSubscription=n})})})}unsubscribe(r=this.pushSubscription){return new Promise((e,t)=>{if(y.isNull(r))e(!1);else{let n=r===this.pushSubscription;r.unsubscribe().then(i=>{n&&(this.pushSubscription=null),e(i)})}})}subscribe(r=this.publicKey){return new Promise((e,t)=>{typeof r=="string"&&(r=LP(r));let n=this.registration?.pushManager;y.isNull(n)?e(null):n.subscribe({userVisibleOnly:!0,applicationServerKey:r}).then(i=>{Notification.permission==="denied"?e(this.pushSubscription=null):e(this.pushSubscription=i)})})}};l([M()],za.prototype,"registration",2),l([M()],za.prototype,"pushSubscription",2),l([M({emit:!1,converter:S.String})],za.prototype,"src",2),l([M({emit:!1,converter:S.String})],za.prototype,"publicKey",2),za=l([W({tagName:F+"-serviceworker-proxy"})],za);var QM="keydown";function NP(a,r,e=[]){if(y.isNullOrEmpty(r))return!1;let t=/(\w+)\s*\+/,n=[],i;for(;!y.isNullOrEmpty(i=t.exec(r));)r=r.substr(i.index+i[0].length),n.push(i[1]);if(!Yt.matchModifiers(a,n))return!1;let s=r.split(",").map(c=>c.trim().toLowerCase());if(y.isNullOrEmpty(s))return!1;var o=a.key.toLowerCase();return TP(o,s[e.length])?(e.push(o),e.length==s.length?!0:"ongoing"):!1}function TP(a,r){return a===r||a==="escape"&&r==="esc"||a==="backspace"&&r==="back"||a==="control"&&r==="ctrl"||a==="delete"&&(r==="del"||r==="canc")||/^arrow/.test(a)&&r===a.substr(5)}var eS="execute",kd=class extends K{constructor(){super(...arguments);this._accumulator=[];this._shortcutHandler=e=>{switch(NP(e,this.combination,this._accumulator)){case!0:Is(e),this.dispatchEvent(new Event(eS,{bubbles:!1,cancelable:!1}));case!1:this._accumulator.splice(0);break}}}viewActivatedCallback(){super.viewActivatedCallback(),this._addHandler()}propertyChangedCallback(e,t,n,i){super.propertyChangedCallback(e,t,n,i),e==="target"&&!i&&(this._removeHandler(t),this._addHandler(n))}disconnectedCallback(){this._removeHandler(),super.disconnectedCallback()}_removeHandler(e=this.target){(e||window).removeEventListener(QM,this._shortcutHandler,!1)}_addHandler(e=this.target){(e||window).addEventListener(QM,this._shortcutHandler,!1)}};l([M({emit:!1,converter:S.String})],kd.prototype,"combination",2),l([M({emit:!1,converter:S.Element})],kd.prototype,"target",2),kd=l([W({tagName:F+"-shortcut"})],kd);var Vu=class extends fd{propertyChangedCallback(r,e,t,n){super.propertyChangedCallback(r,e,t,n),r==="text"&&!n&&(this.textContent=t)}viewActivatedCallback(){super.viewActivatedCallback(),y.isNull(this.text)||(this.textContent=this.text)}};l([M({converter:S.String})],Vu.prototype,"text",2),Vu=l([W({tagName:F+"-span"})],Vu);var Dl=class extends K{propertyChangedCallback(r,e,t,n){switch(super.propertyChangedCallback(r,e,t,n),r){case"cssText":y.isNull(this._style)||(this.cssReady=!1,this._style.textContent=t,y.isNullOrEmpty(t)?this.cssReady=!0:this._idleWhileReady());break;case"disabled":case"src":this._fetch();break}}viewActivatedCallback(){super.viewActivatedCallback();let r=this._style=document.createElement("style");r.setAttribute("type","text/css"),document.head.appendChild(r),this._fetch()}disconnectedCallback(){y.isNull(this._style)||this._style.remove(),super.disconnectedCallback()}_idleWhileReady(){let r=this._style.sheet,t=setInterval(()=>{try{r.cssRules.length>0&&(clearInterval(t),j.Theme.importWebFonts().then(n=>{this.cssReady=!0,this.dispatchEvent(new Event("cssready"))}))}catch{}},100)}_fetch(){let r=this.src,e=this._style;this.disabled||y.isNull(e)||(y.isNullOrEmpty(r)?e.textContent=this.cssText||"":(this.cssReady=!1,fetch(r).then(t=>{t.text().then(n=>{e.textContent=n,this._idleWhileReady()},n=>{this.cssReady=!0})},t=>{this.cssReady=!0})))}};l([M({emit:!1,converter:S.String})],Dl.prototype,"src",2),l([M({emit:!1,converter:S.String})],Dl.prototype,"cssText",2),l([M({converter:S.Boolean})],Dl.prototype,"cssReady",2),Dl=l([W({tagName:F+"-style-proxy"})],Dl);var Uu=class extends HTMLElement{constructor(){super()}connectedCallback(){this.childNodes.length==0&&(this.innerHTML=" "),this._text=this.childNodes.item(0)}propertyChangedCallback(r,e,t,n){y.isNull(t)&&n===!0||(this._text.nodeValue=t)}};l([M({emit:!1,converter:S.String})],Uu.prototype,"text",2),Uu=l([W({tagName:F+"-text"})],Uu);var zu=class extends K{constructor(){super();this._handle=0}propertyChangedCallback(e,t,n,i){switch(super.propertyChangedCallback(e,t,n,i),e){case"interval":case"disabled":this._restart();break}}viewActivatedCallback(){super.viewActivatedCallback(),this._restart()}disconnectedCallback(){window.clearInterval(this._handle),super.disconnectedCallback()}_restart(){clearInterval(this._handle),!this.disabled&&this.interval>0&&(this._handle=window.setInterval(()=>{this.dispatchEvent(new Event("tick",{bubbles:!1,cancelable:!1}))},this.interval))}};l([M({emit:!1,converter:S.Number})],zu.prototype,"interval",2),zu=l([W({tagName:F+"-timer"})],zu);var Gu=class extends K{propertyChangedCallback(r,e,t,n){super.propertyChangedCallback(r,e,t,n),this._update()}viewActivatedCallback(){super.viewActivatedCallback(),this._update()}_update(){let r=this.value;y.isNullOrEmpty(r)||this.disabled||(document.title=r)}};l([M({emit:!1,converter:S.String})],Gu.prototype,"value",2),Gu=l([W({tagName:F+"-title-proxy"})],Gu);var Jb=class extends st{constructor(r){super("step",r)}},Zb=class extends CustomEvent{constructor(){super("end")}},Qb=class extends CustomEvent{constructor(){super("start")}};var di=class extends K{constructor(e=new Sl){super();this._tweener=e;this.duration=1e3}propertyChangedCallback(e,t,n,i){super.propertyChangedCallback(e,t,n,i),e==="start"&&n===!0&&this.disabled!=!0&&this._animate()}run(){return this._animate()}_animate(){var e=!1;return this._tweener.run(this.from,this.to,this.duration,this.delay,this.easing,(t,n)=>{e=e==!1&&this.dispatchEvent(new Qb),this.dispatchEvent(new Jb({time:t,value:this.value=n})),this.log("info","value: "+this.value),t==1&&(this.dispatchEvent(new Zb),this.start=!1)})}};l([M({emit:!1})],di.prototype,"easing",2),l([M({emit:!1,reflectBack:!0,converter:S.Number})],di.prototype,"from",2),l([M({emit:!1,reflectBack:!0,converter:S.Number})],di.prototype,"to",2),l([M({emit:!1,converter:S.Number})],di.prototype,"duration",2),l([M({emit:!1,converter:S.Number})],di.prototype,"delay",2),l([M({emit:!1,converter:S.Boolean})],di.prototype,"start",2),l([M({converter:S.Number})],di.prototype,"value",2),di=l([W({tagName:F+"-tween"})],di);var ey=class{constructor(r){this._global=r;this.viewports=[];this._checkHandler=r=>{this._oncheck(r)}}register(r){let e=this.viewports,t=this._global;e.indexOf(r)===-1&&(e.push(r),e.length===1&&(t.addEventListener("resize",this._checkHandler,!1),t.addEventListener("scroll",this._checkHandler,!1),t.addEventListener("transitionend",this._checkHandler,!1),t.addEventListener("animationend",this._checkHandler,!1)),this._oncheck())}unregister(r){var e;let t=this.viewports,n=this._global;(e=t.indexOf(r))!==-1&&(t.splice(e,1),t.length===0&&(n.removeEventListener("resize",this._checkHandler,!1),n.removeEventListener("scroll",this._checkHandler,!1),n.removeEventListener("transitionend",this._checkHandler,!1),n.removeEventListener("animationend",this._checkHandler,!1)),this._oncheck())}isElementVisible(r,e){let t=y.windowSize;var n=this._global.document,i=r.getBoundingClientRect(),s=t.width,o=t.height,c=function(d,p){return document.elementFromPoint(d,p)};return i.bottom>0&&i.top<0+o&&(e||i.left<s+0&&i.right>0)}_oncheck(r){for(var e of this.viewports){let n=e.target||e,i=this.isElementVisible(n,e.ignoreHorizontal);if(i!==e.visible){var t=e.visible=i;t?y.addClass(n,re+"-in-viewport"):y.removeClass(n,re+"-in-viewport")}}}};l([Ib(100)],ey.prototype,"_oncheck",1);var tS=new ey(window),Rl=class extends K{viewActivatedCallback(){super.viewActivatedCallback(),tS.register(this)}disconnectedCallback(){tS.unregister(this),super.disconnectedCallback()}};l([M({converter:S.Boolean})],Rl.prototype,"visible",2),l([M({emit:!1,converter:S.Element})],Rl.prototype,"target",2),l([M({emit:!1,converter:S.Boolean})],Rl.prototype,"ignoreHorizontal",2),Rl=l([W({tagName:F+"-viewport-aware"})],Rl);var Ga=class extends K{constructor(){super(...arguments);this.autosend=!0;this._messageHandler=e=>{this.result=e.data,this.dispatchEvent(new CustomEvent("receive",{detail:e.data,bubbles:!1,cancelable:!1}))};this._errorHandler=e=>{this.dispatchEvent(new CustomEvent("error",{detail:e.error,bubbles:!1,cancelable:!1}))}}viewActivatedCallback(){super.viewActivatedCallback(),this._initializeWorker()}propertyChangedCallback(e,t,n,i){if(super.propertyChangedCallback(e,t,n,i),!i)switch(e){case"src":this._disposeWorker(),this._initializeWorker(n);break;case"autosend":case"disabled":case"message":this.autosend&&this.send(this.message);break}}disconnectedCallback(){this._disposeWorker(),super.disconnectedCallback()}send(e=this.message){if(this.disabled)return;let t=this._worker;y.isNull(t)||t.postMessage(e)}_initializeWorker(e=this.src){if(!y.isNullOrEmpty(e)){let t=this._worker=new Worker(e);t.addEventListener("message",this._messageHandler,!1),t.addEventListener("error",this._errorHandler,!1),this.autosend&&!y.isNull(this.message)&&this.send()}}_disposeWorker(e=this._worker){y.isNull(e)||(e.removeEventListener("error",this._errorHandler,!1),e.removeEventListener("message",this._messageHandler,!1),e.terminate())}};l([M({emit:!1,converter:S.String})],Ga.prototype,"message",2),l([M({converter:S.String})],Ga.prototype,"result",2),l([M({emit:!1,converter:S.String})],Ga.prototype,"src",2),l([M({emit:!1,reflectBack:!0,converter:S.Boolean})],Ga.prototype,"autosend",2),Ga=l([W({tagName:F+"-webworker-proxy"})],Ga);import{Matrix2D as nS}from"@pacem/pacem-foundation";var Us=class extends K{#e=new WeakSet;register(r){var e=this.#e;e.has(r)||(e.add(r),this.decorate(r))}unregister(r){var e=this.#e;e.has(r)&&(this.undecorate(r),e.delete(r))}has(r){return this.#e.has(r)}};import{Point as rS}from"@pacem/pacem-foundation";var ty=class{constructor(r){this._builder=r;this.currentPosition=r.currentPosition,this.target=r.target}get element(){return this._builder.element}get origin(){return this._builder.origin}get initialDelta(){return this._builder.initialDelta}get startTime(){return this._builder.startTime}get floater(){return this._builder.floater}get delta(){var r=this;return rS.add(r.initialDelta,rS.subtract(r.origin,r.currentPosition))}},ry=class a extends ty{constructor(r){super(r),this.placeholder=r.placeholder,this.data=r.data}static fromArgs(r){return new a(y.extend({},r))}},Fa=class a extends ty{constructor(e,t=e.placeholder,n=e.data){super(e);this._placeholder=t;this._data=n}get placeholder(){return this._placeholder}get data(){return this._data}static fromArgs(e){return new a(y.extend({},e))}},zs=class extends wl{constructor(r,e,t,n){super(r,e,t,n)}};var VC=j.getAttachedPropertyValue,UC=j.setAttachedPropertyValue,Nf=j.deleteAttachedPropertyValue,ny="pacem:dragdrop:mousedown",Lf="pacem:dragdrop:info",iS="pacem:dragdrop:delegate",zC=class{constructor(r,e){this._logFn=e;this._started=!1;this._enterHandler=r=>{this._currentTarget=r.target};this._leaveHandler=r=>{this._currentTarget=null};this._revertTrackedTarget=null;this._moveHandler=r=>{r.type!=="wheel"&&Is(r);var e=this._element,t=this._dragDropper,n,i=VC(e,Lf);function s(){return n=n||(r instanceof MouseEvent?{x:r.pageX,y:r.pageY}:{x:r.touches[0].pageX,y:r.touches[0].pageY})}if(!this._started){if(this._logFn("info","Dragging act started"),this._started=!0,t.dropBehavior==="insert"){var o=e;do o=o.parentElement;while(o&&t.dropTargets.indexOf(o)==-1);this._currentTarget=o}t.dispatchEvent(new zs("dragstart",Fa.fromArgs(i),{},r))}if(!y.isNull(i)){this._logFn("debug","Dragging act ongoing");let p=r instanceof MouseEvent;y.addClass(j.findAncestorShell(e),re+"-dragging");let u=i.currentPosition=s(),h=i.floater,m=new zs("drag",Fa.fromArgs(i),{cancelable:!0},r);if(t.dispatchEvent(m),!m.defaultPrevented&&(h instanceof HTMLElement||h instanceof SVGElement)){let f={x:m.detail.delta.x,y:m.detail.delta.y};h.style.transform=`translate3d(${f.x}px, ${f.y}px, 0)`}var c=this._currentTarget;!p&&t.dropTargets.length>0&&(c=document.elementsFromPoint(i.currentPosition.x-y.scrollLeft,i.currentPosition.y-y.scrollTop).find(f=>t.dropTargets.indexOf(f)>=0));var d=i.target;if(c!==d)if(y.isNull(d)||(y.removeClass(d,re+"-dropping"),t.dispatchEvent(new zs("dragout",Fa.fromArgs(i),{},r)),this._logFn("info",`Drop area left (${d.id||d.constructor.name})`)),t.dropTargets.indexOf(c)!=-1){i.target=c,this._logFn("info",`Drop area entering (${i.target.id||i.target.constructor.name})`);let f=new zs("dragover",Fa.fromArgs(i),{cancelable:!0},r);t.dispatchEvent(f),f.defaultPrevented?delete i.target:(y.addClass(i.target,re+"-dropping"),this._logFn("info",`Drop area entered (${i.target.id||i.target.constructor.name})`))}else delete i.target;if(this._revertTrackedTarget=i.target||d,!y.isNull(i.target)&&t.dropBehavior==="insert")this._insertChild(c,i);else if(y.isNull(i.target)&&t.mode==="copy"){let f=i.placeholder;f instanceof Element&&f.remove()}}};this._endHandler=r=>{var e=this._element,t=j.findAncestorShell(e),n=this._dragDropper,i;if(!y.isNull(i=VC(e,Lf))){r instanceof MouseEvent&&Is(r);let o=()=>{let d=i.floater;(d instanceof HTMLElement||d instanceof SVGElement)&&(d.style.pointerEvents=""),n.mode!=="self"&&i.floater.remove(),y.removeClass(e,re+"-dragging"),y.removeClass(e,re+"-drag-lock"),Nf(e,Lf),y.isNull(i.placeholder)||(y.removeClass(i.placeholder,re+"-dragging"),y.removeClass(i.placeholder,"drag-placeholder"),y.removeClass(i.placeholder,re+"-drag-lock"),Nf(i.placeholder,Lf));let p=!y.isNull(i.target);p&&(n.dispatchEvent(new zs("drop",Fa.fromArgs(i),{},r)),y.removeClass(i.target,re+"-dropping"));let u=i.data,h=n.dropTargets,m=i.placeholder,f=this._repeaterItem,g=this._sourceRepeater,v=!y.isNull(f),b=m&&this._findTargetRepeaterItem(i.placeholder.parentElement,i.placeholder.nextElementSibling),_=b&&b.repeater,E=n.mode==="copy",C=p&&!y.isNull(_)&&!(y.isNull(f)&&g===_);if(v&&!E&&p&&g.removeItem(f.index),C)if(i.placeholder.remove(),_===g&&!E){let k=f.index,w=b.index;w>k&&w--,g.datasource.moveWithin(k,w)}else E||g&&g.datasource.splice(f.index,1),_&&(_.datasource=_.datasource||[]).splice(b.index,0,u);!p&&!y.isNullOrEmpty(n.dropTargets)&&n.spillBehavior==="remove"&&!E&&(v?g.datasource.splice(f.index,1):e.remove()),n.dispatchEvent(new zs("dragend",Fa.fromArgs(i),{},r)),y.removeClass(t,re+"-dragging")},c=i.placeholder||i.element;if(i.floater!=c){let d=i.floater;var s=y.deserializeTransform(getComputedStyle(d));if(!y.isNull(i.target)||n.spillBehavior==="revert"||n.dropBehavior==="insert"&&n.spillBehavior!=="remove"){let p=y.offset(c),u=y.offset(d);d.style.transition="transform .2s ease-in-out",s=nS.translate(s,{x:p.left-u.left,y:p.top-u.top})}else d.style.transition="transform .2s ease-in, opacity .2s linear",s=nS.scale(s,.1),d.style.opacity="0";y.addAnimationEndCallback(d,o,300),d.style.transform=`matrix(${s.a},${s.b},${s.c},${s.d},${s.e},${s.f})`}else o()}y.removeClass(e,re+"-drag-lock"),this.dispose(),this._logFn("info","Dragging act disposed")};this._dragDropper=r.dragDrop,y.addClass(this._element=r.element,re+"-drag-lock"),window.addEventListener("mouseup",this._endHandler,!1),window.addEventListener("touchend",this._endHandler,!1),window.addEventListener("mousemove",this._moveHandler,!1),document.addEventListener("wheel",this._moveHandler,!1),window.addEventListener("touchmove",this._moveHandler,{capture:!0,passive:!1}),this._dragDropper.dropTargets.forEach(n=>{n.addEventListener("mouseenter",this._enterHandler,!1),n.addEventListener("mouseleave",this._leaveHandler,!1)});var t=kl.findItemContext(this._element,0,null);t&&(t.dom&&t.dom.length===1&&t.dom[0]===this._element&&(this._repeaterItem=t),this._sourceRepeater=t.repeater),this._bootstrap(r.placeholder,r.data)}_getLogicalData(r){return r instanceof Ia?r.item:r instanceof HTMLElement?r.dataset:r}_getPhysicalData(r){return r instanceof Bu?r.dom:[r]}_createFloater(r,e){let t=this._dragDropper,n=r;if(t.mode!="self"&&(n=n.cloneNode(!0),j.stripObservedAttributes(n),n instanceof HTMLElement||n instanceof SVGElement)){y.addClass(n,re+"-drag-floater"),j.findAncestorShell(this._element).appendChild(n),n.style.position="absolute";let i={left:e.x+n.clientWidth/2,top:e.y-n.clientHeight/2};if(r===this._element||r.classList.contains("drag-floater-resize")){let s=y.offset(this._element);n.style.boxSizing="border-box",n.style.width=s.width+"px",n.style.height=s.height+"px",i={left:s.left,top:s.top}}n.style.left=`${i.left}px`,n.style.top=`${i.top}px`}return(n instanceof HTMLElement||n instanceof SVGElement)&&(n.style.pointerEvents="none"),n}_findTargetRepeaterItem(r,e){var t=kl.findItemContext(e,0,null);if(y.isNull(t)){var n=null,i=-1;if(r instanceof Xi?n=r:n=j.findAncestorOfType(r,Xi),!y.isNull(n))return{repeater:n,index:n.datasource&&n.datasource.length||0}}else return{repeater:t.repeater,index:t.index};return null}_findNextSibling(r,e){var t=0,n=0;let i=Array.from(r.children),s=i.length,o=document.elementFromPoint(e.currentPosition.x-y.scrollLeft,e.currentPosition.y-y.scrollTop),c;if(o===r)return this._currentHover=c=e.placeholder,c.parentElement===r?c.nextElementSibling:null;for(var d=o;d.parentElement!=r&&d.parentElement!=null;)d=d.parentElement;if(d.parentElement!=r||d===e.placeholder)return this._currentHover=c=e.placeholder,c.nextElementSibling;if(d!=this._currentHover){c=this._currentHover;let p=i.indexOf(c),u=i.indexOf(d);return this._currentHover=d,p>u?d:d.nextElementSibling}return d}_insertChild(r,e){let t=e.placeholder||e.element,n=e.target,i=this._findNextSibling(n,e);(t.nextSibling!=i||t.parentElement!=n)&&(y.isNull(i)||i.parentElement==r)&&(r.insertBefore(t,i),this._logFn("info",`Positioned before ${i&&(i.id||i.constructor.name)||"null"} for drop`))}_bootstrap(r,e){var t=this._element,n=this._dragDropper,i,s;if(!y.isNull(i=VC(t,ny))){this._started=!1,Nf(t,ny),y.addClass(t,re+"-dragging");let o=getComputedStyle(t),c={x:0,y:0},d=y.deserializeTransform(o);c.x+=d.e,c.y+=d.f;let p=this._createFloater(n.floater||t,i);if(y.isNull(r))switch(n.mode){case"alias":r=t;break;case"copy":r=t.cloneNode(!0);break}y.isNull(r)||y.addClass(r,"drag-placeholder"),!y.isNull(this._repeaterItem)&&!y.isNull(r)&&j.freezeObservedAttributes(r);let u=e||this._getLogicalData(this._repeaterItem||t);s={element:t,placeholder:r||t,data:u,startTime:Date.now(),origin:i,initialDelta:c,currentPosition:i,floater:p},UC(t,Lf,s)}}dispose(){this._dragDropper.dropTargets.forEach(r=>{r.removeEventListener("mouseenter",this._enterHandler,!1),r.removeEventListener("mouseleave",this._leaveHandler,!1)}),window.removeEventListener("mouseup",this._endHandler,!1),window.removeEventListener("touchend",this._endHandler,!1),window.removeEventListener("mousemove",this._moveHandler,!1),document.removeEventListener("wheel",this._moveHandler,!1),window.removeEventListener("touchmove",this._moveHandler,{capture:!0})}},pi=class extends Us{constructor(){super(...arguments);this._startHandler=e=>{if(this.disabled||!e.isTrusted||!y.isNullOrEmpty(this.handleSelector)&&e.currentTarget.querySelector(this.handleSelector)!==e.target)return;let t=e.currentTarget,n=Yt.getEventCoordinates(e),i=n.page,s=t,o=ry.fromArgs({element:s,placeholder:null,currentPosition:i,origin:i,initialDelta:{x:0,y:0},startTime:null,floater:null,data:null}),c=new zs("draginit",o,{cancelable:!0},e);if(this.dispatchEvent(c),c.defaultPrevented)return;Is(e);let d=()=>{t.removeEventListener("mouseup",p,!1),t.removeEventListener("touchend",p,!1),this.log("info","Drag locked!"),UC(t,ny,i),UC(t,iS,new zC({element:s,dragDrop:this,placeholder:o.placeholder,data:o.data},(h,m,f)=>this.log.apply(this,[h,m,f])))},p=h=>{this.log("info","Drag avoided!"),clearTimeout(u)},u=setTimeout(d,this.lockTimeout);t.addEventListener("mouseup",p,!1),t.addEventListener("touchend",p,!1)};this.lockTimeout=100;this.dropTargets=[];this.mode="self"}decorate(e){let t={capture:!1,passive:!1};e.addEventListener("mousedown",this._startHandler,!1),e.addEventListener("touchstart",this._startHandler,t)}undecorate(e){let t={capture:!1,passive:!1};e.removeEventListener("mousedown",this._startHandler,!1),e.removeEventListener("touchstart",this._startHandler,t)}addEventListener(e,t,n){super.addEventListener(e,t,n)}removeEventListener(e,t,n){super.removeEventListener(e,t,n)}dispatchEvent(e){return e.type==="dragend"&&(Nf(e.detail.element,ny),Nf(e.detail.element,iS)),super.dispatchEvent(e)}};l([M({emit:!1,converter:S.Number})],pi.prototype,"lockTimeout",2),l([M({emit:!1})],pi.prototype,"dropTargets",2),l([M({emit:!1,converter:S.String})],pi.prototype,"mode",2),l([M({emit:!1,converter:S.Element})],pi.prototype,"floater",2),l([M({emit:!1,converter:S.String})],pi.prototype,"dropBehavior",2),l([M({emit:!1,converter:S.String})],pi.prototype,"spillBehavior",2),l([M({emit:!1,converter:S.String})],pi.prototype,"handleSelector",2),pi=l([W({tagName:F+"-drag-drop"})],pi);import{Point as An}from"@pacem/pacem-foundation";var Fu=class a{constructor(r){this._builder=r}get currentPosition(){return this._builder.currentPosition}get targetRect(){return this._builder.targetRect}get element(){return this._builder.element}get handle(){return this._builder.handle}static fromArgs(r){return new a(y.extend({},r))}},Wu=class extends wl{constructor(r,e,t,n){super(r,e,t,n)}};var FC=class{constructor(r,e,t,n){this._element=r;this._type=e;this._rescaler=t;this._logFn=n;this._startTime=Date.now();this._moveHandler=r=>{r.stopPropagation();let e=this._element,t=this._origin,n=this._rescaler,i=this._type,s=n.keepProportions,o=n.minWidth||0,c=n.minHeight||0,d=n.maxWidth||Number.MAX_SAFE_INTEGER,p=n.maxHeight||Number.MAX_SAFE_INTEGER,u=r instanceof MouseEvent?{x:r.pageX,y:r.pageY}:{x:r.touches[0].pageX,y:r.touches[0].pageY},h={x:u.x,y:u.y},m=this._rect;switch(i){case"top":case"bottom":h.x=t.x;break;case"left":case"right":h.y=t.y;break}this._position=h;let f={x:h.x-t.x,y:h.y-t.y};var g;if(s){let _={x:m.x,y:m.y},E={x:m.x+m.width,y:m.y},C={x:m.x+m.width,y:m.y+m.height},k={x:m.x,y:m.y+m.height},w=An.distance(C,k)/An.distance(C,_),T=An.distance(_,k)/An.distance(C,_),I=An.distance(_,C),O=(D,P)=>(D.x*P.x+D.y*P.y)/I;switch(i){case"topleft":let D=An.subtract(C,_),P=O(An.subtract(C,h),D),N={x:C.x-P*w,y:C.y-P*T};g={x:N.x,y:N.y,width:C.x-N.x,height:C.y-N.y};break;case"topright":let H=An.subtract(k,E),V=O(An.subtract(k,h),H),B={x:k.x+V*w,y:k.y-V*T};g={x:k.x,y:B.y,width:B.x-k.x,height:k.y-B.y};break;case"bottomleft":let R=An.subtract(E,k),U=O(An.subtract(E,h),R),z={x:E.x-U*w,y:E.y+U*T};g={x:z.x,y:E.y,width:E.x-z.x,height:z.y-E.y};break;default:let G=An.subtract(_,C),Z=O(An.subtract(_,h),G),q={x:_.x+Z*w,y:_.y+Z*T};g={x:_.x,y:_.y,width:q.x-_.x,height:q.y-_.y};break}}else g={x:this._rect.x,y:this._rect.y,width:this._rect.width+f.x,height:this._rect.height+f.y},i.startsWith("top")&&(g.y=this._rect.y+f.y,g.height=this._rect.height-f.y),i.endsWith("left")&&(g.x=this._rect.x+f.x,g.width=this._rect.width-f.x);this._logFn("log",`handle: ${i}, origin: ${JSON.stringify(t)}, currentPosition: ${JSON.stringify(u)}`,"Rescaling"),this._logFn("log",`delta: ${JSON.stringify(f)}, position: ${JSON.stringify(h)}`,"Rescaling"),this._logFn("log",`from: ${JSON.stringify(this._rect)}, to: ${JSON.stringify(g)}`,"Rescaling");let v=g.width>=o&&g.width<=d,b=g.height>=c&&g.height<=p;if(s&&(!v||!b)&&(v=b=!1),v||(g.x=this._targetRect.x,g.width=this._targetRect.width),b||(g.y=this._targetRect.y,g.height=this._targetRect.height),v||b){let _={currentPosition:h,element:e,handle:i,origin:t,targetRect:g,startTime:this._startTime},E=new Wu("rescale",Fu.fromArgs(_),{cancelable:!0},r);if(n.dispatchEvent(E),!E.defaultPrevented){let C=this._originalTransform;e.style.transform=`matrix(${C.a},${C.b},${C.c},${C.d},${C.e+g.x-this._rect.x},${C.f+g.y-this._rect.y})`,e.style.width=g.width+"px",e.style.height=g.height+"px"}this._targetRect=g}};this._endHandler=r=>{r.stopPropagation();let e=this._type,t=new Wu("rescaleend",Fu.fromArgs({element:this._element,origin:this._origin,handle:e,startTime:this._startTime,currentPosition:this._position,targetRect:this._targetRect}),{},r);y.removeClass(document.body,re+"-rescaling rescale-"+e),this._rescaler.dispatchEvent(t),sS(this._element,oS),window.removeEventListener("mouseup",this._endHandler,!1),window.removeEventListener("touchend",this._endHandler,!1),window.removeEventListener("mousemove",this._moveHandler,!1),window.removeEventListener("touchmove",this._moveHandler,!1)};window.addEventListener("mouseup",this._endHandler,!1),window.addEventListener("touchend",this._endHandler,!1),window.addEventListener("mousemove",this._moveHandler,!1),window.addEventListener("touchmove",this._moveHandler,!1),this._origin=this._position=WC(r,aS),this._rect=this._targetRect=y.offsetRect(r),this._originalTransform=y.deserializeTransform(getComputedStyle(r)),y.addClass(document.body,re+"-rescaling rescale-"+e)}},WC=j.getAttachedPropertyValue,GC=j.setAttachedPropertyValue,sS=j.deleteAttachedPropertyValue,AP="top right bottom left topleft topright bottomright bottomleft".split(" "),iy="pacem:rescale:frame",aS="pacem:rescale:origin",oS="pacem:rescale:delegate",qi=class extends Us{constructor(){super(...arguments);this._bag=[];this._startHandler=e=>{e.stopPropagation();let t=Yt.getEventCoordinates(e),n=e.currentTarget,i=t.page,s=/rescale-(.+)/.exec(n.className)[1],o=n.parentElement,c=new Wu("rescalestart",Fu.fromArgs({currentPosition:i,origin:i,element:o,handle:s,startTime:Date.now()}),{cancelable:!0},e);this.dispatchEvent(c),!c.defaultPrevented&&(Is(e),GC(o,aS,i),GC(o,oS,new FC(o,s,this,(d,p,u)=>this.log.apply(this,[d,p,u]))))}}decorate(e){let t=e,n=getComputedStyle(t);y.addClass(t,re+"-rescalable"),this._setFrame(t)}undecorate(e){let t=e;y.removeClass(t,re+"-rescalable"),this._removeFrame(t)}viewActivatedCallback(){super.viewActivatedCallback(),this._syncHandles()}propertyChangedCallback(e,t,n,i){switch(super.propertyChangedCallback(e,t,n,i),e){case"disabled":case"handles":case"keepProportions":this._syncHandles();break}}_syncHandles(){let e=this.handles||["all"],t=e.find(s=>s==="all")!=null,n=this.disabled,i=this.keepProportions;for(let s of this._bag){let o=WC(s,iy);o.top.hidden=n||!t&&e.find(c=>c==="top")==null,o.bottom.hidden=n||!t&&e.find(c=>c==="bottom")==null,o.left.hidden=n||!t&&e.find(c=>c==="left")==null,o.right.hidden=n||!t&&e.find(c=>c==="right")==null,o.topleft.hidden=o.top.hidden||o.left.hidden,o.topright.hidden=o.top.hidden||o.right.hidden,o.bottomleft.hidden=o.bottom.hidden||o.left.hidden,o.bottomright.hidden=o.bottom.hidden||o.right.hidden,i&&(o.top.hidden=o.bottom.hidden=o.left.hidden=o.right.hidden=!0)}}_setFrame(e){let t={};for(let n of AP){let i=t[n]=document.createElement("div");y.addClass(i,re+"-rescale rescale-"+n),e.setAttribute("pacem",""),e.appendChild(i),i.addEventListener("mousedown",this._startHandler,!1),i.addEventListener("touchstart",this._startHandler,{capture:!1,passive:!0})}GC(e,iy,t),this._bag.push(e),this._syncHandles()}_removeFrame(e){let t=WC(e,iy);for(var n in t){let i=t[n];i.removeEventListener("mousedown",this._startHandler,!1),i.removeEventListener("touchstart",this._startHandler,{capture:!1}),i.remove()}sS(e,iy),this._bag.splice(this._bag.indexOf(e),1)}};l([M({emit:!1,converter:S.StringArray})],qi.prototype,"handles",2),l([M({emit:!1,converter:S.Number})],qi.prototype,"minWidth",2),l([M({emit:!1,converter:S.Number})],qi.prototype,"maxWidth",2),l([M({emit:!1,converter:S.Number})],qi.prototype,"minHeight",2),l([M({emit:!1,converter:S.Number})],qi.prototype,"maxHeight",2),l([M({emit:!1,converter:S.Boolean})],qi.prototype,"keepProportions",2),qi=l([W({tagName:F+"-rescale"})],qi);import{Matrix2D as DP,Angle as RP,Numbers as OP}from"@pacem/pacem-foundation";var ju=class a{constructor(r){this._builder=r}get currentPosition(){return this._builder.currentPosition}get rotation(){return this._builder.rotation}get element(){return this._builder.element}get center(){return this._builder.center}static fromArgs(r){return new a(y.extend({},r))}},Yu=class extends wl{constructor(r,e,t,n){super(r,e,t,n)}};var sy=j.getAttachedPropertyValue,ay=j.setAttachedPropertyValue,PP=j.deleteAttachedPropertyValue,lS="pacem:rotate:origin",cS="pacem:rotate:delegate",jC="pacem:rotate:offset",dS="pacem:rotate:center",NK=2*Math.PI,YC=class{constructor(r,e,t){this._element=r;this._rotator=e;this._logFn=t;this._startTime=Date.now();this._moveHandler=r=>{r.stopPropagation();let e=this._element,t=this._previousPosition,n=this._rotator,i=n.minRotation,s=n.maxRotation,o=r instanceof MouseEvent?{x:r.pageX,y:r.pageY}:{x:r.touches[0].pageX,y:r.touches[0].pageY},c=this._pivot;var d=this._computeAngle(c,o,t)+this._previousAngle,p=this._constraintAngle(d,n.step);for(this._logFn("log",`previousPosition: ${JSON.stringify(t)}, currentPosition: ${JSON.stringify(o)}`,"Rotating"),d>s&&(d=s);p>s&&n.step>0;)this._logFn("log",`angle: ${p} constrained to max: ${s}`,"Rotating"),p-=n.step;for(d<i&&(d=i);p<i&&n.step>0;)this._logFn("log",`angle: ${p} constrained to min: ${i}`,"Rotating"),p+=n.step;if(this._logFn("log",`angle: ${p}, origin: ${JSON.stringify(this._originalPosition)}, current: ${JSON.stringify(o)}`,"Rotating"),p!=this._previousRenderedAngle){let u=new Yu("rotate",ju.fromArgs({element:this._element,origin:this._originalPosition,startTime:this._startTime,currentPosition:o,rotation:p,center:this._pivot}),{cancelable:!0},r);if(this._rotator.dispatchEvent(u),!u.defaultPrevented){let h=this._originalTransform,m=DP.rotate(h,p-this._originalAngle);e.style.transform=`matrix(${m.a}, ${m.b}, ${m.c}, ${m.d}, ${m.e}, ${m.f})`,ay(this._element,jC,p)}this._previousRenderedAngle=p}this._previousPosition=o,this._previousAngle=d};this._endHandler=r=>{r.stopPropagation();let e=new Yu("rotateend",ju.fromArgs({element:this._element,origin:this._originalPosition,startTime:this._startTime,currentPosition:this._previousPosition,rotation:this._previousAngle,center:this._pivot}),{},r);this._rotator.dispatchEvent(e),PP(this._element,cS),window.removeEventListener("mouseup",this._endHandler,!1),window.removeEventListener("touchend",this._endHandler,!1),window.removeEventListener("mousemove",this._moveHandler,!1),window.removeEventListener("touchmove",this._moveHandler,!1)};window.addEventListener("mouseup",this._endHandler,!1),window.addEventListener("touchend",this._endHandler,!1),window.addEventListener("mousemove",this._moveHandler,!1),window.addEventListener("touchmove",this._moveHandler,!1),this._originalPosition=this._previousPosition=sy(r,lS),this._originalAngle=this._previousAngle=this._previousRenderedAngle=sy(r,jC,0),this._pivot=sy(r,dS),this._originalTransform=y.Css.deserializeTransform(r)}_computeAngle(r,e,t){return RP.angleBetween(r,e,t)}_constraintAngle(r,e){return e>0?OP.round(r,e):r}},Wa=class extends Us{constructor(){super(...arguments);this._startHandler=e=>{if(this.disabled)return;let t=Yt.getEventCoordinates(e),n=e.currentTarget,i=t.page,s=y.offsetRect(n),o=s.width/2,c=s.height/2;var d=this.center;if(y.isNull(d))d={x:s.x+o,y:s.y+c},n.style.transformOrigin="50% 50%";else{let u=s.x+o-d.x,h=s.y+c-d.y;n.style.transformOrigin=`${-u}px ${-h}px`}let p=new Yu("rotatestart",ju.fromArgs({currentPosition:i,rotation:sy(n,jC,0),center:d,origin:i,element:n,startTime:Date.now()}),{cancelable:!0},e);this.dispatchEvent(p),!p.defaultPrevented&&(Is(e),ay(n,lS,i),ay(n,dS,d),ay(n,cS,new YC(n,this,(u,h,m)=>this.log.apply(this,[u,h,m]))))}}decorate(e){let t=e;y.addClass(t,re+"-rotatable");let n={capture:!1,passive:!1};e.addEventListener("mousedown",this._startHandler,!1),e.addEventListener("touchstart",this._startHandler,n)}undecorate(e){let t=e;y.removeClass(t,re+"-rotatable");let n={capture:!1,passive:!1};e.removeEventListener("mousedown",this._startHandler,!1),e.removeEventListener("touchstart",this._startHandler,n)}};l([M({emit:!1,converter:S.Number})],Wa.prototype,"step",2),l([M({emit:!1,converter:S.Number})],Wa.prototype,"minRotation",2),l([M({emit:!1,converter:S.Number})],Wa.prototype,"maxRotation",2),l([M({emit:!1,converter:S.Point})],Wa.prototype,"center",2),Wa=l([W({tagName:F+"-rotate"})],Wa);import{Matrix2D as IP}from"@pacem/pacem-foundation";var oy=class a{constructor(r){this._builder=r}get#e(){let{verticalspeed:r,horizontalspeed:e,vertical:t}=this._builder;return t??Math.abs(e)<Math.abs(r)}get direction(){return this.#e?this._builder.verticalspeed>0?"down":"up":this._builder.horizontalspeed>0?"right":"left"}get speed(){let{verticalspeed:r,horizontalspeed:e}=this._builder;return this.#e?r:e}get delta(){let{position:{x:r,y:e},t0:{position:{x:t,y:n}}}=this._builder;return this.#e?e-n:r-t}get flinging(){let{fling:r}=this._builder;return r>0&&Math.abs(this.speed)>r}get predictedDelta(){let r=this._builder.inertia??8;return this.delta+this.speed/r}get predictedDuration(){let r=this._builder.inertia??8;return-Math.log(.01)/r}get element(){return this._builder.element}static fromArgs(r){return new a(y.extend({},r))}},Ol=class extends st{constructor(r,e,t){super(r,e,t)}};var pS=j.getAttachedPropertyValue,XC=j.setAttachedPropertyValue,qC=j.deleteAttachedPropertyValue,Xu="pacem:swipe:preparing",uS="pacem:swipe:delegate",hS={fling:400,inertia:8,start:32,autoresetSpans:!1,bouncy:!0},KC=class{constructor(r,e,t,n){this._element=r;this._swiper=e;this._init=t;this._logFn=n;this._moveHandler=r=>{let e=this.#t,t=this._buildStateFromUiEvent(r);for(e.push(this.#n=t);e.length>0&&t.timestamp-e[0].timestamp>100;)e.shift();let n=this._buildSwipeArgsFromState(t),i=new Ol("pan",n,{cancelable:!0,bubbles:!1}),s=this._swiper;if(s.dispatchEvent(i),!i.defaultPrevented){let{delta:o}=this._delta(this._init,t);if(!s.options.bouncy){let c=s.snaps.slice().sort(),d=c[0],p=c[c.length-1],u=this._swiper.direction,{x:h,y:m}=o,f=h.clamp(d,p),g=m.clamp(d,p);o=u==="vertical"?{x:0,y:g}:{x:f,y:0}}this._animateOffsetBy(o,0)}};this._endHandler=r=>{if(window.removeEventListener("pointermove",this._moveHandler),y.isNull(this.#n))console.log("How come?!");else{let e=this._buildSwipeArgsFromState(),t=new Ol("swipe",e,{cancelable:!0,bubbles:!1}),n=this._swiper;if(n.dispatchEvent(t),!t.defaultPrevented){let i=new Ol("swipe"+e.direction,e,{cancelable:!0,bubbles:!1});if(n.dispatchEvent(i),!i.defaultPrevented){let s=n.snaps??[0];s.sort();let o=n.options.bouncy?e.predictedDelta:e.predictedDelta.clamp(s[0],s[s.length-1]),c=s.reduce((m,f)=>{let g=Math.abs(f-o),v=Math.abs(m-o);return g<v?f:m},0),d=n.direction==="vertical",p=e.predictedDuration,u=d?{x:0,y:o}:{x:o,y:0},h=()=>{let m=new Ol("swipeanimationend",e,{cancelable:!1,bubbles:!1});return n.dispatchEvent(m)?m:null};if(c.isCloseTo(0))this._animateOffsetBy(u,p).then(()=>{this._animateOffsetBy({x:0,y:0},.3,"cubic-bezier(.37,-0.01,.34,1.43)").then(()=>h())});else{let m=(c-o)*(c-e.delta)>=0,f=d?{x:0,y:c}:{x:c,y:0},g=()=>this._animateOffsetBy(f,m?p:.2,"cubic-bezier(0,0,0,1)");(m?Promise.resolve():this._animateOffsetBy(u,p)).then(()=>g().then(()=>{h();let b=new Ol("swipe"+e.direction+"animationend",e,{cancelable:!1,bubbles:!1});n.dispatchEvent(b)}))}this.#e.autoresetSpans&&(this._swiper.snaps=s.map(m=>m-c))}}}this.dispose()};this.#t=[];let i=r;this.#e=y.extend({},hS,e.options??{}),this.#r=y.deserializeTransform(getComputedStyle(i)),window.addEventListener("pointermove",this._moveHandler,!1),window.addEventListener("pointerup",this._endHandler,!1),window.addEventListener("pointercancel",this._endHandler,!1)}_serializeTransformMatrix(r){return`matrix3d(${r.a},${r.b},0,0,${r.c},${r.d},0,0,0,0,1,0,${r.e},${r.f},0,1)`}_animateOffsetBy(r,e,t=y.Css.getVariableValue(`--${re}-easing-out-sine`)){let n=IP.translate(this.#r,r),i=Math.min(.3,e)*1e3,s=this._element,o=this._serializeTransformMatrix(n);return new Promise((c,d)=>{let p=s.animate([{transform:o}],{fill:"forwards",duration:i,easing:t}),u=h=>{p.removeEventListener("finish",u),p.commitStyles(),p.cancel(),c()};p.addEventListener("finish",u,!1)})}_buildStateFromUiEvent(r){let e=Yt.getEventCoordinates(r),t=performance.now();return{position:e.client,timestamp:t}}_buildSwipeArgsFromState(r=this.#n){let e=this.#e,t=this.speed,i=this._swiper.direction==="vertical",s=i?0:t,o=i?t:0;return oy.fromArgs({position:r.position,element:this._element,t0:this._init,timestamp:r.timestamp,inertia:e.inertia,fling:e.fling,horizontalspeed:s,verticalspeed:o,vertical:i})}_delta(r,e){let{position:{x:t,y:n},timestamp:i}=r,{position:{x:s,y:o},timestamp:c}=e;return{delta:this._swiper.direction==="vertical"?{x:0,y:o-n}:{x:s-t,y:0},time:c-i}}get speed(){let r=this.#t;if(r.length<2)return 0;let e=r[0],t=r[r.length-1],{delta:n,time:i}=this._delta(e,t),s=i/1e3,o=n.x+n.y;return s>0?o/s:0}#e;#t;#r;#n;dispose(){let r=this._element;qC(r,uS),window.removeEventListener("pointercancel",this._endHandler),window.removeEventListener("pointerup",this._endHandler)}},Tf,ja=class extends Us{constructor(){super(...arguments);$(this,Tf);this._prepareHandler=e=>{if(this.disabled)return;let t=Yt.getEventCoordinates(e),n=e.currentTarget,i=t.client,s=this.handleSelector;!y.isNullOrEmpty(s)&&n.querySelector(s)!==e.target||(e.stopPropagation(),XC(n,Xu,{position:i,timestamp:performance.now()}),XC(window,Xu,n),window.addEventListener("pointermove",this._startHandler,!1),window.addEventListener("pointerup",this._undoHandler,!1))};this._startHandler=e=>{let t=pS(window,Xu),n=pS(t,Xu);if(y.isNull(n)){this._undo(t);return}let i=Yt.getEventCoordinates(e),{x:s,y:o}=i.client,{position:{x:c,y:d}}=n,h=(this.direction||"horizontal")==="vertical"?o-d:s-c,m=x(this,Tf),{start:f}=m;if(Math.abs(h)>f){this._undo(t);let g=this,v=new KC(t,g,n,(b,_,E)=>{g.log(b,_,E)});XC(t,uS,v)}};this._undoHandler=e=>{let t=e.currentTarget;this._undo(t)}}decorate(e){(e instanceof HTMLElement||e instanceof SVGElement)&&y.addClass(e,re+"-swipe"),e.addEventListener("pointerdown",this._prepareHandler,!1)}undecorate(e){(e instanceof HTMLElement||e instanceof SVGElement)&&y.removeClass(e,re+"-swipe"),e.removeEventListener("pointerdown",this._prepareHandler,!1)}viewActivatedCallback(){super.viewActivatedCallback(),this._setOptions()}propertyChangedCallback(e,t,n,i){super.propertyChangedCallback(e,t,n,i),!i&&e==="options"&&this._setOptions(n)}_setOptions(e=this.options){A(this,Tf,y.extend({},hS,e??{}))}_undo(e){window.removeEventListener("pointermove",this._startHandler),window.removeEventListener("pointerup",this._undoHandler),qC(e,Xu),qC(window,Xu)}};Tf=new WeakMap,l([M({emit:!1,reflectBack:!0,converter:{convert:(e,t)=>e.match(/[-+]?[\d\.]+/g).map(n=>parseFloat(n)),convertBack:(e,t)=>e?.join(" ")}})],ja.prototype,"snaps",2),l([M({emit:!1,converter:S.String,reflectBack:!0})],ja.prototype,"direction",2),l([M({emit:!1,converter:S.Json})],ja.prototype,"options",2),l([M({emit:!1,converter:S.String,reflectBack:!0})],ja.prototype,"handleSelector",2),ja=l([W({tagName:F+"-swipe"})],ja);var $P={convert:a=>Yi[a]??Yi.linear},Dn=class extends Tl{};l([M({emit:!1,converter:S.Element})],Dn.prototype,"target",2),l([M({emit:!1,converter:S.String})],Dn.prototype,"property",2),l([M({emit:!1,converter:S.Number})],Dn.prototype,"delay",2),l([M({emit:!1,converter:S.Number})],Dn.prototype,"duration",2),l([M({emit:!1,converter:$P})],Dn.prototype,"easing",2),l([M({emit:!1,converter:S.Number})],Dn.prototype,"iterations",2),l([M({emit:!1,converter:S.String})],Dn.prototype,"direction",2);var Ya=class extends Dn{constructor(e=new Sl){super();this._tweener=e}get tweener(){return this._tweener}#e=!1;startAnimation(){return this.#e=!1,new Promise((e,t)=>{this._tweener.run(0,1,this.duration??0,this.delay??0,this.easing??Yi.linear,(n,i)=>{this.#e||(this.target[this.property]=this.tweenInterpolationCallback(n,i))}).then(e)})}cancelAnimation(){this.#e=!0}};import{Colors as JC}from"@pacem/pacem-foundation";var ZC={h:0,l:0,s:.5,a:1},HP={h:0,l:1,s:.5,a:1},Af,Df,Md=class extends Ya{constructor(){super(...arguments);$(this,Af,ZC);$(this,Df,HP)}propertyChangedCallback(e,t,n,i){if(super.propertyChangedCallback(e,t,n,i),!i)switch(e){case"from":this._precomputeFrom(n);break;case"to":this._precomputeTo(n);break}}viewActivatedCallback(){super.viewActivatedCallback(),this._precomputeColors()}_precomputeColors(){this._precomputeFrom(),this._precomputeTo()}_precomputeFrom(e=this.from){A(this,Af,this._precomputeColor(e)??ZC)}_precomputeTo(e=this.to){A(this,Df,this._precomputeColor(e)??ZC)}_precomputeColor(e){if(!y.isNullOrEmpty(e))try{return this._parseColor(e)}catch{return null}}_parseColor(e){return JC.hsl(JC.parse(e))}tweenInterpolationCallback(e,t){let n=x(this,Af),i=x(this,Df),s={h:(i.h-n.h)*t+n.h,s:(i.s-n.s)*t+n.s,l:(i.l-n.l)*t+n.l,a:(i.a-n.a)*t+n.a};return JC.stringify(s)}};Af=new WeakMap,Df=new WeakMap,l([M({emit:!1,converter:S.String})],Md.prototype,"from",2),l([M({emit:!1,converter:S.String})],Md.prototype,"to",2),Md=l([W({tagName:F+"-color-animation"})],Md);var BP=0,VP=1,Sd=class extends Ya{tweenInterpolationCallback(r,e){let t=this.to??VP,n=this.from??BP;return(t-n)*e+n}};l([M({emit:!1,converter:S.Number})],Sd.prototype,"from",2),l([M({emit:!1,converter:S.Number})],Sd.prototype,"to",2),Sd=l([W({tagName:F+"-number-animation"})],Sd);var UP={x:0,y:0},zP={x:1,y:1},Ld=class extends Ya{tweenInterpolationCallback(r,e){let t=this.to??zP,n=this.from??UP;return{x:(t.x-n.x)*e+n.x,y:(t.y-n.y)*e+n.y}}};l([M({emit:!1,converter:S.Point})],Ld.prototype,"from",2),l([M({emit:!1,converter:S.Point})],Ld.prototype,"to",2),Ld=l([W({tagName:F+"-point-animation"})],Ld);var Xa=class extends Bs{validate(r){return r instanceof Dn}viewActivatedCallback(){super.viewActivatedCallback(),this._animate()}propertyChangedCallback(r,e,t,n){if(super.propertyChangedCallback(r,e,t,n),!n)switch(r){case"datasource":this._buildDatasourceFromDatasource(t);break;case"items":this._buildDatasourceFromItems(t);break;case"_adaptedDatasource":case"autostart":this._animate();break}}_buildDatasourceFromItems(r=this.items){this._adaptedDatasource=r||[]}_buildDatasourceFromDatasource(r=this.datasource){this._adaptedDatasource=r||[]}_animate(r=this.autostart){let e=this._adaptedDatasource,t=[];if(r&&!y.isNullOrEmpty(e))for(let n of e)t.push(n.startAnimation());return Promise.all(t)}cancelAnimation(){let r=this._adaptedDatasource||[];for(let e of r)e.cancelAnimation()}startAnimation(){return this._animate(!0)}};l([M({emit:!1,converter:S.Boolean})],Xa.prototype,"autostart",2),l([M({emit:!1,converter:S.Number})],Xa.prototype,"duration",2),l([M({emit:!1})],Xa.prototype,"datasource",2),l([M({emit:!1})],Xa.prototype,"_adaptedDatasource",2),Xa=l([W({tagName:F+"-storyboard"})],Xa);var eE={};tt(eE,{PacemConsoleElement:()=>Ku,PacemFpsElement:()=>Rf,PacemTrackerElement:()=>Pl});import{PacemEventTarget as GP,Watch as mS,PropertyConverters as fS,Utils as FP,Concurrent as WP}from"@pacem/pacem-core";var gS={current:0,count:0,average:0,max:Number.MIN_VALUE,min:Number.MAX_VALUE},Pl=class extends GP{constructor(){super();this.data=gS}propertyChangedCallback(e,t,n,i){super.propertyChangedCallback(e,t,n,i),e==="entry"&&this._update(n).then(s=>this.data=s)}_update(e){let t=()=>{let n=this.data,i=Math.min(e,n.min),s=Math.max(e,n.max),o=n.count+1,c=(n.count*n.average+e)/o;return{count:o,min:i,max:s,average:c,current:e}};return FP.fromResultAsync(t)}reset(){this.data=gS}};l([mS({converter:fS.Json})],Pl.prototype,"data",2),l([mS({emit:!1,converter:fS.Number})],Pl.prototype,"entry",2),l([WP()],Pl.prototype,"_update",1);import{PacemEventTarget as jP,Watch as YP,PropertyConverters as XP,Utils as QC,CustomElement as qP,Logging as qu,P as KP}from"@pacem/pacem-core";var vS={error:!0,info:!0,warn:!0},Ku=class extends jP{constructor(){super(...arguments);this._config=vS}propertyChangedCallback(e,t,n,i){super.propertyChangedCallback(e,t,n,i),e==="configuration"&&(this._config=QC.extend({},vS,n??{}))}log(e,t,n){try{this._log(e,t,n)}catch{}}_log(e,t,n){if(!this.disabled&&this._config[e]===!0){n!==this._category&&(QC.isNullOrEmpty(this._category)||console.groupEnd(),QC.isNullOrEmpty(n)||console.group(n),this._category=n);var i=s=>{};switch(e){case qu.LogLevel.Debug:i=console.debug;break;case qu.LogLevel.Error:i=console.error;break;case qu.LogLevel.Info:i=console.info;break;case qu.LogLevel.Trace:i=console.trace;break;case qu.LogLevel.Warn:i=console.warn;break;case qu.LogLevel.Log:i=console.log;break}i(new Date().toISOString()+": "+t)}}};l([YP({emit:!1,converter:XP.Json})],Ku.prototype,"configuration",2),Ku=l([qP({tagName:KP+"-console"})],Ku);import{CustomElement as JP,P as ZP}from"@pacem/pacem-core";var Rf=class extends Pl{constructor(){super()}_start(r=Date.now()){this._handle=requestAnimationFrame(()=>{let e=Date.now(),t=e-r;this.entry=Math.min(60,1e3/t),this._start(e)})}viewActivatedCallback(){super.viewActivatedCallback(),this._start()}disconnectedCallback(){cancelAnimationFrame(this._handle),super.disconnectedCallback()}};Rf=l([JP({tagName:ZP+"-fps"})],Rf);var $E={};tt($E,{AdapterOrientation:()=>tE,AdapterPageButtonRefreshEvent:()=>dy,AdapterPageButtonRefreshEventName:()=>Of,BalloonAlignment:()=>TS,BalloonBehavior:()=>LS,BalloonPopoutEventName:()=>OS,BalloonPopupEventName:()=>RS,BalloonPosition:()=>AS,BalloonSizing:()=>DS,BalloonTrigger:()=>NS,BinderAnchor:()=>HS,BinderEnd:()=>BS,BinderInteractionEvent:()=>my,BinderInteractionEventName:()=>US,BinderTension:()=>VS,CalendarEventSelectEvent:()=>_y,CalendarEventUnselectEvent:()=>xy,CalendarZoom:()=>qS,DateSelectEvent:()=>by,DialogButton:()=>oE,DialogButtons:()=>aE,DialogResultEvent:()=>fy,DialogResultEventName:()=>XS,ElementOrPointPropertyConverter:()=>Qu,LightboxBehavior:()=>gE,LoaderType:()=>gL,MEDIAQUERY_2K:()=>i$,MEDIAQUERY_4K:()=>s$,MEDIAQUERY_HD:()=>n$,MEDIAQUERY_LANDSCAPE:()=>o$,MEDIAQUERY_LG:()=>t$,MEDIAQUERY_MD:()=>e$,MEDIAQUERY_PORTRAIT:()=>a$,MEDIAQUERY_PREFERS_DARK:()=>c$,MEDIAQUERY_PREFERS_LIGHT:()=>l$,MEDIAQUERY_SM:()=>QI,MEDIAQUERY_XL:()=>r$,MEDIAQUERY_XS:()=>ZI,MarkdownService:()=>Kf,PacemAdaptedIterativeElement:()=>Xf,PacemAdapterElement:()=>at,PacemAgendaElement:()=>Pd,PacemAnchorElement:()=>Zi,PacemBalloonElement:()=>Gs,PacemBinderElement:()=>hn,PacemBladeElement:()=>th,PacemBottomSheetElement:()=>es,PacemBottomSheetHandleElement:()=>Rd,PacemButtonElement:()=>qr,PacemButtonsetElement:()=>Hf,PacemCalendarBaseElement:()=>Rn,PacemCalendarDayOfWeekRuleElement:()=>lh,PacemCalendarElement:()=>Hl,PacemCalendarEventElement:()=>ts,PacemCalendarRuleBaseElement:()=>Bf,PacemCalendarWithEventsBaseElement:()=>Uf,PacemClockElement:()=>oh,PacemCollapseElement:()=>Ja,PacemDialogBase:()=>nh,PacemDialogElement:()=>ui,PacemDividerElement:()=>uh,PacemIconElement:()=>hh,PacemImageElement:()=>Za,PacemInfiniteScrollerElement:()=>Bl,PacemLightboxElement:()=>hi,PacemLoaderElement:()=>Fs,PacemMarkdownElement:()=>fh,PacemMarqueeElement:()=>eo,PacemMediaQueryElement:()=>$d,PacemMenuCursorElement:()=>Hd,PacemMenuElement:()=>fn,PacemPagerElement:()=>mi,PacemPictureElement:()=>Ys,PacemPictureSourceElement:()=>to,PacemProgressbarElement:()=>Xs,PacemScheduleElement:()=>Id,PacemSidebarElement:()=>Bd,PacemSlideElement:()=>gh,PacemSlideshowElement:()=>ag,PacemStickyHeaderElement:()=>ro,PacemTabElement:()=>no,PacemTabsElement:()=>qs,PacemTickerElement:()=>Fl,PacemToastElement:()=>Zr,PacemTocElement:()=>Pn,PacemTunerElement:()=>Qr,PacemTweetEmbedElement:()=>vh,PacemVibrateElement:()=>xh,PacemViewElement:()=>rs,PacemWindowAreaElement:()=>gg,PacemWindowElement:()=>io,StickyHeaderVisibility:()=>VL,TimeSelectEvent:()=>yy,ViewDateChangeEvent:()=>vy});import{P as wt,PCSS as qa,Defaults as QP,CustomElement as e1,ViewChild as Ju,Watch as Ki,Utils as Ji,PropertyConverters as Nd,Debounce as t1,avoidHandler as ly,Throttle as bS}from"@pacem/pacem-core";import{Components as ES,UI as yS}from"@pacem/pacem-core";var{PacemElement:cy,RepeaterItemCreateEventName:_S,ItemRegisterEventName:xS,ItemUnregisterEventName:CS}=ES,tE=(e=>(e.Vertical="vertical",e.Horizontal="horizontal",e))(tE||{}),Of="pagerefresh",dy=class extends CustomEvent{constructor(r){super(Of,{detail:r,bubbles:!1,cancelable:!1})}},at=class extends ES.PacemAdapter{constructor(){super(...arguments);this._itemCreatedHandler=e=>{let t=e.detail.index;this._pageMap.set(t,e.detail.dom[0].firstElementChild),this._fireAdapterPageRefreshCallback(t,e.detail.item)};this._pageMap=new Map;this.interactive=!0;this.swipeEnabled=!0;this.loop=!0;this.labelCallback=(e,t)=>(t+1).toString();this._itemRegisterHandler=e=>{let t=e.detail;!Ji.isNull(this._swiper)&&t instanceof cy&&t.behaviors.indexOf(this._swiper)==-1&&t.behaviors.push(this._swiper)};this._itemUnregisterHandler=e=>{let t=e.detail,n;!Ji.isNull(this._swiper)&&t instanceof cy&&(n=t.behaviors.indexOf(this._swiper))>=0&&t.behaviors.splice(n,1)};this._keydownHandler=e=>{if(this.interactive)switch(this.orientation){case"vertical":switch(e.keyCode){case 40:this._next(e);break;case 38:this._previous(e);break}break;default:switch(e.keyCode){case 39:this._next(e);break;case 37:this._previous(e);break}break}}}masterPropertyChangedCallback(e,t,n,i){switch(super.masterPropertyChangedCallback(e,t,n,i),e){case"items":this._syncViewWithItems();break;case"index":this._index=n;break}}viewActivatedCallback(){super.viewActivatedCallback(),this._repeater.addEventListener(_S,this._itemCreatedHandler,!1),this._syncViewWithItems()}disconnectedCallback(){this._repeater&&this._repeater.removeEventListener(_S,this._itemCreatedHandler,!1),super.disconnectedCallback()}initializeCallback(){super.initializeCallback(),this.addEventListener("keydown",this._keydownHandler,!1);let e=this.master;if(!Ji.isNull(e)){let t=this._previousTabIndex=e.tabIndex;(!t||t<0)&&(e.tabIndex=0),e.addEventListener("keydown",this._keydownHandler,!1),e.addEventListener(xS,this._itemRegisterHandler,!1),e.addEventListener(CS,this._itemUnregisterHandler,!1)}this._syncViewWithItems()}destroyCallback(){this.removeEventListener("keydown",this._keydownHandler,!1);let e=this.master;if(!Ji.isNull(e)){if(e.removeEventListener("keydown",this._keydownHandler,!1),e.removeEventListener(xS,this._itemRegisterHandler,!1),e.removeEventListener(CS,this._itemUnregisterHandler,!1),!Ji.isNullOrEmpty(e.items))for(let t of e.items){let n=t.behaviors,i=n.indexOf(this._swiper);i>=0&&n.splice(i,1)}e.tabIndex=this._previousTabIndex}super.destroyCallback()}itemPropertyChangedCallback(e,t,n,i,s){super.itemPropertyChangedCallback(e,t,n,i,s),this._tickVersion(),this._fireAdapterPageRefreshCallback(e)}_fireAdapterPageRefreshCallback(e,t){t=t||this.master.items[e];var n=t.hide||!1,i=t.disabled||!1,s=this._labelCallback(t,e);let o=new dy({index:e,hide:n,disabled:i,content:s});this.dispatchEvent(o),n=this._isHidden(t,e,o.detail.hide),i=this._isDisabled(t,e,o.detail.disabled),s=o.detail.content;let c=this._pageMap;if(c.has(e)){let d=c.get(e),p=d.firstElementChild,u=h=>{h&&d.removeEventListener("load",u,!1),d.hide=n,d.disabled=i,p.content=s};d.isReady?u():d.addEventListener("load",u,!1)}}_tickVersion(){this._v=Date.now()}propertyChangedCallback(e,t,n,i){switch(super.propertyChangedCallback(e,t,n,i),e){case"interval":this._resetTimer(n);break;case"swipeEnabled":this._swiper.disabled=!n||!this.interactive;break;case"interactive":this.hidden=!n,this._swiper.disabled=!n||!this.swipeEnabled;break;case"pausable":n==!0?this._liPause.removeAttribute("hidden"):this._liPause.setAttribute("hidden","hidden");break}}_syncViewWithItems(){if(!(!this.isReady||Ji.isNull(this.master)||Ji.isNull(this._prevBtn)||Ji.isNull(this._nextBtn)||Ji.isNull(this._repeater))){var e=this.master.items;if(this._prevBtn.hide=this._nextBtn.hide=this._panel.hide=!(e&&e.length>1),this._panel.hide=Ji.isNullOrEmpty(e),this._repeater.datasource=e,this._index=this.master.index,!Ji.isNullOrEmpty(e))for(let t of e)t instanceof cy&&t.behaviors.indexOf(this._swiper)==-1&&t.behaviors.push(this._swiper)}}_toggle(e){(this._paused=!this._paused)?(ly(e),this._resetTimer(0)):this._next(e)}_resetTimer(e){clearInterval(this._handle),e>0&&(this._handle=window.setInterval(()=>{super.next()},e))}_next(e){e.type!==yS.SwipeEventType.SwipeLeft&&ly(e),this._resetTimer(this.interval),super.next(this.loop)}_previous(e){e.type!==yS.SwipeEventType.SwipeRight&&ly(e),this._resetTimer(this.interval),super.previous(this.loop)}_select(e,t){ly(t),this._resetTimer(this.interval),!this.deselectable||e!==this._index?super.select(e):this.master.index=this._index=-1}_isDisabled(e,t,n,i){return this._disableOrHide(e,t,n)}_isHidden(e,t,n,i){return this._disableOrHide(e,t,n)}_disableOrHide(e,t,n){let i=e instanceof cy&&n===!0;return(this._index===-1&&i===!1||i===!0&&t===this._index)&&(this.deselectable?this.master.index=this._index=-1:super.select(t)),i}_labelCallback(e,t,n){return this.labelCallback(e,t)}};l([Ju(wt+"-repeater")],at.prototype,"_repeater",2),l([Ju(wt+"-button."+qa+"-adapter-previous")],at.prototype,"_prevBtn",2),l([Ju(wt+"-button."+qa+"-adapter-next")],at.prototype,"_nextBtn",2),l([Ju(wt+"-panel")],at.prototype,"_panel",2),l([Ju(wt+"-swipe")],at.prototype,"_swiper",2),l([Ju("."+qa+"-adapter-dashboard > li[pacem]")],at.prototype,"_liPause",2),l([t1()],at.prototype,"_tickVersion",1),l([Ki({converter:Nd.Boolean})],at.prototype,"pausable",2),l([Ki({emit:!1,converter:Nd.Number})],at.prototype,"interval",2),l([Ki({emit:!1,converter:Nd.String})],at.prototype,"orientation",2),l([Ki({emit:!1,reflectBack:!0,converter:Nd.Boolean})],at.prototype,"interactive",2),l([Ki({emit:!1,reflectBack:!0,converter:Nd.Boolean})],at.prototype,"swipeEnabled",2),l([Ki({emit:!1,reflectBack:!0,converter:Nd.Boolean})],at.prototype,"deselectable",2),l([Ki({emit:!1,reflectBack:!0,converter:Nd.Boolean})],at.prototype,"loop",2),l([Ki({emit:!1})],at.prototype,"labelCallback",2),l([Ki()],at.prototype,"_index",2),l([Ki()],at.prototype,"_paused",2),l([Ki()],at.prototype,"_v",2),l([bS(333)],at.prototype,"_next",1),l([bS(333)],at.prototype,"_previous",1),at=l([e1({tagName:wt+"-adapter",shadow:QP.USE_SHADOW_ROOT,template:`<${wt}-button class="${qa}-adapter-previous" on-click=":host._previous($event)"><</${wt}-button>
|
|
15
|
+
<${wt}-button class="${qa}-adapter-next" on-click=":host._next($event)">></${wt}-button>
|
|
16
|
+
<${wt}-swipe on-swipeleft=":host._next($event)" on-swiperight=":host._previous($event)"></${wt}-swipe>
|
|
17
|
+
<${wt}-panel tabindex="0">
|
|
18
|
+
<${wt}-repeater>
|
|
19
|
+
<ol class="${qa}-adapter-dashboard">
|
|
20
|
+
<li pacem hidden>
|
|
21
|
+
<${wt}-button class="${qa}-play-pause"
|
|
22
|
+
css-class="{{ {'paused' : :host._paused, 'playing': !:host._paused } }}"
|
|
23
|
+
disabled="{{ !:host.pausable }}" on-click=":host._toggle($event)"></${wt}-button>
|
|
24
|
+
</li>
|
|
25
|
+
<template>
|
|
26
|
+
<li>
|
|
27
|
+
<${wt}-button on-click=":host._select(^index, $event)" class="${qa}-adapter-page" css-class="{{ { '${qa}-adapter-active': ^index === :host._index } }}">
|
|
28
|
+
<${wt}-span></${wt}-span>
|
|
29
|
+
</${wt}-button>
|
|
30
|
+
</li>
|
|
31
|
+
</template>
|
|
32
|
+
</ol></${wt}-repeater></${wt}-panel>`})],at);import{P as r1,PCSS as py,CustomElement as n1,Watch as Zu,Utils as It,PropertyConverters as Pf,Components as i1,PropertyChangeEvent as wS}from"@pacem/pacem-core";var Zi=class extends i1.PacemElement{constructor(){super("link");this._fetching=!1}get fetching(){return this._fetching}connectedCallback(){super.connectedCallback(),this.hasAttribute("tab-order")||(this.tabOrder=0)}propertyChangedCallback(e,t,n,i){switch(super.propertyChangedCallback(e,t,n,i),e){case"target":(It.isNullOrEmpty(n)?It.removeClass:It.addClass)(this,"a-target");break;case"href":(It.isNull(n)?It.removeClass:It.addClass)(this,"a-url");break;case"download":(It.isNullOrEmpty(n)?It.removeClass:It.addClass)(this,"a-download");break}}emit(e){if(super.emit(e),this.disabled)return;switch(e.type){case"mousedown":It.addClass(this,py+"-active");break;case"keydown":e.key==="Enter"&&(e.preventDefault(),It.addClass(this,py+"-active"));break;case"blur":case"mouseup":It.removeClass(this,py+"-active");break;case"keyup":e.key==="Enter"&&(this.click(),It.removeClass(this,py+"-active"));break}let t=this.href,n=this.target,i=this.router,s=this.download,o=()=>It.isNull(i)?t:It.URIs.format(t,i.state);!It.isNull(t)&&!e.defaultPrevented&&(e.type==="click"&&e.ctrlKey||e.type==="mousedown"&&e.button===1?window.open(o(),"_blank"):e.type==="click"&&(s===!0?this._download(o()):typeof s=="string"&&!It.isNullOrEmpty(s)?this._download(o(),s):It.isNullOrEmpty(n)?It.isNull(i)?location.assign(t):i.path=t:window.open(o(),n)))}async _download(e,t){this.dispatchEvent(new wS({propertyName:"fetching",oldValue:this._fetching,currentValue:this._fetching=!0}));try{await It.download(e,{credentials:this.fetchCredentials,headers:this.fetchHeaders,filename:t})}finally{this.dispatchEvent(new wS({propertyName:"fetching",oldValue:this._fetching,currentValue:this._fetching=!1}))}}};l([Zu({emit:!1,converter:Pf.String})],Zi.prototype,"fetchCredentials",2),l([Zu({emit:!1,converter:Pf.Json})],Zi.prototype,"fetchHeaders",2),l([Zu({reflectBack:!0,converter:Pf.String})],Zi.prototype,"href",2),l([Zu({reflectBack:!0,converter:Pf.String})],Zi.prototype,"target",2),l([Zu({reflectBack:!1,converter:{convert:e=>{switch(e){case"true":return!0;case"false":return!1;default:return e}},convertBack:e=>e}})],Zi.prototype,"download",2),l([Zu({reflectBack:!1,converter:Pf.Element})],Zi.prototype,"router",2),Zi=l([n1({tagName:r1+"-a"})],Zi);import{P as Td,PCSS as Ad,CustomElement as s1,Watch as kS,Utils as De,PropertyConverters as a1,Components as rE,PropertyChangeEvent as MS,ViewChild as nE,stopPropagationHandler as If,preventDefaultHandler as o1}from"@pacem/pacem-core";var Qu={convert:a=>document.querySelector(a)??JSON.parse(a)};var LS=(t=>(t.Menu="menu",t.Tooltip="tooltip",t.Inert="inert",t))(LS||{}),NS=(n=>(n.Hover="hover",n.Click="click",n.ContextMenu="contextmenu",n.Focus="focus",n))(NS||{}),TS=(n=>(n.Start="start",n.Center="center",n.End="end",n.Auto="auto",n))(TS||{}),AS=(o=>(o.Top="top",o.Left="left",o.Bottom="bottom",o.Right="right",o.Auto="auto",o.HorizontalAuto="x",o.VerticalAuto="y",o))(AS||{}),DS=(e=>(e.Auto="auto",e.Match="match",e))(DS||{}),RS="popup",OS="popout",iE={Defaults:{trigger:"hover",position:"auto",size:"auto",behavior:"menu",verticalOffset:0,horizontalOffset:0,hoverDelay:250,hoverTimeout:500,align:"center",track:!0}},PS="balloon-right balloon-left balloon-bottom balloon-top balloon-start balloon-center balloon-end",SS=Ad+"-balloon "+PS+" balloon-out balloon-in balloon-on",Gs=class extends rE.PacemElement{constructor(){super(...arguments);this._options=iE.Defaults;this._originalNeighborhood=null;this._popoutDelegate=e=>{this.popout()};this._hoverDelegate=e=>{this.disabled||this.popup(this._options.hoverDelay)};this._outConditionalDelegate=e=>{(e.srcElement||e.target)!=this&&this._outDelegate(e)};this._mousedownConditionalDelegate=e=>{o1(e),this._visible&&If(e)};this._outDelegate=e=>{this.popout(this._options.hoverTimeout)};this._toggleDelegate=e=>{e.preventDefault(),this._visible?this._outDelegate(e):this._hoverDelegate(e)}}get visible(){return this._visible}propertyChangedCallback(e,t,n,i){super.propertyChangedCallback(e,t,n,i),e==="target"?(t instanceof Element&&this._removeHandlers(t),n instanceof Element||this._adjust()):e==="options"?(this.target instanceof Element&&this._removeHandlers(this.target),this._options=De.extend({},De.clone(iE.Defaults),n),this._synchronizeOptions()):e==="disabled"&&n&&this.popout(),this.target instanceof Element&&e!=="disabled"&&this._setHandlers(this.target)}viewActivatedCallback(){super.viewActivatedCallback(),this._ensurePopup(),this.target=this.target||this.parentElement,this._synchronizeOptions()}disconnectedCallback(){super.disconnectedCallback(),this._destroyPopup(),this.target instanceof Element&&this._removeHandlers(this.target)}_synchronizeOptions(){let e=this,t=e.options||{};if(t.moveToRoot&&De.isNull(this._originalNeighborhood))this._originalNeighborhood={parent:e.parentElement,nextSibling:e.nextElementSibling},document.body.appendChild(e);else if(!t.moveToRoot&&!De.isNull(this._originalNeighborhood)){let n=this._originalNeighborhood.parent;De.isNull(n)||n.appendChild(e),this._originalNeighborhood=null}}_ensurePopup(){let e=this,t=e._container;return e&&t&&!De.hasClass(e,Ad+"-balloon")&&(De.addClass(e,Ad+"-balloon"),e.style.position="absolute",t.style.position="relative",t.style.zIndex="1",e.style.visibility="hidden"),e}_destroyPopup(){var e=this,t=e._container;De.removeClass(e,SS),e.style.position="",De.isNull(t)||(t.style.position="",t.style.zIndex="")}_registerEvents(){let e=this._ensurePopup(),t=this._options;switch(t.behavior){case"menu":switch(t.trigger){case"focus":e.addEventListener("mousedown",If,!1),e.addEventListener("focus",this._hoverDelegate,!1);break;case"click":case"contextmenu":e.addEventListener("mousedown",If,!1),window.document.body.addEventListener("mousedown",this._outConditionalDelegate,!1);break;default:e.addEventListener("mouseenter",this._hoverDelegate,!1),e.addEventListener("mouseleave",this._outDelegate,!1);break}break;case"tooltip":switch(t.trigger){case"focus":case"click":case"contextmenu":window.document.body.addEventListener("mousedown",this._outConditionalDelegate,!1);break;default:break}break}}_unregisterEvents(){var e=this._ensurePopup(),t=this._options;switch(t.behavior){case"menu":switch(t.trigger){case"focus":e.removeEventListener("mousedown",If,!1),e.removeEventListener("focus",this._hoverDelegate,!1);break;case"click":case"contextmenu":e.removeEventListener("mousedown",If,!1),window.document.body.removeEventListener("mousedown",this._outConditionalDelegate,!1);break;default:e.removeEventListener("mouseenter",this._hoverDelegate,!1),e.removeEventListener("mouseleave",this._outDelegate,!1);break}break;case"tooltip":switch(t.trigger){case"click":case"contextmenu":window.document.body.removeEventListener("mousedown",this._outConditionalDelegate,!1);break}break}}_onLayoutChange(e){this._visible&&this._adjust()}_adjust(){let e=this,t=e.target;if(De.isNull(t))return;let n=t instanceof Element?De.offset(t):{top:t.y,left:t.x,width:0,height:0},i=De.windowSize;var s=this._options,o=s.position,c=s.align;if(o!="top"&&o!="bottom"&&o!="left"&&o!="right"){let C=i.height,k=i.width,w=n.left-De.scrollLeft,T=n.top-De.scrollTop,I=C-(T+n.height),O=k-(w+n.width);o==="x"?o=w>O?"left":"right":o=T>I?"top":"bottom"}if(s.size==="match")switch(o){case"bottom":case"top":e.style.minWidth=n.width+"px",e.style.minHeight="";break;case"left":case"right":e.style.minHeight=n.height+"px",e.style.minWidth="";break}else e.style.minWidth=e.style.minHeight="";let d={width:e.offsetWidth,height:e.offsetHeight},p=n.width-d.width,u=p*.5,h=n.height-d.height,m=h*.5;switch(c){case"center":case"start":case"end":break;case"auto":switch(c="center",o){case"right":case"left":let C=De.scrollTop+i.height/2;n.top+n.height<C?c="start":n.top>C&&(c="end");break;case"top":case"bottom":let k=De.scrollLeft+i.width/2;n.left+n.width<k?c="start":n.left>k&&(c="end");break}break;default:c=iE.Defaults.align;break}De.removeClass(e,PS),De.addClass(e,"balloon-"+o),De.addClass(e,"balloon-"+c);let f=De.Css.getVariableValue(`--${Ad}-balloon-tail-size`),g=De.Css.getVariableValue(`--${Ad}-balloon-tail-inset`),v=parseInt(g)+.5*parseInt(f),b={width:n.width/2,height:n.height/2},_=s.autoAdjust&&v>b.width,E=s.autoAdjust&&v>b.height;switch(o){case"top":switch(n.top-=d.height,c){case"center":n.left+=u;break;case"end":n.left+=p,_&&(n.left+=v-b.width);break;case"start":_&&(n.left-=v-b.width);break}break;case"left":switch(n.left-=d.width,c){case"center":n.top+=m;break;case"end":n.top+=h,E&&(n.top+=v-b.height);break;case"start":E&&(n.top-=v-b.height);break}break;case"right":switch(n.left+=n.width,c){case"center":n.top+=m;break;case"end":n.top+=h,E&&(n.top+=v-b.height);break;case"start":E&&(n.top-=v-b.height);break}break;default:switch(n.top+=n.height,c){case"center":n.left+=u;break;case"end":n.left+=p,_&&(n.left+=v-b.width);break;case"start":_&&(n.left-=v-b.width);break}break}n.left=Math.min(i.width-d.width,Math.max(0,n.left)),n.top+=s.verticalOffset,n.left+=s.horizontalOffset,e.style.top=Math.round(n.top)+"px",e.style.left=Math.round(n.left)+"px"}_adjustWatchers(e){let t=this.options||{};De.isNull(this._resize)||(this._resize.disabled=!e,this._position.disabled=!e||!(t.track||t.trackPosition))}popup(e=0){if(clearTimeout(this._timer),e>0){this._timer=setTimeout(()=>this.popup(),e);return}let t=this,n=De.isVisible(t);this._adjustWatchers(!0),!(n||this.disabled)&&(this._registerEvents(),t.style.pointerEvents="none",this._visible=!0,t.style.visibility="visible",this._adjust(),De.addClass(t,"balloon-in"),De.addAnimationEndCallback(t,()=>{De.addClass(t,"balloon-on"),t.dispatchEvent(new MS({propertyName:"visible",oldValue:!1,currentValue:!0})),t.dispatchEvent(new Event(RS)),t.style.pointerEvents="auto"},500))}popout(e=0){if(clearTimeout(this._timer),e>0){this._timer=setTimeout(()=>this.popout(),e);return}var t=this;let n=De.isVisible(t);this._adjustWatchers(!1),n&&(this._unregisterEvents(),t.style.pointerEvents="none",De.removeClass(t,"balloon-in balloon-on"),De.addClass(t,"balloon-out"),De.addAnimationEndCallback(t,()=>{t.style.visibility="hidden",this._visible=!1,De.removeClass(t,SS),t.dispatchEvent(new Event(OS)),t.dispatchEvent(new MS({propertyName:"visible",oldValue:!0,currentValue:!1}))},500))}toggle(e=0){!De.isVisible(this)&&!this.disabled?this.popup(e):this.popout(e)}_removeHandlers(e){De.isNull(e)||(e.removeEventListener("mouseenter",this._hoverDelegate,!1),e.removeEventListener("mouseleave",this._outDelegate,!1),e.removeEventListener("mousedown",this._popoutDelegate,!1),e.removeEventListener("mousedown",this._mousedownConditionalDelegate,!1),e.removeEventListener("click",this._toggleDelegate,!1),e.removeEventListener("focus",this._hoverDelegate,!1),e.removeEventListener("blur",this._outDelegate,!1),e.removeEventListener("contextmenu",this._toggleDelegate,!1))}_setHandlers(e){this.popout();var t=this._options;if(t.behavior!="inert")switch(t.trigger){case"hover":e.addEventListener("mouseenter",this._hoverDelegate,!1),e.addEventListener("mouseleave",this._outDelegate,!1),e.addEventListener("mousedown",this._popoutDelegate,!1);break;case"focus":e.addEventListener("focus",this._hoverDelegate,!1),e.addEventListener("blur",this._outDelegate,!1);break;case"click":t.hoverDelay=t.hoverTimeout=0,e.addEventListener("mousedown",this._mousedownConditionalDelegate,!1),e.addEventListener("click",this._toggleDelegate,!1);break;case"contextmenu":t.hoverDelay=t.hoverTimeout=0,e.addEventListener("contextmenu",this._toggleDelegate,!1);break}}};l([nE(`.${Ad}-balloon`)],Gs.prototype,"_container",2),l([nE(Td+"-resize[content]")],Gs.prototype,"_resize",2),l([nE(Td+"-resize[watch-position=true]")],Gs.prototype,"_position",2),l([kS({converter:Qu})],Gs.prototype,"target",2),l([kS({emit:!1,converter:a1.Json})],Gs.prototype,"options",2),Gs=l([s1({tagName:Td+"-balloon",shadow:!0,template:`<${Td}-resize target="{{ :host.target }}" disabled="true" watch-position="true" on-${rE.ResizeEventName}=":host._onLayoutChange($event)"></${Td}-resize>
|
|
33
|
+
<div class="${Ad}-balloon"><${Td}-resize on-${rE.ResizeEventName}=":host._onLayoutChange($event)" disabled="true" content><slot></slot></${Td}-resize></div>
|
|
34
|
+
<div class="corner top-left" part="corner-topleft"></div><div class="corner bottom-left" part="corner-bottomleft"></div><div class="corner top-right" part="corner-topright"></div><div class="corner bottom-right" part="corner-bottomright"></div>`})],Gs);import{P as l1,PCSS as IS,CustomElement as c1,Watch as Ka,Utils as _t,PropertyConverters as Dd,Components as eh,CustomUIEvent as d1,CustomElementUtils as uy}from"@pacem/pacem-core";import{Point as p1}from"@pacem/pacem-foundation";var HS=(s=>(s.Auto="auto",s.Left="left",s.Top="top",s.Right="right",s.Bottom="bottom",s.Center="center",s))(HS||{}),BS=(n=>(n.Default="default",n.Arrow="arrow",n.FatArrow="fatarrow",n.None="none",n))(BS||{}),VS=(e=>(e.Mass="mass",e.Path="path",e))(VS||{}),US="interact",my=class extends d1{constructor(r){super(US,null,r)}},hy="pacem:components:ui:binders",sE=class{constructor(r){this.binders=[];this.fire=r=>{for(var e of this.binders)e.refresh(this.resize.target,r.detail)};let e=this.resize=new eh.PacemResizeElement;e.target=r,e.watchPosition=!0,document.body.appendChild(e)}dispose(){this.resize.remove()}},Il=class{static{this._pageBinders=[]}static _updateResizeListener(){let r=this._pageBinders;if(_t.isNull(this._bodyResizeListener)){let e=this._bodyResizeListener=new eh.PacemResizeElement;e.target=document.body,document.body.appendChild(e),document.addEventListener(eh.ResizeEventName,()=>{for(let t of r)t.invalidateSize()},!1)}this._bodyResizeListener.disabled=r.length===0}static register(r,e){var t=uy.getAttachedPropertyValue(r,hy),n=this._pageBinders;_t.isNull(t)&&(t=new sE(r),uy.setAttachedPropertyValue(r,hy,t)),t.binders.indexOf(e)==-1&&(t.binders.length===0&&t.resize.addEventListener(eh.ResizeEventName,t.fire,!1),e.refresh(r,t.resize.currentSize),t.binders.push(e)),n.indexOf(e)===-1&&(n.push(e),this._updateResizeListener())}static unregister(r,e){var t=uy.getAttachedPropertyValue(r,hy),n,i=this._pageBinders,s;!_t.isNull(t)&&(n=t.binders.indexOf(e))>-1&&(t.binders.splice(n,1),t.binders.length===0&&(t.resize.removeEventListener(eh.ResizeEventName,t.fire,!1),t.dispose(),uy.deleteAttachedPropertyValue(r,hy))),(s=i.indexOf(e))>=0&&(i.splice(s,1),this._updateResizeListener())}},$S=["click","dblclick","mouseover","mouseout","mouseenter","mouseleave","mousedown","mouseup","mousemove","contextmenu"],hn=class extends eh.PacemElement{constructor(){super(...arguments);this._broadcastHandler=e=>{var t=new my(e);this.dispatchEvent(t)};this._state={}}connectedCallback(){super.connectedCallback(),this._ensurePath()}viewActivatedCallback(){super.viewActivatedCallback(),this.from instanceof Element&&Il.register(this.from,this),this.to instanceof Element&&Il.register(this.to,this)}propertyChangedCallback(e,t,n,i){switch(super.propertyChangedCallback(e,t,n,i),e){case"from":case"to":t instanceof Element&&Il.unregister(t,this),n instanceof Element?Il.register(n,this):this.refresh(n);break;case"fromLimit":case"toLimit":case"fromEnd":case"toEnd":case"tension":this._draw();break;case"fromAnchor":this.refresh(this.from);break;case"toAnchor":this.refresh(this.to);break;case"cssClass":_t.isNull(this._svg)||this._svg.setAttribute("class",IS+"-binder "+this.className);break;case"hide":i||this._setPathVisibility();break}}disconnectedCallback(){_t.isNull(this._path)||($S.forEach(e=>{this._path.removeEventListener(e,this._broadcastHandler,!1)}),this._svg.remove(),this._path=void 0),this.from instanceof Element&&Il.unregister(this.from,this),this.to instanceof Element&&Il.unregister(this.to,this),super.disconnectedCallback()}_setPathVisibility(e=this._path,t=this.hide,n=this.interactive){_t.isNull(e)||(t?e.setAttribute("display","none"):e.removeAttribute("display"),n?(e.setAttribute("pointer-events","visibleStroke"),e.tabIndex=0):(e.removeAttribute("pointer-events"),e.tabIndex=-1))}_ensurePath(){if(_t.isNull(this._path)){let e=this._svg=document.createElementNS("http://www.w3.org/2000/svg","svg");e.style.position="absolute",_t.addClass(e,IS+"-binder "+this.className),e.style.top="0",e.style.left="0",e.style.overflow="hidden",e.style.pointerEvents="none";let t=this._path=document.createElementNS("http://www.w3.org/2000/svg","path");t.setAttribute("fill","none"),t.setAttribute("display","none"),this._setPathVisibility(),e.appendChild(t),this.invalidateSize(),document.body.appendChild(e),$S.forEach(n=>{t.addEventListener(n,this._broadcastHandler,!1)})}}invalidateSize(){let e=this._svg;_t.isNull(e)||(e.setAttribute("width",document.body.scrollWidth.toString()),e.setAttribute("height",document.body.scrollHeight.toString()))}_computeAnchorPoints(e,t,n,i,s,o,c){var d,p,u,h;let m=e.top,f=e.left,g=e.width,v=e.height,b=g/2,_=v/2,E=i.top,C=i.left,k=i.width,w=i.height,T=k/2,I=w/2,O={x:f+b,y:m+_},D={x:C+T,y:E+I},P={x:f+b,y:m},N={x:f+b,y:m+v},H={x:f,y:m+_},V={x:f+g,y:m+_},B={x:C+T,y:E},R={x:C+T,y:E+w},U={x:C,y:E+I},z={x:C+k,y:E+I},G={p1_top:P,p1_bottom:N,p1_left:H,p1_right:V,p2_top:B,p2_bottom:R,p2_left:U,p2_right:z};var Z={};function q(ee,J){let $e=ee+"_"+J;return Z[$e]=Z[$e]||p1.distance(G["p1_"+ee],G["p2_"+J])}if(t=="auto"||s=="auto"){let ee={x:O.x,y:-O.y},J={x:D.x,y:-D.y},$e=Math.atan2(J.y-ee.y,J.x-ee.x)*180/Math.PI;switch($e){case 0:t=="auto"&&(t="right"),s=="auto"&&(s="left");break;case 90:t=="auto"&&(t="top"),s=="auto"&&(s="bottom");break;case 180:t=="auto"&&(t="left"),s=="auto"&&(s="right");break;case-90:t=="auto"&&(t="bottom"),s=="auto"&&(s="top");break;default:if($e<90&&$e>0){let ue=q("top","left"),Te=q("right","left"),He=q("right","bottom"),ze=q("top","bottom");var Q=Math.min(ue,Te,He,ze);switch(Q){case ue:t=="auto"&&(t="top"),s=="auto"&&(s="left");break;case ze:t=="auto"&&(t="top"),s=="auto"&&(s="bottom");break;case He:t=="auto"&&(t="right"),s=="auto"&&(s="bottom");break;default:t=="auto"&&(t="right"),s=="auto"&&(s="left");break}}else if($e<180&&$e>90){let ue=q("top","right"),Te=q("left","right"),He=q("left","bottom"),ze=q("top","bottom");var Q=Math.min(ue,Te,He,ze);switch(Q){case ue:t=="auto"&&(t="top"),s=="auto"&&(s="right");break;case Te:t=="auto"&&(t="left"),s=="auto"&&(s="right");break;case He:t=="auto"&&(t="left"),s=="auto"&&(s="bottom");break;default:t=="auto"&&(t="top"),s=="auto"&&(s="bottom");break}}else if($e<-90){let ue=q("bottom","right"),Te=q("left","right"),He=q("left","top"),ze=q("bottom","top");var Q=Math.min(ue,Te,He,ze);switch(Q){case ue:t=="auto"&&(t="bottom"),s=="auto"&&(s="right");break;case Te:t=="auto"&&(t="left"),s=="auto"&&(s="right");break;case He:t=="auto"&&(t="left"),s=="auto"&&(s="top");break;default:t=="auto"&&(t="bottom"),s=="auto"&&(s="top");break}}else{let ue=q("bottom","left"),Te=q("right","left"),He=q("right","top"),ze=q("bottom","top");var Q=Math.min(ue,Te,He,ze);switch(Q){case ue:t=="auto"&&(t="bottom"),s=="auto"&&(s="left");break;case Te:t=="auto"&&(t="right"),s=="auto"&&(s="left");break;case He:t=="auto"&&(t="right"),s=="auto"&&(s="top");break;default:t=="auto"&&(t="bottom"),s=="auto"&&(s="top");break}}break}}function Ne(ee){switch(ee){case"arrow":case"fatarrow":return 2;default:return 1}}let ne=Ne(n),pe=Ne(o);switch(t){case"bottom":d=N;break;case"center":d={x:f+b,y:m+_},u=d;break;case"left":d=H;break;case"right":d=V;break;case"top":d=P;break}switch(s){case"bottom":p=R;break;case"center":p={x:C+T,y:E+I},h=p;break;case"left":p=U;break;case"right":p=z;break;case"top":p=B;break}switch(c){case"path":let ee=.333;switch(t){case"bottom":u={x:d.x,y:d.y+Math.abs(ne*ee*(p.y-d.y))};break;case"left":u={x:d.x-Math.abs(ne*ee*(p.x-d.x)),y:d.y};break;case"right":u={x:d.x+Math.abs(ne*ee*(p.x-d.x)),y:d.y};break;case"top":u={x:d.x,y:d.y-Math.abs(ne*ee*(d.y-p.y))};break}switch(s){case"bottom":h={x:p.x,y:p.y+Math.abs(pe*ee*(p.y-d.y))};break;case"left":h={x:p.x-Math.abs(pe*ee*(p.x-d.x)),y:p.y};break;case"right":h={x:p.x+Math.abs(pe*ee*(p.x-d.x)),y:p.y};break;case"top":h={x:p.x,y:p.y-Math.abs(pe*ee*(p.y-d.y))};break}break;default:switch(t){case"bottom":u={x:d.x,y:d.y+Math.abs(ne*(N.y-O.y))};break;case"left":u={x:d.x-Math.abs(ne*(O.x-H.x)),y:d.y};break;case"right":u={x:d.x+Math.abs(ne*(V.x-O.x)),y:d.y};break;case"top":u={x:d.x,y:d.y-Math.abs(ne*(P.y-O.y))};break}switch(s){case"bottom":h={x:p.x,y:p.y+Math.abs(pe*(R.y-D.y))};break;case"left":h={x:p.x-Math.abs(pe*(D.x-U.x)),y:p.y};break;case"right":h={x:p.x+Math.abs(pe*(z.x-D.x)),y:p.y};break;case"top":h={x:p.x,y:p.y-Math.abs(pe*(B.y-D.y))};break}}return{points:[d,u,p,h],anchors:[t,s]}}refresh(e,t){var n;if(_t.isNull(e)||_t.isNull(n=this._path))return;let i=!_t.isNull(this.from)&&!_t.isNull(this.to),s=_t.isNull(this.from)&&_t.isNull(this.to);if((this.disabled||!i)&&(n.removeAttribute("d"),s))return;let o=e===this.from?"from":"to";var c=(o==="from"?this.fromAnchor:this.toAnchor)||"auto";_t.isNull(t)&&(e instanceof Element?o in this._state&&(t=this._state[o].size):(t={height:0,width:0,left:e.x,top:e.y},c="center")),!_t.isNull(t)&&(this._state[o]={size:t,anchor:c},i&&this._draw())}_draw(){var e=this._state.from,t=this._state.to,n=this._path;if(_t.isNull(n))return;if(_t.isNullOrEmpty(e)||_t.isNullOrEmpty(t)||this.from instanceof HTMLElement&&!_t.isVisible(this.from)||this.to instanceof HTMLElement&&!_t.isVisible(this.to)){n.setAttribute("d","");return}let{points:i,anchors:s}=this._computeAnchorPoints(e.size,e.anchor,this.fromEnd,t.size,t.anchor,this.toEnd,this.tension),o=i[0],c=i[1],d=i[2],p=i[3],u=s[0],h=s[1],m=o.x,f=o.y,g=c.x,v=c.y,b=d.x,_=d.y,E=p.x,C=p.y,k=this._getDefaultEndingPath(m,f);switch(this.fromEnd){case"arrow":k=this._getArrowEndingPath(m,f,u);break;case"fatarrow":k=this._getFatArrowEndingPath(m,f,u);break;case"none":k="";break}let w=this._getDefaultEndingPath(b,_);switch(this.toEnd){case"arrow":w=this._getArrowEndingPath(b,_,h);break;case"fatarrow":w=this._getFatArrowEndingPath(b,_,h);break;case"none":w="";break}let T=k+`M${m},${f} C${g},${v} ${E},${C} ${b},${_}`+w;T.indexOf("NaN")===-1&&n.setAttribute("d",T),_t.isNullOrEmpty(this.color)||(n.style.stroke=this.color)}_getDefaultEndingPath(e,t){return`M${e-2},${t-2} h4 v4 h-4 z`}_getArrowEndingPath(e,t,n){switch(n){case"bottom":return`M${e-4},${t+4} l4,-4 l4,4`;case"top":return`M${e-4},${t-4} l4,4 l4,-4`;case"left":return`M${e-4},${t-4} l4,4 l-4,4`;case"right":return`M${e+4},${t-4} l-4,4 l4,4`;default:return""}}_getFatArrowEndingPath(e,t,n){switch(n){case"bottom":case"top":case"left":case"right":return this._getArrowEndingPath(e,t,n)+" z";default:return""}}};l([Ka({emit:!1,converter:Qu})],hn.prototype,"from",2),l([Ka({emit:!1,converter:Qu})],hn.prototype,"to",2),l([Ka({emit:!1,converter:Dd.String})],hn.prototype,"fromAnchor",2),l([Ka({emit:!1,converter:Dd.String})],hn.prototype,"toAnchor",2),l([Ka({emit:!1,converter:Dd.String})],hn.prototype,"fromEnd",2),l([Ka({emit:!1,converter:Dd.String})],hn.prototype,"toEnd",2),l([Ka({emit:!1,converter:Dd.String})],hn.prototype,"tension",2),l([Ka({emit:!1,converter:Dd.String})],hn.prototype,"color",2),l([Ka({emit:!1,converter:Dd.Boolean})],hn.prototype,"interactive",2),hn=l([c1({tagName:l1+"-binder"})],hn);import{P as u1,CustomElement as h1,Watch as m1,Utils as zS,PropertyConverters as f1,Components as g1}from"@pacem/pacem-core";var v1="blade-open",th=class extends g1.PacemElement{propertyChangedCallback(r,e,t,n){super.propertyChangedCallback(r,e,t,n),r==="open"&&this._toggle(t)}_toggle(r=this.open){(r?zS.addClass:zS.removeClass)(this,v1);let t=r?"open":"close";this.dispatchEvent(new Event(t))}};l([m1({emit:!1,converter:f1.Boolean})],th.prototype,"open",2),th=l([h1({tagName:u1+"-blade",shadow:!0})],th);import{P as qt,PCSS as GS,CustomElement as FS,Watch as WS,Utils as kt,PropertyConverters as jS,Components as rh,preventDefaultHandler as b1,ViewChild as $f,CustomElementUtils as y1,UI as Qi}from"@pacem/pacem-core";var _1="bottom-sheet-open",$l,Rd=class extends rh.PacemElement{constructor(){super(...arguments);$(this,$l);this._clickHandler=e=>{let t=x(this,$l);t.open=!t.open}}viewActivatedCallback(){super.viewActivatedCallback(),this._setIcon(),this._toggleHandle(),A(this,$l,y1.findAncestorOfType(this,es)),this._bindToBottomSheet()}propertyChangedCallback(e,t,n,i){if(super.propertyChangedCallback(e,t,n,i),!i)switch(e){case"iconGlyph":this._setIcon(n);break;case"disabled":this._toggleHandle(n);break}}disconnectedCallback(){this.removeEventListener("click",this._clickHandler);let e=x(this,$l);kt.isNull(e)||e._setHandle(null),A(this,$l,null),super.disconnectedCallback()}_bindToBottomSheet(){let e=x(this,$l);if(kt.isNull(e))return;let t=kt.isNullOrEmpty(this.id)?this.id="handle_"+kt.uniqueCode():this.id;e._setHandle(this),this.addEventListener("click",this._clickHandler,!1)}_toggleHandle(e=this.disabled){this.style.pointerEvents=e?"none":""}_setIcon(e=this.iconGlyph){let t=this._icon;kt.isNull(t)||(t.icon=e??"horizontal_rule")}};$l=new WeakMap,l([$f(qt+"-icon")],Rd.prototype,"_icon",2),l([WS({emit:!1,converter:jS.String})],Rd.prototype,"iconGlyph",2),Rd=l([FS({tagName:qt+"-bottom-sheet-handle",shadow:!1,template:`<div class="bottom-sheet-handle">
|
|
35
|
+
<${qt}-icon class="icon-size icon-size-6"></${qt}-icon>
|
|
36
|
+
</div>`})],Rd);var es=class extends rh.PacemElement{constructor(){super(...arguments);this._resizeHandler=e=>{this._rebuildSwiperSnaps(),this._setPosition()};this._panHandler=e=>{let t=this._swiper.snaps.find(o=>o!=0),{delta:n}=e.detail,i=(t<0?n.clamp(t,0):n.clamp(0,t))/t;t>0&&(i=1-i);let s=6*i**2;this.style.backdropFilter=`blur(${s.toFixed(2)}px)`};this._swipeHandler=e=>{switch(b1(e),e.type){case Qi.SwipeEventType.SwipeAnimationEnd:this.style.backdropFilter="";return;case Qi.SwipeEventType.SwipeUpAnimationEnd:this.open=!0;break;case Qi.SwipeEventType.SwipeDownAnimationEnd:this.open=!1;break}this._setPosition()}}propertyChangedCallback(e,t,n,i){if(super.propertyChangedCallback(e,t,n,i),!i)switch(e){case"open":this._toggle(n),this._rebuildSwiperSnaps(n);break;case"logger":this._assignLogger(n);break;case"disabled":this._toggleSwiper(n);break}}_toggleSwiper(e=this.disabled){let t=this._swiper;kt.isNull(t)||(t.disabled=e)}_setHandle(e){kt.isNull(e)?this._swiper.handleSelector=null:this._swiper.handleSelector=`#${e.id}`,this._handleResizer.target=e}_assignLogger(e=this.logger){this._swiper.logger=e}_rebuildSwiperSnaps(e=this.open){let t=this._swiper,n=this._getSnap(e);t.snaps=[0,n].sort()}viewActivatedCallback(){super.viewActivatedCallback(),this._assignLogger(),this._resizer.addEventListener(rh.ResizeEventName,this._resizeHandler),this._handleResizer.addEventListener(rh.ResizeEventName,this._resizeHandler);let e=this._swiper;e.addEventListener(Qi.SwipeEventType.Pan,this._panHandler,!1),e.addEventListener(Qi.SwipeEventType.SwipeAnimationEnd,this._swipeHandler,!1),e.addEventListener(Qi.SwipeEventType.SwipeUpAnimationEnd,this._swipeHandler,!1),e.addEventListener(Qi.SwipeEventType.SwipeDownAnimationEnd,this._swipeHandler,!1),this._toggle(),this._rebuildSwiperSnaps(),this._toggleSwiper()}disconnectedCallback(){let e=this._resizer;kt.isNull(e)||e.removeEventListener(rh.ResizeEventName,this._resizeHandler);let t=this._handleResizer;kt.isNull(e)||t.removeEventListener(rh.ResizeEventName,this._resizeHandler);let n=this._swiper;kt.isNull(n)||(n.removeEventListener(Qi.SwipeEventType.Pan,this._panHandler),n.removeEventListener(Qi.SwipeEventType.SwipeAnimationEnd,this._swipeHandler),n.removeEventListener(Qi.SwipeEventType.SwipeUpAnimationEnd,this._swipeHandler),n.removeEventListener(Qi.SwipeEventType.SwipeDownAnimationEnd,this._swipeHandler)),super.disconnectedCallback()}_getSnap(e=this.open){let t=this._resizer,n=this._handleResizer;if(kt.isNull(t)||kt.isNull(n))return 0;let{top:i}=kt.naturalOffset(t.target),{top:s}=kt.naturalOffset(n.target),{height:o}=t.currentSize,{height:c}=n.currentSize,{height:d}=kt.windowSize,p=Math.max(parseInt(kt.Css.getVariableValue(`--${GS}-layout-header-height`)),d-(o??0)),u=d-((i??0)-(s??0)+(c??0));return(e?1:-1)*Math.abs(p-u)}_getCssTransform(e=this.open){let t=this._resizer,n=this._handleResizer;if(kt.isNull(t)||kt.isNull(n))return"";if(e)return`translate3d(0, max(var(--${GS}-layout-header-height), calc(100vh - 100%)), 0)`;{let{top:i}=kt.naturalOffset(t.target),{top:s,height:o}=kt.naturalOffset(n.target);return`translate3d(0, calc(100vh - ${-(i??0)+(s??0)+(o??0)}px), 0)`}}_setPosition(e=this.open){let t=this._sheet,n=this._getCssTransform(e);t.style.transform=n}_toggle(e=this.open){(e?kt.addClass:kt.removeClass)(this,_1),this._sheet.style.transform="";let n=e?"open":"close";this.dispatchEvent(new Event(n))}};l([$f(qt+"-swipe")],es.prototype,"_swiper",2),l([$f(qt+"-resize")],es.prototype,"_resizer",2),l([$f(qt+"-resize[handle]")],es.prototype,"_handleResizer",2),l([$f(qt+"-panel.bottom-sheet")],es.prototype,"_sheet",2),l([WS({emit:!1,converter:jS.Boolean})],es.prototype,"open",2),es=l([FS({tagName:qt+"-bottom-sheet",shadow:!1,template:`
|
|
37
|
+
<${qt}-swipe direction="vertical" options='{ "bouncy": false }'></${qt}-swipe>
|
|
38
|
+
<${qt}-resize target="{{ ::_sheet }}"></${qt}-resize>
|
|
39
|
+
<${qt}-resize handle></${qt}-resize>
|
|
40
|
+
<${qt}-panel class="bottom-sheet" behaviors="{{ [::_swiper] }}">
|
|
41
|
+
<${qt}-content></${qt}-content>
|
|
42
|
+
</${qt}-panel>`})],es);import{P as M1,PCSS as gy,CustomElement as S1,Watch as ih,Utils as sh,PropertyConverters as ah,Components as L1,CommandEvent as N1}from"@pacem/pacem-core";import{Watch as x1,Utils as C1,Components as E1,CustomTypedEvent as w1,Logging as YS,avoidHandler as k1}from"@pacem/pacem-core";var aE=(n=>(n.YesNo="yesno",n.YesNoCancel="yesnocancel",n.Ok="ok",n.OkCancel="okcancel",n))(aE||{}),oE=(n=>(n.Yes="yes",n.No="no",n.Cancel="cancel",n.Ok="ok",n))(oE||{}),XS="commit",fy=class extends w1{constructor(r){super(XS,r)}},nh=class extends E1.PacemElement{#e;open(r){let e=this.lightbox;if(!C1.isNull(this.#e))throw"Dialog already open.";let t=this.#e=Promise.withResolvers();return this.hide||this.disabled?(this.log(YS.LogLevel.Warn,"Dialog hidden or disabled, opening forbidden."),t.reject()):(this.dispatchEvent(new Event("open")),e.show=!0,this.state=r),t.promise}commit(r,e){k1(e),this.log(YS.LogLevel.Debug,`Committing dialog by clicking '${r}'.`);let t=this.state;var n=new fy({button:r,state:t});this.lightbox.show=!1,this.#e.resolve(n.detail),this.#e=null,this.dispatchEvent(n)}};l([x1()],nh.prototype,"state",2);var qr=class extends L1.PacemIterableElement{constructor(){super("button")}connectedCallback(){super.connectedCallback(),this.hasAttribute("tab-order")||(this.tabOrder=0)}propertyChangedCallback(r,e,t,n){switch(super.propertyChangedCallback(r,e,t,n),r){case"iconGlyph":case"iconUrl":this.dataset[r]=t;break}}emit(r){let e=t=>{if(super.emit(t),!t.defaultPrevented)if(t.type==="click"&&!sh.isNullOrEmpty(this.commandName))this.dispatchEvent(new N1({commandName:this.commandName,commandArgument:this.commandArgument}));else switch(t.type){case"mousedown":r.button===0&&sh.addClass(this,gy+"-active");break;case"keydown":(t.keyCode===32||t.keyCode===13)&&(r.preventDefault(),sh.addClass(this,gy+"-active"));break;case"blur":case"mouseup":sh.removeClass(this,gy+"-active");break;case"keyup":(t.keyCode===32||t.keyCode===13)&&(this.click(),sh.removeClass(this,gy+"-active"));break}};!this.disabled&&r.type==="click"&&!sh.isNull(this.confirmationDialog)?this.confirmationDialog.open(this.confirmationMessage).then(t=>{(t.button==="yes"||t.button==="ok")&&e(r)}):(!(r instanceof MouseEvent)||r.button===0)&&e(r)}};l([ih({emit:!1,converter:ah.String})],qr.prototype,"iconGlyph",2),l([ih({emit:!1,converter:ah.String})],qr.prototype,"iconUrl",2),l([ih({emit:!1,converter:ah.String})],qr.prototype,"commandName",2),l([ih({emit:!1,converter:ah.Json})],qr.prototype,"commandArgument",2),l([ih({emit:!1,converter:ah.String})],qr.prototype,"confirmationMessage",2),l([ih({emit:!1,converter:ah.Element})],qr.prototype,"confirmationDialog",2),qr=l([S1({tagName:M1+"-button"})],qr);import{P as T1,CustomElement as A1,Components as D1}from"@pacem/pacem-core";var Hf=class extends D1.PacemIterativeElement{connectedCallback(){super.connectedCallback(),"tabindex"in this.attributes||(this.tabIndex=0)}propertyChangedCallback(r,e,t,n){switch(super.propertyChangedCallback(r,e,t,n),r){case"index":let s=0;for(var i of this.items){if(s==t){i.focus();break}s++}break}}validate(r){return r instanceof qr}};Hf=l([A1({tagName:T1+"-buttonset"})],Hf);import{P as X,PCSS as cE,CustomElement as dh,Watch as lr,ViewChild as lE,Utils as ce,PropertyConverters as Ir,Components as dE,CustomTypedEvent as zf,PropertyChangeEvent as pE,Defaults as uE,CustomElementUtils as R1,Debounce as O1,PropertyChangeEventName as P1}from"@pacem/pacem-core";var qS=(t=>(t.Month="month",t.Week="week",t.Day="day",t))(qS||{}),vy=class extends zf{constructor(r){super("viewdatechange",r)}},by=class extends zf{constructor(r){super("dateselect",r,{bubbles:!0})}},yy=class extends zf{constructor(r){super("timeselect",r,{bubbles:!0})}},Vf=1e3*60*60,ch=Vf*24,Od=[0,.5,1,1.5,2,2.5,3,3.5,4,4.5,5,5.5,6,6.5,7,7.5,8,8.5,9,9.5,10,10.5,11,11.5,12,12.5,13,13.5,14,14.5,15,15.5,16,16.5,17,17.5,18,18.5,19,19.5,20,20.5,21,21.5,22,22.5,23,23.5],I1=new Date,$1=ce.Dates.dateOnly(I1).valueOf(),H1=["sunday","monday","tuesday","wednesday","thursday","friday","saturday"],ts=class extends dE.PacemItemElement{propertyChangedCallback(r,e,t,n){super.propertyChangedCallback(r,e,t,n),cancelAnimationFrame(this._handle),this._handle=requestAnimationFrame(()=>{let i=this.container;ce.isNull(i)||i.dispatchEvent(new pE({propertyName:"items",oldValue:i.items,currentValue:i.items}))})}};l([lr({converter:Ir.Datetime})],ts.prototype,"start",2),l([lr({converter:Ir.Datetime})],ts.prototype,"end",2),l([lr({converter:Ir.String})],ts.prototype,"caption",2),l([lr({converter:Ir.Json})],ts.prototype,"place",2),l([lr({converter:Ir.Boolean})],ts.prototype,"allDay",2),ts=l([dh({tagName:X+"-calendar-event"})],ts);var _y=class extends zf{constructor(r){super("eventselect",r,{bubbles:!1,cancelable:!0})}},xy=class extends zf{constructor(r){super("eventunselect",r,{bubbles:!1,cancelable:!0})}},Rn=class extends dE.PacemItemsContainerElement{validate(r){return r instanceof ts}propertyChangedCallback(r,e,t,n){switch(super.propertyChangedCallback(r,e,t,n),(r==="viewDate"||r==="weekStart")&&this._synchronizeWeek(),r){case"viewDate":this.dispatchEvent(new vy(t)),ce.removeClass(this,"viewdate-next viewdate-previous"),requestAnimationFrame(()=>{ce.addClass(this,e>t?"viewdate-previous":"viewdate-next")});break;case"zoom":ce.removeClass(this,"viewdate-next viewdate-previous");break}}oneventselect(r,e){this.dispatchEvent(new _y({element:r,event:e}))}oneventunselect(r,e){this.dispatchEvent(new xy({element:r,event:e}))}getHeaderLabel(r,e){let t=e==="week"?{weekday:"short",day:"numeric",month:"numeric"}:e==="day"?{weekday:"long"}:{weekday:"short"};return ce.parseDate(r).toLocaleString(ce.lang(this),t)}getDayLabel(r){let e=r.getDate()==1?{month:"short",day:"numeric"}:{day:"numeric"};return ce.parseDate(r).toLocaleString(ce.lang(this),e)}getHourLabel(r){let e={hour:"numeric"};return ce.parseDate(r).toLocaleString(ce.lang(this),e)}getTimeLabel(r){let e={hour:"numeric",minute:"numeric"};return ce.parseDate(r).toLocaleString(ce.lang(this),e)}isNow(r,e){let t=ce.parseDate(r),n=ce.parseDate(e||new Date);return t.getHours()===n.getHours()&&this.isToday(r,e)}isToday(r,e){return this.isDate(r,e||new Date)}isViewDay(r,e=this.viewDate){return this.isDate(r,e||this.viewDate||new Date)}isDate(r,e){if(!ce.Dates.isDate(e)||!ce.Dates.isDate(r))return!1;let t=ce.parseDate(r),n=ce.parseDate(e);return t.getDate()===n.getDate()&&t.getMonth()==n.getMonth()&&t.getFullYear()===n.getFullYear()}isViewWeek(r){let e=ce.parseDate(r);return this.week&&this.week.find(t=>t.getDate()==e.getDate()&&t.getMonth()==e.getMonth()&&t.getDate()==e.getDate())}isViewMonth(r){let e=ce.parseDate(r),t=ce.parseDate(this.viewDate||new Date);return e.getMonth()==t.getMonth()&&e.getFullYear()===t.getFullYear()}isTimeSlotDisabled(r,e,t){if(!ce.isNullOrEmpty(r)){t=t||0;let n=new Date(e.getFullYear(),e.getMonth(),e.getDate(),Math.floor(t),60*(t%1)),i=n.getTimezoneOffset(),s=n.valueOf()-i*60*1e3;for(let o of r){let c=ce.Dates.parse(o.from),d=ce.Dates.parse(o.to);if((!c||c&&c.valueOf()<=s)&&(!d||d&&d.valueOf()>s)&&(d||c))return!0}}return!1}_getWeekStart(r,e){let t=r.getDay(),n=r.valueOf(),i=(e||"m").toLowerCase().startsWith("m")?1:0;return t===i?n:(t===0&&(t=7),n+(i-t)*ch)}_getDatasource(r,e=this.weekStart){let t=ce.Dates.dateOnly(ce.parseDate(r)),n=this.month,i=n&&n.length&&n[0]&&n[0].length&&n[0][0];if(i&&i.getMonth()==t.getMonth()&&i.getFullYear()==t.getFullYear()&&n.find(p=>!ce.isNull(p.find(u=>u.valueOf()==t.valueOf()))))return n;let s=new Date(t.getFullYear(),t.getMonth(),1),o=this._getWeekStart(s,e),c=[],d=[];do{let p=ce.Dates.dateOnly(new Date(o));d.push(p),d.length==7&&c.push(d.splice(0)),o=p.valueOf()+ch+Vf}while(c.length<6);return this.month=c}_synchronizeWeek(){let r=ce.parseDate(this.viewDate),e=new Date(r.getFullYear(),r.getMonth(),1),n=this._getDatasource(e,this.weekStart).filter((i,s)=>i.some(o=>o.getDate()==r.getDate()&&o.getMonth()==r.getMonth()&&o.getFullYear()==r.getFullYear()))[0];(!(this.week&&this.week.length)||this.week[0]!==n[0])&&(this.week=n)}};l([lr({converter:Ir.Datetime})],Rn.prototype,"viewDate",2),l([lr({converter:Ir.Datetime})],Rn.prototype,"now",2),l([lr({converter:Ir.String})],Rn.prototype,"zoom",2),l([lr({converter:Ir.String})],Rn.prototype,"weekStart",2),l([lr({converter:Ir.Eval})],Rn.prototype,"week",2),l([lr({converter:Ir.Eval})],Rn.prototype,"month",2),l([lr({converter:Ir.Eval})],Rn.prototype,"disabledRanges",2);var Uf=class extends Rn{constructor(){super(...arguments);this._datasource=[]}get datasource(){return this._datasource}_getSortedItems(e){return e.slice().sort((t,n)=>{let i=t.start.valueOf(),s=n.start.valueOf();if(i!=s)return i<s?-1:1;let o=t.end.valueOf(),c=n.end.valueOf(),d=o-i,p=c-s;return d!=p?d>p?-1:1:0})}propertyChangedCallback(e,t,n,i){switch(super.propertyChangedCallback(e,t,n,i),e){case"month":case"week":case"items":case"zoom":case"viewDate":cancelAnimationFrame(this._handle),this._handle=requestAnimationFrame(()=>{let s=this._datasource,o=this._datasource=this.buildDataSource(this._getSortedItems(this.items||[]));this.dispatchEvent(new pE({propertyName:"datasource",oldValue:s,currentValue:o}))});break}}};function KS(a,r){let e=r.length-1,t=r[0].valueOf(),n=r[e].valueOf();return a.filter(i=>{let s=ce.Dates.dateOnly(i.start),o=ce.Dates.dateOnly(i.end);return s.valueOf()<=n&&o.valueOf()>=t}).map(i=>{let s=ce.Dates.dateOnly(i.start),o=r.find(f=>f.valueOf()==s.valueOf()),c=r.indexOf(o),d=ce.Dates.dateOnly(i.end),p=r.find(f=>f.valueOf()==d.valueOf()),u=r.indexOf(p),h=c==-1?0:c,m=u==-1?e:u;return{start:i.start,end:i.end,allDay:!0,day:h,continuing:{start:c==-1,end:u==-1},span:m+1-h,caption:i.caption,event:i}})}function B1(){let a="";for(let r=0;r<7;r++)r==0&&(a+='<div class="agenda-left all-day"></div>'),a+=`<${X}-panel class="agenda-slot all-day day-${r+1}" css-class="{{ {'viewday': :host.isViewDay(:host.week[${r}], :host.viewDate), 'today': :host.isToday(:host.week[${r}], :host.now)} }}"></${X}-panel>`;for(let r=0;r<7;r++)for(let e of Od){let t=e%1==0,n=`hour-${t?"whole":"half"}`;r==0&&t&&(a+=`<${X}-text class="agenda-left ${n} hour-${e*2+1}"" text="{{ :host.getHourLabel(${$1+e*Vf}) }}"></${X}-text>`),a+=`<${X}-panel on-click=":host.time = Pacem.Utils.Dates.parse(:host.week[${r}].valueOf() + ${e*Vf})" disabled="{{ :host.isTimeSlotDisabled(:host.disabledRanges, :host.week[${r}], ${e}) }}" class="agenda-slot ${n} day-${r+1} hour-${e*2+1}" css-class="{{ {'viewday': :host.isViewDay(:host.week[${r}], :host.viewDate), 'today': :host.isToday(:host.week[${r}], :host.now)} }}"></${X}-panel>`}return a}var Pd=class extends Uf{constructor(){super(...arguments);this._allDayDatasource=[]}buildDataSource(e){var t=this.week;this.zoom==="day"&&(t=[ce.Dates.dateOnly(this.viewDate)]);let n=[];if(!ce.isNull(t)){this.dispatchEvent(new pE({propertyName:"allDayDatasource",oldValue:this._allDayDatasource,currentValue:this._allDayDatasource=KS(e.filter(i=>i.end.valueOf()-i.start.valueOf()>=ch),t)}));for(let i=0;i<t.length;i++){let s=t[i],o=s.valueOf(),c=e.filter(d=>{let p=ce.Dates.dateOnly(d.start),u=ce.Dates.dateOnly(d.end);return p.valueOf()<=o&&u.valueOf()>=o}).map(d=>{let p=d.start.valueOf(),u=d.end.valueOf(),h={allDay:d.allDay||u-p>=ch,continuing:{start:p<o,end:u>o+ch},caption:d.caption,hour:0,span:Od.length-1,offset:{start:"0",end:"0"},event:d},m=d.start.getHours()+d.start.getMinutes()/60,f=h.continuing.start?0:Math.floor(m*2),g=d.end.getHours()+d.end.getMinutes()/60,v=-1+(h.continuing.end?Od.length:Math.ceil(g*2)),b=v+1,_=b>=Od.length?24:Od[b],E=_-Od[f];return h.hour=f,h.span=1+v-f,h.continuing.start||(h.offset.start=(m-Od[f])/E*100+"%"),h.continuing.end||(h.offset.end=(_-g)/E*100+"%"),h});n.push(c)}}return n}get allDayDatasource(){return this._allDayDatasource}propertyChangedCallback(e,t,n,i){super.propertyChangedCallback(e,t,n,i);let s=this._clock;if(e==="time")this.dispatchEvent(new yy(n));else if(!ce.isNull(s)&&(e==="now"&&(s.now=n,s.className=`hour-${n.getHours()} minute-${n.getMinutes()}`),e==="now"||e==="zoom"||e==="viewDate")){let o=this.now,c=this.zoom,d=o&&c&&(this.isViewDay(o)&&c==="day"||this.isViewWeek(o)&&c==="week");s.hidden=!d}}};l([lE(X+"-clock")],Pd.prototype,"_clock",2),l([lr({converter:Ir.Datetime})],Pd.prototype,"time",2),Pd=l([dh({tagName:X+"-agenda",shadow:uE.USE_SHADOW_ROOT,template:`<${X}-repeater class="${cE}-agenda agenda-grid" datasource="{{ :host.datasource }}">${B1()}<${X}-clock hidden></${X}-clock>
|
|
43
|
+
<template>
|
|
44
|
+
<${X}-repeater class="agenda-day" datasource="{{ ^item }}">
|
|
45
|
+
<template>
|
|
46
|
+
<${X}-panel class="agenda-event-wrapper"
|
|
47
|
+
css-class="{{ ['hour-start-'+ (^item.hour + 1), 'hour-end-'+ (^item.hour + ^item.span +1), 'day-start-'+ (!^item.continuing.start), 'day-end-'+ (!^item.continuing.end)] }}">
|
|
48
|
+
<${X}-panel class="agenda-event" css="{{ {'top': ^item.offset.start, 'bottom': ^item.offset.end} }}" tab-order="{{ (^^index + 1) * 1000 + (^item.hour + 1) * 100 + ^index }}"
|
|
49
|
+
on-focus=":host.oneventselect($this, ^item.event)" on-blur=":host.oneventunselect($this, ^item.event)">
|
|
50
|
+
<${X}-span class="event-caption" text="{{ ^item.caption }}"></${X}-span>
|
|
51
|
+
</${X}-panel>
|
|
52
|
+
</${X}-panel>
|
|
53
|
+
</template>
|
|
54
|
+
</${X}-repeater>
|
|
55
|
+
</template>
|
|
56
|
+
<${X}-repeater class="agenda-allday" datasource="{{ :host.allDayDatasource }}">
|
|
57
|
+
<template>
|
|
58
|
+
<${X}-panel class="agenda-event" tab-order="{{ (^index + 1) * 500 + (^item.day + 1) * 50 + ^index }}" css-class="{{ ['day-start-'+ (^item.day + 1), 'day-end-'+ (^item.day + ^item.span + 1)] }}"
|
|
59
|
+
on-focus=":host.oneventselect($this, ^item.event)" on-blur=":host.oneventunselect($this, ^item.event)">
|
|
60
|
+
<${X}-text class="event-caption" text="{{ ^item.caption }}"></${X}-text>
|
|
61
|
+
</${X}-panel>
|
|
62
|
+
</template>
|
|
63
|
+
</${X}-repeater>
|
|
64
|
+
</${X}-repeater><${X}-content></${X}-content>`})],Pd);function V1(){let a="";for(let r=0;r<6;r++)for(let e=0;e<7;e++){let t=`class="calendar-day week-${r+1} day-${e+1}"`;a+=`<${X}-panel disabled="{{ :host.isTimeSlotDisabled(:host.disabledRanges, :host.month[${r}][${e}]) }}" on-click=":host._setDate(:host.month[${r}][${e}])" ${t} css-class="{{ {'viewmonth': :host.isViewMonth(:host.month[${r}][${e}]), 'viewday': :host.isViewDay(:host.month[${r}][${e}], :host.viewDate), 'today': :host.isToday(:host.month[${r}][${e}], :host.now), 'selected-date': :host.isDate(:host.month[${r}][${e}], :host.date)} }}"><${X}-span culture="{{ :host.culture }}" class="text-ellipsed" text="{{ :host.getDayLabel(:host.month[${r}][${e}], :host._formatVersion) }}"></${X}-span></${X}-panel>`}return a}var Hl=class extends Uf{buildDataSource(r){let e=this.month,t=[];if(!ce.isNull(e))for(let n=0;n<e.length;n++){let i=e[n],s=KS(r,i);t.push(s)}return t}propertyChangedCallback(r,e,t,n){super.propertyChangedCallback(r,e,t,n),r==="dayLabelFormatter"&&(this._formatVersion=Date.now())}_setDate(r){r?.valueOf()!==this.date?.valueOf()&&(this.date=r,this.dispatchEvent(new by(r)))}getDayLabel(r,e=this._formatVersion){let t=this.dayLabelFormatter;return typeof t=="function"?t(r):super.getDayLabel(r)}};l([lr({converter:Ir.Datetime})],Hl.prototype,"date",2),l([lr({emit:!1})],Hl.prototype,"dayLabelFormatter",2),l([lr()],Hl.prototype,"_formatVersion",2),Hl=l([dh({tagName:X+"-calendar",shadow:uE.USE_SHADOW_ROOT,template:`<${X}-repeater class="${cE}-calendar calendar-grid" datasource="{{ :host.datasource }}">${V1()}
|
|
65
|
+
<template>
|
|
66
|
+
<${X}-repeater class="calendar-week" datasource="{{ ^item }}">
|
|
67
|
+
<template>
|
|
68
|
+
<${X}-panel class="calendar-event" tab-order="{{ (^^index + 1) * 1000 + (^item.day + 1) * 100 + ^index }}"
|
|
69
|
+
on-focus=":host.oneventselect($this, ^item.event)" on-blur=":host.oneventunselect($this, ^item.event)"
|
|
70
|
+
css-class="{{ ['day-start-'+ (^item.day + 1), 'day-end-'+ (^item.day + ^item.span + 1)] }}">
|
|
71
|
+
<${X}-span class="event-startdate" culture="{{ :host.culture }}" hide="{{ ^item.continuing.start }}" text="{{ :host.getTimeLabel(^item.event.start) }}"></${X}-span>
|
|
72
|
+
<${X}-span class="event-caption" text="{{ ^item.caption }}"></${X}-span>
|
|
73
|
+
</${X}-panel>
|
|
74
|
+
</template>
|
|
75
|
+
</${X}-repeater>
|
|
76
|
+
</template>
|
|
77
|
+
</${X}-repeater><${X}-content></${X}-content>`})],Hl);var oh=class extends dE.PacemElement{};l([lr({converter:Ir.Datetime})],oh.prototype,"now",2),oh=l([dh({tagName:X+"-clock"})],oh);function U1(){let a="";for(let e=0;e<7;e++)a+=`<${X}-span culture="{{ :host.culture }}" css-class="{{ {'viewday': :host.isViewDay(:host.week[${e}], :host.viewDate)} }}" class="schedule-heading day-${e+1} text-ellipsed" text="{{ :host.getHeaderLabel(:host.week[${e}], :host.zoom) }}"></${X}-span>`;let r="dock_"+ce.uniqueCode();return`<div class="schedule-header schedule-grid"><div class="heading-left"></div>${a}</div>`}var Id=class extends Rn{viewActivatedCallback(){super.viewActivatedCallback(),this._calendar.addEventListener("dateselect",this.emitHandler,!1),this._agenda.addEventListener("timeselect",this.emitHandler,!1),this.now=new Date}disconnectedCallback(){this._calendar&&(this._calendar.removeEventListener("dateselect",this.emitHandler,!1),this._agenda.removeEventListener("timeselect",this.emitHandler,!1)),super.disconnectedCallback()}};l([lE(X+"-calendar")],Id.prototype,"_calendar",2),l([lE(X+"-agenda")],Id.prototype,"_agenda",2),Id=l([dh({tagName:X+"-schedule",shadow:uE.USE_SHADOW_ROOT,template:`<${X}-panel class="${cE}-schedule" css-class="{{ ['schedule-'+ (:host.zoom || 'month')] }}">
|
|
78
|
+
<${X}-timer interval="10000" on-tick=":host.now = Pacem.Utils.parseDate(Date.now())"></${X}-timer>
|
|
79
|
+
${U1()}
|
|
80
|
+
<${X}-agenda disabled-ranges="{{ :host.disabledRanges }}" on-eventselect=":host.handle($event)" on-eventunselect=":host.handle($event)" now="{{ :host.now }}" culture="{{ :host.culture }}" view-date="{{ :host.viewDate }}" zoom="{{ :host.zoom }}" week-start="{{ :host.weekStart }}" items="{{ :host.items }}"></${X}-agenda>
|
|
81
|
+
<${X}-calendar disabled-ranges="{{ :host.disabledRanges }}" on-eventselect=":host.handle($event)" on-eventunselect=":host.handle($event)" now="{{ :host.now }}" culture="{{ :host.culture }}" view-date="{{ :host.viewDate }}" zoom="{{ :host.zoom }}" week-start="{{ :host.weekStart }}" items="{{ :host.items }}"></${X}-calendar>
|
|
82
|
+
<${X}-content></${X}-content>
|
|
83
|
+
</${X}-panel>`})],Id);var Bf=class extends HTMLElement{constructor(){super(...arguments);this._disabledRanges=[]}viewActivatedCallback(){if(!ce.isNull(this._target=R1.findAncestor(this,e=>e instanceof Rn)))this.refreshDisabledRanges();else throw`Missing ancestor calendar element for ${this.constructor.name}.`}disconnectedCallback(){this._target=void 0}get target(){return this._target}refreshDisabledRanges(){if(ce.isNullOrEmpty(this._target))return;let e=this._target.disabledRanges||[];for(let t of this._disabledRanges){let n=e.indexOf(t);n>=0&&e.splice(n,1)}this._disabledRanges=this.computeDisabledRanges()||[];for(let t of this._disabledRanges)e.push(t);this._target.disabledRanges=e}};l([O1(!0)],Bf.prototype,"refreshDisabledRanges",1);var lh=class extends Bf{constructor(){super(...arguments);this._daysOfWeek=[];this._calendarChangeHandler=e=>{e.detail.propertyName=="month"&&this.refreshDisabledRanges()}}viewActivatedCallback(){super.viewActivatedCallback(),this.target.addEventListener(P1,this._calendarChangeHandler,!1)}propertyChangedCallback(e,t,n,i){e==="days"&&(this._daysOfWeek=(n||[]).map(s=>H1.indexOf(s)).filter(s=>s>=0),this.refreshDisabledRanges())}computeDisabledRanges(){let e=[];for(let t of this.target.month)for(let n of t)if(this._daysOfWeek.indexOf(n.getDay())==-1){let i=ce.Dates.dateOnly(n),s=ce.Dates.dateOnly(new Date(i.valueOf()+ch+Vf));e.push({from:i,to:s})}return e}};l([lr({emit:!1,converter:Ir.StringArray})],lh.prototype,"days",2),lh=l([dh({tagName:X+"-calendar-daysofweek-rule"})],lh);import{P as Cy,PCSS as JS,CustomElement as z1,Watch as ZS,ViewChild as QS,Utils as Ey,PropertyConverters as eL,PacemEventTarget as G1,Components as F1}from"@pacem/pacem-core";var ph,Ja=class extends G1{constructor(){super(...arguments);$(this,ph);this._resizeHandler=e=>{A(this,ph,e.detail),this._toggle()}}propertyChangedCallback(e,t,n,i){if(super.propertyChangedCallback(e,t,n,i),!i)switch(e){case"collapse":this._toggle();case"disabled":Ey.isNull(this._resizer)||(this._resizer.disabled=this.disabled||this.collapse);break}}viewActivatedCallback(){super.viewActivatedCallback();let e=this._resizer;A(this,ph,e.currentSize),this._toggle()}_toggle(){let e=this,t=this.collapse,n=x(this,ph);this.disabled||Ey.isNull(e)||(this.horizontal?(Ey.addClass(e,JS+"-horizontal"),e.style.height=n&&n.height+"px"||"",e.style.width=t?"0":n&&n.width+"px"||""):(Ey.removeClass(e,JS+"-horizontal"),e.style.height=t?"0":n&&n.height+"px"||""))}};ph=new WeakMap,l([ZS({converter:eL.Boolean})],Ja.prototype,"collapse",2),l([ZS({emit:!1,converter:eL.Boolean})],Ja.prototype,"horizontal",2),l([QS(Cy+"-resize")],Ja.prototype,"_resizer",2),l([QS("[part=content]")],Ja.prototype,"_container",2),Ja=l([z1({tagName:Cy+"-collapse",shadow:!0,template:`<${Cy}-resize on-${F1.ResizeEventName}=":host._resizeHandler($event)" target="{{ ::_container }}"></${Cy}-resize><div part="container"><div part="content"><slot></slot></div></div>`})],Ja);import{P as Mt,PCSS as hE,Defaults as W1,CustomElement as j1,ViewChild as tL,Watch as Gf,PropertyConverters as Ff}from"@pacem/pacem-core";var ui=class extends nh{constructor(){super(...arguments);this.buttons="ok";this.okCaption="OK";this.yesCaption="Yes";this.noCaption="No";this.cancelCaption="Cancel"}propertyChangedCallback(e,t,n,i){super.propertyChangedCallback(e,t,n,i)}open(e){let t=super.open(e);switch(this.buttons){case"ok":case"okcancel":this.dialogButtons.ok.focus();break;default:this.dialogButtons.yes.focus();break}return t}viewActivatedCallback(){super.viewActivatedCallback()}get dialogButtons(){let e=this._buttons;return{ok:e&&e.firstElementChild.firstElementChild,yes:e&&e.firstElementChild.children.item(1),no:e&&e.firstElementChild.children.item(2),cancel:e&&e.firstElementChild.lastElementChild}}};l([Gf({converter:Ff.String})],ui.prototype,"buttons",2),l([Gf({reflectBack:!0,converter:Ff.String})],ui.prototype,"okCaption",2),l([Gf({reflectBack:!0,converter:Ff.String})],ui.prototype,"yesCaption",2),l([Gf({reflectBack:!0,converter:Ff.String})],ui.prototype,"noCaption",2),l([Gf({reflectBack:!0,converter:Ff.String})],ui.prototype,"cancelCaption",2),l([tL(`.${hE}-dialog-buttons`)],ui.prototype,"_buttons",2),l([tL(Mt+"-lightbox")],ui.prototype,"lightbox",2),ui=l([j1({tagName:Mt+"-dialog",shadow:W1.USE_SHADOW_ROOT,template:`<${Mt}-lightbox modal="true" logger="{{ :host.logger }}">
|
|
84
|
+
<${Mt}-content></${Mt}-content>
|
|
85
|
+
<div class="${hE}-dialog-buttons ${hE}-buttonset buttons" part="dialog-buttons" slot="bottom">
|
|
86
|
+
<div class="buttonset-left">
|
|
87
|
+
<${Mt}-button class="button button-size size-small primary dialog-ok" css-class="{{ {'buttonset-last': :host.buttons === 'ok'} }}" on-click=":host.commit('ok', $event)" disabled="{{ :host.disabled || this.hide }}" hide="{{ :host.buttons !== 'ok' && :host.buttons !== 'okcancel' }}"><${Mt}-text text="{{ :host.okCaption }}"></${Mt}-text></${Mt}-button>
|
|
88
|
+
<${Mt}-button class="button button-size size-small primary dialog-yes" css-class="{{ {'buttonset-first': :host.buttons !== 'ok' || :host.buttons !== 'okcancel'} }}" on-click=":host.commit('yes', $event)" disabled="{{ :host.disabled || this.hide }}" hide="{{ :host.buttons === 'ok' || :host.buttons === 'okcancel' }}"><${Mt}-text text="{{ :host.yesCaption }}"></${Mt}-text></${Mt}-button>
|
|
89
|
+
<${Mt}-button class="button button-size size-small dialog-no" css-class="{{ {'buttonset-last': :host.buttons === 'yesno'} }}" on-click=":host.commit('no', $event)" disabled="{{ :host.disabled || this.hide }}" hide="{{ :host.buttons !== 'yesno' && :host.buttons !== 'yesnocancel' }}"><${Mt}-text text="{{ :host.noCaption }}"></${Mt}-text></${Mt}-button>
|
|
90
|
+
<${Mt}-button class="button button-size size-small dialog-cancel" on-click=":host.commit('cancel', $event)" disabled="{{ :host.disabled || this.hide }}" hide="{{ :host.buttons !== 'yesnocancel' && :host.buttons !== 'okcancel' }}"><${Mt}-text text="{{ :host.cancelCaption }}"></${Mt}-text></${Mt}-button>
|
|
91
|
+
</div>
|
|
92
|
+
</div>
|
|
93
|
+
</${Mt}-lightbox>`})],ui);import{P as Y1,CustomElement as X1,Watch as q1,Utils as rL,PropertyConverters as K1,Components as J1}from"@pacem/pacem-core";var uh=class extends J1.PacemElement{constructor(){super("separator")}propertyChangedCallback(r,e,t,n){super.propertyChangedCallback(r,e,t,n),!n&&r==="orientation"&&this._syncOrientation(t)}viewActivatedCallback(){super.viewActivatedCallback(),this._syncOrientation()}_syncOrientation(r=this.orientation){r!=="vertical"&&(r="horizontal"),super.aria.attributes.set("orientation",r),r==="vertical"?rL.addClass(this,"divider-vertical"):rL.removeClass(this,"divider-vertical")}};l([q1({converter:K1.String,emit:!1})],uh.prototype,"orientation",2),uh=l([X1({tagName:Y1+"-divider",shadow:!0,template:'<div part="divider"><div part="prepend"></div><slot part="content"></slot><div part="append"></div></div>'})],uh);import{P as Z1,PCSS as Q1,CustomElement as eI,Watch as tI,Utils as cL,PropertyConverters as rI,Components as nI,CustomElementUtils as nL}from"@pacem/pacem-core";var iI=/^\s*<svg\s/,sI=/^fa(b|r|s|l|d|t|-brands|-solid|-regular|-light|-thin|-duotone)?\s+fa-/,iL={url:"https://kit.fontawesome.com/4922589c3c.js",crossOrigin:!0},aI=/^lni\s+lni-/,oI="https://cdn.lineicons.com/2.0/LineIcons.css",lI=/^ci[dlsbf]-/,cI="https://unpkg.com/@coreui/icons/css/all.min.css",sL=/^material-icons?\s+([\w]+)/,aL=/^material(-symbols?)?\s+([\w]+)/,oL="https://fonts.googleapis.com/css2?family=Material+Symbols+Outlined:opsz,wght,FILL,GRAD@20..48,100..700,0..1,-50..200",dI=/^(https?:\/\/|\/\/)?.+\.(webp|svg|gif|png|jpe?g)$/,lL=[];function Wf(a,r,e,t,n){return lL.indexOf(a)>=0||(lL.push(a),cL.Css.isClassDefined(a))?Promise.resolve():n?nL.importjs(r,e,t):nL.importcss(r,e,t)}function pI(a){return new Promise((r,e)=>{if(cL.isNullOrEmpty(a))e("No icon provided");else if(iI.test(a))r(a);else if(sI.test(a))Wf("fa",iL.url,void 0,iL.crossOrigin,!0).then(t=>{r(`<i class="${a}"></i>`)},t=>e(t));else if(aL.test(a))Wf("material-symbols",oL).then(t=>{let n=aL.exec(a),i=n[2],s=a.substring(n[0].length);r(`<i class="material-symbols-outlined${s}">${i}</i>`)},t=>e(t));else if(sL.test(a))Wf("material-icons",oL).then(t=>{let n=sL.exec(a),i=n[1],s=a.substring(n[0].length);r(`<i class="material-icons${s}">${i}</i>`)},t=>e(t));else if(aI.test(a))Wf("lni",oI).then(t=>{r(`<i class="${a}"></i>`)},t=>e(t));else if(lI.test(a))Wf("clb",cI).then(t=>{r(`<i class="${a}"></i>`)},t=>e(t));else if(dI.test(a))r(`<img src="${a}" />`);else{let t=a.trim().split(" "),n=t[0],i=t.length>1?" "+t.slice(1).join(" "):"";r(`<i class="${Q1}-icon${i}">${n}</i>`)}})}var hh=class extends nI.PacemElement{constructor(){super("",{hidden:"true"})}propertyChangedCallback(r,e,t,n){if(super.propertyChangedCallback(r,e,t,n),!n)switch(r){case"icon":this._setIcon();break;case"hide":t||this.aria.attributes.set("hidden","true");break}}viewActivatedCallback(){super.viewActivatedCallback(),this._setIcon()}_setIcon(r=this.icon){pI(r).then(e=>{this.innerHTML=e},e=>{this.innerHTML=""})}};l([tI({emit:!1,converter:rI.String})],hh.prototype,"icon",2),hh=l([eI({tagName:Z1+"-icon"})],hh);import{P as uI,CustomElement as hI,Watch as wy,Utils as jf,PropertyConverters as mE,Components as mI}from"@pacem/pacem-core";var Yf,Za=class extends mI.PacemElement{constructor(){super("img");$(this,Yf)}propertyChangedCallback(e,t,n,i){if(super.propertyChangedCallback(e,t,n,i),!i)switch(e){case"src":case"disabled":this._setSource();break;case"size":case"adapt":this._setLayout();break;case"loading":(n?jf.removeClass:jf.addClass)(this,"img-ready");break}}viewActivatedCallback(){super.viewActivatedCallback(),this._setLayout(),this._setSource()}_setLayout(){let e=!jf.isNullOrEmpty(this.size),t=this.adapt||"auto",n=this.size||x(this,Yf)||{width:"0",height:"0"};this.style.backgroundSize=t;let i=t==="auto",s=n.width,o=n.height;(i||e)&&(this.style.width=s||"",this.style.height=o||"")}async _setSource(){if(this.disabled||!this.isReady)return;let e=this.src;if(this.style.backgroundImage="",!jf.isNullOrEmpty(e)){this.loading=!0;try{let t=await jf.loadImage(e),n,i,s;window.performance&&(i=performance.getEntriesByName(t.src))&&(s=i[0])&&(n=s.decodedBodySize),A(this,Yf,{width:t.naturalWidth+"px",height:t.naturalHeight+"px",weight:n}),this._setLayout(),this.style.backgroundImage=`url("${t.src}")`}catch{}finally{this.loading=!1}}}};Yf=new WeakMap,l([wy({emit:!1,converter:mE.String})],Za.prototype,"adapt",2),l([wy({emit:!1,converter:mE.String})],Za.prototype,"src",2),l([wy({emit:!1,converter:{convert:(e,t)=>{let i=/^\s*([\d.]+)(px|em|rem|vw|vh)?\s*(?:,\s*([\d.]+)(px|em|rem|vw|vh)?)?\s*$/i.exec(e),s=i?i[1]+(i[2]||"px"):"0",o=i?i[3]?i[3]+(i[4]||"px"):s:"0";return{width:s,height:o}},convertBack:(e,t)=>`${e?.width},${e?.height}`},reflectBack:!0})],Za.prototype,"size",2),l([wy({converter:mE.Boolean})],Za.prototype,"loading",2),Za=l([hI({tagName:uI+"-img"})],Za);import{P as fI,Debounce as gI,CustomElement as vI,Watch as dL,Utils as pL,PropertyConverters as uL,PacemEventTarget as bI}from"@pacem/pacem-core";var Bl=class extends bI{constructor(){super();this._scrollDelegate=()=>this._doScroll();this._enabled=!0;this._viewportHeight=0;this._innerHeight=0;this._isDocument=!1;this._container=null;this._viewport=null;this._scroller=null;this._bottomGap=10;this._container=this,this._viewport=this,this._scroller=this}viewActivatedCallback(){super.viewActivatedCallback(),this.setInfiniteScrollContainer(this._container)}disconnectedCallback(){pL.isNull(this._scroller)||this._scroller.removeEventListener("scroll",this._scrollDelegate,!1),super.disconnectedCallback()}propertyChangedCallback(e,t,n,i){switch(super.propertyChangedCallback(e,t,n,i),e){case"container":this.setInfiniteScrollContainer(n);break;case"disabled":(this._enabled=!n)&&this._doScroll();break;case"threshold":this._bottomGap=n||0;break}}setInfiniteScrollContainer(e="$document"){var t=e,n=this._isDocument=t==="$document"||t===document.body||t===document.documentElement;this._container=n?document.body||document.documentElement:typeof e=="string"?document.querySelector(t):t,this._viewport=n?window:this._container,this._scroller&&this._scroller.removeEventListener("scroll",this._scrollDelegate,!1),this._scroller=n?window.document:this._container,this._scroller.addEventListener("scroll",this._scrollDelegate,!1),this._enabled&&this._doScroll()}_emitFetchMore(){var e=new CustomEvent("fetchmore");this.dispatchEvent(e)}_doScroll(){if(this._enabled)if(this._computeHeight())this._doScroll();else{var e=this._scroller instanceof Document?window.pageYOffset:this._scroller.scrollTop,t=this._viewportHeight,n=this._innerHeight,i=n-(e+t);(i<this._bottomGap||n<=t)&&(this._emitFetchMore(),window.requestAnimationFrame(()=>{this._enabled&&this._doScroll()}))}}_computeHeight(){if(this._container){var e=this._container,t=Number.MAX_VALUE,n=0,i=0,s;if(this._isDocument){var o=e;s=Math.max(o.scrollHeight,o.offsetHeight,o.clientHeight)}else{for(var c=0;c<e.children.length;c++){var d=e.children.item(c),p=d.offsetTop,u=d.offsetHeight,h=p+u;i+=u,p<t&&(t=p),h>n&&(n=h)}s=Math.round(n-t)}var m=this._viewport instanceof Window?pL.windowSize.height:this._viewport.offsetHeight;return s!=this._innerHeight||m!=this._viewportHeight?(this._innerHeight=s,this._viewportHeight=m,!0):!1}}};l([dL({converter:uL.String})],Bl.prototype,"container",2),l([dL({reflectBack:!0,converter:uL.Number})],Bl.prototype,"threshold",2),l([gI(100)],Bl.prototype,"_doScroll",1),Bl=l([vI({tagName:fI+"-infinite-scroller"})],Bl);import{Watch as hL,Utils as fE,PropertyConverters as yI,Components as _I}from"@pacem/pacem-core";var Xf=class extends _I.PacemElement{constructor(){super(...arguments);this.index=0}isCloseTo(e,t){return fE.isNull(this.datasource)||this.datasource.length==0?!1:this._isCloseToCore(e,t,this.datasource.length)}isPrevious(e,t){return fE.isNull(this.datasource)||this.datasource.length==0?!1:this._isPreviousCore(e,t,this.datasource.length)}isNext(e,t){return fE.isNull(this.datasource)||this.datasource.length==0?!1:this._isNextCore(e,t,this.datasource.length)}_isNextCore(e,t,n){return(t+1)%n===e}_isPreviousCore(e,t,n){return(t-1+n)%n===e}_isCloseToCore(e,t,n){return(t+n)%n==(e+n)%n||this._isNextCore(e,t,n)||this._isPreviousCore(e,t,n)}};l([hL({converter:yI.Number})],Xf.prototype,"index",2),l([hL()],Xf.prototype,"datasource",2);var gE=(e=>(e.ClickOutsideClose="clickOutsideClose",e.ExplicitClose="explicitClose",e))(gE||{});import{P as xI,PCSS as Vl,CustomElement as CI,Watch as vE,Utils as Kr,PropertyConverters as bE,Components as EI,stopPropagationHandler as yE,ViewChild as ky,avoidHandler as _E}from"@pacem/pacem-core";var Qa,hi=class extends EI.PacemElement{constructor(){super(...arguments);this._keyupHandler=e=>{e.keyCode===27&&this.show&&!this.modal&&(this.show=!1)};this._wrapperMousedownHandler=e=>{this.modal||this.behavior==="explicitClose"?yE(e):this.show=!1};this._slotchangeHandler=e=>{this._resetLayout()};this._closeHandler=e=>{this._close(e)};$(this,Qa)}_resetLayout(){this._disposeButton();let e=this._ensureButton();Kr.isNull(e)||e.addEventListener("click",this._closeHandler,!1)}_toggleCloseVisibility(){let e=this._closeWrapper;Kr.isNull(e)||(e.hidden=this.modal)}viewActivatedCallback(){super.viewActivatedCallback(),this._toggleCloseVisibility();var e=this._wrapperElement,t=this._container;e.addEventListener("mousedown",this._wrapperMousedownHandler,!1),t.addEventListener("mousedown",yE,!1),document.body.removeEventListener("scroll",_E,!0),window.addEventListener("keyup",this._keyupHandler,!1),this._resetLayout(),this._slot.addEventListener("slotchange",this._slotchangeHandler,!1)}propertyChangedCallback(e,t,n,i){if(super.propertyChangedCallback(e,t,n,i),!i)switch(e){case"show":let o=this._wrapperElement,c=this._container;if(n){this.inert=!1,this.dispatchEvent(new Event("open",{bubbles:!0,cancelable:!1})),o.style.display="",o.hidden=!1,window.requestAnimationFrame(()=>{Kr.addPart(o,"lightbox-wrapper-shown"),Kr.addPart(c,"lightbox-shown")});var s=this.querySelector("."+Vl+"-scrollable");s&&window.requestAnimationFrame(()=>s.scrollTop=0)}else t&&(this.inert=!0,this.dispatchEvent(new Event("close",{bubbles:!0,cancelable:!1})),Kr.removePart(o,"lightbox-wrapper-shown"),Kr.removePart(c,"lightbox-shown"),Kr.addAnimationEndCallback(o,d=>{d.hidden=!0,d.style.display="none"},500));break;case"modal":this._toggleCloseVisibility();break}}disconnectedCallback(){this.show&&this._close();var e=this._wrapperElement,t=this._container;document.body.removeEventListener("scroll",_E,!0),Kr.isNull(e)||e.removeEventListener("mousedown",this._wrapperMousedownHandler,!1),Kr.isNull(t)||t.removeEventListener("mousedown",yE,!1),window.removeEventListener("keyup",this._keyupHandler,!1),this._disposeButton(),this._disposeSlot(),super.disconnectedCallback()}_disposeButton(){x(this,Qa)?.removeEventListener("click",this._closeHandler),A(this,Qa,null)}_disposeSlot(){this._slot?.removeEventListener("slotchange",this._slotchangeHandler,!1)}_close(e){Kr.isNull(e)||_E(e),this.show=!1}_ensureButton(){if(!Kr.isNull(x(this,Qa)))return x(this,Qa);let e=this._slot;if(Kr.isNull(e))return null;let t=this._lookForAButton();if(!Kr.isNull(t))return A(this,Qa,t);let n=new qr;return n.setAttribute("slot","close"),n.className=`${Vl}-margin margin-0 ${Vl}-rise rise--2 button-circle circle-smaller`,n.iconGlyph="close",this.appendChild(n),A(this,Qa,n)}_lookForAButton(){let e=this._slot;if(Kr.isNull(e))return null;let t=e.assignedElements({flatten:!0});return Kr.isNullOrEmpty(t)?null:t[0]}};Qa=new WeakMap,l([vE({converter:bE.Boolean})],hi.prototype,"show",2),l([vE({converter:bE.Boolean})],hi.prototype,"modal",2),l([vE({emit:!1,converter:bE.String})],hi.prototype,"behavior",2),l([ky("."+Vl+"-lightbox-wrapper")],hi.prototype,"_wrapperElement",2),l([ky("."+Vl+"-lightbox")],hi.prototype,"_container",2),l([ky("slot[name=close]")],hi.prototype,"_slot",2),l([ky("div[part=close]")],hi.prototype,"_closeWrapper",2),hi=l([CI({tagName:xI+"-lightbox",shadow:!0,template:`<div class="${Vl}-lightbox-wrapper" part="lightbox-wrapper" hidden>
|
|
94
|
+
<div class="${Vl}-lightbox" part="lightbox">
|
|
95
|
+
<div part="top"><slot name="top"></slot></div>
|
|
96
|
+
<div class="${Vl}-scrollable" part="scrollable">
|
|
97
|
+
<slot></slot>
|
|
98
|
+
</div>
|
|
99
|
+
<div part="bottom"><slot name="bottom"></slot></div>
|
|
100
|
+
<div part="close">
|
|
101
|
+
<slot name="close"></slot>
|
|
102
|
+
</div>
|
|
103
|
+
</div>
|
|
104
|
+
</div>`})],hi);import{P as wI,PCSS as qf,CustomElement as kI,Watch as mL,ViewChild as xE,Utils as My,PropertyConverters as fL,Components as MI,Defaults as SI}from"@pacem/pacem-core";var gL=(t=>(t.Spinner="spin",t.Pacem="pacem",t.Custom="custom",t))(gL||{}),Fs=class extends MI.PacemElement{viewActivatedCallback(){super.viewActivatedCallback();var r="_"+My.uniqueCode();this._svgSpinner.innerHTML=`<defs>
|
|
105
|
+
<mask id="hole${r}">
|
|
106
|
+
<rect width="100%" height="100%" fill="white" />
|
|
107
|
+
<circle cx="36" cy="36" r="12"></circle>
|
|
108
|
+
<path d="M18,0 L32,16 H40 L54,0 Z" fill="#000"></path>
|
|
109
|
+
<g transform="rotate(120,36,36)">
|
|
110
|
+
<path d="M18,0 L32,16 H40 L54,0 Z" fill="#000"></path>
|
|
111
|
+
</g>
|
|
112
|
+
</mask>
|
|
113
|
+
</defs>
|
|
114
|
+
|
|
115
|
+
<circle class="circle1" cx="36" cy="36" r="34" stroke-width="4" fill="none"></circle>
|
|
116
|
+
<g class="gear">
|
|
117
|
+
<circle cx="36" cy="36" r="25" mask="url(#hole${r})"></circle>
|
|
118
|
+
</g>
|
|
119
|
+
<circle class="circle2" cx="36" cy="36" r="8" stroke-width="2" fill="none"></circle>
|
|
120
|
+
|
|
121
|
+
<g class="bounds">
|
|
122
|
+
<path d="M8,0 H0 V8 M64,0 H71 V8 M71,63 V71 H64 M8,71 H0 V63" stroke-width="2"></path>
|
|
123
|
+
</g>`}propertyChangedCallback(r,e,t,n){if(super.propertyChangedCallback(r,e,t,n),!My.isNull(this._container))switch(r){case"active":case"disabled":this.active===!0&&!this.disabled?My.addClass(this._container,"active"):My.removeClass(this._container,"active");break;case"type":this._svgSpinner.setAttribute("hidden","hidden"),this._spinner.setAttribute("hidden","hidden"),t==="pacem"?this._svgSpinner.removeAttribute("hidden"):this._spinner.removeAttribute("hidden");break}}};l([xE("div."+qf+"-spinner")],Fs.prototype,"_spinner",2),l([xE("div."+qf+"-loader")],Fs.prototype,"_container",2),l([xE("svg")],Fs.prototype,"_svgSpinner",2),l([mL({converter:fL.Boolean})],Fs.prototype,"active",2),l([mL({converter:fL.String})],Fs.prototype,"type",2),Fs=l([kI({tagName:wI+"-loader",shadow:SI.USE_SHADOW_ROOT,template:`<div class="${qf}-loader" pacem>
|
|
124
|
+
<div class="${qf}-spinner" pacem>
|
|
125
|
+
<div></div>
|
|
126
|
+
<div></div>
|
|
127
|
+
</div>
|
|
128
|
+
<svg class="${qf}-spinner" pacem hidden xmlns="http://www.w3.org/2000/svg"
|
|
129
|
+
xmlns:xlink="http://www.w3.org/1999/xlink"
|
|
130
|
+
viewBox="-18,-18,108,108" preserveAspectRatio="xMidYMid">
|
|
131
|
+
</svg>
|
|
132
|
+
</div>`})],Fs);import{P as OI,CustomElement as PI,Watch as II,PropertyConverters as $I,Components as HI}from"@pacem/pacem-core";import{Compile as LI}from"@pacem/pacem-foundation";import{P as vL}from"@pacem/pacem-core";var mn=(a,r,e)=>{let t=r.exec(a);return t&&t.length?e(t):null},NI=[{exec:a=>mn(a,/^((<|<)!--(?:(?!(--(>|>)))[\s\S])*(--(?:>|>)|$))/,r=>{let e=r[0];return[{type:"code-comment",raw:e,text:e,index:r.index}]})},{exec:(a,r)=>mn(a,/^(<|<)([\w-]+)(?:\s+[\w-]+(?:=(?:'[^']*'|"[^"]*"))*)*(\s*\/?(?:>|>))/,e=>{let t=e[1],n=e[2],i=e[3],s=e[0].length-i.length,o=t.length+n.length,c=a.substring(o,s),d=r.tokenize(c,[{exec:u=>mn(u,/^(\s+[\w-]+)(=('[^']*'|"[^"]*"))?/,h=>{let m=h[1],f=[{type:"code-attribute",raw:m,text:m,index:h[0].indexOf(m)}];return h.length>2&&f.push({type:"code-string",raw:h[2],text:h[2],index:h.index+h[0].length-h[2].length}),f})}]),p=[{type:"code-tag",raw:t,text:t,index:0},{type:"code-tagname",raw:n,text:n,index:t.length}];return Array.prototype.push.apply(p,d),p.push({type:"code-tag",raw:i,text:i,index:s}),p})},{exec:a=>mn(a,/^((?:<|<)\/)([\w-]+)(\s*(?:>|>))/,r=>{let e=r[1],t=r[2],n=r[3];return[{type:"code-tag",raw:e,text:e,index:0},{type:"code-tagname",raw:t,text:t,index:e.length},{type:"code-tag",raw:n,text:n,index:r.index+r[0].length-n.length}]})},{exec:a=>mn(a,/^(<|<)?((?!<|<).)+/,r=>{let e=r[0];return[{type:"text",raw:e,text:e}]})}],mh=[{exec:(a,r)=>mn(a,/^\/\/.*/,e=>{let t=e[0];return[{type:"code-comment",raw:t,text:t}]})},{exec:(a,r)=>mn(a,/^\/\*(?:(?!(\*\/))[\s\S])*(?:\*\/|$)/,e=>{let t=e[0];return[{type:"code-comment",raw:t,text:t}]})},{exec:(a,r)=>mn(a,/^('(\\'|[^'])*[^\\]?'|@?\$?"(\\"|[^"])*[^\\]?")/,e=>{let t=e[0];return[{type:"code-string",raw:t,text:t}]})},{exec:(a,r)=>mn(a,/^\b(abstract|as|base|bool|break|byte|case|catch|char|checked|class|const|continue|decimal|default|delegate|do|double|else|enum|event|explicit|extern|false|finally|fixed|float|for|foreach|goto|if|implicit|in|int|interface|internal|is|lock|long|namespace|new|null|object|operator|out|out|override|params|private|protected|public|readonly|ref|return|sbyte|sealed|short|sizeof|stackalloc|static|string|struct|switch|this|throw|true|try|typeof|uint|ulong|unchecked|unsafe|ushort|using|static|virtual|void|volatile|while|add|alias|ascending|async|await|descending|dynamic|from|get|global|group|into|join|let|nameof|orderby|partial|remove|select|set|value|var|when|where|yield)\b/,e=>{let t=e[0];return[{type:"code-keyword",raw:t,text:t}]})},{exec:(a,r)=>mn(a,/^\b((0x[0-9a-fA-F]|[\d])*\.?[\d]+)\b/,e=>{let t=e[0];return[{type:"code-number",raw:t,text:t}]})},{exec:(a,r)=>mn(a,/^(@?\w+|:|\?\??|\?=?|\|\|?|&&?|&=?|;|,|=|\*=?|--|-=?|\+\+|\+=?|\/=?|\^|\(|\[|\)|\]|\{|\})/,e=>{let t=e[0];return[{type:"text",raw:t,text:t}]})},{exec:(a,r)=>mn(a,/^\s+/,e=>{let t=e[0];return[{type:"space",raw:t,text:t}]})}],TI=[mh[0],mh[1],{exec:(a,r)=>mn(a,/^('(\\'|[^'])*[^\\]?'|"(\\"|[^"])*[^\\]?"|`(\\`|[^`])*[^\\]?`)/,e=>{let t=e[0];return[{type:"code-string",raw:t,text:t}]})},{exec:(a,r)=>mn(a,/^\b(abstract|any|arguments|async|await|boolean|break|byte|case|catch|char|class|const|continue|debugger|declare|default|delete|do|double|else|enum|eval|export|extends|false|final|finally|float|for|function|get|goto|if|implements|import|in|instanceof|int|interface|let|long|native|new|null|number|package|private|protected|public|return|short|static|string|super|switch|synchronized|this|throw|throws|transient|true|try|type|typeof|var|void|volatile|while|with|yield)\b/,e=>{let t=e[0];return[{type:"code-keyword",raw:t,text:t}]})},mh[4],mh[5],mh[6]],AI={rule:{exec:a=>{let r=/\{tweet\}\(([^\)]+)\)/.exec(a);return r&&r.length>1?[{type:"tweet",raw:r[0],text:r[1],index:r.index}]:null}},type:"inline"},DI={rule:{exec:a=>{let r=/\{yt([\d]+x[\d]+)?\}\(([^\)]+)\)/.exec(a);if(r&&r.length>2){let t=(r[1]||"560x315").split("x"),n=t[0],i=t[1];return[{type:"youtube",raw:r[0],text:r[2],index:r.index,width:n,height:i}]}return null}},type:"inline"},RI=a=>{switch(a.type){case"youtube":return`<!-- youtube embed -->
|
|
133
|
+
<iframe width="${a.width}" height="${a.height}" src="https://www.youtube-nocookie.com/embed/${a.text}" frameborder="0" allow="autoplay; encrypted-media" allowfullscreen></iframe>`;case"tweet":return`<!-- twitter embed -->
|
|
134
|
+
<${vL}-tweetembed tweetid="${a.text}"></${vL}-tweetembed>`;case"code-string":case"code-keyword":case"code-number":case"code-comment":case"code-tag":case"code-tagname":case"code-attribute":return`<span class="${a.type}">${a.text}</span>`}},Kf=class{constructor(){let r=[AI,DI];for(let e of["c-sharp","c","c#","csharp","c++","cpp"]){let t=mh.map(n=>({rule:n,lang:e,type:"code"}));Array.prototype.push.apply(r,t)}for(let e of["ts","js","typescript","javascript"]){let t=TI.map(n=>({rule:n,lang:e,type:"code"}));Array.prototype.push.apply(r,t)}for(let e of["xml","html"]){let t=NI.map(n=>({rule:n,lang:e,type:"code"}));Array.prototype.push.apply(r,t)}this.#e=r}#e;#t=new LI.Markdown.Parser;_escape(r){return(r??"").replace(/</g,"<")}toHtml(r){return this.#t.toHtml(this._escape(r),this.#e,RI)}tokenize(r){return this.#t.tokenize(this._escape(r),this.#e)}};var fh=class extends HI.PacemElement{constructor(e=new Kf){super();this._md=e}propertyChangedCallback(e,t,n,i){super.propertyChangedCallback(e,t,n,i),e==="value"&&(this.innerHTML=this.html())}tokens(e=this.value){return this._md.tokenize(e)}html(e=this.value){return this._md.toHtml(e)}};l([II({emit:!1,converter:$I.String})],fh.prototype,"value",2),fh=l([PI({tagName:OI+"-markdown"})],fh);import{P as Ul,PCSS as Sy,Utils as bL,CustomElement as BI,Watch as VI,ViewChild as CE,PropertyConverters as UI,Components as EE,Defaults as zI}from"@pacem/pacem-core";var eo=class extends EE.PacemElement{constructor(){super(...arguments);this._state={overlap:0,content:0}}connectedCallback(){super.connectedCallback();let e=this._css=document.createElement("style");document.head.appendChild(e)}propertyChangedCallback(e,t,n,i){super.propertyChangedCallback(e,t,n,i),e==="speed"&&this._adjust()}viewActivatedCallback(){super.viewActivatedCallback(),this._adjust()}disconnectedCallback(){bL.isNull(this._css)||this._css.remove(),super.disconnectedCallback()}_overlapResize(e){this._state.overlap=e.detail.width,this._adjust()}_contentResize(e){this._state.content=e.detail.width,this._adjust()}_adjust(){let e=this._state;if(e.content>0&&e.overlap>0){let t=this._marquee,n="marquee-"+bL.uniqueCode(),i=Math.round(e.overlap),s=-Math.round(e.content);this._css.innerHTML=`@keyframes ${n} {
|
|
135
|
+
0% {
|
|
136
|
+
transform: translateX(${i}px);
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
100% {
|
|
140
|
+
transform: translateX(${s}px);
|
|
141
|
+
}
|
|
142
|
+
}`;let o=this.speed||20,c=Math.max(o,Math.round(o*Math.abs(i-s)/1920));t.style.animationName=n,t.style.animationDuration=c+"s",t.style.animationIterationCount="infinite",t.style.animationTimingFunction="linear"}}};l([CE(`.${Sy}-marquee`)],eo.prototype,"_marquee",2),l([CE(`.${Sy}-marquee-overlap`)],eo.prototype,"_overlap",2),l([CE(Ul+"-resize")],eo.prototype,"_resizer",2),l([VI({converter:UI.Number})],eo.prototype,"speed",2),eo=l([BI({tagName:Ul+"-marquee",shadow:zI.USE_SHADOW_ROOT,template:`<div class="${Sy}-marquee"><${Ul}-content></${Ul}-content></div><div class="${Sy}-marquee-overlap"></div>
|
|
143
|
+
<${Ul}-resize target="{{ :host._overlap }}" on-${EE.ResizeEventName}=":host._overlapResize($event)"></${Ul}-resize>
|
|
144
|
+
<${Ul}-resize target="{{ :host._marquee }}" on-${EE.ResizeEventName}=":host._contentResize($event)"></${Ul}-resize>`})],eo);import{P as GI,Utils as yL,CustomElement as FI,Watch as _L,PropertyConverters as xL,PacemEventTarget as WI}from"@pacem/pacem-core";var CL=768,jI=992,YI=1200,XI=1824,qI=1920,KI=2048,JI=3840,ZI=`(max-width: ${CL-1}px)`,QI=`(min-width: ${CL}px)`,e$=`(min-width: ${jI}px)`,t$=`(min-width: ${YI}px)`,r$=`(min-width: ${XI}px)`,n$=`(min-width: ${qI}px)`,i$=`(min-width: ${KI}px)`,s$=`(min-width: ${JI}px)`,a$="(orientation: portrait)",o$="(orientation: landscape)",l$="(prefers-color-scheme: light)",c$="(prefers-color-scheme: dark)",Jf,$d=class extends WI{constructor(){super(...arguments);$(this,Jf);this._changeHandler=e=>{this.isMatch=e.matches}}viewActivatedCallback(){super.viewActivatedCallback(),this._init()}propertyChangedCallback(e,t,n,i){switch(super.propertyChangedCallback(e,t,n,i),e){case"query":i||this._init();break;case"isMatch":this._broadcastChange(n);break}}disconnectedCallback(){this._init(""),super.disconnectedCallback()}_broadcastChange(e=this.isMatch){this.dispatchEvent(new Event("change")),this.dispatchEvent(new Event(e?"match":"unmatch"))}_init(e=this.query){let t=x(this,Jf);if(yL.isNull(t)||t.removeEventListener("change",this._changeHandler),!yL.isNullOrEmpty(e)){let n=A(this,Jf,window.matchMedia(e));n.addEventListener("change",this._changeHandler),this.isMatch=n.matches}}};Jf=new WeakMap,l([_L({emit:!1,converter:xL.String})],$d.prototype,"query",2),l([_L({reflectBack:!0,converter:xL.Boolean})],$d.prototype,"isMatch",2),$d=l([FI({tagName:GI+"-media-query"})],$d);import{P as On,PCSS as Ws,Utils as cr,CustomElement as wL,Watch as Zf,ViewChild as EL,PropertyConverters as Qf,Components as kL,Defaults as d$,avoidHandler as p$,stopPropagationHandler as Ly,CustomElementUtils as ML,Logging as u$}from"@pacem/pacem-core";var fn=class extends kL.PacemElement{constructor(){super(...arguments);this.synchronizeShell=!0;this._stopPropagationHandlerConditional=e=>{if(!cr.isNull(this._container)&&!cr.isNull(this._base)){let t=cr.offset(this._container),n=cr.offset(this._base);t.width<n.width&&(this.open=!1)}}}viewActivatedCallback(){super.viewActivatedCallback(),this._container.addEventListener("click",Ly,!1),this._container.addEventListener("scroll",Ly,!1),this._sync()}disconnectedCallback(){window.removeEventListener("navigate",this._stopPropagationHandlerConditional,!1),cr.isNull(this._container)||(this._container.removeEventListener("click",Ly,!1),this._container.removeEventListener("scroll",Ly,!1)),this._sync(!1),super.disconnectedCallback()}connectedCallback(){super.connectedCallback(),window.addEventListener("navigate",this._stopPropagationHandlerConditional,!1),this._shell=ML.findAncestorShell(this)}_toggle(e){p$(e),this.open=!this.open,this.dispatchEvent(new Event("toggle"))}_sync(e=this.open){this.synchronizeShell?(cr.addClass(this,"menu-sync"),cr.addClass(this._shell,Ws+(e===!0?"-menu-open":"-menu-close")),cr.removeClass(this._shell,Ws+(e===!0?"-menu-close":"-menu-open"))):(cr.removeClass(this,"menu-sync"),cr.removeClass(this._shell,Ws+"-menu-close "+Ws+"-menu-open")),this.outset?cr.addClass(this,"menu-outset"):cr.removeClass(this,"menu-outset")}propertyChangedCallback(e,t,n,i){super.propertyChangedCallback(e,t,n,i),(e==="open"||e==="synchronizeShell"||e==="outset")&&this._sync()}};l([Zf({converter:Qf.Boolean})],fn.prototype,"open",2),l([Zf({converter:Qf.Boolean})],fn.prototype,"hideHamburgerButton",2),l([Zf({converter:Qf.Boolean})],fn.prototype,"hideBackButton",2),l([Zf({emit:!1,converter:Qf.Boolean})],fn.prototype,"outset",2),l([Zf({emit:!1,converter:Qf.Boolean})],fn.prototype,"synchronizeShell",2),l([EL("nav")],fn.prototype,"_container",2),l([EL(`.${Ws}-menu`)],fn.prototype,"_base",2),fn=l([wL({tagName:On+"-menu",template:`<${On}-panel class="${Ws}-menu" css-class="{{ {'menu-close': !:host.open, 'menu-open': :host.open} }}" on-click=":host._toggle($event)">
|
|
145
|
+
<nav><${On}-content></${On}-content></nav>
|
|
146
|
+
</${On}-panel>
|
|
147
|
+
<${On}-shell-proxy>
|
|
148
|
+
<${On}-button hide="{{ :host.hideBackButton }}" class="${Ws}-back ${Ws}-menu button-flat" css-class="{{ {'menu-close': !:host.open, 'menu-open': :host.open} }}" on-click=":host._toggle($event)">BACK</${On}-button>
|
|
149
|
+
<${On}-button hide="{{ :host.hideHamburgerButton }}" class="${Ws}-hamburger ${Ws}-menu button-flat" css-class="{{ {'menu-close': :host.open, 'menu-open': !:host.open} }}" on-click=":host._toggle($event)">MENU</${On}-button></${On}-shell-proxy>`,shadow:d$.USE_SHADOW_ROOT})],fn);var Hd=class extends kL.PacemElement{constructor(){super(...arguments);this._onPathChange=e=>{let t=this._menu,n=e&&e.detail||window.location.pathname;if(cr.isNull(t)){this.log(u$.LogLevel.Warn,`Couldn't find a ${fn} ancestor for this ${Hd}.`);return}var i=t.querySelectorAll(On+"-a"),s=null;for(let o=0;o<i.length;o++){let c=i.item(o);if(c.href===n){s=c;break}}if(cr.isNull(s)&&(s=t.querySelector(`a[href='${n}']`)),!cr.isNull(s)){let o=cr.offset(s),c=cr.offset(t);this.style.top=o.top+"px",this.style.left=c.left+"px",this.style.width="0",this.style.height=o.height+"px",cr.addAnimationEndCallback(this,()=>{this.style.width=o.width+o.left-c.left+"px"},500)}}}viewActivatedCallback(){super.viewActivatedCallback(),this._menu=ML.findAncestorOfType(this,fn),this._onPathChange()}connectedCallback(){super.connectedCallback(),window.addEventListener("navigate",this._onPathChange,!1)}disconnectedCallback(){this._menu=null,window.removeEventListener("navigate",this._onPathChange,!1),super.disconnectedCallback()}};Hd=l([wL({tagName:On+"-menu-cursor"})],Hd);import{P as zl,PCSS as wE,Utils as Ny,CustomElement as h$,Watch as eg,ViewChild as m$,PropertyConverters as tg,Components as f$,Defaults as g$,Debounce as v$}from"@pacem/pacem-core";var mi=class extends f$.PacemElement{propertyChangedCallback(r,e,t,n){switch(super.propertyChangedCallback(r,e,t,n),r){case"index":case"total":case"pages":case"size":case"mode":this._databind();break}}_databind(){let r=this._repeater;if(Ny.isNull(r))return;var e=[];let t=this.size??10,n=this.pages??5,i=this.total??0,s=this.index??0,o=this.mode??"standard";if(i>0){let c=Math.ceil(i/t),d=Math.floor(s/t),p=Math.max(0,Math.ceil(d-n/2)),u=Math.min(c-1,p+n-1);for(;p>0&&1+u-p<n;)p--;o==="numeric-only"?p>0&&e.push({caption:1 .toLocaleString(Ny.lang(this)),index:0,disabled:!(d>0)}):(e.push({caption:"«",index:0,first:!0,disabled:!(d>0)}),e.push({caption:"<",index:t*(d-1),previous:!0,disabled:!(d>0)})),(p>0&&o!=="numeric-only"||p>1&&o==="numeric-only")&&e.push({caption:"…",index:t*(p-1)});for(let h=p;h<=u;h++)e.push({caption:(h+1).toLocaleString(Ny.lang(this)),index:h*t});(u<c-1&&o!=="numeric-only"||u<c-2&&o==="numeric-only")&&e.push({caption:"…",index:t*(u+1)}),o==="numeric-only"?u<c-1&&e.push({caption:c.toLocaleString(Ny.lang(this)),index:t*(c-1),disabled:!(d<c-1)}):(e.push({caption:">",index:t*(d+1),next:!0,disabled:!(d<c-1)}),e.push({caption:"»",index:t*(c-1),last:!0,disabled:!(d<c-1)})),this.index=d*t}r.datasource=e}};l([m$(zl+"-repeater")],mi.prototype,"_repeater",2),l([eg({converter:tg.Number})],mi.prototype,"index",2),l([eg({converter:tg.Number,emit:!1})],mi.prototype,"total",2),l([eg({converter:tg.Number,emit:!1})],mi.prototype,"pages",2),l([eg({converter:tg.Number,emit:!1})],mi.prototype,"size",2),l([eg({converter:tg.String,emit:!1})],mi.prototype,"mode",2),l([v$(!0)],mi.prototype,"_databind",1),mi=l([h$({tagName:zl+"-pager",shadow:g$.USE_SHADOW_ROOT,template:`<${zl}-repeater class="${wE}-pager"><div class="${wE}-buttonset">
|
|
150
|
+
<div class="pager-buttons">
|
|
151
|
+
<template>
|
|
152
|
+
<${zl}-button class="${wE}-page button" on-click=":host.index = ^item.index" disabled="{{ ^item.disabled }}"
|
|
153
|
+
css-class="{{ { 'currentpage': ^item.index === :host.index, 'firstpage buttonset-first': ^item.first, 'previouspage': ^item.previous, 'nextpage': ^item.next, 'lastpage buttonset-last': ^item.last } }}"><${zl}-span content="{{ ^item.caption }}"></${zl}-span></${zl}-button>
|
|
154
|
+
</template>
|
|
155
|
+
</div>
|
|
156
|
+
</div></${zl}-repeater>`})],mi);import{P as LL,Utils as js,CustomElement as NL,Watch as rg,ViewChild as SL,PropertyConverters as ng,Components as TL}from"@pacem/pacem-core";var to=class extends TL.PacemItemElement{propertyChangedCallback(r,e,t,n){super.propertyChangedCallback(r,e,t,n);let i=this.container;i instanceof Ys&&["srcset","media","type","disabled"].indexOf(r)>=0&&i.refreshSources()}};l([rg({emit:!1,converter:ng.String})],to.prototype,"srcset",2),l([rg({emit:!1,converter:ng.String})],to.prototype,"media",2),l([rg({emit:!1,converter:ng.String})],to.prototype,"type",2),to=l([NL({tagName:LL+"-picture-source"})],to);var Ys=class extends TL.PacemItemsContainerElement{constructor(){super("img",{label:"picture"});this._updateCurrentSrcHandler=e=>{this.currentSrc=this._img.currentSrc}}validate(e){return e instanceof to}propertyChangedCallback(e,t,n,i){switch(super.propertyChangedCallback(e,t,n,i),e){case"src":this._setSource();break;case"items":this._setSources();break;case"tooltip":this._setAltText();break}}viewActivatedCallback(){super.viewActivatedCallback(),this._img.addEventListener("load",this._updateCurrentSrcHandler,!1),this._setSource(),this._setAltText(),this._setSources()}disconnectedCallback(){let e=this._img;js.isNull(e)||e.removeEventListener("load",this._updateCurrentSrcHandler,!1),super.disconnectedCallback()}refreshSources(){this._setSources()}_setSources(e=this.items){let t=this._picture,n=this._img;if(!js.isNull(t)&&!js.isNull(n)){let i=t.querySelectorAll("source"),s=e?.length??0;for(let o=0;o<s;o++){let c=this.items[o],d;i.length<=o?(d=document.createElement("source"),d.setAttribute("part","source"),t.insertBefore(d,n)):d=i.item(o),c.disabled||js.isNullOrEmpty(c.srcset)?d.removeAttribute("srcset"):d.srcset=c.srcset,js.isNullOrEmpty(c.media)?d.removeAttribute("media"):d.media=c.media,js.isNullOrEmpty(c.type)?d.removeAttribute("type"):d.type=c.type}for(let o=i.length-1;o>=s;o--)i.item(o).remove()}}_setSource(e=this.src){let t=this._img;js.isNull(t)||(js.isNullOrEmpty(e)?t.removeAttribute("src"):t.src=e)}_setAltText(e=this.tooltip){let t=this._img;js.isNull(t)||(js.isNullOrEmpty(e)?t.alt=this.aria.attributes.toObject().label:t.alt=e)}};l([SL("picture")],Ys.prototype,"_picture",2),l([SL("img")],Ys.prototype,"_img",2),l([rg({emit:!1,converter:ng.String})],Ys.prototype,"src",2),l([rg({converter:ng.String})],Ys.prototype,"currentSrc",2),Ys=l([NL({tagName:LL+"-picture",shadow:!0,template:'<picture part="picture"><img loading="lazy" part="img" /></picture><slot></slot>'})],Ys);import{P as b$,Utils as AL,CustomElement as y$,Watch as DL,ViewChild as kE,PropertyConverters as RL,Components as _$,Defaults as x$}from"@pacem/pacem-core";var Xs=class extends _$.PacemElement{constructor(){super("progressbar",{valuemin:"0%",valuemax:"100%",valuenow:"0%"})}propertyChangedCallback(r,e,t,n){switch(super.propertyChangedCallback(r,e,t,n),r){case"percentage":this._bar.style.transform=`translateX(${-100+(t||0)}%)`,this._glow.style.transform=`scaleX(${(t||0)*.01})`;let i=AL.leftPad(Math.floor(t),2,"0")+"%";this.aria.attributes.set("valuenow",i),AL.isNullOrEmpty(this.caption)&&this.aria.attributes.set("valuetext",this._caption.textContent=i);break;case"caption":this.aria.attributes.set("valuetext",this._caption.textContent=t);break}}};l([kE(".progressbar-bar")],Xs.prototype,"_bar",2),l([kE(".progressbar-glow")],Xs.prototype,"_glow",2),l([kE(".progressbar-caption")],Xs.prototype,"_caption",2),l([DL({emit:!1,converter:RL.String})],Xs.prototype,"caption",2),l([DL({converter:RL.Number})],Xs.prototype,"percentage",2),Xs=l([y$({tagName:b$+"-progressbar",shadow:x$.USE_SHADOW_ROOT,template:`<div class="progressbar-glow"></div>
|
|
157
|
+
<div class="progressbar-track"><div class="progressbar-bar"></div></div>
|
|
158
|
+
<label class="progressbar-caption"></label>`})],Xs);import{P as ME,PCSS as Ty,Utils as ig,CustomElement as C$,Watch as OL,PropertyConverters as PL,Components as E$,CustomElementUtils as w$}from"@pacem/pacem-core";var sg,Bd=class extends E$.PacemElement{constructor(){super(...arguments);this.open=!1;this.synchronizeShell=!0;$(this,sg)}propertyChangedCallback(e,t,n,i){switch(super.propertyChangedCallback(e,t,n,i),e){case"open":case"synchronizeShell":this._sync();break}}disconnectedCallback(){this._sync(!1),super.disconnectedCallback()}_sync(e=this.open){let t=x(this,sg);this.synchronizeShell?(ig.addClass(this,"sidebar-sync"),ig.addClass(t,Ty+(e===!0?"-sidebar-open":"-sidebar-close")),ig.removeClass(t,Ty+(e===!0?"-sidebar-close":"-sidebar-open"))):(ig.removeClass(this,"sidebar-sync"),ig.removeClass(t,Ty+"-sidebar-close "+Ty+"-sidebar-open"))}connectedCallback(){super.connectedCallback(),A(this,sg,w$.findAncestorShell(this))}};sg=new WeakMap,l([OL({converter:PL.Boolean})],Bd.prototype,"open",2),l([OL({emit:!1,converter:PL.Boolean})],Bd.prototype,"synchronizeShell",2),Bd=l([C$({tagName:ME+"-sidebar",template:`<${ME}-panel class="sidebar-drawer" part="drawer" css-part="{{ { 'open': :host.open } }}" css-class="{{ {'open': :host.open } }}">
|
|
159
|
+
<slot></slot>
|
|
160
|
+
</${ME}-panel>`,shadow:!0})],Bd);import{P as IL,CustomElement as $L,Components as HL}from"@pacem/pacem-core";var gh=class extends HL.PacemIterableElement{};gh=l([$L({tagName:IL+"-slide"})],gh);var ag=class extends HL.PacemIterativeElement{validate(r){return r instanceof gh}};ag=l([$L({tagName:IL+"-slideshow"})],ag);import{P as k$,CustomElementUtils as M$,CustomElement as S$,Watch as L$,PropertyConverters as N$,Components as T$}from"@pacem/pacem-core";var vh=class extends T$.PacemElement{constructor(){super(...arguments);this._scriptsLoaded=!1}propertyChangedCallback(e,t,n,i){super.propertyChangedCallback(e,t,n,i),e==="tweetid"&&this._scriptsLoaded&&this._render()}viewActivatedCallback(){super.viewActivatedCallback(),M$.importjs("https://platform.twitter.com/widgets.js").then(()=>{this._scriptsLoaded=!0,this._render()})}_render(){this.tweetid&&this._scriptsLoaded&&twttr.ready(e=>e.widgets.createTweet(this.tweetid,this))}};l([L$({emit:!1,converter:N$.String})],vh.prototype,"tweetid",2),vh=l([S$({tagName:k$+"-tweetembed"})],vh);import{P as A$,CustomElementUtils as D$,CustomElement as R$,Watch as Ay,PropertyConverters as Dy,PacemEventTarget as O$,Components as SE,Utils as gn,Logging as BL}from"@pacem/pacem-core";var VL=(e=>(e.Persistent="persistent",e.QuickReturn="quickreturn",e))(VL||{}),Gl,og,Vd,bh,ro=class extends O${constructor(){super(...arguments);$(this,Gl);$(this,og,{left:0,top:0});$(this,Vd);$(this,bh);this._scrollHandler=e=>{this.offset=e.detail}}_ensureScrollAwareElement(){if(gn.isNull(x(this,Gl))){let e=A(this,Gl,new SE.PacemScrollAwareElement);this.log(BL.LogLevel.Debug,"creating scroll aware "+x(this,Vd)),A(this,bh,D$.findAncestorShell(this)).appendChild(e),e.dataset.target=x(this,Vd),e.addEventListener(SE.ScrollEventName,this._scrollHandler,!1)}x(this,Gl).disabled=this.disabled}_manageOffsetChange(e=this.offset){if(this.disabled)return;let t=this.visibility||"persistent",n=x(this,og).top,i=e.top,s=this.threshold||0,o=x(this,bh);n<=s&&i>s?(gn.removeClass(o,"sticky-header-top"),gn.addClass(o,"sticky-header-scroll"),t==="quickreturn"&&(gn.addClass(o,"sticky-header-fade"),this.visible=!1)):n>s&&i<=s?(gn.removeClass(o,"sticky-header-fade"),gn.removeClass(o,"sticky-header-scroll"),gn.addClass(o,"sticky-header-top")):n>s&&i>s&&n>i?(this.visible=!0,gn.removeClass(o,"sticky-header-fade")):n>s&&i>s&&n<i&&t=="quickreturn"&&gn.addClass(o,"sticky-header-fade"),A(this,og,e)}propertyChangedCallback(e,t,n,i){switch(super.propertyChangedCallback(e,t,n,i),e){case"offset":this._manageOffsetChange(n);break;case"disabled":this._ensureScrollAwareElement();break}}connectedCallback(){super.connectedCallback(),A(this,Vd,this.id||"sticky-"+gn.uniqueCode()),this._ensureScrollAwareElement()}disconnectedCallback(){let e=x(this,Gl),t=x(this,bh);gn.isNull(e)||(this.log(BL.LogLevel.Debug,"disposing scroll aware "+x(this,Vd)),e.removeEventListener(SE.ScrollEventName,this._scrollHandler,!1),e.remove(),A(this,Gl,void 0),gn.removeClass(t,"sticky-header-fade"),gn.removeClass(t,"sticky-header-top"),gn.removeClass(t,"sticky-header-scroll")),super.disconnectedCallback()}};Gl=new WeakMap,og=new WeakMap,Vd=new WeakMap,bh=new WeakMap,l([Ay({converter:Dy.Number,emit:!1})],ro.prototype,"threshold",2),l([Ay({converter:Dy.Point})],ro.prototype,"offset",2),l([Ay({converter:Dy.Boolean})],ro.prototype,"visible",2),l([Ay({converter:Dy.String,emit:!1})],ro.prototype,"visibility",2),ro=l([R$({tagName:A$+"-sticky-header"})],ro);import{P as Ud,PCSS as lg,CustomElement as GL,Watch as Oy,ViewChild as Ry,PropertyConverters as yh,Components as FL,Utils as Kt,PropertyChangeEvent as P$,Animations as UL}from"@pacem/pacem-core";var zL="tab-focus",I$={convert:(a,r)=>a.startsWith("#")?yh.Element.convert(a,r):yh.String.convert(a,r),convertBack:(a,r)=>a instanceof Node?yh.Element.convertBack(a,r):yh.String.convertBack(a,r),retryConversionWhenReady:!0},cg,no=class extends FL.PacemIterableElement{constructor(){super("tab");this._slotChangeHandler=e=>{let t=x(this,cg),n=A(this,cg,this.content);this.dispatchEvent(new P$({propertyName:"content",currentValue:n,oldValue:t}))};$(this,cg)}viewActivatedCallback(){super.viewActivatedCallback(),this._slotLabel.addEventListener("slotchange",this._slotChangeHandler,!1)}disconnectedCallback(){let e=this._slotLabel;Kt.isNull(e)||e.removeEventListener("slotchange",this._slotChangeHandler,!1),super.disconnectedCallback()}get content(){return this.querySelectorAll("*[slot=label]")}};cg=new WeakMap,l([Ry("slot[name=label]")],no.prototype,"_slotLabel",2),l([Oy({converter:I$})],no.prototype,"label",2),l([Oy({converter:yh.String})],no.prototype,"key",2),no=l([GL({tagName:Ud+"-tab",shadow:!0,template:'<slot name="label" part="label"></slot><slot></slot>'})],no);var qs=class extends FL.PacemIterativeElement{constructor(e=new UL.TweenService){super("tablist");this._tweener=e}_labelCallback(e,t){let n=e.content;if(n.length>0){let i="";return n.forEach(s=>{i+=s.outerHTML}),i}return e.label instanceof Node?e.label:`<span class="${e.key||"tab"}">${e.label}</span>`}_syncOrientation(e=this.orientation){Kt.isNull(this._defaultTabAdapter)||(this._defaultTabAdapter.orientation=e),Kt.isNull(this._tabs)||(e==="vertical"?Kt.addClass:Kt.removeClass)(this._tabs,"tabs-vertical")}_syncVisibility(e=this.index,t=-1){let i=this._container,s=i.clientHeight,o=getComputedStyle(i),c=o.boxSizing==="border-box"?0:parseInt(o.paddingTop)+parseInt(o.paddingBottom);i.style.height=s-c+"px";let d=0;for(let p of this.items||[])d===e?(Kt.addClass(p,"tab-in"),requestAnimationFrame(()=>{Kt.addClass(p,zL),Kt.removeClass(p,"tab-in"),Kt.addAnimationEndCallback(p,u=>{Kt.removeClass(u,"tab-previous tab-next");let h=Kt.offset(u).height;this._tweener.run(parseInt(i.style.height),h,100,0,UL.Easings.sineOut,(m,f)=>{i.style.height=Math.round(f)+"px"}).then(m=>{i.style.height=""})},500)}),p.aria.attributes.set("selected","true")):(Kt.removeClass(p,"tab-previous tab-next"),Kt.addClass(p,d<e?"tab-previous":"tab-next"),d===t&&(Kt.addClass(p,"tab-out"),Kt.removeClass(p,zL),Kt.addAnimationEndCallback(p,u=>{Kt.removeClass(u,"tab-out")},500),p.aria.attributes.set("selected","false"))),d++}viewActivatedCallback(){super.viewActivatedCallback(),Kt.isNull(this.adapter)&&(this._syncOrientation(),this._syncVisibility(),this.adapter=this._defaultTabAdapter)}propertyChangedCallback(e,t,n,i){switch(super.propertyChangedCallback(e,t,n,i),e){case"adapter":Kt.isNull(n)&&(this.adapter=this._defaultTabAdapter),this._isUsingDefaultTabAdapter=this.adapter===this._defaultTabAdapter;break;case"index":this._syncVisibility(n,t);break;case"orientation":this._syncOrientation(n);break}}validate(e){return e instanceof no}};l([Ry(Ud+"-adapter")],qs.prototype,"_defaultTabAdapter",2),l([Ry("."+lg+"-tabs")],qs.prototype,"_tabs",2),l([Ry("."+lg+"-tabs-content")],qs.prototype,"_container",2),l([Oy()],qs.prototype,"_isUsingDefaultTabAdapter",2),l([Oy({converter:yh.String})],qs.prototype,"orientation",2),qs=l([GL({tagName:Ud+"-tabs",shadow:!1,template:`<div class="${lg}-tabs">
|
|
161
|
+
<${Ud}-adapter class="${lg}-tabs-adapter" swipe-enabled="false" hide="{{ !:host._isUsingDefaultTabAdapter }}" label-callback="{{ :host._labelCallback }}"></${Ud}-adapter>
|
|
162
|
+
<div class="${lg}-tabs-content">
|
|
163
|
+
<${Ud}-content></${Ud}-content>
|
|
164
|
+
</div>
|
|
165
|
+
</div>`})],qs);import{P as $$,CustomElement as H$,ViewChild as LE,Components as B$,Utils as Py}from"@pacem/pacem-core";var Wl,Fl=class extends B$.PacemSafeContentElement{constructor(){super(...arguments);$(this,Wl);this._contentChangeHandler=e=>{this._incoming.replaceChildren(...x(this,Wl)),Py.addClass(this,"ticking"),Py.addAnimationEndCallback(this._incoming,t=>{Py.removeClass(this,"ticking"),this._outgoing.replaceChildren(...x(this,Wl))})}}_tickContent(e=this.content){if(typeof e=="number"&&(e=e.toLocaleString()),typeof e=="string"){let t=this.sanitize(e);A(this,Wl,this._buildMarkupNode(t))}else if(e instanceof Node){let t=this.sanitize(e);this.replaceChildren(...A(this,Wl,[t]))}else{let t=e.map(n=>this.sanitize(n));this.replaceChildren(...A(this,Wl,t))}}_buildMarkupNode(e){let t=document.createElement("template");return t.innerHTML=e,Array.from(t.content.childNodes)}propertyChangedCallback(e,t,n,i){super.propertyChangedCallback(e,t,n,i),e==="content"&&!i&&this._tickContent(n)}viewActivatedCallback(){super.viewActivatedCallback(),this._slot.addEventListener("slotchange",this._contentChangeHandler,!1);let e=this.content??this._slot.assignedNodes();this._tickContent(e)}disconnectedCallback(){let e=this._slot;Py.isNull(e)||e.removeEventListener("slotchange",this._contentChangeHandler),super.disconnectedCallback()}};Wl=new WeakMap,l([LE("slot")],Fl.prototype,"_slot",2),l([LE("div[part=ticker-outgoing]")],Fl.prototype,"_outgoing",2),l([LE("div[part=ticker-incoming]")],Fl.prototype,"_incoming",2),Fl=l([H$({tagName:$$+"-ticker",shadow:!0,template:'<div part="ticker-outgoing"></div><div part="ticker-incoming"></div><slot hidden></slot>'})],Fl);import{P as V$,PCSS as WL,CustomElement as U$,Watch as NE,Components as z$,Utils as Jr,PropertyConverters as TE,CustomElementUtils as jL,Transformer as YL}from"@pacem/pacem-core";var XL="pacem:toast:pops",Zr=class extends z$.PacemElement{constructor(){super(...arguments);this.autohide=!0;this.timeout=3e3;this._doHide=e=>{window.clearTimeout(this._handle),this.show=!1}}connectedCallback(){super.connectedCallback(),this.addEventListener("click",this._doHide,!1)}propertyChangedCallback(e,t,n,i){if(super.propertyChangedCallback(e,t,n,i),e==="show")if(n!==!0)Jr.removeClass(this,"toast-show"),Jr.addClass(this,"toast-hide"),this.dispatchEvent(new CustomEvent("close")),Jr.waitForAnimationEnd(this,1e3).then(()=>{Jr.removeClass(this,"toast-hide")});else{let s=jL.getAttachedPropertyValue(Zr,XL,0)-1;jL.setAttachedPropertyValue(Zr,XL,s),this.style.order=""+s,Jr.addClass(this,"toast-show"),this._show()}}disconnectedCallback(){this.removeEventListener("click",this._doHide,!1),super.disconnectedCallback()}_show(){window.clearTimeout(this._handle),!this.disabled&&this.autohide&&(this._handle=window.setTimeout(()=>{this.show=!1},this.timeout))}popup(){this.show?this._show():this.show=!0}static toast(e,t,n,i){var s=new Zr;if(Jr.isNullOrEmpty(i?.cssClass))s.className="toast-"+t;else{let u=Jr.isArray(i.cssClass)?i.cssClass.join(" "):i.cssClass;Jr.addClass(s,u)}Jr.isNull(i?.autohide)||(s.autohide=i.autohide),i?.timeout>0&&(s.timeout=i.timeout);let o=document.createElement("i");o.className=WL+"-icon text-bigger-steady "+WL+"-margin margin-right-1 flex-auto";var c="info";switch(t){case"danger":case"error":c="error";break;case"warning":c="warning";break;case"success":c="check_circle";break}o.textContent=c;let d=document.createElement("div");Jr.addClass(d,"display-flex flex-stretch flex-start flex-nowrap"),d.appendChild(o);let p=document.createElement("span");return Jr.addClass(p,"text-small text-pre"),typeof n=="string"?p.innerHTML=n:p.appendChild(n),d.appendChild(p),s.appendChild(d),e.appendChild(s),new Promise((u,h)=>{window.setTimeout(()=>{s.popup()},100);let m=()=>{s.removeEventListener("close",m,!1),u(),Jr.waitForAnimationEnd(s,1e3).then(f=>{s.remove()})};s.addEventListener("close",m,!1)})}static toast2(e,t,n,i){let s=i?.cssClass,o=["fill-"+t+"-container","fill-glass","border-solid","border-size--2","border-round","border-radius--6"];return Jr.isNullOrEmpty(s)||(Jr.isArray(s)?Array.prototype.push.apply(o,s):Array.prototype.push.apply(o,s.split(" "))),Zr.toast(e,t,n,Jr.extend({},i??{},{cssClass:o}))}};l([NE({emit:!1,converter:TE.Boolean})],Zr.prototype,"autohide",2),l([NE({emit:!1,converter:TE.Number})],Zr.prototype,"timeout",2),l([NE({converter:TE.Boolean})],Zr.prototype,"show",2),l([YL("poptoast")],Zr,"toast",1),l([YL("poptoastcontainer")],Zr,"toast2",1),Zr=l([U$({tagName:V$+"-toast"})],Zr);import{P as Ks,PCSS as AE,CustomElement as G$,Watch as dg,ViewChild as F$,Components as qL,Utils as Cr,PropertyConverters as pg,Defaults as W$,Animations as KL,Debounce as JL,avoidHandler as j$}from"@pacem/pacem-core";var Pn=class extends qL.PacemElement{constructor(e=new KL.TweenService){super();this._tweener=e;this._items=[];this._scrollToSelf=e=>{this._scrollTo("#"+e.target.id)};this._hashChange=e=>{e.preventDefault(),this._scrollTo(window.location.hash,!1)}}propertyChangedCallback(e,t,n,i){switch(super.propertyChangedCallback(e,t,n,i),e){case"target":Cr.isNull(this._observer)||this._observe();break;case"selector":this.refresh();break}}connectedCallback(){super.connectedCallback(),window.addEventListener("hashchange",this._hashChange,!1)}disconnectedCallback(){window.removeEventListener("hashchange",this._hashChange,!1),Cr.isNull(this._observer)||this._observer.disconnect(),super.disconnectedCallback()}viewActivatedCallback(){super.viewActivatedCallback(),this._observer=new MutationObserver(e=>{this.refresh()}),this._observe()}_onScroll(e){this._update(Cr.scrollTop)}_observe(){this._observer.observe(this.target||document.body,{subtree:!0,childList:!0})}_getTop(e){return Cr.offset(e).top}_scrollTo(e,t=!0){if(/^#[^&=]+$/.test(e)){let n=!Cr.isNullOrEmpty(e)&&document.querySelector(e),i=!Cr.isNull(n)&&this._items.find(s=>s.dom===n);if(i&&!Cr.isNull(i.dom)){let s=this._getTop(i.dom)-(this.offset||0);if(t){let o=Cr.scrollTop;window.location.hash=i.dom.id,this._tweener.run(o,s,500,0,KL.Easings.sineInOut,(c,d)=>{window.scrollTo(0,d)})}else window.scrollTo(0,s)}}}_startScrollTo(e,t){j$(t),this._scrollTo(e.url)}_update(e){let t=e+(this.offset||0);var n=this._items&&this._items.length>0&&this._items[0];for(var i of this._items)if(Cr.offset(i.dom).top<=t)n=i;else break;let s=[];for(var i of this._items)Cr.isNullOrEmpty(i.dom.id)&&(i.dom.id=i.dom.innerText.trim().replace(/[^a-zA-Z0-9]/g,"-").replace(/-*$/,"").replace(/^-*/,"").toLowerCase()),s.push({focus:i===n,label:i.dom.innerText,url:"#"+i.dom.id});Cr.isNull(this._repeater)||(this._repeater.datasource=s)}refresh(){for(let s of this._items)s.dom.removeEventListener("click",this._scrollToSelf,!1),Cr.removeClass(s.dom,AE+"-toc-item");let e=this.selector;if(Cr.isNullOrEmpty(e)){this._repeater&&(this._repeater.datasource=[]),this.hasContent=!1;return}let t=(this.target||document).querySelectorAll(e),n=[];for(let s=0;s<t.length;s++){let o=t.item(s);o.addEventListener("click",this._scrollToSelf,!1),Cr.addClass(o,AE+"-toc-item"),n.push({dom:o,top:this._getTop(o)})}this._items=n,this._update(Cr.scrollTop),this.hasContent=!Cr.isNullOrEmpty(n);let i=window.location.hash;Cr.isNullOrEmpty(i)||setTimeout(()=>{this._scrollTo(i,!0)},1e3)}};l([dg({emit:!1,converter:pg.String})],Pn.prototype,"selector",2),l([dg({emit:!1,converter:pg.Number})],Pn.prototype,"offset",2),l([dg({emit:!1,converter:pg.Element})],Pn.prototype,"target",2),l([dg({converter:pg.Element})],Pn.prototype,"router",2),l([dg({converter:pg.Boolean})],Pn.prototype,"hasContent",2),l([F$(Ks+"-repeater")],Pn.prototype,"_repeater",2),l([JL(100)],Pn.prototype,"_onScroll",1),l([JL(250)],Pn.prototype,"refresh",1),Pn=l([G$({tagName:Ks+"-toc",shadow:W$.USE_SHADOW_ROOT,template:`<${Ks}-scroll-aware on-${qL.ScrollEventName}=":host._onScroll($event)" url="{{ :host.url }}"></${Ks}-scroll-aware>
|
|
166
|
+
<${Ks}-repeater><nav class="${AE}-toc"><template>
|
|
167
|
+
<${Ks}-a on-click=":host._startScrollTo(^item, $event)" router="{{ :host.router }}" css-class="{{ {'toc-focus': ^item.focus} }}" href="{{ ^item.url }}"><${Ks}-text text="{{ ^item.label }}"></${Ks}-text></${Ks}-a>
|
|
168
|
+
</template></nav></${Ks}-repeater>`})],Pn);import{P as zd,PCSS as ZL,CustomElement as Y$,Watch as ug,ViewChild as hg,Components as X$,Utils as _h,PropertyConverters as mg,UI as Iy,Animations as q$}from"@pacem/pacem-core";import{Angle as K$}from"@pacem/pacem-foundation";var $y=Math.PI*2;function DE(a,r,e,t){return{x:a+e*Math.cos(t),y:r+e*Math.sin(t)}}var fg,Qr=class extends X$.PacemElement{constructor(){super();$(this,fg);this.min=0;this.max=100;this._rotateStartHandler=e=>{let t=A(this,fg,this._getAngle(e)),n=this._rotate;n.minRotation=0-t,n.maxRotation=$y-t,this._setValue(t)};this._rotateEndHandler=e=>{};this._rotateHandler=e=>{e.preventDefault();let t=e.detail.rotation+x(this,fg);this._setValue(t)}}viewActivatedCallback(){super.viewActivatedCallback();let e=this._rotate,t=this._tween;e.addEventListener(Iy.RotateEventType.Start,this._rotateStartHandler,!1),e.addEventListener(Iy.RotateEventType.Rotate,this._rotateHandler,!1),e.addEventListener(Iy.RotateEventType.End,this._rotateEndHandler,!1),e.register(this._canvas),this._toggleRotate(),requestAnimationFrame(()=>this._draw(this.min)),t.easing=q$.Easings.sineInOut,t.delay=500+(Math.random()*100-100),t.start=this.value>this.min}disconnectedCallback(){let e=this._rotate,t=this._canvas;_h.isNull(e)||(e.removeEventListener(Iy.RotateEventType.Rotate,this._rotateHandler,!1),_h.isNull(t)||e.unregister(t)),super.disconnectedCallback()}propertyChangedCallback(e,t,n,i){switch(super.propertyChangedCallback(e,t,n,i),e){case"interactive":this._toggleRotate(n),n?_h.addClass(this,"tuner-interactive"):_h.removeClass(this,"tuner-interactive");break;case"round":if(Math.round(n)!=n||n<0)throw`${this.constructor.name}: round value must be an integer greater or equal to zero.`;break;default:this._draw();break}}_toggleRotate(e=this.interactive){let t=this._rotate;_h.isNull(t)||(t.disabled=!e)}_angleToValue(e){let t=Math.pow(10,this.round||0),n=this.min+e*(this.max-this.min)/$y;return Math.round(t*n)/t}_valueToAngle(e=this.value??this.min){return $y*(e-this.min)/(this.max-this.min)}_setValue(e){let t=this._angleToValue(e).clamp(this.min,this.max);t!=this.value&&(this.value=t,this.dispatchEvent(new Event("change")))}_getAngle(e){let t={vertex:e.detail.center,end:e.detail.currentPosition,start:{x:e.detail.center.x,y:e.detail.center.y-1}},n=K$.value(t);return n>0?$y-n:-n}_draw(e=this.value){if(this.disabled||_h.isNull(this._rail))return;e=(isNaN(e)?this.min:e).clamp(this.min,this.max);let t=this._rail,n=this._counterRail,i=e===this.min,s=e===this.max;if(i||s){let o="M 50 50 m -50,0 a 50,50 0 1,1 100,0 a 50,50 0 1,1 -100,0";t.setAttribute("d",i?"":o),n.setAttribute("d",s?"":o)}else{let o=Math.PI*.5,c=DE(50,50,50,-o),d=this._valueToAngle(e),p=DE(50,50,50,-o+d),u=d>Math.PI?1:0,h=`M ${p.x} ${p.y} A 50 50 0 ${u} 0 ${c.x} ${c.y}`;t.setAttribute("d",h);let m=p,f=DE(50,50,50,3*o),v=this._valueToAngle(this.max-e)>Math.PI?1:0,b=`M ${f.x} ${f.y} A 50 50 0 ${v} 0 ${m.x} ${m.y}`;n.setAttribute("d",b)}}};fg=new WeakMap,l([hg("svg")],Qr.prototype,"_canvas",2),l([hg("path[part=rail]")],Qr.prototype,"_rail",2),l([hg("path[part=complementary-rail]")],Qr.prototype,"_counterRail",2),l([hg(zd+"-tween")],Qr.prototype,"_tween",2),l([hg(zd+"-rotate")],Qr.prototype,"_rotate",2),l([ug({converter:mg.Number})],Qr.prototype,"value",2),l([ug({emit:!1,converter:mg.Number})],Qr.prototype,"min",2),l([ug({emit:!1,converter:mg.Number})],Qr.prototype,"max",2),l([ug({emit:!1,converter:mg.Boolean})],Qr.prototype,"interactive",2),l([ug({emit:!1,converter:mg.Number})],Qr.prototype,"round",2),Qr=l([Y$({tagName:zd+"-tuner",shadow:!0,template:`<svg xmlns="http://www.w3.org/2000/svg" class="${ZL}-tuner" part="tuner" viewBox="0 0 100 100">
|
|
169
|
+
<circle part="track" cx="50" cy="50" r="50" />
|
|
170
|
+
<path part="rail" />
|
|
171
|
+
<path part="complementary-rail" />
|
|
172
|
+
</svg><div class="${ZL}-content" part="content"><slot></slot></div>
|
|
173
|
+
<${zd}-rotate></${zd}-rotate>
|
|
174
|
+
<${zd}-tween on-step=":host._draw($event.detail.value)" on-end="this.disabled = true" duration="500" to="{{ :host.value }}" from="{{ :host.min }}"></${zd}-tween>`})],Qr);import{P as J$,CustomElement as Z$,Watch as Q$,PacemEventTarget as eH,Utils as tH}from"@pacem/pacem-core";var xh=class extends eH{vibrate(){if(this.disabled)return;let r=this.pattern;tH.isNullOrEmpty(r)||typeof navigator.vibrate=="function"&&navigator.vibrate(r)}};l([Q$({emit:!1,converter:{convert:r=>r?.split(/[ ,]+/).map(e=>parseInt(e)),convertBack:r=>r?.join(" ")}})],xh.prototype,"pattern",2),xh=l([Z$({tagName:J$+"-vibrate"})],xh);import{P as rH,CustomElement as nH,Watch as Ch,PacemEventTarget as iH,Components as QL,Utils as Gd,PropertyConverters as RE,Logging as OE}from"@pacem/pacem-core";var eN=500,sH={convert:(a,r)=>{try{return document.querySelector(a)??(r.isConnected?a:null)}catch{return a}},convertBack:a=>a instanceof Element&&a.id?"#"+a.id:a,retryConversionWhenReady:!0},Eh,rs=class extends iH{constructor(){super(...arguments);this._templateChangeHandler=e=>{let t=e.target;this._setTmpl(t.target)};$(this,Eh)}propertyChangedCallback(e,t,n,i){super.propertyChangedCallback(e,t,n,i),e==="url"||e==="disabled"?(this._dispose(t),this._manage()):e==="fetching"&&(n?Gd.addClass:Gd.removeClass)(this,"view-fetching")}viewActivatedCallback(){super.viewActivatedCallback();let e=this.url;this._isReference(e)&&!this.disabled&&this._manageRef()}_isReference(e){return e instanceof HTMLElement||typeof e=="string"&&e.trim().startsWith("#")}_dispose(e){e instanceof QL.PacemTemplateProxyElement&&e.removeEventListener("templatechange",this._templateChangeHandler)}_manage(){if(this.disabled)return;let e=this.debounce||0,t=this.url;this._isReference(t)?(clearTimeout(this._fetchHandle),this._fetchHandle=setTimeout((()=>this._manageRef()),e)):typeof t=="string"&&!Gd.isNullOrEmpty(t)?(this.fetching=!0,clearTimeout(this._fetchHandle),this._fetchHandle=setTimeout((()=>this._manageUrl(t)),e)):this.innerHTML=""}_manageRef(){let e=this.url,t=e instanceof HTMLElement?e:document.querySelector("template"+e);t instanceof QL.PacemTemplateProxyElement?(t.addEventListener("templatechange",this._templateChangeHandler,!1),this._setTmpl(t.target)):t instanceof HTMLTemplateElement?this._setTmpl(t):Gd.isNull(t)?this.log(OE.LogLevel.Error,"Template element not found."):this.log(OE.LogLevel.Error,`Invalid '${t.constructor.name}' element, HTMLTemplate expected.`)}_setTmpl(e){cancelAnimationFrame(this._renderHandle),this.innerHTML="",this._renderHandle=requestAnimationFrame(()=>{if(Gd.isNull(e)){this.log(OE.LogLevel.Error,"Template element not found.");return}this.appendChild(e.cloneNode(!0).content),this._dispatchRender()})}_manageUrl(e){x(this,Eh)&&x(this,Eh).abort();let{signal:t}=A(this,Eh,new AbortController);fetch(e,{credentials:"same-origin",signal:t}).then(async n=>{let i=(o,c)=>{(o.status===301||o.status===302)&&this.followRedirects?this._manageUrl(o.headers.get("Location")):o.ok||this.renderErrors?c.then(d=>Gd.addAnimationEndCallback(this,()=>this._manageResult(d),eN)):this._manageResult("")},s=+n.headers.get("Content-Length");if(s>0){this.progress=0;let o=0,c=[],d=n.body.getReader();for(;;){let{done:p,value:u}=await d.read();if(p)break;this.progress=(o+=u.length)/s,c.push(u)}i(n,new Promise((p,u)=>{try{let h=new Uint8Array(o),m=0;for(let g of c)h.set(g,m),m+=g.length;let f=new TextDecoder("utf-8").decode(h);p(f)}catch(h){u(h)}}))}else i(n,n.text())},n=>{})}_manageResult(e){cancelAnimationFrame(this._renderHandle),this.scrollTo({top:0,left:0,behavior:"instant"}),this.innerHTML="",this._renderHandle=requestAnimationFrame(()=>{this.innerHTML=e,this.fetching=!1,this.progress=Number.NaN,Gd.addAnimationEndCallback(this,()=>{this._dispatchRender()},eN)})}_dispatchRender(){this.dispatchEvent(new CustomEvent("render"))}};Eh=new WeakMap,l([Ch({reflectBack:!0,converter:sH})],rs.prototype,"url",2),l([Ch()],rs.prototype,"fetching",2),l([Ch()],rs.prototype,"progress",2),l([Ch({emit:!1,converter:RE.Boolean})],rs.prototype,"renderErrors",2),l([Ch({emit:!1,converter:RE.Boolean})],rs.prototype,"followRedirects",2),l([Ch({emit:!1,converter:RE.Number})],rs.prototype,"debounce",2),rs=l([nH({tagName:rH+"-view"})],rs);import{P as In,PCSS as aH,CustomElement as rN,Watch as PE,Components as nN,UI as Hy,Utils as vn,PropertyConverters as IE,Defaults as oH,CustomElementUtils as lH,PropertyChangeEventName as tN}from"@pacem/pacem-core";var iN="window-title",gg=class extends nN.PacemIterativeElement{constructor(){super(...arguments);this._zIndex=1;this._startHandler=e=>{this._incrementZIndex(e.detail.element),vn.addClass(e.detail.element,"window-rescaling")};this._blurHandler=e=>{vn.removeClass(e.detail.element,"window-rescaling")};this._focusHandler=e=>{this._incrementZIndex(e.currentTarget)};this._itemPropertyChangeHandler=e=>{if(e.detail.propertyName==="floating"&&e.detail.currentValue===!1){let t=e.currentTarget,n=this.items.indexOf(t);vn.addClass(t,"docking-in"),this.adapter.select(n),vn.addAnimationEndCallback(t,i=>{vn.removeClass(i,"docking-in")},150)}};this._adapterPagerCallback=e=>{let t=e.detail.index,n=this.items[t];e.detail.hide=n.hide||n.floating}}validate(e){return e instanceof io}_incrementZIndex(e){this._zIndex!=parseInt(e.style.zIndex)&&(e.style.zIndex=""+ ++this._zIndex)}connectedCallback(){super.connectedCallback();let e=lH.findAncestorShell(this);this._behaviors=[e.appendChild(this._dragDrop=document.createElement(In+"-drag-drop")),e.appendChild(this._rescale=document.createElement(In+"-rescale"))],this._dragDrop.handleSelector="."+iN,this._rescale.addEventListener(Hy.RescaleEventType.Start,this._startHandler,!1),this._rescale.addEventListener(Hy.RescaleEventType.End,this._blurHandler,!1)}viewActivatedCallback(){if(super.viewActivatedCallback(),vn.isNull(this.adapter)){let e=this.adapter=this.appendChild(document.createElement(In+"-adapter"));vn.addClass(e,"windows-adapter"),e.labelCallback=(t,n)=>t.caption,e.swipeEnabled=!1,e.deselectable=!0,e.initialize(this)}this.adapter.addEventListener(Of,this._adapterPagerCallback,!1)}disconnectedCallback(){vn.isNull(this.adapter)||(this.adapter.removeEventListener(Of,this._adapterPagerCallback,!1),this.adapter.remove(),this.adapter=null),this._rescale.removeEventListener(Hy.RescaleEventType.End,this._blurHandler,!1),this._rescale.removeEventListener(Hy.RescaleEventType.Start,this._startHandler,!1);for(let e of this._behaviors)e.remove();super.disconnectedCallback()}propertyChangedCallback(e,t,n,i){super.propertyChangedCallback(e,t,n,i),e==="index"&&this._syncVisibility()}register(e){let t=super.register(e);if(t){e.addEventListener(tN,this._itemPropertyChangeHandler,!1),e.addEventListener("mousedown",this._focusHandler,!1);for(let n of this._behaviors)e.behaviors.indexOf(n)===-1&&e.behaviors.push(n)}return t}unregister(e){let t=super.unregister(e);if(t){e.removeEventListener(tN,this._itemPropertyChangeHandler,!1),e.removeEventListener("mousedown",this._focusHandler,!1);for(let n of this._behaviors){let i=e.behaviors.indexOf(n);i>=0&&e.behaviors.splice(i,1)}}return t}_syncVisibility(){let e=0,t=this.items??[];for(let n of t)e===this.index?vn.addClass(n,"dock-open"):vn.removeClass(n,"dock-open"),e++}};gg=l([rN({tagName:In+"-window-area"})],gg);var io=class extends nN.PacemIterableElement{propertyChangedCallback(r,e,t,n){super.propertyChangedCallback(r,e,t,n),(r==="minimized"||r==="floating")&&this._syncLayout()}viewActivatedCallback(){super.viewActivatedCallback(),this._syncLayout()}_syncLayout(){(this.minimized?vn.addClass:vn.removeClass).apply(this,[this,"window-min"]),(this.floating?vn.removeClass:vn.addClass).apply(this,[this,"window-dock"])}};l([PE({converter:IE.String})],io.prototype,"caption",2),l([PE({converter:IE.Boolean})],io.prototype,"minimized",2),l([PE({converter:IE.Boolean})],io.prototype,"floating",2),io=l([rN({tagName:In+"-window",shadow:oH.USE_SHADOW_ROOT,template:`<div class="${iN}">
|
|
175
|
+
<${In}-text text="{{ :host.caption || 'Window' }}"></${In}-text>
|
|
176
|
+
</div>
|
|
177
|
+
<div class="window-buttons ${aH}-buttonset"><div class="buttonset-right">
|
|
178
|
+
<${In}-button class="button" on-click=":host.minimized = !:host.minimized" icon-glyph="{{ :host.minimized ? 'maximize' : 'minimize' }}" hide="{{ !:host.floating }}"></${In}-button>
|
|
179
|
+
<${In}-button class="button" on-click=":host.floating = !:host.floating" css-class="{{ {'buttonset-first': !:host.floating} }}" icon-glyph="{{ :host.floating? 'lock_open' : 'lock' }}"></${In}-button>
|
|
180
|
+
</div></div>
|
|
181
|
+
<div class="window-content"><${In}-content></${In}-content></div>`})],io);var Iw={};tt(Iw,{BASIC_VALIDATOR_TEMPLATE:()=>_o,CHAR_COUNTER_CHILD:()=>en,CONTENTELEMENT_BUTTONCOMMAND_TEMPLATE:()=>$n,CalendarDateUnselectEvent:()=>_g,ChangePolicy:()=>dw,ContenteditableDOMObserver:()=>jd,ContenteditableUtils:()=>xe,DEFAULT_ATTRIBUTION:()=>IV,DEFAULT_TILES:()=>PV,FileChangeEvent:()=>Hh,FileChangeEventName:()=>iT,FileUploadEvent:()=>Ag,FileUploadEventName:()=>p_,FormEventEmitter:()=>Uy,FormResetEvent:()=>Vy,FormResetEventName:()=>dN,FormSubmitEvent:()=>By,FormSubmitEventName:()=>cN,ImageFetchRequestEvent:()=>Pg,ImageFetchRequestEventName:()=>h_,KnownExecCommand:()=>XE,PacemAsyncValidatorElement:()=>Vn,PacemBaseElement:()=>ge,PacemBaseInputElement:()=>na,PacemBaseValidatorElement:()=>$r,PacemBinaryValidatorElement:()=>bo,PacemCalendarMonthPickerElement:()=>Yd,PacemCalendarPickerElement:()=>tn,PacemCalendarYearPickerElement:()=>Xd,PacemCharCountElement:()=>Kl,PacemCharsInputElement:()=>So,PacemCheckboxElement:()=>gi,PacemCheckboxListElement:()=>tc,PacemChildFormElement:()=>yn,PacemChildFormPropagatorElement:()=>nc,PacemColorInputElement:()=>Lo,PacemCompareValidatorElement:()=>vo,PacemContenteditableAlignCommandElement:()=>os,PacemContenteditableButtonCommandElement:()=>Zt,PacemContenteditableCommandElement:()=>Zs,PacemContenteditableElement:()=>oo,PacemContenteditableExecCommandElement:()=>bn,PacemContenteditableHistoryCommandElement:()=>co,PacemContenteditableImageCommandElement:()=>po,PacemContenteditableLinkCommandElement:()=>Jl,PacemContenteditablePlaceholderElement:()=>ec,PacemContenteditableWrapCommandElement:()=>Th,PacemCustomValidatorElement:()=>sc,PacemDataItemElement:()=>is,PacemDataSourceElement:()=>Ht,PacemDatetimePickerElement:()=>nt,PacemEditImageElement:()=>Nt,PacemEmailInputElement:()=>ep,PacemFormElement:()=>ot,PacemFormFieldElement:()=>rn,PacemFormRelevantElement:()=>ns,PacemGeolocateElement:()=>vi,PacemHiddenInputElement:()=>Bh,PacemHierarchyElement:()=>Qt,PacemImageInputElement:()=>Hr,PacemItemElement:()=>kh,PacemItemsContainerBaseElement:()=>ql,PacemLatLngElement:()=>Mr,PacemLengthValidatorElement:()=>fo,PacemMarkdownTextAreaElement:()=>Io,PacemModelElement:()=>Fd,PacemNameValueListElement:()=>op,PacemNumberInputElement:()=>dc,PacemOrdinalInputElement:()=>cc,PacemPasswordInputElement:()=>uc,PacemPropertyPickerElement:()=>lp,PacemRadioElement:()=>aa,PacemRadioListElement:()=>hc,PacemRangeValidatorElement:()=>go,PacemRegexValidatorElement:()=>yo,PacemRequiredValidatorElement:()=>Kd,PacemSearchInputElement:()=>zh,PacemSelectElement:()=>Oo,PacemSliderElement:()=>fr,PacemSnapshotElement:()=>zt,PacemSuggestElement:()=>rr,PacemTagElement:()=>vc,PacemTagsElement:()=>ps,PacemTelInputElement:()=>np,PacemTextAreaElement:()=>Po,PacemTextInputElement:()=>ip,PacemTextualInputElement:()=>dt,PacemUploadElement:()=>it,PacemUrlInputElement:()=>sp,Picture:()=>gw,SnapshotStep:()=>fw});import{CustomElement as FH,Defaults as WH,P as jH,PropertyConverters as YH,Utils as Zl,Watch as XH}from"@pacem/pacem-core";import{P as Mh,PropertyConverters as Wy,Utils as vN,Watch as jy}from"@pacem/pacem-core";import{CustomTypedEvent as xH,CustomEventUtils as CH,Debounce as EH,Utils as Js,P as GE,PCSS as FE,CustomElement as wH,Watch as WE,Defaults as kH,ViewChild as mN,PropertyChangeEvent as MH,PropertyChangeEventName as fN}from"@pacem/pacem-core";import{HistoryService as SH}from"@pacem/pacem-foundation";import{P as mH,PCSS as ao,CustomElementUtils as VE,Utils as ie,Components as fH,PropertyConverters as Er,CustomElement as gH,Watch as Bt,stopPropagationHandler as Wd,DefaultComparer as hN,PropertyChangeEventName as pN,Debounce as vH}from"@pacem/pacem-core";import{P as $t,PCSS as so,CustomElement as cH,Watch as Jt,Utils as dr,PropertyConverters as pr,CustomTypedEvent as dH,CommandEventName as oN,Components as lN,Net as fi,Debounce as pH,avoidHandler as HE,PropertyChangeEvent as BE,PropertyChangeEventName as jl,DeferPromise as uH,Logging as Yl,CustomElementUtils as hH}from"@pacem/pacem-core";var cN="submit",dN="reset",By=class extends dH{constructor(r){super(cN,r,{bubbles:!0,cancelable:!0})}},Vy=class extends Event{constructor(){super(dN,{bubbles:!0,cancelable:!0})}},sN=["download",nu,oN],aN=!1,Uy=class{constructor(r){this._element=r;this._itemEmitHandler=r=>{if(this._element.handle(r),r.type===oN){let e=r;this._element.handle(new CustomEvent("item"+e.detail.commandName.toLowerCase(),{detail:e.detail.commandArgument}))}}}start(){sN.forEach(r=>this._element.addEventListener(r,this._itemEmitHandler,!1))}stop(){sN.forEach(r=>this._element.removeEventListener(r,this._itemEmitHandler,!1))}},ns=class extends lN.PacemElement{viewActivatedCallback(){super.viewActivatedCallback(),this.form=hH.findAncestorOfType(this,ot)}};l([Jt({converter:pr.Element})],ns.prototype,"form",2);var wh,ot=class extends ns{constructor(){super("form");this.method=fi.HttpMethod.Post;this._emitter=null;this._buttons={submit:void 0,reset:void 0};$(this,wh,!1);this._keyupHandler=e=>{if(e.keyCode===13&&!e.shiftKey&&!e.ctrlKey&&!e.altKey&&!e.metaKey){let t=e.currentTarget.querySelector($t+"-button[type=submit]");!dr.isNull(t)&&dr.isVisible(t)&&!t.disabled&&t.click()}};this._submit=(e,t)=>{dr.isNull(t)||HE(t),Promise.all(this._validateAllFields()).then(n=>{n.findIndex(i=>i===!1)===-1&&this.submit(e).then(i=>{this.setPristine()},i=>{})})};this._reset=e=>{dr.isNull(e)||HE(e);var t=new Vy;if(this.dispatchEvent(t),!t.defaultPrevented){for(var n in this._fields){var i=this._fields[n];i instanceof Fd&&i.reset()}for(var s of this._subForms)s._reset()}};this._fields={};this._validators={};this._subForms=[];this._fieldPropertyChanged=e=>{switch(e.detail.propertyName){case"value":let t=e.target;this._checkFieldValidity(t.name);break;case"dirty":this._checkDirtyness();break;case"valid":this._checkValidity();break}};this._validatorPropertyChanged=e=>{let t=e.target,n=t.watch;if(e.detail.propertyName==="invalid"){let i=this._fields[t.watch];t.invalid?i.valid=!1:this._checkFieldValidity(n)}else this._checkFieldValidity(n)};this.suddenValidation=!0;this.resettable=!0;this._emitter=new Uy(this)}propertyChangedCallback(e,t,n,i){super.propertyChangedCallback(e,t,n,i),(e==="method"&&this.autogenerate===!0&&!dr.isNullOrEmpty(this.metadata)||e==="metadata"&&this.autogenerate===!0||e==="autogenerate"&&n===!0&&this.metadata&&(this.metadata.props||this.metadata).length>0)&&this._buildUpForm()}viewActivatedCallback(){super.viewActivatedCallback(),this.form&&this.form.registerSubForm(this),this._checkValidity(),this.addEventListener("keyup",this._keyupHandler,!1),this._emitter.start()}disconnectedCallback(){this._emitter.stop(),this.removeEventListener("keyup",this._keyupHandler,!1),this.form&&this.form.unregisterSubForm(this),super.disconnectedCallback()}_buildUpForm(){let e="_"+dr.uniqueCode(),t=this.id=this.id||e,n="fetch"+e,i=document.createElement("form");i.id="form"+e,i.className=so+"-form",i.setAttribute("pacem",""),i.setAttribute("novalidate","");let s=`<${$t}-repeater datasource="{{ #${t}.metadata && (#${t}.metadata.props || #${t}.metadata) }}">
|
|
182
|
+
<${$t}-panel css="{{ #${t}.metadata.display && #${t}.metadata.display.css }}" css-class="{{ (#${t}.metadata.display && #${t}.metadata.display.cssClass || []).concat(#${t}.suddenValidation ? [] : ['lazy-validation']) }}" class="${so}-animatable-list ${so}-list-appear">
|
|
183
|
+
<template>
|
|
184
|
+
<${$t}-form-field fetch-credentials="{{ #${t}.fetchCredentials }}" fetch-headers="{{ #${t}.fetchHeaders }}"
|
|
185
|
+
logger="{{ #${t}.logger }}" entity="{{ #${t}.entity, twoway }}"
|
|
186
|
+
metadata="{{ ^item }}" readonly="{{ #${t}.readonly || ^item.isReadOnly }}"></${$t}-form-field>
|
|
187
|
+
</template>
|
|
188
|
+
</${$t}-panel>
|
|
189
|
+
</${$t}-repeater>
|
|
190
|
+
<${$t}-fetch logger="{{ #${t}.logger }}" id="${n}" method="${this.method}" credentials="{{ #${t}.fetchCredentials }}" headers="{{ #${t}.fetchHeaders }}"></${$t}-fetch>
|
|
191
|
+
<div class="${so}-buttonset buttons">
|
|
192
|
+
<div class="buttonset-left">
|
|
193
|
+
<${$t}-button logger="{{ #${t}.logger }}" on-click="#${t}._submit(#${t}.fetcher || #${n}, $event)" type="submit" hide="{{ #${t}.readonly || $pacem.isNullOrEmpty(#${t}.action) || !$pacem.isNull(#${t}.form) }}"
|
|
194
|
+
class="button primary button-size size-small"
|
|
195
|
+
css-class="{{ {'buttonset-last': !#${t}.resettable || !#${t}.dirty || !$pacem.isNull(#${t}.form) } }}"
|
|
196
|
+
disabled="{{ (#${t}.suddenValidation && (!(#${t}.valid && #${t}.dirty))) || #${t}.fetching }}">
|
|
197
|
+
<${$t}-panel class="submit-spinner ${so}-anim anim-pop" hide="{{ !#${t}.fetching }}"><i class="${so}-icon ${so}-anim anim-rotate rotate-uniform display-block">refresh</i></${$t}-panel>
|
|
198
|
+
<${$t}-text text="{{ #${t}.submitCaption || 'OK' }}"></${$t}-text>
|
|
199
|
+
</${$t}-button>
|
|
200
|
+
<${$t}-button logger="{{ #${t}.logger }}" on-click="#${t}._reset($event)" type="reset" class="button button-size size-small" css-class="{{ {'buttonset-first': #${t}.readonly || $pacem.isNullOrEmpty(#${t}.action) || !$pacem.isNull(#${t}.form)} }}" hide="{{ !#${t}.resettable || #${t}.readonly || !#${t}.dirty || !Pacem.Utils.isNull(#${t}.form) }}" disabled="{{ #${t}.fetching }}">
|
|
201
|
+
<${$t}-text text="{{ #${t}.resetCaption || 'Reset' }}"></${$t}-text>
|
|
202
|
+
</${$t}-button>
|
|
203
|
+
</div></div>`;i.innerHTML=s,this.innerHTML="",this.appendChild(i),i.addEventListener("submit",HE,!1);let o=this._buttons,c=this._buttons={submit:i.lastElementChild.firstElementChild.firstElementChild,reset:i.lastElementChild.firstElementChild.lastElementChild};this.dispatchEvent(new BE({propertyName:"formButtons",currentValue:c,oldValue:o}))}get formButtons(){return this._buttons}get fetching(){return x(this,wh)}submit(e){return new Promise((t,n)=>{dr.isNull(e)&&n("Fetcher cannot be null while submitting a form."),this._submitInternally(e).then(i=>{this.dispatchEvent(new CustomEvent("success",{detail:i})),t(i)},i=>{i!==aN&&this.dispatchEvent(new CustomEvent("fail",{detail:i})),n(i)})})}reset(){this._reset()}_submitInternally(e,c){if(dr.isNull(e))throw"Fetcher cannot be null while submitting a form.";var n=uH.defer();let i=this.entity,s=this.entityName;var o={};dr.isNullOrEmpty(s)?o=i:o[s]=i;var c={parameters:o,fields:this._getAllFields()},d=new By(c);if(this.dispatchEvent(d),d.defaultPrevented)n.reject(aN);else{e.parameters=dr.extend({},d.detail.parameters);let p=f=>{e.removeEventListener(fi.FetchSuccessEventName,p,!1),e.removeEventListener(fi.FetchErrorEventName,h,!1);let g=f.detail;fi.Fetcher.isEmpty(g)&&(e.removeEventListener(fi.FetchResultEventName,u,!1),this.success=!0,n.resolve({})),g.status===205&&this._reset()},u=f=>{e.removeEventListener(fi.FetchResultEventName,u,!1);var g=f.detail;typeof g=="object"&&g.hasOwnProperty("success")?g.success===!0?(this.success=!0,n.resolve(g.result||{})):(this.fail=!0,n.reject(g.error)):(this.success=!0,n.resolve(g))},h=f=>{e.removeEventListener(fi.FetchSuccessEventName,p,!1),e.removeEventListener(fi.FetchResultEventName,u,!1),e.removeEventListener(fi.FetchErrorEventName,h,!1),this.fail=!0;let g=f.detail;n.reject(g)},m=f=>{f.detail.propertyName==="fetching"&&(f.detail.currentValue===!0?(dr.addClass(this,so+"-fetching"),A(this,wh,!0),this.dispatchEvent(new BE({currentValue:!0,oldValue:!1,propertyName:"fetching"}))):(A(this,wh,!1),this.dispatchEvent(new BE({currentValue:!1,oldValue:!0,propertyName:"fetching"})),dr.removeClass(this,so+"-fetching"),e.removeEventListener(jl,m,!1)))};e.addEventListener(jl,m,!1),e.addEventListener(fi.FetchSuccessEventName,p,!1),e.addEventListener(fi.FetchResultEventName,u,!1),e.addEventListener(fi.FetchErrorEventName,h,!1),dr.isNullOrEmpty(this.action)||(e.url=this.action),e instanceof lN.PacemFetchElement&&!e.autofetch&&e.fetch(),this.success=this.fail=!1}return n.promise}_getAllFields(e={}){dr.extend(e,this._fields);for(var t of this._subForms)t._getAllFields(e);return e}apply(e){if(!dr.isNullOrEmpty(e)){this.entity=dr.extend({},this.entity,e);for(let t in e)this.setDirty(t)}}setPristine(...e){this._setAs(!1,...e)}setDirty(...e){this._setAs(!0,...e)}_setAs(e,...t){let n=!dr.isEmpty(t);for(let i in this._fields)if(!n||t.indexOf(i)>=0){let s=this._fields[i];s instanceof Fd&&(e?s.setDirty():s.setPristine())}for(let i of this._subForms)e?i.setDirty(...t):i.setPristine(...t)}_checkFieldValidity(e){return this.suddenValidation?e in this._fields?this._validateField(e,!1):Promise.resolve(!1):Promise.resolve(null)}validate(e){return dr.isNullOrEmpty(e)?Promise.all(this._validateAllFields()).then(t=>!t.some(n=>n===!1)):this._validateField(e,!1)}_validateAllFields(e=!0){let t=[];for(let n in this._fields)t.push(this._validateField(n,e));for(let n of this._subForms)Array.prototype.push.apply(t,n._validateAllFields(e));return t}_validateField(e,t){return new Promise((n,i)=>{var s=this._fields[e];if(s){var o=this._validators[s.name];o&&o.length>0?(this.log(Yl.LogLevel.Log,`Computing "${s.name}" validity.`),Promise.all(o.map(c=>c.validate(s.value).then(d=>!(c.invalid=!d)))).then(c=>{let d=!0;for(var p of c)if(p===!1){d=!1,t&&s.setDirty();break}this.log(Yl.LogLevel.Log,`Property "${s.name}" turns out to be ${d?"":"not "}valid.`),n(s.valid=d)})):(this.log(Yl.LogLevel.Log,`Property "${s.name}" has no validators.`),n(s.valid=!0))}else this.log(Yl.LogLevel.Log,`Property "${e}" has no fields in this form.`),n(!0)})}_checkDirtyness(){let e=!1;for(var t in this._fields)if(this._fields[t].dirty===!0){e=!0;break}if(e===!1){for(var n of this._subForms)if(n.dirty){e=!0;break}}this.dirty=e}_checkValidity(){let e=!0;for(var t in this._fields)if(this.log(Yl.LogLevel.Log,`Checking "${t}" validity.`),this._fields[t].valid===!1){this.log(Yl.LogLevel.Log,`"${t}" is not valid.`),e=!1;break}if(e===!0){for(var n of this._subForms)if(!n.valid){e=!1;break}}this.valid=e}registerSubForm(e){let t=this._subForms;t.indexOf(e)==-1&&(e.addEventListener(jl,this._fieldPropertyChanged,!1),t.push(e),this._checkValidity(),this._checkDirtyness())}unregisterSubForm(e){let t=this._subForms,n=t.indexOf(e);n>=0&&(e.removeEventListener(jl,this._fieldPropertyChanged,!1),t.splice(n,1),this._checkValidity(),this._checkDirtyness())}registerField(e,t){var n=this._fields;n[e]!=t&&(this.unregisterField(e,!1),n[e]=t,this.log(Yl.LogLevel.Log,`Registering "${e}" field.`),t instanceof HTMLElement&&t.addEventListener(jl,this._fieldPropertyChanged,!1),this._checkFieldValidity(e),this._checkDirtyness())}unregisterField(e,t=!0){var n=this._fields,i=n[e];i instanceof HTMLElement&&i.removeEventListener(jl,this._fieldPropertyChanged,!1),delete n[e],i&&t===!0&&(this._checkValidity(),this._checkDirtyness())}registerValidator(e,t){var n=this._validators[e]=this._validators[e]||[],i=n.indexOf(t);i==-1&&(n.push(t),t instanceof HTMLElement&&t.addEventListener(jl,this._validatorPropertyChanged,!1),this.log(Yl.LogLevel.Log,`Calling "${e}" validity check after validator registration.`),this._checkFieldValidity(e))}unregisterValidator(e,t){this._unregisterValidator(e,t,!0)}_unregisterValidator(e,t,n){var i=this._validators[e]=this._validators[e]||[],s=i.indexOf(t);s>=0&&(t instanceof HTMLElement&&t.removeEventListener(jl,this._validatorPropertyChanged,!1),i.splice(s,1),n&&this._checkFieldValidity(e))}};wh=new WeakMap,l([Jt({emit:!1,converter:pr.Element})],ot.prototype,"fetcher",2),l([Jt({emit:!1,converter:pr.String})],ot.prototype,"fetchCredentials",2),l([Jt({emit:!1,converter:pr.Json})],ot.prototype,"fetchHeaders",2),l([Jt({reflectBack:!0,converter:pr.String})],ot.prototype,"method",2),l([Jt({reflectBack:!0,converter:pr.String})],ot.prototype,"submitCaption",2),l([Jt({reflectBack:!0,converter:pr.String})],ot.prototype,"resetCaption",2),l([pH(100)],ot.prototype,"_buildUpForm",1),l([Jt({reflectBack:!0,converter:pr.Boolean})],ot.prototype,"valid",2),l([Jt({reflectBack:!0,converter:pr.Boolean})],ot.prototype,"dirty",2),l([Jt({reflectBack:!0,converter:pr.Boolean})],ot.prototype,"readonly",2),l([Jt({converter:pr.Boolean})],ot.prototype,"success",2),l([Jt({converter:pr.Boolean})],ot.prototype,"fail",2),l([Jt({converter:pr.Json})],ot.prototype,"entity",2),l([Jt({emit:!1,converter:pr.String})],ot.prototype,"entityName",2),l([Jt()],ot.prototype,"metadata",2),l([Jt({emit:!1,converter:pr.Boolean})],ot.prototype,"autogenerate",2),l([Jt({converter:pr.Boolean})],ot.prototype,"suddenValidation",2),l([Jt({emit:!1,converter:pr.Boolean})],ot.prototype,"resettable",2),l([Jt({converter:pr.String})],ot.prototype,"action",2),ot=l([cH({tagName:$t+"-form"})],ot);var uN="pacem:model:original-value",Xl=class Xl extends ns{viewActivatedCallback(){super.viewActivatedCallback(),this._registerFieldConditionally(),this._setAsOriginalValue(this.value)}_registerFieldConditionally(){let r=this.name,e=this.form;if(!ie.isNullOrEmpty(r)&&!ie.isNull(e)&&(!this.hasAttribute("autobind")||this.getAttribute("autobind")!=="off"&&this.getAttribute("autobind")!=="false")&&(e.registerField(r,this),!this.hasAttribute("value"))){let t=e.id=e.id||"frm_"+ie.uniqueCode();this.setAttribute("value",`{{ #${t}.entity.${r}, twoway }}`)}}propertyChangedCallback(r,e,t,n){switch(super.propertyChangedCallback(r,e,t,n),r){case"value":this.viewValue=this.getViewValue(t);break;case"valid":t?ie.removeClass(this,ao+"-invalid"):ie.addClass(this,ao+"-invalid");break;case"dirty":t?ie.addClass(this,ao+"-dirty"):ie.removeClass(this,ao+"-dirty");break;case"name":let i=this.form;i!=null&&e&&i.unregisterField(e),this._registerFieldConditionally();break;case"form":let s=this.name;ie.isNullOrEmpty(s)||e?.unregisterField(s),this._registerFieldConditionally();break}}disconnectedCallback(){let r=this.name,e=this.form;!ie.isNullOrEmpty(r)&&!ie.isNull(e)&&e.unregisterField(r),super.disconnectedCallback()}get originalValue(){return VE.getAttachedPropertyValue(this,uN)}_setAsOriginalValue(r){VE.setAttachedPropertyValue(this,uN,r)}reset(){this.value=this.originalValue,this.dirty=!1}setPristine(){this._setAsOriginalValue(this.value),this.dirty=!1}setDirty(){this.dirty=!0}};l([Bt({converter:Er.String})],Xl.prototype,"viewValue",2),l([Bt({converter:{convert:(r,e)=>e instanceof Xl?e.convertValueAttributeToProperty(r):r,convertBack:r=>r.toString()}})],Xl.prototype,"value",2),l([Bt({converter:Er.Boolean})],Xl.prototype,"dirty",2),l([Bt({converter:Er.Boolean})],Xl.prototype,"valid",2),l([Bt({converter:Er.String})],Xl.prototype,"name",2);var Fd=Xl,ge=class extends Fd{constructor(){super(...arguments);this.focusHandler=e=>{let t=(i=!0)=>{ie.hasClass(this.parentElement,"."+ao+"-fieldgroup")&&(i?ie.addClass:ie.removeClass).apply(this,[this.parentElement,ao+"-focus"])},n=()=>t(!1);switch(e.type){case"focus":ie.addClass(this,ao+"-focus"),t(),this._preFocusValue=this.value;break;case"blur":ie.removeClass(this,ao+"-focus"),n();break}e.bubbles?this.emit(e):this.dispatchEvent(new FocusEvent(e.type))};this.changeHandler=e=>{let t=this.value;this.onChange(e).then(n=>{this.compareValuePropertyValues(t,n)||(this.dispatchEvent(new Qm({fieldName:this.name,oldValue:t,currentValue:n,firstChange:!this.dirty})),this.dirty=!0)},n=>{})};this.keydownHandler=e=>{Wd(e)};this.keyupHandler=e=>{switch(e.keyCode){case 27:Wd(e),this.compareValuePropertyValues(this.originalValue,this._preFocusValue)?this.reset():this.value=this._preFocusValue,this.blur();break;case 13:this.preventKeyboardSubmit&&Wd(e);break}}}compareValuePropertyValues(e,t){return hN(e,t)}get preventKeyboardSubmit(){return!1}propertyChangedCallback(e,t,n,i){switch(super.propertyChangedCallback(e,t,n,i),e){case"required":case"disabled":case"autofocus":case"placeholder":case"readonly":for(let s of this.inputFields)n?s.setAttribute(e,n):s.removeAttribute(e);break;case"tabOrder":for(let s of this.inputFields)s.setAttribute("tabindex",n);break;case"value":this.acceptValue(n);break}if(e==="required"||e==="disabled"||e==="readonly"){let s=`${ao}-${e}`;n?ie.addClass(this,s):ie.removeClass(this,s)}e==="readonly"?this.toggleReadonlyView(n):e==="required"?this.aria.attributes.set("required",!!n+""):e==="valid"&&this.aria.attributes.set("invalid",(!n&&!!this.dirty)+"")}registerInputFields(e=this.inputFields){!ie.isNull(e)&&!ie.isArray(e)&&(e=[e]);for(let t of e)t.addEventListener("focus",this.focusHandler,!1),t.addEventListener("blur",this.focusHandler,!1),t.addEventListener("change",this.changeHandler,!1),t.addEventListener("keydown",this.keydownHandler,!1),t.addEventListener("keyup",this.keyupHandler,!1),t.addEventListener("mousedown",Wd,!1),t.addEventListener("touchstart",Wd,{passive:!1,capture:!1})}unregisterInputFields(e=this.inputFields){!ie.isNull(e)&&!ie.isArray(e)&&(e=[e]);for(let t of e)ie.isNull(t)||(t.removeEventListener("touchstart",Wd,{capture:!1}),t.removeEventListener("keydown",this.keydownHandler,!1),t.removeEventListener("keyup",this.keyupHandler,!1),t.removeEventListener("mousedown",Wd,!1),t.removeEventListener("change",this.changeHandler,!1),t.removeEventListener("focus",this.focusHandler,!1),t.removeEventListener("blur",this.focusHandler,!1))}viewActivatedCallback(){if(super.viewActivatedCallback(),this.toggleReadonlyView(this.readonly||!1),!ie.isNullOrEmpty(this.id)){let e=document.querySelector(`label[for=${this.id}]`);e?e.id?this.aria.attributes.set("labelledby",e.id):this.aria.attributes.set("label",e.textContent):(this.aria.attributes.remove("labelledby"),this.aria.attributes.remove("label"))}this.registerInputFields()}disconnectedCallback(){this.unregisterInputFields(),super.disconnectedCallback()}focus(){let e=this.inputFields;e&&e.length&&e[0].focus()}blur(){let e=this.inputFields;if(!ie.isNullOrEmpty(e))for(let t of e)t.blur()}};l([Bt({converter:Er.Boolean})],ge.prototype,"required",2),l([Bt({converter:Er.Boolean})],ge.prototype,"autofocus",2),l([Bt({converter:Er.Boolean})],ge.prototype,"readonly",2),l([Bt({converter:Er.String})],ge.prototype,"name",2),l([Bt({converter:Er.String})],ge.prototype,"placeholder",2);var kh=class extends fH.PacemElement{#e;findContainer(){return VE.findAncestor(this,r=>r instanceof ql)}get container(){return this.#e}viewActivatedCallback(){super.viewActivatedCallback();let r=this.#e=this.findContainer();ie.isNull(r)||r.register(this)}disconnectedCallback(){ie.isNull(this.#e)||this.#e.unregister(this),super.disconnectedCallback()}},ql=class extends ge{register(r){let e=!0;return ie.isNull(this.items)?this.items=[r]:this.items.indexOf(r)===-1?this.items.push(r):e=!1,e}unregister(r){let e=!ie.isNull(this.items)&&this.items.indexOf(r);return e>=0?(this.items.splice(e,1)[0],!0):!1}};l([Bt()],ql.prototype,"items",2);var is=class extends kh{};l([Bt({converter:{convert:(r,e)=>{if(r==="true")return!0;if(r==="false")return!1;let t=parseFloat(r);if(!isNaN(t))return t;let n=ie.Dates.parse(r);return ie.Dates.isDate(n)?n:r},convertBack:r=>r.toString()}})],is.prototype,"value",2),l([Bt({converter:Er.String})],is.prototype,"label",2),l([Bt({converter:Er.Boolean})],is.prototype,"disabled",2),is=l([gH({tagName:mH+"-data-item"})],is);var Ht=class extends ql{constructor(e=!1){super();this.multipleChoice=e;this._itemPropertyChangedHandler=e=>{this.databind()}}register(e){let t=super.register(e);return t&&e.addEventListener(pN,this._itemPropertyChangedHandler,!1),t}unregister(e){let t=super.register(e);return t&&e.removeEventListener(pN,this._itemPropertyChangedHandler,!1),t}buildAdaptedDatasource(e=this.datasource){return e&&e.map(t=>this.mapEntityToItem(t))}databind(e=this.buildAdaptedDatasource(this.datasource)){if(ie.isNull(e)&&ie.isNull(this.adaptedDatasource))return;let t=this.adaptedDatasource=e||[];ie.isNullOrEmpty(t.filter(n=>this.isDataSourceItemSelected(n)))&&this.handleDatasourceMismatch(t)}handleDatasourceMismatch(e){this.value=void 0}isItemSelected(e,t=this.value){if(ie.isNullOrEmpty(t))return!1;let n=this.mapEntityToValue(e),i=this.compareBy;return this.multipleChoice&&ie.isArray(t)?!ie.isNull(t.find(s=>s==n||typeof s=="object"&&!ie.isNullOrEmpty(i)&&i in n&&i in s&&n[i]==s[i])):this.multipleChoice?!1:t==n||typeof t=="object"&&!ie.isNullOrEmpty(i)&&i in n&&i in t&&n[i]==t[i]}isDataSourceItemSelected(e,t=this.value){if(ie.isNullOrEmpty(t)||e.disabled)return!1;let n=this.compareBy;if(this.multipleChoice&&ie.isArray(t)){let i=t.find(s=>s==e.value||typeof s=="object"&&!ie.isNullOrEmpty(n)&&n in s&&!ie.isNullOrEmpty(e.value)&&n in e.value&&s[n]==e.value[n]);return!ie.isNull(i)}else return!this.multipleChoice&&!ie.isNullOrEmpty(e.value)?t==e.value||typeof t=="object"&&!ie.isNullOrEmpty(n)&&n in t&&!ie.isNullOrEmpty(e.value)&&n in e.value&&t[n]==e.value[n]:!1}mapEntityToValue(e){if(e==null)throw"entity cannot be null";if(e instanceof is)return e.value;let t=e,n;return(n=this.valueProperty)&&(t=e[n]),t}mapEntityToViewValue(e){if(e==null)throw"entity cannot be null";if(e instanceof is)return e.label||e.value;let t=e.toString(),n;return(n=this.textProperty)&&(t=e[n]),t}mapEntityToItem(e){if(e==null)throw"entity cannot be null";if(e instanceof is)return{value:e.value,viewValue:e.label||e.value,disabled:e.disabled,data:e};let t=!1,n=this.disabledProperty;return ie.isNullOrEmpty(n)||(t=e[n]||!1),{value:this.mapEntityToValue(e),viewValue:this.mapEntityToViewValue(e),disabled:t,data:e}}propertyChangedCallback(e,t,n,i){switch(super.propertyChangedCallback(e,t,n,i),e){case"datasource":case"textProperty":case"disabledProperty":case"valueProperty":cancelAnimationFrame(this._handle),this._handle=requestAnimationFrame(()=>{this.databind(),this.viewValue=this.getViewValue(this.value)});break;case"items":cancelAnimationFrame(this._handleItems),this._handleItems=requestAnimationFrame(()=>{this.datasource=this.items});break}}getViewValue(e){if(!ie.isNullOrEmpty(this.datasource))return this.datasource.filter(t=>this.isItemSelected(t)).map(t=>this.mapEntityToViewValue(t)).join(", ")}convertValueAttributeToProperty(e){return this.multipleChoice?e.split(",").map(t=>t.trim()):e}compareValuePropertyValues(e,t){return hN(e,t)}};l([Bt({emit:!1,converter:Er.Json})],Ht.prototype,"datasource",2),l([Bt({emit:!1,converter:Er.String})],Ht.prototype,"valueProperty",2),l([Bt({emit:!1,converter:Er.String})],Ht.prototype,"textProperty",2),l([Bt({emit:!1,converter:Er.String})],Ht.prototype,"disabledProperty",2),l([Bt({emit:!1,converter:Er.String})],Ht.prototype,"compareBy",2),l([Bt({converter:Er.Json})],Ht.prototype,"adaptedDatasource",2),l([vH(!0)],Ht.prototype,"databind",1);import{Components as bH,CustomElement as yH,Defaults as _H,P as ss,PCSS as zy,PropertyConverters as UE,Watch as zE}from"@pacem/pacem-core";var en=`<${ss}-char-count hide="{{ :host.readonly || !(:host.minlength > 0 || :host.maxlength > 0) }}" minlength="{{ :host.minlength }}" maxlength="{{ :host.maxlength }}" string="{{ :host.value }}"></${ss}-char-count>`,Kl=class extends bH.PacemElement{_isValid(r){let e=this._length(r);return!(this.minlength>0&&e<this.minlength||this.maxlength>0&&e>this.maxlength)}_length(r){return r&&r.length||0}};l([zE({converter:UE.Number})],Kl.prototype,"minlength",2),l([zE({converter:UE.Number})],Kl.prototype,"maxlength",2),l([zE({converter:UE.String})],Kl.prototype,"string",2),Kl=l([yH({tagName:ss+"-char-count",shadow:_H.USE_SHADOW_ROOT,template:`<${ss}-panel class="${zy}-char-count" css-class="{{ {'valid': :host._isValid(:host.string), 'invalid': !:host._isValid(:host.string) } }}">
|
|
204
|
+
<${ss}-span hide="{{ !(:host.minlength > 0) }}" class="${zy}-char-min" content="{{ :host.minlength }}"></${ss}-span>
|
|
205
|
+
<${ss}-span class="${zy}-char-curr" content="{{ :host._length(:host.string) || '0' }}"></${ss}-span>
|
|
206
|
+
<${ss}-span hide="{{ !(:host.maxlength > 0) }}" class="${zy}-char-max" content="{{ :host.maxlength }}"></${ss}-span>
|
|
207
|
+
</${ss}-panel>`})],Kl);var jE="execute",Gy="<p><br></p>",Fy=class extends xH{constructor(r){super("contenteditablechange",{html:r})}},Zs=class extends kh{constructor(){super(...arguments);this._containerPropChangeHandler=e=>{let t=e.detail;this.containerPropertyChangedCallback(t.propertyName,t.oldValue,t.currentValue,t.firstChange)}}execCommand(...e){let t=this;t.disabled||t.exec.apply(t,e).then(n=>{t.dispatchEvent(new Event(jE))},n=>{console.error(n)})}connectedCallback(){super.connectedCallback(),Js.addClass(this,FE+"-contenteditable-command")}viewActivatedCallback(){super.viewActivatedCallback();let e=this.container;Js.isNull(e)||(this.contentElement=e.contentElement,e.addEventListener(fN,this._containerPropChangeHandler,!1))}disconnectedCallback(){let e=this.container;Js.isNull(e)||e.removeEventListener(fN,this._containerPropChangeHandler,!1),super.disconnectedCallback()}containerPropertyChangedCallback(e,t,n,i){e==="range"&&(this.range=n)}};l([WE()],Zs.prototype,"range",2),l([WE()],Zs.prototype,"contentElement",2);function LH(a){return a instanceof Zs&&"pasteCallback"in a&&typeof a.pasteCallback=="function"}function gN(a){return a?.nodeType==Node.ELEMENT_NODE}var lo,oo=class extends ql{constructor(){super("rich text editor");$(this,lo);this._focusHandler=e=>{this._ensureInteractiveMarkup()};this._blurHandler=e=>{let t=this._container;for(let n of this.items)n.cleanUp(t);this._checkChangedHandler(e)};this._pasteHandler=e=>{e.preventDefault();let t=this.range,n=e.clipboardData.files;if(!Js.isNull(t)&&n.length===0){let s=e.clipboardData.getData("text/plain").replace(/</gi,"<").replace(/\n/gi,"<br />"),o=t.createContextualFragment(s);t.deleteContents(),t.insertNode(o),this._checkChangedHandler(e)}else for(let i=0;i<n.length;i++){let s=n.item(i);for(let o of this.items)LH(o)&&o.pasteCallback(s).then(c=>this._checkChangedHandler(e),c=>{})}};this._shortcutHandler=e=>{e.ctrlKey&&["C","V","X"].indexOf(e.key?.toUpperCase())===-1&&e.preventDefault()};this._inputHandler=e=>{this._fixRangeMarkup(),this._checkChangedHandler(e)};this._checkChangedHandler=e=>{let t=this._container,n=t.innerHTML;var i=n;(Js.isNullOrEmpty(n)||n==="<br>"||n===Gy)&&(t.innerHTML=Gy,i=""),i!=this.value&&(this.changeHandler(new Fy(i)),this.value!=x(this,lo).current&&this._updateHistory()),this._fireHistoryChange()};this._selectionChangeHandler=e=>{let t=document.getSelection();if(t&&t.anchorNode&&this._container.contains(t.anchorNode)){let n=t.getRangeAt(0);this.range=n.cloneRange()}else this.range=null}}get history(){return x(this,lo)}reset(){super.reset(),x(this,lo).reset(),this._fireHistoryChange()}_fireHistoryChange(){let e=x(this,lo);this.dispatchEvent(new MH({propertyName:"history",oldValue:e,currentValue:e}))}convertValueAttributeToProperty(e){return e}toggleReadonlyView(e){this._dashboard.hidden=e,e?this._container.removeAttribute("contenteditable"):(this._container.setAttribute("contenteditable","true"),document.execCommand("defaultParagraphSeparator",!1,"p"))}register(e){return super.register(e)?(e.addEventListener(jE,this._checkChangedHandler,!1),!0):!1}unregister(e){return super.unregister(e)?(e.removeEventListener(jE,this._checkChangedHandler,!1),!0):!1}get preventKeyboardSubmit(){return!0}get inputFields(){return[this._container]}get contentElement(){return this._container}onChange(e){return new Promise((t,n)=>{if(CH.isInstanceOf(e,Fy)){let i=this.value=e.detail.html;t(i),this._selectionChangeHandler(e)}else t(this.value)})}_fixRangeMarkup(){let e=this.range,t=i=>{i.childNodes.forEach(s=>t(s)),gN(i)&&i.tagName==="SPAN"?Element.prototype.replaceWith.apply(i,Array.from(i.childNodes)):i instanceof HTMLElement&&i.removeAttribute("style")},n=i=>{let s=i;gN(s)||(s=i.parentElement),t(s)};Js.isNull(e)||n(e.commonAncestorContainer)}_ensureInteractiveMarkup(){let e=this._container,t=e.childNodes,n=t.length;if(n==0||e.innerHTML===Gy)e.innerHTML=Gy;else{let i,s,o=c=>{s.setEndAfter(c);let d=document.createElement("p");s.surroundContents(d)};for(let c=0;c<n;c++)i=t.item(c),i instanceof Element?s&&(o(i.previousSibling),s=null):Js.isNull(s)&&(s=document.createRange(),s.setStartBefore(i));Js.isNull(s)||o(i)}}_updateHistory(){x(this,lo).push(this.value),this._fireHistoryChange()}acceptValue(e){!Js.isNull(this._container)&&e!=this._container.innerHTML&&(this._container.innerHTML=e)}viewActivatedCallback(){super.viewActivatedCallback();let e=this._container;A(this,lo,new SH(this.value)),e.addEventListener("blur",this._blurHandler,!1),e.addEventListener("keydown",this._shortcutHandler,!1),e.addEventListener("focus",this._focusHandler,!1),e.addEventListener("input",this._inputHandler,!1),e.addEventListener("paste",this._pasteHandler,!1),document.addEventListener("selectionchange",this._selectionChangeHandler,!1)}disconnectedCallback(){document.removeEventListener("selectionchange",this._selectionChangeHandler,!1);let e=this._container;Js.isNull(e)||(e.removeEventListener("keydown",this._shortcutHandler,!1),e.removeEventListener("blur",this._blurHandler,!1),e.removeEventListener("focus",this._focusHandler,!1),e.removeEventListener("input",this._inputHandler,!1),e.removeEventListener("paste",this._pasteHandler,!1)),super.disconnectedCallback()}getViewValue(e){return e}};lo=new WeakMap,l([mN("div[pacem]")],oo.prototype,"_container",2),l([mN("div[dashboard]")],oo.prototype,"_dashboard",2),l([WE()],oo.prototype,"range",2),l([EH(500)],oo.prototype,"_updateHistory",1),oo=l([wH({tagName:GE+"-contenteditable",shadow:kH.USE_SHADOW_ROOT,template:`<div class="${FE}-contenteditable ${FE}-viewfinder">
|
|
208
|
+
<div contenteditable="true" role="presenter" pacem></div>
|
|
209
|
+
</div>${en}
|
|
210
|
+
<div dashboard>
|
|
211
|
+
<${GE}-content></${GE}-content>
|
|
212
|
+
</div>`})],oo);var Zt=class extends Zs{cleanUp(r){}propertyChangedCallback(r,e,t,n){super.propertyChangedCallback(r,e,t,n),r==="range"&&(this.active=!vN.isNull(t))}getTooltip(r=this.altText,e=this.keyboardShortcut){let t=r;return vN.isNullOrEmpty(e)?t:`${t} (${e})`}};l([jy({converter:Wy.String})],Zt.prototype,"icon",2),l([jy({converter:Wy.String})],Zt.prototype,"keyboardShortcut",2),l([jy({converter:Wy.String})],Zt.prototype,"altText",2),l([jy({converter:Wy.Boolean})],Zt.prototype,"active",2);var $n=`<${Mh}-button disabled="{{ !:host.active }}" css-class="{{ {'text-primary': :host.isRelevant(:host.range)} }}" tooltip="{{ :host.getTooltip(:host.altText, :host.keyboardShortcut) }}" class="button" on-click=":host.execCommand()"><${Mh}-icon class="text-rootsize" icon="{{ :host.icon }}"></${Mh}-icon></${Mh}-button>
|
|
213
|
+
<${Mh}-shortcut disabled="{{ !:host.active }}" target="{{ :host.contentElement }}" combination="{{ :host.keyboardShortcut }}" on-execute=":host.execCommand()"></${Mh}-shortcut>`;import{Utils as uo,PCSS as bg}from"@pacem/pacem-core";import{P as NH,CustomElement as TH,Defaults as AH,Utils as bN,Watch as DH,PropertyConverters as RH}from"@pacem/pacem-core";var co=class extends Zt{exec(){return new Promise((r,e)=>{let t=this.container?.history;bN.isNull(t)||(this.command==="redo"?t.canRedo&&(t.redo(),r()):t.canUndo&&(t.undo(),r()),this.contentElement.innerHTML=t.current)})}isRelevant(r){return!1}propertyChangedCallback(r,e,t,n){super.propertyChangedCallback(r,e,t,n),r==="command"&&(this.icon=this.icon||t,this.altText=t,this.keyboardShortcut=this.keyboardShortcut||"Ctrl+"+(t==="redo"?"Y":"Z"))}containerPropertyChangedCallback(r,e,t,n){super.containerPropertyChangedCallback(r,e,t,n);let i=this.container,s=i.history;(r==="range"||r==="history")&&(this.active=!bN.isNull(i.range)&&(this.command==="redo"&&s?.canRedo||this.command!=="redo"&&s?.canUndo))}};l([DH({emit:!1,converter:RH.String,reflectBack:!0})],co.prototype,"command",2),co=l([TH({tagName:NH+"-contenteditable-historycommand",shadow:AH.USE_SHADOW_ROOT,template:$n})],co);import{P as OH,CustomElement as PH,Defaults as IH,Utils as Yy,Watch as $H,PropertyConverters as HH}from"@pacem/pacem-core";var Jl=class extends Zt{isRelevant(r){return!Yy.isNull(xe.findSurroundingNode(r,HTMLAnchorElement))}viewActivatedCallback(){super.viewActivatedCallback(),Yy.isNullOrEmpty(this.altText)&&(this.altText="insert link"),Yy.isNullOrEmpty(this.icon)&&(this.icon="insert_link"),Yy.isNullOrEmpty(this.keyboardShortcut)&&(this.keyboardShortcut="Ctrl+H")}exec(r,e=this.target){return new Promise((t,n)=>{var i=this.range,s=xe.findSurroundingNode(i,HTMLAnchorElement),o="http://",c=/<a.*href=\"([^\"]*)/;if(s&&c.test(s.outerHTML)&&(o=c.exec(s.outerHTML)[1]),r==="current")return o=="http://"?"":o;var d=r||r===void 0&&window.prompt("link (empty to unlink):",o);d?(document.execCommand("createLink",!1,d),s=xe.findSurroundingNode(i,HTMLAnchorElement),s&&s.setAttribute("target",e||"_blank")):document.execCommand("unlink"),t()})}};l([$H({emit:!1,converter:HH.String})],Jl.prototype,"target",2),Jl=l([PH({tagName:OH+"-contenteditable-linkcommand",shadow:IH.USE_SHADOW_ROOT,template:$n})],Jl);import{CustomElement as BH,Defaults as VH,P as Xy,PCSS as YE,Utils as as,ViewChild as yN}from"@pacem/pacem-core";function _N(a,r){return new Promise((e,t)=>{as.blobToDataURL(r).then(as.loadImage).then(n=>{let i=document.createElement("picture");i.setAttribute("contenteditable","false"),n.tabIndex=0,i.appendChild(n),a.deleteContents(),a.insertNode(i),e(i)})})}var vg,po=class extends Zt{constructor(){super(...arguments);$(this,vg);this._setBehaviorHandler=e=>{let t=e.target,n=t.parentElement;this.range=xe.select(n)};this._disposeBehaviorHandler=e=>{}}pasteCallback(e){return e.type.startsWith("image")?_N(this.range,e):Promise.reject()}cleanUp(e){e.querySelectorAll("picture[contenteditable=false]").forEach(t=>{let n=t.childNodes.length;for(let i=n-1;i>0;i--)t.childNodes.item(i).remove()}),e.querySelectorAll("div."+YE+"-rescale").forEach(t=>t.remove())}isRelevant(e){return!1}viewActivatedCallback(){super.viewActivatedCallback(),as.isNullOrEmpty(this.altText)&&(this.altText="insert image"),as.isNullOrEmpty(this.icon)&&(this.icon="insert_photo"),as.isNullOrEmpty(this.keyboardShortcut)&&(this.keyboardShortcut="Ctrl+Shift+I"),this._rescale.addEventListener("rescale",this._rescaleImg,!1)}disconnectedCallback(){as.isNull(this._rescale)||(this._rescale.removeEventListener("rescale",this._rescaleImg,!1),this._disposeContainer()),super.disconnectedCallback()}propertyChangedCallback(e,t,n,i){switch(super.propertyChangedCallback(e,t,n,i),e){case"disabled":as.isNull(this._rescale)||(this._rescale.disabled=n);break;case"contentElement":t&&this._disposeContainer(t),n&&this._initContainer(n);break;case"range":this._rangeChangeCallback(t,n);break}}exec(){return new Promise((e,t)=>{let n=this._file,i=this.range;n.onchange=s=>{let o=n.files[0];as.isNull(o)?e():_N(i,o).then(c=>{n.value="",e()})},n.click()})}_rescaleImg(e){e.preventDefault();let t=e.detail.element,n=e.detail.targetRect,i=t.firstElementChild;i.style.width=n.width+"px",i.style.height=n.height+"px"}_rangeChangeCallback(e,t){if(!as.isNull(e)&&!e.collapsed&&e.commonAncestorContainer instanceof Element&&e.commonAncestorContainer===e.startContainer&&e.commonAncestorContainer===e.endContainer&&e.startOffset===e.endOffset-1){let n=e.commonAncestorContainer.childNodes.item(e.startOffset);n instanceof HTMLPictureElement&&this._rescale.unregister(n)}if(!as.isNull(t)&&!t.collapsed&&t.commonAncestorContainer instanceof Element&&t.commonAncestorContainer===t.startContainer&&t.commonAncestorContainer===t.endContainer&&t.startOffset===t.endOffset-1){let n=t.commonAncestorContainer.childNodes.item(t.startOffset);n instanceof HTMLPictureElement&&this._rescale.register(n)}}_enhancePictureElement(e){e.firstElementChild&&(e.firstElementChild.addEventListener("focus",this._setBehaviorHandler,!1),e.firstElementChild.addEventListener("blur",this._disposeBehaviorHandler,!1))}_downgradePictureElement(e){e.firstElementChild&&(e.firstElementChild.removeEventListener("focus",this._setBehaviorHandler,!1),e.firstElementChild.removeEventListener("blur",this._disposeBehaviorHandler,!1))}_initContainer(e=this.contentElement){A(this,vg,new jd(e,(t,n)=>{t instanceof HTMLPictureElement&&(n?this._downgradePictureElement(t):this._enhancePictureElement(t))},"picture"))}_disposeContainer(e=this.contentElement){let t=x(this,vg);as.isNull(t)||t.dispose()}};vg=new WeakMap,l([yN("input[type=file]")],po.prototype,"_file",2),l([yN(Xy+"-rescale")],po.prototype,"_rescale",2),po=l([BH({tagName:Xy+"-contenteditable-imagecommand",shadow:VH.USE_SHADOW_ROOT,template:`<input type="file" accept="image/png, image/gif, image/jpeg, image/bmp, image/x-icon" class="${YE}-trasparent ${YE}-inert" pacem hidden>`+$n+`<${Xy}-rescale keep-proportions="true"></${Xy}-rescale>`})],po);import{CustomElement as UH,Defaults as zH,P as GH,PropertyConverters as xN,Utils as Sh,Watch as CN}from"@pacem/pacem-core";var XE=(p=>(p.Bold="bold",p.Italic="italic",p.Underline="underline",p.StrikeThrough="strikeThrough",p.OrderedList="insertOrderedList",p.UnorderedList="insertUnorderedList",p.JustifyLeft="justifyLeft",p.JustifyCenter="justifyCenter",p.JustifyRight="justifyRight",p.JustifyFull="justifyFull",p))(XE||{});function EN(a){let r=a?.toLowerCase();switch(r){case"bold":case"italic":return"format_"+r;case"underline":return"format_underlined";case"strikethrough":return"strikethrough_s";case"insertorderedlist":return"format_list_numbered";case"insertunorderedlist":return"format_list_bulleted";case"justifyleft":case"justifyright":case"justifycenter":return"format_align_"+r.substr(7);case"justifyfull":return"format_align_justify";default:return"help_outline"}}function wN(a,r){switch(a?.toLowerCase()){case"bold":return["b","strong"];case"italic":return["i","em"];case"underline":return["u"];case"strikethrough":return["strike","s","del"];case"insertorderedlist":return["ol"];case"insertunorderedlist":return["ul"];case"justifyleft":return[{style:{name:"text-align",value:"left"}}];case"justifyright":return[{style:{name:"text-align",value:"right"}}];case"justifycenter":return[{style:{name:"text-align",value:"center"}}];case"justifyfull":return[{style:{name:"text-align",value:"justify"}}];case"formatblock":return[r];default:return["none"]}}var bn=class extends Zt{_matchRelevance(r,e){let t=typeof e=="object"?xe.findSurroundingNode(r,n=>n instanceof HTMLElement&&(Sh.isNullOrEmpty(e.tagName)||n.tagName===e.tagName.toUpperCase())&&n.style[e.style.name]===e.style.value):xe.findSurroundingNode(r,e);return!Sh.isNull(t)}isRelevant(r){let e=wN(this.command,this.argument);for(let t of e)if(this._matchRelevance(r,t))return!0;return!1}propertyChangedCallback(r,e,t,n){super.propertyChangedCallback(r,e,t,n),r==="command"&&((Sh.isNullOrEmpty(this.icon)||this.icon===EN(e))&&(this.icon=EN(t)),(Sh.isNullOrEmpty(this.altText)||this.altText===e)&&(this.altText=t))}exec(){return new Promise((r,e)=>{let t=this.range,n=wN(this.command,this.argument)[0];if(!Sh.isNull(t)){let i=xe.testInertElementWrapping(t);if(i.result&&typeof n=="string"&&["b","i","strike","u"].indexOf(n)>=0){let s=xe.findSurroundingNode(t,n);if(!Sh.isNull(s)&&s.childNodes.length===1){let o=s.childNodes.item(0),c=i.element;s.parentElement.replaceChild(o,s),xe.select(c)}else{let o=document.createElement(n),c=i.element,d=t.extractContents();t.insertNode(o),o.append(d),xe.select(c)}}else document.execCommand(this.command,!1,this.argument)}r()})}};l([CN({converter:xN.String})],bn.prototype,"command",2),l([CN({emit:!1,converter:xN.String})],bn.prototype,"argument",2),bn=l([UH({tagName:GH+"-contenteditable-execcommand",shadow:zH.USE_SHADOW_ROOT,template:$n})],bn);function qE(a){return a instanceof HTMLDivElement&&a.contentEditable==="true"&&a.hasAttribute("pacem")&&a.hasAttribute("role")&&a.attributes.role.value==="presenter"}var jd=class{constructor(r,e,t="*[contenteditable=false]"){this.#t=e,this.#e=t,this.#n=new MutationObserver(n=>{let i=(s,o)=>{s.childNodes.forEach(c=>i(c,o)),e(s,o)};for(let s of n){let o=s.addedNodes,c=s.removedNodes;for(let d=0;d<o.length;d++){let p=o.item(d);i(p,!1)}for(let d=0;d<c.length;d++){let p=c.item(d);i(p,!0)}}}),this._initContainer(r)}_initContainer(r){r.querySelectorAll(this.#e).forEach(e=>this.#t(e)),this.#n.observe(r,{subtree:!0,childList:!0}),this.#r=r}_disposeContainer(r){let e=this.#n;uo.isNull(e)||e.disconnect(),r.querySelectorAll(this.#e).forEach(t=>this.#t(t,!0))}dispose(){this._disposeContainer(this.#r)}#e;#t;#r;#n},xe=class a{static getDefaultDashboard(){let r=new DocumentFragment,e=document.createElement("div");uo.addClass(e,bg+"-contenteditable-toolbar");let t=new co;t.command="undo",t.keyboardShortcut="Ctrl+Z";let n=new co;n.command="redo",n.keyboardShortcut="Ctrl+Y",e.append(t,n);let i=document.createElement("div");uo.addClass(i,bg+"-contenteditable-separator");let s=document.createElement("div");uo.addClass(s,bg+"-contenteditable-toolbar");let o=new bn;o.command="bold",o.keyboardShortcut="Ctrl+B";let c=new bn;c.command="italic",c.keyboardShortcut="Ctrl+I";let d=new bn;d.command="underline",d.keyboardShortcut="Ctrl+U";let p=new bn;p.command="strikeThrough",d.keyboardShortcut="Ctrl+K";let u=new bn;u.command="insertUnorderedList";let h=new bn;h.command="insertOrderedList";let m=new os;m.align="left";let f=new os;f.align="center";let g=new os;g.align="right";let v=new os;v.align="justify",s.append(o,c,d,p,u,h,m,f,g,v);let b=document.createElement("div");uo.addClass(b,bg+"-contenteditable-separator");let _=document.createElement("div");uo.addClass(_,bg+"-contenteditable-toolbar");let E=new Jl,C=new po;return _.append(E,C),r.append(e,i,s,b,_),r}static findSurroundingNode(r,e){for(var t=r instanceof Node?r:r.commonAncestorContainer;t&&!(typeof e=="string"&&t instanceof Element&&t.tagName===e.toUpperCase()||typeof e=="function"&&uo.isNull(e.prototype)&&e(t)||typeof e=="function"&&!uo.isNull(e.prototype)&&t instanceof e);){let n=t.parentNode;if(qE(n)){t=null;break}t=n}return t}static findSurroundingBlockElement(r){return this.findSurroundingNode(r,a.isBlockElement)}static findSurroundingSiblingBlockElements(r){let e=[];if(qE(r.startContainer)){if(!r.collapsed){let i=r.startContainer;for(let s=r.startOffset;s<=r.endOffset;s++){let o=i.children.item(s);this.isBlockElement(o)&&e.push(i.children.item(s))}}return e}if(r.startContainer===r.endContainer){let i=r.startContainer;for(;!a.isBlockElement(i)&&i.parentElement.contentEditable!="true";)i=i.parentElement;return i instanceof Element?[i]:i.parentElement.contentEditable==="true"?[]:[i.parentElement]}let t=r.commonAncestorContainer,n=!1;for(let i=0;i<t.childNodes.length;i++){let s=t.childNodes.item(i);if((!n&&s.contains(r.startContainer)||n)&&a.isBlockElement(s)&&(e.push(s),n=!0,s.contains(r.endContainer)))break}return n?e:t instanceof Element&&!qE(t)?[t]:[]}static findContainingRootElements(r){let e=r.cloneRange(),t=r.cloneRange();e.collapse(!0),t.collapse();let n=this.findSurroundingNode(e,s=>s.parentElement.contentEditable==="true"),i=[n];for(;!n.contains(t.startContainer);)i.push(n=n.nextElementSibling);return i}static isBlockElement(r){return r instanceof Element&&!getComputedStyle(r).display.startsWith("inline")}static select(r,e=!1){let t=document.createRange();e?(t.setStart(r,0),t.setEnd(r,r.childNodes.length)):(t.setStartBefore(r),t.setEndAfter(r));let n=document.getSelection();return n.removeAllRanges(),n.addRange(t),t}static copyAttributes(r,e){let t=e.attributes;for(let n=0;n<t.length;n++){let i=t.item(n);r.setAttribute(i.name,i.value)}}static testInertElementWrapping(r){if(!uo.isNull(r)){let t=r.startContainer,n=r.startOffset;var e;if(t===r.endContainer&&n==r.endOffset-1&&(e=t.childNodes.item(n))instanceof HTMLElement&&e.contentEditable==="false")return{result:!0,element:e}}return{result:!1}}};function kN(a){return"format_align_"+a}var os=class extends Zt{isRelevant(r){let e=xe.findSurroundingSiblingBlockElements(r);if(Zl.isNullOrEmpty(e))return!1;let t=e[0];return getComputedStyle(t).textAlign==this.align}propertyChangedCallback(r,e,t,n){super.propertyChangedCallback(r,e,t,n),r==="align"&&((Zl.isNullOrEmpty(this.icon)||this.icon===kN(e))&&(this.icon=kN(t)),(Zl.isNullOrEmpty(this.altText)||this.altText===e)&&(this.altText=t))}exec(){let r=xe.findSurroundingSiblingBlockElements(this.range),e;for(let t of r)xe.isBlockElement(t)&&t instanceof HTMLElement&&(Zl.isNull(e)&&(e=Zl.hasClass(t,"text-"+this.align)?"":this.align),t.style.textAlign="",Zl.removeClass(t,"text-left text-right text-center text-justify"),Zl.isEmpty(e)||Zl.addClass(t,"text-"+e));return Promise.resolve()}};l([XH({converter:YH.String})],os.prototype,"align",2),os=l([FH({tagName:jH+"-contenteditable-aligncommand",shadow:WH.USE_SHADOW_ROOT,template:$n})],os);import{P as Ql,CustomElement as qH,Defaults as KH,Utils as Lh,Watch as JH,PropertyConverters as ZH,ViewChild as MN,PCSS as QH}from"@pacem/pacem-core";function eB(a,r){let e=document.createElement("ins");return e.textContent=r,e.setAttribute("contenteditable","false"),e.tabIndex=0,a.deleteContents(),a.insertNode(e),e}function SN(a){return a instanceof HTMLModElement&&a.tagName==="INS"}function tB(a){let r=xe.testInertElementWrapping(a);if(r.result&&SN(r.element)){let e=r.element,t=e.textContent;return{result:!0,element:e,placeholder:t}}return{result:!1}}var Nh,qy,yg,ec=class extends Zs{constructor(){super(...arguments);$(this,Nh);$(this,qy);$(this,yg);this._focusHandler=e=>{let t=e.target;this.range=xe.select(t)}}cleanUp(e){e.querySelectorAll("ins[contenteditable=false]").forEach(t=>{Lh.removeClass(t,"placeholder-selected")})}exec(e){let t=eB(this.range,e);return xe.select(t).collapse(!1),Promise.resolve(t)}isRelevant(e){return x(this,Nh)?.result??!1}viewActivatedCallback(){super.viewActivatedCallback(),this._fillDropdown(),this._initContainer()}propertyChangedCallback(e,t,n,i){if(super.propertyChangedCallback(e,t,n,i),!i)switch(e){case"datasource":this._fillDropdown();break;case"contentElement":t&&this._disposeContainer(t),n&&this._initContainer(n);break;case"range":this._changeRelevancy();break}}disconnectedCallback(){this._disposeContainer(),super.disconnectedCallback()}_changeRelevancy(e=this.range){let t=x(this,Nh);Lh.isNull(t?.element)||Lh.removeClass(t.element,"placeholder-selected");let n=A(this,Nh,tB(e));Lh.isNull(n?.element)||Lh.addClass(n.element,"placeholder-selected"),n.result?this._dropdown.value=n.placeholder:(this._dropdown.popout(),this._dropdown.value=void 0)}_fillDropdown(e=this.datasource||[]){let t=A(this,qy,e.map(i=>typeof i=="string"?{placeholder:i,definition:i}:i)),n=this._dropdown;n.textProperty=n.valueProperty="placeholder",n.datasource=t}_initContainer(e=this.contentElement){A(this,yg,new jd(e,(t,n)=>{SN(t)&&(n?this._downgradePlaceholderElement(t):this._enhancePlaceholderElement(t))},"ins[contenteditable=false]"))}_disposeContainer(e=this.contentElement){let t=x(this,yg);Lh.isNull(t)||t.dispose()}_enhancePlaceholderElement(e){e.addEventListener("focus",this._focusHandler,!1)}_downgradePlaceholderElement(e){e.removeEventListener("focus",this._focusHandler,!1)}};Nh=new WeakMap,qy=new WeakMap,yg=new WeakMap,l([MN("template")],ec.prototype,"_itemtemplate",2),l([MN(Ql+"-suggest")],ec.prototype,"_dropdown",2),l([JH({emit:!1,converter:ZH.Json})],ec.prototype,"datasource",2),ec=l([qH({tagName:Ql+"-contenteditable-placeholder",shadow:KH.USE_SHADOW_ROOT,template:`<template>
|
|
214
|
+
<${Ql}-span text="{{ ^item.viewValue }}" class="text-tech"></${Ql}-span>
|
|
215
|
+
<${Ql}-markdown hide="{{ $pacem.isNullOrEmpty(^item.data.definition) || ^item.viewValue === ^item.data.definition }}" class="${QH}-margin margin-0 text-small" value="{{ ^item.data.definition }}"></${Ql}-markdown>
|
|
216
|
+
</template>
|
|
217
|
+
<${Ql}-suggest placeholder="Placeholder" class="pacem-button button" disabled="{{ $pacem.isNull(:host.range) }}"
|
|
218
|
+
on-change=":host.execCommand($this.value)"
|
|
219
|
+
css-class="{{ {'text-primary': :host.isRelevant(:host.range)} }}"
|
|
220
|
+
compare-by="placeholder" text-property="placeholder" itemtemplate="{{ ::_itemtemplate }}" prevent-focus="true" allow-typing="false"></${Ql}-suggest>`})],ec);import{P as rB,CustomElement as nB,Defaults as iB,Utils as Ky,Watch as sB,PropertyConverters as aB}from"@pacem/pacem-core";var Th=class extends Zt{isRelevant(r){return!Ky.isNull(xe.findSurroundingNode(r,this.tagname))}exec(){return new Promise((r,e)=>{let t=this.tagname;if(!Ky.isNullOrEmpty(t)){let n=this.range,i=xe.findSurroundingNode(n,t)||xe.findSurroundingNode(n.startContainer,t)||xe.findSurroundingNode(n.endContainer,t);if(Ky.isNull(i)){let s=xe.findSurroundingSiblingBlockElements(n);if(!Ky.isNullOrEmpty(s)){let o=document.createElement(t);if(s.length===1){let d=s[0];n.setStart(d,0),n.setEnd(d,d.childNodes.length);let p=n.extractContents();o.append(p),xe.copyAttributes(o,d),d.parentElement.insertBefore(o,d),d.remove()}else{n.setStartBefore(s[0]),n.setEndAfter(s[s.length-1]);let d=n.extractContents();o.append(d),n.insertNode(o)}xe.select(o,!0).collapse()}}else{n.setStart(i,0),n.setEnd(i,i.childNodes.length);let s=!1,o=i.childNodes;for(let c=0;c<o.length;c++){let d=o.item(c);if(!xe.isBlockElement(d)){s=!0;break}}if(s){let c=document.createElement("p");xe.copyAttributes(c,i),c.append(n.extractContents()),i.parentNode.replaceChild(c,i),xe.select(c,!0).collapse()}else i.parentNode.replaceChild(n.extractContents(),i),xe.select(n.endContainer,!0).collapse()}}r()})}};l([sB({converter:aB.String})],Th.prototype,"tagname",2),Th=l([nB({tagName:rB+"-contenteditable-wrapcommand",shadow:iB.USE_SHADOW_ROOT,template:$n})],Th);import{Components as KE,CustomElement as JE,CustomElementUtils as oB,CustomEventUtils as LN,Defaults as ZE,P as ve,PCSS as Qs,PropertyConverters as ls,stopPropagationHandler as NN,Utils as se,ViewChild as Jy,Watch as ea}from"@pacem/pacem-core";import{Components as TN}from"@pacem/pacem-ui";var lB={convert:(a,r)=>/\{.+\}/.test(a)?ls.Json.convert(a):ls.String.convert(a),convertBack:(a,r)=>typeof a=="string"?a:ls.Json.convertBack(a,r)};function cB(){let a="";for(let r=0;r<12;r++)a+=`<div class="calendar-month month-${r+1}"><${ve}-span class="month-button text-ellipsed" on-click=":host._setMonth(${r})" css-class="{{ { 'selected-month': :host._isSelectedMonth(${r}, :host.month, :host.viewYear), 'this-month': :host._isThisMonth(${r}, :host.viewYear) } }}" text="{{ :host._getMonthLabel(${r}) }}"></${ve}-span></div>`;return a}var Yd=class extends KE.PacemElement{propertyChangedCallback(r,e,t,n){super.propertyChangedCallback(r,e,t,n),r==="viewYear"&&(this.dispatchEvent(new CustomEvent("viewyearchange",{detail:new Date(t,0,1),bubbles:!1,cancelable:!1})),se.removeClass(this,"viewyear-next viewyear-previous"),requestAnimationFrame(()=>{se.addClass(this,e>t?"viewyear-previous":"viewyear-next")}))}_getMonthLabel(r){let e=new Date().getFullYear();return new Date(e,r,1).toLocaleString(se.lang(this),{month:"short"})}_isThisMonth(r,e=this.viewYear){return this._isSelectedMonth(r,new Date,e)}_isSelectedMonth(r,e=this.month,t=this.viewYear){let n=se.parseDate(e);if(!se.Dates.isDate(n))return!1;let i=t??new Date().getFullYear();return n.getMonth()===r&&n.getFullYear()===i}_setMonth(r){let e=this.viewYear,t=new Date(e,r,1);this.month=t,this.dispatchEvent(new CustomEvent("monthselect",{detail:t,bubbles:!1,cancelable:!1}))}};l([ea({converter:ls.Date})],Yd.prototype,"month",2),l([ea({converter:ls.Date})],Yd.prototype,"viewYear",2),Yd=l([JE({tagName:ve+"-calendar-month-picker",shadow:ZE.USE_SHADOW_ROOT,template:`<div class="${Qs}-month-picker">${cB()}</div>`})],Yd);var _g=class extends TN.UI.DateSelectEvent{constructor(){super(void 0)}},AN=12;function dB(){let a="";for(let r=0;r<AN;r++)a+=`<div class="calendar-year year-${r+1}"><${ve}-span class="year-button text-ellipsed" on-click=":host._setYear(${r})" css-class="{{ { 'selected-year': :host._isSelectedYear(${r}, :host.year, :host.viewYear), 'this-year': :host._isThisYear(${r}, :host.viewYear) } }}" text="{{ :host._getYearLabel(${r}, :host.viewYear) }}"></${ve}-span></div>`;return a}function Zy(a){let r=a%10;return a-r}var Xd=class extends KE.PacemElement{propertyChangedCallback(r,e,t,n){super.propertyChangedCallback(r,e,t,n),r==="viewYear"&&(this.dispatchEvent(new CustomEvent("viewyearchange",{detail:new Date(t,0,1),bubbles:!1,cancelable:!1})),se.removeClass(this,"viewyear-next viewyear-previous"),requestAnimationFrame(()=>{se.addClass(this,e>t?"viewyear-previous":"viewyear-next")}))}_getYearLabel(r,e=this.viewYear){return""+(Zy(e)+r)}_isThisYear(r,e=this.viewYear){return this._isSelectedYear(r,new Date,e)}_isSelectedYear(r,e=this.year,t=this.viewYear){let n=se.parseDate(e);if(!se.Dates.isDate(n))return!1;let i=Zy(t),s=i+r;return n.getFullYear()===s}_setYear(r){let e=this.viewYear,t=Zy(e),n=new Date(t+r,0,1);this.year=n,this.dispatchEvent(new CustomEvent("yearselect",{detail:n,bubbles:!1,cancelable:!1}))}};l([ea({converter:ls.Date})],Xd.prototype,"year",2),l([ea({converter:ls.Date})],Xd.prototype,"viewYear",2),Xd=l([JE({tagName:ve+"-calendar-year-picker",shadow:ZE.USE_SHADOW_ROOT,template:`<div class="${Qs}-year-picker">${dB()}</div>`})],Xd);function pB(){let a="";for(let r=0;r<7;r++)a+=`<${ve}-span class="calendar-heading day-${r+1} text-ellipsed" text="{{ :host._getHeaderLabel(:host._week[${r}]) }}"></${ve}-span>`;return`<${ve}-panel hide="{{ :host.viewmode !== 'calendar' }}" class="calendar-header">${a}</${ve}-panel>`}var Ah,tn=class extends ge{constructor(){super(...arguments);this.viewmode="calendar";$(this,Ah,!1);this._swipeHandler=e=>{switch(e.detail.direction){case"left":this._next(e);break;case"right":this._prev(e);break}};this._clearBtnHandler=e=>{e.preventDefault(),this._viewDate=new Date,this.changeHandler(new _g)};this._viewDateChangeHandler=e=>{this._onViewDateChange(e)};this._popCalendarHandler=e=>{if(x(this,Ah))return;this.viewmode="calendar";let t=se.parseDate(this.value);this._calendar.viewDate=this._monthPicker.month=this._yearPicker.year=se.Dates.isDate(t)?t:this._calendar.viewDate;let n=se.offset(this._input),i=this._dropdown;i.style.top=n.top+n.height+"px",i.style.left=n.left+"px",i.hidden=!1,requestAnimationFrame(()=>{se.addClass(i,"dropdown-in")})};this._hideCalendarHandler=e=>{let t=e.composedPath()||[];t.indexOf(this._input)>=0||t.indexOf(this._dropdown)>=0||this._hideCalendar()}}propertyChangedCallback(e,t,n,i){switch(super.propertyChangedCallback(e,t,n,i),e){case"viewmode":case"_viewDate":this._onViewDateChange(this._viewDate);break}}viewActivatedCallback(){super.viewActivatedCallback();let e=this._dropdown=this._proxy.dom[0],t=this._calendar=e.querySelector(ve+"-calendar"),n=this._monthPicker=e.querySelector(ve+"-calendar-month-picker"),i=this._yearPicker=e.querySelector(ve+"-calendar-year-picker");this._monthLabel=e.querySelector(".calendar-month"),this._yearLabel=e.querySelector(".calendar-year"),this._rangeLabel=e.querySelector(".calendar-year-range");let s=this._calendar.now=new Date,o=se.Dates.parse(this.value),d=se.Dates.isDate(o)?o:s;t.dayLabelFormatter=m=>se.parseDate(m).toLocaleString(se.lang(this),{day:"numeric"}),n.addEventListener("viewyearchange",this._viewDateChangeHandler,!1),i.addEventListener("viewyearchange",this._viewDateChangeHandler,!1),t.addEventListener("viewdatechange",this._viewDateChangeHandler,!1),t.viewDate=d,t.date=o;let p=this._input;p.addEventListener("focus",this._popCalendarHandler,!1),p.addEventListener("mousedown",this._popCalendarHandler,!1),e.addEventListener("mousedown",NN,!1),window.document.body.addEventListener("mousedown",this._hideCalendarHandler,!0),this._clearButton.addEventListener("mousedown",this._clearBtnHandler,!1);let u=new KE.PacemSwipeElement;t.behaviors.push(u),n.behaviors.push(u),i.behaviors.push(u),u.addEventListener("swipe",this._swipeHandler,!1);let h=oB.findAncestorShell(this);this._swiper=h.appendChild(u)}disconnectedCallback(){let e=this._input;se.isNull(e)||(this._clearButton.removeEventListener("mousedown",this._clearBtnHandler,!1),e.removeEventListener("focus",this._popCalendarHandler,!1),e.removeEventListener("mousedown",this._popCalendarHandler,!1),this._dropdown.removeEventListener("mousedown",NN,!1),window.document.body.removeEventListener("mousedown",this._hideCalendarHandler,!0),this._calendar.removeEventListener("viewdatechange",this._viewDateChangeHandler,!1),this._monthPicker.removeEventListener("viewyearchange",this._viewDateChangeHandler,!1),this._yearPicker.removeEventListener("viewyearchange",this._viewDateChangeHandler,!1));let t=this._swiper;if(!se.isNull(t)){let n=this._calendar,i=this._monthPicker,s=this._yearPicker;for(let o of[n,i,s]){let c=o.behaviors,d=c.indexOf(t);d>=0&&o.behaviors.splice(d,1)}t.removeEventListener("swipe",this._swipeHandler,!1),t.remove(),this._swiper=null}super.disconnectedCallback()}_getHeaderLabel(e,t=this.viewmode){let n=se.parseDate(e);return se.Dates.isDate(n)?n.toLocaleString(se.lang(this),{weekday:"narrow"}):"..."}_prev(e){let t=-1;switch(this.viewmode){case"month":t=-12;break;case"year":t=-120;break}this._jumpMonths(t)}_next(e){let t=1;switch(this.viewmode){case"month":t=12;break;case"year":t=120;break}this._jumpMonths(t)}_jumpMonths(e){let t=se.parseDate(this._viewDate);this._viewDate=se.Dates.addMonths(t,e)}_setMonth(e){this._viewDate=e.detail,this.viewmode="calendar"}_setYear(e){this._viewDate=e.detail,this.viewmode="month"}_onViewDateChange(e){if(se.isNullOrEmpty(e))return;let t=se.parseDate(this._viewDate);if(se.Dates.isDate(t)&&!se.isNull(this._monthLabel))switch(this.viewmode){case"month":this._yearLabel.text=t.toLocaleString(se.lang(this),{year:"numeric"});break;case"year":let n=Zy(t.getFullYear());this._rangeLabel.text=`${n} - ${n+AN-1}`;break;default:this._monthLabel.text=t.toLocaleString(se.lang(this),{month:"long",year:"numeric"});break}}_hideCalendar(){se.removeClass(this._dropdown,"dropdown-in"),se.addAnimationEndCallback(this._dropdown,e=>{this._dropdown.hidden=!0,se.removeClass(this._dropdown,"dropdown-select")},250)}get inputFields(){return[this._input]}toggleReadonlyView(e){this.isReady&&(this._input.readOnly=!0,this._input.hidden=e,this._span.hide=!e)}onChange(e){return new Promise((t,n)=>{LN.isInstanceOf(e,TN.UI.DateSelectEvent)?(se.addClass(this._dropdown,"dropdown-select"),LN.isInstanceOf(e,_g)&&A(this,Ah,!0),this.focus(),A(this,Ah,!1),this._hideCalendar(),t(this.value=e.detail)):t(this.value)})}acceptValue(e){this._input.value=this.viewValue;let t=this._calendar;if(!se.isNull(t)){let n=se.parseDate(e);se.Dates.isDate(n)?t.viewDate=t.date=n:t.date=void 0}}getViewValue(e){let t=se.Dates.parse(e);return se.Dates.isDate(t)?se.core.date(t,this.format||"short",se.lang(this)):""}compareValuePropertyValues(e,t){let n=se.parseDate(e),i=se.parseDate(t);return se.isNullOrEmpty(n)&&se.isNullOrEmpty(i)?!0:se.isNullOrEmpty(n)||se.isNullOrEmpty(i)?!1:n.valueOf()==i.valueOf()}convertValueAttributeToProperty(e){return ls.Datetime.convert(e)}};Ah=new WeakMap,l([Jy("input[type=text]")],tn.prototype,"_input",2),l([Jy(`.${Qs}-readonly`)],tn.prototype,"_span",2),l([Jy(`${ve}-button[clear]`)],tn.prototype,"_clearButton",2),l([Jy(ve+"-shell-proxy")],tn.prototype,"_proxy",2),l([ea({emit:!1,converter:lB})],tn.prototype,"format",2),l([ea({converter:ls.Eval})],tn.prototype,"disabledRanges",2),l([ea({converter:ls.String})],tn.prototype,"weekStart",2),l([ea({converter:ls.String})],tn.prototype,"viewmode",2),l([ea()],tn.prototype,"_week",2),l([ea()],tn.prototype,"_viewDate",2),tn=l([JE({tagName:ve+"-calendar-picker",shadow:ZE.USE_SHADOW_ROOT,template:`<div class="${Qs}-calendar-picker">
|
|
221
|
+
<input type="text" class="${Qs}-input" /><${ve}-span text="{{ :host.viewValue }}" class="${Qs}-readonly"></${ve}-span>
|
|
222
|
+
<${ve}-button class="button-flat ${Qs}-anim anim-pop anim-sudden anim-quick pos-absolute absolute-right absolute-top display-block ${Qs}-margin margin-0"
|
|
223
|
+
tab-order="-1"
|
|
224
|
+
hide="{{ :host.readonly || :host.required || !Pacem.Utils.Dates.isDate(Pacem.Utils.Dates.parse(:host.value)) }}"
|
|
225
|
+
icon-glyph="close"
|
|
226
|
+
clear></${ve}-button>
|
|
227
|
+
</div>
|
|
228
|
+
<${ve}-shell-proxy>
|
|
229
|
+
<div class="${Qs}-calendar-picker-dropdown" pacem hidden>
|
|
230
|
+
<${ve}-collapse collapse="false">
|
|
231
|
+
<div class="dropdown-grid">
|
|
232
|
+
<div class="calendar-title">
|
|
233
|
+
<${ve}-span class="calendar-month calendar-zoom" on-click=":host.viewmode = 'month'" hide="{{ :host.viewmode !== 'calendar' }}"></${ve}-span>
|
|
234
|
+
<${ve}-span class="calendar-year calendar-zoom" on-click=":host.viewmode = 'year'" hide="{{ :host.viewmode !== 'month' }}"></${ve}-span>
|
|
235
|
+
<${ve}-span class="calendar-year-range" hide="{{ :host.viewmode !== 'year' }}"></${ve}-span>
|
|
236
|
+
</div>
|
|
237
|
+
<div class="calendar-month-nav ${Qs}-buttonset buttons">
|
|
238
|
+
<div class="buttonset-left">
|
|
239
|
+
<${ve}-button class="button button-size size-auto" on-click=":host._prev($event)" icon-glyph="chevron_left"></${ve}-button>
|
|
240
|
+
<${ve}-button class="button button-size size-auto" on-click=":host._next($event)" icon-glyph="chevron_right"></${ve}-button>
|
|
241
|
+
</div>
|
|
242
|
+
</div>
|
|
243
|
+
${pB()}
|
|
244
|
+
<${ve}-calendar hide="{{ :host.viewmode !== 'calendar' }}" week="{{ :host._week, twoway }}" view-date="{{ :host._viewDate, twoway }}" week-start="{{ :host.weekStart }}" disabled-ranges="{{ :host.disabledRanges }}" on-dateselect="{{ :host.changeHandler($event) }}"></${ve}-calendar>
|
|
245
|
+
<${ve}-calendar-month-picker hide="{{ :host.viewmode !== 'month' }}" on-monthselect=":host._setMonth($event)" month="{{ :host.value || Date.now() }}" view-year="{{ :host._viewDate && :host._viewDate.getFullYear() }}"></${ve}-calendar-month-picker>
|
|
246
|
+
<${ve}-calendar-year-picker hide="{{ :host.viewmode !== 'year' }}" on-yearselect=":host._setYear($event)" year="{{ :host.value || Date.now() }}" view-year="{{ :host._viewDate && :host._viewDate.getFullYear() }}"></${ve}-calendar-year-picker>
|
|
247
|
+
</div>
|
|
248
|
+
<${ve}-collapse>
|
|
249
|
+
</div>
|
|
250
|
+
</${ve}-shell-proxy>`})],tn);import{CustomElement as uB,Defaults as hB,P as xg,PCSS as ho,PropertyConverters as DN,Utils as Dh,ViewChild as QE,Watch as Qy}from"@pacem/pacem-core";var ew={convert:a=>a==="true"?!0:a==="false"?!1:a,convertBack:a=>a.toString()},gi=class extends ge{constructor(){super("checkbox");this.caption="";this._key="_"+Dh.uniqueCode()}convertValueAttributeToProperty(e){ew.convert(e)===this.trueValue?this.trueValue:this.falseValue}toggleReadonlyView(e){this.span.hidden=!e,this._checkbox.hidden=this._label.hidden=e}get inputFields(){return[this._checkbox]}onChange(e){this.selected=this._checkbox.checked;let t=this.value=this.selected?this.trueValue:this.falseValue;return Dh.fromResult(t)}viewActivatedCallback(){super.viewActivatedCallback(),this._checkbox.id=this._label.htmlFor=this._key,this._synchronizeUi(),this.value==this.trueValue?this.selected=!0:this.value==this.falseValue&&(this.selected=!1)}propertyChangedCallback(e,t,n,i){if(super.propertyChangedCallback(e,t,n,i),!!this.isReady)switch(e){case"caption":this._label.hidden=Dh.isNullOrEmpty(n);break;case"name":this._checkbox.name=n;break;case"selected":this._synchronizeUi();break}}_synchronizeUi(e=this.selected){(this._checkbox.checked=e)?(this.value=this.trueValue,Dh.addClass(this,ho+"-selected"),this.aria.attributes.set("checked","true")):(this.value=this.falseValue,Dh.removeClass(this,ho+"-selected"),this.aria.attributes.set("checked","false"))}acceptValue(e){this.selected=e==this.trueValue}getViewValue(e){return Dh.isNull(e)?"":this.caption}};l([QE("input[type=checkbox]")],gi.prototype,"_checkbox",2),l([QE("label")],gi.prototype,"_label",2),l([QE(`.${ho}-readonly`)],gi.prototype,"span",2),l([Qy({converter:DN.String})],gi.prototype,"caption",2),l([Qy({emit:!1,converter:ew})],gi.prototype,"trueValue",2),l([Qy({emit:!1,converter:ew})],gi.prototype,"falseValue",2),l([Qy({converter:DN.Boolean})],gi.prototype,"selected",2),gi=l([uB({tagName:xg+"-checkbox",template:`<${xg}-span class="${ho}-readonly ${ho}-checkbox" text="{{ :host.caption }}"></${xg}-span>
|
|
251
|
+
<input type="checkbox" class="${ho}-input" /><label class="${ho}-label ${ho}-checkbox ${ho}-viewfinder" pacem><${xg}-span content="{{ :host.caption }}"></${xg}-span></label>`,shadow:hB.USE_SHADOW_ROOT})],gi);import{CustomElement as mB,Defaults as fB,P as Hn,PCSS as e_,PropertyChangeEventName as gB,Utils as RN,ViewChild as tw}from"@pacem/pacem-core";var tc=class extends Ht{constructor(){super(!0);this._selectedUiItems=[];this.key="_"+RN.uniqueCode()}acceptValue(e){}get inputFields(){return[]}propertyChangedCallback(e,t,n,i){super.propertyChangedCallback(e,t,n,i),e==="disabled"&&(this._disable.model=n)}viewActivatedCallback(){super.viewActivatedCallback(),this._disable.model=this.disabled}toggleReadonlyView(e){this._span.hidden=!e,this._repeater.hidden=e}_selectionChanged(e,t,n){if(e.detail.propertyName==="selected"){let i,s=this._selectedUiItems;e.detail.currentValue===!0?s.push(this.datasource[t]):(i=s.indexOf(this.datasource[t]))!==-1&&s.splice(i,1)}}onChange(e){let t=this.value=this._selectedUiItems.map(n=>this.mapEntityToValue(n));return RN.fromResult(t)}};l([tw(`span.${e_}-readonly`)],tc.prototype,"_span",2),l([tw(Hn+"-repeater")],tc.prototype,"_repeater",2),l([tw(Hn+"-data")],tc.prototype,"_disable",2),tc=l([mB({tagName:Hn+"-checkbox-list",template:`<${Hn}-repeater datasource="{{ :host.adaptedDatasource }}">
|
|
252
|
+
<ol class="${e_}-checkbox-list ${e_}-viewfinder" pacem>
|
|
253
|
+
<template>
|
|
254
|
+
<li><${Hn}-checkbox disabled="{{ ::_disable.model || ^item.disabled }}" name="{{ :host.key, once }}" autobind="off" caption="{{ ^item.viewValue }}" true-value="{{ ^item.value }}" selected="{{ :host.isDataSourceItemSelected(^item, :host.value) }}"
|
|
255
|
+
on-focus=":host.focusHandler($event)" on-blur=":host.focusHandler($event)"
|
|
256
|
+
on-${gB}=":host._selectionChanged($event, ^index, ^item)" on-change=":host.changeHandler($event)"></${Hn}-checkbox></li>
|
|
257
|
+
</template>
|
|
258
|
+
</ol>
|
|
259
|
+
</${Hn}-repeater><span class="${e_}-readonly"><${Hn}-text text="{{ :host.viewValue }}"></${Hn}-text></span><${Hn}-data></${Hn}-data><${Hn}-content></${Hn}-content>`,shadow:fB.USE_SHADOW_ROOT})],tc);import{CustomElement as ON,Defaults as vB,P as St,PCSS as ta,PacemEventTarget as bB,PropertyChangeEventName as yB,Components as _B,PropertyConverters as rc,Utils as _n,ViewChild as rw,Watch as mo,UI as t_,avoidHandler as xB}from"@pacem/pacem-core";var nc=class extends bB{propertyChangedCallback(r,e,t,n){if(super.propertyChangedCallback(r,e,t,n),!n){let i=this.property,s=this.watch,o=!_n.isNullOrEmpty(i),c=!_n.isNull(this.model);(r==="watch"||r==="property"||r==="model"&&o&&c&&_n.isArray(t)&&t.some(d=>!(i in d)||d[i]!==s)||r==="model"&&o&&c&&!_n.isArray(t)&&(!(i in t)||t[i]!==s))&&this._synchronize()}}viewActivatedCallback(){super.viewActivatedCallback(),this._synchronize()}_synchronize(){let r=this.model,e=this.property,t=this.watch;if(!(_n.isNullOrEmpty(r)||_n.isNullOrEmpty(e)))if(_n.isArray(r)){for(let n of r)n[e]=t;this.model=r.slice(0)}else r[e]=t,this.model=_n.extend({},r)}};l([mo({emit:!0})],nc.prototype,"model",2),l([mo({emit:!1,converter:rc.String,reflectBack:!0})],nc.prototype,"property",2),l([mo({emit:!1})],nc.prototype,"watch",2),nc=l([ON({tagName:St+"-childform-propagator"})],nc);var yn=class extends ge{constructor(){super(...arguments);this._model=[];this._subForms=[]}get inputFields(){return[]}toggleReadonlyView(e){}onChange(e){return new Promise((t,n)=>{var i=this._modelToEntity();t(this.value=i)})}acceptValue(e){this._entityToModel(e)}getViewValue(e){return""}convertValueAttributeToProperty(e){return rc.Json.convert(e,this)}propertyChangedCallback(e,t,n,i){super.propertyChangedCallback(e,t,n,i),e==="mode"&&this._entityToModel()}_dragStart(e){var t=e.detail;let n=_n.offset(t.element),i=t.floater;i.style.width=n.width+"px",i.style.height=n.height+"px"}_dragEnd(e){this.mode==="array"&&this._triggerChange()}reset(){super.reset(),this._subForms.forEach(e=>{e.setPristine()})}_itemCreate(e){let t=e.detail.index,n=this._subForms;e.detail.dom[0].childNodes.forEach(i=>{i instanceof Element&&i.localName===St+"-form"&&n.splice(t,n.length-t,i)})}_itemChange(e,t){t.detail.propertyName==="entity"&&_n.Json.stringify(this._model[e])!==_n.Json.stringify(t.detail.currentValue)&&(this._model.splice(e,1,t.detail.currentValue),this._triggerChange())}_deleteAt(e){xB(e.srcEvent);let t=this._model;this.mode==="array"?t.splice(e.detail,1):t.splice(0,t.length),this._triggerChange()}_addItem(e){let t=this.mode,n=this._model;t==="array"?n.push({}):n.splice(0,n.length,{}),this._triggerChange()}_triggerChange(){this.changeHandler(new Event("change"))}_entityToModel(e=this.value){if(this.mode==="array"){let t=e||[];_n.isArray(t)&&this._model.cloneFrom(t)}else{let n=this._model,i=n.length;(i!==1||n[0]!==e)&&(_n.isNull(e)?n.splice(0,i):n.splice(0,i,e))}}_modelToEntity(e=this._model){return this.mode==="array"?_n.clone(e):e&&e.length&&e[0]||null}};l([mo({emit:!1,converter:rc.String})],yn.prototype,"fetchCredentials",2),l([mo({emit:!1,converter:rc.Json})],yn.prototype,"fetchHeaders",2),l([rw("."+ta+"-childform")],yn.prototype,"_container",2),l([rw(St+"-drag-drop")],yn.prototype,"_dragger",2),l([rw("."+ta+"-childform-item-floater")],yn.prototype,"_floater",2),l([mo({converter:rc.String})],yn.prototype,"mode",2),l([mo({converter:rc.Boolean})],yn.prototype,"lockItems",2),l([mo({converter:rc.Json})],yn.prototype,"metadata",2),l([mo({converter:rc.Json})],yn.prototype,"_model",2),yn=l([ON({tagName:St+"-childform",shadow:vB.USE_SHADOW_ROOT,template:`<${St}-repeater datasource="{{ :host._model }}" on-itemdelete=":host._deleteAt($event)" on-${_B.RepeaterItemCreateEventName}=":host._itemCreate($event)">
|
|
260
|
+
<div class="${ta}-childform">
|
|
261
|
+
<template>
|
|
262
|
+
<${St}-panel class="${ta}-childform-item" behaviors="{{ [::_dragger] }}">
|
|
263
|
+
<${St}-panel class="childform-item-handle ${ta}-margin margin-right-1" hide="{{ :host.lockItems || :host.readonly || :host.mode !== 'array' || !(:host._model && :host._model.length > 1) }}"><i class="${ta}-icon drag-handle">drag_handle</i></${St}-panel>
|
|
264
|
+
<${St}-panel class="childform-item-index text-small"><${St}-span hide="{{ !:host.readonly || :host.mode !== 'array' }}" class="${ta}-margin margin-right-1" text="{{ ^index+1 }}"></${St}-span></${St}-panel>
|
|
265
|
+
<${St}-form entity="{{ ^item }}" fetch-headers="{{ :host.fetchHeaders }}" fetch-credentials="{{ :host.fetchCredentials }}" on-${yB}=":host._itemChange(^index, $event)" readonly="{{ :host.readonly }}" metadata="{{ :host.metadata }}" autogenerate="true" logger="{{ :host.logger }}"></${St}-form>
|
|
266
|
+
<${St}-button tab-order="-1" class="flat circular circle-small clear ${ta}-margin margin-left-1" hide="{{ :host.lockItems || :host.readonly }}" command-name="delete" command-argument="{{ ^index }}"></${St}-button>
|
|
267
|
+
</${St}-panel>
|
|
268
|
+
</template>
|
|
269
|
+
</div>
|
|
270
|
+
<${St}-button tab-order="-1" class="flat circular circle-small add" hide="{{ :host.lockItems || :host.readonly || !(:host.mode === 'array' || $pacem.isNullOrEmpty(:host._model)) }}" on-click=":host._addItem($event)"></${St}-button>
|
|
271
|
+
</${St}-repeater>
|
|
272
|
+
<div class="${ta}-childform-item-floater ${ta}-panel panel-border">
|
|
273
|
+
<div class="corner top-left"></div><div class="corner top-right"></div><div class="corner bottom-left"></div><div class="corner bottom-right"></div>
|
|
274
|
+
</div>
|
|
275
|
+
<${St}-drag-drop floater="{{ ::_floater }}" disabled="{{ :host.lockItems }}"
|
|
276
|
+
on-${t_.DragDropEventType.Start}=":host._dragStart($event)"
|
|
277
|
+
on-${t_.DragDropEventType.End}=":host._dragEnd($event)"
|
|
278
|
+
drop-behavior="${t_.DropBehavior.InsertChild}" mode="${t_.DragDataMode.Alias}" handle-selector=".drag-handle" drop-targets="{{ [::_container] }}"></${St}-drag-drop>`})],yn);import{Logging as CB,PropertyConverters as ic,Debounce as EB,Utils as wr,P as Re,PCSS as ur,CustomElement as wB,Watch as Bn,Defaults as kB,ViewChild as qd}from"@pacem/pacem-core";var MB={convert:(a,r)=>/\{.+\}/.test(a)?ic.Json.convert(a):ic.String.convert(a),convertBack:(a,r)=>typeof a=="string"?a:ic.Json.convertBack(a,r)},nt=class extends ge{constructor(){super();this.precision="day";this._months=[];this._dates=[];this._a24=[];this._a60=[];this._years=[];this.hours="00";this.minutes="00";this.seconds="00"}get inputFields(){return[this._yearel,this._monthel,this._dateel,this._hourel,this._minel,this._secel]}toggleReadonlyView(e){this._allFields.hidden=e}convertValueAttributeToProperty(e){return ic.Datetime.convert(e)}connectedCallback(){super.connectedCallback();let e=new Date,t=this.year=e.getFullYear();this.min=new Date(t-100,0,1),this.max=new Date(t+10,11,31),this.month=e.getMonth();let n=[],i=[],s=[],o=wr.leftPad;for(let c=0;c<12;c++){let d=new Date(t,c,1),p=d.toLocaleString(wr.lang(this),{month:"short"});n.push({value:c,date:d,label:p})}this._months=n;for(let c=0;c<24;c++)i.push(o(c,2,"0"));this._a24=i;for(let c=0;c<60;c++)s.push(o(c,2,"0"));this._a60=s}propertyChangedCallback(e,t,n,i){switch(super.propertyChangedCallback(e,t,n,i),e){case"dateValue":this.log(CB.LogLevel.Log,`dateValue changed from ${t} to ${n}`),this._disassembleDate(n);break;case"min":case"max":!wr.isNullOrEmpty(this.min)&&!wr.isNullOrEmpty(this.max)&&this._setupYears();break;case"year":case"month":this._buildupDates();break;case"date":case"hours":case"minutes":case"seconds":this._buildup();break}}acceptValue(e){this.dateValue=wr.parseDate(e)}_disassembleDate(e){if(!e){this.date=void 0;return}typeof e=="string"&&(e=wr.parseDate(e));let t=n=>wr.leftPad(n,2,"0");this.year=e.getFullYear(),this.month=e.getMonth(),this.date=e.getDate(),this.hours=t(e.getHours()),this.minutes=t(e.getMinutes()),this.seconds=t(e.getSeconds())}_setupYears(){let e=[],t=wr.parseDate(this.min),n=wr.parseDate(this.max);for(let i=t.getFullYear();i<=n.getFullYear();i++)e.push(i);this._years=e}onChange(e){return new Promise((t,n)=>{t(this.value=this._computeValue())})}_buildupDates(e){e&&e.stopPropagation();let t=this,n={weekday:"short",day:"numeric"},i=o=>{try{let c=+t.month;return new Date(+t.year,+t.month,o).getMonth()==c}catch{return!1}};var s=[];if(!wr.isNullOrEmpty(t.year)&&!wr.isNullOrEmpty(t.month)){let o=1;do{let c=new Date(+t.year,+t.month,o),d=c.toLocaleString(wr.lang(this),n);s.push({value:o,date:c,label:d,disabled:c<this.min||c>this.max})}while(i(++o))}this._dates=s,i(+this.date)?this._buildup():this.date=""}_computeValue(){let e=this;if(wr.isNullOrEmpty(e.year)||wr.isNullOrEmpty(e.month)||wr.isNullOrEmpty(e.date))return null;try{let t=new Date(+e.year,+e.month,+e.date);return t.setHours(+e.hours),t.setMinutes(+e.minutes),t.setSeconds(+e.seconds),t.setMilliseconds(0),Number.isNaN(t.valueOf())?null:t}catch{return null}}_buildup(e){e&&e.stopPropagation(),this.dateValue=this._computeValue()}getViewValue(e){let t=e;return t?wr.core.date(t,this.format||(this.precision!="day"?"full":"short"),wr.lang(this)):""}};l([qd("."+ur+"-datetime-picker-year > "+Re+"-select")],nt.prototype,"_yearel",2),l([qd("."+ur+"-datetime-picker-month > "+Re+"-select")],nt.prototype,"_monthel",2),l([qd("."+ur+"-datetime-picker-date > "+Re+"-select")],nt.prototype,"_dateel",2),l([qd("."+ur+"-datetime-picker-hours > "+Re+"-select")],nt.prototype,"_hourel",2),l([qd("."+ur+"-datetime-picker-minutes > "+Re+"-select")],nt.prototype,"_minel",2),l([qd("."+ur+"-datetime-picker-seconds > "+Re+"-select")],nt.prototype,"_secel",2),l([qd(`div.${ur}-datetime-picker-fields`)],nt.prototype,"_allFields",2),l([Bn({converter:ic.Datetime})],nt.prototype,"dateValue",2),l([Bn({converter:ic.Datetime})],nt.prototype,"min",2),l([Bn({converter:ic.Datetime})],nt.prototype,"max",2),l([Bn({converter:ic.String})],nt.prototype,"precision",2),l([Bn({emit:!1,converter:MB})],nt.prototype,"format",2),l([Bn()],nt.prototype,"_dates",2),l([Bn()],nt.prototype,"_years",2),l([Bn()],nt.prototype,"year",2),l([Bn()],nt.prototype,"month",2),l([Bn()],nt.prototype,"date",2),l([Bn()],nt.prototype,"hours",2),l([Bn()],nt.prototype,"minutes",2),l([Bn()],nt.prototype,"seconds",2),l([EB(10)],nt.prototype,"_buildup",1),nt=l([wB({tagName:Re+"-datetime-picker",shadow:kB.USE_SHADOW_ROOT,template:`<div class="${ur}-datetime-picker">
|
|
279
|
+
<div class="${ur}-datetime-picker-fields ${ur}-viewfinder">
|
|
280
|
+
|
|
281
|
+
<div class="${ur}-datetime-picker-year">
|
|
282
|
+
<${Re}-select value="{{ :host.year, twoway }}" placeholder="..." datasource="{{ :host._years }}">
|
|
283
|
+
</${Re}-select></div>
|
|
284
|
+
|
|
285
|
+
<div class="${ur}-datetime-picker-month">
|
|
286
|
+
<${Re}-select value="{{ :host.month, twoway }}" placeholder="..." value-property="value" text-property="label" datasource="{{ :host._months }}">
|
|
287
|
+
</${Re}-select></div>
|
|
288
|
+
|
|
289
|
+
<div class="${ur}-datetime-picker-date">
|
|
290
|
+
<${Re}-select value="{{ :host.date, twoway }}" placeholder="..." value-property="value" text-property="label" datasource="{{ :host._dates }}">
|
|
291
|
+
</${Re}-select></div>
|
|
292
|
+
|
|
293
|
+
<${Re}-panel class="${ur}-datetime-picker-hours" hide="{{ :host.precision === 'day' }}">
|
|
294
|
+
<${Re}-select value="{{ :host.hours, twoway }}" datasource="{{ :host._a24 }}">
|
|
295
|
+
</${Re}-select></${Re}-panel>
|
|
296
|
+
|
|
297
|
+
<${Re}-panel class="${ur}-datetime-picker-minutes" hide="{{ :host.precision === 'day' }}">
|
|
298
|
+
<${Re}-select value="{{ :host.minutes, twoway }}" datasource="{{ :host._a60 }}">
|
|
299
|
+
</${Re}-select></${Re}-panel>
|
|
300
|
+
|
|
301
|
+
<${Re}-panel class="${ur}-datetime-picker-seconds" hide="{{ :host.precision !== 'second' }}">
|
|
302
|
+
<${Re}-select value="{{ :host.seconds, twoway }}" datasource="{{ :host._a60 }}">
|
|
303
|
+
</${Re}-select></${Re}-panel>
|
|
304
|
+
|
|
305
|
+
</div>
|
|
306
|
+
<${Re}-panel class="${ur}-datetime-picker-preview" hide="{{ Pacem.Utils.isNullOrEmpty(:host.dateValue) || :host.precision === 'day' || :host.readonly }}">
|
|
307
|
+
<dl>
|
|
308
|
+
<dt>local:</dt><dd><${Re}-text text="{{ :host.viewValue }}"></${Re}-text></dd>
|
|
309
|
+
<dt>iso:</dt><dd><${Re}-text text="{{ (:host.dateValue && :host.dateValue.toISOString()) || '' }}"></${Re}-text></dd>
|
|
310
|
+
</dl>
|
|
311
|
+
</${Re}-panel>
|
|
312
|
+
<${Re}-span class="${ur}-readonly" css-class="{{ { 'date': :host.precision === 'day', 'datetime': :host.precision !== 'day' } }}" content="{{ :host.viewValue }}" hide="{{ !:host.readonly }}"></${Re}-span>
|
|
313
|
+
</div>`})],nt);import{Logging as PN,PropertyConverters as r_,Net as TB,Utils as Y,P as de,PCSS as ct,CustomElement as AB,Watch as Eg,PropertyChangeEvent as IN,PropertyChangeEventName as nw,ViewChild as wg,CustomElementUtils as n_,JsonFunctionConversion as DB}from"@pacem/pacem-core";import{Components as kg}from"@pacem/pacem-ui";import{Watch as hr,P as Un,PCSS as SB,CustomElement as oc,ViewChild as LB,Utils as Ye,PropertyConverters as kr,Defaults as lc,DeferPromise as NB}from"@pacem/pacem-core";var $r=class extends ns{constructor(){super()}viewActivatedCallback(){super.viewActivatedCallback(),Ye.addClass(this,SB+"-validator")}propertyChangedCallback(r,e,t,n){super.propertyChangedCallback(r,e,t,n);let i=this.form;switch(r){case"watch":e&&i&&i.unregisterValidator(t,this),i&&i.registerValidator(t,this);break;case"invalid":break;case"form":let s=this.watch;Ye.isNullOrEmpty(s)||(e?.unregisterValidator(s,this),t?.registerValidator(s,this));break;case"disabled":this.triggerFormFieldValidation();break}}#e;triggerFormFieldValidation(){let r=this.form,e=this.watch;!Ye.isNull(r)&&!Ye.isNullOrEmpty(e)&&(cancelAnimationFrame(this.#e),this.#e=requestAnimationFrame(()=>{r.validate(e)}))}validate(r){return this.disabled?Ye.fromResult(!0):this.evaluate(r)}};l([hr({converter:kr.Boolean})],$r.prototype,"invalid",2),l([hr({converter:kr.String})],$r.prototype,"errorMessage",2),l([hr({emit:!1,reflectBack:!0,converter:kr.String})],$r.prototype,"watch",2);var _o=`<${Un}-span part="error-message" hide="{{ !:host.invalid }}" text="{{ :host.errorMessage }}"></${Un}-span>`;function ac(a){return Ye.isNullOrEmpty(a)}var Kd=class extends $r{evaluate(r){let e=!ac(r);return Ye.fromResult(e)}};Kd=l([oc({tagName:Un+"-required-validator",template:_o,shadow:lc.USE_SHADOW_ROOT})],Kd);var yo=class extends $r{propertyChangedCallback(r,e,t,n){super.propertyChangedCallback(r,e,t,n),!n&&r==="pattern"&&this.triggerFormFieldValidation()}evaluate(r){let e=!0,t=this.pattern;return ac(r)||(e=new RegExp(t).test(r)),Ye.fromResult(e)}};l([hr({emit:!1,converter:kr.String})],yo.prototype,"pattern",2),yo=l([oc({tagName:Un+"-regex-validator",template:_o,shadow:lc.USE_SHADOW_ROOT})],yo);var fo=class extends $r{propertyChangedCallback(r,e,t,n){super.propertyChangedCallback(r,e,t,n),!n&&(r==="min"||r==="max")&&this.triggerFormFieldValidation()}evaluate(r){let e=!0;return ac(r)||(this.min>=0&&(e=e&&(r||"").toString().length>=this.min),this.max>=0&&(e=e&&(r||"").toString().length<=this.max)),Ye.fromResult(e)}};l([hr({emit:!1,converter:kr.Number})],fo.prototype,"min",2),l([hr({emit:!1,converter:kr.Number})],fo.prototype,"max",2),fo=l([oc({tagName:Un+"-length-validator",template:_o,shadow:lc.USE_SHADOW_ROOT})],fo);var go=class extends $r{propertyChangedCallback(r,e,t,n){super.propertyChangedCallback(r,e,t,n),!n&&(r==="min"||r==="max")&&this.triggerFormFieldValidation()}evaluate(r){let e=!0;if(!ac(r)){let t=r;r instanceof Date||typeof r!="number"&&(t=Ye.parseDate(r))instanceof Date&&isFinite(t.valueOf())?(this.min!=null&&(e=e&&t.valueOf()>=Ye.parseDate(this.min).valueOf()),this.max!=null&&(e=e&&t.valueOf()<=Ye.parseDate(this.max).valueOf())):(this.min!=null&&(e=e&&r>=this.min),this.max!=null&&(e=e&&r<=this.max))}return Ye.fromResult(e)}};l([hr({emit:!1,converter:kr.Number})],go.prototype,"min",2),l([hr({emit:!1,converter:kr.Number})],go.prototype,"max",2),go=l([oc({tagName:Un+"-range-validator",template:_o,shadow:lc.USE_SHADOW_ROOT})],go);var vo=class extends $r{propertyChangedCallback(r,e,t,n){super.propertyChangedCallback(r,e,t,n),!n&&(r==="operator"||r==="to")&&this.triggerFormFieldValidation()}_prepareValuesForComparison(r,e){return Ye.Dates.isDate(r)||Ye.Dates.isDate(e)?[Ye.parseDate(r),Ye.parseDate(e)]:[r,e]}evaluate(r){let e=!0,t=this.to;if(!ac(r)&&!ac(t)){let n=this._prepareValuesForComparison(r,t);switch(r=n[0],t=n[1],this.operator){case"lessOrEqual":e=r<=t;break;case"less":e=r<t;break;case"greaterOrEqual":e=r>=t;break;case"greater":e=r>t;break;case"notEqual":e=r!==t;break;default:e=r===t;break}}return Ye.fromResult(e)}};l([hr({emit:!1,converter:kr.String})],vo.prototype,"operator",2),l([hr({emit:!1,reflectBack:!0})],vo.prototype,"to",2),vo=l([oc({tagName:Un+"-compare-validator",template:_o,shadow:lc.USE_SHADOW_ROOT})],vo);var bo=class extends $r{propertyChangedCallback(r,e,t,n){super.propertyChangedCallback(r,e,t,n),!n&&(r==="pattern"||r==="maxSize")&&this.triggerFormFieldValidation()}evaluate(r){let e=!0,t=this.pattern,n=this.maxSize;if(!ac(r)){if(!Ye.isNullOrEmpty(t)){let i=typeof r=="string"?r:r.name;e=new RegExp(t,"i").test(i)}!Ye.isNull(n)&&typeof r=="object"&&r.size>0&&(e=e&&r.size<=n)}return Ye.fromResult(e)}};l([hr({emit:!1,converter:kr.String})],bo.prototype,"pattern",2),l([hr({emit:!1,converter:kr.String})],bo.prototype,"maxSize",2),bo=l([oc({tagName:Un+"-binary-validator",template:_o,shadow:lc.USE_SHADOW_ROOT})],bo);var Cg,Vn=class extends $r{constructor(){super(...arguments);$(this,Cg);this._deferredToken=null}_evaluateResult(){let t=this._fetcher.result;switch(t){case"true":return!0;case"false":return!1;default:try{let n=JSON.parse(t);return Ye.getApiResult(n)||!1}catch{return!1}}}_fetch(e){let t=this._deferredToken,n=this._fetcher;var i=this.parameters||{};i[this.watch]=e;let s={parameters:i,url:this.url,as:"text",method:this.method},o=Ye.jsonSortStringify(s),c=x(this,Cg),d=!1;if(Ye.isNullOrEmpty(c)||(d=o===c),d){let p=this._evaluateResult();t.resolve(p)}else Ye.extend(n,s),clearTimeout(this._debouncer),this._debouncer=setTimeout(()=>{n.fetch().then(p=>{let u=this._evaluateResult();t.resolve(u),A(this,Cg,o)},p=>{t.resolve(!1)})},1e3);return t.promise}evaluate(e){return Ye.isNullOrEmpty(e)?Ye.fromResult(!0):(this._deferredToken=this._deferredToken=NB.defer(),this._fetch(e).then(t=>(this._deferredToken=null,t),t=>(this._deferredToken=null,!1)))}propertyChangedCallback(e,t,n,i){if(super.propertyChangedCallback(e,t,n,i),!i)switch(e){case"parameters":case"url":case"method":case"fetchCredentials":case"fetchHeaders":this.triggerFormFieldValidation();break}}};Cg=new WeakMap,l([hr({emit:!1,converter:kr.Json})],Vn.prototype,"parameters",2),l([hr({emit:!1,converter:kr.Json})],Vn.prototype,"fetchCredentials",2),l([hr({emit:!1,converter:kr.Json})],Vn.prototype,"fetchHeaders",2),l([hr({emit:!1,converter:kr.String})],Vn.prototype,"url",2),l([hr({emit:!1,converter:kr.String})],Vn.prototype,"method",2),l([LB(Un+"-fetch")],Vn.prototype,"_fetcher",2),Vn=l([oc({tagName:Un+"-async-validator",template:_o+`<${Un}-fetch autofetch="false" throttle="true" credentials="{{ :host.fetchCredentials }}" headers="{{ :host.fetchHeaders }}"></${Un}-fetch>`,shadow:lc.USE_SHADOW_ROOT})],Vn);var sc=class extends $r{propertyChangedCallback(r,e,t,n){super.propertyChangedCallback(r,e,t,n),!n&&r==="isValid"&&this.triggerFormFieldValidation()}evaluate(r){let e=!0;return ac(r)||(e=!!this.isValid),Ye.fromResult(e)}};l([hr({emit:!1,converter:kr.Boolean})],sc.prototype,"isValid",2),sc=l([oc({tagName:Un+"-custom-validator",template:_o,shadow:lc.USE_SHADOW_ROOT})],sc);function RB(a){return"form"+a}function iw(a){return new RegExp(a).source}function OB(a){return"errorMessage"in a}function PB(a){return"attributes"in a&&typeof a.attributes=="function"}var rn=class extends ns{constructor(e=new kg.UI.MarkdownService){super();this._md=e;this._entityPropertyChangeHandler=e=>{this.dispatchEvent(new IN({propertyName:"entity",currentValue:this.entity}))};this._labelClickHandler=e=>{document.getElementById(this._label.htmlFor).focus()};this._key="_"+Y.uniqueCode()}get key(){return this._key}get fetcher(){return this._fetcher}get field(){return this._field}viewActivatedCallback(){super.viewActivatedCallback(),this._buildUpForm(),this._buildUpFetcher()}propertyChangedCallback(e,t,n,i){switch(super.propertyChangedCallback(e,t,n,i),e){case"readonly":this._ensureBalloon();break;case"metadata":this._ensureBalloon(),this._buildUpCss(),this._buildUpLabel(),this._buildUpField();break;case"entity":t instanceof HTMLElement&&t.removeEventListener(nw,this._entityPropertyChangeHandler,!1),n instanceof HTMLElement&&n.addEventListener(nw,this._entityPropertyChangeHandler,!1);break}}disconnectedCallback(){this.entity instanceof HTMLElement&&this.entity.removeEventListener(nw,this._entityPropertyChangeHandler,!1),Y.isNull(this._label)||this._label.removeEventListener("click",this._labelClickHandler,!1),Y.isNull(this._balloon)||this._balloon.remove(),super.disconnectedCallback()}_normalizeTooltip(){let e=this.metadata&&this.metadata.extra&&this.metadata.extra.tooltip||!1;return typeof e=="object"?e:{type:e}}_ensureBalloon(){var e,t;let n=this.readonly||(t=this._normalizeTooltip()).type===!1||Y.isNullOrEmpty(e=this.metadata&&this.metadata.display&&this.metadata.display.description);if(Y.isNull(this._balloon)&&!n){let o=document.createElement(de+"-balloon");o.options={behavior:kg.UI.BalloonBehavior.Tooltip,trigger:t.trigger||kg.UI.BalloonTrigger.Hover,position:t.position||kg.UI.BalloonPosition.Top,hoverDelay:200,hoverTimeout:50,align:t.align||kg.UI.BalloonAlignment.Auto},Y.addClass(o,ct+"-field-tooltip");var i=n_.findAncestorShell(this);i.appendChild(this._balloon=o)}let s=this._balloon;if(!Y.isNull(s)&&(s.target=this._label,!(s.disabled=n))){let o=e||"";switch(t.type){case"md":case"markdown":s.innerHTML=this._md.toHtml(o);break;case"html":s.innerHTML=o;break;default:s.innerText=o;break}}}_buildUpCss(){let e=this.metadata?.display;if(!Y.isNull(e)){if(typeof e.cssClass=="function"){let{cssClassAttr:t}=e.cssClass(this,"$this","$this.entity");this.setAttribute("css-class",t)}else this.cssClass=e.cssClass;if(typeof e.css=="function"){let{cssAttr:t}=e.css(this,"$this","$this.entity");this.setAttribute("css",t)}else this.css=e.css}}_buildUpLabel(){let e=this._label,t=e.firstElementChild,n=this.metadata;e.htmlFor=this._key,Y.addClass(e,ct+"-label");let i=this.metadata.validators;if(i&&i.find(s=>s.type==="required")?Y.addClass(e,ct+"-required"):Y.removeClass(e,ct+"-required"),!Y.isNull(this._balloon)&&!this._balloon.disabled?Y.addClass(e,ct+"-tooltip"):Y.removeClass(e,ct+"-tooltip"),typeof n.display?.name=="function"){let{contentAttr:s}=n.display.name(this,":host",":host.entity","::_form");t.setAttribute("content",s)}else t.removeAttribute("content"),t.content=n.display&&n.display.name||n.prop;e.setAttribute("id","label"+this._key),e.addEventListener("click",this._labelClickHandler,!1)}_isValueNullOrEmpty(e=this.entity,t=this.metadata){if(Y.isNull(t))return!0;let n=t.prop.split("."),i=e;for(let s=0;s<n.length;s++){let o=n[s];if(Y.isNullOrEmpty(i&&i[o]))return!0;i=i[o]}return!1}_handleValueChange(e){if(e.detail.propertyName==="value"){let t=e.detail.currentValue,n=this.metadata.prop;if(this.entity instanceof HTMLElement){let i=n_.camelToKebab(n);Y.isNullOrEmpty(t)?this.entity.removeAttribute(i):this.entity.setAttribute(i,t.toString())}else this.entity[n]=t}}_adjustDependencyValue(e){return Y.Dates.isDate(e)?Y.Dates.parse(e).toISOString():e}_broadcastFetchResult(e){let t=this;this.dispatchEvent(new CustomEvent("fetch",{detail:e,bubbles:!0,cancelable:!1}))}_buildUpFetcher(){var e=this._fetcher;e.setAttribute("id","fetch"+this._key),e.setAttribute("on-fetchresult",":host._broadcastFetchResult($event.detail)")}_buildUpForm(){var e=this._form;e.setAttribute("id",RB(this._key)),e.setAttribute("sudden-validation","{{ ::form.suddenValidation }}")}_buildUpField(){this._field&&this._field.remove(),this._fetcher.removeAttribute("parameters"),this._fetcher.result=this._fetcher.url=null;for(var e=this._validators.children.length-1;e>=0;e--)this._validators.children[e].remove();var t=this.metadata;let n=de+"-input-text",i=de+(t.display&&t.display.ui==="slider"?"-slider":"-input-number"),s={id:this._key,name:t.prop,readonly:"{{ :host.readonly || :host.metadata.isReadOnly || ::_form.readonly }}",value:`{{ :host.entity.${t.prop}, twoway }}`,placeholder:`${t.display&&t.display.watermark||""}`};t.extra?.autofocus==!0&&(s["on-load"]="requestAnimationFrame(() => $this.focus())");let o=t.extra||{},c={},d="false",p="",u="",h="",m=[];if(!Y.isNullOrEmpty(o.dependsOn))if(typeof o.dependsOn=="function"){let I=o.dependsOn(this,":host",":host.entity","$this.entity"),O=I.hideAttr;if(Y.isNullOrEmpty(O)||this.setAttribute("hide",O),Y.isNullOrEmpty(I.disabledAttr)||(d=I.disabledAttr,n_.isBindingAttribute(d)&&(u=n_.extractBindingAttributeExpression(d))),!Y.isNullOrEmpty(I.parameterAttrs)){let D=I.parameterAttrs,P=[];for(let N in D){let H=D[N];P.push(`${N}: ${H}`),m.push({prop:H})}h=P.join(", ")}}else{m=o.dependsOn;let I={empty:[],notEqual:{}},O={empty:[],notEqual:{}},D=[],P=[];for(var f of m){let H=":host.entity."+f.prop,V="$this.entity."+f.prop;if(Y.isNullOrEmpty(f.value)){if(!f.optional){let B=R=>"$pacem.isNullOrEmpty("+R+")";I.empty.push(B(H)),f.hide&&O.empty.push(B(V))}}else{let B=R=>R+" !== "+JSON.stringify(f.value);(I.notEqual[H]=I.notEqual[H]||[]).push(B(H)),f.hide&&(O.notEqual[V]=O.notEqual[V]||[]).push(B(V))}P.push(H),D.push(`${f.alias||f.prop}: :host._adjustDependencyValue(${H})`),f.optional||(p+=`!$pacem.isNullOrEmpty(${H}) && `)}h=D.join(", ");let N=H=>{let V="false",B="false";if(!Y.isNullOrEmpty(H.notEqual)){let R=[];for(let U in H.notEqual)R.push("("+H.notEqual[U].join(" && ")+")");V="("+R.join(" || ")+")"}return Y.isNullOrEmpty(H.empty)||(B="("+H.empty.join(" || ")+")"),V+" || "+B};u=N(I),d=`{{ ${u} }}`,this.setAttribute("hide",`{{ ${N(O)} }}`)}let g="fn",v=this[g]=this[g]||{},b=(I=[])=>{let O=(m||[]).map(P=>":host.entity."+P.prop).join(", "),D="fn"+Y.uniqueCode();switch(typeof I){case"function":v[D]=I;break;default:if(Y.isArray(I))v[D]=()=>I;else throw"Unsupported source format.";break}return`{{ :host.${g}.${D}(${O}) }}`},_=new DocumentFragment,E;if(typeof t.type=="function"){var C=t.type(this,":host",":host.entity");if(C.tagName.indexOf("-")===-1)this.log(PN.LogLevel.Error,`${n} is not an allowed form-field`);else{let I=function(O,D){if(!Y.isNullOrEmpty(D))for(let P of D){if(P.tagName.indexOf("-")===-1){this.log(PN.LogLevel.Error,`${P.tagName} is not an allowed child element for form-field ${n}`);continue}let N=document.createElement(P.tagName);if(!Y.isNullOrEmpty(P.attrs))for(let H in P.attrs){let V=P.attrs[H];N.setAttribute(H,V)}Y.isNullOrEmpty(P.children)||I(N,P.children),O.appendChild(N)}};n=C.tagName,Y.extend(s,C.attrs||{}),I(_,C.children)}}else switch(E=t.display&&t.display.ui){case"contentEditable":console.warn("`contentEditable` ui hint is deprecated. Lean on `dataType` equal to 'HTML' instead."),n=de+"-contenteditable",_.append(xe.getDefaultDashboard());break;case"snapshot":n=de+"-snapshot",o.width>0&&(s.width=""+o.width),o.height>0&&(s.height=""+o.height),o.quality>=0&&(s.quality=""+o.quality);break;case"chars":case"digits":case"otp":n=de+"-input-chars",o.charCount>0&&(s.charCount=""+o.charCount),Y.isNullOrEmpty(o.inputTransform)||(s["input-transform"]=o.inputTransform);break;case"oneToMany":case"dropdown":case"radioList":case"checkboxList":case"manyToMany":E==="oneToMany"||E==="dropdown"?(n=de+"-select",o.preventWheel!==!1&&(s["on-wheel"]="$event.preventDefault()")):(delete s.placeholder,n=de+(E==="radioList"?"-radio-list":"-checkbox-list")),Y.isNullOrEmpty(o.textProperty)||(s["text-property"]=o.textProperty),Y.isNullOrEmpty(o.disabledProperty)||(s["disabled-property"]=o.disabledProperty),Y.isNullOrEmpty(o.valueProperty)||(t.isComplexType?s["compare-by"]=o.valueProperty:s["value-property"]=o.valueProperty),Y.isNullOrEmpty(o.source)?(this._fetcher.id=`fetch${this._key}`,this._fetcher.url=o.sourceUrl,this._fetcher.method=o.verb,c.parameters=`{{ { ${h} } }}`,c.disabled=d,s.datasource=`{{ ${p}Utils.getApiResult(#fetch${this._key}.result) || null }}`):s.datasource=b(o.source);break;case"suggest":case"tags":case"autocomplete":let I=t.display.ui==="tags";n=de+(I?"-tags":"-suggest"),this._fetcher.id=`fetch${this._key}`,Y.isNullOrEmpty(o.textProperty)||(s["text-property"]=o.textProperty);let O=`#${this._key}.value`;if(Y.isNullOrEmpty(o.valueProperty)||(s["compare-by"]=o.valueProperty,I?O=`(${O} && ${O}.${o.valueProperty}) || ''`:t.isComplexType?O+=` && ${O}.${o.valueProperty}`:s["value-property"]=o.valueProperty),Y.isNullOrEmpty(o.sourceUrl)?s.datasource=b(o.source):(c.url=`${o.sourceUrl}`,this._fetcher.method=o.verb,Y.isNullOrEmpty(o.dependsOn)?c.parameters=`{{ {q: #${this._key}.hint || '', ${o.valueProperty||"value"}: ${O} || '' } }}`:(c.parameters=`{{ { ${h}, q: #${this._key}.hint || '', ${o.valueProperty||"value"}: ${O} || '' } }}`,c.disabled=d),s.datasource=`{{ ${p}Utils.getApiResult(#fetch${this._key}.result) || null }}`),I)s["allow-new"]=(t.extra.allowNew===!0).toString(),s["allow-duplicates"]=(t.extra.allowDuplicates===!0).toString();else{if(Y.isNullOrEmpty(o.disabledProperty)||(s["disabled-property"]=o.disabledProperty),!Y.isNullOrEmpty(o.itemtemplate)){let N=o.itemtemplate;N instanceof HTMLElement?(s.itemtemplate="{{ #"+(N.id=N.id||this._key+"_itemtmpl")+" }}",N.isConnected||this.append(N)):s.itemtemplate=N}if(!Y.isNullOrEmpty(o.filterFields)){let N=o.filterFields;s["filter-fields"]=Y.isArray(N)?N.join(" "):N}Y.isNullOrEmpty(o.maxSuggestions)||(s["max-suggestions"]=o.maxSuggestions.toString())}break;case"calendar":n=de+"-calendar-picker";let D=t.display?.format??t.extra?.format;Y.isNullOrEmpty(D)||(s.format="{{ "+JSON.stringify(D)+" }}"),Y.isNullOrEmpty(o.disabledRanges)||(s["disabled-ranges"]="{{ "+JSON.stringify(o.disabledRanges)+" }}");break;case"dictionary":n=de+"-namevalue-list",s.dictionary="true";break;case"switcher":if((t.type||"").toLowerCase()==="boolean")s.class="checkbox-switch";else break;default:let P=(t.dataType||t.type||"").toLowerCase();switch(P){case"upload":n=de+"-upload";let N=t.extra||{};s.url=N.uploadUrl,s.parallelism=""+N.parallelism,s["chunk-size"]=""+N.chunkSize,s["max-image-width"]=""+N.maxImageWidth,s["max-image-height"]=""+N.maxImageHeight,s["select-mode"]=N.mode??"file";break;case"html":n=de+"-contenteditable",_.append(xe.getDefaultDashboard());break;case"enumeration":n=de+"-radio-list",s.class=ct+"-radio-list",s["value-property"]="value",s["text-property"]="caption",s.datasource="{{ "+JSON.stringify(t.extra.enum)+" }}",delete s.placeholder;break;case"password":n=de+"-input-password";break;case"emailaddress":n=de+"-input-email";break;case"color":n=de+"-input-color";break;case"time":case"date":case"datetime":n=de+"-datetime-picker",delete s.placeholder,P==="datetime"&&(s.precision="minute");let H=t.display?.format??t.extra?.format;Y.isNullOrEmpty(H)||(s.format="{{ "+JSON.stringify(H)+" }}"),Y.isNullOrEmpty(o.disabledRanges)||(s["disabled-ranges"]="{{ "+JSON.stringify(o.disabledRanges)+" }}");break;case"url":n=de+"-input-url";break;case"phonenumber":n=de+"-input-tel";break;case"multilinetext":n=de+"-textarea";break;case"markdown":n=de+"-textarea-markdown";break;case"latlng":n=de+"-latlng",!Y.isNullOrEmpty(t.extra)&&typeof t.extra=="object"&&!Y.isArray(t.extra)&&(s.options=JSON.stringify(t.extra));break;case"percent":case"percentage":case"currency":let V=P==="currency"?{style:"currency",currency:"EUR"}:{style:"percent",maximumFractionDigits:2},B=t.display?.format??V;s.format=JSON.stringify(B);default:switch((t.type||"").toLowerCase()){case"boolean":n=de+"-checkbox",s["true-value"]="{{ true }}",s["false-value"]="{{ false }}",s.caption=s.placeholder,delete s.placeholder;break;case"byte":s.min="0",s.max="255";case"int16":case"int32":case"int64":case"short":case"integer":case"int":case"long":s.step=""+(t.extra?.step??"1"),n=i;let R=t.display?.format;Y.isNullOrEmpty(R)||(s.format=JSON.stringify(R)),o.preventWheel!==!1&&n===de+"-input-number"&&(s["on-wheel"]="$event.preventDefault()");break;case"double":case"decimal":case"float":case"single":case"number":n=i,s.step=""+(t.extra?.step??"any");let U=t.display?.format;Y.isNullOrEmpty(U)||(s.format=JSON.stringify(U)),o.preventWheel!==!1&&n===de+"-input-number"&&(s["on-wheel"]="$event.preventDefault()");break;default:if((t.type==="array"||t.type==="object")&&!Y.isNullOrEmpty(t.props)){if(n=de+"-childform",delete s.placeholder,s.metadata=Y.Json.stringify(t.props,{functions:DB.Reference}),s.mode=t.type,s["lock-items"]=""+(t.extra&&t.extra.lockItems||!1),s.logger="{{ :host.logger }}",!Y.isNullOrEmpty(m)){var k="";for(let z of m)k+=`<${de}-childform-propagator model="${s.value}" watch="{{ :host.entity.${z.prop} }}" property="${z.alias||z.prop}"></${de}-childform-propagator>
|
|
314
|
+
`;this._container.innerHTML=k}s["fetch-credentials"]="{{ :host.fetchCredentials }}",s["fetch-headers"]="{{ :host.fetchHeaders }}"}break}break}break}if(!Y.isNullOrEmpty(t.commands)){Y.addClass(this._container,ct+"-fieldgroup");let I=this._container.appendChild(document.createElement("div")),O=this._container.appendChild(document.createElement("div"));Y.addClass(I,`fieldgroup-prepend ${ct}-buttonset buttons`),Y.addClass(O,`fieldgroup-append ${ct}-buttonset buttons`);let D=u||"false";t.commands.forEach(P=>{let N=document.createElement(de+"-button");N.setAttribute("icon-glyph",P.icon),N.setAttribute("command-name",P.name),P.dependsOnValue?(N.setAttribute("disabled",`{{ (${D}) || !::_form.valid || $pacem.isNullOrEmpty(:host.entity.${t.prop}) }}`),N.setAttribute("command-argument",`{{ :host.entity.${t.prop} }}`)):N.setAttribute("disabled",d),N.setAttribute("tooltip",P.tooltip),Y.isNullOrEmpty(P.cssClass)||Y.addClass(N,P.cssClass.join(" ")),(P.prepend?I:O).appendChild(N)})}Y.isNullOrEmpty(t.validators)||t.validators.forEach(I=>{var O,D={},P={};switch(OB(I)&&(D=I.params||{},P["error-message"]=I.errorMessage),PB(I)&&Y.extend(P,I.attributes(this,":host",":host.entity")),I.type){case"required":s.required="true",O=new Kd;break;case"length":let N=new fo;O=N;let H=D&&D.max,V=D&&D.min;H!=null?(s.maxlength=""+(N.max=H),n===de+"-input-chars"&&(s.count??=""+H)):"max"in P&&(s.max=P.max),V!=null?s.minlength=""+(N.min=V):"min"in P&&(s.minlength=P.min);break;case"range":let B=new go;O=B;let R=D&&D.max,U=D&&D.min,z=n===de+"-datetime-picker";R!=null?(B.max=R,s.max="{{ "+(z?"'"+R+"'":R)+" }}"):"max"in P&&(s.max=P.max),U!=null?(B.min=U,s.min="{{ "+(z?"'"+U+"'":U)+" }}"):"min"in P&&(s.min=P.min);break;case"email":let G=new yo;O=G,s.pattern=iw(G.pattern=/^[\w\-\.]+@[\w\-\.]+\.[a-zA-Z0-9]{2,6}$/);break;case"regex":let Z=new yo;O=Z;let q=D.pattern;q||=P.pattern,s.pattern=iw(q),Z.pattern=q;break;case"binary":let Q=new bo;O=Q;let Ne=D.pattern;Ne!=null?(s.pattern=iw(Ne),Q.pattern=Ne):"pattern"in P&&(s.pattern=P.pattern);let ne=D&&D.maxSize;ne!=null?(Q.maxSize=ne,s["max-size"]=""+ne):"max-size"in P&&(s["max-size"]=P["max-size"]);break;case"compare":let pe=new vo;O=pe;let ee="";"value"in D?ee=JSON.stringify(D.value):ee=`:host.entity.${"to"in D?D.to:D.toProperty}`;let J=`{{ ${ee} }}`;pe.setAttribute("to",J);let $e=pe.operator=D.operator||P.operator||"equal";if(n===de+"-datetime-picker")switch($e){case"lessOrEqual":case"less":s.max=J;break;case"greaterOrEqual":case"greater":s.min=J;break}break;case"async":let ue=new Vn;O=ue,ue.url=D.url;let Te=[],He=D.dependsOn||m;Te.push(`${t.prop}: :host._adjustDependencyValue(:host.entity.${t.prop})`);for(let ze of He||[])Te.push(`${ze.alias||ze.prop}: :host._adjustDependencyValue(:host.entity.${ze.prop})`);ue.setAttribute("parameters",`{{ { ${Te.join(", ")} } }}`),ue.method=D.verb||TB.HttpMethod.Get,ue.setAttribute("fetch-credentials","{{ :host.fetchCredentials }}"),ue.setAttribute("fetch-headers","{{ :host.fetchHeaders }}");break;case"custom":O=new sc;break;default:if(!Y.isNullOrEmpty(I.type)&&I.type.indexOf("-")>0){let ze=I.type,Fr=document.createElement(ze);Fr instanceof $r&&(O=Fr)}break}if(Y.isNull(O))throw`Cannot generate a formfield validator based on type: ${I.type}.`;O.watch=t.prop,O.setAttribute("hide","{{ !this.invalid }}"),O.setAttribute("disabled",d);for(let N in P)O.setAttribute(N,P[N]);this._validators.appendChild(O)});let w=document.createElement(n);for(var T in s){let I;Y.isNullOrEmpty(I=s[T])||w.setAttribute(T,I)}w.append(_),this._field=w,this._container.insertBefore(w,this._container.firstElementChild);for(var T in c){let O;Y.isNullOrEmpty(O=c[T])||this._fetcher.setAttribute(T,O)}this.dispatchEvent(new IN({propertyName:"field",currentValue:w}))}};l([wg("label")],rn.prototype,"_label",2),l([wg(`div.${ct}-input-container`)],rn.prototype,"_container",2),l([wg(de+"-fetch")],rn.prototype,"_fetcher",2),l([wg(de+"-form")],rn.prototype,"_form",2),l([wg(de+"-panel."+ct+"-validators")],rn.prototype,"_validators",2),l([Eg({converter:r_.Json})],rn.prototype,"metadata",2),l([Eg({converter:r_.Json})],rn.prototype,"fetchHeaders",2),l([Eg({converter:r_.String})],rn.prototype,"fetchCredentials",2),l([Eg({converter:r_.Boolean})],rn.prototype,"readonly",2),l([Eg()],rn.prototype,"entity",2),rn=l([AB({tagName:de+"-form-field",template:`<${de}-form class="${ct}-field" logger="{{ :host.logger }}"
|
|
315
|
+
css-class="{{ {'${ct}-fetching': ::_fetcher.fetching, '${ct}-dirty': this.dirty, '${ct}-invalid': !this.valid, '${ct}-editable': !:host.readonly, '${ct}-readonly': :host.readonly, '${ct}-pristine': !this.dirty, '${ct}-valid': this.valid, '${ct}-has-value': !:host._isValueNullOrEmpty(:host.entity, :host.metadata) } }}">
|
|
316
|
+
<label class="${ct}-label"><${de}-span></${de}-span></label>
|
|
317
|
+
<div class="${ct}-input-container"></div>
|
|
318
|
+
<${de}-fetch debounce="300" logger="{{ :host.logger }}" credentials="{{ :host.fetchCredentials }}" headers="{{ :host.fetchHeaders }}" diff-by-values="true"
|
|
319
|
+
on-fetchresult=":host._broadcastFetchResult($event.detail)"></${de}-fetch>
|
|
320
|
+
<${de}-panel class="${ct}-validators" hide="{{ ::_form.valid || !::_form.dirty || :host.readonly }}"></${de}-panel>
|
|
321
|
+
</${de}-form>`})],rn);import{P as zn,ViewChild as i_,CustomElement as IB,Watch as sw,Utils as xo,PropertyConverters as s_}from"@pacem/pacem-core";import{Components as $B,Maps as Rh}from"@pacem/pacem-maps";var HB=3,Co,vi=class extends ge{constructor(){super(...arguments);$(this,Co);this._dragendHandler=e=>{this._reverseGeocoder.position=e.detail.position}}get inputFields(){return[]}toggleReadonlyView(e){this._setupSuggest(),this._setupMapMarker()}onChange(e){return new Promise((t,n)=>{if(e.type==="success"&&e.target===this._reverseGeocoder){let i=x(this,Co).position,s=e.detail.sort((d,p)=>{let u=Rh.MapProjection.distanceBetween(d.position,i),h=Rh.MapProjection.distanceBetween(p.position,i);return u<h?0:-1}),o=s[0].position.altitude,c=xo.extend({},s[0],{position:xo.extend({altitude:o},i)});t(this.value=c)}else e.type===nu&&e.target===this._suggest?t(this.value=this._suggest.value):t(this.value)})}fetch(e){Rh.LatLng.isLatLng(e)&&(x(this,Co).position=this._reverseGeocoder.position=e)}compareValuePropertyValues(e,t){let n=e?.position??Rh.LatLng.Empty,i=t?.position??Rh.LatLng.Empty;return Rh.LatLng.equals(n,i)}acceptValue(e){xo.isNull(e)?this._datasource.model=[]:(this._datasource.model=[e],this._setupMapMarker()),this._setupSuggest()}getViewValue(e){return e?.fullAddress||""}convertValueAttributeToProperty(e){return s_.Json.convert(e,this)}viewActivatedCallback(){super.viewActivatedCallback(),this._setup()}propertyChangedCallback(e,t,n,i){if(super.propertyChangedCallback(e,t,n,i),!i)switch(e){case"adapter":this._setupAdapters(n);break;case"map":t&&this._detachMarker(t),n&&this._setupMapMarker(n);break;case"icon":this._setupMapMarker();break;case"plaeholder":this._setupSuggest();break;case"disabled":this._setupMapMarker(),this._setupSuggest();break}}disconnectedCallback(){this._disposeMarker(),super.disconnectedCallback()}_setupAdapters(e=this.adapter){let t=this._geocoder,n=this._reverseGeocoder;xo.isNull(t)||(t.adapter=e),xo.isNull(n)||(n.adapter=e)}_setupSuggest(){let e=this._suggest;xo.isNull(e)||(e.placeholder=this.placeholder??"search...",e.readonly=this.readonly,e.disabled=this.disabled,e.value=this.value)}_detachMarker(e=this.map){let t=x(this,Co);!xo.isNull(t)&&t.map===e&&t.remove()}_createMarker(){let e=new $B.Maps.PacemMapMarkerElement;return e.addEventListener("dragend",this._dragendHandler,!1),e}_disposeMarker(){let e=x(this,Co);xo.isNull(e)||e.removeEventListener("dragend",this._dragendHandler,!1)}_setupMapMarker(e=this.map){let t=x(this,Co)||A(this,Co,this._createMarker());t.icon=this.icon,t.draggable=!this.readonly&&!this.disabled,t.hide=this.disabled;let n=this.value;n&&n.position&&(t.position=n.position),t.map!==e&&!xo.isNull(e)&&e.appendChild(t)}_setup(){this._setupAdapters(),this._setupSuggest(),this._setupMapMarker()}};Co=new WeakMap,l([sw({emit:!1,converter:s_.Element})],vi.prototype,"adapter",2),l([sw({emit:!1,converter:s_.Element})],vi.prototype,"map",2),l([sw({emit:!1,converter:s_.Json})],vi.prototype,"icon",2),l([i_(zn+"-data[ds]")],vi.prototype,"_datasource",2),l([i_(zn+"-suggest")],vi.prototype,"_suggest",2),l([i_(zn+"-map-geocode")],vi.prototype,"_geocoder",2),l([i_(zn+"-map-geocode[reverse]")],vi.prototype,"_reverseGeocoder",2),vi=l([IB({tagName:zn+"-geolocate",shadow:!1,template:`<${zn}-map-geocode search="{{ ::_suggest.hint }}"
|
|
322
|
+
disabled="{{ (::_suggest.hint || '').length < ${HB} }}" on-success="::_datasource.model = $event.detail"></${zn}-map-geocode>
|
|
323
|
+
<${zn}-map-geocode reverse on-success=":host.changeHandler($event)"></${zn}-map-geocode>
|
|
324
|
+
|
|
325
|
+
<${zn}-data ds></${zn}-data>
|
|
326
|
+
|
|
327
|
+
<${zn}-suggest on-change=":host.changeHandler($event)" datasource="{{ ::_datasource.model || [] }}"
|
|
328
|
+
compare-by="fullAddress" text-property="fullAddress"></${zn}-suggest>`})],vi);import{Components as $N,PropertyConverters as Eo,Utils as Lt,P as Oe,PCSS as lw,CustomElement as BB,Watch as wo,Defaults as VB,ViewChild as Mg,CustomEventUtils as UB,CustomElementUtils as zB,avoidHandler as HN,UI as Vt}from"@pacem/pacem-core";import{Components as cs}from"@pacem/pacem-ui";var a_=class extends CustomEvent{constructor(r){super("hierarchychange",{detail:r,bubbles:!1,cancelable:!1})}},cw="hierarchy-item",BN=cw+" "+lw+"-anim anim-fade-in anim-sudden",VN="{{ { 'item-disabled' : ^item.disabled } }}",UN="pacemHierarchy",zN="item-content",jN="item-link",GN=jN+" icon-rotate rotate-135",FN="link",aw="item-move",WN="drag_indicator",ow="parents",Jd,Sg,ko,Lg,ra,Oh,Qt=class extends ge{constructor(){super();$(this,Jd);$(this,Sg,new Map);$(this,ko);$(this,Lg);$(this,ra,new Map);$(this,Oh);this.unlinkCaption="Delete";this._binderClickHandler=e=>{let t=e.originalEvent.type;if(t==="mousedown"&&e.originalEvent.button===1){HN(e.originalEvent);let n=e.srcElement;this._unlink(n)}else if(t==="click"||t==="contextmenu"){HN(e.originalEvent),A(this,Lg,e.srcElement);let n=this._balloon;n.target={x:e.pageX,y:e.pageY},n.popup()}};this._dragInitHandler=e=>{let t=e.detail,n=this._dragger;n.floater=document.createElement("span"),n.dropTargets=Array.from(x(this,ra).keys()).filter(s=>s!==t.element),Lt.isNull(x(this,ko))||x(this,ko).remove();let i=A(this,ko,new cs.UI.PacemBinderElement);i.from=t.element,x(this,Oh).appendChild(i)};this._dragStartHandler=e=>{Lt.addClass(e.detail.element,"item-drag")};this._dragHandler=e=>{x(this,ko).to=e.detail.currentPosition};this._dragEndHandler=e=>{Lt.removeClass(e.detail.element,"item-drag"),x(this,ko).remove(),A(this,ko,null)};this._dropHandler=e=>{let t=e.detail.data,n=x(this,ra).get(e.detail.target);!this._isInAncestors(t,n)&&!this._isInDescendants(t,n)&&this._compileHierarchy({source:t,target:n})};this._dragOverHandler=e=>{let t=e.detail.data,n=x(this,ra).get(e.detail.target);(n.disabled||this._isInAncestors(t,n)||this._isInDescendants(t,n))&&e.preventDefault()};this._dragOutHandler=e=>{};this._popoutHandler=e=>{this._balloon.popout()};A(this,Jd,Lt.uniqueCode())}getViewValue(e){return""}convertValueAttributeToProperty(e){return Lt.Json.parse(e)}get inputFields(){return[]}toggleReadonlyView(e){this._dragger.disabled=e,Lt.isNull(this._adaptedDatasource)||this._databind()}onChange(e){return new Promise((t,n)=>{UB.isInstanceOf(e,a_)&&t(this.value=e.detail),t(this.value)})}acceptValue(e){}viewActivatedCallback(){super.viewActivatedCallback(),A(this,Oh,zB.findAncestorShell(this)),this._setupItemTemplate(),this._setupDragger(),this._setupBalloon()}propertyChangedCallback(e,t,n,i){switch(super.propertyChangedCallback(e,t,n,i),e){case"datasource":case"textProperty":case"disabledProperty":case"valueProperty":cancelAnimationFrame(this._handle),this._handle=requestAnimationFrame(()=>{this._buildAdaptedDatasource()});break;case"itemtemplate":i||this._setupItemTemplate();break;case"_adaptedDatasource":case"value":cancelAnimationFrame(this._handle2),this._handle2=requestAnimationFrame(()=>{this._databind()});break}}disconnectedCallback(){this._disposeDragger(),this._disposeBalloon(),super.disconnectedCallback()}_buildAdaptedDatasource(e=this.datasource){this._adaptedDatasource=e&&e.map(t=>this._mapEntityToItem(t))}_mapEntityToValue(e){let t=e,n;return(n=this.valueProperty)&&(t=e[n]),t}_mapEntityToViewValue(e){let t=e.toString(),n;return(n=this.textProperty)&&(t=e[n]),t}_mapEntityToItem(e){if(e==null)throw new Error("Entity cannot be null");let t=!1,n=this.disabledProperty;return Lt.isNullOrEmpty(n)||(t=e[n]||!1),{value:this._mapEntityToValue(e),viewValue:this._mapEntityToViewValue(e),disabled:t,data:e}}_unlink(e){var t;e instanceof cs.UI.PacemBinderElement?t=e:(e.preventDefault(),e.stopPropagation(),t=x(this,Lg));let{parent:n,child:i}=JSON.parse(t.dataset[UN]),s=this._adaptedDatasource,o=s.find(d=>d.value===n),c=s.find(d=>d.value===i);!o.disabled&&!c.disabled&&this._compileHierarchy({source:o,target:c},!0)}_buildHierarchyItemDomId(e){return`hierarchyitem_${x(this,Jd)}_${e}`}_itemCreate(e){let t=e.detail.dom.find(s=>s instanceof HTMLElement&&s.classList.contains(cw)),n=e.detail.index,i=e.detail.item;t.id=this._buildHierarchyItemDomId(i.value),i.disabled?t.setAttribute("behaviors","{{ [#"+this._dragger2.id+"] }}"):t.setAttribute("behaviors","{{ [#"+this._dragger.id+", #"+this._dragger2.id+"] }}");for(let s of i.parents||[]){let o=new cs.UI.PacemBinderElement;o.to=t,o.toAnchor=cs.UI.BinderAnchor.Top,o.toEnd=cs.UI.BinderEnd.Arrow,o.setAttribute("from","{{ #"+this._buildHierarchyItemDomId(s.value)+" }}"),o.fromAnchor=cs.UI.BinderAnchor.Bottom,o.cssClass=["hierarchy-binder"],o.interactive=!this.readonly&&!i.disabled&&!s.disabled,o.addEventListener(cs.UI.BinderInteractionEventName,this._binderClickHandler,!1),o.dataset[UN]=JSON.stringify({parent:s.value,child:i.value}),x(this,Sg).set(i.value,o),x(this,Oh).appendChild(o)}x(this,ra).has(t)||x(this,ra).set(t,i)}_itemRemove(e){let t=e.detail.dom.find(s=>s instanceof HTMLElement&&s.classList.contains(cw)),n=e.detail.item,i=x(this,Sg);if(i.has(n.value)){let s=i.get(n.value);s.removeEventListener(cs.UI.BinderInteractionEventName,this._binderClickHandler,!1),s.remove(),i.delete(n.value)}x(this,ra).has(t)&&x(this,ra).delete(t)}_setupItemTemplate(){if(this.itemtemplate instanceof HTMLTemplateElement){let e=this.itemtemplate.cloneNode(!0).content,t=document.createElement("template"),n=document.createElement(Oe+"-panel");n.className=BN,n.setAttribute("css-class",VN);let i=new cs.UI.PacemIconElement;i.setAttribute("icon",WN),i.className=aw,n.appendChild(i);let s=document.createElement("div");s.className=zN,s.append(e),n.appendChild(s);let o=new cs.UI.PacemIconElement;o.setAttribute("icon",FN),o.className=GN,n.appendChild(o),t.content.appendChild(n),this._template=t}else this._template=this._defaultTemplate}_compileHierarchy(e,t=!1){let n=Lt.clone(this.value||[]),i=e.source.value,s=e.target.value,o=this.parentsProperty||ow;var c=n.find(d=>d[this.valueProperty]===s);if(t){if(!Lt.isNull(c)){let d=c[o]||[],p=d.indexOf(i);p>=0&&d.splice(p,1)}}else Lt.isNull(c)&&(c={},c[this.valueProperty]=s,c[o]=[],n.push(c)),c[o].push(i);this._cleanupHierarchy(n),this.changeHandler(new a_(n))}_cleanupHierarchy(e=[]){let t=this.valueProperty,n=this.parentsProperty||ow,i=(s,o)=>{let c=e.find(p=>p[t]==o);if(Lt.isNull(c)||Lt.isNullOrEmpty(c[n]))return!1;let d=c[n];return d.indexOf(s)>=0?!0:d.some(p=>i(s,p))};for(let s of e){let o=s[n]||[];for(let c=o.length-1;c>=0;c--){let d=o[c],p=o.filter(u=>u!==d);for(let u of p)if(i(d,u)){o.splice(c,1);break}}}}_setupDragger(){let e=this._dragger;e.id="hierarchy_link_"+x(this,Jd),e.handleSelector="."+jN,e.dropBehavior=Vt.DropBehavior.None,e.spillBehavior=Vt.DropTargetMissedBehavior.None,e.mode=Vt.DragDataMode.Copy,e.addEventListener(Vt.DragDropEventType.Drop,this._dropHandler,!1),e.addEventListener(Vt.DragDropEventType.Drag,this._dragHandler,!1),e.addEventListener(Vt.DragDropEventType.Init,this._dragInitHandler,!1),e.addEventListener(Vt.DragDropEventType.Start,this._dragStartHandler,!1),e.addEventListener(Vt.DragDropEventType.End,this._dragEndHandler,!1),e.addEventListener(Vt.DragDropEventType.Over,this._dragOverHandler,!1),e.addEventListener(Vt.DragDropEventType.Out,this._dragOutHandler,!1);let t=this._dragger2;t.id="hierarchy_move_"+x(this,Jd),t.mode=Vt.DragDataMode.Self,t.dropBehavior=Vt.DropBehavior.None,t.spillBehavior=Vt.DropTargetMissedBehavior.None,t.handleSelector="."+aw}_disposeDragger(){let e=this._dragger;Lt.isNull(e)||(e.removeEventListener(Vt.DragDropEventType.Drop,this._dropHandler,!1),e.removeEventListener(Vt.DragDropEventType.Drag,this._dragHandler,!1),e.removeEventListener(Vt.DragDropEventType.Init,this._dragInitHandler,!1),e.removeEventListener(Vt.DragDropEventType.Start,this._dragStartHandler,!1),e.removeEventListener(Vt.DragDropEventType.End,this._dragEndHandler,!1),e.removeEventListener(Vt.DragDropEventType.Over,this._dragOverHandler,!1),e.removeEventListener(Vt.DragDropEventType.Out,this._dragOutHandler,!1))}_setupBalloon(){this._balloon=this._shellProxy.dom.find(e=>e instanceof cs.UI.PacemBalloonElement),window.addEventListener("mousedown",this._popoutHandler,!1)}_disposeBalloon(){window.removeEventListener("mousedown",this._popoutHandler,!1)}_isInAncestors(e,t){return Lt.isNull(t)||Lt.isNullOrEmpty(t.parents)?!1:t.parents.indexOf(e)>=0?!0:t.parents.some(n=>this._isInAncestors(e,n))}_isInDescendants(e,t){return this._isInAncestors(t,e)}_databind(){this._repeater.datasource=[];let e=this.valueProperty;if(Lt.isNullOrEmpty(e))throw new Error("Missing valueProperty.");let t=Lt.clone(this._adaptedDatasource||[]),n=this.value||[],i=this.parentsProperty||ow;for(let s of t){let o=n.find(c=>c[e]===s.value);Lt.isNull(o)||(s.parents=(o[i]||[]).map(c=>t.find(d=>d.value===c)).filter(c=>!Lt.isNull(c)))}this._databindByParents(t)}_databindByParents(e){let t=[];function n(){return t.reduce((i,s)=>i+s.length,0)}do if(Lt.isNullOrEmpty(t)){let i=e.filter(s=>Lt.isNullOrEmpty(s.parents));t.push(i)}else{let i=Array.prototype.concat.apply([],t),s=t[t.length-1],o=e.filter(c=>Lt.isNullOrEmpty(c.parents)?!1:c.parents.every(d=>i.indexOf(d)>=0)&&c.parents.some(d=>s.indexOf(d)>=0));t.push(o)}while(n()<e.length);this._repeater.datasource=t}};Jd=new WeakMap,Sg=new WeakMap,ko=new WeakMap,Lg=new WeakMap,ra=new WeakMap,Oh=new WeakMap,l([Mg("template[default]")],Qt.prototype,"_defaultTemplate",2),l([Mg(Oe+"-repeater")],Qt.prototype,"_repeater",2),l([Mg(Oe+"-drag-drop")],Qt.prototype,"_dragger",2),l([Mg(Oe+"-drag-drop[move]")],Qt.prototype,"_dragger2",2),l([Mg(Oe+"-shell-proxy")],Qt.prototype,"_shellProxy",2),l([wo({emit:!1,converter:Eo.Json})],Qt.prototype,"datasource",2),l([wo({emit:!1,converter:Eo.String})],Qt.prototype,"valueProperty",2),l([wo({emit:!1,converter:Eo.String})],Qt.prototype,"textProperty",2),l([wo({emit:!1,converter:Eo.String})],Qt.prototype,"disabledProperty",2),l([wo({converter:Eo.String})],Qt.prototype,"unlinkCaption",2),l([wo({converter:Eo.Json})],Qt.prototype,"_adaptedDatasource",2),l([wo({emit:!1,converter:Eo.Element})],Qt.prototype,"itemtemplate",2),l([wo({converter:Eo.Element})],Qt.prototype,"_template",2),l([wo({emit:!1,converter:Eo.String})],Qt.prototype,"parentsProperty",2),Qt=l([BB({tagName:Oe+"-hierarchy",shadow:VB.USE_SHADOW_ROOT,template:`<${Oe}-repeater>
|
|
329
|
+
<template>
|
|
330
|
+
<${Oe}-repeater on-${$N.RepeaterItemCreateEventName}=":host._itemCreate($event)" on-${$N.RepeaterItemRemoveEventName}=":host._itemRemove($event)" datasource="{{ ^item }}">
|
|
331
|
+
<div class="hierarchy-level">
|
|
332
|
+
<${Oe}-template-proxy target="{{ :host._template }}"></${Oe}-template-proxy>
|
|
333
|
+
</div>
|
|
334
|
+
</${Oe}-repeater>
|
|
335
|
+
</template>
|
|
336
|
+
</div>
|
|
337
|
+
</${Oe}-repeater><${Oe}-content></${Oe}-content>
|
|
338
|
+
<${Oe}-drag-drop></${Oe}-drag-drop>
|
|
339
|
+
<${Oe}-drag-drop move></${Oe}-drag-drop>
|
|
340
|
+
<template default>
|
|
341
|
+
<${Oe}-panel class="${BN} item-default" css-class="${VN}">
|
|
342
|
+
<${Oe}-icon class="${aw}" icon="${WN}"></${Oe}-icon>
|
|
343
|
+
<pacem-span class="${zN}" content="{{ ^item.viewValue }}"></${Oe}-span>
|
|
344
|
+
<${Oe}-icon class="${GN}" icon="${FN}"></${Oe}-icon>
|
|
345
|
+
</${Oe}-panel>
|
|
346
|
+
</template>
|
|
347
|
+
<${Oe}-shell-proxy>
|
|
348
|
+
<${Oe}-balloon options="{{ { behavior: ComponentsUI.UI.BalloonBehavior.Inert } }}">
|
|
349
|
+
<${Oe}-button icon-glyph="link_off" class="${lw}-margin margin-0 button-flat display-flex flex-middle icon-rotate rotate-135"
|
|
350
|
+
on-click=":host._unlink($event)"
|
|
351
|
+
on-mousedown="$event.stopPropagation()"
|
|
352
|
+
on-mouseup="::_balloon.popout()"><${Oe}-text class="${lw}-margin margin-left-1" text="{{ :host.unlinkCaption }}"></${Oe}-text></${Oe}-button>
|
|
353
|
+
</${Oe}-balloon>
|
|
354
|
+
</${Oe}-shell-proxy>`})],Qt);import{PropertyConverters as Zd,Utils as Ph,Watch as Mo,CustomElementUtils as o_}from"@pacem/pacem-core";var dw=(e=>(e.Input="input",e.Blur="blur",e))(dw||{}),l_="pacem:scaffolding:input_field",na=class extends ge{constructor(){super(...arguments);this.debounce=!1;this.changePolicy="input";this._focusHandler=e=>{if(!this.autoselect)return;let t=this.inputField;for(let n of this.inputFields??[])if(n===document.activeElement){t=n;break}t?.select()}}propertyChangedCallback(e,t,n,i){switch(super.propertyChangedCallback(e,t,n,i),e){case"placeholder":for(let s of this.inputFields??[])s.setAttribute(e,n);break}}acceptValue(e){this.inputField&&e!==this.inputField.value&&(this.inputField.value=Ph.isNullOrEmpty(e)?"":e)}get inputField(){return this.inputFields[0]}onChange(e){return new Promise(t=>{if(this.readonly)t(this.value);else if(e.type==="input"&&this.changePolicy==="blur")t(this.value);else{let n=()=>{let s=this.getValue(this.inputField.value);s!==this.value&&(this.value=s),t(s)},i=this.debounce;typeof i=="number"&&i>0?(clearTimeout(this._handle),this._handle=setTimeout(n,i)):i===!0?(cancelAnimationFrame(this._handle),this._handle=requestAnimationFrame(n)):requestAnimationFrame(n)}})}registerInputFields(e=this.inputFields){super.registerInputFields(e),!Ph.isNull(e)&&!Ph.isArray(e)&&(e=[e]);for(let t of e??[])!(t instanceof HTMLInputElement)&&!(t instanceof HTMLTextAreaElement)||o_.getAttachedPropertyValue(t,l_,"off")!=="on"&&(o_.setAttachedPropertyValue(t,l_,"on"),"size"in t&&(t.size=1),t.autocomplete="off",t.addEventListener("input",this.changeHandler,!1),t.addEventListener("focus",this._focusHandler,!1))}unregisterInputFields(e=this.inputFields){super.unregisterInputFields(e),!Ph.isNull(e)&&!Ph.isArray(e)&&(e=[e]);for(let t of e??[])o_.getAttachedPropertyValue(t,l_)==="on"&&(o_.deleteAttachedPropertyValue(t,l_),t.removeEventListener("input",this.changeHandler,!1),t.removeEventListener("focus",this._focusHandler,!1))}viewActivatedCallback(){super.viewActivatedCallback(),this.registerInputFields()}disconnectedCallback(){this.unregisterInputFields(),super.disconnectedCallback()}};l([Mo({emit:!1,converter:{convert:e=>{switch(e){case"true":return!0;case"false":return!1;default:return parseFloat(e)}},convertBack:e=>e.toString()}})],na.prototype,"debounce",2),l([Mo({emit:!1,converter:Zd.String})],na.prototype,"changePolicy",2),l([Mo({emit:!1,converter:Zd.Boolean})],na.prototype,"autoselect",2);var cc=class extends na{convertValueAttributeToProperty(r){return parseFloat(r)}propertyChangedCallback(r,e,t,n){switch(super.propertyChangedCallback(r,e,t,n),r){case"min":case"max":case"step":t!=null?this.inputField.setAttribute(r,t):this.inputField.removeAttribute(r);break}}};l([Mo({converter:Zd.Number})],cc.prototype,"min",2),l([Mo({converter:Zd.Number})],cc.prototype,"max",2),l([Mo({converter:{convert:r=>{let e=parseFloat(r);return isNaN(e)?"any":e},convertBack:r=>r.toString()}})],cc.prototype,"step",2);var dt=class extends na{convertValueAttributeToProperty(r){return r}propertyChangedCallback(r,e,t,n){switch(super.propertyChangedCallback(r,e,t,n),r){case"pattern":case"maxlength":case"minlength":t!=null?this.inputField.setAttribute(r,t):this.inputField.removeAttribute(r);break}}getValue(r){return Ph.isNullOrEmpty(r)?null:r}getViewValue(r){return r}};l([Mo({converter:Zd.String})],dt.prototype,"pattern",2),l([Mo({converter:Zd.Number})],dt.prototype,"minlength",2),l([Mo({converter:Zd.Number})],dt.prototype,"maxlength",2);import{Arrays as YN}from"@pacem/pacem-foundation";import{Components as XN,PropertyConverters as qN,Utils as ia,P as Ih,PCSS as pw,CustomElement as GB,Watch as KN,Defaults as FB,ViewChild as JN}from"@pacem/pacem-core";var sa,So=class extends na{constructor(){super();this.charCount=6;this.inputTransform="none";this._itemCreateHandler=e=>{let{dom:t,index:n}=e.detail,i=t.find(s=>s instanceof HTMLInputElement);x(this,sa)[n]=i,this.registerInputFields(i)};$(this,sa,[])}redactViewValue(e=this.value){this.viewValue=this.getViewValue(e)}getValue(e){let t=x(this,sa).reduce((n,i)=>n+(ia.isNullOrEmpty(i.value)?" ":i.value),"");switch(this.inputTransform){case"lowercase":return t.toLowerCase();case"uppercase":return t.toUpperCase();default:return t}}getViewValue(e){let t=this.charCount;return this.inputTransform=="password"?YN.range(t).map(n=>"*").join(""):e}convertValueAttributeToProperty(e){return e}toggleReadonlyView(e=this.readonly){this._span.hidden=!e,this._chars.hidden=e}focus(){for(let e of this.inputFields??[])if(e===document.activeElement){this.autofocus&&e.select();return}super.focus()}propertyChangedCallback(e,t,n,i){if(super.propertyChangedCallback(e,t,n,i),!i)switch(e){case"charCount":this._databind(),this.redactViewValue();break;case"inputTransform":this.registerInputFields(),this.value=this.getValue(this.value);break}}registerInputFields(e=this.inputFields){super.registerInputFields(e),!ia.isNull(e)&&!ia.isArray(e)&&(e=[e]);let t=x(this,sa);for(let n of e??[]){let i=t.indexOf(n);ia.toggleClass(n,"last-char",i===this.charCount-1),ia.toggleClass(n,"first-char",i===0),ia.isNullOrEmpty(n.id)&&n.setAttribute("id","code_"+i+"_"+ia.uniqueCode()),n.value=this.value?.charAt(i)||"",this.inputTransform==="password"?n.setAttribute("type","password"):n.setAttribute("type","text")}}acceptValue(e){let t=x(this,sa);if(typeof e=="string"){let n=0,i=Math.min(e.length,t.length);for(let s=0;s<i;s++)t[s].value=e.charAt(s),n++;for(let s=n;s<t.length;s++)t[s].value=""}}onChange(e){return super.onChange(e).then(t=>{let n=x(this,sa),i=n.indexOf(e.target);if(i>=0&&i<n.length-1){let s=n[i];if(ia.isNullOrEmpty(s.value?.trim()))s.value="";else{let o=i+1;n[o].focus()}}return t})}viewActivatedCallback(){super.viewActivatedCallback(),ia.isNull(this.autoselect)&&(this.autoselect=!0),this._chars.addEventListener(XN.RepeaterItemCreateEventName,this._itemCreateHandler,!1),this._databind()}disconnectedCallback(){let e=this._chars;ia.isNull(e)||e.removeEventListener(XN.RepeaterItemCreateEventName,this._itemCreateHandler),super.disconnectedCallback()}_databind(){let e=this.charCount,t=x(this,sa);t.length>e&&super.unregisterInputFields(t.splice(e)),this._chars.datasource=YN.range(e)}get inputFields(){return x(this,sa)}};sa=new WeakMap,l([KN({emit:!1,reflectBack:!0,converter:qN.Number})],So.prototype,"charCount",2),l([KN({emit:!1,reflectBack:!0,converter:qN.String})],So.prototype,"inputTransform",2),l([JN(Ih+"-repeater")],So.prototype,"_chars",2),l([JN("span."+pw+"-readonly")],So.prototype,"_span",2),So=l([GB({tagName:Ih+"-input-chars",template:`<${Ih}-repeater class="display-flex flex-nowrap">
|
|
355
|
+
<template><input type="text" class="${pw}-input flex-auto" maxlength="1" /></template>
|
|
356
|
+
</${Ih}-repeater><span class="${pw}-readonly"><${Ih}-text text="{{ :host.viewValue }}"></${Ih}-text></span>`,shadow:FB.USE_SHADOW_ROOT})],So);import{Colors as c_}from"@pacem/pacem-foundation";import{Utils as ZN,P as Ng,PCSS as Qd,CustomElement as WB,Defaults as jB,ViewChild as d_}from"@pacem/pacem-core";var Lo=class extends ge{acceptValue(r){let e=this._parseValue(r);e!=null&&(this._tint.value=e.tint,this._alpha.value=e.alpha.toString())}convertValueAttributeToProperty(r){return r}onChange(r){let e=this._alpha.valueAsNumber||parseInt(this._alpha.value),t=this._tint.value,n=this.value=this._getValue(t,e);return ZN.fromResult(n)}constructor(){super()}toggleReadonlyView(r){this._wrapper.hidden=r,this._span.hidden=!r}_getValue(r,e){if(isNaN(e)||e===100)return r;let t=c_.parse(r);return t.a=e*.01,c_.stringify(t)}_parseValue(r){let e=c_.parse(r);return ZN.isNullOrEmpty(e)?null:{tint:c_.stringify({r:e.r,g:e.g,b:e.b}),alpha:e.a*100}}getViewValue(r){return r}get inputFields(){return[this._tint,this._alpha]}};l([d_("input[type=color]")],Lo.prototype,"_tint",2),l([d_("input[type=number]")],Lo.prototype,"_alpha",2),l([d_(`.${Qd}-viewfinder`)],Lo.prototype,"_wrapper",2),l([d_(`.${Qd}-readonly`)],Lo.prototype,"_span",2),Lo=l([WB({tagName:Ng+"-input-color",template:`<div class="${Qd}-viewfinder">
|
|
357
|
+
<${Ng}-panel class="${Qd}-input-color" css="{{ { 'background-color': :host.viewValue } }}"><input type="color" class="${Qd}-input" /></${Ng}-panel>
|
|
358
|
+
<input class="${Qd}-input" type="number" min="0" max="100" step="1" value="100" />
|
|
359
|
+
</div>
|
|
360
|
+
<${Ng}-span class="${Qd}-readonly" css="{{ { 'background-color': :host.viewValue } }}"></${Ng}-span>`,shadow:jB.USE_SHADOW_ROOT})],Lo);import{P as $h,PCSS as uw,CustomElement as YB,Defaults as XB,ViewChild as QN}from"@pacem/pacem-core";var ep=class extends dt{toggleReadonlyView(r){this.input.hidden=r,this.anchor.hidden=!r}get inputFields(){return[this.input]}};l([QN("input[type=email]")],ep.prototype,"input",2),l([QN($h+"-a")],ep.prototype,"anchor",2),ep=l([YB({tagName:$h+"-input-email",template:`<input type="email" class="${uw}-input ${uw}-viewfinder" />${en}<${$h}-a class="${uw}-readonly" disabled="{{ $pacem.isNullOrEmpty(:host.value) }}" href="{{ 'mailto:'+ :host.value }}"><${$h}-text text="{{ :host.viewValue }}"></${$h}-text></${$h}-a>`,shadow:XB.USE_SHADOW_ROOT})],ep);import{P as Xe,PCSS as tp,CustomElement as qB,Watch as er,Defaults as KB,ViewChild as eT,CustomTypedEvent as mw,CustomEventUtils as tT,PropertyConverters as tr,Animations as hw,Utils as Ut,stopPropagationHandler as rT,avoidHandler as nT}from"@pacem/pacem-core";var p_="fileupload",iT="filechange",Tg=class extends mw{constructor(r){super("pick",r)}},Ag=class extends mw{constructor(r){super(p_,r)}},Hh=class extends mw{constructor(r){super(iT,r)}},JB="!$pacem.isNullOrEmpty(:host.value) && :host.invalidFile && $pacem.isNullOrEmpty(:host.url)";async function sT(a,r={files:0,directories:0,size:0}){for await(let[e,t]of a.entries())if(t.kind==="file"){r.files++;let n=await t.getFile();r.size+=n.size}else r.directories++,await sT(t,r);return r}async function ZB(a){let r={files:0,directories:0,size:0};for(let e of a){let t=await e.getFile();r.files++,r.size+=t.size}return r}var it=class extends ge{constructor(e=new hw.TweenService){super();this._tweener=e;this.undoCaption="undo";this.retryCaption="retry";this.clearCaption="clear";this.uploading=!1;this.size=0;this.percentage=0;this.complete=!1;this.failed=!1;this.invalidFile=!1;this._fields={parallelism:3,uid:"",ongoing:0,enqueuer:null,blob:null,retryFrom:0,chunkSize:1024*128,undone:!1}}convertValueAttributeToProperty(e){return e}acceptValue(e){this.percentage=0,this.uploading=!1,this._fileupload.value=""}_getMimeIcon(e=this.value,t=this.uploading,n=this.selectMode??"file"){if(t)return"sync";let i=!Ut.isNullOrEmpty(e);switch(n){case"directory":case"directory-picker":return i?"folder":"drive_folder_upload";case"multiple":case"multiple-picker":return i?"files":"upload_file"}if(Ut.isNullOrEmpty(e))return"upload_file";var s=e;typeof e=="object"&&(s=e.name);let c=/\.([\w]+)(\s|$)/.exec(s);if(c&&c.length)switch(c[1].toLowerCase()){case"pdf":return"picture_as_pdf";case"jpg":case"jpeg":case"gif":case"png":return"filter"}return"filter_none"}get blob(){return this._fields.blob}get inputFields(){return[this._fileupload]}getViewValue(e){let t=this._localValue||e;if(Ut.isNullOrEmpty(t))return"";if(typeof t=="string")return t;let n="name"in t?t.name:"";Ut.isArray(t)&&(n=t.map(c=>c.name).join(", "));let i=this._stats;if(Ut.isNullOrEmpty(i))return n;let{size:s,files:o}=i;return`${n}
|
|
361
|
+
(${o} file${o===1?"":"s"}, ${Ut.core.size(s)})`}toggleReadonlyView(e){this._setupInputElement(e)}viewActivatedCallback(){super.viewActivatedCallback(),this._setupInputElement(),this._fileupload.addEventListener("click",rT,!1)}propertyChangedCallback(e,t,n,i){super.propertyChangedCallback(e,t,n,i),i||e==="selectMode"&&this._setupInputElement()}disconnectedCallback(){this._fileupload&&this._fileupload.removeEventListener("click",rT,!1),super.disconnectedCallback()}_setupInputElement(e=this.readonly,t=this.selectMode??"file"){let n=this._fileupload;switch(n.removeAttribute("webkitdirectory"),n.removeAttribute("multiple"),n.hidden=e,t){case"directory":n.setAttribute("webkitdirectory","true");break;case"multiple":n.setAttribute("multiple","true");break;case"directory-picker":case"file-picker":case"multiple-picker":n.hidden=!0;break}}_dispatchDownload(e){nT(e);let t=this._localValue||this.value,n=i=>{this.dispatchEvent(new CustomEvent("download",{detail:i,bubbles:!0,cancelable:!1}))};Ut.isNullOrEmpty(t)||(typeof t=="string"?n(t):"content"in t&&!Ut.isNullOrEmpty(t.content)?Ut.download(Ut.dataURLToBlob("data:application/download;base64,"+t.content),t.name,t.type):"name"in t&&("kind"in t&&t.kind==="file"?t.getFile().then(i=>{Ut.download(i,i.name,i.type)}):n(t.name)))}reset(){super.reset(),this._localValue=null,this.invalidFile=!1}_validateAll(){let e=this._stats,t=this.maxSize;return t>0&&t<e.size?(this.invalidFile=!0,!1):(this.invalidFile=!1,!0)}_validateSingleFile(e=this._fileupload.files[0],t){e instanceof File&&(t=e.name),t=t.substring(t.lastIndexOf("\\")+1);let n=this.maxSize;if(n>0&&n<e.size)return this.invalidFile=!0,!1;let i=this.pattern;return i&&!new RegExp(i,"i").test(t)?(this.invalidFile=!0,!1):(this.invalidFile=!1,!0)}upload(e,t,n){if(this._validateSingleFile(e,t))return this._upload(e,t,n)}async _upload(e,t,n){var i=this,s=i._fields;if(!e)return;!t&&e instanceof File&&(t=e.name),i.failed=!1,s.undone=!1,s.ongoing=0;let o=e,c=i.size=o.size;t=t.substring(t.lastIndexOf("\\")+1),i.percentage=0,i.complete=!1;var d={filename:t,length:c,action:"start",state:n,type:e.type};i.uploading=!0;try{var p=await i._fetch(d);if(p.ok){var u=await p.json();s.retryFrom=0,s.blob=o,s.uid=u.uid,i._manage()}else i.uploading=!1;return p}catch{i.uploading=!1}}async _blobToBase64(e){let t=await Ut.blobToDataURL(e);return t.substring(t.indexOf("base64,")+7)}async _doUpload(e,t){var n=this,i=n._fields;i.ongoing++;var o={chunk:await this._blobToBase64(e),uid:i.uid,position:t,action:"do"};try{let c=await n._fetch(o);if(c.ok){if(i.ongoing--,i.undone)return;let p=await c.json();p.percentage>this.percentage&&await n._tweenPercentage(Math.round(Math.max(1,p.percentage)),200),n.complete!=p.complete&&(n.complete=p.complete,n.complete===!0&&(n.uploading=!1,n.changeHandler(new Ag(p))))}else i.retryFrom=t,n.failed=!0,n.uploading=!1}catch{i.retryFrom=t,n.failed=!0,n.uploading=!1}}_manage(){let e=this._fields,t=this.size,n=e.blob,i=this.chunkSize||e.chunkSize;var s=e.retryFrom,o=s+i;e.enqueuer=setInterval(()=>{if(s<t&&!this.failed){let d=this.parallelism||e.parallelism;if(e.ongoing>=d)return;this._doUpload(n.slice(s,o),s),s=o,o=s+i}else{var c=this._fileupload;c.value="",window.clearInterval(e.enqueuer)}},100)}async _buildLocalValue(e,t=e.name,n=e){return this._localValue={name:t,size:n.size,type:e.type,lastModified:Ut.parseDate(e.lastModified).toISOString(),content:await this._blobToBase64(n)}}_canPick(e){return"showDirectoryPicker"in e&&(()=>{try{return e.self===e.top}catch{return!1}})()}_tryPickDirectory(){this._canPick(window)&&window.showDirectoryPicker({mode:"read"}).then(e=>{this.changeHandler(new Tg(e))})}_tryPickFiles(e=this.selectMode==="multiple-picker",t=this.pattern){this._canPick(window)&&window.showOpenFilePicker({multiple:e}).then(n=>{this.changeHandler(new Tg(n))})}_clickHandler(e){if(nT(e),!this.readonly)switch(this.selectMode){case"directory-picker":this._tryPickDirectory();break;case"file-picker":case"multiple-picker":this._tryPickFiles();break}}async _mimicCompute(){this.uploading=!0,Ut.isNullOrEmpty(this.value)?await Ut.idle(250):(this.percentage=0,await Ut.waitForAnimationEnd(this._tuner)),await this._tweener.run(0,100,500,0,hw.Easings.sineInOut,(e,t)=>{this.percentage=t}),this.percentage=0,this.uploading=!1}onChange(e){return new Promise(async(t,n)=>{if(tT.isInstanceOf(e,Ag)){let i=this.value=e.detail.filename;this.dispatchEvent(e),t(i)}else if(tT.isInstanceOf(e,Tg)){let i=e.detail,s,o,c;switch(this.selectMode){case"directory-picker":s=i,this._stats=await sT(s);break;case"multiple-picker":case"file-picker":c=i,c.length===1&&(i=c[0]),this._stats=await ZB(c);break;default:this._stats={directories:0,files:0,size:0};break}t(this.value=this._localValue=i);let d=this._validateAll();this.dispatchEvent(new Hh({directory:s,file:o,files:c,valid:d}))}else{let i=this._fileupload;if(i.files.length===0)this._stats={directories:0,files:0,size:0},t(this.value=null);else{let s=i.files.length;if(this._stats={directories:0,files:s,size:Array.from(i.files).reduce((o,c,d)=>o+=c.size,0)},s>1){let o=Array.from(i.files);t(this.value=this._localValue=o);let c=this._validateAll();this.dispatchEvent(new Hh({files:o,valid:c}))}else{let o=i.files[0],c=o.name,d=o;!this._validateSingleFile(o)&&!Ut.isNullOrEmpty(this.url)?t(this.value=await this._buildLocalValue(o)):(/\.(jpe?g|png)$/i.test(c)&&this.maxImageWidth>0&&this.maxImageHeight>0&&(d=await Ut.Images.resize(d,this.maxImageWidth,this.maxImageHeight,{quality:.8})),await this._buildLocalValue(o,c,d),Ut.isNullOrEmpty(this.url)?(await this._mimicCompute(),t(this.value=this._localValue)):(this._upload(d,i.value),t(this.value))),this.dispatchEvent(new Hh({valid:!this.invalidFile,file:o}))}}}})}_fetch(e){return fetch(this.url,{method:"POST",credentials:this.fetchCredentials,headers:Ut.extend({Accept:"application/json","Content-Type":"application/json"},this.fetchHeaders||{}),body:JSON.stringify(e)})}async _undo(e){e.preventDefault(),e.stopPropagation();var t=this,n=t._fields,i=t._fileupload;clearInterval(n.enqueuer);var s={action:"undo",uid:n.uid};try{var o=await t._fetch(s);return o.ok&&(n.undone=!0,t.size=0,t._tweenPercentage(0,300)),o}catch{}finally{return i.value="",t.uploading=!1,o}}_tweenPercentage(e,t=500){let n=this.percentage;return this._tweener.run(n,e,t,0,hw.Easings.sineInOut,(i,s)=>{this.percentage=s})}_retry(e){e.preventDefault(),e.stopPropagation(),this.failed=!1,this._manage()}_clear(e){e.preventDefault(),e.stopPropagation(),this.invalidFile=!1;let t=this.inputFields[0];t.value="",/safari/i.test(navigator.userAgent)||(t.type="",t.type="file"),this.changeHandler(null)}};l([er({emit:!1,converter:tr.Json})],it.prototype,"fetchCredentials",2),l([er({emit:!1,converter:tr.String})],it.prototype,"fetchHeaders",2),l([eT("input[type=file]")],it.prototype,"_fileupload",2),l([eT(`${Xe}-tuner`)],it.prototype,"_tuner",2),l([er({converter:tr.String})],it.prototype,"undoCaption",2),l([er({converter:tr.String})],it.prototype,"retryCaption",2),l([er({converter:tr.String})],it.prototype,"clearCaption",2),l([er({emit:!1,reflectBack:!0,converter:tr.String})],it.prototype,"pattern",2),l([er({emit:!1,reflectBack:!0,converter:tr.String})],it.prototype,"url",2),l([er({emit:!1,reflectBack:!0,converter:tr.Number})],it.prototype,"maxImageWidth",2),l([er({emit:!1,reflectBack:!0,converter:tr.Number})],it.prototype,"parallelism",2),l([er({emit:!1,reflectBack:!0,converter:tr.Number})],it.prototype,"chunkSize",2),l([er({emit:!1,reflectBack:!0,converter:tr.Number})],it.prototype,"maxImageHeight",2),l([er({emit:!1,reflectBack:!0,converter:tr.Number})],it.prototype,"maxSize",2),l([er({reflectBack:!0,converter:tr.String})],it.prototype,"selectMode",2),l([er({converter:tr.Boolean})],it.prototype,"uploading",2),l([er({converter:tr.Number})],it.prototype,"size",2),l([er({converter:tr.Number})],it.prototype,"percentage",2),l([er({converter:tr.Boolean})],it.prototype,"complete",2),l([er({converter:tr.Boolean})],it.prototype,"failed",2),l([er({converter:tr.Boolean})],it.prototype,"invalidFile",2),it=l([qB({tagName:Xe+"-upload",shadow:KB.USE_SHADOW_ROOT,template:`<${Xe}-button on-click=":host._dispatchDownload($event)" class="${tp}-upload ${tp}-viewfinder flat" css-class="{{ {'upload-chosen': !$pacem.isNullOrEmpty(:host.value) && !:host.uploading, 'upload-error': ${JB}, 'upload-readonly': :host.readonly } }}">
|
|
362
|
+
|
|
363
|
+
<${Xe}-panel class="upload-button" hide="{{ (:host.uploading || :host.failed) && !$pacem.isNullOrEmpty(:host.url) }}">
|
|
364
|
+
<${Xe}-button tooltip="{{ :host.readonly ? :host.viewValue : 'upload' }}" class="button-circle pos-relative overflow-hidden"
|
|
365
|
+
icon-glyph="{{ :host._getMimeIcon(:host.value, :host.uploading, :host.selectMode) }}"
|
|
366
|
+
on-click=":host._clickHandler($event)"
|
|
367
|
+
on-mouseover="$this.iconGlyph = :host._getMimeIcon(:host.readonly ? :host.value : '', :host.uploading, :host.selectMode)"
|
|
368
|
+
on-mouseout="$this.iconGlyph = :host._getMimeIcon(:host.value, :host.uploading, :host.selectMode)"
|
|
369
|
+
css-class="{{ {'${tp}-anim anim-rotate': :host.uploading, 'button-error': :host.invalidFile, 'button-primary': $pacem.isNullOrEmpty(:host.value) && !:host.invalidFile, 'button-success': !Pacem.Utils.isNullOrEmpty(:host.value) && !:host.invalidFile } }}">
|
|
370
|
+
<input type="file" class="${tp}-transparent ${tp}-clickable pos-absolute absolute-left absolute-right absolute-top absolute-bottom" />
|
|
371
|
+
</${Xe}-button>
|
|
372
|
+
</${Xe}-panel>
|
|
373
|
+
<${Xe}-panel class="upload-button" hide="{{ !:host.failed }}">
|
|
374
|
+
<${Xe}-button class="button-circle button-flat" icon-glyph="refresh"
|
|
375
|
+
tooltip="{{ :host.retryCaption }}" on-click=":host._retry($event)"><${Xe}-text text="{{ :host.retryCaption }}"></${Xe}-text></${Xe}-button>
|
|
376
|
+
</${Xe}-panel>
|
|
377
|
+
<${Xe}-panel class="upload-button" hide="{{ !:host.uploading || $pacem.isNullOrEmpty(:host.url) }}">
|
|
378
|
+
<${Xe}-button class="button-circle button-flat" icon-glyph="clear" tooltip="{{ :host.undoCaption }}"
|
|
379
|
+
on-click=":host._undo($event)"><${Xe}-text text="{{ :host.undoCaption }}"></${Xe}-text></${Xe}-button>
|
|
380
|
+
</${Xe}-panel>
|
|
381
|
+
|
|
382
|
+
<${Xe}-span tooltip="{{ :host.viewValue }}"
|
|
383
|
+
hide="{{ $pacem.isNullOrEmpty(:host.value) || :host.uploading }}" class="upload-data readonly text-reset display-block ${tp}-anim text-truncate text-left ${tp}-pad pad-right-3" text="{{ :host.viewValue }}"></${Xe}-span>
|
|
384
|
+
|
|
385
|
+
<${Xe}-panel class="upload-progress hit-none" hide="{{ :host.readonly || (!$pacem.isNullOrEmpty(:host.value) && !:host.uploading) }}">
|
|
386
|
+
<${Xe}-tuner value="{{ :host.percentage }}" css-class="{{ {'tuner-success': !:host.invalidFile, 'tuner-error': :host.invalidFile} }}" interactive="false"></${Xe}-tuner>
|
|
387
|
+
</${Xe}-panel>
|
|
388
|
+
|
|
389
|
+
<${Xe}-button class="button-circle button-flat clear-button" icon-glyph="clear" hide="{{ $pacem.isNullOrEmpty(:host.value) || :host.uploading }}" tooltip="{{ :host.clearCaption }}" on-click=":host._clear($event)"></${Xe}-button>
|
|
390
|
+
|
|
391
|
+
</${Xe}-button>`})],it);import{P as QB,CustomElement as eV,Defaults as tV,ViewChild as rV}from"@pacem/pacem-core";var Bh=class extends dt{constructor(){super()}toggleReadonlyView(r){}get inputFields(){return[this.input]}};l([rV("input[type=hidden]")],Bh.prototype,"input",2),Bh=l([eV({tagName:QB+"-input-hidden",template:'<input type="hidden" />',shadow:tV.USE_SHADOW_ROOT})],Bh);import{P as ae,PCSS as xn,CustomElement as oT,Watch as mr,Defaults as lT,ViewChild as To,CustomTypedEvent as lV,Components as cV,CustomEventUtils as dV,PropertyConverters as nn,PropertyChangeEventName as Og,Utils as Br,Debounce as pV,avoidHandler as uV}from"@pacem/pacem-core";import{Components as rp}from"@pacem/pacem-ui";import{P as Ve,PCSS as Vh,CustomElement as nV,Watch as Uh,Defaults as iV,ViewChild as No,CustomEventUtils as sV,PropertyConverters as Dg,Utils as bi,CustomUIEvent as aV,avoidHandler as Rg,Logging as oV}from"@pacem/pacem-core";var aT=bi.getUserMediaFunctions(),fw=(t=>(t.Start="start",t.Taking="taking",t.Confirm="confirm",t))(fw||{}),u_=class extends aV{constructor(r){super("confirmsnapshot",{buffer:r})}},zt=class extends ge{constructor(){super(...arguments);this._resizeHandler=e=>{this._renderValue()};this.step="start";this._canUseWebcam=aT.length>0;this._countdown=0;this._webcamInitialized=!1;this._grabberChangeHandler=e=>{let t=this._grabber;t.files.length>0&&bi.blobToDataURL(t.files[0]).then(n=>{bi.loadImage(n).then(i=>{this._shutter(i)})})};this._snapshooterClickHandler=e=>{Rg(e),this.step="taking"};this._pickerClickHandler=e=>{Rg(e),this._grabber.click()};this._takerClickHandler=e=>{Rg(e),this._countdown=0,this._shutter()};this._timerClickHandler=e=>{Rg(e),this._countdown=3,this._shutter()};this._confirmerClickHandler=e=>{Rg(e),this.changeHandler(new u_(this._buffer))}}get inputFields(){return[]}toggleReadonlyView(e){}onChange(e){return new Promise((t,n)=>{sV.isInstanceOf(e,u_)?(t(this.value=e.detail.buffer),this.step="start"):t(this.value)})}acceptValue(e){this._renderValue(e)}getViewValue(e){return e}convertValueAttributeToProperty(e){return Dg.String.convert(e,this)}get _getUserMedia(){return this._canUseWebcam&&aT[0]}propertyChangedCallback(e,t,n,i){switch(super.propertyChangedCallback(e,t,n,i),e){case"step":switch(n){case"start":this._buffer=null;let s=this._grabber;s.value="",/safari/i.test(navigator.userAgent)||(s.type="",s.type="file");break;case"taking":this._ensureWebcamRunning();break}break;case"_buffer":this._renderValue(n||this.value);break;case"width":case"height":this._syncSize();break}}viewActivatedCallback(){super.viewActivatedCallback(),this._syncSize(),this._picker.addEventListener("click",this._pickerClickHandler,!1),this._snapshooter.addEventListener("click",this._snapshooterClickHandler,!1),this._taker.addEventListener("click",this._takerClickHandler,!1),this._timer.addEventListener("click",this._timerClickHandler,!1),this._confirmer.addEventListener("click",this._confirmerClickHandler,!1),this._grabber.addEventListener("change",this._grabberChangeHandler,!1)}disconnectedCallback(){this.isReady&&(this._picker.removeEventListener("click",this._pickerClickHandler,!1),this._snapshooter.removeEventListener("click",this._snapshooterClickHandler,!1),this._taker.removeEventListener("click",this._takerClickHandler,!1),this._timer.removeEventListener("click",this._timerClickHandler,!1),this._confirmer.removeEventListener("click",this._confirmerClickHandler,!1),this._grabber.removeEventListener("change",this._grabberChangeHandler,!1)),super.disconnectedCallback()}_syncSize(){let e=this._stage,t=this._player;!bi.isNull(e)&&!bi.isNull(t)&&(e.style.width=t.style.width=this.width&&this.width+"px"||"",e.style.height=t.style.height=this.height&&this.height+"px"||"",this._renderValue(this._buffer||this.value))}_shutter(e){let t=this,n=this._player,i=this._stage;t._confirmer.disabled=!0,bi.isNull(e)&&(e=t._player);var s,o;if(e instanceof HTMLVideoElement?(s=e.videoWidth,o=e.videoHeight):(s=e.naturalWidth,o=e.naturalHeight),t._countdown<=0){var c=document.createElement("canvas");c.width=this.width||i.clientWidth,c.height=this.height||i.clientHeight;var d=c.getContext("2d");bi.cropImageOntoCanvas(e,d,s,o);let p=t._root;p.insertBefore(c,n),c.className="snapshot-brightout",setTimeout(function(){p.removeChild(c)},1e3),t._refreshBuffer(c.toDataURL()).then(u=>{t._setToBeConfirmed(u),t._confirmer.disabled=!1})}else setTimeout(()=>{t._countdown--,this._shutter()},1e3)}_renderValue(e=this.value){let t=this._stage;if(!bi.isNull(t)){t.width=t.clientWidth,t.height=t.clientHeight;let n=t.getContext("2d");bi.isNullOrEmpty(e)?n.clearRect(0,0,t.width,t.height):bi.loadImage(e).then(i=>{bi.cropImageOntoCanvas(i,n,i.width,i.height)})}}_setToBeConfirmed(e){this.step="confirm",this._buffer=e}_refreshBuffer(e){var t=this._stage;t.width=t.clientWidth,t.height=t.clientHeight;let n;return this.quality>0&&(n=Math.min(1,Math.max(0,this.quality))),bi.cropImage(e,t.width,t.height,n)}_ensureWebcamRunning(){if(this._canUseWebcam&&!this._webcamInitialized){var e=this;e._webcamInitialized=!0,e._getUserMedia.apply(navigator,[{video:!0},function(t){var n=e._player;n.srcObject=t},function(t){e.log(oV.LogLevel.Error,(t||t.message).toString())}])}}};l([No("."+Vh+"-snapshot")],zt.prototype,"_root",2),l([No("canvas")],zt.prototype,"_stage",2),l([No("input[type=file]")],zt.prototype,"_grabber",2),l([No("video")],zt.prototype,"_player",2),l([No(Ve+"-button.button.snapshot-upload")],zt.prototype,"_picker",2),l([No(Ve+"-button.button.snapshot-camera")],zt.prototype,"_snapshooter",2),l([No(Ve+"-button.button.snapshot-take")],zt.prototype,"_taker",2),l([No(Ve+"-button.button.snapshot-timer3s")],zt.prototype,"_timer",2),l([No(Ve+"-button.button.snapshot-confirm")],zt.prototype,"_confirmer",2),l([Uh({converter:Dg.String})],zt.prototype,"step",2),l([Uh({emit:!1,converter:Dg.Number})],zt.prototype,"width",2),l([Uh({emit:!1,converter:Dg.Number})],zt.prototype,"height",2),l([Uh({emit:!1,converter:Dg.Number})],zt.prototype,"quality",2),l([Uh()],zt.prototype,"_countdown",2),l([Uh({emit:!1})],zt.prototype,"_buffer",2),zt=l([nV({tagName:Ve+"-snapshot",shadow:iV.USE_SHADOW_ROOT,template:`<${Ve}-panel class="${Vh}-snapshot"
|
|
392
|
+
css-class="{{ {
|
|
393
|
+
'snapshot-start': :host.step === 'start',
|
|
394
|
+
'snapshot-taking': :host.step === 'taking',
|
|
395
|
+
'snapshot-confirm': :host.step === 'confirm' } }}">
|
|
396
|
+
|
|
397
|
+
<${Ve}-resize target="{{ ::_stage }}" on-resize=":host._resizeHandler($event)"></${Ve}-resize>
|
|
398
|
+
|
|
399
|
+
<canvas class="${Vh}-viewfinder"></canvas>
|
|
400
|
+
|
|
401
|
+
<video autoplay="autoplay"></video>
|
|
402
|
+
|
|
403
|
+
<input type="file" accept="image/*" />
|
|
404
|
+
|
|
405
|
+
<div class="${Vh}-buttonset snapshot-step step-start">
|
|
406
|
+
<div class="buttonset-center">
|
|
407
|
+
<${Ve}-button class="button snapshot-upload" icon-glyph="upload"></${Ve}-button>
|
|
408
|
+
<${Ve}-button class="button snapshot-camera" icon-glyph="photo_camera"></${Ve}-button>
|
|
409
|
+
</div>
|
|
410
|
+
</div>
|
|
411
|
+
|
|
412
|
+
<div class="${Vh}-buttonset snapshot-step step-taking">
|
|
413
|
+
<div class="buttonset-center">
|
|
414
|
+
<${Ve}-button class="button snapshot-undo" icon-glyph="undo" on-click=":host.step = 'start'"></${Ve}-button>
|
|
415
|
+
<${Ve}-button class="button snapshot-take" icon-glyph="camera"></${Ve}-button>
|
|
416
|
+
<${Ve}-button class="button snapshot-timer3s" icon-glyph="timer_3"></${Ve}-button>
|
|
417
|
+
</div>
|
|
418
|
+
</div>
|
|
419
|
+
|
|
420
|
+
<div class="${Vh}-buttonset snapshot-step step-confirm">
|
|
421
|
+
<div class="buttonset-center">
|
|
422
|
+
<${Ve}-button class="button snapshot-undo" icon-glyph="undo" on-click=":host.step = 'start'"></${Ve}-button>
|
|
423
|
+
<${Ve}-button class="button snapshot-confirm" icon-glyph="done"></${Ve}-button>
|
|
424
|
+
</div>
|
|
425
|
+
</div>
|
|
426
|
+
|
|
427
|
+
<${Ve}-span class="snapshot-countdown" text="{{ :host._countdown }}" hide="{{ :host.step !== 'taking' || !(:host._countdown > 0) }}"></${Ve}-span>
|
|
428
|
+
<${Ve}-span hide="{{ :host._canUseWebcam }}"><${Ve}-content></${Ve}-content></${Ve}-span>
|
|
429
|
+
|
|
430
|
+
</${Ve}-panel>`})],zt);var gw=class{},h_="imagefetchrequest",Pg=class extends lV{constructor(r){super(h_,r,{bubbles:!0})}},Nt=class extends cV.PacemElement{constructor(){super(...arguments);this._index=0;this.hint=""}_uploaderPropertyChangedCallback(e){let t=e.detail.currentValue;switch(e.detail.propertyName){case"percentage":this._progressbar.percentage=t*100;break;case"uploading":t&&this._done(!0);break}}_thumbnailUploaderPropertyChangedCallback(e){let t=e.detail.currentValue;switch(e.detail.propertyName){case"percentage":this._progressbar.percentage=t*100;break;case"uploading":this._done(t);break}}_uploaderFileUploadCallback(e){let t=this._uploader,n=this._thumbUploader,i=n.maxImageWidth,s=n.maxImageHeight;if(i>0&&s>0){var o=t.blob;let c=e.detail.uid;Br.resizeImage(o,i,s).then(d=>{if(d!=o){n.upload(d,"thumbnail.jpg",c);return}else this._done(!1)})}else this._done(!1)}_done(e){e||this._imagefetch(0),this._repeater.hidden=e,this._progressbar.hidden=!e}_snapshotPropertyChangedCallback(e){if(e.detail.propertyName==="value"){let t=Br.dataURLToBlob(e.detail.currentValue);this._uploader.upload(t,"snapshot.jpg")}}reset(){this._snapshot.step="start"}propertyChangedCallback(e,t,n,i){switch(super.propertyChangedCallback(e,t,n,i),e){case"imageSet":let s=n||{skip:0,set:[]};Br.isNullOrEmpty(this._images)||s.skip===0?this._images=s.set:Br.isNull(this._images)||Array.prototype.splice.apply(this._images,[s.skip,this._images.length-s.skip].concat(s.set)),this._fetching=!1;break;case"hint":i||this._imagefetch(0);break}}_imagefetchSuddenly(e){this._fetching=!0,this._imagefetch(e)}_imagefetch(e){e>=0||(e=this._images&&this._images.length||0),this.dispatchEvent(new Pg({hint:this.hint,skip:e,take:18}))}};l([mr({converter:nn.String})],Nt.prototype,"uploadUrl",2),l([mr({converter:nn.String})],Nt.prototype,"hint",2),l([mr()],Nt.prototype,"imageSet",2),l([mr({converter:nn.String})],Nt.prototype,"value",2),l([mr({converter:nn.Number})],Nt.prototype,"maxWidth",2),l([mr({converter:nn.Number})],Nt.prototype,"maxHeight",2),l([mr({converter:nn.Number})],Nt.prototype,"maxThumbnailWidth",2),l([mr({converter:nn.Number})],Nt.prototype,"maxThumbnailHeight",2),l([mr({converter:nn.Boolean})],Nt.prototype,"allowSnapshot",2),l([mr()],Nt.prototype,"_fetching",2),l([mr()],Nt.prototype,"_images",2),l([To(ae+"-repeater")],Nt.prototype,"_repeater",2),l([To(ae+"-upload[main]")],Nt.prototype,"_uploader",2),l([To(ae+"-upload[thumb]")],Nt.prototype,"_thumbUploader",2),l([To(ae+"-snapshot")],Nt.prototype,"_snapshot",2),l([To(ae+"-progressbar")],Nt.prototype,"_progressbar",2),l([pV(500)],Nt.prototype,"_imagefetch",1),Nt=l([oT({tagName:ae+"-edit-image",shadow:lT.USE_SHADOW_ROOT,template:`<${ae}-panel class="${xn}-edit-image"
|
|
431
|
+
css-class="{{ {'${xn}-snapshot': ::_snapshot.step != 'start', '${xn}-uploading': ::_uploader.uploading, '${xn}-upload-enabled': !Pacem.Utils.isNullOrEmpty(:host.uploadUrl), '${xn}-snapshot-enabled': !Pacem.Utils.isNullOrEmpty(:host.uploadUrl) && :host.allowSnapshot} }}">
|
|
432
|
+
<div>
|
|
433
|
+
<${ae}-input-search value="{{ :host.hint, twoway }}"></${ae}-input-search>
|
|
434
|
+
<${ae}-upload main pattern=".+.(jpe?g|png|svg|ico)$" url="{{ :host.uploadUrl }}"
|
|
435
|
+
max-image-width="{{ :host.maxWidth }}" max-image-height="{{ :host.maxHeight }}"
|
|
436
|
+
on-${p_}=":host._uploaderFileUploadCallback($event)"
|
|
437
|
+
on-${Og}=":host._uploaderPropertyChangedCallback($event)" hide="{{ Pacem.Utils.isNullOrEmpty(:host.uploadUrl) || ::_thumbUploader.uploading }}"></${ae}-upload>
|
|
438
|
+
<${ae}-upload thumb pattern=".+.(jpe?g|png|svg|ico)$" url="{{ :host.uploadUrl }}" hide="{{ !::_thumbUploader.uploading }}"
|
|
439
|
+
max-image-width="{{ :host.maxThumbnailWidth }}" max-image-height="{{ :host.maxThumbnailHeight }}"
|
|
440
|
+
on-${Og}=":host._thumbnailUploaderPropertyChangedCallback($event)"></${ae}-upload>
|
|
441
|
+
<${ae}-button class="${xn}-snapshot" on-click="Pacem.avoidHandler($event); ::_snapshot.step = 'taking'" hide="{{ Pacem.Utils.isNullOrEmpty(:host.uploadUrl) || !:host.allowSnapshot }}"></${ae}-button>
|
|
442
|
+
<${ae}-infinite-scroller container="{{ ::_repeater }}" on-fetchmore=":host._imagefetchSuddenly()" disabled="{{ :host._fetching || :host.disabled || :host._images.length >= :host.imageSet.total }}"></${ae}-infinite-scroller>
|
|
443
|
+
<${ae}-repeater datasource="{{ :host._images }}">
|
|
444
|
+
<template>
|
|
445
|
+
<${ae}-img css-class="{{ {'${xn}-selected': ^item.src === :host.value } }}" on-click=":host.value = ^item.src" src="{{ ^item.thumb }}" adapt="contain"></${ae}-img>
|
|
446
|
+
</template>
|
|
447
|
+
</${ae}-repeater>
|
|
448
|
+
<${ae}-progressbar class="progressbar-smaller progressbar-accent" caption="{{ ::_thumbUploader.uploading ? 'thumbnail...' : 'uploading...' }}"></${ae}-progressbar>
|
|
449
|
+
</div>
|
|
450
|
+
<div>
|
|
451
|
+
<${ae}-snapshot hide="{{ !:host.allowSnapshot }}" on-${Og}=":host._snapshotPropertyChangedCallback($event)"></${ae}-snapshot>
|
|
452
|
+
</div>
|
|
453
|
+
</${ae}-panel>`})],Nt);var Hr=class extends ge{constructor(){super(...arguments);this._broadcastFetchRequestEventName=e=>{this.dispatchEvent(new Pg(e.detail))};this._innerValueChangedHandler=e=>{e.detail.propertyName==="value"&&!Br.isNull(this._dialog)&&(this._dialog.state=e.detail.currentValue)}}convertValueAttributeToProperty(e){return e}getViewValue(e){return e}get inputFields(){return[]}_clear(e){this.changeHandler(e)}onChange(e){let t=this.value;return dV.isInstanceOf(e,rp.UI.DialogResultEvent)&&e.detail.button===rp.UI.DialogButton.Ok?t=this.value=e.detail.state:e.target===this._input?t=this.value=this._input.value:e.target===this._clearBtn&&(t=this.value=void 0),Br.fromResult(t)}toggleReadonlyView(e){this._input.hidden=this._editBtn.hide=this._clearBtn.hide=e}_addDialog(){var e=document.createElement(ae+"-dialog");return e.buttons=rp.UI.DialogButtons.OkCancel,e.addEventListener(rp.UI.DialogResultEventName,this.changeHandler,!1),e.appendChild(this._addEditImage()),document.body.appendChild(e),this._dialog=e}_removeDialog(){this._removeEditImage(),Br.isNull(this._dialog)||(this._dialog.removeEventListener(rp.UI.DialogResultEventName,this.changeHandler,!1),this._dialog.remove())}_addEditImage(){var e=document.createElement(ae+"-edit-image");return e.disabled=!0,e.addEventListener(Og,this._innerValueChangedHandler,!1),e.addEventListener(h_,this._broadcastFetchRequestEventName,!1),e.uploadUrl=this.uploadUrl,e.allowSnapshot=this.allowSnapshot,e.maxWidth=this.maxWidth,e.maxHeight=this.maxHeight,e.maxThumbnailHeight=this.maxThumbnailHeight,e.maxThumbnailWidth=this.maxThumbnailWidth,this._editImage=e}_removeEditImage(){Br.isNull(this._editImage)||(this._editImage.removeEventListener(Og,this._innerValueChangedHandler,!1),this._editImage.removeEventListener(h_,this._broadcastFetchRequestEventName,!1))}connectedCallback(){super.connectedCallback(),this._addDialog()}disconnectedCallback(){this._removeDialog(),super.disconnectedCallback()}propertyChangedCallback(e,t,n,i){switch(super.propertyChangedCallback(e,t,n,i),e){case"uploadUrl":Br.isNull(this._editImage)||(this._editImage.uploadUrl=n);break;case"allowSnapshot":Br.isNull(this._editImage)||(this._editImage.allowSnapshot=n);break;case"imageSet":Br.isNull(this._editImage)||(this._editImage.imageSet=n);break;case"maxThumbnailHeight":Br.isNull(this._editImage)||(this._editImage.maxThumbnailHeight=n);break;case"maxThumbnailWidth":Br.isNull(this._editImage)||(this._editImage.maxThumbnailWidth=n);break;case"maxHeight":Br.isNull(this._editImage)||(this._editImage.maxHeight=n);break;case"maxWidth":Br.isNull(this._editImage)||(this._editImage.maxWidth=n);break}}acceptValue(e){Br.isNull(this._editImage)||(this._editImage.value=e)}_update(e){this._image.src=e}_retrieve(){return this.value}_edit(e){uV(e);var t=this._editImage,n=this.value;t.disabled=!1,t.reset(),t.value=n,this._dialog.open(n).then(i=>{switch(i.button){case rp.UI.DialogButton.Cancel:this._update(this.value);break;case rp.UI.DialogButton.Ok:this._update(i.state);break}this._editImage.disabled=!0})}};l([To(ae+"-img")],Hr.prototype,"_image",2),l([To(ae+"-button."+xn+"-edit")],Hr.prototype,"_editBtn",2),l([To(ae+"-button."+xn+"-clear")],Hr.prototype,"_clearBtn",2),l([To(ae+"-input-url")],Hr.prototype,"_input",2),l([mr({emit:!1,converter:nn.String})],Hr.prototype,"uploadUrl",2),l([mr({emit:!1,converter:nn.Json})],Hr.prototype,"imageSet",2),l([mr({emit:!1,converter:nn.Number})],Hr.prototype,"maxWidth",2),l([mr({emit:!1,converter:nn.Number})],Hr.prototype,"maxHeight",2),l([mr({emit:!1,converter:nn.Number})],Hr.prototype,"maxThumbnailWidth",2),l([mr({emit:!1,converter:nn.Number})],Hr.prototype,"maxThumbnailHeight",2),l([mr({emit:!1,converter:nn.Boolean})],Hr.prototype,"allowSnapshot",2),Hr=l([oT({tagName:ae+"-input-image",shadow:lT.USE_SHADOW_ROOT,template:`<div class="${xn}-input-image"><${ae}-img src="{{ :host.value }}" adapt="contain"></${ae}-img><div class="${xn}-input-image-dashboard">
|
|
454
|
+
<${ae}-button on-click=":host._edit($event)" hide="{{ :host.disabled }}" class="${xn}-edit">Edit</${ae}-button>
|
|
455
|
+
<${ae}-button on-click=":host._clear($event)" hide="{{ :host.disabled }}" class="${xn}-clear">Clear</${ae}-button>
|
|
456
|
+
</div><${ae}-input-url placeholder="{{ :host.placeholder }}" on-change=":host.changeHandler($event)" value="{{ :host.value }}"></${ae}-input-url>
|
|
457
|
+
|
|
458
|
+
<${ae}-panel hide="{{ Pacem.Utils.isNullOrEmpty(:host.value) }}">
|
|
459
|
+
<dl class="${xn}-input-image-preview">
|
|
460
|
+
<dt>dimensions:</dt><dd><${ae}-text text="{{ ::_image.size.width +'x'+ ::_image.size.height }}"></${ae}-text></dd>
|
|
461
|
+
<dt>size:</dt><dd><${ae}-text text="{{ $pacem.size(::_image.size.weight) }}"></${ae}-text></dd>
|
|
462
|
+
</dl></${ae}-panel>
|
|
463
|
+
|
|
464
|
+
</div>`})],Hr);import{P as vw,PCSS as m_,CustomElement as hV,Watch as mV,Defaults as fV,ViewChild as cT,PropertyConverters as gV,Utils as bw}from"@pacem/pacem-core";var dc=class extends cc{toggleReadonlyView(r){this._span.hidden=!r,this._input.hidden=r}get inputFields(){return[this._input]}getViewValue(r){return this.value!=null?this._format(this.value):void 0}_format(r=this.value){let e=this.format;return bw.isNullOrEmpty(e)?r.toString():new Intl.NumberFormat(bw.lang(this),e).format(r)}getValue(r){let e=this.inputField.valueAsNumber||parseFloat(this.inputField.value);return isNaN(e)?void 0:e}viewActivatedCallback(){super.viewActivatedCallback();var r={capture:!1,passive:!1};this._input.addEventListener("wheel",this.emitHandler,r)}disconnectedCallback(){if(!bw.isNull(this._input)){var r={capture:!1,passive:!1};this._input.removeEventListener("wheel",this.emitHandler,r)}super.disconnectedCallback()}};l([cT("input[type=number]")],dc.prototype,"_input",2),l([cT(`span.${m_}-readonly`)],dc.prototype,"_span",2),l([mV({emit:!1,converter:gV.Json})],dc.prototype,"format",2),dc=l([hV({tagName:vw+"-input-number",template:`<input type="number" class="${m_}-input ${m_}-viewfinder" /><span class="${m_}-readonly"><${vw}-text text="{{ :host.viewValue }}"></${vw}-text></span>`,shadow:fV.USE_SHADOW_ROOT})],dc);import{P as yw,PCSS as pc,CustomElement as vV,avoidHandler as bV,Defaults as yV,ViewChild as _w,Utils as xw}from"@pacem/pacem-core";var uc=class extends dt{constructor(){super();this._togglerMousedownHandler=e=>{e.button==0&&(bV(e),this.toggleVisibility())}}get inputFields(){return[this._input]}viewActivatedCallback(){super.viewActivatedCallback();let e=this.id??"_"+xw.uniqueCode(),t=this._input.id=e+"_ctrl";this._toggler.setAttribute("aria-controls",t),this._toggler.setAttribute("role","button"),this._syncToggler(),this._toggler.addEventListener("mousedown",this._togglerMousedownHandler,!1)}disconnectedCallback(){xw.isNull(this._toggler)||this._toggler.removeEventListener("mousedown",this._togglerMousedownHandler,!1)}toggleVisibility(){let e=this._input.type;this._input.type=e==="password"?"text":"password",this._syncToggler()}_syncToggler(){let e=this._input.type==="password";this._toggler.innerText=e?"visibility_off":"visibility",this._toggler.setAttribute("aria-expanded",(!e).toString())}toggleReadonlyView(e){this._input.hidden=this._toggler.hidden=e,this._span.hidden=!e}getViewValue(e){return xw.leftPad("",Math.floor(8+3*Math.random()),"\u2022")}};l([_w("input[type=password]")],uc.prototype,"_input",2),l([_w(`span.${pc}-readonly`)],uc.prototype,"_span",2),l([_w(`i.${pc}-icon.${pc}-clickable`)],uc.prototype,"_toggler",2),uc=l([vV({tagName:yw+"-input-password",template:`<input type="password" class="${pc}-input ${pc}-viewfinder" /><i class="${pc}-icon ${pc}-clickable"></i>
|
|
465
|
+
${en}<span class="${pc}-readonly"><${yw}-text text="{{ :host.viewValue }}"></${yw}-text></span>`,shadow:yV.USE_SHADOW_ROOT})],uc);import{P as _V,PCSS as xV,CustomElement as CV,Defaults as EV,ViewChild as wV}from"@pacem/pacem-core";var zh=class extends dt{constructor(){super()}get inputFields(){return[this.input]}toggleReadonlyView(r){}};l([wV("input[type=search]")],zh.prototype,"input",2),zh=l([CV({tagName:_V+"-input-search",template:'<input type="search" class="'+xV+'-input" />',shadow:EV.USE_SHADOW_ROOT})],zh);import{P as Gh,PCSS as dT,CustomElement as kV,Defaults as MV,ViewChild as pT}from"@pacem/pacem-core";var np=class extends dt{constructor(){super()}toggleReadonlyView(r){this.input.hidden=r,this.anchor.hidden=!r}get inputFields(){return[this.input]}};l([pT("input[type=tel]")],np.prototype,"input",2),l([pT(Gh+"-a")],np.prototype,"anchor",2),np=l([kV({tagName:Gh+"-input-tel",template:`<input type="tel" class="${dT}-input" /><${Gh}-a class="${dT}-readonly" disabled="{{ $pacem.isNullOrEmpty(:host.value) }}" href="{{ 'tel:'+ :host.value }}"><${Gh}-text text="{{ :host.viewValue }}"></${Gh}-text></${Gh}-a>`,shadow:MV.USE_SHADOW_ROOT})],np);import{P as Cw,PCSS as Ew,CustomElement as SV,Defaults as LV,ViewChild as uT}from"@pacem/pacem-core";var ip=class extends dt{constructor(){super()}toggleReadonlyView(r){this._span.hidden=!r,this._input.hidden=r}get inputFields(){return[this._input]}};l([uT("input[type=text]")],ip.prototype,"_input",2),l([uT("span."+Ew+"-readonly")],ip.prototype,"_span",2),ip=l([SV({tagName:Cw+"-input-text",template:`<input type="text" class="${Ew}-input" />${en}<span class="${Ew}-readonly"><${Cw}-text text="{{ :host.viewValue }}"></${Cw}-text></span>`,shadow:LV.USE_SHADOW_ROOT})],ip);import{P as Fh,PCSS as hT,CustomElement as NV,Defaults as TV,ViewChild as mT}from"@pacem/pacem-core";var sp=class extends dt{constructor(){super()}toggleReadonlyView(r){this.input.hidden=r,this.anchor.hidden=!r}get inputFields(){return[this.input]}};l([mT("input[type=url]")],sp.prototype,"input",2),l([mT(Fh+"-a")],sp.prototype,"anchor",2),sp=l([NV({tagName:Fh+"-input-url",template:`<input type="url" class="${hT}-input" />${en}<${Fh}-a class="${hT}-readonly" disabled="{{ $pacem.isNullOrEmpty(:host.value) }}" href="{{ :host.value }}" target="_blank"><${Fh}-text text="{{ :host.viewValue }}"></${Fh}-text></${Fh}-a>`,shadow:TV.USE_SHADOW_ROOT})],sp);import{P as we,PCSS as yi,ViewChild as Ao,CustomElement as AV,Watch as ww,Utils as ap,PropertyConverters as DV,Defaults as RV}from"@pacem/pacem-core";import{Components as OV}from"@pacem/pacem-maps";var PV="",IV="",$V="https://nominatim.openstreetmap.org/reverse",Mr=class extends ge{convertValueAttributeToProperty(r){let e=/^\s*([+-]?\d+\.?\d+)[,\s]\s*([+-]?\d+\.?\d+)\s*$/.exec(r);if(e&&e.length===3)return{lat:parseFloat(e[1]),lng:parseFloat(e[2])};throw`Invalid coordinates format for "${r}"`}compareValuePropertyValues(r,e){return r&&typeof r.lat=="number"&&typeof r.lng=="number"&&e&&typeof e.lat=="number"&&typeof e.lng=="number"?r.lat===e.lat&&r.lng===e.lng:!1}getViewValue(r){return this._getViewValue(r)}_getViewValue(r,e=8){return r&&typeof r.lat=="number"&&typeof r.lng=="number"&&r.lat.toFixed(e)+","+r.lng.toFixed(e)||""}get inputFields(){return[this._latInput,this._lngInput]}toggleReadonlyView(r){this._inputContainer.hidden=r}acceptValue(r){let e=this._ensureValue(r);this._lat=e.lat,this._lng=e.lng}_ensureValue(r){return r&&typeof r.lat=="number"&&typeof r.lng=="number"?r:OV.Maps.MapConsts.DEFAULT_COORDS}onChange(r){if(r&&r.type==="dragend"){var e=r;this._lat=e.detail.position.lat,this._lng=e.detail.position.lng}let t=this._lat,n=this._lng;return ap.isNull(t)||ap.isNull(n)?ap.fromResult(this.value):ap.fromResult(this.value={lat:t,lng:n})}propertyChangedCallback(r,e,t,n){if(super.propertyChangedCallback(r,e,t,n),r==="options"&&!n){let i=ap.clone(t||{provider:"osm"});this._synchronizeOptions(i)}}viewActivatedCallback(){super.viewActivatedCallback(),this._synchronizeOptions()}_synchronizeOptions(r=this.options||{provider:"osm"}){let e=this._marker,t=this._map;switch(e.icon=r.icon,r&&r.provider){case"azure":this._azureAdapter.subscriptionKey=r.apiKey,t.adapter=this._azureAdapter;break;case"google":case"gmaps":this._googleAdapter.apiKey=r.apiKey,t.adapter=this._googleAdapter;break;default:ap.isNullOrEmpty(r.attribution)||(this._leafletAdapter.attribution=r.attribution),ap.isNullOrEmpty(r.tiles)||(this._leafletAdapter.tiles=r.tiles),t.adapter=this._leafletAdapter;break}delete r.provider,delete r.icon,delete r.apiKey,delete r.attribution,delete r.tiles;for(let n in r)n in t&&(t[n]=r[n])}};l([Ao(we+"-map-adapter-leaflet")],Mr.prototype,"_leafletAdapter",2),l([Ao(we+"-map-adapter-azure")],Mr.prototype,"_azureAdapter",2),l([Ao(we+"-map-adapter-google")],Mr.prototype,"_googleAdapter",2),l([Ao(we+"-map")],Mr.prototype,"_map",2),l([Ao(we+"-map-marker")],Mr.prototype,"_marker",2),l([Ao(we+"-input-number:nth-child(1)")],Mr.prototype,"_latInput",2),l([Ao(we+"-input-number:nth-child(2)")],Mr.prototype,"_lngInput",2),l([Ao(`.${yi}-latlng-fields`)],Mr.prototype,"_inputContainer",2),l([Ao(we+"-fetch")],Mr.prototype,"_fetcher",2),l([ww({converter:DV.Json,emit:!1})],Mr.prototype,"options",2),l([ww()],Mr.prototype,"_lat",2),l([ww()],Mr.prototype,"_lng",2),Mr=l([AV({tagName:we+"-latlng",shadow:RV.USE_SHADOW_ROOT,template:`<div class="${yi}-latlng">
|
|
466
|
+
<div class="${yi}-latlng-fields ${yi}-viewfinder">
|
|
467
|
+
<${we}-input-number class="${yi}-lat" value="{{ :host._lat, twoway }}" min="-90" max="90" step="{{ 'any' }}"></${we}-input-number>
|
|
468
|
+
<${we}-input-number class="${yi}-lng" value="{{ :host._lng, twoway }}" min="-180" max="180" step="{{ 'any' }}"></${we}-input-number>
|
|
469
|
+
</div>
|
|
470
|
+
<${we}-panel hide="{{ Pacem.Utils.isNull(:host.value) || :host.readonly }}">
|
|
471
|
+
<dl class="${yi}-latlng-preview">
|
|
472
|
+
<dt>decimals:</dt><dd><${we}-text text="{{ :host._getViewValue(:host.value, 12) }}"></${we}-text></dd>
|
|
473
|
+
<dt>address:</dt><dd><${we}-text text="{{ ::_fetcher.result.display_name || '?' }}"></${we}-text></dd>
|
|
474
|
+
<dt>degrees:</dt><dd><${we}-span css-class="{{ {'${yi}-lat-north': :host._lat > 0, '${yi}-lat-south': :host._lat < 0} }}" content="{{ $pacem.decToDeg(Math.abs(:host._lat)) }}"></${we}-span>,
|
|
475
|
+
<${we}-span css-class="{{ {'${yi}-lng-east': :host._lng > 0, '${yi}-lng-west': :host._lng < 0} }}" content="{{ $pacem.decToDeg(Math.abs(:host._lng)) }}"></${we}-span></dd>
|
|
476
|
+
</dl>
|
|
477
|
+
</${we}-panel>
|
|
478
|
+
<${we}-span class="${yi}-readonly" hide="{{ !:host.readonly }}" content="{{ :host.viewValue + ($pacem.isNullOrEmpty(::_fetcher.result.display_name) ? '' : (' <small>'+ ::_fetcher.result.display_name +'</small>')) }}"></${we}-span>
|
|
479
|
+
|
|
480
|
+
<${we}-map-adapter-leaflet></${we}-map-adapter-leaflet>
|
|
481
|
+
<${we}-map-adapter-azure></${we}-map-adapter-azure>
|
|
482
|
+
<${we}-map-adapter-google></${we}-map-adapter-google>
|
|
483
|
+
|
|
484
|
+
<${we}-map adapter="{{ ::_adapter }}">
|
|
485
|
+
<${we}-map-marker position="{{ :host._ensureValue(:host.value) }}" on-dragend=":host.changeHandler($event)" draggable="{{ !:host.readonly }}"></${we}-map-marker>
|
|
486
|
+
</${we}-map>
|
|
487
|
+
<${we}-fetch disabled="{{ $pacem.isNull(:host.value) }}" parameters="{{ { format: 'json', lat: :host._lat, lon: :host._lng } }}" url="${$V}"></${we}-fetch>
|
|
488
|
+
</div>`})],Mr);import{P as ds,PCSS as Ig,CustomElement as HV,Watch as fT,Utils as Do,PropertyConverters as kw,Defaults as BV}from"@pacem/pacem-core";var gT='change-policy="blur" readonly="{{ :host.readonly }}"';function vT(a){return Do.isNullOrEmpty(a&&a.name)}function bT(){return{name:"",value:""}}var op=class extends ge{constructor(){super(...arguments);this.inputFields=[];this._bag=[]}toggleReadonlyView(e){}onChange(e){return new Promise((t,n)=>{let i=this._bagToValue(this._bag);this.compareValuePropertyValues(i,this.value)?n():t(this.value=i)})}acceptValue(e){this._bag=this._valueToBag(e)}getViewValue(e){return""}compareValuePropertyValues(e,t){return Do.Json.stringify(e)===Do.Json.stringify(t)}convertValueAttributeToProperty(e){return kw.Json.convert(e)}propertyChangedCallback(e,t,n,i){super.propertyChangedCallback(e,t,n,i),e==="dictionary"&&!i&&(this.value=this._bagToValue())}_bagToValue(e=this._bag){if(!this.dictionary){let n=[];for(let i of e||[])vT(i)||n.find(s=>s.name===i.name&&s.value===i.value)||n.push(i);return n}let t={};for(let n of e||[])n.name in t||(t[n.name]=n.value);return t}_valueToBag(e=this.value){let t=[];if(!Do.isNullOrEmpty(e)&&typeof e=="object")if(this.dictionary&&!Do.isArray(e))for(let n in e)t.push({name:n,value:e[n]});else!this.dictionary&&Do.isArray(e)&&Array.prototype.splice.apply(t,[0,0].concat(e.map(n=>Do.clone(n))));return Do.isNullOrEmpty(t)?[bT()]:t}_deleteAt(e){this._bag.splice(e.detail,1),this.changeHandler(e)}_addItem(e){let t=this._bag,n=this._bag[this._bag.length-1];(Do.isEmpty(t)||!vT(n))&&t.push(bT())}};l([fT({emit:!1,converter:kw.Boolean})],op.prototype,"dictionary",2),l([fT({converter:kw.Json})],op.prototype,"_bag",2),op=l([HV({tagName:ds+"-namevalue-list",shadow:BV.USE_SHADOW_ROOT,template:`<${ds}-repeater datasource="{{ :host._bag }}" on-itemdelete=":host._deleteAt($event)">
|
|
489
|
+
<template>
|
|
490
|
+
<div class="${Ig}-fieldset ${Ig}-margin margin-bottom-1">
|
|
491
|
+
<div class="fieldset-auto">
|
|
492
|
+
<div class="${Ig}-fieldgroup">
|
|
493
|
+
<${ds}-input-text ${gT} value="{{ ^item.name, twoway }}" on-change=":host.changeHandler($event)"></${ds}-input-text>
|
|
494
|
+
<div class="fieldgroup-prepend"></div>
|
|
495
|
+
</div>
|
|
496
|
+
<div class="${Ig}-fieldgroup">
|
|
497
|
+
<${ds}-input-text ${gT} value="{{ ^item.value, twoway }}" on-change=":host.changeHandler($event)"></${ds}-input-text>
|
|
498
|
+
<div class="fieldgroup-append">
|
|
499
|
+
<${ds}-button class="${Ig}-cell cols-2 flat delete" hide="{{ :host.readonly }}" command-name="delete" command-argument="{{ ^index }}"></${ds}-button>
|
|
500
|
+
</div>
|
|
501
|
+
</div>
|
|
502
|
+
</div>
|
|
503
|
+
</div>
|
|
504
|
+
</template>
|
|
505
|
+
<${ds}-button class="flat add" hide="{{ :host.readonly }}" on-click=":host._addItem($event)"></${ds}-button>
|
|
506
|
+
</${ds}-repeater>`})],op);import{P as f_,ViewChild as VV,CustomElement as UV,Watch as zV,Utils as Mw,PropertyConverters as yT,Defaults as GV,CustomElementUtils as FV}from"@pacem/pacem-core";var lp=class extends ge{get inputFields(){return[this._select]}toggleReadonlyView(r){this._select.readonly=r}onChange(r){return Mw.fromResult(this.value=this._select.value)}acceptValue(r){this._select.value=r}getViewValue(r){return this._select.viewValue}convertValueAttributeToProperty(r){return yT.Element.convert(r)}viewActivatedCallback(){super.viewActivatedCallback(),this._databind()}propertyChangedCallback(r,e,t,n){super.propertyChangedCallback(r,e,t,n),n||r==="target"&&this._databind()}_databind(){let r=[],e=(n,i,s)=>{let o=n[i];if(typeof o=="object"&&o!=null&&!Mw.isArray(o))for(let c of Object.keys(o)){let d=s+"."+c;r.push(d),e(o,c,d)}},t=this.target;if(!Mw.isNull(t)){let n=FV.getWatchedProperties(t);for(let i of n){let s=i.name;r.push(s),e(t,s,s)}}this._select.datasource=r.sort()}};l([VV(f_+"-select")],lp.prototype,"_select",2),l([zV({converter:yT.Element})],lp.prototype,"target",2),lp=l([UV({tagName:f_+"-property-picker",shadow:GV.USE_SHADOW_ROOT,template:`<${f_}-select></${f_}-select>`})],lp);import{P as $g,PCSS as Ro,ViewChild as Sw,CustomElement as WV,Watch as _T,Utils as Wh,PropertyConverters as xT,Defaults as jV}from"@pacem/pacem-core";var aa=class extends ge{convertValueAttributeToProperty(r){return r}constructor(){super(),this._key="_"+Wh.uniqueCode()}toggleReadonlyView(r){this.span.hidden=!r,this._radio.hidden=r}get inputFields(){return[this._radio]}onChange(r){this.selected=this._radio.checked;let e=this.selected?this._radio.value:void 0;return Wh.fromResult(e)}viewActivatedCallback(){super.viewActivatedCallback(),this._radio.id=this._label.htmlFor=this._key}propertyChangedCallback(r,e,t,n){switch(super.propertyChangedCallback(r,e,t,n),r){case"name":this._radio.name=t;break;case"selected":(this._radio.checked=t)?Wh.addClass(this,Ro+"-selected"):Wh.removeClass(this,Ro+"-selected");break}}acceptValue(r){this._radio.value=Wh.isNullOrEmpty(r)?"":r}getViewValue(r){return Wh.isNull(r)?"":this.caption}};l([Sw("input[type=radio]")],aa.prototype,"_radio",2),l([Sw("label")],aa.prototype,"_label",2),l([Sw(`.${Ro}-readonly`)],aa.prototype,"span",2),l([_T({converter:xT.String})],aa.prototype,"caption",2),l([_T({converter:xT.Boolean})],aa.prototype,"selected",2),aa=l([WV({tagName:$g+"-radio",template:`<${$g}-span class="${Ro}-readonly ${Ro}-radio" text="{{ :host.caption }}"></${$g}-span><input type="radio" class="${Ro}-input" /><label class="${Ro}-label ${Ro}-radio ${Ro}-viewfinder"><${$g}-text text="{{ :host.caption }}"></${$g}-text></label>`,shadow:jV.USE_SHADOW_ROOT})],aa);import{CustomElement as YV,Defaults as XV,P as Gn,PCSS as Hg,PropertyChangeEventName as qV,Utils as CT,ViewChild as Lw}from"@pacem/pacem-core";var hc=class extends Ht{acceptValue(r){}constructor(){super(),this.key="_"+CT.uniqueCode()}get inputFields(){return[]}propertyChangedCallback(r,e,t,n){super.propertyChangedCallback(r,e,t,n),r==="disabled"&&(this._disable.model=t)}viewActivatedCallback(){super.viewActivatedCallback(),this._disable.model=this.disabled}toggleReadonlyView(r){this._repeater.hidden=r,this._span.hidden=!r}_selectionChanged(r,e,t){r.detail.propertyName==="selected"&&r.detail.currentValue===!0&&(this._selectedValue=this.mapEntityToValue(this.datasource[e]),this.changeHandler(r))}onChange(r){return this.value=this._selectedValue,this.databind(),CT.fromResult(this._selectedValue)}};l([Lw(Gn+"-repeater")],hc.prototype,"_repeater",2),l([Lw(Gn+"-data")],hc.prototype,"_disable",2),l([Lw(`span.${Hg}-readonly`)],hc.prototype,"_span",2),hc=l([YV({tagName:Gn+"-radio-list",template:`<${Gn}-repeater datasource="{{ :host.adaptedDatasource }}">
|
|
507
|
+
<ol class="${Hg}-radio-list ${Hg}-viewfinder" pacem>
|
|
508
|
+
<template>
|
|
509
|
+
<li><${Gn}-radio disabled="{{ ::_disable.model || ^item.disabled }}" name="{{ :host.key, once }}" autobind="off" caption="{{ ^item.viewValue }}" value="{{ ^item.value }}" selected="{{ :host.isDataSourceItemSelected(^item, :host.value) }}"
|
|
510
|
+
on-focus=":host.focusHandler($event)" on-blur=":host.focusHandler($event)"
|
|
511
|
+
on-${qV}=":host._selectionChanged($event, ^index, ^item)"></${Gn}-radio></li>
|
|
512
|
+
</template>
|
|
513
|
+
</ol>
|
|
514
|
+
</${Gn}-repeater><span class="${Hg}-readonly ${Hg}-radio"><${Gn}-text text="{{ :host.viewValue }}"></${Gn}-text></span><${Gn}-data></${Gn}-data><${Gn}-content></${Gn}-content>`,shadow:XV.USE_SHADOW_ROOT})],hc);import{Components as KV,PropertyConverters as JV,Utils as cp,P as mc,PCSS as Bg,CustomElement as ZV,Watch as QV,Defaults as eU,ViewChild as Nw}from"@pacem/pacem-core";var Oo=class extends Ht{constructor(){super(...arguments);this.emptyOption=!0}toggleReadonlyView(e){this._repeater.hidden=e,this._span.hidden=!e}get inputFields(){return[this._select]}_manageDom(e){let t=e.detail,n=t.item,i=t.dom.find(s=>s instanceof HTMLOptionElement);i.value=n.value,i.textContent=n.viewValue,i.disabled=n.disabled,i.selected=this.isDataSourceItemSelected(n),(cp.isNullOrEmpty(i.value)?cp.addClass:cp.removeClass).apply(this,[i,Bg+"-watermark"])}onChange(e){let t=this._select,n=t.selectedIndex,i=this.adaptedDatasource,s=n>=0&&i[n],o;return s!=null?o=s.value:o=void 0,cp.fromResult(this.value=o)}propertyChangedCallback(e,t,n,i){switch(super.propertyChangedCallback(e,t,n,i),e){case"placeholder":case"emptyOption":this.databind();break}}buildAdaptedDatasource(e=this.datasource){let t=super.buildAdaptedDatasource(e);return t&&this.emptyOption&&t.splice(0,0,{viewValue:this.placeholder||"",value:void 0,data:void 0}),t}handleDatasourceMismatch(e){this.emptyOption?super.handleDatasourceMismatch(e):cp.isNullOrEmpty(e)?this.value=void 0:this.value=e[0].value}acceptValue(e){let t=this.adaptedDatasource,n=t&&t.filter(i=>this.isDataSourceItemSelected(i,e));if(n&&n.length==1)this._select.selectedIndex=t.indexOf(n[0]);else{this._select.value=void 0;let i=this._select.options;i.length>0&&cp.isNullOrEmpty(i[0].value)&&(this._select.selectedIndex=0)}}viewActivatedCallback(){super.viewActivatedCallback();var e={capture:!1,passive:!1};this._select.addEventListener("wheel",this.emitHandler,e)}disconnectedCallback(){if(!cp.isNull(this._select)){var e={capture:!1,passive:!1};this._select.removeEventListener("wheel",this.emitHandler,e)}super.disconnectedCallback()}};l([Nw("select")],Oo.prototype,"_select",2),l([Nw(mc+"-repeater")],Oo.prototype,"_repeater",2),l([Nw(`span.${Bg}-readonly`)],Oo.prototype,"_span",2),l([QV({emit:!1,converter:JV.Boolean})],Oo.prototype,"emptyOption",2),Oo=l([ZV({tagName:mc+"-select",template:`<${mc}-repeater datasource="{{ :host.adaptedDatasource }}" on-${KV.RepeaterItemCreateEventName}=":host._manageDom($event)">
|
|
515
|
+
<select class="${Bg}-select ${Bg}-viewfinder">
|
|
516
|
+
<template>
|
|
517
|
+
<option></option>
|
|
518
|
+
</template>
|
|
519
|
+
</select>
|
|
520
|
+
</${mc}-repeater><span class="${Bg}-readonly"><${mc}-text text="{{ :host.viewValue }}"></${mc}-text></span><${mc}-content></${mc}-content>`,shadow:eU.USE_SHADOW_ROOT})],Oo);import{Components as g_}from"@pacem/pacem-ui";import{P as xt,PCSS as Tw,ViewChild as dp,CustomElement as tU,Watch as jh,Utils as Tt,PropertyConverters as Vg,Defaults as rU,avoidHandler as nU,Components as iU,UI as Yh}from"@pacem/pacem-core";var fr=class extends ge{constructor(){super(...arguments);this.inputFields=[];this._dragHandler=e=>{e.preventDefault(),this._computeAndAssignValue(e.detail.currentPosition.x,this.changePolicy!=="end")};this._endHandler=e=>{e.preventDefault(),this._computeAndAssignValue(e.detail.currentPosition.x,this.changePolicy==="end")};this._startHandler=e=>{this._thumb.focus()};this._downHandler=e=>{let t=e instanceof MouseEvent?e.clientX:e.touches&&e.touches.length&&e.touches[0].clientX,n=this._trackSize;Tt.isNullOrEmpty(n)||this._computeAndAssignValue(t,!0)};this._keydownHandler=e=>{switch(e.keyCode){case 39:case 37:nU(e);let t=e.keyCode===39,n=(typeof this.step!="number"?1:this.step)*(t?1:-1),i=!1,s=o=>{i=!0,window.removeEventListener("keyup",s,!1),Tt.removeClass(this,"slider-keydown")};window.addEventListener("keyup",s,!1),Tt.addClass(this,"slider-keydown"),Tt.accelerateCallback(o=>{(o.cancel=i)||this._setValue(this.value+n)});break}}}onChange(e){return new Promise((t,n)=>{e.type==="slide"&&t(this.value=e.detail),t(this.value)})}_draw(e=this.value){let t=this._trackSize;if(Tt.isNull(t))return;let n=Tt.isNullOrEmpty(e)?this.min:parseFloat(e),i=Math.min(1,Math.max(0,(n-this.min)/(this.max-this.min)));this._progress.style.transform=`scale(${i}, 1)`,this._thumb.style.transform=`translateX(${Math.round(i*t.width)}px)`}_format(e){let t=this.format;if(!Tt.isNullOrEmpty(t))return new Intl.NumberFormat(Tt.lang(this),t).format(e);let n="-";Tt.isNull(e)||(n=e.toLocaleString());let i=new CustomEvent("formatvalue",{detail:{value:e}});return this.dispatchEvent(i),Tt.isNull(i.detail.output)?n:i.detail.output}acceptValue(e){this._draw(e)}getViewValue(e){return this._format(e)}convertValueAttributeToProperty(e){return parseFloat(e)}toggleReadonlyView(e){this._thumb.hidden=e;let t="cursor-pointer";e?(Tt.removeClass(this._max,t),Tt.removeClass(this._min,t)):(Tt.addClass(this._max,t),Tt.addClass(this._min,t))}_setTrackSize(e){let t=e.detail;this._trackSize={x:t.left,y:t.top,width:t.width,height:t.height},this._draw(this.value)}_computeAndAssignValue(e,t){if(this.readonly||this.disabled)return;let n=this._trackSize,i=this.step,s=(e-n.x)/n.width,o=(this.max-this.min)*s+this.min;typeof i=="number"&&(o=Math.round(o/i)*i),t?this._setValue(o):this._draw(o)}_setValue(e){isNaN(e)||Tt.isNull(e)?e=void 0:(!isNaN(this.min)&&e<this.min&&(e=this.min),!isNaN(this.max)&&e>this.max&&(e=this.max)),this.changeHandler(new CustomEvent("slide",{detail:e}))}connectedCallback(){super.connectedCallback(),this.addEventListener("mousedown",this._downHandler,!1),this.addEventListener("touchstart",this._downHandler,{passive:!1,capture:!1})}viewActivatedCallback(){super.viewActivatedCallback(),this._dragger.addEventListener(Yh.DragDropEventType.Init,this._startHandler,!1),this._dragger.addEventListener(Yh.DragDropEventType.Drag,this._dragHandler,!1),this._dragger.addEventListener(Yh.DragDropEventType.End,this._endHandler,!1),this._thumb.addEventListener("keydown",this._keydownHandler,!1),this._min.text=this._format(this.min),this._max.text=this._format(this.max);let e=this._shellProxy.dom[0];Tt.isNull(e)||(e.target=this._thumb,e.options={trigger:g_.UI.BalloonTrigger.Focus,trackPosition:!0,position:g_.UI.BalloonPosition.Top,align:g_.UI.BalloonAlignment.Center,behavior:g_.UI.BalloonBehavior.Tooltip,hoverDelay:0,hoverTimeout:0},this._syncThumbLabel()),this._thumb.tabIndex=0}_syncThumbLabel(e=this.thumbLabel){let t=this._shellProxy.dom[0];(e?Tt.addClass:Tt.removeClass).apply(this,[this,"slider-thumblabel"]),t.disabled=!e}disconnectedCallback(){this.removeEventListener("mousedown",this._downHandler,!1),this.removeEventListener("touchstart",this._downHandler,{capture:!1}),Tt.isNull(this._dragger)||(this._dragger.removeEventListener(Yh.DragDropEventType.End,this._endHandler,!1),this._dragger.removeEventListener(Yh.DragDropEventType.Drag,this._dragHandler,!1),this._dragger.removeEventListener(Yh.DragDropEventType.Init,this._startHandler,!1)),Tt.isNull(this._thumb)||this._thumb.removeEventListener("keydown",this._keydownHandler,!1),super.disconnectedCallback()}propertyChangedCallback(e,t,n,i){if(super.propertyChangedCallback(e,t,n,i),!i)switch(e){case"thumbLabel":this._syncThumbLabel(n);break;case"min":case"max":!Tt.isNull(this._max)&&!Tt.isNull(this._min)&&(this._min.text=this._format(this.min),this._max.text=this._format(this.max)),this._setValue(this.value),this._draw();break}}};l([jh({emit:!1,converter:Vg.Number})],fr.prototype,"min",2),l([jh({emit:!1,converter:Vg.Number})],fr.prototype,"max",2),l([jh({emit:!1,converter:Vg.Boolean})],fr.prototype,"thumbLabel",2),l([jh({emit:!1,converter:{convert:e=>{let t=parseFloat(e);return isNaN(t)?"any":t},convertBack:e=>(e||"").toString()}})],fr.prototype,"step",2),l([jh({emit:!1,converter:Vg.String})],fr.prototype,"changePolicy",2),l([jh({emit:!1,converter:Vg.Json})],fr.prototype,"format",2),l([dp(".slider-track")],fr.prototype,"_track",2),l([dp(".slider-progress")],fr.prototype,"_progress",2),l([dp(".slider-thumb")],fr.prototype,"_thumb",2),l([dp(`${xt}-text[min]`)],fr.prototype,"_min",2),l([dp(`${xt}-text[max]`)],fr.prototype,"_max",2),l([dp(`${xt}-drag-drop`)],fr.prototype,"_dragger",2),l([dp(`${xt}-shell-proxy`)],fr.prototype,"_shellProxy",2),fr=l([tU({tagName:xt+"-slider",template:`<div class="${Tw}-viewfinder ${Tw}-slider"><${xt}-text text="{{ :host._format(:host.min) }}" min></${xt}-text>
|
|
521
|
+
<div class="slider-track"><div class="slider-progress"></div></div>
|
|
522
|
+
<${xt}-panel class="${Tw}-clickable slider-thumb" behaviors="{{ [::_dragger] }}">
|
|
523
|
+
<div class="thumb-label"></div>
|
|
524
|
+
</${xt}-panel>
|
|
525
|
+
<${xt}-text text="{{ :host._format(:host.max) }}" max></${xt}-text>
|
|
526
|
+
<div class="slider-footer"><${xt}-text text="{{ :host.viewValue }}"></${xt}-text></div>
|
|
527
|
+
</div>
|
|
528
|
+
<${xt}-drag-drop lock-timeout="0"></${xt}-drag-drop><${xt}-resize watch-position="true" on-${iU.ResizeEventName}=":host._setTrackSize($event)" target="{{ ::_track }}"></${xt}-resize>
|
|
529
|
+
<${xt}-shell-proxy><${xt}-balloon class="text-center"><${xt}-text text="{{ :host.viewValue }}"></${xt}-text></${xt}-balloon></${xt}-shell-proxy>
|
|
530
|
+
`,shadow:rU.USE_SHADOW_ROOT})],fr);import{CustomTypedEvent as sU,CustomElement as aU,Watch as pp,ViewChild as up,Defaults as oU,PCSS as fc,P as Gt,Components as ET,PropertyConverters as hp,Utils as be,avoidHandler as gc,Logging as lU,CustomElementUtils as cU}from"@pacem/pacem-core";import{Components as Ug}from"@pacem/pacem-ui";var zg=class extends sU{constructor(r){super("suggestionselect",{selectedValue:r})}},wT=100,kT=0,Gg,Xh,oa,rr=class extends Ht{constructor(){super(...arguments);$(this,Gg);this._toggleBtnHandler=e=>{e.preventDefault(),this.disabled||this._balloon.toggle()};this._clearBtnHandler=e=>{e.preventDefault(),this.hint=this._input.value="",this.value=void 0,this._focus(null),this.changeHandler(new zg(null))};this._balloonPopupHandler=e=>{be.addClass(this._btnArrow,"rotate-180")};this._balloonPopoutHandler=e=>{be.removeClass(this._btnArrow,"rotate-180")};this._inputHandler=e=>{switch(e.keyCode){case 9:case 13:break;default:this._focus(null),this.hint=this._input.value,this.changeHandler(new zg(null));break}};this._keyupHandler=e=>{x(this,Xh)&&(gc(e),A(this,Xh,!1))};this._focusHandler=e=>{this.preventFocus&&(e.preventDefault(),this._balloon.visible?this.popout():this.popup());let t=this._input.value;this.viewValue!=t&&this._databind()};this._blurHandler=e=>{this._undo()};$(this,Xh,!1);this._keydownHandler=e=>{var t=!1;if(be.isNull(x(this,oa))){let o=this._findFirstAvailableListItem();if(!be.isNull(o))switch(e.keyCode){case 40:gc(e),this._focus(o);break;case 13:gc(e),t=!0,x(this,Gg).length===1?this._select(o):this._focus(o);break}}else{var n=x(this,oa),i=n,s;let o=d=>!be.isNull(d)&&d.localName==="li"&&d.dataset.pacemDisabled==="true",c=d=>!be.isNull(d)&&d.localName==="li"&&d.dataset.pacemDisabled!=="true";switch(e.keyCode){case 38:gc(e);do if(i=i.previousElementSibling,c(i)){s=i;break}while(o(i));s??=n;break;case 40:gc(e);do if(i=i.nextElementSibling,c(i)){s=i;break}while(o(i));s??=n;break;case 27:gc(e),this._undo(),this.popout();break;case 9:case 13:gc(e),t=!0,this._select();break}this._focus(s),A(this,Xh,t)}};this._selectHandler=e=>{gc(e),this._select(e.currentTarget)};$(this,oa)}get inputFields(){return[this._input]}acceptValue(e){(this.allowNew||!be.isNullOrEmpty(this.datasource))&&(this._input.value=this.getViewValue(e)||(this._isTyping?this._input.value:""))}getViewValue(e){var t=super.getViewValue(e);return be.isNullOrEmpty(t)&&this.allowNew&&!be.isNullOrEmpty(e)&&(t=this.mapEntityToViewValue(e)),t}onChange(e){return new Promise((t,n)=>{if(e.type==="suggestionselect"){let i=e.detail.selectedValue;this.value=i,i&&this.popout(),t(i)}else t(this.value)})}viewActivatedCallback(){super.viewActivatedCallback(),this._setDropdownMode(),this._setupItemTemplate();var e=this._createBalloon();e.appendChild(this._repeater),this._checkBalloon(e),cU.findAncestorShell(this).appendChild(e),this._balloon=e,this._input.addEventListener("mousedown",this._focusHandler,!1),this._input.addEventListener("keydown",this._keydownHandler,!1),this._input.addEventListener("keyup",this._keyupHandler,!1),this._input.addEventListener("focus",this._focusHandler,!1),this._input.addEventListener("blur",this._blurHandler,!1),this._input.addEventListener("input",this._inputHandler,!1),this._btnClear.addEventListener("mousedown",this._clearBtnHandler,!1),this._btnArrow.addEventListener("mousedown",this._toggleBtnHandler,!1),this._databind(),this._syncButtons()}propertyChangedCallback(e,t,n,i){if(super.propertyChangedCallback(e,t,n,i),be.isNull(this._balloon))return;let s=this._isTyping;switch(e){case"adaptedDatasource":be.isNullOrEmpty(n)?this.popout():s?this.popup():this._input.value=this.getViewValue(this.value);break;case"hint":!s&&n!==this._input.value&&(this._input.value=n,A(this,oa,null));break;case"readonly":this._setDropdownMode();case"disabled":case"value":this._checkBalloon();break;case"itemtemplate":i||this._setupItemTemplate();break;case"allowTyping":i||this._setDropdownMode();break}["adaptedDatasource","hint","value"].indexOf(e)>=0&&this._databind(),["allowTyping","value","hint"].indexOf(e)>=0&&this._syncButtons()}disconnectedCallback(){be.isNull(this._balloon)||(this._balloon.removeEventListener("popup",this._balloonPopupHandler,!1),this._balloon.removeEventListener("popout",this._balloonPopoutHandler,!1),this._balloon.remove()),be.isNull(this._input)||(this._input.removeEventListener("mousedown",this._focusHandler,!1),this._input.removeEventListener("focus",this._focusHandler,!1),this._input.removeEventListener("blur",this._blurHandler,!1),this._input.removeEventListener("keydown",this._keydownHandler,!1),this._input.removeEventListener("keyup",this._keyupHandler,!1),this._input.removeEventListener("input",this._inputHandler,!1)),be.isNull(this._btnClear)||this._btnClear.removeEventListener("mousedown",this._clearBtnHandler,!1),be.isNull(this._btnArrow)||this._btnArrow.addEventListener("mousedown",this._toggleBtnHandler,!1),super.disconnectedCallback()}_databind(){if(!be.isNull(this._repeater)){let e=A(this,Gg,this._filter(this.adaptedDatasource,this._input.value));this._repeater.datasource=e}}_syncButtons(){be.isNull(this._btnArrow)||(this._btnArrow.hide=this.allowTyping!==!1||!be.isNullOrEmpty(this._input.value||this.value)),be.isNull(this._btnClear)||(this._btnClear.hide=this.readonly||be.isNullOrEmpty(this._input.value||this.value))}get _isTyping(){return be.is(this._input,":focus")}_undo(){this._focus(null),this.hint=this._input.value=this.getViewValue(this.value)||""}_findFirstAvailableListItem(){var e;if(this._balloon.visible===!0&&!be.isNull(e=this._repeater.querySelector("ol > li")))for(;!be.isNull(e)&&e.dataset.pacemDisabled==="true"&&e.localName==="li";)e=e.nextElementSibling;return e}_setDropdownMode(e=this.allowTyping){this._input.readOnly=!(e??!0)}_setupItemTemplate(){if(this.itemtemplate instanceof HTMLTemplateElement){let e=this.itemtemplate.cloneNode(!0).content,t=document.createElement("template"),n=document.createElement("li");n.append(e),t.content.appendChild(n),this._tmplProxy.target=t}else this._tmplProxy.target=this._defaultTemplate}_focus(e){if(this.preventFocus)return;if(be.isNull(e)){A(this,oa,null);return}let t=e.parentElement.children;for(let n=0;n<t.length;n++){let i=t.item(n);if(i===e){i.dataset.pacemFocused="true",A(this,oa,i);let s=this._input,o=s.value=JSON.parse(i.dataset.pacemViewValue);s.setSelectionRange(o.length,o.length)}else delete i.dataset.pacemFocused}}_select(e=x(this,oa)){let t=JSON.parse(e.dataset.pacemValue);e.dataset.pacemDisabled==="true"||this.changeHandler(new zg(t))}_filter(e,t,n=this.value){let i=e||[];if(!be.isNullOrEmpty(t&&t.trim())){let o=t.toLowerCase().split(" "),c=i.filter(p=>{for(let u of o){if(p.viewValue?.toLowerCase().indexOf(u)>=0)return!0;let h=this.filterFields;if(!be.isNullOrEmpty(h)){let m=p.data;if(typeof m=="object"&&!be.isNullOrEmpty(m))for(let f of h){let g=f.split("."),v=0,b=m;for(;!be.isNull(b)&&v<g.length;)b=b[g[v]],v++;if(!be.isNullOrEmpty(b)&&b.toString().toLowerCase().indexOf(u)>=0)return!0}}}return!1});i=this.allowNew&&be.isNullOrEmpty(this.valueProperty)&&be.isNullOrEmpty(this.textProperty)&&(be.isNullOrEmpty(c)||be.isNull(c.find(p=>p.viewValue===t)))?[{value:t,viewValue:t,data:t}].concat(c):c}let s=i;return this.allowTyping!==!1&&(s=i.slice(0,this.maxSuggestions||10)),this._isTyping&&this.popup(),this._balloon.style.opacity=be.isNullOrEmpty(s)?"0":"",this.log(lU.LogLevel.Log,`${s.length} dropdown suggestion(s), given hint '${t}' and ${(e||[]).length} datasource items`),s}_itemCreate(e){let t=e.detail.dom.find(o=>o instanceof HTMLLIElement),n=e.detail.item,i=e.detail.index,s=n.disabled===!0;t.tabIndex=s?-1:0,t.dataset.pacemValue=JSON.stringify(n.value),t.dataset.pacemViewValue=JSON.stringify(n.viewValue),t.dataset.pacemDisabled=s.toString(),t.addEventListener("mousedown",this._selectHandler,!1)}_itemRemove(e){e.detail.dom.find(n=>n instanceof HTMLLIElement).removeEventListener("mousedown",this._selectHandler,!1)}toggleReadonlyView(e){this.span.hidden=!e,this._input.hidden=e,e?this._btnClear.hide=this._btnArrow.hide=!0:this._syncButtons()}popup(e=wT){!be.isNullOrEmpty(this.adaptedDatasource)&&be.isVisible(this)&&this._balloon?.popup(e)}popout(e=kT){A(this,oa,null),this._balloon?.popout(e)}_checkBalloon(e=this._balloon){if(!be.isNull(e)){let t=!be.isNullOrEmpty(this.value)&&!be.isNullOrEmpty(this._input.value);e.disabled=t||this.readonly||this.disabled||!1}}_createBalloon(){let e=document.createElement(Gt+"-balloon");return be.addClass(e,"suggest dropdown"),e.options={trackPosition:!0,trigger:Ug.UI.BalloonTrigger.Focus,position:Ug.UI.BalloonPosition.VerticalAuto,size:Ug.UI.BalloonSizing.Match,align:Ug.UI.BalloonAlignment.Start,behavior:Ug.UI.BalloonBehavior.Menu,hoverDelay:wT,hoverTimeout:kT},e.addEventListener("popup",this._balloonPopupHandler,!1),e.addEventListener("popout",this._balloonPopoutHandler,!1),e.target=this._input,e}};Gg=new WeakMap,Xh=new WeakMap,oa=new WeakMap,l([up("input[type=text]")],rr.prototype,"_input",2),l([up(Gt+"-repeater")],rr.prototype,"_repeater",2),l([up(`span.${fc}-readonly`)],rr.prototype,"span",2),l([up("template")],rr.prototype,"_defaultTemplate",2),l([up(Gt+"-template-proxy")],rr.prototype,"_tmplProxy",2),l([up(`${Gt}-button[toggle]`)],rr.prototype,"_btnArrow",2),l([up(`${Gt}-button[clear]`)],rr.prototype,"_btnClear",2),l([pp({converter:hp.String})],rr.prototype,"hint",2),l([pp({emit:!1,converter:hp.Number})],rr.prototype,"maxSuggestions",2),l([pp({converter:hp.Boolean})],rr.prototype,"allowTyping",2),l([pp({emit:!1,converter:hp.Boolean})],rr.prototype,"preventFocus",2),l([pp({emit:!1,converter:hp.Element})],rr.prototype,"itemtemplate",2),l([pp({emit:!1,converter:hp.StringArray})],rr.prototype,"filterFields",2),l([pp({emit:!1,converter:hp.Boolean})],rr.prototype,"allowNew",2),rr=l([aU({tagName:Gt+"-suggest",shadow:oU.USE_SHADOW_ROOT,template:`<div class="${fc}-relative"><input type="text" class="${fc}-input" />
|
|
531
|
+
<${Gt}-button clear tab-order="-1"
|
|
532
|
+
class="button-flat ${fc}-anim anim-pop anim-sudden anim-quick pos-absolute absolute-right absolute-top display-block ${fc}-margin margin-0"
|
|
533
|
+
icon-glyph="highlight_off"></${Gt}-button>
|
|
534
|
+
<${Gt}-button
|
|
535
|
+
class="button-flat icon-rotate ${fc}-anim anim-pop anim-sudden anim-quick pos-absolute absolute-right absolute-top display-block ${fc}-margin margin-0"
|
|
536
|
+
icon-glyph="arrow_drop_down" tab-order="-1" toggle></${Gt}-button>
|
|
537
|
+
</div>
|
|
538
|
+
<span class="${fc}-readonly"><${Gt}-text text="{{ :host.viewValue }}"></${Gt}-text></span>
|
|
539
|
+
<${Gt}-repeater on-${ET.RepeaterItemCreateEventName}=":host._itemCreate($event)" on-${ET.RepeaterItemRemoveEventName}=":host._itemRemove($event)">
|
|
540
|
+
<ol>
|
|
541
|
+
<${Gt}-template-proxy></${Gt}-template-proxy>
|
|
542
|
+
</ol>
|
|
543
|
+
</${Gt}-repeater><${Gt}-content></${Gt}-content>
|
|
544
|
+
<template>
|
|
545
|
+
<li><${Gt}-span content="{{ $pacem.highlight(^item.viewValue, :host.hint) }}"></${Gt}-span></li>
|
|
546
|
+
</template>`})],rr);import{CustomElement as MT,Defaults as ST,P as Sr,PCSS as mp,Components as dU,CustomTypedEvent as LT,PropertyConverters as qh,Watch as Kh,Utils as la,ViewChild as Aw}from"@pacem/pacem-core";var Dw=class extends LT{constructor(r){super("tagremove",{index:r})}},Rw=class extends LT{constructor(r){super("tagadd",{value:r})}},vc=class extends dU.PacemElement{propertyChangedCallback(r,e,t,n){switch(super.propertyChangedCallback(r,e,t,n),r){case"readonly":let i=!!t;(i?la.addClass:la.removeClass)(this,"tag-readonly"),this._btn.disabled=this._btn.hide=i;break;case"tag":la.removeClass(this,"tag-out");break}}_remove(){let r=this;la.addClass(r,"tag-out"),la.addAnimationEndCallback(r,()=>{this.dispatchEvent(new Event("remove"))})}};l([Kh({converter:qh.String})],vc.prototype,"tag",2),l([Kh({emit:!1,converter:qh.Boolean})],vc.prototype,"readonly",2),l([Aw(Sr+"-button")],vc.prototype,"_btn",2),vc=l([MT({tagName:Sr+"-tag",shadow:ST.USE_SHADOW_ROOT,template:`<${Sr}-text text="{{ :host.tag }}"></${Sr}-text>
|
|
547
|
+
<${Sr}-button on-click=":host._remove()"></${Sr}-button>`})],vc);var ps=class extends Ht{constructor(){super(!0);this.inputFields=[]}toggleReadonlyView(e){this._suggest.readonly=e,this.querySelector(".tag-new").hidden=e}_tagRemove(e){this.changeHandler(new Dw(e))}_tagAdd(e){this.changeHandler(new Rw(e))}handleDatasourceMismatch(){}propertyChangedCallback(e,t,n,i){switch(super.propertyChangedCallback(e,t,n,i),e){case"datasource":case"textProperty":this._suggest[e]=n;break;case"valueProperty":if(!la.isNullOrEmpty(n))throw`Cannot set 'valueProperty' on ${this.constructor.name}s.`;break;case"value":this._tags.datasource=n;break}}onChange(e){return new Promise((t,n)=>{switch(e.type){case"tagremove":this._justAddedIndex=-1;let i=e,s=i.detail.index,o=la.clone(this.value),c=o.splice(s+1),d=o.splice(0,s);t(this.value=d.concat(c));break;case"tagadd":let p=e.detail.value,u=la.clone(this.value);if(!la.isNullOrEmpty(p)&&(this.allowDuplicates||la.isNullOrEmpty(u&&u.find(h=>this.mapEntityToViewValue(h)==this.mapEntityToViewValue(p))))){let h=(u||[]).concat([p]);t(this.value=h),this._justAddedIndex=this.value.length-1,setTimeout(()=>{this._suggest.focus()},250),this._suggest.blur(),this._suggest.hint="",this._suggest.reset()}break;default:t(this.value);break}})}acceptValue(e){}};l([Kh({converter:qh.String})],ps.prototype,"hint",2),l([Kh({emit:!1,converter:qh.Boolean})],ps.prototype,"allowDuplicates",2),l([Kh({converter:qh.Boolean})],ps.prototype,"allowNew",2),l([Kh({converter:qh.Number})],ps.prototype,"_justAddedIndex",2),l([Aw(Sr+"-suggest")],ps.prototype,"_suggest",2),l([Aw(Sr+"-repeater."+mp+"-tags")],ps.prototype,"_tags",2),ps=l([MT({tagName:Sr+"-tags",shadow:ST.USE_SHADOW_ROOT,template:`<${Sr}-repeater class="${mp}-tags">
|
|
548
|
+
<ul class="${mp}-tags ${mp}-viewfinder ${mp}-list list-unstyled list-inline">
|
|
549
|
+
<template>
|
|
550
|
+
<li class="${mp}-tag">
|
|
551
|
+
<${Sr}-tag on-remove=":host._tagRemove(^index)" css-class="{{ { 'tag-in': :host._justAddedIndex === ^index } }}" tag="{{ :host.mapEntityToViewValue(^item) }}" readonly="{{ :host.readonly }}"></${Sr}-tag>
|
|
552
|
+
</li>
|
|
553
|
+
</template>
|
|
554
|
+
<li class="tag-new">
|
|
555
|
+
<${Sr}-suggest logger="{{ :host.logger }}" placeholder="{{ :host.placeholder }}" allow-new="{{ :host.allowNew }}" class="${mp}-tags" on-change=":host._tagAdd($this.value)" hint="{{ :host.hint, twoway }}">
|
|
556
|
+
<${Sr}-content></${Sr}-content>
|
|
557
|
+
</${Sr}-suggest>
|
|
558
|
+
</li>
|
|
559
|
+
</ul>
|
|
560
|
+
</${Sr}-repeater>`})],ps);import{P as Ow,PCSS as Pw,CustomElement as pU,Watch as NT,Defaults as uU,ViewChild as TT,PropertyConverters as AT}from"@pacem/pacem-core";var Po=class extends dt{constructor(){super(...arguments);this.rows=5;this.cols=50}get preventKeyboardSubmit(){return!0}toggleReadonlyView(e){this._span.hidden=!e,this._input.hidden=e}get inputFields(){return[this._input]}propertyChangedCallback(e,t,n,i){super.propertyChangedCallback(e,t,n,i),(e==="rows"||e==="cols")&&this.inputField.setAttribute(e,n)}};l([NT({emit:!1,converter:AT.Number})],Po.prototype,"rows",2),l([NT({emit:!1,converter:AT.Number})],Po.prototype,"cols",2),l([TT("textarea")],Po.prototype,"_input",2),l([TT(`span.${Pw}-readonly`)],Po.prototype,"_span",2),Po=l([pU({tagName:Ow+"-textarea",template:`<textarea class="${Pw}-input" pacem></textarea>${en}<span class="${Pw}-readonly"><${Ow}-text text="{{ :host.viewValue }}"></${Ow}-text></span>`,shadow:uU.USE_SHADOW_ROOT})],Po);import{P as hU,PCSS as v_,CustomElement as mU,Watch as DT,Defaults as fU,ViewChild as RT,PropertyConverters as OT,preventDefaultHandler as gU}from"@pacem/pacem-core";import{Components as vU}from"@pacem/pacem-ui";var Io=class extends dt{constructor(e=new vU.UI.MarkdownService){super();this._md=e;this.rows=5;this.cols=50;this._keydownHandler=e=>{if(e.keyCode===9){let n=this.input,i=n.value;var t=n.selectionStart;n.value=i.substr(0,t)+" "+i.substr(t),gU(e)}}}toggleReadonlyView(e){this.input.hidden=e}get preventKeyboardSubmit(){return!0}get inputFields(){return[this.input]}getViewValue(e){return this._md.toHtml(e)}propertyChangedCallback(e,t,n,i){super.propertyChangedCallback(e,t,n,i),e==="rows"||e==="cols"?this.inputField.setAttribute(e,n):e=="viewValue"&&(this._markdown.innerHTML=n)}viewActivatedCallback(){super.viewActivatedCallback(),this.input.addEventListener("keydown",this._keydownHandler,!1)}disconnectedCallback(){this.input&&this.input.removeEventListener("keydown",this._keydownHandler,!1),super.disconnectedCallback()}};l([DT({emit:!1,converter:OT.Number})],Io.prototype,"rows",2),l([DT({emit:!1,converter:OT.Number})],Io.prototype,"cols",2),l([RT("textarea")],Io.prototype,"input",2),l([RT(`div.${v_}-readonly`)],Io.prototype,"_markdown",2),Io=l([mU({tagName:hU+"-textarea-markdown",template:`<textarea class="${v_}-input" pacem></textarea>${en}<div class="${v_}-readonly ${v_}-markdown"></div>`,shadow:fU.USE_SHADOW_ROOT})],Io);var Uw={};tt(Uw,{ChartEvent:()=>y_,MANAGED_EVENTS:()=>Jh,PacemChartElement:()=>fp,PacemChartSeriesElement:()=>_i,PacemColumnChartElement:()=>gp,PacemPieChartElement:()=>us,PacemPieSliceElement:()=>da,PacemSeriesChartElement:()=>gr});import{CustomElement as bU,Watch as sn,PropertyConverters as Cn,P as yU,PCSS as $w,Components as Fg,CustomUIEvent as _U,CustomElementUtils as bc,Utils as pt,Throttle as xU,PropertyChangeEventName as PT}from"@pacem/pacem-core";var Jh=["keydown","keyup","click","dblclick","mouseover","mouseout","mouseenter","mouseleave","mousedown","mouseup","mousemove","contextmenu"],IT=1e3*60*60*24,CU=10,EU=10,b_="pacem:chart-series:dataitem",Hw="pacem:chart-series:series";function wU(a,r,e,t,n,i=CU){let s=r==="number"||r==="date"?t-e:Math.max(1,a.length-1),o=i-1;for(var c=[],d=1,p=o;p>1;p--)if(s%p===0){d=s/p;break}d===1&&s>i&&(d=s);let u=typeof n=="function"?n:d>=IT?(g=>g.toLocaleDateString(n)):(g=>g.toLocaleTimeString(n)),h=typeof n=="function"?n:d<IT?(g=>g.toLocaleString(n)):u,m=typeof n=="function"?n:g=>g.toLocaleString(n);for(var f=0;f<=s;f+=d){let g;switch(r){case"string":if(f>=a.length)continue;g=a[f].label;break;case"number":g=m(e+f);break;case"date":let v=pt.parseDate(e+f);g=(f==0?h:u)(v);break;default:throw"Not supported."}c.push(g)}return c}function kU(a,r,e){e??=Math.min($T(a,r),EU);let t=(r-a)/e,n=Math.pow(10,Math.floor(Math.log10(t))),i=[1,2,5,10].map(s=>s*n).filter(s=>s>=t).reduce((s,o)=>Math.min(s,o),Number.POSITIVE_INFINITY);return{min:Math.floor(a/i)*i,max:Math.ceil(r/i)*i,round:i}}function $T(a,r){let e=r-a;if(!(e>0))return 2;let t=Math.floor(Math.log10(e)),n=Math.pow(10,-t);if(t!=0)return $T(a*n,r*n);let i=d=>{let p=Math.floor(Math.abs(d)*10);return(p+10-p%10).roundoff()},s=i(e),o=10;a!==0&&(o=i(Math.abs(r)));let c=HT(o,s);return c===1?s:Math.max(c,10-c)}function HT(a,r){return a<=0?r:HT(r%a,a)}var y_=class extends _U{constructor(r,e,t){super(r,e,t)}},_i=class extends Fg.PacemItemElement{get values(){return this.datasource}};l([sn({emit:!0,converter:Cn.Json})],_i.prototype,"datasource",2),l([sn({emit:!0,converter:Cn.String})],_i.prototype,"label",2),l([sn({emit:!0,converter:Cn.String})],_i.prototype,"color",2),l([sn({emit:!0,converter:Cn.Boolean})],_i.prototype,"datapoints",2),l([sn()],_i.prototype,"_uiElements",2),_i=l([bU({tagName:yU+"-chart-series"})],_i);var ca="http://www.w3.org/2000/svg",gr=class extends Fg.PacemItemsContainerElement{constructor(){super();this._itemPropertyChangedCallback=e=>{let t=e.detail.propertyName;(t==="datasource"||t==="label"||t==="datapoints"||t==="cssClass"||t==="color")&&this.draw()};this._series=[];this._resizeHandler=e=>{this._size=e.detail,this.draw()};this._broadcastHandler=e=>{let t=e.currentTarget,n=bc.getAttachedPropertyValue(t,b_);if(pt.isNull(n))return;let i=this,s=i.getAnchorPoint(t),o=new y_("item"+e.type,{detail:{dataItem:n,anchorPoint:s}},e),c=bc.getAttachedPropertyValue(t,Hw);c instanceof _i&&c.dispatchEvent(o),i.dispatchEvent(o)};this._key=pt.uniqueCode()}validate(e){return e instanceof _i}register(e){return super.register(e)?(e.addEventListener(PT,this._itemPropertyChangedCallback,!1),!0):!1}unregister(e){return super.unregister(e)?(e.removeEventListener(PT,this._itemPropertyChangedCallback,!1),!0):!1}propertyChangedCallback(e,t,n,i){if(super.propertyChangedCallback(e,t,n,i),e==="target"){this._div!=t&&this._div&&this._div.remove(),this._div=null,this._body=null;let s=t;s&&(s.classList.remove($w+"-chart-area"),s.innerHTML=""),this._ensureResizer(),this.draw()}else if(!i)switch(e){case"items":this._databindAndDrawDebounced();break;case"datasource":this._databind();case"yAxisDensity":case"xAxisDensity":case"xAxisType":case"yAxisMax":case"xAxisPosition":case"yAxisFormat":this.draw();break}}_databindAndDrawDebounced(){cancelAnimationFrame(this._handle),this._handle=requestAnimationFrame(()=>{this._databind(),this.draw()})}_databind(){this._datasource=pt.isNullOrEmpty(this.datasource)?this.items:this.datasource}disconnectedCallback(){this._div&&this._div.remove();let e=this._resizer;pt.isNull(e)||(e.removeEventListener(Fg.ResizeEventName,this._resizeHandler,!1),e.remove(),this._resizer=null),super.disconnectedCallback()}viewActivatedCallback(){super.viewActivatedCallback(),this._ensureResizer(),this._databind(),this.draw()}_ensureResizer(e=this.target||this._div){if(pt.isNull(this._resizer)){let t=bc.findAncestorShell(this);(this._resizer=t.appendChild(new Fg.PacemResizeElement)).addEventListener(Fg.ResizeEventName,this._resizeHandler,!1)}this._resizer.target=e}get chartSize(){return this._size}get chartSeries(){return this._series}get chartBody(){return this._body}get chartGrid(){return this._grid}get chartMask(){return this._mask}get chartKey(){return this._key}get chartContainer(){return this._div}assignUiBehaviors(e,t,n,i){let s=!pt.isNull(bc.getAttachedPropertyValue(e,b_)),o=pt.extend({series:t.label,color:i||t.color},n);bc.setAttachedPropertyValue(e,b_,o),bc.setAttachedPropertyValue(e,Hw,t),s||Jh.forEach(c=>{e.addEventListener(c,this._broadcastHandler)})}disposeUiBehaviors(e){bc.deleteAttachedPropertyValue(e,b_),bc.deleteAttachedPropertyValue(e,Hw),Jh.forEach(t=>{e.removeEventListener(t,this._broadcastHandler)})}ensureChartContainer(){if(pt.isNull(this._div)){let e=this._div=this.target||document.createElement("div");e.classList.add($w+"-chart-area"),e!=this.target&&this.parentElement.insertBefore(e,this)}return this._div}ensureChartBody(e,t,n){if(pt.isNull(this._body)){let i=this._body=document.createElementNS(ca,"svg");i.setAttribute("pacem",""),i.setAttribute("class",$w+"-"+e+"-chart"),i.setAttribute("preserveAspectRatio","xMinYMax slice");let s=this._grid=document.createElementNS(ca,"svg");s.setAttribute("pacem",""),s.setAttribute("class","chart-grid");let o=document.createElementNS(ca,"defs"),c=this._mask=document.createElementNS(ca,"mask"),d=document.createElementNS(ca,"rect");d.setAttribute("x","0"),d.setAttribute("y","0"),d.setAttribute("width","100%"),d.setAttribute("height","100%");let p=document.createElementNS(ca,"rect");p.setAttribute("y","0"),p.setAttribute("width","100%"),p.setAttribute("fill","#fff"),c.id="gnrc_mask_"+this._key,c.appendChild(d),c.appendChild(p),o.appendChild(c),i.appendChild(o),i.appendChild(s),this._div.appendChild(i)}return this._body}chartDataItemToPoint(e,t){switch(this.xAxisType||"string"){case"number":return{x:parseFloat(e.label),y:e.value};case"date":return{x:pt.parseDate(e.label).valueOf(),y:e.value};case"string":return{x:t.findIndex(n=>n.label==e.label),y:e.value};default:throw"Not supported."}}getVirtualGrid(e,t,n,i,s,o=this.xAxisType,c,d){let p=kU(i,s,c),u=p.round;var h=[];for(let b=p.min;b<=p.max;b+=u)h.push(b.roundoff());let m=pt.lang(this),f=null,g=this.xAxisFormat;if(!pt.isNullOrEmpty(g))switch(o){case"number":f=b=>Intl.NumberFormat(m,g).format(b);break;case"date":f=b=>Intl.DateTimeFormat(m,g).format(pt.parseDate(b));break}return{x:wU(e,o,t,n,f??m,d),y:h}}wipeOut(e=this._series,t=0){for(var n=e.length-1;n>=t;n--)e[n].remove();e.splice(t)}buildLinearGradient(e,t=!1){let n=document.createElementNS(ca,"linearGradient");n.id=this.chartKey+"_grad"+e+(t?"_inverted":""),t&&pt.addClass(n,"bottom-up"),n.setAttribute("x1","0%"),n.setAttribute("x2","0%"),n.setAttribute("y1","0%"),n.setAttribute("y2","100%"),n.setAttribute("spreadMethod","pad");let i=document.createElementNS(ca,"stop");i.setAttribute("offset","0%");let s=document.createElementNS(ca,"stop");return s.setAttribute("offset","100%"),n.appendChild(i),n.appendChild(s),n}setGradientColor(e,t){for(let n=0;n<e.children.length;n++){let i=e.children.item(n);i instanceof SVGStopElement&&(i.style.stopColor=t)}}estimateYAxisLabelWidth(e){let t=this.formatYAxisLabel(e);return this.estimateLabelWidth(t)}estimateLabelWidth(e){let t=this._grid;if(pt.isNull(t))throw new Error("Unable to estimate label without an underlying grid available.");let n=document.createElementNS(ca,"text");n.textContent=e,t.appendChild(n);let i=pt.offset(n);return n.remove(),i.width}formatYAxisLabel(e){let t=this.yAxisFormat;return pt.isNullOrEmpty(t)?e.toString():Intl.NumberFormat(pt.lang(this),t).format(e)}estimateXAxisLabelWidth(e){let t=this.formatXAxisLabel(e);return this.estimateLabelWidth(t)}formatXAxisLabel(e){let t=this.xAxisFormat,n=pt.lang(this);switch(this.xAxisType){case"date":let i=pt.Dates.parse(e);return pt.isNullOrEmpty(t)?i.toLocaleString(n):Intl.DateTimeFormat(n,t).format(i);case"number":let s=e;return pt.isNullOrEmpty(t)?s.toLocaleString(n):Intl.NumberFormat(n,t).format(s);default:return e}}draw(){this.drawSeries(this._datasource)}getAnchorPoint(e){let t=pt.offset(e);return{x:t.left+t.width*.5,y:t.top+t.height*.5}}};l([sn({converter:Cn.Element})],gr.prototype,"target",2),l([sn({emit:!1,converter:Cn.String})],gr.prototype,"xAxisType",2),l([sn({emit:!1,converter:Cn.String})],gr.prototype,"xAxisPosition",2),l([sn({emit:!1,converter:Cn.Json})],gr.prototype,"datasource",2),l([sn({emit:!1,converter:Cn.Number})],gr.prototype,"yAxisDensity",2),l([sn({emit:!1,converter:Cn.Number})],gr.prototype,"xAxisDensity",2),l([sn({emit:!1,converter:Cn.Number})],gr.prototype,"yAxisMin",2),l([sn({emit:!1,converter:Cn.Number})],gr.prototype,"yAxisMax",2),l([sn({emit:!1,converter:Cn.Json})],gr.prototype,"yAxisFormat",2),l([sn({emit:!1,converter:Cn.Json})],gr.prototype,"xAxisFormat",2),l([xU(!0)],gr.prototype,"draw",1);import{CustomElement as MU,Watch as BT,PropertyConverters as VT,P as SU,PCSS as LU,Utils as xi,CustomElementUtils as Bw,Logging as NU}from"@pacem/pacem-core";function TU(a,r,e){let t=a,n=a,i=xi.isNull(r),s=xi.isNull(e);if(!(i&&s)){let c,d;i||(c=(a.y-r.y)/(a.x-r.x)),s||(d=(e.y-a.y)/(e.x-a.x));let p=((d||c||0)+(c||d||0))/2,u=i?0:(a.x-r.x)/3,h=s?0:(e.x-a.x)/3;t={x:a.x-u,y:a.y-u*p},n={x:a.x+h,y:a.y+h*p}}return{c0:t,c1:n}}var UT=Bw.getAttachedPropertyValue,zT=Bw.setAttachedPropertyValue,dae=Bw.deleteAttachedPropertyValue,AU=24,__="pacem:chart-series:area",yc="http://www.w3.org/2000/svg",Zh,fp=class extends gr{constructor(){super(...arguments);$(this,Zh,!1);this._enterHandler=e=>{A(this,Zh,!0)};this._leaveHandler=e=>{A(this,Zh,!1)};this._moveHandler=e=>{x(this,Zh)};this._chartFillSeries=[]}_getVirtualGrid(e,t,n,i,s,o=this.xAxisType,c,d){return super.getVirtualGrid(e,t,n,i,s,o,c,d)}_wipe(e=this.chartSeries,t=0){super.wipeOut(e,t)}viewActivatedCallback(){super.viewActivatedCallback(),this._setupBehavior()}disconnectedCallback(){this._dismantleBehavior(),super.disconnectedCallback()}propertyChangedCallback(e,t,n,i){switch(super.propertyChangedCallback(e,t,n,i),e){case"type":case"aspectRatio":this.draw();break}}_setupBehavior(){this.addEventListener("mouseenter",this._enterHandler,!1),this.addEventListener("mouseleave",this._enterHandler,!1),this.addEventListener("mousemove",this._moveHandler,!1)}_dismantleBehavior(){this.removeEventListener("mouseenter",this._enterHandler,!1),this.removeEventListener("mouseleave",this._leaveHandler,!1),this.removeEventListener("mousemove",this._moveHandler,!1)}_buildLinearGradient(e){return super.buildLinearGradient(e)}_setGradientColor(e,t){super.setGradientColor(e,t)}drawSeries(e){if(!this.isReady||xi.isNull(this.chartSize))return;this.ensureChartContainer();let t=this.type||"line",n=AU;var i=this.chartSize;if(i.height<=n||i.width<=n)return;if(xi.isNullOrEmpty(e)||e.every(te=>xi.isNullOrEmpty(te.values))){this._wipe();return}let s=this.ensureChartBody("line",i.width,i.height);this.log(NU.LogLevel.Debug,`Drawing ${t} chart.`);let o=this.xAxisType||"string",c=this.yAxisMin??Number.NaN,d=this.yAxisMax??Number.NaN,p=Number.NaN,u=Number.NaN,h=1;for(let te of e){let ye=te.values;if(ye&&ye.length){let et=0;for(let Bi of ye){let Or=this.chartDataItemToPoint(Bi,ye);xi.isNull(this.yAxisMin)&&(c=isNaN(c)?Or.y:Math.min(c,Or.y)),xi.isNull(this.yAxisMax)&&(d=isNaN(d)?Or.y:Math.max(d,Or.y)),et===0?p=isNaN(p)?Or.x:Math.min(p,Or.x):et===ye.length-1&&(u=isNaN(u)?Or.x:Math.max(u,Or.x)),et++}}}let m=e.find(te=>!xi.isNullOrEmpty(te.values)),f=this._getVirtualGrid(m.values,p,u,c,d,o,this.yAxisDensity,this.xAxisDensity),g=f.y[f.y.length-1],v=f.y[0];if(g===v)return;let b=n*.5,_=f.y.reduce((te,ye)=>Math.max(te,this.estimateYAxisLabelWidth(ye)+b),n),E=f.x.reduce((te,ye)=>Math.max(te,this.estimateXAxisLabelWidth(ye)),n)*.5,C=Math.max(E,_),k=E,w=i.width-C-k,T=i.height-2*n,I=T*(1-(g-v-(d-c))/(g-v)),O=T*(g-d)/(g-v);(o!=="number"||this.aspectRatio!=="monometric"&&this.aspectRatio!=="logaritmic")&&(h=w/I,s.setAttribute("height",i.height.toString()),s.setAttribute("width",i.width.toString())),s.setAttribute("viewBox",`0 0 ${i.width} ${i.height}`);let D=0,P=u-p,N=d-c,H=100*h/P,V=100/N,B=100*n/I,R=(te,ye)=>{let et=this.chartDataItemToPoint(te,ye);return et.y*=V,et.x=(et.x-p)*H,et},U=this.chartSeries,z=this._chartFillSeries,G=this.chartGrid,Z=t==="spline"||t==="splinearea";for(let te of e){let ye,et,Bi;if(U.length>D)ye=U[D],et=z[D],Bi=et.firstElementChild.firstElementChild;else{ye=document.createElementNS(yc,"svg"),ye.setAttribute("pacem",""),s.appendChild(ye),et=document.createElementNS(yc,"svg"),et.setAttribute("pacem",""),s.insertBefore(et,s.children.item(D+2));let Ie=document.createElementNS(yc,"defs");Ie.appendChild(Bi=this._buildLinearGradient(D)),et.appendChild(Ie),et.appendChild(document.createElementNS(yc,"path")),z.push(et),ye.appendChild(document.createElementNS(yc,"path")),U.push(ye)}let Or="chart-series",he=t==="area"||t==="splinearea";xi.isNullOrEmpty(te.className)||(Or+=" "+te.className),[ye,et].forEach(Ie=>{Ie.setAttribute("class",Or),Ie.setAttribute("x",C.toString()),Ie.setAttribute("y",O.toString()),Ie.setAttribute("width",w.toString()),Ie.setAttribute("height",(I+2*n).toString())}),xi.addClass(et,LU+"-inert");let _e=et.children.item(1),Fe=ye.firstElementChild;Fe.style.stroke=te.color,_e.style.stroke=Fe.style.fill="none",this._setGradientColor(Bi,te.color),_e.style.fill=`url(#${Bi.id})`,_e.style.display=he?"":"none";let un="",Be=te.values;if(Be&&Be.length){let Ie=(sr,vt,Se,qe,ar)=>{let or=vt+1,Ke;ye.children.length>or?Ke=ye.children.item(or):(Ke=document.createElementNS(yc,"line"),Ke.setAttribute("class","circle"),ye.appendChild(Ke));let ni=sr.x.toString(),Vi=(-sr.y).toString();Ke.setAttribute("x1",ni),Ke.setAttribute("y1",Vi),Ke.setAttribute("x2",ni),Ke.setAttribute("y2",Vi),Ke.style.stroke=ar,this.assignUiBehaviors(Ke,Se,qe,ar)},Xv=()=>{let sr=te.datapoints?Be.length+1:1;for(let Se=ye.children.length-1;Se>=sr;Se--){var vt=ye.children.item(Se);this.disposeUiBehaviors(vt),vt.remove()}};if(Z){let sr,vt,Se;for(let qe=0;qe<Be.length;qe++){let ar=Be[qe];if(isNaN(ar.value))continue;vt||(vt=R(ar,Be));let or;Z&&qe<Be.length-1&&(or=R(Be[qe+1],Be));let Ke=UT(te,__,0);Ke+=ar.value,zT(te,__,Ke);var q=TU(vt,sr,or);un+=xi.isNullOrEmpty(un)?`M${vt.x},${-vt.y} `:`C${Se.x},${-Se.y} ${q.c0.x},${-q.c0.y} ${vt.x},${-vt.y} `,te.datapoints&&Ie(vt,qe,te,ar,te.color),sr=vt,vt=or,Se=q.c1}}else{let sr=0;for(let vt of Be){if(isNaN(vt.value))continue;let Se=R(vt,Be),qe=UT(te,__,0);qe+=vt.value,zT(te,__,qe),un+=xi.isNullOrEmpty(un)?`M${Se.x},${-Se.y} `:`L${Se.x},${-Se.y} `,te.datapoints&&Ie(Se,sr,te,vt,te.color),sr++}}Xv()}Fe.setAttribute("d",un),_e.setAttribute("d",un+`V${-c*V} H0 Z`),D++}this._wipe(z,D),this._wipe(U,D);let Q=100*h,Ne=100+2*B,ne=0,pe=d*V+B,ee=`${ne} ${-pe} ${Q} ${Ne}`;for(var J of U.concat(z))J.setAttribute("viewBox",ee);let ue=this.chartMask.children.item(1);if(ue.setAttribute("x",ne.toString()),ue.setAttribute("height",(i.height-n).toString()),G.setAttribute("viewBox",`0 0 ${i.width} ${i.height}`),f.x.length<=1||f.y.length<=1){for(let te=G.children.length-1;te>=0;te--)G.children.item(te).remove();return}let Te;G.children.length>0?Te=G.children.item(0):(Te=document.createElementNS(yc,"path"),G.appendChild(Te));let He=n*.25,ze=0,Fr=(te,ye,et,Bi)=>{let Or=te+1,he;return G.children.length<=Or?(he=document.createElementNS(yc,"text"),G.appendChild(he)):he=G.children.item(Or),he.textContent=Bi,he.setAttribute("x",ye.toString()),he.setAttribute("y",et.toString()),he},Cs=`M${C},${n} v${T}`,Mn=0,fl=w/(f.x.length-1),Na=T/(f.y.length-1);if(this.xAxisPosition!=="none")for(var gl of f.x){let te=C+Mn*fl;if(this.xAxisPosition==="top"){Cs+=` M${te},${n} v${-He}`;let ye=Fr(ze++,te,0,gl);ye.setAttribute("text-anchor","middle"),ye.setAttribute("alignment-baseline","hanging")}else{let ye=T+n;Cs+=` M${te},${ye} v${He}`,Fr(ze++,te,ye+n,gl).setAttribute("text-anchor","middle")}Mn++}Mn=0;for(var eu of f.y){let te=T+n-Mn*Na,ye=C-He;Cs+=` M${ye},${te} H${w+C}`;let et=this.formatYAxisLabel(eu);Fr(ze++,ye-He,te,et).setAttribute("text-anchor","end"),Mn++}Te.setAttribute("d",Cs);for(let te=G.children.length-1;te>ze;te--)G.children.item(te).remove()}};Zh=new WeakMap,l([BT({emit:!1,converter:VT.String})],fp.prototype,"type",2),l([BT({converter:VT.String})],fp.prototype,"aspectRatio",2),fp=l([MU({tagName:SU+"-chart"})],fp);import{CustomElement as DU,Watch as GT,PropertyConverters as FT,P as RU,Utils as Ci,Logging as OU}from"@pacem/pacem-core";var Qh="http://www.w3.org/2000/svg",Vw=24,gp=class extends gr{constructor(){super(...arguments);this.groupWidth=0}propertyChangedCallback(e,t,n,i){super.propertyChangedCallback(e,t,n,i),(e==="type"||e==="groupWidth")&&this.draw()}_safen(e=this.groupWidth){return Math.min(1,Math.max(e||.75,0))}drawSeries(e){if(!this.isReady||Ci.isNull(this.chartSize))return;let t=this.ensureChartContainer(),n=this.type||"cluster",i=Vw;var s=this.chartSize;if(s.height<=i||s.width<=i)return;if(Ci.isNullOrEmpty(e)||e.every(he=>Ci.isNullOrEmpty(he.values))){this.wipeOut();return}let o=this.ensureChartBody("column",s.width,s.height);this.log(OU.LogLevel.Debug,`Drawing ${n} chart.`);let c=this.xAxisType||"string",d=this.yAxisMin??0,p=this.yAxisMax??0,u=0,h=0,m=0,f=1,g={negative:[],positive:[]};for(let he of e){let _e=he.values;if(!Ci.isNullOrEmpty(_e)){let Fe=0;for(let un of _e){g.positive[Fe]=g.positive[Fe]||0,g.negative[Fe]=g.negative[Fe]||0;let Be=this.chartDataItemToPoint(un,_e);Ci.isNull(this.yAxisMin)&&(d=Math.min(d,Be.y)),Ci.isNull(this.yAxisMax)&&(p=Math.max(p,Be.y)),u=Math.min(u,Be.x),h=Math.max(h,Be.x),Be.y>0?g.positive[Fe]+=Be.y:Be.y<0&&(g.negative[Fe]+=Be.y),Fe++}m=Math.max(m,_e.length)}}let v=n==="stack";v&&(Ci.isNull(this.yAxisMin)&&(d=Math.min.apply(null,g.negative)),Ci.isNull(this.yAxisMax)&&(p=Math.max.apply(null,g.positive))),h===0&&h===u&&(h=1);let b=(h-u)/m,_=b*.5,E=b*this._safen(this.groupWidth),C=E*.5,k=e.find(he=>!Ci.isNullOrEmpty(he.values)),w=this.getVirtualGrid(k.values,u-_,h+_,d,p,c,this.yAxisDensity,this.xAxisDensity),T=w.y[w.y.length-1],I=w.y[0];if(T===I)return;let O=Vw*.5,D=w.y.reduce((he,_e)=>Math.max(he,this.estimateYAxisLabelWidth(_e)+O),i),P=s.width-D-i,N=s.height-2*i,H=N*(1-(T-I-(p-d))/(T-I)),V=N*(T-p)/(T-I);f=P/H,o.setAttribute("height",s.height.toString()),o.setAttribute("width",s.width.toString()),o.setAttribute("viewBox",`0 0 ${s.width} ${s.height}`);let B=0,R=h-u,U=p-d,z=100*f/R,G=100/U,Z=100*i/H,q=this.chartSeries,Q=this.chartGrid,Ne=(_-u)*z,ne=(he,_e)=>{let Fe=this.chartDataItemToPoint(he,_e);return{x:Ne+Fe.x*2*Ne,y:Fe.y*G}};var pe=new Array(m);for(let he of e){let _e,Fe,un,Be;if(q.length>B)_e=q[B],Fe=_e.firstElementChild.firstElementChild,un=_e.firstElementChild.lastElementChild,Be=_e.lastElementChild;else{_e=document.createElementNS(Qh,"svg"),_e.setAttribute("pacem",""),Q.insertAdjacentElement("afterend",_e);let Se=document.createElementNS(Qh,"defs");Se.appendChild(Fe=this.buildLinearGradient(B)),Se.appendChild(un=this.buildLinearGradient(B,!0)),_e.appendChild(Se),_e.appendChild(Be=document.createElementNS(Qh,"g")),q.push(_e)}var ee="chart-series series-fill";Ci.isNullOrEmpty(he.className)||(ee+=" "+he.className),_e.setAttribute("class",ee),_e.setAttribute("x",D.toString()),_e.setAttribute("y",V.toString()),_e.setAttribute("width",P.toString()),_e.setAttribute("height",(H+2*i).toString());let Ie=he.values,Xv=Se=>{for(;Se>=Be.children.length;)Be.appendChild(document.createElementNS(Qh,"rect"));let qe=Be.children.item(Se);qe.style.stroke=he.color;let ar=Ie[Se].value<0?un:Fe;return this.setGradientColor(ar,he.color),qe.style.fill=`url(#${ar.id})`,qe},sr=10,vt=(Se,qe,ar,or=qe)=>{let Ke=-Math.max(qe.y,ar.y),ni=Math.abs(ar.y-qe.y),Vi=()=>{Se.setAttribute("y",Ke.toFixed(sr)),Se.setAttribute("height",ni.toFixed(sr))};Se.hasAttribute("y")?Vi():(Se.setAttribute("y","-"+or.y.toFixed(sr)),Se.setAttribute("height","0"),requestAnimationFrame(Vi))};if(!Ci.isNullOrEmpty(Ie)){let Se=ne({value:0,label:Ie[0].label},Ie);if(v){let qe=C*z,ar=(E*z).toFixed(sr);for(let or=0;or<Ie.length;or++){let Ke=Ie[or];Ci.isNullOrEmpty(pe[or])&&(pe[or]={positive:0,negative:0});let ni=pe[or],Vi=ni.positive,qv=ni.negative,vl=Ke.value<0,wk=vl?qv:Vi+Ke.value,kk=vl?qv+Ke.value:Vi,Mk=ne({label:Ke.label,value:wk},Ie),tR=ne({label:Ke.label,value:kk},Ie),rR=Mk.x-qe,Kv=Xv(or);this.assignUiBehaviors(Kv,he,Ke),Kv.setAttribute("x",rR.toFixed(sr)),Kv.setAttribute("width",ar),vt(Kv,tR,Mk,Se),vl?ni.negative=kk:ni.positive=wk}}else{let qe=C*z,ar=qe*2/e.length,or=ar.toFixed(sr);for(let Ke=0;Ke<Ie.length;Ke++){let ni=Ie[Ke],Vi=ne(ni,Ie),qv=Vi.x-qe+ar*B,vl=Xv(Ke);this.assignUiBehaviors(vl,he,ni),vl.setAttribute("x",qv.toFixed(sr)),vl.setAttribute("width",or),vt(vl,Se,Vi)}}}for(let Se=Be.children.length-1;Se>=Ie?.length;Se--){let qe=Be.children.item(Se);this.disposeUiBehaviors(qe),qe.remove()}B++}this.wipeOut(q,B);let J=100*f,$e=100+2*Z,ue=0,Te=p*G+Z,He=`${ue} ${-Te} ${J} ${$e}`;for(var ze of q)ze.setAttribute("viewBox",He);let Cs=this.chartMask.children.item(1);if(Cs.setAttribute("x",ue.toString()),Cs.setAttribute("height",(s.height-i).toString()),Q.setAttribute("viewBox",`0 0 ${s.width} ${s.height}`),w.x.length<1||w.y.length<=1){for(let he=Q.children.length-1;he>=0;he--)Q.children.item(he).remove();return}let Mn;Q.children.length>0?Mn=Q.children.item(0):(Mn=document.createElementNS(Qh,"path"),Q.appendChild(Mn));let fl=Vw*.25,Na=0,gl=(he,_e,Fe,un)=>{let Be=he+1,Ie;return Q.children.length<=Be?(Ie=document.createElementNS(Qh,"text"),Q.appendChild(Ie)):Ie=Q.children.item(Be),Ie.textContent=un,Ie.setAttribute("x",_e.toString()),Ie.setAttribute("y",Fe.toString()),Ie},eu=`M${D},${i} v${N}`,te=0,ye=P/w.x.length,et=N/(w.y.length-1);if(this.xAxisPosition!=="none"){let he=ye*.5+D;for(var Bi of w.x){let _e=he+te*ye;if(this.xAxisPosition==="top"){eu+=` M${_e},${i} v${-fl}`;let Fe=gl(Na++,_e,0,Bi);Fe.setAttribute("text-anchor","middle"),Fe.setAttribute("alignment-baseline","hanging")}else{let Fe=N+i;eu+=` M${_e},${Fe} v${fl}`,gl(Na++,_e,Fe+i,Bi).setAttribute("text-anchor","middle")}te++}}te=0;for(var Or of w.y){let he=N+i-te*et,_e=D-fl;eu+=` M${_e},${he} H${P+D}`;let Fe=this.formatYAxisLabel(Or);gl(Na++,_e-fl,he,Fe).setAttribute("text-anchor","end"),te++}Mn.setAttribute("d",eu);for(let he=Q.children.length-1;he>Na;he--)Q.children.item(he).remove()}};l([GT({converter:FT.String})],gp.prototype,"type",2),l([GT({converter:FT.Number})],gp.prototype,"groupWidth",2),gp=l([DU({tagName:RU+"-column-chart"})],gp);import{CustomElement as WT,Watch as _c,PropertyConverters as xc,P as jT,PCSS as x_,Components as YT,Utils as Fn,CustomElementUtils as PU,Debounce as IU}from"@pacem/pacem-core";var da=class extends YT.PacemItemElement{constructor(){super(...arguments);this._broadcastHandler=e=>{this.emit(e)}}findContainer(){return PU.findAncestorOfType(this,us)}get chart(){return this.container}getCenterOfMass(){let e=this.chart&&this.chart.area;if(Fn.isNull(e))return null;let t=Fn.offset(e),n={x:t.width/2+t.left,y:t.top+t.height/2},i=Math.min(t.width,t.height)*.5,s=this.normalizedPolarCoords,o=HU-s.angle;return{y:n.y-i*s.radius*Math.sin(o),x:n.x+i*s.radius*Math.cos(o)}}propertyChangedCallback(e,t,n,i){super.propertyChangedCallback(e,t,n,i),!i&&this.chart&&e!="normalizedPolarCoords"&&this.chart.draw()}_assignUi(e){let t=this._ui=e;Jh.forEach(n=>{t.addEventListener(n,this._broadcastHandler)})}_disposeUi(){Fn.isNull(this._ui)||Jh.forEach(e=>{this._ui.removeEventListener(e,this._broadcastHandler)})}};l([_c({converter:xc.Number})],da.prototype,"value",2),l([_c({converter:xc.String})],da.prototype,"label",2),l([_c({converter:xc.String})],da.prototype,"color",2),l([_c({converter:xc.Json})],da.prototype,"normalizedPolarCoords",2),da=l([WT({tagName:jT+"-pie-slice"})],da);var $U=Math.PI*2,HU=Math.PI*.5,us=class extends YT.PacemItemsContainerElement{constructor(){super();this.cutout=0;this.slicePadding=0;this._slices=new WeakMap;this._key=Fn.uniqueCode()}validate(e){return e instanceof da}viewActivatedCallback(){super.viewActivatedCallback(),this.draw()}propertyChangedCallback(e,t,n,i){if(super.propertyChangedCallback(e,t,n,i),e==="target"){this._g=null,this._div&&this._div.remove();let s=t;s&&(s.classList.remove(x_+"-chart-area"),s.innerHTML=""),this.draw()}else!i&&(e==="cutout"||e==="items"||e==="slicePadding")&&this.draw()}get area(){return this._svg}disconnectedCallback(){this._div&&this._div.remove(),super.disconnectedCallback()}_ensureArea(){if(Fn.isNull(this._g)){let t=this.target||(this._div=document.createElement("div"));t.classList.add(x_+"-chart-area");let n=this._svg=document.createElementNS("http://www.w3.org/2000/svg","svg");n.setAttribute("pacem",""),n.setAttribute("preserveAspectRatio","xMidYMid meet"),n.setAttribute("viewBox","0 0 100 100"),n.classList.add(x_+"-pie-chart");let i=document.createElementNS("http://www.w3.org/2000/svg","defs"),s=this._g=document.createElementNS("http://www.w3.org/2000/svg","g");n.appendChild(i),n.appendChild(s),t.appendChild(n),this._div&&this.parentElement.insertBefore(t,this)}if(this.maskBasedRendering){if(Fn.isNull(this._mask)){let n=document.createElementNS("http://www.w3.org/2000/svg","mask");n.id="pie_mask_"+this._key;let i=document.createElementNS("http://www.w3.org/2000/svg","rect");i.setAttribute("x","0"),i.setAttribute("y","0"),i.setAttribute("width","100"),i.setAttribute("height","100"),i.setAttribute("fill","#fff");let s=this._mask=document.createElementNS("http://www.w3.org/2000/svg","circle");s.setAttribute("cx","50"),s.setAttribute("cy","50");let o=this._svg.firstElementChild;n.appendChild(i),n.appendChild(s),o.appendChild(n),this._g.setAttribute("mask",`url(#${n.id})`)}let t=50*this._safeCutout;this._mask.setAttribute("r",`${t}`)}else Fn.isNull(this._mask)||(this._svg.firstElementChild.innerHTML="",this._mask=null,this._g.removeAttribute("mask"));let e=this._safeSlicePaddingPixels;if(e>0){let t=this._svg.getCTM(),n=(e/t.a).roundoff(),i=this._sliceMaskId,s=this._svg.firstElementChild,o=s.querySelector(`#${i}`);Fn.isNull(o)?(o=document.createElementNS("http://www.w3.org/2000/svg","mask"),o.id=i,s.appendChild(o)):o.innerHTML="";let c=document.createElementNS("http://www.w3.org/2000/svg","path"),d=`M${50+n},0 H100 V100 H0 V0 H50 V50 h${n} Z`;c.setAttribute("d",d),c.setAttribute("fill","#fff"),o.appendChild(c)}return this._g}get _sliceMaskId(){return"pieslice_mask_"+this._key}get _safeCutout(){return Math.min(1,Math.max(0,this.cutout))||0}get _safeSlicePaddingPixels(){return Math.max(0,this.slicePadding??0)}_drawSlice(e,t,n,i){let s=t.value>.5*n?1:0,o=$U*t.value/n,c=360*i/n,d=t.value>=n?49.9:50*(1+Math.sin(o)),p=50*(1-Math.cos(o)),u=this._safeCutout,h=u*50;e.style.fill=t.color,e.style.transform=`rotate(${c}deg)`,e.style.transformOrigin="50% 50%";let m=this.maskBasedRendering?`M50,50 V0 A50,50 0 ${s} 1 ${d} ${p} L50,50 Z`:`M50,0 A50,50 0 ${s} 1 ${d} ${p} l${(50-d)*(1-u)},${(50-p)*(1-u)} A${h},${h} 0 ${s} 0 50,${50-h} Z`;e.setAttribute("d",m),t.normalizedPolarCoords={radius:u+Math.SQRT1_2*(1-u),angle:Math.PI*c/180+o/2}}_isSliceOk(e){return!e.disabled}_padSlice(e){this._safeSlicePaddingPixels>0?e.setAttribute("mask",`url(#${this._sliceMaskId})`):e.removeAttribute("mask")}draw(){let e=this._ensureArea(),t=e.children.length,n=this._svg.parentElement,i=0,s=0,o=0;if(Fn.isNullOrEmpty(this.items))e.innerHTML="",Fn.removeClass(n,"chart-has-data");else{Fn.addClass(n,"chart-has-data");for(let c of this.items)this._isSliceOk(c)&&(s+=c.value);if(s<=0)e.innerHTML="",Fn.removeClass(n,"chart-has-data");else for(let c of this.items){if(!this._isSliceOk(c))continue;let d;if(i>=t){let p=document.createElementNS("http://www.w3.org/2000/svg","g");p.setAttribute("class","chart-series "+x_+"-pie-slice"+(Fn.isNullOrEmpty(c.className)?"":" "+c.className)),d=document.createElementNS("http://www.w3.org/2000/svg","path"),p.appendChild(d),e.appendChild(p),c._assignUi(p),this._slices.set(p,c)}else d=e.children.item(i).firstElementChild;c.value>0?(this._drawSlice(d,c,s,o),this._padSlice(d),o+=c.value,d.removeAttribute("display")):d.setAttribute("display","none"),i++}}for(;i<e.children.length;){let c=this._slices,d=e.children.item(i);c.has(d)&&(c.get(d)._disposeUi(),c.delete(d)),e.removeChild(d)}}};l([_c({converter:xc.Number})],us.prototype,"cutout",2),l([_c({converter:xc.Element})],us.prototype,"target",2),l([_c({converter:xc.Boolean})],us.prototype,"maskBasedRendering",2),l([_c({converter:xc.Number})],us.prototype,"slicePadding",2),l([IU(!0)],us.prototype,"draw",1),us=l([WT({tagName:jT+"-pie-chart"})],us);var i0={};tt(i0,{LatLngBoundsConverter:()=>ZT,LatLngConverter:()=>_p,LayerLoadEventName:()=>lA,MapColorScheme:()=>k_,MapConsts:()=>UU,MapEvent:()=>an,MapItemAdapter:()=>yp,MapRelevantElement:()=>ha,MapType:()=>w_,MapUtils:()=>jn,PacemAzureMapAdapterElement:()=>ma,PacemGoogleMapAdapterElement:()=>Si,PacemLayerAdapter:()=>Ho,PacemLeafletMapAdapterElement:()=>wc,PacemMapAdapterElement:()=>fs,PacemMapCircleElement:()=>ms,PacemMapElement:()=>lt,PacemMapGeocodeElement:()=>hs,PacemMapGeolocateElement:()=>Uo,PacemMapLayerElement:()=>wi,PacemMapMarkerElement:()=>Wn,PacemMapOverlayElement:()=>bp,PacemMapOverlayImageElement:()=>Cc,PacemMapPolygonElement:()=>ua,PacemMapPolylineElement:()=>pa,PacemMapShapeElement:()=>ki,PacemMarkerAdapter:()=>Bo,PacemOverlayAdapter:()=>$o,PacemShapeAdapter:()=>Vo,isLatLng:()=>zU,isLatLngBounds:()=>GU});import{P as Ei,PCSS as XT,CustomElement as Ec,Watch as oe,Utils as Ee,PropertyConverters as me,CustomTypedEvent as BU,PropertyChangeEvent as KT,CustomElementUtils as JT,Debounce as VU,PropertyChangeEventName as C_,PacemEventTarget as E_}from"@pacem/pacem-core";var w_=(i=>(i.ROAD="road",i.SATELLITE="satellite",i.HYBRID="hybrid",i.TERRAIN="terrain",i.HIGH_CONTRAST="high_contrast",i))(w_||{}),k_=(t=>(t.LIGHT="light",t.DARK="dark",t.SYSTEM="system",t))(k_||{}),Mi={MAP_SELECTOR:Ei+"-map",LINK_SELECTOR:Ei+"-map-link",MARKER_SELECTOR:Ei+"-map-marker",POLYLINE_SELECTOR:Ei+"-map-polyline",CIRCLE_SELECTOR:Ei+"-map-circle",POLYGON_SELECTOR:Ei+"-map-polygon",RECTANGLE_SELECTOR:Ei+"-map-rectangle",LAYER_SELECTOR:Ei+"-map-layer",OVERLAY_IMAGE_SELECTOR:Ei+"-map-overlay-image",OVERLAY_PANEL_SELECTOR:Ei+"-map-overlay-panel",GEOCODER_SELECTOR:Ei+"-map-geocode",DEFAULT_COORDS:{lat:44.71418802507798,lng:10.296516444873811}},UU={DEFAULT_COORDS:Mi.DEFAULT_COORDS};function zU(a){return yt.isLatLng(a)}function GU(a){return Et.isLatLngBounds(a)}var qT="defaultMapTarget",_p={convert:a=>{let r=/^\s*([+\-\d\.]+)\s*,?\s*([+\-\d\.]+)\s*$/.exec(a);return r&&r.length>2?{lat:parseFloat(r[1]),lng:parseFloat(r[2])}:JSON.parse(a)},convertBack:a=>JSON.stringify(a)},ZT={convert:a=>{let r=/^\s*([+\-\d\.]+)\s*,?\s*([+\-\d\.]+)\s*,?\s*([+\-\d\.]+)\s*,?\s*([+\-\d\.]+)\s*$/.exec(a);return r&&r.length>4?{sw:{lat:parseFloat(r[3]),lng:parseFloat(r[4])},ne:{lat:parseFloat(r[1]),lng:parseFloat(r[2])}}:JSON.parse(a)},convertBack:a=>JSON.stringify(a)},jn=class{static parseCoords(r){if(r&&!isNaN(r.lat)&&!isNaN(r.lng))return[r.lat,r.lng];if(Ee.isArray(r)&&r.length>1)return[r[0],r[1]];if(/^\s*(\+|-)?[\d]+(.[\d]+)?\s*,\s*(\+|-)?[\d]+(.[\d]+)?\s*$/.test(r)){var e=r.split(",");return[parseFloat(e[0]),parseFloat(e[1])]}return[Mi.DEFAULT_COORDS.lat,Mi.DEFAULT_COORDS.lng]}static expandBounds(r,e){e&&(Array.isArray(e)||(e=[e.lat,e.lng]),r.push(e))}static isContentEmpty(r){return r.children.length==0}},ha=class extends E_{get map(){return this._map=this._map||JT.findAncestorOfType(this,lt)}propertyChangedCallback(r,e,t,n){if(super.propertyChangedCallback(r,e,t,n),!n&&r==="hide"){let i=this.map;i?.adapter?.fitBounds(i,!0)}}viewActivatedCallback(){super.viewActivatedCallback(),this.map&&this.map.register(this)}disconnectedCallback(){this.map&&this.map.unregister(this),super.disconnectedCallback()}};l([oe({converter:me.Boolean})],ha.prototype,"hide",2),l([oe({converter:me.Boolean})],ha.prototype,"inactive",2);var an=class extends BU{constructor(r,e){super(r,e)}},em,tm,rm,hs=class extends E_{constructor(){super(...arguments);this.debounce=1e3;$(this,em,!1);$(this,tm);$(this,rm)}get fetching(){return x(this,em)}_guards(){let e=this.results;if(!Ee.isNullOrEmpty(e)){let n=e[0];if(!Ee.isNull(this.position)&&yt.equals(this.position,n.position)&&this.search===n.fullAddress)return Promise.resolve(e)}let t=this.adapter;return Ee.isNull(t)||t.disabled||!t.active?Promise.resolve([]):null}propertyChangedCallback(e,t,n,i){switch(super.propertyChangedCallback(e,t,n,i),e){case"search":this.geocode(n);break;case"position":this.reverseGeocode(n);break;case"results":if(Ee.isNullOrEmpty(n))this.search="",this.position=null;else{let s=n[0];this.search=s.fullAddress,this.position=s.position}break}}_broadcastFetchingUpdate(e){e!==x(this,em)&&(A(this,em,e),this.dispatchEvent(new KT({propertyName:"fetching",oldValue:!e,currentValue:e})))}_fetch(e){let{promise:t,search:n,position:i,key:s}=e,o=x(this,rm);!Ee.isNull(o)&&yt.equals(o.position,i)&&(o.search||"")===(n||"")||(A(this,rm,{key:s,promise:t,position:i,search:n}),this._broadcastFetchingUpdate(!0),t.then(c=>{s===x(this,rm).key&&(this._broadcastFetchingUpdate(!1),this._successCallback(c))},c=>this._errorCallback(c)))}_debounce(e,t=this.debounce){x(this,tm)&&clearTimeout(x(this,tm)),A(this,tm,window.setTimeout(()=>{e()},t||0))}reverseGeocode(e=this.position,t=this.maxResults){this.disabled||this._debounce(()=>{let n=this._guards()??this.adapter.reverseGeocode(e,t||1);this._fetch({promise:n,position:e,key:Ee.uniqueCode()})})}geocode(e=this.search,t=this.maxResults){this.disabled||this._debounce(()=>{let n=this._guards()??this.adapter.geocode(e,t||10);this._fetch({promise:n,search:e,position:yt.Empty,key:Ee.uniqueCode()})})}_successCallback(e){let t=!Ee.isNullOrEmpty(e);(t||!Ee.isNullOrEmpty(this.results))&&e!==this.results&&(this.results=e,t&&this.dispatchEvent(new CustomEvent("success",{detail:e,bubbles:!1,cancelable:!1})))}_errorCallback(e){Ee.isNullOrEmpty(this.results)||(this.results=[]),this.dispatchEvent(new CustomEvent("error",{detail:e,bubbles:!1,cancelable:!1}))}};em=new WeakMap,tm=new WeakMap,rm=new WeakMap,l([oe({emit:!1,converter:me.Element})],hs.prototype,"adapter",2),l([oe({emit:!1,converter:me.Number})],hs.prototype,"maxResults",2),l([oe({emit:!1,converter:me.Number})],hs.prototype,"debounce",2),l([oe({emit:!0,converter:me.Json})],hs.prototype,"results",2),l([oe({emit:!0,converter:me.String})],hs.prototype,"search",2),l([oe({emit:!0,converter:_p})],hs.prototype,"position",2),hs=l([Ec({tagName:Mi.GEOCODER_SELECTOR})],hs);var fs=class extends E_{constructor(){super(...arguments);this.active=!0;this.#e=new Map;this.#t=new WeakMap;this.#r=new WeakMap;this.#n=new WeakMap;this.#i=new WeakMap}propertyChangedCallback(e,t,n,i){super.propertyChangedCallback(e,t,n,i),i||(this.active=!this.disabled&&this.isActive())}#e;#t;#r;#n;#i;get layerAdapters(){return this.#n}get overlayAdapters(){return this.#i}get markerAdapters(){return this.#t}get shapeAdapters(){return this.#r}hasMap(e){return this.#e.has(e)}enrolledMaps(){return this.#e.keys()}tryGetMap(e){let t=this.#e;return t.has(e)?t.get(e):null}getMap(e){return this.tryGetMap(e)?.map}async initialize(e){let t=this.#e;if(!t.has(e)){let n=await this.init(e);t.set(e,n);let i=this.#n;i.has(e)||i.set(e,this.buildLayerAdapterFor(e));let s=this.#i;s.has(e)||s.set(e,this.buildOverlayAdapterFor(e));let o=this.#t;o.has(e)||o.set(e,this.buildMarkerAdapterFor(e));let c=this.#r;return c.has(e)||c.set(e,this.buildShapeAdapterFor(e)),n.container}return t.get(e).container}destroy(e){let t=this.#n;t.has(e)&&t.delete(e);let n=this.#i;n.has(e)&&n.delete(e);let i=this.#t;i.has(e)&&i.delete(e);let s=this.#r;s.has(e)&&s.delete(e);let o=this.#e;o.has(e)&&(this.dispose(e),o.delete(e))}removeItem(e){let t=e.map;if(e instanceof wi){let n=this.layerAdapters;n.has(t)&&n.get(t).removeLayer(e)}else if(e instanceof Wn){let n=this.markerAdapters;n.has(t)&&n.get(t).removeMarker(e)}else if(e instanceof ki){let n=this.shapeAdapters;n.has(t)&&n.get(t).removeShape(e)}else if(e instanceof bp){let n=this.overlayAdapters;n.has(t)&&n.get(t).removeOverlay(e)}e.inactive||this.fitBounds(t,!0)}drawItem(e){let t=e.map;if(e instanceof wi){let n=this.layerAdapters;n.has(t)&&n.get(t).drawLayer(e)}else if(e instanceof Wn){let n=this.markerAdapters;n.has(t)&&n.get(t).drawMarker(e)}else if(e instanceof ki){let n=this.shapeAdapters;n.has(t)&&n.get(t).drawShape(e)}else if(e instanceof bp){let n=this.overlayAdapters;n.has(t)&&n.get(t).drawOverlay(e)}e.inactive||this.fitBounds(t,!0)}popupInfoWindow(e){let t=e.map;if(e instanceof Wn){let n=this.markerAdapters;n.has(t)&&n.get(t).openInfoWindow(e)}}popoutInfoWindow(e){let t=e.map;if(e instanceof Wn){let n=this.markerAdapters;n.has(t)&&n.get(t).closeInfoWindow(e)}}setView(e,t,n){if(!this.hasMap(e))return;let i={};typeof t=="number"?i=Ee.extend({},{zoom:t}):yt.isLatLng(t)?i=Ee.extend({},{center:t,zoom:n}):i=t,this.setViewNative(e,i)}fitBounds(e,t){if(!Ee.isNull(e))this._fitBounds(e,t);else for(let n of this.enrolledMaps()||[])this._fitBounds(n,t)}_fitBounds(e,t){if(!this.hasMap(e)||!e.autofit&&t===!0)return;if(Et.isLatLngBounds(t)&&!Et.isEmpty(t)){this.fitBoundsNative(e,t);return}let n=this.markerAdapters.get(e)?.getBounds(),i=this.shapeAdapters.get(e)?.getBounds(),s=Ee.isNull(n)||Et.isEmpty(n),o=Ee.isNull(i)||Et.isEmpty(i);if(s&&o){this.setView(e,{center:e.center,zoom:e.zoom});return}let c=Et.Empty;s||(c=Et.union(c,n)),o||(c=Et.union(c,i)),Et.isPoint(c)?this.setView(e,{zoom:e.zoom,center:c.ne}):this.fitBoundsNative(e,c)}updateMapElement(e,t,n){["type","tilt","heading"].forEach(o=>{o in t&&(e[o]=t[o])});let i="zoom"in t?t.zoom:n;!Ee.isNullOrEmpty(i)&&i!==e.zoom&&(e.zoom=i);let s=yt.isLatLng(t)?t:t.center;!Ee.isNullOrEmpty(s)&&(s.lat!=e.center?.lat||s.lng!=e.center?.lng)&&(e.center=s),e.updateBounds(this.getBounds(e))}};l([oe({emit:!0,converter:me.Boolean})],fs.prototype,"active",2),l([VU(1e3,(e,t)=>`pacem:debounce:${e}:${t.id}`)],fs.prototype,"_fitBounds",1);var yp=class{constructor(r,e=r.adapter){this._map=r;this._adapter=e}get adapter(){return this._adapter}get map(){return this._map}getMap(r){return this._adapter.getMap(r.map)}},$o=class extends yp{constructor(r,e=r.adapter){super(r,e)}#e=new Map;get layers(){return this.#e}onOverlayLoad(r,e){r.dispatchEvent(new Event("overlayload"))}ensureOverlay(r,e){let t=this,n=t.#e,i;return n.has(r)?i=n.get(r):(i=this.buildOverlay(r,e),Ee.isNull(i)||n.set(r,i)),i}removeOverlay(r){let e=this,t=e.getMap(r),n=this.#e;if(n.has(r)){let i=n.get(r);e.deleteOverlay(i,t),n.delete(r)}}drawOverlay(r){let e=this,t=e.getMap(r);if(Ee.isNull(t))return;if(Ee.isNullOrEmpty(r)||r.hide){e.removeOverlay(r);return}let n=this.ensureOverlay(r,t);this.setBounds(n,t,r.bounds),this.updateOverlay(n,t,r)}},bp=class extends ha{};l([oe({emit:!1,converter:ZT})],bp.prototype,"bounds",2);var Cc=class extends bp{};l([oe({emit:!1,converter:me.String})],Cc.prototype,"src",2),Cc=l([Ec({tagName:Mi.OVERLAY_IMAGE_SELECTOR})],Cc);var Ho=class extends yp{constructor(r,e=r.adapter){super(r,e)}#e=new Map;#t=new Map;get layers(){return this.#e}onTileLoad(r,e){r.dispatchEvent(new Event("tileload"))}ensureLayer(r,e){let t=this,n=t.#e,i;if(n.has(r))i=n.get(r);else if(i=this.buildLayer(r,e),i!=null){let s=o=>{t.onTileLoad(r,o)};this.#t.set(r,s),this.addLoadEventListener(i,e,s),n.set(r,i)}return i}removeLayer(r){let e=this,t=e.getMap(r),n=this.#e;if(n.has(r)){let i=n.get(r),s=this.#t;if(s.has(r)){let o=s.get(r);this.removeLoadEventListener(i,t,o),s.delete(r)}e.deleteLayer(i,t),n.delete(r)}}drawLayer(r){let e=this,t=e.getMap(r);if(!Ee.isNull(t)){if(Ee.isNullOrEmpty(r)||r.hide){e.removeLayer(r);return}this.ensureLayer(r,t)}}},wi=class extends ha{};l([oe({emit:!1,converter:me.String})],wi.prototype,"url",2),l([oe({emit:!1,converter:me.Json})],wi.prototype,"include",2),l([oe({emit:!1,converter:me.String})],wi.prototype,"mode",2),l([oe({emit:!1,converter:me.Number})],wi.prototype,"minZoom",2),l([oe({emit:!1,converter:me.Number})],wi.prototype,"maxZoom",2),wi=l([Ec({tagName:Mi.LAYER_SELECTOR})],wi);var Bo=class extends yp{constructor(r,e=r.adapter){super(r,e)}get mapAutomaticallyScrollsOnDrag(){return!1}#e=new Map;#t=new Map;getBounds(r=e=>!0){let e=this.markers,t=Et.Empty;for(var n of e.keys()){if(!r(n)||n.inactive)continue;let i=e.get(n);Ee.isNull(i)||(t=Et.union(t,this.getMarkerPosition(i)))}return t}get markers(){return this.#e}get infoWindows(){return this.#t}onDragEnd(r,e){let t=this.markers.get(r),n=this.getMarkerPosition(t);r.onDragEnd(n)}onClick(r,e){let t=this.markers.get(r),n=this.getMarkerPosition(t);r.onClick(n)}onInfoOpen(r){r.onInfoOpen()}onInfoClose(r){r.onInfoClose()}ensureMarker(r,e){let t=this,n;return t.markers.has(r)?n=t.markers.get(r):(n=this.buildMarker(r,e),n!=null&&(this.addClickEventListener(n,e,i=>{t.onClick(r,i),t.openInfoWindow(r,i)}),this.addDragEventListener(n,e,i=>{this.mapAutomaticallyScrollsOnDrag||t.adapter.fitBounds(r.map,!0)}),this.addDragEndEventListener(n,e,i=>t.onDragEnd(r,i)),t.markers.set(r,n))),n}removeMarker(r){let e=this,t=e.getMap(r),n=this.#t,i=this.#e;if(n.has(r)&&n.delete(r),i.has(r)){let s=i.get(r);e.deleteMarker(s,t),i.delete(r)}}drawMarker(r){let e=this,t=e.getMap(r);if(Ee.isNull(t))return;if(Ee.isNullOrEmpty(r&&r.position)||r.hide){e.removeMarker(r);return}let n=this.ensureMarker(r,t);this.setPosition(n,r.position),this.setIcon(n,r.icon),this.setLabel(n,r.caption),this.setDraggable(n,r.draggable)}closeInfoWindow(r,e){let t=this;if(t.infoWindows.has(r)){let n=t.infoWindows.get(r);this.closeInfo(n)}}ensureInfoWindow(r,e){var t=this;let n;return t.infoWindows.has(r)?n=t.infoWindows.get(r):(n=this.buildInfoWindow(r),this.addCloseClickEventListener(n,e,i=>{t.deleteInfoWindow(n,e),t.onInfoClose(r)}),t.infoWindows.set(r,n)),n}openInfoWindow(r,e){var t=this,n=t.markers.get(r),i=r.caption,s=t.getMap(r);if(jn.isContentEmpty(r)||(i=r.innerHTML),!Ee.isNullOrEmpty(i)){let o=this.ensureInfoWindow(r,s);this.setContent(o,i),this.openInfo(o,i,s,n),t.onInfoOpen(r)}}},Wn=class extends ha{onDragEnd(r){this.position=r,this.dispatchEvent(new an("dragend",{position:r}))}onClick(r){this.position=r,this.dispatchEvent(new an("click",{position:r}))}onInfoOpen(){this.dispatchEvent(new an("openinfo"))}onInfoClose(){this.dispatchEvent(new an("closeinfo"))}};l([oe({converter:_p})],Wn.prototype,"position",2),l([oe({converter:me.Json})],Wn.prototype,"icon",2),l([oe({converter:me.String})],Wn.prototype,"caption",2),l([oe({converter:me.Boolean})],Wn.prototype,"draggable",2),Wn=l([Ec({tagName:Mi.MARKER_SELECTOR})],Wn);var Vo=class extends yp{constructor(r,e=r.adapter){super(r,e)}#e=new Map;get shapes(){return this.#e}getBounds(r=e=>!0){let e=this.shapes,t=Et.Empty;for(var n of e.keys()){if(!r(n)||n.inactive)continue;let i=e.get(n);Ee.isNull(i)||(t=Et.union(t,this.getShapeBounds(i)))}return t}removeShape(r){let e=this,t=e.getMap(r),n=this.#e;if(n.has(r)){let i=n.get(r);e.deleteShape(i,t),n.delete(r)}}_dispatchEvent(r,e,t){let n=this.shapes.get(r),i=this.getShapePosition(t??n);r.dispatchEvent(new an(e,{position:i}))}#t=new Map;onDragStart(r,e){let t=this.shapes.get(r),n=this.getShapeBounds(t);this.#t.set(r,n.ne),this._dispatchEvent(r,"dragstart",e)}onDragEnd(r,e){let t=this.shapes.get(r),n=this.getShapeBounds(t),i=this.#t.get(r),s=n.ne,o={lat:s.lat-i.lat,lng:s.lng-i.lng};this._translateShape(r,o),this._dispatchEvent(r,"dragend",e)}_translateShape(r,e){if(r instanceof ms){r.center=yt.translate(r.center,e);return}if(r instanceof pa){let t=r.vertices.map(n=>yt.translate(n,e));r.vertices=t;return}if(r instanceof ua){let t=r.vertices.map(n=>yt.translate(n,e));r.vertices=t;return}}onDrag(r,e){this._dispatchEvent(r,"drag",e)}onClick(r,e){this._dispatchEvent(r,"click",e)}ensureShape(r,e){let t=this,n;return t.shapes.has(r)?n=t.shapes.get(r):(n=this.buildShape(r,e),n!=null&&(this.addClickEventListener(n,i=>t.onClick(r,i)),this.addDragEventListener(n,i=>{t.onDrag(r,i),t.adapter.fitBounds(r.map,!0)}),this.addDragEndEventListener(n,i=>t.onDragEnd(r,i)),this.addDragStartEventListener(n,i=>t.onDragStart(r,i)),t.shapes.set(r,n))),n}drawShape(r){let e=this,t=e.getMap(r);if(Ee.isNull(t))return;if(Ee.isNullOrEmpty(r)||r.hide){e.removeShape(r);return}let n=this.ensureShape(r,t);this.setShape(n,r),this.setEditable(n,r.editable),this.setDraggable(n,r.draggable)}},ki=class extends ha{};l([oe({emit:!0,converter:me.Boolean})],ki.prototype,"draggable",2),l([oe({emit:!0,converter:me.Boolean})],ki.prototype,"editable",2),l([oe({emit:!0,converter:me.Json})],ki.prototype,"stroke",2),l([oe({emit:!0,converter:me.Json})],ki.prototype,"fill",2);var pa=class extends ki{};l([oe({emit:!0,converter:me.Json})],pa.prototype,"vertices",2),pa=l([Ec({tagName:Mi.POLYLINE_SELECTOR})],pa);var ua=class extends ki{};l([oe({emit:!0,converter:me.Json})],ua.prototype,"vertices",2),ua=l([Ec({tagName:Mi.POLYGON_SELECTOR})],ua);var ms=class extends ki{};l([oe({emit:!0,converter:_p})],ms.prototype,"center",2),l([oe({emit:!0,converter:me.Json})],ms.prototype,"radius",2),ms=l([Ec({tagName:Mi.CIRCLE_SELECTOR})],ms);var vp,lt=class extends E_{constructor(){super(...arguments);this.zoom=12;this.center=Mi.DEFAULT_COORDS;$(this,vp,Et.Empty);this.scale=!0;this.mousewheel=!0;this.draggable=!0;this.doubleClickZoom=!0;this.keyboardShortcuts=!0;this.autofit=!0;this.paddingTop=0;this.paddingLeft=0;this.paddingRight=0;this.paddingBottom=0;this.tilt=0;this.heading=0;this._drawHandler=e=>{this._draw(e.target)};this._listenToActiveAdapter=e=>{let t=e.target;e.detail.propertyName==="active"&&e.detail.currentValue&&(t.removeEventListener(C_,this._listenToActiveAdapter,!1),this._switchAdapter(t))};this._initialized=!1;this._afterInit=(e,t)=>{this._initialized=!0;for(var n of JT.findDescendants(this,i=>i instanceof ha))this._erase(n,t),this._draw(n);t&&t?.destroy(this)};this._resizeHandler=e=>{this.onResize(e)}}updateBounds(e){if(!Et.equals(e,x(this,vp))){let t=x(this,vp),n=A(this,vp,e);this.dispatchEvent(new KT({propertyName:"bounds",oldValue:t,currentValue:n}))}}get bounds(){return x(this,vp)}get container(){return this._container}register(e){e.addEventListener(C_,this._drawHandler,!1),this._draw(e)}unregister(e){this._erase(e),e.removeEventListener(C_,this._drawHandler,!1)}_draw(e,t=this.adapter){this._initialized&&t&&t.drawItem(e)}_erase(e,t=this.adapter){this._initialized&&t&&t.removeItem(e)}_switchAdapter(e,t){e.active?e.initialize(this).then(n=>this._afterInit(n,t)):(t&&this._afterInit(null,t),e.addEventListener(C_,this._listenToActiveAdapter,!1))}viewActivatedCallback(){super.viewActivatedCallback(),this._setupContainer(),this.adapter&&this._switchAdapter(this.adapter)}propertyChangedCallback(e,t,n,i){if(super.propertyChangedCallback(e,t,n,i),e!=="bounds")if(e==="adapter")Ee.isNull(this._container)||(this._initialized=!1,n?this._switchAdapter(n,t):t&&this._afterInit(null,t));else{switch(e){case"zoom":case"center":case"type":case"theme":case"tilt":case"heading":this.adapter?.setView(this,{type:this.type,tilt:this.tilt,heading:this.heading,zoom:this.zoom,center:this.center,theme:this.theme});break;case"autofit":n&&this.adapter?.fitBounds(this);break;case"target":t&&this._dismissContainer(t),n?(this._setupContainer(n),this._setupResizer()):this._dismissResizer();break}this.adapter&&this.adapter.invalidateSize(this)}}_dismissContainer(e=this._container){e.dataset[qT]==="true"?e.remove():Ee.removeClass(e,XT+"-map"),e===this._container&&(this._container=null)}_dismissResizer(){let e=this._resizer;e.removeEventListener("resize",this._resizeHandler,!1),e.remove(),this._resizer=null}_setupContainer(e=this.target){Ee.isNull(e)&&(e=document.createElement("div"),e.dataset[qT]="true",this.insertAdjacentElement("afterend",e));let t=this._container=e;return Ee.addClass(t,XT+"-map"),t}_setupResizer(){let e=this._container;if(Ee.isNull(e))throw new Error("You must set up the map container before its resizing listener.");if(Ee.isNull(this._resizer)){let t=this._resizer=document.createElement(Ei+"-resize");t.addEventListener("resize",this._resizeHandler,!1),e.insertAdjacentElement("afterend",t)}return this._resizer.target=e,this._resizer}_detach(){Ee.isNull(this._container)||this._dismissContainer(),Ee.isNull(this._resizer)||this._dismissResizer()}disconnectedCallback(){this._detach(),super.disconnectedCallback()}onResize(e){this.adapter&&this.adapter.invalidateSize(this)}};vp=new WeakMap,l([oe({emit:!0,converter:me.Number})],lt.prototype,"zoom",2),l([oe({emit:!0,converter:_p})],lt.prototype,"center",2),l([oe({emit:!1,converter:me.String})],lt.prototype,"type",2),l([oe({emit:!1,converter:me.String})],lt.prototype,"theme",2),l([oe({emit:!1,converter:me.Boolean})],lt.prototype,"scale",2),l([oe({emit:!1,converter:me.Boolean})],lt.prototype,"mousewheel",2),l([oe({emit:!1,converter:me.String})],lt.prototype,"zoomControl",2),l([oe({emit:!1,converter:me.Boolean})],lt.prototype,"draggable",2),l([oe({emit:!1,converter:me.Boolean})],lt.prototype,"doubleClickZoom",2),l([oe({emit:!1,converter:me.Boolean})],lt.prototype,"keyboardShortcuts",2),l([oe({emit:!1,converter:me.Boolean})],lt.prototype,"autofit",2),l([oe({emit:!1,converter:me.Number})],lt.prototype,"paddingTop",2),l([oe({emit:!1,converter:me.Number})],lt.prototype,"paddingLeft",2),l([oe({emit:!1,converter:me.Number})],lt.prototype,"paddingRight",2),l([oe({emit:!1,converter:me.Number})],lt.prototype,"paddingBottom",2),l([oe({emit:!1,converter:me.Element})],lt.prototype,"adapter",2),l([oe({emit:!1,converter:me.Element})],lt.prototype,"target",2),l([oe({emit:!1,converter:me.Number})],lt.prototype,"tilt",2),l([oe({emit:!1,converter:me.Number})],lt.prototype,"heading",2),lt=l([Ec({tagName:Mi.MAP_SELECTOR})],lt);import{Utils as FU,CustomElement as WU,Watch as M_,P as jU,PropertyConverters as zw,PropertyChangeEvent as YU,PacemEventTarget as XU}from"@pacem/pacem-core";var Wg={GEOLOCATION_UNAVAILABLE:"geolocation_unavailable",POSITION_UNAVAILABLE:"position_unavailable",PERMISSION_DENIED:"permission_denied",TIMEOUT:"timeout",UNKNOWN_ERROR:"unknown_error"},jg,Uo=class extends XU{constructor(){super(...arguments);this.permission="prompt";this.maximumAge=15e3;this.timeout=3e4;$(this,jg,!1);this._successCallback=e=>{this.permission="granted",this._setFetching(!1);let t={lat:e.coords.latitude,lng:e.coords.longitude,timestamp:e.timestamp,altitude:e.coords.altitude,heading:e.coords.heading,speed:e.coords.speed};this.position=t,this.dispatchEvent(new CustomEvent("success",{detail:t}))};this._errorCallback=e=>{this._setFetching(!1);let t=typeof e=="string"?e:this._errToString(e);this.dispatchEvent(new CustomEvent("error",{detail:t}))}}_checkPermission(){return new Promise(e=>{let t=navigator.permissions;FU.isNull(t)?e("prompt"):t.query({name:"geolocation"}).then(n=>{e(this.permission=n.state)})})}get fetching(){return x(this,jg)}_setFetching(e){e!==this.fetching&&(A(this,jg,e),this.dispatchEvent(new YU({propertyName:"fetching",currentValue:e,oldValue:!e})))}fetch(){if(!this.disabled){if(!navigator.geolocation){this._errorCallback(Wg.GEOLOCATION_UNAVAILABLE);return}this._checkPermission().then(e=>{this._setFetching(!0),navigator.geolocation.getCurrentPosition(this._successCallback,this._errorCallback,{enableHighAccuracy:!0,maximumAge:this.maximumAge})})}}viewActivatedCallback(){super.viewActivatedCallback(),this._checkPermission()}_errToString(e){switch(e.code){case GeolocationPositionError.PERMISSION_DENIED:return Wg.PERMISSION_DENIED;case GeolocationPositionError.POSITION_UNAVAILABLE:return Wg.POSITION_UNAVAILABLE;case GeolocationPositionError.TIMEOUT:return Wg.TIMEOUT;default:return Wg.UNKNOWN_ERROR}}};jg=new WeakMap,l([M_({emit:!0,converter:_p})],Uo.prototype,"position",2),l([M_({emit:!0,converter:zw.String})],Uo.prototype,"permission",2),l([M_({emit:!1,converter:zw.Number})],Uo.prototype,"maximumAge",2),l([M_({emit:!1,converter:zw.Number})],Uo.prototype,"timeout",2),Uo=l([WU({tagName:jU+"-map-geolocate"})],Uo);import{Utils as Lr,CustomElement as qU,Watch as QT,P as KU,PropertyConverters as eA,CustomElementUtils as tA,Debounce as JU}from"@pacem/pacem-core";var rA={TIMEOUT:1e3,API_JS:"https://atlas.microsoft.com/sdk/javascript/mapcontrol/3/atlas.min.js",API_CSS:"https://atlas.microsoft.com/sdk/javascript/mapcontrol/3/atlas.min.css"};function nA(a){return{city:a.municipality,state:a.countrySubdivision,province:a.countrySecondarySubdivision,village:a.municipalitySubdivision??a.localName,zipCode:a.postalCode,streetName:a.street??a.streetName,houseNumber:a.buildingNumber??a.streetNumber,countryCode:a.countryCode,country:a.country}}var gs=class a{static getPosition(r){return Array.isArray(r)&&(r={lat:r[0],lng:r[1]}),atlas.data.Position.fromLatLng(r)}static getBounds(r){if(Lr.isArray(r))return atlas.data.BoundingBox.fromPositions(r.map(n=>[n[1],n[0]]));let e=a.getPosition(r.ne),t=a.getPosition(r.sw);return atlas.data.BoundingBox.fromPositions([e,t])}static getLatLng(r){return{lat:r[1],lng:r[0]}}static getLatLngBounds(r){let e=atlas.data.BoundingBox.getNorthEast(r),t=atlas.data.BoundingBox.getSouthWest(r);return{ne:a.getLatLng(e),sw:a.getLatLng(t)}}static parseGeocoding(r){return Lr.isNullOrEmpty(r.results)?[]:r.results.map(e=>({fullAddress:e.address.freeformAddress,address:nA(e.address),position:{lat:e.position.lat,lng:e.position.lon,altitude:null}}))}static parseReverseGeocoding(r,e){if(r.summary.numResults<1)return{fullAddress:"",address:{},position:null};let t=r.addresses[0],n=(e??t.position).split(",").map(o=>parseFloat(o)),i=t.address;return{fullAddress:i.freeformAddress,address:nA(i),position:{lat:n[0],lng:n[1],altitude:n.length>2?n[2]:null}}}},Gw=class extends $o{deleteOverlay(r,e){throw new Error("Method not implemented.")}buildOverlay(r,e){throw new Error("Method not implemented.")}setBounds(r,e,t){throw new Error("Method not implemented.")}updateOverlay(r,e,t){throw new Error("Method not implemented.")}},Fw=class extends Ho{addLoadEventListener(r,e,t){throw new Error("Method not implemented.")}removeLoadEventListener(r,e,t){throw new Error("Method not implemented.")}deleteLayer(r,e){throw new Error("Method not implemented.")}buildLayer(r,e){throw new Error("Method not implemented.")}},Ww=class extends Bo{getMarkerPosition(r){let e=r.getOptions().position;return gs.getLatLng(e)}buildMarker(r,e){let t=new atlas.HtmlMarker;return e.markers.add(t),t.setOptions({popup:new atlas.Popup}),t}addClickEventListener(r,e,t){e.events.add("click",r,t)}addDragEventListener(r,e,t){e.events.add("drag",r,t)}addDragEndEventListener(r,e,t){e.events.add("dragend",r,t)}_setPopupPosition(r,e){let t=this._getPopup(r);Lr.isNull(t)||t.setOptions({position:e})}setPosition(r,e){let t=gs.getPosition(e);r.setOptions({position:t}),this._setPopupPosition(r,t)}setIcon(r,e){let t={pixelOffset:[0,-36]},n={popup:new atlas.Popup},i=(s,o,c)=>`<img width="${o||"auto"}" height="${c||"auto"}" style="pointer-events: none" src="${s}" />`;if(typeof e=="string")n.htmlContent=i(e);else if(!Lr.isNull(e)){let s=e.size,o=e.anchor;n.htmlContent=i(e.url,s&&s.width,s&&s.height),o?(n.anchor="top-left",n.pixelOffset=[-o.x,-o.y],t.pixelOffset=[0,-o.y]):s&&s.height&&(t.pixelOffset=[0,-s.height/2])}n.popup.setOptions(t),r.setOptions(n)}setLabel(r,e){let t={text:e};r.setOptions(t)}setDraggable(r,e){let t={draggable:e};r.setOptions(t)}deleteMarker(r,e){e.markers.remove(r)}deleteInfoWindow(r,e){this._getPopup(r).remove()}closeInfo(r){let e=this._getPopup(r);e?.isOpen()===!0&&e.close()}openInfo(r,e,t,n){let{popup:i,position:s}=r.getOptions();this._setContent(i,e,s),n.togglePopup(),t.events.addOnce("close",i,o=>{i.setOptions({content:""})})}buildInfoWindow(r){return this.markers.get(r)}addCloseClickEventListener(r,e,t){let n=this._getPopup(r);e.events.add("close",n,t)}setContent(r,e){let{popup:t,position:n}=r.getOptions();this._setContent(t,e,n)}_getPopup(r){return r.getOptions().popup}_setContent(r,e,t){r.setOptions({content:`<div style="padding: 8px 24px 8px 8px;">${e}</div>`,position:t})}},jw=class extends Vo{addDragStartEventListener(r,e){throw new Error("Method not implemented.")}deleteShape(r,e){throw new Error("Method not implemented.")}getShapeBounds(r){throw new Error("Method not implemented.")}getShapePosition(r){throw new Error("Method not implemented.")}buildShape(r,e){throw new Error("Method not implemented.")}addClickEventListener(r,e){throw new Error("Method not implemented.")}addDragEventListener(r,e){throw new Error("Method not implemented.")}addDragEndEventListener(r,e){throw new Error("Method not implemented.")}setShape(r,e){throw new Error("Method not implemented.")}setEditable(r,e){throw new Error("Method not implemented.")}setDraggable(r,e){throw new Error("Method not implemented.")}},S_=class{_buildGeocodeRequest(r,e,t=10,n=""){let i="https://atlas.microsoft.com/search/address/json?api-version=1.0",s={"subscription-key":r,query:e,limit:""+t,language:n};return{uri:Lr.URIs.appendQuery(i,s),options:{mode:"cors"}}}parseGeocodeResponse(r){return new Promise((e,t)=>{r.json().then(n=>{let i=gs.parseGeocoding(n);e(i)},n=>t(n))})}geocode(r,e,t=10,n=""){return new Promise((i,s)=>{let o=this._buildGeocodeRequest(r,e,t,n);return fetch(o.uri,o.options).then(c=>{c.ok?this.parseGeocodeResponse(c).then(i,s):s(c)},c=>s(c))})}reverseGeocode(r,e,t=""){return new Promise((n,i)=>{let s=this._buildReverseRequest(r,e,t);return fetch(s.uri,s.options).then(o=>{o.ok?this._parseReverseResponse(o).then(n,i):i(o)},o=>i(o))})}_buildReverseRequest(r,e,t=""){let n="https://atlas.microsoft.com/search/address/reverse/json?api-version=1.0",i=jn.parseCoords(e),s={"subscription-key":r,query:i[0]+","+i[1],language:t};return{uri:Lr.URIs.appendQuery(n,s),options:{mode:"cors"}}}_parseReverseResponse(r){return new Promise((e,t)=>{r.json().then(n=>{let i=gs.parseReverseGeocoding(n);e([i])},n=>t(n))})}},ZU=["moveend","dragend","zoomend","rotateend"];function QU(a){let r=a.theme=="dark"||a.theme!=="light"&&window.matchMedia("(prefers-color-scheme: dark)").matches;switch(a.type){case"satellite":case"satellite_road_labels":case"grayscale_dark":case"grayscale_light":case"night":case"road_shaded_relief":case"road":case"high_constrast_dark":case"high_constrast_light":return a.type;case"hybrid":return"satellite_road_labels";case"satellite":return"satellite";case"terrain":return"road_shaded_relief";case"high_contrast":return r?"high_constrast_dark":"high_constrast_light";default:return r?"night":"road"}}var nm,Yg,ma=class extends fs{constructor(){super(...arguments);$(this,nm,new WeakMap);$(this,Yg,new WeakMap)}geocode(e,t){return new S_().geocode(this.subscriptionKey,e,t,Lr.lang(this))}reverseGeocode(e,t){return new S_().reverseGeocode(this.subscriptionKey,e,Lr.lang(this))}getBounds(e){let t=this.getMap(e),{bounds:n}=t.getCamera();return gs.getLatLngBounds(n)}isActive(){return!Lr.isNullOrEmpty(this.subscriptionKey)}buildOverlayAdapterFor(e){return new Gw(e,this)}buildMarkerAdapterFor(e){return new Ww(e,this)}buildShapeAdapterFor(e){return new jw(e,this)}buildLayerAdapterFor(e){return new Fw(e,this)}setViewNative(e,t){let n=this.getMap(e);t=Lr.extend({type:e.type,theme:e.theme},t);let i=QU(t);n.setStyle({style:i});let s=t.center&&gs.getPosition(t.center)||n.getCamera().center,o=t.zoom||n.getCamera().zoom;n.setCamera({center:s,zoom:o})}snapshot(e,t="image/png",n){if(!this.hasMap(e))return Promise.reject();let{map:i}=this.tryGetMap(e);return new Promise((s,o)=>{Lr.blobToDataURL(x(this,Yg).get(e)).then(c=>{let d=i.getCanvasContainer();d.style.backgroundImage=`url(${c})`,d.style.backgroundSize="contain",Lr.snapshotElement(d,null,t,n).then(s)})})}dispose(e){if(!this.hasMap(e))return;let{map:t}=this.tryGetMap(e);x(this,nm).get(e).forEach(i=>{t.events.remove(i.eventName,i.handler)}),x(this,nm).delete(e),t.dispose()}async init(e){await Promise.all([tA.importjs(rA.API_JS),tA.importcss(rA.API_CSS,void 0,!0)]);let t=e,n=t.scale,i=t.draggable,s=t.doubleClickZoom,o=t.keyboardShortcuts,d={center:gs.getPosition(t.center),zoom:t.zoom,subscriptionKey:this.subscriptionKey,dragPanInteraction:i,scrollZoomInteraction:t.mousewheel,dblClickZoomInteraction:!s,keyboardInteraction:o,language:this.language||Lr.lang(e)},p=t.container,u=document.createElement("div");u.id=`azure-maps-${Lr.uniqueCode()}`,u.style.width="100%",u.style.height="100%",p.innerHTML="",p.appendChild(u);let h=new atlas.Map(u.id,d),m=[];return x(this,nm).set(t,m),ZU.forEach(f=>{let g=this._spinMapUpdateHandler(t,h);h.events.add(f,g),m.push({eventName:f,handler:g})}),n&&t.zoomControl&&h.events.addOnce("ready",f=>{let g=atlas.ControlPosition.NonFixed;switch(t.zoomControl){case"topleft":g=atlas.ControlPosition.TopLeft;break;case"topright":g=atlas.ControlPosition.TopRight;break;case"bottomright":g=atlas.ControlPosition.BottomRight;break;case"bottomleft":g=atlas.ControlPosition.BottomLeft;break}h.controls.add(new atlas.control.ZoomControl,{position:g})}),h.events.add("idle",f=>{h.getCanvas().toBlob(g=>{x(this,Yg).set(e,g)})}),h.events.addOnce("ready",()=>{e.dispatchEvent(new an("maploaded"))}),{map:h,container:u}}invalidateSize(e){if(!this.hasMap(e))return;let{map:t}=this.tryGetMap(e);t&&t.resize()}propertyChangedCallback(e,t,n,i){if(super.propertyChangedCallback(e,t,n,i),!i&&e==="language")for(let s of this.enrolledMaps()){let{map:o}=this.tryGetMap(s);o.setStyle({language:n||Lr.lang(s)})}}_spinMapUpdateHandler(e,t){return()=>{this._updateMap(e,t)}}_updateMap(e,t){if(!Lr.isNull(t)&&!Lr.isNull(e)){let n=t.getCamera(),i=n.center,s=n.zoom;n.zoom===1?console.warn("Azure Maps control lacks in reflecting the actual map zoom onto the camera property. Cannot reflect info back to PacemMapElement."):this.updateMapElement(e,gs.getLatLng(i),s)}}static _getBounds(e){let t=e.paddingTop||0,n=e.paddingLeft||0,i=e.paddingRight||0,s=e.paddingBottom||0;return{top:t,bottom:s,left:n,right:i}}fitBoundsNative(e,t,n=ma._getBounds(e)){this.getMap(e).setCamera({bounds:gs.getBounds(t),padding:n})}};nm=new WeakMap,Yg=new WeakMap,l([QT({emit:!1,converter:eA.String})],ma.prototype,"subscriptionKey",2),l([QT({emit:!1,converter:eA.String})],ma.prototype,"language",2),l([JU(500)],ma.prototype,"_updateMap",1),ma=l([qU({tagName:KU+"-map-adapter-azure"})],ma);import{Utils as Vr,CustomElement as e2,Watch as iA,P as t2,PropertyConverters as sA,Debounce as r2,CustomTypedEvent as n2,CustomElementUtils as aA}from"@pacem/pacem-core";var L_={API_JS:"https://cdn.jsdelivr.net/npm/leaflet@1.9.4/dist/leaflet.min.js",API_JS_INTEGRITY:null,API_CSS:"https://cdn.jsdelivr.net/npm/leaflet@1.9.4/dist/leaflet.min.css",API_CSS_INTEGRITY:null};function i2(a){return{city:a.city,state:a.state,provinceCode:a["ISO3166-2-lvl6"]?.split("-")[1],province:a.county,village:a.village,zipCode:a.postcode,streetName:a.road,houseNumber:a.house_number,countryCode:a.country_code?.toUpperCase(),country:a.country}}function oA(a){return{fullAddress:a.display_name,address:i2(a.address),position:{lat:parseFloat(a.lat),lng:parseFloat(a.lon),altitude:null}}}var Xg=class{static toLiteral(r){let e=r.getNorthEast(),t=r.getSouthWest();return{ne:e,sw:t}}static parseGeocoding(r){return Vr.isNullOrEmpty(r)?[]:r.map(oA)}static parseReverseGeocoding(r){return Vr.isNullOrEmpty(r)?[]:[oA(r)]}},lA="layerload",Yw=class extends n2{constructor(r){super(lA,r,{bubbles:!0})}},Xw=class extends Bo{deleteInfoWindow(r,e){r.unbindPopup()}deleteMarker(r,e){r.removeFrom(e)}getMarkerPosition(r){return r.getLatLng()}buildMarker(r,e){return L.marker(r.position).addTo(e)}addClickEventListener(r,e,t){r.on("click",t)}addDragEventListener(r,e,t){r.on("drag",t)}addDragEndEventListener(r,e,t){r.on("dragend",t)}setPosition(r,e){r.setLatLng(e)}setIcon(r,e){let t=this;if(typeof e=="string")t._setIcon(r,e);else if(!Vr.isNull(e)){let n={iconUrl:e.url};Vr.isNullOrEmpty(e.size)||Vr.extend(n,{iconSize:[e.size.width,e.size.height],iconAnchor:[e.size.width/2,e.size.height],popupAnchor:[0,-e.size.height]}),Vr.isNullOrEmpty(e.anchor)||Vr.extend(n,{iconAnchor:[e.anchor.x,e.anchor.y]}),t._setIcon(r,new L.Icon(n))}}setLabel(r,e){}setDraggable(r,e){e===!0?r.dragging.enable():r.dragging.disable()}closeInfo(r){r.closePopup()}openInfo(r,e,t,n){r.bindPopup(e).openPopup()}buildInfoWindow(r){return this.markers.get(r)}addCloseClickEventListener(r,e,t){r.on("popupclose",t)}setContent(r,e){let t=r.getPopup();t&&t.getContent()!=e&&r.setPopupContent(e)}_setIcon(r,e){if(typeof e=="string"){var t={iconUrl:e},n,i,s;if((n=this.size)&&/[\d]+,[\d]+/.test(n)){var o=-1,c=[parseInt(n.substring(0,o=n.indexOf(","))),parseInt(n.substring(o+1))];Object.assign(t,{iconSize:c})}if((i=this.anchor)&&/[\d]+,[\d]+/.test(i)){var o=-1,d=[parseInt(i.substring(0,o=i.indexOf(","))),parseInt(i.substring(o+1))];Object.assign(t,{iconAnchor:d,popupAnchor:[0,-d[1]]})}if((s=this.popupAnchor)&&/[\d]+,[\d]+/.test(s)){var o=-1,d=[parseInt(i.substring(0,o=i.indexOf(","))),parseInt(i.substring(o+1))];Object.assign(t,{popupAnchor:d})}r.setIcon(L.icon(t))}else e&&r.setIcon(e)}},qw=class extends Vo{addDragStartEventListener(r,e){throw new Error("Method not implemented.")}deleteShape(r,e){throw new Error("Method not implemented.")}getShapeBounds(r){throw new Error("Method not implemented.")}getShapePosition(r){throw new Error("Method not implemented.")}buildShape(r,e){throw new Error("Method not implemented.")}addClickEventListener(r,e){throw new Error("Method not implemented.")}addDragEventListener(r,e){throw new Error("Method not implemented.")}addDragEndEventListener(r,e){throw new Error("Method not implemented.")}setShape(r,e){throw new Error("Method not implemented.")}setEditable(r,e){throw new Error("Method not implemented.")}setDraggable(r,e){throw new Error("Method not implemented.")}},Kw=class extends Ho{addLoadEventListener(r,e,t){r.on("load",t)}removeLoadEventListener(r,e,t){r.off("load",t)}deleteLayer(r,e){r.remove()}buildLayer(r,e){let t=(r.mode||"").toLowerCase();return t==="wms"?L.tileLayer.wms(r.url,{layers:(r.include||[]).join(","),minZoom:r.minZoom,maxZoom:r.maxZoom,transparent:!0,format:"image/png"}).addTo(e):L.tileLayer(r.url,{tms:t==="tms",minZoom:r.minZoom,maxZoom:r.maxZoom}).addTo(e)}},Jw=class extends $o{deleteOverlay(r,e){throw new Error("Method not implemented.")}buildOverlay(r,e){throw new Error("Method not implemented.")}setBounds(r,e,t){throw new Error("Method not implemented.")}updateOverlay(r,e,t){throw new Error("Method not implemented.")}},xp,wc=class extends fs{constructor(){super(...arguments);$(this,xp,new WeakMap);this.tiles="//{s}.tile.openstreetmap.org/{z}/{x}/{y}.png";this.attribution='Map data \xA9 <a href="http://openstreetmap.org">OpenStreetMap</a> contributors';this._tileLayerLoadHandler=e=>{this.dispatchLayerLoadEvent(e.sourceTarget)};this._mapUpdateHandler=e=>{let t=this.getMap(e);!Vr.isNull(t)&&!Vr.isNull(e)&&this.updateMapElement(e,t.getCenter(),t.getZoom())}}buildOverlayAdapterFor(e){return new Jw(e,this)}geocode(e,t){return new N_().geocode(e,t,Vr.lang(this))}reverseGeocode(e,t){return new N_().reverseGeocode(e,Vr.lang(this))}getBounds(e){let n=this.getMap(e).getBounds();return Xg.toLiteral(n)}isActive(){return!0}setViewNative(e,t){let n=this.getMap(e);t.center?n.setView(t.center,t.zoom??n.getZoom(),{animate:!0}):typeof t.zoom=="number"&&n.setZoom(t.zoom,{animate:!0})}buildMarkerAdapterFor(e){return new Xw(e,this)}buildShapeAdapterFor(e){return new qw(e,this)}buildLayerAdapterFor(e){return new Kw(e,this)}snapshot(e,t="image/png",n){return Vr.snapshotElement(e.container.firstElementChild,null,t,n)}propertyChangedCallback(e,t,n,i){switch(super.propertyChangedCallback(e,t,n,i),e){case"tiles":for(let s of this.enrolledMaps())this._redrawMap(s);default:for(let s of this.enrolledMaps())this.invalidateSize(s);break}}dispose(e){let{map:t}=this.tryGetMap(e),n=x(this,xp).get(e);n&&n.off("load",this._tileLayerLoadHandler),t.clearAllEventListeners(),x(this,xp).delete(e)}async init(e){await Promise.all([aA.importjs(L_.API_JS,L_.API_JS_INTEGRITY,!0),aA.importcss(L_.API_CSS,L_.API_CSS_INTEGRITY,!0)]);let t=e;var n=t.scale,i=t.draggable,s=t.doubleClickZoom,o=t.keyboardShortcuts,c=L.latLng(jn.parseCoords(t.center)),d={zoomControl:n&&!Vr.isNullOrEmpty(t.zoomControl),scrollWheelZoom:t.mousewheel,dragging:i,doubleClickZoom:!s,keyboard:o};let p=t.container,u=document.createElement("div");u.style.width="100%",u.style.height="100%",p.innerHTML="",p.appendChild(u);let h=L.map(u,d);["zoomend","moveend"].forEach(v=>{h.on(v,b=>{this._idleFiller(t),this._mapUpdateHandler(t)})}),h.on("load",()=>{n&&t.zoomControl&&h.zoomControl.setPosition(t.zoomControl),this._idleFiller(t)});let m=L.tileLayer(this.tiles,{attribution:this.attribution}).addTo(h);m.on("load",this._tileLayerLoadHandler),x(this,xp).set(t,m),h.setView(c,t.zoom),h.once("idle",function(){h.fire("resize"),e.dispatchEvent(new an("maploaded"))});let f=jn.parseCoords(t.center),g=[f[0],f[1]];return h.setView(g,t.zoom),{map:h,container:u}}dispatchLayerLoadEvent(e){this.dispatchEvent(new Yw(e))}invalidateSize(e){this.hasMap(e)&&this.getMap(e).invalidateSize()}_idleFiller(e){this.hasMap(e)&&this.getMap(e).fire("idle")}fitBoundsNative(e,t,n={top:e.paddingTop||0,left:e.paddingLeft||0,right:e.paddingRight||0,bottom:e.paddingBottom||0}){let i=this.getMap(e),s={paddingTopLeft:new L.Point(n.left,n.top),paddingBottomRight:new L.Point(n.right,n.bottom)},o=t.ne,c=t.sw;try{i.fitBounds([[o.lat,o.lng],[c.lat,c.lng]],s)}catch(d){throw d}}_redrawMap(e){var t=this,n=x(t,xp).get(e);Vr.isNull(t.tiles&&n)||n.setUrl(t.tiles)}};xp=new WeakMap,l([iA({emit:!1,converter:sA.String})],wc.prototype,"tiles",2),l([iA({emit:!1,converter:sA.String})],wc.prototype,"attribution",2),l([r2(500)],wc.prototype,"_idleFiller",1),wc=l([e2({tagName:t2+"-map-adapter-leaflet"})],wc);var N_=class{_buildGeocodeRequest(r,e=10,t=""){let n="https://nominatim.openstreetmap.org/search?addressdetails=1&format=json",i={q:r,limit:""+e,"accept-language":t};return{uri:Vr.URIs.appendQuery(n,i),options:{mode:"cors"}}}parseGeocodeResponse(r){return new Promise((e,t)=>{r.json().then(n=>{let i=Xg.parseGeocoding(n);e(i)},n=>t(n))})}geocode(r,e=10,t=""){return new Promise((n,i)=>{let s=this._buildGeocodeRequest(r,e,t);return fetch(s.uri,s.options).then(o=>{o.ok?this.parseGeocodeResponse(o).then(n,i):i(o)},o=>i(o))})}reverseGeocode(r,e=""){return new Promise((t,n)=>{let i=this._buildReverseRequest(r,e);return fetch(i.uri,i.options).then(s=>{s.ok?this._parseReverseResponse(s).then(t,n):n(s)},s=>n(s))})}_buildReverseRequest(r,e=""){let t="https://nominatim.openstreetmap.org/reverse?addressdetails=1&format=json",n=jn.parseCoords(r),i={lat:""+n[0],lon:""+n[1],"accept-language":e};return{uri:Vr.URIs.appendQuery(t,i),options:{mode:"cors"}}}_parseReverseResponse(r){return new Promise((e,t)=>{r.json().then(n=>{let i=Xg.parseReverseGeocoding(n);e(i)},n=>t(n))})}};import{Utils as Ue,CustomElement as s2,Watch as im,P as a2,PropertyConverters as sm,Debounce as o2}from"@pacem/pacem-core";var qg={DETACH_TIMEOUT:200,API_URI:"https://maps.googleapis.com/maps/api/js",MAX_ROADMAP_ZOOM:22,BOOTSTRAP_SNIPPET:(a,r,e,t)=>`(g=>{var h,a,k,p="The Google Maps JavaScript API",c="google",l="importLibrary",q="__ib__",m=document,b=window;b=b[c]||(b[c]={});var d=b.maps||(b.maps={}),r=new Set,e=new URLSearchParams,u=()=>h||(h=new Promise(async(f,n)=>{await (a=m.createElement("script"));e.set("libraries",[...r]+"");for(k in g)e.set(k.replace(/[A-Z]/g,t=>"_"+t[0].toLowerCase()),g[k]);e.set("callback",c+".maps."+q);a.src=\`https://maps.\${c}apis.com/maps/api/js?\`+e;d[q]=f;a.onerror=()=>h=n(Error(p+" could not load."));a.nonce=m.querySelector("script[nonce]")?.nonce||"";m.head.append(a)}));d[l]?console.warn(p+" only loads once. Ignoring:",g):d[l]=(f,...n)=>r.add(f)&&u().then(()=>d[l](f,...n))})({
|
|
561
|
+
key: "${a}", v: "${t}", language: "${r}", region: "${e}",
|
|
562
|
+
// Add other bootstrap parameters as needed, using camel case.
|
|
563
|
+
});`,MAPS_NOT_FOUND:"google.maps not found.",GEOCODER_UNAVAILABLE:"google.maps geocoder unavailable.",INVALID_KEY:"invalid google.maps api key.",TILE_EXTENT:[-Math.PI*6378137,Math.PI*6378137]},Zw=class a{#e;#t;_equivalent(r,e,t,n){let i=this.#t;return!Ue.isNull(i)&&i.key===r&&i.language===(e||i.language)&&i.region===(t||i.region)&&i.version===(n||i.version)}_spinFuture(r,e,t,n){return new Promise((i,s)=>{this._equivalent(r,e,t,n)||a._ensureBootstrapScript(r,e,t,n),this.#t={language:e,region:t,version:n,key:r},google.maps.importLibrary("maps").then(o=>{i(),this.#e=null},o=>{s(o),this.#e=null})})}boostrap(r,e,t,n="weekly"){return Ue.isNullOrEmpty(r)?Promise.reject(qg.INVALID_KEY):((Ue.isNull(this.#e)||!this._equivalent(r,e,t,n))&&(this.#e=this._spinFuture(r,e,t,n)),this.#e)}static _ensureBootstrapScript(r,e,t,n){let i="pacem-googlemaps",s=`v=${n},l=${e},r=${t}`,o=document.querySelector(`script[${i}]`);if(!Ue.isNull(o)){if(o.getAttribute(i)===s)return;o.remove(),document.querySelectorAll("script[src^='https://maps.googleapis.com/maps']").forEach(c=>c.remove()),delete window.google}Ue.isNullOrEmpty(r)||(o=document.createElement("script"),o.setAttribute(i,s),o.textContent=qg.BOOTSTRAP_SNIPPET(r,e,t,n),document.head.appendChild(o))}},Qw=new Zw,Li=class a{static getPosition(r){return Array.isArray(r)?{lat:r[0],lng:r[1]}:r}static getBounds(r){return Ue.isNullOrEmpty(r)?null:{north:r.ne.lat,east:r.ne.lng,south:r.sw.lat,west:r.sw.lng}}static mapGeocodeResults(r,e=[]){let t=[];r??=[];for(let n=0;n<r.length;n++){let i=e.length>n?e[n]:null,s=a.mapGeocodeResult(r[n],i);t.push(s)}return t}static mapGeocodeResult(r,e){let t=r?.address_components||[],n=t.find(f=>f.types.indexOf("street_number")>=0)?.long_name,i=t.find(f=>f.types.indexOf("route")>=0)?.long_name,s=t.find(f=>f.types.indexOf("locality")>=0)?.long_name,o=t.find(f=>f.types.indexOf("administrative_area_level_3")>=0)?.long_name,c=t.find(f=>f.types.indexOf("administrative_area_level_2")>=0),d=t.find(f=>f.types.indexOf("administrative_area_level_1")>=0)?.short_name,p=t.find(f=>f.types.indexOf("country")>=0),u=t.find(f=>f.types.indexOf("postal_code")>=0)?.short_name,h={houseNumber:n,city:o||s,provinceCode:c?.short_name,province:c?.long_name,countryCode:p?.short_name,country:p?.long_name,zipCode:u,streetName:i,state:d,village:s,type:r.geometry.location_type};return{fullAddress:r.formatted_address,position:a.toLiteral(r.geometry.location,e?.elevation),address:h}}static toLiteral(r,e){if(Ue.isNull(r))return null;if("lat"in r&&typeof r.lat=="function"&&"lng"in r&&typeof r.lng=="function")return{lat:r.lat(),lng:r.lng(),altitude:e};if("getNorthEast"in r&&typeof r.getNorthEast=="function"&&"getSouthWest"in r&&typeof r.getSouthWest=="function"){let t=r.getNorthEast(),n=r.getSouthWest();return{ne:a.toLiteral(t),sw:a.toLiteral(n)}}return"north"in r&&typeof r.north=="number"&&"south"in r&&typeof r.south=="number"&&"west"in r&&typeof r.west=="number"&&"east"in r&&typeof r.east=="number"?{ne:{lat:r.north,lng:r.east},sw:{lat:r.south,lng:r.west}}:Ue.extend({altitude:e},r)}static areEqual(r,e){if(Ue.isNull(r)||Ue.isNull(e))return!1;let t=a.toLiteral(r),n=a.toLiteral(e);return t.lat===n.lat&&t.lng===n.lng}static fitBounds(r,e,t){r?.fitBounds(e,t)}static setCenter(r,e){!Ue.isNull(r)&&!a.areEqual(r.getCenter(),e)&&r.panTo(e)}},e0=class extends Vo{getShapeBounds(r){let e=new google.maps.LatLngBounds;if(r instanceof google.maps.Circle){let t=r.getBounds();t&&(e.extend(t.getNorthEast()),e.extend(t.getSouthWest()))}else r instanceof google.maps.Polygon?r.getPath().forEach(t=>e.extend(t)):r instanceof google.maps.Polyline&&r.getPath().forEach(t=>e.extend(t));return e.isEmpty()!==!1?Et.Empty:Li.toLiteral(e)}deleteShape(r,e){r.setMap(null)}getShapePosition(r){return"latLng"in r?r.latLng:null}buildShape(r,e){return r instanceof pa?new google.maps.Polyline({path:r.vertices,clickable:!0,map:e}):r instanceof ua?new google.maps.Polygon({paths:[r.vertices],clickable:!0,map:e}):r instanceof ms?new google.maps.Circle({center:r.center,radius:r.radius,clickable:!0,map:e}):null}addClickEventListener(r,e){r.addListener("click",e)}addDragEventListener(r,e){r.addListener("drag",e)}addDragStartEventListener(r,e){r.addListener("dragstart",e)}addDragEndEventListener(r,e){r.addListener("dragend",e)}setShape(r,e){e instanceof pa&&r.setOptions({strokeColor:e.stroke?.color,strokeOpacity:e.stroke?.alpha??1,strokeWeight:e.stroke?.thickness,path:e.vertices}),e instanceof ua&&r.setOptions({strokeColor:e.stroke?.color,strokeOpacity:e.stroke?.alpha??1,strokeWeight:e.stroke?.thickness,strokePosition:google.maps.StrokePosition.CENTER,fillColor:e.fill?.color,fillOpacity:e.fill?.alpha,paths:[e.vertices]}),e instanceof ms&&r.setOptions({strokeColor:e.stroke?.color,strokeOpacity:e.stroke?.alpha??1,strokeWeight:e.stroke?.thickness,strokePosition:google.maps.StrokePosition.CENTER,fillColor:e.fill?.color,fillOpacity:e.fill?.alpha,center:e.center,radius:e.radius})}setEditable(r,e){r.setOptions({editable:e})}setDraggable(r,e){r.setOptions({draggable:e})}},t0=class extends Bo{deleteInfoWindow(r,e){r.unbindAll()}deleteMarker(r,e){r.setMap(null)}get mapAutomaticallyScrollsOnDrag(){return!0}getMarkerPosition(r){let e=r.getPosition();return{lat:e.lat(),lng:e.lng()}}buildMarker(r,e){return new google.maps.Marker({position:r.position,map:e})}addClickEventListener(r,e,t){r.addListener("click",t)}addDragEventListener(r,e,t){r.addListener("drag",t)}addDragEndEventListener(r,e,t){r.addListener("dragend",t)}setPosition(r,e){r.setPosition(e)}setIcon(r,e){if(typeof e=="string")r.setIcon(e);else if(!Ue.isNull(e)){let t={url:e.url};Ue.isNullOrEmpty(e.size)||(t.size=new google.maps.Size(e.size.width,e.size.height),t.anchor=new google.maps.Point(e.size.width/2,e.size.height)),Ue.isNullOrEmpty(e.anchor)||(t.anchor=new google.maps.Point(e.anchor.x,e.anchor.y)),r.setIcon(t)}}setLabel(r,e){r.setLabel(e)}setDraggable(r,e){r.setDraggable(e)}closeInfo(r){r.close()}openInfo(r,e,t,n){r.open(t,n)}buildInfoWindow(r){let e=0;return typeof r.icon!="string"&&!Ue.isNull(r.icon)&&(e=(r.icon.size?.width??0)/2-(r.icon.anchor?.x??0)),new google.maps.InfoWindow({pixelOffset:new google.maps.Size(-e,0)})}addCloseClickEventListener(r,e,t){r.addListener("closeclick",t)}setContent(r,e){r.setContent(e)}},r0=class extends Ho{addLoadEventListener(r,e,t){r.addListener("tilesloaded",t)}removeLoadEventListener(r,e,t){}deleteLayer(r,e){let n=e.overlayMapTypes.getArray().findIndex(i=>i===r);n>=0&&e.overlayMapTypes.removeAt(n)}_getBounds(r,e,t){let n=qg.TILE_EXTENT;var i=n[1]*2/Math.pow(2,t),s=n[0]+r*i,o=n[0]+(r+1)*i,c=n[1]-(e+1)*i,d=n[1]-e*i;return[s,c,o,d]}_getWmsTileUrl(r,e){return(t,n)=>Ue.URIs.appendQuery(r,{service:"WMS",styles:"",transparent:"true",request:"GetMap",srs:"EPSG:3857",format:"image/png",version:"1.1.1",layers:e?.join(",")||"",width:"256",height:"256",bbox:this._getBounds(t.x,t.y,n).join(",")})}_getWmsLayer(r,e){let t=new google.maps.ImageMapType({getTileUrl:this._getWmsTileUrl(r.url,r.include),minZoom:r.minZoom,maxZoom:r.maxZoom,opacity:1});return e.overlayMapTypes.push(t),t}_getTmsTileUrl(r){function t(n){return"abc"[Math.abs(n.x+n.y)%3]}return(n,i)=>{let s={r:"",s:t(n),x:""+n.x,y:""+n.y,z:""+i},o=r;for(let c in s)o=o.replaceAll("{"+c+"}",s[c]);return o}}_getTmsLayer(r,e){let t=new google.maps.ImageMapType({getTileUrl:this._getTmsTileUrl(r.url),minZoom:r.minZoom,maxZoom:r.maxZoom,opacity:1});return e.overlayMapTypes.push(t),t}buildLayer(r,e){switch((r.mode||"").toLowerCase()){case"wms":return this._getWmsLayer(r,e);case"tms":return this._getTmsLayer(r,e);default:throw new Error(`"${r.mode}" overlays not supported for the Google Maps integration.`)}}};function l2(a){class r extends google.maps.OverlayView{constructor(i){super();this._item=i}get element(){return this._item}get bounds(){let i=this._item.bounds;return Ue.isNull(i)?null:Li.getBounds(i)}getBoundingBox(){let i=this.getProjection(),s=this.bounds;if(Ue.isNullOrEmpty(s))return null;let o=i.fromLatLngToDivPixel({lat:s.south,lng:s.west}),c=i.fromLatLngToDivPixel({lat:s.north,lng:s.east});return{x:o.x,y:c.y,width:c.x-o.x,height:o.y-c.y}}}class e extends r{get src(){return this.element.src}#e;onAdd(){let n=this.#e=this.#e||document.createElement("div");n.style.position="absolute",this.getPanes().overlayLayer.appendChild(n)}onRemove(){let n=this.#e;Ue.isNull(n)||(n.remove(),this.#e=null)}draw(){let n=this.#e;if(Ue.isNull(n))return;let i=this.getBoundingBox();Ue.isNull(i)||(n.style.top=i.y+"px",n.style.left=i.x+"px",n.style.width=i.width+"px",n.style.height=i.height+"px",n.style.backgroundSize=`${i.width}px ${i.height}px`,n.style.backgroundImage=`url(${this.src})`)}}return a instanceof Cc?new e(a):null}var n0=class extends $o{updateOverlay(r,e,t){r.set,r.draw()}deleteOverlay(r,e){r.setMap(null)}buildOverlay(r,e){let t=l2(r);return t.setMap(e),t}setBounds(r,e,t){r.draw()}},c2=["dragend","zoom_changed","center_changed","maptypeid_changed","tilt_changed","heading_changed","bounds_changed"];function cA(a){let r=a.theme=="dark"?google.maps.ColorScheme.DARK:a.theme!="light"?google.maps.ColorScheme.FOLLOW_SYSTEM:google.maps.ColorScheme.LIGHT;switch(a.type){case google.maps.MapTypeId.HYBRID:case google.maps.MapTypeId.ROADMAP:case google.maps.MapTypeId.TERRAIN:case google.maps.MapTypeId.SATELLITE:return{type:a.type,theme:r};case"hybrid":return{type:google.maps.MapTypeId.HYBRID,theme:r};case"satellite":return{type:google.maps.MapTypeId.SATELLITE,theme:r};case"terrain":return{type:google.maps.MapTypeId.TERRAIN,theme:r};default:return{type:google.maps.MapTypeId.ROADMAP,theme:r}}}var am,om,Si=class extends fs{constructor(){super(...arguments);$(this,am,new WeakMap);$(this,om,!1)}geocode(e,t){let n=this.language||"",i=this.region||"",s=this.version||"weekly";return new T_(this.apiKey,n,i,s).geocode(e,t)}reverseGeocode(e,t){let n=this.language||"",i=this.region||"",s=this.version||"weekly";return new T_(this.apiKey,n,i,s).reverseGeocode(e,t)}getBounds(e){if(!this.hasMap(e))return Et.Empty;let n=this.getMap(e).getBounds();return Li.toLiteral(n)}isActive(){return!Ue.isNullOrEmpty(this.apiKey)}buildMarkerAdapterFor(e){return new t0(e,this)}buildOverlayAdapterFor(e){return new n0(e,this)}buildShapeAdapterFor(e){return new e0(e,this)}buildLayerAdapterFor(e){return new r0(e,this)}getMaxAvailableZoom(e){return new Promise((t,n)=>{new google.maps.MaxZoomService().getMaxZoomAtLatLng(e,s=>{s.status===google.maps.MaxZoomStatus.OK?t(s.zoom):n()})})}snapshot(e,t="image/png",n){let{container:i}=this.tryGetMap(e);return Ue.snapshotElement(i,null,t,n)}setViewNative(e,t){let n=this.getMap(e);t=Ue.extend({type:e.type,theme:e.theme},t);let{type:i,theme:s}=cA(t);if(x(this,om)&&s!==n.get("colorScheme")){this._bootstrapDebounced();return}n.setOptions({colorScheme:s,mapTypeId:i}),typeof t.tilt=="number"&&n.setTilt(t.tilt),typeof t.heading=="number"&&n.setHeading(t.heading);let o=()=>{t.center&&Li.setCenter(n,t.center)};if(typeof t.zoom=="number"&&t.zoom!==n.getZoom())switch(n.getMapTypeId()){case google.maps.MapTypeId.SATELLITE:case google.maps.MapTypeId.HYBRID:let d=Li.toLiteral(n.getCenter());this.getMaxAvailableZoom(d).then(u=>{let h=Math.min(u,t.zoom);n.setZoom(h),o()});break;default:let p=Math.min(qg.MAX_ROADMAP_ZOOM,t.zoom);n.setZoom(p),o();break}else o()}propertyChangedCallback(e,t,n,i){if(super.propertyChangedCallback(e,t,n,i),!i)switch(e){case"libraries":case"apiKey":case"language":case"region":x(this,om)&&this._bootstrapDebounced();break;case"defaultOptions":for(let s of this.enrolledMaps())this._updateMapOptions(s);break;default:for(let s of this.enrolledMaps())this.invalidateSize(s);break}}dispose(e){let t=x(this,am).get(e);for(;t.length;)google.maps.event.removeListener(t.pop());x(this,am).delete(e)}_updateMapOptions(e){if(!this.hasMap(e))return;let{map:t}=this.tryGetMap(e);t.setOptions(this._buildMapOptions(e))}_buildMapOptions(e){let t=e.scale,n=e.draggable,i=e.doubleClickZoom,s=e.keyboardShortcuts,{type:o,theme:c}=cA({type:e.type,theme:e.theme});return Ue.extend({},this.defaultOptions||{streetViewControl:!1,zoomControl:!1,mapTypeControl:!1,fullscreenControl:!1,cameraControl:!1},{zoomControl:t&&!Ue.isNullOrEmpty(e.zoomControl),zoomControlOptions:{position:(function(d){switch(d){case"topright":return google.maps.ControlPosition.RIGHT_TOP;case"bottomleft":return google.maps.ControlPosition.LEFT_BOTTOM;case"bottomright":return google.maps.ControlPosition.RIGHT_BOTTOM;default:return google.maps.ControlPosition.LEFT_TOP}})(e.zoomControl)},scrollwheel:e.mousewheel,disableDoubleClickZoom:i,keyboardShortcuts:s,draggable:n,mapTypeId:o,colorScheme:c,tilt:e.tilt,heading:e.heading})}_bootstrapDebounced(){this._bootstrap().then(e=>{for(let t of this.enrolledMaps())t.adapter=null,t.adapter=this})}_bootstrap(){return new Promise((e,t)=>{let n=this.apiKey,i=this.language||"",s=this.region||"",o=this.version||"weekly";Qw.boostrap(n,i,s,o).then(c=>{let d=[];for(let p of this.libraries||[])d.push(google.maps.importLibrary(p));Promise.all(d).then(p=>{e(),A(this,om,!0)},t)},t)})}async init(e){await this._bootstrap();let t=e,n=jn.parseCoords(t.center),i=new google.maps.LatLng(n[0],n[1]),s=this._buildMapOptions(t),o=t.container,c=document.createElement("div");c.style.width="100%",c.style.height="100%",o.innerHTML="",o.appendChild(c);let d=new google.maps.Map(c,s),p=[];x(this,am).set(t,p),c2.forEach(f=>{p.push(d.addListener(f,this._spinMapUpdateHandler(t,d)))}),d.setZoom(t.zoom),d.setCenter(i);var u=d.addListener("idle",function(g){u.remove(),e.dispatchEvent(new an("maploaded"))});p.push(d.addListener("tilesloaded",f=>{e.dispatchEvent(new an("tilesloaded"))}));let h=jn.parseCoords(t.center),m=new google.maps.LatLng(h[0],h[1]);return d.setZoom(t.zoom),d.setCenter(m),{map:d,container:c}}invalidateSize(e){if(!this.hasMap(e))return;let{map:t}=this.tryGetMap(e);google.maps.event.trigger(t,"resize")}_spinMapUpdateHandler(e,t){return()=>{if(!Ue.isNull(t)&&!Ue.isNull(e)){let n=t.getCenter();if(Ue.isNull(n))return;this.updateMapElement(e,{center:{lat:n.lat(),lng:n.lng()},zoom:t.getZoom(),type:t.getMapTypeId(),tilt:t.getTilt(),heading:t.getHeading()})}}}fitBoundsNative(e,t,n=this._getPadding(e)){let i=this.tryGetMap(e)?.map;if(Ue.isNull(i))return;let s=Li.getBounds(t);Li.fitBounds(i,s,n)}_getPadding(e){let t=e.paddingTop||0,n=e.paddingLeft||0,i=e.paddingRight||0,s=e.paddingBottom||0;return n||t||i||s?{top:t,bottom:s,left:n,right:i}:null}_padBounds(e){let t=e.paddingTop||0,n=e.paddingLeft||0,i=e.paddingRight||0,s=e.paddingBottom||0;if(n||t||i||s){let o=this.tryGetMap(e).map,c=o.getBounds(),d=o.getDiv().clientWidth,p=o.getDiv().clientHeight,u=o.getProjection().fromPointToLatLng(new google.maps.Point(-n,-t)),h=o.getProjection().fromPointToLatLng(new google.maps.Point(d+i,p+s));c.extend(u),c.extend(h)}}_redrawMap(){}};am=new WeakMap,om=new WeakMap,l([im({emit:!1,converter:sm.String})],Si.prototype,"apiKey",2),l([im({emit:!1,converter:sm.String})],Si.prototype,"version",2),l([im({emit:!1,converter:sm.String})],Si.prototype,"language",2),l([im({emit:!1,converter:sm.String})],Si.prototype,"region",2),l([im({emit:!1,converter:sm.Json})],Si.prototype,"defaultOptions",2),l([im({emit:!1,converter:sm.StringArray})],Si.prototype,"libraries",2),l([o2(qg.DETACH_TIMEOUT)],Si.prototype,"_bootstrapDebounced",1),Si=l([s2({tagName:a2+"-map-adapter-google"})],Si);var T_=class{constructor(r,e="",t="",n="weekly"){this.apiKey=r;this.language=e;this.region=t;this.version=n}_elevateResults(r){return new Promise((e,t)=>{new google.maps.ElevationService().getElevationForLocations({locations:r.map(i=>i.geometry.location)},(i,s)=>{if(s===google.maps.ElevationStatus.OK){let o=Li.mapGeocodeResults(r,i);e(o)}else{let o=Li.mapGeocodeResults(r);e(o)}})})}geocode(r,e=10){return new Promise((t,n)=>{Qw.boostrap(this.apiKey,this.language||"",this.region||"",this.version||"weekly").then(i=>{new google.maps.Geocoder().geocode({address:r},(o,c)=>{if(c===google.maps.GeocoderStatus.OK||c==google.maps.GeocoderStatus.ZERO_RESULTS){let d=(o||[]).filter((p,u)=>u<(e||10));this._elevateResults(d).then(t)}else n(c)})},n)})}_reverseGeocodeInternal(r,e){let t=Li.getPosition(r);return new Promise((n,i)=>{Qw.boostrap(this.apiKey,this.language||"",this.region||"",this.version||"weekly").then(s=>{new google.maps.Geocoder().geocode({location:t},(c,d)=>{if(d===google.maps.GeocoderStatus.OK||d==google.maps.GeocoderStatus.ZERO_RESULTS){let p=(c||[]).filter((u,h)=>h<(e||10));this._elevateResults(p).then(n)}else i(d)})},i)})}reverseGeocode(r,e=1){return this._reverseGeocodeInternal(r,e)}};var l0={};tt(l0,{PacemFxElement:()=>En,PacemFxFancyElement:()=>Lc,PacemFxGradientElement:()=>Sc,PacemFxGradientItemElement:()=>Ep,PacemFxGradientStopElement:()=>Fo,PacemFxHeroElement:()=>Go,PacemFxLinearGradientElement:()=>pm,PacemFxListElement:()=>Kg,PacemFxPulseElement:()=>zo,PacemFxRadialGradientElement:()=>Mc,PacemFxRippleElement:()=>lm});import{Watch as d2,PropertyConverters as p2,PacemEventTarget as u2}from"@pacem/pacem-core";var En=class extends u2{};l([d2({converter:p2.Element})],En.prototype,"target",2);import{CustomElement as h2,Defaults as m2,P as f2,ViewChild as g2,Utils as kc,PacemEventTarget as v2}from"@pacem/pacem-core";import{Point as A_}from"@pacem/pacem-foundation";var dA="ripple",lm=class extends En{constructor(){super(...arguments);this._lock=!1;this._remove=!1;this._rippleHandler=e=>{if(this.disabled||this.target instanceof v2&&this.target.disabled||e instanceof MouseEvent&&e.button!==0)return;let t=kc.offset(this.target),n=getComputedStyle(this.target),i=this.style;i.top=t.top+"px",i.left=t.left+"px",i.width=t.width+"px",i.height=t.height+"px",i.borderRadius=n.borderRadius;let s=e.type==="touchstart"?e.touches[0]:e,o={x:s.pageX,y:s.pageY},c={x:t.left,y:t.top},d={x:t.left+t.width,y:t.top},p={x:t.left,y:t.top+t.height},u={x:d.x,y:p.y},h=Math.max(A_.distance(o,c),A_.distance(o,d),A_.distance(o,u),A_.distance(o,p)),m=this._wave;m.style.left=o.x-t.left-h+"px",m.style.top=o.y-t.top-h+"px",m.style.width=m.style.height=2*h+"px",kc.addAnimationEndCallback(m,()=>{this._lock=!1,this._tryRemove()}),this._lock=!0,kc.addClass(m,"ripple-go")};this._unrippleHandler=e=>{this._remove=!0,this._tryRemove()}}propertyChangedCallback(e,t,n,i){super.propertyChangedCallback(e,t,n,i),e==="target"&&(kc.isNull(t)||this._reset(t),kc.isNull(n)||this._set(n))}viewActivatedCallback(){super.viewActivatedCallback(),kc.isNull(this.target)||this._set()}disconnectedCallback(){kc.isNull(this.target)||this._reset(),super.disconnectedCallback()}_tryRemove(){!this._lock&&this._remove&&(this._remove=!1,kc.removeClass(this._wave,"ripple-go"))}_set(e=this.target){e.addEventListener("mousedown",this._rippleHandler,!1),e.addEventListener("touchstart",this._rippleHandler,!1),e.addEventListener("touchend",this._unrippleHandler,!1),e.addEventListener("mouseup",this._unrippleHandler,!1),e.addEventListener("mousemove",this._unrippleHandler,!1)}_reset(e=this.target){e.removeEventListener("mousedown",this._rippleHandler,!1),e.removeEventListener("touchstart",this._rippleHandler,!1),e.removeEventListener("touchend",this._unrippleHandler,!1),e.removeEventListener("mouseup",this._unrippleHandler,!1),e.removeEventListener("mousemove",this._unrippleHandler,!1)}};l([g2("."+dA)],lm.prototype,"_wave",2),lm=l([h2({tagName:f2+"-fx-ripple",shadow:m2.USE_SHADOW_ROOT,template:`<div class="${dA}"></div>`})],lm);import{CustomElement as b2,Defaults as y2,P as D_,PCSS as _2,ViewChild as R_,Utils as Cp,Components as x2}from"@pacem/pacem-core";var C2="pulse",E2="http://www.w3.org/2000/svg";function pA(a){return`${_2}-fx-pulse-${a}`}function w2(a,r,e="0",t=e){let n="style#"+a,i=document.querySelector(n);if(Cp.isNull(i)){let h=document.createElement("style");h.id=a,document.head.appendChild(h)}let s=document.querySelector(n),o=r.width,c=r.height,d=Math.max(o,c),p=.5*(d-o),u=.5*(d-c);s.sheet.insertRule(`@keyframes ${pA(a)} {
|
|
564
|
+
0%{
|
|
565
|
+
opacity: .25; stroke-thickness: 0; rx: ${e}; ry: ${t}; x: ${p}px; y: ${u}px; width: ${r.width}px; height: ${r.height}px;
|
|
566
|
+
}
|
|
567
|
+
50%{
|
|
568
|
+
width: ${r.width}px; height: ${r.height}px; transform: scale(1); stroke-width: 10px; rx: ${e}; ry: ${t}; opacity: .333; x: ${p}px; y: ${u}px; width: ${o}px; height: ${c}px;
|
|
569
|
+
}
|
|
570
|
+
80%{
|
|
571
|
+
stroke-width: 10px;
|
|
572
|
+
}
|
|
573
|
+
100%{
|
|
574
|
+
opacity: 0; rx: 50%; ry: 50%; transform: scale(2); stroke-width: 0; width: ${d}px; height: ${d}px; x: 0; y: 0
|
|
575
|
+
}
|
|
576
|
+
}`,0);for(let h=s.sheet.rules.length-1;h>0;h--)s.sheet.deleteRule(h);return s}var cm,zo=class extends En{constructor(){super();$(this,cm);this._resizeHandler=e=>{this._pulse(e.detail)};A(this,cm,Cp.uniqueCode())}viewActivatedCallback(){super.viewActivatedCallback(),this._pulse()}disconnectedCallback(){Cp.isNull(this._sheet)||(this._sheet.remove(),this._sheet=null),super.disconnectedCallback()}propertyChangedCallback(e,t,n,i){super.propertyChangedCallback(e,t,n,i),e==="disabled"&&!i&&this._pulse()}_pulse(e=this._resize.currentSize){let t=Cp.isNull(this.target)||Cp.isNull(e)||!(e.height>0)||!(e.width>0);if(this._resize.disabled=this.disabled,this.disabled||t){Cp.addClass(this,"pulse-off");return}Cp.removeClass(this,"pulse-off");let n=e,i=getComputedStyle(this.target),s=this.style,o=Math.max(n.width,n.height);s.width=o+"px",s.height=o+"px",s.top=n.top+.5*(n.height-o)+"px",s.left=n.left+.5*(n.width-o)+"px";let c=this._rect1,d=this._rect2,p=c.style,u=d.style;this._sheet=w2(x(this,cm),e,i.borderTopLeftRadius);let h=pA(x(this,cm));p.animation=u.animation=`${h} both cubic-bezier(0.37, 0, 0.63, 1) 1.25s infinite`,u.animationDelay=".175s"}};cm=new WeakMap,l([R_(D_+"-resize")],zo.prototype,"_resize",2),l([R_("svg")],zo.prototype,"_svg",2),l([R_("svg > rect[rect1]")],zo.prototype,"_rect1",2),l([R_("svg > rect[rect2]")],zo.prototype,"_rect2",2),zo=l([b2({tagName:D_+"-fx-pulse",shadow:y2.USE_SHADOW_ROOT,template:`<${D_}-resize target="{{ :host.target }}" watch-position="true" on-${x2.ResizeEventName}=":host._resizeHandler($event)"></${D_}-resize>
|
|
577
|
+
<svg class="${C2}" xmlns="${E2}">
|
|
578
|
+
<rect rect1 /><rect rect2 />
|
|
579
|
+
</svg>`})],zo);import{CustomElement as k2,Watch as O_,PropertyConverters as P_,P as M2,PCSS as S2,Utils as on}from"@pacem/pacem-core";var uA=S2+"-hero",hA=200,L2="entering",N2="exiting",T2="entered",A2="exited",mA={convert:a=>a.trim().startsWith("#")?P_.Element.convert(a):P_.Json.convert(a)},Go=class extends En{propertyChangedCallback(r,e,t,n){super.propertyChangedCallback(r,e,t,n),r==="target"&&!on.isNull(e)&&this._resetTarget(e),r==="from"&&this.hero&&!on.isNull(t)&&(this._originalState=this._computeFromState()),(r==="hero"||r==="target"||r==="goal")&&(on.isNull(this.target)||(this.hero?this.start():this.reset()))}viewActivatedCallback(){super.viewActivatedCallback(),this.hero&&!on.isNull(this.target)&&this.start()}disconnectedCallback(){on.isNull(this.target)||this.reset(),super.disconnectedCallback()}_computeFromState(){let r=this.target,e=on.offset(r);if(this.from instanceof Element){let t=on.offset(this.from);return{x:t.left,y:t.top,width:t.width,height:t.height}}else return{x:e.left,y:e.top,width:e.width,height:e.height}}_resetTarget(r=this.target){let e=r.style;e.top=e.left=e.height=e.width="";for(let t=0;t<e.length;t++){let n=e.item(t);e[n]=""}for(let t in this._originalStyle)e[t]=this._originalStyle[t];on.removeClass(r,uA)}reset(){if(!(on.isNull(this._originalState)||on.isNull(this._targetState)))return this.dispatchEvent(new Event(N2)),this._animate(this._targetState,this._originalState).then(()=>{this._resetTarget(),this.dispatchEvent(new Event(A2))})}start(){if(!this.disabled&&!on.isNull(this.target)){let r;if(this.to instanceof Element){let o=on.offset(this.to);r={x:o.left,y:o.top,width:o.width,height:o.height}}else r=this.to;let e=this.target,t=on.windowSize,n=r||{x:0,y:0,width:t.width,height:t.height},i=e.style;this._targetState=n;let s=this._originalState=this._computeFromState();this._originalStyle={};for(let o=0;o<i.length;o++){let c=i.item(o);this._originalStyle[c]=i[c]}return on.addClass(e,uA),this.dispatchEvent(new Event(L2)),this._animate(s,n).then(()=>{this.dispatchEvent(new Event(T2))})}return Promise.resolve()}_animate(r,e){let t=this.target,n=t.style,i=r.width/e.width,s=r.height/e.height,o=r.x-e.x+"px",c=r.y-e.y+"px";return n.transformOrigin="0 0",n.transition="none",n.transform=`translate(${o}, ${c}) scale(${i}, ${s})`,n.width=e.width+"px",n.height=e.height+"px",n.top=e.y+"px",n.left=e.x+"px",requestAnimationFrame(()=>{let d=this.duration||hA;n.transition=`transform cubic-bezier(0.445, 0.05, 0.55, 0.95) ${d}ms, opacity ${d}ms`,n.transform="translate(0, 0) scale(1)"}),on.waitForAnimationEnd(t,hA+10)}};l([O_({converter:P_.Boolean})],Go.prototype,"hero",2),l([O_({converter:mA,emit:!1})],Go.prototype,"to",2),l([O_({converter:mA,emit:!1})],Go.prototype,"from",2),l([O_({converter:P_.Number,emit:!1})],Go.prototype,"duration",2),Go=l([k2({tagName:M2+"-fx-hero"})],Go);import{CustomElement as D2,P as R2,PCSS as O2,Utils as I_}from"@pacem/pacem-core";var fA=O2+"-fx-list",Kg=class extends En{constructor(){super(...arguments);this._observed=e=>{let t=Array.from(this.target.children);for(let n of e)n.removedNodes.forEach(i=>{i instanceof Element&&this.dispatchEvent(new CustomEvent("itemremoved",{detail:i}))}),n.addedNodes.forEach((i,s)=>{i instanceof Element&&this.dispatchEvent(new CustomEvent("itemadded",{detail:{item:i,index:t.indexOf(i)}}))})}}viewActivatedCallback(){super.viewActivatedCallback(),I_.isNull(this.target)||this._setup()}disconnectedCallback(){I_.isNull(this._observer)||this._observer.disconnect(),super.disconnectedCallback()}propertyChangedCallback(e,t,n,i){super.propertyChangedCallback(e,t,n,i),e==="target"&&(t?this._reset(t):this._setup())}_reset(e){I_.removeClass(e,fA),this._observer.disconnect()}_setup(){let e=this.target;I_.addClass(e,fA),(this._observer=new MutationObserver(this._observed)).observe(e,{childList:!0})}};Kg=l([D2({tagName:R2+"-fx-list"})],Kg);import{CustomElement as B_,Watch as Wo,PropertyConverters as jo,P as V_,PCSS as $_,Components as s0,CustomElementUtils as P2,Utils as vs,Debounce as I2}from"@pacem/pacem-core";import{Size as $2,Colors as gA}from"@pacem/pacem-foundation";var Jg="gradientchange",H_=class extends Event{constructor(){super(Jg,{cancelable:!1,bubbles:!1})}},H2={convert:(a,r)=>{try{return $2.parse(a)}catch{return jo.Number.convert(a,r)}}};function dm(a){return Math.round(a*1e3)/10+"%"}var Fo=class extends s0.PacemItemElement{findContainer(){return P2.findAncestor(this,r=>r instanceof Ep)}propertyChangedCallback(r,e,t,n){super.propertyChangedCallback(r,e,t,n),!n&&(r==="offset"||r==="color"||r==="opacity"||r==="disabled"||r==="hide")&&this.dispatchEvent(new H_)}};l([Wo({emit:!1,converter:jo.Number})],Fo.prototype,"offset",2),l([Wo({emit:!1,converter:jo.String})],Fo.prototype,"color",2),l([Wo({emit:!1,converter:jo.Number})],Fo.prototype,"opacity",2),Fo=l([B_({tagName:V_+"-fx-gradient-stop"})],Fo);var Ep=class extends s0.PacemCrossItemsContainerElement{constructor(){super(...arguments);this._dispatchGradientChangeHandler=e=>{this._dispatchGradientChange()}}validate(e){return e instanceof Fo}register(e){let t=super.register(e);return t&&e.addEventListener(Jg,this._dispatchGradientChangeHandler,!1),t}unregister(e){let t=super.unregister(e);return t&&e.removeEventListener(Jg,this._dispatchGradientChangeHandler,!1),t}propertyChangedCallback(e,t,n,i){super.propertyChangedCallback(e,t,n,i),!i&&this.doesPropertyTriggerGradientChange(e)&&this._dispatchGradientChange()}_dispatchGradientChange(){this.dispatchEvent(new H_)}buildColor(e,t){if(t>=0&&t<=1){let n=gA.parse(e);return gA.stringify(vs.extend(n,{a:t}))}return e}},Mc=class extends Ep{doesPropertyTriggerGradientChange(r){return["shape","size","center","items","hide","disabled"].indexOf(r)>=0}buildGradient(){let r=this.items;if(vs.isNullOrEmpty(r))return"";let e=this.shape==="circle"?"circle":"ellipse",t=this.center??{x:.5,y:.5},n=this.size,i="";vs.isNullOrEmpty(n)||(typeof n=="number"?i=`${n}px`:i=`${dm(n.width/2)} ${dm(n.height/2)}`);let s=[];for(let{offset:o,color:c,hide:d,disabled:p,opacity:u}of r){if(d||p)continue;let h=this.buildColor(c,u);s.push(`${h} ${dm(o)}`)}return`radial-gradient(${e} ${i} at ${dm(t.x)} ${dm(t.y)} in oklab, ${s.join(", ")})`}};l([Wo({emit:!1,converter:jo.String})],Mc.prototype,"shape",2),l([Wo({emit:!1,converter:jo.Point})],Mc.prototype,"center",2),l([Wo({emit:!1,converter:H2})],Mc.prototype,"size",2),Mc=l([B_({tagName:V_+"-fx-gradient-radial"})],Mc);var pm=class extends Ep{doesPropertyTriggerGradientChange(r){return["angle","items","hide","disabled"].indexOf(r)>=0}buildGradient(){let r=this.items;if(vs.isNullOrEmpty(r))return"";let e=this.angle??0,t=[];for(let{offset:n,color:i,hide:s,disabled:o,opacity:c}of r){if(s||o)continue;let d=this.buildColor(i,c);t.push(`${d} ${dm(n)}`)}return`linear-gradient(${e}deg in oklab, ${t.join(", ")})`}};l([Wo({emit:!1,converter:jo.Number})],pm.prototype,"angle",2),pm=l([B_({tagName:V_+"-fx-gradient-linear"})],pm);var Sc=class extends s0.PacemItemsContainerElement{constructor(){super(...arguments);this._gradientChangeHandler=e=>{this._buildGradient()}}validate(e){return e instanceof Ep}register(e){let t=super.register(e);return t&&e.addEventListener(Jg,this._gradientChangeHandler,!1),t}unregister(e){let t=super.unregister(e);return t&&e.removeEventListener(Jg,this._gradientChangeHandler,!1),t}viewActivatedCallback(){super.viewActivatedCallback(),this._buildGradient()}propertyChangedCallback(e,t,n,i){if(super.propertyChangedCallback(e,t,n,i),!i)switch(e){case"target":t&&this._removeGradient(t);case"mode":case"disabled":this._buildGradient();break}}_removeGradient(e){vs.removeClass(e,$_+"-fx-gradient-text"),vs.removeClass(e,$_+"-fx-gradient-fill"),e.style.backgroundImage=""}_buildGradient(){let e=this.target;if(vs.isNull(e))return;let t="",n=this.disabled?[]:this.items??[];for(let i of n){if(i.hide||i.disabled)continue;let s=i.buildGradient();vs.isNullOrEmpty(s)||(t+=s,t.trim().endsWith(",")||(t+=","))}if(vs.isNullOrEmpty(t))this._removeGradient(e);else{let i=$_+"-fx-gradient-text",s=$_+"-fx-gradient-fill",o=this.mode==="text";vs.removeClass(e,o?s:i),vs.addClass(e,o?i:s),e.style.backgroundImage=t.substring(0,t.length-1)}}};l([Wo({converter:jo.Element})],Sc.prototype,"target",2),l([Wo({converter:jo.String})],Sc.prototype,"mode",2),l([I2(!0)],Sc.prototype,"_buildGradient",1),Sc=l([B_({tagName:V_+"-fx-gradient"})],Sc);import{CustomElement as B2,Watch as a0,PropertyConverters as o0,P as V2,PCSS as bA,Utils as wp,PropertyChangeEvent as U_}from"@pacem/pacem-core";var vA=bA+"-fancy",U2=bA+"-fancify",z2=20,Lc=class extends En{constructor(){super(...arguments);this._progress=0;this._started=!1}get progress(){return this._progress}get started(){return this._started}propertyChangedCallback(e,t,n,i){super.propertyChangedCallback(e,t,n,i),(e==="fancify"||e==="target")&&(wp.isNull(this.target)||(this.fancify?this.start():this._reset()))}viewActivatedCallback(){super.viewActivatedCallback(),this.fancify&&!wp.isNull(this.target)&&this.start()}disconnectedCallback(){cancelAnimationFrame(this._handle),clearTimeout(this._handle1),wp.isNull(this.target)||this._reset(),super.disconnectedCallback()}_reset(){wp.removeClass(this.target,vA),this._started&&this.dispatchEvent(new U_({propertyName:"started",oldValue:this._started,currentValue:this._started=!1})),this.dispatchEvent(new U_({propertyName:"progress",oldValue:this._progress,currentValue:this._progress=0})),wp.isNull(this._originalContent)?this._originalContent=this.target.innerHTML:this.target.innerHTML=this._originalContent}_parse(){let e,t=[],n=document.createTreeWalker(this.target,NodeFilter.SHOW_TEXT);for(;e=n.nextNode();)e.textContent&&t.push(e);this._textNodes=t}start(){this.disabled||(this._reset(),this._parse(),this._startShow(),this._handle1=setTimeout(()=>{this.dispatchEvent(new U_({propertyName:"started",oldValue:this._started,currentValue:this._started=!0}))},this.delay||0))}_startShow(e=0){wp.addClass(this.target,vA);let t=this._textNodes,n=t.length;this._fancify(t[e]);let i=this._progress;e++;let s=this._progress=e/n;this.dispatchEvent(new U_({propertyName:"progress",oldValue:i,currentValue:s})),e<n&&(this._handle=requestAnimationFrame(()=>{this._startShow(e)}))}_fancify(e){let t=e.textContent;if(wp.isNullOrEmpty(t)||!/[^\s]/.test(t))return;let n=/^\s/.test(t),i=/\s$/.test(t);e.textContent="";let s=t.trim().split(" "),o=this.gap||z2,c=this.delay||0,d=0;for(let u of s){var p=document.createElement("span");p.className=U2,p.style.animationDelay=`${c+d*o}ms`,(n||d>0)&&e.parentElement.insertBefore(document.createTextNode(" "),e),p.textContent=u,e.parentElement.insertBefore(p,e),d++}i&&e.parentElement.insertBefore(document.createTextNode(" "),e)}};l([a0({converter:o0.Boolean})],Lc.prototype,"fancify",2),l([a0({converter:o0.Number})],Lc.prototype,"delay",2),l([a0({converter:o0.Number})],Lc.prototype,"gap",2),Lc=l([B2({tagName:V2+"-fx-fancy"})],Lc);var p0={};tt(p0,{PacemHubListenerElement:()=>Yo,PacemHubProxyElement:()=>ga,PacemServerSentEventsListenerElement:()=>kp,PacemServerSentEventsProxyElement:()=>va});import{P as _A,CustomElement as xA,Watch as um,PropertyConverters as hm,Utils as fa,PropertyChangeEventName as yA,CustomElementUtils as G2,Components as CA}from"@pacem/pacem-core";var F2="https://cdn.jsdelivr.net/npm/@microsoft/signalr@10.0.0/dist/browser/signalr.min.js",W2={API_JS:F2},Zg,Yo=class extends CA.PacemItemElement{constructor(){super(...arguments);$(this,Zg);this._receiveHandler=(...e)=>{this.dispatchEvent(new CustomEvent("receive",{detail:Array.from(e)}))};this._completeHandler=()=>{this.dispatchEvent(new Event("complete"))};this._errorHandler=e=>{this.dispatchEvent(new CustomEvent("error",{detail:e}))};this._connectedHandler=e=>{e.detail.propertyName==="connected"&&e.detail.currentValue===!0&&this._start()}}get _isConnected(){return this.container instanceof ga&&this.container.connected||!1}get _connection(){return this.container instanceof ga&&this.container.connection||null}start(){this.disabled||this._start()}stop(){this._stop()}_stop(e=this.method,t=this.stream){if(!this._isConnected)return;let n=this._connection;fa.isNullOrEmpty(e)||(t?x(this,Zg)?.dispose():n.off(e,this._receiveHandler))}_start(e=this.method,t=this.stream){if(!this._isConnected)return;let n=this._connection;if(!fa.isNullOrEmpty(e))if(!t)n.on(e,this._receiveHandler);else{let i=this.arguments||[],s=signalR.HubConnection.prototype.stream.apply(n,[e].concat(i));A(this,Zg,s.subscribe({next:this._receiveHandler,complete:this._completeHandler,error:this._errorHandler}))}}viewActivatedCallback(){super.viewActivatedCallback();let e=this.container;fa.isNull(e)||e.addEventListener(yA,this._connectedHandler,!1),this.start()}disconnectedCallback(){let e=this.container;fa.isNull(e)||e.removeEventListener(yA,this._connectedHandler,!1),super.disconnectedCallback()}propertyChangedCallback(e,t,n,i){switch(super.propertyChangedCallback(e,t,n,i),e){case"arguments":this._stop(),this._start();break;case"method":fa.isNullOrEmpty(t)||this._stop(t,this.stream),fa.isNullOrEmpty(n)||this._start(n,this.stream);break;case"stream":let s=this.method;fa.isNullOrEmpty(s)||(this._stop(s,t),this._start(s,n));break;case"disabled":fa.isNullOrEmpty(this.method)||(n?this._stop:this._start)();break}}};Zg=new WeakMap,l([um({emit:!1,converter:hm.String})],Yo.prototype,"method",2),l([um({emit:!1,converter:hm.Boolean})],Yo.prototype,"stream",2),l([um({emit:!1,converter:hm.Json})],Yo.prototype,"arguments",2),Yo=l([xA({tagName:_A+"-hub-listener"})],Yo);var ga=class extends CA.PacemItemsContainerElement{validate(r){return r instanceof Yo}get connection(){return this._hub}invoke(r,...e){if(this.connected)return this._hub.invoke.apply(this._hub,arguments);throw"Hub is not connected. Cannot call `invoke` method."}send(r,...e){if(this.connected)return this._hub.send(r,...e);throw"Hub is not connected. Cannot call `send` method."}start(){return this._resetProxy()}async stop(){this.connected&&await this._hub.stop()}propertyChangedCallback(r,e,t,n){super.propertyChangedCallback(r,e,t,n),!n&&(r==="url"||r==="disabled"||r==="accesstoken")&&this._resetProxy()}viewActivatedCallback(){super.viewActivatedCallback(),this.start()}disconnectedCallback(){this.stop(),super.disconnectedCallback()}async _resetProxy(){fa.isNull(this._hub)||await this._hub.stop(),this._setupProxy()}async _initialize(){"signalR"in window||await G2.importjs(W2.API_JS)}async _setupProxy(){let r=this.items||[];if(!this.disabled&&!fa.isNullOrEmpty(this.url)){await this._initialize();let e=new signalR.HubConnectionBuilder;e.withUrl(this.url,{accessTokenFactory:()=>this.accesstoken});let t=this._hub=e.build();t.onclose(()=>{for(var n of r)n.stop();this.connected=!1,this._hub=null}),await t.start(),this.connected=!0}}};l([um({emit:!1,converter:hm.String})],ga.prototype,"url",2),l([um({emit:!1,converter:hm.String})],ga.prototype,"accesstoken",2),l([um({converter:hm.Boolean})],ga.prototype,"connected",2),ga=l([xA({tagName:_A+"-hub-proxy"})],ga);import{P as wA,CustomElement as kA,Watch as c0,PropertyConverters as d0,Utils as Xo,PropertyChangeEventName as EA,Debounce as j2,Components as MA}from"@pacem/pacem-core";var kp=class extends MA.PacemItemElement{constructor(){super(...arguments);this._receiveHandler=e=>{this.dispatchEvent(new CustomEvent("receive",{detail:e.data}))};this._connectedHandler=e=>{e.detail.propertyName==="connected"&&e.detail.currentValue===!0&&this._start()}}get _isConnected(){return this.container instanceof va&&this.container.connected||!1}get _connection(){return this.container instanceof va&&this.container.eventSource||null}_stop(e=this.method){if(!this._isConnected)return;let t=this._connection;Xo.isNullOrEmpty(e)||t.removeEventListener(e,this._receiveHandler)}_start(e=this.method){if(!this._isConnected)return;let t=this._connection;Xo.isNullOrEmpty(e)||t.addEventListener(e,this._receiveHandler)}start(){this.disabled||this._start()}stop(){this._stop()}viewActivatedCallback(){super.viewActivatedCallback();let e=this.container;Xo.isNull(e)||e.addEventListener(EA,this._connectedHandler,!1),this.start()}disconnectedCallback(){let e=this.container;Xo.isNull(e)||e.removeEventListener(EA,this._connectedHandler,!1),super.disconnectedCallback()}propertyChangedCallback(e,t,n,i){switch(super.propertyChangedCallback(e,t,n,i),e){case"method":Xo.isNullOrEmpty(t)||this._stop(t),Xo.isNullOrEmpty(n)||this._start(n);break;case"disabled":Xo.isNullOrEmpty(this.method)||(n?this._stop:this._start)();break}}};l([c0({emit:!1,converter:d0.String})],kp.prototype,"method",2),kp=l([kA({tagName:wA+"-sse-listener"})],kp);var Nc,va=class extends MA.PacemItemsContainerElement{constructor(){super(...arguments);$(this,Nc);this._connectHandler=e=>{this.connected=!0,x(this,Nc).onmessage=this._receiveHandler};this._errorHandler=e=>{this.connected=!1};this._receiveHandler=e=>{this.dispatchEvent(new CustomEvent("receive",{detail:e.data}))}}validate(e){return e instanceof kp}viewActivatedCallback(){super.viewActivatedCallback(),this._start()}disconnectedCallback(){this._stop(),super.disconnectedCallback()}propertyChangedCallback(e,t,n,i){super.propertyChangedCallback(e,t,n,i),!i&&(e==="url"||e==="disabled")&&this._restart()}_restart(){this._stop(),this._start()}_start(e=this.url){if(!Xo.isNullOrEmpty(e)&&!this.disabled){let t=A(this,Nc,new EventSource(e));t.onopen=this._connectHandler,t.onerror=this._errorHandler}}get eventSource(){return x(this,Nc)}_stop(){let e=this.items||[];for(var t of e)t.stop();let n=x(this,Nc);Xo.isNull(n)||(n.onopen=null,n.onerror=null,n.onmessage=null,n.close()),this.connected=!1,A(this,Nc,null)}};Nc=new WeakMap,l([c0({emit:!1,converter:d0.String})],va.prototype,"url",2),l([c0({converter:d0.Boolean})],va.prototype,"connected",2),l([j2(!0)],va.prototype,"_restart",1),va=l([kA({tagName:wA+"-sse-proxy"})],va);var m0={};tt(m0,{PacemAudioElement:()=>Tc,PacemMediaRecorderElement:()=>Ni});import{P as Y2,CustomElement as X2,PacemEventTarget as q2,Watch as u0,PropertyConverters as h0}from"@pacem/pacem-core";var qo,mm,fm,Tc=class extends q2{constructor(){super(...arguments);$(this,qo);$(this,mm);$(this,fm);this._endedHandler=e=>{this.dispatchEvent(new Event("end"))};this._canPlayHandler=e=>{A(this,mm,!0),this._autoplay()};this._canPlayThroughHandler=e=>{A(this,fm,!0),this._autoplay()}}connectedCallback(){super.connectedCallback();let e=A(this,qo,new Audio);e.addEventListener("canplay",this._canPlayHandler,!1),e.addEventListener("ended",this._endedHandler,!1),e.addEventListener("canplaythrough",this._canPlayThroughHandler,!1)}propertyChangedCallback(e,t,n,i){super.propertyChangedCallback(e,t,n,i),i||e==="src"&&this._init()}viewActivatedCallback(){super.viewActivatedCallback(),this._init()}disconnectedCallback(){let e=x(this,qo);e.removeEventListener("ended",this._endedHandler,!1),e.removeEventListener("canplaythrough",this._canPlayThroughHandler,!1),e.removeEventListener("canplay",this._canPlayHandler,!1),super.disconnectedCallback()}play(){return this.disabled?Promise.reject("disabled"):x(this,qo).play().then(e=>{this.dispatchEvent(new Event("start"))},e=>{this.dispatchEvent(new CustomEvent("error",{detail:e}))})}pause(){x(this,qo).pause()}reset(){x(this,qo).load()}get _canPlay(){return this.stream&&x(this,mm)||x(this,fm)}_autoplay(){this.autoplay&&this._canPlay&&this.play()}_init(e=this.src){let t=x(this,qo);A(this,mm,A(this,fm,!1)),t.src=e}};qo=new WeakMap,mm=new WeakMap,fm=new WeakMap,l([u0({emit:!1,converter:h0.String})],Tc.prototype,"src",2),l([u0({emit:!1,converter:h0.Boolean})],Tc.prototype,"stream",2),l([u0({emit:!1,converter:h0.Boolean})],Tc.prototype,"autoplay",2),Tc=l([X2({tagName:Y2+"-audio"})],Tc);import{P as K2,CustomElement as J2,PacemEventTarget as Z2,Watch as Mp,PropertyConverters as gm,Utils as vm}from"@pacem/pacem-core";var Q2=25,SA="video/mp4",e3=128e3,t3=25e5,LA=["start","stop","dataavailable","pause","resume","error","warning"];function r3(a){return a instanceof HTMLCanvasElement?!0:"captureStream"in a&&typeof a.captureStream=="function"}var Ti,bm,Ni=class extends Z2{constructor(){super(...arguments);this._recorderLifecycleHandler=e=>{switch(this.state=x(this,Ti).state,e.type){case"start":this.output=null;break;case"stop":this.flush();break;case"dataavailable":var t=e;x(this,bm).push(t.data);break}};$(this,Ti,null);$(this,bm,[])}viewActivatedCallback(){super.viewActivatedCallback(),this._setupMediaRecorder()}propertyChangedCallback(e,t,n,i){if(super.propertyChangedCallback(e,t,n,i),!i)switch(e){case"source":case"fps":case"mimeType":case"audioBitsPerSecond":case"videoBitsPerSecond":this._setupMediaRecorder();break}}disconnectedCallback(){this._closeMediaRecorder(),super.disconnectedCallback()}_setupMediaRecorder(e=this.source,t={mimeType:this.mimeType||SA,audioBitsPerSecond:this.audioBitsPerSecond??e3,videoBitsPerSecond:this.videoBitsPerSecond??t3}){if(this._closeMediaRecorder(),!vm.isNull(e)){if(r3(e)){let i=this.fps||Q2;e=e.captureStream(i)}try{A(this,Ti,new MediaRecorder(e,t))}catch(i){console.error(i)}let n=x(this,Ti);LA.forEach(i=>{n.addEventListener(i,this._recorderLifecycleHandler,!1)})}}_closeMediaRecorder(){let e=x(this,Ti);vm.isNull(e)||(e.state!=="inactive"&&e.stop(),LA.forEach(t=>{e.removeEventListener(t,this._recorderLifecycleHandler,!1)}),A(this,Ti,null))}flush(){let e=new Blob(x(this,bm),{type:this.mimeType||SA});A(this,bm,[]),this.output=e}start(){let e=x(this,Ti);!vm.isNull(e)&&e.state==="inactive"&&e.start()}stop(){let e=x(this,Ti);!vm.isNull(e)&&e.state!=="inactive"&&e.stop()}resume(){let e=x(this,Ti);!vm.isNull(e)&&e.state==="paused"&&e.start()}pause(){let e=x(this,Ti);!vm.isNull(e)&&e.state!=="paused"&&e.pause()}};Ti=new WeakMap,bm=new WeakMap,l([Mp({emit:!1,converter:gm.Element})],Ni.prototype,"source",2),l([Mp({emit:!1,converter:gm.Number})],Ni.prototype,"fps",2),l([Mp({emit:!1,converter:gm.String})],Ni.prototype,"mimeType",2),l([Mp({emit:!1,converter:gm.Number})],Ni.prototype,"audioBitsPerSecond",2),l([Mp({emit:!1,converter:gm.Number})],Ni.prototype,"videoBitsPerSecond",2),l([Mp({converter:gm.String})],Ni.prototype,"state",2),l([Mp()],Ni.prototype,"output",2),Ni=l([J2({tagName:K2+"-media-recorder"})],Ni);var E0={};tt(E0,{AdapterUtils:()=>At,CornerType:()=>BA,DrawableElement:()=>Ko,Pacem2DElement:()=>Nr,PacemCanvasAdapterElement:()=>dv,PacemCircleElement:()=>bs,PacemEllipseElement:()=>Xn,PacemGroupElement:()=>Ac,PacemImageElement:()=>wn,PacemLineElement:()=>Qo,PacemPathElement:()=>km,PacemPolygonElement:()=>Kn,PacemPolylineElement:()=>ya,PacemRectElement:()=>qn,PacemSvgAdapterElement:()=>hv,PacemTextElement:()=>Tr,PresentationElement:()=>Ai,ShapeElement:()=>Rt,UiElement:()=>vr,getStageOptions:()=>Cm});import{Components as c3,CustomElementUtils as RA,PropertyConverters as OA,Watch as PA}from"@pacem/pacem-core";import{CustomElement as n3,Watch as ym,ViewChild as NA,Debounce as i3,PCSS as TA,P as z_,Utils as Ct,PropertyConverters as Qg,PropertyChangeEvent as s3,CustomEventUtils as f0,avoidHandler as g0,EventKeyModifier as AA,Components as G_}from"@pacem/pacem-core";import{Rect as v0,Matrix2D as a3}from"@pacem/pacem-foundation";var Jle=2*Math.PI;var o3=/^\s*[xX]\s*([Mm](in|ax|id))\s*[yY]\s*([Mm](in|ax|id))(\s+(none|slice|meet))?\s*$/,l3={convert:a=>{let r=o3.exec(a);return r&&r.length>=4?{x:r[1].toLowerCase(),y:r[3].toLowerCase(),slice:r[6]==="slice"}:"none"},convertBack:a=>Ct.isNull(a)||typeof a=="string"?"none":`xM${a.x.substring(1)}YM${a.y.substring(1)} ${a.slice?"slice":"meet"}`},DA={panControl:!0,zoomControl:!0,panModifiers:[AA.AltKey],zoomModifiers:[AA.AltKey],clickModifiers:[]};function Cm(a){let r=a instanceof Nr?a.options:{};return Ct.extend({},DA,r)}var _m,Sp,Lp,ba,xm,Nr=class extends G_.PacemItemsContainerElement{constructor(){super(...arguments);$(this,_m);$(this,Sp,a3.identity);$(this,Lp,DA);$(this,ba);this._resizeHandler=e=>{A(this,ba,{x:e.detail.left,y:e.detail.top,width:e.detail.width,height:e.detail.height});let t=this.adapter;Ct.isNull(t)||this._invalidateSize()};this._zoomHandler=e=>{if(!e.isTrusted)return;let t=x(this,Lp);if(t.zoomControl&&f0.matchModifiers(e,t.zoomModifiers)){g0(e);let n=e.deltaY<0,i=.1,s=n?-1:1,o=i*s,c=1+o,d=Ct.offsetRect(e.currentTarget),p={x:e.clientX,y:e.clientY};this._zoom(c,d,p)}};this._panHandler=e=>{let t=x(this,xm),n=this._getPanPoint(e);if(!Ct.isNullOrEmpty(t&&t.point)&&!Ct.isNull(n)){g0(e);let i=t.factor,s=t.box,o=t.point;this.viewbox={x:s.x-i*(n.x-o.x),y:s.y-i*(n.y-o.y),width:s.width,height:s.height}}};$(this,xm);this._panStartHandler=e=>{if(!x(this,Lp).panControl||!e.isTrusted)return;let n=x(this,ba),i=this.viewbox||{x:0,y:0,width:n.width,height:n.height},s=this._getPanPoint(e);if(s){g0(e),this._stage.style.pointerEvents="none";let o=this._getActualAspectRatio(),c=i.width/n.width,d=i.height/n.height,p=o.slice?Math.min(c,d):Math.max(c,d);A(this,xm,{point:s,box:i,factor:p})}};this._panEndHandler=e=>{this._stage.style.pointerEvents="",A(this,xm,null)}}get stage(){return this._stage}snapshot(e,t,n){let i=this.adapter;return Ct.isNull(i)?Promise.resolve(null):i.snapshot(this,e,t,n)}get transformMatrix(){return x(this,Sp)}_transformMatrixScale(){let e=x(this,ba)||Ct.offsetRect(this._stage);var t=x(this,_m)||e;let n=this.viewbox||t,i=this.aspectRatio||"none",s=i==="none"?"stretch":i.slice?"cover":"contain";return v0.findTransform(n,t,s).a}validate(e){return e instanceof Ko&&Ct.isNull(e.parent)}draw(e,t=!1){let n=this.adapter;if(!this.disabled&&!Ct.isNull(n)){let i=new CustomEvent("predraw",{cancelable:!0});this.dispatchEvent(i),i.defaultPrevented||(n.draw(this,e,t),this.dispatchEvent(new CustomEvent("draw")))}}_drawDebounced(e,t=!1){!Ct.isNull(e)&&sd(e)?this.draw(e,t):this.draw(e)}requestDraw(e,t=!1){this._drawDebounced(e,t)}_buildUpDatasourceFromDOM(){this.datasource=(this.items||[]).slice()}_getActualAspectRatio(){let e=this.aspectRatio||"none",t=e==="none"?"mid":e.x,n=e==="none"?"mid":e.y,i=e==="none"?!1:e.slice;return{x:t,y:n,slice:i}}_zoomFromValue(e){let t=x(this,ba);if(Ct.isNull(t))return;let n=t,i=x(this,_m)||n,s=this.viewbox||i,o=this.aspectRatio||"none",c=o==="none"?"stretch":o.slice?"cover":"contain",d=v0.findTransform(s,n,c),p=v0.findTransform(i,n,c),u=d.a,m=p.a*e,f=u/m;this._zoom(f)}_zoom(e,t,n){Ct.isNull(t)&&(t=Ct.offsetRect(this._stage)),Ct.isNull(n)&&(n={x:t.x+t.width*.5,y:t.y+t.height*.5});let i=x(this,ba),s=this.viewbox||i,o=Math.min(s.width,s.height),c=o*e,d=o*e;if(c>0&&d>0){let p=this._getActualAspectRatio(),u=p.x,h=p.y,m=p.slice,f=s.width/s.height,g=m?Math.max(t.width,t.height):Math.min(t.width,t.height),v,b;switch(u){case"mid":v=(c-s.width)*(n.x-t.x-.5*(t.width-g))/(g*f);break;case"max":v=(c-s.width)*(n.x-t.x-(t.width-g))/(g*f);break;default:v=(c-s.width)*(n.x-t.x)/(g*f);break}switch(h){case"mid":b=(d-s.height)*(n.y-t.y-.5*(t.height-g))/(g*f);break;case"max":b=(d-s.height)*(n.y-t.y-(t.height-g))/(g*f);break;default:b=(d-s.height)*(n.y-t.y)/(g*f);break}let _=s.x-v,E=s.y-b;this.viewbox={x:_,y:E,width:c,height:d}}}_getPanPoint(e){let t=x(this,Lp);return e instanceof MouseEvent&&f0.matchModifiers(e,t.panModifiers)?f0.getEventCoordinates(e).page:null}_invalidateSize(){this.adapter.invalidateSize(this,x(this,ba));let e=x(this,Sp);A(this,Sp,this.adapter.getTransformMatrix(this)),this.dispatchEvent(new s3({propertyName:"transformMatrix",currentValue:x(this,Sp),oldValue:e})),this.zoom=this._transformMatrixScale(),this.dispatchEvent(new G_.ResizeEvent(x(this,ba)))}viewActivatedCallback(){super.viewActivatedCallback();let e=this.adapter;Ct.isNull(e)||(e.initialize(this),this._invalidateSize(),this._drawDebounced());let t=this._resize;t.addEventListener(G_.ResizeEventName,this._resizeHandler,!1);let n=this._stage;t.target=n;let i={capture:!1,passive:!0};n.addEventListener("wheel",this._zoomHandler,!1),n.addEventListener("mousedown",this._panStartHandler,!1),n.addEventListener("touchstart",this._panStartHandler,i),window.addEventListener("mousemove",this._panHandler,!1),window.addEventListener("mouseup",this._panEndHandler,!1),window.addEventListener("touchmove",this._panHandler,i),window.addEventListener("touchend",this._panEndHandler,i)}propertyChangedCallback(e,t,n,i){switch(super.propertyChangedCallback(e,t,n,i),e){case"adapter":Ct.isNull(t)||t.dispose(this),Ct.isNull(n)||(n.initialize(this),this._invalidateSize(),this._drawDebounced());break;case"aspectRatio":Ct.isNull(this.adapter)||this._invalidateSize();break;case"viewbox":Ct.isNull(this.adapter)||this._invalidateSize(),x(this,_m)??A(this,_m,this.viewbox||null);break;case"items":this._buildUpDatasourceFromDOM();break;case"zoom":n!==this._transformMatrixScale()&&this._zoomFromValue(n);break;case"options":A(this,Lp,Cm(this));break;case"disabled":case"datasource":this._drawDebounced();break}}disconnectedCallback(){let e=this._resize,t=this._stage;Ct.isNull(e)||e.removeEventListener(G_.ResizeEventName,this._resizeHandler,!1),Ct.isNull(t)||(t.removeEventListener("wheel",this._zoomHandler,!1),t.removeEventListener("mousedown",this._panStartHandler,!1),t.removeEventListener("touchstart",this._panStartHandler),window.removeEventListener("mousemove",this._panHandler,!1),window.removeEventListener("mouseup",this._panEndHandler,!1),window.removeEventListener("touchmove",this._panHandler),window.removeEventListener("touchend",this._panEndHandler)),Ct.isNull(this.adapter)||this.adapter.dispose(this),super.disconnectedCallback()}};_m=new WeakMap,Sp=new WeakMap,Lp=new WeakMap,ba=new WeakMap,xm=new WeakMap,l([ym({converter:Qg.Element})],Nr.prototype,"adapter",2),l([ym({reflectBack:!0,converter:Qg.Rect})],Nr.prototype,"viewbox",2),l([ym({emit:!1,reflectBack:!0,converter:l3})],Nr.prototype,"aspectRatio",2),l([ym({emit:!1,converter:Qg.Json})],Nr.prototype,"datasource",2),l([ym({emit:!1,converter:Qg.Json})],Nr.prototype,"options",2),l([ym({converter:Qg.Number})],Nr.prototype,"zoom",2),l([NA("."+TA+"-2d")],Nr.prototype,"_stage",2),l([NA(z_+"-resize")],Nr.prototype,"_resize",2),l([i3(!0)],Nr.prototype,"_drawDebounced",1),Nr=l([n3({tagName:z_+"-"+"2d",shadow:!0,template:`<${z_}-resize watch-position="true"></${z_}-resize><div class="${TA}-2d" part="container"></div><slot></slot>`})],Nr);var ev=class ev extends c3.PacemCrossItemsContainerElement{validate(r){return!1}findContainer(){return this.parent||this.stage}get stage(){return this._scene=this._scene||RA.findAncestorOfType(this,Nr)}get parent(){return this._drawableParent=this._drawableParent||RA.findAncestor(this,r=>r instanceof ev)}disconnectedCallback(){delete this._scene,delete this._drawableParent,super.disconnectedCallback()}propertyChangedCallback(r,e,t,n){super.propertyChangedCallback(r,e,t,n),n||r==="hide"&&this.stage?.draw(this)}};l([PA({emit:!1,reflectBack:!0,converter:OA.String})],ev.prototype,"tag",2),l([PA({emit:!1,converter:OA.Boolean})],ev.prototype,"inert",2);var Ko=ev;import{Watch as Yn,PropertyConverters as Di,Utils as d3}from"@pacem/pacem-core";import{Matrix2D as p3}from"@pacem/pacem-foundation";var u3=Math.PI/180,vr=class extends Ko{#e=p3.identity;viewActivatedCallback(){super.viewActivatedCallback(),this._updateTransformMatrix()}propertyChangedCallback(r,e,t,n){if(super.propertyChangedCallback(r,e,t,n),!n)switch(r){case"rotate":case"scaleX":case"scaleY":case"translateX":case"translateY":this._updateTransformMatrix();case"opacity":this.stage?.draw(this);break}}_updateTransformMatrix(){let r=u3*(this.rotate??0),e=Math.cos(r),t=Math.sin(r),n=(this.scaleX??1)*e,i=-t,s=t,o=(this.scaleY??1)*e,c=this.translateX??0,d=this.translateY??0;this.#e={a:n,b:i,c:s,d:o,e:c,f:d}}get transformMatrix(){let r=this.#e;return{a:r.a,b:r.b,c:r.c,d:r.d,e:r.e,f:r.f}}};l([Yn({emit:!1,converter:Di.Number})],vr.prototype,"rotate",2),l([Yn({emit:!1,converter:Di.Number})],vr.prototype,"scaleX",2),l([Yn({emit:!1,converter:Di.Number})],vr.prototype,"scaleY",2),l([Yn({emit:!1,converter:Di.Number})],vr.prototype,"translateX",2),l([Yn({emit:!1,converter:Di.Number})],vr.prototype,"translateY",2),l([Yn({emit:!1,converter:Di.Number})],vr.prototype,"opacity",2);var Ai=class extends vr{propertyChangedCallback(r,e,t,n){if(super.propertyChangedCallback(r,e,t,n),!n)switch(r){case"stroke":case"lineWidth":case"lineJoin":case"lineCap":case"dashArray":case"fill":d3.isNull(this.stage)||this.stage.draw(this);break}}};l([Yn({emit:!1,converter:Di.String})],Ai.prototype,"stroke",2),l([Yn({emit:!1,converter:Di.String})],Ai.prototype,"fill",2),l([Yn({emit:!1,converter:{convert:r=>r?.split(",").map(e=>parseInt(e)).filter(e=>!Number.isNaN(e)),convertBack:r=>r?.join(",")}})],Ai.prototype,"dashArray",2),l([Yn({emit:!1,converter:Di.Number})],Ai.prototype,"lineWidth",2),l([Yn({emit:!1,converter:Di.String})],Ai.prototype,"lineJoin",2),l([Yn({emit:!1,converter:Di.String})],Ai.prototype,"lineCap",2);var Rt=class extends Ai{propertyChangedCallback(r,e,t,n){super.propertyChangedCallback(r,e,t,n),n||r==="data"&&this.stage?.draw(this)}viewActivatedCallback(){super.viewActivatedCallback(),this.recomputeShape()}recomputeShape(){let{pathData:r,vertices:e,boundingRect:t}=this.getShapeGeometry();this.#t=e,this.#e=t,this.data=r}get pathData(){return this.data}#e;get boundingRect(){return this.#e}#t;get vertices(){return this.#t}};l([Yn({emit:!1,converter:Di.String})],Rt.prototype,"data",2);import{CustomElement as h3,Watch as m3,P as f3,Utils as g3}from"@pacem/pacem-core";var tv,Ac=class extends Ai{constructor(){super(...arguments);$(this,tv,[])}validate(e){return e instanceof Ko&&e.parent===this}get childDrawables(){return x(this,tv)}propertyChangedCallback(e,t,n,i){switch(super.propertyChangedCallback(e,t,n,i),e){case"items":case"datasource":A(this,tv,n||[]);let s=this.stage;g3.isNull(s)||s.draw(this,!0);break}}};tv=new WeakMap,l([m3({emit:!1})],Ac.prototype,"datasource",2),Ac=l([h3({tagName:f3+"-"+"2d"+"-group"})],Ac);import{CustomElement as IA,Watch as Jo,PropertyConverters as Zo,P as $A,Utils as nv}from"@pacem/pacem-core";import{Rect as rv}from"@pacem/pacem-foundation";function v3(a,r,e){let t=2*r,n=a.x,i=a.y;return{pathData:`M ${n} ${i} m ${-r},0 a ${r},${e} 0 1,1 ${t},0 a ${r},${e} 0 1,1 ${-t},0`,vertices:[],boundingRect:{x:n-r,y:i-e,width:2*r,height:2*e}}}function b3(a,r,e,t,n){let i=Math.PI/180,s=i*t,o=i*n,c=_=>r*e/Math.sqrt(Math.pow(Math.cos(_)*e,2)+Math.pow(Math.sin(_)*r,2)),d=c(s),p=c(o),u=(_,E)=>({x:_*Math.cos(E),y:_*Math.sin(E)}),h=u(d,s),m=u(p,o),f={x:a.x+h.x,y:a.y+h.y},g={x:a.x+m.x,y:a.y+m.y},v=rv.expand(a,f,g);n<t&&(n+=360),(t<=0&&n>0||n>=360)&&(v=rv.expand(v,{x:a.x+r,y:a.y})),(t<=90&&n>90||n>=450)&&(v=rv.expand(v,{x:a.x,y:a.y+e})),(t<=180&&n>180||n>=540)&&(v=rv.expand(v,{x:a.x-r,y:a.y})),(t<=270&&n>270||n>=630)&&(v=rv.expand(v,{x:a.x,y:a.y-e}));let b=o-s>Math.PI?"1":"0";return{pathData:`M ${f.x} ${f.y} A ${r},${e} 0 ${b},1 ${g.x},${g.y} L ${a.x},${a.y} Z`,vertices:[f,g],boundingRect:v}}function b0(a,r,e,t,n){for(t??=0,n??=0,t%=360,n%=360;t<0;)t+=360;for(;n<t;)n+=360;return(t-n).isCloseTo(0)?v3(a,r,e):b3(a,r,e,t,n)}var Xn=class extends Rt{propertyChangedCallback(r,e,t,n){if(super.propertyChangedCallback(r,e,t,n),!n)switch(r){case"center":case"rx":case"ry":case"start":case"end":this.recomputeShape();break}}getPathData(){let r=this.rx,e=this.ry,t=this.center,n=this.start??0,i=this.end??0;return!nv.isNull(t)&&!nv.isNull(r)&&!nv.isNull(e)?Xn.getPathData(t,r,e,n,i):null}getShapeGeometry(){let r=this.center??{x:0,y:0},e=this.rx??0,t=this.ry??0;return b0(r,e,t,this.start,this.end)}static getPathData(r={x:NaN,y:NaN},e=NaN,t=NaN,n,i){let{pathData:s}=b0(r,e,t,n,i);return s}};l([Jo({emit:!1,converter:Zo.Point})],Xn.prototype,"center",2),l([Jo({emit:!1,converter:Zo.Number})],Xn.prototype,"rx",2),l([Jo({emit:!1,converter:Zo.Number})],Xn.prototype,"ry",2),l([Jo({emit:!1,converter:Zo.Number})],Xn.prototype,"start",2),l([Jo({emit:!1,converter:Zo.Number})],Xn.prototype,"end",2),Xn=l([IA({tagName:$A+"-"+"2d"+"-ellipse"})],Xn);var bs=class extends Rt{propertyChangedCallback(r,e,t,n){if(super.propertyChangedCallback(r,e,t,n),!n)switch(r){case"center":case"radius":case"start":case"end":this.recomputeShape();break}}getPathData(){let r=this.radius,e=this.center;return!nv.isNull(e)&&!nv.isNull(r)?bs.getPathData(e,r,this.start,this.end):null}getShapeGeometry(){let r=this.center??{x:0,y:0},e=this.radius??0;return b0(r,e,e,this.start,this.end)}static getPathData(r={x:NaN,y:NaN},e=NaN,t,n){return Xn.getPathData(r,e,e,t,n)}};l([Jo({emit:!1,converter:Zo.Point})],bs.prototype,"center",2),l([Jo({emit:!1,converter:Zo.Number})],bs.prototype,"radius",2),l([Jo({emit:!1,converter:Zo.Number})],bs.prototype,"start",2),l([Jo({emit:!1,converter:Zo.Number})],bs.prototype,"end",2),bs=l([IA({tagName:$A+"-"+"2d"+"-circle"})],bs);import{CustomElement as y3,Watch as Em,PropertyConverters as iv,P as _3,Utils as wm}from"@pacem/pacem-core";function sv(a){let r=a[2],e=a[4]??r,t=a[6]==="cut"?"cut":"rounded";return{rx:HA(r),ry:HA(e),type:t}}function HA(a){return{value:parseFloat(a),unit:a.endsWith("%")?"pct":"u"}}function Dc(a){return`${a.value}${a.unit==="pct"?"%":""}`}var x3=/(([\d\.]+%?)(\s*,?\s*([\d\.]+%?))?(\s+(cut|round))?)/g;function C3(a){let r,e=[];for(;r=x3.exec(a);)e.push(r);switch(e.length){case 1:let t=sv(e[0]);return[t,t,t,t];case 4:let n=sv(e[0]),i=sv(e[1]),s=sv(e[2]),o=sv(e[3]);return[n,i,s,o];default:return null}}function E3(a){let r=a[0],e=a[1],t=a[2],n=a[3],i=Dc(r.rx),s=Dc(r.ry),o=Dc(e.rx),c=Dc(e.ry),d=Dc(t.rx),p=Dc(t.ry),u=Dc(n.rx),h=Dc(n.ry);return`${i},${s} ${o},${c} ${d},${p} ${u},${h}`}var BA=(e=>(e.Rounded="rounded",e.Cut="cut",e))(BA||{}),qn=class extends Rt{propertyChangedCallback(r,e,t,n){super.propertyChangedCallback(r,e,t,n),!n&&(r==="x"||r==="y"||r==="w"||r==="h"||r==="r"||r==="cornerType")&&this.recomputeShape()}getPathData(){let r=this.x,e=this.y,t=this.w,n=this.h,i=this.r??{rx:{value:0},ry:{value:0},type:"rounded"};return wm.isArray(i)||(i=[i,i,i,i]),i=i.map(s=>typeof s=="number"?{rx:{value:s},ry:{value:s},type:this.cornerType}:s),!wm.isNull(r)&&!wm.isNull(e)&&!wm.isNull(t)&&!wm.isNull(n)?qn.getPathData(r,e,t,n,i):null}getShapeGeometry(){let r=this.x,e=this.y,t=r+this.w,n=e+this.h;return{pathData:this.getPathData(),vertices:[{x:r,y:e},{x:t,y:e},{x:t,y:n},{x:r,y:n}],boundingRect:{x:r,y:e,width:this.w,height:this.h}}}static getPathData(r=NaN,e=NaN,t=NaN,n=NaN,i=null){if(!i)return`M ${r} ${e} h ${t} v ${n} h ${-t} z`;wm.isArray(i)||(i=[i,i,i,i]);let s=i[0],o=i[1],c=i[2],d=i[3],p=k=>k.unit==="pct"?k.value*.01*t:k.value,u=k=>k.unit==="pct"?k.value*.01*n:k.value,h=p(s.rx),m=u(s.ry),f=p(o.rx),g=u(o.ry),v=p(c.rx),b=u(c.ry),_=p(d.rx),E=u(d.ry),C=`M ${r},${e+m}`;return s.type==="cut"?C+=` l ${h},${-m}`:C+=` a ${h} ${m} 0 0 1 ${h} ${-m}`,C+=` h ${t-h-f}`,o.type==="cut"?C+=` l ${f},${g}`:C+=` a ${f} ${g} 0 0 1 ${f} ${g}`,C+=` v ${n-g-b}`,c.type==="cut"?C+=` l ${-v},${b}`:C+=` a ${v} ${b} 0 0 1 ${-v} ${b}`,C+=` h ${-(t-v-_)}`,d.type==="cut"?C+=` l ${-_},${-E}`:C+=` a ${_} ${E} 0 0 1 ${-_} ${-E}`,C+" z"}};l([Em({emit:!1,converter:iv.Number})],qn.prototype,"x",2),l([Em({emit:!1,converter:iv.Number})],qn.prototype,"y",2),l([Em({emit:!1,converter:iv.Number})],qn.prototype,"w",2),l([Em({emit:!1,converter:iv.Number})],qn.prototype,"h",2),l([Em({emit:!1,converter:{convert:r=>C3(r),convertBack:r=>E3(r)}})],qn.prototype,"r",2),l([Em({emit:!1,converter:iv.String})],qn.prototype,"cornerType",2),qn=l([y3({tagName:_3+"-"+"2d"+"-rect"})],qn);import{CustomElement as w3,Watch as VA,PropertyConverters as UA,P as k3,Utils as F_}from"@pacem/pacem-core";var Qo=class extends Rt{propertyChangedCallback(r,e,t,n){if(super.propertyChangedCallback(r,e,t,n),!n)switch(r){case"from":case"to":this.recomputeShape();break}}getShapeGeometry(){let r=this.from,e=this.to;if(F_.isNull(r)||F_.isNull(e))return Da.empty();let t=r.x,n=r.y,i=e.x,s=e.y,o={x:Math.min(t,i),y:Math.min(n,s),width:Math.abs(t-i),height:Math.abs(n-s)};return{pathData:this.getPathData(),vertices:[r,e],boundingRect:o}}getPathData(){let r=this.from,e=this.to;return!F_.isNull(r)&&!F_.isNull(e)?Qo.getPathData(r,e):null}static getPathData(r={x:NaN,y:NaN},e={x:NaN,y:NaN}){let t=r.x,n=r.y,i=e.x,s=e.y;return`M ${t} ${n} L ${i} ${s}`}};l([VA({emit:!1,converter:UA.Point})],Qo.prototype,"from",2),l([VA({emit:!1,converter:UA.Point})],Qo.prototype,"to",2),Qo=l([w3({tagName:k3+"-"+"2d"+"-line"})],Qo);import{CustomElement as M3,Watch as S3,PropertyConverters as L3,P as N3}from"@pacem/pacem-core";var km=class extends Rt{constructor(){super(...arguments);this.getPathData=()=>this.d}propertyChangedCallback(e,t,n,i){super.propertyChangedCallback(e,t,n,i),e==="d"&&!i&&this.recomputeShape()}getShapeGeometry(){return{pathData:this.getPathData(),boundingRect:null,vertices:[]}}};l([S3({emit:!1,converter:L3.String})],km.prototype,"d",2),km=l([M3({tagName:N3+"-"+"2d"+"-path"})],km);import{CustomElement as T3,Watch as W_,PropertyConverters as j_,P as A3,Utils as zA}from"@pacem/pacem-core";var Kn=class extends Rt{propertyChangedCallback(r,e,t,n){if(super.propertyChangedCallback(r,e,t,n),!n)switch(r){case"radius":case"starIndent":case"sides":this.recomputeShape();break}}getPathData(){let r=this.sides,e=this.radius,t=this.center;return!zA.isNull(r)&&!zA.isNull(e)?Kn.getPathData(t,e,r,this.starIndent):null}getShapeGeometry(){let r=this.center??{x:0,y:0},e=this.radius??0,t=this.sides??3,n=this.starIndent;return t<3?Da.empty():Kn.getShapeGeometry(r,e,t,n)}static getShapeGeometry(r,e,t,n=0){let i={x:r.x,y:r.y-e},s=`M ${i.x} ${i.y}`,o=[i],c=2*Math.PI/t,d=.5*c,p=n>0,u=e*Math.cos(d);for(let m=1;m<t;m++){let f=m*c,g=r.x+Math.sin(f)*e,v=r.y-Math.cos(f)*e;if(p){let b=u*(1-n),_=f-d,E=r.x+Math.sin(_)*b,C=r.y-Math.cos(_)*b;s+=` L ${E} ${C} L ${g} ${v}`,o.push({x:E,y:C})}else s+=` L ${g} ${v}`;o.push({x:g,y:v})}if(p){let m=u*(1-n),f=2*Math.PI-d,g=r.x+Math.sin(f)*m,v=r.y-Math.cos(f)*m;s+=` L ${g} ${v}`,o.push({x:g,y:v})}o.push(i);let h=e*2;return{pathData:s+" Z",vertices:o,boundingRect:{x:i.x-e,y:i.y,width:h,height:h}}}static getPathData(r,e,t,n=0){let{pathData:i}=Kn.getShapeGeometry(r,e,t,n);return i}};l([W_({emit:!1,converter:j_.Number})],Kn.prototype,"sides",2),l([W_({emit:!1,converter:j_.Number})],Kn.prototype,"radius",2),l([W_({emit:!1,converter:j_.Point})],Kn.prototype,"center",2),l([W_({emit:!1,converter:j_.Number})],Kn.prototype,"starIndent",2),Kn=l([T3({tagName:A3+"-"+"2d"+"-polygon"})],Kn);import{CustomElement as D3,Watch as GA,PropertyConverters as R3,P as O3,Utils as P3}from"@pacem/pacem-core";import{parseAsNumericalArray as I3}from"@pacem/pacem-foundation";var $3={convert:a=>{let r=I3(a);if(r.length%2===0){let e=[];for(let t=0;t<r.length;t+=2)e.push({x:r[t],y:r[t+1]});return e}return JSON.parse(a)},convertBack:a=>JSON.stringify(a)},ya=class extends Rt{propertyChangedCallback(r,e,t,n){if(super.propertyChangedCallback(r,e,t,n),!n)switch(r){case"points":case"closed":this.recomputeShape();break}}static getShapeGeometry(r,e){if(P3.isNullOrEmpty(r))return Da.empty();let t="",n=Number.MAX_VALUE,i=Number.MAX_VALUE,s=Number.MIN_VALUE,o=Number.MIN_VALUE;for(let d=0;d<r.length;d++){let{x:p,y:u}=r[d];t+=`${d===0?"M":"L"} ${p} ${u} `,n=Math.min(n,p),s=Math.max(s,p),i=Math.min(i,u),o=Math.max(o,u)}let c={x:n,y:i,width:s-n,height:o-i};return e&&(t+="Z"),{pathData:t,vertices:r,boundingRect:c}}getShapeGeometry(){return ya.getShapeGeometry(this.points,this.closed)}getPathData(){let{pathData:r}=this.getShapeGeometry();return r}static getPathData(r,e){let{pathData:t}=ya.getShapeGeometry(r,e);return t}};l([GA({emit:!1,converter:$3})],ya.prototype,"points",2),l([GA({emit:!1,converter:R3.Boolean})],ya.prototype,"closed",2),ya=l([D3({tagName:O3+"-"+"2d"+"-polyline"})],ya);import{CustomElement as H3,Watch as av,PropertyConverters as ov,P as B3}from"@pacem/pacem-core";var wn=class extends vr{propertyChangedCallback(r,e,t,n){if(super.propertyChangedCallback(r,e,t,n),!n)switch(r){case"src":case"x":case"y":case"width":case"height":this.stage?.draw(this);break}}};l([av({emit:!1,converter:ov.String})],wn.prototype,"src",2),l([av({emit:!1,converter:ov.Number})],wn.prototype,"x",2),l([av({emit:!1,converter:ov.Number})],wn.prototype,"y",2),l([av({emit:!1,converter:ov.Number})],wn.prototype,"width",2),l([av({emit:!1,converter:ov.Number})],wn.prototype,"height",2),wn=l([H3({tagName:B3+"-"+"2d"+"-image"})],wn);import{CustomElement as V3,Watch as Rc,PropertyConverters as Oc,P as U3,Utils as z3}from"@pacem/pacem-core";var Tr=class extends vr{propertyChangedCallback(r,e,t,n){if(!n)switch(r){case"text":case"color":case"fontFamily":case"fontSize":case"fontWeight":case"fontStyle":case"anchor":z3.isNull(this.stage)||this.stage.draw(this);break}}};l([Rc({emit:!1,converter:Oc.String})],Tr.prototype,"text",2),l([Rc({emit:!1,converter:Oc.String})],Tr.prototype,"color",2),l([Rc({emit:!1,converter:Oc.String})],Tr.prototype,"fontFamily",2),l([Rc({emit:!1,converter:Oc.Number})],Tr.prototype,"fontSize",2),l([Rc({emit:!1,converter:Oc.String})],Tr.prototype,"fontWeight",2),l([Rc({emit:!1,converter:Oc.String})],Tr.prototype,"fontStyle",2),l([Rc({emit:!1,converter:Oc.Point})],Tr.prototype,"anchor",2),l([Rc({emit:!1,converter:Oc.String})],Tr.prototype,"textAnchor",2),Tr=l([V3({tagName:U3+"-"+"2d"+"-text"})],Tr);import{Utils as FA,UI as Y_}from"@pacem/pacem-core";import{Rect as G3}from"@pacem/pacem-foundation";var At=class{static stageDispatch(r,e,t){r instanceof EventTarget&&r.dispatchEvent(new sf("stage"+e,r,t,r.transformMatrix))}static isValidViewbox(r){return!FA.isNullOrEmpty(r)&&G3.isRect(r)&&Number.isFinite(r.x)&&Number.isFinite(r.y)&&Number.isFinite(r.width)&&Number.isFinite(r.height)}static itemDispatch(r,e,t){if(FA.isNull(r?.stage))return!1;var n,i,s;t instanceof Event?i=t:n={item:r,offset:t},typeof e=="string"?s=e:(s=e.type,i=e.originalEvent);let o=r.stage.transformMatrix,c=()=>t instanceof Event?new Ui(s,r,i,o):new au(s,{detail:n,cancelable:s===Y_.DragDropEventType.Init||s===Y_.DragDropEventType.Drag},i,o),d=t instanceof Event?new Ui("item"+s,r,i,o):new au("item"+s,{detail:n,cancelable:s===Y_.DragDropEventType.Init||s===Y_.DragDropEventType.Drag},i,o);var p=!1;if(r instanceof EventTarget){let u=c();r.dispatchEvent(u),p=u.defaultPrevented}return r.stage.dispatchEvent(d),p||d.defaultPrevented}};import{CustomElement as j3,P as jA,CustomElementUtils as _0,Utils as Ce,Logging as Y3,CustomEventUtils as y0,UI as el,avoidHandler as X3}from"@pacem/pacem-core";import{Matrix2D as tl,Rect as q3}from"@pacem/pacem-foundation";import{PacemEventTarget as F3,Utils as WA}from"@pacem/pacem-core";var W3=.9,Mm=class extends F3{constructor(){super(...arguments);this.DefaultShapeValues={stroke:"#000",lineWidth:1,fill:"#fff"}}snapshotElement(e,t,n,i){let s=!WA.isNullOrEmpty(t),o=n??(s?"image/jpeg":null),c=i??(s?W3:null);return WA.snapshotElement(e,t,o,c)}};var X_="pacem:2d-canvas-scene",YA="pacem:2d-parent-matrix",K3="pacem:2d-world-matrix",q_=_0.setAttachedPropertyValue,lv=_0.getAttachedPropertyValue;function Np(a){return a==="none"||Ce.isNullOrEmpty(a)}function cv(a,r){return Ce.isNull(a)?r:a}var Tp,Pc,dv=class extends Mm{constructor(){super(...arguments);$(this,Tp);$(this,Pc);this._pointer={page:{x:Number.NaN,y:Number.NaN},screen:{x:Number.NaN,y:Number.NaN},client:{x:Number.NaN,y:Number.NaN}};this._dragInitHandler=e=>{let t=this._hitTarget;if(Ce.isNull(t)||!Sn(t)||!t.draggable){e.preventDefault();return}let n=e.detail,i=t,s=t.transformMatrix??tl.identity,o=lv(t,YA,tl.identity);n.data={item:i,initialTransformMatrix:s,parentMatrix:o},At.itemDispatch(i,e,{x:0,y:0})&&e.preventDefault()};this._draggingHandler=e=>{X3(e),this._dragging=!0;let t=e.detail,n=t.data,i={x:t.currentPosition.x-t.origin.x,y:t.currentPosition.y-t.origin.y},s={x:i.x*n.parentMatrix.a+n.initialTransformMatrix.e,y:i.y*n.parentMatrix.d+n.initialTransformMatrix.f},o=n.item.stage.transformMatrix;if(!At.itemDispatch(n.item,e,{x:i.x*o.a+o.e,y:i.y*o.d+o.f}))if(n.item instanceof vr)n.item.translateX=s.x,n.item.translateY=s.y;else{let d=n.initialTransformMatrix,p={a:d.a,b:d.b,c:d.c,d:d.d,e:s.x,f:s.y};Ce.extend(n.item,{transformMatrix:p})}};this._dragEndHandler=e=>{this._dragging=!1;let t=e.detail,n=t.data,i=n.item.transformMatrix;At.itemDispatch(n.item,e,{x:i.e,y:i.f})};this._mouseleaveHandler=e=>{if(this._dragging)return;let t=this._hitTarget;if(Ce.isNull(t))return;this._scopeEvent=e;let n={x:Number.NaN,y:Number.NaN};this._pointer={page:n,screen:n,client:n};let i=e.srcElement,s=lv(i,X_);this._requestDraw(s)};this._mousemoveHandler=e=>{this._scopeEvent=e,this._pointer=y0.getEventCoordinates(e);let t=e.srcElement,n=lv(t,X_);this._requestDraw(n),this._dragging||Ce.isNull(this._hitTarget)||At.stageDispatch(n,"move",e)};this._mouseDownUpHandler=e=>{this._scopeEvent=e,this._pointer=y0.getEventCoordinates(e);let t=e.target;if(t instanceof HTMLCanvasElement){let n=lv(t,X_),i=this._hitTarget,s=e.type.replace(/^(mouse|touch)/,""),o=s==="end"?"click":s,c=Cm(n);y0.matchModifiers(e,c.clickModifiers)&&(!Ce.isNull(i)&&i.stage===n?At.itemDispatch(i,o,e):At.stageDispatch(n,o,e))}};this._scenes=new WeakMap;this._handles=new WeakMap}snapshot(e,t,n,i){let s=this._scenes;if(s.has(e)){let o=s.get(e).context,c=o.canvas;return this.snapshotElement(c,t,n,i)}else return Promise.resolve(null)}getCanvas(e){let t=this._scenes;return t.has(e)?t.get(e).context.canvas:null}_getScreenInverseMatrix(e,t){return tl.invert({a:e.a,b:e.b,c:e.c,d:e.d,e:e.e+t.x,f:e.f+t.y})}getTransformMatrix(e){let t=this._scenes;return t.has(e)?t.get(e).screenInverseMatrix:tl.identity}viewActivatedCallback(){super.viewActivatedCallback();let e=A(this,Tp,document.createElement(jA+"-drag-drop"));e.mode=el.DragDataMode.Copy,e.dropBehavior=el.DropBehavior.None,e.spillBehavior=el.DropTargetMissedBehavior.None;let t=document.createElement("div");t.hidden=!0,e.floater=t,_0.findAncestorShell(this).appendChild(e),e.addEventListener(el.DragDropEventType.Init,this._dragInitHandler,!1),e.addEventListener(el.DragDropEventType.Drag,this._draggingHandler,!1),e.addEventListener(el.DragDropEventType.End,this._dragEndHandler,!1)}disconnectedCallback(){let e=x(this,Tp);Ce.isNull(e)||(e.removeEventListener(el.DragDropEventType.Init,this._dragInitHandler,!1),e.removeEventListener(el.DragDropEventType.Drag,this._draggingHandler,!1),e.removeEventListener(el.DragDropEventType.End,this._dragEndHandler,!1),e.remove()),super.disconnectedCallback()}invalidateSize(e,t){let n=this._scenes;if(!Ce.isNull(e)&&!Ce.isNullOrEmpty(t)&&n.has(e)){let i=n.get(e),s=i.context;s.canvas.width=t.width,s.canvas.height=t.height;let o=i.offset=Ce.offsetRect(s.canvas),c={x:0,y:0,width:t.width,height:t.height},d=e.aspectRatio,p=e.viewbox;if(At.isValidViewbox(p)){let u="contain",h="center",m="middle";if(typeof d=="object"){switch(u=d.slice?"cover":"contain",d.x){case"min":h="left";break;case"max":h="right";break}switch(d.y){case"min":m="top";break;case"max":m="bottom";break}}let f=q3.findTransform({x:0,y:0,width:p.width,height:p.height},c,u,h,m),g=tl.translate(f,{x:-f.a*p.x,y:-f.a*p.y});i.transformMatrix=g,i.screenInverseMatrix=this._getScreenInverseMatrix(g,o)}else i.transformMatrix=tl.identity}this._requestDraw(e)}getHitTarget(e){let t=this._hitTarget;return!Ce.isNull(t)&&t.stage===e?t:null}initialize(e){if(Ce.isNull(e))throw"Provided scene is null or undefined.";let t=this._scenes,n=x(this,Tp);if(t.has(e)){let c=t.get(e).context.canvas;return Ce.isNull(n)||n.register(c),c}let i=e.stage;i.innerHTML="";let s=document.createElement("canvas");s.setAttribute("part","stage"),q_(s,X_,e);let o=s.getContext("2d");return s.addEventListener("mousemove",this._mousemoveHandler,!1),s.addEventListener("mouseleave",this._mouseleaveHandler,!1),s.addEventListener("touchstart",this._mouseDownUpHandler,{passive:!0}),s.addEventListener("touchmove",this._mouseDownUpHandler,{passive:!0}),s.addEventListener("touchend",this._mouseDownUpHandler,{passive:!0}),s.addEventListener("click",this._mouseDownUpHandler,!1),s.addEventListener("mousedown",this._mouseDownUpHandler,!1),s.addEventListener("mouseup",this._mouseDownUpHandler,!1),i.appendChild(s),t.set(e,{context:o,transformMatrix:tl.identity,offset:Ce.offsetRect(s),screenInverseMatrix:tl.identity}),Ce.isNull(n)||n.register(s),s}dispose(e){let t=this._scenes;if(t.has(e)){var n=t.get(e),i=n.context,s=i.canvas;let o=x(this,Tp);Ce.isNull(o)||o.unregister(s),s.removeEventListener("click",this._mouseDownUpHandler,!1),s.removeEventListener("touchend",this._mouseDownUpHandler,!1),s.removeEventListener("mousedown",this._mouseDownUpHandler,!1),s.removeEventListener("mouseup",this._mouseDownUpHandler,!1),s.removeEventListener("touchstart",this._mouseDownUpHandler),s.removeEventListener("mouseleave",this._mouseleaveHandler,!1),s.removeEventListener("mousemove",this._mousemoveHandler,!1),s.remove(),t.delete(e)}}_requestDraw(e){let t=this._handles;t.has(e)&&cancelAnimationFrame(t.get(e));let n=()=>(this.draw(e),requestAnimationFrame(()=>{}));t.set(e,n())}draw(e){let t=this._scenes,n=this._handles;if(!Ce.isNull(e)){if(e.adapter!==this){t.has(e)&&(t.delete(e),n.get(e));return}if(!t.has(e)){this.initialize(e);return}n.has(e)&&cancelAnimationFrame(n.get(e));let i=this._hitTarget,s=e.datasource||[];this._hitTarget=null;let o=t.get(e),c=o.context,d=c.canvas;A(this,Pc,getComputedStyle(d)),c.resetTransform(),c.clearRect(0,0,d.width,d.height);let p=o.transformMatrix;c.setTransform(p);let u=this._pointer,h=o.offset,m=Number.isNaN(u.page.x)||Number.isNaN(u.page.y)?null:{x:u.page.x-h.x,y:u.page.y-h.y};for(let g of s)this._draw(e,c,g,{transformMatrix:p},m);let f=this._hitTarget;f!=i&&(Ce.isNull(i)||(i instanceof Element&&i.dispatchEvent(new Ui("out",i,this._scopeEvent,p)),e.dispatchEvent(new Ui("itemout",i,this._scopeEvent,p))),Ce.isNull(f)||(f instanceof Element&&f.dispatchEvent(new Ui("over",f,this._scopeEvent,p)),e.dispatchEvent(new Ui("itemover",f,this._scopeEvent,p))))}}_draw(e,t,n,i,s){if(n.stage??=e,ou(n)&&n.hide)return;Sn(n)&&n.draggable&&!n.hide&&!n.inert&&q_(n,YA,t.getTransform().inverse());let o;Sn(n)&&(o=n.transformMatrix,!Ce.isNull(o)&&!tl.isIdentity(o)&&t.transform(o.a,o.b,o.c,o.d,o.e,o.f));let c=i;if(of(n)&&(c=nf.combine(n,i,t.getTransform()),this._setPresentationState(t,c)),cu(n)||n instanceof Rt)this._drawShape(t,n,s);else if(du(n)||n instanceof Tr)this._drawText(t,n,s);else if(pu(n)||n instanceof wn)this._drawImage(t,n,s);else if(sd(n)||n instanceof Ac)for(let d of n.childDrawables||[])this._draw(e,t,d,c,s);Sn(n)&&n.draggable&&!n.hide&&!n.inert&&q_(n,K3,t.getTransform().inverse()),this._setPresentationState(t,i)}_setPresentationState(e,t){if(e.setTransform(t.transformMatrix),!Ce.isNullOrEmpty(t.stroke)&&!Np(t.stroke)?e.strokeStyle=t.stroke:e.strokeStyle="transparent",Ce.isNullOrEmpty(t.lineWidth)?e.lineWidth=0:e.lineWidth=t.lineWidth,Ce.isNullOrEmpty(t.dashArray)?e.setLineDash([]):e.setLineDash(t.dashArray),Ce.isNullOrEmpty(t.lineCap)?e.lineCap="butt":e.lineCap=t.lineCap,Ce.isNullOrEmpty(t.lineJoin)?e.lineJoin="miter":e.lineJoin=t.lineJoin,typeof t.fill=="object"&&!Ce.isNullOrEmpty(t.fill)){let{stops:n}=t.fill,i;if(af(t.fill)){let{start:s,end:o}=t.fill;i=e.createLinearGradient(s.x,s.y,o.x,o.y)}else if(lu(t.fill)){let{center:s,radius:o}=t.fill;i=e.createRadialGradient(s.x,s.y,o,s.x,s.y,o)}else throw new Error("Unmanaged gradient type.");for(let s of n)i.addColorStop(s.offset,s.color);e.fillStyle=i}else!Ce.isNullOrEmpty(t.fill)&&typeof t.fill=="string"&&!Np(t.fill)?e.fillStyle=t.fill:e.fillStyle="transparent";Ce.isNullOrEmpty(t.opacity)?e.globalAlpha=1:e.globalAlpha=t.opacity}_drawImage(e,t,n){let i="pacem:2d-canvas-imagesrc",s=lv(t,i),o=()=>{let c=s.naturalWidth,d=s.naturalHeight,p=t.width,u=t.height;if(p>0&&u>0||(p>0?u=d*p/c:u>0?p=c*u/d:(p=c,u=d)),!this._dragging&&!t.inert&&!Ce.isNull(n)){let h=new Path2D(`M ${t.x} ${t.y} h ${p} v ${u} H ${t.x} Z`);e.isPointInPath(h,n.x,n.y)&&(this._hitTarget=t)}e.globalAlpha=cv(t.opacity,1),e.drawImage(s,t.x,t.y,p,u)};Ce.isNull(s)?(s=new Image,s.src=t.src,s.onload=()=>{q_(t,i,s),o()}):o()}_drawText(e,t,n){let i=this.DefaultShapeValues,s=e.fillStyle=cv(t.color,i.stroke),o=e.getTransform(),c=t.fontSize>0?`${t.fontSize}px`:x(this,Pc).fontSize,d=t.fontStyle||x(this,Pc).fontStyle,p=t.fontWeight||x(this,Pc).fontWeight;e.font=`${d} ${p} ${c} ${t.fontFamily??x(this,Pc).fontFamily}`,e.textAlign=t.textAnchor==="middle"?"center":t.textAnchor,e.fillText(t.text,t.anchor.x,t.anchor.y),e.globalAlpha=cv(t.opacity,1);let u=!Np(s);if(!this._dragging&&!t.inert&&!Ce.isNull(n)){let h=e.measureText(t.text),m=h.width,f=h.actualBoundingBoxAscent+h.actualBoundingBoxDescent,g=t.anchor.x-h.actualBoundingBoxLeft,v=t.anchor.y-h.actualBoundingBoxAscent,b=new Path2D(`M ${g} ${v} h ${m} v ${f} H ${g} z`);u&&e.isPointInPath(b,n.x,n.y)&&(this._hitTarget=t)}}_drawShape(e,t,n){if(Ce.isNullOrEmpty(t?.pathData))return;e.beginPath();let i=typeof e.fillStyle!="string"||!Np(e.fillStyle),s=typeof e.strokeStyle!="string"||!Np(e.strokeStyle);var o=new Path2D(t.pathData);!this._dragging&&!t.inert&&!Ce.isNull(n)&&(i&&e.isPointInPath(o,n.x,n.y)||s&&e.isPointInStroke(o,n.x,n.y))&&(this._hitTarget=t),s&&e.stroke(o),i&&e.fill(o);let c=!Ce.isNullOrEmpty(t.vertices)&&t.vertices.length>1,d=!Ce.isNull(t.markerEnd),p=!Ce.isNull(t.markerStart),u=!Ce.isNull(t.markerMid);if((d||u||p)&&(c||this.log(Y3.LogLevel.Warn,"Not enough vertices were explicited in order to make markers renderable.")),c){let h=e.getTransform();if(p){let m=t.markerEnd,f=t.vertices[1],g=t.vertices[0],v=Math.atan2(g.y-f.y,g.x-f.x);this._drawMarker(e,m,g,v)}if(u){let m=t.markerEnd;for(let f=1;f<t.vertices.length-1;f++){e.setTransform(h);let g=t.vertices[f],v=t.vertices[f+1],b=Math.atan2(v.y-g.y,v.x-g.x);this._drawMarker(e,m,v,b)}}if(d){e.setTransform(h);let m=t.markerEnd,f=t.vertices[t.vertices.length-2],g=t.vertices[t.vertices.length-1],v=Math.atan2(g.y-f.y,g.x-f.x);this._drawMarker(e,m,g,v)}}}_drawMarker(e,t,n,i){let s=this.DefaultShapeValues,o=t.ref?.x||0,c=t.ref?.y||0,d=(t.width||1)*e.lineWidth,p=(t.width||1)*e.lineWidth,u=t.viewbox,h={x:0,y:0,width:d,height:p};Ce.isNull(u)&&(u=h);let m={a:h.width/u.width,d:h.height/u.height};e.translate(n.x,n.y),e.rotate(i),e.scale(m.a,m.d),e.translate(-o,-c),e.fillStyle=cv(t.fill,s.fill),e.strokeStyle=cv(t.stroke,s.stroke);let f=!Np(t.fill),g=!Np(t.stroke);var v=new Path2D(t.pathData);f&&e.fill(v),g&&e.stroke(v)}};Tp=new WeakMap,Pc=new WeakMap,dv=l([j3({tagName:jA+"-"+"2d"+"-canvas-adapter"})],dv);import{CustomElement as J3,P as XA,CustomElementUtils as J_,CustomEventUtils as qA,Utils as le,UI as Ap,avoidHandler as Z3}from"@pacem/pacem-core";import{Matrix2D as x0}from"@pacem/pacem-foundation";var _a="http://www.w3.org/2000/svg",pv="pacem:2-svg-drawable",K_="pacem:2d-svg-stage",uv=J_.getAttachedPropertyValue,KA=J_.setAttachedPropertyValue,JA=J_.deleteAttachedPropertyValue;function C0(a,r){return le.isNull(a)?r:a}function ZA(a,r,e){return e>=a.children.length?(a.appendChild(r),null):a.replaceChild(r,a.children.item(e))}var Ic,Dp,hv=class extends Mm{constructor(){super(...arguments);$(this,Ic);this._hitTarget=null;$(this,Dp);this._dragInitHandler=e=>{let t=e.detail,n=t.element,i=uv(n,pv),s=i.stage.transformMatrix,o=i.transformMatrix??x0.identity;t.data={stageTransformMatrix:s,item:i,initialTransformMatrix:o},At.itemDispatch(i,e,{x:0,y:0})&&e.preventDefault()};this._draggingHandler=e=>{Z3(e),A(this,Dp,!0);let t=e.detail.element,n=e.detail.data,i=e.detail,s={x:(i.currentPosition.x-i.origin.x)*n.stageTransformMatrix.a,y:(i.currentPosition.y-i.origin.y)*n.stageTransformMatrix.d},o={x:s.x+n.initialTransformMatrix.e,y:s.y+n.initialTransformMatrix.f},c={x:s.x+n.stageTransformMatrix.e,y:s.y+n.stageTransformMatrix.f};if(!At.itemDispatch(n.item,e,c)){let p=n.initialTransformMatrix;t.style.transform=`matrix(${p.a},${p.b},${p.c},${p.d},${o.x},${o.y})`}};this._dragEndHandler=e=>{A(this,Dp,!1);let t=e.detail,n=t.element,i=t.data,s=le.deserializeTransform(n.style),o={x:s.e,y:s.f};if(i.item instanceof vr)i.item.translateX=o.x,i.item.translateY=o.y;else{let c=i.initialTransformMatrix,d={a:c.a,b:c.b,c:c.c,d:c.d,e:o.x,f:o.y};le.extend(i.item,{transformMatrix:d})}n.style.transform="",At.itemDispatch(i.item,e,o)};this._mouseleaveHandler=e=>{if(x(this,Dp))return;let t=this._hitTarget;le.isNull(t)||(this._hitTarget=null,le.isNull(t)||(x(this,Ic).unregister(this._items.get(t)),At.itemDispatch(t,"out",e)))};this._mousemoveHandler=e=>{var t=qA.getEventCoordinates(e).client;if(!x(this,Dp)){var n=null;e.target.getRootNode().elementsFromPoint(t.x,t.y).find(d=>(n=uv(d,pv),n&&!n.inert));var i=this._hitTarget,s=n;(le.isNull(n&&n.stage)||!this._scenes.has(n.stage)||n.inert)&&(s=null);let c=this._hitTarget=s;if(s!==i&&(le.isNull(i)||(x(this,Ic).unregister(this._items.get(i)),At.itemDispatch(i,"out",e)),le.isNull(s)||(s.draggable&&x(this,Ic).register(this._items.get(s)),At.itemDispatch(s,"over",e))),le.isNull(c)){let d=e.currentTarget,p=uv(d,K_);le.isNull(p)||At.stageDispatch(p,"move",e)}}};this._mouseDownUpHandler=e=>{let t=e.currentTarget;if(t instanceof SVGSVGElement){let n=uv(t,K_),i=this._hitTarget,s=e.type.replace(/^mouse/,""),o=Cm(n);qA.matchModifiers(e,o.clickModifiers)&&(!le.isNull(i)&&i.stage===n?At.itemDispatch(i,s,e):At.stageDispatch(n,s,e))}};this._scenes=new WeakMap;this._markers=new WeakMap;this._gradients=new WeakMap;this._items=new WeakMap}snapshot(e,t,n,i){if(this._scenes.has(e)){let s=this._scenes.get(e);return this.snapshotElement(s,t,n,i)}else return Promise.resolve(null)}getTransformMatrix(e){let t=this._scenes;return t.has(e)?t.get(e).getScreenCTM().inverse():x0.identity}viewActivatedCallback(){super.viewActivatedCallback();let e=A(this,Ic,document.createElement(XA+"-drag-drop"));e.mode=Ap.DragDataMode.Self,J_.findAncestorShell(this).appendChild(e),e.addEventListener(Ap.DragDropEventType.Init,this._dragInitHandler,!1),e.addEventListener(Ap.DragDropEventType.Drag,this._draggingHandler,!1),e.addEventListener(Ap.DragDropEventType.End,this._dragEndHandler,!1)}disconnectedCallback(){let e=x(this,Ic);le.isNull(e)||(e.removeEventListener(Ap.DragDropEventType.Init,this._dragInitHandler,!1),e.removeEventListener(Ap.DragDropEventType.Drag,this._draggingHandler,!1),e.removeEventListener(Ap.DragDropEventType.End,this._dragEndHandler,!1),e.remove()),super.disconnectedCallback()}invalidateSize(e,t){let n=this._scenes;if(!le.isNull(e)&&!le.isNullOrEmpty(t)&&n.has(e)){var i=n.get(e);i.setAttribute("width",t.width+""),i.setAttribute("height",t.height+"");let s=e.viewbox,o=e.aspectRatio;At.isValidViewbox(s)?i.setAttribute("viewBox",`${s.x} ${s.y} ${s.width} ${s.height}`):i.removeAttribute("viewBox"),le.isNullOrEmpty(o)||typeof o=="string"?i.removeAttribute("preserveAspectRatio"):i.setAttribute("preserveAspectRatio",`xM${o.x.substring(1)}YM${o.y.substring(1)} ${o.slice?"slice":"meet"}`)}}initialize(e){if(le.isNull(e))throw"Provided scene is null or undefined.";let t=this._scenes;if(t.has(e))return t.get(e);let n=e.stage;n.innerHTML="",this._items=new WeakMap;var i=document.createElementNS(_a,"svg");i.setAttribute("part","stage"),KA(i,K_,e),n.appendChild(i),t.set(e,i);let s={passive:!1,capture:!0};return i.addEventListener("mousemove",this._mousemoveHandler,!1),i.addEventListener("click",this._mouseDownUpHandler,!1),i.addEventListener("mousedown",this._mouseDownUpHandler,!1),i.addEventListener("mouseup",this._mouseDownUpHandler,!1),i.addEventListener("mouseleave",this._mouseleaveHandler,!1),i}dispose(e){let t=this._scenes;if(t.has(e)){var n=t.get(e);n.removeEventListener("mousemove",this._mousemoveHandler),n.removeEventListener("click",this._mouseDownUpHandler),n.removeEventListener("mousedown",this._mouseDownUpHandler),n.removeEventListener("mouseup",this._mouseDownUpHandler),n.removeEventListener("mouseleave",this._mouseleaveHandler),JA(n,K_),n.remove(),t.delete(e)}}getHitTarget(e){return this._hitTarget}draw(e,t,n=!1){let i=this._scenes,s=this._items;if(!le.isNull(e)){if(e.adapter===this)i.has(e)||this.initialize(e);else{i.has(e)&&i.delete(e);return}var o=e.datasource,c=!0,d=i.get(e);!le.isNull(t)&&s.has(t)&&(o=[t],d=s.get(t).parentNode,c=!1),c&&(d.innerHTML="<defs></defs>",this._markers=new WeakMap),this._draw(e,d,o||[],c,n)}}_hasItems(e){return sd(e)}_disposeSvg(e){if(!le.isNull(e)){var t=uv(e,pv);JA(e,pv),this._items.delete(t)}}_draw(e,t,n,i,s){let o=this._items,c=0;if(t.firstElementChild instanceof SVGDefsElement&&c++,!le.isNullOrEmpty(n))for(let d of n){d.stage??=e;let p;if(o.has(d)?(p=o.get(d),p.parentNode!==t&&this._disposeSvg(ZA(t,p,c))):(p=this._buildSVGElement(d),KA(p,pv,d),this._disposeSvg(ZA(t,p,c)),o.set(d,p)),ou(d)&&(d.hide?p.setAttribute("display","none"):p.removeAttribute("display"),p.style.transform=""),cu(d)){let u=p;u.setAttribute("d",C0(d.pathData,"M0,0"));for(let{marker:h,suffix:m}of[{marker:d.markerStart,suffix:"start"},{marker:d.markerEnd,suffix:"end"},{marker:d.markerMid,suffix:"mid"}])if(h){let f=this._ensureMarker(t,h);u.setAttribute("marker-"+m,`url(#${f.id})`)}else u.removeAttribute("marker-"+m)}else if(du(d)){let u=p;u.textContent=d.text,u.style.fill=le.isNullOrEmpty(d.color)?"":d.color,u.style.fontFamily=le.isNullOrEmpty(d.fontFamily)?"":d.fontFamily,u.style.fontSize=le.isNull(d.fontSize)?"":d.fontSize+"px",le.isNullOrEmpty(d.fontWeight)||(u.style.fontWeight=d.fontWeight),le.isNullOrEmpty(d.fontStyle)||(u.style.fontStyle=d.fontStyle),u.setAttribute("text-anchor",C0(d.textAnchor,"start")),le.isNull(d.anchor)?(u.removeAttribute("x"),u.removeAttribute("y")):(u.setAttribute("x",d.anchor.x.toString()),u.setAttribute("y",d.anchor.y.toString()))}else if(pu(d)){let u=p;u.setAttribute("href",d.src),u.setAttribute("preserveAspectRatio","none"),d.width>0?u.setAttribute("width",""+d.width):u.removeAttribute("width"),d.height>0?u.setAttribute("height",""+d.height):u.removeAttribute("height"),le.isNull(d.x)?u.removeAttribute("x"):u.setAttribute("x",""+d.x),le.isNull(d.y)?u.removeAttribute("y"):u.setAttribute("y",""+d.y)}if(Sn(d)){let u=d.transformMatrix;le.isNull(u)||x0.isIdentity(u)?p.removeAttribute("transform"):p.setAttribute("transform",`matrix(${u.a} ${u.b} ${u.c} ${u.d} ${u.e} ${u.f})`);let h=C0(d.opacity,1);h===1?p.removeAttribute("opacity"):p.setAttribute("opacity",""+h)}if(of(d)){if(le.isNullOrEmpty(d.fill))p.removeAttribute("fill");else if(typeof d.fill=="string")p.setAttribute("fill",d.fill);else{let u=this._ensureGradient(t,d.fill);p.setAttribute("fill",`url(#${u.id})`)}le.isNullOrEmpty(d.stroke)?p.removeAttribute("stroke"):p.setAttribute("stroke",d.stroke),le.isNullOrEmpty(d.dashArray)?p.removeAttribute("stroke-dasharray"):p.setAttribute("stroke-dasharray",d.dashArray.join(" ")),le.isNullOrEmpty(d.lineCap)?p.removeAttribute("stroke-linecap"):p.setAttribute("stroke-linecap",d.lineCap),le.isNullOrEmpty(d.lineJoin)?p.removeAttribute("stroke-linejoin"):p.setAttribute("stroke-linejoin",d.lineJoin),le.isNullOrEmpty(d.lineWidth)?p.removeAttribute("stroke-width"):p.setAttribute("stroke-width",""+d.lineWidth)}d.inert?p.style.pointerEvents="none":p.style.pointerEvents="",(i||s)&&this._hasItems(d)&&this._draw(e,p,d.childDrawables,!0,s),c++}if(i)for(let d=t.children.length-1;d>=c;d--){let p=t.children.item(d);this._disposeSvg(p),p.remove()}}_buildSVGElement(e){return cu(e)||e instanceof Rt?document.createElementNS(_a,"path"):du(e)||e instanceof Tr?document.createElementNS(_a,"text"):pu(e)||e instanceof wn?document.createElementNS(_a,"image"):document.createElementNS(_a,"g")}_ensureGradient(e,t){let n=this._gradients;n.has(e)||n.set(e,new WeakMap);let i=n.get(e),s=af(t),o=lu(t);if(i.has(t)){let u=i.get(t);(s&&u instanceof SVGLinearGradientElement||o&&u instanceof SVGRadialGradientElement)&&(u.remove(),i.delete(t))}if(!i.has(t)){let u=e,h;for(;le.isNull(h=u.querySelector(":scope > defs"));){let m=u.parentElement;if(m instanceof SVGElement)u=m;else break}if(le.isNull(h))throw new Error("Must provide a <defs> element.");var c=null;if(s)c=document.createElementNS(_a,"linearGradient");else if(lu(t))c=document.createElementNS(_a,"radialGradient");else throw new Error("Unmanaged gradient type.");c.setAttribute("gradientUnits","userSpaceOnUse"),c.setAttribute("id",`grad-${le.uniqueCode()}`),h.appendChild(c),i.set(t,c)}let d=i.get(t);s?(d.setAttribute("x1",t.start.x.toString()),d.setAttribute("y1",t.start.y.toString()),d.setAttribute("x2",t.end.x.toString()),d.setAttribute("y2",t.end.y.toString())):o&&(d.setAttribute("cx",t.center.x.toString()),d.setAttribute("cy",t.center.y.toString()),d.setAttribute("r",t.radius.toString()));let p=0;for(let u of t.stops){for(;d.children.length<=p;){let m=document.createElementNS(_a,"stop");d.appendChild(m)}let h=d.children.item(p);h.setAttribute("offset",u.offset*100+"%"),h.setAttribute("stop-color",u.color),le.isNull(u.opacity)||h.setAttribute("stop-opacity",u.opacity.toString()),p++}for(;d.children.length>t.stops.length;){let u=d.children.item(d.children.length-1);d.removeChild(u)}return d}_ensureMarker(e,t){let n=this._markers;n.has(e)||n.set(e,new WeakMap);let i=n.get(e);if(!i.has(t)){let c=document.createElementNS(_a,"marker");i.set(t,c);let d=document.createElementNS(_a,"path");c.appendChild(d),c.setAttribute("id","mark"+le.uniqueCode());let p=e,u;for(;le.isNull(u=p.querySelector(":scope > defs"));){let h=p.parentElement;if(h instanceof SVGElement)p=h;else break}if(le.isNull(u))throw new Error("Must provide a <defs> element.");u.appendChild(c)}let s=i.get(t),o=s.firstElementChild;return s.setAttribute("orient","auto-start-reverse"),le.isNullOrEmpty(t.viewbox)?s.removeAttribute("viewBox"):s.setAttribute("viewBox",`${t.viewbox.x} ${t.viewbox.y} ${t.viewbox.width} ${t.viewbox.height}`),le.isNullOrEmpty(t.ref)?(s.removeAttribute("refX"),s.removeAttribute("refY")):(s.setAttribute("refX",t.ref.x.toString()),s.setAttribute("refY",t.ref.y.toString())),t.height>0?s.setAttribute("markerHeight",t.height.toString()):s.removeAttribute("markerHeight"),t.width>0?s.setAttribute("markerWidth",t.width.toString()):s.removeAttribute("markerWidth"),o.setAttribute("d",t.pathData),le.isNullOrEmpty(t.fill)?o.removeAttribute("fill"):o.setAttribute("fill",t.fill),le.isNullOrEmpty(t.stroke)?o.removeAttribute("stroke"):o.setAttribute("stroke",t.stroke),s}};Ic=new WeakMap,Dp=new WeakMap,hv=l([J3({tagName:XA+"-"+"2d"+"-svg-adapter"})],hv);var dk={};tt(dk,{AdapterUtils:()=>sl,BasicMaterialElement:()=>mv,DragEvent:()=>ad,KnownShader:()=>Fi,LambertMaterialElement:()=>$c,LineMaterialElement:()=>rl,MaterialElement:()=>Ot,OrbitCameraBehavior:()=>wx,Pacem3DAdapterElement:()=>yl,Pacem3DCameraElement:()=>ai,Pacem3DDetector:()=>w0,Pacem3DElement:()=>Xr,Pacem3DGroupElement:()=>Ts,Pacem3DLightElement:()=>Ln,Pacem3DMeshElement:()=>zi,Pacem3DObjectElement:()=>Gi,Pacem3DOrthographicCameraElement:()=>si,Pacem3DPerspectiveCameraElement:()=>Ns,Pacem3DPrimitiveElement:()=>Ft,Pacem3DThreeAdapterElement:()=>Am,Pacem3DWebgpuAdapterElement:()=>al,Pacem3DWgslScriptElement:()=>Yc,PacemBoxElement:()=>Ur,PacemConeElement:()=>Jn,PacemCylinderElement:()=>Zn,PacemDodecahedronElement:()=>$p,PacemHexahedronElement:()=>Pp,PacemIcosahedronElement:()=>Ip,PacemLineElement:()=>nl,PacemOctahedronElement:()=>Op,PacemOrbitCameraBehaviorElement:()=>ei,PacemPlaneElement:()=>Ri,PacemSphereElement:()=>Ca,PacemTetrahedronElement:()=>Rp,PacemTorusElement:()=>Oi,PhongMaterialElement:()=>ys,PolyhedronElement:()=>il,RenderableElement:()=>Ls,RenderableEvent:()=>od,StalePropertyFlag:()=>Os,StandardMaterialElement:()=>xa,UI3DEvent:()=>bu,Ui3DElement:()=>_r,computePlaneNormal:()=>yC,computeSharpVertexNormals:()=>xr,isBasicMaterial:()=>yb,isCamera:()=>Pr,isGeometry:()=>df,isGroup:()=>cd,isInteraction:()=>bb,isLambertMaterial:()=>_b,isLight:()=>Rs,isLineMaterial:()=>xl,isMaterial:()=>oi,isMesh:()=>Nn,isMeshGeometry:()=>xu,isOrthographicCamera:()=>vb,isPerspectiveCamera:()=>gb,isPhongMaterial:()=>xb,isRenderable:()=>cf,isShaderMaterial:()=>gM,isStage:()=>bC,isStandardMaterial:()=>Cb,isUi3DObject:()=>_u});var w0=class{constructor(){this._detected={supported:!1,info:{}};let r=document.createElement("canvas"),e=["webgl","experimental-webgl","moz-webgl","webkit-3d"],t,n=function(o){if(o)return t.getParameter(o)},i=(o,c,d)=>{let p=this._detected;var u=p.info[o]=p.info[o]||{};c=c.replace(/[^\w]+/g,""),c=c.substring(0,1).toLowerCase()+c.substring(1),u[c]=d};if(navigator.userAgent.indexOf("MSIE")>=0)try{t=window.WebGLHelper.CreateGLContext(r,"canvas")}catch{}else for(var s=0;s<e.length;s++)try{if(t=r.getContext(e[s]),t){i("main","Context Name",e[s]);break}}catch{}this._detected.supported=!!t,i("main","Platform",navigator.platform),i("main","Agent",navigator.userAgent),t&&(i("main","Vendor",n(t.VENDOR)),i("main","Version",n(t.VERSION)),i("main","Renderer",n(t.RENDERER)),i("main","Shading Language Version",n(t.SHADING_LANGUAGE_VERSION)),i("bits","Rgba Bits",n(t.RED_BITS)+", "+n(t.GREEN_BITS)+", "+n(t.BLUE_BITS)+", "+n(t.ALPHA_BITS)),i("bits","Depth Bits",n(t.DEPTH_BITS)),i("shader","Max Vertex Attribs",n(t.MAX_VERTEX_ATTRIBS)),i("shader","Max Vertex Texture Image Units",n(t.MAX_VERTEX_TEXTURE_IMAGE_UNITS)),i("shader","Max Varying Vectors",n(t.MAX_VARYING_VECTORS)),i("shader","Max Uniform Vectors",n(t.MAX_VERTEX_UNIFORM_VECTORS)),i("tex","Max Combined Texture Image Units",n(t.MAX_COMBINED_TEXTURE_IMAGE_UNITS)),i("tex","Max Texture Size",n(t.MAX_TEXTURE_SIZE)),i("tex","Max Cube Map Texture Size",n(t.MAX_CUBE_MAP_TEXTURE_SIZE)),i("tex","Num. Compressed Texture Formats",n(t.COMPRESSED_TEXTURE_FORMATS)),i("misc","Max Render Buffer Size",n(t.MAX_RENDERBUFFER_SIZE)),i("misc","Max Viewport Dimensions",n(t.MAX_VIEWPORT_DIMS)),i("misc","Aliased Line Width Range",n(t.ALIASED_LINE_WIDTH_RANGE)),i("misc","Aliased Point Size Range",n(t.ALIASED_POINT_SIZE_RANGE)),i("misc","Supported Extensions",t.getSupportedExtensions()||[]))}get info(){return this._detected.info}get supported(){return this._detected.supported}};import{CustomElement as Q3,P as ez}from"@pacem/pacem-core";var mv=class extends Ot{constructor(){super("basic")}};mv=l([Q3({tagName:`${ez}-${"3d"}-material-basic`})],mv);import{CustomElement as tz,P as rz,Watch as k0,PropertyConverters as M0,Utils as nz}from"@pacem/pacem-core";var $c=class extends Ot{constructor(){super("lambert")}async createMaterial(){return nz.extend({emissiveColor:this.emissiveColor||"#000",reflectivity:this.reflectivity??0,refractionRatio:this.refractionRatio??0},await super.createMaterial())}propertyChangedCallback(r,e,t,n){if(super.propertyChangedCallback(r,e,t,n),!n)switch(r){case"emissiveColor":case"reflectivity":case"refractionRatio":this.updateMaterial();break}}};l([k0({emit:!1,converter:M0.String})],$c.prototype,"emissiveColor",2),l([k0({emit:!1,converter:M0.Number})],$c.prototype,"reflectivity",2),l([k0({emit:!1,converter:M0.Number})],$c.prototype,"refractionRatio",2),$c=l([tz({tagName:`${rz}-${"3d"}-material-lambert`})],$c);import{CustomElement as iz,P as sz,Watch as Z_,PropertyConverters as S0,Utils as az}from"@pacem/pacem-core";var rl=class extends Ot{constructor(){super("line")}propertyChangedCallback(r,e,t,n){if(super.propertyChangedCallback(r,e,t,n),!n)switch(r){case"lineWidth":case"lineJoin":case"lineCap":case"dashArray":this.updateMaterial();break}}async createMaterial(){return az.extend({lineWidth:this.lineWidth??1,lineJoin:this.lineJoin??"round",lineCap:this.lineCap??"round",dashArray:this.dashArray},await super.createMaterial())}};l([Z_({emit:!1,converter:S0.Number})],rl.prototype,"lineWidth",2),l([Z_({emit:!1,converter:S0.String})],rl.prototype,"lineJoin",2),l([Z_({emit:!1,converter:S0.String})],rl.prototype,"lineCap",2),l([Z_({emit:!1,converter:{convert:r=>r?.split(",").map(e=>parseInt(e)).filter(e=>!Number.isNaN(e)),convertBack:r=>r?.join(",")}})],rl.prototype,"dashArray",2),rl=l([iz({tagName:`${sz}-${"3d"}-material-line`})],rl);import{CustomElement as oz,P as lz,Watch as Sm,PropertyConverters as Lm,Utils as cz}from"@pacem/pacem-core";var ys=class extends Ot{constructor(){super("phong")}async createMaterial(){return cz.extend({emissiveColor:this.emissiveColor||"#000",reflectivity:this.reflectivity??0,refractionRatio:this.refractionRatio??0,specularColor:this.specularColor||"#000",shininess:this.shininess??0,flatShading:this.flatShading??!0},await super.createMaterial())}propertyChangedCallback(r,e,t,n){if(super.propertyChangedCallback(r,e,t,n),!n)switch(r){case"emissiveColor":case"reflectivity":case"refractionRatio":case"specularColor":case"shininess":case"flatShading":this.updateMaterial();break}}};l([Sm({emit:!1,converter:Lm.String})],ys.prototype,"emissiveColor",2),l([Sm({emit:!1,converter:Lm.Number})],ys.prototype,"reflectivity",2),l([Sm({emit:!1,converter:Lm.Number})],ys.prototype,"refractionRatio",2),l([Sm({emit:!1,converter:Lm.String})],ys.prototype,"specularColor",2),l([Sm({emit:!1,converter:Lm.Number})],ys.prototype,"shininess",2),l([Sm({emit:!1,converter:Lm.Boolean})],ys.prototype,"flatShading",2),ys=l([oz({tagName:`${lz}-${"3d"}-material-phong`})],ys);import{CustomElement as dz,P as pz,Watch as fv,PropertyConverters as gv,Utils as uz}from"@pacem/pacem-core";var xa=class extends Ot{constructor(){super("standard")}async createMaterial(){return uz.extend({emissiveColor:this.emissiveColor||"#000",refractionRatio:this.refractionRatio??0,metalness:this.metalness??0,roughness:this.roughness??0,flatShading:this.flatShading??!1},await super.createMaterial())}propertyChangedCallback(r,e,t,n){if(super.propertyChangedCallback(r,e,t,n),!n)switch(r){case"emissiveColor":case"roughness":case"metalness":case"refractionRatio":case"flatShading":this.updateMaterial();break}}};l([fv({emit:!1,converter:gv.String})],xa.prototype,"emissiveColor",2),l([fv({emit:!1,converter:gv.Number})],xa.prototype,"refractionRatio",2),l([fv({emit:!1,converter:gv.Number})],xa.prototype,"roughness",2),l([fv({emit:!1,converter:gv.Number})],xa.prototype,"metalness",2),l([fv({emit:!1,converter:gv.Boolean})],xa.prototype,"flatShading",2),xa=l([dz({tagName:`${pz}-${"3d"}-material-standard`})],xa);import{PacemEventTarget as hz,Watch as mz,PropertyConverters as fz,Utils as gz}from"@pacem/pacem-core";var Ft=class extends hz{viewActivatedCallback(){super.viewActivatedCallback(),gz.isNull(this.geometry)&&(this.geometry=this.createDefaultGeometry())}};l([mz({converter:fz.Json})],Ft.prototype,"geometry",2);import{CustomElement as vz,P as bz,Watch as Nm,PropertyConverters as Tm}from"@pacem/pacem-core";var Ur=class extends Ft{static createMeshGeometry(r,e,t,n,i,s){let o=r||1,c=e||1,d=t||1,p=n||1,u=i||1,h=s||1,m=[],f=[],g=[];for(var v=0;v<=u;v++)for(var b=c/2-c*(1*v)/(1*u),_=0;_<=h;_++)for(var E=-d/2+d*(1*_)/(1*h),C=0;C<=p;C++){var k=-o/2+o*(1*C)/(1*p);(C==0||C==p||_==0||_==h||v==0||v==u)&&m.push({x:k,y:b,z:E})}for(var w=function(ne,pe,ee){for(var J=1e-5,$e=0;$e<m.length;$e++){var ue=m[$e];if(Math.abs(ue.x-ne)<J&&Math.abs(ue.y-pe)<J&&Math.abs(ue.z-ee)<J)return $e}return-1},T=function(ne,pe,ee,J,$e,ue,Te,He){g.push(ne),g.push(pe),g.push(ee),g.push(ne),g.push(ee),g.push(J),f.push({x:$e,y:He}),f.push({x:Te,y:He}),f.push({x:Te,y:ue}),f.push({x:$e,y:He}),f.push({x:Te,y:ue}),f.push({x:$e,y:ue})},_=0;_<h;_++)for(var b=c/2,E=-d/2+d*(1*_)/(1*h),I=-d/2+d*(1*(_+1))/(1*h),C=0;C<p;C++){var k=-o/2+1*C*o/(1*p),O=-o/2+1*(C+1)*o/(1*p),D=w(k,b,I),P=w(O,b,I),N=w(O,b,E),H=w(k,b,E),V=1*(C+1)/(1*p),B=1*C/(1*p),R=1-1*(_+1)/(1*h),U=1-1*_/(1*h);T(D,P,N,H,B,U,V,R)}for(var v=0;v<u;v++)for(var b=c/2-1*v*c/(1*u),z=c/2-(v+1)*c/(1*u),E=-d/2,C=0;C<p;C++){var k=o/2-1*C*o/(1*p),O=o/2-(C+1)*o/(1*p),D=w(k,z,E),P=w(O,z,E),N=w(O,b,E),H=w(k,b,E),V=(C+1)/(1*p),B=1*C/(1*p),R=1-(v+1)/(1*u),U=1-1*v/(1*u);T(D,P,N,H,B,U,V,R)}for(var v=0;v<u;v++)for(var b=c/2-1*v*c/(1*u),z=c/2-(v+1)*c/(1*u),k=-o/2,_=0;_<h;_++){var E=-d/2+_*d/(1*h),I=-d/2+(_+1)*d/(1*h),D=w(k,z,E),P=w(k,z,I),N=w(k,b,I),H=w(k,b,E),V=(_+1)/(1*h),B=1*_/(1*h),R=1-(v+1)/(1*u),U=1-v/(1*u);T(D,P,N,H,B,U,V,R)}for(var v=0;v<u;v++)for(var b=c/2-v*c/(1*u),z=c/2-(v+1)*c/(1*u),E=d/2,C=0;C<p;C++){var k=-o/2+C*o/(1*p),O=-o/2+(C+1)*o/(1*p),D=w(k,z,E),P=w(O,z,E),N=w(O,b,E),H=w(k,b,E),V=(C+1)/(1*p),B=1*C/(1*p),R=1-(v+1)/(1*u),U=1-1*v/(1*u);T(D,P,N,H,B,U,V,R)}for(var v=0;v<u;v++)for(var b=c/2-v*c/(1*u),z=c/2-(v+1)*c/(1*u),k=o/2,_=0;_<h;_++){var E=d/2-_*d/(1*h),I=d/2-(_+1)*d/(1*h),D=w(k,z,E),P=w(k,z,I),N=w(k,b,I),H=w(k,b,E),V=(_+1)/(1*h),B=1*_/(1*h),R=1-(v+1)/(1*u),U=1-1*v/(1*u);T(D,P,N,H,B,U,V,R)}for(var _=0;_<h;_++)for(var b=-c/2,E=d/2-d*_/(1*h),I=d/2-d*(_+1)/(1*h),C=0;C<p;C++){var k=-o/2+C*o/(1*p),O=-o/2+(C+1)*o/(1*p),D=w(k,b,I),P=w(O,b,I),N=w(O,b,E),H=w(k,b,E),V=(C+1)/(1*p),B=1*C/(1*p),R=1-(_+1)/(1*h),U=1-1*_/(1*h);T(D,P,N,H,B,U,V,R)}let G=new je(m,g,f);G.key=`box_${r}x${e}x${t}_w${n}_h${i}_d${s}`,xr(G);let Z={x:0,y:0,z:0},q=r/2,Q=e/2,Ne=t/2;return G.barycenter=Z,G.boundingBox={maxX:q,maxY:Q,maxZ:Ne,minX:-q,minY:-Q,minZ:-Ne},G.boundingSphere={center:Z,radius:Math.sqrt(Math.pow(q,2)+Math.pow(Q,2)+Math.pow(Ne,2))},G}createDefaultGeometry(){return Ur.createMeshGeometry()}propertyChangedCallback(r,e,t,n){switch(super.propertyChangedCallback(r,e,t,n),r){case"width":case"height":case"depth":case"widthSegments":case"heightSegments":case"depthSegments":this.geometry=Ur.createMeshGeometry(this.width,this.height,this.depth,this.widthSegments,this.heightSegments,this.depthSegments);break}}};l([Nm({emit:!1,converter:Tm.Number})],Ur.prototype,"width",2),l([Nm({emit:!1,converter:Tm.Number})],Ur.prototype,"height",2),l([Nm({emit:!1,converter:Tm.Number})],Ur.prototype,"depth",2),l([Nm({emit:!1,converter:Tm.Number})],Ur.prototype,"widthSegments",2),l([Nm({emit:!1,converter:Tm.Number})],Ur.prototype,"heightSegments",2),l([Nm({emit:!1,converter:Tm.Number})],Ur.prototype,"depthSegments",2),Ur=l([vz({tagName:bz+"-"+"3d"+"-primitive-box"})],Ur);import{CustomElement as yz,P as _z,Watch as vv,PropertyConverters as bv}from"@pacem/pacem-core";var Jn=class extends Ft{static createMeshGeometry(r=1,e=1,t=18,n=5,i=1){let s=r,o=[],c=[],d=[],p=Oa*(360/t),u=s/e,h=e/n,m=1/t;o.push({x:0,y:e,z:0});for(let b=1;b<=n;b++){let _=e-h*b,E=_/e,C=(e-_)*u,w=(_+h)/e;for(let T=0;T<t;T++){let I=p*T,O=Math.cos(I)*C,D=-Math.sin(I)*C;o.push({x:O,y:_,z:D});let P=1+t*(b-1)+T,N=T==0?P+t-1:P-1,H=T*m,V=T==0?1-m:m*(T-1);if(b==1){d.push(0,N,P),c.push({x:H,y:1},{x:V,y:E},{x:H,y:E});continue}let B=1+t*(b-2)+T,U=T==0?B+t-1:B-1,z=N,G=P,Z=B;d.push(G,U,z),d.push(G,Z,U);let q={x:V,y:w},Q={x:V,y:E},Ne={x:H,y:E},ne={x:H,y:w};c.push(Ne,q,Q),c.push(Ne,ne,q)}}let f=1+(n-1)*t;o.push({x:0,y:0,z:0});let g=f+t;for(let b=1;b<=i;b++){let _=b/i,E=r*_,C=(b-1)/i;for(let k=0;k<t;k++){let w=p*k,T=Math.cos(w),I=Math.sin(w),O=w-p,D=Math.cos(O),P=Math.sin(O),N=.5*(1+T*_),H=.5*(1+I*_),V=.5*(1+D*_),B=.5*(1+P*_),R,U;if(b!=i){let ze=Math.cos(w)*E,Fr=-Math.sin(w)*E;o.push({x:ze,y:0,z:Fr}),R=g+1+(b-1)*t+k,U=k==0?R+t-1:R-1}else R=f+k,U=k==0?f+t-1:R-1;if(b==1){d.push(g,R,U),c.push({x:.5,y:.5},{x:N,y:H},{x:V,y:B});continue}let z=.5*(1+T*C),G=.5*(1+I*C),Z=.5*(1+D*C),q=.5*(1+P*C),Q=g+1+(b-2)*t+k,ne=k==0?Q+t-1:Q-1,pe=U,ee=R,J=Q;d.push(ne,J,pe),d.push(pe,J,ee);let $e={x:Z,y:q},ue={x:V,y:B},Te={x:N,y:H},He={x:z,y:G};c.push($e,He,ue),c.push(ue,He,Te)}}let v=new je(o,d,c);return v.key=`cone_${r}x${e}_s${t}_h${n}_c${i}`,xr(v),v}createDefaultGeometry(){return Jn.createMeshGeometry()}propertyChangedCallback(r,e,t,n){switch(super.propertyChangedCallback(r,e,t,n),r){case"radius":case"height":case"sides":case"heightSegments":case"capSegments":this.geometry=Jn.createMeshGeometry(this.radius,this.height,this.sides,this.heightSegments,this.capSegments);break}}};l([vv({emit:!1,converter:bv.Number})],Jn.prototype,"radius",2),l([vv({emit:!1,converter:bv.Number})],Jn.prototype,"height",2),l([vv({emit:!1,converter:bv.Number})],Jn.prototype,"sides",2),l([vv({emit:!1,converter:bv.Number})],Jn.prototype,"heightSegments",2),l([vv({emit:!1,converter:bv.Number})],Jn.prototype,"capSegments",2),Jn=l([yz({tagName:_z+"-"+"3d"+"-primitive-cone"})],Jn);import{CustomElement as xz,P as Cz,Watch as yv,PropertyConverters as _v}from"@pacem/pacem-core";var Zn=class extends Ft{static createMeshGeometry(r=1,e=1,t=18,n=5,i=1){let s=r,o=[],c=[],d=[],p=Oa*(360/t);o.push({x:0,y:e,z:0}),o.push({x:0,y:0,z:0});let u=s/i;for(let w=1;w<=i;w++)for(var h=u*w,m=0;m<t;m++){let T=2+2*t*(w-1),I=m==0?T+2*(t-1):T+2*(m-1),O=T+2*m,D=Math.cos(p*m),P=-Math.sin(p*m),N=Math.cos(p*(m-1)),H=-Math.sin(p*(m-1)),V=h*D,B=h*P,R={x:V,y:e,z:B},U={x:V,y:0,z:B};o.push(R),o.push(U);let z=.5*h/s,G=D*z,Z=P*z,q=N*z,Q=H*z;if(w==1){let Ne=[0,I,O],ne=[1,O+1,I+1],pe=[{x:.5,y:.5},{x:.5+q,y:.5-Q},{x:.5+G,y:.5-Z}],ee=[{x:.5,y:.5},{x:.5+G,y:.5+Z},{x:.5+q,y:.5+Q}];d.push(...Ne),d.push(...ne);for(let J=0;J<pe.length;J++)c.push(pe[J]);for(let J=0;J<ee.length;J++)c.push(ee[J])}else{let Ne=2+2*t*(w-2),ne=m==0?Ne+2*(t-1):Ne+2*(m-1),pe=Ne+2*m,ee=.5*((w-1)/i),J=D*ee,$e=P*ee,ue=N*ee,Te=H*ee,He={x:.5+q,y:.5-Q},ze={x:.5+G,y:.5-Z},Fr={x:.5+J,y:.5-$e},Cs={x:.5+ue,y:.5-Te},Mn={x:.5+q,y:.5+Q},fl={x:.5+G,y:.5+Z},Na={x:.5+J,y:.5+$e},gl={x:.5+ue,y:.5+Te};d.push(I),d.push(O),d.push(ne),d.push(ne),d.push(O),d.push(pe),d.push(pe+1),d.push(O+1),d.push(I+1),d.push(pe+1),d.push(I+1),d.push(ne+1),c.push(He),c.push(ze),c.push(Cs),c.push(Cs),c.push(ze),c.push(Fr),c.push(Na),c.push(fl),c.push(Mn),c.push(Na),c.push(Mn),c.push(gl)}}let f=2+2*t*i,g=2+2*t*(i-1),v=1/t,b=1/n;for(let w=1;w<=n;w++)for(let T=0;T<t;T++){if(w!=n){var _=s*Math.cos(p*T),E=-s*Math.sin(p*T),C=e*w/n;o.push({x:_,y:C,z:E})}let I=T==0?t-1:T-1,O=w==1?g+2*I+1:f+t*(w-2)+I,D=w==1?g+2*T+1:f+t*(w-2)+T,P=w==n?g+2*T:f+t*(w-1)+T,N=w==n?g+2*I:f+t*(w-1)+I,H=I*v,V=(w-1)*b,B=T==0?1:T*v,R=w*b,U={x:H,y:V},z={x:B,y:V},G={x:B,y:R},Z={x:H,y:R};d.push(O),d.push(D),d.push(P),d.push(O),d.push(P),d.push(N),c.push(U),c.push(z),c.push(G),c.push(U),c.push(G),c.push(Z)}let k=new je(o,d,c);return k.key=`cylinder_${r}x${e}_s${t}_h${n}_c${i}`,xr(k),k}createDefaultGeometry(){return Zn.createMeshGeometry()}propertyChangedCallback(r,e,t,n){switch(super.propertyChangedCallback(r,e,t,n),r){case"radius":case"height":case"sides":case"heightSegments":case"capSegments":this.geometry=Zn.createMeshGeometry(this.radius,this.height,this.sides,this.heightSegments,this.capSegments);break}}};l([yv({emit:!1,converter:_v.Number})],Zn.prototype,"radius",2),l([yv({emit:!1,converter:_v.Number})],Zn.prototype,"height",2),l([yv({emit:!1,converter:_v.Number})],Zn.prototype,"sides",2),l([yv({emit:!1,converter:_v.Number})],Zn.prototype,"heightSegments",2),l([yv({emit:!1,converter:_v.Number})],Zn.prototype,"capSegments",2),Zn=l([xz({tagName:Cz+"-"+"3d"+"-primitive-cylinder"})],Zn);import{CustomElement as Ez,P as wz,Watch as kz,PropertyConverters as Mz}from"@pacem/pacem-core";var Sz=[{x:0,y:0,z:0},{x:0,y:1,z:0}],nl=class extends Ft{static createLineGeometry(r){return new _l(r||Sz)}createDefaultGeometry(){return nl.createLineGeometry()}propertyChangedCallback(r,e,t,n){super.propertyChangedCallback(r,e,t,n),r==="positions"&&(this.geometry=nl.createLineGeometry(t))}};l([kz({emit:!1,converter:Mz.Json})],nl.prototype,"positions",2),nl=l([Ez({tagName:wz+"-"+"3d"+"-primitive-line"})],nl);import{CustomElement as Lz,P as Nz,Watch as Q_,PropertyConverters as ex}from"@pacem/pacem-core";import{Geometry as Tz}from"@pacem/pacem-numerical";var Ri=class extends Ft{static createMeshGeometry(r,e,t,n){r||=1,e||=1,t||=4,n||=4;let i=r*.5,s=e*.5,o=[],c=[],d=[],p=[],u=Tz.LinearAlgebra.Vector3D.from(0,0,1);for(let m=0;m<=n;m++)for(let f=0;f<=t;f++){let g=-i+f*r/(1*t),v=0,b=-s+m*e/(1*n);if(o.push({x:g,y:v,z:b}),m<n&&f<t){let _=t+1,E=(f+1)/(1*t),C=1*f/(1*t),k=1-(m+1)/(1*n),w=1-1*m/(1*n);d.push((m+1)*_+f),d.push((m+1)*_+f+1),d.push(m*_+f+1),d.push((m+1)*_+f),d.push(m*_+f+1),d.push(m*_+f),c.push({x:C,y:k}),c.push({x:E,y:k}),c.push({x:E,y:w}),c.push({x:C,y:k}),c.push({x:E,y:w}),c.push({x:C,y:w}),p.push(u,u,u,u,u,u)}}let h=new je(o,d,c,p);return h.key=`plane_${r}x${e}_w${t}_l${n}`,h}createDefaultGeometry(){return Ri.createMeshGeometry()}propertyChangedCallback(r,e,t,n){switch(super.propertyChangedCallback(r,e,t,n),r){case"width":case"length":case"widthSegments":case"lengthSegments":this.geometry=Ri.createMeshGeometry(this.width,this.length,this.widthSegments,this.lengthSegments);break}}};l([Q_({emit:!1,converter:ex.Number})],Ri.prototype,"width",2),l([Q_({emit:!1,converter:ex.Number})],Ri.prototype,"length",2),l([Q_({emit:!1,converter:ex.Number})],Ri.prototype,"widthSegments",2),l([Q_({emit:!1,converter:ex.Number})],Ri.prototype,"lengthSegments",2),Ri=l([Lz({tagName:Nz+"-"+"3d"+"-primitive-plane"})],Ri);import{CustomElement as xv,P as Cv,Watch as Az,PropertyConverters as Dz}from"@pacem/pacem-core";import{Geometry as Rz}from"@pacem/pacem-numerical";var Hp={parseFloats:function(a){let r=/([\d.-]+)/i;var e=r.exec(a);let t=[];for(;e!=null;){let n=e[0],i=parseFloat(n);t.push(i),a=a.replace(n,""),e=r.exec(a)}return t}},ht=Rz.LinearAlgebra.Vector3D,il=class extends Ft{propertyChangedCallback(r,e,t,n){super.propertyChangedCallback(r,e,t,n),r==="radius"&&this._assignMeshGeometry(t)}_assignMeshGeometry(r){this.geometry=this.createMeshGeometry(r>0?r:1)}createDefaultGeometry(){return this.createMeshGeometry(1)}};l([Az({emit:!1,converter:Dz.Number})],il.prototype,"radius",2);var Rp=class extends il{static createMeshGeometry(r){r||=1;let t="0 0.5774 -0.8165, 0 0.5774 0.8165, 0.8165 -0.5774 0, -0.8165 -0.5774 0".split(","),n=[];for(let u=0;u<t.length;u++){let h=t[u],m=Hp.parseFloats(h);n.push({x:m[0]*r,y:m[1]*r,z:m[2]*r})}let i=[1,2,0,2,3,0,3,1,0,3,2,1],o="0.5 0.9995, 0.5 0.0004995, 0.0004995 0.5, 0.9995 0.5, 0.5 0.0004995, 0.9995 0.5, 0.5 0.9995, 0.0004995 0.5, 0.9995 0.5, 0.5 0.9995, 0.0004995 0.5, 0.5 0.0004995".split(","),c=[4,5,6,7,8,9,10,11,0,3,2,1],d=[];for(let u=0;u<c.length;u++){let h=c[u],m=Hp.parseFloats(o[h]);d.push({x:m[0],y:m[1]})}let p=new je(n,i,d);return p.key=`tetrahedron_${r}`,xr(p),p.boundingSphere={center:ht.zero(),radius:r},p}createMeshGeometry(r=this.radius){return Rp.createMeshGeometry(r)}};Rp=l([xv({tagName:Cv+"-"+"3d"+"-primitive-tetrahedron"})],Rp);var Op=class extends il{static createMeshGeometry(r){r||=1;let e="0 0.7071 -0.7071, 0 0.7071 0.7071, 1 0 0, 0 -0.7071 -0.7071, -1 0 0, 0 -0.7071 0.7071",t=[1,2,0,2,3,0,3,4,0,4,1,0,4,5,1,5,2,1,2,5,3,4,3,5],n="0.5 0.9995, 0.5 0.9995, 0.0004995 0.5, 0.5 0.9995, 0.9995 0.5, 0.5 0.0004995, 0.5 0.0004995, 0.9995 0.5, 0.5 0.9995, 0.0004995 0.5, 0.5 0.0004995, 0.5 0.9995, 0.5 0.0004995, 0.9995 0.5, 0.5 0.9995, 0.0004995 0.5, 0.5 0.0004995, 0.0004995 0.5, 0.5 0.0004995, 0.5 0.9995, 0.5 0.0004995, 0.9995 0.5, 0.5 0.0004995, 0.5 0.9995",i=[6,7,8,9,10,11,12,13,14,15,16,0,17,18,19,20,21,1,2,22,23,4,3,5],s=e.split(","),o=[];for(let u=0;u<s.length;u++){let h=s[u],m=Hp.parseFloats(h);o.push({x:m[0]*r,y:m[1]*r,z:m[2]*r})}let c=n.split(","),d=[];for(let u=0;u<i.length;u++){let h=i[u],m=Hp.parseFloats(c[h]);d.push({x:m[0],y:m[1]})}let p=new je(o,t,d);return p.key=`octahedron_${r}`,xr(p),p.boundingSphere={center:ht.zero(),radius:r},p}createMeshGeometry(r=this.radius){return Op.createMeshGeometry(r)}};Op=l([xv({tagName:Cv+"-"+"3d"+"-primitive-octahedron"})],Op);var Pp=class extends il{static createMeshGeometry(r){r||=1;let e=1/Math.sqrt(3),t=2*r*e,n=Ur.createMeshGeometry(t,t,t);return n.key=`hexahedron_${r}`,n}createMeshGeometry(r=this.radius){return Pp.createMeshGeometry(r)}};Pp=l([xv({tagName:Cv+"-"+"3d"+"-primitive-hexahedron"})],Pp);var Ip=class extends il{static createMeshGeometry(r){r||=1;let e="0 0.850651 -0.525731, 0 0.850651 0.525731, 0.850651 0.525731 0, 0.525731 0 -0.850651, -0.525731 0 -0.850651, -0.850651 0.525731 0, -0.525731 0 0.850651, 0.525731 0 0.850651, 0.850651 -0.525731 0, 0 -0.850651 0.525731, 0 -0.850651 -0.525731, -0.850651 -0.525731 0",t=[1,2,0,2,3,0,3,4,0,4,5,0,5,1,0,5,6,1,6,7,1,7,2,1,2,8,3,2,7,8,6,9,7,9,8,7,8,10,3,8,9,10,6,11,9,11,10,9,10,4,3,10,11,4,6,5,11,5,4,11],n="0.5 0.808708, 0.5 0.999501, 0.5 0.808708, 0.191292 0.5, 0.000499547 0.5, 0.5 0.808708, 0.9995 0.5, 0.808708 0.5,0.000499487 0.5, 0.5 0.191292, 0.5 0.000499487, 0.5 0.191292,0.5 0.191292, 0.999501 0.5, 0.5 0.808708, 0.5 0.808708,0.9995 0.5, 0.808708 0.999501, 0.191292 0.5, 0.808708 0.5,0.5 0.999501, 0.808708 0.5, 0.999501 0.808708, 0.5 0.999501,0.000499487 0.5, 0.5 0.191292, 0.5 0.808708, 0.9995 0.5,0.808708 0.999501, 0.191292 0.5, 0.808708 0.5, 0.5 0.999501,0.808708 0.5, 0.999501 0.808708, 0.5 0.808708, 0.5 0.191292,0.9995 0.5, 0.000499547 0.5, 0.5 0.191292, 0.191292 0.5,0.5 0.000499487, 0.808708 0.5, 0.5 0.000499487, 0.999501 0.191292,0.5 0.191292, 0.808708 0.000499487, 0.9995 0.5, 0.5 0.191292,0.5 0.808708, 0.9995 0.5, 0.5 0.191292, 0.808708 0.000499487,0.999501 0.5, 0.5 0.808708, 0.5 0.000499487, 0.808708 0.5,0.999501 0.191292, 0.808708 0.5, 0.5 0.808708, 0.5 0.191292",i=[12,13,14,15,16,17,18,19,20,21,22,23,24,25,0,26,27,28,29,30,31,32,33,1,34,35,36,2,37,38,39,40,41,42,43,7,44,45,46,8,47,48,49,50,51,52,53,9,54,55,3,10,56,57,6,58,59,5,4,11],s=e.split(","),o=[];for(let u=0;u<s.length;u++){let h=s[u],m=Hp.parseFloats(h);o.push({x:m[0]*r,y:m[1]*r,z:m[2]*r})}let c=n.split(","),d=[];for(let u=0;u<i.length;u++){let h=i[u],m=Hp.parseFloats(c[h]);d.push({x:m[0],y:m[1]})}let p=new je(o,t,d);return p.key=`icosahedron_${r}`,xr(p),p.boundingSphere={center:ht.zero(),radius:r},p}createMeshGeometry(r=this.radius){return Ip.createMeshGeometry(r)}};Ip=l([xv({tagName:Cv+"-"+"3d"+"-primitive-icosahedron"})],Ip);var $p=class extends il{static createMeshGeometry(r){r||=1;let e=ht.from(.356822*r,.934172*r,0*r),t=ht.from(-.356822*r,.934172*r,0*r),n=ht.from(.57735*r,.57735*r,-.57735*r),i=ht.from(0*r,.356822*r,-.934172*r),s=ht.from(-.57735*r,.57735*r,-.57735*r),o=ht.from(-.57735*r,.57735*r,.57735*r),c=ht.from(0*r,.356822*r,.934172*r),d=ht.from(.57735*r,.57735*r,.57735*r),p=ht.from(.934172*r,0*r,-.356822*r),u=ht.from(.934172*r,0*r,.356822*r),h=ht.from(0*r,-.356822*r,.934172*r),m=ht.from(.57735*r,-.57735*r,.57735*r),f=ht.from(.57735*r,-.57735*r,-.57735*r),g=ht.from(.356822*r,-.934172*r,0*r),v=ht.from(-.57735*r,-.57735*r,.57735*r),b=ht.from(-.356822*r,-.934172*r,0*r),_=ht.from(0*r,-.356822*r,-.934172*r),E=ht.from(-.57735*r,-.57735*r,-.57735*r),C=ht.from(-.934172*r,0*r,.356822*r),k=ht.from(-.934172*r,0*r,-.356822*r),w=[e,t,n,i,s,o,c,d,p,u,h,m,f,g,v,b,_,E,C,k],T=[0,2,3,0,3,4,0,4,1,1,5,6,1,6,7,1,7,0,7,9,8,7,8,2,7,2,0,7,6,10,7,10,11,7,11,9,11,13,12,11,12,8,11,8,9,11,10,14,11,14,15,11,15,13,15,17,16,15,16,12,15,12,13,15,14,18,15,18,19,15,19,17,19,4,3,19,3,16,19,16,17,19,18,5,19,5,1,19,1,4,18,14,10,18,10,6,18,6,5,3,2,8,3,8,12,3,12,16],I=`0.5 0.999501, 0.5 0.999501, 0.191292 0.808708, 0.5 0.690792,
|
|
580
|
+
0.191292 0.808708, 0.191292 0.808708, 0.5 0.690792,
|
|
581
|
+
0.808708 0.808708, 0.000499517 0.5, 0.309208 0.5, 0.5 0.309208,
|
|
582
|
+
0.191292 0.191292, 0.191292 0.191292, 0.309208 0.5,
|
|
583
|
+
0.191292 0.191292, 0.5 0.000499517, 0.5 0.309208, 0.808708 0.191292,
|
|
584
|
+
0.000499517 0.5, 0.309208 0.5, 0.690792 0.5, 0.808708 0.808708,
|
|
585
|
+
0.5 0.999501, 0.690792 0.5, 0.5 0.999501, 0.191292 0.808708,
|
|
586
|
+
0.690792 0.5, 0.191292 0.808708, 0.309208 0.5, 0.309208 0.5,
|
|
587
|
+
0.191292 0.191292, 0.5 0.000499517, 0.309208 0.5, 0.5 0.000499517,
|
|
588
|
+
0.808708 0.191292, 0.309208 0.5, 0.808708 0.191292,
|
|
589
|
+
0.690792 0.5, 0.191292 0.808708, 0.309208 0.5, 0.690792 0.5,
|
|
590
|
+
0.191292 0.808708, 0.690792 0.5, 0.808708 0.808708,
|
|
591
|
+
0.191292 0.808708, 0.808708 0.808708, 0.808708 0.808708,
|
|
592
|
+
0.5 0.690792, 0.5 0.309208, 0.808708 0.808708, 0.5 0.309208,
|
|
593
|
+
0.808708 0.191292, 0.808708 0.191292, 0.9995 0.5, 0.191292 0.191292,
|
|
594
|
+
0.5 0.000499517, 0.808708 0.191292, 0.191292 0.191292,
|
|
595
|
+
0.808708 0.191292, 0.690792 0.5, 0.191292 0.191292,
|
|
596
|
+
0.690792 0.5, 0.191292 0.191292, 0.5 0.000499517, 0.808708 0.191292,
|
|
597
|
+
0.191292 0.191292, 0.808708 0.191292, 0.690792 0.5,
|
|
598
|
+
0.690792 0.5, 0.309208 0.5, 0.690792 0.5, 0.808708 0.808708,
|
|
599
|
+
0.5 0.999501, 0.690792 0.5, 0.5 0.999501, 0.191292 0.808708,
|
|
600
|
+
0.690792 0.5, 0.191292 0.808708, 0.5 0.000499517, 0.808708 0.191292,
|
|
601
|
+
0.690792 0.5, 0.5 0.000499517, 0.690792 0.5, 0.309208 0.5,
|
|
602
|
+
0.309208 0.5, 0.191292 0.191292, 0.9995 0.5, 0.808708 0.808708,
|
|
603
|
+
0.5 0.690792, 0.9995 0.5, 0.5 0.690792, 0.5 0.309208,
|
|
604
|
+
0.9995 0.5, 0.5 0.309208, 0.309208 0.5, 0.690792 0.5,
|
|
605
|
+
0.808708 0.808708, 0.309208 0.5, 0.808708 0.808708,
|
|
606
|
+
0.5 0.999501, 0.000499517 0.5, 0.5 0.309208, 0.000499517 0.5,
|
|
607
|
+
0.5 0.690792, 0.5 0.690792, 0.000499517 0.5, 0.5 0.690792,
|
|
608
|
+
0.191292 0.191292`,O=[20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,0,46,47,48,49,50,51,7,52,53,54,55,56,57,58,59,60,61,9,62,63,64,65,66,67,11,68,69,70,71,72,73,74,75,76,77,13,78,79,80,81,82,83,15,84,85,86,87,88,89,90,91,92,93,17,94,95,96,97,98,99,19,1,4,100,14,101,102,10,103,18,6,5,104,2,105,106,8,107,3,12,16],D=I.split(","),P=[];for(let H=0;H<O.length;H++){let V=O[H],B=Hp.parseFloats(D[V]);P.push({x:B[0],y:B[1]})}let N=new je(w,T,P);return N.key=`dodecahedron_${r}`,xr(N),N.boundingSphere={center:ht.zero(),radius:r},N}createMeshGeometry(r=this.radius){return $p.createMeshGeometry(r)}};$p=l([xv({tagName:Cv+"-"+"3d"+"-primitive-dodecahedron"})],$p);import{CustomElement as Oz,P as Pz,Watch as QA,PropertyConverters as eD}from"@pacem/pacem-core";var Ca=class extends Ft{static createMeshGeometry(r=1,e=8){let t=[],n=[],i=[],s=r,o=e,c=Oa*(360/o),d=o%2==0?o/2:(o-1)/2;t.push({x:0,y:s,z:0});for(let h=1;h<d;h++){let m=c*h,f=Math.cos(m),g=Math.sin(m),v=1-1*h/d;for(let b=0;b<o;b++){let _=c*b-Math.PI/2,E=Math.cos(_),C=Math.sin(_),k=s*g*E,w=s*f,T=s*g*C;t.push({x:k,y:w,z:T});let I=b==0?o-1:b-1,O=b==0?0:1-1*b/o,D=1-1*I/o;if(h==1)i.push(1+b),i.push(1+I),i.push(0),n.push({x:O,y:v}),n.push({x:D,y:v}),n.push({x:.5,y:1});else{i.push((h-1)*o+b+1),i.push((h-1)*o+I+1),i.push((h-2)*o+I+1),i.push((h-1)*o+b+1),i.push((h-2)*o+I+1),i.push((h-2)*o+b+1);let P=1-(h-1)/d;n.push({x:O,y:v}),n.push({x:D,y:v}),n.push({x:D,y:P}),n.push({x:O,y:v}),n.push({x:D,y:P}),n.push({x:O,y:P})}}}t.push({x:0,y:-s,z:0});let p=t.length-1;for(let h=0;h<o;h++){let m=d-2,f=h==0?o-1:h-1,g=h==0?0:1-1*h/o,v=1-1*f/o,b=1-(m+1)/d;i.push(p),i.push(m*o+1+f),i.push(m*o+1+h),n.push({x:.5,y:0}),n.push({x:v,y:b}),n.push({x:g,y:b})}let u=new je(t,i,n);return u.key=`sphere_${r}_s${e}`,xr(u),u}createDefaultGeometry(){return Ca.createMeshGeometry()}propertyChangedCallback(r,e,t,n){switch(super.propertyChangedCallback(r,e,t,n),r){case"radius":case"segments":this.geometry=Ca.createMeshGeometry(this.radius,this.segments);break}}};l([QA({emit:!1,converter:eD.Number})],Ca.prototype,"radius",2),l([QA({emit:!1,converter:eD.Number})],Ca.prototype,"segments",2),Ca=l([Oz({tagName:Pz+"-"+"3d"+"-primitive-sphere"})],Ca);import{CustomElement as Iz,P as $z,Watch as tx,PropertyConverters as rx}from"@pacem/pacem-core";var Oi=class extends Ft{static createMeshGeometry(r=1,e=.25,t=24,n=12){let i=[],s=[],o=[],c=Oa*(360/t),d=Oa*(360/n),p=r,u=e;for(let m=0;m<t;m++){let f=c*m-Math.PI/2,g=Math.sin(f),v=Math.cos(f);for(let b=0;b<n;b++){let _=d*b+Math.PI,E=Math.cos(_),C=p*v+u*E*v,k=u*Math.sin(_),w=p*g+u*E*g;i.push({x:C,y:k,z:w});let T=m>0?m-1:t-1,I=b>0?b-1:n-1,O=m==0?0:1-1*m/t,D=b>0?1*b/n:1,P=m>0?1-(m-1)/t:1/t,N=b>0?(b-1)/n:1-1/n;o.push(m*n+I),o.push(T*n+I),o.push(T*n+b),o.push(m*n+I),o.push(T*n+b),o.push(m*n+b),s.push({x:O,y:N}),s.push({x:P,y:N}),s.push({x:P,y:D}),s.push({x:O,y:N}),s.push({x:P,y:D}),s.push({x:O,y:D})}}let h=new je(i,o,s);return h.key=`torus_${r}x${e}_t${t}_s${n}`,xr(h),h}createDefaultGeometry(){return Oi.createMeshGeometry()}propertyChangedCallback(r,e,t,n){switch(super.propertyChangedCallback(r,e,t,n),r){case"radius":case"innerRadius":case"segments":case"sides":this.geometry=Oi.createMeshGeometry(this.radius,this.innerRadius,this.segments,this.sides);break}}};l([tx({emit:!1,converter:rx.Number})],Oi.prototype,"radius",2),l([tx({emit:!1,converter:rx.Number})],Oi.prototype,"innerRadius",2),l([tx({emit:!1,converter:rx.Number})],Oi.prototype,"segments",2),l([tx({emit:!1,converter:rx.Number})],Oi.prototype,"sides",2),Oi=l([Iz({tagName:$z+"-"+"3d"+"-primitive-torus"})],Oi);import{CustomEventUtils as Hz,Utils as L0}from"@pacem/pacem-core";import{Point as Bz}from"@pacem/pacem-foundation";function Vz(a,r){let e,t;if(Bz.isPoint(a))e=a.x,t=a.y;else{let{page:s}=Hz.getEventCoordinates(a),o={x:s.x-r.x,y:s.y-r.y};e=o.x,t=o.y}let n=e/r.width*2-1,i=t/r.height*-2+1;return{x:n,y:i}}var sl=class a{static isMeshGeometry(r){return"positions"in r&&L0.isArray(r.positions)&&"triangleIndices"in r&&L0.isArray(r.triangleIndices)}static isVector3D(r){return"x"in r&&typeof r.x=="number"&&"y"in r&&typeof r.y=="number"&&"z"in r&&typeof r.z=="number"}static isRgba(r){return"r"in r&&typeof r.r=="number"&&"g"in r&&typeof r.g=="number"&&"b"in r&&typeof r.b=="number"}static flattenVectorArray(r){let e=[];for(let t of r)a.isVector3D(t)?e.push(t.x,t.y,t.z):a.isRgba(t)?e.push(t.r,t.g,t.b,t.a??1):e.push(t.x,t.y);return e}static findCamera(r){return(r||[]).find(e=>Pr(e)&&!e.hide)}clipPixel(r,e){return e instanceof HTMLElement&&(e=L0.offsetRect(e)),Vz(r,e)}};import{CustomElement as Uz,P as zz,Watch as Gz,PropertyConverters as Fz,Utils as ke,CustomElementUtils as N0}from"@pacem/pacem-core";import{Colors as T0}from"@pacem/pacem-foundation";import{Geometry as tD}from"@pacem/pacem-numerical";function nx(a){return sl.flattenVectorArray(a)}var rD="0.152.2",Wz="0.147.0",ix={VERSION:rD,API_URI:`https://unpkg.com/three@${rD}/build/three.min.js`,ORBIT_URI:`https://unpkg.com/three@${Wz}/examples/js/controls/OrbitControls.js`,LOADERS:[],DEFAULT_MATERIAL:function(){return new THREE.MeshStandardMaterial({color:"#069",flatShading:!0})}};function jz(a,r,e,t=1.333){let n=new THREE.Box3;for(let m of e)n.expandByObject(m);let i=n.getSize(new THREE.Vector3),s=n.getCenter(new THREE.Vector3),c=Math.max(i.x,i.y,i.z)/(2*Math.atan(Math.PI*a.fov/360)),d=c/a.aspect,p=t*Math.max(c,d),u=!ke.isNull(r);var h;u&&(h=r.target.clone().sub(a.position).normalize().multiplyScalar(p),r.maxDistance=p*10,r.target.copy(s)),a.near=p/100,a.far=p*100,a.updateProjectionMatrix(),u&&(a.position.copy(r.target).sub(h),r.update())}function Yz(a){return[a.m11,a.m21,a.m31,a.offsetX,a.m12,a.m22,a.m32,a.offsetY,a.m13,a.m23,a.m33,a.offsetZ,a.m14,a.m24,a.m34,a.m44]}function Xz(a){let r=new THREE.BufferGeometry,e=nx(a.positions);if(r.setAttribute("position",new THREE.Float32BufferAttribute(e,3)),a instanceof je){ke.isNullOrEmpty(a.triangleIndices)||r.setIndex(a.triangleIndices);let t=nx(a.positions);r.setAttribute("position",new THREE.Float32BufferAttribute(t,3));let n=nx(a.textureCoordinates);if(r.setAttribute("uv",new THREE.Float32BufferAttribute(n,2)),ke.isNullOrEmpty(a.normals))r.computeVertexNormals();else{let i=nx(a.normals);r.setAttribute("normal",new THREE.Float32BufferAttribute(i,3))}}return r}function qz(a){var r;if(a.type==="spot"){let e=new THREE.SpotLight;e.target.position.set(a.target.x,a.target.y,a.target.z),r=e}else r=new THREE.PointLight;return r}function nD(a){if(ke.isNull(a))return null;let r={color:typeof a.color=="string"?a.color:T0.stringify(a.color),opacity:a.opacity??1,transparent:!0,wireframe:a.wireframe??!1,visible:a.visible??!0},e=ke.extend({},r,{wireframe:a.wireframe??!1}),t=n=>(a.map&&(n.map=new THREE.TextureLoader().load(a.map,i=>{n.needsUpdate=!0})),n);if(Cb(a))return t(new THREE.MeshStandardMaterial(ke.extend(e,{roughness:a.roughness,metalness:a.metalness,emissive:a.emissiveColor,flatShading:a.flatShading,refractionRatio:a.refractionRatio})));if(xb(a))return t(new THREE.MeshPhongMaterial(ke.extend(e,{shininess:a.shininess,emissive:a.emissiveColor,flatShading:a.flatShading,specular:a.specularColor,reflectivity:a.reflectivity,refractionRatio:a.refractionRatio})));if(_b(a))return t(new THREE.MeshLambertMaterial(ke.extend(e,{emissive:a.emissiveColor,reflectivity:a.reflectivity,refractionRatio:a.refractionRatio})));if(xl(a)){let n=a.dashArray&&a.dashArray[0]||null,i=a.dashArray&&a.dashArray.length>1&&a.dashArray[1]||n,s=ke.extend(r,{linecap:a.lineCap??"round",linejoin:a.lineJoin??"round",linewidth:a.lineWidth??1});return ke.isNullOrEmpty(a.dashArray)?new THREE.LineBasicMaterial(s):new THREE.LineDashedMaterial(ke.extend({dashSize:n,gapSize:i},s))}else return oi(a)?t(new THREE.MeshBasicMaterial(e)):null}function Kz(a,r,e){let t=e,n=[],i=nD(a);if(ke.isNull(i)||(i.side=THREE.FrontSide,n.push(i)),!ke.isNull(r))if(r==a)i.side=THREE.DoubleSide;else{let s=nD(r);ke.isNull(s)||(s.side=THREE.BackSide,n.push(s))}return t&&n.length>1?n:i}function iD(a){if(ke.isNullOrEmpty(a.content))throw new Error("Missing content.");return a.type?.toLowerCase()==="obj"?new THREE.OBJLoader().parse(a.content):new THREE.ObjectLoader().parse(a.content)}function Jz(a){return a instanceof _l?THREE.Line:THREE.Mesh}function sD(a){if(ke.isNullOrEmpty(a.geometry))return null;let r=Jz(a.geometry);return new r}function Ev(){return"THREE"in window}async function Zz(...a){let r=Date.now();var e=!1;do{e=Ev();for(let t of a)e&&=t();e||await new Promise(t=>setTimeout(t,500))}while(!e&&Date.now()-r<3e4);if(!e)throw new Error("The wait for THREE adapter initialization timed out.")}var Am=class extends yl{constructor(){super(...arguments);this._renderer=null;this._camera=null;this._scene=null;this._orbitCtrls=null;this._objects=new WeakMap;this._dict={};this._orbitControlsDelegate=e=>{};this._ensureAndRefresh=(e,t,n)=>{if(t.matrixAutoUpdate=!1,t.visible=!e.hide){if(Nn(e)){let s=t;if(e.flags.indexOf("geometry")>=0){s.geometry.dispose();let o=sD(e);o.constructor.name!==s.constructor.name&&(n.remove(t),delete this._dict[t.id],t=s=o),s.geometry=Xz(e.geometry)}if(e.flags.indexOf("material")>=0){if(ke.isArray(s.material))for(let o of s.material)o.dispose();else s.material.dispose();s.material=Kz(e.material)||ix.DEFAULT_MATERIAL()}}else if(e instanceof Gi&&(e.flags.indexOf("material")>=0||e.flags.indexOf("geometry")>=0))t.parent&&t.parent.remove(t),t=iD(e);else if(e instanceof Ts){if(e.flags.indexOf("children")>=0){for(let s=t.children.length-1;s>=0;s--){let o=t.children[s];t.remove(o)}for(let s of e.items)this._addOrUpdateItem(s,t)}}else if(e instanceof Ln){let s=t;e.flags.indexOf("light")>=0&&(s.color=new THREE.Color(e.color),s.intensity=e.intensity)}let i=e.position;if(_u(e)&&!ke.isNull(e.transformMatrix)&&(e.flags.indexOf("position")>=0||e.flags.indexOf("transform")>=0)){let s=tD.LinearAlgebra.Matrix3D.from(1,0,0,0,0,1,0,0,0,0,1,0,i.x,i.y,i.z,1),o=tD.LinearAlgebra.Matrix3D.multiply(e.transformMatrix,s);THREE.Matrix4.prototype.set.apply(t.matrix,Yz(o))}else e.flags.indexOf("position")>=0&&(t.position.set(i.x,i.y,i.z),t.updateMatrix())}return t.userData=e.tag,ke.isNull(n.getObjectById(t.id))&&(n.add(t),this._dict[t.id]=e),e.flags.splice(0),t}}_assertMonoStage(e){if(e!=this._3d&&!ke.isNull(this._3d))throw new Error("Stage mismatch.")}dispose(e){}snapshot(e,t,n,i){if(e!=this._3d)return Promise.resolve(null);let s=!ke.isNullOrEmpty(t),o=n??(s?"image/jpeg":null),c=i??(s?.9:null);return new Promise((d,p)=>{this.render(),ke.snapshotElement(this._stage,t,o,c).then(d)})}project(e,t){if(this._assertMonoStage(e),ke.isNull(this._camera)||ke.isNull(this._stage))return null;let n=this._stage,i=new THREE.Vector3(t.x,t.y,t.z),s=n.width,o=n.height,c=s/2,d=o/2,p=i.project(this._camera),u=p.x*c+c,h=-(p.y*d)+d;return{x:u,y:h}}zoomFit(e,...t){return this._assertMonoStage(e),new Promise((n,i)=>{let s=this._camera,o=this._objects,c=t.filter(d=>o.has(d)).map(d=>o.get(d));(ke.isNull(s)||ke.isNullOrEmpty(c))&&n(),jz(s,this._orbitCtrls,c),n()})}getScene(e){return this._assertMonoStage(e),this._scene}raycast(e,t,n,i){if(this._assertMonoStage(e),Ev()&&!ke.isNull(this._camera)){let s=this._camera,o=new THREE.Vector2(t.x/n.width*2-1,-(t.y/n.height)*2+1),c=new THREE.Raycaster;c.setFromCamera(o,s);let d=c.intersectObjects(this._scene.children,!0),p,u,h=0;for(;d.length>h&&(u=d[h++])&&(p=u.object);){if(this._dict[p.id].inert)continue;let f=u.point,g=f.x,v=f.y,b=f.z,_={x:g,y:v,z:b};i({object:this._dict[p.id],point:_});return}}i(null)}async initialize(e){if(!ke.isNull(this._stage))return this._stage;this._3d=e;let t=e.stage,n=this._stage=document.createElement("canvas");t.innerHTML="",t.appendChild(n),Ev()||(await N0.importjs(ix.API_URI),await Zz(),await Promise.all([N0.importjs(ix.ORBIT_URI)].concat(ix.LOADERS.map(c=>N0.importjs(c))))),this._scene=new THREE.Scene,this.invalidateSize(e);let i=this._stage.width,s=this._stage.height,o={canvas:n,antialias:!0,stencil:!1,alpha:e.transparent??!0};if(this._renderer=new THREE.WebGLRenderer(o),this._renderer.setSize(i,s),e.background&&!e.transparent){let c=e.background;typeof c=="string"&&(c=T0.parse(c));let d=new THREE.Color(c.r,c.g,c.b);this._renderer.setClearColor(d,c.a)}return this.orbit=e.orbit,n}_setCamera(e){this._camera=e,this.invalidateSize(this._3d),this._disposeOrbitControls(),this.orbit&&this._initOrbitControls()}propertyChangedCallback(e,t,n,i){super.propertyChangedCallback(e,t,n,i),e==="orbit"&&(n===!0?this._initOrbitControls():this._disposeOrbitControls())}_initOrbitControls(){let e=this._camera;if(ke.isNull(this._3d)||ke.isNull(e))return;(this._orbitCtrls=new THREE.OrbitControls(e,this._3d.stage)).addEventListener("change",this._orbitControlsDelegate)}_disposeOrbitControls(){let e=this._orbitCtrls;ke.isNull(e)||(e.removeEventListener("change",this._orbitControlsDelegate),e.dispose())}_updateRenderer(e,t=this._renderer){if(e.transparent)t.setClearAlpha(0);else if(e.background){let n=e.background;typeof n=="string"&&(n=T0.parse(n));let i=new THREE.Color(n.r,n.g,n.b);t.setClearColor(i,n.a)}else t.setClearColor(null)}invalidateSize(e,t=e.size){if(this._assertMonoStage(e),!Ev()||ke.isNull(t))return;let n=t.width,i=t.height;this._stage.width=n,this._stage.height=i;let s=this._camera;s instanceof THREE.PerspectiveCamera&&(s.aspect=n/i,s.updateProjectionMatrix()),this._renderer&&(this._renderer.setSize(n,i),this._updateRenderer(e))}removeItem(e,t){this._assertMonoStage(e);let n=this._objects,i=n.get(t);ke.isNull(i)||(this._scene.remove(i),delete this._dict[i.id],n.delete(t))}updateItem(e,t){this._assertMonoStage(e);let n=this._objects;if(!ke.isNull(t.parent)&&n.has(t.parent)){let i=n.get(t.parent);this._addOrUpdateItem(t,i)}else this._addOrUpdateItem(t)}addItem(e,t){this._assertMonoStage(e),this._addOrUpdateItem(t)}_addOrUpdateItem(e,t=this._scene){if(!(!Ev()||ke.isNull(t)))if(e instanceof ai)if(e instanceof Ns){var n;if(this._camera instanceof THREE.PerspectiveCamera)var n=this._camera;else n=new THREE.PerspectiveCamera;let s=new THREE.Vector3(e.lookAt.x,e.lookAt.y,e.lookAt.z);n.lookAt(s),n.position.set(e.position.x,e.position.y,e.position.z),n.fov=e.fov,n.aspect=e.aspect,n.near=e.near,n.far=e.far,this._setCamera(n);let o=this._orbitCtrls;!ke.isNull(o)&&o.object===n&&(o.target=s,o.update())}else if(e instanceof si){var i;if(this._camera instanceof THREE.OrthographicCamera)var i=this._camera;else i=new THREE.OrthographicCamera;let s=new THREE.Vector3(e.lookAt.x,e.lookAt.y,e.lookAt.z);i.lookAt(s),i.position.set(e.position.x,e.position.y,e.position.z),i.left=e.left,i.right=e.right,i.top=e.top,i.bottom=e.bottom,i.near=e.near,i.far=e.far,this._setCamera(i);let o=this._orbitCtrls;!ke.isNull(o)&&o.object===i&&(o.target=s,o.update())}else throw new Error(`Camera ${e} not supported.`);else if(this._objects.has(e)){let s=this._objects.get(e),o=this._ensureAndRefresh(e,s,t);o!=s&&this._objects.set(e,o)}else{let s=o=>{o&&(o=this._ensureAndRefresh(e,o,t),this._objects.set(e,o))};if(e instanceof Gi){let o=iD(e);s(o)}else if(e instanceof zi){let o=sD(e);s(o)}else if(e instanceof Ln){let o=qz(e);s(o)}else if(e instanceof Ts){let o=new THREE.Group;s(o)}}}render(){this._camera&&this._renderer.render(this._scene,this._camera)}};l([Gz({emit:!1,converter:Fz.Boolean})],Am.prototype,"orbit",2),Am=l([Uz({tagName:zz+"-3d-three-adapter"})],Am);import{CustomElementUtils as Cx,CustomElement as PD,P as ID,Watch as xx,PropertyConverters as ok,PropertyChangeEvent as lk,PropertyChangeEventName as AD,Debounce as _G,Utils as jc,Logging as xG,Components as CG}from"@pacem/pacem-core";import{Strings as EG}from"@pacem/pacem-foundation";import{Utils as Wt,P as mG,Logging as fG}from"@pacem/pacem-core";import{Colors as gG}from"@pacem/pacem-foundation";import{Geometry as vG}from"@pacem/pacem-numerical";var Ge="pacem-3d-";var Bp="color",sx="ambient",wv="lighting",Ea="VertexInput",ln="VertexOutput",Hc="InteractionData";import{Utils as Le}from"@pacem/pacem-core";var br=class{static create(r,e,t=""){let n=r.createBuffer({size:e.byteLength,label:t,usage:40,mappedAtCreation:!0});return new Float32Array(n.getMappedRange()).set(e),n.unmap(),n}static createUniform(r,e,t=""){return r.createBuffer({size:e.byteLength,label:t,usage:72})}static createStorage(r,e,t=""){return r.createBuffer({size:e.byteLength,label:t,usage:136})}static createIndexed(r,e,t=""){let n=r.createBuffer({size:e.byteLength,label:t,usage:24,mappedAtCreation:!0});return new Uint16Array(n.getMappedRange()).set(e),n.unmap(),n}},Vp=class{static createVertex(r=0,e=3,...t){let n=[],i=0,s=0;for(let o of[e].concat(t))n.push({shaderLocation:r+s,offset:i*Float32Array.BYTES_PER_ELEMENT,format:`float32x${o}`}),i+=o,s++;return{arrayStride:i*Float32Array.BYTES_PER_ELEMENT,attributes:n,stepMode:"vertex"}}};import{Utils as $0}from"@pacem/pacem-core";import{Colors as iG}from"@pacem/pacem-foundation";import{Utils as eG}from"@pacem/pacem-core";var aD={outputNormalLocation:0,outputVertexLocation:1,outputUvLocation:2,outputVertexIndexLocation:3,outputRayIndexLocation:4,outputInstanceIndexLocation:5,storageMaterialGroupIndex:2,storageMaterialBindingIndex:0};function oD(a=[]){return a.join(`\r
|
|
609
|
+
`)}function tG(a=[]){let r="";for(let e of a){let t=e.trim();t.endsWith(";")?r+=t+`\r
|
|
610
|
+
`:r+=`${Bp} = ${t};\r
|
|
611
|
+
`}return r}function lD(a={},r=aD){let e=eG.extend({},aD,r),t=oD(a.definitions),n=oD(a.bindings),i=tG(a.modifiers),s=Bp,o=wv,c=sx;return`// definitions
|
|
612
|
+
|
|
613
|
+
${t}
|
|
614
|
+
|
|
615
|
+
// bindings
|
|
616
|
+
@group(${e.storageMaterialGroupIndex}) @binding(${e.storageMaterialBindingIndex}) var<storage, read> diffuseColor: vec4f;
|
|
617
|
+
${n}
|
|
618
|
+
|
|
619
|
+
const empty = vec4f(0,0,0,0);
|
|
620
|
+
const white = vec4f(1,1,1,1);
|
|
621
|
+
|
|
622
|
+
@fragment fn main (
|
|
623
|
+
@builtin(position) position: vec4f, // clip-space position
|
|
624
|
+
@location(${e.outputNormalLocation}) normal: vec3f, // world-space normal
|
|
625
|
+
@location(${e.outputVertexLocation}) vertex: vec3f, // world-space position
|
|
626
|
+
@location(${e.outputUvLocation}) uv: vec2f,
|
|
627
|
+
@location(${e.outputVertexIndexLocation}) @interpolate(flat) index: u32, // vertex index,
|
|
628
|
+
@location(${e.outputRayIndexLocation}) ray: vec3f, // ray (eye-to-vertex) vector
|
|
629
|
+
@location(${e.outputInstanceIndexLocation}) @interpolate(flat) instance : u32, // instance index
|
|
630
|
+
) -> @location(0) vec4f {
|
|
631
|
+
var ${s} = diffuseColor;
|
|
632
|
+
var ${c}: vec4f = empty;
|
|
633
|
+
var ${o}: vec4f = empty;
|
|
634
|
+
|
|
635
|
+
// modifiers
|
|
636
|
+
${i}
|
|
637
|
+
|
|
638
|
+
${o} = select(white, ${o}, ${o}.a > 0);
|
|
639
|
+
return ${s} * ${o} + ${c};
|
|
640
|
+
}`}import{Utils as rG}from"@pacem/pacem-core";var cD={outputInstanceIndexLocation:0,outputVertexIndexLocation:1,storageMaterialGroupIndex:3,storageMaterialBindingIndex:0};function dD(a=[]){return a.join(`\r
|
|
641
|
+
`)}function nG(a=[]){let r="";for(let e of a){let t=e.trim();t.endsWith(";")?r+=t+`\r
|
|
642
|
+
`:r+=`output = ${t};\r
|
|
643
|
+
`}return r}function pD(a={},r=cD){let e=rG.extend({},cD,r),t=dD(a.definitions),n=dD(a.bindings),i=nG(a.modifiers);return`// definitions
|
|
644
|
+
${t}
|
|
645
|
+
|
|
646
|
+
// bindings
|
|
647
|
+
@group(${r.storageMaterialGroupIndex}) @binding(${r.storageMaterialBindingIndex}) var<storage, read> vertexColors: array<vec4f>;
|
|
648
|
+
${n}
|
|
649
|
+
|
|
650
|
+
fn getVertexColor(index: u32) -> vec4f {
|
|
651
|
+
let numColors = arrayLength(&vertexColors);
|
|
652
|
+
let vertexColorIndex = index % numColors;
|
|
653
|
+
return vertexColors[vertexColorIndex];
|
|
654
|
+
}
|
|
655
|
+
|
|
656
|
+
@fragment fn main (
|
|
657
|
+
@builtin(position) position: vec4f, // clip-space position
|
|
658
|
+
@location(${e.outputInstanceIndexLocation}) @interpolate(flat) instance: u32, // instance index
|
|
659
|
+
@location(${e.outputVertexIndexLocation}) @interpolate(flat) index: u32 // vertex index
|
|
660
|
+
) -> @location(0) vec4f {
|
|
661
|
+
var output = getVertexColor(index);
|
|
662
|
+
|
|
663
|
+
// modifiers
|
|
664
|
+
${i}
|
|
665
|
+
|
|
666
|
+
return output;
|
|
667
|
+
}`}var ax=class{static create(r){if(yb(r))return new Mv(r);if(xl(r))return new Sv(r);throw new TypeError(`Material type '${r.shader}' not supported.`)}},sG={},ox=class{constructor(r){if($0.isNull(this.#e=r))throw new ReferenceError("Null material provided.")}#e;get material(){return this.#e}get wgsl(){return sG}buffer({device:r},e=Ge+"material-"+this.shader+"-buffer"){let{r:t,g:n,b:i,a:s}=this._diffuseColor(),o=new Float32Array([t,n,i,s]);return{buffer:br.createStorage(r,o,e),value:o,version:performance.now()}}_diffuseColor(){let{visible:r,opacity:e,color:t}=this.material;if(!(r??!0))return{r:0,g:0,b:0,a:0};let n=typeof t=="string"?iG.parse(t):t??{r:1,g:1,b:1,a:1};return e>=0&&e<=1?$0.extend(n,{a:n.a*e}):n}},Mv=class extends ox{get shader(){return"basic"}constructor(r){if(super(r),r.shader!=this.shader)throw new TypeError("Basic material expected.")}texture({device:r},e="texture"){let t=this.material;if(e==="texture"&&!$0.isNull(t.texture)){let n=t.texture;return{texture:r.createTexture({format:"rgba8unorm",usage:22,size:[n.width,n.height]}),source:n}}return null}static{this.fragment=lD}},Sv=class extends ox{get shader(){return"line"}constructor(r){if(super(r),r.shader!=this.shader)throw new TypeError("Line material expected.")}buffer(r,e){if(e==="line"){let{device:t,canvas:n}=r,i=this.material,s=new Float32Array([n.clientWidth,n.clientHeight,i.lineWidth/2]);return{buffer:br.createUniform(t,s,Ge+"line-"+this.shader+"-buffer"),value:s,version:performance.now()}}else return super.buffer(r)}texture(r){return null}static{this.fragment=pD}};import{Utils as lx}from"@pacem/pacem-core";var aG=["input","data"];function H0(a){typeof a!="string"&&(a=a(...aG));let r=new RegExp(`fn\\s+(\\w+)\\s*\\(([^)]*)\\)\\s*->\\s*(${Ea}|${ln})\\s*{((.|\\n)+)}\\s*$`),e=a.match(r);if(e){let t=e[1],n=e[2].split(",").map(s=>{let o=s.split(":");return{name:o[0].trim(),type:o[1].trim()}});if(n.length!==2||n[0].type!==e[3]||n[1].type!==Hc)throw new Error(`Invalid modifier function. Invalid signature types (arg1: ${n[0]?.type}, arg2: ${n[1]?.type})`);let i=e[4].trim();return{name:t,args:n.map(s=>s.name),body:i}}else throw new Error(`Invalid modifier function. Must be a valid WGSL function with the signature: fn name(arg1: ${Ea}|${ln}, arg2: ${Hc}) -> ${Ea}|${ln}`)}var cx={outputNormalLocation:0,outputVertexLocation:1,outputUvLocation:2,outputVertexIndexLocation:3,outputInstanceIndexLocation:5,outputRayLocation:4,inputPositionLocation:0,inputNormalLocation:1,inputUvLocation:2,uniformViewBindingIndex:0,uniformViewGroupIndex:0,uniformWorldBindingIndex:0,uniformWorldGroupIndex:1,uniformInteractionBindingIndex:1,uniformInteractionGroupIndex:0};function hD(a=cx){a!=cx&&(a=lx.extend({},cx,a));let r=a.inputModifier,e="vertexInput",t="";if(!lx.isNullOrEmpty(r)){let{name:c,args:[d,p],body:u}=H0(r);e=`${c}(vertexInput, interaction)`,t=`fn ${c} (${d}: ${Ea}, ${p}: ${Hc}) -> ${Ea} {
|
|
668
|
+
${u}
|
|
669
|
+
}`}let n=a.outputModifier,i="output",s="";if(!lx.isNullOrEmpty(n)){let{name:c,args:[d,p],body:u}=H0(n);i=`${c}(output, interaction)`,s=`fn ${c} (${d}: ${Ea}, ${p}: ${Hc}) -> ${ln} {
|
|
670
|
+
${u}
|
|
671
|
+
}`}let o=lx.extend({},cx,a);return`struct ${ln} {
|
|
672
|
+
@builtin(position) position : vec4f, // clip space position
|
|
673
|
+
@location(${o.outputNormalLocation}) normal: vec3f, // world space normal
|
|
674
|
+
@location(${o.outputVertexLocation}) vertex : vec3f, // world space position
|
|
675
|
+
@location(${o.outputUvLocation}) uv : vec2f, // texture coordinates
|
|
676
|
+
@location(${o.outputVertexIndexLocation}) @interpolate(flat) index : u32, // vertex index
|
|
677
|
+
@location(${o.outputRayLocation}) ray : vec3f, // eye-to-point vector in world space
|
|
678
|
+
@location(${o.outputInstanceIndexLocation}) @interpolate(flat) instance : u32, // instance index
|
|
679
|
+
}
|
|
680
|
+
|
|
681
|
+
struct ${Ea} {
|
|
682
|
+
@location(${o.inputPositionLocation}) position: vec3f,
|
|
683
|
+
@location(${o.inputNormalLocation}) normal: vec3f,
|
|
684
|
+
@location(${o.inputUvLocation}) uv: vec2f,
|
|
685
|
+
@builtin(vertex_index) index: u32,
|
|
686
|
+
@builtin(instance_index) instance: u32,
|
|
687
|
+
}
|
|
688
|
+
|
|
689
|
+
struct Transforms {
|
|
690
|
+
world: mat4x4f,
|
|
691
|
+
normal: mat3x3f,
|
|
692
|
+
}
|
|
693
|
+
|
|
694
|
+
struct Camera {
|
|
695
|
+
view: mat4x4f,
|
|
696
|
+
projection: mat4x4f,
|
|
697
|
+
position: vec3f,
|
|
698
|
+
}
|
|
699
|
+
|
|
700
|
+
struct ${Hc} {
|
|
701
|
+
// mouse coordinatges in NDC space ([-1,1], [-1,1])
|
|
702
|
+
cursor: vec2f,
|
|
703
|
+
// canvas size in pixels
|
|
704
|
+
resolution: vec2f,
|
|
705
|
+
// some phase timer (e.g. time since mouse down, or time since last click, etc.)
|
|
706
|
+
time: f32,
|
|
707
|
+
}
|
|
708
|
+
|
|
709
|
+
${t}
|
|
710
|
+
|
|
711
|
+
${s}
|
|
712
|
+
|
|
713
|
+
@group(${o.uniformWorldGroupIndex}) @binding(${o.uniformWorldBindingIndex}) var<uniform> transforms: Transforms;
|
|
714
|
+
@group(${o.uniformViewGroupIndex}) @binding(${o.uniformViewBindingIndex}) var<uniform> camera: Camera;
|
|
715
|
+
@group(${o.uniformInteractionGroupIndex}) @binding(${o.uniformInteractionBindingIndex}) var<uniform> interaction: ${Hc};
|
|
716
|
+
|
|
717
|
+
@vertex fn main(vertexInput: ${Ea}) -> ${ln} {
|
|
718
|
+
let input = ${e};
|
|
719
|
+
let position4 = vec4f(input.position, 1.0);
|
|
720
|
+
let worldTransform = transforms.world;
|
|
721
|
+
let viewProjectionTransform = camera.projection;
|
|
722
|
+
let worldViewProjectionTransform = viewProjectionTransform * worldTransform;
|
|
723
|
+
let worldPosition = (worldTransform * position4).xyz;
|
|
724
|
+
let output = ${ln}(
|
|
725
|
+
worldViewProjectionTransform * position4,
|
|
726
|
+
transforms.normal * input.normal,
|
|
727
|
+
worldPosition,
|
|
728
|
+
input.uv,
|
|
729
|
+
input.index,
|
|
730
|
+
normalize(worldPosition - camera.position),
|
|
731
|
+
input.instance
|
|
732
|
+
);
|
|
733
|
+
return ${i};
|
|
734
|
+
}`}import{Utils as mD}from"@pacem/pacem-core";var hx={inputPositionLocation:0,outputInstanceIndexLocation:0,outputVertexIndexLocation:1,storagePositionsGroupIndex:2,storagePositionsBindingIndex:0,uniformDimensionsGroupIndex:2,uniformDimensionsBindingIndex:1,uniformViewGroupIndex:0,uniformViewBindingIndex:0,uniformWorldGroupIndex:1,uniformWorldBindingIndex:0};function fD(a){return`struct ${ln} {
|
|
735
|
+
@builtin(position) position : vec4f, // clip space position
|
|
736
|
+
@location(${a.outputInstanceIndexLocation}) @interpolate(flat) instance : u32, // instance index
|
|
737
|
+
@location(${a.outputVertexIndexLocation}) @interpolate(flat) index : u32, // vertex index
|
|
738
|
+
}`}function gD(a=hx){let r=mD.extend({},hx,a);return`${fD(r)}
|
|
739
|
+
|
|
740
|
+
struct Transforms {
|
|
741
|
+
world: mat4x4f,
|
|
742
|
+
normal: mat3x3f,
|
|
743
|
+
}
|
|
744
|
+
|
|
745
|
+
struct Camera {
|
|
746
|
+
view: mat4x4f,
|
|
747
|
+
projection: mat4x4f,
|
|
748
|
+
position: vec3f
|
|
749
|
+
}
|
|
750
|
+
|
|
751
|
+
@group(${r.uniformWorldGroupIndex}) @binding(${r.uniformWorldBindingIndex}) var<uniform> transforms: Transforms;
|
|
752
|
+
@group(${r.uniformViewGroupIndex}) @binding(${r.uniformViewBindingIndex}) var<uniform> camera: Camera;
|
|
753
|
+
@group(${r.storagePositionsGroupIndex}) @binding(${r.storagePositionsBindingIndex}) var<storage, read> positions: array<f32>;
|
|
754
|
+
|
|
755
|
+
@vertex fn main(@builtin(instance_index) instance: u32,
|
|
756
|
+
@builtin(vertex_index) index: u32) -> ${ln} {
|
|
757
|
+
|
|
758
|
+
let x = positions[3u * index + 0u];
|
|
759
|
+
let y = positions[3u * index + 1u];
|
|
760
|
+
let z = positions[3u * index + 2u];
|
|
761
|
+
let position4 = vec4f(x, y, z, 1.0);
|
|
762
|
+
let worldTransform = transforms.world;
|
|
763
|
+
let viewProjectionTransform = camera.projection;
|
|
764
|
+
let worldViewProjectionTransform = viewProjectionTransform * worldTransform;
|
|
765
|
+
let worldPosition = (worldTransform * position4).xyz;
|
|
766
|
+
return ${ln}(
|
|
767
|
+
worldViewProjectionTransform * position4,
|
|
768
|
+
instance,
|
|
769
|
+
index);
|
|
770
|
+
}`}function vD(a=hx){let r=mD.extend({},hx,a);return`${fD(r)}
|
|
771
|
+
|
|
772
|
+
struct Transforms {
|
|
773
|
+
world: mat4x4f,
|
|
774
|
+
normal: mat3x3f,
|
|
775
|
+
}
|
|
776
|
+
|
|
777
|
+
struct Camera {
|
|
778
|
+
view: mat4x4f,
|
|
779
|
+
projection: mat4x4f,
|
|
780
|
+
position: vec3f
|
|
781
|
+
}
|
|
782
|
+
|
|
783
|
+
struct Pixels {
|
|
784
|
+
viewportWidth: f32,
|
|
785
|
+
viewportHeight: f32,
|
|
786
|
+
halfLineWidth: f32
|
|
787
|
+
}
|
|
788
|
+
|
|
789
|
+
@group(${r.uniformWorldGroupIndex}) @binding(${r.uniformWorldBindingIndex}) var<uniform> transforms: Transforms;
|
|
790
|
+
@group(${r.uniformViewGroupIndex}) @binding(${r.uniformViewBindingIndex}) var<uniform> camera: Camera;
|
|
791
|
+
@group(${r.storagePositionsGroupIndex}) @binding(${r.storagePositionsBindingIndex}) var<storage, read> positions: array<f32>;
|
|
792
|
+
@group(${r.uniformDimensionsGroupIndex}) @binding(${r.uniformDimensionsBindingIndex}) var<uniform> dimensions: Pixels;
|
|
793
|
+
|
|
794
|
+
fn computeClipPosition(index: u32) -> vec4f {
|
|
795
|
+
let x = positions[3u * index + 0u];
|
|
796
|
+
let y = positions[3u * index + 1u];
|
|
797
|
+
let z = positions[3u * index + 2u];
|
|
798
|
+
let position4 = vec4f(x, y, z, 1.0);
|
|
799
|
+
let worldTransform = transforms.world;
|
|
800
|
+
let viewProjectionTransform = camera.projection;
|
|
801
|
+
let worldViewProjectionTransform = viewProjectionTransform * worldTransform;
|
|
802
|
+
return worldViewProjectionTransform * position4;
|
|
803
|
+
}
|
|
804
|
+
|
|
805
|
+
fn computeOffsetPosition(p0: vec4f, p1: vec4f, index: u32) -> vec4f {
|
|
806
|
+
|
|
807
|
+
let viewportSize = vec2f(dimensions.viewportWidth, dimensions.viewportHeight);
|
|
808
|
+
let normalizedSize = normalize(viewportSize);
|
|
809
|
+
let halfThickness = dimensions.halfLineWidth / dimensions.viewportWidth;
|
|
810
|
+
let p0ndc = p0.xyz / p0.w;
|
|
811
|
+
let p1ndc = p1.xyz / p1.w;
|
|
812
|
+
let dir = normalize((p1ndc - p0ndc).xy);
|
|
813
|
+
let offsetX = halfThickness * 2.0 / normalizedSize.x;
|
|
814
|
+
let offsetY = halfThickness * 2.0 / normalizedSize.y;
|
|
815
|
+
|
|
816
|
+
// perp
|
|
817
|
+
let perp0 = vec2f(-dir.y * offsetX, dir.x * offsetY);
|
|
818
|
+
let perp1 = perp0;
|
|
819
|
+
|
|
820
|
+
/*
|
|
821
|
+
|
|
822
|
+
position0-0 -----*----- position0-1
|
|
823
|
+
|\\ |
|
|
824
|
+
| \\ |
|
|
825
|
+
| \\ |
|
|
826
|
+
| \\ |
|
|
827
|
+
| \\ |
|
|
828
|
+
| \\ |
|
|
829
|
+
| \\ |
|
|
830
|
+
| \\|
|
|
831
|
+
position1-0 -----*----- position1-1
|
|
832
|
+
|
|
833
|
+
indexes:
|
|
834
|
+
------------
|
|
835
|
+
p0-0 -> 0, 3
|
|
836
|
+
p0-1 -> 5
|
|
837
|
+
p1-0 -> 1
|
|
838
|
+
p1-1 -> 2, 4
|
|
839
|
+
*/
|
|
840
|
+
|
|
841
|
+
var outPos: vec2f;
|
|
842
|
+
var w = p0.w;
|
|
843
|
+
var z = p0.z;
|
|
844
|
+
if (index == 0 || index == 3){
|
|
845
|
+
outPos = p0ndc.xy - perp0;
|
|
846
|
+
}
|
|
847
|
+
else if (index == 1){
|
|
848
|
+
outPos = p1ndc.xy - perp1;
|
|
849
|
+
w = p1.w;
|
|
850
|
+
z = p1.z;
|
|
851
|
+
}
|
|
852
|
+
else if (index == 5){
|
|
853
|
+
outPos = p0ndc.xy + perp0;
|
|
854
|
+
}
|
|
855
|
+
else { //if (index == 2 || index == 4)
|
|
856
|
+
outPos = p1ndc.xy + perp1;
|
|
857
|
+
w = p1.w;
|
|
858
|
+
z = p1.z;
|
|
859
|
+
}
|
|
860
|
+
|
|
861
|
+
// return vec4f(outPos , 0, 1.0);
|
|
862
|
+
return vec4f(outPos * w, z, w);
|
|
863
|
+
}
|
|
864
|
+
|
|
865
|
+
@vertex fn main(@builtin(instance_index) instance: u32,
|
|
866
|
+
@builtin(vertex_index) index: u32) -> ${ln} {
|
|
867
|
+
|
|
868
|
+
// vertex index starting at 1
|
|
869
|
+
let position0 = computeClipPosition(instance);
|
|
870
|
+
let position1 = computeClipPosition(instance + 1);
|
|
871
|
+
|
|
872
|
+
// apply offset
|
|
873
|
+
let position = computeOffsetPosition(position0, position1, index);
|
|
874
|
+
|
|
875
|
+
return ${ln}(
|
|
876
|
+
position,
|
|
877
|
+
instance,
|
|
878
|
+
index
|
|
879
|
+
);
|
|
880
|
+
}`}function V0(a=2){return`struct ColorPicker {
|
|
881
|
+
id: u32,
|
|
882
|
+
};
|
|
883
|
+
|
|
884
|
+
@group(${a}) @binding(0) var<uniform> colorPicker: ColorPicker;
|
|
885
|
+
|
|
886
|
+
@fragment
|
|
887
|
+
fn main(@builtin(position) position: vec4f) -> @location(0) u32 {
|
|
888
|
+
return colorPicker.id;
|
|
889
|
+
}
|
|
890
|
+
`}import{Utils as U0}from"@pacem/pacem-core";var bD={uv:"uv"};function yD(a=bD,r,e=1){let t=U0.uniqueCode(),n=`sampler_${t}`,i=`tex_${t}`,s=U0.extend({},bD,a),o=s.inputColor,c=s.outputColors;if(U0.isNullOrEmpty(o))throw new Error("Must provide either input and output vertex color parameter names.");let d=c?c.map((p,u)=>u===0?`${p} = textureSample(${i}, ${n}, ${s.uv}) * ${o};`:`${p} = ${c[0]};`):[`textureSample(${i}, ${n}, ${s.uv}) * ${o}`];return{bindings:[`@group(${r}) @binding(${e}) var ${n}: sampler;`,`@group(${r}) @binding(${e+1}) var ${i}: texture_2d<f32>;`],modifiers:d}}import{Utils as z0}from"@pacem/pacem-core";var oG={normal:"normal",inputColor:"white"};function _D(a,r,e){let n=`directional_${z0.uniqueCode()}`,i=z0.extend({},oG,a),s=i.inputColor,o=i.outputColor,c=i.normal??"normal";if(z0.isNullOrEmpty(s))throw new Error("Must provide input vertex color parameter name.");return{definitions:[`struct DirectionalLight {
|
|
891
|
+
color: vec4f,
|
|
892
|
+
direction: vec3f,
|
|
893
|
+
intensity: f32
|
|
894
|
+
}`,`fn computeDirectional(normal: vec3f, color: vec4f, light: DirectionalLight) -> vec4f {
|
|
895
|
+
let n = normalize(normal);
|
|
896
|
+
let d = normalize(light.direction);
|
|
897
|
+
let factor = light.intensity * .5 * (1.0 + dot(n, -d));
|
|
898
|
+
let output = color.rgb * light.color.rgb * factor;
|
|
899
|
+
return vec4f(output, color.a);
|
|
900
|
+
}`],bindings:[`@group(${r}) @binding(${e}) var<uniform> ${n}: DirectionalLight;`],modifiers:o?[`${o} += computeDirectional(${c}, ${s}, ${n});`]:[`computeDirectional(${c}, ${s}, ${n})`]}}import{Utils as G0}from"@pacem/pacem-core";var lG={normal:"normal",position:"vertex",ray:"ray",inputColor:"white",specularColor:"empty",shininess:"0"};function xD(a,r,e){let n=`omni_${G0.uniqueCode()}`,i=G0.extend({},lG,a),s=i.inputColor,o=i.outputColor,c=i.normal,d=i.ray,p=i.position,u=i.shininess,h=i.specularColor;if(G0.isNullOrEmpty(s))throw new Error("Must provide input vertex color parameter name.");return{definitions:[`struct OmniLight {
|
|
901
|
+
color: vec4f,
|
|
902
|
+
position: vec3f,
|
|
903
|
+
intensity: f32
|
|
904
|
+
}`,`fn computeOmni(position: vec3f, normal: vec3f, ray: vec3f, color: vec4f, specularColor: vec4f, shininess: f32, light: OmniLight) -> vec4f {
|
|
905
|
+
|
|
906
|
+
// color
|
|
907
|
+
let n = normalize(normal);
|
|
908
|
+
let d = normalize(position - light.position);
|
|
909
|
+
let factor = light.intensity * .5 * (1.0 + dot(n, -d));
|
|
910
|
+
|
|
911
|
+
// specular
|
|
912
|
+
let r = normalize(ray);
|
|
913
|
+
let halfVector = normalize(d + r);
|
|
914
|
+
let specular = specularColor.rgb * shininess * dot(n, -halfVector);
|
|
915
|
+
|
|
916
|
+
let output = color.rgb * light.color.rgb * factor + specular;
|
|
917
|
+
return vec4f(output, color.a);
|
|
918
|
+
}`],bindings:[`@group(${r}) @binding(${e}) var<uniform> ${n}: OmniLight;`],modifiers:o?[`${o} += computeOmni(${p}, ${c}, ${d}, ${s}, ${h}, ${u}, ${n});`]:[`computeOmni(${p}, ${c}, ${d}, ${s}, ${h}, ${u}, ${n})`]}}import{Utils as F0}from"@pacem/pacem-core";function CD(a,r,e){let n=`ambient_${F0.uniqueCode()}`,i=a.inputColor,s=a.outputColor;if(F0.isNullOrEmpty(i)||F0.isNullOrEmpty(s))throw new Error("Must provide either input and output vertex color parameter names.");return{definitions:[`struct AmbientLight {
|
|
919
|
+
color: vec4f,
|
|
920
|
+
intensity: f32
|
|
921
|
+
}`,`fn computeAmbient(color: vec4f, light: AmbientLight) -> vec4f {
|
|
922
|
+
return vec4f(light.intensity * color.rgb * light.color.rgb, color.a);
|
|
923
|
+
}`],bindings:[`@group(${r}) @binding(${e}) var<uniform> ${n}: AmbientLight;`],modifiers:[`${s} = computeAmbient(${i}, ${n});`]}}import{Utils as Me}from"@pacem/pacem-core";import{Colors as X0}from"@pacem/pacem-foundation";import{Geometry as SD}from"@pacem/pacem-numerical";import{Geometry as ED}from"@pacem/pacem-numerical";var Pi=ED.LinearAlgebra.Vector3D,Y0=ED.LinearAlgebra.Matrix3D,wD={width:1,height:1},fx=class{static create(r){if(gb(r))return new j0(r);if(vb(r))return new W0(r);throw new TypeError(`Camera type '${r.type}' not supported.`)}};function kD(a,r,e){let t=Pi.subtract(r,a),n=Pi.cross(e,t),i=Pi.cross(t,n);Pi.normalize(n),Pi.normalize(t),Pi.normalize(i);let s=-Pi.dot(n,a),o=-Pi.dot(i,a),c=-Pi.dot(t,a);return Y0.from(n.x,i.x,t.x,0,n.y,i.y,t.y,0,n.z,i.z,t.z,0,s,o,c,1)}function MD(a,r){if(a<=0)throw new RangeError("Near plane distance must be positive.");if(r<=a)throw new RangeError("Far plane distance must be greater than near plane distance.")}function cG(a=120,r=1,e=.1,t=1e3){MD(e,t);let n=Math.tan(.5*Math.PI*(1-a/180)),i=n/r,s=Number.isFinite(t),o=s?t/(e-t):-1,c=s?t*e/(e-t):-e;return Y0.from(i,0,0,0,0,n,0,0,0,0,o,-1,0,0,c,0)}function dG(a,r,e,t,n=.1,i=1e3){return MD(n,i),Y0.from(2/(r-a),0,0,0,0,2/(e-t),0,0,0,0,1/(n-i),0,(a+r)/(a-r),(e+t)/(t-e),n/(n-i),1)}var W0=class a{constructor(r){this._camera=r}static view(r){return kD(r.position,r.lookAt,r.up)}static projection(r,e=wD){let t=r.position,n=r.lookAt,i=Pi.subtract(n,t);Pi.normalize(i);let s=Pi.dot(i,t),{height:o,width:c}=e,d=c/o,p=.5*s,u=p*d,h=p,m=r.top*h,f=r.bottom*h,g=r.right*u,v=r.left*u;return dG(v,g,m,f,r.near,r.far)}view(){return a.view(this._camera)}projection(r){return a.projection(this._camera,r)}},j0=class a{constructor(r){this._camera=r}static view(r){return kD(r.position,r.lookAt,r.up)}static projection(r,e=wD){let t=e.width/e.height/r.aspectRatio;return cG(r.fov,t,r.near,r.far)}view(){return a.view(this._camera)}projection(r){return a.projection(this._camera,r)}};var q0=SD.LinearAlgebra.Vector3D,Qn=SD.LinearAlgebra.Matrix3D;function Pm(a,r){throw typeof r=="function"&&(r=r.name),new RangeError(`Buffer '${a}' not available for ${r}.`)}function LD(a,r,...e){if(a.stage??=r?.item.stage,cd(a))return a.key??="group_"+Me.uniqueCode(),new K0(a,r,...e);if(Nn(a))return a.key??="mesh_"+Me.uniqueCode(),new Q0(a,r,...e);if(Pr(a))return a.key??="camera_"+Me.uniqueCode(),new J0(a);if(Rs(a))return a.key??="light_"+a.type+"_"+Me.uniqueCode(),new ek(a);throw new Error("Renderable is not supported.")}var gx=class{constructor(r){this._set=r}get items(){return this._set}loop(r){let{meshes:e,cameras:t,groups:n,lights:i}=this._set,s=t[0],o=!1,c=!1;for(let d of e)d.disposed||!r(d,s,i)||(mt.clearFlags(d),o||(mt.clearFlags(s),o=!0),c||(i.forEach(u=>mt.clearFlags(u)),c=!0));for(let d of n)mt.clearFlags(d)}},Dm=class{static create(r){if(df(r))return r.key??="geometry_"+Me.uniqueCode(),new Nv(r);if(oi(r))return new Tv(r);if(bb(r))return new Z0(r);throw new Error("Object is not supported.")}},mt=class a{static create(r,...e){return LD(r,null,...e)}static clearFlags(r,e=!1){if(r.item.flags.splice(0),e){let t=r;Me.isNull(t.parent)||a.clearFlags(t.parent,!0)}}static allFlags(r){let e=r,t=e.parent,n=Me.isNull(t)?[]:a.allFlags(t);return e.item.flags.union(n)}},Rm=class{#e;constructor(r){this.#e=r}get item(){return this.#e}#t=!1;lock(){this.#t=!0}unlock(){this.#t=!1;let r=this.#r;for(;r.length>0;){let e=r.shift();this._destroyUnsafe(e)}}#r=[];_destroyUnsafe(r){"texture"in r?r.texture.destroy():"buffer"in r&&r.buffer.destroy()}destroySafely(...r){for(let e of Array.from(r).concat(...this.#r.splice(0)))e&&(this.#t?this.#r.push(e):this._destroyUnsafe(e))}#n=!1;destroy(){this.dispose(),this.#n=!0}get disposed(){return this.#n}},Om=class extends Rm{constructor(r,e){super(r),this.#t=e,this.#e=Me.uniqueId()%4294967295}#e;#t;#r=new Map;get parent(){return this.#t}get id(){return this.#e}allFlags(){let r=this.parent;return this.item.flags.union(r?.allFlags()??[])}buildParentWorldTransform(){let r=Qn.identity(),e=this;for(;!Me.isNull(e.parent);){let t=e.parent.item,n=Qn.translate(t.transformMatrix??Qn.identity(),t.position??q0.zero());r=Qn.multiply(r,n),e=e.parent}return r}buildWorldTransform(){let r=Qn.translate(this.item.transformMatrix??Qn.identity(),this.item.position??q0.zero()),e=this.buildParentWorldTransform();return Qn.multiply(r,e)}#n=new Map;version(r){return this.#n.get(r)??0}buffer(r,e){if(e==="u32id"){let n=this.#r,{pipeline:i,device:s}=r;if(n.has(i))return Me.extend({fresh:!1},n.get(i));let o=new Uint32Array([this.id]),c=br.createUniform(s,o,Ge+"u32id-buffer"),d=Me.extend({buffer:c,value:o,version:performance.now()},{fresh:!0});return this.#r.set(i,d),d}let t=this.specificBuffer(r,e);return this.#n.set(e,t.version),t}},uG={shader:"basic",color:"#c0c0c0",flags:[]},K0=class extends Om{#e;constructor(r,e,...t){super(r,e),this.#e=r.childRenderables.map(n=>LD(n,this,...t))}get children(){return this.#e}specificBuffer(r,e){return null}texture(r){throw new Error("Method not implemented.")}dispose(){this.#e.forEach(r=>r.destroy())}},J0=class a extends Om{#e=new Map;#t;constructor(r){super(r)}texture(r){throw new Error("Method not implemented.")}specificBuffer(r,e){let t=!1;(this.allFlags().length>0||Me.isNull(this.#t))&&(t=!0,this.#e.clear(),this._rebuildMatrices(r));let{pipeline:n}=r;if(this.#e.has(n)||(t=!0,this.#e.set(n,this.#t)),mt.clearFlags(this),e==="cameraViewTransform")return Me.extend(this.#t,{fresh:t});Pm(e,a)}_rebuildMatrices({device:r,canvas:e}){let t=this.item,n=fx.create(t),{x:i,y:s,z:o}=t.position,c=n.view(),d=n.projection(e),p=Qn.multiply(c,d),u=new Float32Array(36);if(u.set(Qn.toArray(c),0),u.set(Qn.toArray(p),16),u.set([i,s,o],32),Me.isNull(this.#t)){let h=br.createUniform(r,u,Ge+"view-buffer");this.#t={buffer:h,value:u,version:performance.now().roundoff()}}else this.#t.value=u,this.#t.version=performance.now().roundoff()}_destroyView(){this.#e.clear();let r=this.#t;this.#t=null,this.destroySafely(r)}dispose(){this._destroyView()}},Nv=class a extends Rm{#e={};#t={positions:!0,normals:!0,uv:!0,packed:!0};#r;constructor(r){super(r),r.flags??=[]}buffer(r,e){let t=this.item.flags??[];(Me.isNull(this.#r)||t.includes("geometry"))&&(t.splice(0),this.#e={},this._rebuildGeometryBuffers(r));let n=this.#t,i=this.#r,{pipeline:s}=r,o=this.#e[e]??=new Map,c=!o.has(s),d=p=>(c&&o.set(s,p),p);switch(e){case"geometryPositions":let{positions:p}=i,u=n.positions;return n.positions=!1,Me.extend(d(p),{fresh:u||c});case"geometryNormals":let{normals:h}=i,m=n.normals;return n.normals=!1,Me.extend(d(h),{fresh:m||c});case"geometryTexCoords":let{uv:f}=i,g=n.uv;return n.uv=!1,Me.extend({fresh:g||c},d(f));case"geometry":let{packed:v}=i,b=n.packed;return n.packed=!1,Me.extend(d(v),{fresh:b||c});default:Pm(e,a)}}texture(r){throw new Error("Method not implemented.")}_rebuildGeometryBuffers({device:r}){this._destroyBuffers();let e=performance.now(),t=this.item,n=t.key;if(xu(t)){let i=t,o=!Me.isNullOrEmpty(i.triangleIndices)?i.triangleIndices.map(_=>i.positions[_]):i.positions,c=o.length*2,d=c+o.length,p=new Float32Array(d),u=new Float32Array(d),h=new Float32Array(c),m=new Float32Array(2*d+c);for(let _=0;_<o.length;_++){let E=2*_,C=3*_,{x:k,y:w,z:T}=o[_],{x:I,y:O,z:D}=i.normals[_],{x:P,y:N}=i.textureCoordinates[_];p.set([k,w,T],C),u.set([I,O,D],C),h.set([P,N],E),m.set([k,w,T,I,O,D,P,N],C*2+E)}let f=br.create(r,p,Ge+"meshgeometry-"+n+"-positions-buffer"),g=br.create(r,u,Ge+"meshgeometry-"+n+"-normals-buffer"),v=br.create(r,h,Ge+"meshgeometry-"+n+"-uvmap-buffer"),b=br.create(r,m,Ge+"meshgeometry-"+n+"-buffer");this.#r={packed:{buffer:b,value:m,version:e},positions:{buffer:f,value:p,version:e},normals:{buffer:g,value:u,version:e},uv:{buffer:v,value:h,version:e}},this.#t={positions:!0,normals:!0,uv:!0,packed:!0}}else{let i=new Float32Array(sl.flattenVectorArray(t.positions)),s=br.createStorage(r,i,Ge+"nodegeometry-"+n+"-positions-buffer");this.#r={positions:{buffer:s,value:i,version:e},packed:{buffer:s,value:i,version:e}},this.#t={positions:!0,packed:!0}}}_destroyBuffers(){this.#e={};let r=this.#r;Me.isNull(r)||this.destroySafely(r.positions,r.normals,r.uv)}dispose(){this._destroyBuffers()}},Tv=class a extends Rm{#e={};#t={};#r;#n=new Map;#i=new Map;constructor(r){super(r),r.flags??=[],r.flags.indexOf("material")===-1&&r.flags.push("material")}buffer(r,e){let t=this.item.flags??[],n=Me.isNull(this.#r);t.includes("material")&&(this.#e={},t.splice(0),n=!0,this.#i.clear(),this._resetMaterialBuffers());let{pipeline:i}=r,s=this.#e[e]??=new Map;switch(e){case"material":case"line":let o=this._ensureMaterialBuffer(r,e);return o?(s.has(i)||(n=!0,s.set(i,o)),Me.extend(o,{fresh:n})):null;default:Pm(e,a)}}_ensureMaterialBuffer(r,e="material"){let t=this.#n,n=t.get(e);return n||(t.has(e)?null:(n=this.#r?.buffer(r,e),n&&t.set(e,n),n))}_resetMaterialBuffers(){this.#r=ax.create(this.item),this._destroyBuffers()}texture(r,e="texture"){let t=this.#i,n=t.get(e),i=!1;if(!n){if(n=this.#r?.texture(r,e),!n)return null;t.set(e,n),i=!0,this.#t={}}let{pipeline:s}=r,o=this.#t[e]??=new Map;return o.has(s)||(i=!0,o.set(s,n)),Me.extend(n,{fresh:i})}dispose(){this._destroyBuffers()}_destroyBuffers(){this.#e={},this.#t={};let r=this.#n.values();this.#n.clear(),this.destroySafely(...r);let e=this.#i.values();this.#i.clear(),e.forEach(t=>t.texture.destroy())}},Z0=class a extends Rm{#e={time:0,cursor:{x:0,y:0},resolution:{width:0,height:0}};#t;#r=new Map;constructor(r){super(r),Me.extend(this.#e,r)}buffer(r,e){if(e==="interaction")return this._ensureInteractionBuffer(r);Pm(e,a)}texture(r){throw new Error("Method not implemented.")}_ensureInteractionBuffer(r,e="interaction"){let t=this.#e,n=this.item,i=!this.#t||n.time!==t.time||n.resolution?.width!==t.resolution.width||n.resolution?.height!==t.resolution.height;if(!i&&!Me.isNull(n.cursor)&&(i=n.cursor.x!==t.cursor.x||n.cursor.y!==t.cursor.y),i){let c=new Float32Array([n.cursor?.x??0,n.cursor?.y??0,n.resolution.width,n.resolution.height,n.time,0]),d=br.createUniform(r.device,c,Ge+"interaction-buffer");this.#t={buffer:d,value:c,version:performance.now()},this.#r.clear()}let{pipeline:s}=r,o=this.#r;return o.has(s)||(i=!0,o.set(s,this.#t)),Me.extend(this.#t,{fresh:i})}_destroyBuffers(){this.#r.clear();let r=this.#t;Me.isNull(r)||this.destroySafely(r)}dispose(){this._destroyBuffers()}},Q0=class a extends Om{#e;#t;#r;#n;#i;#a={geometry:!0,material:!0,transform:!0};#s=new Map;constructor(r,e,t,n){super(r,e),r.flags??=[],r.flags.indexOf("geometry")===-1&&r.flags.push("geometry"),r.flags.indexOf("material")===-1&&r.flags.push("material"),r.flags.indexOf("position")===-1&&r.flags.indexOf("transform")===-1&&r.flags.push("transform"),this.#e=t,this.#r=n}texture(r,e){return this.#n?.texture(r,e)}specificBuffer(r,e){let t=this.#a,n=this.allFlags();(Me.isNull(this.#i)||n.includes("position")||n.includes("transform"))&&(this.#s.clear(),t.transform=!0,this._rebuildWorldMatrices(r)),(Me.isNull(this.#t)||n.includes("geometry"))&&(t.geometry=!0,this._ensureGeometryBuffer()),(Me.isNull(this.#n)||n.includes("material"))&&(t.material=!0,this._ensureMaterialBuffer()),mt.clearFlags(this);let i=this.#t,s=this.#n;switch(e){case"geometryPositions":case"geometryNormals":case"geometryTexCoords":case"geometry":return i.buffer(r,e);case"material":case"line":return s.buffer(r,e);case"objectWorldTransform":let o=this.#i,c=t.transform;t.transform=!1;let d=this.#s,{pipeline:p}=r,u=!d.has(p);return u&&d.set(p,o),Me.extend(o,{fresh:c||u});default:Pm(e,a)}}_ensureGeometryBuffer(){let r=this.#t,e=this.#e,n=this.item.geometry;if(Me.isNull(e))r?.destroy(),this.#t=new Nv(n);else{let i=e?.get(n);i?.disposed!==!1&&(i=new Nv(n),e.set(n,i)),this.#t=i}}_ensureMaterialBuffer(){let r=this.#n,e=this.#r,n=this.item.material??uG;if(Me.isNull(e))r?.destroy(),this.#n=new Tv(n);else{let i=e?.get(n);i?.disposed!==!1&&(i=new Tv(n),e.set(n,i)),this.#n=i}}_rebuildWorldMatrices({device:r}){let e=this.item,t=this.buildWorldTransform(),n=Qn.transpose(Qn.invert(t)),i=new Float32Array(28);if(i.set(Qn.toArray(t),0),i.set([n.m11,n.m12,n.m13,0,n.m21,n.m22,n.m23,0,n.m31,n.m32,n.m33,0],16),Me.isNull(this.#i)){let s=br.createUniform(r,i,Ge+"mesh-"+e.key+"-worldmatrix-buffer");this.#i={buffer:s,value:i,version:performance.now().roundoff()}}else this.#i.value=i,this.#i.version=performance.now().roundoff()}dispose(){this.#s.clear();let r=this.#i;this.#i=null,this.destroySafely(r);let e=this.#n;this.#n=null,e?.destroy();let t=this.#t;this.#t=null,t?.destroy()}},ek=class a extends Om{#e;#t=new Map;constructor(r){super(r),r.flags.push("light")}_rebuildAmbientLightBuffer({device:r}){let e=this.item,t=4,n=1,i=0,s=4,o=24,c=new Float32Array(o),{r:d,g:p,b:u,a:h}=X0.parse(e.color??"#fff");c.set([d,p,u,h],i),c.set([e.intensity],s),this.#e={value:c,buffer:br.createUniform(r,c,Ge+"ambient-light-buffer"),version:performance.now()}}_rebuildDirectionalLightBuffer({device:r}){let e=this.item,t=1,n=4,i=3,s=0,o=4,c=7,d=c+t,p=new Float32Array(d),{r:u,g:h,b:m,a:f}=X0.parse(e.color??"#fff");p.set([u,h,m,f],s),p.set([e.intensity],c);let g=q0.subtract(e.position,e.target);p.set([g.x,g.y,g.z],o),this.#e={value:p,buffer:br.createUniform(r,p,Ge+"directional-light-buffer"),version:performance.now()}}_rebuildOmniLightBuffer({device:r}){let e=this.item,t=1,n=4,i=3,s=0,o=4,c=7,d=c+t,p=new Float32Array(d),{r:u,g:h,b:m,a:f}=X0.parse(e.color??"#fff");p.set([u,h,m,f],s),p.set([e.intensity],c),p.set([e.position.x,e.position.y,e.position.z],o),this.#e={value:p,buffer:br.createUniform(r,p,Ge+"omni-light-buffer"),version:performance.now()}}_rebuildLight(r){this.destroySafely(this.#e);let e=this.item;switch(e.type){case"direction":this._rebuildDirectionalLightBuffer(r);break;case"omni":this._rebuildOmniLightBuffer(r);break;case"ambient":this._rebuildAmbientLightBuffer(r);break;default:throw new Error(`Light '${e.type}' is not supported.`)}}texture(r){throw new Error("Method not implemented.")}specificBuffer(r,e){let t=this.#t,n=Me.isNull(this.#e)||this.allFlags().length>0;n&&(t.clear(),this._rebuildLight(r)),mt.clearFlags(this);let{pipeline:i}=r;if(t.has(i)||(n=!0,t.set(i,this.#e)),e==="light")return Me.extend(this.#e,{fresh:n});Pm(e,a)}dispose(){this.#t.clear();let r=this.#e;this.#e=null,this.destroySafely(r)}};var Pe=Ge,TD={multisample:!0,packedVertices:!0,primitive:{topology:"triangle-list",frontFace:"ccw",cullMode:"back"}},zr=a=>{},Up=class a{static{this._memoizer=new WeakMap}static dispose(r){let e=this._memoizer,t=e.get(r);Le.isNull(t)||(t.clear(),e.delete(r))}static createColorPicking(r,e){let t=a.create(r,e);return t instanceof bx||t instanceof yx?{frame:t.raycast}:null}static create(r,[e,t,...n],i){let s=a._memoizer,o=s.get(r);if(Le.isNull(o)&&s.set(r,o=new Map),Le.isNull(e))throw new Error("Pipeline not implemented, given the provided arguments.");if(Nn(e.item)){let c=xu(e.item.geometry),d=!c&&xl(e.item.material);if(!c&&!d)throw new Error("Pipeline not implemented, given the provided mesh argument.");let p=c?new tk(e,t,...n):new rk(e,t),u=p.key+(i?.modifiers?.version??""),h=o.get(u);if(h)return h;let m=c?new bx(r,p):new yx(r,p);m.build(i);let f=m;return Le.extend(f,{id:u+"-"+r.canvas.width+"x"+r.canvas.height+"-"+Le.Dates.now().toISOString()}),o.set(u,f),f}else throw new ReferenceError("Pipeline not implemented, given thst the first argument is not a mesh.")}},vx=class{constructor(){this.#e=new Map}#e;ensureBindGroup({device:r},e,t,n,i,s,o=()=>{}){let c=this.#e,d=typeof e=="string"?e:e.key,p=c.get(d);if(Le.isNull(p)&&c.set(d,p=new Map),n||!p.has(s)){let u=t.map((f,g)=>({binding:g,resource:{buffer:f}})),h={label:s,layout:i,entries:u};o(h);let m=r.createBindGroup(h);return p.set(s,m),m}else return p.get(s)}},tk=class a{#e=[];#t;#r;#n=new Map;#i={shader:"basic",lights:""};constructor(...r){this.add(...r)}reset(){this.#e.splice(0),this.#t=null,this.#n.clear(),this.#i={shader:"basic",lights:""}}add(...r){for(let e of r??[])if(Nn(e.item))if(Le.isNull(this.#t)){this.#t=e;let t=e.item.material??{shader:"basic"};this.#i.shader=t.shader+"-"+(t.map?"map":"nomap")}else throw new Error("Mesh already added.");else if(Rs(e.item))this.#e.push(e),this.#i.lights+="-"+e.item.type;else if(Pr(e.item))this.#r??=e;else throw new Error("Unknown object type.")}build(r){let e=this._computeBasicData(),t=this.key,n=this.vertex({inputModifier:r?.vertexInput,outputModifier:r?.vertexOutput}),i=this.fragment(e,{modifier:r?.fragment}),s=(...c)=>a.prototype.bindgroup.apply(this,c),o={lightCount:this.#e.length,mapCount:this.#t.item.material?.map?1:0};return{vertex:n,fragment:i,key:t,bindings:s,metadata:o}}get key(){let{shader:r,lights:e}=this.#i;return"mesh-"+r+e}bindgroup(r,e,t){let i=this.#n.get(r);if(Le.isNull(i))return null;if(Le.isNullOrEmpty(e))return i;let s=i.filter(o=>o.key===e);return isNaN(t)?s:t>=0&&t<i.length?s[t]:s}vertex(r){return hD(r)}_computeBasicData(){let r=this.#t.item,e=this.#e,t=r.material,n=!Le.isNull(t?.texture),i=!Le.isNullOrEmpty(e),s=Le.isNull(r)?"basic":r.material?.shader??"basic";return{hasTexture:n,hasLighting:i,shader:s,materialBindGroupIndex:2,lightingBindGroupIndex:3}}_computeBindGroupsAndReferences(r=this._computeBasicData()){let{hasTexture:e,materialBindGroupIndex:t,lightingBindGroupIndex:n}=r,i=this.#n,s=this.#e,o={key:"objectWorldTransform",group:1,binding:0,type:"buffer"},c={key:"material",group:t,binding:0,type:"buffer"};e?i.set("mesh",[o,c,{key:"texture",group:t,type:"texture"}]):i.set("mesh",[o,c]),i.set("camera",[{key:"cameraViewTransform",group:0,binding:0,type:"buffer"}]);let d=s.map((p,u)=>({key:"light",group:n,binding:u,type:"buffer"}));d.push(...d),i.set("interaction",[{key:"interaction",group:0,type:"buffer",binding:1}])}fragment(r=this._computeBasicData(),e){this._computeBindGroupsAndReferences(r);let t={definitions:[],bindings:[],modifiers:[]},n=i=>{for(let s of i.definitions??[])t.definitions.indexOf(s)===-1&&t.definitions.push(s);Le.isNullOrEmpty(i.bindings)||t.bindings.push(...i.bindings),Le.isNullOrEmpty(i.modifiers)||t.modifiers.push(...i.modifiers)};switch(r.shader){case"basic":if(r.hasTexture){let o=r.materialBindGroupIndex,c=yD({inputColor:Bp,outputColors:[Bp],uv:"uv"},o);n(c)}let i=0,s=this.#e;for(let o of s){switch(o.item.type){case"direction":let d=_D({outputColor:wv,normal:"normal"},r.lightingBindGroupIndex,i);n(d);break;case"omni":let p=xD({outputColor:wv,normal:"normal",position:"vertex"},r.lightingBindGroupIndex,i);n(p);break;case"ambient":let u=CD({inputColor:Bp,outputColor:sx},r.lightingBindGroupIndex,i);n(u);break}i++}return Mv.fragment(t,e)}}},Ii={writeBufferConditionally:(a,r)=>{r.fresh&&a.queue.writeBuffer(r.buffer,0,r.value)}},bx=class{constructor(r,e,t=new vx){this._context=r;this._builder=e;this._cache=t;this._ensureU32idBindGroup=(r,e,t)=>this._cache.ensureBindGroup(this._context,r,[e],t,this._pickBindGroupLayout,Pe+"mesh-colorpick-bind-group");this._ensureMaterialBindGroup=(r,e,t,n,i=2)=>{let s=this._bindGroupLayouts[i],o=Pe+"material-bind-group";if(s.label!==Pe+"material-bind-group-layout")throw new Error("BindGroupLayout mismatch!");return this._cache.ensureBindGroup(this._context,r,[e],n,s,o,c=>{let{device:d}=this.context,p=c.entries;t&&p.push({binding:1,resource:d.createSampler({addressModeU:"repeat",addressModeV:"repeat",magFilter:"linear",minFilter:"linear"})},{binding:2,resource:t.createView()})})};this._ensureWorldTransformBindGroup=(r,e,t,n=1,i=!1)=>{let s=this._bindGroupLayouts[n];if(s.label!==Pe+"mesh-transforms-bind-group-layout")throw new Error("BindGroupLayout mismatch!");let o=r.key+"-"+(i?1:0),c=`${Pe}${i?"colorpick":"mesh"}-transforms-bind-group`;return this._cache.ensureBindGroup(this._context,o,[e],t,s,c)};this._ensureCameraProjectionAndInteractionDataBindGroup=(r,e,t,n,i=0,s=!1)=>{let o=this._bindGroupLayouts[i],c=r.key+"-"+(s?1:0),d=`${Pe}${s?"colorpick":"mesh"}-view-bind-group`;return this._cache.ensureBindGroup(this._context,c,[e,t],n,o,d)};this._ensureLightingBindGroup=(r,e,t=3)=>{let n=this._bindGroupLayouts[t],i=r.map(o=>o.id).join(":"),s=r.map(o=>o.buffer.buffer);return this._cache.ensureBindGroup(this._context,i,s,e,n,Pe+"mesh-lighting-bind-group")};this._bindGroupLayouts=[];this._bindVertex=zr;this._bindPicker=zr;this._bindWorldTransform=zr;this._bindRaycastWorldTransform=zr;this._bindCameraProjectionAndInteractionData=zr;this._bindRaycastCameraProjectionAndInteractionData=zr;this._bindLighting=zr;this._bindMaterial=zr;this.set=r=>{throw new Error("Deprecated.")};this.bind=(r,...e)=>{throw new Error("Deprecated.")};this.draw=(r,...e)=>{throw new Error("Deprecated.")};this.frame=(r,e,t,n,...i)=>{r.setPipeline(this._pipeline);try{this._bindVertex(r,t),this._bindWorldTransform(r,t),this._bindMaterial(r,t),this._bindCameraProjectionAndInteractionData(r,n,e),this._bindLighting(r,...i);let s=t.item,o=s.geometry;r.draw(o.triangleIndices?.length||o.positions.length)}catch(s){console.error("Pacem.Drawing3D.FrameException",s)}};this.raycast=(r,e,t,n)=>{r.setPipeline(this._pickPipeline);try{this._bindVertex(r,t),this._bindRaycastWorldTransform(r,t),this._bindRaycastCameraProjectionAndInteractionData(r,n,e),this._bindPicker(r,t);let i=t.item,s=i.geometry;r.draw(s.triangleIndices.length)}catch{}};this._key=e.key}get context(){return this._context}get key(){return this._key}build(r){let e=Le.extend({},TD,r??{}),t=this._builder,n=t.build(e.modifiers),i=Le.extend({pipeline:this},this._context),s=i.device,o={module:s.createShaderModule({code:n.vertex}),buffers:e.packedVertices?[Vp.createVertex(0,3,3,2)]:[Vp.createVertex(0,3),Vp.createVertex(1,3),Vp.createVertex(2,2)]},c=s.createBindGroupLayout({entries:[{binding:0,visibility:3,buffer:{type:"uniform"}},{binding:1,visibility:3,buffer:{type:"uniform"}}],label:Pe+"mesh-view-bind-group-layout"}),d=s.createBindGroupLayout({entries:[{binding:0,visibility:1,buffer:{type:"uniform"}}],label:Pe+"mesh-transforms-bind-group-layout"}),p=[c,d],u={module:s.createShaderModule({code:n.fragment}),targets:[{format:i.format,blend:{color:{srcFactor:"src-alpha",dstFactor:"one-minus-src-alpha"},alpha:{}}}]},h=p.length,m=[{binding:0,visibility:2,buffer:{type:"read-only-storage"}}],{mapCount:f}=n.metadata,g=f>0;g&&m.push({visibility:2,binding:1,sampler:{}},...Array(f).keys().map(N=>({visibility:2,binding:2+N,texture:{}})));let v={label:Pe+"material-bind-group-layout",entries:m},b=s.createBindGroupLayout(v);p.push(b);let _=p.length,{lightCount:E}=n.metadata,C=E>0;if(C){let N=s.createBindGroupLayout({entries:[...Array(E).keys()].map((H,V)=>({visibility:2,binding:V,buffer:{type:"uniform"}})),label:Pe+"lighting-bind-group-layout"});p.push(N)}let k={label:Pe+"mesh-render-pipeline",vertex:o,fragment:u,layout:s.createPipelineLayout({label:Pe+"mesh-render-pipeline-layout",bindGroupLayouts:this._bindGroupLayouts=p}),primitive:e.primitive};e.multisample&&(k.multisample={count:4},k.depthStencil={depthCompare:"less",format:"depth24plus",depthWriteEnabled:!0}),this._pipeline=s.createRenderPipeline(k);let w=this._pickBindGroupLayout=s.createBindGroupLayout({label:Pe+"mesh-colorpick-bind-group-layout",entries:[{visibility:2,binding:0,buffer:{type:"uniform"}}]}),T={label:Pe+"mesh-colorpick-pipeline",vertex:o,fragment:{module:s.createShaderModule({code:V0(2)}),targets:[{format:"r32uint"}]},layout:s.createPipelineLayout({label:Pe+"mesh-colorpick-pipeline-layout",bindGroupLayouts:[c,d,w]}),primitive:e.primitive,depthStencil:{depthWriteEnabled:!0,depthCompare:"less",format:"depth24plus"}};this._pickPipeline=s.createRenderPipeline(T);let I=(N,...H)=>{let V=H.at(0);if(Le.isNull(V))throw new ReferenceError(`Null ${mt.name} bringing vertex buffers was provided.`);let{buffer:B}=V.buffer(i,"geometryPositions"),{buffer:R}=V.buffer(i,"geometryNormals"),{buffer:U}=V.buffer(i,"geometryTexCoords");N.setVertexBuffer(0,B),N.setVertexBuffer(1,R),N.setVertexBuffer(2,U)},O=(N,...H)=>{let V=H.at(0);if(Le.isNull(V))throw new ReferenceError(`Null ${mt.name} bringing vertex buffers was provided.`);let{buffer:B}=V.buffer(i,"geometry");N.setVertexBuffer(0,B)};this._bindVertex=e.packedVertices?O:I;let D=(N,H,V)=>{if(Le.isNull(H))throw new ReferenceError(`Null ${mt.name} bringing world transform buffer was provided.`);let B=H.buffer(i,"objectWorldTransform"),R=B.buffer;Ii.writeBufferConditionally(s,B);let{group:U}=n.bindings("mesh","objectWorldTransform",0),z=this._ensureWorldTransformBindGroup(H.item,R,B.fresh,U,V);N.setBindGroup(U,z)};this._bindWorldTransform=(N,...H)=>{let V=H.at(0);D(N,V,!1)},this._bindRaycastWorldTransform=(N,...H)=>{let V=H.at(0);D(N,V,!0)};let P=(N,H,V,B)=>{if(Le.isNull(H))throw new ReferenceError(`Null ${mt.name} bringing view projection buffers was provided.`);let R=H.buffer(i,"cameraViewTransform"),U=R.buffer;if(Ii.writeBufferConditionally(s,R),Le.isNull(V))throw new ReferenceError(`Null ${mt.name} bringing interaction buffers was provided.`);let z=V.buffer(i,"interaction"),G=z.buffer;Ii.writeBufferConditionally(s,z);let{group:Z}=n.bindings("camera","cameraViewTransform",0),{group:q}=n.bindings("interaction","interaction",0);if(Z!==q)throw new ReferenceError(`Layout bind group mismatch: ${Z} vs ${q}.`);let Q=this._ensureCameraProjectionAndInteractionDataBindGroup(H.item,U,G,R.fresh||z.fresh,Z,B);N.setBindGroup(Z,Q)};this._bindCameraProjectionAndInteractionData=(N,...H)=>{let V=H.at(0),B=H.at(1);P(N,V,B,!1)},this._bindRaycastCameraProjectionAndInteractionData=(N,...H)=>{let V=H.at(0),B=H.at(1);P(N,V,B,!0)},this._bindMaterial=(N,...H)=>{let V=H.at(0);if(Le.isNull(V))throw new ReferenceError(`Null ${mt.name} bringing vertex colors was provided.`);let B=V.buffer(i,"material"),R=B.buffer;Ii.writeBufferConditionally(s,B);let U=V.texture(i),z=U?.texture,G=this._ensureMaterialBindGroup(V.item,R,z,B.fresh,h);N.setBindGroup(h,G),g&&s.queue.copyExternalImageToTexture({source:U.source,flipY:!0},{texture:z},{width:z.width,height:z.height})},this._bindLighting=(N,...H)=>{if(C){let B=Array.from(H).map(z=>({buffer:z.buffer(i,"light"),id:z.item.key})),R=B.some(z=>z.buffer.fresh),U=this._ensureLightingBindGroup(B,R,_);for(let z of B)Ii.writeBufferConditionally(s,z.buffer);N.setBindGroup(_,U)}},this._bindPicker=(N,...H)=>{let V=H.at(0);if(Le.isNull(V))throw new ReferenceError(`Null ${mt.name} bringing world transform buffer was provided.`);let B=V.buffer(i,"u32id"),R=B.buffer;Ii.writeBufferConditionally(s,B);let U=2,z=B.fresh,G=this._ensureU32idBindGroup(V.item,R,z);N.setBindGroup(U,G)}}},rk=class a{#e;#t;#r=new Map;constructor(...r){this.add(...r)}reset(){this.#e=null,this.#r.clear()}add(...r){for(let e of r??[])if(Nn(e.item))if(Le.isNull(this.#e))this.#e=e;else throw new Error("Line already added.");else if(Pr(e.item))this.#t??=e;else if(!Rs(e.item))throw new Error("Unknown object type.")}build(){let r=this._computeBasicData(),e=this.key,t=this.vertex(r),n=this.fragment(r);return{vertex:t,fragment:n,key:e,bindings:(...s)=>a.prototype.bindgroup.apply(this,s),metadata:{thickness:r.thickness,dashPattern:r.dashPattern}}}get key(){let r=(this.#e?.item).material?.lineWidth>1;return"line"+(r?"-fat":"")}bindgroup(r,e,t){let i=this.#r.get(r);if(Le.isNull(i))return null;if(Le.isNullOrEmpty(e))return i;let s=i.filter(o=>o.key===e);return isNaN(t)?s:t>=0&&t<i.length?s[t]:s}vertex(r=this._computeBasicData()){return r.thickness>1?vD():gD()}_computeBasicData(){let r=this.#e.item,e=Le.isNull(r)?"line":r.material?.shader??"line",t=r.material,n=t?.lineWidth??1,i=t?.dashArray;return{shader:e,thickness:n,dashPattern:i}}_computeBindGroupsAndReferences(r=this._computeBasicData()){let e=this.#r,t={key:"objectWorldTransform",group:1,binding:0,type:"buffer"},n={key:"material",group:3,binding:0,type:"buffer"},i={key:"geometryPositions",group:2,binding:0,type:"buffer"},s={key:"line",group:2,binding:1,type:"buffer"};e.set("mesh",[t,n,i,s]),e.set("camera",[{key:"cameraViewTransform",group:0,binding:0,type:"buffer"}])}fragment(r=this._computeBasicData()){this._computeBindGroupsAndReferences(r);let e={definitions:[],bindings:[],modifiers:[]};if(r.shader==="line")return Sv.fragment(e)}},yx=class{constructor(r,e,t=new vx){this._lineBuilder=e;this._cache=t;this._ensureLineU32idBindGroup=(r,e,t)=>{let n=this.context;return this._cache.ensureBindGroup(n,r,[e],t,this._pickLineBindGroupLayout,Pe+"line-colorpick-bind-group")};this._ensureLineMaterialBindGroup=(r,e,t,n=2)=>{let i=this._bindLineGroupLayouts[n];if(i.label!==Pe+"line-material-bind-group-layout")throw new Error("BindGroupLayout mismatch!");let s=this.context;return this._cache.ensureBindGroup(s,r,[e],t,i,Pe+"line-material-bind-group")};this._ensureLinePositionsBindGroup=(r,e,t,n)=>{let i=this._bindLineGroupLayouts[n];if(i.label!==Pe+"line-positions-bind-group-layout")throw new Error("BindGroupLayout mismatch!");let s=this.context;return this._cache.ensureBindGroup(s,r,e,t,i,Pe+"line-positions-bind-group")};this._ensureLineWorldTransformBindGroup=(r,e,t,n=1,i=!1)=>{let s=this._bindLineGroupLayouts[n];if(s.label!==Pe+"line-transforms-bind-group-layout")throw new Error("BindGroupLayout mismatch!");let o=r.key+"-line-"+(i?1:0),c=`${Pe}${i?"colorpick":""}-line-transforms-bind-group`,d=this.context;return this._cache.ensureBindGroup(d,o,[e],t,s,c)};this._ensureLineCameraProjectionBindGroup=(r,e,t,n=0,i=!1)=>{let s=this._bindLineGroupLayouts[n],o=r.key+"-line-"+(i?1:0),c=`${Pe}${i?"colorpick":""}-line-view-bind-group`,d=this.context;return this._cache.ensureBindGroup(d,o,[e],t,s,c)};this._bindLineGroupLayouts=[];this._bindLinePositions=zr;this._bindLinePicker=zr;this._bindLineWorldTransform=zr;this._bindLineRaycastWorldTransform=zr;this._bindLineCameraProjection=zr;this._bindLineRaycastCameraProjection=zr;this._bindLineMaterial=zr;this._drawLine=zr;this.set=r=>{throw new Error("Deprecated.")};this.bind=(r,...e)=>{throw new Error("Deprecated.")};this.draw=(r,...e)=>{throw new Error("Deprecated.")};this.frame=(r,e,t)=>{r.setPipeline(this._linePipeline);try{this._bindLineWorldTransform(r,e),this._bindLineCameraProjection(r,t),this._bindLinePositions(r,e),this._bindLineMaterial(r,e),this._drawLine(r,e)}catch(n){console.error("Pacem.Drawing3D.FrameException",n)}};this.raycast=(r,e,t)=>{r.setPipeline(this._pickLinePipeline);try{this._bindLineRaycastWorldTransform(r,e),this._bindLineRaycastCameraProjection(r,t),this._bindLinePositions(r,e),this._bindLinePicker(r,e),this._drawLine(r,e)}catch{}};this.#e=r,this._lineKey=e.key}#e;get context(){return this.#e}get key(){return this._lineKey}build(r){let e=Le.extend({},TD,r??{}),t=this._lineBuilder,n=t.build(),i=Le.extend({pipeline:this},this.#e),s=i.device,o=n.metadata.thickness>1,c={module:s.createShaderModule({code:n.vertex}),buffers:[]},d=s.createBindGroupLayout({entries:[{binding:0,visibility:1,buffer:{type:"uniform"}}],label:Pe+"line-transforms-bind-group-layout"}),p=s.createBindGroupLayout({entries:[{binding:0,visibility:1,buffer:{type:"uniform"}}],label:Pe+"line-view-bind-group-layout"}),u=[{binding:0,visibility:1,buffer:{type:"read-only-storage"}}];o&&u.push({binding:1,visibility:1,buffer:{type:"uniform"}});let h=s.createBindGroupLayout({entries:u,label:Pe+"line-positions-bind-group-layout"}),m=[d,p,h],f=m.length,g=m.slice(),v={module:s.createShaderModule({code:n.fragment}),targets:[{format:i.format,blend:{color:{srcFactor:"src-alpha",dstFactor:"one-minus-src-alpha"},alpha:{}}}]},b=g.length,_=[{binding:0,visibility:2,buffer:{type:"read-only-storage"}}],E={label:Pe+"line-material-bind-group-layout",entries:_},C=s.createBindGroupLayout(E);g.push(C);let k=o?e.primitive.topology:"line-list",w={label:Pe+"line-render-pipeline",vertex:c,fragment:v,layout:s.createPipelineLayout({label:Pe+"line-render-pipeline-layout",bindGroupLayouts:this._bindLineGroupLayouts=g}),primitive:Le.extend({},e.primitive,{topology:k})};e.multisample&&(w.multisample={count:4},w.depthStencil={depthCompare:"less",format:"depth24plus",depthWriteEnabled:!0}),this._linePipeline=s.createRenderPipeline(w);let T=this._pickLineBindGroupLayout=s.createBindGroupLayout({label:Pe+"line-colorpick-bind-group-layout",entries:[{visibility:2,binding:0,buffer:{type:"uniform"}}]}),I={label:Pe+"line-colorpick-pipeline",vertex:c,fragment:{module:s.createShaderModule({code:V0(f)}),targets:[{format:"r32uint"}]},layout:s.createPipelineLayout({label:Pe+"line-colorpick-pipeline-layout",bindGroupLayouts:m.concat(T)}),primitive:Le.extend({},e.primitive,{topology:k}),depthStencil:{depthWriteEnabled:!0,depthCompare:"less",format:"depth24plus"}};this._pickLinePipeline=s.createRenderPipeline(I);let O=(P,N,H)=>{if(Le.isNull(N))throw new ReferenceError(`Null ${mt.name} bringing world transform buffer was provided.`);let V=N.buffer(i,"objectWorldTransform"),B=V.buffer;Ii.writeBufferConditionally(s,V);let{group:R}=n.bindings("mesh","objectWorldTransform",0),U=this._ensureLineWorldTransformBindGroup(N.item,B,!1,R,H);P.setBindGroup(R,U)};this._bindLineWorldTransform=(P,...N)=>{let H=N.at(0);O(P,H,!1)},this._bindLineRaycastWorldTransform=(P,...N)=>{let H=N.at(0);O(P,H,!0)};let D=(P,N,H)=>{if(Le.isNull(N))throw new ReferenceError(`Null ${mt.name} bringing view projection buffers was provided.`);let V=N.buffer(i,"cameraViewTransform"),B=V.buffer;Ii.writeBufferConditionally(s,V);let{group:R}=n.bindings("camera","cameraViewTransform",0),U=this._ensureLineCameraProjectionBindGroup(N.item,B,!1,R,H);P.setBindGroup(R,U)};this._bindLineCameraProjection=(P,...N)=>{let H=N.at(0);D(P,H,!1)},this._bindLineRaycastCameraProjection=(P,...N)=>{let H=N.at(0);D(P,H,!0)},this._bindLinePositions=(P,...N)=>{let H=N.at(0);if(Le.isNull(H))throw new ReferenceError(`Null ${mt.name} bringing vertex buffers was provided as index 0.`);let V=H.buffer(i,"geometryPositions"),B=V.buffer,R=V.fresh,U=[B];if(Ii.writeBufferConditionally(s,V),o){let Z=H.buffer(i,"line"),q=Z.buffer;R||=Z.fresh,U.push(q),Ii.writeBufferConditionally(s,Z)}let{group:z}=n.bindings("mesh","line",0),G=this._ensureLinePositionsBindGroup(H.item,U,R,z);P.setBindGroup(z,G)},this._bindLineMaterial=(P,...N)=>{let H=N.at(0);if(Le.isNull(H))throw new ReferenceError(`Null ${mt.name} bringing vertex colors was provided.`);let V=H.buffer(i,"material"),B=V.buffer;Ii.writeBufferConditionally(s,V);let R=this._ensureLineMaterialBindGroup(H.item,B,V.fresh,b);P.setBindGroup(b,R)},this._bindLinePicker=(P,...N)=>{let H=N.at(0);if(Le.isNull(H))throw new ReferenceError(`Null ${mt.name} bringing world transform buffer was provided.`);let V=H.buffer(i,"u32id"),B=V.buffer,R=V.value;Ii.writeBufferConditionally(s,V);let U=this._ensureLineU32idBindGroup(H.item,B,!1);P.setBindGroup(f,U)},this._drawLine=(P,...N)=>{let V=N.at(0).item,B=V.geometry;o?P.draw(6,B.positions.length-1,0,0):P.draw(B.positions.length)}}};import{Utils as zp}from"@pacem/pacem-core";var Dv=class{static{this._memoizer=new WeakMap}static dispose(r){let e=this._memoizer;if(e.has(r)){let t=e.get(r);for(let n of t.values())n.destroy();t.clear(),e.delete(r)}}static createColorPicking(r){let e=this._memoizer;e.has(r)||e.set(r,new Map);let t=e.get(r),n="colorpick";if(t.has(n))return t.get(n);let i=new nk(r);return t.set(n,i),i}},Av=1,nk=class{constructor(r){this._context=r;this._objects=new Map;this.frame=(r,...e)=>{if(zp.isNull(this._encoder))throw new Error("Null encoder. Maybe you missed to call the 'begin' method first.");let t=Array.from(e);Up.createColorPicking(this._context,t)?.frame(this._pass,r,...e);for(let i of t)i.item.inert||this._objects.set(i.id,i)};this.end=r=>{if(!zp.isNull(this._handle))return this._handle;let e=this._pass,t=this._encoder,{device:n}=this._context,{render:i}=this._textures,s=i.texture,o=this._ensureBuffer();e.end(),t.copyTextureToBuffer({texture:s,origin:{x:r.x,y:r.y}},{buffer:o,bytesPerRow:(Av*4+255|0)*256,rowsPerImage:1},{width:Av}),n.queue.submit([t.finish()]),this._encoder=null;let c=this,d=c._objects,p=()=>{c._handle=null};return this._handle=new Promise((u,h)=>{o.mapAsync(1,0,4*Av).then(m=>{let g=new Uint32Array(o.getMappedRange(0,4*Av))[0];o.unmap(),p();let v=d.get(g);u(v?[v.item]:[])})})}}_createTexture(r){let{device:e,canvas:t}=this._context,n=Math.min(e.limits.maxTextureDimension2D,t.clientWidth),i=Math.min(e.limits.maxTextureDimension2D,t.clientHeight);return e.createTexture({size:[n,i,1],format:r,usage:17})}_ensureBuffer(){let r=this._buffer;if(!zp.isNull(r))return r;let{device:e}=this._context;return this._buffer=e.createBuffer({label:Ge+"colorpick-output-buffer",size:Av*4,usage:9})}_ensureTextures(){let r=this._textures;if(!zp.isNull(r))return r;let e=this._createTexture("r32uint"),t=this._createTexture("depth24plus"),n={texture:e,view:e.createView()},i={texture:t,view:t.createView()};return this._textures={render:n,depth:i}}_destroyTexture(r){zp.isNull(r)||r.texture?.destroy()}destroy(){let r=this._textures,e=this._buffer;if(!zp.isNullOrEmpty(r)){let{render:t,depth:n}=r;this._destroyTexture(t),this._destroyTexture(n),this._textures=null}zp.isNull(e)||(e.destroy(),this._buffer=null)}begin(){let{device:r}=this._context;this._encoder=r.createCommandEncoder({label:Ge+"colorpick-raycaster"});let{render:e,depth:t}=this._ensureTextures(),n={label:Ge+"colorpick-raycaster-pass",colorAttachments:[{view:e.view,clearValue:{r:0,g:0,b:0,a:0},loadOp:"clear",storeOp:"store"}],depthStencilAttachment:{view:t.view,depthClearValue:1,depthLoadOp:"clear",depthStoreOp:"store"}};this._pass=this._encoder.beginRenderPass(n),this._objects.clear()}};var ik=vG.LinearAlgebra.Vector3D;var _x=class{static create(r,e){return new Promise((t,n)=>{if(!navigator.gpu)n({message:"WebGPU not supported.",cause:0});else{let i=new sk(r);i.init(e).then(s=>t(i),s=>{let c={message:typeof s=="string"?s:s.message,cause:1};n(c)})}})}};function bG(a){return{bottom:-1,top:1,left:-1,right:1,near:.1,far:200,lookAt:ik.from(0,0,0),up:ik.j(),position:ik.from(0,0,1),type:"orthographic",flags:[],stage:a}}function yG(...a){for(let r of a||[])r?.destroy()}var sk=class{constructor(r){this.#n=new WeakMap;this.#i=new WeakMap;this.#a=new WeakMap;this.#l={enableValidation:!1};this.#h=!1;this._logError=r=>{let e=this.#e,t=e.logger;if(!Wt.isNull(t)){let n="error"in r?r.error:r;t.log(fG.LogLevel.Error,n.message,"WebGPU")}};this.#c=!0;this.#u=!1;let e=(this.#e=r).stage,t=document.createElement("canvas");t.id=mG+"_3d_stage_"+Wt.uniqueCode(),e.innerHTML="",e.appendChild(this.#t=t),this.#d=Dm.create(this.#p={time:performance.now(),cursor:{x:0,y:0},resolution:{width:0,height:0}})}#e;#t;#r;#n;#i;#a;#s;#o;#l;#h;#d;#p;_buildPassDescriptor({multisample:r,format:e}){let{context:t,device:n}=this.#r,i=t.getCurrentTexture(),s=this.#o;if(Wt.isNull(s)){if(s={},r){let f=n.createTexture({label:Ge+"render-texture",format:e??i.format,usage:16,size:[i.width,i.height],sampleCount:4});s.render={texture:f,view:f.createView({label:Ge+"render-texture-view"})};let g=n.createTexture({label:Ge+"depth-texture",format:"depth24plus",usage:16,size:[i.width,i.height],sampleCount:4});s.depth={texture:g,view:g.createView({label:Ge+"depth-texture-view"})}}this.#o=s}let{transparent:o,background:c}=this.#e,d=o?{r:0,g:0,b:0,a:0}:c?typeof c=="string"?gG.parse(c):c:{r:0,g:0,b:0,a:1},p=sl.flattenVectorArray([d]),u=i.createView({label:Ge+"canvas-texture-view"}),h={view:u,clearValue:p,loadOp:"clear",storeOp:"store"},m={colorAttachments:[h]};if(r){let f=s.render.view,g=s.depth.view;m.depthStencilAttachment={view:g,depthClearValue:1,depthLoadOp:"clear",depthStoreOp:"store",stencilClearValue:0,stencilReadOnly:!0},h.view=f,h.resolveTarget=u}return m}_buildContext(r=this.#t,e=this.#e.size){e??=r;let t=e.width,n=e.height,i=1;r.width=t*i,r.height=n*i;let s=r.getContext("webgpu"),o=navigator.gpu.getPreferredCanvasFormat();return{context:s,textureFormat:o}}_buildUpContext(r,e,t,n){let{transparent:i}=this.#e;t.configure({alphaMode:i?"premultiplied":"opaque",device:r,format:n}),this.#r={device:r,adapter:e,canvas:this.#t,context:t,format:n},this.#c=!1}async init(r){this.#l=r;let e=await navigator.gpu.requestAdapter();if(Wt.isNull(e))throw new Error("WebGPU adapter unavalable or disabled.");let t=await e.requestDevice();if(Wt.isNull(e))throw new Error("WebGPU device unavalable or disabled.");t.addEventListener("uncapturederror",this._logError),this.#u=!Wt.isNull(r.modifiers?.version)&&!Wt.isNull(r.modifiers)&&(!Wt.isNull(r.modifiers.vertexInput)||!Wt.isNull(r.modifiers.vertexOutput)||!Wt.isNull(r.modifiers.fragment));let{context:n,textureFormat:i}=this._buildContext();this._buildUpContext(t,e,n,i)}#c;#u;render(r){if(this.#c||Wt.isNull(this.#s)||!(this.#t.width>0)||!(this.#t.height>0))return;let e=this.#r,t=e.device,n=this.#s,i=this.#l?.enableValidation??!1;this.#u&&Wt.extend(this.#p,r);let o=this._buildPassDescriptor({multisample:!0}),c=t.createCommandEncoder({label:Ge+"renderer"}),d=c.beginRenderPass(o);n.loop((p,u,h)=>{if(p.item.hide)return!1;i&&t.pushErrorScope("validation");let m=[p,u,...h];return Up.create(e,m,{multisample:!0,modifiers:this.#l.modifiers}).frame(d,this.#d,...m),i&&t.popErrorScope().then(g=>{g&&this._logError(g)}),!0}),d.end(),t.queue.submit([c.finish()])}set disabled(r){this.#h=r}get disabled(){return this.#h}raycast(r){if(this.#c||Wt.isNull(this.#s))return Promise.resolve([]);let e=this.#r,t=e.device,n=this.#s,i=this.#l?.enableValidation??!1,s=Dv.createColorPicking(e);return s.begin(),n.loop((o,c)=>o.item.hide?!1:(i&&t.pushErrorScope("validation"),s.frame(this.#d,o,c),i&&t.popErrorScope().then(d=>{d&&this._logError(d)}),!0)),s.end(r)}_disposeRenderableJustInCase(r){let e=this.#n;e.has(r)&&(e.get(r)?.destroy(),e.delete(r))}_createOrYieldRenderable(r,e=this.#i,t=this.#a){r.stage??=this.#e;let n=this.#n,i=n.get(r);return Wt.isNull(i)&&n.set(r,i=mt.create(r,e)),i}_createOrYieldGeometry(r){let e=this.#i,t=e.get(r);return Wt.isNull(t)&&e.set(r,t=Dm.create(r)),t}_createOrYieldMaterial(r){let e=this.#a,t=e.get(r);return Wt.isNull(t)&&e.set(r,t=Dm.create(r)),t}_unwrapBuffers(r,e){e??={meshes:[],lights:[],cameras:[],groups:[]};for(let t of r.children)t.item.stage??=this.#e,Nn(t.item)&&e.meshes.push(t),Pr(t.item)&&e.cameras.push(t),Rs(t.item)&&e.lights.push(t),cd(t.item)&&(e.groups.push(t),this._unwrapBuffers(t,e));return e}_update(r){let e=[],t=[],n=[],i=d=>this._createOrYieldRenderable(d),s;for(let d of r){if(d.hide){this._disposeRenderableJustInCase(d);continue}if(d.stage??=this.#e,cd(d)){let p=d;p.flags.includes("children")&&this.#n.delete(p),e.push(i(p))}Nn(d)&&d.geometry&&(this._createOrYieldGeometry(d.geometry),Wt.isNull(d.material)||this._createOrYieldMaterial(d.material),t.push(i(d))),Rs(d)&&n.push(i(d)),Pr(d)&&(s??=d)}s??=bG(this.#e);let o=i(s),c={meshes:t,lights:n,cameras:[o],groups:e};for(let d of e)c=this._unwrapBuffers(d,c);this.#s?.items.meshes.forEach(d=>{t.includes(d)||d.destroy()}),this.#s=new gx(c)}update(...r){this._update(Array.from(r))}dispose(){if(this.#s=null,this._disposeContext()){let{device:r}=this.#r;r.removeEventListener("uncapturederror",this._logError),r.destroy}}_disposeContext(){let r=this.#r;if(Wt.isNull(r))return!1;Dv.dispose(r),Up.dispose(r);let e=this.#o;if(this.#o=null,!Wt.isNull(e)){let{render:t,depth:n}=e;yG(t?.texture,n?.texture)}return r.context.unconfigure(),!0}resize(r){if(this.#c=!0,this._disposeContext()){let{device:e,adapter:t}=this.#r,{context:n,textureFormat:i}=this._buildContext(this.canvas,r);this._buildUpContext(e,t,n,i),this.#u&&Wt.extend(this.#p,{resolution:r})}}get canvas(){return this.#t}};var DD="WebGPURaycastCallback",ak="WebGPURaycastPixel",RD=Cx.getAttachedPropertyValue,OD=Cx.setAttachedPropertyValue,wG=Cx.deleteAttachedPropertyValue,Gp,Rv,Yc=class extends CG.PacemItemElement{constructor(){super(...arguments);$(this,Gp,"");$(this,Rv,new MutationObserver(()=>{this.wgsl=this.textContent}))}findContainer(){return Cx.findAncestor(this,e=>e instanceof al)}get version(){return x(this,Gp)}viewActivatedCallback(){super.viewActivatedCallback(),this.wgsl=this.textContent,x(this,Rv).observe(this,{characterData:!0})}propertyChangedCallback(e,t,n,i){super.propertyChangedCallback(e,t,n,i),e==="wgsl"&&this._computeVersion(n)}_computeVersion(e=this.wgsl){EG.hash(e).then(t=>{if(t!==x(this,Gp)){let n=x(this,Gp),i=t;A(this,Gp,i);let s=new lk({propertyName:"version",oldValue:n,currentValue:i,firstChange:jc.isNullOrEmpty(n)});this.dispatchEvent(s)}})}disconnectedCallback(){x(this,Rv).disconnect(),super.disconnectedCallback()}};Gp=new WeakMap,Rv=new WeakMap,l([xx({emit:!1,converter:ok.String})],Yc.prototype,"type",2),l([xx({emit:!1,converter:ok.String})],Yc.prototype,"wgsl",2),Yc=l([PD({tagName:ID+"-3d-wgsl-script"})],Yc);var Fp,Wp,Xc,Im,$m,Hm,al=class extends yl{constructor(){super(...arguments);$(this,Fp,[]);this._scriptVersionChangeHandler=e=>{let{propertyName:t}=e.detail;t==="version"&&this._parseWgslModifiers(e.detail.currentValue)};$(this,Wp,new Set);$(this,Xc,new Map);$(this,Im,!0);$(this,$m,!0);$(this,Hm,new WeakMap)}invalidateSize(e,t=e.size){this._ensureRenderer(e)?.resize(t)}get items(){return x(this,Fp)}register(e){let t=x(this,Fp);return e instanceof Yc&&!t.includes(e)?(e.addEventListener(AD,this._scriptVersionChangeHandler,!1),t.push(e),this._parseWgslModifiers(this.modifiers?.version),!0):!1}unregister(e){let t=x(this,Fp),n=t.indexOf(e);return n>=0?(e.removeEventListener(AD,this._scriptVersionChangeHandler,!1),t.splice(n,1),this._parseWgslModifiers(this.modifiers?.version),!0):!1}get supported(){return x(this,Im)}get active(){return x(this,$m)}_webGPUNotSupported(e){x(this,Im)&&e.cause===0&&(A(this,Im,!1),this.dispatchEvent(new lk({propertyName:"supported",oldValue:null,currentValue:!1}))),x(this,$m)&&(A(this,$m,!1),this.dispatchEvent(new lk({propertyName:"active",oldValue:null,currentValue:!1})))}initialize(e){let t=x(this,Xc),n=x(this,Wp);return n.has(e)||n.add(e),_x.create(e,{enableValidation:this.enableValidation??!1,modifiers:this.modifiers}).then(i=>(t.get(e)?.update(),t.set(e,i),this._updatePipeline(e),i.canvas),i=>(this.log(xG.LogLevel.Error,i.message),this._webGPUNotSupported(i),null))}_parseWgslModifiers(e){let t=x(this,Fp),n=t.find(p=>p.type=="vertex-input"),i=t.find(p=>p.type=="vertex-output"),s=t.find(p=>p.type=="fragment"),o=n?.wgsl,c=i?.wgsl,d=s?.wgsl;this.modifiers={vertexInput:o,vertexOutput:c,fragment:d,version:e}}propertyChangedCallback(e,t,n,i){if(super.propertyChangedCallback(e,t,n,i),!i)switch(e){case"modifiers":case"enableValidation":this._reinitialize();break}}disconnectedCallback(){let e=x(this,Xc);for(let[t,n]of e)n?.dispose();e.clear(),x(this,Wp).clear(),super.disconnectedCallback()}dispose(e){let t=x(this,Xc),n=x(this,Wp);t.has(e)&&(t.get(e)?.dispose(),t.delete(e)),n.has(e)&&n.delete(e)}_reinitialize(){for(let e of x(this,Wp).values())this.initialize(e)}_ensureRenderer(e){return x(this,Xc).get(e)}_updatePipeline(e){this._ensureRenderer(e)?.update(...e.datasource)}render(e){let t=e.size?.width,n=e.size?.height;if(!(t>0)||!(n>0))return;let i=this._ensureRenderer(e);if(jc.isNull(i))return;x(this,Hm).has(e)&&(x(this,Hm).delete(e),this._itemsChangedExec(e));let s=RD(e,ak);if(i.render({cursor:s,time:performance.now(),resolution:{width:t,height:n}}),!e.interactive)return;let o=RD(e,DD);if(!jc.isNullOrEmpty(o)){if(jc.isNullOrEmpty(s)){o(null);return}i.raycast(s).then(c=>{if(jc.isNullOrEmpty(c))o(null);else{let d={object:c[0],point:null};o(d)}})}}snapshot(e,t,n,i){let s=x(this,Xc);if(!s.has(e))return Promise.resolve(null);let{canvas:o}=s.get(e),c=!jc.isNullOrEmpty(t),d=n??(c?"image/jpeg":null),p=i??(c?.9:null);return new Promise((u,h)=>{this.render(e),jc.snapshotElement(o,t,d,p).then(u)})}raycast(e,t,n,i){OD(e,DD,i),t.x<0||t.y<0||t.x>=n.width||t.y>=n.height?wG(e,ak):OD(e,ak,t)}_itemsChangedExec(e){this._updatePipeline(e)}_itemsChanged(e,t){x(this,Hm).set(e,!0)}addItem(e,t){this._itemsChanged(e,t)}removeItem(e,t){this._itemsChanged(e,t)}updateItem(e,t){(jc.isNull(t)||t.flags.indexOf("visibility")>=0||t.flags.indexOf("children")>=0)&&this._itemsChanged(e,t)}zoomFit(e,...t){return Promise.resolve()}project(e,t){return{x:0,y:0}}getScene(e){return e}};Fp=new WeakMap,Wp=new WeakMap,Xc=new WeakMap,Im=new WeakMap,$m=new WeakMap,Hm=new WeakMap,l([_G(100)],al.prototype,"_parseWgslModifiers",1),l([xx({emit:!1})],al.prototype,"modifiers",2),l([xx({emit:!1,converter:ok.Boolean})],al.prototype,"enableValidation",2),al=l([PD({tagName:ID+"-3d-webgpu-adapter"})],al);import{CustomElement as kG,P as MG,Watch as qc,PropertyConverters as jp,Utils as Yp,CustomEventUtils as ck,avoidHandler as Ov,Behaviors as SG,PropertyChangeEventName as $D}from"@pacem/pacem-core";import{Geometry as kx}from"@pacem/pacem-numerical";var Ar=kx.LinearAlgebra.Vector3D,Kc=kx.LinearAlgebra.Matrix3D,Ex=kx.LinearAlgebra.Quaternion,hve=kx.LinearAlgebra.Spherical;function LG(a){return Pr(a)?a.stage:null}var NG=1,TG=1,AG=.05,Pv=.001,Iv={maxAzimuth:180,minAzimuth:-180,inertia:!1,maxPolar:1/0,minPolar:-1/0,zoom:{enabled:!0},pan:{enabled:!0,button:2},rotation:{enabled:!0,button:0}},wx=class a{constructor(r,e){this._config=e;this._input={rho:0,theta:0,phi:0,x:0,y:0};this._progress={rho:0,theta:0,phi:0,x:0,y:0};this._startHandler=r=>{let{rotation:e,pan:t}=this._config,n=r.pointerType==="mouse",i=e.enabled&&n&&r.button===e.button&&ck.matchModifiers(r,e.modifiers),s=t.enabled&&n&&r.button===t.button&&ck.matchModifiers(r,t.modifiers);!i&&!s||(this.#t=i,(this.#e=s)&&(this._currentState=a._buildState(this._camera),Yp.extend(this._input,Ar.zero()),this._progress.x=this._progress.y=0),Ov(r),window.addEventListener("pointerup",this._endHandler,!1),window.addEventListener("pointermove",this._moveHandler,!1),window.addEventListener("contextmenu",this._avoidHandler,!1))};this._avoidHandler=r=>Ov(r);this._endHandler=r=>{Ov(r),window.setTimeout(()=>{window.removeEventListener("pointerup",this._endHandler),window.removeEventListener("pointermove",this._moveHandler),window.removeEventListener("contextmenu",this._avoidHandler)},20)};this._zoomHandler=r=>{let{zoom:e}=this._config;if(!(e.enabled&&ck.matchModifiers(r,e.modifiers)))return;Ov(r);let n=this._input;n.rho-=Math.sign(r.deltaY)};this._moveHandler=r=>{Ov(r);let{height:e,width:t}=this._scene.size,n=this._input,i=Math.min(e,t);if(this.#t){let s=-NG*360/i,{phi:o,theta:c}=n,{maxPolar:d,minPolar:p,maxAzimuth:u,minAzimuth:h}=this._config;n.phi=(o+r.movementX*s).clamp(p,d),n.theta=(c+r.movementY*s).clamp(h,u)}else if(this.#e){let s=this._currentState.radius/i;n.x+=-r.movementX*s,n.y+=r.movementY*s}};this._renderHandler=r=>{this._update()};let t=this._scene=(this._camera=r).stage;this._initialState=this._currentState=a._buildState(r);let n=this._canvas=t.stage;n.addEventListener("pointerdown",this._startHandler,!1),n.addEventListener("wheel",this._zoomHandler,{passive:!1}),t.addEventListener("render",this._renderHandler,!1)}static _buildState(r){let e=Ar.subtract(r.position,r.lookAt),t=Ar.mag(e);return{target:r.lookAt,versor:Ar.unit(e),up:r.up,radius:t,position:r.position}}static tryAttach(r,e){e??=Iv;let t=LG(r)?.stage;if(Yp.isNull(t))return null;{let{position:n,lookAt:i}=r;return Yp.isNull(n)||Yp.isNull(i)||Ar.areClose(n,i)?null:new a(r,e)}}get configuration(){return this._config}set configuration(r){this._config=r}#e;#t;_getSafeAzimuth({theta:r}){return a._modAngle(r)}_getSafePolar({phi:r}){return a._modAngle(r)}static _modAngle(r){for(;r<0;)r+=360;return r%360}static _getViewXYZ(r){let{versor:e,up:t}=r,n=Ar.cross(e,t),i=Ar.cross(n,e);return Ar.normalize(n),Ar.normalize(i),{right:n,up:i,versor:e}}#r;_update(){if(this.#r)return;this.#r=!0;let r=this._camera,{radius:e,versor:t,target:n,up:i}=this._initialState,{target:s}=this._currentState,{theta:o,phi:c,rho:d,x:p,y:u}=this._input,h=this._progress,{theta:m,phi:f,rho:g,x:v,y:b}=h,_=Math.abs(f-c)>Pv||Math.abs(m-o)>Pv,E=Math.abs(g-d)>Pv,C=Math.abs(p-v)>Pv||Math.abs(u-b)>Pv;if(E||_||C){let k=typeof this._config.inertia=="boolean"?this._config.inertia?AG:0:this._config.inertia,w=k>0&&k<1,{right:T,up:I}=a._getViewXYZ(this._initialState),O=n,D=i,P=s,N=g;w?N+=(d-g)*k:N=d,h.rho=N;let H=Math.pow(.95,N*TG),V=Ar.scale(t,-H*e);O=Ar.add(O,V);let B=f,R=m;w?(B+=(c-f)*k,R+=(o-m)*k):(B=c,R=o);let U=this._getSafePolar({phi:h.phi=B}),z=this._getSafeAzimuth({theta:h.theta=R}),G=Ar.negate(n),Z=Kc.translate(Kc.identity(),G),q=Ex.fromAxisAngle(I,U),Q=Ex.fromAxisAngle(T,z),Ne=Kc.multiply(Ex.toRotationMatrix(Q),Ex.toRotationMatrix(q));Z=Kc.multiply(Z,Ne),Z=Kc.translate(Z,Ar.negate(G)),O=Kc.transform(O,Z),D=Kc.transform(D,Kc.clone(Z,Fr=>{Fr.offsetX=Fr.offsetY=Fr.offsetZ=0}));let ne=v,pe=b,ee=ne,J=pe;w?(ee+=(p-ne)*k,J+=(u-pe)*k):(ee=p,J=u),h.x=ee,h.y=J;let{right:$e,up:ue}=a._getViewXYZ(this._currentState),Te=Ar.scale($e,ee),He=Ar.scale(ue,J),ze=Ar.add(Te,He);P=Ar.add(s,ze),r.lookAt=P,r.position=O,r.up=D,r.flags.push("camera")}this.#r=!1}dispose(){let r=this._canvas,e=this._scene;Yp.isNull(r)||(r.removeEventListener("pointerdown",this._startHandler),r.removeEventListener("wheel",this._zoomHandler)),e.removeEventListener("render",this._renderHandler,!1)}},Xp,ei=class extends SG.PacemBehavior{constructor(){super(...arguments);$(this,Xp,new Map);this._readyHandler=e=>{if(e.detail.propertyName==="isReady"&&e.detail.currentValue===!0){let t=e.currentTarget;t.removeEventListener($D,this._readyHandler),this._decorateCore(t)}}}propertyChangedCallback(e,t,n,i){switch(super.propertyChangedCallback(e,t,n,i),e){case"maxAzimuth":case"minAzimuth":case"inertia":case"zoomControl":case"panControl":case"rotationControl":let s=this._buildConfig(),o=x(this,Xp);for(let c of o.values())c.configuration=s;break}}disconnectedCallback(){let e=x(this,Xp);for(let t of e.values())t.dispose();e.clear(),super.disconnectedCallback()}_buildConfig(){return Yp.extend({},Iv,{maxAzimuth:this.maxAzimuth??1/0,minAzimuth:this.minAzimuth??-1/0,minPolar:this.minPolar??-1/0,maxPolar:this.maxPolar??1/0,inertia:this.inertia??!1,zoom:this.zoomControl??Iv.zoom,pan:this.panControl??Iv.pan,rotation:this.rotationControl??Iv.rotation})}_decorateCore(e){let t=wx.tryAttach(e,this._buildConfig());Yp.isNull(t)||x(this,Xp).set(e,t)}decorate(e){e.isConnected?this._decorateCore(e):e.addEventListener($D,this._readyHandler,!1)}undecorate(e){let t=x(this,Xp);t.has(e)&&(t.get(e).dispose(),t.delete(e))}};Xp=new WeakMap,l([qc({emit:!1,converter:jp.Number})],ei.prototype,"maxAzimuth",2),l([qc({emit:!1,converter:jp.Number})],ei.prototype,"maxPolar",2),l([qc({emit:!1,converter:jp.Number})],ei.prototype,"minAzimuth",2),l([qc({emit:!1,converter:jp.Number})],ei.prototype,"minPolar",2),l([qc({emit:!1,converter:jp.Number})],ei.prototype,"zoomControl",2),l([qc({emit:!1,converter:jp.Number})],ei.prototype,"rotationControl",2),l([qc({emit:!1,converter:jp.Number})],ei.prototype,"panControl",2),l([qc({emit:!1,converter:vC})],ei.prototype,"inertia",2),ei=l([kG({tagName:MG+"-"+"3d"+"-orbit-camera"})],ei);import{CustomElement as DG,Defaults as RG,P as nr,PCSS as ol,ViewChild as HD,Watch as BD,PropertyConverters as VD}from"@pacem/pacem-core";import{Components as OG}from"@pacem/pacem-ui";var PG=OG.UI,ll=class extends PG.PacemAdaptedIterativeElement{constructor(){super(...arguments);this.interval=4e3}};l([HD(nr+"-adapter")],ll.prototype,"adapter",2),l([HD(nr+"-slideshow")],ll.prototype,"slideshow",2),l([BD({converter:VD.Number})],ll.prototype,"interval",2),l([BD({converter:VD.Boolean})],ll.prototype,"pausable",2),ll=l([DG({tagName:nr+"-carousel",shadow:RG.USE_SHADOW_ROOT,template:`<${nr}-repeater datasource="{{ :host.datasource }}">
|
|
924
|
+
<${nr}-slideshow class="${ol}-carousel" adapter="{{ ::adapter }}" index="{{ :host.index, twoway }}" on-load="this.focus()">
|
|
925
|
+
|
|
926
|
+
<template>
|
|
927
|
+
|
|
928
|
+
<${nr}-slide class="${ol}-carousel-item" css-class="{{ { '${ol}-carousel-previous': :host.isPrevious(^index, ::slideshow.index), '${ol}-carousel-next': :host.isNext(^index, ::slideshow.index), '${ol}-carousel-focus': ^index === ::slideshow.index } }}">
|
|
929
|
+
<${nr}-a href="{{ ^item.url }}">
|
|
930
|
+
<${nr}-img disabled="{{ !:host.isCloseTo(^index, ::slideshow.index) }}" class="${ol}-carousel-splash" adapt="cover" src="{{ ^item.image }}"></${nr}-img>
|
|
931
|
+
<div class="${ol}-carousel-content">
|
|
932
|
+
<div class="${ol}-carousel-caption">
|
|
933
|
+
<h3><${nr}-text text="{{ ^item.title }}"></${nr}-text></h3>
|
|
934
|
+
<${nr}-panel class="paragraph" content="{{ ^item.content }}"></${nr}-panel>
|
|
935
|
+
</div>
|
|
936
|
+
</div>
|
|
937
|
+
</${nr}-a>
|
|
938
|
+
</${nr}-slide>
|
|
939
|
+
|
|
940
|
+
</template>
|
|
941
|
+
</${nr}-slideshow>
|
|
942
|
+
|
|
943
|
+
</${nr}-repeater><${nr}-adapter pausable="{{ :host.pausable }}" class="${ol}-carousel-adapter" interval="{{ :host.interval }}"></${nr}-adapter>`})],ll);import{CustomElement as mk,P as fk,PCSS as uk,Watch as wa,PropertyConverters as ka,Utils as Gr,CustomElementUtils as IG,avoidHandler as $G,Debounce as HG,ViewChild as BG,Components as hk,CommandEvent as VG,CommandEventName as pk,AttributeChangeEventName as UD}from"@pacem/pacem-core";import{Components as UG}from"@pacem/pacem-ui";var qp=UG.UI,Vm=class extends hk.PacemItemElement{connectedCallback(){super.connectedCallback(),Gr.addClass(this,uk+"-context-menuitem")}propertyChangedCallback(r,e,t,n){super.propertyChangedCallback(r,e,t,n);let i=this.container;i instanceof Ma&&i.refresh()}},ti=class extends Vm{createMenuItemElement(){let r=new qp.PacemButtonElement;return r.commandArgument=this.commandArgument,r.commandName=this.commandName,r.textContent=this.caption,r.iconGlyph=this.iconGlyph,r.confirmationDialog=this.confirmationDialog,r.confirmationMessage=this.confirmationMessage,r.tooltip=this.tooltip,r.disabled=this.disabled,r.cssClass=this.buttonCssClass,r}};l([wa({emit:!1,reflectBack:!0,converter:ka.String})],ti.prototype,"commandName",2),l([wa({emit:!1,reflectBack:!0,converter:ka.String})],ti.prototype,"caption",2),l([wa({emit:!1,reflectBack:!0,converter:ka.String})],ti.prototype,"tooltip",2),l([wa({emit:!1,reflectBack:!0,converter:ka.String})],ti.prototype,"iconGlyph",2),l([wa({emit:!1,reflectBack:!0,converter:ka.StringArray})],ti.prototype,"buttonCssClass",2),l([wa({emit:!1,reflectBack:!0,converter:ka.String})],ti.prototype,"confirmationMessage",2),l([wa({emit:!1,reflectBack:!0,converter:ka.Element})],ti.prototype,"confirmationDialog",2),l([wa({emit:!1,reflectBack:!0,converter:ka.Json})],ti.prototype,"commandArgument",2),ti=l([mk({tagName:fk+"-context-menuitem-command"})],ti);var $v=class extends Vm{createMenuItemElement(){let r=document.createElement("hr");return r.style.pointerEvents="none",r}};$v=l([mk({tagName:fk+"-context-menuitem-separator"})],$v);var cl,Bm,Jc,Ma=class extends hk.PacemItemsContainerElement{constructor(){super(...arguments);this._dispatchCommand=e=>{$G(e),this._onCommand(new VG({commandName:e.detail.commandName,commandArgument:e.detail.commandArgument??this.commandArgument}))};$(this,cl);$(this,Bm);$(this,Jc);this._slotchangeHandler=e=>{this._resetLayout()};this._attributeChangeHandler=e=>this._refreshMenuItems;this._mouseupHandler=e=>{let t=this._ensureBalloon();Gr.isNull(t)||t.popout()}}validate(e){return e instanceof Vm}_ensureButton(){if(!Gr.isNull(x(this,cl)))return x(this,cl);let e=this._slot;if(Gr.isNull(e))return null;let t=this._lookForAButton();if(!Gr.isNull(t))return A(this,cl,t);let n=new qp.PacemButtonElement;n.setAttribute("slot","button"),n.className=`${uk}-margin margin-0 button-flat`;let i=A(this,Bm,new qp.PacemIconElement);return n.appendChild(i),this.appendChild(n),A(this,cl,n)}_lookForAButton(){let e=this._slot;if(Gr.isNull(e))return null;let t=e.assignedElements({flatten:!0});return Gr.isNullOrEmpty(t)?null:t[0]}_ensureBalloon(){let e=x(this,Jc);if(!Gr.isNull(e))return e;let t=IG.findAncestorShell(this);return Gr.isNull(t)?null:(e=new qp.PacemBalloonElement,e.options={trigger:qp.BalloonTrigger.Click,position:qp.BalloonPosition.HorizontalAuto,align:qp.BalloonAlignment.Auto,autoAdjust:!0},e.addEventListener(pk,this._dispatchCommand,!1),e.className=`${uk}-contextmenu`,t.appendChild(e),A(this,Jc,e))}register(e){let t=super.register(e);return t&&(e.addEventListener(UD,this._attributeChangeHandler,!1),this._refreshMenuItems()),t}unregister(e){let t=super.unregister(e);return t&&(e.removeEventListener(UD,this._attributeChangeHandler,!1),this._refreshMenuItems()),t}_onCommand(e){this.dispatchEvent(new CustomEvent(pk,{detail:e.detail,cancelable:!0,bubbles:!0})),this.dispatchEvent(new CustomEvent(e.detail.commandName.toLowerCase(),{detail:e.detail.commandArgument,cancelable:!0,bubbles:!0}))}_resetLayout(){let e=this._ensureButton(),t=this._ensureBalloon();!Gr.isNull(e)&&!Gr.isNull(t)&&(t.target=e),this._toggleBtn(),this._toggleIcon()}_toggleBtn(e=this.disabled){let t=x(this,cl);!Gr.isNull(t)&&t instanceof hk.PacemElement&&(t.disabled=e)}_toggleIcon(e=this.icon){let t=x(this,Bm);Gr.isNull(t)||(t.icon=e)}viewActivatedCallback(){super.viewActivatedCallback(),this._resetLayout(),this._slot.addEventListener("slotchange",this._slotchangeHandler,!1)}propertyChangedCallback(e,t,n,i){if(super.propertyChangedCallback(e,t,n,i),!i)switch(e){case"icon":this._toggleIcon(n);break;case"disabled":this._toggleBtn(n);break}}disconnectedCallback(){this._disposeButton(),this._disposeSlot(),this._disposeBalloon(),super.disconnectedCallback()}refresh(){this._refreshMenuItems()}_disposeButton(){A(this,cl,A(this,Bm,null))}_disposeSlot(){let e=this._slot;Gr.isNull(e)||e.removeEventListener("slotchange",this._slotchangeHandler,!1)}_disposeBalloon(){let e=x(this,Jc);Gr.isNull(e)||(e.removeEventListener(pk,this._dispatchCommand,!1),this._disposeBalloonChildren(0),e.remove(),A(this,Jc,null))}_disposeBalloonChildren(e){let t=x(this,Jc),n=t.children.length;for(let i=n-1;i>=e;i--){let s=t.children.item(i);s.removeEventListener("mouseup",this._mouseupHandler,!1),s.remove()}}_refreshMenuItems(){let e=this._ensureBalloon();if(Gr.isNull(e))return;let t=e.children.length,n=0;for(let i of this.items){if(i.hide)continue;let s=i.createMenuItemElement();if(s.addEventListener("mouseup",this._mouseupHandler,!1),n<t){let o=e.children.item(n);o.removeEventListener("mouseup",this._mouseupHandler,!1),o.replaceWith(s)}else e.appendChild(s);n++}this._disposeBalloonChildren(n)}};cl=new WeakMap,Bm=new WeakMap,Jc=new WeakMap,l([BG("slot[name=button]")],Ma.prototype,"_slot",2),l([wa({converter:ka.Json})],Ma.prototype,"commandArgument",2),l([wa({converter:ka.String})],Ma.prototype,"icon",2),l([HG(!0)],Ma.prototype,"_refreshMenuItems",1),Ma=l([mk({tagName:fk+"-context-menu",shadow:!0,template:'<slot name="button"></slot><slot></slot>'})],Ma);import{CustomElement as zG,P as dl,PCSS as Hv,Watch as Zc,PropertyConverters as Kp,Utils as ft,PropertyChangeEventName as Qc,Components as GG,avoidHandler as FG}from"@pacem/pacem-core";import{Components as WG}from"@pacem/pacem-ui";import{Components as jG}from"@pacem/pacem-scaffolding";var Mx=WG.UI,gk=jG.Scaffolding,zD=(n=>(n.Text="text",n.Html="html",n.Image="image",n.Markdown="markdown",n))(zD||{}),ri=class extends GG.PacemElement{constructor(e=new Mx.MarkdownService){super();this._markdown=e;this._dialogPropertyChangedHandler=e=>{this._dialogPropertyChangedCallback(e)};this._broadcastFetchRequestEventName=e=>{this.dispatchEvent(new gk.ImageFetchRequestEvent(e.detail))};this._innerValueChangedHandler=e=>{e.detail.propertyName==="value"&&!ft.isNull(this._dialog)&&(this._dialog.state=e.detail.currentValue)};this._editHandler=e=>{this.edit(e)}}_addButton(){if(ft.isNull(this._button)){var e=document.createElement(dl+"-button");return e.className=Hv+"-edit-button",e.addEventListener("click",this._editHandler,!1),this._target.appendChild(e),this._button=e}}_removeButton(){var e=this._button;ft.isNull(e)||(e.removeEventListener("click",this._editHandler,!1),e.remove(),this._button=null)}_addDialog(){var e=document.createElement(dl+"-dialog");return e.buttons=Mx.DialogButtons.OkCancel,e.addEventListener(Qc,this._dialogPropertyChangedHandler,!1),e.appendChild(this._addTextarea()),e.appendChild(this._addContenteditable()),e.appendChild(this._addEditImage()),document.body.appendChild(e),this._dialog=e}_removeDialog(){this._removeTextarea(),this._removeContenteditable(),this._removeEditImage(),ft.isNull(this._dialog)||(this._dialog.removeEventListener(Qc,this._dialogPropertyChangedHandler,!1),this._dialog.remove())}_addTextarea(){var e=document.createElement(dl+"-textarea");e.className=Hv+"-edit-text",e.addEventListener(Qc,this._innerValueChangedHandler,!1);let t=this.type||"text";return e.hide=t!=="text"&&t!=="markdown",this._textarea=e}_removeTextarea(){ft.isNull(this._textarea)||this._textarea.removeEventListener(Qc,this._innerValueChangedHandler,!1)}_addContenteditable(){var e=document.createElement(dl+"-contenteditable");e.className=Hv+"-edit-content",e.addEventListener(Qc,this._innerValueChangedHandler,!1);let t=this.type||"text";return e.hide=t!=="html",this._contenteditable=e}_removeContenteditable(){ft.isNull(this._contenteditable)||this._contenteditable.removeEventListener(Qc,this._innerValueChangedHandler,!1)}_addEditImage(){var e=document.createElement(dl+"-edit-image");e.disabled=!0,e.addEventListener(Qc,this._innerValueChangedHandler,!1),e.addEventListener(gk.ImageFetchRequestEventName,this._broadcastFetchRequestEventName,!1);let t=this.type||"text";return e.hide=t!=="image",e.uploadUrl=this.imageUploadUrl,e.allowSnapshot=this.allowSnapshot,e.maxWidth=this.maxImageWidth,e.maxHeight=this.maxImageHeight,this._editImage=e}_removeEditImage(){ft.isNull(this._editImage)||(this._editImage.removeEventListener(Qc,this._innerValueChangedHandler,!1),this._editImage.removeEventListener(gk.ImageFetchRequestEventName,this._broadcastFetchRequestEventName,!1))}_update(e){var t=this._content;switch(this.type){case"html":t.innerHTML=e;break;case"markdown":t.localName===dl+"-markdown"?t.value=e:t.innerHTML=this._markdown.toHtml(e);break;case"image":switch(t.localName){case"img":case dl+"-img":t.src=e;break;default:t.style.backgroundImage=`url(${e})`;break}break;default:this._content.textContent=e;break}}_retrieve(){var e=this._content;switch(this.type){case"html":return e.innerHTML;case"image":switch(e.localName){case dl+"-img":case"img":return e.src;default:let t=getComputedStyle(e).backgroundImage,n=/url\(["']?([^'"]+)["']?\)/.exec(t);return n&&n.length&&n[1]}case"markdown":return e.value||e.textContent;default:return e.textContent}}_setup(){this.disabled?(ft.removeClass(this._target,Hv+"-editing"),this._removeButton()):(ft.addClass(this._target,Hv+"-editing"),this._addButton())}_dialogPropertyChangedCallback(e){if(e.detail.propertyName==="state"){let t=e.detail.currentValue;ft.isNull(this._textarea)||(this._textarea.value=t),ft.isNull(this._contenteditable)||(this._contenteditable.value=t),ft.isNull(this._editImage)||(this._editImage.value=t),this._update(e.detail.currentValue)}}get _target(){var e=this.target;return ft.isNull(e)&&(e=this.firstElementChild),e}connectedCallback(){super.connectedCallback(),this._addDialog()}viewActivatedCallback(){super.viewActivatedCallback(),this._addButton(),this._setup()}disconnectedCallback(){this._removeButton(),this._removeDialog(),super.disconnectedCallback()}propertyChangedCallback(e,t,n,i){switch(super.propertyChangedCallback(e,t,n,i),e){case"imageUploadUrl":ft.isNull(this._editImage)||(this._editImage.uploadUrl=n);break;case"allowSnapshot":ft.isNull(this._editImage)||(this._editImage.allowSnapshot=n);break;case"imageSet":ft.isNull(this._editImage)||(this._editImage.imageSet=n);break;case"disabled":this._setup();break;case"type":let s=n;ft.isNull(this._textarea)||(this._textarea.hide=s!=="text"&&s!=="markdown"),ft.isNull(this._contenteditable)||(this._contenteditable.hide=s!=="html"),ft.isNull(this._editImage)||(this._editImage.hide=s!=="image");break;case"maxImageHeight":ft.isNull(this._editImage)||(this._editImage.maxHeight=n);break;case"maxImageWidth":ft.isNull(this._editImage)||(this._editImage.maxWidth=n);break}}edit(e){FG(e);var t=this._target;if(!ft.isNull(t)){this._removeButton(),this._content=t;var n=this._state=this._retrieve();ft.isNull(this._editImage)||(this._editImage.disabled=!1),this._dialog.open(n).then(i=>{switch(i.button){case Mx.DialogButton.Cancel:this._update(this._state);break;case Mx.DialogButton.Ok:this._update(i.state),this.dispatchEvent(new CustomEvent("commit",{detail:{value:i.state}}));break}this._content=null,ft.isNull(this._editImage)||(this._editImage.disabled=!0),this._addButton()})}}};l([Zc({emit:!1,converter:Kp.String})],ri.prototype,"key",2),l([Zc({converter:Kp.String})],ri.prototype,"type",2),l([Zc({converter:Kp.Element})],ri.prototype,"target",2),l([Zc({emit:!1,converter:Kp.String})],ri.prototype,"imageUploadUrl",2),l([Zc({emit:!1})],ri.prototype,"imageSet",2),l([Zc({emit:!1,converter:Kp.Number})],ri.prototype,"maxImageWidth",2),l([Zc({emit:!1,converter:Kp.Number})],ri.prototype,"maxImageHeight",2),l([Zc({emit:!1,converter:Kp.Boolean})],ri.prototype,"allowSnapshot",2),ri=l([zG({tagName:dl+"-edit"})],ri);import{CustomElement as YG,Defaults as XG,P as Ze,PCSS as Sa,ViewChild as Um,Watch as Sx,PropertyConverters as vk,Utils as ed,Components as GD}from"@pacem/pacem-core";import{Components as qG}from"@pacem/pacem-ui";var FD=qG.UI;function WD(a=jD(),r="image"){return`<${Ze}-slide class="${Sa}-gallery-item"
|
|
944
|
+
css-class="{{ { '${Sa}-gallery-previous': :host.isPrevious(^index, ::_slideshow.index), '${Sa}-gallery-next': :host.isNext(^index, ::_slideshow.index), '${Sa}-gallery-focus': ^index === ::_slideshow.index } }}"
|
|
945
|
+
>
|
|
946
|
+
<${Ze}-img src="{{ ^item.${r} }}" disabled="{{ !::_lightbox.show || !(:host.isCloseTo(^index, ::_slideshow.index) || ^index === ::_slideshow.index) }}"
|
|
947
|
+
css="{{ {'visibility': (:host._poppingUp ? 'hidden' : ''), 'transition': (:host._poppingUp ? 'none' : '')} }}" class="${Sa}-gallery-splash" adapt="contain"></${Ze}-img>
|
|
948
|
+
|
|
949
|
+
${a}
|
|
950
|
+
|
|
951
|
+
</${Ze}-slide>`}function jD(a="caption"){return`<${Ze}-panel hide="{{ $pacem.isNullOrEmpty(^item.${a}) }}" class="${Sa}-gallery-caption gallery-caption-default">
|
|
952
|
+
<${Ze}-span class="paragraph" text="{{ ^item.${a} }}"></${Ze}-span>
|
|
953
|
+
</${Ze}-panel>`}var cn=class extends FD.PacemAdaptedIterativeElement{constructor(){super(...arguments);this._templateChangeHandler=e=>{let t=e.target;this._setupWithCaptionTemplate(t.target)}}viewActivatedCallback(){super.viewActivatedCallback(),this._setupWithCaptionTemplate(),this._databind()}propertyChangedCallback(e,t,n,i){if(super.propertyChangedCallback(e,t,n,i),!i)switch(e){case"datasource":this._databind();break;case"captionTemplate":this._setupWithCaptionTemplate(n,t);break;case"imageProperty":this._setupWithCaptionTemplate(this.captionTemplate,this.captionTemplate);break;case"captionProperty":ed.isNull(this.captionTemplate)&&this._setupDefaultTemplate();break}}disconnectedCallback(){this._disposeTemplate(),super.disconnectedCallback()}_disposeTemplate(e=this.captionTemplate){e instanceof GD.PacemTemplateProxyElement&&e.removeEventListener("templatechange",this._templateChangeHandler)}_setupWithCaptionTemplate(e=this.captionTemplate,t){if(this._disposeTemplate(t),ed.isNull(e)){this._setupDefaultTemplate();return}e instanceof GD.PacemTemplateProxyElement&&(e.addEventListener("templatechange",this._templateChangeHandler,!1),e=e.target);let n=e.content.firstElementChild;ed.addClass(n,Sa+"-gallery-caption");let i=document.createElement("template");i.innerHTML=WD(e.innerHTML,this.imageProperty),this._setupTemplate(i)}_setupTemplate(e){this._templateProxy.target=e}_setupDefaultTemplate(){let e=document.createElement("template");e.innerHTML=WD(jD(this.captionProperty),this.imageProperty),this._setupTemplate(e)}_databind(){let e=this._repeater;ed.isNull(e)||(e.datasource=this.datasource)}get adapter(){return this._adapter}async _heroAnimate(e,t){if(!ed.isNull(e)){let n=new FD.PacemImageElement,i=this._heroPlaceholderProxy.dom[0],s=300;n.src=t||e.src,n.adapt="contain";let o=ed.offset(i),c=ed.offset(e),d=n.style,p=getComputedStyle(i);d.border=p.border,d.width=i.clientWidth+"px",d.height=i.clientHeight+"px",d.position="absolute",d.zIndex=p.zIndex,d.top=o.top+"px",d.left=o.left+"px";let u=e.clientWidth/i.clientWidth,h=e.clientHeight/i.clientHeight,m=c.left-o.left+"px",f=c.top-o.top+"px";d.transformOrigin="0 0",d.transition=`transform cubic-bezier(0.445, 0.05, 0.55, 0.95) ${s}ms, opacity ${s}ms`,d.transform=`translate(${m}, ${f}) scale(${u}, ${h})`,document.body.appendChild(n),requestAnimationFrame(()=>{n.style.transform=""}),await ed.waitForAnimationEnd(n,s),n.remove()}}open(e,t,n){this._poppingUp=!0,this._lightbox.show=!0,this._slideshow.index=e,this._heroAnimate(t,n).then(i=>{this._poppingUp=!1,this._slideshow.focus()})}};l([Um(Ze+"-adapter")],cn.prototype,"_adapter",2),l([Um(Ze+"-lightbox")],cn.prototype,"_lightbox",2),l([Um(Ze+"-slideshow")],cn.prototype,"_slideshow",2),l([Um(Ze+"-repeater")],cn.prototype,"_repeater",2),l([Um(Ze+"-template-proxy")],cn.prototype,"_templateProxy",2),l([Um(Ze+"-shell-proxy")],cn.prototype,"_heroPlaceholderProxy",2),l([Sx()],cn.prototype,"_poppingUp",2),l([Sx({emit:!1,converter:vk.Element})],cn.prototype,"captionTemplate",2),l([Sx({emit:!1,converter:vk.String})],cn.prototype,"captionProperty",2),l([Sx({emit:!1,converter:vk.String})],cn.prototype,"imageProperty",2),cn=l([YG({tagName:Ze+"-gallery",shadow:XG.USE_SHADOW_ROOT,template:`<${Ze}-lightbox class="${Sa}-gallery">
|
|
954
|
+
<${Ze}-repeater>
|
|
955
|
+
<${Ze}-slideshow adapter="{{ ::_adapter }}" index="{{ :host.index, twoway }}" hide="{{ !::_lightbox.show }}">
|
|
956
|
+
<${Ze}-template-proxy></${Ze}-template-proxy>
|
|
957
|
+
</${Ze}-slideshow>
|
|
958
|
+
</${Ze}-repeater>
|
|
959
|
+
<${Ze}-adapter class="${Sa}-gallery-adapter"></${Ze}-adapter>
|
|
960
|
+
</${Ze}-lightbox>
|
|
961
|
+
<${Ze}-shell-proxy><div class="${Sa}-gallery-hero-target"></div></${Ze}-shell-proxy>`})],cn);import{CustomElement as KG,Defaults as JG,P as Qe,PCSS as pl,Watch as $i,PropertyConverters as Hi,ViewChild as bk,Utils as Bv,Net as ZG,avoidHandler as QG}from"@pacem/pacem-core";import{Components as eF}from"@pacem/pacem-ui";import{Components as tF}from"@pacem/pacem-scaffolding";var Vv=eF.UI,Uv,Dt=class extends Vv.PacemDialogBase{constructor(){super();this.suddenValidation=!0;this.method=ZG.HttpMethod.Post;this._keyupHandler=e=>{if(e.keyCode===13&&!e.shiftKey&&!e.ctrlKey&&!e.altKey&&!e.metaKey){let t=e.currentTarget.querySelector(`.${pl}-dialog-buttons ${Qe}-button[type=submit]`);!Bv.isNull(t)&&Bv.isVisible(t)&&!t.disabled&&t.click()}};$(this,Uv,!1);this._emitter=new tF.Scaffolding.FormEventEmitter(this)}get form(){return this._form}viewActivatedCallback(){super.viewActivatedCallback(),this.addEventListener("keyup",this._keyupHandler,!1),this._emitter.start()}disconnectedCallback(){this._emitter.stop(),this.removeEventListener("keyup",this._keyupHandler,!1),super.disconnectedCallback()}_submit(e){this.readonly?this.commit(Vv.DialogButton.Ok,e):(QG(e),this._form.validate().then(t=>{t&&(Bv.isNullOrEmpty(this.action)?this.commit(Vv.DialogButton.Ok,e):this._form.submit(this._fetcher).then(n=>{this.commit(Vv.DialogButton.Ok,e)},n=>{}))}))}_onSubmit(e){this.emit(e)}open(e,t,n=!0){if(Bv.isNull(e))throw`The state of a ${Dt} cannot be null.`;A(this,Uv,t);var i=super.open(e);return n&&this._form.setPristine(),i}commit(e,t){super.commit(e,t),x(this,Uv)||Bv.waitForAnimationEnd(this,500).then(n=>{this.state={}})}_cancel(e){this.commit(Vv.DialogButton.Cancel,e),this._form.reset()}_broadcast(e){this.dispatchEvent(new CustomEvent(e.type,{detail:e.detail}))}get modalButtons(){let e=this._buttons;return{ok:e&&e.firstElementChild&&e.firstElementChild.firstElementChild,cancel:e&&e.firstElementChild&&e.firstElementChild.lastElementChild}}};Uv=new WeakMap,l([$i({converter:Hi.Boolean})],Dt.prototype,"suddenValidation",2),l([$i({reflectBack:!0,converter:Hi.String})],Dt.prototype,"okCaption",2),l([$i({reflectBack:!0,converter:Hi.String})],Dt.prototype,"cancelCaption",2),l([$i({reflectBack:!0,converter:Hi.String})],Dt.prototype,"method",2),l([$i({converter:Hi.Json})],Dt.prototype,"metadata",2),l([$i({converter:Hi.String})],Dt.prototype,"action",2),l([$i({converter:Hi.String})],Dt.prototype,"loaderType",2),l([$i({converter:Hi.Boolean})],Dt.prototype,"success",2),l([$i({converter:Hi.Boolean})],Dt.prototype,"fail",2),l([$i({converter:Hi.Boolean})],Dt.prototype,"readonly",2),l([$i({converter:Hi.Json})],Dt.prototype,"fetchHeaders",2),l([$i({converter:Hi.String})],Dt.prototype,"fetchCredentials",2),l([bk(Qe+"-lightbox")],Dt.prototype,"lightbox",2),l([bk(Qe+"-form[entity]")],Dt.prototype,"_form",2),l([bk(Qe+"-fetch")],Dt.prototype,"_fetcher",2),Dt=l([KG({tagName:Qe+"-modal-form",shadow:JG.USE_SHADOW_ROOT,template:`<${Qe}-lightbox modal="true" logger="{{ :host.logger }}">
|
|
962
|
+
<${Qe}-form wrapper>
|
|
963
|
+
<${Qe}-form logger="{{ :host.logger }}" on-submit=":host._onSubmit($event)" readonly="{{ :host.readonly }}" entity="{{ :host.state, twoway }}" on-success=":host._broadcast($event)"
|
|
964
|
+
on-fail=":host._broadcast($event)" success="{{ :host.success, twoway }}" fail="{{ :host.fail, twoway }}" autogenerate="{{ !$pacem.isNull($this.entity) }}" metadata="{{ :host.metadata }}"
|
|
965
|
+
fetch-headers="{{ :host.fetchHeaders }}" fetch-credentials="{{ :host.fetchCredentials }}" sudden-validation="{{ :host.suddenValidation }}"></${Qe}-form>
|
|
966
|
+
</${Qe}-form>
|
|
967
|
+
<${Qe}-fetch logger="{{ :host.logger }}" method="{{ :host.method }}" headers="{{ :host.fetchHeaders }}" credentials="{{ :host.fetchCredentials }}" autofetch="false" url="{{ :host.action }}"></${Qe}-fetch>
|
|
968
|
+
<div class="${pl}-dialog-buttons ${pl}-buttonset buttons" slot="bottom">
|
|
969
|
+
<div class="buttonset-left">
|
|
970
|
+
<${Qe}-button on-click=":host._submit($event)" css-class="{{ {'buttonset-last': :host.readonly} }}" type="submit"
|
|
971
|
+
class="button primary button-size size-small" disabled="{{ (:host.suddenValidation && !:host.readonly && !(::_form.valid && ::_form.dirty)) || ::_fetcher.fetching }}">
|
|
972
|
+
<${Qe}-panel class="submit-spinner ${pl}-anim anim-pop" hide="{{ !::_form.fetching }}"><i class="${pl}-icon ${pl}-anim anim-rotate rotate-uniform display-block">refresh</i></${Qe}-panel>
|
|
973
|
+
<${Qe}-text text="{{ :host.okCaption || 'OK' }}"></${Qe}-text>
|
|
974
|
+
</${Qe}-button>
|
|
975
|
+
<${Qe}-button on-click=":host._cancel($event)" hide="{{ :host.readonly }}" class="button button-size size-small" disabled="{{ ::_fetcher.fetching }}"><${Qe}-text text="{{ :host.cancelCaption || 'Cancel' }}"></${Qe}-text></${Qe}-button>
|
|
976
|
+
</div></div>
|
|
977
|
+
<div class="${pl}-dialog-heading" slot="top">
|
|
978
|
+
<${Qe}-content></${Qe}-content>
|
|
979
|
+
</div>
|
|
980
|
+
<div class="pos-absolute absolute-top absolute-right absolute-left absolute-bottom overflow-hidden ${pl}-inert display-flex flex-center flex-middle">
|
|
981
|
+
<${Qe}-loader type="{{ :host.loaderType }}" class="loader-primary loader-smaller ${pl}-anim anim-pop" active="{{ ::_fetcher.fetching }}"></${Qe}-loader>
|
|
982
|
+
</div>
|
|
983
|
+
</${Qe}-lightbox>`})],Dt);import{CustomElement as rF,P as nF,Watch as Lx,PropertyConverters as zm,Utils as gt,PacemEventTarget as iF}from"@pacem/pacem-core";var hl,ul=class extends iF{constructor(){super(...arguments);this.default={};this.state={};this.normalizedState={};$(this,hl);this._routerNavigatingHandler=e=>{A(this,hl,!0)};this._routerNavigateHandler=e=>{A(this,hl,!1),this._updateStateFromURI()}}viewActivatedCallback(){super.viewActivatedCallback(),this._updateStateFromURI(),this._setupRouterHandlers(this.router)}propertyChangedCallback(e,t,n,i){switch(super.propertyChangedCallback(e,t,n,i),e){case"state":!i&&!x(this,hl)&&(this._updateNormalizedState(),this._updateURIFromState());break;case"disabled":n&&this._updateStateFromURI();break;case"default":this._updateStateFromURI();break;case"router":i||(this._disposeRouterHandlers(t),this._setupRouterHandlers(n));break}}disconnectedCallback(){this._disposeRouterHandlers(),super.disconnectedCallback()}_setupRouterHandlers(e=this.router){gt.isNull(e)||(window.addEventListener("navigating",this._routerNavigatingHandler,!1),window.addEventListener("navigate",this._routerNavigateHandler,!1))}_disposeRouterHandlers(e=this.router){gt.isNull(e)||(window.removeEventListener("navigating",this._routerNavigatingHandler,!1),window.removeEventListener("navigate",this._routerNavigateHandler,!1))}_currentBasePath(){let e=this.router;if(!gt.isNull(e)){let t=e.state.$querystring;return this._normalizePath(document.location.pathname,t)}return null}_normalizePath(e,t){return gt.isNullOrEmpty(e)?e:(e.endsWith("/")&&(e=e.substring(0,e.length-1)),t??="",e+(t.length>0?"?"+t:""))}_areStatesEquivalent(e,t){let n=gt.extend({},e||{}),i=gt.extend({},t||{});for(let s in n){if(!this._areSubstantiallyEquivalent(n[s],i[s]))return!1;delete n[s],delete i[s]}for(let s in i)if(!this._areSubstantiallyEquivalent(n[s],i[s]))return!1;return!0}_updateNormalizedState(e=this.state){if(this.disabled||x(this,hl))return;let t=this._normalizeState(e);this._areStatesEquivalent(t,this.normalizedState)||(this.normalizedState=t)}_updateStateFromURI(){if(this.disabled||x(this,hl))return;var e=gt.extend({},this.default||{});let t=this.router;if(!gt.isNull(t)){let n=this._denormalizeState(gt.URIs.parseQuery(t.state&&t.state.$hash||"{}"));gt.extend(e,n)}this._areStatesEquivalent(this.state,e)||(this.state=e)}_updateURIFromState(e=this.normalizedState){if(this.disabled||x(this,hl))return;let t=this.router;if(!gt.isNull(t)){let i=this._currentBasePath(),s=gt.URIs.parseQuery(t.state.$hash||"{}"),o=e||{};if(!this._areStatesEquivalent(s,o)){let c=this._cleanupStateForURI(o);var n=i;gt.isNullOrEmpty(c)||(n=gt.URIs.appendQuery(i,c,!1,!0)),t.path=n}}}_areSubstantiallyEquivalent(e,t){return e??="",t??="",e.toString()==t.toString()||gt.areSemanticallyEqual(e,t)||JSON.stringify(e)===JSON.stringify(t)}_cleanupStateForURI(e=this.state){let t=gt.clone(e||{}),n=this.default;for(let i in t)(gt.isNullOrEmpty(t[i])&&(gt.isNull(n)||!(i in n))||!gt.isNull(n)&&i in n&&this._areSubstantiallyEquivalent(n[i],t[i]))&&delete t[i];return t}_normalizeState(e=this.state,t=this.default){var n={};let i=t;for(let s in e||{}){let o=e[s];if(gt.isNullOrEmpty(o)){!gt.isNull(i)&&s in i&&!gt.isNullOrEmpty(i[s])&&(n[s]="");continue}switch(typeof o){case"number":case"bigint":case"boolean":Object.defineProperty(n,s,{enumerable:!0,value:o.toString()});break;case"symbol":case"string":Object.defineProperty(n,s,{enumerable:!0,value:o});break;default:if(gt.Dates.isDate(o))Object.defineProperty(n,s,{enumerable:!0,value:o.toISOString()});else if(o instanceof RegExp)Object.defineProperty(n,s,{enumerable:!0,value:o.source});else throw new Error("Type not supported to be normalized into a URI hash.");break}}return n}_denormalizeState(e=this.normalizedState,t=this.default){let n={},i=t||{};for(let s in e){if(!(s in i)){n[s]=e[s];continue}let o=i[s],c=e[s];switch(typeof o){case"boolean":Object.defineProperty(n,s,{enumerable:!0,value:zm.Boolean.convert(c)});break;case"number":case"bigint":Object.defineProperty(n,s,{enumerable:!0,value:zm.Number.convert(c)});break;case"symbol":case"string":Object.defineProperty(n,s,{enumerable:!0,value:zm.String.convert(c)});break;default:o instanceof Date?Object.defineProperty(n,s,{enumerable:!0,value:zm.Date.convert(c)}):o instanceof RegExp?Object.defineProperty(n,s,{enumerable:!0,value:new RegExp(c,o.flags)}):Object.defineProperty(n,s,{enumerable:!0,value:c});break}}return n}set(e,t){var n={};typeof e=="string"?Object.defineProperty(n,e,{enumerable:!0,value:t}):n=e,this.state=gt.extend({},this.state||{},n)}};hl=new WeakMap,l([Lx({emit:!1,converter:zm.Element})],ul.prototype,"router",2),l([Lx({emit:!1,converter:zm.Json})],ul.prototype,"default",2),l([Lx()],ul.prototype,"state",2),l([Lx()],ul.prototype,"normalizedState",2),ul=l([rF({tagName:nF+"-router-hash-state"})],ul);import{CustomElement as sF,Defaults as aF,P as La,Watch as zv,PropertyConverters as Nx,ViewChild as oF,Components as lF}from"@pacem/pacem-core";var _s=class extends lF.PacemElement{constructor(){super(...arguments);this.hintParameter="q"}propertyChangedCallback(e,t,n,i){if(super.propertyChangedCallback(e,t,n,i),e==="hint"){let s={};s[this.hintParameter]=n,this._fetcher.parameters=s}}};l([oF(La+"-fetch")],_s.prototype,"_fetcher",2),l([zv()],_s.prototype,"datasource",2),l([zv({converter:Nx.String})],_s.prototype,"hint",2),l([zv({converter:Nx.String})],_s.prototype,"url",2),l([zv({converter:Nx.String})],_s.prototype,"method",2),l([zv({emit:!1,converter:Nx.String})],_s.prototype,"hintParameter",2),_s=l([sF({tagName:La+"-search",shadow:aF.USE_SHADOW_ROOT,template:`<${La}-fetch debounce="800" url="{{ :host.url }}" method="{{ :host.method }}">
|
|
984
|
+
</${La}-fetch><${La}-input-search value="{{ :host.hint, twoway }}"></${La}-input-search>
|
|
985
|
+
<${La}-repeater datasource="{{ ::_fetch.result }}">
|
|
986
|
+
<${La}-content></${La}-content>
|
|
987
|
+
</${La}-repeater>`})],_s);import{CustomElement as cF,P as Gm,PCSS as yk,Watch as _k,PropertyConverters as xk,Utils as Dr,CustomElementUtils as dF,ViewChild as pF}from"@pacem/pacem-core";var qD="datarowselectchange",Gv=class extends CustomEvent{constructor(r){super(qD,{detail:r,bubbles:!1,cancelable:!0})}},YD={},XD=[],ml=class extends Wi{updateLayout(r=this.metadata){this._setup(r)}connectedCallback(){super.connectedCallback(),Dr.addClass(this,yk+"-datacell")}propertyChangedCallback(r,e,t,n){if(super.propertyChangedCallback(r,e,t,n),!n)switch(r){case"_contentTooltip":this._updateTooltipJustInCase();break;case"gridState":case"rowindex":this._updateSelection();break}}_updateTooltipJustInCase(){(this.metadata.dataCell?.autoTooltip??!0)&&!Dr.isNullOrEmpty(this._contentTooltip)?this.setAttribute("tooltip",this._contentTooltip):this.removeAttribute("tooltip")}_inflateContent(r=this.dataitem,e=this.rowindex,t=this.metadata){this._contentTooltip="";let n=t.dataCell?.format,i=t.dataCell?.null??"";if(typeof n=="function"){let d=n(this,t,r,e);return Dr.isNullOrEmpty(d)?i:d}let o=dF.resolvePath(t.prop,r)?.target?.value;if(Dr.isNullOrEmpty(o))return i;let c=Dr.lang(this);switch(t.dataType){case"boolean":return`<${Gm}-icon icon="material ${o?"check_circle_outline":"radio_button_unchecked"} text-big-steady"></${Gm}-icon>`;case"time":case"date":case"datetime":return this._contentTooltip=Dr.core.date(o,n,c);case"byte":case"int16":case"int32":case"int64":case"short":case"integer":case"int":case"long":case"double":case"decimal":case"float":case"single":case"number":return this._contentTooltip=Dr.core.number(o,n||"",c);case"currency":return n??="EUR",typeof n=="string"?this._contentTooltip=Dr.core.currency(o,n,c):this._contentTooltip=Dr.core.number(o,n,c);case"percent":case"percentage":return n??={style:"percent",maximumFractionDigits:2},typeof n=="string"?this._contentTooltip=Dr.core.currency(o,n,c):this._contentTooltip=Dr.core.number(o,n,c);default:return this._contentTooltip=o}}_inflateCssClass(r=this.dataitem,e=this.rowindex,t=this.metadata,n){if(Dr.isNull(r)||Dr.isNullOrEmpty(t))return XD;let i=t.dataCell&&t.dataCell.cssClass||XD,s=[];switch(typeof i=="function"?Array.prototype.push.apply(s,i(this,t,r,e)||[]):Array.prototype.push.apply(s,i),t.dataCell?.verticalAlign?.toLowerCase()){case"top":s.push("datacell-top");break;case"bottom":s.push("datacell-bottom");break;case"middle":s.push("datacell-middle");break}switch(t.dataCell?.horizontalAlign?.toLowerCase()){case"left":s.push("datacell-left");break;case"right":s.push("datacell-right");break;case"center":s.push("datacell-center");break}return n?.length&&(e===0&&s.push("datacell-firstrow"),e===n.length-1&&s.push("datacell-lastrow")),s}_inflateCss(r=this.dataitem,e=this.rowindex,t=this.metadata){if(Dr.isNull(r)||Dr.isNullOrEmpty(t))return YD;let n=t.dataCell&&t.dataCell.css||YD;return typeof n=="function"?n(this,t,r,e):n}_setup(r=this.metadata){this.setAttribute("css-class","{{ this._inflateCssClass(^item, ^index, this.metadata, :host.datasource) }}"),this.setAttribute("css","{{ Pacem.Utils.extend({ 'grid-row': ^index+2 }, this._inflateCss(^item, ^index, this.metadata, :host.datasource)) }}");let t=!!r.dataCell?.textEllipsis?["text-truncate"]:[];switch(r?.dataCell?.selectMode?.toLowerCase()){case"cell":case"row":t.push(yk+"-inert"),t.push(yk+"-unselect");break}this._content.cssClass=t,this._updateSelection()}_updateSelection(){(this.gridState?.selectedRows??[]).indexOf(this.rowindex)>=0?Dr.addClass(this,"datarow-selected datacell-filled datacell-primary"):Dr.removeClass(this,"datarow-selected datacell-filled datacell-primary")}};l([_k({emit:!1,converter:xk.Eval})],ml.prototype,"dataitem",2),l([_k({emit:!1,converter:xk.Number})],ml.prototype,"rowindex",2),l([_k({emit:!1,converter:xk.String,debounce:200})],ml.prototype,"_contentTooltip",2),l([pF(Gm+"-span")],ml.prototype,"_content",2),ml=l([cF({tagName:Gm+"-datacell",shadow:!1,template:`<${Gm}-span content="{{ :host._inflateContent(^item, ^index, :host.metadata) }}"></${Gm}-span>`})],ml);import{CustomElement as uF,P as hF,PCSS as Fv,Utils as ir,CustomElementUtils as KD,Components as JD,UI as Jp}from"@pacem/pacem-core";import{Components as mF}from"@pacem/pacem-ui";var Zp=mF.UI,Tx="datacolumnsort",Fm=class extends CustomEvent{constructor(r){super(Tx,{detail:r,bubbles:!1,cancelable:!0})}},Ax="datacolumnrescale",Wm=class extends CustomEvent{constructor(r){super(Ax,{detail:r,bubbles:!1,cancelable:!0})}},Wv=class extends Wi{constructor(e=new Zp.MarkdownService){super();this._md=e;this._sortButtonClickHandler=e=>{let t=this.metadata,n=this.gridState,i=t.prop,s=n.sort?.column===i?n.sort.dir==="desc"?"asc":"desc":t.defaultSort||"asc";this.dispatchEvent(new Fm({column:i,dir:s}))};this._rescaleHandler=e=>{e.preventDefault();let t=e.detail,n=Math.max(this.metadata.minPixelWidth??24,t.currentPosition.x-this._columnBBox.x);this.dispatchEvent(new Wm({width:n}))};this._rescaleStartHandler=e=>{this._columnBBox=ir.offsetRect(this)};this._rescaleEndHandler=e=>{}}connectedCallback(){super.connectedCallback(),ir.addClass(this,Fv+"-headcell")}propertyChangedCallback(e,t,n,i){super.propertyChangedCallback(e,t,n,i),!i&&e==="gridState"&&this._updateSortButtonIconGlyph()}viewActivatedCallback(){super.viewActivatedCallback(),this._ensureBalloon()}disconnectedCallback(){this._disposeBalloon(),this._disposeRescaler(),super.disconnectedCallback()}updateLayout(e=this.metadata){this._setup(e)}_setupSortButton(){let e=new Zp.PacemButtonElement;return e.className=`button-flat headcell-sort ${Fv}-inert`,this.addEventListener("click",this._sortButtonClickHandler,!1),ir.addClass(this,Fv+"-clickable"),e}_disposeSortButton(e=this._sortButton){ir.isNull(e)||(ir.removeClass(this,Fv+"-clickable"),this.removeEventListener("click",this._sortButtonClickHandler,!1),e.remove(),this._sortButton=null)}_updateSortButtonIconGlyph(e=this._sortButton,t=this.gridState,n=this.metadata){ir.isNull(e)||ir.isNullOrEmpty(n)||(e.iconGlyph=t?.sort?.column===n.prop?t.sort.dir==="desc"?"arrow_drop_down":"arrow_drop_up":"")}_ensureRescaler(){if(ir.isNull(this._rescaler)){let e=this._rescaler=this._rescaler||new JD.PacemRescaleElement;e.handles=[Jp.RescaleHandle.Right],e.addEventListener(Jp.RescaleEventType.Rescale,this._rescaleHandler,!1),e.addEventListener(Jp.RescaleEventType.Start,this._rescaleStartHandler,!1),e.addEventListener(Jp.RescaleEventType.End,this._rescaleEndHandler,!1),KD.findAncestorShell(this).appendChild(e)}}_setupRescaleContainer(){this._ensureRescaler();let e=new JD.PacemPanelElement;return e.className="headcell-rescale",e.behaviors=[this._rescaler],e}_disposeRescaleContainer(e=this._rescaleContainer){ir.isNull(e)||(e.remove(),this._rescaleContainer=null)}_disposeRescaler(e=this._rescaler){ir.isNull(e)||(e.removeEventListener(Jp.RescaleEventType.Rescale,this._rescaleHandler,!1),e.removeEventListener(Jp.RescaleEventType.Start,this._rescaleStartHandler,!1),e.removeEventListener(Jp.RescaleEventType.End,this._rescaleEndHandler,!1),e.remove(),this._rescaler=null)}_setup(e=this.metadata){this.setAttribute("css-class","{{ this.metadata && this.metadata.headCell && this.metadata.headCell.cssClass || [] }}"),this.setAttribute("css","{{ this.metadata && this.metadata.headCell && this.metadata.headCell.css }}");let n=!!e.headCell?.textEllipsis?["text-truncate"]:[];switch(e.headCell?.verticalAlign?.toLowerCase()){case"top":ir.addClass(this,"headcell-top");break;case"bottom":ir.addClass(this,"headcell-bottom");break;case"middle":ir.addClass(this,"headcell-middle");break}switch(e.headCell?.horizontalAlign?.toLowerCase()){case"left":n.push("text-left");break;case"right":n.push("text-right");break;case"center":n.push("text-center");break}this.removeAttribute("content");let i=ir.isNullOrEmpty(n)?"":` class="${n.join(" ")}"`,s=e.headCell?.name??e.prop;if(this.innerHTML=`<div${i}>${s}</div>`,e.isSortable){this._disposeSortButton();let o=this._sortButton=this._setupSortButton();this._updateSortButtonIconGlyph(o),this.appendChild(o)}if(e.isRescalable){this._disposeRescaleContainer();let o=this._rescaleContainer=this._setupRescaleContainer();this.appendChild(o)}e.isTogglable}_normalizeTooltip(){let e=this.metadata.headCell?.tooltip||!1;return typeof e=="object"?e:{type:e}}_ensureBalloon(){var e,t;let n=(t=this._normalizeTooltip()).type===!1||ir.isNullOrEmpty(e=this.metadata.headCell?.description);if(ir.isNull(this._balloon)&&!n){let o=new Zp.PacemBalloonElement;o.options={behavior:Zp.BalloonBehavior.Tooltip,trigger:t.trigger||Zp.BalloonTrigger.Hover,position:t.position||Zp.BalloonPosition.Top,hoverDelay:200,hoverTimeout:50,align:t.align||Zp.BalloonAlignment.Auto},ir.addClass(o,Fv+"-headcell-tooltip");var i=KD.findAncestorShell(this);i.appendChild(this._balloon=o)}let s=this._balloon;if(!ir.isNull(s)&&(s.target=this,!(s.disabled=n))){let o=e||"";switch(t.type){case"md":case"markdown":s.innerHTML=this._md.toHtml(o);break;case"html":s.innerHTML=o;break;default:s.innerText=o;break}}}_disposeBalloon(){ir.isNull(this._balloon)||(this._balloon.remove(),this._balloon=null)}};Wv=l([uF({tagName:hF+"-headcell"})],Wv);import{CustomElement as QD,P as pn,PCSS as Qp,Watch as yr,PropertyConverters as dn,Utils as xs,Debounce as fF,ViewChild as gF,CommandEventName as ZD,CustomUIEvent as vF,Components as jv,Logging as bF}from"@pacem/pacem-core";var Ck="datacolumnchange",Ek="datacolumnstatechange",yF={Defaults:{selectCaption:"Details",editCaption:"Edit",editIcon:"edit",deleteCaption:"Delete",deleteIcon:"delete"}},Dx=class extends CustomEvent{constructor(r){super("databind",{cancelable:!1,bubbles:!1,detail:r})}},Yv=class extends vF{constructor(r,e,t){super(r,e,{bubbles:!1,cancelable:!0},t)}},Rr=class extends jv.PacemItemElement{propertyChangedCallback(r,e,t,n){if(super.propertyChangedCallback(r,e,t,n),!n)switch(r){case"field":case"headcellCss":case"headcellCssClass":case"datacellCss":case"datacellCssClass":case"resizable":case"togglable":case"sortable":case"label":this.dispatchEvent(new Event(Ck));break;case"order":case"hide":this.dispatchEvent(new Event(Ek));break}}};l([yr({emit:!1,converter:dn.String})],Rr.prototype,"field",2),l([yr({emit:!1,converter:dn.String})],Rr.prototype,"label",2),l([yr({emit:!1,converter:dn.Boolean})],Rr.prototype,"resizable",2),l([yr({emit:!1,converter:dn.Boolean})],Rr.prototype,"togglable",2),l([yr({emit:!1,converter:dn.Boolean})],Rr.prototype,"sortable",2),l([yr({emit:!1,converter:dn.Number})],Rr.prototype,"order",2),l([yr({emit:!1,converter:dn.Json})],Rr.prototype,"format",2),l([yr({emit:!1,converter:dn.Number})],Rr.prototype,"headcellCss",2),l([yr({emit:!1,converter:dn.Number})],Rr.prototype,"headcellCssClass",2),l([yr({emit:!1,converter:dn.Number})],Rr.prototype,"datacellCss",2),l([yr({emit:!1,converter:dn.Number})],Rr.prototype,"datacellCssClass",2),Rr=l([QD({tagName:pn+"-datacolumn"})],Rr);function _F(a){return`<${pn}-headcell metadata="{{ :host._getColumnMetadata('${a.prop}') }}" state="{{ :host._columnState.${a.prop} }}" grid-state="{{ :host._gridState }}"
|
|
988
|
+
on-${Tx}=":host._broadcastSortCommand($event)"
|
|
989
|
+
on-${Ax}=":host._broadcastRescaleCommand($event)"></${pn}-headcell>`}function xF(a,r){return`<${pn}-datacell metadata="{{ :host._getColumnMetadata('${a.prop}') }}" state="{{ :host._columnState.${a.prop} }}" grid-state="{{ :host._gridState }}"
|
|
990
|
+
dataitem="{{ ^item }}" rowindex="{{ ^index }}" ${r}></${pn}-datacell>`}var kn=class extends jv.PacemItemsContainerElement{constructor(e=xs.uniqueCode()){super();this._key=e;this.state={};this._columnState={};this._gridState={sort:{},orderedColumns:[],selectedRows:[]};this._itemDataColumnRebuildHandler=e=>{this._adaptColumnMetadata(this.items||[])};this._itemDataColumnChangeHandler=e=>{this._adaptColumnMetadata(this.items||[])};this._memoizer={}}validate(e){return e instanceof Rr}viewActivatedCallback(){super.viewActivatedCallback(),this.addEventListener(ZD,this._onCommand,!1),this._adaptColumnMetadata();let e=this._adaptedColumnMetadata||[];this._buildUpGrid(e)}disconnectedCallback(){this.removeEventListener(ZD,this._onCommand,!1),super.disconnectedCallback()}propertyChangedCallback(e,t,n,i){if(super.propertyChangedCallback(e,t,n,i),!i)switch(e){case"items":case"metadata":this._adaptColumnMetadata();break;case"_adaptedColumnMetadata":this._buildUpGrid(n);break;case"datasource":let s={keepRowSelection:!1,datasource:n},o=new Dx(s);this.dispatchEvent(o),s.keepRowSelection||this._setRowSelection();break;case"state":this._mergeState(n);break}}register(e){return super.register(e)?(e.addEventListener(Ck,this._itemDataColumnRebuildHandler,!1),e.addEventListener(Ek,this._itemDataColumnChangeHandler,!1),!0):!1}unregister(e){return super.unregister(e)?(e.removeEventListener(Ck,this._itemDataColumnRebuildHandler,!1),e.removeEventListener(Ek,this._itemDataColumnChangeHandler,!1),!0):!1}setRowSelection(...e){let t=Array.from(e);this._setRowSelection(t)}_setRowSelection(e){let t=(e||[]).map(i=>({item:this.datasource[i],index:i})),n=new Gv({selectedRows:t});if(this.dispatchEvent(n),!n.defaultPrevented){let i=n.detail.selectedRows;xs.isArray(i)||(i=[]),this._doSetRowSelection(i.map(s=>s?.index??-1).filter(s=>s>=0))}}_doSetRowSelection(e){let t={selectedRows:e};this._mergeState(t)}_mergeState(e=this.state){e??={};let t={selectedRows:(e.selectedRows||[]).map(i=>typeof i=="number"?i:i.index)},n=this._gridState=xs.extend({},this._gridState,e,t);this.state=xs.extend(this.state??{},n)}_adaptColumnMetadata(e=this.items,t=this.metadata){let n=Array.prototype.concat.apply((e||[]).map(i=>({prop:i.field,headCell:{name:i.label,cssClass:i.headcellCssClass||[],css:i.headcellCss||{}},dataCell:{format:i.format,cssClass:i.datacellCssClass||[],css:i.datacellCss||{}},hide:i.hide,isRescalable:i.resizable,isSortable:i.sortable,isTogglable:i.togglable,order:i.order,width:1})),t||[]);this._memoizer={},this._adaptedColumnMetadata=n}_getColumnMetadata(e){return this._memoizer[e]=this._memoizer[e]||this._adaptedColumnMetadata.find(t=>t.prop===e)}_buildUpGrid(e){let t=this._tableContainer;if(xs.isNull(t))return;if(xs.isNullOrEmpty(e)){t.innerHTML="";return}let n=this.options=xs.extend({},yF.Defaults,this.options||{}),i=n.allowDelete||n.allowEdit||n.allowSelect,s=n.allowMultiSelect&&i,o=s?"auto ":"",c=s?`<div class="${Qp}-headcell"></div>`:"",d=s?`<${pn}-panel class="${Qp}-datacell" style="grid-column: 1;" css="{{ {'grid-row': ^index+2} }}"></${pn}-panel>`:"",p=s?`<div class="${Qp}-footcell"></div>`:"",u=s?2:1,h=s?e.length+2:i?e.length+1:e.length;this._gridState.orderedColumns=e.sort((g,v)=>(g.order??0)-(v.order??0)).map(g=>g.prop);let m="";for(let g of jv.PacemElement.emittedEventTypes)m+=` on-${g}=":host._broadcastUiEvent(^item, ^index, $event)"`;for(let g of e)this._columnState[g.prop]={hidden:g.hide},o+=this._getColumnSize(g).replaceAll(" ","")+" ",c+=_F(g),d+=xF(g,m),u++;d+=`<${pn}-panel class="${Qp}-datarow" css-class="{{ {'datarow-alt': ^index % 2 === 1, 'datarow-first': ^index === 0, 'datarow-last': ^index === (:host.datasource.length - 1), 'datarow-selected': :host._gridState.selectedRows.indexOf(^index) >= 0 } }}" style="grid-column: 1 /span ${h};" css="{{ {'grid-row': ^index+2} }}"></${pn}-panel>`;let f=`<${pn}-repeater datasource="{{ :host.datasource }}">
|
|
991
|
+
<${pn}-panel class="${Qp}-datatable" css="{{ {'grid-template-columns': :host._getColumnSizes(:host._columnState, '${o.trimEnd()}', :host._gridState) } }}">
|
|
992
|
+
${c}
|
|
993
|
+
<template>
|
|
994
|
+
${d}
|
|
995
|
+
</template>
|
|
996
|
+
${p}
|
|
997
|
+
</${pn}-panel>`;t.innerHTML=f}_getColumnSizes(e=this._columnState,t,n=this._gridState){if(xs.isNullOrEmpty(e))return t;let i=t.split(" ");for(let s in e){let o=e[s],c=n.orderedColumns.indexOf(s);o.hidden?i[c]="auto":o.pixelWidth>0&&(i[c]=o.pixelWidth+"px")}return i.join(" ")}_getColumnSize(e){if(e.hide)return"auto";let t=e.minPixelWidth,n=e.maxPixelWidth;if(n>0&&t>0)return`minmax(${t}px, ${n}px)`;{let i=typeof e.width=="number"?e.width+"fr":"auto";return t>0?`minmax(${t}px, ${i})`:n>0?`minmax(${i}, ${n}px)`:i}}_onCommand(e){this.dispatchEvent(new jv.ItemCommandEvent(e)),this.dispatchEvent(new jv.CustomItemCommandEvent(e))}_broadcastUiEvent(e,t,n){let i=n.type.toLowerCase(),s="datacell"+i,o={dataitem:e,rowindex:t,datacell:n.srcElement},c=n instanceof MouseEvent||n instanceof TouchEvent||n instanceof KeyboardEvent?new Yv(s,o,n):new Yv(s,o);if(this.dispatchEvent(c),i==="click"&&!c.defaultPrevented)switch(c.detail.datacell.metadata?.dataCell?.selectMode?.toLowerCase()){case"cell":break;case"row":this._broadcastSelectCommand(c.detail.rowindex);break}}_broadcastSortCommand(e){let t=e.detail,n=new Fm(t);if(this.dispatchEvent(n),!n.defaultPrevented){let i={column:""};typeof n.detail.column=="string"&&(i.column=n.detail.column),typeof n.detail.dir=="string"&&(i.dir=n.detail.dir==="desc"?"desc":"asc"),this._gridState=xs.extend({},this._gridState,{sort:i})}}_broadcastRescaleCommand(e){let t=e.detail,n=new Wm(t);if(this.dispatchEvent(n),!n.defaultPrevented){let i=t.width;typeof n.detail.width=="number"&&n.detail.width>0&&(i=n.detail.width);let s=e.srcElement.metadata,o={};o[s.prop]={pixelWidth:i},this._columnState=xs.extend({},this._columnState,o)}}_broadcastSelectCommand(e){let t=(this._gridState.selectedRows||[]).slice(0),n=t.indexOf(e),i=!0;if(n>=0)t.splice(n,1);else{let s=this.options;if(s.allowMultiSelect)t.push(e);else if(s.allowSelect)t=[e];else{i=!1;let o=`Cannot select the row at index ${e} since datagrid options do not allow any row selection.`;xs.isNull(this.logger)?console.warn(o):this.log(bF.LogLevel.Warn,o)}}i&&this._setRowSelection(t)}};l([yr({emit:!1,converter:dn.Json})],kn.prototype,"metadata",2),l([yr({emit:!1,converter:dn.Json})],kn.prototype,"options",2),l([yr({emit:!1,converter:dn.Json})],kn.prototype,"state",2),l([yr({emit:!0,converter:dn.Json})],kn.prototype,"datasource",2),l([gF("."+Qp+"-datagrid")],kn.prototype,"_tableContainer",2),l([yr()],kn.prototype,"_adaptedColumnMetadata",2),l([yr()],kn.prototype,"_columnState",2),l([yr()],kn.prototype,"_gridState",2),l([fF()],kn.prototype,"_adaptColumnMetadata",1),kn=l([QD({tagName:pn+"-datagrid",shadow:!1,template:`<div class="${Qp}-datagrid"></div><${pn}-content></${pn}-content>`})],kn);export{zk as Angle,Rk as Arrays,Ok as Blobs,Uk as Colors,qk as Compile,eR as Components,Jv as Dates,Ak as DeepMerger,lM as Drawing,vM as Drawing3D,Jk as Geometry,Gk as HistoryService,Fk as Imaging,Wk as Keys,_M as Maps,iM as Mathematics,Ym as Matrix2D,We as NullChecker,jk as Numbers,xM as Plus,td as Point,eb as Rect,sM as Scaffolding,Zv as Size,Yk as Strings,AF as detect,Qv as parseAsNumericalArray};
|