@pacem/pacem 1.0.0-goedel → 1.0.1

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.
Files changed (34) hide show
  1. package/dist/browser/pacem-2d.js +1 -1
  2. package/dist/browser/pacem-2d.min.js +1 -1
  3. package/dist/browser/pacem-3d.js +1 -1
  4. package/dist/browser/pacem-3d.min.js +2 -2
  5. package/dist/browser/pacem-charts.js +1 -1
  6. package/dist/browser/pacem-charts.min.js +1 -1
  7. package/dist/browser/pacem-cms.js +1 -1
  8. package/dist/browser/pacem-cms.min.js +1 -1
  9. package/dist/browser/pacem-core.js +1 -1
  10. package/dist/browser/pacem-core.min.js +2 -2
  11. package/dist/browser/pacem-foundation.js +1 -1
  12. package/dist/browser/pacem-foundation.min.js +1 -1
  13. package/dist/browser/pacem-fx.js +1 -1
  14. package/dist/browser/pacem-fx.min.js +1 -1
  15. package/dist/browser/pacem-logging.js +1 -1
  16. package/dist/browser/pacem-logging.min.js +1 -1
  17. package/dist/browser/pacem-maps.js +1 -1
  18. package/dist/browser/pacem-maps.min.js +1 -1
  19. package/dist/browser/pacem-media.js +1 -1
  20. package/dist/browser/pacem-media.min.js +1 -1
  21. package/dist/browser/pacem-networking.js +1 -1
  22. package/dist/browser/pacem-networking.min.js +1 -1
  23. package/dist/browser/pacem-numerical.js +1 -1
  24. package/dist/browser/pacem-numerical.min.js +1 -1
  25. package/dist/browser/pacem-plus.js +1 -1
  26. package/dist/browser/pacem-plus.min.js +1 -1
  27. package/dist/browser/pacem-scaffolding.js +1 -1
  28. package/dist/browser/pacem-scaffolding.min.js +2 -2
  29. package/dist/browser/pacem-ui.js +1 -1
  30. package/dist/browser/pacem-ui.min.js +1 -1
  31. package/dist/bundle/pacem.min.mjs +1 -1
  32. package/dist/bundle/pacem.mjs +1 -1
  33. package/dist/typings/index.d.ts +1 -1
  34. package/package.json +1 -1
@@ -1,6 +1,6 @@
1
1
  /*!
2
- * @pacem/pacem v1.0.0-goedel (https://js.pacem.it)
2
+ * @pacem/pacem v1.0.1 (https://js.pacem.it)
3
3
  * Pacem (https://pacem.it)
4
4
  * Licensed under Apache-2.0
5
5
  */
6
- !function(e,t,i,a){"use strict";const s="change";class FieldChangeEvent extends t.CustomTypedEvent{constructor(e){super(s,e,{bubbles:!0,cancelable:!1})}}var r;!function(e){e.String="string",e.Number="number",e.Datetime="datetime",e.Boolean="boolean",e.Binary="binary",e.Object="object"}(r||(r={}));class ApiParserBase{async load(e,t){let i=await fetch(e,{mode:"cors",credentials:"omit",headers:t});try{let t=await i.json();return this.parse(t,e)}catch(e){return null}}}const n=/^#\/(definitions|components\/schemas)\/(.+)$/;const o=t.Net.HttpMethod;class SwaggerParser extends ApiParserBase{_findDefinitionName(e){var t=/#\/definitions\/(.+)/.exec(e);return null==t||t.length<2?e:t[1]}parse(e,t){let i=e;"string"==typeof i&&(i=JSON.parse(i));const a=i;let s={};for(let e in a.definitions){s[this._findDefinitionName(e)]=a.definitions[e]}let r="";if(a.host&&a.schemes.length>0)r=a.schemes[0]+"://"+a.host+a.basePath;else if(t){let e=/^(https?):\/\/([^\/]+)/.exec(t);e&&e.length&&(!a.schemes&&e.length>1&&(a.schemes=[e[1]]),!a.host&&e.length>2&&(a.host=e[2],a.basePath=""),r=e[0])}else console.warn("Not able to find a base url from the OpenApi specs.");let n={endpoints:[],definitions:s,baseUrl:r};for(let e in a.paths){let t=a.paths[e];for(let i of[o.Get,o.Delete,o.Post,o.Put]){let s=t[i.toLowerCase()];if(s){let t=this._tryGetEndpoint(a,s,e,i);n.endpoints.push(t)}}}return n}_tryGetEndpoint(e,t,i,a){return{response:this._tryGetResponse(e,t),path:i,method:a,parameters:this._tryGetParameters(e,t)}}_translateType(e,t){switch(e){case"number":case"integer":return r.Number;case"boolean":return r.Boolean;case"string":switch(t){case"date":case"date-time":return r.Datetime;case"byte":return r.Binary;case"binary":throw"Binary octets not supported."}return r.String}return r.String}_tryGetParameters(e,t){return(t.parameters||[]).map(t=>{const i=t;let a={name:i.name,required:i.required||!1},s=t.type;if(t.schema){let i=t;a.type=r.Object;let s=a.fullType=this._findDefinitionName(i.schema.$ref);a.meta=e.definitions[s]}else s&&(a.type=this._translateType(s,t.format));return a})}_tryGetResponse(e,t){let i=t.responses[200];if(!i||!i.schema)return null;let a,s,r=i.schema.type||"object";return i.schema.$ref?(s=this._findDefinitionName(i.schema.$ref),a=e.definitions[s]):(a=i.schema,i.schema.items&&(i.schema.items.hasOwnProperty("$ref")?(s=this._findDefinitionName(i.schema.items.$ref),a=e.definitions[s]):a=i.schema.items)),{type:r,fullType:s,meta:a}}}class OpenApi3Parser extends ApiParserBase{parse(e,t){let i=e;"string"==typeof i&&(i=JSON.parse(i));const a=i,s=[],r=this._gatherDefinitions(new Map,a.components.schemas);for(let e in a.paths)for(let t in a.paths[e]){const i=a.paths[e][t];s.push({path:e,method:t.toUpperCase(),parameters:this._convertToApiParameters(i.parameters),response:this._tryGetResponse(r,i.responses)})}return{endpoints:s,definitions:r,baseUrl:t}}_convertToApiParameters(e=[]){const t=[];for(let i of e){const e=i.schema;"type"in e&&t.push({name:i.name,required:i.required,type:this._translateType(e.type,e.format)})}return t}_translateType(e,t){switch(e){case"number":case"integer":return r.Number;case"boolean":return r.Boolean;case"string":switch(t){case"date":case"date-time":return r.Datetime;case"byte":return r.Binary;case"binary":throw"Binary octets not supported."}return r.String}return r.String}_gatherDefinitions(e,t){const i={};for(let a in t)i[a]=this._findDefinition(e,t,a);return i}_findDefinition(e,t,i){if(e.has(i))return e.get(i);if(i in t){const a=t[i];return e.set(i,a),a}return null}_findDefinitionName(e){var t=/#\/components\/schemas\/(.+)/.exec(e);return null==t||t.length<2?e:t[1]}_tryGetResponse(e,i){let a,s={responses:i}.responses[200];if(t.Utils.isNullOrEmpty(s&&s.content))return null;for(let e in s.content){a=s.content[e].schema;break}let r,n,o="object";return"$ref"in a?(n=this._findDefinitionName(a.$ref),r=e[n]):(o=a.type,r=a,"array"===a.type&&("$ref"in a.items?(n=this._findDefinitionName(a.items.$ref),r=e[n]):r=a.items)),{type:o,fullType:n,meta:r}}}var l=Object.freeze({__proto__:null,get ApiParameterType(){return r},ApiParserBase:ApiParserBase,OpenApi3Parser:OpenApi3Parser,OpenApiParser:class OpenApiParser extends ApiParserBase{constructor(e=new OpenApi3Parser,t=new SwaggerParser){super(),this._openApi3=e,this._swagger=t}parse(e,t){let i=e;"string"==typeof i&&(i=JSON.parse(i));const a=i;return"openapi"in a?this._openApi3.parse(a,t):this._swagger.parse(a,t)}},SwaggerParser:SwaggerParser,getOpenApiDefinition:function(e,t){var i=n.exec(t);return i&&i.length>2?{name:i[2],schema:e.definitions[i[2]]}:null}}),c=function(e,t,i,a){var s,r=arguments.length,n=r<3?t:null===a?a=Object.getOwnPropertyDescriptor(t,i):a;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(e,t,i,a);else for(var o=e.length-1;o>=0;o--)(s=e[o])&&(n=(r<3?s(n):r>3?s(t,i,n):s(t,i))||n);return r>3&&n&&Object.defineProperty(t,i,n),n};const d={display:(e,t,i)=>i[`${e}_${t}`],validator:(e,t,i,a)=>a["validator_"+e+"_"+i]??a["validator_"+e+t+"_"+i],commandTooltip:(e,t)=>t["command_tooltip_"+e]};class Forms{static localizeMetadata(e,t,i){return Forms._localizeMetadata(e,t,i)}static _localizeMetadata(e,i,a,s=""){a=t.Utils.extend({},d,a);for(let r of e.props){if("props"in r&&"object"==typeof r.props&&!t.Utils.isArray(r.props)){const e=s+r.prop+".";r.props=Forms._localizeMetadata(r.props,i,a,e)}const e=r.display=r.display??{},n=s+r.prop;if(e.name=a.display("name",n,i)??e.name,e.watermark=a.display("watermark",n,i)??e.watermark,e.description=a.display("description",n,i)??e.description,!t.Utils.isNullOrEmpty(r.commands))for(let e of r.commands){const s=a.commandTooltip(e.name,i);t.Utils.isNullOrEmpty(s)||(e.tooltip=s)}if(!t.Utils.isNullOrEmpty(r.validators)){const e={};for(let s of r.validators){const r=s.type;if("string"==typeof r){const o=e[r]=(e[r]??-1)+1,l=a.validator(r,o,n,i);t.Utils.isNullOrEmpty(l)||(s.errorMessage=l)}}}}return e}}c([t.Transformer("forms.localizeMetadata")],Forms,"localizeMetadata",null);var h=Object.freeze({__proto__:null,Forms:Forms}),p=Object.freeze({__proto__:null,FieldChangeEvent:FieldChangeEvent,FieldChangeEventName:s,L10n:h,OpenApi:l}),u=function(e,t,i,a){var s,r=arguments.length,n=r<3?t:null===a?a=Object.getOwnPropertyDescriptor(t,i):a;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(e,t,i,a);else for(var o=e.length-1;o>=0;o--)(s=e[o])&&(n=(r<3?s(n):r>3?s(t,i,n):s(t,i))||n);return r>3&&n&&Object.defineProperty(t,i,n),n};const m="submit",v="reset";class FormSubmitEvent extends t.CustomTypedEvent{constructor(e){super(m,e,{bubbles:!0,cancelable:!0})}}class FormResetEvent extends Event{constructor(){super(v,{bubbles:!0,cancelable:!0})}}const g=["download",s,t.CommandEventName],y=!1;class FormEventEmitter{constructor(e){this._element=e,this._itemEmitHandler=e=>{if(this._element.handle(e),e.type===t.CommandEventName){const t=e;this._element.handle(new CustomEvent("item"+t.detail.commandName.toLowerCase(),{detail:t.detail.commandArgument}))}}}start(){g.forEach(e=>this._element.addEventListener(e,this._itemEmitHandler,!1))}stop(){g.forEach(e=>this._element.removeEventListener(e,this._itemEmitHandler,!1))}}class PacemFormRelevantElement extends t.Components.PacemElement{viewActivatedCallback(){super.viewActivatedCallback(),this.form=t.CustomElementUtils.findAncestorOfType(this,f)}}u([t.Watch({converter:t.PropertyConverters.Element})],PacemFormRelevantElement.prototype,"form",void 0);let f=class PacemFormElement extends PacemFormRelevantElement{constructor(){super("form"),this.method=t.Net.HttpMethod.Post,this._emitter=null,this._buttons={submit:void 0,reset:void 0},this.#e=!1,this._keyupHandler=e=>{if(!(13!==e.keyCode||e.shiftKey||e.ctrlKey||e.altKey||e.metaKey)){let i=e.currentTarget.querySelector(t.P+"-button[type=submit]");t.Utils.isNull(i)||!t.Utils.isVisible(i)||i.disabled||i.click()}},this._submit=(e,i)=>{t.Utils.isNull(i)||t.avoidHandler(i),Promise.all(this._validateAllFields()).then(t=>{-1===t.findIndex(e=>!1===e)&&this.submit(e).then(e=>{this.setPristine()},e=>{})})},this._reset=e=>{t.Utils.isNull(e)||t.avoidHandler(e);var i=new FormResetEvent;if(this.dispatchEvent(i),!i.defaultPrevented){for(var a in this._fields){var s=this._fields[a];s instanceof PacemModelElement&&s.reset()}for(var r of this._subForms)r._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()}},this._validatorPropertyChanged=e=>{const t=e.target,i=t.watch;if("invalid"===e.detail.propertyName){let e=this._fields[t.watch];t.invalid?e.valid=!1:this._checkFieldValidity(i)}else this._checkFieldValidity(i)},this.suddenValidation=!0,this.resettable=!0,this._emitter=new FormEventEmitter(this)}propertyChangedCallback(e,i,a,s){super.propertyChangedCallback(e,i,a,s),("method"===e&&!0===this.autogenerate&&!t.Utils.isNullOrEmpty(this.metadata)||"metadata"===e&&!0===this.autogenerate||"autogenerate"===e&&!0===a&&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(){const e="_"+t.Utils.uniqueCode(),i=this.id=this.id||e,a="fetch"+e,s=document.createElement("form");s.id="form"+e,s.className=t.PCSS+"-form",s.setAttribute("pacem",""),s.setAttribute("novalidate","");const r=`<${t.P}-repeater datasource="{{ #${i}.metadata && (#${i}.metadata.props || #${i}.metadata) }}">\n <${t.P}-panel css="{{ #${i}.metadata.display && #${i}.metadata.display.css }}" css-class="{{ (#${i}.metadata.display && #${i}.metadata.display.cssClass || []).concat(#${i}.suddenValidation ? [] : ['lazy-validation']) }}" class="${t.PCSS}-animatable-list ${t.PCSS}-list-appear">\n <template>\n <${t.P}-form-field fetch-credentials="{{ #${i}.fetchCredentials }}" fetch-headers="{{ #${i}.fetchHeaders }}"\n logger="{{ #${i}.logger }}" entity="{{ #${i}.entity, twoway }}" \n metadata="{{ ^item }}" readonly="{{ #${i}.readonly || ^item.isReadOnly }}"></${t.P}-form-field>\n </template>\n </${t.P}-panel>\n</${t.P}-repeater>\n<${t.P}-fetch logger="{{ #${i}.logger }}" id="${a}" method="${this.method}" credentials="{{ #${i}.fetchCredentials }}" headers="{{ #${i}.fetchHeaders }}"></${t.P}-fetch> \n<div class="${t.PCSS}-buttonset buttons">\n <div class="buttonset-left">\n <${t.P}-button logger="{{ #${i}.logger }}" on-click="#${i}._submit(#${i}.fetcher || #${a}, $event)" type="submit" hide="{{ #${i}.readonly || $pacem.isNullOrEmpty(#${i}.action) || !$pacem.isNull(#${i}.form) }}"\nclass="button primary button-size size-small"\ncss-class="{{ {'buttonset-last': !#${i}.resettable || !#${i}.dirty || !$pacem.isNull(#${i}.form) } }}" \ndisabled="{{ (#${i}.suddenValidation && (!(#${i}.valid && #${i}.dirty))) || #${i}.fetching }}">\n <${t.P}-panel class="submit-spinner ${t.PCSS}-anim anim-pop" hide="{{ !#${i}.fetching }}"><i class="${t.PCSS}-icon ${t.PCSS}-anim anim-rotate rotate-uniform display-block">refresh</i></${t.P}-panel>\n <${t.P}-text text="{{ #${i}.submitCaption || 'OK' }}"></${t.P}-text>\n </${t.P}-button>\n <${t.P}-button logger="{{ #${i}.logger }}" on-click="#${i}._reset($event)" type="reset" class="button button-size size-small" css-class="{{ {'buttonset-first': #${i}.readonly || $pacem.isNullOrEmpty(#${i}.action) || !$pacem.isNull(#${i}.form)} }}" hide="{{ !#${i}.resettable || #${i}.readonly || !#${i}.dirty || !$pacem.isNull(#${i}.form) }}" disabled="{{ #${i}.fetching }}">\n <${t.P}-text text="{{ #${i}.resetCaption || 'Reset' }}"></${t.P}-text>\n </${t.P}-button>\n</div></div>`;s.innerHTML=r,this.innerHTML="",this.appendChild(s),s.addEventListener("submit",t.avoidHandler,!1);const n=this._buttons,o=this._buttons={submit:s.lastElementChild.firstElementChild.firstElementChild,reset:s.lastElementChild.firstElementChild.lastElementChild};this.dispatchEvent(new t.PropertyChangeEvent({propertyName:"formButtons",currentValue:o,oldValue:n}))}get formButtons(){return this._buttons}#e;get fetching(){return this.#e}submit(e){return new Promise((i,a)=>{t.Utils.isNull(e)&&a("Fetcher cannot be null while submitting a form."),this._submitInternally(e).then(e=>{this.dispatchEvent(new CustomEvent("success",{detail:e})),i(e)},e=>{e!==y&&this.dispatchEvent(new CustomEvent("fail",{detail:e})),a(e)})})}reset(){this._reset()}_submitInternally(e,i){if(t.Utils.isNull(e))throw"Fetcher cannot be null while submitting a form.";var a=t.DeferPromise.defer();const s=this.entity,r=this.entityName;var n={};t.Utils.isNullOrEmpty(r)?n=s:n[r]=s;i={parameters:n,fields:this._getAllFields()};var o=new FormSubmitEvent(i);if(this.dispatchEvent(o),o.defaultPrevented)a.reject(y);else{e.parameters=t.Utils.extend({},o.detail.parameters);const i=n=>{e.removeEventListener(t.Net.FetchSuccessEventName,i,!1),e.removeEventListener(t.Net.FetchErrorEventName,r,!1);const o=n.detail;if(t.Net.Fetcher.isEmpty(o)&&(e.removeEventListener(t.Net.FetchResultEventName,s,!1),this.success=!0,a.resolve({})),205===o.status)this._reset()},s=i=>{e.removeEventListener(t.Net.FetchResultEventName,s,!1);var r=i.detail;"object"==typeof r&&r.hasOwnProperty("success")?!0===r.success?(this.success=!0,a.resolve(r.result||{})):(this.fail=!0,a.reject(r.error)):(this.success=!0,a.resolve(r))},r=n=>{e.removeEventListener(t.Net.FetchSuccessEventName,i,!1),e.removeEventListener(t.Net.FetchResultEventName,s,!1),e.removeEventListener(t.Net.FetchErrorEventName,r,!1),this.fail=!0;const o=n.detail;a.reject(o)},n=i=>{if("fetching"===i.detail.propertyName)!0===i.detail.currentValue?(t.Utils.addClass(this,t.PCSS+"-fetching"),this.#e=!0,this.dispatchEvent(new t.PropertyChangeEvent({currentValue:!0,oldValue:!1,propertyName:"fetching"}))):(this.#e=!1,this.dispatchEvent(new t.PropertyChangeEvent({currentValue:!1,oldValue:!0,propertyName:"fetching"})),t.Utils.removeClass(this,t.PCSS+"-fetching"),e.removeEventListener(t.PropertyChangeEventName,n,!1))};e.addEventListener(t.PropertyChangeEventName,n,!1),e.addEventListener(t.Net.FetchSuccessEventName,i,!1),e.addEventListener(t.Net.FetchResultEventName,s,!1),e.addEventListener(t.Net.FetchErrorEventName,r,!1),t.Utils.isNullOrEmpty(this.action)||(e.url=this.action),e instanceof t.Components.PacemFetchElement&&!e.autofetch&&e.fetch(),this.success=this.fail=!1}return a.promise}_getAllFields(e={}){for(var i of(t.Utils.extend(e,this._fields),this._subForms))i._getAllFields(e);return e}apply(e){if(!t.Utils.isNullOrEmpty(e)){this.entity=t.Utils.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,...i){const a=!t.Utils.isEmpty(i);for(let t in this._fields)if(!a||i.indexOf(t)>=0){const i=this._fields[t];i instanceof PacemModelElement&&(e?i.setDirty():i.setPristine())}for(let t of this._subForms)e?t.setDirty(...i):t.setPristine(...i)}_checkFieldValidity(e){return this.suddenValidation?e in this._fields?this._validateField(e,!1):Promise.resolve(!1):Promise.resolve(null)}validate(e){return t.Utils.isNullOrEmpty(e)?Promise.all(this._validateAllFields()).then(e=>!e.some(e=>!1===e)):this._validateField(e,!1)}_validateAllFields(e=!0){const t=[];for(let i in this._fields)t.push(this._validateField(i,e));for(let i of this._subForms)Array.prototype.push.apply(t,i._validateAllFields(e));return t}_validateField(e,i){return new Promise((a,s)=>{var r=this._fields[e];if(r){var n=this._validators[r.name];n&&n.length>0?(this.log(t.Logging.LogLevel.Log,`Computing "${r.name}" validity.`),Promise.all(n.map(e=>e.validate(r.value).then(t=>!(e.invalid=!t)))).then(e=>{let s=!0;for(var n of e)if(!1===n){s=!1,i&&r.setDirty();break}this.log(t.Logging.LogLevel.Log,`Property "${r.name}" turns out to be ${s?"":"not "}valid.`),a(r.valid=s)})):(this.log(t.Logging.LogLevel.Log,`Property "${r.name}" has no validators.`),a(r.valid=!0))}else this.log(t.Logging.LogLevel.Log,`Property "${e}" has no fields in this form.`),a(!0)})}_checkDirtyness(){let e=!1;for(var t in this._fields)if(!0===this._fields[t].dirty){e=!0;break}if(!1===e)for(var i of this._subForms)if(i.dirty){e=!0;break}this.dirty=e}_checkValidity(){let e=!0;for(var i in this._fields)if(this.log(t.Logging.LogLevel.Log,`Checking "${i}" validity.`),!1===this._fields[i].valid){this.log(t.Logging.LogLevel.Log,`"${i}" is not valid.`),e=!1;break}if(!0===e)for(var a of this._subForms)if(!a.valid){e=!1;break}this.valid=e}registerSubForm(e){let i=this._subForms;-1==i.indexOf(e)&&(e.addEventListener(t.PropertyChangeEventName,this._fieldPropertyChanged,!1),i.push(e),this._checkValidity(),this._checkDirtyness())}unregisterSubForm(e){let i=this._subForms,a=i.indexOf(e);a>=0&&(e.removeEventListener(t.PropertyChangeEventName,this._fieldPropertyChanged,!1),i.splice(a,1),this._checkValidity(),this._checkDirtyness())}registerField(e,i){var a=this._fields;a[e]!=i&&(this.unregisterField(e,!1),a[e]=i,this.log(t.Logging.LogLevel.Log,`Registering "${e}" field.`),i instanceof HTMLElement&&i.addEventListener(t.PropertyChangeEventName,this._fieldPropertyChanged,!1),this._checkFieldValidity(e),this._checkDirtyness())}unregisterField(e,i=!0){var a=this._fields,s=a[e];s instanceof HTMLElement&&s.removeEventListener(t.PropertyChangeEventName,this._fieldPropertyChanged,!1),delete a[e],s&&!0===i&&(this._checkValidity(),this._checkDirtyness())}registerValidator(e,i){var a=this._validators[e]=this._validators[e]||[];-1==a.indexOf(i)&&(a.push(i),i instanceof HTMLElement&&i.addEventListener(t.PropertyChangeEventName,this._validatorPropertyChanged,!1),this.log(t.Logging.LogLevel.Log,`Calling "${e}" validity check after validator registration.`),this._checkFieldValidity(e))}unregisterValidator(e,t){this._unregisterValidator(e,t,!0)}_unregisterValidator(e,i,a){var s=this._validators[e]=this._validators[e]||[],r=s.indexOf(i);r>=0&&(i instanceof HTMLElement&&i.removeEventListener(t.PropertyChangeEventName,this._validatorPropertyChanged,!1),s.splice(r,1),a&&this._checkFieldValidity(e))}};u([t.Watch({emit:!1,converter:t.PropertyConverters.Element})],f.prototype,"fetcher",void 0),u([t.Watch({emit:!1,converter:t.PropertyConverters.String})],f.prototype,"fetchCredentials",void 0),u([t.Watch({emit:!1,converter:t.PropertyConverters.Json})],f.prototype,"fetchHeaders",void 0),u([t.Watch({reflectBack:!0,converter:t.PropertyConverters.String})],f.prototype,"method",void 0),u([t.Watch({reflectBack:!0,converter:t.PropertyConverters.String})],f.prototype,"submitCaption",void 0),u([t.Watch({reflectBack:!0,converter:t.PropertyConverters.String})],f.prototype,"resetCaption",void 0),u([t.Debounce(100)],f.prototype,"_buildUpForm",null),u([t.Watch({reflectBack:!0,converter:t.PropertyConverters.Boolean})],f.prototype,"valid",void 0),u([t.Watch({reflectBack:!0,converter:t.PropertyConverters.Boolean})],f.prototype,"dirty",void 0),u([t.Watch({reflectBack:!0,converter:t.PropertyConverters.Boolean})],f.prototype,"readonly",void 0),u([t.Watch({converter:t.PropertyConverters.Boolean})],f.prototype,"success",void 0),u([t.Watch({converter:t.PropertyConverters.Boolean})],f.prototype,"fail",void 0),u([t.Watch({converter:t.PropertyConverters.Json})],f.prototype,"entity",void 0),u([t.Watch({emit:!1,converter:t.PropertyConverters.String})],f.prototype,"entityName",void 0),u([t.Watch()],f.prototype,"metadata",void 0),u([t.Watch({emit:!1,converter:t.PropertyConverters.Boolean})],f.prototype,"autogenerate",void 0),u([t.Watch({converter:t.PropertyConverters.Boolean})],f.prototype,"suddenValidation",void 0),u([t.Watch({emit:!1,converter:t.PropertyConverters.Boolean})],f.prototype,"resettable",void 0),u([t.Watch({converter:t.PropertyConverters.String})],f.prototype,"action",void 0),f=u([t.CustomElement({tagName:t.P+"-form"})],f);var _=function(e,t,i,a){var s,r=arguments.length,n=r<3?t:null===a?a=Object.getOwnPropertyDescriptor(t,i):a;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(e,t,i,a);else for(var o=e.length-1;o>=0;o--)(s=e[o])&&(n=(r<3?s(n):r>3?s(t,i,n):s(t,i))||n);return r>3&&n&&Object.defineProperty(t,i,n),n};const b="pacem:model:original-value";class PacemModelElement extends PacemFormRelevantElement{viewActivatedCallback(){super.viewActivatedCallback(),this._registerFieldConditionally(),this._setAsOriginalValue(this.value)}_registerFieldConditionally(){const e=this.name,i=this.form;if(!(t.Utils.isNullOrEmpty(e)||t.Utils.isNull(i)||this.hasAttribute("autobind")&&("off"===this.getAttribute("autobind")||"false"===this.getAttribute("autobind"))||(i.registerField(e,this),this.hasAttribute("value")))){const a=i.id=i.id||"frm_"+t.Utils.uniqueCode();this.setAttribute("value",`{{ #${a}.entity.${e}, twoway }}`)}}propertyChangedCallback(e,i,a,s){switch(super.propertyChangedCallback(e,i,a,s),e){case"value":this.viewValue=this.getViewValue(a);break;case"valid":a?t.Utils.removeClass(this,t.PCSS+"-invalid"):t.Utils.addClass(this,t.PCSS+"-invalid");break;case"dirty":a?t.Utils.addClass(this,t.PCSS+"-dirty"):t.Utils.removeClass(this,t.PCSS+"-dirty");break;case"name":let e=this.form;null!=e&&i&&e.unregisterField(i),this._registerFieldConditionally();break;case"form":let s=this.name;t.Utils.isNullOrEmpty(s)||null!=i&&i.unregisterField(s),this._registerFieldConditionally()}}disconnectedCallback(){let e=this.name,i=this.form;t.Utils.isNullOrEmpty(e)||t.Utils.isNull(i)||i.unregisterField(e),super.disconnectedCallback()}get originalValue(){return t.CustomElementUtils.getAttachedPropertyValue(this,b)}_setAsOriginalValue(e){t.CustomElementUtils.setAttachedPropertyValue(this,b,e)}reset(){this.value=this.originalValue,this.dirty=!1}setPristine(){this._setAsOriginalValue(this.value),this.dirty=!1}setDirty(){this.dirty=!0}}_([t.Watch({converter:t.PropertyConverters.String})],PacemModelElement.prototype,"viewValue",void 0),_([t.Watch({converter:{convert:(e,t)=>t instanceof PacemModelElement?t.convertValueAttributeToProperty(e):e,convertBack:e=>e.toString()}})],PacemModelElement.prototype,"value",void 0),_([t.Watch({converter:t.PropertyConverters.Boolean})],PacemModelElement.prototype,"dirty",void 0),_([t.Watch({converter:t.PropertyConverters.Boolean})],PacemModelElement.prototype,"valid",void 0),_([t.Watch({converter:t.PropertyConverters.String})],PacemModelElement.prototype,"name",void 0);class PacemBaseElement extends PacemModelElement{constructor(){super(...arguments),this.focusHandler=e=>{const i=(e=!0)=>{t.Utils.hasClass(this.parentElement,"."+t.PCSS+"-fieldgroup")&&(e?t.Utils.addClass:t.Utils.removeClass).apply(this,[this.parentElement,t.PCSS+"-focus"])};switch(e.type){case"focus":t.Utils.addClass(this,t.PCSS+"-focus"),i(),this._preFocusValue=this.value;break;case"blur":t.Utils.removeClass(this,t.PCSS+"-focus"),i(!1)}e.bubbles?this.emit(e):this.dispatchEvent(new FocusEvent(e.type))},this.changeHandler=e=>{const t=this.value;this.onChange(e).then(e=>{this.compareValuePropertyValues(t,e)||(this.dispatchEvent(new FieldChangeEvent({fieldName:this.name,oldValue:t,currentValue:e,firstChange:!this.dirty})),this.dirty=!0)},e=>{})},this.keydownHandler=e=>{t.stopPropagationHandler(e)},this.keyupHandler=e=>{switch(e.keyCode){case 27:t.stopPropagationHandler(e),this.compareValuePropertyValues(this.originalValue,this._preFocusValue)?this.reset():this.value=this._preFocusValue,this.blur();break;case 13:this.preventKeyboardSubmit&&t.stopPropagationHandler(e)}}}compareValuePropertyValues(e,i){return t.DefaultComparer(e,i)}get preventKeyboardSubmit(){return!1}propertyChangedCallback(e,i,a,s){switch(super.propertyChangedCallback(e,i,a,s),e){case"required":case"disabled":case"autofocus":case"placeholder":case"readonly":for(let t of this.inputFields)a?t.setAttribute(e,a):t.removeAttribute(e);break;case"tabOrder":for(let e of this.inputFields)e.setAttribute("tabindex",a);break;case"value":this.acceptValue(a)}if("required"===e||"disabled"===e||"readonly"===e){let i=`${t.PCSS}-${e}`;a?t.Utils.addClass(this,i):t.Utils.removeClass(this,i)}"readonly"===e?this.toggleReadonlyView(a):"required"===e?this.aria.attributes.set("required",!!a+""):"valid"===e&&this.aria.attributes.set("invalid",(!a&&!!this.dirty)+"")}registerInputFields(e=this.inputFields){t.Utils.isNull(e)||t.Utils.isArray(e)||(e=[e]);for(let i of e)i.addEventListener("focus",this.focusHandler,!1),i.addEventListener("blur",this.focusHandler,!1),i.addEventListener("change",this.changeHandler,!1),i.addEventListener("keydown",this.keydownHandler,!1),i.addEventListener("keyup",this.keyupHandler,!1),i.addEventListener("mousedown",t.stopPropagationHandler,!1),i.addEventListener("touchstart",t.stopPropagationHandler,{passive:!1,capture:!1})}unregisterInputFields(e=this.inputFields){t.Utils.isNull(e)||t.Utils.isArray(e)||(e=[e]);for(let i of e)t.Utils.isNull(i)||(i.removeEventListener("touchstart",t.stopPropagationHandler,{capture:!1}),i.removeEventListener("keydown",this.keydownHandler,!1),i.removeEventListener("keyup",this.keyupHandler,!1),i.removeEventListener("mousedown",t.stopPropagationHandler,!1),i.removeEventListener("change",this.changeHandler,!1),i.removeEventListener("focus",this.focusHandler,!1),i.removeEventListener("blur",this.focusHandler,!1))}viewActivatedCallback(){if(super.viewActivatedCallback(),this.toggleReadonlyView(this.readonly||!1),!t.Utils.isNullOrEmpty(this.id)){const 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(){const e=this.inputFields;e&&e.length&&e[0].focus()}blur(){const e=this.inputFields;if(!t.Utils.isNullOrEmpty(e))for(let t of e)t.blur()}}_([t.Watch({converter:t.PropertyConverters.Boolean})],PacemBaseElement.prototype,"required",void 0),_([t.Watch({converter:t.PropertyConverters.Boolean})],PacemBaseElement.prototype,"autofocus",void 0),_([t.Watch({converter:t.PropertyConverters.Boolean})],PacemBaseElement.prototype,"readonly",void 0),_([t.Watch({converter:t.PropertyConverters.String})],PacemBaseElement.prototype,"name",void 0),_([t.Watch({converter:t.PropertyConverters.String})],PacemBaseElement.prototype,"placeholder",void 0);class PacemItemElement extends t.Components.PacemElement{#t;findContainer(){return t.CustomElementUtils.findAncestor(this,e=>e instanceof PacemItemsContainerBaseElement)}get container(){return this.#t}viewActivatedCallback(){super.viewActivatedCallback();const e=this.#t=this.findContainer();t.Utils.isNull(e)||e.register(this)}disconnectedCallback(){t.Utils.isNull(this.#t)||this.#t.unregister(this),super.disconnectedCallback()}}class PacemItemsContainerBaseElement extends PacemBaseElement{register(e){let i=!0;return t.Utils.isNull(this.items)?this.items=[e]:-1===this.items.indexOf(e)?this.items.push(e):i=!1,i}unregister(e){const i=!t.Utils.isNull(this.items)&&this.items.indexOf(e);return i>=0&&(this.items.splice(i,1)[0],!0)}}_([t.Watch()],PacemItemsContainerBaseElement.prototype,"items",void 0);let C=class PacemDataItemElement extends PacemItemElement{};_([t.Watch({converter:{convert:(e,i)=>{if("true"===e)return!0;if("false"===e)return!1;let a=parseFloat(e);if(!isNaN(a))return a;let s=t.Utils.Dates.parse(e);return t.Utils.Dates.isDate(s)?s:e},convertBack:e=>e.toString()}})],C.prototype,"value",void 0),_([t.Watch({converter:t.PropertyConverters.String})],C.prototype,"label",void 0),_([t.Watch({converter:t.PropertyConverters.Boolean})],C.prototype,"disabled",void 0),C=_([t.CustomElement({tagName:t.P+"-data-item"})],C);class PacemDataSourceElement extends PacemItemsContainerBaseElement{constructor(e=!1){super(),this.multipleChoice=e,this._itemPropertyChangedHandler=e=>{this.databind()}}register(e){const i=super.register(e);return i&&e.addEventListener(t.PropertyChangeEventName,this._itemPropertyChangedHandler,!1),i}unregister(e){const i=super.register(e);return i&&e.removeEventListener(t.PropertyChangeEventName,this._itemPropertyChangedHandler,!1),i}buildAdaptedDatasource(e=this.datasource){return e&&e.map(e=>this.mapEntityToItem(e))}databind(e=this.buildAdaptedDatasource(this.datasource)){if(t.Utils.isNull(e)&&t.Utils.isNull(this.adaptedDatasource))return;const i=this.adaptedDatasource=e||[];t.Utils.isNullOrEmpty(i.filter(e=>this.isDataSourceItemSelected(e)))&&this.handleDatasourceMismatch(i)}handleDatasourceMismatch(e){this.value=void 0}isItemSelected(e,i=this.value){if(t.Utils.isNullOrEmpty(i))return!1;const a=this.mapEntityToValue(e),s=this.compareBy;return this.multipleChoice&&t.Utils.isArray(i)?!t.Utils.isNull(i.find(e=>e==a||"object"==typeof e&&!t.Utils.isNullOrEmpty(s)&&s in a&&s in e&&a[s]==e[s])):!this.multipleChoice&&(i==a||"object"==typeof i&&!t.Utils.isNullOrEmpty(s)&&s in a&&s in i&&a[s]==i[s])}isDataSourceItemSelected(e,i=this.value){if(t.Utils.isNullOrEmpty(i))return!1;if(e.disabled)return!1;const a=this.compareBy;if(this.multipleChoice&&t.Utils.isArray(i)){let s=i.find(i=>i==e.value||"object"==typeof i&&!t.Utils.isNullOrEmpty(a)&&a in i&&!t.Utils.isNullOrEmpty(e.value)&&a in e.value&&i[a]==e.value[a]);return!t.Utils.isNull(s)}return!this.multipleChoice&&!t.Utils.isNullOrEmpty(e.value)&&(i==e.value||"object"==typeof i&&!t.Utils.isNullOrEmpty(a)&&a in i&&!t.Utils.isNullOrEmpty(e.value)&&a in e.value&&i[a]==e.value[a])}mapEntityToValue(e){if(null==e)throw"entity cannot be null";if(e instanceof C)return e.value;let t,i=e;return(t=this.valueProperty)&&(i=e[t]),i}mapEntityToViewValue(e){if(null==e)throw"entity cannot be null";if(e instanceof C)return e.label||e.value;let t,i=e.toString();return(t=this.textProperty)&&(i=e[t]),i}mapEntityToItem(e){if(null==e)throw"entity cannot be null";if(e instanceof C)return{value:e.value,viewValue:e.label||e.value,disabled:e.disabled,data:e};let i=!1;const a=this.disabledProperty;return t.Utils.isNullOrEmpty(a)||(i=e[a]||!1),{value:this.mapEntityToValue(e),viewValue:this.mapEntityToViewValue(e),disabled:i,data:e}}propertyChangedCallback(e,t,i,a){switch(super.propertyChangedCallback(e,t,i,a),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})}}getViewValue(e){if(!t.Utils.isNullOrEmpty(this.datasource))return this.datasource.filter(e=>this.isItemSelected(e)).map(e=>this.mapEntityToViewValue(e)).join(", ")}convertValueAttributeToProperty(e){return this.multipleChoice?e.split(",").map(e=>e.trim()):e}compareValuePropertyValues(e,i){return t.DefaultComparer(e,i)}}_([t.Watch({emit:!1,converter:t.PropertyConverters.Json})],PacemDataSourceElement.prototype,"datasource",void 0),_([t.Watch({emit:!1,converter:t.PropertyConverters.String})],PacemDataSourceElement.prototype,"valueProperty",void 0),_([t.Watch({emit:!1,converter:t.PropertyConverters.String})],PacemDataSourceElement.prototype,"textProperty",void 0),_([t.Watch({emit:!1,converter:t.PropertyConverters.String})],PacemDataSourceElement.prototype,"disabledProperty",void 0),_([t.Watch({emit:!1,converter:t.PropertyConverters.String})],PacemDataSourceElement.prototype,"compareBy",void 0),_([t.Watch({converter:t.PropertyConverters.Json})],PacemDataSourceElement.prototype,"adaptedDatasource",void 0),_([t.Debounce(!0)],PacemDataSourceElement.prototype,"databind",null);var P=function(e,t,i,a){var s,r=arguments.length,n=r<3?t:null===a?a=Object.getOwnPropertyDescriptor(t,i):a;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(e,t,i,a);else for(var o=e.length-1;o>=0;o--)(s=e[o])&&(n=(r<3?s(n):r>3?s(t,i,n):s(t,i))||n);return r>3&&n&&Object.defineProperty(t,i,n),n};const E=`<${t.P}-char-count hide="{{ :host.readonly || !(:host.minlength > 0 || :host.maxlength > 0) }}" minlength="{{ :host.minlength }}" maxlength="{{ :host.maxlength }}" string="{{ :host.value }}"></${t.P}-char-count>`;let w=class PacemCharCountElement extends t.Components.PacemElement{_isValid(e){const t=this._length(e);return!(this.minlength>0&&t<this.minlength)&&!(this.maxlength>0&&t>this.maxlength)}_length(e){return e&&e.length||0}};P([t.Watch({converter:t.PropertyConverters.Number})],w.prototype,"minlength",void 0),P([t.Watch({converter:t.PropertyConverters.Number})],w.prototype,"maxlength",void 0),P([t.Watch({converter:t.PropertyConverters.String})],w.prototype,"string",void 0),w=P([t.CustomElement({tagName:t.P+"-char-count",shadow:t.Defaults.USE_SHADOW_ROOT,template:`<${t.P}-panel class="${t.PCSS}-char-count" css-class="{{ {'valid': :host._isValid(:host.string), 'invalid': !:host._isValid(:host.string) } }}">\n <${t.P}-span hide="{{ !(:host.minlength > 0) }}" class="${t.PCSS}-char-min" content="{{ :host.minlength }}"></${t.P}-span>\n <${t.P}-span class="${t.PCSS}-char-curr" content="{{ :host._length(:host.string) || '0' }}"></${t.P}-span>\n <${t.P}-span hide="{{ !(:host.maxlength > 0) }}" class="${t.PCSS}-char-max" content="{{ :host.maxlength }}"></${t.P}-span>\n</${t.P}-panel>`})],w);var S=function(e,t,i,a){var s,r=arguments.length,n=r<3?t:null===a?a=Object.getOwnPropertyDescriptor(t,i):a;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(e,t,i,a);else for(var o=e.length-1;o>=0;o--)(s=e[o])&&(n=(r<3?s(n):r>3?s(t,i,n):s(t,i))||n);return r>3&&n&&Object.defineProperty(t,i,n),n};const k="execute",$="<p><br></p>";class ContenteditableChangeEvent extends t.CustomTypedEvent{constructor(e){super("contenteditablechange",{html:e})}}class PacemContenteditableCommandElement extends PacemItemElement{constructor(){super(...arguments),this._containerPropChangeHandler=e=>{const t=e.detail;this.containerPropertyChangedCallback(t.propertyName,t.oldValue,t.currentValue,t.firstChange)}}execCommand(...e){const t=this;t.disabled||t.exec.apply(t,e).then(e=>{t.dispatchEvent(new Event(k))},e=>{console.error(e)})}connectedCallback(){super.connectedCallback(),t.Utils.addClass(this,t.PCSS+"-contenteditable-command")}viewActivatedCallback(){super.viewActivatedCallback();const e=this.container;t.Utils.isNull(e)||(this.contentElement=e.contentElement,e.addEventListener(t.PropertyChangeEventName,this._containerPropChangeHandler,!1))}disconnectedCallback(){const e=this.container;t.Utils.isNull(e)||e.removeEventListener(t.PropertyChangeEventName,this._containerPropChangeHandler,!1),super.disconnectedCallback()}containerPropertyChangedCallback(e,t,i,a){"range"===e&&(this.range=i)}}function U(e){return e instanceof PacemContenteditableCommandElement&&"pasteCallback"in e&&"function"==typeof e.pasteCallback}function N(e){return e?.nodeType==Node.ELEMENT_NODE}S([t.Watch()],PacemContenteditableCommandElement.prototype,"range",void 0),S([t.Watch()],PacemContenteditableCommandElement.prototype,"contentElement",void 0);let O=class PacemContenteditableElement extends PacemItemsContainerBaseElement{constructor(){super("rich text editor"),this._focusHandler=e=>{this._ensureInteractiveMarkup()},this._blurHandler=e=>{const t=this._container;for(let e of this.items)e.cleanUp(t);this._checkChangedHandler(e)},this._pasteHandler=e=>{e.preventDefault();const i=this.range,a=e.clipboardData.files;if(t.Utils.isNull(i)||0!==a.length)for(let t=0;t<a.length;t++){const i=a.item(t);for(let t of this.items)U(t)&&t.pasteCallback(i).then(t=>this._checkChangedHandler(e),e=>{})}else{const t=e.clipboardData.getData("text/plain").replace(/</gi,"&lt;").replace(/\n/gi,"<br />"),a=i.createContextualFragment(t);i.deleteContents(),i.insertNode(a),this._checkChangedHandler(e)}},this._shortcutHandler=e=>{e.ctrlKey&&-1===["C","V","X"].indexOf(e.key?.toUpperCase())&&e.preventDefault()},this._inputHandler=e=>{this._fixRangeMarkup(),this._checkChangedHandler(e)},this._checkChangedHandler=e=>{const i=this._container,a=i.innerHTML;var s=a;(t.Utils.isNullOrEmpty(a)||"<br>"===a||a===$)&&(i.innerHTML=$,s=""),s!=this.value&&(this.changeHandler(new ContenteditableChangeEvent(s)),this.value!=this.#i.current&&this._updateHistory()),this._fireHistoryChange()},this._selectionChangeHandler=e=>{const t=document.getSelection();if(t&&t.anchorNode&&this._container.contains(t.anchorNode)){const e=t.getRangeAt(0);this.range=e.cloneRange()}else this.range=null}}#i;get history(){return this.#i}reset(){super.reset(),this.#i.reset(),this._fireHistoryChange()}_fireHistoryChange(){const e=this.#i;this.dispatchEvent(new t.PropertyChangeEvent({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(k,this._checkChangedHandler,!1),!0)}unregister(e){return!!super.unregister(e)&&(e.removeEventListener(k,this._checkChangedHandler,!1),!0)}get preventKeyboardSubmit(){return!0}get inputFields(){return[this._container]}get contentElement(){return this._container}onChange(e){return new Promise((i,a)=>{if(t.CustomEventUtils.isInstanceOf(e,ContenteditableChangeEvent)){i(this.value=e.detail.html),this._selectionChangeHandler(e)}else i(this.value)})}_fixRangeMarkup(){const e=this.range,i=e=>{e.childNodes.forEach(e=>i(e)),N(e)&&"SPAN"===e.tagName?Element.prototype.replaceWith.apply(e,Array.from(e.childNodes)):e instanceof HTMLElement&&e.removeAttribute("style")};t.Utils.isNull(e)||(e=>{let t=e;N(t)||(t=e.parentElement),i(t)})(e.commonAncestorContainer)}_ensureInteractiveMarkup(){const e=this._container,i=e.childNodes,a=i.length;if(0==a||e.innerHTML===$)e.innerHTML=$;else{let e,s;const r=e=>{s.setEndAfter(e);const t=document.createElement("p");s.surroundContents(t)};for(let n=0;n<a;n++)e=i.item(n),e instanceof Element?s&&(r(e.previousSibling),s=null):t.Utils.isNull(s)&&(s=document.createRange(),s.setStartBefore(e));t.Utils.isNull(s)||r(e)}}_updateHistory(){this.#i.push(this.value),this._fireHistoryChange()}acceptValue(e){t.Utils.isNull(this._container)||e==this._container.innerHTML||(this._container.innerHTML=e)}viewActivatedCallback(){super.viewActivatedCallback();const t=this._container;this.#i=new e.HistoryService(this.value),t.addEventListener("blur",this._blurHandler,!1),t.addEventListener("keydown",this._shortcutHandler,!1),t.addEventListener("focus",this._focusHandler,!1),t.addEventListener("input",this._inputHandler,!1),t.addEventListener("paste",this._pasteHandler,!1),document.addEventListener("selectionchange",this._selectionChangeHandler,!1)}disconnectedCallback(){document.removeEventListener("selectionchange",this._selectionChangeHandler,!1);const e=this._container;t.Utils.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}};S([t.ViewChild("div[pacem]")],O.prototype,"_container",void 0),S([t.ViewChild("div[dashboard]")],O.prototype,"_dashboard",void 0),S([t.Watch()],O.prototype,"range",void 0),S([t.Debounce(500)],O.prototype,"_updateHistory",null),O=S([t.CustomElement({tagName:t.P+"-contenteditable",shadow:t.Defaults.USE_SHADOW_ROOT,template:`<div class="${t.PCSS}-contenteditable ${t.PCSS}-viewfinder">\n <div contenteditable="true" role="presenter" pacem></div>\n</div>${E}\n<div dashboard>\n <${t.P}-content></${t.P}-content>\n</div>`})],O);var x=function(e,t,i,a){var s,r=arguments.length,n=r<3?t:null===a?a=Object.getOwnPropertyDescriptor(t,i):a;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(e,t,i,a);else for(var o=e.length-1;o>=0;o--)(s=e[o])&&(n=(r<3?s(n):r>3?s(t,i,n):s(t,i))||n);return r>3&&n&&Object.defineProperty(t,i,n),n};class PacemContenteditableButtonCommandElement extends PacemContenteditableCommandElement{cleanUp(e){}propertyChangedCallback(e,i,a,s){super.propertyChangedCallback(e,i,a,s),"range"===e&&(this.active=!t.Utils.isNull(a))}getTooltip(e=this.altText,i=this.keyboardShortcut){const a=e;return t.Utils.isNullOrEmpty(i)?a:`${a} (${i})`}}x([t.Watch({converter:t.PropertyConverters.String})],PacemContenteditableButtonCommandElement.prototype,"icon",void 0),x([t.Watch({converter:t.PropertyConverters.String})],PacemContenteditableButtonCommandElement.prototype,"keyboardShortcut",void 0),x([t.Watch({converter:t.PropertyConverters.String})],PacemContenteditableButtonCommandElement.prototype,"altText",void 0),x([t.Watch({converter:t.PropertyConverters.Boolean})],PacemContenteditableButtonCommandElement.prototype,"active",void 0);const V=`<${t.P}-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()"><${t.P}-icon class="text-rootsize" icon="{{ :host.icon }}"></${t.P}-icon></${t.P}-button>\n <${t.P}-shortcut disabled="{{ !:host.active }}" target="{{ :host.contentElement }}" combination="{{ :host.keyboardShortcut }}" on-execute=":host.execCommand()"></${t.P}-shortcut>`;var D=function(e,t,i,a){var s,r=arguments.length,n=r<3?t:null===a?a=Object.getOwnPropertyDescriptor(t,i):a;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(e,t,i,a);else for(var o=e.length-1;o>=0;o--)(s=e[o])&&(n=(r<3?s(n):r>3?s(t,i,n):s(t,i))||n);return r>3&&n&&Object.defineProperty(t,i,n),n};let H=class PacemContenteditableHistoryCommandElement extends PacemContenteditableButtonCommandElement{exec(){return new Promise((e,i)=>{const a=this.container?.history;if(!t.Utils.isNull(a)){if("redo"===this.command)a.canRedo&&(a.redo(),e());else a.canUndo&&(a.undo(),e());this.contentElement.innerHTML=a.current}})}isRelevant(e){return!1}propertyChangedCallback(e,t,i,a){if(super.propertyChangedCallback(e,t,i,a),"command"===e)this.icon=this.icon||i,this.altText=i,this.keyboardShortcut=this.keyboardShortcut||"Ctrl+"+("redo"===i?"Y":"Z")}containerPropertyChangedCallback(e,i,a,s){super.containerPropertyChangedCallback(e,i,a,s);const r=this.container,n=r.history;"range"!==e&&"history"!==e||(this.active=!t.Utils.isNull(r.range)&&("redo"===this.command&&n?.canRedo||"redo"!==this.command&&n?.canUndo))}};D([t.Watch({emit:!1,converter:t.PropertyConverters.String,reflectBack:!0})],H.prototype,"command",void 0),H=D([t.CustomElement({tagName:t.P+"-contenteditable-historycommand",shadow:t.Defaults.USE_SHADOW_ROOT,template:V})],H);var A=function(e,t,i,a){var s,r=arguments.length,n=r<3?t:null===a?a=Object.getOwnPropertyDescriptor(t,i):a;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(e,t,i,a);else for(var o=e.length-1;o>=0;o--)(s=e[o])&&(n=(r<3?s(n):r>3?s(t,i,n):s(t,i))||n);return r>3&&n&&Object.defineProperty(t,i,n),n};let T=class PacemContenteditableLinkCommandElement extends PacemContenteditableButtonCommandElement{isRelevant(e){return!t.Utils.isNull(ContenteditableUtils.findSurroundingNode(e,HTMLAnchorElement))}viewActivatedCallback(){super.viewActivatedCallback(),t.Utils.isNullOrEmpty(this.altText)&&(this.altText="insert link"),t.Utils.isNullOrEmpty(this.icon)&&(this.icon="insert_link"),t.Utils.isNullOrEmpty(this.keyboardShortcut)&&(this.keyboardShortcut="Ctrl+H")}exec(e,t=this.target){return new Promise((i,a)=>{var s=this.range,r=ContenteditableUtils.findSurroundingNode(s,HTMLAnchorElement),n="http://",o=/<a.*href=\"([^\"]*)/;if(r&&o.test(r.outerHTML)&&(n=o.exec(r.outerHTML)[1]),"current"===e)return"http://"==n?"":n;var l=e||void 0===e&&window.prompt("link (empty to unlink):",n);l?(document.execCommand("createLink",!1,l),(r=ContenteditableUtils.findSurroundingNode(s,HTMLAnchorElement))&&r.setAttribute("target",t||"_blank")):document.execCommand("unlink"),i()})}};A([t.Watch({emit:!1,converter:t.PropertyConverters.String})],T.prototype,"target",void 0),T=A([t.CustomElement({tagName:t.P+"-contenteditable-linkcommand",shadow:t.Defaults.USE_SHADOW_ROOT,template:V})],T);var R=function(e,t,i,a){var s,r=arguments.length,n=r<3?t:null===a?a=Object.getOwnPropertyDescriptor(t,i):a;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(e,t,i,a);else for(var o=e.length-1;o>=0;o--)(s=e[o])&&(n=(r<3?s(n):r>3?s(t,i,n):s(t,i))||n);return r>3&&n&&Object.defineProperty(t,i,n),n};function L(e,i){return new Promise((a,s)=>{t.Utils.blobToDataURL(i).then(t.Utils.loadImage).then(t=>{const i=document.createElement("picture");i.setAttribute("contenteditable","false"),t.tabIndex=0,i.appendChild(t),e.deleteContents(),e.insertNode(i),a(i)})})}let I=class PacemContenteditableImageCommandElement extends PacemContenteditableButtonCommandElement{constructor(){super(...arguments),this._setBehaviorHandler=e=>{const t=e.target.parentElement;this.range=ContenteditableUtils.select(t)},this._disposeBehaviorHandler=e=>{}}pasteCallback(e){return e.type.startsWith("image")?L(this.range,e):Promise.reject()}cleanUp(e){e.querySelectorAll("picture[contenteditable=false]").forEach(e=>{for(let t=e.childNodes.length-1;t>0;t--)e.childNodes.item(t).remove()}),e.querySelectorAll("div."+t.PCSS+"-rescale").forEach(e=>e.remove())}isRelevant(e){return!1}viewActivatedCallback(){super.viewActivatedCallback(),t.Utils.isNullOrEmpty(this.altText)&&(this.altText="insert image"),t.Utils.isNullOrEmpty(this.icon)&&(this.icon="insert_photo"),t.Utils.isNullOrEmpty(this.keyboardShortcut)&&(this.keyboardShortcut="Ctrl+Shift+I"),this._rescale.addEventListener("rescale",this._rescaleImg,!1)}disconnectedCallback(){t.Utils.isNull(this._rescale)||(this._rescale.removeEventListener("rescale",this._rescaleImg,!1),this._disposeContainer()),super.disconnectedCallback()}propertyChangedCallback(e,i,a,s){switch(super.propertyChangedCallback(e,i,a,s),e){case"disabled":t.Utils.isNull(this._rescale)||(this._rescale.disabled=a);break;case"contentElement":i&&this._disposeContainer(i),a&&this._initContainer(a);break;case"range":this._rangeChangeCallback(i,a)}}exec(){return new Promise((e,i)=>{const a=this._file,s=this.range;a.onchange=i=>{const r=a.files[0];t.Utils.isNull(r)?e():L(s,r).then(t=>{a.value="",e()})},a.click()})}_rescaleImg(e){e.preventDefault();const t=e.detail.element,i=e.detail.targetRect,a=t.firstElementChild;a.style.width=i.width+"px",a.style.height=i.height+"px"}#a;_rangeChangeCallback(e,i){if(!t.Utils.isNull(e)&&!e.collapsed&&e.commonAncestorContainer instanceof Element&&e.commonAncestorContainer===e.startContainer&&e.commonAncestorContainer===e.endContainer&&e.startOffset===e.endOffset-1){const t=e.commonAncestorContainer.childNodes.item(e.startOffset);t instanceof HTMLPictureElement&&this._rescale.unregister(t)}if(!t.Utils.isNull(i)&&!i.collapsed&&i.commonAncestorContainer instanceof Element&&i.commonAncestorContainer===i.startContainer&&i.commonAncestorContainer===i.endContainer&&i.startOffset===i.endOffset-1){const e=i.commonAncestorContainer.childNodes.item(i.startOffset);e instanceof HTMLPictureElement&&this._rescale.register(e)}}_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){this.#a=new ContenteditableDOMObserver(e,(e,t)=>{e instanceof HTMLPictureElement&&(t?this._downgradePictureElement(e):this._enhancePictureElement(e))},"picture")}_disposeContainer(e=this.contentElement){const i=this.#a;t.Utils.isNull(i)||i.dispose()}};R([t.ViewChild("input[type=file]")],I.prototype,"_file",void 0),R([t.ViewChild(t.P+"-rescale")],I.prototype,"_rescale",void 0),I=R([t.CustomElement({tagName:t.P+"-contenteditable-imagecommand",shadow:t.Defaults.USE_SHADOW_ROOT,template:`<input type="file" accept="image/png, image/gif, image/jpeg, image/bmp, image/x-icon" class="${t.PCSS}-trasparent ${t.PCSS}-inert" pacem hidden>`+V+`<${t.P}-rescale keep-proportions="true"></${t.P}-rescale>`})],I);var F,W=function(e,t,i,a){var s,r=arguments.length,n=r<3?t:null===a?a=Object.getOwnPropertyDescriptor(t,i):a;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(e,t,i,a);else for(var o=e.length-1;o>=0;o--)(s=e[o])&&(n=(r<3?s(n):r>3?s(t,i,n):s(t,i))||n);return r>3&&n&&Object.defineProperty(t,i,n),n};function B(e){const t=e?.toLowerCase();switch(t){case"bold":case"italic":return"format_"+t;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_"+t.substr(7);case"justifyfull":return"format_align_justify";default:return"help_outline"}}function j(e,t){const i=e?.toLowerCase();switch(i){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[t];default:return["none"]}}!function(e){e.Bold="bold",e.Italic="italic",e.Underline="underline",e.StrikeThrough="strikeThrough",e.OrderedList="insertOrderedList",e.UnorderedList="insertUnorderedList",e.JustifyLeft="justifyLeft",e.JustifyCenter="justifyCenter",e.JustifyRight="justifyRight",e.JustifyFull="justifyFull"}(F||(F={}));let M=class PacemContenteditableExecCommandElement extends PacemContenteditableButtonCommandElement{_matchRelevance(e,i){const a="object"==typeof i?ContenteditableUtils.findSurroundingNode(e,e=>e instanceof HTMLElement&&(t.Utils.isNullOrEmpty(i.tagName)||e.tagName===i.tagName.toUpperCase())&&e.style[i.style.name]===i.style.value):ContenteditableUtils.findSurroundingNode(e,i);return!t.Utils.isNull(a)}isRelevant(e){const t=j(this.command,this.argument);for(let i of t)if(this._matchRelevance(e,i))return!0;return!1}propertyChangedCallback(e,i,a,s){super.propertyChangedCallback(e,i,a,s),"command"===e&&((t.Utils.isNullOrEmpty(this.icon)||this.icon===B(i))&&(this.icon=B(a)),(t.Utils.isNullOrEmpty(this.altText)||this.altText===i)&&(this.altText=a))}exec(){return new Promise((e,i)=>{const a=this.range,s=j(this.command,this.argument)[0];if(!t.Utils.isNull(a)){const e=ContenteditableUtils.testInertElementWrapping(a);if(e.result&&"string"==typeof s&&["b","i","strike","u"].indexOf(s)>=0){const i=ContenteditableUtils.findSurroundingNode(a,s);if(t.Utils.isNull(i)||1!==i.childNodes.length){const t=document.createElement(s),i=e.element,r=a.extractContents();a.insertNode(t),t.append(r),ContenteditableUtils.select(i)}else{const t=i.childNodes.item(0),a=e.element;i.parentElement.replaceChild(t,i),ContenteditableUtils.select(a)}}else document.execCommand(this.command,!1,this.argument)}e()})}};function z(e){return e instanceof HTMLDivElement&&"true"===e.contentEditable&&e.hasAttribute("pacem")&&e.hasAttribute("role")&&"presenter"===e.attributes.role.value}W([t.Watch({converter:t.PropertyConverters.String})],M.prototype,"command",void 0),W([t.Watch({emit:!1,converter:t.PropertyConverters.String})],M.prototype,"argument",void 0),M=W([t.CustomElement({tagName:t.P+"-contenteditable-execcommand",shadow:t.Defaults.USE_SHADOW_ROOT,template:V})],M);class ContenteditableDOMObserver{constructor(e,t,i="*[contenteditable=false]"){this.#s=t,this.#r=i,this.#n=new MutationObserver(e=>{const i=(e,a)=>{e.childNodes.forEach(e=>i(e,a)),t(e,a)};for(let t of e){const e=t.addedNodes,a=t.removedNodes;for(let t=0;t<e.length;t++){const a=e.item(t);i(a,!1)}for(let e=0;e<a.length;e++){const t=a.item(e);i(t,!0)}}}),this._initContainer(e)}_initContainer(e){e.querySelectorAll(this.#r).forEach(e=>this.#s(e)),this.#n.observe(e,{subtree:!0,childList:!0}),this.#o=e}_disposeContainer(e){const i=this.#n;t.Utils.isNull(i)||i.disconnect(),e.querySelectorAll(this.#r).forEach(e=>this.#s(e,!0))}dispose(){this._disposeContainer(this.#o)}#r;#s;#o;#n}class ContenteditableUtils{static getDefaultDashboard(){const e=new DocumentFragment,i=document.createElement("div");t.Utils.addClass(i,t.PCSS+"-contenteditable-toolbar");const a=new H;a.command="undo",a.keyboardShortcut="Ctrl+Z";const s=new H;s.command="redo",s.keyboardShortcut="Ctrl+Y",i.append(a,s);const r=document.createElement("div");t.Utils.addClass(r,t.PCSS+"-contenteditable-separator");const n=document.createElement("div");t.Utils.addClass(n,t.PCSS+"-contenteditable-toolbar");const o=new M;o.command=F.Bold,o.keyboardShortcut="Ctrl+B";const l=new M;l.command=F.Italic,l.keyboardShortcut="Ctrl+I";const c=new M;c.command=F.Underline,c.keyboardShortcut="Ctrl+U";const d=new M;d.command=F.StrikeThrough,c.keyboardShortcut="Ctrl+K";const h=new M;h.command=F.UnorderedList;const p=new M;p.command=F.OrderedList;const u=new Y;u.align="left";const m=new Y;m.align="center";const v=new Y;v.align="right";const g=new Y;g.align="justify",n.append(o,l,c,d,h,p,u,m,v,g);const y=document.createElement("div");t.Utils.addClass(y,t.PCSS+"-contenteditable-separator");const f=document.createElement("div");t.Utils.addClass(f,t.PCSS+"-contenteditable-toolbar");const _=new T,b=new I;return f.append(_,b),e.append(i,r,n,y,f),e}static findSurroundingNode(e,i){for(var a=e instanceof Node?e:e.commonAncestorContainer;a&&!("string"==typeof i&&a instanceof Element&&a.tagName===i.toUpperCase()||"function"==typeof i&&t.Utils.isNull(i.prototype)&&i(a)||"function"==typeof i&&!t.Utils.isNull(i.prototype)&&a instanceof i);){const e=a.parentNode;if(z(e)){a=null;break}a=e}return a}static findSurroundingBlockElement(e){return this.findSurroundingNode(e,ContenteditableUtils.isBlockElement)}static findSurroundingSiblingBlockElements(e){let t=[];if(z(e.startContainer)){if(!e.collapsed){const i=e.startContainer;for(let a=e.startOffset;a<=e.endOffset;a++){const e=i.children.item(a);this.isBlockElement(e)&&t.push(i.children.item(a))}}return t}if(e.startContainer===e.endContainer){let t=e.startContainer;for(;!ContenteditableUtils.isBlockElement(t)&&"true"!=t.parentElement.contentEditable;)t=t.parentElement;return t instanceof Element?[t]:"true"===t.parentElement.contentEditable?[]:[t.parentElement]}let i=e.commonAncestorContainer,a=!1;for(let s=0;s<i.childNodes.length;s++){const r=i.childNodes.item(s);if((!a&&r.contains(e.startContainer)||a)&&ContenteditableUtils.isBlockElement(r)&&(t.push(r),a=!0,r.contains(e.endContainer)))break}return a?t:i instanceof Element&&!z(i)?[i]:[]}static findContainingRootElements(e){const t=e.cloneRange(),i=e.cloneRange();t.collapse(!0),i.collapse();let a=this.findSurroundingNode(t,e=>"true"===e.parentElement.contentEditable);const s=[a];for(;!a.contains(i.startContainer);)s.push(a=a.nextElementSibling);return s}static isBlockElement(e){return e instanceof Element&&!getComputedStyle(e).display.startsWith("inline")}static select(e,t=!1){const i=document.createRange();t?(i.setStart(e,0),i.setEnd(e,e.childNodes.length)):(i.setStartBefore(e),i.setEndAfter(e));const a=document.getSelection();return a.removeAllRanges(),a.addRange(i),i}static copyAttributes(e,t){const i=t.attributes;for(let t=0;t<i.length;t++){const a=i.item(t);e.setAttribute(a.name,a.value)}}static testInertElementWrapping(e){if(!t.Utils.isNull(e)){const t=e.startContainer,a=e.startOffset;var i;if(t===e.endContainer&&a==e.endOffset-1&&(i=t.childNodes.item(a))instanceof HTMLElement&&"false"===i.contentEditable)return{result:!0,element:i}}return{result:!1}}}var q=function(e,t,i,a){var s,r=arguments.length,n=r<3?t:null===a?a=Object.getOwnPropertyDescriptor(t,i):a;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(e,t,i,a);else for(var o=e.length-1;o>=0;o--)(s=e[o])&&(n=(r<3?s(n):r>3?s(t,i,n):s(t,i))||n);return r>3&&n&&Object.defineProperty(t,i,n),n};function J(e){return"format_align_"+e}let Y=class PacemContenteditableAlignCommandElement extends PacemContenteditableButtonCommandElement{isRelevant(e){const i=ContenteditableUtils.findSurroundingSiblingBlockElements(e);if(t.Utils.isNullOrEmpty(i))return!1;const a=i[0];return getComputedStyle(a).textAlign==this.align}propertyChangedCallback(e,i,a,s){super.propertyChangedCallback(e,i,a,s),"align"===e&&((t.Utils.isNullOrEmpty(this.icon)||this.icon===J(i))&&(this.icon=J(a)),(t.Utils.isNullOrEmpty(this.altText)||this.altText===i)&&(this.altText=a))}exec(){const e=ContenteditableUtils.findSurroundingSiblingBlockElements(this.range);let i;for(let a of e)ContenteditableUtils.isBlockElement(a)&&a instanceof HTMLElement&&(t.Utils.isNull(i)&&(i=t.Utils.hasClass(a,"text-"+this.align)?"":this.align),a.style.textAlign="",t.Utils.removeClass(a,"text-left text-right text-center text-justify"),t.Utils.isEmpty(i)||t.Utils.addClass(a,"text-"+i));return Promise.resolve()}};q([t.Watch({converter:t.PropertyConverters.String})],Y.prototype,"align",void 0),Y=q([t.CustomElement({tagName:t.P+"-contenteditable-aligncommand",shadow:t.Defaults.USE_SHADOW_ROOT,template:V})],Y);var G=function(e,t,i,a){var s,r=arguments.length,n=r<3?t:null===a?a=Object.getOwnPropertyDescriptor(t,i):a;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(e,t,i,a);else for(var o=e.length-1;o>=0;o--)(s=e[o])&&(n=(r<3?s(n):r>3?s(t,i,n):s(t,i))||n);return r>3&&n&&Object.defineProperty(t,i,n),n};function K(e){return e instanceof HTMLModElement&&"INS"===e.tagName}let X=class PacemContenteditablePlaceholderElement extends PacemContenteditableCommandElement{constructor(){super(...arguments),this._focusHandler=e=>{const t=e.target;this.range=ContenteditableUtils.select(t)}}#l;#c;cleanUp(e){e.querySelectorAll("ins[contenteditable=false]").forEach(e=>{t.Utils.removeClass(e,"placeholder-selected")})}exec(e){const t=function(e,t){const i=document.createElement("ins");return i.textContent=t,i.setAttribute("contenteditable","false"),i.tabIndex=0,e.deleteContents(),e.insertNode(i),i}(this.range,e);return ContenteditableUtils.select(t).collapse(!1),Promise.resolve(t)}isRelevant(e){return this.#l?.result??!1}viewActivatedCallback(){super.viewActivatedCallback(),this._fillDropdown(),this._initContainer()}propertyChangedCallback(e,t,i,a){if(super.propertyChangedCallback(e,t,i,a),!a)switch(e){case"datasource":this._fillDropdown();break;case"contentElement":t&&this._disposeContainer(t),i&&this._initContainer(i);break;case"range":this._changeRelevancy()}}disconnectedCallback(){this._disposeContainer(),super.disconnectedCallback()}_changeRelevancy(e=this.range){const i=this.#l;t.Utils.isNull(i?.element)||t.Utils.removeClass(i.element,"placeholder-selected");const a=this.#l=function(e){const t=ContenteditableUtils.testInertElementWrapping(e);if(t.result&&K(t.element)){const e=t.element;return{result:!0,element:e,placeholder:e.textContent}}return{result:!1}}(e);t.Utils.isNull(a?.element)||t.Utils.addClass(a.element,"placeholder-selected"),a.result?this._dropdown.value=a.placeholder:(this._dropdown.popout(),this._dropdown.value=void 0)}_fillDropdown(e=this.datasource||[]){const t=this.#c=e.map(e=>"string"==typeof e?{placeholder:e,definition:e}:e),i=this._dropdown;i.textProperty=i.valueProperty="placeholder",i.datasource=t}#a;_initContainer(e=this.contentElement){this.#a=new ContenteditableDOMObserver(e,(e,t)=>{K(e)&&(t?this._downgradePlaceholderElement(e):this._enhancePlaceholderElement(e))},"ins[contenteditable=false]")}_disposeContainer(e=this.contentElement){const i=this.#a;t.Utils.isNull(i)||i.dispose()}_enhancePlaceholderElement(e){e.addEventListener("focus",this._focusHandler,!1)}_downgradePlaceholderElement(e){e.removeEventListener("focus",this._focusHandler,!1)}};G([t.ViewChild("template")],X.prototype,"_itemtemplate",void 0),G([t.ViewChild(t.P+"-suggest")],X.prototype,"_dropdown",void 0),G([t.Watch({emit:!1,converter:t.PropertyConverters.Json})],X.prototype,"datasource",void 0),X=G([t.CustomElement({tagName:t.P+"-contenteditable-placeholder",shadow:t.Defaults.USE_SHADOW_ROOT,template:`<template>\n<${t.P}-span text="{{ ^item.viewValue }}" class="text-tech"></${t.P}-span>\n<${t.P}-markdown hide="{{ $pacem.isNullOrEmpty(^item.data.definition) || ^item.viewValue === ^item.data.definition }}" class="${t.PCSS}-margin margin-0 text-small" value="{{ ^item.data.definition }}"></${t.P}-markdown>\n</template>\n<${t.P}-suggest placeholder="Placeholder" class="pacem-button button" disabled="{{ $pacem.isNull(:host.range) }}"\n on-change=":host.execCommand($this.value)"\n css-class="{{ {'text-primary': :host.isRelevant(:host.range)} }}" \n compare-by="placeholder" text-property="placeholder" itemtemplate="{{ ::_itemtemplate }}" prevent-focus="true" allow-typing="false"></${t.P}-suggest>`})],X);var Z=function(e,t,i,a){var s,r=arguments.length,n=r<3?t:null===a?a=Object.getOwnPropertyDescriptor(t,i):a;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(e,t,i,a);else for(var o=e.length-1;o>=0;o--)(s=e[o])&&(n=(r<3?s(n):r>3?s(t,i,n):s(t,i))||n);return r>3&&n&&Object.defineProperty(t,i,n),n};let Q=class PacemContenteditableWrapCommandElement extends PacemContenteditableButtonCommandElement{isRelevant(e){return!t.Utils.isNull(ContenteditableUtils.findSurroundingNode(e,this.tagname))}exec(){return new Promise((e,i)=>{const a=this.tagname;if(!t.Utils.isNullOrEmpty(a)){const e=this.range,i=ContenteditableUtils.findSurroundingNode(e,a)||ContenteditableUtils.findSurroundingNode(e.startContainer,a)||ContenteditableUtils.findSurroundingNode(e.endContainer,a);if(t.Utils.isNull(i)){const i=ContenteditableUtils.findSurroundingSiblingBlockElements(e);if(!t.Utils.isNullOrEmpty(i)){const t=document.createElement(a);if(1===i.length){const a=i[0];e.setStart(a,0),e.setEnd(a,a.childNodes.length);const s=e.extractContents();t.append(s),ContenteditableUtils.copyAttributes(t,a),a.parentElement.insertBefore(t,a),a.remove()}else{e.setStartBefore(i[0]),e.setEndAfter(i[i.length-1]);const a=e.extractContents();t.append(a),e.insertNode(t)}ContenteditableUtils.select(t,!0).collapse()}}else{e.setStart(i,0),e.setEnd(i,i.childNodes.length);let t=!1;const a=i.childNodes;for(let e=0;e<a.length;e++){const i=a.item(e);if(!ContenteditableUtils.isBlockElement(i)){t=!0;break}}if(t){const t=document.createElement("p");ContenteditableUtils.copyAttributes(t,i),t.append(e.extractContents()),i.parentNode.replaceChild(t,i);ContenteditableUtils.select(t,!0).collapse()}else{i.parentNode.replaceChild(e.extractContents(),i);ContenteditableUtils.select(e.endContainer,!0).collapse()}}}e()})}};Z([t.Watch({converter:t.PropertyConverters.String})],Q.prototype,"tagname",void 0),Q=Z([t.CustomElement({tagName:t.P+"-contenteditable-wrapcommand",shadow:t.Defaults.USE_SHADOW_ROOT,template:V})],Q);var ee=function(e,t,i,a){var s,r=arguments.length,n=r<3?t:null===a?a=Object.getOwnPropertyDescriptor(t,i):a;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(e,t,i,a);else for(var o=e.length-1;o>=0;o--)(s=e[o])&&(n=(r<3?s(n):r>3?s(t,i,n):s(t,i))||n);return r>3&&n&&Object.defineProperty(t,i,n),n};const te={convert:(e,i)=>/\{.+\}/.test(e)?t.PropertyConverters.Json.convert(e):t.PropertyConverters.String.convert(e),convertBack:(e,i)=>"string"==typeof e?e:t.PropertyConverters.Json.convertBack(e,i)};let ie=class PacemCalendarMonthPickerElement extends t.Components.PacemElement{propertyChangedCallback(e,i,a,s){if(super.propertyChangedCallback(e,i,a,s),"viewYear"===e)this.dispatchEvent(new CustomEvent("viewyearchange",{detail:new Date(a,0,1),bubbles:!1,cancelable:!1})),t.Utils.removeClass(this,"viewyear-next viewyear-previous"),requestAnimationFrame(()=>{t.Utils.addClass(this,i>a?"viewyear-previous":"viewyear-next")})}_getMonthLabel(e){const i=(new Date).getFullYear();return new Date(i,e,1).toLocaleString(t.Utils.lang(this),{month:"short"})}_isThisMonth(e,t=this.viewYear){return this._isSelectedMonth(e,new Date,t)}_isSelectedMonth(e,i=this.month,a=this.viewYear){const s=t.Utils.parseDate(i);if(!t.Utils.Dates.isDate(s))return!1;const r=a??(new Date).getFullYear();return s.getMonth()===e&&s.getFullYear()===r}_setMonth(e){const t=this.viewYear,i=new Date(t,e,1);this.month=i,this.dispatchEvent(new CustomEvent("monthselect",{detail:i,bubbles:!1,cancelable:!1}))}};ee([t.Watch({converter:t.PropertyConverters.Date})],ie.prototype,"month",void 0),ee([t.Watch({converter:t.PropertyConverters.Date})],ie.prototype,"viewYear",void 0),ie=ee([t.CustomElement({tagName:t.P+"-calendar-month-picker",shadow:t.Defaults.USE_SHADOW_ROOT,template:`<div class="${t.PCSS}-month-picker">${function(){let e="";for(let i=0;i<12;i++)e+=`<div class="calendar-month month-${i+1}"><${t.P}-span class="month-button text-ellipsed" on-click=":host._setMonth(${i})" css-class="{{ { 'selected-month': :host._isSelectedMonth(${i}, :host.month, :host.viewYear), 'this-month': :host._isThisMonth(${i}, :host.viewYear) } }}" text="{{ :host._getMonthLabel(${i}) }}"></${t.P}-span></div>`;return e}()}</div>`})],ie);class CalendarDateUnselectEvent extends i.Components.UI.DateSelectEvent{constructor(){super(void 0)}}function ae(e){return e-e%10}let se=class PacemCalendarYearPickerElement extends t.Components.PacemElement{propertyChangedCallback(e,i,a,s){if(super.propertyChangedCallback(e,i,a,s),"viewYear"===e)this.dispatchEvent(new CustomEvent("viewyearchange",{detail:new Date(a,0,1),bubbles:!1,cancelable:!1})),t.Utils.removeClass(this,"viewyear-next viewyear-previous"),requestAnimationFrame(()=>{t.Utils.addClass(this,i>a?"viewyear-previous":"viewyear-next")})}_getYearLabel(e,t=this.viewYear){return""+(ae(t)+e)}_isThisYear(e,t=this.viewYear){return this._isSelectedYear(e,new Date,t)}_isSelectedYear(e,i=this.year,a=this.viewYear){const s=t.Utils.parseDate(i);if(!t.Utils.Dates.isDate(s))return!1;const r=ae(a)+e;return s.getFullYear()===r}_setYear(e){const t=ae(this.viewYear),i=new Date(t+e,0,1);this.year=i,this.dispatchEvent(new CustomEvent("yearselect",{detail:i,bubbles:!1,cancelable:!1}))}};ee([t.Watch({converter:t.PropertyConverters.Date})],se.prototype,"year",void 0),ee([t.Watch({converter:t.PropertyConverters.Date})],se.prototype,"viewYear",void 0),se=ee([t.CustomElement({tagName:t.P+"-calendar-year-picker",shadow:t.Defaults.USE_SHADOW_ROOT,template:`<div class="${t.PCSS}-year-picker">${function(){let e="";for(let i=0;i<12;i++)e+=`<div class="calendar-year year-${i+1}"><${t.P}-span class="year-button text-ellipsed" on-click=":host._setYear(${i})" css-class="{{ { 'selected-year': :host._isSelectedYear(${i}, :host.year, :host.viewYear), 'this-year': :host._isThisYear(${i}, :host.viewYear) } }}" text="{{ :host._getYearLabel(${i}, :host.viewYear) }}"></${t.P}-span></div>`;return e}()}</div>`})],se);let re=class PacemCalendarPickerElement extends PacemBaseElement{constructor(){super(...arguments),this.viewmode="calendar",this.#d=!1,this._swipeHandler=e=>{switch(e.detail.direction){case"left":this._next(e);break;case"right":this._prev(e)}},this._clearBtnHandler=e=>{e.preventDefault(),this._viewDate=new Date,this.changeHandler(new CalendarDateUnselectEvent)},this._viewDateChangeHandler=e=>{this._onViewDateChange(e)},this._popCalendarHandler=e=>{if(this.#d)return;this.viewmode="calendar";const i=t.Utils.parseDate(this.value);this._calendar.viewDate=this._monthPicker.month=this._yearPicker.year=t.Utils.Dates.isDate(i)?i:this._calendar.viewDate;const a=t.Utils.offset(this._input),s=this._dropdown;s.style.top=a.top+a.height+"px",s.style.left=a.left+"px",s.hidden=!1,requestAnimationFrame(()=>{t.Utils.addClass(s,"dropdown-in")})},this._hideCalendarHandler=e=>{const t=e.composedPath()||[];t.indexOf(this._input)>=0||t.indexOf(this._dropdown)>=0||this._hideCalendar()}}#d;propertyChangedCallback(e,t,i,a){switch(super.propertyChangedCallback(e,t,i,a),e){case"viewmode":case"_viewDate":this._onViewDateChange(this._viewDate)}}viewActivatedCallback(){super.viewActivatedCallback();const e=this._dropdown=this._proxy.dom[0],i=this._calendar=e.querySelector(t.P+"-calendar"),a=this._monthPicker=e.querySelector(t.P+"-calendar-month-picker"),s=this._yearPicker=e.querySelector(t.P+"-calendar-year-picker");this._monthLabel=e.querySelector(".calendar-month"),this._yearLabel=e.querySelector(".calendar-year"),this._rangeLabel=e.querySelector(".calendar-year-range");const r=this._calendar.now=new Date,n=t.Utils.Dates.parse(this.value),o=t.Utils.Dates.isDate(n)?n:r;i.dayLabelFormatter=e=>t.Utils.parseDate(e).toLocaleString(t.Utils.lang(this),{day:"numeric"}),a.addEventListener("viewyearchange",this._viewDateChangeHandler,!1),s.addEventListener("viewyearchange",this._viewDateChangeHandler,!1),i.addEventListener("viewdatechange",this._viewDateChangeHandler,!1),i.viewDate=o,i.date=n;const l=this._input;l.addEventListener("focus",this._popCalendarHandler,!1),l.addEventListener("mousedown",this._popCalendarHandler,!1),e.addEventListener("mousedown",t.stopPropagationHandler,!1),window.document.body.addEventListener("mousedown",this._hideCalendarHandler,!0),this._clearButton.addEventListener("mousedown",this._clearBtnHandler,!1);const c=new t.Components.PacemSwipeElement;i.behaviors.push(c),a.behaviors.push(c),s.behaviors.push(c),c.addEventListener("swipe",this._swipeHandler,!1);const d=t.CustomElementUtils.findAncestorShell(this);this._swiper=d.appendChild(c)}disconnectedCallback(){const e=this._input;t.Utils.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",t.stopPropagationHandler,!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));const i=this._swiper;if(!t.Utils.isNull(i)){const e=this._calendar,t=this._monthPicker,a=this._yearPicker;for(let s of[e,t,a]){const e=s.behaviors.indexOf(i);e>=0&&s.behaviors.splice(e,1)}i.removeEventListener("swipe",this._swipeHandler,!1),i.remove(),this._swiper=null}super.disconnectedCallback()}_getHeaderLabel(e,i=this.viewmode){const a=t.Utils.parseDate(e);return t.Utils.Dates.isDate(a)?a.toLocaleString(t.Utils.lang(this),{weekday:"narrow"}):"..."}_prev(e){let t=-1;switch(this.viewmode){case"month":t=-12;break;case"year":t=-120}this._jumpMonths(t)}_next(e){let t=1;switch(this.viewmode){case"month":t=12;break;case"year":t=120}this._jumpMonths(t)}_jumpMonths(e){const i=t.Utils.parseDate(this._viewDate);this._viewDate=t.Utils.Dates.addMonths(i,e)}_setMonth(e){this._viewDate=e.detail,this.viewmode="calendar"}_setYear(e){this._viewDate=e.detail,this.viewmode="month"}_onViewDateChange(e){if(t.Utils.isNullOrEmpty(e))return;const i=t.Utils.parseDate(this._viewDate);if(t.Utils.Dates.isDate(i)&&!t.Utils.isNull(this._monthLabel))switch(this.viewmode){case"month":this._yearLabel.text=i.toLocaleString(t.Utils.lang(this),{year:"numeric"});break;case"year":const e=ae(i.getFullYear());this._rangeLabel.text=`${e} - ${e+12-1}`;break;default:this._monthLabel.text=i.toLocaleString(t.Utils.lang(this),{month:"long",year:"numeric"})}}_hideCalendar(){t.Utils.removeClass(this._dropdown,"dropdown-in"),t.Utils.addAnimationEndCallback(this._dropdown,e=>{this._dropdown.hidden=!0,t.Utils.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((a,s)=>{if(t.CustomEventUtils.isInstanceOf(e,i.Components.UI.DateSelectEvent)){t.Utils.addClass(this._dropdown,"dropdown-select");t.CustomEventUtils.isInstanceOf(e,CalendarDateUnselectEvent)&&(this.#d=!0),this.focus(),this.#d=!1,this._hideCalendar(),a(this.value=e.detail)}else a(this.value)})}acceptValue(e){this._input.value=this.viewValue;const i=this._calendar;if(!t.Utils.isNull(i)){const a=t.Utils.parseDate(e);t.Utils.Dates.isDate(a)?i.viewDate=i.date=a:i.date=void 0}}getViewValue(e){const i=t.Utils.Dates.parse(e);return t.Utils.Dates.isDate(i)?t.Utils.core.date(i,this.format||"short",t.Utils.lang(this)):""}compareValuePropertyValues(e,i){const a=t.Utils.parseDate(e),s=t.Utils.parseDate(i);return!(!t.Utils.isNullOrEmpty(a)||!t.Utils.isNullOrEmpty(s))||!t.Utils.isNullOrEmpty(a)&&!t.Utils.isNullOrEmpty(s)&&a.valueOf()==s.valueOf()}convertValueAttributeToProperty(e){return t.PropertyConverters.Datetime.convert(e)}};ee([t.ViewChild("input[type=text]")],re.prototype,"_input",void 0),ee([t.ViewChild(`.${t.PCSS}-readonly`)],re.prototype,"_span",void 0),ee([t.ViewChild(`${t.P}-button[clear]`)],re.prototype,"_clearButton",void 0),ee([t.ViewChild(t.P+"-shell-proxy")],re.prototype,"_proxy",void 0),ee([t.Watch({emit:!1,converter:te})],re.prototype,"format",void 0),ee([t.Watch({converter:t.PropertyConverters.Eval})],re.prototype,"disabledRanges",void 0),ee([t.Watch({converter:t.PropertyConverters.String})],re.prototype,"weekStart",void 0),ee([t.Watch({converter:t.PropertyConverters.String})],re.prototype,"viewmode",void 0),ee([t.Watch()],re.prototype,"_week",void 0),ee([t.Watch()],re.prototype,"_viewDate",void 0),re=ee([t.CustomElement({tagName:t.P+"-calendar-picker",shadow:t.Defaults.USE_SHADOW_ROOT,template:`<div class="${t.PCSS}-calendar-picker">\n <input type="text" class="${t.PCSS}-input" /><${t.P}-span text="{{ :host.viewValue }}" class="${t.PCSS}-readonly"></${t.P}-span>\n <${t.P}-button class="button-flat ${t.PCSS}-anim anim-pop anim-sudden anim-quick pos-absolute absolute-right absolute-top display-block ${t.PCSS}-margin margin-0"\n tab-order="-1"\n hide="{{ :host.readonly || :host.required || !Pacem.Utils.Dates.isDate(Pacem.Utils.Dates.parse(:host.value)) }}"\n icon-glyph="close"\n clear></${t.P}-button>\n</div>\n<${t.P}-shell-proxy>\n <div class="${t.PCSS}-calendar-picker-dropdown" pacem hidden>\n <${t.P}-collapse collapse="false">\n <div class="dropdown-grid">\n <div class="calendar-title">\n <${t.P}-span class="calendar-month calendar-zoom" on-click=":host.viewmode = 'month'" hide="{{ :host.viewmode !== 'calendar' }}"></${t.P}-span>\n <${t.P}-span class="calendar-year calendar-zoom" on-click=":host.viewmode = 'year'" hide="{{ :host.viewmode !== 'month' }}"></${t.P}-span>\n <${t.P}-span class="calendar-year-range" hide="{{ :host.viewmode !== 'year' }}"></${t.P}-span>\n </div>\n <div class="calendar-month-nav ${t.PCSS}-buttonset buttons">\n <div class="buttonset-left">\n <${t.P}-button class="button button-size size-auto" on-click=":host._prev($event)" icon-glyph="chevron_left"></${t.P}-button>\n <${t.P}-button class="button button-size size-auto" on-click=":host._next($event)" icon-glyph="chevron_right"></${t.P}-button>\n </div>\n </div>\n ${function(){let e="";for(let i=0;i<7;i++)e+=`<${t.P}-span class="calendar-heading day-${i+1} text-ellipsed" text="{{ :host._getHeaderLabel(:host._week[${i}]) }}"></${t.P}-span>`;return`<${t.P}-panel hide="{{ :host.viewmode !== 'calendar' }}" class="calendar-header">${e}</${t.P}-panel>`}()}\n <${t.P}-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) }}"></${t.P}-calendar>\n <${t.P}-calendar-month-picker hide="{{ :host.viewmode !== 'month' }}" on-monthselect=":host._setMonth($event)" month="{{ :host.value || Date.now() }}" view-year="{{ :host._viewDate && :host._viewDate.getFullYear() }}"></${t.P}-calendar-month-picker>\n <${t.P}-calendar-year-picker hide="{{ :host.viewmode !== 'year' }}" on-yearselect=":host._setYear($event)" year="{{ :host.value || Date.now() }}" view-year="{{ :host._viewDate && :host._viewDate.getFullYear() }}"></${t.P}-calendar-year-picker>\n </div>\n <${t.P}-collapse>\n </div>\n</${t.P}-shell-proxy>`})],re);var ne=function(e,t,i,a){var s,r=arguments.length,n=r<3?t:null===a?a=Object.getOwnPropertyDescriptor(t,i):a;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(e,t,i,a);else for(var o=e.length-1;o>=0;o--)(s=e[o])&&(n=(r<3?s(n):r>3?s(t,i,n):s(t,i))||n);return r>3&&n&&Object.defineProperty(t,i,n),n};const oe={convert:e=>"true"===e||"false"!==e&&e,convertBack:e=>e.toString()};let le=class PacemCheckboxElement extends PacemBaseElement{constructor(){super("checkbox"),this.caption="",this._key="_"+t.Utils.uniqueCode()}convertValueAttributeToProperty(e){oe.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;const i=this.value=this.selected?this.trueValue:this.falseValue;return t.Utils.fromResult(i)}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,i,a,s){if(super.propertyChangedCallback(e,i,a,s),this.isReady)switch(e){case"caption":this._label.hidden=t.Utils.isNullOrEmpty(a);break;case"name":this._checkbox.name=a;break;case"selected":this._synchronizeUi()}}_synchronizeUi(e=this.selected){(this._checkbox.checked=e)?(this.value=this.trueValue,t.Utils.addClass(this,t.PCSS+"-selected"),this.aria.attributes.set("checked","true")):(this.value=this.falseValue,t.Utils.removeClass(this,t.PCSS+"-selected"),this.aria.attributes.set("checked","false"))}acceptValue(e){this.selected=e==this.trueValue}getViewValue(e){return t.Utils.isNull(e)?"":this.caption}};ne([t.ViewChild("input[type=checkbox]")],le.prototype,"_checkbox",void 0),ne([t.ViewChild("label")],le.prototype,"_label",void 0),ne([t.ViewChild(`.${t.PCSS}-readonly`)],le.prototype,"span",void 0),ne([t.Watch({converter:t.PropertyConverters.String})],le.prototype,"caption",void 0),ne([t.Watch({emit:!1,converter:oe})],le.prototype,"trueValue",void 0),ne([t.Watch({emit:!1,converter:oe})],le.prototype,"falseValue",void 0),ne([t.Watch({converter:t.PropertyConverters.Boolean})],le.prototype,"selected",void 0),le=ne([t.CustomElement({tagName:t.P+"-checkbox",template:`<${t.P}-span class="${t.PCSS}-readonly ${t.PCSS}-checkbox" text="{{ :host.caption }}"></${t.P}-span>\n<input type="checkbox" class="${t.PCSS}-input" /><label class="${t.PCSS}-label ${t.PCSS}-checkbox ${t.PCSS}-viewfinder" pacem><${t.P}-span content="{{ :host.caption }}"></${t.P}-span></label>`,shadow:t.Defaults.USE_SHADOW_ROOT})],le);var ce=function(e,t,i,a){var s,r=arguments.length,n=r<3?t:null===a?a=Object.getOwnPropertyDescriptor(t,i):a;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(e,t,i,a);else for(var o=e.length-1;o>=0;o--)(s=e[o])&&(n=(r<3?s(n):r>3?s(t,i,n):s(t,i))||n);return r>3&&n&&Object.defineProperty(t,i,n),n};let de=class PacemCheckboxListElement extends PacemDataSourceElement{acceptValue(e){}constructor(){super(!0),this._selectedUiItems=[],this.key="_"+t.Utils.uniqueCode()}get inputFields(){return[]}propertyChangedCallback(e,t,i,a){super.propertyChangedCallback(e,t,i,a),"disabled"===e&&(this._disable.model=i)}viewActivatedCallback(){super.viewActivatedCallback(),this._disable.model=this.disabled}toggleReadonlyView(e){this._span.hidden=!e,this._repeater.hidden=e}_selectionChanged(e,t,i){if("selected"===e.detail.propertyName){let i,a=this._selectedUiItems;!0===e.detail.currentValue?a.push(this.datasource[t]):-1!==(i=a.indexOf(this.datasource[t]))&&a.splice(i,1)}}onChange(e){const i=this.value=this._selectedUiItems.map(e=>this.mapEntityToValue(e));return t.Utils.fromResult(i)}};ce([t.ViewChild(`span.${t.PCSS}-readonly`)],de.prototype,"_span",void 0),ce([t.ViewChild(t.P+"-repeater")],de.prototype,"_repeater",void 0),ce([t.ViewChild(t.P+"-data")],de.prototype,"_disable",void 0),de=ce([t.CustomElement({tagName:t.P+"-checkbox-list",template:`<${t.P}-repeater datasource="{{ :host.adaptedDatasource }}">\n <ol class="${t.PCSS}-checkbox-list ${t.PCSS}-viewfinder" pacem>\n <template>\n <li><${t.P}-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) }}"\non-focus=":host.focusHandler($event)" on-blur=":host.focusHandler($event)"\non-${t.PropertyChangeEventName}=":host._selectionChanged($event, ^index, ^item)" on-change=":host.changeHandler($event)"></${t.P}-checkbox></li>\n </template>\n </ol>\n</${t.P}-repeater><span class="${t.PCSS}-readonly"><${t.P}-text text="{{ :host.viewValue }}"></${t.P}-text></span><${t.P}-data></${t.P}-data><${t.P}-content></${t.P}-content>`,shadow:t.Defaults.USE_SHADOW_ROOT})],de);var he=function(e,t,i,a){var s,r=arguments.length,n=r<3?t:null===a?a=Object.getOwnPropertyDescriptor(t,i):a;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(e,t,i,a);else for(var o=e.length-1;o>=0;o--)(s=e[o])&&(n=(r<3?s(n):r>3?s(t,i,n):s(t,i))||n);return r>3&&n&&Object.defineProperty(t,i,n),n};let pe=class PacemChildFormPropagatorElement extends t.PacemEventTarget{propertyChangedCallback(e,i,a,s){if(super.propertyChangedCallback(e,i,a,s),!s){const i=this.property,s=this.watch,r=!t.Utils.isNullOrEmpty(i),n=!t.Utils.isNull(this.model);("watch"===e||"property"===e||"model"===e&&r&&n&&t.Utils.isArray(a)&&a.some(e=>!(i in e)||e[i]!==s)||"model"===e&&r&&n&&!t.Utils.isArray(a)&&(!(i in a)||a[i]!==s))&&this._synchronize()}}viewActivatedCallback(){super.viewActivatedCallback(),this._synchronize()}_synchronize(){const e=this.model,i=this.property,a=this.watch;if(!t.Utils.isNullOrEmpty(e)&&!t.Utils.isNullOrEmpty(i))if(t.Utils.isArray(e)){for(let t of e)t[i]=a;this.model=e.slice(0)}else e[i]=a,this.model=t.Utils.extend({},e)}};he([t.Watch({emit:!0})],pe.prototype,"model",void 0),he([t.Watch({emit:!1,converter:t.PropertyConverters.String,reflectBack:!0})],pe.prototype,"property",void 0),he([t.Watch({emit:!1})],pe.prototype,"watch",void 0),pe=he([t.CustomElement({tagName:t.P+"-childform-propagator"})],pe);let ue=class PacemChildFormElement extends PacemBaseElement{constructor(){super(...arguments),this._model=[],this._subForms=[]}get inputFields(){return[]}toggleReadonlyView(e){}onChange(e){return new Promise((e,t)=>{var i=this._modelToEntity();e(this.value=i)})}acceptValue(e){this._entityToModel(e)}getViewValue(e){return""}convertValueAttributeToProperty(e){return t.PropertyConverters.Json.convert(e,this)}propertyChangedCallback(e,t,i,a){if(super.propertyChangedCallback(e,t,i,a),"mode"===e)this._entityToModel()}_dragStart(e){var i=e.detail;const a=t.Utils.offset(i.element),s=i.floater;s.style.width=a.width+"px",s.style.height=a.height+"px"}_dragEnd(e){"array"===this.mode&&this._triggerChange()}reset(){super.reset(),this._subForms.forEach(e=>{e.setPristine()})}_itemCreate(e){const i=e.detail.index,a=this._subForms;e.detail.dom[0].childNodes.forEach(e=>{e instanceof Element&&e.localName===t.P+"-form"&&a.splice(i,a.length-i,e)})}_itemChange(e,i){"entity"===i.detail.propertyName&&t.Utils.Json.stringify(this._model[e])!==t.Utils.Json.stringify(i.detail.currentValue)&&(this._model.splice(e,1,i.detail.currentValue),this._triggerChange())}_deleteAt(e){t.avoidHandler(e.srcEvent);const i=this._model;"array"===this.mode?i.splice(e.detail,1):i.splice(0,i.length),this._triggerChange()}_addItem(e){const t=this.mode,i=this._model;"array"===t?i.push({}):i.splice(0,i.length,{}),this._triggerChange()}_triggerChange(){this.changeHandler(new Event("change"))}_entityToModel(e=this.value){if("array"===this.mode){let i=e||[];t.Utils.isArray(i)&&this._model.cloneFrom(i)}else{const i=this._model,a=i.length;1===a&&i[0]===e||(t.Utils.isNull(e)?i.splice(0,a):i.splice(0,a,e))}}_modelToEntity(e=this._model){return"array"===this.mode?t.Utils.clone(e):e&&e.length&&e[0]||null}};he([t.Watch({emit:!1,converter:t.PropertyConverters.String})],ue.prototype,"fetchCredentials",void 0),he([t.Watch({emit:!1,converter:t.PropertyConverters.Json})],ue.prototype,"fetchHeaders",void 0),he([t.ViewChild("."+t.PCSS+"-childform")],ue.prototype,"_container",void 0),he([t.ViewChild(t.P+"-drag-drop")],ue.prototype,"_dragger",void 0),he([t.ViewChild("."+t.PCSS+"-childform-item-floater")],ue.prototype,"_floater",void 0),he([t.Watch({converter:t.PropertyConverters.String})],ue.prototype,"mode",void 0),he([t.Watch({converter:t.PropertyConverters.Boolean})],ue.prototype,"lockItems",void 0),he([t.Watch({converter:t.PropertyConverters.Json})],ue.prototype,"metadata",void 0),he([t.Watch({converter:t.PropertyConverters.Json})],ue.prototype,"_model",void 0),ue=he([t.CustomElement({tagName:t.P+"-childform",shadow:t.Defaults.USE_SHADOW_ROOT,template:`<${t.P}-repeater datasource="{{ :host._model }}" on-itemdelete=":host._deleteAt($event)" on-${t.Components.RepeaterItemCreateEventName}=":host._itemCreate($event)">\n <div class="${t.PCSS}-childform">\n <template>\n <${t.P}-panel class="${t.PCSS}-childform-item" behaviors="{{ [::_dragger] }}">\n <${t.P}-panel class="childform-item-handle ${t.PCSS}-margin margin-right-1" hide="{{ :host.lockItems || :host.readonly || :host.mode !== 'array' || !(:host._model && :host._model.length > 1) }}"><i class="${t.PCSS}-icon drag-handle">drag_handle</i></${t.P}-panel>\n <${t.P}-panel class="childform-item-index text-small"><${t.P}-span hide="{{ !:host.readonly || :host.mode !== 'array' }}" class="${t.PCSS}-margin margin-right-1" text="{{ ^index+1 }}"></${t.P}-span></${t.P}-panel>\n <${t.P}-form entity="{{ ^item }}" fetch-headers="{{ :host.fetchHeaders }}" fetch-credentials="{{ :host.fetchCredentials }}" on-${t.PropertyChangeEventName}=":host._itemChange(^index, $event)" readonly="{{ :host.readonly }}" metadata="{{ :host.metadata }}" autogenerate="true" logger="{{ :host.logger }}"></${t.P}-form>\n <${t.P}-button tab-order="-1" class="flat circular circle-small clear ${t.PCSS}-margin margin-left-1" hide="{{ :host.lockItems || :host.readonly }}" command-name="delete" command-argument="{{ ^index }}"></${t.P}-button>\n </${t.P}-panel>\n </template>\n </div>\n <${t.P}-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)"></${t.P}-button>\n</${t.P}-repeater>\n<div class="${t.PCSS}-childform-item-floater ${t.PCSS}-panel panel-border">\n <div class="corner top-left"></div><div class="corner top-right"></div><div class="corner bottom-left"></div><div class="corner bottom-right"></div>\n</div>\n<${t.P}-drag-drop floater="{{ ::_floater }}" disabled="{{ :host.lockItems }}"\n on-${t.UI.DragDropEventType.Start}=":host._dragStart($event)"\n on-${t.UI.DragDropEventType.End}=":host._dragEnd($event)" \n drop-behavior="${t.UI.DropBehavior.InsertChild}" mode="${t.UI.DragDataMode.Alias}" handle-selector=".drag-handle" drop-targets="{{ [::_container] }}"></${t.P}-drag-drop>`})],ue);var me=function(e,t,i,a){var s,r=arguments.length,n=r<3?t:null===a?a=Object.getOwnPropertyDescriptor(t,i):a;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(e,t,i,a);else for(var o=e.length-1;o>=0;o--)(s=e[o])&&(n=(r<3?s(n):r>3?s(t,i,n):s(t,i))||n);return r>3&&n&&Object.defineProperty(t,i,n),n};const ve={convert:(e,i)=>/\{.+\}/.test(e)?t.PropertyConverters.Json.convert(e):t.PropertyConverters.String.convert(e),convertBack:(e,i)=>"string"==typeof e?e:t.PropertyConverters.Json.convertBack(e,i)};let ge=class PacemDatetimePickerElement extends PacemBaseElement{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 t.PropertyConverters.Datetime.convert(e)}connectedCallback(){super.connectedCallback();const e=new Date;let i=this.year=e.getFullYear();this.min=new Date(i-100,0,1),this.max=new Date(i+10,11,31),this.month=e.getMonth();let a=[],s=[],r=[],n=t.Utils.leftPad;for(let e=0;e<12;e++){let s=new Date(i,e,1),r=s.toLocaleString(t.Utils.lang(this),{month:"short"});a.push({value:e,date:s,label:r})}this._months=a;for(let e=0;e<24;e++)s.push(n(e,2,"0"));this._a24=s;for(let e=0;e<60;e++)r.push(n(e,2,"0"));this._a60=r}propertyChangedCallback(e,i,a,s){switch(super.propertyChangedCallback(e,i,a,s),e){case"dateValue":this.log(t.Logging.LogLevel.Log,`dateValue changed from ${i} to ${a}`),this._disassembleDate(a);break;case"min":case"max":t.Utils.isNullOrEmpty(this.min)||t.Utils.isNullOrEmpty(this.max)||this._setupYears();break;case"year":case"month":this._buildupDates();break;case"date":case"hours":case"minutes":case"seconds":this._buildup()}}acceptValue(e){this.dateValue=t.Utils.parseDate(e)}_disassembleDate(e){if(!e)return void(this.date=void 0);"string"==typeof e&&(e=t.Utils.parseDate(e));const i=e=>t.Utils.leftPad(e,2,"0");this.year=e.getFullYear(),this.month=e.getMonth(),this.date=e.getDate(),this.hours=i(e.getHours()),this.minutes=i(e.getMinutes()),this.seconds=i(e.getSeconds())}_setupYears(){let e=[];const i=t.Utils.parseDate(this.min),a=t.Utils.parseDate(this.max);for(let t=i.getFullYear();t<=a.getFullYear();t++)e.push(t);this._years=e}onChange(e){return new Promise((e,t)=>{e(this.value=this._computeValue())})}_buildupDates(e){e&&e.stopPropagation();const i=this,a={weekday:"short",day:"numeric"},s=e=>{try{let t=+i.month;return new Date(+i.year,+i.month,e).getMonth()==t}catch(e){return!1}};var r=[];if(!t.Utils.isNullOrEmpty(i.year)&&!t.Utils.isNullOrEmpty(i.month)){let e=1;do{let s=new Date(+i.year,+i.month,e),n=s.toLocaleString(t.Utils.lang(this),a);r.push({value:e,date:s,label:n,disabled:s<this.min||s>this.max})}while(s(++e))}this._dates=r,s(+this.date)?this._buildup():this.date=""}_computeValue(){const e=this;if(t.Utils.isNullOrEmpty(e.year)||t.Utils.isNullOrEmpty(e.month)||t.Utils.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(e){return null}}_buildup(e){e&&e.stopPropagation(),this.dateValue=this._computeValue()}getViewValue(e){const i=e;return i?t.Utils.core.date(i,this.format||("day"!=this.precision?"full":"short"),t.Utils.lang(this)):""}};me([t.ViewChild("."+t.PCSS+"-datetime-picker-year > "+t.P+"-select")],ge.prototype,"_yearel",void 0),me([t.ViewChild("."+t.PCSS+"-datetime-picker-month > "+t.P+"-select")],ge.prototype,"_monthel",void 0),me([t.ViewChild("."+t.PCSS+"-datetime-picker-date > "+t.P+"-select")],ge.prototype,"_dateel",void 0),me([t.ViewChild("."+t.PCSS+"-datetime-picker-hours > "+t.P+"-select")],ge.prototype,"_hourel",void 0),me([t.ViewChild("."+t.PCSS+"-datetime-picker-minutes > "+t.P+"-select")],ge.prototype,"_minel",void 0),me([t.ViewChild("."+t.PCSS+"-datetime-picker-seconds > "+t.P+"-select")],ge.prototype,"_secel",void 0),me([t.ViewChild(`div.${t.PCSS}-datetime-picker-fields`)],ge.prototype,"_allFields",void 0),me([t.Watch({converter:t.PropertyConverters.Datetime})],ge.prototype,"dateValue",void 0),me([t.Watch({converter:t.PropertyConverters.Datetime})],ge.prototype,"min",void 0),me([t.Watch({converter:t.PropertyConverters.Datetime})],ge.prototype,"max",void 0),me([t.Watch({converter:t.PropertyConverters.String})],ge.prototype,"precision",void 0),me([t.Watch({emit:!1,converter:ve})],ge.prototype,"format",void 0),me([t.Watch()],ge.prototype,"_dates",void 0),me([t.Watch()],ge.prototype,"_years",void 0),me([t.Watch()],ge.prototype,"year",void 0),me([t.Watch()],ge.prototype,"month",void 0),me([t.Watch()],ge.prototype,"date",void 0),me([t.Watch()],ge.prototype,"hours",void 0),me([t.Watch()],ge.prototype,"minutes",void 0),me([t.Watch()],ge.prototype,"seconds",void 0),me([t.Debounce(10)],ge.prototype,"_buildup",null),ge=me([t.CustomElement({tagName:t.P+"-datetime-picker",shadow:t.Defaults.USE_SHADOW_ROOT,template:`<div class="${t.PCSS}-datetime-picker">\n <div class="${t.PCSS}-datetime-picker-fields ${t.PCSS}-viewfinder">\n\n <div class="${t.PCSS}-datetime-picker-year">\n <${t.P}-select value="{{ :host.year, twoway }}" placeholder="..." datasource="{{ :host._years }}">\n </${t.P}-select></div>\n\n <div class="${t.PCSS}-datetime-picker-month">\n <${t.P}-select value="{{ :host.month, twoway }}" placeholder="..." value-property="value" text-property="label" datasource="{{ :host._months }}">\n </${t.P}-select></div>\n\n <div class="${t.PCSS}-datetime-picker-date">\n <${t.P}-select value="{{ :host.date, twoway }}" placeholder="..." value-property="value" text-property="label" datasource="{{ :host._dates }}">\n </${t.P}-select></div>\n\n <${t.P}-panel class="${t.PCSS}-datetime-picker-hours" hide="{{ :host.precision === 'day' }}">\n <${t.P}-select value="{{ :host.hours, twoway }}" datasource="{{ :host._a24 }}">\n </${t.P}-select></${t.P}-panel>\n\n <${t.P}-panel class="${t.PCSS}-datetime-picker-minutes" hide="{{ :host.precision === 'day' }}">\n <${t.P}-select value="{{ :host.minutes, twoway }}" datasource="{{ :host._a60 }}">\n </${t.P}-select></${t.P}-panel>\n\n <${t.P}-panel class="${t.PCSS}-datetime-picker-seconds" hide="{{ :host.precision !== 'second' }}">\n <${t.P}-select value="{{ :host.seconds, twoway }}" datasource="{{ :host._a60 }}">\n </${t.P}-select></${t.P}-panel>\n\n </div>\n <${t.P}-panel class="${t.PCSS}-datetime-picker-preview" hide="{{ Pacem.Utils.isNullOrEmpty(:host.dateValue) || :host.precision === 'day' || :host.readonly }}">\n <dl>\n <dt>local:</dt><dd><${t.P}-text text="{{ :host.viewValue }}"></${t.P}-text></dd>\n <dt>iso:</dt><dd><${t.P}-text text="{{ (:host.dateValue && :host.dateValue.toISOString()) || '' }}"></${t.P}-text></dd>\n </dl>\n </${t.P}-panel>\n <${t.P}-span class="${t.PCSS}-readonly" css-class="{{ { 'date': :host.precision === 'day', 'datetime': :host.precision !== 'day' } }}" content="{{ :host.viewValue }}" hide="{{ !:host.readonly }}"></${t.P}-span>\n</div>`})],ge);var ye=function(e,t,i,a){var s,r=arguments.length,n=r<3?t:null===a?a=Object.getOwnPropertyDescriptor(t,i):a;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(e,t,i,a);else for(var o=e.length-1;o>=0;o--)(s=e[o])&&(n=(r<3?s(n):r>3?s(t,i,n):s(t,i))||n);return r>3&&n&&Object.defineProperty(t,i,n),n};class PacemBaseValidatorElement extends PacemFormRelevantElement{constructor(){super()}viewActivatedCallback(){super.viewActivatedCallback(),t.Utils.addClass(this,t.PCSS+"-validator")}propertyChangedCallback(e,i,a,s){super.propertyChangedCallback(e,i,a,s);let r=this.form;switch(e){case"watch":i&&r&&r.unregisterValidator(a,this),r&&r.registerValidator(a,this);break;case"invalid":break;case"form":let e=this.watch;t.Utils.isNullOrEmpty(e)||(null!=i&&i.unregisterValidator(e,this),null!=a&&a.registerValidator(e,this));break;case"disabled":this.triggerFormFieldValidation()}}#h;triggerFormFieldValidation(){const e=this.form,i=this.watch;t.Utils.isNull(e)||t.Utils.isNullOrEmpty(i)||(cancelAnimationFrame(this.#h),this.#h=requestAnimationFrame(()=>{e.validate(i)}))}validate(e){return this.disabled?t.Utils.fromResult(!0):this.evaluate(e)}}ye([t.Watch({converter:t.PropertyConverters.Boolean})],PacemBaseValidatorElement.prototype,"invalid",void 0),ye([t.Watch({converter:t.PropertyConverters.String})],PacemBaseValidatorElement.prototype,"errorMessage",void 0),ye([t.Watch({emit:!1,reflectBack:!0,converter:t.PropertyConverters.String})],PacemBaseValidatorElement.prototype,"watch",void 0);const fe=`<${t.P}-span part="error-message" hide="{{ !:host.invalid }}" text="{{ :host.errorMessage }}"></${t.P}-span>`;function _e(e){return t.Utils.isNullOrEmpty(e)}let be=class PacemRequiredValidatorElement extends PacemBaseValidatorElement{evaluate(e){let i=!_e(e);return t.Utils.fromResult(i)}};be=ye([t.CustomElement({tagName:t.P+"-required-validator",template:fe,shadow:t.Defaults.USE_SHADOW_ROOT})],be);let Ce=class PacemRegexValidatorElement extends PacemBaseValidatorElement{propertyChangedCallback(e,t,i,a){super.propertyChangedCallback(e,t,i,a),a||"pattern"!==e||this.triggerFormFieldValidation()}evaluate(e){let i=!0,a=this.pattern;return _e(e)||(i=new RegExp(a).test(e)),t.Utils.fromResult(i)}};ye([t.Watch({emit:!1,converter:t.PropertyConverters.String})],Ce.prototype,"pattern",void 0),Ce=ye([t.CustomElement({tagName:t.P+"-regex-validator",template:fe,shadow:t.Defaults.USE_SHADOW_ROOT})],Ce);let Pe=class PacemLengthValidatorElement extends PacemBaseValidatorElement{propertyChangedCallback(e,t,i,a){super.propertyChangedCallback(e,t,i,a),a||"min"!==e&&"max"!==e||this.triggerFormFieldValidation()}evaluate(e){let i=!0;return _e(e)||(this.min>=0&&(i=i&&(e||"").toString().length>=this.min),this.max>=0&&(i=i&&(e||"").toString().length<=this.max)),t.Utils.fromResult(i)}};ye([t.Watch({emit:!1,converter:t.PropertyConverters.Number})],Pe.prototype,"min",void 0),ye([t.Watch({emit:!1,converter:t.PropertyConverters.Number})],Pe.prototype,"max",void 0),Pe=ye([t.CustomElement({tagName:t.P+"-length-validator",template:fe,shadow:t.Defaults.USE_SHADOW_ROOT})],Pe);let Ee=class PacemRangeValidatorElement extends PacemBaseValidatorElement{propertyChangedCallback(e,t,i,a){super.propertyChangedCallback(e,t,i,a),a||"min"!==e&&"max"!==e||this.triggerFormFieldValidation()}evaluate(e){let i=!0;if(!_e(e)){let a=e;e instanceof Date||"number"!=typeof e&&(a=t.Utils.parseDate(e))instanceof Date&&isFinite(a.valueOf())?(null!=this.min&&(i=i&&a.valueOf()>=t.Utils.parseDate(this.min).valueOf()),null!=this.max&&(i=i&&a.valueOf()<=t.Utils.parseDate(this.max).valueOf())):(null!=this.min&&(i=i&&e>=this.min),null!=this.max&&(i=i&&e<=this.max))}return t.Utils.fromResult(i)}};ye([t.Watch({emit:!1,converter:t.PropertyConverters.Number})],Ee.prototype,"min",void 0),ye([t.Watch({emit:!1,converter:t.PropertyConverters.Number})],Ee.prototype,"max",void 0),Ee=ye([t.CustomElement({tagName:t.P+"-range-validator",template:fe,shadow:t.Defaults.USE_SHADOW_ROOT})],Ee);let we=class PacemCompareValidatorElement extends PacemBaseValidatorElement{propertyChangedCallback(e,t,i,a){super.propertyChangedCallback(e,t,i,a),a||"operator"!==e&&"to"!==e||this.triggerFormFieldValidation()}_prepareValuesForComparison(e,i){return t.Utils.Dates.isDate(e)||t.Utils.Dates.isDate(i)?[t.Utils.parseDate(e),t.Utils.parseDate(i)]:[e,i]}evaluate(e){let i=!0,a=this.to;if(!_e(e)&&!_e(a)){const t=this._prepareValuesForComparison(e,a);switch(e=t[0],a=t[1],this.operator){case"lessOrEqual":i=e<=a;break;case"less":i=e<a;break;case"greaterOrEqual":i=e>=a;break;case"greater":i=e>a;break;case"notEqual":i=e!==a;break;default:i=e===a}}return t.Utils.fromResult(i)}};ye([t.Watch({emit:!1,converter:t.PropertyConverters.String})],we.prototype,"operator",void 0),ye([t.Watch({emit:!1,reflectBack:!0})],we.prototype,"to",void 0),we=ye([t.CustomElement({tagName:t.P+"-compare-validator",template:fe,shadow:t.Defaults.USE_SHADOW_ROOT})],we);let Se=class PacemBinaryValidatorElement extends PacemBaseValidatorElement{propertyChangedCallback(e,t,i,a){super.propertyChangedCallback(e,t,i,a),a||"pattern"!==e&&"maxSize"!==e||this.triggerFormFieldValidation()}evaluate(e){let i=!0,a=this.pattern,s=this.maxSize;if(!_e(e)){if(!t.Utils.isNullOrEmpty(a)){let t="string"==typeof e?e:e.name;i=new RegExp(a,"i").test(t)}!t.Utils.isNull(s)&&"object"==typeof e&&e.size>0&&(i=i&&e.size<=s)}return t.Utils.fromResult(i)}};ye([t.Watch({emit:!1,converter:t.PropertyConverters.String})],Se.prototype,"pattern",void 0),ye([t.Watch({emit:!1,converter:t.PropertyConverters.String})],Se.prototype,"maxSize",void 0),Se=ye([t.CustomElement({tagName:t.P+"-binary-validator",template:fe,shadow:t.Defaults.USE_SHADOW_ROOT})],Se);let ke=class PacemAsyncValidatorElement extends PacemBaseValidatorElement{constructor(){super(...arguments),this._deferredToken=null}_evaluateResult(){const e=this._fetcher.result;switch(e){case"true":return!0;case"false":return!1;default:try{let i=JSON.parse(e);return t.Utils.getApiResult(i)||!1}catch(e){return!1}}}_fetch(e){const i=this._deferredToken,a=this._fetcher;var s=this.parameters||{};s[this.watch]=e;const r={parameters:s,url:this.url,as:"text",method:this.method},n=t.Utils.jsonSortStringify(r),o=this.#p;let l=!1;if(t.Utils.isNullOrEmpty(o)||(l=n===o),l){const e=this._evaluateResult();i.resolve(e)}else t.Utils.extend(a,r),clearTimeout(this._debouncer),this._debouncer=setTimeout(()=>{a.fetch().then(e=>{const t=this._evaluateResult();i.resolve(t),this.#p=n},e=>{i.resolve(!1)})},1e3);return i.promise}#p;evaluate(e){return t.Utils.isNullOrEmpty(e)?t.Utils.fromResult(!0):(this._deferredToken=this._deferredToken=t.DeferPromise.defer(),this._fetch(e).then(e=>(this._deferredToken=null,e),e=>(this._deferredToken=null,!1)))}propertyChangedCallback(e,t,i,a){if(super.propertyChangedCallback(e,t,i,a),!a)switch(e){case"parameters":case"url":case"method":case"fetchCredentials":case"fetchHeaders":this.triggerFormFieldValidation()}}};ye([t.Watch({emit:!1,converter:t.PropertyConverters.Json})],ke.prototype,"parameters",void 0),ye([t.Watch({emit:!1,converter:t.PropertyConverters.Json})],ke.prototype,"fetchCredentials",void 0),ye([t.Watch({emit:!1,converter:t.PropertyConverters.Json})],ke.prototype,"fetchHeaders",void 0),ye([t.Watch({emit:!1,converter:t.PropertyConverters.String})],ke.prototype,"url",void 0),ye([t.Watch({emit:!1,converter:t.PropertyConverters.String})],ke.prototype,"method",void 0),ye([t.ViewChild(t.P+"-fetch")],ke.prototype,"_fetcher",void 0),ke=ye([t.CustomElement({tagName:t.P+"-async-validator",template:fe+`<${t.P}-fetch autofetch="false" throttle="true" credentials="{{ :host.fetchCredentials }}" headers="{{ :host.fetchHeaders }}"></${t.P}-fetch>`,shadow:t.Defaults.USE_SHADOW_ROOT})],ke);let $e=class PacemCustomValidatorElement extends PacemBaseValidatorElement{propertyChangedCallback(e,t,i,a){super.propertyChangedCallback(e,t,i,a),a||"isValid"!==e||this.triggerFormFieldValidation()}evaluate(e){let i=!0;return _e(e)||(i=!!this.isValid),t.Utils.fromResult(i)}};ye([t.Watch({emit:!1,converter:t.PropertyConverters.Boolean})],$e.prototype,"isValid",void 0),$e=ye([t.CustomElement({tagName:t.P+"-custom-validator",template:fe,shadow:t.Defaults.USE_SHADOW_ROOT})],$e);var Ue=function(e,t,i,a){var s,r=arguments.length,n=r<3?t:null===a?a=Object.getOwnPropertyDescriptor(t,i):a;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(e,t,i,a);else for(var o=e.length-1;o>=0;o--)(s=e[o])&&(n=(r<3?s(n):r>3?s(t,i,n):s(t,i))||n);return r>3&&n&&Object.defineProperty(t,i,n),n};function Ne(e){return new RegExp(e).source}let Oe=class PacemFormFieldElement extends PacemFormRelevantElement{constructor(e=new i.Components.UI.MarkdownService){super(),this._md=e,this._entityPropertyChangeHandler=e=>{this.dispatchEvent(new t.PropertyChangeEvent({propertyName:"entity",currentValue:this.entity}))},this._labelClickHandler=e=>{document.getElementById(this._label.htmlFor).focus()},this._key="_"+t.Utils.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,i,a,s){switch(super.propertyChangedCallback(e,i,a,s),e){case"readonly":this._ensureBalloon();break;case"metadata":this._ensureBalloon(),this._buildUpCss(),this._buildUpLabel(),this._buildUpField();break;case"entity":i instanceof HTMLElement&&i.removeEventListener(t.PropertyChangeEventName,this._entityPropertyChangeHandler,!1),a instanceof HTMLElement&&a.addEventListener(t.PropertyChangeEventName,this._entityPropertyChangeHandler,!1)}}disconnectedCallback(){this.entity instanceof HTMLElement&&this.entity.removeEventListener(t.PropertyChangeEventName,this._entityPropertyChangeHandler,!1),t.Utils.isNull(this._label)||this._label.removeEventListener("click",this._labelClickHandler,!1),t.Utils.isNull(this._balloon)||this._balloon.remove(),super.disconnectedCallback()}_normalizeTooltip(){const e=this.metadata&&this.metadata.extra&&this.metadata.extra.tooltip||!1;return"object"==typeof e?e:{type:e}}_ensureBalloon(){var e,a;const s=this.readonly||!1===(a=this._normalizeTooltip()).type||t.Utils.isNullOrEmpty(e=this.metadata&&this.metadata.display&&this.metadata.display.description);if(t.Utils.isNull(this._balloon)&&!s){let e=document.createElement(t.P+"-balloon");e.options={behavior:i.Components.UI.BalloonBehavior.Tooltip,trigger:a.trigger||i.Components.UI.BalloonTrigger.Hover,position:a.position||i.Components.UI.BalloonPosition.Top,hoverDelay:200,hoverTimeout:50,align:a.align||i.Components.UI.BalloonAlignment.Auto},t.Utils.addClass(e,t.PCSS+"-field-tooltip"),t.CustomElementUtils.findAncestorShell(this).appendChild(this._balloon=e)}const r=this._balloon;if(!(t.Utils.isNull(r)||(r.target=this._label,r.disabled=s))){const t=e||"";switch(a.type){case"md":case"markdown":r.innerHTML=this._md.toHtml(t);break;case"html":r.innerHTML=t;break;default:r.innerText=t}}}_buildUpCss(){const e=this.metadata?.display;if(!t.Utils.isNull(e)){if("function"==typeof e.cssClass){const{cssClassAttr:t}=e.cssClass(this,"$this","$this.entity");this.setAttribute("css-class",t)}else this.cssClass=e.cssClass;if("function"==typeof e.css){const{cssAttr:t}=e.css(this,"$this","$this.entity");this.setAttribute("css",t)}else this.css=e.css}}_buildUpLabel(){const e=this._label,i=e.firstElementChild,a=this.metadata;e.htmlFor=this._key,t.Utils.addClass(e,t.PCSS+"-label");const s=this.metadata.validators;if(s&&s.find(e=>"required"===e.type)?t.Utils.addClass(e,t.PCSS+"-required"):t.Utils.removeClass(e,t.PCSS+"-required"),t.Utils.isNull(this._balloon)||this._balloon.disabled?t.Utils.removeClass(e,t.PCSS+"-tooltip"):t.Utils.addClass(e,t.PCSS+"-tooltip"),"function"==typeof a.display?.name){const{contentAttr:e}=a.display.name(this,":host",":host.entity","::_form");i.setAttribute("content",e)}else i.removeAttribute("content"),i.content=a.display&&a.display.name||a.prop;e.setAttribute("id","label"+this._key),e.addEventListener("click",this._labelClickHandler,!1)}_isValueNullOrEmpty(e=this.entity,i=this.metadata){if(t.Utils.isNull(i))return!0;const a=i.prop.split(".");let s=e;for(let e=0;e<a.length;e++){const i=a[e];if(t.Utils.isNullOrEmpty(s&&s[i]))return!0;s=s[i]}return!1}_handleValueChange(e){if("value"===e.detail.propertyName){const i=e.detail.currentValue,a=this.metadata.prop;if(this.entity instanceof HTMLElement){let e=t.CustomElementUtils.camelToKebab(a);t.Utils.isNullOrEmpty(i)?this.entity.removeAttribute(e):this.entity.setAttribute(e,i.toString())}else this.entity[a]=i}}_adjustDependencyValue(e){return t.Utils.Dates.isDate(e)?t.Utils.Dates.parse(e).toISOString():e}_broadcastFetchResult(e){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","form"+this._key),e.setAttribute("sudden-validation","{{ ::form.suddenValidation }}")}_apiResult(e){return t.Utils.getApiResult(e)}_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 i=this.metadata;let a=t.P+"-input-text",s=t.P+(i.display&&"slider"===i.display.ui?"-slider":"-input-number"),r={id:this._key,name:i.prop,readonly:"{{ :host.readonly || :host.metadata.isReadOnly || ::_form.readonly }}",value:`{{ :host.entity.${i.prop}, twoway }}`,placeholder:`${i.display&&i.display.watermark||""}`};1==i.extra?.autofocus&&(r["on-load"]="requestAnimationFrame(() => $this.focus())");let n=i.extra||{},o={},l="false",c="",d="",h="",p=[];if(!t.Utils.isNullOrEmpty(n.dependsOn))if("function"==typeof n.dependsOn){const E=n.dependsOn(this,":host",":host.entity","$this.entity"),w=E.hideAttr;if(t.Utils.isNullOrEmpty(w)||this.setAttribute("hide",w),t.Utils.isNullOrEmpty(E.disabledAttr)||(l=E.disabledAttr,t.CustomElementUtils.isBindingAttribute(l)&&(d=t.CustomElementUtils.extractBindingAttributeExpression(l))),!t.Utils.isNullOrEmpty(E.parameterAttrs)){const S=E.parameterAttrs,k=[];for(let $ in S){const U=S[$];k.push(`${$}: ${U}`),p.push({prop:U})}h=k.join(", ")}}else{p=n.dependsOn;let N={empty:[],notEqual:{}},O={empty:[],notEqual:{}},x=[];for(var u of p){let D=":host.entity."+u.prop,H="$this.entity."+u.prop;if(t.Utils.isNullOrEmpty(u.value)){if(!u.optional){let A=e=>"$pacem.isNullOrEmpty("+e+")";N.empty.push(A(D)),u.hide&&O.empty.push(A(H))}}else{let T=e=>e+" !== "+JSON.stringify(u.value);(N.notEqual[D]=N.notEqual[D]||[]).push(T(D)),u.hide&&(O.notEqual[H]=O.notEqual[H]||[]).push(T(H))}x.push(`${u.alias||u.prop}: :host._adjustDependencyValue(${D})`),u.optional||(c+=`!$pacem.isNullOrEmpty(${D}) && `)}h=x.join(", ");let V=e=>{let i="false",a="false";if(!t.Utils.isNullOrEmpty(e.notEqual)){const t=[];for(let i in e.notEqual)t.push("("+e.notEqual[i].join(" && ")+")");i="("+t.join(" || ")+")"}return t.Utils.isNullOrEmpty(e.empty)||(a="("+e.empty.join(" || ")+")"),i+" || "+a};d=V(N),l=`{{ ${d} }}`,this.setAttribute("hide",`{{ ${V(O)} }}`)}const m="fn",v=this[m]=this[m]||{},g=(e=[])=>{let i=(p||[]).map(e=>":host.entity."+e.prop).join(", ");const a="fn"+t.Utils.uniqueCode();if("function"==typeof e)v[a]=e;else{if(!t.Utils.isArray(e))throw"Unsupported source format.";v[a]=()=>e}return`{{ :host.${m}.${a}(${i}) }}`},y=new DocumentFragment;let f;if("function"==typeof i.type){var _=i.type(this,":host",":host.entity");if(-1===_.tagName.indexOf("-"))this.log(t.Logging.LogLevel.Error,`${a} is not an allowed form-field`);else{function R(e,i){if(!t.Utils.isNullOrEmpty(i))for(let s of i){if(-1===s.tagName.indexOf("-")){this.log(t.Logging.LogLevel.Error,`${s.tagName} is not an allowed child element for form-field ${a}`);continue}const i=document.createElement(s.tagName);if(!t.Utils.isNullOrEmpty(s.attrs))for(let e in s.attrs){const t=s.attrs[e];i.setAttribute(e,t)}t.Utils.isNullOrEmpty(s.children)||R(i,s.children),e.appendChild(i)}}a=_.tagName,t.Utils.extend(r,_.attrs||{}),R(y,_.children)}}else switch(f=i.display&&i.display.ui){case"contentEditable":console.warn("`contentEditable` ui hint is deprecated. Lean on `dataType` equal to 'HTML' instead."),a=t.P+"-contenteditable",y.append(ContenteditableUtils.getDefaultDashboard());break;case"snapshot":a=t.P+"-snapshot",n.width>0&&(r.width=""+n.width),n.height>0&&(r.height=""+n.height),n.quality>=0&&(r.quality=""+n.quality);break;case"chars":case"digits":case"otp":a=t.P+"-input-chars",n.charCount>0&&(r.charCount=""+n.charCount),t.Utils.isNullOrEmpty(n.inputTransform)||(r["input-transform"]=n.inputTransform);break;case"oneToMany":case"dropdown":case"radioList":case"checkboxList":case"manyToMany":"oneToMany"===f||"dropdown"===f?(a=t.P+"-select",!1!==n.preventWheel&&(r["on-wheel"]="$event.preventDefault()")):(delete r.placeholder,a=t.P+("radioList"===f?"-radio-list":"-checkbox-list")),t.Utils.isNullOrEmpty(n.textProperty)||(r["text-property"]=n.textProperty),t.Utils.isNullOrEmpty(n.disabledProperty)||(r["disabled-property"]=n.disabledProperty),t.Utils.isNullOrEmpty(n.valueProperty)||(i.isComplexType?r["compare-by"]=n.valueProperty:r["value-property"]=n.valueProperty),t.Utils.isNullOrEmpty(n.source)?(this._fetcher.id=`fetch${this._key}`,this._fetcher.url=n.sourceUrl,this._fetcher.method=n.verb,o.parameters=`{{ { ${h} } }}`,o.disabled=l,r.datasource=`{{ ${c}:host._apiResult(#fetch${this._key}.result) || null }}`):r.datasource=g(n.source);break;case"suggest":case"tags":case"autocomplete":const L="tags"===i.display.ui;a=t.P+(L?"-tags":"-suggest"),this._fetcher.id=`fetch${this._key}`,t.Utils.isNullOrEmpty(n.textProperty)||(r["text-property"]=n.textProperty);let I=`#${this._key}.value`;if(t.Utils.isNullOrEmpty(n.valueProperty)||(r["compare-by"]=n.valueProperty,L?I=`(${I} && ${I}.${n.valueProperty}) || ''`:i.isComplexType?I+=` && ${I}.${n.valueProperty}`:r["value-property"]=n.valueProperty),t.Utils.isNullOrEmpty(n.sourceUrl)?r.datasource=g(n.source):(o.url=`${n.sourceUrl}`,this._fetcher.method=n.verb,t.Utils.isNullOrEmpty(n.dependsOn)?o.parameters=`{{ {q: #${this._key}.hint || '', ${n.valueProperty||"value"}: ${I} || '' } }}`:(o.parameters=`{{ { ${h}, q: #${this._key}.hint || '', ${n.valueProperty||"value"}: ${I} || '' } }}`,o.disabled=l),r.datasource=`{{ ${c}:host._apiResult(#fetch${this._key}.result) || null }}`),L)r["allow-new"]=(!0===i.extra.allowNew).toString(),r["allow-duplicates"]=(!0===i.extra.allowDuplicates).toString();else{if(t.Utils.isNullOrEmpty(n.disabledProperty)||(r["disabled-property"]=n.disabledProperty),!t.Utils.isNullOrEmpty(n.itemtemplate)){const B=n.itemtemplate;B instanceof HTMLElement?(r.itemtemplate="{{ #"+(B.id=B.id||this._key+"_itemtmpl")+" }}",B.isConnected||this.append(B)):r.itemtemplate=B}if(!t.Utils.isNullOrEmpty(n.filterFields)){const j=n.filterFields;r["filter-fields"]=t.Utils.isArray(j)?j.join(" "):j}t.Utils.isNullOrEmpty(n.maxSuggestions)||(r["max-suggestions"]=n.maxSuggestions.toString())}break;case"calendar":a=t.P+"-calendar-picker";const F=i.display?.format??i.extra?.format;t.Utils.isNullOrEmpty(F)||(r.format="{{ "+JSON.stringify(F)+" }}"),t.Utils.isNullOrEmpty(n.disabledRanges)||(r["disabled-ranges"]="{{ "+JSON.stringify(n.disabledRanges)+" }}");break;case"dictionary":a=t.P+"-namevalue-list",r.dictionary="true";break;case"switcher":if("boolean"!==(i.type||"").toLowerCase())break;r.class="checkbox-switch";default:let W=(i.dataType||i.type||"").toLowerCase();switch(W){case"upload":a=t.P+"-upload";let M=i.extra||{};r.url=M.uploadUrl,r.parallelism=""+M.parallelism,r["chunk-size"]=""+M.chunkSize,r["max-image-width"]=""+M.maxImageWidth,r["max-image-height"]=""+M.maxImageHeight,r["select-mode"]=M.mode??"file";break;case"html":a=t.P+"-contenteditable",y.append(ContenteditableUtils.getDefaultDashboard());break;case"enumeration":a=t.P+"-radio-list",r.class=t.PCSS+"-radio-list",r["value-property"]="value",r["text-property"]="caption",r.datasource="{{ "+JSON.stringify(i.extra.enum)+" }}",delete r.placeholder;break;case"password":a=t.P+"-input-password";break;case"emailaddress":a=t.P+"-input-email";break;case"color":a=t.P+"-input-color";break;case"time":case"date":case"datetime":a=t.P+"-datetime-picker",delete r.placeholder,"datetime"===W&&(r.precision="minute");const z=i.display?.format??i.extra?.format;t.Utils.isNullOrEmpty(z)||(r.format="{{ "+JSON.stringify(z)+" }}"),t.Utils.isNullOrEmpty(n.disabledRanges)||(r["disabled-ranges"]="{{ "+JSON.stringify(n.disabledRanges)+" }}");break;case"url":a=t.P+"-input-url";break;case"phonenumber":a=t.P+"-input-tel";break;case"multilinetext":a=t.P+"-textarea";break;case"markdown":a=t.P+"-textarea-markdown";break;case"latlng":a=t.P+"-latlng",t.Utils.isNullOrEmpty(i.extra)||"object"!=typeof i.extra||t.Utils.isArray(i.extra)||(r.options=JSON.stringify(i.extra));break;case"percent":case"percentage":case"currency":let q="currency"===W?{style:"currency",currency:"EUR"}:{style:"percent",maximumFractionDigits:2},J=i.display?.format??q;r.format=JSON.stringify(J);default:switch((i.type||"").toLowerCase()){case"boolean":a=t.P+"-checkbox",r["true-value"]="{{ true }}",r["false-value"]="{{ false }}",r.caption=r.placeholder,delete r.placeholder;break;case"byte":r.min="0",r.max="255";case"int16":case"int32":case"int64":case"short":case"integer":case"int":case"long":r.step=""+(i.extra?.step??"1"),a=s;const Y=i.display?.format;t.Utils.isNullOrEmpty(Y)||(r.format=JSON.stringify(Y)),!1!==n.preventWheel&&a===t.P+"-input-number"&&(r["on-wheel"]="$event.preventDefault()");break;case"double":case"decimal":case"float":case"single":case"number":a=s,r.step=""+(i.extra?.step??"any");const G=i.display?.format;t.Utils.isNullOrEmpty(G)||(r.format=JSON.stringify(G)),!1!==n.preventWheel&&a===t.P+"-input-number"&&(r["on-wheel"]="$event.preventDefault()");break;default:if(("array"===i.type||"object"===i.type)&&!t.Utils.isNullOrEmpty(i.props)){if(a=t.P+"-childform",delete r.placeholder,r.metadata=t.Utils.Json.stringify(i.props,{functions:t.JsonFunctionConversion.Reference}),r.mode=i.type,r["lock-items"]=""+(i.extra&&i.extra.lockItems||!1),r.logger="{{ :host.logger }}",!t.Utils.isNullOrEmpty(p)){var b="";for(let K of p)b+=`<${t.P}-childform-propagator model="${r.value}" watch="{{ :host.entity.${K.prop} }}" property="${K.alias||K.prop}"></${t.P}-childform-propagator>\n`;this._container.innerHTML=b}r["fetch-credentials"]="{{ :host.fetchCredentials }}",r["fetch-headers"]="{{ :host.fetchHeaders }}"}}}}if(!t.Utils.isNullOrEmpty(i.commands)){t.Utils.addClass(this._container,t.PCSS+"-fieldgroup");const X=this._container.appendChild(document.createElement("div")),Z=this._container.appendChild(document.createElement("div"));t.Utils.addClass(X,`fieldgroup-prepend ${t.PCSS}-buttonset buttons`),t.Utils.addClass(Z,`fieldgroup-append ${t.PCSS}-buttonset buttons`);const Q=d||"false";i.commands.forEach(e=>{const a=document.createElement(t.P+"-button");a.setAttribute("icon-glyph",e.icon),a.setAttribute("command-name",e.name),e.dependsOnValue?(a.setAttribute("disabled",`{{ (${Q}) || !::_form.valid || $pacem.isNullOrEmpty(:host.entity.${i.prop}) }}`),a.setAttribute("command-argument",`{{ :host.entity.${i.prop} }}`)):a.setAttribute("disabled",l),a.setAttribute("tooltip",e.tooltip),t.Utils.isNullOrEmpty(e.cssClass)||t.Utils.addClass(a,e.cssClass.join(" ")),(e.prepend?X:Z).appendChild(a)})}t.Utils.isNullOrEmpty(i.validators)||i.validators.forEach(e=>{var s,n={},o={};switch(function(e){return"errorMessage"in e}(e)&&(n=e.params||{},o["error-message"]=e.errorMessage),function(e){return"attributes"in e&&"function"==typeof e.attributes}(e)&&t.Utils.extend(o,e.attributes(this,":host",":host.entity")),e.type){case"required":r.required="true",s=new be;break;case"length":let l=new Pe;s=l;let c=n&&n.max,d=n&&n.min;null!=c?(r.maxlength=""+(l.max=c),a===t.P+"-input-chars"&&(r.count??=""+c)):"max"in o&&(r.max=o.max),null!=d?r.minlength=""+(l.min=d):"min"in o&&(r.minlength=o.min);break;case"range":let h=new Ee;s=h;let u=n&&n.max,m=n&&n.min,v=a===t.P+"-datetime-picker";null!=u?(h.max=u,r.max="{{ "+(v?"'"+u+"'":u)+" }}"):"max"in o&&(r.max=o.max),null!=m?(h.min=m,r.min="{{ "+(v?"'"+m+"'":m)+" }}"):"min"in o&&(r.min=o.min);break;case"email":let g=new Ce;s=g,r.pattern=Ne(g.pattern=/^[\w\-\.]+@[\w\-\.]+\.[a-zA-Z0-9]{2,6}$/);break;case"regex":let y=new Ce;s=y;let f=n.pattern;f||=o.pattern,r.pattern=Ne(f),y.pattern=f;break;case"binary":let _=new Se;s=_;let b=n.pattern;null!=b?(r.pattern=Ne(b),_.pattern=b):"pattern"in o&&(r.pattern=o.pattern);let C=n&&n.maxSize;null!=C?(_.maxSize=C,r["max-size"]=""+C):"max-size"in o&&(r["max-size"]=o["max-size"]);break;case"compare":let P=new we;s=P;let E="";if("value"in n)E=JSON.stringify(n.value);else{E=`:host.entity.${"to"in n?n.to:n.toProperty}`}const w=`{{ ${E} }}`;P.setAttribute("to",w);let S=P.operator=n.operator||o.operator||"equal";if(a===t.P+"-datetime-picker")switch(S){case"lessOrEqual":case"less":r.max=w;break;case"greaterOrEqual":case"greater":r.min=w}break;case"async":let k=new ke;s=k,k.url=n.url;let $=[],U=n.dependsOn||p;$.push(`${i.prop}: :host._adjustDependencyValue(:host.entity.${i.prop})`);for(let e of U||[])$.push(`${e.alias||e.prop}: :host._adjustDependencyValue(:host.entity.${e.prop})`);k.setAttribute("parameters",`{{ { ${$.join(", ")} } }}`),k.method=n.verb||t.Net.HttpMethod.Get,k.setAttribute("fetch-credentials","{{ :host.fetchCredentials }}"),k.setAttribute("fetch-headers","{{ :host.fetchHeaders }}");break;case"custom":s=new $e;break;default:if(!t.Utils.isNullOrEmpty(e.type)&&e.type.indexOf("-")>0){const t=e.type,i=document.createElement(t);i instanceof PacemBaseValidatorElement&&(s=i)}}if(t.Utils.isNull(s))throw`Cannot generate a formfield validator based on type: ${e.type}.`;s.watch=i.prop,s.setAttribute("hide","{{ !this.invalid }}"),s.setAttribute("disabled",l);for(let e in o)s.setAttribute(e,o[e]);this._validators.appendChild(s)});let C=document.createElement(a);for(var P in r){let ee;t.Utils.isNullOrEmpty(ee=r[P])||C.setAttribute(P,ee)}for(var P in C.append(y),this._field=C,this._container.insertBefore(C,this._container.firstElementChild),o){let te;t.Utils.isNullOrEmpty(te=o[P])||this._fetcher.setAttribute(P,te)}this.dispatchEvent(new t.PropertyChangeEvent({propertyName:"field",currentValue:C}))}};Ue([t.ViewChild("label")],Oe.prototype,"_label",void 0),Ue([t.ViewChild(`div.${t.PCSS}-input-container`)],Oe.prototype,"_container",void 0),Ue([t.ViewChild(t.P+"-fetch")],Oe.prototype,"_fetcher",void 0),Ue([t.ViewChild(t.P+"-form")],Oe.prototype,"_form",void 0),Ue([t.ViewChild(t.P+"-panel."+t.PCSS+"-validators")],Oe.prototype,"_validators",void 0),Ue([t.Watch({converter:t.PropertyConverters.Json})],Oe.prototype,"metadata",void 0),Ue([t.Watch({converter:t.PropertyConverters.Json})],Oe.prototype,"fetchHeaders",void 0),Ue([t.Watch({converter:t.PropertyConverters.String})],Oe.prototype,"fetchCredentials",void 0),Ue([t.Watch({converter:t.PropertyConverters.Boolean})],Oe.prototype,"readonly",void 0),Ue([t.Watch()],Oe.prototype,"entity",void 0),Oe=Ue([t.CustomElement({tagName:t.P+"-form-field",template:`<${t.P}-form class="${t.PCSS}-field" logger="{{ :host.logger }}" \ncss-class="{{ {'${t.PCSS}-fetching': ::_fetcher.fetching, '${t.PCSS}-dirty': this.dirty, '${t.PCSS}-invalid': !this.valid, '${t.PCSS}-editable': !:host.readonly, '${t.PCSS}-readonly': :host.readonly, '${t.PCSS}-pristine': !this.dirty, '${t.PCSS}-valid': this.valid, '${t.PCSS}-has-value': !:host._isValueNullOrEmpty(:host.entity, :host.metadata) } }}">\n <label class="${t.PCSS}-label"><${t.P}-span></${t.P}-span></label>\n <div class="${t.PCSS}-input-container"></div>\n <${t.P}-fetch debounce="300" logger="{{ :host.logger }}" credentials="{{ :host.fetchCredentials }}" headers="{{ :host.fetchHeaders }}" diff-by-values="true"\n on-fetchresult=":host._broadcastFetchResult($event.detail)"></${t.P}-fetch>\n <${t.P}-panel class="${t.PCSS}-validators" hide="{{ ::_form.valid || !::_form.dirty || :host.readonly }}"></${t.P}-panel>\n</${t.P}-form>`})],Oe);var xe=function(e,t,i,a){var s,r=arguments.length,n=r<3?t:null===a?a=Object.getOwnPropertyDescriptor(t,i):a;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(e,t,i,a);else for(var o=e.length-1;o>=0;o--)(s=e[o])&&(n=(r<3?s(n):r>3?s(t,i,n):s(t,i))||n);return r>3&&n&&Object.defineProperty(t,i,n),n};let Ve=class PacemGeolocateElement extends PacemBaseElement{constructor(){super(...arguments),this._dragendHandler=e=>{this._reverseGeocoder.position=e.detail.position}}get inputFields(){return[]}toggleReadonlyView(e){this._setupSuggest(),this._setupMapMarker()}onChange(e){return new Promise((i,r)=>{if("success"===e.type&&e.target===this._reverseGeocoder){const s=this.#u.position,r=e.detail.sort((e,t)=>a.Maps.MapProjection.distanceBetween(e.position,s)<a.Maps.MapProjection.distanceBetween(t.position,s)?0:-1),n=r[0].position.altitude,o=t.Utils.extend({},r[0],{position:t.Utils.extend({altitude:n},s)});i(this.value=o)}else e.type===s&&e.target===this._suggest?i(this.value=this._suggest.value):i(this.value)})}fetch(e){a.Maps.LatLng.isLatLng(e)&&(this.#u.position=this._reverseGeocoder.position=e)}compareValuePropertyValues(e,t){const i=e?.position??a.Maps.LatLng.Empty,s=t?.position??a.Maps.LatLng.Empty;return a.Maps.LatLng.equals(i,s)}acceptValue(e){t.Utils.isNull(e)?this._datasource.model=[]:(this._datasource.model=[e],this._setupMapMarker()),this._setupSuggest()}getViewValue(e){return e?.fullAddress||""}convertValueAttributeToProperty(e){return t.PropertyConverters.Json.convert(e,this)}#u;viewActivatedCallback(){super.viewActivatedCallback(),this._setup()}propertyChangedCallback(e,t,i,a){if(super.propertyChangedCallback(e,t,i,a),!a)switch(e){case"adapter":this._setupAdapters(i);break;case"map":t&&this._detachMarker(t),i&&this._setupMapMarker(i);break;case"icon":this._setupMapMarker();break;case"plaeholder":this._setupSuggest();break;case"disabled":this._setupMapMarker(),this._setupSuggest()}}disconnectedCallback(){this._disposeMarker(),super.disconnectedCallback()}_setupAdapters(e=this.adapter){const i=this._geocoder,a=this._reverseGeocoder;t.Utils.isNull(i)||(i.adapter=e),t.Utils.isNull(a)||(a.adapter=e)}_setupSuggest(){const e=this._suggest;t.Utils.isNull(e)||(e.placeholder=this.placeholder??"search...",e.readonly=this.readonly,e.disabled=this.disabled,e.value=this.value)}_detachMarker(e=this.map){const i=this.#u;t.Utils.isNull(i)||i.map!==e||i.remove()}_createMarker(){const e=new a.Components.Maps.PacemMapMarkerElement;return e.addEventListener("dragend",this._dragendHandler,!1),e}_disposeMarker(){const e=this.#u;t.Utils.isNull(e)||e.removeEventListener("dragend",this._dragendHandler,!1)}_setupMapMarker(e=this.map){const i=this.#u||(this.#u=this._createMarker());i.icon=this.icon,i.draggable=!this.readonly&&!this.disabled,i.hide=this.disabled;const a=this.value;a&&a.position&&(i.position=a.position),i.map===e||t.Utils.isNull(e)||e.appendChild(i)}_setup(){this._setupAdapters(),this._setupSuggest(),this._setupMapMarker()}};xe([t.Watch({emit:!1,converter:t.PropertyConverters.Element})],Ve.prototype,"adapter",void 0),xe([t.Watch({emit:!1,converter:t.PropertyConverters.Element})],Ve.prototype,"map",void 0),xe([t.Watch({emit:!1,converter:t.PropertyConverters.Json})],Ve.prototype,"icon",void 0),xe([t.ViewChild(t.P+"-data[ds]")],Ve.prototype,"_datasource",void 0),xe([t.ViewChild(t.P+"-suggest")],Ve.prototype,"_suggest",void 0),xe([t.ViewChild(t.P+"-map-geocode")],Ve.prototype,"_geocoder",void 0),xe([t.ViewChild(t.P+"-map-geocode[reverse]")],Ve.prototype,"_reverseGeocoder",void 0),Ve=xe([t.CustomElement({tagName:t.P+"-geolocate",shadow:!1,template:`<${t.P}-map-geocode search="{{ ::_suggest.hint }}"\n disabled="{{ (::_suggest.hint || '').length < 3 }}" on-success="::_datasource.model = $event.detail"></${t.P}-map-geocode>\n<${t.P}-map-geocode reverse on-success=":host.changeHandler($event)"></${t.P}-map-geocode>\n\n<${t.P}-data ds></${t.P}-data>\n\n<${t.P}-suggest on-change=":host.changeHandler($event)" datasource="{{ ::_datasource.model || [] }}"\n compare-by="fullAddress" text-property="fullAddress"></${t.P}-suggest>`})],Ve);var De=function(e,t,i,a){var s,r=arguments.length,n=r<3?t:null===a?a=Object.getOwnPropertyDescriptor(t,i):a;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(e,t,i,a);else for(var o=e.length-1;o>=0;o--)(s=e[o])&&(n=(r<3?s(n):r>3?s(t,i,n):s(t,i))||n);return r>3&&n&&Object.defineProperty(t,i,n),n};class HierarchyChangeEvent extends CustomEvent{constructor(e){super("hierarchychange",{detail:e,bubbles:!1,cancelable:!1})}}const He="hierarchy-item",Ae=He+" "+t.PCSS+"-anim anim-fade-in anim-sudden",Te="{{ { 'item-disabled' : ^item.disabled } }}",Re="pacemHierarchy",Le="item-content",Ie="item-link",Fe=Ie+" icon-rotate rotate-135",We="link",Be="item-move",je="drag_indicator",Me="parents";let ze=class PacemHierarchyElement extends PacemBaseElement{getViewValue(e){return""}convertValueAttributeToProperty(e){return t.Utils.Json.parse(e)}constructor(){super(),this.#m=new Map,this.#v=new Map,this.unlinkCaption="Delete",this._binderClickHandler=e=>{const i=e.originalEvent.type;if("mousedown"===i&&1===e.originalEvent.button){t.avoidHandler(e.originalEvent);const i=e.srcElement;this._unlink(i)}else if("click"===i||"contextmenu"===i){t.avoidHandler(e.originalEvent),this.#g=e.srcElement;const i=this._balloon;i.target={x:e.pageX,y:e.pageY},i.popup()}},this._dragInitHandler=e=>{let a=e.detail;const s=this._dragger;s.floater=document.createElement("span"),s.dropTargets=Array.from(this.#v.keys()).filter(e=>e!==a.element),t.Utils.isNull(this.#y)||this.#y.remove();const r=this.#y=new i.Components.UI.PacemBinderElement;r.from=a.element,this.#f.appendChild(r)},this._dragStartHandler=e=>{t.Utils.addClass(e.detail.element,"item-drag")},this._dragHandler=e=>{this.#y.to=e.detail.currentPosition},this._dragEndHandler=e=>{t.Utils.removeClass(e.detail.element,"item-drag"),this.#y.remove(),this.#y=null},this._dropHandler=e=>{const t=e.detail.data,i=this.#v.get(e.detail.target);this._isInAncestors(t,i)||this._isInDescendants(t,i)||this._compileHierarchy({source:t,target:i})},this._dragOverHandler=e=>{const t=e.detail.data,i=this.#v.get(e.detail.target);(i.disabled||this._isInAncestors(t,i)||this._isInDescendants(t,i))&&e.preventDefault()},this._dragOutHandler=e=>{},this._popoutHandler=e=>{this._balloon.popout()},this.#_=t.Utils.uniqueCode()}#_;#m;#y;#g;#v;#f;get inputFields(){return[]}toggleReadonlyView(e){this._dragger.disabled=e,t.Utils.isNull(this._adaptedDatasource)||this._databind()}onChange(e){return new Promise((i,a)=>{t.CustomEventUtils.isInstanceOf(e,HierarchyChangeEvent)?i(this.value=e.detail):i(this.value)})}acceptValue(e){}viewActivatedCallback(){super.viewActivatedCallback(),this.#f=t.CustomElementUtils.findAncestorShell(this),this._setupItemTemplate(),this._setupDragger(),this._setupBalloon()}propertyChangedCallback(e,t,i,a){switch(super.propertyChangedCallback(e,t,i,a),e){case"datasource":case"textProperty":case"disabledProperty":case"valueProperty":cancelAnimationFrame(this._handle),this._handle=requestAnimationFrame(()=>{this._buildAdaptedDatasource()});break;case"itemtemplate":a||this._setupItemTemplate();break;case"_adaptedDatasource":case"value":cancelAnimationFrame(this._handle2),this._handle2=requestAnimationFrame(()=>{this._databind()})}}disconnectedCallback(){this._disposeBindersAndTargets(),this._disposeDragger(),this._disposeBalloon(),super.disconnectedCallback()}_buildAdaptedDatasource(e=this.datasource){this._adaptedDatasource=e&&e.map(e=>this._mapEntityToItem(e))}_mapEntityToValue(e){let t,i=e;return(t=this.valueProperty)&&(i=e[t]),i}_mapEntityToViewValue(e){let t,i=e.toString();return(t=this.textProperty)&&(i=e[t]),i}_mapEntityToItem(e){if(null==e)throw new Error("Entity cannot be null");let i=!1;const a=this.disabledProperty;return t.Utils.isNullOrEmpty(a)||(i=e[a]||!1),{value:this._mapEntityToValue(e),viewValue:this._mapEntityToViewValue(e),disabled:i,data:e}}_unlink(e){var t;e instanceof i.Components.UI.PacemBinderElement?t=e:(e.preventDefault(),e.stopPropagation(),t=this.#g);const{parent:a,child:s}=JSON.parse(t.dataset[Re]),r=this._adaptedDatasource,n=r.find(e=>e.value===a),o=r.find(e=>e.value===s);n.disabled||o.disabled||this._compileHierarchy({source:n,target:o},!0)}_buildHierarchyItemDomId(e){return`hierarchyitem_${this.#_}_${e}`}_itemCreate(e){const a=e.detail.dom.find(e=>e instanceof HTMLElement&&e.classList.contains(He));e.detail.index;const s=e.detail.item;a.id=this._buildHierarchyItemDomId(s.value),s.disabled?a.setAttribute("behaviors","{{ [#"+this._dragger2.id+"] }}"):a.setAttribute("behaviors","{{ [#"+this._dragger.id+", #"+this._dragger2.id+"] }}");const r=this.#m,n=s.value;let o;r.has(n)?o=r.get(n):r.set(n,o=new Map);for(let e of s.parents||[]){const t=e.value,r=!o.has(t),n=r?new i.Components.UI.PacemBinderElement:o.get(t);n.fromAnchor=i.Components.UI.BinderAnchor.Bottom,n.toAnchor=i.Components.UI.BinderAnchor.Top,n.toEnd=i.Components.UI.BinderEnd.Arrow,n.setAttribute("from","{{ #"+this._buildHierarchyItemDomId(e.value)+" }}"),n.setAttribute("to","{{ #"+a.id+" }}"),n.cssClass=["hierarchy-binder"],n.dataset[Re]=JSON.stringify({parent:e.value,child:s.value}),n.interactive=!this.readonly&&!s.disabled&&!e.disabled,r&&(n.addEventListener(i.Components.UI.BinderInteractionEventName,this._binderClickHandler,!1),this.#f.appendChild(n),o.set(t,n))}for(let e of o.keys()){const a=s.parents.find(t=>t.value===e);if(!t.Utils.isNull(a))continue;const r=o.get(e);r.removeEventListener(i.Components.UI.BinderInteractionEventName,this._binderClickHandler),r.remove(),o.delete(e)}this.#v.has(a)||this.#v.set(a,s)}_itemRemove(e){const t=e.detail.dom.find(e=>e instanceof HTMLElement&&e.classList.contains(He)),i=e.detail.item;this._disposeBinders(i.value),this.#v.has(t)&&this.#v.delete(t)}_disposeBinders(e){const t=this.#m;if(t.has(e)){const a=t.get(e);for(let e of a.keys()){const t=a.get(e);t.removeEventListener(i.Components.UI.BinderInteractionEventName,this._binderClickHandler,!1),t.remove()}t.delete(e)}}_disposeBindersAndTargets(){for(let e of this.#m.keys())this._disposeBinders(e);this.#v.clear()}_setupItemTemplate(){if(this.itemtemplate instanceof HTMLTemplateElement){const e=this.itemtemplate.cloneNode(!0).content,a=document.createElement("template"),s=document.createElement(t.P+"-panel");s.className=Ae,s.setAttribute("css-class",Te);const r=new i.Components.UI.PacemIconElement;r.setAttribute("icon",je),r.className=Be,s.appendChild(r);const n=document.createElement("div");n.className=Le,n.append(e),s.appendChild(n);const o=new i.Components.UI.PacemIconElement;o.setAttribute("icon",We),o.className=Fe,s.appendChild(o),a.content.appendChild(s),this._template=a}else this._template=this._defaultTemplate}_compileHierarchy(e,i=!1){const a=t.Utils.clone(this.value||[]),s=e.source.value,r=e.target.value,n=this.parentsProperty||Me;var o=a.find(e=>e[this.valueProperty]===r);if(i){if(!t.Utils.isNull(o)){const e=o[n]||[],t=e.indexOf(s);t>=0&&e.splice(t,1)}}else t.Utils.isNull(o)&&((o={})[this.valueProperty]=r,o[n]=[],a.push(o)),o[n].push(s);this._tidyUpHierarchy(a),this.changeHandler(new HierarchyChangeEvent(a))}_tidyUpHierarchy(e=[]){const i=this.valueProperty,a=this.parentsProperty||Me,s=(r,n)=>{const o=e.find(e=>e[i]==n);if(t.Utils.isNull(o)||t.Utils.isNullOrEmpty(o[a]))return!1;const l=o[a];return l.indexOf(r)>=0||l.some(e=>s(r,e))};for(let t of e){const e=t[a]||[];for(let t=e.length-1;t>=0;t--){const i=e[t],a=e.filter(e=>e!==i);for(let r of a)if(s(i,r)){e.splice(t,1);break}}}}_setupDragger(){const e=this._dragger;e.id="hierarchy_link_"+this.#_,e.handleSelector="."+Ie,e.dropBehavior=t.UI.DropBehavior.None,e.spillBehavior=t.UI.DropTargetMissedBehavior.None,e.mode=t.UI.DragDataMode.Copy,e.addEventListener(t.UI.DragDropEventType.Drop,this._dropHandler,!1),e.addEventListener(t.UI.DragDropEventType.Drag,this._dragHandler,!1),e.addEventListener(t.UI.DragDropEventType.Init,this._dragInitHandler,!1),e.addEventListener(t.UI.DragDropEventType.Start,this._dragStartHandler,!1),e.addEventListener(t.UI.DragDropEventType.End,this._dragEndHandler,!1),e.addEventListener(t.UI.DragDropEventType.Over,this._dragOverHandler,!1),e.addEventListener(t.UI.DragDropEventType.Out,this._dragOutHandler,!1);const i=this._dragger2;i.id="hierarchy_move_"+this.#_,i.mode=t.UI.DragDataMode.Self,i.dropBehavior=t.UI.DropBehavior.None,i.spillBehavior=t.UI.DropTargetMissedBehavior.None,i.handleSelector="."+Be}_disposeDragger(){const e=this._dragger;t.Utils.isNull(e)||(e.removeEventListener(t.UI.DragDropEventType.Drop,this._dropHandler,!1),e.removeEventListener(t.UI.DragDropEventType.Drag,this._dragHandler,!1),e.removeEventListener(t.UI.DragDropEventType.Init,this._dragInitHandler,!1),e.removeEventListener(t.UI.DragDropEventType.Start,this._dragStartHandler,!1),e.removeEventListener(t.UI.DragDropEventType.End,this._dragEndHandler,!1),e.removeEventListener(t.UI.DragDropEventType.Over,this._dragOverHandler,!1),e.removeEventListener(t.UI.DragDropEventType.Out,this._dragOutHandler,!1))}_setupBalloon(){this._balloon=this._shellProxy.dom.find(e=>e instanceof i.Components.UI.PacemBalloonElement),window.addEventListener("mousedown",this._popoutHandler,!1)}_disposeBalloon(){window.removeEventListener("mousedown",this._popoutHandler,!1)}_isInAncestors(e,i){return!t.Utils.isNull(i)&&!t.Utils.isNullOrEmpty(i.parents)&&(i.parents.indexOf(e)>=0||i.parents.some(t=>this._isInAncestors(e,t)))}_isInDescendants(e,t){return this._isInAncestors(t,e)}_databind(){const e=this.valueProperty;if(t.Utils.isNullOrEmpty(e))throw new Error("Missing valueProperty.");const i=t.Utils.clone(this._adaptedDatasource||[]),a=this.value||[],s=this.parentsProperty||Me;for(let r of i){const n=a.find(t=>t[e]===r.value);t.Utils.isNull(n)||(r.parents=(n[s]||[]).map(e=>i.find(t=>t.value===e)).filter(e=>!t.Utils.isNull(e)))}this._databindByParents(i)}_databindByParents(e){const i=[];function a(){return i.reduce((e,t)=>e+t.length,0)}do{if(t.Utils.isNullOrEmpty(i)){const a=e.filter(e=>t.Utils.isNullOrEmpty(e.parents));i.push(a)}else{const a=Array.prototype.concat.apply([],i),s=i[i.length-1],r=e.filter(e=>!t.Utils.isNullOrEmpty(e.parents)&&(e.parents.every(e=>a.indexOf(e)>=0)&&e.parents.some(e=>s.indexOf(e)>=0)));i.push(r)}}while(a()<e.length);this._repeater.datasource=i}};De([t.ViewChild("template[default]")],ze.prototype,"_defaultTemplate",void 0),De([t.ViewChild(t.P+"-repeater")],ze.prototype,"_repeater",void 0),De([t.ViewChild(t.P+"-drag-drop")],ze.prototype,"_dragger",void 0),De([t.ViewChild(t.P+"-drag-drop[move]")],ze.prototype,"_dragger2",void 0),De([t.ViewChild(t.P+"-shell-proxy")],ze.prototype,"_shellProxy",void 0),De([t.Watch({emit:!1,converter:t.PropertyConverters.Json})],ze.prototype,"datasource",void 0),De([t.Watch({emit:!1,converter:t.PropertyConverters.String})],ze.prototype,"valueProperty",void 0),De([t.Watch({emit:!1,converter:t.PropertyConverters.String})],ze.prototype,"textProperty",void 0),De([t.Watch({emit:!1,converter:t.PropertyConverters.String})],ze.prototype,"disabledProperty",void 0),De([t.Watch({converter:t.PropertyConverters.String})],ze.prototype,"unlinkCaption",void 0),De([t.Watch({converter:t.PropertyConverters.Json})],ze.prototype,"_adaptedDatasource",void 0),De([t.Watch({emit:!1,converter:t.PropertyConverters.Element})],ze.prototype,"itemtemplate",void 0),De([t.Watch({converter:t.PropertyConverters.Element})],ze.prototype,"_template",void 0),De([t.Watch({emit:!1,converter:t.PropertyConverters.String})],ze.prototype,"parentsProperty",void 0),ze=De([t.CustomElement({tagName:t.P+"-hierarchy",shadow:t.Defaults.USE_SHADOW_ROOT,template:`<${t.P}-repeater>\n <template>\n <${t.P}-repeater on-${t.Components.RepeaterItemCreateEventName}=":host._itemCreate($event)" on-${t.Components.RepeaterItemRemoveEventName}=":host._itemRemove($event)" datasource="{{ ^item }}">\n <div class="hierarchy-level">\n <${t.P}-template-proxy target="{{ :host._template }}"></${t.P}-template-proxy>\n </div>\n </${t.P}-repeater>\n </template>\n </div>\n</${t.P}-repeater><${t.P}-content></${t.P}-content>\n<${t.P}-drag-drop></${t.P}-drag-drop>\n<${t.P}-drag-drop move></${t.P}-drag-drop>\n<template default>\n <${t.P}-panel class="${Ae} item-default" css-class="${Te}">\n <${t.P}-icon class="${Be}" icon="${je}"></${t.P}-icon>\n <pacem-span class="${Le}" content="{{ ^item.viewValue }}"></${t.P}-span>\n <${t.P}-icon class="${Fe}" icon="${We}"></${t.P}-icon>\n </${t.P}-panel>\n</template>\n<${t.P}-shell-proxy>\n <${t.P}-balloon options="{{ { behavior: '${i.Components.UI.BalloonBehavior.Inert}' } }}">\n <${t.P}-button icon-glyph="link_off" class="${t.PCSS}-margin margin-0 button-flat display-flex flex-middle icon-rotate rotate-135"\n on-click=":host._unlink($event)"\n on-mousedown="$event.stopPropagation()"\n on-mouseup="::_balloon.popout()"><${t.P}-text class="${t.PCSS}-margin margin-left-1" text="{{ :host.unlinkCaption }}"></${t.P}-text></${t.P}-button>\n </${t.P}-balloon>\n</${t.P}-shell-proxy>`})],ze);var qe,Je=function(e,t,i,a){var s,r=arguments.length,n=r<3?t:null===a?a=Object.getOwnPropertyDescriptor(t,i):a;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(e,t,i,a);else for(var o=e.length-1;o>=0;o--)(s=e[o])&&(n=(r<3?s(n):r>3?s(t,i,n):s(t,i))||n);return r>3&&n&&Object.defineProperty(t,i,n),n};!function(e){e.Input="input",e.Blur="blur"}(qe||(qe={}));const Ye="pacem:scaffolding:input_field";class PacemBaseInputElement extends PacemBaseElement{constructor(){super(...arguments),this.debounce=!1,this.changePolicy=qe.Input,this._focusHandler=e=>{if(!this.autoselect)return;let t=this.inputField;for(let e of this.inputFields??[])if(e===document.activeElement){t=e;break}t?.select()}}propertyChangedCallback(e,t,i,a){if(super.propertyChangedCallback(e,t,i,a),"placeholder"===e)for(let t of this.inputFields??[])t.setAttribute(e,i)}acceptValue(e){this.inputField&&e!==this.inputField.value&&(this.inputField.value=t.Utils.isNullOrEmpty(e)?"":e)}get inputField(){return this.inputFields[0]}onChange(e){return new Promise(t=>{if(this.readonly)t(this.value);else if("input"===e.type&&this.changePolicy===qe.Blur)t(this.value);else{const e=()=>{const e=this.getValue(this.inputField.value);e!==this.value&&(this.value=e),t(e)},i=this.debounce;"number"==typeof i&&i>0?(clearTimeout(this._handle),this._handle=setTimeout(e,i)):!0===i?(cancelAnimationFrame(this._handle),this._handle=requestAnimationFrame(e)):requestAnimationFrame(e)}})}registerInputFields(e=this.inputFields){super.registerInputFields(e),t.Utils.isNull(e)||t.Utils.isArray(e)||(e=[e]);for(let i of e??[])(i instanceof HTMLInputElement||i instanceof HTMLTextAreaElement)&&"on"!==t.CustomElementUtils.getAttachedPropertyValue(i,Ye,"off")&&(t.CustomElementUtils.setAttachedPropertyValue(i,Ye,"on"),"size"in i&&(i.size=1),i.autocomplete="off",i.addEventListener("input",this.changeHandler,!1),i.addEventListener("focus",this._focusHandler,!1))}unregisterInputFields(e=this.inputFields){super.unregisterInputFields(e),t.Utils.isNull(e)||t.Utils.isArray(e)||(e=[e]);for(let i of e??[])"on"===t.CustomElementUtils.getAttachedPropertyValue(i,Ye)&&(t.CustomElementUtils.deleteAttachedPropertyValue(i,Ye),i.removeEventListener("input",this.changeHandler,!1),i.removeEventListener("focus",this._focusHandler,!1))}viewActivatedCallback(){super.viewActivatedCallback(),this.registerInputFields()}disconnectedCallback(){this.unregisterInputFields(),super.disconnectedCallback()}}Je([t.Watch({emit:!1,converter:{convert:e=>{switch(e){case"true":return!0;case"false":return!1;default:return parseFloat(e)}},convertBack:e=>e.toString()}})],PacemBaseInputElement.prototype,"debounce",void 0),Je([t.Watch({emit:!1,converter:t.PropertyConverters.String})],PacemBaseInputElement.prototype,"changePolicy",void 0),Je([t.Watch({emit:!1,converter:t.PropertyConverters.Boolean})],PacemBaseInputElement.prototype,"autoselect",void 0);class PacemOrdinalInputElement extends PacemBaseInputElement{convertValueAttributeToProperty(e){return parseFloat(e)}propertyChangedCallback(e,t,i,a){switch(super.propertyChangedCallback(e,t,i,a),e){case"min":case"max":case"step":null!=i?this.inputField.setAttribute(e,i):this.inputField.removeAttribute(e)}}}Je([t.Watch({converter:t.PropertyConverters.Number})],PacemOrdinalInputElement.prototype,"min",void 0),Je([t.Watch({converter:t.PropertyConverters.Number})],PacemOrdinalInputElement.prototype,"max",void 0),Je([t.Watch({converter:{convert:e=>{const t=parseFloat(e);return isNaN(t)?"any":t},convertBack:e=>e.toString()}})],PacemOrdinalInputElement.prototype,"step",void 0);class PacemTextualInputElement extends PacemBaseInputElement{convertValueAttributeToProperty(e){return e}propertyChangedCallback(e,t,i,a){switch(super.propertyChangedCallback(e,t,i,a),e){case"pattern":case"maxlength":case"minlength":null!=i?this.inputField.setAttribute(e,i):this.inputField.removeAttribute(e)}}getValue(e){return t.Utils.isNullOrEmpty(e)?null:e}getViewValue(e){return e}}Je([t.Watch({converter:t.PropertyConverters.String})],PacemTextualInputElement.prototype,"pattern",void 0),Je([t.Watch({converter:t.PropertyConverters.Number})],PacemTextualInputElement.prototype,"minlength",void 0),Je([t.Watch({converter:t.PropertyConverters.Number})],PacemTextualInputElement.prototype,"maxlength",void 0);var Ge=function(e,t,i,a){var s,r=arguments.length,n=r<3?t:null===a?a=Object.getOwnPropertyDescriptor(t,i):a;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(e,t,i,a);else for(var o=e.length-1;o>=0;o--)(s=e[o])&&(n=(r<3?s(n):r>3?s(t,i,n):s(t,i))||n);return r>3&&n&&Object.defineProperty(t,i,n),n};let Ke=class PacemCharsInputElement extends PacemBaseInputElement{constructor(){super(),this.charCount=6,this.inputTransform="none",this._itemCreateHandler=e=>{const{dom:t,index:i}=e.detail,a=t.find(e=>e instanceof HTMLInputElement);this.#b[i]=a,this.registerInputFields(a)},this.#b=[]}redactViewValue(e=this.value){this.viewValue=this.getViewValue(e)}getValue(e){const i=this.#b.reduce((e,i)=>e+(t.Utils.isNullOrEmpty(i.value)?" ":i.value),"");switch(this.inputTransform){case"lowercase":return i.toLowerCase();case"uppercase":return i.toUpperCase();default:return i}}getViewValue(t){const i=this.charCount;return"password"==this.inputTransform?e.Arrays.range(i).map(e=>"*").join(""):t}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)return void(this.autofocus&&e.select());super.focus()}propertyChangedCallback(e,t,i,a){if(super.propertyChangedCallback(e,t,i,a),!a)switch(e){case"charCount":this._databind(),this.redactViewValue();break;case"inputTransform":this.registerInputFields(),this.value=this.getValue(this.value)}}registerInputFields(e=this.inputFields){super.registerInputFields(e),t.Utils.isNull(e)||t.Utils.isArray(e)||(e=[e]);const i=this.#b;for(let a of e??[]){const e=i.indexOf(a);t.Utils.toggleClass(a,"last-char",e===this.charCount-1),t.Utils.toggleClass(a,"first-char",0===e),t.Utils.isNullOrEmpty(a.id)&&a.setAttribute("id","code_"+e+"_"+t.Utils.uniqueCode()),a.value=this.value?.charAt(e)||"","password"===this.inputTransform?a.setAttribute("type","password"):a.setAttribute("type","text")}}acceptValue(e){const t=this.#b;if("string"==typeof e){let i=0;const a=Math.min(e.length,t.length);for(let s=0;s<a;s++)t[s].value=e.charAt(s),i++;for(let e=i;e<t.length;e++)t[e].value=""}}onChange(e){return super.onChange(e).then(i=>{const a=this.#b,s=a.indexOf(e.target);if(s>=0&&s<a.length-1){const e=a[s];if(t.Utils.isNullOrEmpty(e.value?.trim()))e.value="";else{a[s+1].focus()}}return i})}viewActivatedCallback(){super.viewActivatedCallback(),t.Utils.isNull(this.autoselect)&&(this.autoselect=!0),this._chars.addEventListener(t.Components.RepeaterItemCreateEventName,this._itemCreateHandler,!1),this._databind()}disconnectedCallback(){const e=this._chars;t.Utils.isNull(e)||e.removeEventListener(t.Components.RepeaterItemCreateEventName,this._itemCreateHandler),super.disconnectedCallback()}_databind(){const t=this.charCount,i=this.#b;i.length>t&&super.unregisterInputFields(i.splice(t)),this._chars.datasource=e.Arrays.range(t)}#b;get inputFields(){return this.#b}};Ge([t.Watch({emit:!1,reflectBack:!0,converter:t.PropertyConverters.Number})],Ke.prototype,"charCount",void 0),Ge([t.Watch({emit:!1,reflectBack:!0,converter:t.PropertyConverters.String})],Ke.prototype,"inputTransform",void 0),Ge([t.ViewChild(t.P+"-repeater")],Ke.prototype,"_chars",void 0),Ge([t.ViewChild("span."+t.PCSS+"-readonly")],Ke.prototype,"_span",void 0),Ke=Ge([t.CustomElement({tagName:t.P+"-input-chars",template:`<${t.P}-repeater class="display-flex flex-nowrap">\n <template><input type="text" class="${t.PCSS}-input flex-auto" maxlength="1" /></template>\n </${t.P}-repeater><span class="${t.PCSS}-readonly"><${t.P}-text text="{{ :host.viewValue }}"></${t.P}-text></span>`,shadow:t.Defaults.USE_SHADOW_ROOT})],Ke);var Xe=function(e,t,i,a){var s,r=arguments.length,n=r<3?t:null===a?a=Object.getOwnPropertyDescriptor(t,i):a;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(e,t,i,a);else for(var o=e.length-1;o>=0;o--)(s=e[o])&&(n=(r<3?s(n):r>3?s(t,i,n):s(t,i))||n);return r>3&&n&&Object.defineProperty(t,i,n),n};let Ze=class PacemColorInputElement extends PacemBaseElement{acceptValue(e){const t=this._parseValue(e);null!=t&&(this._tint.value=t.tint,this._alpha.value=t.alpha.toString())}convertValueAttributeToProperty(e){return e}onChange(e){const i=this._alpha.valueAsNumber||parseInt(this._alpha.value),a=this._tint.value,s=this.value=this._getValue(a,i);return t.Utils.fromResult(s)}constructor(){super()}toggleReadonlyView(e){this._wrapper.hidden=e,this._span.hidden=!e}_getValue(t,i){if(isNaN(i)||100===i)return t;const a=e.Colors.parse(t);return a.a=.01*i,e.Colors.stringify(a)}_parseValue(i){const a=e.Colors.parse(i);return t.Utils.isNullOrEmpty(a)?null:{tint:e.Colors.stringify({r:a.r,g:a.g,b:a.b}),alpha:100*a.a}}getViewValue(e){return e}get inputFields(){return[this._tint,this._alpha].filter(e=>!t.Utils.isNull(e))}};Xe([t.ViewChild("input[type=color]")],Ze.prototype,"_tint",void 0),Xe([t.ViewChild("input[type=number]")],Ze.prototype,"_alpha",void 0),Xe([t.ViewChild(`.${t.PCSS}-viewfinder`)],Ze.prototype,"_wrapper",void 0),Xe([t.ViewChild(`.${t.PCSS}-readonly`)],Ze.prototype,"_span",void 0),Ze=Xe([t.CustomElement({tagName:t.P+"-input-color",template:`<div class="${t.PCSS}-viewfinder">\n<${t.P}-panel class="${t.PCSS}-input-color" css="{{ { 'background-color': :host.viewValue } }}"><input type="color" class="${t.PCSS}-input" /></${t.P}-panel>\n<input class="${t.PCSS}-input" type="number" min="0" max="100" step="1" value="100" />\n</div>\n<${t.P}-span class="${t.PCSS}-readonly" css="{{ { 'background-color': :host.viewValue } }}"></${t.P}-span>`,shadow:t.Defaults.USE_SHADOW_ROOT})],Ze);var Qe=function(e,t,i,a){var s,r=arguments.length,n=r<3?t:null===a?a=Object.getOwnPropertyDescriptor(t,i):a;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(e,t,i,a);else for(var o=e.length-1;o>=0;o--)(s=e[o])&&(n=(r<3?s(n):r>3?s(t,i,n):s(t,i))||n);return r>3&&n&&Object.defineProperty(t,i,n),n};let et=class PacemEmailInputElement extends PacemTextualInputElement{toggleReadonlyView(e){const i=this._input,a=this._anchor;t.Utils.isNull(i)||(i.hidden=e),t.Utils.isNull(a)||(a.hidden=!e)}get inputFields(){return t.Utils.isNull(this._input)?[]:[this._input]}};Qe([t.ViewChild("input[type=email]")],et.prototype,"_input",void 0),Qe([t.ViewChild(t.P+"-a")],et.prototype,"_anchor",void 0),et=Qe([t.CustomElement({tagName:t.P+"-input-email",template:`<input type="email" class="${t.PCSS}-input ${t.PCSS}-viewfinder" />${E}<${t.P}-a class="${t.PCSS}-readonly" disabled="{{ $pacem.isNullOrEmpty(:host.value) }}" href="{{ 'mailto:'+ :host.value }}"><${t.P}-text text="{{ :host.viewValue }}"></${t.P}-text></${t.P}-a>`,shadow:t.Defaults.USE_SHADOW_ROOT})],et);var tt=function(e,t,i,a){var s,r=arguments.length,n=r<3?t:null===a?a=Object.getOwnPropertyDescriptor(t,i):a;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(e,t,i,a);else for(var o=e.length-1;o>=0;o--)(s=e[o])&&(n=(r<3?s(n):r>3?s(t,i,n):s(t,i))||n);return r>3&&n&&Object.defineProperty(t,i,n),n};const it="fileupload",at="filechange";class StoragePickEvent extends t.CustomTypedEvent{constructor(e){super("pick",e)}}class FileUploadEvent extends t.CustomTypedEvent{constructor(e){super(it,e)}}class FileChangeEvent extends t.CustomTypedEvent{constructor(e){super(at,e)}}async function st(e,t={files:0,directories:0,size:0}){for await(let[i,a]of e.entries())if("file"===a.kind){t.files++;const e=await a.getFile();t.size+=e.size}else t.directories++,await st(a,t);return t}let rt=class PacemUploadElement extends PacemBaseElement{constructor(e=new t.Animations.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:131072,undone:!1}}convertValueAttributeToProperty(e){return e}acceptValue(e){this.percentage=0,this.uploading=!1,this._fileupload.value=""}_getMimeIcon(e=this.value,i=this.uploading,a=this.selectMode??"file"){if(i)return"sync";const s=!t.Utils.isNullOrEmpty(e);switch(a){case"directory":case"directory-picker":return s?"folder":"drive_folder_upload";case"multiple":case"multiple-picker":return s?"files":"upload_file"}if(t.Utils.isNullOrEmpty(e))return"upload_file";var r=e;"object"==typeof e&&(r=e.name);const n=/\.([\w]+)(\s|$)/.exec(r);if(n&&n.length)switch(n[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 t.Utils.isNull(this._fileupload)?[]:[this._fileupload]}getViewValue(e){const i=this._localValue||e;if(t.Utils.isNullOrEmpty(i))return"";if("string"==typeof i)return i;let a="name"in i?i.name:"";t.Utils.isArray(i)&&(a=i.map(e=>e.name).join(", "));const s=this._stats;if(t.Utils.isNullOrEmpty(s))return a;const{size:r,files:n}=s;return`${a}\n(${n} file${1===n?"":"s"}, ${t.Utils.core.size(r)})`}toggleReadonlyView(e){this._setupInputElement(e)}viewActivatedCallback(){super.viewActivatedCallback(),this._setupInputElement(),this._fileupload.addEventListener("click",t.stopPropagationHandler,!1)}propertyChangedCallback(e,t,i,a){if(super.propertyChangedCallback(e,t,i,a),!a&&"selectMode"===e)this._setupInputElement()}disconnectedCallback(){this._fileupload&&this._fileupload.removeEventListener("click",t.stopPropagationHandler,!1),super.disconnectedCallback()}_setupInputElement(e=this.readonly,t=this.selectMode??"file"){const i=this._fileupload;switch(i.removeAttribute("webkitdirectory"),i.removeAttribute("multiple"),i.hidden=e,t){case"directory":i.setAttribute("webkitdirectory","true");break;case"multiple":i.setAttribute("multiple","true");break;case"directory-picker":case"file-picker":case"multiple-picker":i.hidden=!0}}_dispatchDownload(e){t.avoidHandler(e);const i=this._localValue||this.value,a=e=>{this.dispatchEvent(new CustomEvent("download",{detail:e,bubbles:!0,cancelable:!1}))};t.Utils.isNullOrEmpty(i)||("string"==typeof i?a(i):"content"in i&&!t.Utils.isNullOrEmpty(i.content)?t.Utils.download(t.Utils.dataURLToBlob("data:application/download;base64,"+i.content),i.name,i.type):"name"in i&&("kind"in i&&"file"===i.kind?i.getFile().then(e=>{t.Utils.download(e,e.name,e.type)}):a(i.name)))}reset(){super.reset(),this._localValue=null,this.invalidFile=!1}_validateAll(){const 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);const i=this.maxSize;if(i>0&&i<e.size)return this.invalidFile=!0,!1;const a=this.pattern;return a&&!new RegExp(a,"i").test(t)?(this.invalidFile=!0,!1):(this.invalidFile=!1,!0)}upload(e,t,i){if(this._validateSingleFile(e,t))return this._upload(e,t,i)}async _upload(e,t,i){var a=this,s=a._fields;if(!e)return;!t&&e instanceof File&&(t=e.name),a.failed=!1,s.undone=!1,s.ongoing=0;const r=e,n=a.size=r.size;t=t.substring(t.lastIndexOf("\\")+1),a.percentage=0,a.complete=!1;var o={filename:t,length:n,action:"start",state:i,type:e.type};a.uploading=!0;try{var l=await a._fetch(o);if(l.ok){var c=await l.json();s.retryFrom=0,s.blob=r,s.uid=c.uid,a._manage()}else a.uploading=!1;return l}catch(e){a.uploading=!1}}async _blobToBase64(e){const i=await t.Utils.blobToDataURL(e);return i.substring(i.indexOf("base64,")+7)}async _doUpload(e,t){var i=this,a=i._fields;a.ongoing++;var s={chunk:await this._blobToBase64(e),uid:a.uid,position:t,action:"do"};try{const e=await i._fetch(s);if(e.ok){if(a.ongoing--,a.undone)return;const t=await e.json();t.percentage>this.percentage&&await i._tweenPercentage(Math.round(Math.max(1,t.percentage)),200),i.complete!=t.complete&&(i.complete=t.complete,!0===i.complete&&(i.uploading=!1,i.changeHandler(new FileUploadEvent(t))))}else a.retryFrom=t,i.failed=!0,i.uploading=!1}catch(e){a.retryFrom=t,i.failed=!0,i.uploading=!1}}_manage(){const e=this._fields,t=this.size,i=e.blob,a=this.chunkSize||e.chunkSize;var s=e.retryFrom,r=s+a;e.enqueuer=setInterval(()=>{if(s<t&&!this.failed){const t=this.parallelism||e.parallelism;if(e.ongoing>=t)return;this._doUpload(i.slice(s,r),s),r=(s=r)+a}else{this._fileupload.value="",window.clearInterval(e.enqueuer)}},100)}async _buildLocalValue(e,i=e.name,a=e){return this._localValue={name:i,size:a.size,type:e.type,lastModified:t.Utils.parseDate(e.lastModified).toISOString(),content:await this._blobToBase64(a)}}_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 StoragePickEvent(e))})}_tryPickFiles(e="multiple-picker"===this.selectMode,t=this.pattern){this._canPick(window)&&window.showOpenFilePicker({multiple:e}).then(e=>{this.changeHandler(new StoragePickEvent(e))})}_clickHandler(e){if(t.avoidHandler(e),!this.readonly)switch(this.selectMode){case"directory-picker":this._tryPickDirectory();break;case"file-picker":case"multiple-picker":this._tryPickFiles()}}async _mimicCompute(){this.uploading=!0,t.Utils.isNullOrEmpty(this.value)?await t.Utils.idle(250):(this.percentage=0,await t.Utils.waitForAnimationEnd(this._tuner)),await this._tweener.run(0,100,500,0,t.Animations.Easings.sineInOut,(e,t)=>{this.percentage=t}),this.percentage=0,this.uploading=!1}onChange(e){return new Promise(async(i,a)=>{if(t.CustomEventUtils.isInstanceOf(e,FileUploadEvent)){const t=this.value=e.detail.filename;this.dispatchEvent(e),i(t)}else if(t.CustomEventUtils.isInstanceOf(e,StoragePickEvent)){let t,a,s,r=e.detail;switch(this.selectMode){case"directory-picker":t=r,this._stats=await st(t);break;case"multiple-picker":case"file-picker":s=r,1===s.length&&(r=s[0]),this._stats=await async function(e){const t={files:0,directories:0,size:0};for(let i of e){const e=await i.getFile();t.files++,t.size+=e.size}return t}(s);break;default:this._stats={directories:0,files:0,size:0}}i(this.value=this._localValue=r);const n=this._validateAll();this.dispatchEvent(new FileChangeEvent({directory:t,file:a,files:s,valid:n}))}else{let e=this._fileupload;if(0===e.files.length)this._stats={directories:0,files:0,size:0},i(this.value=null);else{const a=e.files.length;if(this._stats={directories:0,files:a,size:Array.from(e.files).reduce((e,t,i)=>e+t.size,0)},a>1){const t=Array.from(e.files);i(this.value=this._localValue=t);const a=this._validateAll();this.dispatchEvent(new FileChangeEvent({files:t,valid:a}))}else{const a=e.files[0],s=a.name;let r=a;this._validateSingleFile(a)||t.Utils.isNullOrEmpty(this.url)?(/\.(jpe?g|png)$/i.test(s)&&this.maxImageWidth>0&&this.maxImageHeight>0&&(r=await t.Utils.Images.resize(r,this.maxImageWidth,this.maxImageHeight,{quality:.8})),await this._buildLocalValue(a,s,r),t.Utils.isNullOrEmpty(this.url)?(await this._mimicCompute(),i(this.value=this._localValue)):(this._upload(r,e.value),i(this.value))):i(this.value=await this._buildLocalValue(a)),this.dispatchEvent(new FileChangeEvent({valid:!this.invalidFile,file:a}))}}}})}_fetch(e){return fetch(this.url,{method:"POST",credentials:this.fetchCredentials,headers:t.Utils.extend({Accept:"application/json","Content-Type":"application/json"},this.fetchHeaders||{}),body:JSON.stringify(e)})}async _undo(e){e.preventDefault(),e.stopPropagation();var t=this,i=t._fields,a=t._fileupload;clearInterval(i.enqueuer);var s={action:"undo",uid:i.uid};try{var r=await t._fetch(s);return r.ok&&(i.undone=!0,t.size=0,t._tweenPercentage(0,300)),r}catch(e){}finally{return a.value="",t.uploading=!1,r}}_tweenPercentage(e,i=500){const a=this.percentage;return this._tweener.run(a,e,i,0,t.Animations.Easings.sineInOut,(e,t)=>{this.percentage=t})}_retry(e){e.preventDefault(),e.stopPropagation(),this.failed=!1,this._manage()}_clear(e){e.preventDefault(),e.stopPropagation(),this.invalidFile=!1;const t=this.inputFields[0];t.value="",/safari/i.test(navigator.userAgent)||(t.type="",t.type="file"),this.changeHandler(null)}};tt([t.Watch({emit:!1,converter:t.PropertyConverters.Json})],rt.prototype,"fetchCredentials",void 0),tt([t.Watch({emit:!1,converter:t.PropertyConverters.String})],rt.prototype,"fetchHeaders",void 0),tt([t.ViewChild("input[type=file]")],rt.prototype,"_fileupload",void 0),tt([t.ViewChild(`${t.P}-tuner`)],rt.prototype,"_tuner",void 0),tt([t.Watch({converter:t.PropertyConverters.String})],rt.prototype,"undoCaption",void 0),tt([t.Watch({converter:t.PropertyConverters.String})],rt.prototype,"retryCaption",void 0),tt([t.Watch({converter:t.PropertyConverters.String})],rt.prototype,"clearCaption",void 0),tt([t.Watch({emit:!1,reflectBack:!0,converter:t.PropertyConverters.String})],rt.prototype,"pattern",void 0),tt([t.Watch({emit:!1,reflectBack:!0,converter:t.PropertyConverters.String})],rt.prototype,"url",void 0),tt([t.Watch({emit:!1,reflectBack:!0,converter:t.PropertyConverters.Number})],rt.prototype,"maxImageWidth",void 0),tt([t.Watch({emit:!1,reflectBack:!0,converter:t.PropertyConverters.Number})],rt.prototype,"parallelism",void 0),tt([t.Watch({emit:!1,reflectBack:!0,converter:t.PropertyConverters.Number})],rt.prototype,"chunkSize",void 0),tt([t.Watch({emit:!1,reflectBack:!0,converter:t.PropertyConverters.Number})],rt.prototype,"maxImageHeight",void 0),tt([t.Watch({emit:!1,reflectBack:!0,converter:t.PropertyConverters.Number})],rt.prototype,"maxSize",void 0),tt([t.Watch({reflectBack:!0,converter:t.PropertyConverters.String})],rt.prototype,"selectMode",void 0),tt([t.Watch({converter:t.PropertyConverters.Boolean})],rt.prototype,"uploading",void 0),tt([t.Watch({converter:t.PropertyConverters.Number})],rt.prototype,"size",void 0),tt([t.Watch({converter:t.PropertyConverters.Number})],rt.prototype,"percentage",void 0),tt([t.Watch({converter:t.PropertyConverters.Boolean})],rt.prototype,"complete",void 0),tt([t.Watch({converter:t.PropertyConverters.Boolean})],rt.prototype,"failed",void 0),tt([t.Watch({converter:t.PropertyConverters.Boolean})],rt.prototype,"invalidFile",void 0),rt=tt([t.CustomElement({tagName:t.P+"-upload",shadow:t.Defaults.USE_SHADOW_ROOT,template:`<${t.P}-button on-click=":host._dispatchDownload($event)" class="${t.PCSS}-upload ${t.PCSS}-viewfinder flat" css-class="{{ {'upload-chosen': !$pacem.isNullOrEmpty(:host.value) && !:host.uploading, 'upload-error': !$pacem.isNullOrEmpty(:host.value) && :host.invalidFile && $pacem.isNullOrEmpty(:host.url), 'upload-readonly': :host.readonly } }}">\n\n <${t.P}-panel class="upload-button" hide="{{ (:host.uploading || :host.failed) && !$pacem.isNullOrEmpty(:host.url) }}">\n <${t.P}-button tooltip="{{ :host.readonly ? :host.viewValue : 'upload' }}" class="button-circle pos-relative overflow-hidden"\n icon-glyph="{{ :host._getMimeIcon(:host.value, :host.uploading, :host.selectMode) }}"\n on-click=":host._clickHandler($event)"\n on-mouseover="$this.iconGlyph = :host._getMimeIcon(:host.readonly ? :host.value : '', :host.uploading, :host.selectMode)"\n on-mouseout="$this.iconGlyph = :host._getMimeIcon(:host.value, :host.uploading, :host.selectMode)"\n css-class="{{ {'${t.PCSS}-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 } }}">\n <input type="file" class="${t.PCSS}-transparent ${t.PCSS}-clickable pos-absolute absolute-left absolute-right absolute-top absolute-bottom" />\n </${t.P}-button>\n </${t.P}-panel>\n <${t.P}-panel class="upload-button" hide="{{ !:host.failed }}">\n <${t.P}-button class="button-circle button-flat" icon-glyph="refresh"\n tooltip="{{ :host.retryCaption }}" on-click=":host._retry($event)"><${t.P}-text text="{{ :host.retryCaption }}"></${t.P}-text></${t.P}-button>\n </${t.P}-panel>\n <${t.P}-panel class="upload-button" hide="{{ !:host.uploading || $pacem.isNullOrEmpty(:host.url) }}">\n <${t.P}-button class="button-circle button-flat" icon-glyph="clear" tooltip="{{ :host.undoCaption }}" \n on-click=":host._undo($event)"><${t.P}-text text="{{ :host.undoCaption }}"></${t.P}-text></${t.P}-button>\n </${t.P}-panel>\n\n <${t.P}-span tooltip="{{ :host.viewValue }}"\n hide="{{ $pacem.isNullOrEmpty(:host.value) || :host.uploading }}" class="upload-data readonly text-reset display-block ${t.PCSS}-anim text-truncate text-left ${t.PCSS}-pad pad-right-3" text="{{ :host.viewValue }}"></${t.P}-span>\n\n <${t.P}-panel class="upload-progress hit-none" hide="{{ :host.readonly || (!$pacem.isNullOrEmpty(:host.value) && !:host.uploading) }}">\n <${t.P}-tuner value="{{ :host.percentage }}" css-class="{{ {'tuner-success': !:host.invalidFile, 'tuner-error': :host.invalidFile} }}" interactive="false"></${t.P}-tuner>\n </${t.P}-panel>\n\n <${t.P}-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)"></${t.P}-button>\n \n</${t.P}-button>`})],rt);var nt=function(e,t,i,a){var s,r=arguments.length,n=r<3?t:null===a?a=Object.getOwnPropertyDescriptor(t,i):a;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(e,t,i,a);else for(var o=e.length-1;o>=0;o--)(s=e[o])&&(n=(r<3?s(n):r>3?s(t,i,n):s(t,i))||n);return r>3&&n&&Object.defineProperty(t,i,n),n};let ot=class PacemHiddenInputElement extends PacemTextualInputElement{constructor(){super()}toggleReadonlyView(e){}get inputFields(){return t.Utils.isNull(this._input)?[]:[this._input]}};nt([t.ViewChild("input[type=hidden]")],ot.prototype,"_input",void 0),ot=nt([t.CustomElement({tagName:t.P+"-input-hidden",template:'<input type="hidden" />',shadow:t.Defaults.USE_SHADOW_ROOT})],ot);var lt=function(e,t,i,a){var s,r=arguments.length,n=r<3?t:null===a?a=Object.getOwnPropertyDescriptor(t,i):a;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(e,t,i,a);else for(var o=e.length-1;o>=0;o--)(s=e[o])&&(n=(r<3?s(n):r>3?s(t,i,n):s(t,i))||n);return r>3&&n&&Object.defineProperty(t,i,n),n};const ct=t.Utils.getUserMediaFunctions();var dt;!function(e){e.Start="start",e.Taking="taking",e.Confirm="confirm"}(dt||(dt={}));class ConfirmSnapshotEvent extends t.CustomUIEvent{constructor(e){super("confirmsnapshot",{buffer:e})}}let ht=class PacemSnapshotElement extends PacemBaseElement{constructor(){super(...arguments),this._resizeHandler=e=>{this._renderValue()},this.step=dt.Start,this._canUseWebcam=ct.length>0,this._countdown=0,this._webcamInitialized=!1,this._grabberChangeHandler=e=>{const i=this._grabber;i.files.length>0&&t.Utils.blobToDataURL(i.files[0]).then(e=>{t.Utils.loadImage(e).then(e=>{this._shutter(e)})})},this._snapshooterClickHandler=e=>{t.avoidHandler(e),this.step=dt.Taking},this._pickerClickHandler=e=>{t.avoidHandler(e),this._grabber.click()},this._takerClickHandler=e=>{t.avoidHandler(e),this._countdown=0,this._shutter()},this._timerClickHandler=e=>{t.avoidHandler(e),this._countdown=3,this._shutter()},this._confirmerClickHandler=e=>{t.avoidHandler(e),this.changeHandler(new ConfirmSnapshotEvent(this._buffer))}}get inputFields(){return[]}toggleReadonlyView(e){}onChange(e){return new Promise((i,a)=>{t.CustomEventUtils.isInstanceOf(e,ConfirmSnapshotEvent)?(i(this.value=e.detail.buffer),this.step=dt.Start):i(this.value)})}acceptValue(e){this._renderValue(e)}getViewValue(e){return e}convertValueAttributeToProperty(e){return t.PropertyConverters.String.convert(e,this)}get _getUserMedia(){return this._canUseWebcam&&ct[0]}propertyChangedCallback(e,t,i,a){switch(super.propertyChangedCallback(e,t,i,a),e){case"step":switch(i){case dt.Start:this._buffer=null;const e=this._grabber;e.value="",/safari/i.test(navigator.userAgent)||(e.type="",e.type="file");break;case dt.Taking:this._ensureWebcamRunning()}break;case"_buffer":this._renderValue(i||this.value);break;case"width":case"height":this._syncSize()}}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(){const e=this._stage,i=this._player;t.Utils.isNull(e)||t.Utils.isNull(i)||(e.style.width=i.style.width=this.width&&this.width+"px"||"",e.style.height=i.style.height=this.height&&this.height+"px"||"",this._renderValue(this._buffer||this.value))}_shutter(e){const i=this,a=this._player,s=this._stage;var r,n;if(i._confirmer.disabled=!0,t.Utils.isNull(e)&&(e=i._player),e instanceof HTMLVideoElement?(r=e.videoWidth,n=e.videoHeight):(r=e.naturalWidth,n=e.naturalHeight),i._countdown<=0){var o=document.createElement("canvas");o.width=this.width||s.clientWidth,o.height=this.height||s.clientHeight;var l=o.getContext("2d");t.Utils.cropImageOntoCanvas(e,l,r,n);let c=i._root;c.insertBefore(o,a),o.className="snapshot-brightout",setTimeout(function(){c.removeChild(o)},1e3),i._refreshBuffer(o.toDataURL()).then(e=>{i._setToBeConfirmed(e),i._confirmer.disabled=!1})}else setTimeout(()=>{i._countdown--,this._shutter()},1e3)}_renderValue(e=this.value){let i=this._stage;if(!t.Utils.isNull(i)){i.width=i.clientWidth,i.height=i.clientHeight;let a=i.getContext("2d");t.Utils.isNullOrEmpty(e)?a.clearRect(0,0,i.width,i.height):t.Utils.loadImage(e).then(e=>{t.Utils.cropImageOntoCanvas(e,a,e.width,e.height)})}}_setToBeConfirmed(e){this.step=dt.Confirm,this._buffer=e}_refreshBuffer(e){var i=this._stage;let a;return i.width=i.clientWidth,i.height=i.clientHeight,this.quality>0&&(a=Math.min(1,Math.max(0,this.quality))),t.Utils.cropImage(e,i.width,i.height,a)}_ensureWebcamRunning(){if(this._canUseWebcam&&!this._webcamInitialized){var e=this;e._webcamInitialized=!0,e._getUserMedia.apply(navigator,[{video:!0},function(t){e._player.srcObject=t},function(i){e.log(t.Logging.LogLevel.Error,(i||i.message).toString())}])}}};lt([t.ViewChild("."+t.PCSS+"-snapshot")],ht.prototype,"_root",void 0),lt([t.ViewChild("canvas")],ht.prototype,"_stage",void 0),lt([t.ViewChild("input[type=file]")],ht.prototype,"_grabber",void 0),lt([t.ViewChild("video")],ht.prototype,"_player",void 0),lt([t.ViewChild(t.P+"-button.button.snapshot-upload")],ht.prototype,"_picker",void 0),lt([t.ViewChild(t.P+"-button.button.snapshot-camera")],ht.prototype,"_snapshooter",void 0),lt([t.ViewChild(t.P+"-button.button.snapshot-take")],ht.prototype,"_taker",void 0),lt([t.ViewChild(t.P+"-button.button.snapshot-timer3s")],ht.prototype,"_timer",void 0),lt([t.ViewChild(t.P+"-button.button.snapshot-confirm")],ht.prototype,"_confirmer",void 0),lt([t.Watch({converter:t.PropertyConverters.String})],ht.prototype,"step",void 0),lt([t.Watch({emit:!1,converter:t.PropertyConverters.Number})],ht.prototype,"width",void 0),lt([t.Watch({emit:!1,converter:t.PropertyConverters.Number})],ht.prototype,"height",void 0),lt([t.Watch({emit:!1,converter:t.PropertyConverters.Number})],ht.prototype,"quality",void 0),lt([t.Watch()],ht.prototype,"_countdown",void 0),lt([t.Watch({emit:!1})],ht.prototype,"_buffer",void 0),ht=lt([t.CustomElement({tagName:t.P+"-snapshot",shadow:t.Defaults.USE_SHADOW_ROOT,template:`<${t.P}-panel class="${t.PCSS}-snapshot" \ncss-class="{{ { \n'snapshot-start': :host.step === '${dt.Start}',\n'snapshot-taking': :host.step === '${dt.Taking}', \n'snapshot-confirm': :host.step === '${dt.Confirm}' } }}">\n\n <${t.P}-resize target="{{ ::_stage }}" on-resize=":host._resizeHandler($event)"></${t.P}-resize>\n\n <canvas class="${t.PCSS}-viewfinder"></canvas>\n\n <video autoplay="autoplay"></video>\n\n <input type="file" accept="image/*" />\n\n <div class="${t.PCSS}-buttonset snapshot-step step-start">\n <div class="buttonset-center">\n <${t.P}-button class="button snapshot-upload" icon-glyph="upload"></${t.P}-button>\n <${t.P}-button class="button snapshot-camera" icon-glyph="photo_camera"></${t.P}-button> \n </div>\n </div>\n\n <div class="${t.PCSS}-buttonset snapshot-step step-taking">\n <div class="buttonset-center">\n <${t.P}-button class="button snapshot-undo" icon-glyph="undo" on-click=":host.step = '${dt.Start}'"></${t.P}-button>\n <${t.P}-button class="button snapshot-take" icon-glyph="camera"></${t.P}-button>\n <${t.P}-button class="button snapshot-timer3s" icon-glyph="timer_3"></${t.P}-button>\n </div>\n </div>\n\n <div class="${t.PCSS}-buttonset snapshot-step step-confirm">\n <div class="buttonset-center">\n <${t.P}-button class="button snapshot-undo" icon-glyph="undo" on-click=":host.step = '${dt.Start}'"></${t.P}-button>\n <${t.P}-button class="button snapshot-confirm" icon-glyph="done"></${t.P}-button>\n </div>\n </div>\n\n <${t.P}-span class="snapshot-countdown" text="{{ :host._countdown }}" hide="{{ :host.step !== '${dt.Taking}' || !(:host._countdown > 0) }}"></${t.P}-span>\n <${t.P}-span hide="{{ :host._canUseWebcam }}"><${t.P}-content></${t.P}-content></${t.P}-span>\n\n</${t.P}-panel>`})],ht);var pt=function(e,t,i,a){var s,r=arguments.length,n=r<3?t:null===a?a=Object.getOwnPropertyDescriptor(t,i):a;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(e,t,i,a);else for(var o=e.length-1;o>=0;o--)(s=e[o])&&(n=(r<3?s(n):r>3?s(t,i,n):s(t,i))||n);return r>3&&n&&Object.defineProperty(t,i,n),n};const ut="imagefetchrequest";class ImageFetchRequestEvent extends t.CustomTypedEvent{constructor(e){super(ut,e,{bubbles:!0})}}let mt=class PacemEditImageElement extends t.Components.PacemElement{constructor(){super(...arguments),this._index=0,this.hint=""}_uploaderPropertyChangedCallback(e){const t=e.detail.currentValue;switch(e.detail.propertyName){case"percentage":this._progressbar.percentage=100*t;break;case"uploading":t&&this._done(!0)}}_thumbnailUploaderPropertyChangedCallback(e){const t=e.detail.currentValue;switch(e.detail.propertyName){case"percentage":this._progressbar.percentage=100*t;break;case"uploading":this._done(t)}}_uploaderFileUploadCallback(e){const i=this._uploader,a=this._thumbUploader,s=a.maxImageWidth,r=a.maxImageHeight;if(s>0&&r>0){var n=i.blob;const o=e.detail.uid;t.Utils.resizeImage(n,s,r).then(e=>{e==n?this._done(!1):a.upload(e,"thumbnail.jpg",o)})}else this._done(!1)}_done(e){e||this._imagefetch(0),this._repeater.hidden=e,this._progressbar.hidden=!e}_snapshotPropertyChangedCallback(e){if("value"===e.detail.propertyName){const i=t.Utils.dataURLToBlob(e.detail.currentValue);this._uploader.upload(i,"snapshot.jpg")}}reset(){this._snapshot.step=dt.Start}propertyChangedCallback(e,i,a,s){switch(super.propertyChangedCallback(e,i,a,s),e){case"imageSet":let e=a||{skip:0,set:[]};t.Utils.isNullOrEmpty(this._images)||0===e.skip?this._images=e.set:t.Utils.isNull(this._images)||Array.prototype.splice.apply(this._images,[e.skip,this._images.length-e.skip].concat(e.set)),this._fetching=!1;break;case"hint":s||this._imagefetch(0)}}_imagefetchSuddenly(e){this._fetching=!0,this._imagefetch(e)}_imagefetch(e){e>=0||(e=this._images&&this._images.length||0),this.dispatchEvent(new ImageFetchRequestEvent({hint:this.hint,skip:e,take:18}))}};pt([t.Watch({converter:t.PropertyConverters.String})],mt.prototype,"uploadUrl",void 0),pt([t.Watch({converter:t.PropertyConverters.String})],mt.prototype,"hint",void 0),pt([t.Watch()],mt.prototype,"imageSet",void 0),pt([t.Watch({converter:t.PropertyConverters.String})],mt.prototype,"value",void 0),pt([t.Watch({converter:t.PropertyConverters.Number})],mt.prototype,"maxWidth",void 0),pt([t.Watch({converter:t.PropertyConverters.Number})],mt.prototype,"maxHeight",void 0),pt([t.Watch({converter:t.PropertyConverters.Number})],mt.prototype,"maxThumbnailWidth",void 0),pt([t.Watch({converter:t.PropertyConverters.Number})],mt.prototype,"maxThumbnailHeight",void 0),pt([t.Watch({converter:t.PropertyConverters.Boolean})],mt.prototype,"allowSnapshot",void 0),pt([t.Watch()],mt.prototype,"_fetching",void 0),pt([t.Watch()],mt.prototype,"_images",void 0),pt([t.ViewChild(t.P+"-repeater")],mt.prototype,"_repeater",void 0),pt([t.ViewChild(t.P+"-upload[main]")],mt.prototype,"_uploader",void 0),pt([t.ViewChild(t.P+"-upload[thumb]")],mt.prototype,"_thumbUploader",void 0),pt([t.ViewChild(t.P+"-snapshot")],mt.prototype,"_snapshot",void 0),pt([t.ViewChild(t.P+"-progressbar")],mt.prototype,"_progressbar",void 0),pt([t.Debounce(500)],mt.prototype,"_imagefetch",null),mt=pt([t.CustomElement({tagName:t.P+"-edit-image",shadow:t.Defaults.USE_SHADOW_ROOT,template:`<${t.P}-panel class="${t.PCSS}-edit-image"\n css-class="{{ {'${t.PCSS}-snapshot': ::_snapshot.step != '${dt.Start}', '${t.PCSS}-uploading': ::_uploader.uploading, '${t.PCSS}-upload-enabled': !Pacem.Utils.isNullOrEmpty(:host.uploadUrl), '${t.PCSS}-snapshot-enabled': !Pacem.Utils.isNullOrEmpty(:host.uploadUrl) && :host.allowSnapshot} }}">\n <div>\n <${t.P}-input-search value="{{ :host.hint, twoway }}"></${t.P}-input-search>\n <${t.P}-upload main pattern=".+.(jpe?g|png|svg|ico)$" url="{{ :host.uploadUrl }}"\n max-image-width="{{ :host.maxWidth }}" max-image-height="{{ :host.maxHeight }}"\n on-${it}=":host._uploaderFileUploadCallback($event)"\n on-${t.PropertyChangeEventName}=":host._uploaderPropertyChangedCallback($event)" hide="{{ Pacem.Utils.isNullOrEmpty(:host.uploadUrl) || ::_thumbUploader.uploading }}"></${t.P}-upload>\n <${t.P}-upload thumb pattern=".+.(jpe?g|png|svg|ico)$" url="{{ :host.uploadUrl }}" hide="{{ !::_thumbUploader.uploading }}"\n max-image-width="{{ :host.maxThumbnailWidth }}" max-image-height="{{ :host.maxThumbnailHeight }}"\n on-${t.PropertyChangeEventName}=":host._thumbnailUploaderPropertyChangedCallback($event)"></${t.P}-upload>\n <${t.P}-button class="${t.PCSS}-snapshot" on-click="Pacem.avoidHandler($event); ::_snapshot.step = '${dt.Taking}'" hide="{{ Pacem.Utils.isNullOrEmpty(:host.uploadUrl) || !:host.allowSnapshot }}"></${t.P}-button>\n <${t.P}-infinite-scroller container="{{ ::_repeater }}" on-fetchmore=":host._imagefetchSuddenly()" disabled="{{ :host._fetching || :host.disabled || :host._images.length >= :host.imageSet.total }}"></${t.P}-infinite-scroller>\n <${t.P}-repeater datasource="{{ :host._images }}">\n <template>\n <${t.P}-img css-class="{{ {'${t.PCSS}-selected': ^item.src === :host.value } }}" on-click=":host.value = ^item.src" src="{{ ^item.thumb }}" adapt="contain"></${t.P}-img>\n </template>\n </${t.P}-repeater>\n <${t.P}-progressbar class="progressbar-smaller progressbar-accent" caption="{{ ::_thumbUploader.uploading ? 'thumbnail...' : 'uploading...' }}"></${t.P}-progressbar>\n </div>\n <div>\n <${t.P}-snapshot hide="{{ !:host.allowSnapshot }}" on-${t.PropertyChangeEventName}=":host._snapshotPropertyChangedCallback($event)"></${t.P}-snapshot>\n </div>\n </${t.P}-panel>`})],mt);let vt=class PacemImageInputElement extends PacemBaseElement{constructor(){super(...arguments),this._broadcastFetchRequestEventName=e=>{this.dispatchEvent(new ImageFetchRequestEvent(e.detail))},this._innerValueChangedHandler=e=>{"value"!==e.detail.propertyName||t.Utils.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 a=this.value;return t.CustomEventUtils.isInstanceOf(e,i.Components.UI.DialogResultEvent)&&e.detail.button===i.Components.UI.DialogButton.Ok?a=this.value=e.detail.state:e.target===this._input?a=this.value=this._input.value:e.target===this._clearBtn&&(a=this.value=void 0),t.Utils.fromResult(a)}toggleReadonlyView(e){this._input.hidden=this._editBtn.hide=this._clearBtn.hide=e}_addDialog(){var e=document.createElement(t.P+"-dialog");return e.buttons=i.Components.UI.DialogButtons.OkCancel,e.addEventListener(i.Components.UI.DialogResultEventName,this.changeHandler,!1),e.appendChild(this._addEditImage()),document.body.appendChild(e),this._dialog=e}_removeDialog(){this._removeEditImage(),t.Utils.isNull(this._dialog)||(this._dialog.removeEventListener(i.Components.UI.DialogResultEventName,this.changeHandler,!1),this._dialog.remove())}_addEditImage(){var e=document.createElement(t.P+"-edit-image");return e.disabled=!0,e.addEventListener(t.PropertyChangeEventName,this._innerValueChangedHandler,!1),e.addEventListener(ut,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(){t.Utils.isNull(this._editImage)||(this._editImage.removeEventListener(t.PropertyChangeEventName,this._innerValueChangedHandler,!1),this._editImage.removeEventListener(ut,this._broadcastFetchRequestEventName,!1))}connectedCallback(){super.connectedCallback(),this._addDialog()}disconnectedCallback(){this._removeDialog(),super.disconnectedCallback()}propertyChangedCallback(e,i,a,s){switch(super.propertyChangedCallback(e,i,a,s),e){case"uploadUrl":t.Utils.isNull(this._editImage)||(this._editImage.uploadUrl=a);break;case"allowSnapshot":t.Utils.isNull(this._editImage)||(this._editImage.allowSnapshot=a);break;case"imageSet":t.Utils.isNull(this._editImage)||(this._editImage.imageSet=a);break;case"maxThumbnailHeight":t.Utils.isNull(this._editImage)||(this._editImage.maxThumbnailHeight=a);break;case"maxThumbnailWidth":t.Utils.isNull(this._editImage)||(this._editImage.maxThumbnailWidth=a);break;case"maxHeight":t.Utils.isNull(this._editImage)||(this._editImage.maxHeight=a);break;case"maxWidth":t.Utils.isNull(this._editImage)||(this._editImage.maxWidth=a)}}acceptValue(e){t.Utils.isNull(this._editImage)||(this._editImage.value=e)}_update(e){this._image.src=e}_retrieve(){return this.value}_edit(e){t.avoidHandler(e);var a=this._editImage,s=this.value;a.disabled=!1,a.reset(),a.value=s,this._dialog.open(s).then(e=>{switch(e.button){case i.Components.UI.DialogButton.Cancel:this._update(this.value);break;case i.Components.UI.DialogButton.Ok:this._update(e.state)}this._editImage.disabled=!0})}};pt([t.ViewChild(t.P+"-img")],vt.prototype,"_image",void 0),pt([t.ViewChild(t.P+"-button."+t.PCSS+"-edit")],vt.prototype,"_editBtn",void 0),pt([t.ViewChild(t.P+"-button."+t.PCSS+"-clear")],vt.prototype,"_clearBtn",void 0),pt([t.ViewChild(t.P+"-input-url")],vt.prototype,"_input",void 0),pt([t.Watch({emit:!1,converter:t.PropertyConverters.String})],vt.prototype,"uploadUrl",void 0),pt([t.Watch({emit:!1,converter:t.PropertyConverters.Json})],vt.prototype,"imageSet",void 0),pt([t.Watch({emit:!1,converter:t.PropertyConverters.Number})],vt.prototype,"maxWidth",void 0),pt([t.Watch({emit:!1,converter:t.PropertyConverters.Number})],vt.prototype,"maxHeight",void 0),pt([t.Watch({emit:!1,converter:t.PropertyConverters.Number})],vt.prototype,"maxThumbnailWidth",void 0),pt([t.Watch({emit:!1,converter:t.PropertyConverters.Number})],vt.prototype,"maxThumbnailHeight",void 0),pt([t.Watch({emit:!1,converter:t.PropertyConverters.Boolean})],vt.prototype,"allowSnapshot",void 0),vt=pt([t.CustomElement({tagName:t.P+"-input-image",shadow:t.Defaults.USE_SHADOW_ROOT,template:`<div class="${t.PCSS}-input-image"><${t.P}-img src="{{ :host.value }}" adapt="contain"></${t.P}-img><div class="${t.PCSS}-input-image-dashboard">\n <${t.P}-button on-click=":host._edit($event)" hide="{{ :host.disabled }}" class="${t.PCSS}-edit">Edit</${t.P}-button>\n <${t.P}-button on-click=":host._clear($event)" hide="{{ :host.disabled }}" class="${t.PCSS}-clear">Clear</${t.P}-button>\n</div><${t.P}-input-url placeholder="{{ :host.placeholder }}" on-change=":host.changeHandler($event)" value="{{ :host.value }}"></${t.P}-input-url>\n\n <${t.P}-panel hide="{{ Pacem.Utils.isNullOrEmpty(:host.value) }}">\n <dl class="${t.PCSS}-input-image-preview">\n <dt>dimensions:</dt><dd><${t.P}-text text="{{ ::_image.size.width +'x'+ ::_image.size.height }}"></${t.P}-text></dd>\n <dt>size:</dt><dd><${t.P}-text text="{{ $pacem.size(::_image.size.weight) }}"></${t.P}-text></dd>\n </dl></${t.P}-panel>\n\n</div>`})],vt);var gt=function(e,t,i,a){var s,r=arguments.length,n=r<3?t:null===a?a=Object.getOwnPropertyDescriptor(t,i):a;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(e,t,i,a);else for(var o=e.length-1;o>=0;o--)(s=e[o])&&(n=(r<3?s(n):r>3?s(t,i,n):s(t,i))||n);return r>3&&n&&Object.defineProperty(t,i,n),n};let yt=class PacemNumberInputElement extends PacemOrdinalInputElement{toggleReadonlyView(e){this._span.hidden=!e,this._input.hidden=e}get inputFields(){return t.Utils.isNull(this._input)?[]:[this._input]}getViewValue(e){return null!=this.value?this._format(this.value):void 0}_format(e=this.value){const i=this.format;return t.Utils.isNullOrEmpty(i)?e.toString():new Intl.NumberFormat(t.Utils.lang(this),i).format(e)}getValue(e){const t=this.inputField.valueAsNumber||parseFloat(this.inputField.value);return isNaN(t)?void 0:t}viewActivatedCallback(){super.viewActivatedCallback();this._input.addEventListener("wheel",this.emitHandler,{capture:!1,passive:!1})}disconnectedCallback(){if(!t.Utils.isNull(this._input)){this._input.removeEventListener("wheel",this.emitHandler,{capture:!1,passive:!1})}super.disconnectedCallback()}};gt([t.ViewChild("input[type=number]")],yt.prototype,"_input",void 0),gt([t.ViewChild(`span.${t.PCSS}-readonly`)],yt.prototype,"_span",void 0),gt([t.Watch({emit:!1,converter:t.PropertyConverters.Json})],yt.prototype,"format",void 0),yt=gt([t.CustomElement({tagName:t.P+"-input-number",template:`<input type="number" class="${t.PCSS}-input ${t.PCSS}-viewfinder" /><span class="${t.PCSS}-readonly"><${t.P}-text text="{{ :host.viewValue }}"></${t.P}-text></span>`,shadow:t.Defaults.USE_SHADOW_ROOT})],yt);var ft=function(e,t,i,a){var s,r=arguments.length,n=r<3?t:null===a?a=Object.getOwnPropertyDescriptor(t,i):a;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(e,t,i,a);else for(var o=e.length-1;o>=0;o--)(s=e[o])&&(n=(r<3?s(n):r>3?s(t,i,n):s(t,i))||n);return r>3&&n&&Object.defineProperty(t,i,n),n};let _t=class PacemPasswordInputElement extends PacemTextualInputElement{constructor(){super(),this._togglerMousedownHandler=e=>{0==e.button&&(t.avoidHandler(e),this.toggleVisibility())}}get inputFields(){return t.Utils.isNull(this._input)?[]:[this._input]}viewActivatedCallback(){super.viewActivatedCallback();const e=this.id??"_"+t.Utils.uniqueCode(),i=this._input.id=e+"_ctrl";this._toggler.setAttribute("aria-controls",i),this._toggler.setAttribute("role","button"),this._syncToggler(),this._toggler.addEventListener("mousedown",this._togglerMousedownHandler,!1)}disconnectedCallback(){t.Utils.isNull(this._toggler)||this._toggler.removeEventListener("mousedown",this._togglerMousedownHandler,!1)}toggleVisibility(){const e=this._input.type;this._input.type="password"===e?"text":"password",this._syncToggler()}_syncToggler(){const e="password"===this._input.type;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 t.Utils.leftPad("",Math.floor(8+3*Math.random()),"•")}};ft([t.ViewChild("input[type=password]")],_t.prototype,"_input",void 0),ft([t.ViewChild(`span.${t.PCSS}-readonly`)],_t.prototype,"_span",void 0),ft([t.ViewChild(`i.${t.PCSS}-icon.${t.PCSS}-clickable`)],_t.prototype,"_toggler",void 0),_t=ft([t.CustomElement({tagName:t.P+"-input-password",template:`<input type="password" class="${t.PCSS}-input ${t.PCSS}-viewfinder" /><i class="${t.PCSS}-icon ${t.PCSS}-clickable"></i>\n${E}<span class="${t.PCSS}-readonly"><${t.P}-text text="{{ :host.viewValue }}"></${t.P}-text></span>`,shadow:t.Defaults.USE_SHADOW_ROOT})],_t);var bt=function(e,t,i,a){var s,r=arguments.length,n=r<3?t:null===a?a=Object.getOwnPropertyDescriptor(t,i):a;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(e,t,i,a);else for(var o=e.length-1;o>=0;o--)(s=e[o])&&(n=(r<3?s(n):r>3?s(t,i,n):s(t,i))||n);return r>3&&n&&Object.defineProperty(t,i,n),n};let Ct=class PacemSearchInputElement extends PacemTextualInputElement{constructor(){super()}get inputFields(){return t.Utils.isNull(this._input)?[]:[this._input]}toggleReadonlyView(e){}};bt([t.ViewChild("input[type=search]")],Ct.prototype,"_input",void 0),Ct=bt([t.CustomElement({tagName:t.P+"-input-search",template:'<input type="search" class="'+t.PCSS+'-input" />',shadow:t.Defaults.USE_SHADOW_ROOT})],Ct);var Pt=function(e,t,i,a){var s,r=arguments.length,n=r<3?t:null===a?a=Object.getOwnPropertyDescriptor(t,i):a;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(e,t,i,a);else for(var o=e.length-1;o>=0;o--)(s=e[o])&&(n=(r<3?s(n):r>3?s(t,i,n):s(t,i))||n);return r>3&&n&&Object.defineProperty(t,i,n),n};let Et=class PacemTelInputElement extends PacemTextualInputElement{constructor(){super()}toggleReadonlyView(e){const i=this._input,a=this._anchor;t.Utils.isNull(i)||(i.hidden=e),t.Utils.isNull(a)||(a.hidden=!e)}get inputFields(){return t.Utils.isNull(this._input)?[]:[this._input]}};Pt([t.ViewChild("input[type=tel]")],Et.prototype,"_input",void 0),Pt([t.ViewChild(t.P+"-a")],Et.prototype,"_anchor",void 0),Et=Pt([t.CustomElement({tagName:t.P+"-input-tel",template:`<input type="tel" class="${t.PCSS}-input" /><${t.P}-a class="${t.PCSS}-readonly" disabled="{{ $pacem.isNullOrEmpty(:host.value) }}" href="{{ 'tel:'+ :host.value }}"><${t.P}-text text="{{ :host.viewValue }}"></${t.P}-text></${t.P}-a>`,shadow:t.Defaults.USE_SHADOW_ROOT})],Et);var wt=function(e,t,i,a){var s,r=arguments.length,n=r<3?t:null===a?a=Object.getOwnPropertyDescriptor(t,i):a;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(e,t,i,a);else for(var o=e.length-1;o>=0;o--)(s=e[o])&&(n=(r<3?s(n):r>3?s(t,i,n):s(t,i))||n);return r>3&&n&&Object.defineProperty(t,i,n),n};let St=class PacemTextInputElement extends PacemTextualInputElement{constructor(){super()}toggleReadonlyView(e){this._span.hidden=!e,this._input.hidden=e}get inputFields(){return t.Utils.isNull(this._input)?[]:[this._input]}};wt([t.ViewChild("input[type=text]")],St.prototype,"_input",void 0),wt([t.ViewChild("span."+t.PCSS+"-readonly")],St.prototype,"_span",void 0),St=wt([t.CustomElement({tagName:t.P+"-input-text",template:`<input type="text" class="${t.PCSS}-input" />${E}<span class="${t.PCSS}-readonly"><${t.P}-text text="{{ :host.viewValue }}"></${t.P}-text></span>`,shadow:t.Defaults.USE_SHADOW_ROOT})],St);var kt=function(e,t,i,a){var s,r=arguments.length,n=r<3?t:null===a?a=Object.getOwnPropertyDescriptor(t,i):a;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(e,t,i,a);else for(var o=e.length-1;o>=0;o--)(s=e[o])&&(n=(r<3?s(n):r>3?s(t,i,n):s(t,i))||n);return r>3&&n&&Object.defineProperty(t,i,n),n};let $t=class PacemUrlInputElement extends PacemTextualInputElement{constructor(){super()}toggleReadonlyView(e){const i=this._input,a=this._anchor;t.Utils.isNull(i)||(i.hidden=e),t.Utils.isNull(a)||(a.hidden=!e)}get inputFields(){return t.Utils.isNull(this._input)?[]:[this._input]}};kt([t.ViewChild("input[type=url]")],$t.prototype,"_input",void 0),kt([t.ViewChild(t.P+"-a")],$t.prototype,"_anchor",void 0),$t=kt([t.CustomElement({tagName:t.P+"-input-url",template:`<input type="url" class="${t.PCSS}-input" />${E}<${t.P}-a class="${t.PCSS}-readonly" disabled="{{ $pacem.isNullOrEmpty(:host.value) }}" href="{{ :host.value }}" target="_blank"><${t.P}-text text="{{ :host.viewValue }}"></${t.P}-text></${t.P}-a>`,shadow:t.Defaults.USE_SHADOW_ROOT})],$t);var Ut=function(e,t,i,a){var s,r=arguments.length,n=r<3?t:null===a?a=Object.getOwnPropertyDescriptor(t,i):a;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(e,t,i,a);else for(var o=e.length-1;o>=0;o--)(s=e[o])&&(n=(r<3?s(n):r>3?s(t,i,n):s(t,i))||n);return r>3&&n&&Object.defineProperty(t,i,n),n};let Nt=class PacemLatLngElement extends PacemBaseElement{convertValueAttributeToProperty(e){const t=/^\s*([+-]?\d+\.?\d+)[,\s]\s*([+-]?\d+\.?\d+)\s*$/.exec(e);if(t&&3===t.length)return{lat:parseFloat(t[1]),lng:parseFloat(t[2])};throw`Invalid coordinates format for "${e}"`}compareValuePropertyValues(e,t){return!(!e||"number"!=typeof e.lat||"number"!=typeof e.lng||!t||"number"!=typeof t.lat||"number"!=typeof t.lng)&&(e.lat===t.lat&&e.lng===t.lng)}getViewValue(e){return this._getViewValue(e)}_getViewValue(e,t=8){return e&&"number"==typeof e.lat&&"number"==typeof e.lng&&e.lat.toFixed(t)+","+e.lng.toFixed(t)||""}get inputFields(){return[this._latInput,this._lngInput]}toggleReadonlyView(e){this._inputContainer.hidden=e}acceptValue(e){let t=this._ensureValue(e);this._lat=t.lat,this._lng=t.lng}_ensureValue(e){return e&&"number"==typeof e.lat&&"number"==typeof e.lng?e:a.Components.Maps.MapConsts.DEFAULT_COORDS}onChange(e){if(e&&"dragend"===e.type){var i=e;this._lat=i.detail.position.lat,this._lng=i.detail.position.lng}const a=this._lat,s=this._lng;return t.Utils.isNull(a)||t.Utils.isNull(s)?t.Utils.fromResult(this.value):t.Utils.fromResult(this.value={lat:a,lng:s})}propertyChangedCallback(e,i,a,s){if(super.propertyChangedCallback(e,i,a,s),"options"===e&&!s){const e=t.Utils.clone(a||{provider:"osm"});this._synchronizeOptions(e)}}viewActivatedCallback(){super.viewActivatedCallback(),this._synchronizeOptions()}_synchronizeOptions(e=this.options||{provider:"osm"}){const i=this._marker,a=this._map;switch(i.icon=e.icon,e&&e.provider){case"azure":this._azureAdapter.subscriptionKey=e.apiKey,a.adapter=this._azureAdapter;break;case"google":case"gmaps":this._googleAdapter.apiKey=e.apiKey,a.adapter=this._googleAdapter;break;default:t.Utils.isNullOrEmpty(e.attribution)||(this._leafletAdapter.attribution=e.attribution),t.Utils.isNullOrEmpty(e.tiles)||(this._leafletAdapter.tiles=e.tiles),a.adapter=this._leafletAdapter}delete e.provider,delete e.icon,delete e.apiKey,delete e.attribution,delete e.tiles;for(let t in e)t in a&&(a[t]=e[t])}};Ut([t.ViewChild(t.P+"-map-adapter-leaflet")],Nt.prototype,"_leafletAdapter",void 0),Ut([t.ViewChild(t.P+"-map-adapter-azure")],Nt.prototype,"_azureAdapter",void 0),Ut([t.ViewChild(t.P+"-map-adapter-google")],Nt.prototype,"_googleAdapter",void 0),Ut([t.ViewChild(t.P+"-map")],Nt.prototype,"_map",void 0),Ut([t.ViewChild(t.P+"-map-marker")],Nt.prototype,"_marker",void 0),Ut([t.ViewChild(t.P+"-input-number:nth-child(1)")],Nt.prototype,"_latInput",void 0),Ut([t.ViewChild(t.P+"-input-number:nth-child(2)")],Nt.prototype,"_lngInput",void 0),Ut([t.ViewChild(`.${t.PCSS}-latlng-fields`)],Nt.prototype,"_inputContainer",void 0),Ut([t.ViewChild(t.P+"-fetch")],Nt.prototype,"_fetcher",void 0),Ut([t.Watch({converter:t.PropertyConverters.Json,emit:!1})],Nt.prototype,"options",void 0),Ut([t.Watch()],Nt.prototype,"_lat",void 0),Ut([t.Watch()],Nt.prototype,"_lng",void 0),Nt=Ut([t.CustomElement({tagName:t.P+"-latlng",shadow:t.Defaults.USE_SHADOW_ROOT,template:`<div class="${t.PCSS}-latlng">\n <div class="${t.PCSS}-latlng-fields ${t.PCSS}-viewfinder">\n <${t.P}-input-number class="${t.PCSS}-lat" value="{{ :host._lat, twoway }}" min="-90" max="90" step="{{ 'any' }}"></${t.P}-input-number>\n <${t.P}-input-number class="${t.PCSS}-lng" value="{{ :host._lng, twoway }}" min="-180" max="180" step="{{ 'any' }}"></${t.P}-input-number>\n </div>\n <${t.P}-panel hide="{{ Pacem.Utils.isNull(:host.value) || :host.readonly }}">\n <dl class="${t.PCSS}-latlng-preview">\n <dt>decimals:</dt><dd><${t.P}-text text="{{ :host._getViewValue(:host.value, 12) }}"></${t.P}-text></dd>\n <dt>address:</dt><dd><${t.P}-text text="{{ ::_fetcher.result.display_name || '?' }}"></${t.P}-text></dd>\n <dt>degrees:</dt><dd><${t.P}-span css-class="{{ {'${t.PCSS}-lat-north': :host._lat > 0, '${t.PCSS}-lat-south': :host._lat < 0} }}" content="{{ $pacem.decToDeg(Math.abs(:host._lat)) }}"></${t.P}-span>,\n <${t.P}-span css-class="{{ {'${t.PCSS}-lng-east': :host._lng > 0, '${t.PCSS}-lng-west': :host._lng < 0} }}" content="{{ $pacem.decToDeg(Math.abs(:host._lng)) }}"></${t.P}-span></dd>\n </dl>\n </${t.P}-panel>\n <${t.P}-span class="${t.PCSS}-readonly" hide="{{ !:host.readonly }}" content="{{ :host.viewValue + ($pacem.isNullOrEmpty(::_fetcher.result.display_name) ? '' : (' <small>'+ ::_fetcher.result.display_name +'</small>')) }}"></${t.P}-span>\n\n <${t.P}-map-adapter-leaflet></${t.P}-map-adapter-leaflet>\n <${t.P}-map-adapter-azure></${t.P}-map-adapter-azure>\n <${t.P}-map-adapter-google></${t.P}-map-adapter-google>\n\n <${t.P}-map adapter="{{ ::_adapter }}">\n <${t.P}-map-marker position="{{ :host._ensureValue(:host.value) }}" on-dragend=":host.changeHandler($event)" draggable="{{ !:host.readonly }}"></${t.P}-map-marker>\n </${t.P}-map>\n <${t.P}-fetch disabled="{{ $pacem.isNull(:host.value) }}" parameters="{{ { format: 'json', lat: :host._lat, lon: :host._lng } }}" url="https://nominatim.openstreetmap.org/reverse"></${t.P}-fetch>\n</div>`})],Nt);var Ot=function(e,t,i,a){var s,r=arguments.length,n=r<3?t:null===a?a=Object.getOwnPropertyDescriptor(t,i):a;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(e,t,i,a);else for(var o=e.length-1;o>=0;o--)(s=e[o])&&(n=(r<3?s(n):r>3?s(t,i,n):s(t,i))||n);return r>3&&n&&Object.defineProperty(t,i,n),n};const xt=`change-policy="${qe.Blur}" readonly="{{ :host.readonly }}"`;function Vt(e){return t.Utils.isNullOrEmpty(e&&e.name)}let Dt=class PacemNameValueListElement extends PacemBaseElement{constructor(){super(...arguments),this.inputFields=[],this._bag=[]}toggleReadonlyView(e){}onChange(e){return new Promise((e,t)=>{let i=this._bagToValue(this._bag);this.compareValuePropertyValues(i,this.value)?t():e(this.value=i)})}acceptValue(e){this._bag=this._valueToBag(e)}getViewValue(e){return""}compareValuePropertyValues(e,i){return t.Utils.Json.stringify(e)===t.Utils.Json.stringify(i)}convertValueAttributeToProperty(e){return t.PropertyConverters.Json.convert(e)}propertyChangedCallback(e,t,i,a){super.propertyChangedCallback(e,t,i,a),"dictionary"!==e||a||(this.value=this._bagToValue())}_bagToValue(e=this._bag){if(!this.dictionary){let t=[];for(let i of e||[])Vt(i)||t.find(e=>e.name===i.name&&e.value===i.value)||t.push(i);return t}let t={};for(let i of e||[])i.name in t||(t[i.name]=i.value);return t}_valueToBag(e=this.value){const i=[];if(!t.Utils.isNullOrEmpty(e)&&"object"==typeof e)if(this.dictionary&&!t.Utils.isArray(e))for(let t in e)i.push({name:t,value:e[t]});else!this.dictionary&&t.Utils.isArray(e)&&Array.prototype.splice.apply(i,[0,0].concat(e.map(e=>t.Utils.clone(e))));return t.Utils.isNullOrEmpty(i)?[{name:"",value:""}]:i}_deleteAt(e){this._bag.splice(e.detail,1),this.changeHandler(e)}_addItem(e){const i=this._bag,a=this._bag[this._bag.length-1];!t.Utils.isEmpty(i)&&Vt(a)||i.push({name:"",value:""})}};Ot([t.Watch({emit:!1,converter:t.PropertyConverters.Boolean})],Dt.prototype,"dictionary",void 0),Ot([t.Watch({converter:t.PropertyConverters.Json})],Dt.prototype,"_bag",void 0),Dt=Ot([t.CustomElement({tagName:t.P+"-namevalue-list",shadow:t.Defaults.USE_SHADOW_ROOT,template:`<${t.P}-repeater datasource="{{ :host._bag }}" on-itemdelete=":host._deleteAt($event)">\n <template>\n <div class="${t.PCSS}-fieldset ${t.PCSS}-margin margin-bottom-1">\n <div class="fieldset-auto">\n <div class="${t.PCSS}-fieldgroup">\n <${t.P}-input-text ${xt} value="{{ ^item.name, twoway }}" on-change=":host.changeHandler($event)"></${t.P}-input-text>\n <div class="fieldgroup-prepend"></div>\n </div>\n <div class="${t.PCSS}-fieldgroup">\n <${t.P}-input-text ${xt} value="{{ ^item.value, twoway }}" on-change=":host.changeHandler($event)"></${t.P}-input-text>\n <div class="fieldgroup-append">\n <${t.P}-button class="${t.PCSS}-cell cols-2 flat delete" hide="{{ :host.readonly }}" command-name="delete" command-argument="{{ ^index }}"></${t.P}-button>\n </div>\n </div>\n </div>\n </div>\n </template>\n <${t.P}-button class="flat add" hide="{{ :host.readonly }}" on-click=":host._addItem($event)"></${t.P}-button>\n</${t.P}-repeater>`})],Dt);var Ht=function(e,t,i,a){var s,r=arguments.length,n=r<3?t:null===a?a=Object.getOwnPropertyDescriptor(t,i):a;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(e,t,i,a);else for(var o=e.length-1;o>=0;o--)(s=e[o])&&(n=(r<3?s(n):r>3?s(t,i,n):s(t,i))||n);return r>3&&n&&Object.defineProperty(t,i,n),n};let At=class PacemPropertyPickerElement extends PacemBaseElement{get inputFields(){return[this._select]}toggleReadonlyView(e){this._select.readonly=e}onChange(e){return t.Utils.fromResult(this.value=this._select.value)}acceptValue(e){this._select.value=e}getViewValue(e){return this._select.viewValue}convertValueAttributeToProperty(e){return t.PropertyConverters.Element.convert(e)}viewActivatedCallback(){super.viewActivatedCallback(),this._databind()}propertyChangedCallback(e,t,i,a){if(super.propertyChangedCallback(e,t,i,a),!a&&"target"===e)this._databind()}_databind(){const e=[],i=(a,s,r)=>{const n=a[s];if("object"==typeof n&&null!=n&&!t.Utils.isArray(n))for(let t of Object.keys(n)){const a=r+"."+t;e.push(a),i(n,t,a)}};let a=this.target;if(!t.Utils.isNull(a)){let s=t.CustomElementUtils.getWatchedProperties(a);for(let t of s){let s=t.name;e.push(s),i(a,s,s)}}this._select.datasource=e.sort()}};Ht([t.ViewChild(t.P+"-select")],At.prototype,"_select",void 0),Ht([t.Watch({converter:t.PropertyConverters.Element})],At.prototype,"target",void 0),At=Ht([t.CustomElement({tagName:t.P+"-property-picker",shadow:t.Defaults.USE_SHADOW_ROOT,template:`<${t.P}-select></${t.P}-select>`})],At);var Tt=function(e,t,i,a){var s,r=arguments.length,n=r<3?t:null===a?a=Object.getOwnPropertyDescriptor(t,i):a;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(e,t,i,a);else for(var o=e.length-1;o>=0;o--)(s=e[o])&&(n=(r<3?s(n):r>3?s(t,i,n):s(t,i))||n);return r>3&&n&&Object.defineProperty(t,i,n),n};let Rt=class PacemRadioElement extends PacemBaseElement{convertValueAttributeToProperty(e){return e}constructor(){super(),this._key="_"+t.Utils.uniqueCode()}toggleReadonlyView(e){this.span.hidden=!e,this._radio.hidden=e}get inputFields(){return[this._radio]}onChange(e){this.selected=this._radio.checked;const i=this.selected?this._radio.value:void 0;return t.Utils.fromResult(i)}viewActivatedCallback(){super.viewActivatedCallback(),this._radio.id=this._label.htmlFor=this._key}propertyChangedCallback(e,i,a,s){switch(super.propertyChangedCallback(e,i,a,s),e){case"name":this._radio.name=a;break;case"selected":(this._radio.checked=a)?t.Utils.addClass(this,t.PCSS+"-selected"):t.Utils.removeClass(this,t.PCSS+"-selected")}}acceptValue(e){this._radio.value=t.Utils.isNullOrEmpty(e)?"":e}getViewValue(e){return t.Utils.isNull(e)?"":this.caption}};Tt([t.ViewChild("input[type=radio]")],Rt.prototype,"_radio",void 0),Tt([t.ViewChild("label")],Rt.prototype,"_label",void 0),Tt([t.ViewChild(`.${t.PCSS}-readonly`)],Rt.prototype,"span",void 0),Tt([t.Watch({converter:t.PropertyConverters.String})],Rt.prototype,"caption",void 0),Tt([t.Watch({converter:t.PropertyConverters.Boolean})],Rt.prototype,"selected",void 0),Rt=Tt([t.CustomElement({tagName:t.P+"-radio",template:`<${t.P}-span class="${t.PCSS}-readonly ${t.PCSS}-radio" text="{{ :host.caption }}"></${t.P}-span><input type="radio" class="${t.PCSS}-input" /><label class="${t.PCSS}-label ${t.PCSS}-radio ${t.PCSS}-viewfinder"><${t.P}-text text="{{ :host.caption }}"></${t.P}-text></label>`,shadow:t.Defaults.USE_SHADOW_ROOT})],Rt);var Lt=function(e,t,i,a){var s,r=arguments.length,n=r<3?t:null===a?a=Object.getOwnPropertyDescriptor(t,i):a;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(e,t,i,a);else for(var o=e.length-1;o>=0;o--)(s=e[o])&&(n=(r<3?s(n):r>3?s(t,i,n):s(t,i))||n);return r>3&&n&&Object.defineProperty(t,i,n),n};let It=class PacemRadioListElement extends PacemDataSourceElement{acceptValue(e){}constructor(){super(),this.key="_"+t.Utils.uniqueCode()}get inputFields(){return[]}propertyChangedCallback(e,t,i,a){super.propertyChangedCallback(e,t,i,a),"disabled"===e&&(this._disable.model=i)}viewActivatedCallback(){super.viewActivatedCallback(),this._disable.model=this.disabled}toggleReadonlyView(e){this._repeater.hidden=e,this._span.hidden=!e}_selectionChanged(e,t,i){"selected"===e.detail.propertyName&&!0===e.detail.currentValue&&(this._selectedValue=this.mapEntityToValue(this.datasource[t]),this.changeHandler(e))}onChange(e){return this.value=this._selectedValue,this.databind(),t.Utils.fromResult(this._selectedValue)}};Lt([t.ViewChild(t.P+"-repeater")],It.prototype,"_repeater",void 0),Lt([t.ViewChild(t.P+"-data")],It.prototype,"_disable",void 0),Lt([t.ViewChild(`span.${t.PCSS}-readonly`)],It.prototype,"_span",void 0),It=Lt([t.CustomElement({tagName:t.P+"-radio-list",template:`<${t.P}-repeater datasource="{{ :host.adaptedDatasource }}">\n <ol class="${t.PCSS}-radio-list ${t.PCSS}-viewfinder" pacem>\n <template>\n <li><${t.P}-radio disabled="{{ ::_disable.model || ^item.disabled }}" name="{{ :host.key, once }}" autobind="off" caption="{{ ^item.viewValue }}" value="{{ ^item.value }}" selected="{{ :host.isDataSourceItemSelected(^item, :host.value) }}"\non-focus=":host.focusHandler($event)" on-blur=":host.focusHandler($event)"\non-${t.PropertyChangeEventName}=":host._selectionChanged($event, ^index, ^item)"></${t.P}-radio></li>\n </template>\n </ol>\n</${t.P}-repeater><span class="${t.PCSS}-readonly ${t.PCSS}-radio"><${t.P}-text text="{{ :host.viewValue }}"></${t.P}-text></span><${t.P}-data></${t.P}-data><${t.P}-content></${t.P}-content>`,shadow:t.Defaults.USE_SHADOW_ROOT})],It);var Ft=function(e,t,i,a){var s,r=arguments.length,n=r<3?t:null===a?a=Object.getOwnPropertyDescriptor(t,i):a;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(e,t,i,a);else for(var o=e.length-1;o>=0;o--)(s=e[o])&&(n=(r<3?s(n):r>3?s(t,i,n):s(t,i))||n);return r>3&&n&&Object.defineProperty(t,i,n),n};let Wt=class PacemSelectElement extends PacemDataSourceElement{constructor(){super(...arguments),this.emptyOption=!0}toggleReadonlyView(e){this._repeater.hidden=e,this._span.hidden=!e}get inputFields(){return t.Utils.isNull(this._select)?[]:[this._select]}_manageDom(e){const i=e.detail,a=i.item;let s=i.dom.find(e=>e instanceof HTMLOptionElement);s.value=a.value,s.textContent=a.viewValue,s.disabled=a.disabled,s.selected=this.isDataSourceItemSelected(a),(t.Utils.isNullOrEmpty(s.value)?t.Utils.addClass:t.Utils.removeClass).apply(this,[s,t.PCSS+"-watermark"])}onChange(e){let i,a=this._select.selectedIndex,s=this.adaptedDatasource,r=a>=0&&s[a];return i=null!=r?r.value:void 0,t.Utils.fromResult(this.value=i)}propertyChangedCallback(e,t,i,a){switch(super.propertyChangedCallback(e,t,i,a),e){case"placeholder":case"emptyOption":this.databind()}}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):t.Utils.isNullOrEmpty(e)?this.value=void 0:this.value=e[0].value}acceptValue(e){const i=this.adaptedDatasource,a=i&&i.filter(t=>this.isDataSourceItemSelected(t,e));if(a&&1==a.length)this._select.selectedIndex=i.indexOf(a[0]);else{this._select.value=void 0;let e=this._select.options;e.length>0&&t.Utils.isNullOrEmpty(e[0].value)&&(this._select.selectedIndex=0)}}viewActivatedCallback(){super.viewActivatedCallback();this._select.addEventListener("wheel",this.emitHandler,{capture:!1,passive:!1})}disconnectedCallback(){if(!t.Utils.isNull(this._select)){this._select.removeEventListener("wheel",this.emitHandler,{capture:!1,passive:!1})}super.disconnectedCallback()}};Ft([t.ViewChild("select")],Wt.prototype,"_select",void 0),Ft([t.ViewChild(t.P+"-repeater")],Wt.prototype,"_repeater",void 0),Ft([t.ViewChild(`span.${t.PCSS}-readonly`)],Wt.prototype,"_span",void 0),Ft([t.Watch({emit:!1,converter:t.PropertyConverters.Boolean})],Wt.prototype,"emptyOption",void 0),Wt=Ft([t.CustomElement({tagName:t.P+"-select",template:`<${t.P}-repeater datasource="{{ :host.adaptedDatasource }}" on-${t.Components.RepeaterItemCreateEventName}=":host._manageDom($event)">\n <select class="${t.PCSS}-select ${t.PCSS}-viewfinder">\n <template>\n <option></option>\n </template>\n </select>\n</${t.P}-repeater><span class="${t.PCSS}-readonly"><${t.P}-text text="{{ :host.viewValue }}"></${t.P}-text></span><${t.P}-content></${t.P}-content>`,shadow:t.Defaults.USE_SHADOW_ROOT})],Wt);var Bt=function(e,t,i,a){var s,r=arguments.length,n=r<3?t:null===a?a=Object.getOwnPropertyDescriptor(t,i):a;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(e,t,i,a);else for(var o=e.length-1;o>=0;o--)(s=e[o])&&(n=(r<3?s(n):r>3?s(t,i,n):s(t,i))||n);return r>3&&n&&Object.defineProperty(t,i,n),n};let jt=class PacemSliderElement extends PacemBaseElement{constructor(){super(...arguments),this.inputFields=[],this._dragHandler=e=>{e.preventDefault(),this._computeAndAssignValue(e.detail.currentPosition.x,"end"!==this.changePolicy)},this._endHandler=e=>{e.preventDefault(),this._computeAndAssignValue(e.detail.currentPosition.x,"end"===this.changePolicy)},this._startHandler=e=>{this._thumb.focus()},this._downHandler=e=>{const i=e instanceof MouseEvent?e.clientX:e.touches&&e.touches.length&&e.touches[0].clientX,a=this._trackSize;t.Utils.isNullOrEmpty(a)||this._computeAndAssignValue(i,!0)},this._keydownHandler=e=>{switch(e.keyCode){case 39:case 37:t.avoidHandler(e);let i=39===e.keyCode,a=("number"!=typeof this.step?1:this.step)*(i?1:-1),s=!1,r=e=>{s=!0,window.removeEventListener("keyup",r,!1),t.Utils.removeClass(this,"slider-keydown")};window.addEventListener("keyup",r,!1),t.Utils.addClass(this,"slider-keydown"),t.Utils.accelerateCallback(e=>{(e.cancel=s)||this._setValue(this.value+a)})}}}onChange(e){return new Promise((t,i)=>{"slide"===e.type&&t(this.value=e.detail),t(this.value)})}_draw(e=this.value){const i=this._trackSize;if(t.Utils.isNull(i))return;const a=t.Utils.isNullOrEmpty(e)?this.min:parseFloat(e),s=Math.min(1,Math.max(0,(a-this.min)/(this.max-this.min)));this._progress.style.transform=`scale(${s}, 1)`,this._thumb.style.transform=`translateX(${Math.round(s*i.width)}px)`}_format(e){const i=this.format;if(!t.Utils.isNullOrEmpty(i))return new Intl.NumberFormat(t.Utils.lang(this),i).format(e);let a="-";t.Utils.isNull(e)||(a=e.toLocaleString());let s=new CustomEvent("formatvalue",{detail:{value:e}});return this.dispatchEvent(s),t.Utils.isNull(s.detail.output)?a:s.detail.output}acceptValue(e){this._draw(e)}getViewValue(e){return this._format(e)}convertValueAttributeToProperty(e){return parseFloat(e)}toggleReadonlyView(e){this._thumb.hidden=e;const i="cursor-pointer";e?(t.Utils.removeClass(this._max,i),t.Utils.removeClass(this._min,i)):(t.Utils.addClass(this._max,i),t.Utils.addClass(this._min,i))}_setTrackSize(e){const 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;const i=this._trackSize,a=this.step;let s=(e-i.x)/i.width,r=(this.max-this.min)*s+this.min;"number"==typeof a&&(r=Math.round(r/a)*a),t?this._setValue(r):this._draw(r)}_setValue(e){isNaN(e)||t.Utils.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(t.UI.DragDropEventType.Init,this._startHandler,!1),this._dragger.addEventListener(t.UI.DragDropEventType.Drag,this._dragHandler,!1),this._dragger.addEventListener(t.UI.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);const e=this._shellProxy.dom[0];t.Utils.isNull(e)||(e.target=this._thumb,e.options={trigger:i.Components.UI.BalloonTrigger.Focus,trackPosition:!0,position:i.Components.UI.BalloonPosition.Top,align:i.Components.UI.BalloonAlignment.Center,behavior:i.Components.UI.BalloonBehavior.Tooltip,hoverDelay:0,hoverTimeout:0},this._syncThumbLabel()),this._thumb.tabIndex=0}_syncThumbLabel(e=this.thumbLabel){const i=this._shellProxy.dom[0];(e?t.Utils.addClass:t.Utils.removeClass).apply(this,[this,"slider-thumblabel"]),i.disabled=!e}disconnectedCallback(){this.removeEventListener("mousedown",this._downHandler,!1),this.removeEventListener("touchstart",this._downHandler,{capture:!1}),t.Utils.isNull(this._dragger)||(this._dragger.removeEventListener(t.UI.DragDropEventType.End,this._endHandler,!1),this._dragger.removeEventListener(t.UI.DragDropEventType.Drag,this._dragHandler,!1),this._dragger.removeEventListener(t.UI.DragDropEventType.Init,this._startHandler,!1)),t.Utils.isNull(this._thumb)||this._thumb.removeEventListener("keydown",this._keydownHandler,!1),super.disconnectedCallback()}propertyChangedCallback(e,i,a,s){if(super.propertyChangedCallback(e,i,a,s),!s)switch(e){case"thumbLabel":this._syncThumbLabel(a);break;case"min":case"max":t.Utils.isNull(this._max)||t.Utils.isNull(this._min)||(this._min.text=this._format(this.min),this._max.text=this._format(this.max)),this._setValue(this.value),this._draw()}}};Bt([t.Watch({emit:!1,converter:t.PropertyConverters.Number})],jt.prototype,"min",void 0),Bt([t.Watch({emit:!1,converter:t.PropertyConverters.Number})],jt.prototype,"max",void 0),Bt([t.Watch({emit:!1,converter:t.PropertyConverters.Boolean})],jt.prototype,"thumbLabel",void 0),Bt([t.Watch({emit:!1,converter:{convert:e=>{let t=parseFloat(e);return isNaN(t)?"any":t},convertBack:e=>(e||"").toString()}})],jt.prototype,"step",void 0),Bt([t.Watch({emit:!1,converter:t.PropertyConverters.String})],jt.prototype,"changePolicy",void 0),Bt([t.Watch({emit:!1,converter:t.PropertyConverters.Json})],jt.prototype,"format",void 0),Bt([t.ViewChild(".slider-track")],jt.prototype,"_track",void 0),Bt([t.ViewChild(".slider-progress")],jt.prototype,"_progress",void 0),Bt([t.ViewChild(".slider-thumb")],jt.prototype,"_thumb",void 0),Bt([t.ViewChild(`${t.P}-text[min]`)],jt.prototype,"_min",void 0),Bt([t.ViewChild(`${t.P}-text[max]`)],jt.prototype,"_max",void 0),Bt([t.ViewChild(`${t.P}-drag-drop`)],jt.prototype,"_dragger",void 0),Bt([t.ViewChild(`${t.P}-shell-proxy`)],jt.prototype,"_shellProxy",void 0),jt=Bt([t.CustomElement({tagName:t.P+"-slider",template:`<div class="${t.PCSS}-viewfinder ${t.PCSS}-slider"><${t.P}-text text="{{ :host._format(:host.min) }}" min></${t.P}-text>\n <div class="slider-track"><div class="slider-progress"></div></div>\n <${t.P}-panel class="${t.PCSS}-clickable slider-thumb" behaviors="{{ [::_dragger] }}">\n <div class="thumb-label"></div>\n </${t.P}-panel>\n <${t.P}-text text="{{ :host._format(:host.max) }}" max></${t.P}-text>\n <div class="slider-footer"><${t.P}-text text="{{ :host.viewValue }}"></${t.P}-text></div>\n </div>\n<${t.P}-drag-drop lock-timeout="0"></${t.P}-drag-drop><${t.P}-resize watch-position="true" on-${t.Components.ResizeEventName}=":host._setTrackSize($event)" target="{{ ::_track }}"></${t.P}-resize>\n<${t.P}-shell-proxy><${t.P}-balloon class="text-center"><${t.P}-text text="{{ :host.viewValue }}"></${t.P}-text></${t.P}-balloon></${t.P}-shell-proxy>\n`,shadow:t.Defaults.USE_SHADOW_ROOT})],jt);var Mt=function(e,t,i,a){var s,r=arguments.length,n=r<3?t:null===a?a=Object.getOwnPropertyDescriptor(t,i):a;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(e,t,i,a);else for(var o=e.length-1;o>=0;o--)(s=e[o])&&(n=(r<3?s(n):r>3?s(t,i,n):s(t,i))||n);return r>3&&n&&Object.defineProperty(t,i,n),n};class SuggestionSelectEvent extends t.CustomTypedEvent{constructor(e){super("suggestionselect",{selectedValue:e})}}let zt=class PacemSuggestElement extends PacemDataSourceElement{constructor(){super(...arguments),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 SuggestionSelectEvent(null))},this._balloonPopupHandler=e=>{t.Utils.addClass(this._btnArrow,"rotate-180")},this._balloonPopoutHandler=e=>{t.Utils.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 SuggestionSelectEvent(null))}},this._keyupHandler=e=>{this.#C&&(t.avoidHandler(e),this.#C=!1)},this._focusHandler=e=>{if(this.preventFocus){e.preventDefault();this._balloon.visible?this.popout():this.popup()}const t=this._input.value;this.viewValue!=t&&this._databind()},this._blurHandler=e=>{this._undo()},this.#C=!1,this._keydownHandler=e=>{var i=!1;if(t.Utils.isNull(this.#P)){const a=this._findFirstAvailableListItem();if(!t.Utils.isNull(a))switch(e.keyCode){case 40:t.avoidHandler(e),this._focus(a);break;case 13:t.avoidHandler(e),i=!0,1===this.#E.length?this._select(a):this._focus(a)}}else{var a,s=this.#P,r=s;const n=e=>!t.Utils.isNull(e)&&"li"===e.localName&&"true"===e.dataset.pacemDisabled,o=e=>!t.Utils.isNull(e)&&"li"===e.localName&&"true"!==e.dataset.pacemDisabled;switch(e.keyCode){case 38:t.avoidHandler(e);do{if(o(r=r.previousElementSibling)){a=r;break}}while(n(r));a??=s;break;case 40:t.avoidHandler(e);do{if(o(r=r.nextElementSibling)){a=r;break}}while(n(r));a??=s;break;case 27:t.avoidHandler(e),this._undo(),this.popout();break;case 9:case 13:t.avoidHandler(e),i=!0,this._select()}this._focus(a),this.#C=i}},this._selectHandler=e=>{t.avoidHandler(e),this._select(e.currentTarget)}}get inputFields(){return[this._input]}acceptValue(e){/*!this._isTyping && */!this.allowNew&&t.Utils.isNullOrEmpty(this.datasource)||(this._input.value=this.getViewValue(e)||(this._isTyping?this._input.value:""))}getViewValue(e){var i=super.getViewValue(e);return t.Utils.isNullOrEmpty(i)&&this.allowNew&&!t.Utils.isNullOrEmpty(e)&&(i=this.mapEntityToViewValue(e)),i}onChange(e){return new Promise((t,i)=>{if("suggestionselect"===e.type){const 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);t.CustomElementUtils.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,i,a,s){if(super.propertyChangedCallback(e,i,a,s),t.Utils.isNull(this._balloon))return;const r=this._isTyping;switch(e){case"adaptedDatasource":t.Utils.isNullOrEmpty(a)?this.popout():r?this.popup():this._input.value=this.getViewValue(this.value);break;case"hint":r||a===this._input.value||(this._input.value=a,this.#P=null);break;case"readonly":this._setDropdownMode();case"disabled":case"value":this._checkBalloon();break;case"itemtemplate":s||this._setupItemTemplate();break;case"allowTyping":s||this._setDropdownMode()}["adaptedDatasource","hint","value"].indexOf(e)>=0&&this._databind(),["allowTyping","value","hint"].indexOf(e)>=0&&this._syncButtons()}disconnectedCallback(){t.Utils.isNull(this._balloon)||(this._balloon.removeEventListener("popup",this._balloonPopupHandler,!1),this._balloon.removeEventListener("popout",this._balloonPopoutHandler,!1),this._balloon.remove()),t.Utils.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)),t.Utils.isNull(this._btnClear)||this._btnClear.removeEventListener("mousedown",this._clearBtnHandler,!1),t.Utils.isNull(this._btnArrow)||this._btnArrow.addEventListener("mousedown",this._toggleBtnHandler,!1),super.disconnectedCallback()}#E;_databind(){if(!t.Utils.isNull(this._repeater)){const e=this.#E=this._filter(this.adaptedDatasource,this._input.value);this._repeater.datasource=e}}_syncButtons(){t.Utils.isNull(this._btnArrow)||(this._btnArrow.hide=!1!==this.allowTyping||!t.Utils.isNullOrEmpty(this._input.value||this.value)),t.Utils.isNull(this._btnClear)||(this._btnClear.hide=this.readonly||t.Utils.isNullOrEmpty(this._input.value||this.value))}get _isTyping(){return t.Utils.is(this._input,":focus")}_undo(){this._focus(null),this.hint=this._input.value=this.getViewValue(this.value)||""}_findFirstAvailableListItem(){var e;if(!0===this._balloon.visible&&!t.Utils.isNull(e=this._repeater.querySelector("ol > li")))for(;!t.Utils.isNull(e)&&"true"===e.dataset.pacemDisabled&&"li"===e.localName;)e=e.nextElementSibling;return e}#C;_setDropdownMode(e=this.allowTyping){this._input.readOnly=!(e??1)}_setupItemTemplate(){if(this.itemtemplate instanceof HTMLTemplateElement){const e=this.itemtemplate.cloneNode(!0).content,t=document.createElement("template"),i=document.createElement("li");i.append(e),t.content.appendChild(i),this._tmplProxy.target=t}else this._tmplProxy.target=this._defaultTemplate}#P;_focus(e){if(this.preventFocus)return;if(t.Utils.isNull(e))return void(this.#P=null);const i=e.parentElement.children;for(let t=0;t<i.length;t++){const a=i.item(t);if(a===e){a.dataset.pacemFocused="true",this.#P=a;const e=this._input,t=e.value=JSON.parse(a.dataset.pacemViewValue);e.setSelectionRange(t.length,t.length)}else delete a.dataset.pacemFocused}}_select(e=this.#P){const t=JSON.parse(e.dataset.pacemValue);"true"===e.dataset.pacemDisabled||this.changeHandler(new SuggestionSelectEvent(t))}_filter(e,i,a=this.value){let s=e||[];if(!t.Utils.isNullOrEmpty(i&&i.trim())){const e=i.toLowerCase().split(" ");let a=s.filter(i=>{for(let a of e){if(i.viewValue?.toLowerCase().indexOf(a)>=0)return!0;const e=this.filterFields;if(!t.Utils.isNullOrEmpty(e)){const s=i.data;if("object"==typeof s&&!t.Utils.isNullOrEmpty(s))for(let i of e){const e=i.split(".");let r=0,n=s;for(;!t.Utils.isNull(n)&&r<e.length;)n=n[e[r]],r++;if(!t.Utils.isNullOrEmpty(n)&&n.toString().toLowerCase().indexOf(a)>=0)return!0}}}return!1});s=this.allowNew&&t.Utils.isNullOrEmpty(this.valueProperty)&&t.Utils.isNullOrEmpty(this.textProperty)&&(t.Utils.isNullOrEmpty(a)||t.Utils.isNull(a.find(e=>e.viewValue===i)))?[{value:i,viewValue:i,data:i}].concat(a):a}let r=s;return!1!==this.allowTyping&&(r=s.slice(0,this.maxSuggestions||10)),this._isTyping&&this.popup(),this._balloon.style.opacity=t.Utils.isNullOrEmpty(r)?"0":"",this.log(t.Logging.LogLevel.Log,`${r.length} dropdown suggestion(s), given hint '${i}' and ${(e||[]).length} datasource items`),r}_itemCreate(e){const t=e.detail.dom.find(e=>e instanceof HTMLLIElement),i=e.detail.item;e.detail.index;const a=!0===i.disabled;t.tabIndex=a?-1:0,t.dataset.pacemValue=JSON.stringify(i.value),t.dataset.pacemViewValue=JSON.stringify(i.viewValue),t.dataset.pacemDisabled=a.toString(),t.addEventListener("mousedown",this._selectHandler,!1)}_itemRemove(e){e.detail.dom.find(e=>e 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=100){!t.Utils.isNullOrEmpty(this.adaptedDatasource)&&t.Utils.isVisible(this)&&this._balloon?.popup(e)}popout(e=0){this.#P=null,this._balloon?.popout(e)}_checkBalloon(e=this._balloon){if(!t.Utils.isNull(e)){const i=!t.Utils.isNullOrEmpty(this.value)&&!t.Utils.isNullOrEmpty(this._input.value);e.disabled=i||this.readonly||this.disabled||!1}}_createBalloon(){const e=document.createElement(t.P+"-balloon");return t.Utils.addClass(e,"suggest dropdown"),e.options={trackPosition:!0,trigger:i.Components.UI.BalloonTrigger.Focus,position:i.Components.UI.BalloonPosition.VerticalAuto,size:i.Components.UI.BalloonSizing.Match,align:i.Components.UI.BalloonAlignment.Start,behavior:i.Components.UI.BalloonBehavior.Menu,hoverDelay:100,hoverTimeout:0},e.addEventListener("popup",this._balloonPopupHandler,!1),e.addEventListener("popout",this._balloonPopoutHandler,!1),e.target=this._input,e}};Mt([t.ViewChild("input[type=text]")],zt.prototype,"_input",void 0),Mt([t.ViewChild(t.P+"-repeater")],zt.prototype,"_repeater",void 0),Mt([t.ViewChild(`span.${t.PCSS}-readonly`)],zt.prototype,"span",void 0),Mt([t.ViewChild("template")],zt.prototype,"_defaultTemplate",void 0),Mt([t.ViewChild(t.P+"-template-proxy")],zt.prototype,"_tmplProxy",void 0),Mt([t.ViewChild(`${t.P}-button[toggle]`)],zt.prototype,"_btnArrow",void 0),Mt([t.ViewChild(`${t.P}-button[clear]`)],zt.prototype,"_btnClear",void 0),Mt([t.Watch({converter:t.PropertyConverters.String})],zt.prototype,"hint",void 0),Mt([t.Watch({emit:!1,converter:t.PropertyConverters.Number})],zt.prototype,"maxSuggestions",void 0),Mt([t.Watch({converter:t.PropertyConverters.Boolean})],zt.prototype,"allowTyping",void 0),Mt([t.Watch({emit:!1,converter:t.PropertyConverters.Boolean})],zt.prototype,"preventFocus",void 0),Mt([t.Watch({emit:!1,converter:t.PropertyConverters.Element})],zt.prototype,"itemtemplate",void 0),Mt([t.Watch({emit:!1,converter:t.PropertyConverters.StringArray})],zt.prototype,"filterFields",void 0),Mt([t.Watch({emit:!1,converter:t.PropertyConverters.Boolean})],zt.prototype,"allowNew",void 0),zt=Mt([t.CustomElement({tagName:t.P+"-suggest",shadow:t.Defaults.USE_SHADOW_ROOT,template:`<div class="${t.PCSS}-relative"><input type="text" class="${t.PCSS}-input" />\n<${t.P}-button clear tab-order="-1"\nclass="button-flat ${t.PCSS}-anim anim-pop anim-sudden anim-quick pos-absolute absolute-right absolute-top display-block ${t.PCSS}-margin margin-0" \n icon-glyph="highlight_off"></${t.P}-button>\n<${t.P}-button \nclass="button-flat icon-rotate ${t.PCSS}-anim anim-pop anim-sudden anim-quick pos-absolute absolute-right absolute-top display-block ${t.PCSS}-margin margin-0" \n icon-glyph="arrow_drop_down" tab-order="-1" toggle></${t.P}-button>\n</div>\n<span class="${t.PCSS}-readonly"><${t.P}-text text="{{ :host.viewValue }}"></${t.P}-text></span>\n<${t.P}-repeater on-${t.Components.RepeaterItemCreateEventName}=":host._itemCreate($event)" on-${t.Components.RepeaterItemRemoveEventName}=":host._itemRemove($event)">\n <ol>\n <${t.P}-template-proxy></${t.P}-template-proxy>\n </ol>\n</${t.P}-repeater><${t.P}-content></${t.P}-content>\n<template>\n <li><${t.P}-span content="{{ $pacem.highlight(^item.viewValue, :host.hint) }}"></${t.P}-span></li>\n</template>`})],zt);var qt=function(e,t,i,a){var s,r=arguments.length,n=r<3?t:null===a?a=Object.getOwnPropertyDescriptor(t,i):a;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(e,t,i,a);else for(var o=e.length-1;o>=0;o--)(s=e[o])&&(n=(r<3?s(n):r>3?s(t,i,n):s(t,i))||n);return r>3&&n&&Object.defineProperty(t,i,n),n};class TagRemoveEvent extends t.CustomTypedEvent{constructor(e){super("tagremove",{index:e})}}class TagAddEvent extends t.CustomTypedEvent{constructor(e){super("tagadd",{value:e})}}let Jt=class PacemTagElement extends t.Components.PacemElement{propertyChangedCallback(e,i,a,s){switch(super.propertyChangedCallback(e,i,a,s),e){case"readonly":let e=!!a;(e?t.Utils.addClass:t.Utils.removeClass)(this,"tag-readonly"),this._btn.disabled=this._btn.hide=e;break;case"tag":t.Utils.removeClass(this,"tag-out")}}_remove(){t.Utils.addClass(this,"tag-out"),t.Utils.addAnimationEndCallback(this,()=>{this.dispatchEvent(new Event("remove"))})}};qt([t.Watch({converter:t.PropertyConverters.String})],Jt.prototype,"tag",void 0),qt([t.Watch({emit:!1,converter:t.PropertyConverters.Boolean})],Jt.prototype,"readonly",void 0),qt([t.ViewChild(t.P+"-button")],Jt.prototype,"_btn",void 0),Jt=qt([t.CustomElement({tagName:t.P+"-tag",shadow:t.Defaults.USE_SHADOW_ROOT,template:`<${t.P}-text text="{{ :host.tag }}"></${t.P}-text>\n <${t.P}-button on-click=":host._remove()"></${t.P}-button>`})],Jt);let Yt=class PacemTagsElement extends PacemDataSourceElement{constructor(){super(!0),this.inputFields=[]}toggleReadonlyView(e){this._suggest.readonly=e,this.querySelector(".tag-new").hidden=e}_tagRemove(e){this.changeHandler(new TagRemoveEvent(e))}_tagAdd(e){this.changeHandler(new TagAddEvent(e))}handleDatasourceMismatch(){}propertyChangedCallback(e,i,a,s){switch(super.propertyChangedCallback(e,i,a,s),e){case"datasource":case"textProperty":this._suggest[e]=a;break;case"valueProperty":if(!t.Utils.isNullOrEmpty(a))throw`Cannot set 'valueProperty' on ${this.constructor.name}s.`;break;case"value":this._tags.datasource=a}}onChange(e){return new Promise((i,a)=>{switch(e.type){case"tagremove":this._justAddedIndex=-1;const a=e.detail.index,s=t.Utils.clone(this.value),r=s.splice(a+1),n=s.splice(0,a);i(this.value=n.concat(r));break;case"tagadd":const o=e.detail.value,l=t.Utils.clone(this.value);if(!t.Utils.isNullOrEmpty(o)&&(this.allowDuplicates||t.Utils.isNullOrEmpty(l&&l.find(e=>this.mapEntityToViewValue(e)==this.mapEntityToViewValue(o))))){let e=(l||[]).concat([o]);i(this.value=e),this._justAddedIndex=this.value.length-1,setTimeout(()=>{this._suggest.focus()},250),this._suggest.blur(),this._suggest.hint="",this._suggest.reset()}break;default:i(this.value)}})}acceptValue(e){}};qt([t.Watch({converter:t.PropertyConverters.String})],Yt.prototype,"hint",void 0),qt([t.Watch({emit:!1,converter:t.PropertyConverters.Boolean})],Yt.prototype,"allowDuplicates",void 0),qt([t.Watch({converter:t.PropertyConverters.Boolean})],Yt.prototype,"allowNew",void 0),qt([t.Watch({converter:t.PropertyConverters.Number})],Yt.prototype,"_justAddedIndex",void 0),qt([t.ViewChild(t.P+"-suggest")],Yt.prototype,"_suggest",void 0),qt([t.ViewChild(t.P+"-repeater."+t.PCSS+"-tags")],Yt.prototype,"_tags",void 0),Yt=qt([t.CustomElement({tagName:t.P+"-tags",shadow:t.Defaults.USE_SHADOW_ROOT,template:`<${t.P}-repeater class="${t.PCSS}-tags">\n <ul class="${t.PCSS}-tags ${t.PCSS}-viewfinder ${t.PCSS}-list list-unstyled list-inline">\n <template>\n <li class="${t.PCSS}-tag">\n <${t.P}-tag on-remove=":host._tagRemove(^index)" css-class="{{ { 'tag-in': :host._justAddedIndex === ^index } }}" tag="{{ :host.mapEntityToViewValue(^item) }}" readonly="{{ :host.readonly }}"></${t.P}-tag>\n </li>\n </template>\n <li class="tag-new">\n <${t.P}-suggest logger="{{ :host.logger }}" placeholder="{{ :host.placeholder }}" allow-new="{{ :host.allowNew }}" class="${t.PCSS}-tags" on-change=":host._tagAdd($this.value)" hint="{{ :host.hint, twoway }}">\n <${t.P}-content></${t.P}-content>\n </${t.P}-suggest>\n </li>\n </ul>\n</${t.P}-repeater>`})],Yt);var Gt=function(e,t,i,a){var s,r=arguments.length,n=r<3?t:null===a?a=Object.getOwnPropertyDescriptor(t,i):a;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(e,t,i,a);else for(var o=e.length-1;o>=0;o--)(s=e[o])&&(n=(r<3?s(n):r>3?s(t,i,n):s(t,i))||n);return r>3&&n&&Object.defineProperty(t,i,n),n};let Kt=class PacemTextAreaElement extends PacemTextualInputElement{constructor(){super(...arguments),this.rows=5,this.cols=50}get preventKeyboardSubmit(){return!0}toggleReadonlyView(e){const i=this._input,a=this._span;t.Utils.isNull(i)||(i.hidden=e),t.Utils.isNull(a)||(a.hidden=!e)}get inputFields(){return t.Utils.isNull(this._input)?[]:[this._input]}propertyChangedCallback(e,t,i,a){super.propertyChangedCallback(e,t,i,a),"rows"!==e&&"cols"!==e||this.inputField.setAttribute(e,i)}};Gt([t.Watch({emit:!1,converter:t.PropertyConverters.Number})],Kt.prototype,"rows",void 0),Gt([t.Watch({emit:!1,converter:t.PropertyConverters.Number})],Kt.prototype,"cols",void 0),Gt([t.ViewChild("textarea")],Kt.prototype,"_input",void 0),Gt([t.ViewChild(`span.${t.PCSS}-readonly`)],Kt.prototype,"_span",void 0),Kt=Gt([t.CustomElement({tagName:t.P+"-textarea",template:`<textarea class="${t.PCSS}-input" pacem></textarea>${E}<span class="${t.PCSS}-readonly"><${t.P}-text text="{{ :host.viewValue }}"></${t.P}-text></span>`,shadow:t.Defaults.USE_SHADOW_ROOT})],Kt);var Xt=function(e,t,i,a){var s,r=arguments.length,n=r<3?t:null===a?a=Object.getOwnPropertyDescriptor(t,i):a;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(e,t,i,a);else for(var o=e.length-1;o>=0;o--)(s=e[o])&&(n=(r<3?s(n):r>3?s(t,i,n):s(t,i))||n);return r>3&&n&&Object.defineProperty(t,i,n),n};let Zt=class PacemMarkdownTextAreaElement extends PacemTextualInputElement{constructor(e=new i.Components.UI.MarkdownService){super(),this._md=e,this.rows=5,this.cols=50,this._keydownHandler=e=>{if(9===e.keyCode){const a=this._input,s=a.value;var i=a.selectionStart;a.value=s.substr(0,i)+" "+s.substr(i),t.preventDefaultHandler(e)}}}toggleReadonlyView(e){t.Utils.isNull(this._input)||(this._input.hidden=e)}get preventKeyboardSubmit(){return!0}get inputFields(){return t.Utils.isNull(this._input)?[]:[this._input]}getViewValue(e){return this._md.toHtml(e)}propertyChangedCallback(e,t,i,a){super.propertyChangedCallback(e,t,i,a),"rows"===e||"cols"===e?this.inputField.setAttribute(e,i):"viewValue"==e&&(this._markdown.innerHTML=i)}viewActivatedCallback(){super.viewActivatedCallback(),this._input.addEventListener("keydown",this._keydownHandler,!1)}disconnectedCallback(){this._input&&this._input.removeEventListener("keydown",this._keydownHandler,!1),super.disconnectedCallback()}};Xt([t.Watch({emit:!1,converter:t.PropertyConverters.Number})],Zt.prototype,"rows",void 0),Xt([t.Watch({emit:!1,converter:t.PropertyConverters.Number})],Zt.prototype,"cols",void 0),Xt([t.ViewChild("textarea")],Zt.prototype,"_input",void 0),Xt([t.ViewChild(`div.${t.PCSS}-readonly`)],Zt.prototype,"_markdown",void 0),Zt=Xt([t.CustomElement({tagName:t.P+"-textarea-markdown",template:`<textarea class="${t.PCSS}-input" pacem></textarea>${E}<div class="${t.PCSS}-readonly ${t.PCSS}-markdown"></div>`,shadow:t.Defaults.USE_SHADOW_ROOT})],Zt);var Qt=Object.freeze({__proto__:null,BASIC_VALIDATOR_TEMPLATE:fe,CHAR_COUNTER_CHILD:E,CONTENTELEMENT_BUTTONCOMMAND_TEMPLATE:V,CalendarDateUnselectEvent:CalendarDateUnselectEvent,get ChangePolicy(){return qe},ContenteditableDOMObserver:ContenteditableDOMObserver,ContenteditableUtils:ContenteditableUtils,DEFAULT_ATTRIBUTION:"",DEFAULT_TILES:"",FileChangeEvent:FileChangeEvent,FileChangeEventName:at,FileUploadEvent:FileUploadEvent,FileUploadEventName:it,FormEventEmitter:FormEventEmitter,FormResetEvent:FormResetEvent,FormResetEventName:v,FormSubmitEvent:FormSubmitEvent,FormSubmitEventName:m,ImageFetchRequestEvent:ImageFetchRequestEvent,ImageFetchRequestEventName:ut,get KnownExecCommand(){return F},get PacemAsyncValidatorElement(){return ke},PacemBaseElement:PacemBaseElement,PacemBaseInputElement:PacemBaseInputElement,PacemBaseValidatorElement:PacemBaseValidatorElement,get PacemBinaryValidatorElement(){return Se},get PacemCalendarMonthPickerElement(){return ie},get PacemCalendarPickerElement(){return re},get PacemCalendarYearPickerElement(){return se},get PacemCharCountElement(){return w},get PacemCharsInputElement(){return Ke},get PacemCheckboxElement(){return le},get PacemCheckboxListElement(){return de},get PacemChildFormElement(){return ue},get PacemChildFormPropagatorElement(){return pe},get PacemColorInputElement(){return Ze},get PacemCompareValidatorElement(){return we},get PacemContenteditableAlignCommandElement(){return Y},PacemContenteditableButtonCommandElement:PacemContenteditableButtonCommandElement,PacemContenteditableCommandElement:PacemContenteditableCommandElement,get PacemContenteditableElement(){return O},get PacemContenteditableExecCommandElement(){return M},get PacemContenteditableHistoryCommandElement(){return H},get PacemContenteditableImageCommandElement(){return I},get PacemContenteditableLinkCommandElement(){return T},get PacemContenteditablePlaceholderElement(){return X},get PacemContenteditableWrapCommandElement(){return Q},get PacemCustomValidatorElement(){return $e},get PacemDataItemElement(){return C},PacemDataSourceElement:PacemDataSourceElement,get PacemDatetimePickerElement(){return ge},get PacemEditImageElement(){return mt},get PacemEmailInputElement(){return et},get PacemFormElement(){return f},get PacemFormFieldElement(){return Oe},PacemFormRelevantElement:PacemFormRelevantElement,get PacemGeolocateElement(){return Ve},get PacemHiddenInputElement(){return ot},get PacemHierarchyElement(){return ze},get PacemImageInputElement(){return vt},PacemItemElement:PacemItemElement,PacemItemsContainerBaseElement:PacemItemsContainerBaseElement,get PacemLatLngElement(){return Nt},get PacemLengthValidatorElement(){return Pe},get PacemMarkdownTextAreaElement(){return Zt},PacemModelElement:PacemModelElement,get PacemNameValueListElement(){return Dt},get PacemNumberInputElement(){return yt},PacemOrdinalInputElement:PacemOrdinalInputElement,get PacemPasswordInputElement(){return _t},get PacemPropertyPickerElement(){return At},get PacemRadioElement(){return Rt},get PacemRadioListElement(){return It},get PacemRangeValidatorElement(){return Ee},get PacemRegexValidatorElement(){return Ce},get PacemRequiredValidatorElement(){return be},get PacemSearchInputElement(){return Ct},get PacemSelectElement(){return Wt},get PacemSliderElement(){return jt},get PacemSnapshotElement(){return ht},get PacemSuggestElement(){return zt},get PacemTagElement(){return Jt},get PacemTagsElement(){return Yt},get PacemTelInputElement(){return Et},get PacemTextAreaElement(){return Kt},get PacemTextInputElement(){return St},PacemTextualInputElement:PacemTextualInputElement,get PacemUploadElement(){return rt},get PacemUrlInputElement(){return $t},Picture:class Picture{},get SnapshotStep(){return dt}}),ei=Object.freeze({__proto__:null,Scaffolding:Qt}),ti=Object.freeze({__proto__:null,Components:ei,Scaffolding:p});e.DeepMerger.merge(ti)}(Pacem,Pacem,Pacem,Pacem);
6
+ !function(e,t,i,a){"use strict";const s="change";class FieldChangeEvent extends t.CustomTypedEvent{constructor(e){super(s,e,{bubbles:!0,cancelable:!1})}}var r;!function(e){e.String="string",e.Number="number",e.Datetime="datetime",e.Boolean="boolean",e.Binary="binary",e.Object="object"}(r||(r={}));class ApiParserBase{async load(e,t){let i=await fetch(e,{mode:"cors",credentials:"omit",headers:t});try{let t=await i.json();return this.parse(t,e)}catch(e){return null}}}const n=/^#\/(definitions|components\/schemas)\/(.+)$/;const o=t.Net.HttpMethod;class SwaggerParser extends ApiParserBase{_findDefinitionName(e){var t=/#\/definitions\/(.+)/.exec(e);return null==t||t.length<2?e:t[1]}parse(e,t){let i=e;"string"==typeof i&&(i=JSON.parse(i));const a=i;let s={};for(let e in a.definitions){s[this._findDefinitionName(e)]=a.definitions[e]}let r="";if(a.host&&a.schemes.length>0)r=a.schemes[0]+"://"+a.host+a.basePath;else if(t){let e=/^(https?):\/\/([^\/]+)/.exec(t);e&&e.length&&(!a.schemes&&e.length>1&&(a.schemes=[e[1]]),!a.host&&e.length>2&&(a.host=e[2],a.basePath=""),r=e[0])}else console.warn("Not able to find a base url from the OpenApi specs.");let n={endpoints:[],definitions:s,baseUrl:r};for(let e in a.paths){let t=a.paths[e];for(let i of[o.Get,o.Delete,o.Post,o.Put]){let s=t[i.toLowerCase()];if(s){let t=this._tryGetEndpoint(a,s,e,i);n.endpoints.push(t)}}}return n}_tryGetEndpoint(e,t,i,a){return{response:this._tryGetResponse(e,t),path:i,method:a,parameters:this._tryGetParameters(e,t)}}_translateType(e,t){switch(e){case"number":case"integer":return r.Number;case"boolean":return r.Boolean;case"string":switch(t){case"date":case"date-time":return r.Datetime;case"byte":return r.Binary;case"binary":throw"Binary octets not supported."}return r.String}return r.String}_tryGetParameters(e,t){return(t.parameters||[]).map(t=>{const i=t;let a={name:i.name,required:i.required||!1},s=t.type;if(t.schema){let i=t;a.type=r.Object;let s=a.fullType=this._findDefinitionName(i.schema.$ref);a.meta=e.definitions[s]}else s&&(a.type=this._translateType(s,t.format));return a})}_tryGetResponse(e,t){let i=t.responses[200];if(!i||!i.schema)return null;let a,s,r=i.schema.type||"object";return i.schema.$ref?(s=this._findDefinitionName(i.schema.$ref),a=e.definitions[s]):(a=i.schema,i.schema.items&&(i.schema.items.hasOwnProperty("$ref")?(s=this._findDefinitionName(i.schema.items.$ref),a=e.definitions[s]):a=i.schema.items)),{type:r,fullType:s,meta:a}}}class OpenApi3Parser extends ApiParserBase{parse(e,t){let i=e;"string"==typeof i&&(i=JSON.parse(i));const a=i,s=[],r=this._gatherDefinitions(new Map,a.components.schemas);for(let e in a.paths)for(let t in a.paths[e]){const i=a.paths[e][t];s.push({path:e,method:t.toUpperCase(),parameters:this._convertToApiParameters(i.parameters),response:this._tryGetResponse(r,i.responses)})}return{endpoints:s,definitions:r,baseUrl:t}}_convertToApiParameters(e=[]){const t=[];for(let i of e){const e=i.schema;"type"in e&&t.push({name:i.name,required:i.required,type:this._translateType(e.type,e.format)})}return t}_translateType(e,t){switch(e){case"number":case"integer":return r.Number;case"boolean":return r.Boolean;case"string":switch(t){case"date":case"date-time":return r.Datetime;case"byte":return r.Binary;case"binary":throw"Binary octets not supported."}return r.String}return r.String}_gatherDefinitions(e,t){const i={};for(let a in t)i[a]=this._findDefinition(e,t,a);return i}_findDefinition(e,t,i){if(e.has(i))return e.get(i);if(i in t){const a=t[i];return e.set(i,a),a}return null}_findDefinitionName(e){var t=/#\/components\/schemas\/(.+)/.exec(e);return null==t||t.length<2?e:t[1]}_tryGetResponse(e,i){let a,s={responses:i}.responses[200];if(t.Utils.isNullOrEmpty(s&&s.content))return null;for(let e in s.content){a=s.content[e].schema;break}let r,n,o="object";return"$ref"in a?(n=this._findDefinitionName(a.$ref),r=e[n]):(o=a.type,r=a,"array"===a.type&&("$ref"in a.items?(n=this._findDefinitionName(a.items.$ref),r=e[n]):r=a.items)),{type:o,fullType:n,meta:r}}}var l=Object.freeze({__proto__:null,get ApiParameterType(){return r},ApiParserBase:ApiParserBase,OpenApi3Parser:OpenApi3Parser,OpenApiParser:class OpenApiParser extends ApiParserBase{constructor(e=new OpenApi3Parser,t=new SwaggerParser){super(),this._openApi3=e,this._swagger=t}parse(e,t){let i=e;"string"==typeof i&&(i=JSON.parse(i));const a=i;return"openapi"in a?this._openApi3.parse(a,t):this._swagger.parse(a,t)}},SwaggerParser:SwaggerParser,getOpenApiDefinition:function(e,t){var i=n.exec(t);return i&&i.length>2?{name:i[2],schema:e.definitions[i[2]]}:null}}),c=function(e,t,i,a){var s,r=arguments.length,n=r<3?t:null===a?a=Object.getOwnPropertyDescriptor(t,i):a;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(e,t,i,a);else for(var o=e.length-1;o>=0;o--)(s=e[o])&&(n=(r<3?s(n):r>3?s(t,i,n):s(t,i))||n);return r>3&&n&&Object.defineProperty(t,i,n),n};const d={display:(e,t,i)=>i[`${e}_${t}`],validator:(e,t,i,a)=>a["validator_"+e+"_"+i]??a["validator_"+e+t+"_"+i],commandTooltip:(e,t)=>t["command_tooltip_"+e]};class Forms{static localizeMetadata(e,t,i){return Forms._localizeMetadata(e,t,i)}static _localizeMetadata(e,i,a,s=""){a=t.Utils.extend({},d,a);for(let r of e.props){if("props"in r&&"object"==typeof r.props&&!t.Utils.isArray(r.props)){const e=s+r.prop+".";r.props=Forms._localizeMetadata(r.props,i,a,e)}const e=r.display=r.display??{},n=s+r.prop;if(e.name=a.display("name",n,i)??e.name,e.watermark=a.display("watermark",n,i)??e.watermark,e.description=a.display("description",n,i)??e.description,!t.Utils.isNullOrEmpty(r.commands))for(let e of r.commands){const s=a.commandTooltip(e.name,i);t.Utils.isNullOrEmpty(s)||(e.tooltip=s)}if(!t.Utils.isNullOrEmpty(r.validators)){const e={};for(let s of r.validators){const r=s.type;if("string"==typeof r){const o=e[r]=(e[r]??-1)+1,l=a.validator(r,o,n,i);t.Utils.isNullOrEmpty(l)||(s.errorMessage=l)}}}}return e}}c([t.Transformer("forms.localizeMetadata")],Forms,"localizeMetadata",null);var h=Object.freeze({__proto__:null,Forms:Forms}),p=Object.freeze({__proto__:null,FieldChangeEvent:FieldChangeEvent,FieldChangeEventName:s,L10n:h,OpenApi:l}),u=function(e,t,i,a){var s,r=arguments.length,n=r<3?t:null===a?a=Object.getOwnPropertyDescriptor(t,i):a;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(e,t,i,a);else for(var o=e.length-1;o>=0;o--)(s=e[o])&&(n=(r<3?s(n):r>3?s(t,i,n):s(t,i))||n);return r>3&&n&&Object.defineProperty(t,i,n),n};const m="submit",v="reset";class FormSubmitEvent extends t.CustomTypedEvent{constructor(e){super(m,e,{bubbles:!0,cancelable:!0})}}class FormResetEvent extends Event{constructor(){super(v,{bubbles:!0,cancelable:!0})}}const g=["download",s,t.CommandEventName],y=!1;class FormEventEmitter{constructor(e){this._element=e,this._itemEmitHandler=e=>{if(this._element.handle(e),e.type===t.CommandEventName){const t=e;this._element.handle(new CustomEvent("item"+t.detail.commandName.toLowerCase(),{detail:t.detail.commandArgument}))}}}start(){g.forEach(e=>this._element.addEventListener(e,this._itemEmitHandler,!1))}stop(){g.forEach(e=>this._element.removeEventListener(e,this._itemEmitHandler,!1))}}class PacemFormRelevantElement extends t.Components.PacemElement{viewActivatedCallback(){super.viewActivatedCallback(),this.form=t.CustomElementUtils.findAncestorOfType(this,f)}}u([t.Watch({converter:t.PropertyConverters.Element})],PacemFormRelevantElement.prototype,"form",void 0);let f=class PacemFormElement extends PacemFormRelevantElement{constructor(){super("form"),this.method=t.Net.HttpMethod.Post,this._emitter=null,this._buttons={submit:void 0,reset:void 0},this.#e=!1,this._keyupHandler=e=>{if(!(13!==e.keyCode||e.shiftKey||e.ctrlKey||e.altKey||e.metaKey)){let i=e.currentTarget.querySelector(t.P+"-button[type=submit]");t.Utils.isNull(i)||!t.Utils.isVisible(i)||i.disabled||i.click()}},this._submit=(e,i)=>{t.Utils.isNull(i)||t.avoidHandler(i),Promise.all(this._validateAllFields()).then(t=>{-1===t.findIndex(e=>!1===e)&&this.submit(e).then(e=>{this.setPristine()},e=>{})})},this._reset=e=>{t.Utils.isNull(e)||t.avoidHandler(e);var i=new FormResetEvent;if(this.dispatchEvent(i),!i.defaultPrevented){for(var a in this._fields){var s=this._fields[a];s instanceof PacemModelElement&&s.reset()}for(var r of this._subForms)r._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()}},this._validatorPropertyChanged=e=>{const t=e.target,i=t.watch;if("invalid"===e.detail.propertyName){let e=this._fields[t.watch];t.invalid?e.valid=!1:this._checkFieldValidity(i)}else this._checkFieldValidity(i)},this.suddenValidation=!0,this.resettable=!0,this._emitter=new FormEventEmitter(this)}propertyChangedCallback(e,i,a,s){super.propertyChangedCallback(e,i,a,s),("method"===e&&!0===this.autogenerate&&!t.Utils.isNullOrEmpty(this.metadata)||"metadata"===e&&!0===this.autogenerate||"autogenerate"===e&&!0===a&&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(){const e="_"+t.Utils.uniqueCode(),i=this.id=this.id||e,a="fetch"+e,s=document.createElement("form");s.id="form"+e,s.className=t.PCSS+"-form",s.setAttribute("pacem",""),s.setAttribute("novalidate","");const r=`<${t.P}-repeater datasource="{{ #${i}.metadata && (#${i}.metadata.props || #${i}.metadata) }}">\n <${t.P}-panel css="{{ #${i}.metadata.display && #${i}.metadata.display.css }}" css-class="{{ (#${i}.metadata.display && #${i}.metadata.display.cssClass || []).concat(#${i}.suddenValidation ? [] : ['lazy-validation']) }}" class="${t.PCSS}-animatable-list ${t.PCSS}-list-appear">\n <template>\n <${t.P}-form-field fetch-credentials="{{ #${i}.fetchCredentials }}" fetch-headers="{{ #${i}.fetchHeaders }}"\n logger="{{ #${i}.logger }}" entity="{{ #${i}.entity, twoway }}" \n metadata="{{ ^item }}" readonly="{{ #${i}.readonly || ^item.isReadOnly }}"></${t.P}-form-field>\n </template>\n </${t.P}-panel>\n</${t.P}-repeater>\n<${t.P}-fetch logger="{{ #${i}.logger }}" id="${a}" method="${this.method}" credentials="{{ #${i}.fetchCredentials }}" headers="{{ #${i}.fetchHeaders }}"></${t.P}-fetch> \n<div class="${t.PCSS}-buttonset buttons">\n <div class="buttonset-left">\n <${t.P}-button logger="{{ #${i}.logger }}" on-click="#${i}._submit(#${i}.fetcher || #${a}, $event)" type="submit" hide="{{ #${i}.readonly || $pacem.isNullOrEmpty(#${i}.action) || !$pacem.isNull(#${i}.form) }}"\nclass="button primary button-size size-small"\ncss-class="{{ {'buttonset-last': !#${i}.resettable || !#${i}.dirty || !$pacem.isNull(#${i}.form) } }}" \ndisabled="{{ (#${i}.suddenValidation && (!(#${i}.valid && #${i}.dirty))) || #${i}.fetching }}">\n <${t.P}-panel class="submit-spinner ${t.PCSS}-anim anim-pop" hide="{{ !#${i}.fetching }}"><i class="${t.PCSS}-icon ${t.PCSS}-anim anim-rotate rotate-uniform display-block">refresh</i></${t.P}-panel>\n <${t.P}-text text="{{ #${i}.submitCaption || 'OK' }}"></${t.P}-text>\n </${t.P}-button>\n <${t.P}-button logger="{{ #${i}.logger }}" on-click="#${i}._reset($event)" type="reset" class="button button-size size-small" css-class="{{ {'buttonset-first': #${i}.readonly || $pacem.isNullOrEmpty(#${i}.action) || !$pacem.isNull(#${i}.form)} }}" hide="{{ !#${i}.resettable || #${i}.readonly || !#${i}.dirty || !$pacem.isNull(#${i}.form) }}" disabled="{{ #${i}.fetching }}">\n <${t.P}-text text="{{ #${i}.resetCaption || 'Reset' }}"></${t.P}-text>\n </${t.P}-button>\n</div></div>`;s.innerHTML=r,this.innerHTML="",this.appendChild(s),s.addEventListener("submit",t.avoidHandler,!1);const n=this._buttons,o=this._buttons={submit:s.lastElementChild.firstElementChild.firstElementChild,reset:s.lastElementChild.firstElementChild.lastElementChild};this.dispatchEvent(new t.PropertyChangeEvent({propertyName:"formButtons",currentValue:o,oldValue:n}))}get formButtons(){return this._buttons}#e;get fetching(){return this.#e}submit(e){return new Promise((i,a)=>{t.Utils.isNull(e)&&a("Fetcher cannot be null while submitting a form."),this._submitInternally(e).then(e=>{this.dispatchEvent(new CustomEvent("success",{detail:e})),i(e)},e=>{e!==y&&this.dispatchEvent(new CustomEvent("fail",{detail:e})),a(e)})})}reset(){this._reset()}_submitInternally(e,i){if(t.Utils.isNull(e))throw"Fetcher cannot be null while submitting a form.";var a=t.DeferPromise.defer();const s=this.entity,r=this.entityName;var n={};t.Utils.isNullOrEmpty(r)?n=s:n[r]=s;i={parameters:n,fields:this._getAllFields()};var o=new FormSubmitEvent(i);if(this.dispatchEvent(o),o.defaultPrevented)a.reject(y);else{e.parameters=t.Utils.extend({},o.detail.parameters);const i=n=>{e.removeEventListener(t.Net.FetchSuccessEventName,i,!1),e.removeEventListener(t.Net.FetchErrorEventName,r,!1);const o=n.detail;if(t.Net.Fetcher.isEmpty(o)&&(e.removeEventListener(t.Net.FetchResultEventName,s,!1),this.success=!0,a.resolve({})),205===o.status)this._reset()},s=i=>{e.removeEventListener(t.Net.FetchResultEventName,s,!1);var r=i.detail;"object"==typeof r&&r.hasOwnProperty("success")?!0===r.success?(this.success=!0,a.resolve(r.result||{})):(this.fail=!0,a.reject(r.error)):(this.success=!0,a.resolve(r))},r=n=>{e.removeEventListener(t.Net.FetchSuccessEventName,i,!1),e.removeEventListener(t.Net.FetchResultEventName,s,!1),e.removeEventListener(t.Net.FetchErrorEventName,r,!1),this.fail=!0;const o=n.detail;a.reject(o)},n=i=>{if("fetching"===i.detail.propertyName)!0===i.detail.currentValue?(t.Utils.addClass(this,t.PCSS+"-fetching"),this.#e=!0,this.dispatchEvent(new t.PropertyChangeEvent({currentValue:!0,oldValue:!1,propertyName:"fetching"}))):(this.#e=!1,this.dispatchEvent(new t.PropertyChangeEvent({currentValue:!1,oldValue:!0,propertyName:"fetching"})),t.Utils.removeClass(this,t.PCSS+"-fetching"),e.removeEventListener(t.PropertyChangeEventName,n,!1))};e.addEventListener(t.PropertyChangeEventName,n,!1),e.addEventListener(t.Net.FetchSuccessEventName,i,!1),e.addEventListener(t.Net.FetchResultEventName,s,!1),e.addEventListener(t.Net.FetchErrorEventName,r,!1),t.Utils.isNullOrEmpty(this.action)||(e.url=this.action),e instanceof t.Components.PacemFetchElement&&!e.autofetch&&e.fetch(),this.success=this.fail=!1}return a.promise}_getAllFields(e={}){for(var i of(t.Utils.extend(e,this._fields),this._subForms))i._getAllFields(e);return e}apply(e){if(!t.Utils.isNullOrEmpty(e)){this.entity=t.Utils.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,...i){const a=!t.Utils.isEmpty(i);for(let t in this._fields)if(!a||i.indexOf(t)>=0){const i=this._fields[t];i instanceof PacemModelElement&&(e?i.setDirty():i.setPristine())}for(let t of this._subForms)e?t.setDirty(...i):t.setPristine(...i)}_checkFieldValidity(e){return this.suddenValidation?e in this._fields?this._validateField(e,!1):Promise.resolve(!1):Promise.resolve(null)}validate(e){return t.Utils.isNullOrEmpty(e)?Promise.all(this._validateAllFields()).then(e=>!e.some(e=>!1===e)):this._validateField(e,!1)}_validateAllFields(e=!0){const t=[];for(let i in this._fields)t.push(this._validateField(i,e));for(let i of this._subForms)Array.prototype.push.apply(t,i._validateAllFields(e));return t}_validateField(e,i){return new Promise((a,s)=>{var r=this._fields[e];if(r){var n=this._validators[r.name];n&&n.length>0?(this.log(t.Logging.LogLevel.Log,`Computing "${r.name}" validity.`),Promise.all(n.map(e=>e.validate(r.value).then(t=>!(e.invalid=!t)))).then(e=>{let s=!0;for(var n of e)if(!1===n){s=!1,i&&r.setDirty();break}this.log(t.Logging.LogLevel.Log,`Property "${r.name}" turns out to be ${s?"":"not "}valid.`),a(r.valid=s)})):(this.log(t.Logging.LogLevel.Log,`Property "${r.name}" has no validators.`),a(r.valid=!0))}else this.log(t.Logging.LogLevel.Log,`Property "${e}" has no fields in this form.`),a(!0)})}_checkDirtyness(){let e=!1;for(var t in this._fields)if(!0===this._fields[t].dirty){e=!0;break}if(!1===e)for(var i of this._subForms)if(i.dirty){e=!0;break}this.dirty=e}_checkValidity(){let e=!0;for(var i in this._fields)if(this.log(t.Logging.LogLevel.Log,`Checking "${i}" validity.`),!1===this._fields[i].valid){this.log(t.Logging.LogLevel.Log,`"${i}" is not valid.`),e=!1;break}if(!0===e)for(var a of this._subForms)if(!a.valid){e=!1;break}this.valid=e}registerSubForm(e){let i=this._subForms;-1==i.indexOf(e)&&(e.addEventListener(t.PropertyChangeEventName,this._fieldPropertyChanged,!1),i.push(e),this._checkValidity(),this._checkDirtyness())}unregisterSubForm(e){let i=this._subForms,a=i.indexOf(e);a>=0&&(e.removeEventListener(t.PropertyChangeEventName,this._fieldPropertyChanged,!1),i.splice(a,1),this._checkValidity(),this._checkDirtyness())}registerField(e,i){var a=this._fields;a[e]!=i&&(this.unregisterField(e,!1),a[e]=i,this.log(t.Logging.LogLevel.Log,`Registering "${e}" field.`),i instanceof HTMLElement&&i.addEventListener(t.PropertyChangeEventName,this._fieldPropertyChanged,!1),this._checkFieldValidity(e),this._checkDirtyness())}unregisterField(e,i=!0){var a=this._fields,s=a[e];s instanceof HTMLElement&&s.removeEventListener(t.PropertyChangeEventName,this._fieldPropertyChanged,!1),delete a[e],s&&!0===i&&(this._checkValidity(),this._checkDirtyness())}registerValidator(e,i){var a=this._validators[e]=this._validators[e]||[];-1==a.indexOf(i)&&(a.push(i),i instanceof HTMLElement&&i.addEventListener(t.PropertyChangeEventName,this._validatorPropertyChanged,!1),this.log(t.Logging.LogLevel.Log,`Calling "${e}" validity check after validator registration.`),this._checkFieldValidity(e))}unregisterValidator(e,t){this._unregisterValidator(e,t,!0)}_unregisterValidator(e,i,a){var s=this._validators[e]=this._validators[e]||[],r=s.indexOf(i);r>=0&&(i instanceof HTMLElement&&i.removeEventListener(t.PropertyChangeEventName,this._validatorPropertyChanged,!1),s.splice(r,1),a&&this._checkFieldValidity(e))}};u([t.Watch({emit:!1,converter:t.PropertyConverters.Element})],f.prototype,"fetcher",void 0),u([t.Watch({emit:!1,converter:t.PropertyConverters.String})],f.prototype,"fetchCredentials",void 0),u([t.Watch({emit:!1,converter:t.PropertyConverters.Json})],f.prototype,"fetchHeaders",void 0),u([t.Watch({reflectBack:!0,converter:t.PropertyConverters.String})],f.prototype,"method",void 0),u([t.Watch({reflectBack:!0,converter:t.PropertyConverters.String})],f.prototype,"submitCaption",void 0),u([t.Watch({reflectBack:!0,converter:t.PropertyConverters.String})],f.prototype,"resetCaption",void 0),u([t.Debounce(100)],f.prototype,"_buildUpForm",null),u([t.Watch({reflectBack:!0,converter:t.PropertyConverters.Boolean})],f.prototype,"valid",void 0),u([t.Watch({reflectBack:!0,converter:t.PropertyConverters.Boolean})],f.prototype,"dirty",void 0),u([t.Watch({reflectBack:!0,converter:t.PropertyConverters.Boolean})],f.prototype,"readonly",void 0),u([t.Watch({converter:t.PropertyConverters.Boolean})],f.prototype,"success",void 0),u([t.Watch({converter:t.PropertyConverters.Boolean})],f.prototype,"fail",void 0),u([t.Watch({converter:t.PropertyConverters.Json})],f.prototype,"entity",void 0),u([t.Watch({emit:!1,converter:t.PropertyConverters.String})],f.prototype,"entityName",void 0),u([t.Watch()],f.prototype,"metadata",void 0),u([t.Watch({emit:!1,converter:t.PropertyConverters.Boolean})],f.prototype,"autogenerate",void 0),u([t.Watch({converter:t.PropertyConverters.Boolean})],f.prototype,"suddenValidation",void 0),u([t.Watch({emit:!1,converter:t.PropertyConverters.Boolean})],f.prototype,"resettable",void 0),u([t.Watch({converter:t.PropertyConverters.String})],f.prototype,"action",void 0),f=u([t.CustomElement({tagName:t.P+"-form"})],f);var _=function(e,t,i,a){var s,r=arguments.length,n=r<3?t:null===a?a=Object.getOwnPropertyDescriptor(t,i):a;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(e,t,i,a);else for(var o=e.length-1;o>=0;o--)(s=e[o])&&(n=(r<3?s(n):r>3?s(t,i,n):s(t,i))||n);return r>3&&n&&Object.defineProperty(t,i,n),n};const b="pacem:model:original-value";class PacemModelElement extends PacemFormRelevantElement{viewActivatedCallback(){super.viewActivatedCallback(),this._registerFieldConditionally(),this._setAsOriginalValue(this.value)}_registerFieldConditionally(){const e=this.name,i=this.form;if(!(t.Utils.isNullOrEmpty(e)||t.Utils.isNull(i)||this.hasAttribute("autobind")&&("off"===this.getAttribute("autobind")||"false"===this.getAttribute("autobind"))||(i.registerField(e,this),this.hasAttribute("value")))){const a=i.id=i.id||"frm_"+t.Utils.uniqueCode();this.setAttribute("value",`{{ #${a}.entity.${e}, twoway }}`)}}propertyChangedCallback(e,i,a,s){switch(super.propertyChangedCallback(e,i,a,s),e){case"value":this.viewValue=this.getViewValue(a);break;case"valid":a?t.Utils.removeClass(this,t.PCSS+"-invalid"):t.Utils.addClass(this,t.PCSS+"-invalid");break;case"dirty":a?t.Utils.addClass(this,t.PCSS+"-dirty"):t.Utils.removeClass(this,t.PCSS+"-dirty");break;case"name":let e=this.form;null!=e&&i&&e.unregisterField(i),this._registerFieldConditionally();break;case"form":let s=this.name;t.Utils.isNullOrEmpty(s)||null!=i&&i.unregisterField(s),this._registerFieldConditionally()}}disconnectedCallback(){let e=this.name,i=this.form;t.Utils.isNullOrEmpty(e)||t.Utils.isNull(i)||i.unregisterField(e),super.disconnectedCallback()}get originalValue(){return t.CustomElementUtils.getAttachedPropertyValue(this,b)}_setAsOriginalValue(e){t.CustomElementUtils.setAttachedPropertyValue(this,b,e)}reset(){this.value=this.originalValue,this.dirty=!1}setPristine(){this._setAsOriginalValue(this.value),this.dirty=!1}setDirty(){this.dirty=!0}}_([t.Watch({converter:t.PropertyConverters.String})],PacemModelElement.prototype,"viewValue",void 0),_([t.Watch({converter:{convert:(e,t)=>t instanceof PacemModelElement?t.convertValueAttributeToProperty(e):e,convertBack:e=>e.toString()}})],PacemModelElement.prototype,"value",void 0),_([t.Watch({converter:t.PropertyConverters.Boolean})],PacemModelElement.prototype,"dirty",void 0),_([t.Watch({converter:t.PropertyConverters.Boolean})],PacemModelElement.prototype,"valid",void 0),_([t.Watch({converter:t.PropertyConverters.String})],PacemModelElement.prototype,"name",void 0);class PacemBaseElement extends PacemModelElement{constructor(){super(...arguments),this.focusHandler=e=>{const i=(e=!0)=>{t.Utils.hasClass(this.parentElement,"."+t.PCSS+"-fieldgroup")&&(e?t.Utils.addClass:t.Utils.removeClass).apply(this,[this.parentElement,t.PCSS+"-focus"])};switch(e.type){case"focus":t.Utils.addClass(this,t.PCSS+"-focus"),i(),this._preFocusValue=this.value;break;case"blur":t.Utils.removeClass(this,t.PCSS+"-focus"),i(!1)}e.bubbles?this.emit(e):this.dispatchEvent(new FocusEvent(e.type))},this.changeHandler=e=>{const t=this.value;this.onChange(e).then(e=>{this.compareValuePropertyValues(t,e)||(this.dispatchEvent(new FieldChangeEvent({fieldName:this.name,oldValue:t,currentValue:e,firstChange:!this.dirty})),this.dirty=!0)},e=>{})},this.keydownHandler=e=>{t.stopPropagationHandler(e)},this.keyupHandler=e=>{switch(e.keyCode){case 27:t.stopPropagationHandler(e),this.compareValuePropertyValues(this.originalValue,this._preFocusValue)?this.reset():this.value=this._preFocusValue,this.blur();break;case 13:this.preventKeyboardSubmit&&t.stopPropagationHandler(e)}}}compareValuePropertyValues(e,i){return t.DefaultComparer(e,i)}get preventKeyboardSubmit(){return!1}propertyChangedCallback(e,i,a,s){switch(super.propertyChangedCallback(e,i,a,s),e){case"required":case"disabled":case"autofocus":case"placeholder":case"readonly":for(let t of this.inputFields)a?t.setAttribute(e,a):t.removeAttribute(e);break;case"tabOrder":for(let e of this.inputFields)e.setAttribute("tabindex",a);break;case"value":this.acceptValue(a)}if("required"===e||"disabled"===e||"readonly"===e){let i=`${t.PCSS}-${e}`;a?t.Utils.addClass(this,i):t.Utils.removeClass(this,i)}"readonly"===e?this.toggleReadonlyView(a):"required"===e?this.aria.attributes.set("required",!!a+""):"valid"===e&&this.aria.attributes.set("invalid",(!a&&!!this.dirty)+"")}registerInputFields(e=this.inputFields){t.Utils.isNull(e)||t.Utils.isArray(e)||(e=[e]);for(let i of e)i.addEventListener("focus",this.focusHandler,!1),i.addEventListener("blur",this.focusHandler,!1),i.addEventListener("change",this.changeHandler,!1),i.addEventListener("keydown",this.keydownHandler,!1),i.addEventListener("keyup",this.keyupHandler,!1),i.addEventListener("mousedown",t.stopPropagationHandler,!1),i.addEventListener("touchstart",t.stopPropagationHandler,{passive:!1,capture:!1})}unregisterInputFields(e=this.inputFields){t.Utils.isNull(e)||t.Utils.isArray(e)||(e=[e]);for(let i of e)t.Utils.isNull(i)||(i.removeEventListener("touchstart",t.stopPropagationHandler,{capture:!1}),i.removeEventListener("keydown",this.keydownHandler,!1),i.removeEventListener("keyup",this.keyupHandler,!1),i.removeEventListener("mousedown",t.stopPropagationHandler,!1),i.removeEventListener("change",this.changeHandler,!1),i.removeEventListener("focus",this.focusHandler,!1),i.removeEventListener("blur",this.focusHandler,!1))}viewActivatedCallback(){if(super.viewActivatedCallback(),this.toggleReadonlyView(this.readonly||!1),!t.Utils.isNullOrEmpty(this.id)){const 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(){const e=this.inputFields;e&&e.length&&e[0].focus()}blur(){const e=this.inputFields;if(!t.Utils.isNullOrEmpty(e))for(let t of e)t.blur()}}_([t.Watch({converter:t.PropertyConverters.Boolean})],PacemBaseElement.prototype,"required",void 0),_([t.Watch({converter:t.PropertyConverters.Boolean})],PacemBaseElement.prototype,"autofocus",void 0),_([t.Watch({converter:t.PropertyConverters.Boolean})],PacemBaseElement.prototype,"readonly",void 0),_([t.Watch({converter:t.PropertyConverters.String})],PacemBaseElement.prototype,"name",void 0),_([t.Watch({converter:t.PropertyConverters.String})],PacemBaseElement.prototype,"placeholder",void 0);class PacemItemElement extends t.Components.PacemElement{#t;findContainer(){return t.CustomElementUtils.findAncestor(this,e=>e instanceof PacemItemsContainerBaseElement)}get container(){return this.#t}viewActivatedCallback(){super.viewActivatedCallback();const e=this.#t=this.findContainer();t.Utils.isNull(e)||e.register(this)}disconnectedCallback(){t.Utils.isNull(this.#t)||this.#t.unregister(this),super.disconnectedCallback()}}class PacemItemsContainerBaseElement extends PacemBaseElement{register(e){let i=!0;return t.Utils.isNull(this.items)?this.items=[e]:-1===this.items.indexOf(e)?this.items.push(e):i=!1,i}unregister(e){const i=!t.Utils.isNull(this.items)&&this.items.indexOf(e);return i>=0&&(this.items.splice(i,1)[0],!0)}}_([t.Watch()],PacemItemsContainerBaseElement.prototype,"items",void 0);let C=class PacemDataItemElement extends PacemItemElement{};_([t.Watch({converter:{convert:(e,i)=>{if("true"===e)return!0;if("false"===e)return!1;let a=parseFloat(e);if(!isNaN(a))return a;let s=t.Utils.Dates.parse(e);return t.Utils.Dates.isDate(s)?s:e},convertBack:e=>e.toString()}})],C.prototype,"value",void 0),_([t.Watch({converter:t.PropertyConverters.String})],C.prototype,"label",void 0),_([t.Watch({converter:t.PropertyConverters.Boolean})],C.prototype,"disabled",void 0),C=_([t.CustomElement({tagName:t.P+"-data-item"})],C);class PacemDataSourceElement extends PacemItemsContainerBaseElement{constructor(e=!1){super(),this.multipleChoice=e,this._itemPropertyChangedHandler=e=>{this.databind()}}register(e){const i=super.register(e);return i&&e.addEventListener(t.PropertyChangeEventName,this._itemPropertyChangedHandler,!1),i}unregister(e){const i=super.register(e);return i&&e.removeEventListener(t.PropertyChangeEventName,this._itemPropertyChangedHandler,!1),i}buildAdaptedDatasource(e=this.datasource){return e&&e.map(e=>this.mapEntityToItem(e))}databind(e=this.buildAdaptedDatasource(this.datasource)){if(t.Utils.isNull(e)&&t.Utils.isNull(this.adaptedDatasource))return;const i=this.adaptedDatasource=e||[];t.Utils.isNullOrEmpty(i.filter(e=>this.isDataSourceItemSelected(e)))&&this.handleDatasourceMismatch(i)}handleDatasourceMismatch(e){this.value=void 0}isItemSelected(e,i=this.value){if(t.Utils.isNullOrEmpty(i))return!1;const a=this.mapEntityToValue(e),s=this.compareBy;return this.multipleChoice&&t.Utils.isArray(i)?!t.Utils.isNull(i.find(e=>e==a||"object"==typeof e&&!t.Utils.isNullOrEmpty(s)&&s in a&&s in e&&a[s]==e[s])):!this.multipleChoice&&(i==a||"object"==typeof i&&!t.Utils.isNullOrEmpty(s)&&s in a&&s in i&&a[s]==i[s])}isDataSourceItemSelected(e,i=this.value){if(t.Utils.isNullOrEmpty(i))return!1;if(e.disabled)return!1;const a=this.compareBy;if(this.multipleChoice&&t.Utils.isArray(i)){let s=i.find(i=>i==e.value||"object"==typeof i&&!t.Utils.isNullOrEmpty(a)&&a in i&&!t.Utils.isNullOrEmpty(e.value)&&a in e.value&&i[a]==e.value[a]);return!t.Utils.isNull(s)}return!this.multipleChoice&&!t.Utils.isNullOrEmpty(e.value)&&(i==e.value||"object"==typeof i&&!t.Utils.isNullOrEmpty(a)&&a in i&&!t.Utils.isNullOrEmpty(e.value)&&a in e.value&&i[a]==e.value[a])}mapEntityToValue(e){if(null==e)throw"entity cannot be null";if(e instanceof C)return e.value;let t,i=e;return(t=this.valueProperty)&&(i=e[t]),i}mapEntityToViewValue(e){if(null==e)throw"entity cannot be null";if(e instanceof C)return e.label||e.value;let t,i=e.toString();return(t=this.textProperty)&&(i=e[t]),i}mapEntityToItem(e){if(null==e)throw"entity cannot be null";if(e instanceof C)return{value:e.value,viewValue:e.label||e.value,disabled:e.disabled,data:e};let i=!1;const a=this.disabledProperty;return t.Utils.isNullOrEmpty(a)||(i=e[a]||!1),{value:this.mapEntityToValue(e),viewValue:this.mapEntityToViewValue(e),disabled:i,data:e}}propertyChangedCallback(e,t,i,a){switch(super.propertyChangedCallback(e,t,i,a),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})}}getViewValue(e){if(!t.Utils.isNullOrEmpty(this.datasource))return this.datasource.filter(e=>this.isItemSelected(e)).map(e=>this.mapEntityToViewValue(e)).join(", ")}convertValueAttributeToProperty(e){return this.multipleChoice?e.split(",").map(e=>e.trim()):e}compareValuePropertyValues(e,i){return t.DefaultComparer(e,i)}}_([t.Watch({emit:!1,converter:t.PropertyConverters.Json})],PacemDataSourceElement.prototype,"datasource",void 0),_([t.Watch({emit:!1,converter:t.PropertyConverters.String})],PacemDataSourceElement.prototype,"valueProperty",void 0),_([t.Watch({emit:!1,converter:t.PropertyConverters.String})],PacemDataSourceElement.prototype,"textProperty",void 0),_([t.Watch({emit:!1,converter:t.PropertyConverters.String})],PacemDataSourceElement.prototype,"disabledProperty",void 0),_([t.Watch({emit:!1,converter:t.PropertyConverters.String})],PacemDataSourceElement.prototype,"compareBy",void 0),_([t.Watch({converter:t.PropertyConverters.Json})],PacemDataSourceElement.prototype,"adaptedDatasource",void 0),_([t.Debounce(!0)],PacemDataSourceElement.prototype,"databind",null);var P=function(e,t,i,a){var s,r=arguments.length,n=r<3?t:null===a?a=Object.getOwnPropertyDescriptor(t,i):a;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(e,t,i,a);else for(var o=e.length-1;o>=0;o--)(s=e[o])&&(n=(r<3?s(n):r>3?s(t,i,n):s(t,i))||n);return r>3&&n&&Object.defineProperty(t,i,n),n};const E=`<${t.P}-char-count hide="{{ :host.readonly || !(:host.minlength > 0 || :host.maxlength > 0) }}" minlength="{{ :host.minlength }}" maxlength="{{ :host.maxlength }}" string="{{ :host.value }}"></${t.P}-char-count>`;let w=class PacemCharCountElement extends t.Components.PacemElement{_isValid(e){const t=this._length(e);return!(this.minlength>0&&t<this.minlength)&&!(this.maxlength>0&&t>this.maxlength)}_length(e){return e&&e.length||0}};P([t.Watch({converter:t.PropertyConverters.Number})],w.prototype,"minlength",void 0),P([t.Watch({converter:t.PropertyConverters.Number})],w.prototype,"maxlength",void 0),P([t.Watch({converter:t.PropertyConverters.String})],w.prototype,"string",void 0),w=P([t.CustomElement({tagName:t.P+"-char-count",shadow:t.Defaults.USE_SHADOW_ROOT,template:`<${t.P}-panel class="${t.PCSS}-char-count" css-class="{{ {'valid': :host._isValid(:host.string), 'invalid': !:host._isValid(:host.string) } }}">\n <${t.P}-span hide="{{ !(:host.minlength > 0) }}" class="${t.PCSS}-char-min" content="{{ :host.minlength }}"></${t.P}-span>\n <${t.P}-span class="${t.PCSS}-char-curr" content="{{ :host._length(:host.string) || '0' }}"></${t.P}-span>\n <${t.P}-span hide="{{ !(:host.maxlength > 0) }}" class="${t.PCSS}-char-max" content="{{ :host.maxlength }}"></${t.P}-span>\n</${t.P}-panel>`})],w);var S=function(e,t,i,a){var s,r=arguments.length,n=r<3?t:null===a?a=Object.getOwnPropertyDescriptor(t,i):a;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(e,t,i,a);else for(var o=e.length-1;o>=0;o--)(s=e[o])&&(n=(r<3?s(n):r>3?s(t,i,n):s(t,i))||n);return r>3&&n&&Object.defineProperty(t,i,n),n};const k="execute",$="<p><br></p>";class ContenteditableChangeEvent extends t.CustomTypedEvent{constructor(e){super("contenteditablechange",{html:e})}}class PacemContenteditableCommandElement extends PacemItemElement{constructor(){super(...arguments),this._containerPropChangeHandler=e=>{const t=e.detail;this.containerPropertyChangedCallback(t.propertyName,t.oldValue,t.currentValue,t.firstChange)}}execCommand(...e){const t=this;t.disabled||t.exec.apply(t,e).then(e=>{t.dispatchEvent(new Event(k))},e=>{console.error(e)})}connectedCallback(){super.connectedCallback(),t.Utils.addClass(this,t.PCSS+"-contenteditable-command")}viewActivatedCallback(){super.viewActivatedCallback();const e=this.container;t.Utils.isNull(e)||(this.contentElement=e.contentElement,e.addEventListener(t.PropertyChangeEventName,this._containerPropChangeHandler,!1))}disconnectedCallback(){const e=this.container;t.Utils.isNull(e)||e.removeEventListener(t.PropertyChangeEventName,this._containerPropChangeHandler,!1),super.disconnectedCallback()}containerPropertyChangedCallback(e,t,i,a){"range"===e&&(this.range=i)}}function U(e){return e instanceof PacemContenteditableCommandElement&&"pasteCallback"in e&&"function"==typeof e.pasteCallback}function N(e){return e?.nodeType==Node.ELEMENT_NODE}S([t.Watch()],PacemContenteditableCommandElement.prototype,"range",void 0),S([t.Watch()],PacemContenteditableCommandElement.prototype,"contentElement",void 0);let O=class PacemContenteditableElement extends PacemItemsContainerBaseElement{constructor(){super("rich text editor"),this._focusHandler=e=>{this._ensureInteractiveMarkup()},this._blurHandler=e=>{const t=this._container;for(let e of this.items)e.cleanUp(t);this._checkChangedHandler(e)},this._pasteHandler=e=>{e.preventDefault();const i=this.range,a=e.clipboardData.files;if(t.Utils.isNull(i)||0!==a.length)for(let t=0;t<a.length;t++){const i=a.item(t);for(let t of this.items)U(t)&&t.pasteCallback(i).then(t=>this._checkChangedHandler(e),e=>{})}else{const t=e.clipboardData.getData("text/plain").replace(/</gi,"&lt;").replace(/\n/gi,"<br />"),a=i.createContextualFragment(t);i.deleteContents(),i.insertNode(a),this._checkChangedHandler(e)}},this._shortcutHandler=e=>{e.ctrlKey&&-1===["C","V","X"].indexOf(e.key?.toUpperCase())&&e.preventDefault()},this._inputHandler=e=>{this._fixRangeMarkup(),this._checkChangedHandler(e)},this._checkChangedHandler=e=>{const i=this._container,a=i.innerHTML;var s=a;(t.Utils.isNullOrEmpty(a)||"<br>"===a||a===$)&&(i.innerHTML=$,s=""),s!=this.value&&(this.changeHandler(new ContenteditableChangeEvent(s)),this.value!=this.#i.current&&this._updateHistory()),this._fireHistoryChange()},this._selectionChangeHandler=e=>{const t=document.getSelection();if(t&&t.anchorNode&&this._container.contains(t.anchorNode)){const e=t.getRangeAt(0);this.range=e.cloneRange()}else this.range=null}}#i;get history(){return this.#i}reset(){super.reset(),this.#i.reset(),this._fireHistoryChange()}_fireHistoryChange(){const e=this.#i;this.dispatchEvent(new t.PropertyChangeEvent({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(k,this._checkChangedHandler,!1),!0)}unregister(e){return!!super.unregister(e)&&(e.removeEventListener(k,this._checkChangedHandler,!1),!0)}get preventKeyboardSubmit(){return!0}get inputFields(){return[this._container]}get contentElement(){return this._container}onChange(e){return new Promise((i,a)=>{if(t.CustomEventUtils.isInstanceOf(e,ContenteditableChangeEvent)){i(this.value=e.detail.html),this._selectionChangeHandler(e)}else i(this.value)})}_fixRangeMarkup(){const e=this.range,i=e=>{e.childNodes.forEach(e=>i(e)),N(e)&&"SPAN"===e.tagName?Element.prototype.replaceWith.apply(e,Array.from(e.childNodes)):e instanceof HTMLElement&&e.removeAttribute("style")};t.Utils.isNull(e)||(e=>{let t=e;N(t)||(t=e.parentElement),i(t)})(e.commonAncestorContainer)}_ensureInteractiveMarkup(){const e=this._container,i=e.childNodes,a=i.length;if(0==a||e.innerHTML===$)e.innerHTML=$;else{let e,s;const r=e=>{s.setEndAfter(e);const t=document.createElement("p");s.surroundContents(t)};for(let n=0;n<a;n++)e=i.item(n),e instanceof Element?s&&(r(e.previousSibling),s=null):t.Utils.isNull(s)&&(s=document.createRange(),s.setStartBefore(e));t.Utils.isNull(s)||r(e)}}_updateHistory(){this.#i.push(this.value),this._fireHistoryChange()}acceptValue(e){t.Utils.isNull(this._container)||e==this._container.innerHTML||(this._container.innerHTML=e)}viewActivatedCallback(){super.viewActivatedCallback();const t=this._container;this.#i=new e.HistoryService(this.value),t.addEventListener("blur",this._blurHandler,!1),t.addEventListener("keydown",this._shortcutHandler,!1),t.addEventListener("focus",this._focusHandler,!1),t.addEventListener("input",this._inputHandler,!1),t.addEventListener("paste",this._pasteHandler,!1),document.addEventListener("selectionchange",this._selectionChangeHandler,!1)}disconnectedCallback(){document.removeEventListener("selectionchange",this._selectionChangeHandler,!1);const e=this._container;t.Utils.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}};S([t.ViewChild("div[pacem]")],O.prototype,"_container",void 0),S([t.ViewChild("div[dashboard]")],O.prototype,"_dashboard",void 0),S([t.Watch()],O.prototype,"range",void 0),S([t.Debounce(500)],O.prototype,"_updateHistory",null),O=S([t.CustomElement({tagName:t.P+"-contenteditable",shadow:t.Defaults.USE_SHADOW_ROOT,template:`<div class="${t.PCSS}-contenteditable ${t.PCSS}-viewfinder">\n <div contenteditable="true" role="presenter" pacem></div>\n</div>${E}\n<div dashboard>\n <${t.P}-content></${t.P}-content>\n</div>`})],O);var x=function(e,t,i,a){var s,r=arguments.length,n=r<3?t:null===a?a=Object.getOwnPropertyDescriptor(t,i):a;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(e,t,i,a);else for(var o=e.length-1;o>=0;o--)(s=e[o])&&(n=(r<3?s(n):r>3?s(t,i,n):s(t,i))||n);return r>3&&n&&Object.defineProperty(t,i,n),n};class PacemContenteditableButtonCommandElement extends PacemContenteditableCommandElement{cleanUp(e){}propertyChangedCallback(e,i,a,s){super.propertyChangedCallback(e,i,a,s),"range"===e&&(this.active=!t.Utils.isNull(a))}getTooltip(e=this.altText,i=this.keyboardShortcut){const a=e;return t.Utils.isNullOrEmpty(i)?a:`${a} (${i})`}}x([t.Watch({converter:t.PropertyConverters.String})],PacemContenteditableButtonCommandElement.prototype,"icon",void 0),x([t.Watch({converter:t.PropertyConverters.String})],PacemContenteditableButtonCommandElement.prototype,"keyboardShortcut",void 0),x([t.Watch({converter:t.PropertyConverters.String})],PacemContenteditableButtonCommandElement.prototype,"altText",void 0),x([t.Watch({converter:t.PropertyConverters.Boolean})],PacemContenteditableButtonCommandElement.prototype,"active",void 0);const V=`<${t.P}-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()"><${t.P}-icon class="text-rootsize" icon="{{ :host.icon }}"></${t.P}-icon></${t.P}-button>\n <${t.P}-shortcut disabled="{{ !:host.active }}" target="{{ :host.contentElement }}" combination="{{ :host.keyboardShortcut }}" on-execute=":host.execCommand()"></${t.P}-shortcut>`;var D=function(e,t,i,a){var s,r=arguments.length,n=r<3?t:null===a?a=Object.getOwnPropertyDescriptor(t,i):a;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(e,t,i,a);else for(var o=e.length-1;o>=0;o--)(s=e[o])&&(n=(r<3?s(n):r>3?s(t,i,n):s(t,i))||n);return r>3&&n&&Object.defineProperty(t,i,n),n};let H=class PacemContenteditableHistoryCommandElement extends PacemContenteditableButtonCommandElement{exec(){return new Promise((e,i)=>{const a=this.container?.history;if(!t.Utils.isNull(a)){if("redo"===this.command)a.canRedo&&(a.redo(),e());else a.canUndo&&(a.undo(),e());this.contentElement.innerHTML=a.current}})}isRelevant(e){return!1}propertyChangedCallback(e,t,i,a){if(super.propertyChangedCallback(e,t,i,a),"command"===e)this.icon=this.icon||i,this.altText=i,this.keyboardShortcut=this.keyboardShortcut||"Ctrl+"+("redo"===i?"Y":"Z")}containerPropertyChangedCallback(e,i,a,s){super.containerPropertyChangedCallback(e,i,a,s);const r=this.container,n=r.history;"range"!==e&&"history"!==e||(this.active=!t.Utils.isNull(r.range)&&("redo"===this.command&&n?.canRedo||"redo"!==this.command&&n?.canUndo))}};D([t.Watch({emit:!1,converter:t.PropertyConverters.String,reflectBack:!0})],H.prototype,"command",void 0),H=D([t.CustomElement({tagName:t.P+"-contenteditable-historycommand",shadow:t.Defaults.USE_SHADOW_ROOT,template:V})],H);var A=function(e,t,i,a){var s,r=arguments.length,n=r<3?t:null===a?a=Object.getOwnPropertyDescriptor(t,i):a;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(e,t,i,a);else for(var o=e.length-1;o>=0;o--)(s=e[o])&&(n=(r<3?s(n):r>3?s(t,i,n):s(t,i))||n);return r>3&&n&&Object.defineProperty(t,i,n),n};let T=class PacemContenteditableLinkCommandElement extends PacemContenteditableButtonCommandElement{isRelevant(e){return!t.Utils.isNull(ContenteditableUtils.findSurroundingNode(e,HTMLAnchorElement))}viewActivatedCallback(){super.viewActivatedCallback(),t.Utils.isNullOrEmpty(this.altText)&&(this.altText="insert link"),t.Utils.isNullOrEmpty(this.icon)&&(this.icon="insert_link"),t.Utils.isNullOrEmpty(this.keyboardShortcut)&&(this.keyboardShortcut="Ctrl+H")}exec(e,t=this.target){return new Promise((i,a)=>{var s=this.range,r=ContenteditableUtils.findSurroundingNode(s,HTMLAnchorElement),n="http://",o=/<a.*href=\"([^\"]*)/;if(r&&o.test(r.outerHTML)&&(n=o.exec(r.outerHTML)[1]),"current"===e)return"http://"==n?"":n;var l=e||void 0===e&&window.prompt("link (empty to unlink):",n);l?(document.execCommand("createLink",!1,l),(r=ContenteditableUtils.findSurroundingNode(s,HTMLAnchorElement))&&r.setAttribute("target",t||"_blank")):document.execCommand("unlink"),i()})}};A([t.Watch({emit:!1,converter:t.PropertyConverters.String})],T.prototype,"target",void 0),T=A([t.CustomElement({tagName:t.P+"-contenteditable-linkcommand",shadow:t.Defaults.USE_SHADOW_ROOT,template:V})],T);var R=function(e,t,i,a){var s,r=arguments.length,n=r<3?t:null===a?a=Object.getOwnPropertyDescriptor(t,i):a;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(e,t,i,a);else for(var o=e.length-1;o>=0;o--)(s=e[o])&&(n=(r<3?s(n):r>3?s(t,i,n):s(t,i))||n);return r>3&&n&&Object.defineProperty(t,i,n),n};function L(e,i){return new Promise((a,s)=>{t.Utils.blobToDataURL(i).then(t.Utils.loadImage).then(t=>{const i=document.createElement("picture");i.setAttribute("contenteditable","false"),t.tabIndex=0,i.appendChild(t),e.deleteContents(),e.insertNode(i),a(i)})})}let I=class PacemContenteditableImageCommandElement extends PacemContenteditableButtonCommandElement{constructor(){super(...arguments),this._setBehaviorHandler=e=>{const t=e.target.parentElement;this.range=ContenteditableUtils.select(t)},this._disposeBehaviorHandler=e=>{}}pasteCallback(e){return e.type.startsWith("image")?L(this.range,e):Promise.reject()}cleanUp(e){e.querySelectorAll("picture[contenteditable=false]").forEach(e=>{for(let t=e.childNodes.length-1;t>0;t--)e.childNodes.item(t).remove()}),e.querySelectorAll("div."+t.PCSS+"-rescale").forEach(e=>e.remove())}isRelevant(e){return!1}viewActivatedCallback(){super.viewActivatedCallback(),t.Utils.isNullOrEmpty(this.altText)&&(this.altText="insert image"),t.Utils.isNullOrEmpty(this.icon)&&(this.icon="insert_photo"),t.Utils.isNullOrEmpty(this.keyboardShortcut)&&(this.keyboardShortcut="Ctrl+Shift+I"),this._rescale.addEventListener("rescale",this._rescaleImg,!1)}disconnectedCallback(){t.Utils.isNull(this._rescale)||(this._rescale.removeEventListener("rescale",this._rescaleImg,!1),this._disposeContainer()),super.disconnectedCallback()}propertyChangedCallback(e,i,a,s){switch(super.propertyChangedCallback(e,i,a,s),e){case"disabled":t.Utils.isNull(this._rescale)||(this._rescale.disabled=a);break;case"contentElement":i&&this._disposeContainer(i),a&&this._initContainer(a);break;case"range":this._rangeChangeCallback(i,a)}}exec(){return new Promise((e,i)=>{const a=this._file,s=this.range;a.onchange=i=>{const r=a.files[0];t.Utils.isNull(r)?e():L(s,r).then(t=>{a.value="",e()})},a.click()})}_rescaleImg(e){e.preventDefault();const t=e.detail.element,i=e.detail.targetRect,a=t.firstElementChild;a.style.width=i.width+"px",a.style.height=i.height+"px"}#a;_rangeChangeCallback(e,i){if(!t.Utils.isNull(e)&&!e.collapsed&&e.commonAncestorContainer instanceof Element&&e.commonAncestorContainer===e.startContainer&&e.commonAncestorContainer===e.endContainer&&e.startOffset===e.endOffset-1){const t=e.commonAncestorContainer.childNodes.item(e.startOffset);t instanceof HTMLPictureElement&&this._rescale.unregister(t)}if(!t.Utils.isNull(i)&&!i.collapsed&&i.commonAncestorContainer instanceof Element&&i.commonAncestorContainer===i.startContainer&&i.commonAncestorContainer===i.endContainer&&i.startOffset===i.endOffset-1){const e=i.commonAncestorContainer.childNodes.item(i.startOffset);e instanceof HTMLPictureElement&&this._rescale.register(e)}}_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){this.#a=new ContenteditableDOMObserver(e,(e,t)=>{e instanceof HTMLPictureElement&&(t?this._downgradePictureElement(e):this._enhancePictureElement(e))},"picture")}_disposeContainer(e=this.contentElement){const i=this.#a;t.Utils.isNull(i)||i.dispose()}};R([t.ViewChild("input[type=file]")],I.prototype,"_file",void 0),R([t.ViewChild(t.P+"-rescale")],I.prototype,"_rescale",void 0),I=R([t.CustomElement({tagName:t.P+"-contenteditable-imagecommand",shadow:t.Defaults.USE_SHADOW_ROOT,template:`<input type="file" accept="image/png, image/gif, image/jpeg, image/bmp, image/x-icon" class="${t.PCSS}-trasparent ${t.PCSS}-inert" pacem hidden>`+V+`<${t.P}-rescale keep-proportions="true"></${t.P}-rescale>`})],I);var F,W=function(e,t,i,a){var s,r=arguments.length,n=r<3?t:null===a?a=Object.getOwnPropertyDescriptor(t,i):a;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(e,t,i,a);else for(var o=e.length-1;o>=0;o--)(s=e[o])&&(n=(r<3?s(n):r>3?s(t,i,n):s(t,i))||n);return r>3&&n&&Object.defineProperty(t,i,n),n};function B(e){const t=e?.toLowerCase();switch(t){case"bold":case"italic":return"format_"+t;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_"+t.substr(7);case"justifyfull":return"format_align_justify";default:return"help_outline"}}function j(e,t){const i=e?.toLowerCase();switch(i){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[t];default:return["none"]}}!function(e){e.Bold="bold",e.Italic="italic",e.Underline="underline",e.StrikeThrough="strikeThrough",e.OrderedList="insertOrderedList",e.UnorderedList="insertUnorderedList",e.JustifyLeft="justifyLeft",e.JustifyCenter="justifyCenter",e.JustifyRight="justifyRight",e.JustifyFull="justifyFull"}(F||(F={}));let M=class PacemContenteditableExecCommandElement extends PacemContenteditableButtonCommandElement{_matchRelevance(e,i){const a="object"==typeof i?ContenteditableUtils.findSurroundingNode(e,e=>e instanceof HTMLElement&&(t.Utils.isNullOrEmpty(i.tagName)||e.tagName===i.tagName.toUpperCase())&&e.style[i.style.name]===i.style.value):ContenteditableUtils.findSurroundingNode(e,i);return!t.Utils.isNull(a)}isRelevant(e){const t=j(this.command,this.argument);for(let i of t)if(this._matchRelevance(e,i))return!0;return!1}propertyChangedCallback(e,i,a,s){super.propertyChangedCallback(e,i,a,s),"command"===e&&((t.Utils.isNullOrEmpty(this.icon)||this.icon===B(i))&&(this.icon=B(a)),(t.Utils.isNullOrEmpty(this.altText)||this.altText===i)&&(this.altText=a))}exec(){return new Promise((e,i)=>{const a=this.range,s=j(this.command,this.argument)[0];if(!t.Utils.isNull(a)){const e=ContenteditableUtils.testInertElementWrapping(a);if(e.result&&"string"==typeof s&&["b","i","strike","u"].indexOf(s)>=0){const i=ContenteditableUtils.findSurroundingNode(a,s);if(t.Utils.isNull(i)||1!==i.childNodes.length){const t=document.createElement(s),i=e.element,r=a.extractContents();a.insertNode(t),t.append(r),ContenteditableUtils.select(i)}else{const t=i.childNodes.item(0),a=e.element;i.parentElement.replaceChild(t,i),ContenteditableUtils.select(a)}}else document.execCommand(this.command,!1,this.argument)}e()})}};function z(e){return e instanceof HTMLDivElement&&"true"===e.contentEditable&&e.hasAttribute("pacem")&&e.hasAttribute("role")&&"presenter"===e.attributes.role.value}W([t.Watch({converter:t.PropertyConverters.String})],M.prototype,"command",void 0),W([t.Watch({emit:!1,converter:t.PropertyConverters.String})],M.prototype,"argument",void 0),M=W([t.CustomElement({tagName:t.P+"-contenteditable-execcommand",shadow:t.Defaults.USE_SHADOW_ROOT,template:V})],M);class ContenteditableDOMObserver{constructor(e,t,i="*[contenteditable=false]"){this.#s=t,this.#r=i,this.#n=new MutationObserver(e=>{const i=(e,a)=>{e.childNodes.forEach(e=>i(e,a)),t(e,a)};for(let t of e){const e=t.addedNodes,a=t.removedNodes;for(let t=0;t<e.length;t++){const a=e.item(t);i(a,!1)}for(let e=0;e<a.length;e++){const t=a.item(e);i(t,!0)}}}),this._initContainer(e)}_initContainer(e){e.querySelectorAll(this.#r).forEach(e=>this.#s(e)),this.#n.observe(e,{subtree:!0,childList:!0}),this.#o=e}_disposeContainer(e){const i=this.#n;t.Utils.isNull(i)||i.disconnect(),e.querySelectorAll(this.#r).forEach(e=>this.#s(e,!0))}dispose(){this._disposeContainer(this.#o)}#r;#s;#o;#n}class ContenteditableUtils{static getDefaultDashboard(){const e=new DocumentFragment,i=document.createElement("div");t.Utils.addClass(i,t.PCSS+"-contenteditable-toolbar");const a=new H;a.command="undo",a.keyboardShortcut="Ctrl+Z";const s=new H;s.command="redo",s.keyboardShortcut="Ctrl+Y",i.append(a,s);const r=document.createElement("div");t.Utils.addClass(r,t.PCSS+"-contenteditable-separator");const n=document.createElement("div");t.Utils.addClass(n,t.PCSS+"-contenteditable-toolbar");const o=new M;o.command=F.Bold,o.keyboardShortcut="Ctrl+B";const l=new M;l.command=F.Italic,l.keyboardShortcut="Ctrl+I";const c=new M;c.command=F.Underline,c.keyboardShortcut="Ctrl+U";const d=new M;d.command=F.StrikeThrough,c.keyboardShortcut="Ctrl+K";const h=new M;h.command=F.UnorderedList;const p=new M;p.command=F.OrderedList;const u=new Y;u.align="left";const m=new Y;m.align="center";const v=new Y;v.align="right";const g=new Y;g.align="justify",n.append(o,l,c,d,h,p,u,m,v,g);const y=document.createElement("div");t.Utils.addClass(y,t.PCSS+"-contenteditable-separator");const f=document.createElement("div");t.Utils.addClass(f,t.PCSS+"-contenteditable-toolbar");const _=new T,b=new I;return f.append(_,b),e.append(i,r,n,y,f),e}static findSurroundingNode(e,i){for(var a=e instanceof Node?e:e.commonAncestorContainer;a&&!("string"==typeof i&&a instanceof Element&&a.tagName===i.toUpperCase()||"function"==typeof i&&t.Utils.isNull(i.prototype)&&i(a)||"function"==typeof i&&!t.Utils.isNull(i.prototype)&&a instanceof i);){const e=a.parentNode;if(z(e)){a=null;break}a=e}return a}static findSurroundingBlockElement(e){return this.findSurroundingNode(e,ContenteditableUtils.isBlockElement)}static findSurroundingSiblingBlockElements(e){let t=[];if(z(e.startContainer)){if(!e.collapsed){const i=e.startContainer;for(let a=e.startOffset;a<=e.endOffset;a++){const e=i.children.item(a);this.isBlockElement(e)&&t.push(i.children.item(a))}}return t}if(e.startContainer===e.endContainer){let t=e.startContainer;for(;!ContenteditableUtils.isBlockElement(t)&&"true"!=t.parentElement.contentEditable;)t=t.parentElement;return t instanceof Element?[t]:"true"===t.parentElement.contentEditable?[]:[t.parentElement]}let i=e.commonAncestorContainer,a=!1;for(let s=0;s<i.childNodes.length;s++){const r=i.childNodes.item(s);if((!a&&r.contains(e.startContainer)||a)&&ContenteditableUtils.isBlockElement(r)&&(t.push(r),a=!0,r.contains(e.endContainer)))break}return a?t:i instanceof Element&&!z(i)?[i]:[]}static findContainingRootElements(e){const t=e.cloneRange(),i=e.cloneRange();t.collapse(!0),i.collapse();let a=this.findSurroundingNode(t,e=>"true"===e.parentElement.contentEditable);const s=[a];for(;!a.contains(i.startContainer);)s.push(a=a.nextElementSibling);return s}static isBlockElement(e){return e instanceof Element&&!getComputedStyle(e).display.startsWith("inline")}static select(e,t=!1){const i=document.createRange();t?(i.setStart(e,0),i.setEnd(e,e.childNodes.length)):(i.setStartBefore(e),i.setEndAfter(e));const a=document.getSelection();return a.removeAllRanges(),a.addRange(i),i}static copyAttributes(e,t){const i=t.attributes;for(let t=0;t<i.length;t++){const a=i.item(t);e.setAttribute(a.name,a.value)}}static testInertElementWrapping(e){if(!t.Utils.isNull(e)){const t=e.startContainer,a=e.startOffset;var i;if(t===e.endContainer&&a==e.endOffset-1&&(i=t.childNodes.item(a))instanceof HTMLElement&&"false"===i.contentEditable)return{result:!0,element:i}}return{result:!1}}}var q=function(e,t,i,a){var s,r=arguments.length,n=r<3?t:null===a?a=Object.getOwnPropertyDescriptor(t,i):a;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(e,t,i,a);else for(var o=e.length-1;o>=0;o--)(s=e[o])&&(n=(r<3?s(n):r>3?s(t,i,n):s(t,i))||n);return r>3&&n&&Object.defineProperty(t,i,n),n};function J(e){return"format_align_"+e}let Y=class PacemContenteditableAlignCommandElement extends PacemContenteditableButtonCommandElement{isRelevant(e){const i=ContenteditableUtils.findSurroundingSiblingBlockElements(e);if(t.Utils.isNullOrEmpty(i))return!1;const a=i[0];return getComputedStyle(a).textAlign==this.align}propertyChangedCallback(e,i,a,s){super.propertyChangedCallback(e,i,a,s),"align"===e&&((t.Utils.isNullOrEmpty(this.icon)||this.icon===J(i))&&(this.icon=J(a)),(t.Utils.isNullOrEmpty(this.altText)||this.altText===i)&&(this.altText=a))}exec(){const e=ContenteditableUtils.findSurroundingSiblingBlockElements(this.range);let i;for(let a of e)ContenteditableUtils.isBlockElement(a)&&a instanceof HTMLElement&&(t.Utils.isNull(i)&&(i=t.Utils.hasClass(a,"text-"+this.align)?"":this.align),a.style.textAlign="",t.Utils.removeClass(a,"text-left text-right text-center text-justify"),t.Utils.isEmpty(i)||t.Utils.addClass(a,"text-"+i));return Promise.resolve()}};q([t.Watch({converter:t.PropertyConverters.String})],Y.prototype,"align",void 0),Y=q([t.CustomElement({tagName:t.P+"-contenteditable-aligncommand",shadow:t.Defaults.USE_SHADOW_ROOT,template:V})],Y);var G=function(e,t,i,a){var s,r=arguments.length,n=r<3?t:null===a?a=Object.getOwnPropertyDescriptor(t,i):a;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(e,t,i,a);else for(var o=e.length-1;o>=0;o--)(s=e[o])&&(n=(r<3?s(n):r>3?s(t,i,n):s(t,i))||n);return r>3&&n&&Object.defineProperty(t,i,n),n};function K(e){return e instanceof HTMLModElement&&"INS"===e.tagName}let X=class PacemContenteditablePlaceholderElement extends PacemContenteditableCommandElement{constructor(){super(...arguments),this._focusHandler=e=>{const t=e.target;this.range=ContenteditableUtils.select(t)}}#l;#c;cleanUp(e){e.querySelectorAll("ins[contenteditable=false]").forEach(e=>{t.Utils.removeClass(e,"placeholder-selected")})}exec(e){const t=function(e,t){const i=document.createElement("ins");return i.textContent=t,i.setAttribute("contenteditable","false"),i.tabIndex=0,e.deleteContents(),e.insertNode(i),i}(this.range,e);return ContenteditableUtils.select(t).collapse(!1),Promise.resolve(t)}isRelevant(e){return this.#l?.result??!1}viewActivatedCallback(){super.viewActivatedCallback(),this._fillDropdown(),this._initContainer()}propertyChangedCallback(e,t,i,a){if(super.propertyChangedCallback(e,t,i,a),!a)switch(e){case"datasource":this._fillDropdown();break;case"contentElement":t&&this._disposeContainer(t),i&&this._initContainer(i);break;case"range":this._changeRelevancy()}}disconnectedCallback(){this._disposeContainer(),super.disconnectedCallback()}_changeRelevancy(e=this.range){const i=this.#l;t.Utils.isNull(i?.element)||t.Utils.removeClass(i.element,"placeholder-selected");const a=this.#l=function(e){const t=ContenteditableUtils.testInertElementWrapping(e);if(t.result&&K(t.element)){const e=t.element;return{result:!0,element:e,placeholder:e.textContent}}return{result:!1}}(e);t.Utils.isNull(a?.element)||t.Utils.addClass(a.element,"placeholder-selected"),a.result?this._dropdown.value=a.placeholder:(this._dropdown.popout(),this._dropdown.value=void 0)}_fillDropdown(e=this.datasource||[]){const t=this.#c=e.map(e=>"string"==typeof e?{placeholder:e,definition:e}:e),i=this._dropdown;i.textProperty=i.valueProperty="placeholder",i.datasource=t}#a;_initContainer(e=this.contentElement){this.#a=new ContenteditableDOMObserver(e,(e,t)=>{K(e)&&(t?this._downgradePlaceholderElement(e):this._enhancePlaceholderElement(e))},"ins[contenteditable=false]")}_disposeContainer(e=this.contentElement){const i=this.#a;t.Utils.isNull(i)||i.dispose()}_enhancePlaceholderElement(e){e.addEventListener("focus",this._focusHandler,!1)}_downgradePlaceholderElement(e){e.removeEventListener("focus",this._focusHandler,!1)}};G([t.ViewChild("template")],X.prototype,"_itemtemplate",void 0),G([t.ViewChild(t.P+"-suggest")],X.prototype,"_dropdown",void 0),G([t.Watch({emit:!1,converter:t.PropertyConverters.Json})],X.prototype,"datasource",void 0),X=G([t.CustomElement({tagName:t.P+"-contenteditable-placeholder",shadow:t.Defaults.USE_SHADOW_ROOT,template:`<template>\n<${t.P}-span text="{{ ^item.viewValue }}" class="text-tech"></${t.P}-span>\n<${t.P}-markdown hide="{{ $pacem.isNullOrEmpty(^item.data.definition) || ^item.viewValue === ^item.data.definition }}" class="${t.PCSS}-margin margin-0 text-small" value="{{ ^item.data.definition }}"></${t.P}-markdown>\n</template>\n<${t.P}-suggest placeholder="Placeholder" class="pacem-button button" disabled="{{ $pacem.isNull(:host.range) }}"\n on-change=":host.execCommand($this.value)"\n css-class="{{ {'text-primary': :host.isRelevant(:host.range)} }}" \n compare-by="placeholder" text-property="placeholder" itemtemplate="{{ ::_itemtemplate }}" prevent-focus="true" allow-typing="false"></${t.P}-suggest>`})],X);var Z=function(e,t,i,a){var s,r=arguments.length,n=r<3?t:null===a?a=Object.getOwnPropertyDescriptor(t,i):a;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(e,t,i,a);else for(var o=e.length-1;o>=0;o--)(s=e[o])&&(n=(r<3?s(n):r>3?s(t,i,n):s(t,i))||n);return r>3&&n&&Object.defineProperty(t,i,n),n};let Q=class PacemContenteditableWrapCommandElement extends PacemContenteditableButtonCommandElement{isRelevant(e){return!t.Utils.isNull(ContenteditableUtils.findSurroundingNode(e,this.tagname))}exec(){return new Promise((e,i)=>{const a=this.tagname;if(!t.Utils.isNullOrEmpty(a)){const e=this.range,i=ContenteditableUtils.findSurroundingNode(e,a)||ContenteditableUtils.findSurroundingNode(e.startContainer,a)||ContenteditableUtils.findSurroundingNode(e.endContainer,a);if(t.Utils.isNull(i)){const i=ContenteditableUtils.findSurroundingSiblingBlockElements(e);if(!t.Utils.isNullOrEmpty(i)){const t=document.createElement(a);if(1===i.length){const a=i[0];e.setStart(a,0),e.setEnd(a,a.childNodes.length);const s=e.extractContents();t.append(s),ContenteditableUtils.copyAttributes(t,a),a.parentElement.insertBefore(t,a),a.remove()}else{e.setStartBefore(i[0]),e.setEndAfter(i[i.length-1]);const a=e.extractContents();t.append(a),e.insertNode(t)}ContenteditableUtils.select(t,!0).collapse()}}else{e.setStart(i,0),e.setEnd(i,i.childNodes.length);let t=!1;const a=i.childNodes;for(let e=0;e<a.length;e++){const i=a.item(e);if(!ContenteditableUtils.isBlockElement(i)){t=!0;break}}if(t){const t=document.createElement("p");ContenteditableUtils.copyAttributes(t,i),t.append(e.extractContents()),i.parentNode.replaceChild(t,i);ContenteditableUtils.select(t,!0).collapse()}else{i.parentNode.replaceChild(e.extractContents(),i);ContenteditableUtils.select(e.endContainer,!0).collapse()}}}e()})}};Z([t.Watch({converter:t.PropertyConverters.String})],Q.prototype,"tagname",void 0),Q=Z([t.CustomElement({tagName:t.P+"-contenteditable-wrapcommand",shadow:t.Defaults.USE_SHADOW_ROOT,template:V})],Q);var ee=function(e,t,i,a){var s,r=arguments.length,n=r<3?t:null===a?a=Object.getOwnPropertyDescriptor(t,i):a;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(e,t,i,a);else for(var o=e.length-1;o>=0;o--)(s=e[o])&&(n=(r<3?s(n):r>3?s(t,i,n):s(t,i))||n);return r>3&&n&&Object.defineProperty(t,i,n),n};const te={convert:(e,i)=>/\{.+\}/.test(e)?t.PropertyConverters.Json.convert(e):t.PropertyConverters.String.convert(e),convertBack:(e,i)=>"string"==typeof e?e:t.PropertyConverters.Json.convertBack(e,i)};let ie=class PacemCalendarMonthPickerElement extends t.Components.PacemElement{propertyChangedCallback(e,i,a,s){if(super.propertyChangedCallback(e,i,a,s),"viewYear"===e)this.dispatchEvent(new CustomEvent("viewyearchange",{detail:new Date(a,0,1),bubbles:!1,cancelable:!1})),t.Utils.removeClass(this,"viewyear-next viewyear-previous"),requestAnimationFrame(()=>{t.Utils.addClass(this,i>a?"viewyear-previous":"viewyear-next")})}_getMonthLabel(e){const i=(new Date).getFullYear();return new Date(i,e,1).toLocaleString(t.Utils.lang(this),{month:"short"})}_isThisMonth(e,t=this.viewYear){return this._isSelectedMonth(e,new Date,t)}_isSelectedMonth(e,i=this.month,a=this.viewYear){const s=t.Utils.parseDate(i);if(!t.Utils.Dates.isDate(s))return!1;const r=a??(new Date).getFullYear();return s.getMonth()===e&&s.getFullYear()===r}_setMonth(e){const t=this.viewYear,i=new Date(t,e,1);this.month=i,this.dispatchEvent(new CustomEvent("monthselect",{detail:i,bubbles:!1,cancelable:!1}))}};ee([t.Watch({converter:t.PropertyConverters.Date})],ie.prototype,"month",void 0),ee([t.Watch({converter:t.PropertyConverters.Date})],ie.prototype,"viewYear",void 0),ie=ee([t.CustomElement({tagName:t.P+"-calendar-month-picker",shadow:t.Defaults.USE_SHADOW_ROOT,template:`<div class="${t.PCSS}-month-picker">${function(){let e="";for(let i=0;i<12;i++)e+=`<div class="calendar-month month-${i+1}"><${t.P}-span class="month-button text-ellipsed" on-click=":host._setMonth(${i})" css-class="{{ { 'selected-month': :host._isSelectedMonth(${i}, :host.month, :host.viewYear), 'this-month': :host._isThisMonth(${i}, :host.viewYear) } }}" text="{{ :host._getMonthLabel(${i}) }}"></${t.P}-span></div>`;return e}()}</div>`})],ie);class CalendarDateUnselectEvent extends i.Components.UI.DateSelectEvent{constructor(){super(void 0)}}function ae(e){return e-e%10}let se=class PacemCalendarYearPickerElement extends t.Components.PacemElement{propertyChangedCallback(e,i,a,s){if(super.propertyChangedCallback(e,i,a,s),"viewYear"===e)this.dispatchEvent(new CustomEvent("viewyearchange",{detail:new Date(a,0,1),bubbles:!1,cancelable:!1})),t.Utils.removeClass(this,"viewyear-next viewyear-previous"),requestAnimationFrame(()=>{t.Utils.addClass(this,i>a?"viewyear-previous":"viewyear-next")})}_getYearLabel(e,t=this.viewYear){return""+(ae(t)+e)}_isThisYear(e,t=this.viewYear){return this._isSelectedYear(e,new Date,t)}_isSelectedYear(e,i=this.year,a=this.viewYear){const s=t.Utils.parseDate(i);if(!t.Utils.Dates.isDate(s))return!1;const r=ae(a)+e;return s.getFullYear()===r}_setYear(e){const t=ae(this.viewYear),i=new Date(t+e,0,1);this.year=i,this.dispatchEvent(new CustomEvent("yearselect",{detail:i,bubbles:!1,cancelable:!1}))}};ee([t.Watch({converter:t.PropertyConverters.Date})],se.prototype,"year",void 0),ee([t.Watch({converter:t.PropertyConverters.Date})],se.prototype,"viewYear",void 0),se=ee([t.CustomElement({tagName:t.P+"-calendar-year-picker",shadow:t.Defaults.USE_SHADOW_ROOT,template:`<div class="${t.PCSS}-year-picker">${function(){let e="";for(let i=0;i<12;i++)e+=`<div class="calendar-year year-${i+1}"><${t.P}-span class="year-button text-ellipsed" on-click=":host._setYear(${i})" css-class="{{ { 'selected-year': :host._isSelectedYear(${i}, :host.year, :host.viewYear), 'this-year': :host._isThisYear(${i}, :host.viewYear) } }}" text="{{ :host._getYearLabel(${i}, :host.viewYear) }}"></${t.P}-span></div>`;return e}()}</div>`})],se);let re=class PacemCalendarPickerElement extends PacemBaseElement{constructor(){super(...arguments),this.viewmode="calendar",this.#d=!1,this._swipeHandler=e=>{switch(e.detail.direction){case"left":this._next(e);break;case"right":this._prev(e)}},this._clearBtnHandler=e=>{e.preventDefault(),this._viewDate=new Date,this.changeHandler(new CalendarDateUnselectEvent)},this._viewDateChangeHandler=e=>{this._onViewDateChange(e)},this._popCalendarHandler=e=>{if(this.#d)return;this.viewmode="calendar";const i=t.Utils.parseDate(this.value);this._calendar.viewDate=this._monthPicker.month=this._yearPicker.year=t.Utils.Dates.isDate(i)?i:this._calendar.viewDate;const a=t.Utils.offset(this._input),s=this._dropdown;s.style.top=a.top+a.height+"px",s.style.left=a.left+"px",s.hidden=!1,requestAnimationFrame(()=>{t.Utils.addClass(s,"dropdown-in")})},this._hideCalendarHandler=e=>{const t=e.composedPath()||[];t.indexOf(this._input)>=0||t.indexOf(this._dropdown)>=0||this._hideCalendar()}}#d;propertyChangedCallback(e,t,i,a){switch(super.propertyChangedCallback(e,t,i,a),e){case"viewmode":case"_viewDate":this._onViewDateChange(this._viewDate)}}viewActivatedCallback(){super.viewActivatedCallback();const e=this._dropdown=this._proxy.dom[0],i=this._calendar=e.querySelector(t.P+"-calendar"),a=this._monthPicker=e.querySelector(t.P+"-calendar-month-picker"),s=this._yearPicker=e.querySelector(t.P+"-calendar-year-picker");this._monthLabel=e.querySelector(".calendar-month"),this._yearLabel=e.querySelector(".calendar-year"),this._rangeLabel=e.querySelector(".calendar-year-range");const r=this._calendar.now=new Date,n=t.Utils.Dates.parse(this.value),o=t.Utils.Dates.isDate(n)?n:r;i.dayLabelFormatter=e=>t.Utils.parseDate(e).toLocaleString(t.Utils.lang(this),{day:"numeric"}),a.addEventListener("viewyearchange",this._viewDateChangeHandler,!1),s.addEventListener("viewyearchange",this._viewDateChangeHandler,!1),i.addEventListener("viewdatechange",this._viewDateChangeHandler,!1),i.viewDate=o,i.date=n;const l=this._input;l.addEventListener("focus",this._popCalendarHandler,!1),l.addEventListener("mousedown",this._popCalendarHandler,!1),e.addEventListener("mousedown",t.stopPropagationHandler,!1),window.document.body.addEventListener("mousedown",this._hideCalendarHandler,!0),this._clearButton.addEventListener("mousedown",this._clearBtnHandler,!1);const c=new t.Components.PacemSwipeElement;i.behaviors.push(c),a.behaviors.push(c),s.behaviors.push(c),c.addEventListener("swipe",this._swipeHandler,!1);const d=t.CustomElementUtils.findAncestorShell(this);this._swiper=d.appendChild(c)}disconnectedCallback(){const e=this._input;t.Utils.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",t.stopPropagationHandler,!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));const i=this._swiper;if(!t.Utils.isNull(i)){const e=this._calendar,t=this._monthPicker,a=this._yearPicker;for(let s of[e,t,a]){const e=s.behaviors.indexOf(i);e>=0&&s.behaviors.splice(e,1)}i.removeEventListener("swipe",this._swipeHandler,!1),i.remove(),this._swiper=null}super.disconnectedCallback()}_getHeaderLabel(e,i=this.viewmode){const a=t.Utils.parseDate(e);return t.Utils.Dates.isDate(a)?a.toLocaleString(t.Utils.lang(this),{weekday:"narrow"}):"..."}_prev(e){let t=-1;switch(this.viewmode){case"month":t=-12;break;case"year":t=-120}this._jumpMonths(t)}_next(e){let t=1;switch(this.viewmode){case"month":t=12;break;case"year":t=120}this._jumpMonths(t)}_jumpMonths(e){const i=t.Utils.parseDate(this._viewDate);this._viewDate=t.Utils.Dates.addMonths(i,e)}_setMonth(e){this._viewDate=e.detail,this.viewmode="calendar"}_setYear(e){this._viewDate=e.detail,this.viewmode="month"}_onViewDateChange(e){if(t.Utils.isNullOrEmpty(e))return;const i=t.Utils.parseDate(this._viewDate);if(t.Utils.Dates.isDate(i)&&!t.Utils.isNull(this._monthLabel))switch(this.viewmode){case"month":this._yearLabel.text=i.toLocaleString(t.Utils.lang(this),{year:"numeric"});break;case"year":const e=ae(i.getFullYear());this._rangeLabel.text=`${e} - ${e+12-1}`;break;default:this._monthLabel.text=i.toLocaleString(t.Utils.lang(this),{month:"long",year:"numeric"})}}_hideCalendar(){t.Utils.removeClass(this._dropdown,"dropdown-in"),t.Utils.addAnimationEndCallback(this._dropdown,e=>{this._dropdown.hidden=!0,t.Utils.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((a,s)=>{if(t.CustomEventUtils.isInstanceOf(e,i.Components.UI.DateSelectEvent)){t.Utils.addClass(this._dropdown,"dropdown-select");t.CustomEventUtils.isInstanceOf(e,CalendarDateUnselectEvent)&&(this.#d=!0),this.focus(),this.#d=!1,this._hideCalendar(),a(this.value=e.detail)}else a(this.value)})}acceptValue(e){this._input.value=this.viewValue;const i=this._calendar;if(!t.Utils.isNull(i)){const a=t.Utils.parseDate(e);t.Utils.Dates.isDate(a)?i.viewDate=i.date=a:i.date=void 0}}getViewValue(e){const i=t.Utils.Dates.parse(e);return t.Utils.Dates.isDate(i)?t.Utils.core.date(i,this.format||"short",t.Utils.lang(this)):""}compareValuePropertyValues(e,i){const a=t.Utils.parseDate(e),s=t.Utils.parseDate(i);return!(!t.Utils.isNullOrEmpty(a)||!t.Utils.isNullOrEmpty(s))||!t.Utils.isNullOrEmpty(a)&&!t.Utils.isNullOrEmpty(s)&&a.valueOf()==s.valueOf()}convertValueAttributeToProperty(e){return t.PropertyConverters.Datetime.convert(e)}};ee([t.ViewChild("input[type=text]")],re.prototype,"_input",void 0),ee([t.ViewChild(`.${t.PCSS}-readonly`)],re.prototype,"_span",void 0),ee([t.ViewChild(`${t.P}-button[clear]`)],re.prototype,"_clearButton",void 0),ee([t.ViewChild(t.P+"-shell-proxy")],re.prototype,"_proxy",void 0),ee([t.Watch({emit:!1,converter:te})],re.prototype,"format",void 0),ee([t.Watch({converter:t.PropertyConverters.Eval})],re.prototype,"disabledRanges",void 0),ee([t.Watch({converter:t.PropertyConverters.String})],re.prototype,"weekStart",void 0),ee([t.Watch({converter:t.PropertyConverters.String})],re.prototype,"viewmode",void 0),ee([t.Watch()],re.prototype,"_week",void 0),ee([t.Watch()],re.prototype,"_viewDate",void 0),re=ee([t.CustomElement({tagName:t.P+"-calendar-picker",shadow:t.Defaults.USE_SHADOW_ROOT,template:`<div class="${t.PCSS}-calendar-picker">\n <input type="text" class="${t.PCSS}-input" /><${t.P}-span text="{{ :host.viewValue }}" class="${t.PCSS}-readonly"></${t.P}-span>\n <${t.P}-button class="button-flat ${t.PCSS}-anim anim-pop anim-sudden anim-quick pos-absolute absolute-right absolute-top display-block ${t.PCSS}-margin margin-0"\n tab-order="-1"\n hide="{{ :host.readonly || :host.required || !Pacem.Utils.Dates.isDate(Pacem.Utils.Dates.parse(:host.value)) }}"\n icon-glyph="close"\n clear></${t.P}-button>\n</div>\n<${t.P}-shell-proxy>\n <div class="${t.PCSS}-calendar-picker-dropdown" pacem hidden>\n <${t.P}-collapse collapse="false">\n <div class="dropdown-grid">\n <div class="calendar-title">\n <${t.P}-span class="calendar-month calendar-zoom" on-click=":host.viewmode = 'month'" hide="{{ :host.viewmode !== 'calendar' }}"></${t.P}-span>\n <${t.P}-span class="calendar-year calendar-zoom" on-click=":host.viewmode = 'year'" hide="{{ :host.viewmode !== 'month' }}"></${t.P}-span>\n <${t.P}-span class="calendar-year-range" hide="{{ :host.viewmode !== 'year' }}"></${t.P}-span>\n </div>\n <div class="calendar-month-nav ${t.PCSS}-buttonset buttons">\n <div class="buttonset-left">\n <${t.P}-button class="button button-size size-auto" on-click=":host._prev($event)" icon-glyph="chevron_left"></${t.P}-button>\n <${t.P}-button class="button button-size size-auto" on-click=":host._next($event)" icon-glyph="chevron_right"></${t.P}-button>\n </div>\n </div>\n ${function(){let e="";for(let i=0;i<7;i++)e+=`<${t.P}-span class="calendar-heading day-${i+1} text-ellipsed" text="{{ :host._getHeaderLabel(:host._week[${i}]) }}"></${t.P}-span>`;return`<${t.P}-panel hide="{{ :host.viewmode !== 'calendar' }}" class="calendar-header">${e}</${t.P}-panel>`}()}\n <${t.P}-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) }}"></${t.P}-calendar>\n <${t.P}-calendar-month-picker hide="{{ :host.viewmode !== 'month' }}" on-monthselect=":host._setMonth($event)" month="{{ :host.value || Date.now() }}" view-year="{{ :host._viewDate && :host._viewDate.getFullYear() }}"></${t.P}-calendar-month-picker>\n <${t.P}-calendar-year-picker hide="{{ :host.viewmode !== 'year' }}" on-yearselect=":host._setYear($event)" year="{{ :host.value || Date.now() }}" view-year="{{ :host._viewDate && :host._viewDate.getFullYear() }}"></${t.P}-calendar-year-picker>\n </div>\n <${t.P}-collapse>\n </div>\n</${t.P}-shell-proxy>`})],re);var ne=function(e,t,i,a){var s,r=arguments.length,n=r<3?t:null===a?a=Object.getOwnPropertyDescriptor(t,i):a;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(e,t,i,a);else for(var o=e.length-1;o>=0;o--)(s=e[o])&&(n=(r<3?s(n):r>3?s(t,i,n):s(t,i))||n);return r>3&&n&&Object.defineProperty(t,i,n),n};const oe={convert:e=>"true"===e||"false"!==e&&e,convertBack:e=>e.toString()};let le=class PacemCheckboxElement extends PacemBaseElement{constructor(){super("checkbox"),this.caption="",this._key="_"+t.Utils.uniqueCode()}convertValueAttributeToProperty(e){oe.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;const i=this.value=this.selected?this.trueValue:this.falseValue;return t.Utils.fromResult(i)}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,i,a,s){if(super.propertyChangedCallback(e,i,a,s),this.isReady)switch(e){case"caption":this._label.hidden=t.Utils.isNullOrEmpty(a);break;case"name":this._checkbox.name=a;break;case"selected":this._synchronizeUi()}}_synchronizeUi(e=this.selected){(this._checkbox.checked=e)?(this.value=this.trueValue,t.Utils.addClass(this,t.PCSS+"-selected"),this.aria.attributes.set("checked","true")):(this.value=this.falseValue,t.Utils.removeClass(this,t.PCSS+"-selected"),this.aria.attributes.set("checked","false"))}acceptValue(e){this.selected=e==this.trueValue}getViewValue(e){return t.Utils.isNull(e)?"":this.caption}};ne([t.ViewChild("input[type=checkbox]")],le.prototype,"_checkbox",void 0),ne([t.ViewChild("label")],le.prototype,"_label",void 0),ne([t.ViewChild(`.${t.PCSS}-readonly`)],le.prototype,"span",void 0),ne([t.Watch({converter:t.PropertyConverters.String})],le.prototype,"caption",void 0),ne([t.Watch({emit:!1,converter:oe})],le.prototype,"trueValue",void 0),ne([t.Watch({emit:!1,converter:oe})],le.prototype,"falseValue",void 0),ne([t.Watch({converter:t.PropertyConverters.Boolean})],le.prototype,"selected",void 0),le=ne([t.CustomElement({tagName:t.P+"-checkbox",template:`<${t.P}-span class="${t.PCSS}-readonly ${t.PCSS}-checkbox" text="{{ :host.caption }}"></${t.P}-span>\n<input type="checkbox" class="${t.PCSS}-input" /><label class="${t.PCSS}-label ${t.PCSS}-checkbox ${t.PCSS}-viewfinder" pacem><${t.P}-span content="{{ :host.caption }}"></${t.P}-span></label>`,shadow:t.Defaults.USE_SHADOW_ROOT})],le);var ce=function(e,t,i,a){var s,r=arguments.length,n=r<3?t:null===a?a=Object.getOwnPropertyDescriptor(t,i):a;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(e,t,i,a);else for(var o=e.length-1;o>=0;o--)(s=e[o])&&(n=(r<3?s(n):r>3?s(t,i,n):s(t,i))||n);return r>3&&n&&Object.defineProperty(t,i,n),n};let de=class PacemCheckboxListElement extends PacemDataSourceElement{acceptValue(e){}constructor(){super(!0),this._selectedUiItems=[],this.key="_"+t.Utils.uniqueCode()}get inputFields(){return[]}propertyChangedCallback(e,t,i,a){super.propertyChangedCallback(e,t,i,a),"disabled"===e&&(this._disable.model=i)}viewActivatedCallback(){super.viewActivatedCallback(),this._disable.model=this.disabled}toggleReadonlyView(e){this._span.hidden=!e,this._repeater.hidden=e}_selectionChanged(e,t,i){if("selected"===e.detail.propertyName){let i,a=this._selectedUiItems;!0===e.detail.currentValue?a.push(this.datasource[t]):-1!==(i=a.indexOf(this.datasource[t]))&&a.splice(i,1)}}onChange(e){const i=this.value=this._selectedUiItems.map(e=>this.mapEntityToValue(e));return t.Utils.fromResult(i)}};ce([t.ViewChild(`span.${t.PCSS}-readonly`)],de.prototype,"_span",void 0),ce([t.ViewChild(t.P+"-repeater")],de.prototype,"_repeater",void 0),ce([t.ViewChild(t.P+"-data")],de.prototype,"_disable",void 0),de=ce([t.CustomElement({tagName:t.P+"-checkbox-list",template:`<${t.P}-repeater datasource="{{ :host.adaptedDatasource }}">\n <ol class="${t.PCSS}-checkbox-list ${t.PCSS}-viewfinder" pacem>\n <template>\n <li><${t.P}-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) }}"\non-focus=":host.focusHandler($event)" on-blur=":host.focusHandler($event)"\non-${t.PropertyChangeEventName}=":host._selectionChanged($event, ^index, ^item)" on-change=":host.changeHandler($event)"></${t.P}-checkbox></li>\n </template>\n </ol>\n</${t.P}-repeater><span class="${t.PCSS}-readonly"><${t.P}-text text="{{ :host.viewValue }}"></${t.P}-text></span><${t.P}-data></${t.P}-data><${t.P}-content></${t.P}-content>`,shadow:t.Defaults.USE_SHADOW_ROOT})],de);var he=function(e,t,i,a){var s,r=arguments.length,n=r<3?t:null===a?a=Object.getOwnPropertyDescriptor(t,i):a;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(e,t,i,a);else for(var o=e.length-1;o>=0;o--)(s=e[o])&&(n=(r<3?s(n):r>3?s(t,i,n):s(t,i))||n);return r>3&&n&&Object.defineProperty(t,i,n),n};let pe=class PacemChildFormPropagatorElement extends t.PacemEventTarget{propertyChangedCallback(e,i,a,s){if(super.propertyChangedCallback(e,i,a,s),!s){const i=this.property,s=this.watch,r=!t.Utils.isNullOrEmpty(i),n=!t.Utils.isNull(this.model);("watch"===e||"property"===e||"model"===e&&r&&n&&t.Utils.isArray(a)&&a.some(e=>!(i in e)||e[i]!==s)||"model"===e&&r&&n&&!t.Utils.isArray(a)&&(!(i in a)||a[i]!==s))&&this._synchronize()}}viewActivatedCallback(){super.viewActivatedCallback(),this._synchronize()}_synchronize(){const e=this.model,i=this.property,a=this.watch;if(!t.Utils.isNullOrEmpty(e)&&!t.Utils.isNullOrEmpty(i))if(t.Utils.isArray(e)){for(let t of e)t[i]=a;this.model=e.slice(0)}else e[i]=a,this.model=t.Utils.extend({},e)}};he([t.Watch({emit:!0})],pe.prototype,"model",void 0),he([t.Watch({emit:!1,converter:t.PropertyConverters.String,reflectBack:!0})],pe.prototype,"property",void 0),he([t.Watch({emit:!1})],pe.prototype,"watch",void 0),pe=he([t.CustomElement({tagName:t.P+"-childform-propagator"})],pe);let ue=class PacemChildFormElement extends PacemBaseElement{constructor(){super(...arguments),this._model=[],this._subForms=[]}get inputFields(){return[]}toggleReadonlyView(e){}onChange(e){return new Promise((e,t)=>{var i=this._modelToEntity();e(this.value=i)})}acceptValue(e){this._entityToModel(e)}getViewValue(e){return""}convertValueAttributeToProperty(e){return t.PropertyConverters.Json.convert(e,this)}propertyChangedCallback(e,t,i,a){if(super.propertyChangedCallback(e,t,i,a),"mode"===e)this._entityToModel()}_dragStart(e){var i=e.detail;const a=t.Utils.offset(i.element),s=i.floater;s.style.width=a.width+"px",s.style.height=a.height+"px"}_dragEnd(e){"array"===this.mode&&this._triggerChange()}reset(){super.reset(),this._subForms.forEach(e=>{e.setPristine()})}_itemCreate(e){const i=e.detail.index,a=this._subForms;e.detail.dom[0].childNodes.forEach(e=>{e instanceof Element&&e.localName===t.P+"-form"&&a.splice(i,a.length-i,e)})}_itemChange(e,i){"entity"===i.detail.propertyName&&t.Utils.Json.stringify(this._model[e])!==t.Utils.Json.stringify(i.detail.currentValue)&&(this._model.splice(e,1,i.detail.currentValue),this._triggerChange())}_deleteAt(e){t.avoidHandler(e.srcEvent);const i=this._model;"array"===this.mode?i.splice(e.detail,1):i.splice(0,i.length),this._triggerChange()}_addItem(e){const t=this.mode,i=this._model;"array"===t?i.push({}):i.splice(0,i.length,{}),this._triggerChange()}_triggerChange(){this.changeHandler(new Event("change"))}_entityToModel(e=this.value){if("array"===this.mode){let i=e||[];t.Utils.isArray(i)&&this._model.cloneFrom(i)}else{const i=this._model,a=i.length;1===a&&i[0]===e||(t.Utils.isNull(e)?i.splice(0,a):i.splice(0,a,e))}}_modelToEntity(e=this._model){return"array"===this.mode?t.Utils.clone(e):e&&e.length&&e[0]||null}};he([t.Watch({emit:!1,converter:t.PropertyConverters.String})],ue.prototype,"fetchCredentials",void 0),he([t.Watch({emit:!1,converter:t.PropertyConverters.Json})],ue.prototype,"fetchHeaders",void 0),he([t.ViewChild("."+t.PCSS+"-childform")],ue.prototype,"_container",void 0),he([t.ViewChild(t.P+"-drag-drop")],ue.prototype,"_dragger",void 0),he([t.ViewChild("."+t.PCSS+"-childform-item-floater")],ue.prototype,"_floater",void 0),he([t.Watch({converter:t.PropertyConverters.String})],ue.prototype,"mode",void 0),he([t.Watch({converter:t.PropertyConverters.Boolean})],ue.prototype,"lockItems",void 0),he([t.Watch({converter:t.PropertyConverters.Json})],ue.prototype,"metadata",void 0),he([t.Watch({converter:t.PropertyConverters.Json})],ue.prototype,"_model",void 0),ue=he([t.CustomElement({tagName:t.P+"-childform",shadow:t.Defaults.USE_SHADOW_ROOT,template:`<${t.P}-repeater datasource="{{ :host._model }}" on-itemdelete=":host._deleteAt($event)" on-${t.Components.RepeaterItemCreateEventName}=":host._itemCreate($event)">\n <div class="${t.PCSS}-childform">\n <template>\n <${t.P}-panel class="${t.PCSS}-childform-item" behaviors="{{ [::_dragger] }}">\n <${t.P}-panel class="childform-item-handle ${t.PCSS}-margin margin-right-1" hide="{{ :host.lockItems || :host.readonly || :host.mode !== 'array' || !(:host._model && :host._model.length > 1) }}"><i class="${t.PCSS}-icon drag-handle">drag_handle</i></${t.P}-panel>\n <${t.P}-panel class="childform-item-index text-small"><${t.P}-span hide="{{ !:host.readonly || :host.mode !== 'array' }}" class="${t.PCSS}-margin margin-right-1" text="{{ ^index+1 }}"></${t.P}-span></${t.P}-panel>\n <${t.P}-form entity="{{ ^item }}" fetch-headers="{{ :host.fetchHeaders }}" fetch-credentials="{{ :host.fetchCredentials }}" on-${t.PropertyChangeEventName}=":host._itemChange(^index, $event)" readonly="{{ :host.readonly }}" metadata="{{ :host.metadata }}" autogenerate="true" logger="{{ :host.logger }}"></${t.P}-form>\n <${t.P}-button tab-order="-1" class="flat circular circle-small clear ${t.PCSS}-margin margin-left-1" hide="{{ :host.lockItems || :host.readonly }}" command-name="delete" command-argument="{{ ^index }}"></${t.P}-button>\n </${t.P}-panel>\n </template>\n </div>\n <${t.P}-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)"></${t.P}-button>\n</${t.P}-repeater>\n<div class="${t.PCSS}-childform-item-floater ${t.PCSS}-panel panel-border">\n <div class="corner top-left"></div><div class="corner top-right"></div><div class="corner bottom-left"></div><div class="corner bottom-right"></div>\n</div>\n<${t.P}-drag-drop floater="{{ ::_floater }}" disabled="{{ :host.lockItems }}"\n on-${t.UI.DragDropEventType.Start}=":host._dragStart($event)"\n on-${t.UI.DragDropEventType.End}=":host._dragEnd($event)" \n drop-behavior="${t.UI.DropBehavior.InsertChild}" mode="${t.UI.DragDataMode.Alias}" handle-selector=".drag-handle" drop-targets="{{ [::_container] }}"></${t.P}-drag-drop>`})],ue);var me=function(e,t,i,a){var s,r=arguments.length,n=r<3?t:null===a?a=Object.getOwnPropertyDescriptor(t,i):a;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(e,t,i,a);else for(var o=e.length-1;o>=0;o--)(s=e[o])&&(n=(r<3?s(n):r>3?s(t,i,n):s(t,i))||n);return r>3&&n&&Object.defineProperty(t,i,n),n};const ve={convert:(e,i)=>/\{.+\}/.test(e)?t.PropertyConverters.Json.convert(e):t.PropertyConverters.String.convert(e),convertBack:(e,i)=>"string"==typeof e?e:t.PropertyConverters.Json.convertBack(e,i)};let ge=class PacemDatetimePickerElement extends PacemBaseElement{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 t.PropertyConverters.Datetime.convert(e)}connectedCallback(){super.connectedCallback();const e=new Date;let i=this.year=e.getFullYear();this.min=new Date(i-100,0,1),this.max=new Date(i+10,11,31),this.month=e.getMonth();let a=[],s=[],r=[],n=t.Utils.leftPad;for(let e=0;e<12;e++){let s=new Date(i,e,1),r=s.toLocaleString(t.Utils.lang(this),{month:"short"});a.push({value:e,date:s,label:r})}this._months=a;for(let e=0;e<24;e++)s.push(n(e,2,"0"));this._a24=s;for(let e=0;e<60;e++)r.push(n(e,2,"0"));this._a60=r}propertyChangedCallback(e,i,a,s){switch(super.propertyChangedCallback(e,i,a,s),e){case"dateValue":this.log(t.Logging.LogLevel.Log,`dateValue changed from ${i} to ${a}`),this._disassembleDate(a);break;case"min":case"max":t.Utils.isNullOrEmpty(this.min)||t.Utils.isNullOrEmpty(this.max)||this._setupYears();break;case"year":case"month":this._buildupDates();break;case"date":case"hours":case"minutes":case"seconds":this._buildup()}}acceptValue(e){this.dateValue=t.Utils.parseDate(e)}_disassembleDate(e){if(!e)return void(this.date=void 0);"string"==typeof e&&(e=t.Utils.parseDate(e));const i=e=>t.Utils.leftPad(e,2,"0");this.year=e.getFullYear(),this.month=e.getMonth(),this.date=e.getDate(),this.hours=i(e.getHours()),this.minutes=i(e.getMinutes()),this.seconds=i(e.getSeconds())}_setupYears(){let e=[];const i=t.Utils.parseDate(this.min),a=t.Utils.parseDate(this.max);for(let t=i.getFullYear();t<=a.getFullYear();t++)e.push(t);this._years=e}onChange(e){return new Promise((e,t)=>{e(this.value=this._computeValue())})}_buildupDates(e){e&&e.stopPropagation();const i=this,a={weekday:"short",day:"numeric"},s=e=>{try{let t=+i.month;return new Date(+i.year,+i.month,e).getMonth()==t}catch(e){return!1}};var r=[];if(!t.Utils.isNullOrEmpty(i.year)&&!t.Utils.isNullOrEmpty(i.month)){let e=1;do{let s=new Date(+i.year,+i.month,e),n=s.toLocaleString(t.Utils.lang(this),a);r.push({value:e,date:s,label:n,disabled:s<this.min||s>this.max})}while(s(++e))}this._dates=r,s(+this.date)?this._buildup():this.date=""}_computeValue(){const e=this;if(t.Utils.isNullOrEmpty(e.year)||t.Utils.isNullOrEmpty(e.month)||t.Utils.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(e){return null}}_buildup(e){e&&e.stopPropagation(),this.dateValue=this._computeValue()}getViewValue(e){const i=e;return i?t.Utils.core.date(i,this.format||("day"!=this.precision?"full":"short"),t.Utils.lang(this)):""}};me([t.ViewChild("."+t.PCSS+"-datetime-picker-year > "+t.P+"-select")],ge.prototype,"_yearel",void 0),me([t.ViewChild("."+t.PCSS+"-datetime-picker-month > "+t.P+"-select")],ge.prototype,"_monthel",void 0),me([t.ViewChild("."+t.PCSS+"-datetime-picker-date > "+t.P+"-select")],ge.prototype,"_dateel",void 0),me([t.ViewChild("."+t.PCSS+"-datetime-picker-hours > "+t.P+"-select")],ge.prototype,"_hourel",void 0),me([t.ViewChild("."+t.PCSS+"-datetime-picker-minutes > "+t.P+"-select")],ge.prototype,"_minel",void 0),me([t.ViewChild("."+t.PCSS+"-datetime-picker-seconds > "+t.P+"-select")],ge.prototype,"_secel",void 0),me([t.ViewChild(`div.${t.PCSS}-datetime-picker-fields`)],ge.prototype,"_allFields",void 0),me([t.Watch({converter:t.PropertyConverters.Datetime})],ge.prototype,"dateValue",void 0),me([t.Watch({converter:t.PropertyConverters.Datetime})],ge.prototype,"min",void 0),me([t.Watch({converter:t.PropertyConverters.Datetime})],ge.prototype,"max",void 0),me([t.Watch({converter:t.PropertyConverters.String})],ge.prototype,"precision",void 0),me([t.Watch({emit:!1,converter:ve})],ge.prototype,"format",void 0),me([t.Watch()],ge.prototype,"_dates",void 0),me([t.Watch()],ge.prototype,"_years",void 0),me([t.Watch()],ge.prototype,"year",void 0),me([t.Watch()],ge.prototype,"month",void 0),me([t.Watch()],ge.prototype,"date",void 0),me([t.Watch()],ge.prototype,"hours",void 0),me([t.Watch()],ge.prototype,"minutes",void 0),me([t.Watch()],ge.prototype,"seconds",void 0),me([t.Debounce(10)],ge.prototype,"_buildup",null),ge=me([t.CustomElement({tagName:t.P+"-datetime-picker",shadow:t.Defaults.USE_SHADOW_ROOT,template:`<div class="${t.PCSS}-datetime-picker">\n <div class="${t.PCSS}-datetime-picker-fields ${t.PCSS}-viewfinder">\n\n <div class="${t.PCSS}-datetime-picker-year">\n <${t.P}-select value="{{ :host.year, twoway }}" placeholder="..." datasource="{{ :host._years }}">\n </${t.P}-select></div>\n\n <div class="${t.PCSS}-datetime-picker-month">\n <${t.P}-select value="{{ :host.month, twoway }}" placeholder="..." value-property="value" text-property="label" datasource="{{ :host._months }}">\n </${t.P}-select></div>\n\n <div class="${t.PCSS}-datetime-picker-date">\n <${t.P}-select value="{{ :host.date, twoway }}" placeholder="..." value-property="value" text-property="label" datasource="{{ :host._dates }}">\n </${t.P}-select></div>\n\n <${t.P}-panel class="${t.PCSS}-datetime-picker-hours" hide="{{ :host.precision === 'day' }}">\n <${t.P}-select value="{{ :host.hours, twoway }}" datasource="{{ :host._a24 }}">\n </${t.P}-select></${t.P}-panel>\n\n <${t.P}-panel class="${t.PCSS}-datetime-picker-minutes" hide="{{ :host.precision === 'day' }}">\n <${t.P}-select value="{{ :host.minutes, twoway }}" datasource="{{ :host._a60 }}">\n </${t.P}-select></${t.P}-panel>\n\n <${t.P}-panel class="${t.PCSS}-datetime-picker-seconds" hide="{{ :host.precision !== 'second' }}">\n <${t.P}-select value="{{ :host.seconds, twoway }}" datasource="{{ :host._a60 }}">\n </${t.P}-select></${t.P}-panel>\n\n </div>\n <${t.P}-panel class="${t.PCSS}-datetime-picker-preview" hide="{{ Pacem.Utils.isNullOrEmpty(:host.dateValue) || :host.precision === 'day' || :host.readonly }}">\n <dl>\n <dt>local:</dt><dd><${t.P}-text text="{{ :host.viewValue }}"></${t.P}-text></dd>\n <dt>iso:</dt><dd><${t.P}-text text="{{ (:host.dateValue && :host.dateValue.toISOString()) || '' }}"></${t.P}-text></dd>\n </dl>\n </${t.P}-panel>\n <${t.P}-span class="${t.PCSS}-readonly" css-class="{{ { 'date': :host.precision === 'day', 'datetime': :host.precision !== 'day' } }}" content="{{ :host.viewValue }}" hide="{{ !:host.readonly }}"></${t.P}-span>\n</div>`})],ge);var ye=function(e,t,i,a){var s,r=arguments.length,n=r<3?t:null===a?a=Object.getOwnPropertyDescriptor(t,i):a;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(e,t,i,a);else for(var o=e.length-1;o>=0;o--)(s=e[o])&&(n=(r<3?s(n):r>3?s(t,i,n):s(t,i))||n);return r>3&&n&&Object.defineProperty(t,i,n),n};class PacemBaseValidatorElement extends PacemFormRelevantElement{constructor(){super()}viewActivatedCallback(){super.viewActivatedCallback(),t.Utils.addClass(this,t.PCSS+"-validator")}propertyChangedCallback(e,i,a,s){super.propertyChangedCallback(e,i,a,s);let r=this.form;switch(e){case"watch":i&&r&&r.unregisterValidator(a,this),r&&r.registerValidator(a,this);break;case"invalid":break;case"form":let e=this.watch;t.Utils.isNullOrEmpty(e)||(null!=i&&i.unregisterValidator(e,this),null!=a&&a.registerValidator(e,this));break;case"disabled":this.triggerFormFieldValidation()}}#h;triggerFormFieldValidation(){const e=this.form,i=this.watch;t.Utils.isNull(e)||t.Utils.isNullOrEmpty(i)||(cancelAnimationFrame(this.#h),this.#h=requestAnimationFrame(()=>{e.validate(i)}))}validate(e){return this.disabled?t.Utils.fromResult(!0):this.evaluate(e)}}ye([t.Watch({converter:t.PropertyConverters.Boolean})],PacemBaseValidatorElement.prototype,"invalid",void 0),ye([t.Watch({converter:t.PropertyConverters.String})],PacemBaseValidatorElement.prototype,"errorMessage",void 0),ye([t.Watch({emit:!1,reflectBack:!0,converter:t.PropertyConverters.String})],PacemBaseValidatorElement.prototype,"watch",void 0);const fe=`<${t.P}-span part="error-message" hide="{{ !:host.invalid }}" text="{{ :host.errorMessage }}"></${t.P}-span>`;function _e(e){return t.Utils.isNullOrEmpty(e)}let be=class PacemRequiredValidatorElement extends PacemBaseValidatorElement{evaluate(e){let i=!_e(e);return t.Utils.fromResult(i)}};be=ye([t.CustomElement({tagName:t.P+"-required-validator",template:fe,shadow:t.Defaults.USE_SHADOW_ROOT})],be);let Ce=class PacemRegexValidatorElement extends PacemBaseValidatorElement{propertyChangedCallback(e,t,i,a){super.propertyChangedCallback(e,t,i,a),a||"pattern"!==e||this.triggerFormFieldValidation()}evaluate(e){let i=!0,a=this.pattern;return _e(e)||(i=new RegExp(a).test(e)),t.Utils.fromResult(i)}};ye([t.Watch({emit:!1,converter:t.PropertyConverters.String})],Ce.prototype,"pattern",void 0),Ce=ye([t.CustomElement({tagName:t.P+"-regex-validator",template:fe,shadow:t.Defaults.USE_SHADOW_ROOT})],Ce);let Pe=class PacemLengthValidatorElement extends PacemBaseValidatorElement{propertyChangedCallback(e,t,i,a){super.propertyChangedCallback(e,t,i,a),a||"min"!==e&&"max"!==e||this.triggerFormFieldValidation()}evaluate(e){let i=!0;return _e(e)||(this.min>=0&&(i=i&&(e||"").toString().length>=this.min),this.max>=0&&(i=i&&(e||"").toString().length<=this.max)),t.Utils.fromResult(i)}};ye([t.Watch({emit:!1,converter:t.PropertyConverters.Number})],Pe.prototype,"min",void 0),ye([t.Watch({emit:!1,converter:t.PropertyConverters.Number})],Pe.prototype,"max",void 0),Pe=ye([t.CustomElement({tagName:t.P+"-length-validator",template:fe,shadow:t.Defaults.USE_SHADOW_ROOT})],Pe);let Ee=class PacemRangeValidatorElement extends PacemBaseValidatorElement{propertyChangedCallback(e,t,i,a){super.propertyChangedCallback(e,t,i,a),a||"min"!==e&&"max"!==e||this.triggerFormFieldValidation()}evaluate(e){let i=!0;if(!_e(e)){let a=e;e instanceof Date||"number"!=typeof e&&(a=t.Utils.parseDate(e))instanceof Date&&isFinite(a.valueOf())?(null!=this.min&&(i=i&&a.valueOf()>=t.Utils.parseDate(this.min).valueOf()),null!=this.max&&(i=i&&a.valueOf()<=t.Utils.parseDate(this.max).valueOf())):(null!=this.min&&(i=i&&e>=this.min),null!=this.max&&(i=i&&e<=this.max))}return t.Utils.fromResult(i)}};ye([t.Watch({emit:!1,converter:t.PropertyConverters.Number})],Ee.prototype,"min",void 0),ye([t.Watch({emit:!1,converter:t.PropertyConverters.Number})],Ee.prototype,"max",void 0),Ee=ye([t.CustomElement({tagName:t.P+"-range-validator",template:fe,shadow:t.Defaults.USE_SHADOW_ROOT})],Ee);let we=class PacemCompareValidatorElement extends PacemBaseValidatorElement{propertyChangedCallback(e,t,i,a){super.propertyChangedCallback(e,t,i,a),a||"operator"!==e&&"to"!==e||this.triggerFormFieldValidation()}_prepareValuesForComparison(e,i){return t.Utils.Dates.isDate(e)||t.Utils.Dates.isDate(i)?[t.Utils.parseDate(e),t.Utils.parseDate(i)]:[e,i]}evaluate(e){let i=!0,a=this.to;if(!_e(e)&&!_e(a)){const t=this._prepareValuesForComparison(e,a);switch(e=t[0],a=t[1],this.operator){case"lessOrEqual":i=e<=a;break;case"less":i=e<a;break;case"greaterOrEqual":i=e>=a;break;case"greater":i=e>a;break;case"notEqual":i=e!==a;break;default:i=e===a}}return t.Utils.fromResult(i)}};ye([t.Watch({emit:!1,converter:t.PropertyConverters.String})],we.prototype,"operator",void 0),ye([t.Watch({emit:!1,reflectBack:!0})],we.prototype,"to",void 0),we=ye([t.CustomElement({tagName:t.P+"-compare-validator",template:fe,shadow:t.Defaults.USE_SHADOW_ROOT})],we);let Se=class PacemBinaryValidatorElement extends PacemBaseValidatorElement{propertyChangedCallback(e,t,i,a){super.propertyChangedCallback(e,t,i,a),a||"pattern"!==e&&"maxSize"!==e||this.triggerFormFieldValidation()}evaluate(e){let i=!0,a=this.pattern,s=this.maxSize;if(!_e(e)){if(!t.Utils.isNullOrEmpty(a)){let t="string"==typeof e?e:e.name;i=new RegExp(a,"i").test(t)}!t.Utils.isNull(s)&&"object"==typeof e&&e.size>0&&(i=i&&e.size<=s)}return t.Utils.fromResult(i)}};ye([t.Watch({emit:!1,converter:t.PropertyConverters.String})],Se.prototype,"pattern",void 0),ye([t.Watch({emit:!1,converter:t.PropertyConverters.String})],Se.prototype,"maxSize",void 0),Se=ye([t.CustomElement({tagName:t.P+"-binary-validator",template:fe,shadow:t.Defaults.USE_SHADOW_ROOT})],Se);let ke=class PacemAsyncValidatorElement extends PacemBaseValidatorElement{constructor(){super(...arguments),this._deferredToken=null}_evaluateResult(){const e=this._fetcher.result;switch(e){case"true":return!0;case"false":return!1;default:try{let i=JSON.parse(e);return t.Utils.getApiResult(i)||!1}catch(e){return!1}}}_fetch(e){const i=this._deferredToken,a=this._fetcher;var s=this.parameters||{};s[this.watch]=e;const r={parameters:s,url:this.url,as:"text",method:this.method},n=t.Utils.jsonSortStringify(r),o=this.#p;let l=!1;if(t.Utils.isNullOrEmpty(o)||(l=n===o),l){const e=this._evaluateResult();i.resolve(e)}else t.Utils.extend(a,r),clearTimeout(this._debouncer),this._debouncer=setTimeout(()=>{a.fetch().then(e=>{const t=this._evaluateResult();i.resolve(t),this.#p=n},e=>{i.resolve(!1)})},1e3);return i.promise}#p;evaluate(e){return t.Utils.isNullOrEmpty(e)?t.Utils.fromResult(!0):(this._deferredToken=this._deferredToken=t.DeferPromise.defer(),this._fetch(e).then(e=>(this._deferredToken=null,e),e=>(this._deferredToken=null,!1)))}propertyChangedCallback(e,t,i,a){if(super.propertyChangedCallback(e,t,i,a),!a)switch(e){case"parameters":case"url":case"method":case"fetchCredentials":case"fetchHeaders":this.triggerFormFieldValidation()}}};ye([t.Watch({emit:!1,converter:t.PropertyConverters.Json})],ke.prototype,"parameters",void 0),ye([t.Watch({emit:!1,converter:t.PropertyConverters.Json})],ke.prototype,"fetchCredentials",void 0),ye([t.Watch({emit:!1,converter:t.PropertyConverters.Json})],ke.prototype,"fetchHeaders",void 0),ye([t.Watch({emit:!1,converter:t.PropertyConverters.String})],ke.prototype,"url",void 0),ye([t.Watch({emit:!1,converter:t.PropertyConverters.String})],ke.prototype,"method",void 0),ye([t.ViewChild(t.P+"-fetch")],ke.prototype,"_fetcher",void 0),ke=ye([t.CustomElement({tagName:t.P+"-async-validator",template:fe+`<${t.P}-fetch autofetch="false" throttle="true" credentials="{{ :host.fetchCredentials }}" headers="{{ :host.fetchHeaders }}"></${t.P}-fetch>`,shadow:t.Defaults.USE_SHADOW_ROOT})],ke);let $e=class PacemCustomValidatorElement extends PacemBaseValidatorElement{propertyChangedCallback(e,t,i,a){super.propertyChangedCallback(e,t,i,a),a||"isValid"!==e||this.triggerFormFieldValidation()}evaluate(e){let i=!0;return _e(e)||(i=!!this.isValid),t.Utils.fromResult(i)}};ye([t.Watch({emit:!1,converter:t.PropertyConverters.Boolean})],$e.prototype,"isValid",void 0),$e=ye([t.CustomElement({tagName:t.P+"-custom-validator",template:fe,shadow:t.Defaults.USE_SHADOW_ROOT})],$e);var Ue=function(e,t,i,a){var s,r=arguments.length,n=r<3?t:null===a?a=Object.getOwnPropertyDescriptor(t,i):a;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(e,t,i,a);else for(var o=e.length-1;o>=0;o--)(s=e[o])&&(n=(r<3?s(n):r>3?s(t,i,n):s(t,i))||n);return r>3&&n&&Object.defineProperty(t,i,n),n};function Ne(e){return new RegExp(e).source}let Oe=class PacemFormFieldElement extends PacemFormRelevantElement{constructor(e=new i.Components.UI.MarkdownService){super(),this._md=e,this._entityPropertyChangeHandler=e=>{this.dispatchEvent(new t.PropertyChangeEvent({propertyName:"entity",currentValue:this.entity}))},this._labelClickHandler=e=>{document.getElementById(this._label.htmlFor).focus()},this._key="_"+t.Utils.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,i,a,s){switch(super.propertyChangedCallback(e,i,a,s),e){case"readonly":this._ensureBalloon();break;case"metadata":this._ensureBalloon(),this._buildUpCss(),this._buildUpLabel(),this._buildUpField();break;case"entity":i instanceof HTMLElement&&i.removeEventListener(t.PropertyChangeEventName,this._entityPropertyChangeHandler,!1),a instanceof HTMLElement&&a.addEventListener(t.PropertyChangeEventName,this._entityPropertyChangeHandler,!1)}}disconnectedCallback(){this.entity instanceof HTMLElement&&this.entity.removeEventListener(t.PropertyChangeEventName,this._entityPropertyChangeHandler,!1),t.Utils.isNull(this._label)||this._label.removeEventListener("click",this._labelClickHandler,!1),t.Utils.isNull(this._balloon)||this._balloon.remove(),super.disconnectedCallback()}_normalizeTooltip(){const e=this.metadata&&this.metadata.extra&&this.metadata.extra.tooltip||!1;return"object"==typeof e?e:{type:e}}_ensureBalloon(){var e,a;const s=this.readonly||!1===(a=this._normalizeTooltip()).type||t.Utils.isNullOrEmpty(e=this.metadata&&this.metadata.display&&this.metadata.display.description);if(t.Utils.isNull(this._balloon)&&!s){let e=document.createElement(t.P+"-balloon");e.options={behavior:i.Components.UI.BalloonBehavior.Tooltip,trigger:a.trigger||i.Components.UI.BalloonTrigger.Hover,position:a.position||i.Components.UI.BalloonPosition.Top,hoverDelay:200,hoverTimeout:50,align:a.align||i.Components.UI.BalloonAlignment.Auto},t.Utils.addClass(e,t.PCSS+"-field-tooltip"),t.CustomElementUtils.findAncestorShell(this).appendChild(this._balloon=e)}const r=this._balloon;if(!(t.Utils.isNull(r)||(r.target=this._label,r.disabled=s))){const t=e||"";switch(a.type){case"md":case"markdown":r.innerHTML=this._md.toHtml(t);break;case"html":r.innerHTML=t;break;default:r.innerText=t}}}_buildUpCss(){const e=this.metadata?.display;if(!t.Utils.isNull(e)){if("function"==typeof e.cssClass){const{cssClassAttr:t}=e.cssClass(this,"$this","$this.entity");this.setAttribute("css-class",t)}else this.cssClass=e.cssClass;if("function"==typeof e.css){const{cssAttr:t}=e.css(this,"$this","$this.entity");this.setAttribute("css",t)}else this.css=e.css}}_buildUpLabel(){const e=this._label,i=e.firstElementChild,a=this.metadata;e.htmlFor=this._key,t.Utils.addClass(e,t.PCSS+"-label");const s=this.metadata.validators;if(s&&s.find(e=>"required"===e.type)?t.Utils.addClass(e,t.PCSS+"-required"):t.Utils.removeClass(e,t.PCSS+"-required"),t.Utils.isNull(this._balloon)||this._balloon.disabled?t.Utils.removeClass(e,t.PCSS+"-tooltip"):t.Utils.addClass(e,t.PCSS+"-tooltip"),"function"==typeof a.display?.name){const{contentAttr:e}=a.display.name(this,":host",":host.entity","::_form");i.setAttribute("content",e)}else i.removeAttribute("content"),i.content=a.display&&a.display.name||a.prop;e.setAttribute("id","label"+this._key),e.addEventListener("click",this._labelClickHandler,!1)}_isValueNullOrEmpty(e=this.entity,i=this.metadata){if(t.Utils.isNull(i))return!0;const a=i.prop.split(".");let s=e;for(let e=0;e<a.length;e++){const i=a[e];if(t.Utils.isNullOrEmpty(s&&s[i]))return!0;s=s[i]}return!1}_handleValueChange(e){if("value"===e.detail.propertyName){const i=e.detail.currentValue,a=this.metadata.prop;if(this.entity instanceof HTMLElement){let e=t.CustomElementUtils.camelToKebab(a);t.Utils.isNullOrEmpty(i)?this.entity.removeAttribute(e):this.entity.setAttribute(e,i.toString())}else this.entity[a]=i}}_adjustDependencyValue(e){return t.Utils.Dates.isDate(e)?t.Utils.Dates.parse(e).toISOString():e}_broadcastFetchResult(e){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","form"+this._key),e.setAttribute("sudden-validation","{{ ::form.suddenValidation }}")}_apiResult(e){return t.Utils.getApiResult(e)}_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 i=this.metadata;let a=t.P+"-input-text",s=t.P+(i.display&&"slider"===i.display.ui?"-slider":"-input-number"),r={id:this._key,name:i.prop,readonly:"{{ :host.readonly || :host.metadata.isReadOnly || ::_form.readonly }}",value:`{{ :host.entity.${i.prop}, twoway }}`,placeholder:`${i.display&&i.display.watermark||""}`};1==i.extra?.autofocus&&(r["on-load"]="requestAnimationFrame(() => $this.focus())");let n=i.extra||{},o={},l="false",c="",d="",h="",p=[];if(!t.Utils.isNullOrEmpty(n.dependsOn))if("function"==typeof n.dependsOn){const E=n.dependsOn(this,":host",":host.entity","$this.entity"),w=E.hideAttr;if(t.Utils.isNullOrEmpty(w)||this.setAttribute("hide",w),t.Utils.isNullOrEmpty(E.disabledAttr)||(l=E.disabledAttr,t.CustomElementUtils.isBindingAttribute(l)&&(d=t.CustomElementUtils.extractBindingAttributeExpression(l))),!t.Utils.isNullOrEmpty(E.parameterAttrs)){const S=E.parameterAttrs,k=[];for(let $ in S){const U=S[$];k.push(`${$}: ${U}`),p.push({prop:U})}h=k.join(", ")}}else{p=n.dependsOn;let N={empty:[],notEqual:{}},O={empty:[],notEqual:{}},x=[];for(var u of p){let D=":host.entity."+u.prop,H="$this.entity."+u.prop;if(t.Utils.isNullOrEmpty(u.value)){if(!u.optional){let A=e=>"$pacem.isNullOrEmpty("+e+")";N.empty.push(A(D)),u.hide&&O.empty.push(A(H))}}else{let T=e=>e+" !== "+JSON.stringify(u.value);(N.notEqual[D]=N.notEqual[D]||[]).push(T(D)),u.hide&&(O.notEqual[H]=O.notEqual[H]||[]).push(T(H))}x.push(`${u.alias||u.prop}: :host._adjustDependencyValue(${D})`),u.optional||(c+=`!$pacem.isNullOrEmpty(${D}) && `)}h=x.join(", ");let V=e=>{let i="false",a="false";if(!t.Utils.isNullOrEmpty(e.notEqual)){const t=[];for(let i in e.notEqual)t.push("("+e.notEqual[i].join(" && ")+")");i="("+t.join(" || ")+")"}return t.Utils.isNullOrEmpty(e.empty)||(a="("+e.empty.join(" || ")+")"),i+" || "+a};d=V(N),l=`{{ ${d} }}`,this.setAttribute("hide",`{{ ${V(O)} }}`)}const m="fn",v=this[m]=this[m]||{},g=(e=[])=>{let i=(p||[]).map(e=>":host.entity."+e.prop).join(", ");const a="fn"+t.Utils.uniqueCode();if("function"==typeof e)v[a]=e;else{if(!t.Utils.isArray(e))throw"Unsupported source format.";v[a]=()=>e}return`{{ :host.${m}.${a}(${i}) }}`},y=new DocumentFragment;let f;if("function"==typeof i.type){var _=i.type(this,":host",":host.entity");if(-1===_.tagName.indexOf("-"))this.log(t.Logging.LogLevel.Error,`${a} is not an allowed form-field`);else{function R(e,i){if(!t.Utils.isNullOrEmpty(i))for(let s of i){if(-1===s.tagName.indexOf("-")){this.log(t.Logging.LogLevel.Error,`${s.tagName} is not an allowed child element for form-field ${a}`);continue}const i=document.createElement(s.tagName);if(!t.Utils.isNullOrEmpty(s.attrs))for(let e in s.attrs){const t=s.attrs[e];i.setAttribute(e,t)}t.Utils.isNullOrEmpty(s.children)||R(i,s.children),e.appendChild(i)}}a=_.tagName,t.Utils.extend(r,_.attrs||{}),R(y,_.children)}}else switch(f=i.display&&i.display.ui){case"contentEditable":console.warn("`contentEditable` ui hint is deprecated. Lean on `dataType` equal to 'HTML' instead."),a=t.P+"-contenteditable",y.append(ContenteditableUtils.getDefaultDashboard());break;case"snapshot":a=t.P+"-snapshot",n.width>0&&(r.width=""+n.width),n.height>0&&(r.height=""+n.height),n.quality>=0&&(r.quality=""+n.quality);break;case"chars":case"digits":case"otp":a=t.P+"-input-chars",n.charCount>0&&(r.charCount=""+n.charCount),t.Utils.isNullOrEmpty(n.inputTransform)||(r["input-transform"]=n.inputTransform);break;case"oneToMany":case"dropdown":case"radioList":case"checkboxList":case"manyToMany":"oneToMany"===f||"dropdown"===f?(a=t.P+"-select",!1!==n.preventWheel&&(r["on-wheel"]="$event.preventDefault()")):(delete r.placeholder,a=t.P+("radioList"===f?"-radio-list":"-checkbox-list")),t.Utils.isNullOrEmpty(n.textProperty)||(r["text-property"]=n.textProperty),t.Utils.isNullOrEmpty(n.disabledProperty)||(r["disabled-property"]=n.disabledProperty),t.Utils.isNullOrEmpty(n.valueProperty)||(i.isComplexType?r["compare-by"]=n.valueProperty:r["value-property"]=n.valueProperty),t.Utils.isNullOrEmpty(n.source)?(this._fetcher.id=`fetch${this._key}`,this._fetcher.url=n.sourceUrl,this._fetcher.method=n.verb,o.parameters=`{{ { ${h} } }}`,o.disabled=l,r.datasource=`{{ ${c}:host._apiResult(#fetch${this._key}.result) || null }}`):r.datasource=g(n.source);break;case"suggest":case"tags":case"autocomplete":const L="tags"===i.display.ui;a=t.P+(L?"-tags":"-suggest"),this._fetcher.id=`fetch${this._key}`,t.Utils.isNullOrEmpty(n.textProperty)||(r["text-property"]=n.textProperty);let I=`#${this._key}.value`;if(t.Utils.isNullOrEmpty(n.valueProperty)||(r["compare-by"]=n.valueProperty,L?I=`(${I} && ${I}.${n.valueProperty}) || ''`:i.isComplexType?I+=` && ${I}.${n.valueProperty}`:r["value-property"]=n.valueProperty),t.Utils.isNullOrEmpty(n.sourceUrl)?r.datasource=g(n.source):(o.url=`${n.sourceUrl}`,this._fetcher.method=n.verb,t.Utils.isNullOrEmpty(n.dependsOn)?o.parameters=`{{ {q: #${this._key}.hint || '', ${n.valueProperty||"value"}: ${I} || '' } }}`:(o.parameters=`{{ { ${h}, q: #${this._key}.hint || '', ${n.valueProperty||"value"}: ${I} || '' } }}`,o.disabled=l),r.datasource=`{{ ${c}:host._apiResult(#fetch${this._key}.result) || null }}`),L)r["allow-new"]=(!0===i.extra.allowNew).toString(),r["allow-duplicates"]=(!0===i.extra.allowDuplicates).toString();else{if(t.Utils.isNullOrEmpty(n.disabledProperty)||(r["disabled-property"]=n.disabledProperty),!t.Utils.isNullOrEmpty(n.itemtemplate)){const B=n.itemtemplate;B instanceof HTMLElement?(r.itemtemplate="{{ #"+(B.id=B.id||this._key+"_itemtmpl")+" }}",B.isConnected||this.append(B)):r.itemtemplate=B}if(!t.Utils.isNullOrEmpty(n.filterFields)){const j=n.filterFields;r["filter-fields"]=t.Utils.isArray(j)?j.join(" "):j}t.Utils.isNullOrEmpty(n.maxSuggestions)||(r["max-suggestions"]=n.maxSuggestions.toString())}break;case"calendar":a=t.P+"-calendar-picker";const F=i.display?.format??i.extra?.format;t.Utils.isNullOrEmpty(F)||(r.format="{{ "+JSON.stringify(F)+" }}"),t.Utils.isNullOrEmpty(n.disabledRanges)||(r["disabled-ranges"]="{{ "+JSON.stringify(n.disabledRanges)+" }}");break;case"dictionary":a=t.P+"-namevalue-list",r.dictionary="true";break;case"switcher":if("boolean"!==(i.type||"").toLowerCase())break;r.class="checkbox-switch";default:let W=(i.dataType||i.type||"").toLowerCase();switch(W){case"upload":a=t.P+"-upload";let M=i.extra||{};r.url=M.uploadUrl,r.parallelism=""+M.parallelism,r["chunk-size"]=""+M.chunkSize,r["max-image-width"]=""+M.maxImageWidth,r["max-image-height"]=""+M.maxImageHeight,r["select-mode"]=M.mode??"file";break;case"html":a=t.P+"-contenteditable",y.append(ContenteditableUtils.getDefaultDashboard());break;case"enumeration":a=t.P+"-radio-list",r.class=t.PCSS+"-radio-list",r["value-property"]="value",r["text-property"]="caption",r.datasource="{{ "+JSON.stringify(i.extra.enum)+" }}",delete r.placeholder;break;case"password":a=t.P+"-input-password";break;case"emailaddress":a=t.P+"-input-email";break;case"color":a=t.P+"-input-color";break;case"time":case"date":case"datetime":a=t.P+"-datetime-picker",delete r.placeholder,"datetime"===W&&(r.precision="minute");const z=i.display?.format??i.extra?.format;t.Utils.isNullOrEmpty(z)||(r.format="{{ "+JSON.stringify(z)+" }}"),t.Utils.isNullOrEmpty(n.disabledRanges)||(r["disabled-ranges"]="{{ "+JSON.stringify(n.disabledRanges)+" }}");break;case"url":a=t.P+"-input-url";break;case"phonenumber":a=t.P+"-input-tel";break;case"multilinetext":a=t.P+"-textarea";break;case"markdown":a=t.P+"-textarea-markdown";break;case"latlng":a=t.P+"-latlng",t.Utils.isNullOrEmpty(i.extra)||"object"!=typeof i.extra||t.Utils.isArray(i.extra)||(r.options=JSON.stringify(i.extra));break;case"percent":case"percentage":case"currency":let q="currency"===W?{style:"currency",currency:"EUR"}:{style:"percent",maximumFractionDigits:2},J=i.display?.format??q;r.format=JSON.stringify(J);default:switch((i.type||"").toLowerCase()){case"boolean":a=t.P+"-checkbox",r["true-value"]="{{ true }}",r["false-value"]="{{ false }}",r.caption=r.placeholder,delete r.placeholder;break;case"byte":r.min="0",r.max="255";case"int16":case"int32":case"int64":case"short":case"integer":case"int":case"long":r.step=""+(i.extra?.step??"1"),a=s;const Y=i.display?.format;t.Utils.isNullOrEmpty(Y)||(r.format=JSON.stringify(Y)),!1!==n.preventWheel&&a===t.P+"-input-number"&&(r["on-wheel"]="$event.preventDefault()");break;case"double":case"decimal":case"float":case"single":case"number":a=s,r.step=""+(i.extra?.step??"any");const G=i.display?.format;t.Utils.isNullOrEmpty(G)||(r.format=JSON.stringify(G)),!1!==n.preventWheel&&a===t.P+"-input-number"&&(r["on-wheel"]="$event.preventDefault()");break;default:if(("array"===i.type||"object"===i.type)&&!t.Utils.isNullOrEmpty(i.props)){if(a=t.P+"-childform",delete r.placeholder,r.metadata=t.Utils.Json.stringify(i.props,{functions:t.JsonFunctionConversion.Reference}),r.mode=i.type,r["lock-items"]=""+(i.extra&&i.extra.lockItems||!1),r.logger="{{ :host.logger }}",!t.Utils.isNullOrEmpty(p)){var b="";for(let K of p)b+=`<${t.P}-childform-propagator model="${r.value}" watch="{{ :host.entity.${K.prop} }}" property="${K.alias||K.prop}"></${t.P}-childform-propagator>\n`;this._container.innerHTML=b}r["fetch-credentials"]="{{ :host.fetchCredentials }}",r["fetch-headers"]="{{ :host.fetchHeaders }}"}}}}if(!t.Utils.isNullOrEmpty(i.commands)){t.Utils.addClass(this._container,t.PCSS+"-fieldgroup");const X=this._container.appendChild(document.createElement("div")),Z=this._container.appendChild(document.createElement("div"));t.Utils.addClass(X,`fieldgroup-prepend ${t.PCSS}-buttonset buttons`),t.Utils.addClass(Z,`fieldgroup-append ${t.PCSS}-buttonset buttons`);const Q=d||"false";i.commands.forEach(e=>{const a=document.createElement(t.P+"-button");a.setAttribute("icon-glyph",e.icon),a.setAttribute("command-name",e.name),e.dependsOnValue?(a.setAttribute("disabled",`{{ (${Q}) || !::_form.valid || $pacem.isNullOrEmpty(:host.entity.${i.prop}) }}`),a.setAttribute("command-argument",`{{ :host.entity.${i.prop} }}`)):a.setAttribute("disabled",l),a.setAttribute("tooltip",e.tooltip),t.Utils.isNullOrEmpty(e.cssClass)||t.Utils.addClass(a,e.cssClass.join(" ")),(e.prepend?X:Z).appendChild(a)})}t.Utils.isNullOrEmpty(i.validators)||i.validators.forEach(e=>{var s,n={},o={};switch(function(e){return"errorMessage"in e}(e)&&(n=e.params||{},o["error-message"]=e.errorMessage),function(e){return"attributes"in e&&"function"==typeof e.attributes}(e)&&t.Utils.extend(o,e.attributes(this,":host",":host.entity")),e.type){case"required":r.required="true",s=new be;break;case"length":let l=new Pe;s=l;let c=n&&n.max,d=n&&n.min;null!=c?(r.maxlength=""+(l.max=c),a===t.P+"-input-chars"&&(r.count??=""+c)):"max"in o&&(r.max=o.max),null!=d?r.minlength=""+(l.min=d):"min"in o&&(r.minlength=o.min);break;case"range":let h=new Ee;s=h;let u=n&&n.max,m=n&&n.min,v=a===t.P+"-datetime-picker";null!=u?(h.max=u,r.max="{{ "+(v?"'"+u+"'":u)+" }}"):"max"in o&&(r.max=o.max),null!=m?(h.min=m,r.min="{{ "+(v?"'"+m+"'":m)+" }}"):"min"in o&&(r.min=o.min);break;case"email":let g=new Ce;s=g,r.pattern=Ne(g.pattern=/^[\w\-\.]+@[\w\-\.]+\.[a-zA-Z0-9]{2,6}$/);break;case"regex":let y=new Ce;s=y;let f=n.pattern;f||=o.pattern,r.pattern=Ne(f),y.pattern=f;break;case"binary":let _=new Se;s=_;let b=n.pattern;null!=b?(r.pattern=Ne(b),_.pattern=b):"pattern"in o&&(r.pattern=o.pattern);let C=n&&n.maxSize;null!=C?(_.maxSize=C,r["max-size"]=""+C):"max-size"in o&&(r["max-size"]=o["max-size"]);break;case"compare":let P=new we;s=P;let E="";if("value"in n)E=JSON.stringify(n.value);else{E=`:host.entity.${"to"in n?n.to:n.toProperty}`}const w=`{{ ${E} }}`;P.setAttribute("to",w);let S=P.operator=n.operator||o.operator||"equal";if(a===t.P+"-datetime-picker")switch(S){case"lessOrEqual":case"less":r.max=w;break;case"greaterOrEqual":case"greater":r.min=w}break;case"async":let k=new ke;s=k,k.url=n.url;let $=[],U=n.dependsOn||p;$.push(`${i.prop}: :host._adjustDependencyValue(:host.entity.${i.prop})`);for(let e of U||[])$.push(`${e.alias||e.prop}: :host._adjustDependencyValue(:host.entity.${e.prop})`);k.setAttribute("parameters",`{{ { ${$.join(", ")} } }}`),k.method=n.verb||t.Net.HttpMethod.Get,k.setAttribute("fetch-credentials","{{ :host.fetchCredentials }}"),k.setAttribute("fetch-headers","{{ :host.fetchHeaders }}");break;case"custom":s=new $e;break;default:if(!t.Utils.isNullOrEmpty(e.type)&&e.type.indexOf("-")>0){const t=e.type,i=document.createElement(t);i instanceof PacemBaseValidatorElement&&(s=i)}}if(t.Utils.isNull(s))throw`Cannot generate a formfield validator based on type: ${e.type}.`;s.watch=i.prop,s.setAttribute("hide","{{ !this.invalid }}"),s.setAttribute("disabled",l);for(let e in o)s.setAttribute(e,o[e]);this._validators.appendChild(s)});let C=document.createElement(a);for(var P in r){let ee;t.Utils.isNullOrEmpty(ee=r[P])||C.setAttribute(P,ee)}for(var P in C.append(y),this._field=C,this._container.insertBefore(C,this._container.firstElementChild),o){let te;t.Utils.isNullOrEmpty(te=o[P])||this._fetcher.setAttribute(P,te)}this.dispatchEvent(new t.PropertyChangeEvent({propertyName:"field",currentValue:C}))}};Ue([t.ViewChild("label")],Oe.prototype,"_label",void 0),Ue([t.ViewChild(`div.${t.PCSS}-input-container`)],Oe.prototype,"_container",void 0),Ue([t.ViewChild(t.P+"-fetch")],Oe.prototype,"_fetcher",void 0),Ue([t.ViewChild(t.P+"-form")],Oe.prototype,"_form",void 0),Ue([t.ViewChild(t.P+"-panel."+t.PCSS+"-validators")],Oe.prototype,"_validators",void 0),Ue([t.Watch({converter:t.PropertyConverters.Json})],Oe.prototype,"metadata",void 0),Ue([t.Watch({converter:t.PropertyConverters.Json})],Oe.prototype,"fetchHeaders",void 0),Ue([t.Watch({converter:t.PropertyConverters.String})],Oe.prototype,"fetchCredentials",void 0),Ue([t.Watch({converter:t.PropertyConverters.Boolean})],Oe.prototype,"readonly",void 0),Ue([t.Watch()],Oe.prototype,"entity",void 0),Oe=Ue([t.CustomElement({tagName:t.P+"-form-field",template:`<${t.P}-form class="${t.PCSS}-field" logger="{{ :host.logger }}" \ncss-class="{{ {'${t.PCSS}-fetching': ::_fetcher.fetching, '${t.PCSS}-dirty': this.dirty, '${t.PCSS}-invalid': !this.valid, '${t.PCSS}-editable': !:host.readonly, '${t.PCSS}-readonly': :host.readonly, '${t.PCSS}-pristine': !this.dirty, '${t.PCSS}-valid': this.valid, '${t.PCSS}-has-value': !:host._isValueNullOrEmpty(:host.entity, :host.metadata) } }}">\n <label class="${t.PCSS}-label"><${t.P}-span></${t.P}-span></label>\n <div class="${t.PCSS}-input-container"></div>\n <${t.P}-fetch debounce="300" logger="{{ :host.logger }}" credentials="{{ :host.fetchCredentials }}" headers="{{ :host.fetchHeaders }}" diff-by-values="true"\n on-fetchresult=":host._broadcastFetchResult($event.detail)"></${t.P}-fetch>\n <${t.P}-panel class="${t.PCSS}-validators" hide="{{ ::_form.valid || !::_form.dirty || :host.readonly }}"></${t.P}-panel>\n</${t.P}-form>`})],Oe);var xe=function(e,t,i,a){var s,r=arguments.length,n=r<3?t:null===a?a=Object.getOwnPropertyDescriptor(t,i):a;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(e,t,i,a);else for(var o=e.length-1;o>=0;o--)(s=e[o])&&(n=(r<3?s(n):r>3?s(t,i,n):s(t,i))||n);return r>3&&n&&Object.defineProperty(t,i,n),n};let Ve=class PacemGeolocateElement extends PacemBaseElement{constructor(){super(...arguments),this._dragendHandler=e=>{this._reverseGeocoder.position=e.detail.position}}get inputFields(){return[]}toggleReadonlyView(e){this._setupSuggest(),this._setupMapMarker()}onChange(e){return new Promise((i,r)=>{if("success"===e.type&&e.target===this._reverseGeocoder){const s=this.#u.position,r=e.detail.sort((e,t)=>a.Maps.MapProjection.distanceBetween(e.position,s)<a.Maps.MapProjection.distanceBetween(t.position,s)?0:-1),n=r[0].position.altitude,o=t.Utils.extend({},r[0],{position:t.Utils.extend({altitude:n},s)});i(this.value=o)}else e.type===s&&e.target===this._suggest?i(this.value=this._suggest.value):i(this.value)})}fetch(e){a.Maps.LatLng.isLatLng(e)&&(this.#u.position=this._reverseGeocoder.position=e)}compareValuePropertyValues(e,t){const i=e?.position??a.Maps.LatLng.Empty,s=t?.position??a.Maps.LatLng.Empty;return a.Maps.LatLng.equals(i,s)}acceptValue(e){t.Utils.isNull(e)?this._datasource.model=[]:(this._datasource.model=[e],this._setupMapMarker()),this._setupSuggest()}getViewValue(e){return e?.fullAddress||""}convertValueAttributeToProperty(e){return t.PropertyConverters.Json.convert(e,this)}#u;viewActivatedCallback(){super.viewActivatedCallback(),this._setup()}propertyChangedCallback(e,t,i,a){if(super.propertyChangedCallback(e,t,i,a),!a)switch(e){case"adapter":this._setupAdapters(i);break;case"map":t&&this._detachMarker(t),i&&this._setupMapMarker(i);break;case"icon":this._setupMapMarker();break;case"plaeholder":this._setupSuggest();break;case"disabled":this._setupMapMarker(),this._setupSuggest()}}disconnectedCallback(){this._disposeMarker(),super.disconnectedCallback()}_setupAdapters(e=this.adapter){const i=this._geocoder,a=this._reverseGeocoder;t.Utils.isNull(i)||(i.adapter=e),t.Utils.isNull(a)||(a.adapter=e)}_setupSuggest(){const e=this._suggest;t.Utils.isNull(e)||(e.placeholder=this.placeholder??"search...",e.readonly=this.readonly,e.disabled=this.disabled,e.value=this.value)}_detachMarker(e=this.map){const i=this.#u;t.Utils.isNull(i)||i.map!==e||i.remove()}_createMarker(){const e=new a.Components.Maps.PacemMapMarkerElement;return e.addEventListener("dragend",this._dragendHandler,!1),e}_disposeMarker(){const e=this.#u;t.Utils.isNull(e)||e.removeEventListener("dragend",this._dragendHandler,!1)}_setupMapMarker(e=this.map){const i=this.#u||(this.#u=this._createMarker());i.icon=this.icon,i.draggable=!this.readonly&&!this.disabled,i.hide=this.disabled;const a=this.value;a&&a.position&&(i.position=a.position),i.map===e||t.Utils.isNull(e)||e.appendChild(i)}_setup(){this._setupAdapters(),this._setupSuggest(),this._setupMapMarker()}};xe([t.Watch({emit:!1,converter:t.PropertyConverters.Element})],Ve.prototype,"adapter",void 0),xe([t.Watch({emit:!1,converter:t.PropertyConverters.Element})],Ve.prototype,"map",void 0),xe([t.Watch({emit:!1,converter:t.PropertyConverters.Json})],Ve.prototype,"icon",void 0),xe([t.ViewChild(t.P+"-data[ds]")],Ve.prototype,"_datasource",void 0),xe([t.ViewChild(t.P+"-suggest")],Ve.prototype,"_suggest",void 0),xe([t.ViewChild(t.P+"-map-geocode")],Ve.prototype,"_geocoder",void 0),xe([t.ViewChild(t.P+"-map-geocode[reverse]")],Ve.prototype,"_reverseGeocoder",void 0),Ve=xe([t.CustomElement({tagName:t.P+"-geolocate",shadow:!1,template:`<${t.P}-map-geocode search="{{ ::_suggest.hint }}"\n disabled="{{ (::_suggest.hint || '').length < 3 }}" on-success="::_datasource.model = $event.detail"></${t.P}-map-geocode>\n<${t.P}-map-geocode reverse on-success=":host.changeHandler($event)"></${t.P}-map-geocode>\n\n<${t.P}-data ds></${t.P}-data>\n\n<${t.P}-suggest on-change=":host.changeHandler($event)" datasource="{{ ::_datasource.model || [] }}"\n compare-by="fullAddress" text-property="fullAddress"></${t.P}-suggest>`})],Ve);var De=function(e,t,i,a){var s,r=arguments.length,n=r<3?t:null===a?a=Object.getOwnPropertyDescriptor(t,i):a;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(e,t,i,a);else for(var o=e.length-1;o>=0;o--)(s=e[o])&&(n=(r<3?s(n):r>3?s(t,i,n):s(t,i))||n);return r>3&&n&&Object.defineProperty(t,i,n),n};class HierarchyChangeEvent extends CustomEvent{constructor(e){super("hierarchychange",{detail:e,bubbles:!1,cancelable:!1})}}const He="hierarchy-item",Ae=He+" "+t.PCSS+"-anim anim-fade-in anim-sudden",Te="{{ { 'item-disabled' : ^item.disabled } }}",Re="pacemHierarchy",Le="item-content",Ie="item-link",Fe=Ie+" icon-rotate rotate-135",We="link",Be="item-move",je="drag_indicator",Me="parents";let ze=class PacemHierarchyElement extends PacemBaseElement{getViewValue(e){return""}convertValueAttributeToProperty(e){return t.Utils.Json.parse(e)}constructor(){super(),this.#m=new Map,this.#v=new Map,this.unlinkCaption="Delete",this._binderClickHandler=e=>{const i=e.originalEvent.type;if("mousedown"===i&&1===e.originalEvent.button){t.avoidHandler(e.originalEvent);const i=e.srcElement;this._unlink(i)}else if("click"===i||"contextmenu"===i){t.avoidHandler(e.originalEvent),this.#g=e.srcElement;const i=this._balloon;i.target={x:e.pageX,y:e.pageY},i.popup()}},this._dragInitHandler=e=>{let a=e.detail;const s=this._dragger;s.floater=document.createElement("span"),s.dropTargets=Array.from(this.#v.keys()).filter(e=>e!==a.element),t.Utils.isNull(this.#y)||this.#y.remove();const r=this.#y=new i.Components.UI.PacemBinderElement;r.from=a.element,this.#f.appendChild(r)},this._dragStartHandler=e=>{t.Utils.addClass(e.detail.element,"item-drag")},this._dragHandler=e=>{this.#y.to=e.detail.currentPosition},this._dragEndHandler=e=>{t.Utils.removeClass(e.detail.element,"item-drag"),this.#y.remove(),this.#y=null},this._dropHandler=e=>{const t=e.detail.data,i=this.#v.get(e.detail.target);this._isInAncestors(t,i)||this._isInDescendants(t,i)||this._compileHierarchy({source:t,target:i})},this._dragOverHandler=e=>{const t=e.detail.data,i=this.#v.get(e.detail.target);(i.disabled||this._isInAncestors(t,i)||this._isInDescendants(t,i))&&e.preventDefault()},this._dragOutHandler=e=>{},this._popoutHandler=e=>{this._balloon.popout()},this.#_=t.Utils.uniqueCode()}#_;#m;#y;#g;#v;#f;get inputFields(){return[]}toggleReadonlyView(e){this._dragger.disabled=e,t.Utils.isNull(this._adaptedDatasource)||this._databind()}onChange(e){return new Promise((i,a)=>{t.CustomEventUtils.isInstanceOf(e,HierarchyChangeEvent)?i(this.value=e.detail):i(this.value)})}acceptValue(e){}viewActivatedCallback(){super.viewActivatedCallback(),this.#f=t.CustomElementUtils.findAncestorShell(this),this._setupItemTemplate(),this._setupDragger(),this._setupBalloon()}propertyChangedCallback(e,t,i,a){switch(super.propertyChangedCallback(e,t,i,a),e){case"datasource":case"textProperty":case"disabledProperty":case"valueProperty":cancelAnimationFrame(this._handle),this._handle=requestAnimationFrame(()=>{this._buildAdaptedDatasource()});break;case"itemtemplate":a||this._setupItemTemplate();break;case"_adaptedDatasource":case"value":cancelAnimationFrame(this._handle2),this._handle2=requestAnimationFrame(()=>{this._databind()})}}disconnectedCallback(){this._disposeBindersAndTargets(),this._disposeDragger(),this._disposeBalloon(),super.disconnectedCallback()}_buildAdaptedDatasource(e=this.datasource){this._adaptedDatasource=e&&e.map(e=>this._mapEntityToItem(e))}_mapEntityToValue(e){let t,i=e;return(t=this.valueProperty)&&(i=e[t]),i}_mapEntityToViewValue(e){let t,i=e.toString();return(t=this.textProperty)&&(i=e[t]),i}_mapEntityToItem(e){if(null==e)throw new Error("Entity cannot be null");let i=!1;const a=this.disabledProperty;return t.Utils.isNullOrEmpty(a)||(i=e[a]||!1),{value:this._mapEntityToValue(e),viewValue:this._mapEntityToViewValue(e),disabled:i,data:e}}_unlink(e){var t;e instanceof i.Components.UI.PacemBinderElement?t=e:(e.preventDefault(),e.stopPropagation(),t=this.#g);const{parent:a,child:s}=JSON.parse(t.dataset[Re]),r=this._adaptedDatasource,n=r.find(e=>e.value===a),o=r.find(e=>e.value===s);n.disabled||o.disabled||this._compileHierarchy({source:n,target:o},!0)}_buildHierarchyItemDomId(e){return`hierarchyitem_${this.#_}_${e}`}_itemCreate(e){const a=e.detail.dom.find(e=>e instanceof HTMLElement&&e.classList.contains(He));e.detail.index;const s=e.detail.item;a.id=this._buildHierarchyItemDomId(s.value),s.disabled?a.setAttribute("behaviors","{{ [#"+this._dragger2.id+"] }}"):a.setAttribute("behaviors","{{ [#"+this._dragger.id+", #"+this._dragger2.id+"] }}");const r=this.#m,n=s.value;let o;r.has(n)?o=r.get(n):r.set(n,o=new Map);for(let e of s.parents||[]){const t=e.value,r=!o.has(t),n=r?new i.Components.UI.PacemBinderElement:o.get(t);n.fromAnchor=i.Components.UI.BinderAnchor.Bottom,n.toAnchor=i.Components.UI.BinderAnchor.Top,n.toEnd=i.Components.UI.BinderEnd.Arrow,n.setAttribute("from","{{ #"+this._buildHierarchyItemDomId(e.value)+" }}"),n.setAttribute("to","{{ #"+a.id+" }}"),n.cssClass=["hierarchy-binder"],n.dataset[Re]=JSON.stringify({parent:e.value,child:s.value}),n.interactive=!this.readonly&&!s.disabled&&!e.disabled,r&&(n.addEventListener(i.Components.UI.BinderInteractionEventName,this._binderClickHandler,!1),this.#f.appendChild(n),o.set(t,n))}for(let e of o.keys()){const a=s.parents.find(t=>t.value===e);if(!t.Utils.isNull(a))continue;const r=o.get(e);r.removeEventListener(i.Components.UI.BinderInteractionEventName,this._binderClickHandler),r.remove(),o.delete(e)}this.#v.has(a)||this.#v.set(a,s)}_itemRemove(e){const t=e.detail.dom.find(e=>e instanceof HTMLElement&&e.classList.contains(He)),i=e.detail.item;this._disposeBinders(i.value),this.#v.has(t)&&this.#v.delete(t)}_disposeBinders(e){const t=this.#m;if(t.has(e)){const a=t.get(e);for(let e of a.keys()){const t=a.get(e);t.removeEventListener(i.Components.UI.BinderInteractionEventName,this._binderClickHandler,!1),t.remove()}t.delete(e)}}_disposeBindersAndTargets(){for(let e of this.#m.keys())this._disposeBinders(e);this.#v.clear()}_setupItemTemplate(){if(this.itemtemplate instanceof HTMLTemplateElement){const e=this.itemtemplate.cloneNode(!0).content,a=document.createElement("template"),s=document.createElement(t.P+"-panel");s.className=Ae,s.setAttribute("css-class",Te);const r=new i.Components.UI.PacemIconElement;r.setAttribute("icon",je),r.className=Be,s.appendChild(r);const n=document.createElement("div");n.className=Le,n.append(e),s.appendChild(n);const o=new i.Components.UI.PacemIconElement;o.setAttribute("icon",We),o.className=Fe,s.appendChild(o),a.content.appendChild(s),this._template=a}else this._template=this._defaultTemplate}_compileHierarchy(e,i=!1){const a=t.Utils.clone(this.value||[]),s=e.source.value,r=e.target.value,n=this.parentsProperty||Me;var o=a.find(e=>e[this.valueProperty]===r);if(i){if(!t.Utils.isNull(o)){const e=o[n]||[],t=e.indexOf(s);t>=0&&e.splice(t,1)}}else t.Utils.isNull(o)&&((o={})[this.valueProperty]=r,o[n]=[],a.push(o)),o[n].push(s);this._tidyUpHierarchy(a),this.changeHandler(new HierarchyChangeEvent(a))}_tidyUpHierarchy(e=[]){const i=this.valueProperty,a=this.parentsProperty||Me,s=(r,n)=>{const o=e.find(e=>e[i]==n);if(t.Utils.isNull(o)||t.Utils.isNullOrEmpty(o[a]))return!1;const l=o[a];return l.indexOf(r)>=0||l.some(e=>s(r,e))};for(let t of e){const e=t[a]||[];for(let t=e.length-1;t>=0;t--){const i=e[t],a=e.filter(e=>e!==i);for(let r of a)if(s(i,r)){e.splice(t,1);break}}}}_setupDragger(){const e=this._dragger;e.id="hierarchy_link_"+this.#_,e.handleSelector="."+Ie,e.dropBehavior=t.UI.DropBehavior.None,e.spillBehavior=t.UI.DropTargetMissedBehavior.None,e.mode=t.UI.DragDataMode.Copy,e.addEventListener(t.UI.DragDropEventType.Drop,this._dropHandler,!1),e.addEventListener(t.UI.DragDropEventType.Drag,this._dragHandler,!1),e.addEventListener(t.UI.DragDropEventType.Init,this._dragInitHandler,!1),e.addEventListener(t.UI.DragDropEventType.Start,this._dragStartHandler,!1),e.addEventListener(t.UI.DragDropEventType.End,this._dragEndHandler,!1),e.addEventListener(t.UI.DragDropEventType.Over,this._dragOverHandler,!1),e.addEventListener(t.UI.DragDropEventType.Out,this._dragOutHandler,!1);const i=this._dragger2;i.id="hierarchy_move_"+this.#_,i.mode=t.UI.DragDataMode.Self,i.dropBehavior=t.UI.DropBehavior.None,i.spillBehavior=t.UI.DropTargetMissedBehavior.None,i.handleSelector="."+Be}_disposeDragger(){const e=this._dragger;t.Utils.isNull(e)||(e.removeEventListener(t.UI.DragDropEventType.Drop,this._dropHandler,!1),e.removeEventListener(t.UI.DragDropEventType.Drag,this._dragHandler,!1),e.removeEventListener(t.UI.DragDropEventType.Init,this._dragInitHandler,!1),e.removeEventListener(t.UI.DragDropEventType.Start,this._dragStartHandler,!1),e.removeEventListener(t.UI.DragDropEventType.End,this._dragEndHandler,!1),e.removeEventListener(t.UI.DragDropEventType.Over,this._dragOverHandler,!1),e.removeEventListener(t.UI.DragDropEventType.Out,this._dragOutHandler,!1))}_setupBalloon(){this._balloon=this._shellProxy.dom.find(e=>e instanceof i.Components.UI.PacemBalloonElement),window.addEventListener("mousedown",this._popoutHandler,!1)}_disposeBalloon(){window.removeEventListener("mousedown",this._popoutHandler,!1)}_isInAncestors(e,i){return!t.Utils.isNull(i)&&!t.Utils.isNullOrEmpty(i.parents)&&(i.parents.indexOf(e)>=0||i.parents.some(t=>this._isInAncestors(e,t)))}_isInDescendants(e,t){return this._isInAncestors(t,e)}_databind(){const e=this.valueProperty;if(t.Utils.isNullOrEmpty(e))throw new Error("Missing valueProperty.");const i=t.Utils.clone(this._adaptedDatasource||[]),a=this.value||[],s=this.parentsProperty||Me;for(let r of i){const n=a.find(t=>t[e]===r.value);t.Utils.isNull(n)||(r.parents=(n[s]||[]).map(e=>i.find(t=>t.value===e)).filter(e=>!t.Utils.isNull(e)))}this._databindByParents(i)}_databindByParents(e){const i=[];function a(){return i.reduce((e,t)=>e+t.length,0)}do{if(t.Utils.isNullOrEmpty(i)){const a=e.filter(e=>t.Utils.isNullOrEmpty(e.parents));i.push(a)}else{const a=Array.prototype.concat.apply([],i),s=i[i.length-1],r=e.filter(e=>!t.Utils.isNullOrEmpty(e.parents)&&(e.parents.every(e=>a.indexOf(e)>=0)&&e.parents.some(e=>s.indexOf(e)>=0)));i.push(r)}}while(a()<e.length);this._repeater.datasource=i}};De([t.ViewChild("template[default]")],ze.prototype,"_defaultTemplate",void 0),De([t.ViewChild(t.P+"-repeater")],ze.prototype,"_repeater",void 0),De([t.ViewChild(t.P+"-drag-drop")],ze.prototype,"_dragger",void 0),De([t.ViewChild(t.P+"-drag-drop[move]")],ze.prototype,"_dragger2",void 0),De([t.ViewChild(t.P+"-shell-proxy")],ze.prototype,"_shellProxy",void 0),De([t.Watch({emit:!1,converter:t.PropertyConverters.Json})],ze.prototype,"datasource",void 0),De([t.Watch({emit:!1,converter:t.PropertyConverters.String})],ze.prototype,"valueProperty",void 0),De([t.Watch({emit:!1,converter:t.PropertyConverters.String})],ze.prototype,"textProperty",void 0),De([t.Watch({emit:!1,converter:t.PropertyConverters.String})],ze.prototype,"disabledProperty",void 0),De([t.Watch({converter:t.PropertyConverters.String})],ze.prototype,"unlinkCaption",void 0),De([t.Watch({converter:t.PropertyConverters.Json})],ze.prototype,"_adaptedDatasource",void 0),De([t.Watch({emit:!1,converter:t.PropertyConverters.Element})],ze.prototype,"itemtemplate",void 0),De([t.Watch({converter:t.PropertyConverters.Element})],ze.prototype,"_template",void 0),De([t.Watch({emit:!1,converter:t.PropertyConverters.String})],ze.prototype,"parentsProperty",void 0),ze=De([t.CustomElement({tagName:t.P+"-hierarchy",shadow:t.Defaults.USE_SHADOW_ROOT,template:`<${t.P}-repeater>\n <template>\n <${t.P}-repeater on-${t.Components.RepeaterItemCreateEventName}=":host._itemCreate($event)" on-${t.Components.RepeaterItemRemoveEventName}=":host._itemRemove($event)" datasource="{{ ^item }}">\n <div class="hierarchy-level">\n <${t.P}-template-proxy target="{{ :host._template }}"></${t.P}-template-proxy>\n </div>\n </${t.P}-repeater>\n </template>\n </div>\n</${t.P}-repeater><${t.P}-content></${t.P}-content>\n<${t.P}-drag-drop></${t.P}-drag-drop>\n<${t.P}-drag-drop move></${t.P}-drag-drop>\n<template default>\n <${t.P}-panel class="${Ae} item-default" css-class="${Te}">\n <${t.P}-icon class="${Be}" icon="${je}"></${t.P}-icon>\n <pacem-span class="${Le}" content="{{ ^item.viewValue }}"></${t.P}-span>\n <${t.P}-icon class="${Fe}" icon="${We}"></${t.P}-icon>\n </${t.P}-panel>\n</template>\n<${t.P}-shell-proxy>\n <${t.P}-balloon options="{{ { behavior: '${i.Components.UI.BalloonBehavior.Inert}' } }}">\n <${t.P}-button icon-glyph="link_off" class="${t.PCSS}-margin margin-0 button-flat display-flex flex-middle icon-rotate rotate-135"\n on-click=":host._unlink($event)"\n on-mousedown="$event.stopPropagation()"\n on-mouseup="::_balloon.popout()"><${t.P}-text class="${t.PCSS}-margin margin-left-1" text="{{ :host.unlinkCaption }}"></${t.P}-text></${t.P}-button>\n </${t.P}-balloon>\n</${t.P}-shell-proxy>`})],ze);var qe,Je=function(e,t,i,a){var s,r=arguments.length,n=r<3?t:null===a?a=Object.getOwnPropertyDescriptor(t,i):a;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(e,t,i,a);else for(var o=e.length-1;o>=0;o--)(s=e[o])&&(n=(r<3?s(n):r>3?s(t,i,n):s(t,i))||n);return r>3&&n&&Object.defineProperty(t,i,n),n};!function(e){e.Input="input",e.Blur="blur"}(qe||(qe={}));const Ye="pacem:scaffolding:input_field";class PacemBaseInputElement extends PacemBaseElement{constructor(){super(...arguments),this.debounce=!1,this.changePolicy=qe.Input,this._focusHandler=e=>{if(!this.autoselect)return;let t=this.inputField;for(let e of this.inputFields??[])if(e===document.activeElement){t=e;break}t?.select()}}propertyChangedCallback(e,t,i,a){if(super.propertyChangedCallback(e,t,i,a),"placeholder"===e)for(let t of this.inputFields??[])t.setAttribute(e,i)}acceptValue(e){this.inputField&&e!==this.inputField.value&&(this.inputField.value=t.Utils.isNullOrEmpty(e)?"":e)}get inputField(){return this.inputFields[0]}onChange(e){return new Promise(t=>{if(this.readonly)t(this.value);else if("input"===e.type&&this.changePolicy===qe.Blur)t(this.value);else{const e=()=>{const e=this.getValue(this.inputField.value);e!==this.value&&(this.value=e),t(e)},i=this.debounce;"number"==typeof i&&i>0?(clearTimeout(this._handle),this._handle=setTimeout(e,i)):!0===i?(cancelAnimationFrame(this._handle),this._handle=requestAnimationFrame(e)):requestAnimationFrame(e)}})}registerInputFields(e=this.inputFields){super.registerInputFields(e),t.Utils.isNull(e)||t.Utils.isArray(e)||(e=[e]);for(let i of e??[])(i instanceof HTMLInputElement||i instanceof HTMLTextAreaElement)&&"on"!==t.CustomElementUtils.getAttachedPropertyValue(i,Ye,"off")&&(t.CustomElementUtils.setAttachedPropertyValue(i,Ye,"on"),"size"in i&&(i.size=1),i.autocomplete="off",i.addEventListener("input",this.changeHandler,!1),i.addEventListener("focus",this._focusHandler,!1))}unregisterInputFields(e=this.inputFields){super.unregisterInputFields(e),t.Utils.isNull(e)||t.Utils.isArray(e)||(e=[e]);for(let i of e??[])"on"===t.CustomElementUtils.getAttachedPropertyValue(i,Ye)&&(t.CustomElementUtils.deleteAttachedPropertyValue(i,Ye),i.removeEventListener("input",this.changeHandler,!1),i.removeEventListener("focus",this._focusHandler,!1))}viewActivatedCallback(){super.viewActivatedCallback(),this.registerInputFields()}disconnectedCallback(){this.unregisterInputFields(),super.disconnectedCallback()}}Je([t.Watch({emit:!1,converter:{convert:e=>{switch(e){case"true":return!0;case"false":return!1;default:return parseFloat(e)}},convertBack:e=>e.toString()}})],PacemBaseInputElement.prototype,"debounce",void 0),Je([t.Watch({emit:!1,converter:t.PropertyConverters.String})],PacemBaseInputElement.prototype,"changePolicy",void 0),Je([t.Watch({emit:!1,converter:t.PropertyConverters.Boolean})],PacemBaseInputElement.prototype,"autoselect",void 0);class PacemOrdinalInputElement extends PacemBaseInputElement{convertValueAttributeToProperty(e){return parseFloat(e)}propertyChangedCallback(e,t,i,a){switch(super.propertyChangedCallback(e,t,i,a),e){case"min":case"max":case"step":null!=i?this.inputField.setAttribute(e,i):this.inputField.removeAttribute(e)}}}Je([t.Watch({converter:t.PropertyConverters.Number})],PacemOrdinalInputElement.prototype,"min",void 0),Je([t.Watch({converter:t.PropertyConverters.Number})],PacemOrdinalInputElement.prototype,"max",void 0),Je([t.Watch({converter:{convert:e=>{const t=parseFloat(e);return isNaN(t)?"any":t},convertBack:e=>e.toString()}})],PacemOrdinalInputElement.prototype,"step",void 0);class PacemTextualInputElement extends PacemBaseInputElement{convertValueAttributeToProperty(e){return e}propertyChangedCallback(e,t,i,a){switch(super.propertyChangedCallback(e,t,i,a),e){case"pattern":case"maxlength":case"minlength":null!=i?this.inputField.setAttribute(e,i):this.inputField.removeAttribute(e)}}getValue(e){return t.Utils.isNullOrEmpty(e)?null:e}getViewValue(e){return e}}Je([t.Watch({converter:t.PropertyConverters.String})],PacemTextualInputElement.prototype,"pattern",void 0),Je([t.Watch({converter:t.PropertyConverters.Number})],PacemTextualInputElement.prototype,"minlength",void 0),Je([t.Watch({converter:t.PropertyConverters.Number})],PacemTextualInputElement.prototype,"maxlength",void 0);var Ge=function(e,t,i,a){var s,r=arguments.length,n=r<3?t:null===a?a=Object.getOwnPropertyDescriptor(t,i):a;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(e,t,i,a);else for(var o=e.length-1;o>=0;o--)(s=e[o])&&(n=(r<3?s(n):r>3?s(t,i,n):s(t,i))||n);return r>3&&n&&Object.defineProperty(t,i,n),n};let Ke=class PacemCharsInputElement extends PacemBaseInputElement{constructor(){super(),this.charCount=6,this.inputTransform="none",this._itemCreateHandler=e=>{const{dom:t,index:i}=e.detail,a=t.find(e=>e instanceof HTMLInputElement);this.#b[i]=a,this.registerInputFields(a)},this.#b=[]}redactViewValue(e=this.value){this.viewValue=this.getViewValue(e)}getValue(e){const i=this.#b.reduce((e,i)=>e+(t.Utils.isNullOrEmpty(i.value)?" ":i.value),"");switch(this.inputTransform){case"lowercase":return i.toLowerCase();case"uppercase":return i.toUpperCase();default:return i}}getViewValue(t){const i=this.charCount;return"password"==this.inputTransform?e.Arrays.range(i).map(e=>"*").join(""):t}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)return void(this.autofocus&&e.select());super.focus()}propertyChangedCallback(e,t,i,a){if(super.propertyChangedCallback(e,t,i,a),!a)switch(e){case"charCount":this._databind(),this.redactViewValue();break;case"inputTransform":this.registerInputFields(),this.value=this.getValue(this.value)}}registerInputFields(e=this.inputFields){super.registerInputFields(e),t.Utils.isNull(e)||t.Utils.isArray(e)||(e=[e]);const i=this.#b;for(let a of e??[]){const e=i.indexOf(a);t.Utils.toggleClass(a,"last-char",e===this.charCount-1),t.Utils.toggleClass(a,"first-char",0===e),t.Utils.isNullOrEmpty(a.id)&&a.setAttribute("id","code_"+e+"_"+t.Utils.uniqueCode()),a.value=this.value?.charAt(e)||"","password"===this.inputTransform?a.setAttribute("type","password"):a.setAttribute("type","text")}}acceptValue(e){const t=this.#b;if("string"==typeof e){let i=0;const a=Math.min(e.length,t.length);for(let s=0;s<a;s++)t[s].value=e.charAt(s),i++;for(let e=i;e<t.length;e++)t[e].value=""}}onChange(e){return super.onChange(e).then(i=>{const a=this.#b,s=a.indexOf(e.target);if(s>=0&&s<a.length-1){const e=a[s];if(t.Utils.isNullOrEmpty(e.value?.trim()))e.value="";else{a[s+1].focus()}}return i})}viewActivatedCallback(){super.viewActivatedCallback(),t.Utils.isNull(this.autoselect)&&(this.autoselect=!0),this._chars.addEventListener(t.Components.RepeaterItemCreateEventName,this._itemCreateHandler,!1),this._databind()}disconnectedCallback(){const e=this._chars;t.Utils.isNull(e)||e.removeEventListener(t.Components.RepeaterItemCreateEventName,this._itemCreateHandler),super.disconnectedCallback()}_databind(){const t=this.charCount,i=this.#b;i.length>t&&super.unregisterInputFields(i.splice(t)),this._chars.datasource=e.Arrays.range(t)}#b;get inputFields(){return this.#b}};Ge([t.Watch({emit:!1,reflectBack:!0,converter:t.PropertyConverters.Number})],Ke.prototype,"charCount",void 0),Ge([t.Watch({emit:!1,reflectBack:!0,converter:t.PropertyConverters.String})],Ke.prototype,"inputTransform",void 0),Ge([t.ViewChild(t.P+"-repeater")],Ke.prototype,"_chars",void 0),Ge([t.ViewChild("span."+t.PCSS+"-readonly")],Ke.prototype,"_span",void 0),Ke=Ge([t.CustomElement({tagName:t.P+"-input-chars",template:`<${t.P}-repeater class="display-flex flex-nowrap">\n <template><input type="text" class="${t.PCSS}-input flex-auto" maxlength="1" /></template>\n </${t.P}-repeater><span class="${t.PCSS}-readonly"><${t.P}-text text="{{ :host.viewValue }}"></${t.P}-text></span>`,shadow:t.Defaults.USE_SHADOW_ROOT})],Ke);var Xe=function(e,t,i,a){var s,r=arguments.length,n=r<3?t:null===a?a=Object.getOwnPropertyDescriptor(t,i):a;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(e,t,i,a);else for(var o=e.length-1;o>=0;o--)(s=e[o])&&(n=(r<3?s(n):r>3?s(t,i,n):s(t,i))||n);return r>3&&n&&Object.defineProperty(t,i,n),n};let Ze=class PacemColorInputElement extends PacemBaseElement{acceptValue(e){const t=this._parseValue(e);null!=t&&(this._tint.value=t.tint,this._alpha.value=t.alpha.toString())}convertValueAttributeToProperty(e){return e}onChange(e){const i=this._alpha.valueAsNumber||parseInt(this._alpha.value),a=this._tint.value,s=this.value=this._getValue(a,i);return t.Utils.fromResult(s)}constructor(){super()}toggleReadonlyView(e){this._wrapper.hidden=e,this._span.hidden=!e}_getValue(t,i){if(isNaN(i)||100===i)return t;const a=e.Colors.parse(t);return a.a=.01*i,e.Colors.stringify(a)}_parseValue(i){const a=e.Colors.parse(i);return t.Utils.isNullOrEmpty(a)?null:{tint:e.Colors.stringify({r:a.r,g:a.g,b:a.b}),alpha:100*a.a}}getViewValue(e){return e}get inputFields(){return[this._tint,this._alpha].filter(e=>!t.Utils.isNull(e))}};Xe([t.ViewChild("input[type=color]")],Ze.prototype,"_tint",void 0),Xe([t.ViewChild("input[type=number]")],Ze.prototype,"_alpha",void 0),Xe([t.ViewChild(`.${t.PCSS}-viewfinder`)],Ze.prototype,"_wrapper",void 0),Xe([t.ViewChild(`.${t.PCSS}-readonly`)],Ze.prototype,"_span",void 0),Ze=Xe([t.CustomElement({tagName:t.P+"-input-color",template:`<div class="${t.PCSS}-viewfinder">\n<${t.P}-panel class="${t.PCSS}-input-color" css="{{ { 'background-color': :host.viewValue } }}"><input type="color" class="${t.PCSS}-input" /></${t.P}-panel>\n<input class="${t.PCSS}-input" type="number" min="0" max="100" step="1" value="100" />\n</div>\n<${t.P}-span class="${t.PCSS}-readonly" css="{{ { 'background-color': :host.viewValue } }}"></${t.P}-span>`,shadow:t.Defaults.USE_SHADOW_ROOT})],Ze);var Qe=function(e,t,i,a){var s,r=arguments.length,n=r<3?t:null===a?a=Object.getOwnPropertyDescriptor(t,i):a;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(e,t,i,a);else for(var o=e.length-1;o>=0;o--)(s=e[o])&&(n=(r<3?s(n):r>3?s(t,i,n):s(t,i))||n);return r>3&&n&&Object.defineProperty(t,i,n),n};let et=class PacemEmailInputElement extends PacemTextualInputElement{toggleReadonlyView(e){const i=this._input,a=this._anchor;t.Utils.isNull(i)||(i.hidden=e),t.Utils.isNull(a)||(a.hidden=!e)}get inputFields(){return t.Utils.isNull(this._input)?[]:[this._input]}};Qe([t.ViewChild("input[type=email]")],et.prototype,"_input",void 0),Qe([t.ViewChild(t.P+"-a")],et.prototype,"_anchor",void 0),et=Qe([t.CustomElement({tagName:t.P+"-input-email",template:`<input type="email" class="${t.PCSS}-input ${t.PCSS}-viewfinder" />${E}<${t.P}-a class="${t.PCSS}-readonly" disabled="{{ $pacem.isNullOrEmpty(:host.value) }}" href="{{ 'mailto:'+ :host.value }}"><${t.P}-text text="{{ :host.viewValue }}"></${t.P}-text></${t.P}-a>`,shadow:t.Defaults.USE_SHADOW_ROOT})],et);var tt=function(e,t,i,a){var s,r=arguments.length,n=r<3?t:null===a?a=Object.getOwnPropertyDescriptor(t,i):a;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(e,t,i,a);else for(var o=e.length-1;o>=0;o--)(s=e[o])&&(n=(r<3?s(n):r>3?s(t,i,n):s(t,i))||n);return r>3&&n&&Object.defineProperty(t,i,n),n};const it="fileupload",at="filechange";class StoragePickEvent extends t.CustomTypedEvent{constructor(e){super("pick",e)}}class FileUploadEvent extends t.CustomTypedEvent{constructor(e){super(it,e)}}class FileChangeEvent extends t.CustomTypedEvent{constructor(e){super(at,e)}}async function st(e,t={files:0,directories:0,size:0}){for await(let[i,a]of e.entries())if("file"===a.kind){t.files++;const e=await a.getFile();t.size+=e.size}else t.directories++,await st(a,t);return t}let rt=class PacemUploadElement extends PacemBaseElement{constructor(e=new t.Animations.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:131072,undone:!1}}convertValueAttributeToProperty(e){return e}acceptValue(e){this.percentage=0,this.uploading=!1,this._fileupload.value=""}_getMimeIcon(e=this.value,i=this.uploading,a=this.selectMode??"file"){if(i)return"sync";const s=!t.Utils.isNullOrEmpty(e);switch(a){case"directory":case"directory-picker":return s?"folder":"drive_folder_upload";case"multiple":case"multiple-picker":return s?"files":"upload_file"}if(t.Utils.isNullOrEmpty(e))return"upload_file";var r=e;"object"==typeof e&&(r=e.name);const n=/\.([\w]+)(\s|$)/.exec(r);if(n&&n.length)switch(n[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 t.Utils.isNull(this._fileupload)?[]:[this._fileupload]}getViewValue(e){const i=this._localValue||e;if(t.Utils.isNullOrEmpty(i))return"";if("string"==typeof i)return i;let a="name"in i?i.name:"";t.Utils.isArray(i)&&(a=i.map(e=>e.name).join(", "));const s=this._stats;if(t.Utils.isNullOrEmpty(s))return a;const{size:r,files:n}=s;return`${a}\n(${n} file${1===n?"":"s"}, ${t.Utils.core.size(r)})`}toggleReadonlyView(e){this._setupInputElement(e)}viewActivatedCallback(){super.viewActivatedCallback(),this._setupInputElement(),this._fileupload.addEventListener("click",t.stopPropagationHandler,!1)}propertyChangedCallback(e,t,i,a){if(super.propertyChangedCallback(e,t,i,a),!a&&"selectMode"===e)this._setupInputElement()}disconnectedCallback(){this._fileupload&&this._fileupload.removeEventListener("click",t.stopPropagationHandler,!1),super.disconnectedCallback()}_setupInputElement(e=this.readonly,t=this.selectMode??"file"){const i=this._fileupload;switch(i.removeAttribute("webkitdirectory"),i.removeAttribute("multiple"),i.hidden=e,t){case"directory":i.setAttribute("webkitdirectory","true");break;case"multiple":i.setAttribute("multiple","true");break;case"directory-picker":case"file-picker":case"multiple-picker":i.hidden=!0}}_dispatchDownload(e){t.avoidHandler(e);const i=this._localValue||this.value,a=e=>{this.dispatchEvent(new CustomEvent("download",{detail:e,bubbles:!0,cancelable:!1}))};t.Utils.isNullOrEmpty(i)||("string"==typeof i?a(i):"content"in i&&!t.Utils.isNullOrEmpty(i.content)?t.Utils.download(t.Utils.dataURLToBlob("data:application/download;base64,"+i.content),i.name,i.type):"name"in i&&("kind"in i&&"file"===i.kind?i.getFile().then(e=>{t.Utils.download(e,e.name,e.type)}):a(i.name)))}reset(){super.reset(),this._localValue=null,this.invalidFile=!1}_validateAll(){const 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);const i=this.maxSize;if(i>0&&i<e.size)return this.invalidFile=!0,!1;const a=this.pattern;return a&&!new RegExp(a,"i").test(t)?(this.invalidFile=!0,!1):(this.invalidFile=!1,!0)}upload(e,t,i){if(this._validateSingleFile(e,t))return this._upload(e,t,i)}async _upload(e,t,i){var a=this,s=a._fields;if(!e)return;!t&&e instanceof File&&(t=e.name),a.failed=!1,s.undone=!1,s.ongoing=0;const r=e,n=a.size=r.size;t=t.substring(t.lastIndexOf("\\")+1),a.percentage=0,a.complete=!1;var o={filename:t,length:n,action:"start",state:i,type:e.type};a.uploading=!0;try{var l=await a._fetch(o);if(l.ok){var c=await l.json();s.retryFrom=0,s.blob=r,s.uid=c.uid,a._manage()}else a.uploading=!1;return l}catch(e){a.uploading=!1}}async _blobToBase64(e){const i=await t.Utils.blobToDataURL(e);return i.substring(i.indexOf("base64,")+7)}async _doUpload(e,t){var i=this,a=i._fields;a.ongoing++;var s={chunk:await this._blobToBase64(e),uid:a.uid,position:t,action:"do"};try{const e=await i._fetch(s);if(e.ok){if(a.ongoing--,a.undone)return;const t=await e.json();t.percentage>this.percentage&&await i._tweenPercentage(Math.round(Math.max(1,t.percentage)),200),i.complete!=t.complete&&(i.complete=t.complete,!0===i.complete&&(i.uploading=!1,i.changeHandler(new FileUploadEvent(t))))}else a.retryFrom=t,i.failed=!0,i.uploading=!1}catch(e){a.retryFrom=t,i.failed=!0,i.uploading=!1}}_manage(){const e=this._fields,t=this.size,i=e.blob,a=this.chunkSize||e.chunkSize;var s=e.retryFrom,r=s+a;e.enqueuer=setInterval(()=>{if(s<t&&!this.failed){const t=this.parallelism||e.parallelism;if(e.ongoing>=t)return;this._doUpload(i.slice(s,r),s),r=(s=r)+a}else{this._fileupload.value="",window.clearInterval(e.enqueuer)}},100)}async _buildLocalValue(e,i=e.name,a=e){return this._localValue={name:i,size:a.size,type:e.type,lastModified:t.Utils.parseDate(e.lastModified).toISOString(),content:await this._blobToBase64(a)}}_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 StoragePickEvent(e))})}_tryPickFiles(e="multiple-picker"===this.selectMode,t=this.pattern){this._canPick(window)&&window.showOpenFilePicker({multiple:e}).then(e=>{this.changeHandler(new StoragePickEvent(e))})}_clickHandler(e){if(t.avoidHandler(e),!this.readonly)switch(this.selectMode){case"directory-picker":this._tryPickDirectory();break;case"file-picker":case"multiple-picker":this._tryPickFiles()}}async _mimicCompute(){this.uploading=!0,t.Utils.isNullOrEmpty(this.value)?await t.Utils.idle(250):(this.percentage=0,await t.Utils.waitForAnimationEnd(this._tuner)),await this._tweener.run(0,100,500,0,t.Animations.Easings.sineInOut,(e,t)=>{this.percentage=t}),this.percentage=0,this.uploading=!1}onChange(e){return new Promise(async(i,a)=>{if(t.CustomEventUtils.isInstanceOf(e,FileUploadEvent)){const t=this.value=e.detail.filename;this.dispatchEvent(e),i(t)}else if(t.CustomEventUtils.isInstanceOf(e,StoragePickEvent)){let t,a,s,r=e.detail;switch(this.selectMode){case"directory-picker":t=r,this._stats=await st(t);break;case"multiple-picker":case"file-picker":s=r,1===s.length&&(r=s[0]),this._stats=await async function(e){const t={files:0,directories:0,size:0};for(let i of e){const e=await i.getFile();t.files++,t.size+=e.size}return t}(s);break;default:this._stats={directories:0,files:0,size:0}}i(this.value=this._localValue=r);const n=this._validateAll();this.dispatchEvent(new FileChangeEvent({directory:t,file:a,files:s,valid:n}))}else{let e=this._fileupload;if(0===e.files.length)this._stats={directories:0,files:0,size:0},i(this.value=null);else{const a=e.files.length;if(this._stats={directories:0,files:a,size:Array.from(e.files).reduce((e,t,i)=>e+t.size,0)},a>1){const t=Array.from(e.files);i(this.value=this._localValue=t);const a=this._validateAll();this.dispatchEvent(new FileChangeEvent({files:t,valid:a}))}else{const a=e.files[0],s=a.name;let r=a;this._validateSingleFile(a)||t.Utils.isNullOrEmpty(this.url)?(/\.(jpe?g|png)$/i.test(s)&&this.maxImageWidth>0&&this.maxImageHeight>0&&(r=await t.Utils.Images.resize(r,this.maxImageWidth,this.maxImageHeight,{quality:.8})),await this._buildLocalValue(a,s,r),t.Utils.isNullOrEmpty(this.url)?(await this._mimicCompute(),i(this.value=this._localValue)):(this._upload(r,e.value),i(this.value))):i(this.value=await this._buildLocalValue(a)),this.dispatchEvent(new FileChangeEvent({valid:!this.invalidFile,file:a}))}}}})}_fetch(e){return fetch(this.url,{method:"POST",credentials:this.fetchCredentials,headers:t.Utils.extend({Accept:"application/json","Content-Type":"application/json"},this.fetchHeaders||{}),body:JSON.stringify(e)})}async _undo(e){e.preventDefault(),e.stopPropagation();var t=this,i=t._fields,a=t._fileupload;clearInterval(i.enqueuer);var s={action:"undo",uid:i.uid};try{var r=await t._fetch(s);return r.ok&&(i.undone=!0,t.size=0,t._tweenPercentage(0,300)),r}catch(e){}finally{return a.value="",t.uploading=!1,r}}_tweenPercentage(e,i=500){const a=this.percentage;return this._tweener.run(a,e,i,0,t.Animations.Easings.sineInOut,(e,t)=>{this.percentage=t})}_retry(e){e.preventDefault(),e.stopPropagation(),this.failed=!1,this._manage()}_clear(e){e.preventDefault(),e.stopPropagation(),this.invalidFile=!1;const t=this.inputFields[0];t.value="",/safari/i.test(navigator.userAgent)||(t.type="",t.type="file"),this.changeHandler(null)}};tt([t.Watch({emit:!1,converter:t.PropertyConverters.Json})],rt.prototype,"fetchCredentials",void 0),tt([t.Watch({emit:!1,converter:t.PropertyConverters.String})],rt.prototype,"fetchHeaders",void 0),tt([t.ViewChild("input[type=file]")],rt.prototype,"_fileupload",void 0),tt([t.ViewChild(`${t.P}-tuner`)],rt.prototype,"_tuner",void 0),tt([t.Watch({converter:t.PropertyConverters.String})],rt.prototype,"undoCaption",void 0),tt([t.Watch({converter:t.PropertyConverters.String})],rt.prototype,"retryCaption",void 0),tt([t.Watch({converter:t.PropertyConverters.String})],rt.prototype,"clearCaption",void 0),tt([t.Watch({emit:!1,reflectBack:!0,converter:t.PropertyConverters.String})],rt.prototype,"pattern",void 0),tt([t.Watch({emit:!1,reflectBack:!0,converter:t.PropertyConverters.String})],rt.prototype,"url",void 0),tt([t.Watch({emit:!1,reflectBack:!0,converter:t.PropertyConverters.Number})],rt.prototype,"maxImageWidth",void 0),tt([t.Watch({emit:!1,reflectBack:!0,converter:t.PropertyConverters.Number})],rt.prototype,"parallelism",void 0),tt([t.Watch({emit:!1,reflectBack:!0,converter:t.PropertyConverters.Number})],rt.prototype,"chunkSize",void 0),tt([t.Watch({emit:!1,reflectBack:!0,converter:t.PropertyConverters.Number})],rt.prototype,"maxImageHeight",void 0),tt([t.Watch({emit:!1,reflectBack:!0,converter:t.PropertyConverters.Number})],rt.prototype,"maxSize",void 0),tt([t.Watch({reflectBack:!0,converter:t.PropertyConverters.String})],rt.prototype,"selectMode",void 0),tt([t.Watch({converter:t.PropertyConverters.Boolean})],rt.prototype,"uploading",void 0),tt([t.Watch({converter:t.PropertyConverters.Number})],rt.prototype,"size",void 0),tt([t.Watch({converter:t.PropertyConverters.Number})],rt.prototype,"percentage",void 0),tt([t.Watch({converter:t.PropertyConverters.Boolean})],rt.prototype,"complete",void 0),tt([t.Watch({converter:t.PropertyConverters.Boolean})],rt.prototype,"failed",void 0),tt([t.Watch({converter:t.PropertyConverters.Boolean})],rt.prototype,"invalidFile",void 0),rt=tt([t.CustomElement({tagName:t.P+"-upload",shadow:t.Defaults.USE_SHADOW_ROOT,template:`<${t.P}-button on-click=":host._dispatchDownload($event)" class="${t.PCSS}-upload ${t.PCSS}-viewfinder flat" css-class="{{ {'upload-chosen': !$pacem.isNullOrEmpty(:host.value) && !:host.uploading, 'upload-error': !$pacem.isNullOrEmpty(:host.value) && :host.invalidFile && $pacem.isNullOrEmpty(:host.url), 'upload-readonly': :host.readonly } }}">\n\n <${t.P}-panel class="upload-button" hide="{{ (:host.uploading || :host.failed) && !$pacem.isNullOrEmpty(:host.url) }}">\n <${t.P}-button tooltip="{{ :host.readonly ? :host.viewValue : 'upload' }}" class="button-circle pos-relative overflow-hidden"\n icon-glyph="{{ :host._getMimeIcon(:host.value, :host.uploading, :host.selectMode) }}"\n on-click=":host._clickHandler($event)"\n on-mouseover="$this.iconGlyph = :host._getMimeIcon(:host.readonly ? :host.value : '', :host.uploading, :host.selectMode)"\n on-mouseout="$this.iconGlyph = :host._getMimeIcon(:host.value, :host.uploading, :host.selectMode)"\n css-class="{{ {'${t.PCSS}-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 } }}">\n <input type="file" class="${t.PCSS}-transparent ${t.PCSS}-clickable pos-absolute absolute-left absolute-right absolute-top absolute-bottom" />\n </${t.P}-button>\n </${t.P}-panel>\n <${t.P}-panel class="upload-button" hide="{{ !:host.failed }}">\n <${t.P}-button class="button-circle button-flat" icon-glyph="refresh"\n tooltip="{{ :host.retryCaption }}" on-click=":host._retry($event)"><${t.P}-text text="{{ :host.retryCaption }}"></${t.P}-text></${t.P}-button>\n </${t.P}-panel>\n <${t.P}-panel class="upload-button" hide="{{ !:host.uploading || $pacem.isNullOrEmpty(:host.url) }}">\n <${t.P}-button class="button-circle button-flat" icon-glyph="clear" tooltip="{{ :host.undoCaption }}" \n on-click=":host._undo($event)"><${t.P}-text text="{{ :host.undoCaption }}"></${t.P}-text></${t.P}-button>\n </${t.P}-panel>\n\n <${t.P}-span tooltip="{{ :host.viewValue }}"\n hide="{{ $pacem.isNullOrEmpty(:host.value) || :host.uploading }}" class="upload-data readonly text-reset display-block ${t.PCSS}-anim text-truncate text-left ${t.PCSS}-pad pad-right-3" text="{{ :host.viewValue }}"></${t.P}-span>\n\n <${t.P}-panel class="upload-progress hit-none" hide="{{ :host.readonly || (!$pacem.isNullOrEmpty(:host.value) && !:host.uploading) }}">\n <${t.P}-tuner value="{{ :host.percentage }}" css-class="{{ {'tuner-success': !:host.invalidFile, 'tuner-error': :host.invalidFile} }}" interactive="false"></${t.P}-tuner>\n </${t.P}-panel>\n\n <${t.P}-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)"></${t.P}-button>\n \n</${t.P}-button>`})],rt);var nt=function(e,t,i,a){var s,r=arguments.length,n=r<3?t:null===a?a=Object.getOwnPropertyDescriptor(t,i):a;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(e,t,i,a);else for(var o=e.length-1;o>=0;o--)(s=e[o])&&(n=(r<3?s(n):r>3?s(t,i,n):s(t,i))||n);return r>3&&n&&Object.defineProperty(t,i,n),n};let ot=class PacemHiddenInputElement extends PacemTextualInputElement{constructor(){super()}toggleReadonlyView(e){}get inputFields(){return t.Utils.isNull(this._input)?[]:[this._input]}};nt([t.ViewChild("input[type=hidden]")],ot.prototype,"_input",void 0),ot=nt([t.CustomElement({tagName:t.P+"-input-hidden",template:'<input type="hidden" />',shadow:t.Defaults.USE_SHADOW_ROOT})],ot);var lt=function(e,t,i,a){var s,r=arguments.length,n=r<3?t:null===a?a=Object.getOwnPropertyDescriptor(t,i):a;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(e,t,i,a);else for(var o=e.length-1;o>=0;o--)(s=e[o])&&(n=(r<3?s(n):r>3?s(t,i,n):s(t,i))||n);return r>3&&n&&Object.defineProperty(t,i,n),n};const ct=t.Utils.getUserMediaFunctions();var dt;!function(e){e.Start="start",e.Taking="taking",e.Confirm="confirm"}(dt||(dt={}));class ConfirmSnapshotEvent extends t.CustomUIEvent{constructor(e){super("confirmsnapshot",{buffer:e})}}let ht=class PacemSnapshotElement extends PacemBaseElement{constructor(){super(...arguments),this._resizeHandler=e=>{this._renderValue()},this.step=dt.Start,this._canUseWebcam=ct.length>0,this._countdown=0,this._webcamInitialized=!1,this._grabberChangeHandler=e=>{const i=this._grabber;i.files.length>0&&t.Utils.blobToDataURL(i.files[0]).then(e=>{t.Utils.loadImage(e).then(e=>{this._shutter(e)})})},this._snapshooterClickHandler=e=>{t.avoidHandler(e),this.step=dt.Taking},this._pickerClickHandler=e=>{t.avoidHandler(e),this._grabber.click()},this._takerClickHandler=e=>{t.avoidHandler(e),this._countdown=0,this._shutter()},this._timerClickHandler=e=>{t.avoidHandler(e),this._countdown=3,this._shutter()},this._confirmerClickHandler=e=>{t.avoidHandler(e),this.changeHandler(new ConfirmSnapshotEvent(this._buffer))}}get inputFields(){return[]}toggleReadonlyView(e){}onChange(e){return new Promise((i,a)=>{t.CustomEventUtils.isInstanceOf(e,ConfirmSnapshotEvent)?(i(this.value=e.detail.buffer),this.step=dt.Start):i(this.value)})}acceptValue(e){this._renderValue(e)}getViewValue(e){return e}convertValueAttributeToProperty(e){return t.PropertyConverters.String.convert(e,this)}get _getUserMedia(){return this._canUseWebcam&&ct[0]}propertyChangedCallback(e,t,i,a){switch(super.propertyChangedCallback(e,t,i,a),e){case"step":switch(i){case dt.Start:this._buffer=null;const e=this._grabber;e.value="",/safari/i.test(navigator.userAgent)||(e.type="",e.type="file");break;case dt.Taking:this._ensureWebcamRunning()}break;case"_buffer":this._renderValue(i||this.value);break;case"width":case"height":this._syncSize()}}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(){const e=this._stage,i=this._player;t.Utils.isNull(e)||t.Utils.isNull(i)||(e.style.width=i.style.width=this.width&&this.width+"px"||"",e.style.height=i.style.height=this.height&&this.height+"px"||"",this._renderValue(this._buffer||this.value))}_shutter(e){const i=this,a=this._player,s=this._stage;var r,n;if(i._confirmer.disabled=!0,t.Utils.isNull(e)&&(e=i._player),e instanceof HTMLVideoElement?(r=e.videoWidth,n=e.videoHeight):(r=e.naturalWidth,n=e.naturalHeight),i._countdown<=0){var o=document.createElement("canvas");o.width=this.width||s.clientWidth,o.height=this.height||s.clientHeight;var l=o.getContext("2d");t.Utils.cropImageOntoCanvas(e,l,r,n);let c=i._root;c.insertBefore(o,a),o.className="snapshot-brightout",setTimeout(function(){c.removeChild(o)},1e3),i._refreshBuffer(o.toDataURL()).then(e=>{i._setToBeConfirmed(e),i._confirmer.disabled=!1})}else setTimeout(()=>{i._countdown--,this._shutter()},1e3)}_renderValue(e=this.value){let i=this._stage;if(!t.Utils.isNull(i)){i.width=i.clientWidth,i.height=i.clientHeight;let a=i.getContext("2d");t.Utils.isNullOrEmpty(e)?a.clearRect(0,0,i.width,i.height):t.Utils.loadImage(e).then(e=>{t.Utils.cropImageOntoCanvas(e,a,e.width,e.height)})}}_setToBeConfirmed(e){this.step=dt.Confirm,this._buffer=e}_refreshBuffer(e){var i=this._stage;let a;return i.width=i.clientWidth,i.height=i.clientHeight,this.quality>0&&(a=Math.min(1,Math.max(0,this.quality))),t.Utils.cropImage(e,i.width,i.height,a)}_ensureWebcamRunning(){if(this._canUseWebcam&&!this._webcamInitialized){var e=this;e._webcamInitialized=!0,e._getUserMedia.apply(navigator,[{video:!0},function(t){e._player.srcObject=t},function(i){e.log(t.Logging.LogLevel.Error,(i||i.message).toString())}])}}};lt([t.ViewChild("."+t.PCSS+"-snapshot")],ht.prototype,"_root",void 0),lt([t.ViewChild("canvas")],ht.prototype,"_stage",void 0),lt([t.ViewChild("input[type=file]")],ht.prototype,"_grabber",void 0),lt([t.ViewChild("video")],ht.prototype,"_player",void 0),lt([t.ViewChild(t.P+"-button.button.snapshot-upload")],ht.prototype,"_picker",void 0),lt([t.ViewChild(t.P+"-button.button.snapshot-camera")],ht.prototype,"_snapshooter",void 0),lt([t.ViewChild(t.P+"-button.button.snapshot-take")],ht.prototype,"_taker",void 0),lt([t.ViewChild(t.P+"-button.button.snapshot-timer3s")],ht.prototype,"_timer",void 0),lt([t.ViewChild(t.P+"-button.button.snapshot-confirm")],ht.prototype,"_confirmer",void 0),lt([t.Watch({converter:t.PropertyConverters.String})],ht.prototype,"step",void 0),lt([t.Watch({emit:!1,converter:t.PropertyConverters.Number})],ht.prototype,"width",void 0),lt([t.Watch({emit:!1,converter:t.PropertyConverters.Number})],ht.prototype,"height",void 0),lt([t.Watch({emit:!1,converter:t.PropertyConverters.Number})],ht.prototype,"quality",void 0),lt([t.Watch()],ht.prototype,"_countdown",void 0),lt([t.Watch({emit:!1})],ht.prototype,"_buffer",void 0),ht=lt([t.CustomElement({tagName:t.P+"-snapshot",shadow:t.Defaults.USE_SHADOW_ROOT,template:`<${t.P}-panel class="${t.PCSS}-snapshot" \ncss-class="{{ { \n'snapshot-start': :host.step === '${dt.Start}',\n'snapshot-taking': :host.step === '${dt.Taking}', \n'snapshot-confirm': :host.step === '${dt.Confirm}' } }}">\n\n <${t.P}-resize target="{{ ::_stage }}" on-resize=":host._resizeHandler($event)"></${t.P}-resize>\n\n <canvas class="${t.PCSS}-viewfinder"></canvas>\n\n <video autoplay="autoplay"></video>\n\n <input type="file" accept="image/*" />\n\n <div class="${t.PCSS}-buttonset snapshot-step step-start">\n <div class="buttonset-center">\n <${t.P}-button class="button snapshot-upload" icon-glyph="upload"></${t.P}-button>\n <${t.P}-button class="button snapshot-camera" icon-glyph="photo_camera"></${t.P}-button> \n </div>\n </div>\n\n <div class="${t.PCSS}-buttonset snapshot-step step-taking">\n <div class="buttonset-center">\n <${t.P}-button class="button snapshot-undo" icon-glyph="undo" on-click=":host.step = '${dt.Start}'"></${t.P}-button>\n <${t.P}-button class="button snapshot-take" icon-glyph="camera"></${t.P}-button>\n <${t.P}-button class="button snapshot-timer3s" icon-glyph="timer_3"></${t.P}-button>\n </div>\n </div>\n\n <div class="${t.PCSS}-buttonset snapshot-step step-confirm">\n <div class="buttonset-center">\n <${t.P}-button class="button snapshot-undo" icon-glyph="undo" on-click=":host.step = '${dt.Start}'"></${t.P}-button>\n <${t.P}-button class="button snapshot-confirm" icon-glyph="done"></${t.P}-button>\n </div>\n </div>\n\n <${t.P}-span class="snapshot-countdown" text="{{ :host._countdown }}" hide="{{ :host.step !== '${dt.Taking}' || !(:host._countdown > 0) }}"></${t.P}-span>\n <${t.P}-span hide="{{ :host._canUseWebcam }}"><${t.P}-content></${t.P}-content></${t.P}-span>\n\n</${t.P}-panel>`})],ht);var pt=function(e,t,i,a){var s,r=arguments.length,n=r<3?t:null===a?a=Object.getOwnPropertyDescriptor(t,i):a;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(e,t,i,a);else for(var o=e.length-1;o>=0;o--)(s=e[o])&&(n=(r<3?s(n):r>3?s(t,i,n):s(t,i))||n);return r>3&&n&&Object.defineProperty(t,i,n),n};const ut="imagefetchrequest";class ImageFetchRequestEvent extends t.CustomTypedEvent{constructor(e){super(ut,e,{bubbles:!0})}}let mt=class PacemEditImageElement extends t.Components.PacemElement{constructor(){super(...arguments),this._index=0,this.hint=""}_uploaderPropertyChangedCallback(e){const t=e.detail.currentValue;switch(e.detail.propertyName){case"percentage":this._progressbar.percentage=100*t;break;case"uploading":t&&this._done(!0)}}_thumbnailUploaderPropertyChangedCallback(e){const t=e.detail.currentValue;switch(e.detail.propertyName){case"percentage":this._progressbar.percentage=100*t;break;case"uploading":this._done(t)}}_uploaderFileUploadCallback(e){const i=this._uploader,a=this._thumbUploader,s=a.maxImageWidth,r=a.maxImageHeight;if(s>0&&r>0){var n=i.blob;const o=e.detail.uid;t.Utils.resizeImage(n,s,r).then(e=>{e==n?this._done(!1):a.upload(e,"thumbnail.jpg",o)})}else this._done(!1)}_done(e){e||this._imagefetch(0),this._repeater.hidden=e,this._progressbar.hidden=!e}_snapshotPropertyChangedCallback(e){if("value"===e.detail.propertyName){const i=t.Utils.dataURLToBlob(e.detail.currentValue);this._uploader.upload(i,"snapshot.jpg")}}reset(){this._snapshot.step=dt.Start}propertyChangedCallback(e,i,a,s){switch(super.propertyChangedCallback(e,i,a,s),e){case"imageSet":let e=a||{skip:0,set:[]};t.Utils.isNullOrEmpty(this._images)||0===e.skip?this._images=e.set:t.Utils.isNull(this._images)||Array.prototype.splice.apply(this._images,[e.skip,this._images.length-e.skip].concat(e.set)),this._fetching=!1;break;case"hint":s||this._imagefetch(0)}}_imagefetchSuddenly(e){this._fetching=!0,this._imagefetch(e)}_imagefetch(e){e>=0||(e=this._images&&this._images.length||0),this.dispatchEvent(new ImageFetchRequestEvent({hint:this.hint,skip:e,take:18}))}};pt([t.Watch({converter:t.PropertyConverters.String})],mt.prototype,"uploadUrl",void 0),pt([t.Watch({converter:t.PropertyConverters.String})],mt.prototype,"hint",void 0),pt([t.Watch()],mt.prototype,"imageSet",void 0),pt([t.Watch({converter:t.PropertyConverters.String})],mt.prototype,"value",void 0),pt([t.Watch({converter:t.PropertyConverters.Number})],mt.prototype,"maxWidth",void 0),pt([t.Watch({converter:t.PropertyConverters.Number})],mt.prototype,"maxHeight",void 0),pt([t.Watch({converter:t.PropertyConverters.Number})],mt.prototype,"maxThumbnailWidth",void 0),pt([t.Watch({converter:t.PropertyConverters.Number})],mt.prototype,"maxThumbnailHeight",void 0),pt([t.Watch({converter:t.PropertyConverters.Boolean})],mt.prototype,"allowSnapshot",void 0),pt([t.Watch()],mt.prototype,"_fetching",void 0),pt([t.Watch()],mt.prototype,"_images",void 0),pt([t.ViewChild(t.P+"-repeater")],mt.prototype,"_repeater",void 0),pt([t.ViewChild(t.P+"-upload[main]")],mt.prototype,"_uploader",void 0),pt([t.ViewChild(t.P+"-upload[thumb]")],mt.prototype,"_thumbUploader",void 0),pt([t.ViewChild(t.P+"-snapshot")],mt.prototype,"_snapshot",void 0),pt([t.ViewChild(t.P+"-progressbar")],mt.prototype,"_progressbar",void 0),pt([t.Debounce(500)],mt.prototype,"_imagefetch",null),mt=pt([t.CustomElement({tagName:t.P+"-edit-image",shadow:t.Defaults.USE_SHADOW_ROOT,template:`<${t.P}-panel class="${t.PCSS}-edit-image"\n css-class="{{ {'${t.PCSS}-snapshot': ::_snapshot.step != '${dt.Start}', '${t.PCSS}-uploading': ::_uploader.uploading, '${t.PCSS}-upload-enabled': !Pacem.Utils.isNullOrEmpty(:host.uploadUrl), '${t.PCSS}-snapshot-enabled': !Pacem.Utils.isNullOrEmpty(:host.uploadUrl) && :host.allowSnapshot} }}">\n <div>\n <${t.P}-input-search value="{{ :host.hint, twoway }}"></${t.P}-input-search>\n <${t.P}-upload main pattern=".+.(jpe?g|png|svg|ico)$" url="{{ :host.uploadUrl }}"\n max-image-width="{{ :host.maxWidth }}" max-image-height="{{ :host.maxHeight }}"\n on-${it}=":host._uploaderFileUploadCallback($event)"\n on-${t.PropertyChangeEventName}=":host._uploaderPropertyChangedCallback($event)" hide="{{ Pacem.Utils.isNullOrEmpty(:host.uploadUrl) || ::_thumbUploader.uploading }}"></${t.P}-upload>\n <${t.P}-upload thumb pattern=".+.(jpe?g|png|svg|ico)$" url="{{ :host.uploadUrl }}" hide="{{ !::_thumbUploader.uploading }}"\n max-image-width="{{ :host.maxThumbnailWidth }}" max-image-height="{{ :host.maxThumbnailHeight }}"\n on-${t.PropertyChangeEventName}=":host._thumbnailUploaderPropertyChangedCallback($event)"></${t.P}-upload>\n <${t.P}-button class="${t.PCSS}-snapshot" on-click="Pacem.avoidHandler($event); ::_snapshot.step = '${dt.Taking}'" hide="{{ Pacem.Utils.isNullOrEmpty(:host.uploadUrl) || !:host.allowSnapshot }}"></${t.P}-button>\n <${t.P}-infinite-scroller container="{{ ::_repeater }}" on-fetchmore=":host._imagefetchSuddenly()" disabled="{{ :host._fetching || :host.disabled || :host._images.length >= :host.imageSet.total }}"></${t.P}-infinite-scroller>\n <${t.P}-repeater datasource="{{ :host._images }}">\n <template>\n <${t.P}-img css-class="{{ {'${t.PCSS}-selected': ^item.src === :host.value } }}" on-click=":host.value = ^item.src" src="{{ ^item.thumb }}" adapt="contain"></${t.P}-img>\n </template>\n </${t.P}-repeater>\n <${t.P}-progressbar class="progressbar-smaller progressbar-accent" caption="{{ ::_thumbUploader.uploading ? 'thumbnail...' : 'uploading...' }}"></${t.P}-progressbar>\n </div>\n <div>\n <${t.P}-snapshot hide="{{ !:host.allowSnapshot }}" on-${t.PropertyChangeEventName}=":host._snapshotPropertyChangedCallback($event)"></${t.P}-snapshot>\n </div>\n </${t.P}-panel>`})],mt);let vt=class PacemImageInputElement extends PacemBaseElement{constructor(){super(...arguments),this._broadcastFetchRequestEventName=e=>{this.dispatchEvent(new ImageFetchRequestEvent(e.detail))},this._innerValueChangedHandler=e=>{"value"!==e.detail.propertyName||t.Utils.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 a=this.value;return t.CustomEventUtils.isInstanceOf(e,i.Components.UI.DialogResultEvent)&&e.detail.button===i.Components.UI.DialogButton.Ok?a=this.value=e.detail.state:e.target===this._input?a=this.value=this._input.value:e.target===this._clearBtn&&(a=this.value=void 0),t.Utils.fromResult(a)}toggleReadonlyView(e){this._input.hidden=this._editBtn.hide=this._clearBtn.hide=e}_addDialog(){var e=document.createElement(t.P+"-dialog");return e.buttons=i.Components.UI.DialogButtons.OkCancel,e.addEventListener(i.Components.UI.DialogResultEventName,this.changeHandler,!1),e.appendChild(this._addEditImage()),document.body.appendChild(e),this._dialog=e}_removeDialog(){this._removeEditImage(),t.Utils.isNull(this._dialog)||(this._dialog.removeEventListener(i.Components.UI.DialogResultEventName,this.changeHandler,!1),this._dialog.remove())}_addEditImage(){var e=document.createElement(t.P+"-edit-image");return e.disabled=!0,e.addEventListener(t.PropertyChangeEventName,this._innerValueChangedHandler,!1),e.addEventListener(ut,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(){t.Utils.isNull(this._editImage)||(this._editImage.removeEventListener(t.PropertyChangeEventName,this._innerValueChangedHandler,!1),this._editImage.removeEventListener(ut,this._broadcastFetchRequestEventName,!1))}connectedCallback(){super.connectedCallback(),this._addDialog()}disconnectedCallback(){this._removeDialog(),super.disconnectedCallback()}propertyChangedCallback(e,i,a,s){switch(super.propertyChangedCallback(e,i,a,s),e){case"uploadUrl":t.Utils.isNull(this._editImage)||(this._editImage.uploadUrl=a);break;case"allowSnapshot":t.Utils.isNull(this._editImage)||(this._editImage.allowSnapshot=a);break;case"imageSet":t.Utils.isNull(this._editImage)||(this._editImage.imageSet=a);break;case"maxThumbnailHeight":t.Utils.isNull(this._editImage)||(this._editImage.maxThumbnailHeight=a);break;case"maxThumbnailWidth":t.Utils.isNull(this._editImage)||(this._editImage.maxThumbnailWidth=a);break;case"maxHeight":t.Utils.isNull(this._editImage)||(this._editImage.maxHeight=a);break;case"maxWidth":t.Utils.isNull(this._editImage)||(this._editImage.maxWidth=a)}}acceptValue(e){t.Utils.isNull(this._editImage)||(this._editImage.value=e)}_update(e){this._image.src=e}_retrieve(){return this.value}_edit(e){t.avoidHandler(e);var a=this._editImage,s=this.value;a.disabled=!1,a.reset(),a.value=s,this._dialog.open(s).then(e=>{switch(e.button){case i.Components.UI.DialogButton.Cancel:this._update(this.value);break;case i.Components.UI.DialogButton.Ok:this._update(e.state)}this._editImage.disabled=!0})}};pt([t.ViewChild(t.P+"-img")],vt.prototype,"_image",void 0),pt([t.ViewChild(t.P+"-button."+t.PCSS+"-edit")],vt.prototype,"_editBtn",void 0),pt([t.ViewChild(t.P+"-button."+t.PCSS+"-clear")],vt.prototype,"_clearBtn",void 0),pt([t.ViewChild(t.P+"-input-url")],vt.prototype,"_input",void 0),pt([t.Watch({emit:!1,converter:t.PropertyConverters.String})],vt.prototype,"uploadUrl",void 0),pt([t.Watch({emit:!1,converter:t.PropertyConverters.Json})],vt.prototype,"imageSet",void 0),pt([t.Watch({emit:!1,converter:t.PropertyConverters.Number})],vt.prototype,"maxWidth",void 0),pt([t.Watch({emit:!1,converter:t.PropertyConverters.Number})],vt.prototype,"maxHeight",void 0),pt([t.Watch({emit:!1,converter:t.PropertyConverters.Number})],vt.prototype,"maxThumbnailWidth",void 0),pt([t.Watch({emit:!1,converter:t.PropertyConverters.Number})],vt.prototype,"maxThumbnailHeight",void 0),pt([t.Watch({emit:!1,converter:t.PropertyConverters.Boolean})],vt.prototype,"allowSnapshot",void 0),vt=pt([t.CustomElement({tagName:t.P+"-input-image",shadow:t.Defaults.USE_SHADOW_ROOT,template:`<div class="${t.PCSS}-input-image"><${t.P}-img src="{{ :host.value }}" adapt="contain"></${t.P}-img><div class="${t.PCSS}-input-image-dashboard">\n <${t.P}-button on-click=":host._edit($event)" hide="{{ :host.disabled }}" class="${t.PCSS}-edit">Edit</${t.P}-button>\n <${t.P}-button on-click=":host._clear($event)" hide="{{ :host.disabled }}" class="${t.PCSS}-clear">Clear</${t.P}-button>\n</div><${t.P}-input-url placeholder="{{ :host.placeholder }}" on-change=":host.changeHandler($event)" value="{{ :host.value }}"></${t.P}-input-url>\n\n <${t.P}-panel hide="{{ Pacem.Utils.isNullOrEmpty(:host.value) }}">\n <dl class="${t.PCSS}-input-image-preview">\n <dt>dimensions:</dt><dd><${t.P}-text text="{{ ::_image.size.width +'x'+ ::_image.size.height }}"></${t.P}-text></dd>\n <dt>size:</dt><dd><${t.P}-text text="{{ $pacem.size(::_image.size.weight) }}"></${t.P}-text></dd>\n </dl></${t.P}-panel>\n\n</div>`})],vt);var gt=function(e,t,i,a){var s,r=arguments.length,n=r<3?t:null===a?a=Object.getOwnPropertyDescriptor(t,i):a;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(e,t,i,a);else for(var o=e.length-1;o>=0;o--)(s=e[o])&&(n=(r<3?s(n):r>3?s(t,i,n):s(t,i))||n);return r>3&&n&&Object.defineProperty(t,i,n),n};let yt=class PacemNumberInputElement extends PacemOrdinalInputElement{toggleReadonlyView(e){this._span.hidden=!e,this._input.hidden=e}get inputFields(){return t.Utils.isNull(this._input)?[]:[this._input]}getViewValue(e){return null!=this.value?this._format(this.value):void 0}_format(e=this.value){const i=this.format;return t.Utils.isNullOrEmpty(i)?e.toString():new Intl.NumberFormat(t.Utils.lang(this),i).format(e)}getValue(e){const t=this.inputField.valueAsNumber||parseFloat(this.inputField.value);return isNaN(t)?void 0:t}viewActivatedCallback(){super.viewActivatedCallback();this._input.addEventListener("wheel",this.emitHandler,{capture:!1,passive:!1})}disconnectedCallback(){if(!t.Utils.isNull(this._input)){this._input.removeEventListener("wheel",this.emitHandler,{capture:!1,passive:!1})}super.disconnectedCallback()}};gt([t.ViewChild("input[type=number]")],yt.prototype,"_input",void 0),gt([t.ViewChild(`span.${t.PCSS}-readonly`)],yt.prototype,"_span",void 0),gt([t.Watch({emit:!1,converter:t.PropertyConverters.Json})],yt.prototype,"format",void 0),yt=gt([t.CustomElement({tagName:t.P+"-input-number",template:`<input type="number" class="${t.PCSS}-input ${t.PCSS}-viewfinder" /><span class="${t.PCSS}-readonly"><${t.P}-text text="{{ :host.viewValue }}"></${t.P}-text></span>`,shadow:t.Defaults.USE_SHADOW_ROOT})],yt);var ft=function(e,t,i,a){var s,r=arguments.length,n=r<3?t:null===a?a=Object.getOwnPropertyDescriptor(t,i):a;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(e,t,i,a);else for(var o=e.length-1;o>=0;o--)(s=e[o])&&(n=(r<3?s(n):r>3?s(t,i,n):s(t,i))||n);return r>3&&n&&Object.defineProperty(t,i,n),n};let _t=class PacemPasswordInputElement extends PacemTextualInputElement{constructor(){super(),this._togglerMousedownHandler=e=>{0==e.button&&(t.avoidHandler(e),this.toggleVisibility())}}get inputFields(){return t.Utils.isNull(this._input)?[]:[this._input]}viewActivatedCallback(){super.viewActivatedCallback();const e=this.id??"_"+t.Utils.uniqueCode(),i=this._input.id=e+"_ctrl";this._toggler.setAttribute("aria-controls",i),this._toggler.setAttribute("role","button"),this._syncToggler(),this._toggler.addEventListener("mousedown",this._togglerMousedownHandler,!1)}disconnectedCallback(){t.Utils.isNull(this._toggler)||this._toggler.removeEventListener("mousedown",this._togglerMousedownHandler,!1)}toggleVisibility(){const e=this._input.type;this._input.type="password"===e?"text":"password",this._syncToggler()}_syncToggler(){const e="password"===this._input.type;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 t.Utils.leftPad("",Math.floor(8+3*Math.random()),"•")}};ft([t.ViewChild("input[type=password]")],_t.prototype,"_input",void 0),ft([t.ViewChild(`span.${t.PCSS}-readonly`)],_t.prototype,"_span",void 0),ft([t.ViewChild(`i.${t.PCSS}-icon.${t.PCSS}-clickable`)],_t.prototype,"_toggler",void 0),_t=ft([t.CustomElement({tagName:t.P+"-input-password",template:`<input type="password" class="${t.PCSS}-input ${t.PCSS}-viewfinder" /><i class="${t.PCSS}-icon ${t.PCSS}-clickable"></i>\n${E}<span class="${t.PCSS}-readonly"><${t.P}-text text="{{ :host.viewValue }}"></${t.P}-text></span>`,shadow:t.Defaults.USE_SHADOW_ROOT})],_t);var bt=function(e,t,i,a){var s,r=arguments.length,n=r<3?t:null===a?a=Object.getOwnPropertyDescriptor(t,i):a;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(e,t,i,a);else for(var o=e.length-1;o>=0;o--)(s=e[o])&&(n=(r<3?s(n):r>3?s(t,i,n):s(t,i))||n);return r>3&&n&&Object.defineProperty(t,i,n),n};let Ct=class PacemSearchInputElement extends PacemTextualInputElement{constructor(){super()}get inputFields(){return t.Utils.isNull(this._input)?[]:[this._input]}toggleReadonlyView(e){}};bt([t.ViewChild("input[type=search]")],Ct.prototype,"_input",void 0),Ct=bt([t.CustomElement({tagName:t.P+"-input-search",template:'<input type="search" class="'+t.PCSS+'-input" />',shadow:t.Defaults.USE_SHADOW_ROOT})],Ct);var Pt=function(e,t,i,a){var s,r=arguments.length,n=r<3?t:null===a?a=Object.getOwnPropertyDescriptor(t,i):a;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(e,t,i,a);else for(var o=e.length-1;o>=0;o--)(s=e[o])&&(n=(r<3?s(n):r>3?s(t,i,n):s(t,i))||n);return r>3&&n&&Object.defineProperty(t,i,n),n};let Et=class PacemTelInputElement extends PacemTextualInputElement{constructor(){super()}toggleReadonlyView(e){const i=this._input,a=this._anchor;t.Utils.isNull(i)||(i.hidden=e),t.Utils.isNull(a)||(a.hidden=!e)}get inputFields(){return t.Utils.isNull(this._input)?[]:[this._input]}};Pt([t.ViewChild("input[type=tel]")],Et.prototype,"_input",void 0),Pt([t.ViewChild(t.P+"-a")],Et.prototype,"_anchor",void 0),Et=Pt([t.CustomElement({tagName:t.P+"-input-tel",template:`<input type="tel" class="${t.PCSS}-input" /><${t.P}-a class="${t.PCSS}-readonly" disabled="{{ $pacem.isNullOrEmpty(:host.value) }}" href="{{ 'tel:'+ :host.value }}"><${t.P}-text text="{{ :host.viewValue }}"></${t.P}-text></${t.P}-a>`,shadow:t.Defaults.USE_SHADOW_ROOT})],Et);var wt=function(e,t,i,a){var s,r=arguments.length,n=r<3?t:null===a?a=Object.getOwnPropertyDescriptor(t,i):a;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(e,t,i,a);else for(var o=e.length-1;o>=0;o--)(s=e[o])&&(n=(r<3?s(n):r>3?s(t,i,n):s(t,i))||n);return r>3&&n&&Object.defineProperty(t,i,n),n};let St=class PacemTextInputElement extends PacemTextualInputElement{constructor(){super()}toggleReadonlyView(e){this._span.hidden=!e,this._input.hidden=e}get inputFields(){return t.Utils.isNull(this._input)?[]:[this._input]}};wt([t.ViewChild("input[type=text]")],St.prototype,"_input",void 0),wt([t.ViewChild("span."+t.PCSS+"-readonly")],St.prototype,"_span",void 0),St=wt([t.CustomElement({tagName:t.P+"-input-text",template:`<input type="text" class="${t.PCSS}-input" />${E}<span class="${t.PCSS}-readonly"><${t.P}-text text="{{ :host.viewValue }}"></${t.P}-text></span>`,shadow:t.Defaults.USE_SHADOW_ROOT})],St);var kt=function(e,t,i,a){var s,r=arguments.length,n=r<3?t:null===a?a=Object.getOwnPropertyDescriptor(t,i):a;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(e,t,i,a);else for(var o=e.length-1;o>=0;o--)(s=e[o])&&(n=(r<3?s(n):r>3?s(t,i,n):s(t,i))||n);return r>3&&n&&Object.defineProperty(t,i,n),n};let $t=class PacemUrlInputElement extends PacemTextualInputElement{constructor(){super()}toggleReadonlyView(e){const i=this._input,a=this._anchor;t.Utils.isNull(i)||(i.hidden=e),t.Utils.isNull(a)||(a.hidden=!e)}get inputFields(){return t.Utils.isNull(this._input)?[]:[this._input]}};kt([t.ViewChild("input[type=url]")],$t.prototype,"_input",void 0),kt([t.ViewChild(t.P+"-a")],$t.prototype,"_anchor",void 0),$t=kt([t.CustomElement({tagName:t.P+"-input-url",template:`<input type="url" class="${t.PCSS}-input" />${E}<${t.P}-a class="${t.PCSS}-readonly" disabled="{{ $pacem.isNullOrEmpty(:host.value) }}" href="{{ :host.value }}" target="_blank"><${t.P}-text text="{{ :host.viewValue }}"></${t.P}-text></${t.P}-a>`,shadow:t.Defaults.USE_SHADOW_ROOT})],$t);var Ut=function(e,t,i,a){var s,r=arguments.length,n=r<3?t:null===a?a=Object.getOwnPropertyDescriptor(t,i):a;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(e,t,i,a);else for(var o=e.length-1;o>=0;o--)(s=e[o])&&(n=(r<3?s(n):r>3?s(t,i,n):s(t,i))||n);return r>3&&n&&Object.defineProperty(t,i,n),n};let Nt=class PacemLatLngElement extends PacemBaseElement{convertValueAttributeToProperty(e){const t=/^\s*([+-]?\d+\.?\d+)[,\s]\s*([+-]?\d+\.?\d+)\s*$/.exec(e);if(t&&3===t.length)return{lat:parseFloat(t[1]),lng:parseFloat(t[2])};throw`Invalid coordinates format for "${e}"`}compareValuePropertyValues(e,t){return!(!e||"number"!=typeof e.lat||"number"!=typeof e.lng||!t||"number"!=typeof t.lat||"number"!=typeof t.lng)&&(e.lat===t.lat&&e.lng===t.lng)}getViewValue(e){return this._getViewValue(e)}_getViewValue(e,t=8){return e&&"number"==typeof e.lat&&"number"==typeof e.lng&&e.lat.toFixed(t)+","+e.lng.toFixed(t)||""}get inputFields(){return[this._latInput,this._lngInput]}toggleReadonlyView(e){this._inputContainer.hidden=e}acceptValue(e){let t=this._ensureValue(e);this._lat=t.lat,this._lng=t.lng}_ensureValue(e){return e&&"number"==typeof e.lat&&"number"==typeof e.lng?e:a.Components.Maps.MapConsts.DEFAULT_COORDS}onChange(e){if(e&&"dragend"===e.type){var i=e;this._lat=i.detail.position.lat,this._lng=i.detail.position.lng}const a=this._lat,s=this._lng;return t.Utils.isNull(a)||t.Utils.isNull(s)?t.Utils.fromResult(this.value):t.Utils.fromResult(this.value={lat:a,lng:s})}propertyChangedCallback(e,i,a,s){if(super.propertyChangedCallback(e,i,a,s),"options"===e&&!s){const e=t.Utils.clone(a||{provider:"osm"});this._synchronizeOptions(e)}}viewActivatedCallback(){super.viewActivatedCallback(),this._synchronizeOptions()}_synchronizeOptions(e=this.options||{provider:"osm"}){const i=this._marker,a=this._map;switch(i.icon=e.icon,e&&e.provider){case"azure":this._azureAdapter.subscriptionKey=e.apiKey,a.adapter=this._azureAdapter;break;case"google":case"gmaps":this._googleAdapter.apiKey=e.apiKey,a.adapter=this._googleAdapter;break;default:t.Utils.isNullOrEmpty(e.attribution)||(this._leafletAdapter.attribution=e.attribution),t.Utils.isNullOrEmpty(e.tiles)||(this._leafletAdapter.tiles=e.tiles),a.adapter=this._leafletAdapter}delete e.provider,delete e.icon,delete e.apiKey,delete e.attribution,delete e.tiles;for(let t in e)t in a&&(a[t]=e[t])}};Ut([t.ViewChild(t.P+"-map-adapter-leaflet")],Nt.prototype,"_leafletAdapter",void 0),Ut([t.ViewChild(t.P+"-map-adapter-azure")],Nt.prototype,"_azureAdapter",void 0),Ut([t.ViewChild(t.P+"-map-adapter-google")],Nt.prototype,"_googleAdapter",void 0),Ut([t.ViewChild(t.P+"-map")],Nt.prototype,"_map",void 0),Ut([t.ViewChild(t.P+"-map-marker")],Nt.prototype,"_marker",void 0),Ut([t.ViewChild(t.P+"-input-number:nth-child(1)")],Nt.prototype,"_latInput",void 0),Ut([t.ViewChild(t.P+"-input-number:nth-child(2)")],Nt.prototype,"_lngInput",void 0),Ut([t.ViewChild(`.${t.PCSS}-latlng-fields`)],Nt.prototype,"_inputContainer",void 0),Ut([t.ViewChild(t.P+"-fetch")],Nt.prototype,"_fetcher",void 0),Ut([t.Watch({converter:t.PropertyConverters.Json,emit:!1})],Nt.prototype,"options",void 0),Ut([t.Watch()],Nt.prototype,"_lat",void 0),Ut([t.Watch()],Nt.prototype,"_lng",void 0),Nt=Ut([t.CustomElement({tagName:t.P+"-latlng",shadow:t.Defaults.USE_SHADOW_ROOT,template:`<div class="${t.PCSS}-latlng">\n <div class="${t.PCSS}-latlng-fields ${t.PCSS}-viewfinder">\n <${t.P}-input-number class="${t.PCSS}-lat" value="{{ :host._lat, twoway }}" min="-90" max="90" step="{{ 'any' }}"></${t.P}-input-number>\n <${t.P}-input-number class="${t.PCSS}-lng" value="{{ :host._lng, twoway }}" min="-180" max="180" step="{{ 'any' }}"></${t.P}-input-number>\n </div>\n <${t.P}-panel hide="{{ Pacem.Utils.isNull(:host.value) || :host.readonly }}">\n <dl class="${t.PCSS}-latlng-preview">\n <dt>decimals:</dt><dd><${t.P}-text text="{{ :host._getViewValue(:host.value, 12) }}"></${t.P}-text></dd>\n <dt>address:</dt><dd><${t.P}-text text="{{ ::_fetcher.result.display_name || '?' }}"></${t.P}-text></dd>\n <dt>degrees:</dt><dd><${t.P}-span css-class="{{ {'${t.PCSS}-lat-north': :host._lat > 0, '${t.PCSS}-lat-south': :host._lat < 0} }}" content="{{ $pacem.decToDeg(Math.abs(:host._lat)) }}"></${t.P}-span>,\n <${t.P}-span css-class="{{ {'${t.PCSS}-lng-east': :host._lng > 0, '${t.PCSS}-lng-west': :host._lng < 0} }}" content="{{ $pacem.decToDeg(Math.abs(:host._lng)) }}"></${t.P}-span></dd>\n </dl>\n </${t.P}-panel>\n <${t.P}-span class="${t.PCSS}-readonly" hide="{{ !:host.readonly }}" content="{{ :host.viewValue + ($pacem.isNullOrEmpty(::_fetcher.result.display_name) ? '' : (' <small>'+ ::_fetcher.result.display_name +'</small>')) }}"></${t.P}-span>\n\n <${t.P}-map-adapter-leaflet></${t.P}-map-adapter-leaflet>\n <${t.P}-map-adapter-azure></${t.P}-map-adapter-azure>\n <${t.P}-map-adapter-google></${t.P}-map-adapter-google>\n\n <${t.P}-map adapter="{{ ::_adapter }}">\n <${t.P}-map-marker position="{{ :host._ensureValue(:host.value) }}" on-dragend=":host.changeHandler($event)" draggable="{{ !:host.readonly }}"></${t.P}-map-marker>\n </${t.P}-map>\n <${t.P}-fetch disabled="{{ $pacem.isNull(:host.value) }}" parameters="{{ { format: 'json', lat: :host._lat, lon: :host._lng } }}" url="https://nominatim.openstreetmap.org/reverse"></${t.P}-fetch>\n</div>`})],Nt);var Ot=function(e,t,i,a){var s,r=arguments.length,n=r<3?t:null===a?a=Object.getOwnPropertyDescriptor(t,i):a;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(e,t,i,a);else for(var o=e.length-1;o>=0;o--)(s=e[o])&&(n=(r<3?s(n):r>3?s(t,i,n):s(t,i))||n);return r>3&&n&&Object.defineProperty(t,i,n),n};const xt=`change-policy="${qe.Blur}" readonly="{{ :host.readonly }}"`;function Vt(e){return t.Utils.isNullOrEmpty(e&&e.name)}let Dt=class PacemNameValueListElement extends PacemBaseElement{constructor(){super(...arguments),this.inputFields=[],this._bag=[]}toggleReadonlyView(e){}onChange(e){return new Promise((e,t)=>{let i=this._bagToValue(this._bag);this.compareValuePropertyValues(i,this.value)?t():e(this.value=i)})}acceptValue(e){this._bag=this._valueToBag(e)}getViewValue(e){return""}compareValuePropertyValues(e,i){return t.Utils.Json.stringify(e)===t.Utils.Json.stringify(i)}convertValueAttributeToProperty(e){return t.PropertyConverters.Json.convert(e)}propertyChangedCallback(e,t,i,a){super.propertyChangedCallback(e,t,i,a),"dictionary"!==e||a||(this.value=this._bagToValue())}_bagToValue(e=this._bag){if(!this.dictionary){let t=[];for(let i of e||[])Vt(i)||t.find(e=>e.name===i.name&&e.value===i.value)||t.push(i);return t}let t={};for(let i of e||[])i.name in t||(t[i.name]=i.value);return t}_valueToBag(e=this.value){const i=[];if(!t.Utils.isNullOrEmpty(e)&&"object"==typeof e)if(this.dictionary&&!t.Utils.isArray(e))for(let t in e)i.push({name:t,value:e[t]});else!this.dictionary&&t.Utils.isArray(e)&&Array.prototype.splice.apply(i,[0,0].concat(e.map(e=>t.Utils.clone(e))));return t.Utils.isNullOrEmpty(i)?[{name:"",value:""}]:i}_deleteAt(e){this._bag.splice(e.detail,1),this.changeHandler(e)}_addItem(e){const i=this._bag,a=this._bag[this._bag.length-1];!t.Utils.isEmpty(i)&&Vt(a)||i.push({name:"",value:""})}};Ot([t.Watch({emit:!1,converter:t.PropertyConverters.Boolean})],Dt.prototype,"dictionary",void 0),Ot([t.Watch({converter:t.PropertyConverters.Json})],Dt.prototype,"_bag",void 0),Dt=Ot([t.CustomElement({tagName:t.P+"-namevalue-list",shadow:t.Defaults.USE_SHADOW_ROOT,template:`<${t.P}-repeater datasource="{{ :host._bag }}" on-itemdelete=":host._deleteAt($event)">\n <template>\n <div class="${t.PCSS}-fieldset ${t.PCSS}-margin margin-bottom-1">\n <div class="fieldset-auto">\n <div class="${t.PCSS}-fieldgroup">\n <${t.P}-input-text ${xt} value="{{ ^item.name, twoway }}" on-change=":host.changeHandler($event)"></${t.P}-input-text>\n <div class="fieldgroup-prepend"></div>\n </div>\n <div class="${t.PCSS}-fieldgroup">\n <${t.P}-input-text ${xt} value="{{ ^item.value, twoway }}" on-change=":host.changeHandler($event)"></${t.P}-input-text>\n <div class="fieldgroup-append">\n <${t.P}-button class="${t.PCSS}-cell cols-2 flat delete" hide="{{ :host.readonly }}" command-name="delete" command-argument="{{ ^index }}"></${t.P}-button>\n </div>\n </div>\n </div>\n </div>\n </template>\n <${t.P}-button class="flat add" hide="{{ :host.readonly }}" on-click=":host._addItem($event)"></${t.P}-button>\n</${t.P}-repeater>`})],Dt);var Ht=function(e,t,i,a){var s,r=arguments.length,n=r<3?t:null===a?a=Object.getOwnPropertyDescriptor(t,i):a;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(e,t,i,a);else for(var o=e.length-1;o>=0;o--)(s=e[o])&&(n=(r<3?s(n):r>3?s(t,i,n):s(t,i))||n);return r>3&&n&&Object.defineProperty(t,i,n),n};let At=class PacemPropertyPickerElement extends PacemBaseElement{get inputFields(){return[this._select]}toggleReadonlyView(e){this._select.readonly=e}onChange(e){return t.Utils.fromResult(this.value=this._select.value)}acceptValue(e){this._select.value=e}getViewValue(e){return this._select.viewValue}convertValueAttributeToProperty(e){return t.PropertyConverters.Element.convert(e)}viewActivatedCallback(){super.viewActivatedCallback(),this._databind()}propertyChangedCallback(e,t,i,a){if(super.propertyChangedCallback(e,t,i,a),!a&&"target"===e)this._databind()}_databind(){const e=[],i=(a,s,r)=>{const n=a[s];if("object"==typeof n&&null!=n&&!t.Utils.isArray(n))for(let t of Object.keys(n)){const a=r+"."+t;e.push(a),i(n,t,a)}};let a=this.target;if(!t.Utils.isNull(a)){let s=t.CustomElementUtils.getWatchedProperties(a);for(let t of s){let s=t.name;e.push(s),i(a,s,s)}}this._select.datasource=e.sort()}};Ht([t.ViewChild(t.P+"-select")],At.prototype,"_select",void 0),Ht([t.Watch({converter:t.PropertyConverters.Element})],At.prototype,"target",void 0),At=Ht([t.CustomElement({tagName:t.P+"-property-picker",shadow:t.Defaults.USE_SHADOW_ROOT,template:`<${t.P}-select></${t.P}-select>`})],At);var Tt=function(e,t,i,a){var s,r=arguments.length,n=r<3?t:null===a?a=Object.getOwnPropertyDescriptor(t,i):a;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(e,t,i,a);else for(var o=e.length-1;o>=0;o--)(s=e[o])&&(n=(r<3?s(n):r>3?s(t,i,n):s(t,i))||n);return r>3&&n&&Object.defineProperty(t,i,n),n};let Rt=class PacemRadioElement extends PacemBaseElement{convertValueAttributeToProperty(e){return e}constructor(){super(),this._key="_"+t.Utils.uniqueCode()}toggleReadonlyView(e){this.span.hidden=!e,this._radio.hidden=e}get inputFields(){return[this._radio]}onChange(e){this.selected=this._radio.checked;const i=this.selected?this._radio.value:void 0;return t.Utils.fromResult(i)}viewActivatedCallback(){super.viewActivatedCallback(),this._radio.id=this._label.htmlFor=this._key}propertyChangedCallback(e,i,a,s){switch(super.propertyChangedCallback(e,i,a,s),e){case"name":this._radio.name=a;break;case"selected":(this._radio.checked=a)?t.Utils.addClass(this,t.PCSS+"-selected"):t.Utils.removeClass(this,t.PCSS+"-selected")}}acceptValue(e){this._radio.value=t.Utils.isNullOrEmpty(e)?"":e}getViewValue(e){return t.Utils.isNull(e)?"":this.caption}};Tt([t.ViewChild("input[type=radio]")],Rt.prototype,"_radio",void 0),Tt([t.ViewChild("label")],Rt.prototype,"_label",void 0),Tt([t.ViewChild(`.${t.PCSS}-readonly`)],Rt.prototype,"span",void 0),Tt([t.Watch({converter:t.PropertyConverters.String})],Rt.prototype,"caption",void 0),Tt([t.Watch({converter:t.PropertyConverters.Boolean})],Rt.prototype,"selected",void 0),Rt=Tt([t.CustomElement({tagName:t.P+"-radio",template:`<${t.P}-span class="${t.PCSS}-readonly ${t.PCSS}-radio" text="{{ :host.caption }}"></${t.P}-span><input type="radio" class="${t.PCSS}-input" /><label class="${t.PCSS}-label ${t.PCSS}-radio ${t.PCSS}-viewfinder"><${t.P}-text text="{{ :host.caption }}"></${t.P}-text></label>`,shadow:t.Defaults.USE_SHADOW_ROOT})],Rt);var Lt=function(e,t,i,a){var s,r=arguments.length,n=r<3?t:null===a?a=Object.getOwnPropertyDescriptor(t,i):a;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(e,t,i,a);else for(var o=e.length-1;o>=0;o--)(s=e[o])&&(n=(r<3?s(n):r>3?s(t,i,n):s(t,i))||n);return r>3&&n&&Object.defineProperty(t,i,n),n};let It=class PacemRadioListElement extends PacemDataSourceElement{acceptValue(e){}constructor(){super(),this.key="_"+t.Utils.uniqueCode()}get inputFields(){return[]}propertyChangedCallback(e,t,i,a){super.propertyChangedCallback(e,t,i,a),"disabled"===e&&(this._disable.model=i)}viewActivatedCallback(){super.viewActivatedCallback(),this._disable.model=this.disabled}toggleReadonlyView(e){this._repeater.hidden=e,this._span.hidden=!e}_selectionChanged(e,t,i){"selected"===e.detail.propertyName&&!0===e.detail.currentValue&&(this._selectedValue=this.mapEntityToValue(this.datasource[t]),this.changeHandler(e))}onChange(e){return this.value=this._selectedValue,this.databind(),t.Utils.fromResult(this._selectedValue)}};Lt([t.ViewChild(t.P+"-repeater")],It.prototype,"_repeater",void 0),Lt([t.ViewChild(t.P+"-data")],It.prototype,"_disable",void 0),Lt([t.ViewChild(`span.${t.PCSS}-readonly`)],It.prototype,"_span",void 0),It=Lt([t.CustomElement({tagName:t.P+"-radio-list",template:`<${t.P}-repeater datasource="{{ :host.adaptedDatasource }}">\n <ol class="${t.PCSS}-radio-list ${t.PCSS}-viewfinder" pacem>\n <template>\n <li><${t.P}-radio disabled="{{ ::_disable.model || ^item.disabled }}" name="{{ :host.key, once }}" autobind="off" caption="{{ ^item.viewValue }}" value="{{ ^item.value }}" selected="{{ :host.isDataSourceItemSelected(^item, :host.value) }}"\non-focus=":host.focusHandler($event)" on-blur=":host.focusHandler($event)"\non-${t.PropertyChangeEventName}=":host._selectionChanged($event, ^index, ^item)"></${t.P}-radio></li>\n </template>\n </ol>\n</${t.P}-repeater><span class="${t.PCSS}-readonly ${t.PCSS}-radio"><${t.P}-text text="{{ :host.viewValue }}"></${t.P}-text></span><${t.P}-data></${t.P}-data><${t.P}-content></${t.P}-content>`,shadow:t.Defaults.USE_SHADOW_ROOT})],It);var Ft=function(e,t,i,a){var s,r=arguments.length,n=r<3?t:null===a?a=Object.getOwnPropertyDescriptor(t,i):a;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(e,t,i,a);else for(var o=e.length-1;o>=0;o--)(s=e[o])&&(n=(r<3?s(n):r>3?s(t,i,n):s(t,i))||n);return r>3&&n&&Object.defineProperty(t,i,n),n};let Wt=class PacemSelectElement extends PacemDataSourceElement{constructor(){super(...arguments),this.emptyOption=!0}toggleReadonlyView(e){this._repeater.hidden=e,this._span.hidden=!e}get inputFields(){return t.Utils.isNull(this._select)?[]:[this._select]}_manageDom(e){const i=e.detail,a=i.item;let s=i.dom.find(e=>e instanceof HTMLOptionElement);s.value=a.value,s.textContent=a.viewValue,s.disabled=a.disabled,s.selected=this.isDataSourceItemSelected(a),(t.Utils.isNullOrEmpty(s.value)?t.Utils.addClass:t.Utils.removeClass).apply(this,[s,t.PCSS+"-watermark"])}onChange(e){let i,a=this._select.selectedIndex,s=this.adaptedDatasource,r=a>=0&&s[a];return i=null!=r?r.value:void 0,t.Utils.fromResult(this.value=i)}propertyChangedCallback(e,t,i,a){switch(super.propertyChangedCallback(e,t,i,a),e){case"placeholder":case"emptyOption":this.databind()}}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):t.Utils.isNullOrEmpty(e)?this.value=void 0:this.value=e[0].value}acceptValue(e){const i=this.adaptedDatasource,a=i&&i.filter(t=>this.isDataSourceItemSelected(t,e));if(a&&1==a.length)this._select.selectedIndex=i.indexOf(a[0]);else{this._select.value=void 0;let e=this._select.options;e.length>0&&t.Utils.isNullOrEmpty(e[0].value)&&(this._select.selectedIndex=0)}}viewActivatedCallback(){super.viewActivatedCallback();this._select.addEventListener("wheel",this.emitHandler,{capture:!1,passive:!1})}disconnectedCallback(){if(!t.Utils.isNull(this._select)){this._select.removeEventListener("wheel",this.emitHandler,{capture:!1,passive:!1})}super.disconnectedCallback()}};Ft([t.ViewChild("select")],Wt.prototype,"_select",void 0),Ft([t.ViewChild(t.P+"-repeater")],Wt.prototype,"_repeater",void 0),Ft([t.ViewChild(`span.${t.PCSS}-readonly`)],Wt.prototype,"_span",void 0),Ft([t.Watch({emit:!1,converter:t.PropertyConverters.Boolean})],Wt.prototype,"emptyOption",void 0),Wt=Ft([t.CustomElement({tagName:t.P+"-select",template:`<${t.P}-repeater datasource="{{ :host.adaptedDatasource }}" on-${t.Components.RepeaterItemCreateEventName}=":host._manageDom($event)">\n <select class="${t.PCSS}-select ${t.PCSS}-viewfinder">\n <template>\n <option></option>\n </template>\n </select>\n</${t.P}-repeater><span class="${t.PCSS}-readonly"><${t.P}-text text="{{ :host.viewValue }}"></${t.P}-text></span><${t.P}-content></${t.P}-content>`,shadow:t.Defaults.USE_SHADOW_ROOT})],Wt);var Bt=function(e,t,i,a){var s,r=arguments.length,n=r<3?t:null===a?a=Object.getOwnPropertyDescriptor(t,i):a;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(e,t,i,a);else for(var o=e.length-1;o>=0;o--)(s=e[o])&&(n=(r<3?s(n):r>3?s(t,i,n):s(t,i))||n);return r>3&&n&&Object.defineProperty(t,i,n),n};let jt=class PacemSliderElement extends PacemBaseElement{constructor(){super(...arguments),this.inputFields=[],this._dragHandler=e=>{e.preventDefault(),this._computeAndAssignValue(e.detail.currentPosition.x,"end"!==this.changePolicy)},this._endHandler=e=>{e.preventDefault(),this._computeAndAssignValue(e.detail.currentPosition.x,"end"===this.changePolicy)},this._startHandler=e=>{this._thumb.focus()},this._downHandler=e=>{const i=e instanceof MouseEvent?e.clientX:e.touches&&e.touches.length&&e.touches[0].clientX,a=this._trackSize;t.Utils.isNullOrEmpty(a)||this._computeAndAssignValue(i,!0)},this._keydownHandler=e=>{switch(e.keyCode){case 39:case 37:t.avoidHandler(e);let i=39===e.keyCode,a=("number"!=typeof this.step?1:this.step)*(i?1:-1),s=!1,r=e=>{s=!0,window.removeEventListener("keyup",r,!1),t.Utils.removeClass(this,"slider-keydown")};window.addEventListener("keyup",r,!1),t.Utils.addClass(this,"slider-keydown"),t.Utils.accelerateCallback(e=>{(e.cancel=s)||this._setValue(this.value+a)})}}}onChange(e){return new Promise((t,i)=>{"slide"===e.type&&t(this.value=e.detail),t(this.value)})}_draw(e=this.value){const i=this._trackSize;if(t.Utils.isNull(i))return;const a=t.Utils.isNullOrEmpty(e)?this.min:parseFloat(e),s=Math.min(1,Math.max(0,(a-this.min)/(this.max-this.min)));this._progress.style.transform=`scale(${s}, 1)`,this._thumb.style.transform=`translateX(${Math.round(s*i.width)}px)`}_format(e){const i=this.format;if(!t.Utils.isNullOrEmpty(i))return new Intl.NumberFormat(t.Utils.lang(this),i).format(e);let a="-";t.Utils.isNull(e)||(a=e.toLocaleString());let s=new CustomEvent("formatvalue",{detail:{value:e}});return this.dispatchEvent(s),t.Utils.isNull(s.detail.output)?a:s.detail.output}acceptValue(e){this._draw(e)}getViewValue(e){return this._format(e)}convertValueAttributeToProperty(e){return parseFloat(e)}toggleReadonlyView(e){this._thumb.hidden=e;const i="cursor-pointer";e?(t.Utils.removeClass(this._max,i),t.Utils.removeClass(this._min,i)):(t.Utils.addClass(this._max,i),t.Utils.addClass(this._min,i))}_setTrackSize(e){const 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;const i=this._trackSize,a=this.step;let s=(e-i.x)/i.width,r=(this.max-this.min)*s+this.min;"number"==typeof a&&(r=Math.round(r/a)*a),t?this._setValue(r):this._draw(r)}_setValue(e){isNaN(e)||t.Utils.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(t.UI.DragDropEventType.Init,this._startHandler,!1),this._dragger.addEventListener(t.UI.DragDropEventType.Drag,this._dragHandler,!1),this._dragger.addEventListener(t.UI.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);const e=this._shellProxy.dom[0];t.Utils.isNull(e)||(e.target=this._thumb,e.options={trigger:i.Components.UI.BalloonTrigger.Focus,trackPosition:!0,position:i.Components.UI.BalloonPosition.Top,align:i.Components.UI.BalloonAlignment.Center,behavior:i.Components.UI.BalloonBehavior.Tooltip,hoverDelay:0,hoverTimeout:0},this._syncThumbLabel()),this._thumb.tabIndex=0}_syncThumbLabel(e=this.thumbLabel){const i=this._shellProxy.dom[0];(e?t.Utils.addClass:t.Utils.removeClass).apply(this,[this,"slider-thumblabel"]),i.disabled=!e}disconnectedCallback(){this.removeEventListener("mousedown",this._downHandler,!1),this.removeEventListener("touchstart",this._downHandler,{capture:!1}),t.Utils.isNull(this._dragger)||(this._dragger.removeEventListener(t.UI.DragDropEventType.End,this._endHandler,!1),this._dragger.removeEventListener(t.UI.DragDropEventType.Drag,this._dragHandler,!1),this._dragger.removeEventListener(t.UI.DragDropEventType.Init,this._startHandler,!1)),t.Utils.isNull(this._thumb)||this._thumb.removeEventListener("keydown",this._keydownHandler,!1),super.disconnectedCallback()}propertyChangedCallback(e,i,a,s){if(super.propertyChangedCallback(e,i,a,s),!s)switch(e){case"thumbLabel":this._syncThumbLabel(a);break;case"min":case"max":t.Utils.isNull(this._max)||t.Utils.isNull(this._min)||(this._min.text=this._format(this.min),this._max.text=this._format(this.max)),this._setValue(this.value),this._draw()}}};Bt([t.Watch({emit:!1,converter:t.PropertyConverters.Number})],jt.prototype,"min",void 0),Bt([t.Watch({emit:!1,converter:t.PropertyConverters.Number})],jt.prototype,"max",void 0),Bt([t.Watch({emit:!1,converter:t.PropertyConverters.Boolean})],jt.prototype,"thumbLabel",void 0),Bt([t.Watch({emit:!1,converter:{convert:e=>{let t=parseFloat(e);return isNaN(t)?"any":t},convertBack:e=>(e||"").toString()}})],jt.prototype,"step",void 0),Bt([t.Watch({emit:!1,converter:t.PropertyConverters.String})],jt.prototype,"changePolicy",void 0),Bt([t.Watch({emit:!1,converter:t.PropertyConverters.Json})],jt.prototype,"format",void 0),Bt([t.ViewChild(".slider-track")],jt.prototype,"_track",void 0),Bt([t.ViewChild(".slider-progress")],jt.prototype,"_progress",void 0),Bt([t.ViewChild(".slider-thumb")],jt.prototype,"_thumb",void 0),Bt([t.ViewChild(`${t.P}-text[min]`)],jt.prototype,"_min",void 0),Bt([t.ViewChild(`${t.P}-text[max]`)],jt.prototype,"_max",void 0),Bt([t.ViewChild(`${t.P}-drag-drop`)],jt.prototype,"_dragger",void 0),Bt([t.ViewChild(`${t.P}-shell-proxy`)],jt.prototype,"_shellProxy",void 0),jt=Bt([t.CustomElement({tagName:t.P+"-slider",template:`<div class="${t.PCSS}-viewfinder ${t.PCSS}-slider"><${t.P}-text text="{{ :host._format(:host.min) }}" min></${t.P}-text>\n <div class="slider-track"><div class="slider-progress"></div></div>\n <${t.P}-panel class="${t.PCSS}-clickable slider-thumb" behaviors="{{ [::_dragger] }}">\n <div class="thumb-label"></div>\n </${t.P}-panel>\n <${t.P}-text text="{{ :host._format(:host.max) }}" max></${t.P}-text>\n <div class="slider-footer"><${t.P}-text text="{{ :host.viewValue }}"></${t.P}-text></div>\n </div>\n<${t.P}-drag-drop lock-timeout="0"></${t.P}-drag-drop><${t.P}-resize watch-position="true" on-${t.Components.ResizeEventName}=":host._setTrackSize($event)" target="{{ ::_track }}"></${t.P}-resize>\n<${t.P}-shell-proxy><${t.P}-balloon class="text-center"><${t.P}-text text="{{ :host.viewValue }}"></${t.P}-text></${t.P}-balloon></${t.P}-shell-proxy>\n`,shadow:t.Defaults.USE_SHADOW_ROOT})],jt);var Mt=function(e,t,i,a){var s,r=arguments.length,n=r<3?t:null===a?a=Object.getOwnPropertyDescriptor(t,i):a;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(e,t,i,a);else for(var o=e.length-1;o>=0;o--)(s=e[o])&&(n=(r<3?s(n):r>3?s(t,i,n):s(t,i))||n);return r>3&&n&&Object.defineProperty(t,i,n),n};class SuggestionSelectEvent extends t.CustomTypedEvent{constructor(e){super("suggestionselect",{selectedValue:e})}}let zt=class PacemSuggestElement extends PacemDataSourceElement{constructor(){super(...arguments),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 SuggestionSelectEvent(null))},this._balloonPopupHandler=e=>{t.Utils.addClass(this._btnArrow,"rotate-180")},this._balloonPopoutHandler=e=>{t.Utils.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 SuggestionSelectEvent(null))}},this._keyupHandler=e=>{this.#C&&(t.avoidHandler(e),this.#C=!1)},this._focusHandler=e=>{if(this.preventFocus){e.preventDefault();this._balloon.visible?this.popout():this.popup()}const t=this._input.value;this.viewValue!=t&&this._databind()},this._blurHandler=e=>{this._undo()},this.#C=!1,this._keydownHandler=e=>{var i=!1;if(t.Utils.isNull(this.#P)){const a=this._findFirstAvailableListItem();if(!t.Utils.isNull(a))switch(e.keyCode){case 40:t.avoidHandler(e),this._focus(a);break;case 13:t.avoidHandler(e),i=!0,1===this.#E.length?this._select(a):this._focus(a)}}else{var a,s=this.#P,r=s;const n=e=>!t.Utils.isNull(e)&&"li"===e.localName&&"true"===e.dataset.pacemDisabled,o=e=>!t.Utils.isNull(e)&&"li"===e.localName&&"true"!==e.dataset.pacemDisabled;switch(e.keyCode){case 38:t.avoidHandler(e);do{if(o(r=r.previousElementSibling)){a=r;break}}while(n(r));a??=s;break;case 40:t.avoidHandler(e);do{if(o(r=r.nextElementSibling)){a=r;break}}while(n(r));a??=s;break;case 27:t.avoidHandler(e),this._undo(),this.popout();break;case 9:case 13:t.avoidHandler(e),i=!0,this._select()}this._focus(a),this.#C=i}},this._selectHandler=e=>{t.avoidHandler(e),this._select(e.currentTarget)}}get inputFields(){return[this._input]}acceptValue(e){/*!this._isTyping && */!this.allowNew&&t.Utils.isNullOrEmpty(this.datasource)||(this._input.value=this.getViewValue(e)||(this._isTyping?this._input.value:""))}getViewValue(e){var i=super.getViewValue(e);return t.Utils.isNullOrEmpty(i)&&this.allowNew&&!t.Utils.isNullOrEmpty(e)&&(i=this.mapEntityToViewValue(e)),i}onChange(e){return new Promise((t,i)=>{if("suggestionselect"===e.type){const 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);t.CustomElementUtils.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,i,a,s){if(super.propertyChangedCallback(e,i,a,s),t.Utils.isNull(this._balloon))return;const r=this._isTyping;switch(e){case"adaptedDatasource":t.Utils.isNullOrEmpty(a)?this.popout():r?this.popup():this._input.value=this.getViewValue(this.value);break;case"hint":r||a===this._input.value||(this._input.value=a,this.#P=null);break;case"readonly":this._setDropdownMode();case"disabled":case"value":this._checkBalloon();break;case"itemtemplate":s||this._setupItemTemplate();break;case"allowTyping":s||this._setDropdownMode()}["adaptedDatasource","hint","value"].indexOf(e)>=0&&this._databind(),["allowTyping","value","hint"].indexOf(e)>=0&&this._syncButtons()}disconnectedCallback(){t.Utils.isNull(this._balloon)||(this._balloon.removeEventListener("popup",this._balloonPopupHandler,!1),this._balloon.removeEventListener("popout",this._balloonPopoutHandler,!1),this._balloon.remove()),t.Utils.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)),t.Utils.isNull(this._btnClear)||this._btnClear.removeEventListener("mousedown",this._clearBtnHandler,!1),t.Utils.isNull(this._btnArrow)||this._btnArrow.addEventListener("mousedown",this._toggleBtnHandler,!1),super.disconnectedCallback()}#E;_databind(){if(!t.Utils.isNull(this._repeater)){const e=this.#E=this._filter(this.adaptedDatasource,this._input.value);this._repeater.datasource=e}}_syncButtons(){t.Utils.isNull(this._btnArrow)||(this._btnArrow.hide=!1!==this.allowTyping||!t.Utils.isNullOrEmpty(this._input.value||this.value)),t.Utils.isNull(this._btnClear)||(this._btnClear.hide=this.readonly||t.Utils.isNullOrEmpty(this._input.value||this.value))}get _isTyping(){return t.Utils.is(this._input,":focus")}_undo(){this._focus(null),this.hint=this._input.value=this.getViewValue(this.value)||""}_findFirstAvailableListItem(){var e;if(!0===this._balloon.visible&&!t.Utils.isNull(e=this._repeater.querySelector("ol > li")))for(;!t.Utils.isNull(e)&&"true"===e.dataset.pacemDisabled&&"li"===e.localName;)e=e.nextElementSibling;return e}#C;_setDropdownMode(e=this.allowTyping){this._input.readOnly=!(e??!0)}_setupItemTemplate(){if(this.itemtemplate instanceof HTMLTemplateElement){const e=this.itemtemplate.cloneNode(!0).content,t=document.createElement("template"),i=document.createElement("li");i.append(e),t.content.appendChild(i),this._tmplProxy.target=t}else this._tmplProxy.target=this._defaultTemplate}#P;_focus(e){if(this.preventFocus)return;if(t.Utils.isNull(e))return void(this.#P=null);const i=e.parentElement.children;for(let t=0;t<i.length;t++){const a=i.item(t);if(a===e){a.dataset.pacemFocused="true",this.#P=a;const e=this._input,t=e.value=JSON.parse(a.dataset.pacemViewValue);e.setSelectionRange(t.length,t.length)}else delete a.dataset.pacemFocused}}_select(e=this.#P){const t=JSON.parse(e.dataset.pacemValue);"true"===e.dataset.pacemDisabled||this.changeHandler(new SuggestionSelectEvent(t))}_filter(e,i,a=this.value){let s=e||[];if(!t.Utils.isNullOrEmpty(i&&i.trim())){const e=i.toLowerCase().split(" ");let a=s.filter(i=>{for(let a of e){if(i.viewValue?.toLowerCase().indexOf(a)>=0)return!0;const e=this.filterFields;if(!t.Utils.isNullOrEmpty(e)){const s=i.data;if("object"==typeof s&&!t.Utils.isNullOrEmpty(s))for(let i of e){const e=i.split(".");let r=0,n=s;for(;!t.Utils.isNull(n)&&r<e.length;)n=n[e[r]],r++;if(!t.Utils.isNullOrEmpty(n)&&n.toString().toLowerCase().indexOf(a)>=0)return!0}}}return!1});s=this.allowNew&&t.Utils.isNullOrEmpty(this.valueProperty)&&t.Utils.isNullOrEmpty(this.textProperty)&&(t.Utils.isNullOrEmpty(a)||t.Utils.isNull(a.find(e=>e.viewValue===i)))?[{value:i,viewValue:i,data:i}].concat(a):a}let r=s;return!1!==this.allowTyping&&(r=s.slice(0,this.maxSuggestions||10)),this._isTyping&&this.popup(),this._balloon.style.opacity=t.Utils.isNullOrEmpty(r)?"0":"",this.log(t.Logging.LogLevel.Log,`${r.length} dropdown suggestion(s), given hint '${i}' and ${(e||[]).length} datasource items`),r}_itemCreate(e){const t=e.detail.dom.find(e=>e instanceof HTMLLIElement),i=e.detail.item;e.detail.index;const a=!0===i.disabled;t.tabIndex=a?-1:0,t.dataset.pacemValue=JSON.stringify(i.value),t.dataset.pacemViewValue=JSON.stringify(i.viewValue),t.dataset.pacemDisabled=a.toString(),t.addEventListener("mousedown",this._selectHandler,!1)}_itemRemove(e){e.detail.dom.find(e=>e 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=100){!t.Utils.isNullOrEmpty(this.adaptedDatasource)&&t.Utils.isVisible(this)&&this._balloon?.popup(e)}popout(e=0){this.#P=null,this._balloon?.popout(e)}_checkBalloon(e=this._balloon){if(!t.Utils.isNull(e)){const i=!t.Utils.isNullOrEmpty(this.value)&&!t.Utils.isNullOrEmpty(this._input.value);e.disabled=i||this.readonly||this.disabled||!1}}_createBalloon(){const e=document.createElement(t.P+"-balloon");return t.Utils.addClass(e,"suggest dropdown"),e.options={trackPosition:!0,trigger:i.Components.UI.BalloonTrigger.Focus,position:i.Components.UI.BalloonPosition.VerticalAuto,size:i.Components.UI.BalloonSizing.Match,align:i.Components.UI.BalloonAlignment.Start,behavior:i.Components.UI.BalloonBehavior.Menu,hoverDelay:100,hoverTimeout:0},e.addEventListener("popup",this._balloonPopupHandler,!1),e.addEventListener("popout",this._balloonPopoutHandler,!1),e.target=this._input,e}};Mt([t.ViewChild("input[type=text]")],zt.prototype,"_input",void 0),Mt([t.ViewChild(t.P+"-repeater")],zt.prototype,"_repeater",void 0),Mt([t.ViewChild(`span.${t.PCSS}-readonly`)],zt.prototype,"span",void 0),Mt([t.ViewChild("template")],zt.prototype,"_defaultTemplate",void 0),Mt([t.ViewChild(t.P+"-template-proxy")],zt.prototype,"_tmplProxy",void 0),Mt([t.ViewChild(`${t.P}-button[toggle]`)],zt.prototype,"_btnArrow",void 0),Mt([t.ViewChild(`${t.P}-button[clear]`)],zt.prototype,"_btnClear",void 0),Mt([t.Watch({converter:t.PropertyConverters.String})],zt.prototype,"hint",void 0),Mt([t.Watch({emit:!1,converter:t.PropertyConverters.Number})],zt.prototype,"maxSuggestions",void 0),Mt([t.Watch({converter:t.PropertyConverters.Boolean})],zt.prototype,"allowTyping",void 0),Mt([t.Watch({emit:!1,converter:t.PropertyConverters.Boolean})],zt.prototype,"preventFocus",void 0),Mt([t.Watch({emit:!1,converter:t.PropertyConverters.Element})],zt.prototype,"itemtemplate",void 0),Mt([t.Watch({emit:!1,converter:t.PropertyConverters.StringArray})],zt.prototype,"filterFields",void 0),Mt([t.Watch({emit:!1,converter:t.PropertyConverters.Boolean})],zt.prototype,"allowNew",void 0),zt=Mt([t.CustomElement({tagName:t.P+"-suggest",shadow:t.Defaults.USE_SHADOW_ROOT,template:`<div class="${t.PCSS}-relative"><input type="text" class="${t.PCSS}-input" />\n<${t.P}-button clear tab-order="-1"\nclass="button-flat ${t.PCSS}-anim anim-pop anim-sudden anim-quick pos-absolute absolute-right absolute-top display-block ${t.PCSS}-margin margin-0" \n icon-glyph="highlight_off"></${t.P}-button>\n<${t.P}-button \nclass="button-flat icon-rotate ${t.PCSS}-anim anim-pop anim-sudden anim-quick pos-absolute absolute-right absolute-top display-block ${t.PCSS}-margin margin-0" \n icon-glyph="arrow_drop_down" tab-order="-1" toggle></${t.P}-button>\n</div>\n<span class="${t.PCSS}-readonly"><${t.P}-text text="{{ :host.viewValue }}"></${t.P}-text></span>\n<${t.P}-repeater on-${t.Components.RepeaterItemCreateEventName}=":host._itemCreate($event)" on-${t.Components.RepeaterItemRemoveEventName}=":host._itemRemove($event)">\n <ol>\n <${t.P}-template-proxy></${t.P}-template-proxy>\n </ol>\n</${t.P}-repeater><${t.P}-content></${t.P}-content>\n<template>\n <li><${t.P}-span content="{{ $pacem.highlight(^item.viewValue, :host.hint) }}"></${t.P}-span></li>\n</template>`})],zt);var qt=function(e,t,i,a){var s,r=arguments.length,n=r<3?t:null===a?a=Object.getOwnPropertyDescriptor(t,i):a;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(e,t,i,a);else for(var o=e.length-1;o>=0;o--)(s=e[o])&&(n=(r<3?s(n):r>3?s(t,i,n):s(t,i))||n);return r>3&&n&&Object.defineProperty(t,i,n),n};class TagRemoveEvent extends t.CustomTypedEvent{constructor(e){super("tagremove",{index:e})}}class TagAddEvent extends t.CustomTypedEvent{constructor(e){super("tagadd",{value:e})}}let Jt=class PacemTagElement extends t.Components.PacemElement{propertyChangedCallback(e,i,a,s){switch(super.propertyChangedCallback(e,i,a,s),e){case"readonly":let e=!!a;(e?t.Utils.addClass:t.Utils.removeClass)(this,"tag-readonly"),this._btn.disabled=this._btn.hide=e;break;case"tag":t.Utils.removeClass(this,"tag-out")}}_remove(){t.Utils.addClass(this,"tag-out"),t.Utils.addAnimationEndCallback(this,()=>{this.dispatchEvent(new Event("remove"))})}};qt([t.Watch({converter:t.PropertyConverters.String})],Jt.prototype,"tag",void 0),qt([t.Watch({emit:!1,converter:t.PropertyConverters.Boolean})],Jt.prototype,"readonly",void 0),qt([t.ViewChild(t.P+"-button")],Jt.prototype,"_btn",void 0),Jt=qt([t.CustomElement({tagName:t.P+"-tag",shadow:t.Defaults.USE_SHADOW_ROOT,template:`<${t.P}-text text="{{ :host.tag }}"></${t.P}-text>\n <${t.P}-button on-click=":host._remove()"></${t.P}-button>`})],Jt);let Yt=class PacemTagsElement extends PacemDataSourceElement{constructor(){super(!0),this.inputFields=[]}toggleReadonlyView(e){this._suggest.readonly=e,this.querySelector(".tag-new").hidden=e}_tagRemove(e){this.changeHandler(new TagRemoveEvent(e))}_tagAdd(e){this.changeHandler(new TagAddEvent(e))}handleDatasourceMismatch(){}propertyChangedCallback(e,i,a,s){switch(super.propertyChangedCallback(e,i,a,s),e){case"datasource":case"textProperty":this._suggest[e]=a;break;case"valueProperty":if(!t.Utils.isNullOrEmpty(a))throw`Cannot set 'valueProperty' on ${this.constructor.name}s.`;break;case"value":this._tags.datasource=a}}onChange(e){return new Promise((i,a)=>{switch(e.type){case"tagremove":this._justAddedIndex=-1;const a=e.detail.index,s=t.Utils.clone(this.value),r=s.splice(a+1),n=s.splice(0,a);i(this.value=n.concat(r));break;case"tagadd":const o=e.detail.value,l=t.Utils.clone(this.value);if(!t.Utils.isNullOrEmpty(o)&&(this.allowDuplicates||t.Utils.isNullOrEmpty(l&&l.find(e=>this.mapEntityToViewValue(e)==this.mapEntityToViewValue(o))))){let e=(l||[]).concat([o]);i(this.value=e),this._justAddedIndex=this.value.length-1,setTimeout(()=>{this._suggest.focus()},250),this._suggest.blur(),this._suggest.hint="",this._suggest.reset()}break;default:i(this.value)}})}acceptValue(e){}};qt([t.Watch({converter:t.PropertyConverters.String})],Yt.prototype,"hint",void 0),qt([t.Watch({emit:!1,converter:t.PropertyConverters.Boolean})],Yt.prototype,"allowDuplicates",void 0),qt([t.Watch({converter:t.PropertyConverters.Boolean})],Yt.prototype,"allowNew",void 0),qt([t.Watch({converter:t.PropertyConverters.Number})],Yt.prototype,"_justAddedIndex",void 0),qt([t.ViewChild(t.P+"-suggest")],Yt.prototype,"_suggest",void 0),qt([t.ViewChild(t.P+"-repeater."+t.PCSS+"-tags")],Yt.prototype,"_tags",void 0),Yt=qt([t.CustomElement({tagName:t.P+"-tags",shadow:t.Defaults.USE_SHADOW_ROOT,template:`<${t.P}-repeater class="${t.PCSS}-tags">\n <ul class="${t.PCSS}-tags ${t.PCSS}-viewfinder ${t.PCSS}-list list-unstyled list-inline">\n <template>\n <li class="${t.PCSS}-tag">\n <${t.P}-tag on-remove=":host._tagRemove(^index)" css-class="{{ { 'tag-in': :host._justAddedIndex === ^index } }}" tag="{{ :host.mapEntityToViewValue(^item) }}" readonly="{{ :host.readonly }}"></${t.P}-tag>\n </li>\n </template>\n <li class="tag-new">\n <${t.P}-suggest logger="{{ :host.logger }}" placeholder="{{ :host.placeholder }}" allow-new="{{ :host.allowNew }}" class="${t.PCSS}-tags" on-change=":host._tagAdd($this.value)" hint="{{ :host.hint, twoway }}">\n <${t.P}-content></${t.P}-content>\n </${t.P}-suggest>\n </li>\n </ul>\n</${t.P}-repeater>`})],Yt);var Gt=function(e,t,i,a){var s,r=arguments.length,n=r<3?t:null===a?a=Object.getOwnPropertyDescriptor(t,i):a;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(e,t,i,a);else for(var o=e.length-1;o>=0;o--)(s=e[o])&&(n=(r<3?s(n):r>3?s(t,i,n):s(t,i))||n);return r>3&&n&&Object.defineProperty(t,i,n),n};let Kt=class PacemTextAreaElement extends PacemTextualInputElement{constructor(){super(...arguments),this.rows=5,this.cols=50}get preventKeyboardSubmit(){return!0}toggleReadonlyView(e){const i=this._input,a=this._span;t.Utils.isNull(i)||(i.hidden=e),t.Utils.isNull(a)||(a.hidden=!e)}get inputFields(){return t.Utils.isNull(this._input)?[]:[this._input]}propertyChangedCallback(e,t,i,a){super.propertyChangedCallback(e,t,i,a),"rows"!==e&&"cols"!==e||this.inputField.setAttribute(e,i)}};Gt([t.Watch({emit:!1,converter:t.PropertyConverters.Number})],Kt.prototype,"rows",void 0),Gt([t.Watch({emit:!1,converter:t.PropertyConverters.Number})],Kt.prototype,"cols",void 0),Gt([t.ViewChild("textarea")],Kt.prototype,"_input",void 0),Gt([t.ViewChild(`span.${t.PCSS}-readonly`)],Kt.prototype,"_span",void 0),Kt=Gt([t.CustomElement({tagName:t.P+"-textarea",template:`<textarea class="${t.PCSS}-input" pacem></textarea>${E}<span class="${t.PCSS}-readonly"><${t.P}-text text="{{ :host.viewValue }}"></${t.P}-text></span>`,shadow:t.Defaults.USE_SHADOW_ROOT})],Kt);var Xt=function(e,t,i,a){var s,r=arguments.length,n=r<3?t:null===a?a=Object.getOwnPropertyDescriptor(t,i):a;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(e,t,i,a);else for(var o=e.length-1;o>=0;o--)(s=e[o])&&(n=(r<3?s(n):r>3?s(t,i,n):s(t,i))||n);return r>3&&n&&Object.defineProperty(t,i,n),n};let Zt=class PacemMarkdownTextAreaElement extends PacemTextualInputElement{constructor(e=new i.Components.UI.MarkdownService){super(),this._md=e,this.rows=5,this.cols=50,this._keydownHandler=e=>{if(9===e.keyCode){const a=this._input,s=a.value;var i=a.selectionStart;a.value=s.substr(0,i)+" "+s.substr(i),t.preventDefaultHandler(e)}}}toggleReadonlyView(e){t.Utils.isNull(this._input)||(this._input.hidden=e)}get preventKeyboardSubmit(){return!0}get inputFields(){return t.Utils.isNull(this._input)?[]:[this._input]}getViewValue(e){return this._md.toHtml(e)}propertyChangedCallback(e,t,i,a){super.propertyChangedCallback(e,t,i,a),"rows"===e||"cols"===e?this.inputField.setAttribute(e,i):"viewValue"==e&&(this._markdown.innerHTML=i)}viewActivatedCallback(){super.viewActivatedCallback(),this._input.addEventListener("keydown",this._keydownHandler,!1)}disconnectedCallback(){this._input&&this._input.removeEventListener("keydown",this._keydownHandler,!1),super.disconnectedCallback()}};Xt([t.Watch({emit:!1,converter:t.PropertyConverters.Number})],Zt.prototype,"rows",void 0),Xt([t.Watch({emit:!1,converter:t.PropertyConverters.Number})],Zt.prototype,"cols",void 0),Xt([t.ViewChild("textarea")],Zt.prototype,"_input",void 0),Xt([t.ViewChild(`div.${t.PCSS}-readonly`)],Zt.prototype,"_markdown",void 0),Zt=Xt([t.CustomElement({tagName:t.P+"-textarea-markdown",template:`<textarea class="${t.PCSS}-input" pacem></textarea>${E}<div class="${t.PCSS}-readonly ${t.PCSS}-markdown"></div>`,shadow:t.Defaults.USE_SHADOW_ROOT})],Zt);var Qt=Object.freeze({__proto__:null,BASIC_VALIDATOR_TEMPLATE:fe,CHAR_COUNTER_CHILD:E,CONTENTELEMENT_BUTTONCOMMAND_TEMPLATE:V,CalendarDateUnselectEvent:CalendarDateUnselectEvent,get ChangePolicy(){return qe},ContenteditableDOMObserver:ContenteditableDOMObserver,ContenteditableUtils:ContenteditableUtils,DEFAULT_ATTRIBUTION:"",DEFAULT_TILES:"",FileChangeEvent:FileChangeEvent,FileChangeEventName:at,FileUploadEvent:FileUploadEvent,FileUploadEventName:it,FormEventEmitter:FormEventEmitter,FormResetEvent:FormResetEvent,FormResetEventName:v,FormSubmitEvent:FormSubmitEvent,FormSubmitEventName:m,ImageFetchRequestEvent:ImageFetchRequestEvent,ImageFetchRequestEventName:ut,get KnownExecCommand(){return F},get PacemAsyncValidatorElement(){return ke},PacemBaseElement:PacemBaseElement,PacemBaseInputElement:PacemBaseInputElement,PacemBaseValidatorElement:PacemBaseValidatorElement,get PacemBinaryValidatorElement(){return Se},get PacemCalendarMonthPickerElement(){return ie},get PacemCalendarPickerElement(){return re},get PacemCalendarYearPickerElement(){return se},get PacemCharCountElement(){return w},get PacemCharsInputElement(){return Ke},get PacemCheckboxElement(){return le},get PacemCheckboxListElement(){return de},get PacemChildFormElement(){return ue},get PacemChildFormPropagatorElement(){return pe},get PacemColorInputElement(){return Ze},get PacemCompareValidatorElement(){return we},get PacemContenteditableAlignCommandElement(){return Y},PacemContenteditableButtonCommandElement:PacemContenteditableButtonCommandElement,PacemContenteditableCommandElement:PacemContenteditableCommandElement,get PacemContenteditableElement(){return O},get PacemContenteditableExecCommandElement(){return M},get PacemContenteditableHistoryCommandElement(){return H},get PacemContenteditableImageCommandElement(){return I},get PacemContenteditableLinkCommandElement(){return T},get PacemContenteditablePlaceholderElement(){return X},get PacemContenteditableWrapCommandElement(){return Q},get PacemCustomValidatorElement(){return $e},get PacemDataItemElement(){return C},PacemDataSourceElement:PacemDataSourceElement,get PacemDatetimePickerElement(){return ge},get PacemEditImageElement(){return mt},get PacemEmailInputElement(){return et},get PacemFormElement(){return f},get PacemFormFieldElement(){return Oe},PacemFormRelevantElement:PacemFormRelevantElement,get PacemGeolocateElement(){return Ve},get PacemHiddenInputElement(){return ot},get PacemHierarchyElement(){return ze},get PacemImageInputElement(){return vt},PacemItemElement:PacemItemElement,PacemItemsContainerBaseElement:PacemItemsContainerBaseElement,get PacemLatLngElement(){return Nt},get PacemLengthValidatorElement(){return Pe},get PacemMarkdownTextAreaElement(){return Zt},PacemModelElement:PacemModelElement,get PacemNameValueListElement(){return Dt},get PacemNumberInputElement(){return yt},PacemOrdinalInputElement:PacemOrdinalInputElement,get PacemPasswordInputElement(){return _t},get PacemPropertyPickerElement(){return At},get PacemRadioElement(){return Rt},get PacemRadioListElement(){return It},get PacemRangeValidatorElement(){return Ee},get PacemRegexValidatorElement(){return Ce},get PacemRequiredValidatorElement(){return be},get PacemSearchInputElement(){return Ct},get PacemSelectElement(){return Wt},get PacemSliderElement(){return jt},get PacemSnapshotElement(){return ht},get PacemSuggestElement(){return zt},get PacemTagElement(){return Jt},get PacemTagsElement(){return Yt},get PacemTelInputElement(){return Et},get PacemTextAreaElement(){return Kt},get PacemTextInputElement(){return St},PacemTextualInputElement:PacemTextualInputElement,get PacemUploadElement(){return rt},get PacemUrlInputElement(){return $t},Picture:class Picture{},get SnapshotStep(){return dt}}),ei=Object.freeze({__proto__:null,Scaffolding:Qt}),ti=Object.freeze({__proto__:null,Components:ei,Scaffolding:p});e.DeepMerger.merge(ti)}(Pacem,Pacem,Pacem,Pacem);