UNPKG

friday-widgets

Version:

Professional embeddable accounting widgets for vertical SaaS platforms. Layer Financial-inspired design with comprehensive financial reporting capabilities.

556 lines (506 loc) 75.5 kB
var FridayJournalWidget=function(e){"use strict";function t(e,t,r,a){var i,s=arguments.length,o=s<3?t:null===a?a=Object.getOwnPropertyDescriptor(t,r):a;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(e,t,r,a);else for(var n=e.length-1;n>=0;n--)(i=e[n])&&(o=(s<3?i(o):s>3?i(t,r,o):i(t,r))||o);return s>3&&o&&Object.defineProperty(t,r,o),o}"function"==typeof SuppressedError&&SuppressedError; /** * @license * Copyright 2019 Google LLC * SPDX-License-Identifier: BSD-3-Clause */ const r=globalThis,a=r.ShadowRoot&&(void 0===r.ShadyCSS||r.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,i=Symbol(),s=new WeakMap;let o=class{constructor(e,t,r){if(this._$cssResult$=!0,r!==i)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=e,this.t=t}get styleSheet(){let e=this.o;const t=this.t;if(a&&void 0===e){const r=void 0!==t&&1===t.length;r&&(e=s.get(t)),void 0===e&&((this.o=e=new CSSStyleSheet).replaceSync(this.cssText),r&&s.set(t,e))}return e}toString(){return this.cssText}};const n=(e,...t)=>{const r=1===e.length?e[0]:t.reduce((t,r,a)=>t+(e=>{if(!0===e._$cssResult$)return e.cssText;if("number"==typeof e)return e;throw Error("Value passed to 'css' function must be a 'css' function result: "+e+". Use 'unsafeCSS' to pass non-literal values, but take care to ensure page security.")})(r)+e[a+1],e[0]);return new o(r,e,i)},d=a?e=>e:e=>e instanceof CSSStyleSheet?(e=>{let t="";for(const r of e.cssRules)t+=r.cssText;return(e=>new o("string"==typeof e?e:e+"",void 0,i))(t)})(e):e,{is:l,defineProperty:c,getOwnPropertyDescriptor:y,getOwnPropertyNames:h,getOwnPropertySymbols:u,getPrototypeOf:p}=Object,_=globalThis,g=_.trustedTypes,m=g?g.emptyScript:"",b=_.reactiveElementPolyfillSupport,v=(e,t)=>e,f={toAttribute(e,t){switch(t){case Boolean:e=e?m:null;break;case Object:case Array:e=null==e?e:JSON.stringify(e)}return e},fromAttribute(e,t){let r=e;switch(t){case Boolean:r=null!==e;break;case Number:r=null===e?null:Number(e);break;case Object:case Array:try{r=JSON.parse(e)}catch(e){r=null}}return r}},x=(e,t)=>!l(e,t),$={attribute:!0,type:String,converter:f,reflect:!1,useDefault:!1,hasChanged:x}; /** * @license * Copyright 2017 Google LLC * SPDX-License-Identifier: BSD-3-Clause */Symbol.metadata??=Symbol("metadata"),_.litPropertyMetadata??=new WeakMap;let F=class extends HTMLElement{static addInitializer(e){this._$Ei(),(this.l??=[]).push(e)}static get observedAttributes(){return this.finalize(),this._$Eh&&[...this._$Eh.keys()]}static createProperty(e,t=$){if(t.state&&(t.attribute=!1),this._$Ei(),this.prototype.hasOwnProperty(e)&&((t=Object.create(t)).wrapped=!0),this.elementProperties.set(e,t),!t.noAccessor){const r=Symbol(),a=this.getPropertyDescriptor(e,r,t);void 0!==a&&c(this.prototype,e,a)}}static getPropertyDescriptor(e,t,r){const{get:a,set:i}=y(this.prototype,e)??{get(){return this[t]},set(e){this[t]=e}};return{get:a,set(t){const s=a?.call(this);i?.call(this,t),this.requestUpdate(e,s,r)},configurable:!0,enumerable:!0}}static getPropertyOptions(e){return this.elementProperties.get(e)??$}static _$Ei(){if(this.hasOwnProperty(v("elementProperties")))return;const e=p(this);e.finalize(),void 0!==e.l&&(this.l=[...e.l]),this.elementProperties=new Map(e.elementProperties)}static finalize(){if(this.hasOwnProperty(v("finalized")))return;if(this.finalized=!0,this._$Ei(),this.hasOwnProperty(v("properties"))){const e=this.properties,t=[...h(e),...u(e)];for(const r of t)this.createProperty(r,e[r])}const e=this[Symbol.metadata];if(null!==e){const t=litPropertyMetadata.get(e);if(void 0!==t)for(const[e,r]of t)this.elementProperties.set(e,r)}this._$Eh=new Map;for(const[e,t]of this.elementProperties){const r=this._$Eu(e,t);void 0!==r&&this._$Eh.set(r,e)}this.elementStyles=this.finalizeStyles(this.styles)}static finalizeStyles(e){const t=[];if(Array.isArray(e)){const r=new Set(e.flat(1/0).reverse());for(const e of r)t.unshift(d(e))}else void 0!==e&&t.push(d(e));return t}static _$Eu(e,t){const r=t.attribute;return!1===r?void 0:"string"==typeof r?r:"string"==typeof e?e.toLowerCase():void 0}constructor(){super(),this._$Ep=void 0,this.isUpdatePending=!1,this.hasUpdated=!1,this._$Em=null,this._$Ev()}_$Ev(){this._$ES=new Promise(e=>this.enableUpdating=e),this._$AL=new Map,this._$E_(),this.requestUpdate(),this.constructor.l?.forEach(e=>e(this))}addController(e){(this._$EO??=new Set).add(e),void 0!==this.renderRoot&&this.isConnected&&e.hostConnected?.()}removeController(e){this._$EO?.delete(e)}_$E_(){const e=new Map,t=this.constructor.elementProperties;for(const r of t.keys())this.hasOwnProperty(r)&&(e.set(r,this[r]),delete this[r]);e.size>0&&(this._$Ep=e)}createRenderRoot(){const e=this.shadowRoot??this.attachShadow(this.constructor.shadowRootOptions);return((e,t)=>{if(a)e.adoptedStyleSheets=t.map(e=>e instanceof CSSStyleSheet?e:e.styleSheet);else for(const a of t){const t=document.createElement("style"),i=r.litNonce;void 0!==i&&t.setAttribute("nonce",i),t.textContent=a.cssText,e.appendChild(t)}})(e,this.constructor.elementStyles),e}connectedCallback(){this.renderRoot??=this.createRenderRoot(),this.enableUpdating(!0),this._$EO?.forEach(e=>e.hostConnected?.())}enableUpdating(e){}disconnectedCallback(){this._$EO?.forEach(e=>e.hostDisconnected?.())}attributeChangedCallback(e,t,r){this._$AK(e,r)}_$ET(e,t){const r=this.constructor.elementProperties.get(e),a=this.constructor._$Eu(e,r);if(void 0!==a&&!0===r.reflect){const i=(void 0!==r.converter?.toAttribute?r.converter:f).toAttribute(t,r.type);this._$Em=e,null==i?this.removeAttribute(a):this.setAttribute(a,i),this._$Em=null}}_$AK(e,t){const r=this.constructor,a=r._$Eh.get(e);if(void 0!==a&&this._$Em!==a){const e=r.getPropertyOptions(a),i="function"==typeof e.converter?{fromAttribute:e.converter}:void 0!==e.converter?.fromAttribute?e.converter:f;this._$Em=a;const s=i.fromAttribute(t,e.type);this[a]=s??this._$Ej?.get(a)??s,this._$Em=null}}requestUpdate(e,t,r){if(void 0!==e){const a=this.constructor,i=this[e];if(r??=a.getPropertyOptions(e),!((r.hasChanged??x)(i,t)||r.useDefault&&r.reflect&&i===this._$Ej?.get(e)&&!this.hasAttribute(a._$Eu(e,r))))return;this.C(e,t,r)}!1===this.isUpdatePending&&(this._$ES=this._$EP())}C(e,t,{useDefault:r,reflect:a,wrapped:i},s){r&&!(this._$Ej??=new Map).has(e)&&(this._$Ej.set(e,s??t??this[e]),!0!==i||void 0!==s)||(this._$AL.has(e)||(this.hasUpdated||r||(t=void 0),this._$AL.set(e,t)),!0===a&&this._$Em!==e&&(this._$Eq??=new Set).add(e))}async _$EP(){this.isUpdatePending=!0;try{await this._$ES}catch(e){Promise.reject(e)}const e=this.scheduleUpdate();return null!=e&&await e,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){if(!this.isUpdatePending)return;if(!this.hasUpdated){if(this.renderRoot??=this.createRenderRoot(),this._$Ep){for(const[e,t]of this._$Ep)this[e]=t;this._$Ep=void 0}const e=this.constructor.elementProperties;if(e.size>0)for(const[t,r]of e){const{wrapped:e}=r,a=this[t];!0!==e||this._$AL.has(t)||void 0===a||this.C(t,void 0,r,a)}}let e=!1;const t=this._$AL;try{e=this.shouldUpdate(t),e?(this.willUpdate(t),this._$EO?.forEach(e=>e.hostUpdate?.()),this.update(t)):this._$EM()}catch(t){throw e=!1,this._$EM(),t}e&&this._$AE(t)}willUpdate(e){}_$AE(e){this._$EO?.forEach(e=>e.hostUpdated?.()),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(e)),this.updated(e)}_$EM(){this._$AL=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$ES}shouldUpdate(e){return!0}update(e){this._$Eq&&=this._$Eq.forEach(e=>this._$ET(e,this[e])),this._$EM()}updated(e){}firstUpdated(e){}};F.elementStyles=[],F.shadowRootOptions={mode:"open"},F[v("elementProperties")]=new Map,F[v("finalized")]=new Map,b?.({ReactiveElement:F}),(_.reactiveElementVersions??=[]).push("2.1.1"); /** * @license * Copyright 2017 Google LLC * SPDX-License-Identifier: BSD-3-Clause */ const w=globalThis,E=w.trustedTypes,S=E?E.createPolicy("lit-html",{createHTML:e=>e}):void 0,A="$lit$",k=`lit$${Math.random().toFixed(9).slice(2)}$`,C="?"+k,P=`<${C}>`,O=document,D=()=>O.createComment(""),U=e=>null===e||"object"!=typeof e&&"function"!=typeof e,R=Array.isArray,T="[ \t\n\f\r]",q=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,I=/-->/g,M=/>/g,z=RegExp(`>|${T}(?:([^\\s"'>=/]+)(${T}*=${T}*(?:[^ \t\n\f\r"'\`<>=]|("|')|))|$)`,"g"),j=/'/g,L=/"/g,N=/^(?:script|style|textarea|title)$/i,B=(e=>(t,...r)=>({_$litType$:e,strings:t,values:r}))(1),H=Symbol.for("lit-noChange"),J=Symbol.for("lit-nothing"),W=new WeakMap,V=O.createTreeWalker(O,129);function K(e,t){if(!R(e)||!e.hasOwnProperty("raw"))throw Error("invalid template strings array");return void 0!==S?S.createHTML(t):t}const X=(e,t)=>{const r=e.length-1,a=[];let i,s=2===t?"<svg>":3===t?"<math>":"",o=q;for(let t=0;t<r;t++){const r=e[t];let n,d,l=-1,c=0;for(;c<r.length&&(o.lastIndex=c,d=o.exec(r),null!==d);)c=o.lastIndex,o===q?"!--"===d[1]?o=I:void 0!==d[1]?o=M:void 0!==d[2]?(N.test(d[2])&&(i=RegExp("</"+d[2],"g")),o=z):void 0!==d[3]&&(o=z):o===z?">"===d[0]?(o=i??q,l=-1):void 0===d[1]?l=-2:(l=o.lastIndex-d[2].length,n=d[1],o=void 0===d[3]?z:'"'===d[3]?L:j):o===L||o===j?o=z:o===I||o===M?o=q:(o=z,i=void 0);const y=o===z&&e[t+1].startsWith("/>")?" ":"";s+=o===q?r+P:l>=0?(a.push(n),r.slice(0,l)+A+r.slice(l)+k+y):r+k+(-2===l?t:y)}return[K(e,s+(e[r]||"<?>")+(2===t?"</svg>":3===t?"</math>":"")),a]};class G{constructor({strings:e,_$litType$:t},r){let a;this.parts=[];let i=0,s=0;const o=e.length-1,n=this.parts,[d,l]=X(e,t);if(this.el=G.createElement(d,r),V.currentNode=this.el.content,2===t||3===t){const e=this.el.content.firstChild;e.replaceWith(...e.childNodes)}for(;null!==(a=V.nextNode())&&n.length<o;){if(1===a.nodeType){if(a.hasAttributes())for(const e of a.getAttributeNames())if(e.endsWith(A)){const t=l[s++],r=a.getAttribute(e).split(k),o=/([.?@])?(.*)/.exec(t);n.push({type:1,index:i,name:o[2],strings:r,ctor:"."===o[1]?te:"?"===o[1]?re:"@"===o[1]?ae:ee}),a.removeAttribute(e)}else e.startsWith(k)&&(n.push({type:6,index:i}),a.removeAttribute(e));if(N.test(a.tagName)){const e=a.textContent.split(k),t=e.length-1;if(t>0){a.textContent=E?E.emptyScript:"";for(let r=0;r<t;r++)a.append(e[r],D()),V.nextNode(),n.push({type:2,index:++i});a.append(e[t],D())}}}else if(8===a.nodeType)if(a.data===C)n.push({type:2,index:i});else{let e=-1;for(;-1!==(e=a.data.indexOf(k,e+1));)n.push({type:7,index:i}),e+=k.length-1}i++}}static createElement(e,t){const r=O.createElement("template");return r.innerHTML=e,r}}function Y(e,t,r=e,a){if(t===H)return t;let i=void 0!==a?r._$Co?.[a]:r._$Cl;const s=U(t)?void 0:t._$litDirective$;return i?.constructor!==s&&(i?._$AO?.(!1),void 0===s?i=void 0:(i=new s(e),i._$AT(e,r,a)),void 0!==a?(r._$Co??=[])[a]=i:r._$Cl=i),void 0!==i&&(t=Y(e,i._$AS(e,t.values),i,a)),t}class Q{constructor(e,t){this._$AV=[],this._$AN=void 0,this._$AD=e,this._$AM=t}get parentNode(){return this._$AM.parentNode}get _$AU(){return this._$AM._$AU}u(e){const{el:{content:t},parts:r}=this._$AD,a=(e?.creationScope??O).importNode(t,!0);V.currentNode=a;let i=V.nextNode(),s=0,o=0,n=r[0];for(;void 0!==n;){if(s===n.index){let t;2===n.type?t=new Z(i,i.nextSibling,this,e):1===n.type?t=new n.ctor(i,n.name,n.strings,this,e):6===n.type&&(t=new ie(i,this,e)),this._$AV.push(t),n=r[++o]}s!==n?.index&&(i=V.nextNode(),s++)}return V.currentNode=O,a}p(e){let t=0;for(const r of this._$AV)void 0!==r&&(void 0!==r.strings?(r._$AI(e,r,t),t+=r.strings.length-2):r._$AI(e[t])),t++}}class Z{get _$AU(){return this._$AM?._$AU??this._$Cv}constructor(e,t,r,a){this.type=2,this._$AH=J,this._$AN=void 0,this._$AA=e,this._$AB=t,this._$AM=r,this.options=a,this._$Cv=a?.isConnected??!0}get parentNode(){let e=this._$AA.parentNode;const t=this._$AM;return void 0!==t&&11===e?.nodeType&&(e=t.parentNode),e}get startNode(){return this._$AA}get endNode(){return this._$AB}_$AI(e,t=this){e=Y(this,e,t),U(e)?e===J||null==e||""===e?(this._$AH!==J&&this._$AR(),this._$AH=J):e!==this._$AH&&e!==H&&this._(e):void 0!==e._$litType$?this.$(e):void 0!==e.nodeType?this.T(e):(e=>R(e)||"function"==typeof e?.[Symbol.iterator])(e)?this.k(e):this._(e)}O(e){return this._$AA.parentNode.insertBefore(e,this._$AB)}T(e){this._$AH!==e&&(this._$AR(),this._$AH=this.O(e))}_(e){this._$AH!==J&&U(this._$AH)?this._$AA.nextSibling.data=e:this.T(O.createTextNode(e)),this._$AH=e}$(e){const{values:t,_$litType$:r}=e,a="number"==typeof r?this._$AC(e):(void 0===r.el&&(r.el=G.createElement(K(r.h,r.h[0]),this.options)),r);if(this._$AH?._$AD===a)this._$AH.p(t);else{const e=new Q(a,this),r=e.u(this.options);e.p(t),this.T(r),this._$AH=e}}_$AC(e){let t=W.get(e.strings);return void 0===t&&W.set(e.strings,t=new G(e)),t}k(e){R(this._$AH)||(this._$AH=[],this._$AR());const t=this._$AH;let r,a=0;for(const i of e)a===t.length?t.push(r=new Z(this.O(D()),this.O(D()),this,this.options)):r=t[a],r._$AI(i),a++;a<t.length&&(this._$AR(r&&r._$AB.nextSibling,a),t.length=a)}_$AR(e=this._$AA.nextSibling,t){for(this._$AP?.(!1,!0,t);e!==this._$AB;){const t=e.nextSibling;e.remove(),e=t}}setConnected(e){void 0===this._$AM&&(this._$Cv=e,this._$AP?.(e))}}class ee{get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}constructor(e,t,r,a,i){this.type=1,this._$AH=J,this._$AN=void 0,this.element=e,this.name=t,this._$AM=a,this.options=i,r.length>2||""!==r[0]||""!==r[1]?(this._$AH=Array(r.length-1).fill(new String),this.strings=r):this._$AH=J}_$AI(e,t=this,r,a){const i=this.strings;let s=!1;if(void 0===i)e=Y(this,e,t,0),s=!U(e)||e!==this._$AH&&e!==H,s&&(this._$AH=e);else{const a=e;let o,n;for(e=i[0],o=0;o<i.length-1;o++)n=Y(this,a[r+o],t,o),n===H&&(n=this._$AH[o]),s||=!U(n)||n!==this._$AH[o],n===J?e=J:e!==J&&(e+=(n??"")+i[o+1]),this._$AH[o]=n}s&&!a&&this.j(e)}j(e){e===J?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,e??"")}}class te extends ee{constructor(){super(...arguments),this.type=3}j(e){this.element[this.name]=e===J?void 0:e}}class re extends ee{constructor(){super(...arguments),this.type=4}j(e){this.element.toggleAttribute(this.name,!!e&&e!==J)}}class ae extends ee{constructor(e,t,r,a,i){super(e,t,r,a,i),this.type=5}_$AI(e,t=this){if((e=Y(this,e,t,0)??J)===H)return;const r=this._$AH,a=e===J&&r!==J||e.capture!==r.capture||e.once!==r.once||e.passive!==r.passive,i=e!==J&&(r===J||a);a&&this.element.removeEventListener(this.name,this,r),i&&this.element.addEventListener(this.name,this,e),this._$AH=e}handleEvent(e){"function"==typeof this._$AH?this._$AH.call(this.options?.host??this.element,e):this._$AH.handleEvent(e)}}class ie{constructor(e,t,r){this.element=e,this.type=6,this._$AN=void 0,this._$AM=t,this.options=r}get _$AU(){return this._$AM._$AU}_$AI(e){Y(this,e)}}const se=w.litHtmlPolyfillSupport;se?.(G,Z),(w.litHtmlVersions??=[]).push("3.3.1");const oe=globalThis; /** * @license * Copyright 2017 Google LLC * SPDX-License-Identifier: BSD-3-Clause */class ne extends F{constructor(){super(...arguments),this.renderOptions={host:this},this._$Do=void 0}createRenderRoot(){const e=super.createRenderRoot();return this.renderOptions.renderBefore??=e.firstChild,e}update(e){const t=this.render();this.hasUpdated||(this.renderOptions.isConnected=this.isConnected),super.update(e),this._$Do=((e,t,r)=>{const a=r?.renderBefore??t;let i=a._$litPart$;if(void 0===i){const e=r?.renderBefore??null;a._$litPart$=i=new Z(t.insertBefore(D(),e),e,void 0,r??{})}return i._$AI(e),i})(t,this.renderRoot,this.renderOptions)}connectedCallback(){super.connectedCallback(),this._$Do?.setConnected(!0)}disconnectedCallback(){super.disconnectedCallback(),this._$Do?.setConnected(!1)}render(){return H}}ne._$litElement$=!0,ne.finalized=!0,oe.litElementHydrateSupport?.({LitElement:ne});const de=oe.litElementPolyfillSupport;de?.({LitElement:ne}),(oe.litElementVersions??=[]).push("4.2.1"); /** * @license * Copyright 2017 Google LLC * SPDX-License-Identifier: BSD-3-Clause */ const le={attribute:!0,type:String,converter:f,reflect:!1,hasChanged:x},ce=(e=le,t,r)=>{const{kind:a,metadata:i}=r;let s=globalThis.litPropertyMetadata.get(i);if(void 0===s&&globalThis.litPropertyMetadata.set(i,s=new Map),"setter"===a&&((e=Object.create(e)).wrapped=!0),s.set(r.name,e),"accessor"===a){const{name:a}=r;return{set(r){const i=t.get.call(this);t.set.call(this,r),this.requestUpdate(a,i,e)},init(t){return void 0!==t&&this.C(a,void 0,e,t),t}}}if("setter"===a){const{name:a}=r;return function(r){const i=this[a];t.call(this,r),this.requestUpdate(a,i,e)}}throw Error("Unsupported decorator location: "+a)}; /** * @license * Copyright 2017 Google LLC * SPDX-License-Identifier: BSD-3-Clause */function ye(e){return(t,r)=>"object"==typeof r?ce(e,t,r):((e,t,r)=>{const a=t.hasOwnProperty(r);return t.constructor.createProperty(r,e),a?Object.getOwnPropertyDescriptor(t,r):void 0})(e,t,r)} /** * @license * Copyright 2017 Google LLC * SPDX-License-Identifier: BSD-3-Clause */function he(e){return ye({...e,state:!0,attribute:!1})}class ue{constructor(e){this.config={timeout:3e4,retryAttempts:3,...e},this.defaultHeaders={"Content-Type":"application/json","X-API-Key":e.apiKey}}setBusinessContext(e){this.config.businessId=e}getBusinessContext(){return this.config.businessId}async request(e,t={}){const r=`${this.config.baseURL}${e}`,a={...this.defaultHeaders,...t.headers},i={...t,headers:a,signal:AbortSignal.timeout(this.config.timeout)};try{const e=await fetch(r,i);if(!e.ok){const t=await e.json().catch(()=>({}));return{success:!1,error:t.error||`HTTP ${e.status}: ${e.statusText}`,details:t.details}}return{success:!0,data:await e.json()}}catch(e){return console.error("API Request failed:",e),{success:!1,error:e instanceof Error?e.message:"Network error occurred"}}}async getBusinesses(){return this.request("/v1/businesses/")}async getBusiness(e){return this.request(`/v1/businesses/${e}/`)}async createBusiness(e){return this.request("/v1/businesses/",{method:"POST",body:JSON.stringify(e)})}async updateBusiness(e,t){return this.request(`/v1/businesses/${e}/`,{method:"PUT",body:JSON.stringify(t)})}async getBusinessStats(e){return this.request(`/v1/businesses/${e}/stats/`)}async lookupBusinessByExternalId(e){return this.request(`/v1/businesses/lookup/?external_id=${encodeURIComponent(e)}`)}async getInvoices(e,t){const r=new URLSearchParams({business_id:e});return t?.status&&r.append("status",t.status),t?.customer_id&&r.append("customer_id",t.customer_id),t?.date_from&&r.append("date_from",t.date_from),t?.date_to&&r.append("date_to",t.date_to),t?.overdue&&r.append("overdue","true"),t?.outstanding&&r.append("outstanding","true"),t?.search&&r.append("search",t.search),this.request(`/invoices/?${r.toString()}`)}async getInvoice(e){return this.request(`/invoices/${e}/`)}async createInvoice(e){return this.request("/invoices/",{method:"POST",body:JSON.stringify(e)})}async updateInvoice(e,t){return this.request(`/invoices/${e}/`,{method:"PUT",body:JSON.stringify(t)})}async deleteInvoice(e){return this.request(`/invoices/${e}/`,{method:"DELETE"})}async recordInvoicePayment(e,t){return this.request(`/invoices/${e}/payment/`,{method:"POST",body:JSON.stringify(t)})}async sendInvoice(e){return this.request(`/invoices/${e}/send/`,{method:"POST"})}async getInvoicePayments(e){return this.request(`/invoices/${e}/payments/list/`)}async getCustomers(e){return this.request(`/customers/?business_id=${e}`)}async getCustomer(e){return this.request(`/customers/${e}/`)}async createCustomer(e){return this.request("/customers/",{method:"POST",body:JSON.stringify(e)})}async updateCustomer(e,t){return this.request(`/customers/${e}/`,{method:"PUT",body:JSON.stringify(t)})}async archiveCustomer(e){return this.request(`/customers/${e}/archive/`,{method:"POST"})}async reactivateCustomer(e){return this.request(`/customers/${e}/reactivate/`,{method:"POST"})}async getAccounts(e,t){const r=new URLSearchParams({business_id:e});return t?.account_type&&r.append("account_type",t.account_type),void 0!==t?.is_active&&r.append("is_active",t.is_active.toString()),t?.search&&r.append("search",t.search),this.request(`/accounts/?${r.toString()}`)}async getAccount(e){return this.request(`/accounts/${e}/`)}async createAccount(e){return this.request("/accounts/",{method:"POST",body:JSON.stringify(e)})}async updateAccount(e,t){return this.request(`/accounts/${e}/`,{method:"PUT",body:JSON.stringify(t)})}async deleteAccount(e){return this.request(`/accounts/${e}/`,{method:"DELETE"})}async getBankAccounts(e){return this.request(`/accounts/bank/?business_id=${e}`)}async getAccountHierarchy(e){return this.request(`/accounts/hierarchy/?business_id=${e}`)}async syncAccount(e){return this.request(`/accounts/${e}/sync/`,{method:"POST"})}async getPayments(e,t){const r=new URLSearchParams({business_id:e});return t?.status&&r.append("status",t.status),t?.customer_id&&r.append("customer_id",t.customer_id),t?.date_from&&r.append("date_from",t.date_from),t?.date_to&&r.append("date_to",t.date_to),t?.search&&r.append("search",t.search),this.request(`/payments/?${r.toString()}`)}async getPayment(e){return this.request(`/payments/${e}/`)}async createPayment(e){return this.request("/payments/",{method:"POST",body:JSON.stringify(e)})}async updatePayment(e,t){return this.request(`/payments/${e}/`,{method:"PUT",body:JSON.stringify(t)})}async completePayment(e){return this.request(`/payments/${e}/complete/`,{method:"POST"})}async failPayment(e){return this.request(`/payments/${e}/fail/`,{method:"POST"})}async getBalanceSheet(e,t){const r=new URLSearchParams({business_id:e});return t&&r.append("effective_date",t),this.request(`/reports/balance-sheet/?${r.toString()}`)}async getPnLData(e,t,r){const a=new URLSearchParams({business_id:e,date_from:t,date_to:r});return this.request(`/reports/pnl/?${a.toString()}`)}async getCashFlowData(e,t,r){const a=new URLSearchParams({business_id:e,date_from:t,date_to:r});return this.request(`/reports/cash-flow/?${a.toString()}`)}async healthCheck(){return this.request("/health/")}formatCurrency(e,t="GBP"){const r="number"==typeof e?e:parseFloat(e.toString());return new Intl.NumberFormat("en-GB",{style:"currency",currency:t}).format(r)}formatDate(e){return new Date(e).toLocaleDateString("en-GB",{year:"numeric",month:"short",day:"numeric"})}validateBusinessAccess(e){return this.config.businessId===e||!!e}handleApiError(e){let t="An unexpected error occurred";return 401===e.response?.status?t="Authentication failed. Check your API key.":404===e.response?.status?t="Business not found or not accessible.":403===e.response?.status?t="Permission denied. Business not accessible.":e.response?.data?.error&&(t=e.response.data.error),{success:!1,error:t,details:e.response?.data?.details}}}class pe extends ne{constructor(){super(...arguments),this.apiKey="",this.businessId="",this.theme="light",this.baseUrl="http://localhost:8000/api",this.loading=!1,this.error=null,this.apiClient=null}connectedCallback(){super.connectedCallback(),this.initializeApiClient(),this.loadData()}initializeApiClient(){if("undefined"!=typeof window&&window.FridayProvider){const e=window.FridayProvider.getApiClient();if(e)return void(this.apiClient=e);const t=window.FridayProvider.getWidgetConfig();if(t)return void(this.apiClient=new ue({baseURL:t.baseUrl,apiKey:t.apiKey,businessId:t.businessId}))}this.apiKey?this.apiClient=new ue({baseURL:this.baseUrl,apiKey:this.apiKey,businessId:this.businessId||void 0}):this.setError("API key is required. Configure FridayProvider or provide api-key attribute.")}async loadData(){}setError(e){if(this.error=e,this.loading=!1,this.emitEvent("error",{message:e}),"undefined"!=typeof window&&window.FridayProvider)try{window.FridayProvider.handleError(new Error(e))}catch(e){}}clearError(){this.error=null}handleApiError(e,t="API request"){let r=`${t} failed`;e?.error?r=e.error:e?.message?r=e.message:"string"==typeof e&&(r=e),e?.details&&(r+=` (${e.details})`),this.setError(r),this.emitEvent("api-error",{context:t,error:e,message:r})}async makeApiRequest(e,t="Request"){try{if(this.setLoading(!0),!this.apiClient)throw new Error("API client not initialized");const r=await e();return r.success?(this.clearError(),r.data||null):(this.handleApiError(r,t),null)}catch(e){return this.handleApiError(e,t),null}finally{this.setLoading(!1)}}setLoading(e){this.loading=e,e&&this.clearError()}emitEvent(e,t={}){const r={type:e,data:t,timestamp:Date.now()};this.dispatchEvent(new CustomEvent(`friday-${e}`,{detail:r,bubbles:!0,composed:!0}))}renderLoading(){return B` <div class="Friday__loading"> <div class="Friday__spinner"></div> <span>Loading...</span> </div> `}renderError(){return B` <div class="Friday__error"> <span>⚠️ ${this.error}</span> </div> `}static get baseStyles(){return n` @import url('https://rsms.me/inter/inter.css'); :host { display: block; /* Friday Design System - Layer Financial Inspired */ --color-black: #1a1a1a; --color-white: white; --color-info: #0968f8; --color-info-bg: #d6e6ff; --color-info-fg: #0056d7; --color-success: hsl(145deg 45% 42%); --color-success-bg: hsl(145deg 59% 86%); --color-success-fg: hsl(145deg 63% 29%); --color-warning: hsl(43deg 100% 44%); --color-warning-bg: hsl(43deg 100% 84%); --color-warning-fg: hsl(43deg 88% 26%); --color-error: hsl(0deg 76% 50%); --color-error-bg: hsl(0deg 83% 86%); --color-error-fg: hsl(0deg 88% 32%); --color-dark-h: 220; --color-dark-s: 15%; --color-dark-l: 7%; --color-dark: hsl(var(--color-dark-h) var(--color-dark-s) var(--color-dark-l)); --color-base-0: #fff; --color-base-50: hsl(var(--color-dark-h) 5% 98%); --color-base-100: hsl(var(--color-dark-h) 5% 95%); --color-base-200: hsl(var(--color-dark-h) 5% 91%); --color-base-300: hsl(var(--color-dark-h) 6% 85%); --color-base-400: hsl(var(--color-dark-h) 7% 75%); --color-base-500: hsl(var(--color-dark-h) 8% 50%); --color-base-600: hsl(var(--color-dark-h) 10% 40%); --color-base-700: hsl(var(--color-dark-h) 12% 27%); --color-base-800: hsl(var(--color-dark-h) 15% 20%); --color-base-900: hsl(var(--color-dark-h) 18% 14%); --text-color-primary: var(--color-dark); --text-color-secondary: var(--color-base-600); --text-color-muted: var(--color-base-500); --text-color-inverse: var(--color-white); --bg-primary: var(--color-base-0); --bg-secondary: var(--color-base-50); --bg-tertiary: var(--color-base-100); --bg-element-hover: var(--color-base-100); --border-primary: var(--color-base-200); --border-secondary: var(--color-base-300); --border-focus: var(--color-info); --font-family: 'InterVariable', 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; --text-2xs: 10px; --text-xs: 11px; --text-sm: 12px; --text-md: 14px; --text-lg: 16px; --text-xl: 18px; --text-2xl: 20px; --text-3xl: 24px; --font-weight-normal: 460; --font-weight-medium: 500; --font-weight-semibold: 540; --font-weight-bold: 600; --spacing-2xs: 6px; --spacing-xs: 8px; --spacing-sm: 12px; --spacing-md: 16px; --spacing-lg: 20px; --spacing-xl: 24px; --spacing-2xl: 32px; --spacing-3xl: 40px; --spacing-4xl: 48px; --radius-sm: 6px; --radius-md: 8px; --radius-lg: 12px; --shadow-sm: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06); --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06); --transition-fast: 150ms ease; } .Friday__component { font-family: var(--font-family); font-size: var(--text-md); line-height: 1.5; color: var(--text-color-primary); background: var(--bg-primary); border: 1px solid var(--border-primary); border-radius: var(--radius-md); box-shadow: var(--shadow-sm); overflow: hidden; } .Friday__loading { display: flex; align-items: center; justify-content: center; padding: var(--spacing-4xl); color: var(--text-color-muted); font-size: var(--text-sm); gap: var(--spacing-xs); } .Friday__spinner { width: 20px; height: 20px; border: 2px solid var(--border-primary); border-top-color: var(--color-info); border-radius: 50%; animation: Friday__spin 1s linear infinite; } @keyframes Friday__spin { to { transform: rotate(360deg); } } .Friday__error { display: flex; align-items: center; gap: var(--spacing-xs); padding: var(--spacing-md); margin: var(--spacing-md); background: var(--color-error-bg); color: var(--color-error-fg); border: 1px solid var(--color-error); border-radius: var(--radius-sm); font-size: var(--text-sm); } .Friday__header { display: flex; align-items: center; justify-content: space-between; padding: var(--spacing-lg) var(--spacing-xl); border-bottom: 1px solid var(--border-primary); background: var(--bg-secondary); } .Friday__header-title { font-size: var(--text-xl); font-weight: var(--font-weight-semibold); color: var(--text-color-primary); margin: 0; } .Friday__header-actions { display: flex; align-items: center; gap: var(--spacing-sm); } .Friday__content { padding: var(--spacing-xl); } .Friday__button { display: inline-flex; align-items: center; justify-content: center; gap: var(--spacing-xs); padding: var(--spacing-xs) var(--spacing-md); border: 1px solid transparent; border-radius: var(--radius-sm); font-family: var(--font-family); font-size: var(--text-sm); font-weight: var(--font-weight-medium); line-height: 1.5; text-decoration: none; cursor: pointer; transition: all var(--transition-fast); white-space: nowrap; user-select: none; } .Friday__button:disabled { opacity: 0.5; cursor: not-allowed; } .Friday__button--primary { background: var(--color-info); color: var(--text-color-inverse); border-color: var(--color-info); } .Friday__button--primary:hover:not(:disabled) { background: var(--color-info-fg); border-color: var(--color-info-fg); } .Friday__button--secondary { background: var(--bg-primary); color: var(--text-color-primary); border-color: var(--border-primary); } .Friday__button--secondary:hover:not(:disabled) { background: var(--bg-element-hover); border-color: var(--border-secondary); } .Friday__button--success { background: var(--color-success); color: var(--text-color-inverse); border-color: var(--color-success); } .Friday__button--success:hover:not(:disabled) { background: var(--color-success-fg); border-color: var(--color-success-fg); } .Friday__button--error { background: var(--color-error); color: var(--text-color-inverse); border-color: var(--color-error); } .Friday__button--sm { padding: var(--spacing-2xs) var(--spacing-sm); font-size: var(--text-xs); } .Friday__input { display: block; width: 100%; padding: var(--spacing-xs) var(--spacing-sm); border: 1px solid var(--border-primary); border-radius: var(--radius-sm); font-family: var(--font-family); font-size: var(--text-sm); line-height: 1.5; color: var(--text-color-primary); background: var(--bg-primary); transition: all var(--transition-fast); } .Friday__input:focus { outline: none; border-color: var(--border-focus); box-shadow: 0 0 0 3px hsla(217, 100%, 50%, 0.1); } .Friday__select { display: block; width: 100%; padding: var(--spacing-xs) var(--spacing-sm); border: 1px solid var(--border-primary); border-radius: var(--radius-sm); font-family: var(--font-family); font-size: var(--text-sm); color: var(--text-color-primary); background: var(--bg-primary); cursor: pointer; transition: all var(--transition-fast); } .Friday__table { width: 100%; border-collapse: collapse; font-size: var(--text-sm); } .Friday__table th, .Friday__table td { padding: var(--spacing-sm) var(--spacing-md); text-align: left; border-bottom: 1px solid var(--border-primary); } .Friday__table th { font-weight: var(--font-weight-semibold); color: var(--text-color-secondary); background: var(--bg-secondary); font-size: var(--text-xs); text-transform: uppercase; letter-spacing: 0.05em; } .Friday__table tbody tr:hover { background: var(--bg-element-hover); } .Friday__badge { display: inline-flex; align-items: center; padding: 2px var(--spacing-xs); border-radius: 9999px; font-size: var(--text-2xs); font-weight: var(--font-weight-medium); text-transform: uppercase; letter-spacing: 0.05em; } .Friday__badge--success { background: var(--color-success-bg); color: var(--color-success-fg); } .Friday__badge--warning { background: var(--color-warning-bg); color: var(--color-warning-fg); } .Friday__badge--error { background: var(--color-error-bg); color: var(--color-error-fg); } .Friday__badge--info { background: var(--color-info-bg); color: var(--color-info-fg); } /* Typography utilities */ .Friday__text-xs { font-size: var(--text-xs); } .Friday__text-sm { font-size: var(--text-sm); } .Friday__text-md { font-size: var(--text-md); } .Friday__text-lg { font-size: var(--text-lg); } .Friday__text-muted { color: var(--text-color-muted); } .Friday__text-secondary { color: var(--text-color-secondary); } .Friday__font-medium { font-weight: var(--font-weight-medium); } .Friday__font-semibold { font-weight: var(--font-weight-semibold); } .Friday__font-bold { font-weight: var(--font-weight-bold); } @media (max-width: 768px) { .Friday__component { border-radius: 0; border-left: none; border-right: none; box-shadow: none; } .Friday__header { padding: var(--spacing-md) var(--spacing-lg); } .Friday__content { padding: var(--spacing-lg); } .Friday__table th, .Friday__table td { padding: var(--spacing-xs) var(--spacing-sm); } } `}}return t([ye({type:String,attribute:"api-key"})],pe.prototype,"apiKey",void 0),t([ye({type:String,attribute:"business-id"})],pe.prototype,"businessId",void 0),t([ye({type:String})],pe.prototype,"theme",void 0),t([ye({type:String,attribute:"base-url"})],pe.prototype,"baseUrl",void 0),t([he()],pe.prototype,"loading",void 0),t([he()],pe.prototype,"error",void 0),e.JournalWidget=class extends pe{constructor(){super(...arguments),this.showDemo=!1,this.dateRange="30-days",this.showUnpostedOnly=!1,this.journalEntries=[],this.accounts=[],this.selectedEntry=null,this.showCreateForm=!1,this.loading=!1,this.error="",this.currentPage=1,this.totalPages=1,this.searchQuery="",this.filterStatus="all"}connectedCallback(){super.connectedCallback(),this.loadJournalEntries(),this.loadAccounts()}async loadJournalEntries(){if(this.apiClient){this.loading=!0,this.error="";try{this.showDemo,this.journalEntries=this.generateDemoJournalEntries()}catch(e){this.error=e instanceof Error?e.message:"Failed to load journal entries"}finally{this.loading=!1}}else this.error="API client not configured"}async loadAccounts(){if(this.apiClient)try{if(this.showDemo)this.accounts=this.generateDemoAccounts();else{const e=await this.apiClient.getAccounts();this.accounts=e.data}}catch(e){console.error("Failed to load accounts:",e)}}generateDemoJournalEntries(){const e=new Date,t=[];for(let r=0;r<15;r++){const a=new Date(e.getTime()-24*r*60*60*1e3),i=Math.random()>.3,s=Math.floor(5e5*Math.random())+1e4;t.push({id:`journal-${r+1}`,business_id:"demo-business",sequence_number:`JE-2025-${(r+1).toString().padStart(6,"0")}`,entry_date:a.toISOString().split("T")[0],reference:`REF-${Math.floor(1e4*Math.random())}`,description:this.getRandomDescription(),is_posted:i,posted_at:i?a.toISOString():void 0,auto_post_eligible:!0,requires_review:Math.random()>.8,ai_confidence_score:.3*Math.random()+.7,created_by:this.getRandomCreatedBy(),bank_transaction_id:Math.random()>.5?`bank-tx-${r}`:void 0,accounting_period_id:"period-2025",lines:this.generateDemoJournalLines(s),total_debits_cents:s,total_credits_cents:s,total_debits:s/100,total_credits:s/100,is_balanced:!0,balance_difference_cents:0,can_be_posted:!i,created_at:a.toISOString(),updated_at:a.toISOString(),metadata:{}})}return t}generateDemoJournalLines(e){const t=this.generateDemoAccounts(),r=t[Math.floor(5*Math.random())],a=t[Math.floor(5*Math.random())+10];return[{id:"line-1",journal_entry_id:"journal-1",ledger_account_id:r.id,debit_amount_cents:e,credit_amount_cents:0,description:"Debit entry",line_number:1,external_reference:"",account:r,account_code:r.code,account_name:r.name,amount_cents:e,amount:e/100,display_amount:`£${(e/100).toFixed(2)}`,is_debit:!0,is_credit:!1,side:"DR",created_at:(new Date).toISOString(),updated_at:(new Date).toISOString(),metadata:{}},{id:"line-2",journal_entry_id:"journal-1",ledger_account_id:a.id,debit_amount_cents:0,credit_amount_cents:e,description:"Credit entry",line_number:2,external_reference:"",account:a,account_code:a.code,account_name:a.name,amount_cents:e,amount:e/100,display_amount:`£${(e/100).toFixed(2)}`,is_debit:!1,is_credit:!0,side:"CR",created_at:(new Date).toISOString(),updated_at:(new Date).toISOString(),metadata:{}}]}generateDemoAccounts(){return[{id:"1",code:"1000",name:"Cash - Current Account",account_type:"current_asset",normal_balance:"debit",is_active:!0,business_id:"demo",created_at:"",updated_at:"",metadata:{}},{id:"2",code:"1200",name:"Accounts Receivable",account_type:"current_asset",normal_balance:"debit",is_active:!0,business_id:"demo",created_at:"",updated_at:"",metadata:{}},{id:"3",code:"1300",name:"Inventory",account_type:"current_asset",normal_balance:"debit",is_active:!0,business_id:"demo",created_at:"",updated_at:"",metadata:{}},{id:"4",code:"1500",name:"Equipment",account_type:"fixed_asset",normal_balance:"debit",is_active:!0,business_id:"demo",created_at:"",updated_at:"",metadata:{}},{id:"5",code:"1600",name:"Office Furniture",account_type:"fixed_asset",normal_balance:"debit",is_active:!0,business_id:"demo",created_at:"",updated_at:"",metadata:{}},{id:"6",code:"2000",name:"Accounts Payable",account_type:"current_liability",normal_balance:"credit",is_active:!0,business_id:"demo",created_at:"",updated_at:"",metadata:{}},{id:"7",code:"2100",name:"VAT Payable",account_type:"current_liability",normal_balance:"credit",is_active:!0,business_id:"demo",created_at:"",updated_at:"",metadata:{}},{id:"8",code:"3000",name:"Share Capital",account_type:"equity",normal_balance:"credit",is_active:!0,business_id:"demo",created_at:"",updated_at:"",metadata:{}},{id:"9",code:"3100",name:"Retained Earnings",account_type:"equity",normal_balance:"credit",is_active:!0,business_id:"demo",created_at:"",updated_at:"",metadata:{}},{id:"10",code:"4000",name:"Sales Revenue",account_type:"revenue",normal_balance:"credit",is_active:!0,business_id:"demo",created_at:"",updated_at:"",metadata:{}},{id:"11",code:"4100",name:"Service Revenue",account_type:"revenue",normal_balance:"credit",is_active:!0,business_id:"demo",created_at:"",updated_at:"",metadata:{}},{id:"12",code:"5000",name:"Cost of Goods Sold",account_type:"cost_of_goods_sold",normal_balance:"debit",is_active:!0,business_id:"demo",created_at:"",updated_at:"",metadata:{}},{id:"13",code:"6000",name:"Office Expenses",account_type:"operating_expense",normal_balance:"debit",is_active:!0,business_id:"demo",created_at:"",updated_at:"",metadata:{}},{id:"14",code:"6100",name:"Marketing Expenses",account_type:"operating_expense",normal_balance:"debit",is_active:!0,business_id:"demo",created_at:"",updated_at:"",metadata:{}},{id:"15",code:"6200",name:"Professional Fees",account_type:"operating_expense",normal_balance:"debit",is_active:!0,business_id:"demo",created_at:"",updated_at:"",metadata:{}}]}getRandomDescription(){const e=["Customer payment received","Supplier invoice payment","Bank transfer processing","Monthly rent payment","Equipment purchase","Professional services","Marketing campaign costs","Office supplies purchase","Insurance premium payment","Utility bill payment","Staff salary payment","Tax payment processing","Inventory purchase","Sales commission payment","Loan repayment"];return e[Math.floor(Math.random()*e.length)]}getRandomCreatedBy(){const e=["ai","manual","system","import"];return e[Math.floor(Math.random()*e.length)]}formatCurrency(e){return`£${(e/100).toLocaleString("en-GB",{minimumFractionDigits:2,maximumFractionDigits:2})}`}formatDate(e){return new Date(e).toLocaleDateString("en-GB",{day:"2-digit",month:"short",year:"numeric"})}selectEntry(e){this.selectedEntry=e,this.dispatchEvent(new CustomEvent("friday-journal-entry-selected",{detail:{entry:e},bubbles:!0,composed:!0}))}closeSidebar(){this.selectedEntry=null,this.showCreateForm=!1}openCreateForm(){this.showCreateForm=!0,this.selectedEntry=null}downloadCSV(){this.dispatchEvent(new CustomEvent("friday-journal-export-requested",{detail:{format:"csv",entries:this.journalEntries},bubbles:!0,composed:!0}))}postEntry(e){this.dispatchEvent(new CustomEvent("friday-journal-entry-post-requested",{detail:{entry:e},bubbles:!0,composed:!0}))}reverseEntry(e){this.dispatchEvent(new CustomEvent("friday-journal-entry-reverse-requested",{detail:{entry:e},bubbles:!0,composed:!0}))}getCreatedByIcon(e){switch(e){case"ai":return"🤖";case"manual":return"👤";case"system":return"⚙️";case"import":return"📥";default:return"📝"}}render(){return this.loading?B` <div class="Friday__loading"> <div>Loading journal entries...</div> </div> `:this.error?B` <div class="Friday__error"> Error: ${this.error} </div> `:B` <div class="Friday__journal-container"> <div class="Friday__main-content"> ${this.renderHeader()} ${this.renderTable()} ${this.renderPagination()} </div> ${this.renderSidebar()} </div> `}renderHeader(){return B` <div class="Friday__header"> <div class="Friday__header-top"> <div class="Friday__title-section"> <h2 class="Friday__title">General Ledger</h2> <p class="Friday__subtitle">Double-entry bookkeeping journal entries</p> </div> <div class="Friday__header-actions"> <button class="Friday__button Friday__button--secondary" @click=${this.downloadCSV}> <svg width="16" height="16" fill="currentColor" viewBox="0 0 24 24"> <path d="M12 2L13.09 8.26L22 9L13.09 9.74L12 16L10.91 9.74L2 9L10.91 8.26L12 2Z"/> </svg> Export CSV </button> <button class="Friday__button Friday__button--primary" @click=${this.openCreateForm}> <svg width="16" height="16" fill="currentColor" viewBox="0 0 24 24"> <path d="M12 2C13.1 2 14 2.9 14 4V10H20C21.1 10 22 10.9 22 12S21.1 14 20 14H14V20C14 21.1 13.1 22 12 22S10 21.1 10 20V14H4C2.9 14 2 13.1 2 12S2.9 10 4 10H10V4C10 2.9 10.9 2 12 2Z"/> </svg> Create Entry </button> </div> </div> <div class="Friday__controls"> <div class="Friday__search-container"> <svg class="Friday__search-icon" fill="none" stroke="currentColor" viewBox="0 0 24 24"> <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z"></path> </svg> <input type="text" class="Friday__search-input" placeholder="Search journal entries..." .value=${this.searchQuery} @input=${e=>this.searchQuery=e.target.value} /> </div> <select class="Friday__filter-select" .value=${this.filterStatus} @change=${e=>this.filterStatus=e.target.value}> <option value="all">All Entries</option> <option value="posted">Posted Only</option> <option value="unposted">Unposted Only</option> </select> </div> </div> `}renderTable(){return 0===this.journalEntries.length?B` <div class="Friday__empty-state"> <svg class="Friday__empty-state-icon" fill="none" stroke="currentColor" viewBox="0 0 24 24"> <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 12h6m-6 4h6m2 5H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z"></path> </svg> <h3>No journal entries found</h3> <p>Get started by creating your first journal entry</p> </div> `:B` <div class="Friday__table-container"> <table class="Friday__table"> <thead> <tr> <th>Entry #</th> <th>Date</th> <th>Reference</th> <th>Description</th> <th>Status</th> <th>Created By</th> <th>Amount</th> </tr> </thead> <tbody> ${this.journalEntries.map(e=>B` <tr class="Friday__table-row ${this.selectedEntry?.id===e.id?"Friday__row--selected":""}" @click=${()=>this.selectEntry(e)} > <td> <span class="Friday__sequence-number">${e.sequence_number}</span> </td> <td>${this.formatDate(e.entry_date)}</td> <td>${e.reference}</td> <td>${e.description}</td> <td> <span class="Friday__status-badge Friday__status-badge--${e.is_posted?"posted":e.is_balanced?"draft":"unbalanced"}"> ${e.is_posted?"Posted":e.is_balanced?"Draft":"Unbalanced"} </span> </td> <td> <span class="Friday__created-by"> <span class="Friday__created-by-icon">${this.getCreatedByIcon(e.created_by)}</span> ${e.created_by} </span> </td> <td class="Friday__amount Friday__amount--${e.is_balanced?"balanced":"unbalanced"}"> ${this.formatCurrency(e.total_debits_cents)} </td> </tr> `)} </tbody> </table> </div> `}renderPagination(){return B` <div class="Friday__pagination"> <div class="Friday__pagination-info"> Showing ${this.journalEntries.length} entries </div> <div class="Friday__pagination-buttons"> <button class="Friday__button Friday__button--secondary" ?disabled=${this.currentPage<=1}> Previous </button> <button class="Friday__button Friday__button--secondary" ?disabled=${this.currentPage>=this.totalPages}> Next </button> </div> </div> `}renderSidebar(){const e=this.selectedEntry||this.showCreateForm;return B` <div class="Friday__sidebar ${e?"Friday__sidebar--open":""}"> ${this.selectedEntry?this.renderEntryDetails():""} ${this.showCreateForm?this.renderCreateForm():""} </div> `}renderEntryDetails(){return this.selectedEntry?B` <div class="Friday__sidebar-header"> <h3 class="Friday__sidebar-title">Journal Entry Details</h3> <p>${this.selectedEntry.sequence_number}</p> </div> <div class="Friday__sidebar-content"> <div class="Friday__entry-details"> <div class="Friday__detail-group"> <div class="Friday__detail-label">Entry Date</div> <div class="Friday__detail-value">${this.formatDate(this.selectedEntry.entry_date)}</div> </div> <div class="Friday__detail-group"> <div class="Friday__detail-label">Reference</div> <div class="Friday__detail-value">${this.selectedEntry.reference}</div> </div> <div class="Friday__detail-group"> <div class="Friday__detail-label">Description</div> <div class="Friday__detail-value">${this.selectedEntry.description}</div> </div> <div class="Friday__detail-group"> <div class="Friday__detail-label">Status</div> <div class="Friday__detail-value"> <span class="Friday__status-badge Friday__status-badge--${this.selectedEntry.is_posted?"posted":"draft"}"> ${this.selectedEntry.