image-salon-sdk 1.0.25 → 1.0.26

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.
@@ -4251,7 +4251,7 @@ function Vt() {
4251
4251
  return s.setAttribute("x1", "14"), s.setAttribute("x2", "14"), s.setAttribute("y1", "11"), s.setAttribute("y2", "17"), i.appendChild(e), i.appendChild(t), i.appendChild(n), i.appendChild(r), i.appendChild(s), document.body.appendChild(i), i;
4252
4252
  }
4253
4253
  var Te, Be, _, ue, O, D, be, J, ve, ye, re, ee, Ce, Re, Ee, Ne, fe, _e, se, oe, ke, Le, pe, Oe, Me, K, te, Ve, He, Ie;
4254
- class Ji {
4254
+ class zi {
4255
4255
  constructor(e) {
4256
4256
  k(this, Te);
4257
4257
  k(this, Be);
@@ -4995,13 +4995,6 @@ class Ji {
4995
4995
  }
4996
4996
  }
4997
4997
  Te = new WeakMap(), Be = new WeakMap(), _ = new WeakMap(), ue = new WeakMap(), O = new WeakMap(), D = new WeakMap(), be = new WeakMap(), J = new WeakMap(), ve = new WeakMap(), ye = new WeakMap(), re = new WeakMap(), ee = new WeakMap(), Ce = new WeakMap(), Re = new WeakMap(), Ee = new WeakMap(), Ne = new WeakMap(), fe = new WeakMap(), _e = new WeakMap(), se = new WeakMap(), oe = new WeakMap(), ke = new WeakMap(), Le = new WeakMap(), pe = new WeakMap(), Oe = new WeakMap(), Me = new WeakMap(), K = new WeakMap(), te = new WeakMap(), Ve = new WeakMap(), He = new WeakMap(), Ie = new WeakMap();
4998
- new Ji({
4999
- handleUpload: () => {
5000
- },
5001
- parentContainerId: "app",
5002
- mode: "development",
5003
- enableMultiSelect: !0
5004
- });
5005
4998
  export {
5006
- Ji as default
4999
+ zi as default
5007
5000
  };
@@ -1,8 +1,8 @@
1
1
  import './style.css';
2
- (function(I,y){typeof exports=="object"&&typeof module<"u"?module.exports=y():typeof define=="function"&&define.amd?define(y):(I=typeof globalThis<"u"?globalThis:I||self,I.ImageSalonSdk=y())})(this,function(){"use strict";var Gi=Object.defineProperty;var dn=I=>{throw TypeError(I)};var Ji=(I,y,H)=>y in I?Gi(I,y,{enumerable:!0,configurable:!0,writable:!0,value:H}):I[y]=H;var _=(I,y,H)=>Ji(I,typeof y!="symbol"?y+"":y,H),hn=(I,y,H)=>y.has(I)||dn("Cannot "+H);var d=(I,y,H)=>(hn(I,y,"read from private field"),H?H.call(I):y.get(I)),L=(I,y,H)=>y.has(I)?dn("Cannot add the same private member more than once"):y instanceof WeakSet?y.add(I):y.set(I,H),f=(I,y,H,Se)=>(hn(I,y,"write to private field"),Se?Se.call(I,H):y.set(I,H),H);var me,Be,ve,D,ge,S,R,Ee,z,_e,Ne,ce,ie,ke,$e,Le,Ie,we,Oe,de,he,Fe,Ae,be,De,je,J,re,Pe,We,Te;function I(i="#333"){const e=document.createElementNS("http://www.w3.org/2000/svg","svg");e.setAttribute("xmlns","http://www.w3.org/2000/svg"),e.setAttribute("x","0px"),e.setAttribute("y","0px"),e.setAttribute("width","18"),e.setAttribute("height","18"),e.setAttribute("viewBox","0 0 50 50"),e.setAttribute("fill",i);const t=document.createElementNS("http://www.w3.org/2000/svg","path");return t.setAttribute("d","M 9.15625 6.3125 L 6.3125 9.15625 L 22.15625 25 L 6.21875 40.96875 L 9.03125 43.78125 L 25 27.84375 L 40.9375 43.78125 L 43.78125 40.9375 L 27.84375 25 L 43.6875 9.15625 L 40.84375 6.3125 L 25 22.15625 Z"),e.appendChild(t),e}function y(i,e,t){let n=document.createElement(i);return n.className+=e,t&&t.appendChild(n),n}class H{constructor(){L(this,me);f(this,me,document.createElementNS("http://www.w3.org/2000/svg","svg")),d(this,me).setAttribute("viewBox","25 25 50 50"),d(this,me).classList.add("loader-svg");const e=document.createElementNS("http://www.w3.org/2000/svg","circle");e.setAttribute("r","20"),e.setAttribute("cy","50"),e.setAttribute("cx","50"),e.classList.add("loader-circle"),d(this,me).appendChild(e)}show(e){e.appendChild(d(this,me))}hide(){d(this,me).remove()}}me=new WeakMap;const Se=new H,Ke=document.body;class Ct{constructor(){_(this,"main");_(this,"dialogContainer");_(this,"dialog");_(this,"dialogBackdrop");_(this,"dialogContent");_(this,"dialogHeader");_(this,"dialogBody");_(this,"dialogFooter");_(this,"confirmButton");_(this,"cancelButton");_(this,"confirmCallback");_(this,"cancelCallback");this.main=y("div"),this.dialog=y("div"),this.confirmCallback=void 0,this.cancelCallback=void 0}_init(e){if(this.main=y("div","dialog-presentation",Ke),this.main.setAttribute("role","presentation"),this.dialogContainer=y("div","dialog-container",this.main),this.dialogBackdrop=y("div","dialog-backdrop",this.dialogContainer),this.dialog=y("div","dialog",this.dialogContainer),this.dialog.className="dialog",this.dialogContent=y("div","dialog-content",this.dialog),e!=null&&e.dialogContentStyle&&Object.assign(this.dialogContent.style,e.dialogContentStyle),this.confirmButton=y("button","dialog-btn confirm",this.dialogFooter),this.confirmButton.type="button",this.cancelButton=y("button","dialog-btn cancel",this.dialogFooter),this.cancelButton.type="button",e.showCloseBtn){const t=y("button","dialog-close-btn",this.dialogContent);t.appendChild(I()),t.onclick=()=>this.hide()}return e.header&&this._setHeader(e),this._setBody(e),this._setFooter(e),this.confirmButton.textContent=e.confirmButtonText||"Upload",this.cancelButton.textContent=e.cancelButtonText||"Cancel",Ke.style.overflow="hidden",this.confirmButton.textContent=e.confirmButtonText||"Upload",this.cancelButton.textContent=e.cancelButtonText||"Cancel",Ke.classList.add("dialog-visible"),new Promise(t=>{const n=r=>()=>{this.hide(),t(r==="confirm")};this.confirmCallback=e.onConfirm||n("confirm"),this.confirmButton.addEventListener("click",this.confirmCallback),this.cancelCallback=e.onCancel||n("cancel"),this.cancelButton.addEventListener("click",this.cancelCallback)})}_setHeader(e){if(this.dialogHeader=y("div","dialog-header",this.dialogContent),!e.header)this.dialogHeader.innerHTML="";else if(typeof e.header=="string"){const t=y("h4","dialog-header-text",this.dialogHeader);t.textContent=e.header}else this.dialogHeader.innerHTML="",this.dialogHeader.appendChild(e.header)}_setBody(e){this.dialogBody=y("div","dialog-body",this.dialogContent),typeof e.content=="string"?this.dialogBody.innerHTML=e.content:(this.dialogBody.innerHTML="",this.dialogBody.appendChild(e.content))}_setFooter(e){this.dialogFooter=y("div","dialog-footer",this.dialogContent),e.showFooter?this.dialogFooter.append(this.confirmButton,this.cancelButton):(this.dialogFooter.innerHTML="",this.dialogFooter.remove())}show(e){this._init(e),setTimeout(()=>{this.dialogContainer.style.opacity="1",this.dialog.style.transform="scale(1)",this.dialog.style.transition="transform 150ms ease-in",this.dialog.style.opacity="1",this.dialogBackdrop.style.opacity="1"},150)}hide(){this.main||Ke.style.removeProperty("overflow"),this.dialog.style.transform="scale(0.8)",this.dialog.style.transition="transform 150ms ease-out",this.dialogBackdrop.style.opacity="0",setTimeout(()=>{this.dialogContainer.style.opacity="0",this.dialog.style.opacity="0",this.dialogContent.style.opacity="0",this.main.remove()},150)}updateUploadBtn(e){e?(Se.show(this.confirmButton),this.confirmButton.disabled=!0):(Se.hide(),this.confirmButton.disabled=!1)}}const Xe=new Ct,M=new Ct;function k(i,e){const t=document.createElement("div");return i&&(t.className=i),e&&(t.id=e),t}function Ue(i,e,t){const n=document.createElement("p");return e&&(n.className=e),t&&(n.id=t),i&&(n.textContent=i),n}function Q(i,e){const t=document.createElement("span");return e&&(t.className=e),i&&(t.textContent=i),t}function un(i,e,t,n){const r=document.createElement("img");return r.className=e,r.src=i,r}function fn(i,e,t){const n=document.createElement("video"),r=document.createElement("source");return n.className=e,r.src=i,n.appendChild(r),n}function pn(i,e,t){const n=document.createElement("audio"),r=document.createElement("source");return n.className=e,n.controls=!0,r.src=i,n.appendChild(r),n}function ee(i,e,t,n,r){const s=document.createElement("button");return e&&(s.className=e),t&&(s.id=t),i&&(s.textContent=i),r&&(s.innerHTML=r),s.disabled=n,s}function Et(i,e,t){const n=document.createElement("input");return n.className=e,n.defaultValue=t,i&&(n.type=i),n}function Nt(i){let e=typeof i;if(e=="object"){if(Array.isArray(i))return"array";if(i===null)return"null"}return e}function mn(i){return i!==null&&typeof i=="object"&&!Array.isArray(i)}let ue="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".split(""),Ge=[];for(let i=0;i<ue.length;i++)Ge[ue[i].charCodeAt(0)]=i;Ge[45]=ue.indexOf("+"),Ge[95]=ue.indexOf("/");function kt(i){let e=i.length*3/4;i[i.length-2]=="="?e-=2:i[i.length-1]=="="&&(e-=1);let t=new Uint8Array(e),n=0,r=0,s,o=0;for(let a=0;a<i.length;a++){if(s=Ge[i.charCodeAt(a)],s===void 0)switch(i[a]){case"=":r=0;case`
3
- `:case"\r":case" ":case" ":continue;default:throw Error("invalid base64 string.")}switch(r){case 0:o=s,r=1;break;case 1:t[n++]=o<<2|(s&48)>>4,o=s,r=2;break;case 2:t[n++]=(o&15)<<4|(s&60)>>2,o=s,r=3;break;case 3:t[n++]=(o&3)<<6|s,r=0;break}}if(r==1)throw Error("invalid base64 string.");return t.subarray(0,n)}function Lt(i){let e="",t=0,n,r=0;for(let s=0;s<i.length;s++)switch(n=i[s],t){case 0:e+=ue[n>>2],r=(n&3)<<4,t=1;break;case 1:e+=ue[r|n>>4],r=(n&15)<<2,t=2;break;case 2:e+=ue[r|n>>6],e+=ue[n&63],t=0;break}return t&&(e+=ue[r],e+="=",t==1&&(e+="=")),e}var N;(function(i){i.symbol=Symbol.for("protobuf-ts/unknown"),i.onRead=(t,n,r,s,o)=>{(e(n)?n[i.symbol]:n[i.symbol]=[]).push({no:r,wireType:s,data:o})},i.onWrite=(t,n,r)=>{for(let{no:s,wireType:o,data:a}of i.list(n))r.tag(s,o).raw(a)},i.list=(t,n)=>{if(e(t)){let r=t[i.symbol];return n?r.filter(s=>s.no==n):r}return[]},i.last=(t,n)=>i.list(t,n).slice(-1)[0];const e=t=>t&&Array.isArray(t[i.symbol])})(N||(N={}));function gn(i,e){return Object.assign(Object.assign({},i),e)}var m;(function(i){i[i.Varint=0]="Varint",i[i.Bit64=1]="Bit64",i[i.LengthDelimited=2]="LengthDelimited",i[i.StartGroup=3]="StartGroup",i[i.EndGroup=4]="EndGroup",i[i.Bit32=5]="Bit32"})(m||(m={}));function wn(){let i=0,e=0;for(let n=0;n<28;n+=7){let r=this.buf[this.pos++];if(i|=(r&127)<<n,!(r&128))return this.assertBounds(),[i,e]}let t=this.buf[this.pos++];if(i|=(t&15)<<28,e=(t&112)>>4,!(t&128))return this.assertBounds(),[i,e];for(let n=3;n<=31;n+=7){let r=this.buf[this.pos++];if(e|=(r&127)<<n,!(r&128))return this.assertBounds(),[i,e]}throw new Error("invalid varint")}function ot(i,e,t){for(let s=0;s<28;s=s+7){const o=i>>>s,a=!(!(o>>>7)&&e==0),l=(a?o|128:o)&255;if(t.push(l),!a)return}const n=i>>>28&15|(e&7)<<4,r=!!(e>>3);if(t.push((r?n|128:n)&255),!!r){for(let s=3;s<31;s=s+7){const o=e>>>s,a=!!(o>>>7),l=(a?o|128:o)&255;if(t.push(l),!a)return}t.push(e>>>31&1)}}const Je=65536*65536;function It(i){let e=i[0]=="-";e&&(i=i.slice(1));const t=1e6;let n=0,r=0;function s(o,a){const l=Number(i.slice(o,a));r*=t,n=n*t+l,n>=Je&&(r=r+(n/Je|0),n=n%Je)}return s(-24,-18),s(-18,-12),s(-12,-6),s(-6),[e,n,r]}function at(i,e){if(e>>>0<=2097151)return""+(Je*e+(i>>>0));let t=i&16777215,n=(i>>>24|e<<8)>>>0&16777215,r=e>>16&65535,s=t+n*6777216+r*6710656,o=n+r*8147497,a=r*2,l=1e7;s>=l&&(o+=Math.floor(s/l),s%=l),o>=l&&(a+=Math.floor(o/l),o%=l);function c(h,g){let w=h?String(h):"";return g?"0000000".slice(w.length)+w:w}return c(a,0)+c(o,a)+c(s,1)}function Ft(i,e){if(i>=0){for(;i>127;)e.push(i&127|128),i=i>>>7;e.push(i)}else{for(let t=0;t<9;t++)e.push(i&127|128),i=i>>7;e.push(1)}}function bn(){let i=this.buf[this.pos++],e=i&127;if(!(i&128))return this.assertBounds(),e;if(i=this.buf[this.pos++],e|=(i&127)<<7,!(i&128))return this.assertBounds(),e;if(i=this.buf[this.pos++],e|=(i&127)<<14,!(i&128))return this.assertBounds(),e;if(i=this.buf[this.pos++],e|=(i&127)<<21,!(i&128))return this.assertBounds(),e;i=this.buf[this.pos++],e|=(i&15)<<28;for(let t=5;i&128&&t<10;t++)i=this.buf[this.pos++];if(i&128)throw new Error("invalid varint");return this.assertBounds(),e>>>0}let T;function yn(){const i=new DataView(new ArrayBuffer(8));T=globalThis.BigInt!==void 0&&typeof i.getBigInt64=="function"&&typeof i.getBigUint64=="function"&&typeof i.setBigInt64=="function"&&typeof i.setBigUint64=="function"?{MIN:BigInt("-9223372036854775808"),MAX:BigInt("9223372036854775807"),UMIN:BigInt("0"),UMAX:BigInt("18446744073709551615"),C:BigInt,V:i}:void 0}yn();function At(i){if(!i)throw new Error("BigInt unavailable, see https://github.com/timostamm/protobuf-ts/blob/v1.0.8/MANUAL.md#bigint-support")}const Tt=/^-?[0-9]+$/,Ye=4294967296,ze=2147483648;class Bt{constructor(e,t){this.lo=e|0,this.hi=t|0}isZero(){return this.lo==0&&this.hi==0}toNumber(){let e=this.hi*Ye+(this.lo>>>0);if(!Number.isSafeInteger(e))throw new Error("cannot convert to safe number");return e}}class $ extends Bt{static from(e){if(T)switch(typeof e){case"string":if(e=="0")return this.ZERO;if(e=="")throw new Error("string is no integer");e=T.C(e);case"number":if(e===0)return this.ZERO;e=T.C(e);case"bigint":if(!e)return this.ZERO;if(e<T.UMIN)throw new Error("signed value for ulong");if(e>T.UMAX)throw new Error("ulong too large");return T.V.setBigUint64(0,e,!0),new $(T.V.getInt32(0,!0),T.V.getInt32(4,!0))}else switch(typeof e){case"string":if(e=="0")return this.ZERO;if(e=e.trim(),!Tt.test(e))throw new Error("string is no integer");let[t,n,r]=It(e);if(t)throw new Error("signed value for ulong");return new $(n,r);case"number":if(e==0)return this.ZERO;if(!Number.isSafeInteger(e))throw new Error("number is no integer");if(e<0)throw new Error("signed value for ulong");return new $(e,e/Ye)}throw new Error("unknown value "+typeof e)}toString(){return T?this.toBigInt().toString():at(this.lo,this.hi)}toBigInt(){return At(T),T.V.setInt32(0,this.lo,!0),T.V.setInt32(4,this.hi,!0),T.V.getBigUint64(0,!0)}}$.ZERO=new $(0,0);class x extends Bt{static from(e){if(T)switch(typeof e){case"string":if(e=="0")return this.ZERO;if(e=="")throw new Error("string is no integer");e=T.C(e);case"number":if(e===0)return this.ZERO;e=T.C(e);case"bigint":if(!e)return this.ZERO;if(e<T.MIN)throw new Error("signed long too small");if(e>T.MAX)throw new Error("signed long too large");return T.V.setBigInt64(0,e,!0),new x(T.V.getInt32(0,!0),T.V.getInt32(4,!0))}else switch(typeof e){case"string":if(e=="0")return this.ZERO;if(e=e.trim(),!Tt.test(e))throw new Error("string is no integer");let[t,n,r]=It(e);if(t){if(r>ze||r==ze&&n!=0)throw new Error("signed long too small")}else if(r>=ze)throw new Error("signed long too large");let s=new x(n,r);return t?s.negate():s;case"number":if(e==0)return this.ZERO;if(!Number.isSafeInteger(e))throw new Error("number is no integer");return e>0?new x(e,e/Ye):new x(-e,-e/Ye).negate()}throw new Error("unknown value "+typeof e)}isNegative(){return(this.hi&ze)!==0}negate(){let e=~this.hi,t=this.lo;return t?t=~t+1:e+=1,new x(t,e)}toString(){if(T)return this.toBigInt().toString();if(this.isNegative()){let e=this.negate();return"-"+at(e.lo,e.hi)}return at(this.lo,this.hi)}toBigInt(){return At(T),T.V.setInt32(0,this.lo,!0),T.V.setInt32(4,this.hi,!0),T.V.getBigInt64(0,!0)}}x.ZERO=new x(0,0);const vt={readUnknownField:!0,readerFactory:i=>new En(i)};function Cn(i){return i?Object.assign(Object.assign({},vt),i):vt}class En{constructor(e,t){this.varint64=wn,this.uint32=bn,this.buf=e,this.len=e.length,this.pos=0,this.view=new DataView(e.buffer,e.byteOffset,e.byteLength),this.textDecoder=t??new TextDecoder("utf-8",{fatal:!0,ignoreBOM:!0})}tag(){let e=this.uint32(),t=e>>>3,n=e&7;if(t<=0||n<0||n>5)throw new Error("illegal tag: field no "+t+" wire type "+n);return[t,n]}skip(e){let t=this.pos;switch(e){case m.Varint:for(;this.buf[this.pos++]&128;);break;case m.Bit64:this.pos+=4;case m.Bit32:this.pos+=4;break;case m.LengthDelimited:let n=this.uint32();this.pos+=n;break;case m.StartGroup:let r;for(;(r=this.tag()[1])!==m.EndGroup;)this.skip(r);break;default:throw new Error("cant skip wire type "+e)}return this.assertBounds(),this.buf.subarray(t,this.pos)}assertBounds(){if(this.pos>this.len)throw new RangeError("premature EOF")}int32(){return this.uint32()|0}sint32(){let e=this.uint32();return e>>>1^-(e&1)}int64(){return new x(...this.varint64())}uint64(){return new $(...this.varint64())}sint64(){let[e,t]=this.varint64(),n=-(e&1);return e=(e>>>1|(t&1)<<31)^n,t=t>>>1^n,new x(e,t)}bool(){let[e,t]=this.varint64();return e!==0||t!==0}fixed32(){return this.view.getUint32((this.pos+=4)-4,!0)}sfixed32(){return this.view.getInt32((this.pos+=4)-4,!0)}fixed64(){return new $(this.sfixed32(),this.sfixed32())}sfixed64(){return new x(this.sfixed32(),this.sfixed32())}float(){return this.view.getFloat32((this.pos+=4)-4,!0)}double(){return this.view.getFloat64((this.pos+=8)-8,!0)}bytes(){let e=this.uint32(),t=this.pos;return this.pos+=e,this.assertBounds(),this.buf.subarray(t,t+e)}string(){return this.textDecoder.decode(this.bytes())}}function E(i,e){if(!i)throw new Error(e)}const Nn=34028234663852886e22,kn=-34028234663852886e22,Ln=4294967295,In=2147483647,Fn=-2147483648;function Re(i){if(typeof i!="number")throw new Error("invalid int 32: "+typeof i);if(!Number.isInteger(i)||i>In||i<Fn)throw new Error("invalid int 32: "+i)}function Qe(i){if(typeof i!="number")throw new Error("invalid uint 32: "+typeof i);if(!Number.isInteger(i)||i>Ln||i<0)throw new Error("invalid uint 32: "+i)}function lt(i){if(typeof i!="number")throw new Error("invalid float 32: "+typeof i);if(Number.isFinite(i)&&(i>Nn||i<kn))throw new Error("invalid float 32: "+i)}const _t={writeUnknownFields:!0,writerFactory:()=>new Tn};function An(i){return i?Object.assign(Object.assign({},_t),i):_t}class Tn{constructor(e){this.stack=[],this.textEncoder=e??new TextEncoder,this.chunks=[],this.buf=[]}finish(){this.chunks.push(new Uint8Array(this.buf));let e=0;for(let r=0;r<this.chunks.length;r++)e+=this.chunks[r].length;let t=new Uint8Array(e),n=0;for(let r=0;r<this.chunks.length;r++)t.set(this.chunks[r],n),n+=this.chunks[r].length;return this.chunks=[],t}fork(){return this.stack.push({chunks:this.chunks,buf:this.buf}),this.chunks=[],this.buf=[],this}join(){let e=this.finish(),t=this.stack.pop();if(!t)throw new Error("invalid state, fork stack empty");return this.chunks=t.chunks,this.buf=t.buf,this.uint32(e.byteLength),this.raw(e)}tag(e,t){return this.uint32((e<<3|t)>>>0)}raw(e){return this.buf.length&&(this.chunks.push(new Uint8Array(this.buf)),this.buf=[]),this.chunks.push(e),this}uint32(e){for(Qe(e);e>127;)this.buf.push(e&127|128),e=e>>>7;return this.buf.push(e),this}int32(e){return Re(e),Ft(e,this.buf),this}bool(e){return this.buf.push(e?1:0),this}bytes(e){return this.uint32(e.byteLength),this.raw(e)}string(e){let t=this.textEncoder.encode(e);return this.uint32(t.byteLength),this.raw(t)}float(e){lt(e);let t=new Uint8Array(4);return new DataView(t.buffer).setFloat32(0,e,!0),this.raw(t)}double(e){let t=new Uint8Array(8);return new DataView(t.buffer).setFloat64(0,e,!0),this.raw(t)}fixed32(e){Qe(e);let t=new Uint8Array(4);return new DataView(t.buffer).setUint32(0,e,!0),this.raw(t)}sfixed32(e){Re(e);let t=new Uint8Array(4);return new DataView(t.buffer).setInt32(0,e,!0),this.raw(t)}sint32(e){return Re(e),e=(e<<1^e>>31)>>>0,Ft(e,this.buf),this}sfixed64(e){let t=new Uint8Array(8),n=new DataView(t.buffer),r=x.from(e);return n.setInt32(0,r.lo,!0),n.setInt32(4,r.hi,!0),this.raw(t)}fixed64(e){let t=new Uint8Array(8),n=new DataView(t.buffer),r=$.from(e);return n.setInt32(0,r.lo,!0),n.setInt32(4,r.hi,!0),this.raw(t)}int64(e){let t=x.from(e);return ot(t.lo,t.hi,this.buf),this}sint64(e){let t=x.from(e),n=t.hi>>31,r=t.lo<<1^n,s=(t.hi<<1|t.lo>>>31)^n;return ot(r,s,this.buf),this}uint64(e){let t=$.from(e);return ot(t.lo,t.hi,this.buf),this}}const Ot={emitDefaultValues:!1,enumAsInteger:!1,useProtoFieldName:!1,prettySpaces:0},xt={ignoreUnknownFields:!1};function Bn(i){return i?Object.assign(Object.assign({},xt),i):xt}function vn(i){return i?Object.assign(Object.assign({},Ot),i):Ot}function _n(i,e){var t,n;let r=Object.assign(Object.assign({},i),e);return r.typeRegistry=[...(t=i==null?void 0:i.typeRegistry)!==null&&t!==void 0?t:[],...(n=e==null?void 0:e.typeRegistry)!==null&&n!==void 0?n:[]],r}const Dt=Symbol.for("protobuf-ts/message-type");function ct(i){let e=!1;const t=[];for(let n=0;n<i.length;n++){let r=i.charAt(n);r=="_"?e=!0:/\d/.test(r)?(t.push(r),e=!0):e?(t.push(r.toUpperCase()),e=!1):n==0?t.push(r.toLowerCase()):t.push(r)}return t.join("")}var u;(function(i){i[i.DOUBLE=1]="DOUBLE",i[i.FLOAT=2]="FLOAT",i[i.INT64=3]="INT64",i[i.UINT64=4]="UINT64",i[i.INT32=5]="INT32",i[i.FIXED64=6]="FIXED64",i[i.FIXED32=7]="FIXED32",i[i.BOOL=8]="BOOL",i[i.STRING=9]="STRING",i[i.BYTES=12]="BYTES",i[i.UINT32=13]="UINT32",i[i.SFIXED32=15]="SFIXED32",i[i.SFIXED64=16]="SFIXED64",i[i.SINT32=17]="SINT32",i[i.SINT64=18]="SINT64"})(u||(u={}));var oe;(function(i){i[i.BIGINT=0]="BIGINT",i[i.STRING=1]="STRING",i[i.NUMBER=2]="NUMBER"})(oe||(oe={}));var et;(function(i){i[i.NO=0]="NO",i[i.PACKED=1]="PACKED",i[i.UNPACKED=2]="UNPACKED"})(et||(et={}));function On(i){var e,t,n,r;return i.localName=(e=i.localName)!==null&&e!==void 0?e:ct(i.name),i.jsonName=(t=i.jsonName)!==null&&t!==void 0?t:ct(i.name),i.repeat=(n=i.repeat)!==null&&n!==void 0?n:et.NO,i.opt=(r=i.opt)!==null&&r!==void 0?r:i.repeat||i.oneof?!1:i.kind=="message",i}function xn(i){if(typeof i!="object"||i===null||!i.hasOwnProperty("oneofKind"))return!1;switch(typeof i.oneofKind){case"string":return i[i.oneofKind]===void 0?!1:Object.keys(i).length==2;case"undefined":return Object.keys(i).length==1;default:return!1}}class Dn{constructor(e){var t;this.fields=(t=e.fields)!==null&&t!==void 0?t:[]}prepare(){if(this.data)return;const e=[],t=[],n=[];for(let r of this.fields)if(r.oneof)n.includes(r.oneof)||(n.push(r.oneof),e.push(r.oneof),t.push(r.oneof));else switch(t.push(r.localName),r.kind){case"scalar":case"enum":(!r.opt||r.repeat)&&e.push(r.localName);break;case"message":r.repeat&&e.push(r.localName);break;case"map":e.push(r.localName);break}this.data={req:e,known:t,oneofs:Object.values(n)}}is(e,t,n=!1){if(t<0)return!0;if(e==null||typeof e!="object")return!1;this.prepare();let r=Object.keys(e),s=this.data;if(r.length<s.req.length||s.req.some(o=>!r.includes(o))||!n&&r.some(o=>!s.known.includes(o)))return!1;if(t<1)return!0;for(const o of s.oneofs){const a=e[o];if(!xn(a))return!1;if(a.oneofKind===void 0)continue;const l=this.fields.find(c=>c.localName===a.oneofKind);if(!l||!this.field(a[a.oneofKind],l,n,t))return!1}for(const o of this.fields)if(o.oneof===void 0&&!this.field(e[o.localName],o,n,t))return!1;return!0}field(e,t,n,r){let s=t.repeat;switch(t.kind){case"scalar":return e===void 0?t.opt:s?this.scalars(e,t.T,r,t.L):this.scalar(e,t.T,t.L);case"enum":return e===void 0?t.opt:s?this.scalars(e,u.INT32,r):this.scalar(e,u.INT32);case"message":return e===void 0?!0:s?this.messages(e,t.T(),n,r):this.message(e,t.T(),n,r);case"map":if(typeof e!="object"||e===null)return!1;if(r<2)return!0;if(!this.mapKeys(e,t.K,r))return!1;switch(t.V.kind){case"scalar":return this.scalars(Object.values(e),t.V.T,r,t.V.L);case"enum":return this.scalars(Object.values(e),u.INT32,r);case"message":return this.messages(Object.values(e),t.V.T(),n,r)}break}return!0}message(e,t,n,r){return n?t.isAssignable(e,r):t.is(e,r)}messages(e,t,n,r){if(!Array.isArray(e))return!1;if(r<2)return!0;if(n){for(let s=0;s<e.length&&s<r;s++)if(!t.isAssignable(e[s],r-1))return!1}else for(let s=0;s<e.length&&s<r;s++)if(!t.is(e[s],r-1))return!1;return!0}scalar(e,t,n){let r=typeof e;switch(t){case u.UINT64:case u.FIXED64:case u.INT64:case u.SFIXED64:case u.SINT64:switch(n){case oe.BIGINT:return r=="bigint";case oe.NUMBER:return r=="number"&&!isNaN(e);default:return r=="string"}case u.BOOL:return r=="boolean";case u.STRING:return r=="string";case u.BYTES:return e instanceof Uint8Array;case u.DOUBLE:case u.FLOAT:return r=="number"&&!isNaN(e);default:return r=="number"&&Number.isInteger(e)}}scalars(e,t,n,r){if(!Array.isArray(e))return!1;if(n<2)return!0;if(Array.isArray(e)){for(let s=0;s<e.length&&s<n;s++)if(!this.scalar(e[s],t,r))return!1}return!0}mapKeys(e,t,n){let r=Object.keys(e);switch(t){case u.INT32:case u.FIXED32:case u.SFIXED32:case u.SINT32:case u.UINT32:return this.scalars(r.slice(0,n).map(s=>parseInt(s)),t,n);case u.BOOL:return this.scalars(r.slice(0,n).map(s=>s=="true"?!0:s=="false"?!1:s),t,n);default:return this.scalars(r,t,n,oe.STRING)}}}function te(i,e){switch(e){case oe.BIGINT:return i.toBigInt();case oe.NUMBER:return i.toNumber();default:return i.toString()}}class Sn{constructor(e){this.info=e}prepare(){var e;if(this.fMap===void 0){this.fMap={};const t=(e=this.info.fields)!==null&&e!==void 0?e:[];for(const n of t)this.fMap[n.name]=n,this.fMap[n.jsonName]=n,this.fMap[n.localName]=n}}assert(e,t,n){if(!e){let r=Nt(n);throw(r=="number"||r=="boolean")&&(r=n.toString()),new Error(`Cannot parse JSON ${r} for ${this.info.typeName}#${t}`)}}read(e,t,n){this.prepare();const r=[];for(const[s,o]of Object.entries(e)){const a=this.fMap[s];if(!a){if(!n.ignoreUnknownFields)throw new Error(`Found unknown field while reading ${this.info.typeName} from JSON format. JSON key: ${s}`);continue}const l=a.localName;let c;if(a.oneof){if(o===null&&(a.kind!=="enum"||a.T()[0]!=="google.protobuf.NullValue"))continue;if(r.includes(a.oneof))throw new Error(`Multiple members of the oneof group "${a.oneof}" of ${this.info.typeName} are present in JSON.`);r.push(a.oneof),c=t[a.oneof]={oneofKind:l}}else c=t;if(a.kind=="map"){if(o===null)continue;this.assert(mn(o),a.name,o);const h=c[l];for(const[g,w]of Object.entries(o)){this.assert(w!==null,a.name+" map value",null);let F;switch(a.V.kind){case"message":F=a.V.T().internalJsonRead(w,n);break;case"enum":if(F=this.enum(a.V.T(),w,a.name,n.ignoreUnknownFields),F===!1)continue;break;case"scalar":F=this.scalar(w,a.V.T,a.V.L,a.name);break}this.assert(F!==void 0,a.name+" map value",w);let v=g;a.K==u.BOOL&&(v=v=="true"?!0:v=="false"?!1:v),v=this.scalar(v,a.K,oe.STRING,a.name).toString(),h[v]=F}}else if(a.repeat){if(o===null)continue;this.assert(Array.isArray(o),a.name,o);const h=c[l];for(const g of o){this.assert(g!==null,a.name,null);let w;switch(a.kind){case"message":w=a.T().internalJsonRead(g,n);break;case"enum":if(w=this.enum(a.T(),g,a.name,n.ignoreUnknownFields),w===!1)continue;break;case"scalar":w=this.scalar(g,a.T,a.L,a.name);break}this.assert(w!==void 0,a.name,o),h.push(w)}}else switch(a.kind){case"message":if(o===null&&a.T().typeName!="google.protobuf.Value"){this.assert(a.oneof===void 0,a.name+" (oneof member)",null);continue}c[l]=a.T().internalJsonRead(o,n,c[l]);break;case"enum":let h=this.enum(a.T(),o,a.name,n.ignoreUnknownFields);if(h===!1)continue;c[l]=h;break;case"scalar":c[l]=this.scalar(o,a.T,a.L,a.name);break}}}enum(e,t,n,r){if(e[0]=="google.protobuf.NullValue"&&E(t===null||t==="NULL_VALUE",`Unable to parse field ${this.info.typeName}#${n}, enum ${e[0]} only accepts null.`),t===null)return 0;switch(typeof t){case"number":return E(Number.isInteger(t),`Unable to parse field ${this.info.typeName}#${n}, enum can only be integral number, got ${t}.`),t;case"string":let s=t;e[2]&&t.substring(0,e[2].length)===e[2]&&(s=t.substring(e[2].length));let o=e[1][s];return typeof o>"u"&&r?!1:(E(typeof o=="number",`Unable to parse field ${this.info.typeName}#${n}, enum ${e[0]} has no value for "${t}".`),o)}E(!1,`Unable to parse field ${this.info.typeName}#${n}, cannot parse enum value from ${typeof t}".`)}scalar(e,t,n,r){let s;try{switch(t){case u.DOUBLE:case u.FLOAT:if(e===null)return 0;if(e==="NaN")return Number.NaN;if(e==="Infinity")return Number.POSITIVE_INFINITY;if(e==="-Infinity")return Number.NEGATIVE_INFINITY;if(e===""){s="empty string";break}if(typeof e=="string"&&e.trim().length!==e.length){s="extra whitespace";break}if(typeof e!="string"&&typeof e!="number")break;let o=Number(e);if(Number.isNaN(o)){s="not a number";break}if(!Number.isFinite(o)){s="too large or small";break}return t==u.FLOAT&&lt(o),o;case u.INT32:case u.FIXED32:case u.SFIXED32:case u.SINT32:case u.UINT32:if(e===null)return 0;let a;if(typeof e=="number"?a=e:e===""?s="empty string":typeof e=="string"&&(e.trim().length!==e.length?s="extra whitespace":a=Number(e)),a===void 0)break;return t==u.UINT32?Qe(a):Re(a),a;case u.INT64:case u.SFIXED64:case u.SINT64:if(e===null)return te(x.ZERO,n);if(typeof e!="number"&&typeof e!="string")break;return te(x.from(e),n);case u.FIXED64:case u.UINT64:if(e===null)return te($.ZERO,n);if(typeof e!="number"&&typeof e!="string")break;return te($.from(e),n);case u.BOOL:if(e===null)return!1;if(typeof e!="boolean")break;return e;case u.STRING:if(e===null)return"";if(typeof e!="string"){s="extra whitespace";break}try{encodeURIComponent(e)}catch(l){l="invalid UTF8";break}return e;case u.BYTES:if(e===null||e==="")return new Uint8Array(0);if(typeof e!="string")break;return kt(e)}}catch(o){s=o.message}this.assert(!1,r+(s?" - "+s:""),e)}}class Un{constructor(e){var t;this.fields=(t=e.fields)!==null&&t!==void 0?t:[]}write(e,t){const n={},r=e;for(const s of this.fields){if(!s.oneof){let c=this.field(s,r[s.localName],t);c!==void 0&&(n[t.useProtoFieldName?s.name:s.jsonName]=c);continue}const o=r[s.oneof];if(o.oneofKind!==s.localName)continue;const a=s.kind=="scalar"||s.kind=="enum"?Object.assign(Object.assign({},t),{emitDefaultValues:!0}):t;let l=this.field(s,o[s.localName],a);E(l!==void 0),n[t.useProtoFieldName?s.name:s.jsonName]=l}return n}field(e,t,n){let r;if(e.kind=="map"){E(typeof t=="object"&&t!==null);const s={};switch(e.V.kind){case"scalar":for(const[l,c]of Object.entries(t)){const h=this.scalar(e.V.T,c,e.name,!1,!0);E(h!==void 0),s[l.toString()]=h}break;case"message":const o=e.V.T();for(const[l,c]of Object.entries(t)){const h=this.message(o,c,e.name,n);E(h!==void 0),s[l.toString()]=h}break;case"enum":const a=e.V.T();for(const[l,c]of Object.entries(t)){E(c===void 0||typeof c=="number");const h=this.enum(a,c,e.name,!1,!0,n.enumAsInteger);E(h!==void 0),s[l.toString()]=h}break}(n.emitDefaultValues||Object.keys(s).length>0)&&(r=s)}else if(e.repeat){E(Array.isArray(t));const s=[];switch(e.kind){case"scalar":for(let l=0;l<t.length;l++){const c=this.scalar(e.T,t[l],e.name,e.opt,!0);E(c!==void 0),s.push(c)}break;case"enum":const o=e.T();for(let l=0;l<t.length;l++){E(t[l]===void 0||typeof t[l]=="number");const c=this.enum(o,t[l],e.name,e.opt,!0,n.enumAsInteger);E(c!==void 0),s.push(c)}break;case"message":const a=e.T();for(let l=0;l<t.length;l++){const c=this.message(a,t[l],e.name,n);E(c!==void 0),s.push(c)}break}(n.emitDefaultValues||s.length>0||n.emitDefaultValues)&&(r=s)}else switch(e.kind){case"scalar":r=this.scalar(e.T,t,e.name,e.opt,n.emitDefaultValues);break;case"enum":r=this.enum(e.T(),t,e.name,e.opt,n.emitDefaultValues,n.enumAsInteger);break;case"message":r=this.message(e.T(),t,e.name,n);break}return r}enum(e,t,n,r,s,o){if(e[0]=="google.protobuf.NullValue")return!s&&!r?void 0:null;if(t===void 0){E(r);return}if(!(t===0&&!s&&!r))return E(typeof t=="number"),E(Number.isInteger(t)),o||!e[1].hasOwnProperty(t)?t:e[2]?e[2]+e[1][t]:e[1][t]}message(e,t,n,r){return t===void 0?r.emitDefaultValues?null:void 0:e.internalJsonWrite(t,r)}scalar(e,t,n,r,s){if(t===void 0){E(r);return}const o=s||r;switch(e){case u.INT32:case u.SFIXED32:case u.SINT32:return t===0?o?0:void 0:(Re(t),t);case u.FIXED32:case u.UINT32:return t===0?o?0:void 0:(Qe(t),t);case u.FLOAT:lt(t);case u.DOUBLE:return t===0?o?0:void 0:(E(typeof t=="number"),Number.isNaN(t)?"NaN":t===Number.POSITIVE_INFINITY?"Infinity":t===Number.NEGATIVE_INFINITY?"-Infinity":t);case u.STRING:return t===""?o?"":void 0:(E(typeof t=="string"),t);case u.BOOL:return t===!1?o?!1:void 0:(E(typeof t=="boolean"),t);case u.UINT64:case u.FIXED64:E(typeof t=="number"||typeof t=="string"||typeof t=="bigint");let a=$.from(t);return a.isZero()&&!o?void 0:a.toString();case u.INT64:case u.SFIXED64:case u.SINT64:E(typeof t=="number"||typeof t=="string"||typeof t=="bigint");let l=x.from(t);return l.isZero()&&!o?void 0:l.toString();case u.BYTES:return E(t instanceof Uint8Array),t.byteLength?Lt(t):o?"":void 0}}}function dt(i,e=oe.STRING){switch(i){case u.BOOL:return!1;case u.UINT64:case u.FIXED64:return te($.ZERO,e);case u.INT64:case u.SFIXED64:case u.SINT64:return te(x.ZERO,e);case u.DOUBLE:case u.FLOAT:return 0;case u.BYTES:return new Uint8Array(0);case u.STRING:return"";default:return 0}}class Rn{constructor(e){this.info=e}prepare(){var e;if(!this.fieldNoToField){const t=(e=this.info.fields)!==null&&e!==void 0?e:[];this.fieldNoToField=new Map(t.map(n=>[n.no,n]))}}read(e,t,n,r){this.prepare();const s=r===void 0?e.len:e.pos+r;for(;e.pos<s;){const[o,a]=e.tag(),l=this.fieldNoToField.get(o);if(!l){let w=n.readUnknownField;if(w=="throw")throw new Error(`Unknown field ${o} (wire type ${a}) for ${this.info.typeName}`);let F=e.skip(a);w!==!1&&(w===!0?N.onRead:w)(this.info.typeName,t,o,a,F);continue}let c=t,h=l.repeat,g=l.localName;switch(l.oneof&&(c=c[l.oneof],c.oneofKind!==g&&(c=t[l.oneof]={oneofKind:g})),l.kind){case"scalar":case"enum":let w=l.kind=="enum"?u.INT32:l.T,F=l.kind=="scalar"?l.L:void 0;if(h){let A=c[g];if(a==m.LengthDelimited&&w!=u.STRING&&w!=u.BYTES){let V=e.uint32()+e.pos;for(;e.pos<V;)A.push(this.scalar(e,w,F))}else A.push(this.scalar(e,w,F))}else c[g]=this.scalar(e,w,F);break;case"message":if(h){let A=c[g],V=l.T().internalBinaryRead(e,e.uint32(),n);A.push(V)}else c[g]=l.T().internalBinaryRead(e,e.uint32(),n,c[g]);break;case"map":let[v,Z]=this.mapEntry(l,e,n);c[g][v]=Z;break}}}mapEntry(e,t,n){let r=t.uint32(),s=t.pos+r,o,a;for(;t.pos<s;){let[l,c]=t.tag();switch(l){case 1:e.K==u.BOOL?o=t.bool().toString():o=this.scalar(t,e.K,oe.STRING);break;case 2:switch(e.V.kind){case"scalar":a=this.scalar(t,e.V.T,e.V.L);break;case"enum":a=t.int32();break;case"message":a=e.V.T().internalBinaryRead(t,t.uint32(),n);break}break;default:throw new Error(`Unknown field ${l} (wire type ${c}) in map entry for ${this.info.typeName}#${e.name}`)}}if(o===void 0){let l=dt(e.K);o=e.K==u.BOOL?l.toString():l}if(a===void 0)switch(e.V.kind){case"scalar":a=dt(e.V.T,e.V.L);break;case"enum":a=0;break;case"message":a=e.V.T().create();break}return[o,a]}scalar(e,t,n){switch(t){case u.INT32:return e.int32();case u.STRING:return e.string();case u.BOOL:return e.bool();case u.DOUBLE:return e.double();case u.FLOAT:return e.float();case u.INT64:return te(e.int64(),n);case u.UINT64:return te(e.uint64(),n);case u.FIXED64:return te(e.fixed64(),n);case u.FIXED32:return e.fixed32();case u.BYTES:return e.bytes();case u.UINT32:return e.uint32();case u.SFIXED32:return e.sfixed32();case u.SFIXED64:return te(e.sfixed64(),n);case u.SINT32:return e.sint32();case u.SINT64:return te(e.sint64(),n)}}}class Mn{constructor(e){this.info=e}prepare(){if(!this.fields){const e=this.info.fields?this.info.fields.concat():[];this.fields=e.sort((t,n)=>t.no-n.no)}}write(e,t,n){this.prepare();for(const s of this.fields){let o,a,l=s.repeat,c=s.localName;if(s.oneof){const h=e[s.oneof];if(h.oneofKind!==c)continue;o=h[c],a=!0}else o=e[c],a=!1;switch(s.kind){case"scalar":case"enum":let h=s.kind=="enum"?u.INT32:s.T;if(l)if(E(Array.isArray(o)),l==et.PACKED)this.packed(t,h,s.no,o);else for(const g of o)this.scalar(t,h,s.no,g,!0);else o===void 0?E(s.opt):this.scalar(t,h,s.no,o,a||s.opt);break;case"message":if(l){E(Array.isArray(o));for(const g of o)this.message(t,n,s.T(),s.no,g)}else this.message(t,n,s.T(),s.no,o);break;case"map":E(typeof o=="object"&&o!==null);for(const[g,w]of Object.entries(o))this.mapEntry(t,n,s,g,w);break}}let r=n.writeUnknownFields;r!==!1&&(r===!0?N.onWrite:r)(this.info.typeName,e,t)}mapEntry(e,t,n,r,s){e.tag(n.no,m.LengthDelimited),e.fork();let o=r;switch(n.K){case u.INT32:case u.FIXED32:case u.UINT32:case u.SFIXED32:case u.SINT32:o=Number.parseInt(r);break;case u.BOOL:E(r=="true"||r=="false"),o=r=="true";break}switch(this.scalar(e,n.K,1,o,!0),n.V.kind){case"scalar":this.scalar(e,n.V.T,2,s,!0);break;case"enum":this.scalar(e,u.INT32,2,s,!0);break;case"message":this.message(e,t,n.V.T(),2,s);break}e.join()}message(e,t,n,r,s){s!==void 0&&(n.internalBinaryWrite(s,e.tag(r,m.LengthDelimited).fork(),t),e.join())}scalar(e,t,n,r,s){let[o,a,l]=this.scalarInfo(t,r);(!l||s)&&(e.tag(n,o),e[a](r))}packed(e,t,n,r){if(!r.length)return;E(t!==u.BYTES&&t!==u.STRING),e.tag(n,m.LengthDelimited),e.fork();let[,s]=this.scalarInfo(t);for(let o=0;o<r.length;o++)e[s](r[o]);e.join()}scalarInfo(e,t){let n=m.Varint,r,s=t===void 0,o=t===0;switch(e){case u.INT32:r="int32";break;case u.STRING:o=s||!t.length,n=m.LengthDelimited,r="string";break;case u.BOOL:o=t===!1,r="bool";break;case u.UINT32:r="uint32";break;case u.DOUBLE:n=m.Bit64,r="double";break;case u.FLOAT:n=m.Bit32,r="float";break;case u.INT64:o=s||x.from(t).isZero(),r="int64";break;case u.UINT64:o=s||$.from(t).isZero(),r="uint64";break;case u.FIXED64:o=s||$.from(t).isZero(),n=m.Bit64,r="fixed64";break;case u.BYTES:o=s||!t.byteLength,n=m.LengthDelimited,r="bytes";break;case u.FIXED32:n=m.Bit32,r="fixed32";break;case u.SFIXED32:n=m.Bit32,r="sfixed32";break;case u.SFIXED64:o=s||x.from(t).isZero(),n=m.Bit64,r="sfixed64";break;case u.SINT32:r="sint32";break;case u.SINT64:o=s||x.from(t).isZero(),r="sint64";break}return[n,r,s||o]}}function Vn(i){const e=i.messagePrototype?Object.create(i.messagePrototype):Object.defineProperty({},Dt,{value:i});for(let t of i.fields){let n=t.localName;if(!t.opt)if(t.oneof)e[t.oneof]={oneofKind:void 0};else if(t.repeat)e[n]=[];else switch(t.kind){case"scalar":e[n]=dt(t.T,t.L);break;case"enum":e[n]=0;break;case"map":e[n]={};break}}return e}function U(i,e,t){let n,r=t,s;for(let o of i.fields){let a=o.localName;if(o.oneof){const l=r[o.oneof];if((l==null?void 0:l.oneofKind)==null)continue;if(n=l[a],s=e[o.oneof],s.oneofKind=l.oneofKind,n==null){delete s[a];continue}}else if(n=r[a],s=e,n==null)continue;switch(o.repeat&&(s[a].length=n.length),o.kind){case"scalar":case"enum":if(o.repeat)for(let c=0;c<n.length;c++)s[a][c]=n[c];else s[a]=n;break;case"message":let l=o.T();if(o.repeat)for(let c=0;c<n.length;c++)s[a][c]=l.create(n[c]);else s[a]===void 0?s[a]=l.create(n):l.mergePartial(s[a],n);break;case"map":switch(o.V.kind){case"scalar":case"enum":Object.assign(s[a],n);break;case"message":let c=o.V.T();for(let h of Object.keys(n))s[a][h]=c.create(n[h]);break}break}}}function Hn(i,e,t){if(e===t)return!0;if(!e||!t)return!1;for(let n of i.fields){let r=n.localName,s=n.oneof?e[n.oneof][r]:e[r],o=n.oneof?t[n.oneof][r]:t[r];switch(n.kind){case"enum":case"scalar":let a=n.kind=="enum"?u.INT32:n.T;if(!(n.repeat?Ut(a,s,o):St(a,s,o)))return!1;break;case"map":if(!(n.V.kind=="message"?Rt(n.V.T(),tt(s),tt(o)):Ut(n.V.kind=="enum"?u.INT32:n.V.T,tt(s),tt(o))))return!1;break;case"message":let l=n.T();if(!(n.repeat?Rt(l,s,o):l.equals(s,o)))return!1;break}}return!0}const tt=Object.values;function St(i,e,t){if(e===t)return!0;if(i!==u.BYTES)return!1;let n=e,r=t;if(n.length!==r.length)return!1;for(let s=0;s<n.length;s++)if(n[s]!=r[s])return!1;return!0}function Ut(i,e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(!St(i,e[n],t[n]))return!1;return!0}function Rt(i,e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(!i.equals(e[n],t[n]))return!1;return!0}const $n=Object.getOwnPropertyDescriptors(Object.getPrototypeOf({}));class j{constructor(e,t,n){this.defaultCheckDepth=16,this.typeName=e,this.fields=t.map(On),this.options=n??{},this.messagePrototype=Object.create(null,Object.assign(Object.assign({},$n),{[Dt]:{value:this}})),this.refTypeCheck=new Dn(this),this.refJsonReader=new Sn(this),this.refJsonWriter=new Un(this),this.refBinReader=new Rn(this),this.refBinWriter=new Mn(this)}create(e){let t=Vn(this);return e!==void 0&&U(this,t,e),t}clone(e){let t=this.create();return U(this,t,e),t}equals(e,t){return Hn(this,e,t)}is(e,t=this.defaultCheckDepth){return this.refTypeCheck.is(e,t,!1)}isAssignable(e,t=this.defaultCheckDepth){return this.refTypeCheck.is(e,t,!0)}mergePartial(e,t){U(this,e,t)}fromBinary(e,t){let n=Cn(t);return this.internalBinaryRead(n.readerFactory(e),e.byteLength,n)}fromJson(e,t){return this.internalJsonRead(e,Bn(t))}fromJsonString(e,t){let n=JSON.parse(e);return this.fromJson(n,t)}toJson(e,t){return this.internalJsonWrite(e,vn(t))}toJsonString(e,t){var n;let r=this.toJson(e,t);return JSON.stringify(r,null,(n=t==null?void 0:t.prettySpaces)!==null&&n!==void 0?n:0)}toBinary(e,t){let n=An(t);return this.internalBinaryWrite(e,n.writerFactory(),n).finish()}internalJsonRead(e,t,n){if(e!==null&&typeof e=="object"&&!Array.isArray(e)){let r=n??this.create();return this.refJsonReader.read(e,r,t),r}throw new Error(`Unable to parse message ${this.typeName} from JSON ${Nt(e)}.`)}internalJsonWrite(e,t){return this.refJsonWriter.write(e,t)}internalBinaryWrite(e,t,n){return this.refBinWriter.write(e,t,n),t}internalBinaryRead(e,t,n,r){let s=r??this.create();return this.refBinReader.read(e,s,n,t),s}}function jn(i,e){var t,n,r;let s=i;return s.service=e,s.localName=(t=s.localName)!==null&&t!==void 0?t:ct(s.name),s.serverStreaming=!!s.serverStreaming,s.clientStreaming=!!s.clientStreaming,s.options=(n=s.options)!==null&&n!==void 0?n:{},s.idempotency=(r=s.idempotency)!==null&&r!==void 0?r:void 0,s}class ht{constructor(e,t,n){this.typeName=e,this.methods=t.map(r=>jn(r,this)),this.options=n??{}}}class B extends Error{constructor(e,t="UNKNOWN",n){super(e),this.name="RpcError",Object.setPrototypeOf(this,new.target.prototype),this.code=t,this.meta=n??{}}toString(){const e=[this.name+": "+this.message];this.code&&(e.push(""),e.push("Code: "+this.code)),this.serviceName&&this.methodName&&e.push("Method: "+this.serviceName+"/"+this.methodName);let t=Object.entries(this.meta);if(t.length){e.push(""),e.push("Meta:");for(let[n,r]of t)e.push(` ${n}: ${r}`)}return e.join(`
4
- `)}}function Pn(i,e){if(!e)return i;let t={};nt(i,t),nt(e,t);for(let n of Object.keys(e)){let r=e[n];switch(n){case"jsonOptions":t.jsonOptions=_n(i.jsonOptions,t.jsonOptions);break;case"binaryOptions":t.binaryOptions=gn(i.binaryOptions,t.binaryOptions);break;case"meta":t.meta={},nt(i.meta,t.meta),nt(e.meta,t.meta);break;case"interceptors":t.interceptors=i.interceptors?i.interceptors.concat(r):r.concat();break}}return t}function nt(i,e){if(!i)return;let t=e;for(let[n,r]of Object.entries(i))r instanceof Date?t[n]=new Date(r.getTime()):Array.isArray(r)?t[n]=r.concat():t[n]=r}var Y;(function(i){i[i.PENDING=0]="PENDING",i[i.REJECTED=1]="REJECTED",i[i.RESOLVED=2]="RESOLVED"})(Y||(Y={}));class ye{constructor(e=!0){this._state=Y.PENDING,this._promise=new Promise((t,n)=>{this._resolve=t,this._reject=n}),e&&this._promise.catch(t=>{})}get state(){return this._state}get promise(){return this._promise}resolve(e){if(this.state!==Y.PENDING)throw new Error(`cannot resolve ${Y[this.state].toLowerCase()}`);this._resolve(e),this._state=Y.RESOLVED}reject(e){if(this.state!==Y.PENDING)throw new Error(`cannot reject ${Y[this.state].toLowerCase()}`);this._reject(e),this._state=Y.REJECTED}resolvePending(e){this._state===Y.PENDING&&this.resolve(e)}rejectPending(e){this._state===Y.PENDING&&this.reject(e)}}class Wn{constructor(){this._lis={nxt:[],msg:[],err:[],cmp:[]},this._closed=!1}onNext(e){return this.addLis(e,this._lis.nxt)}onMessage(e){return this.addLis(e,this._lis.msg)}onError(e){return this.addLis(e,this._lis.err)}onComplete(e){return this.addLis(e,this._lis.cmp)}addLis(e,t){return t.push(e),()=>{let n=t.indexOf(e);n>=0&&t.splice(n,1)}}clearLis(){for(let e of Object.values(this._lis))e.splice(0,e.length)}get closed(){return this._closed!==!1}notifyNext(e,t,n){E((e?1:0)+(t?1:0)+(n?1:0)<=1,"only one emission at a time"),e&&this.notifyMessage(e),t&&this.notifyError(t),n&&this.notifyComplete()}notifyMessage(e){E(!this.closed,"stream is closed"),this.pushIt({value:e,done:!1}),this._lis.msg.forEach(t=>t(e)),this._lis.nxt.forEach(t=>t(e,void 0,!1))}notifyError(e){E(!this.closed,"stream is closed"),this._closed=e,this.pushIt(e),this._lis.err.forEach(t=>t(e)),this._lis.nxt.forEach(t=>t(void 0,e,!1)),this.clearLis()}notifyComplete(){E(!this.closed,"stream is closed"),this._closed=!0,this.pushIt({value:null,done:!0}),this._lis.cmp.forEach(e=>e()),this._lis.nxt.forEach(e=>e(void 0,void 0,!0)),this.clearLis()}[Symbol.asyncIterator](){return this._itState||(this._itState={q:[]}),this._closed===!0?this.pushIt({value:null,done:!0}):this._closed!==!1&&this.pushIt(this._closed),{next:()=>{let e=this._itState;E(e,"bad state"),E(!e.p,"iterator contract broken");let t=e.q.shift();return t?"value"in t?Promise.resolve(t):Promise.reject(t):(e.p=new ye,e.p.promise)}}}pushIt(e){let t=this._itState;if(t)if(t.p){const n=t.p;E(n.state==Y.PENDING,"iterator contract broken"),"value"in e?n.resolve(e):n.reject(e),delete t.p}else t.q.push(e)}}var Zn=function(i,e,t,n){function r(s){return s instanceof t?s:new t(function(o){o(s)})}return new(t||(t=Promise))(function(s,o){function a(h){try{c(n.next(h))}catch(g){o(g)}}function l(h){try{c(n.throw(h))}catch(g){o(g)}}function c(h){h.done?s(h.value):r(h.value).then(a,l)}c((n=n.apply(i,e||[])).next())})};class qn{constructor(e,t,n,r,s,o,a){this.method=e,this.requestHeaders=t,this.request=n,this.headers=r,this.response=s,this.status=o,this.trailers=a}then(e,t){return this.promiseFinished().then(n=>e?Promise.resolve(e(n)):n,n=>t?Promise.resolve(t(n)):Promise.reject(n))}promiseFinished(){return Zn(this,void 0,void 0,function*(){let[e,t,n,r]=yield Promise.all([this.headers,this.response,this.status,this.trailers]);return{method:this.method,requestHeaders:this.requestHeaders,request:this.request,headers:e,response:t,status:n,trailers:r}})}}var Kn=function(i,e,t,n){function r(s){return s instanceof t?s:new t(function(o){o(s)})}return new(t||(t=Promise))(function(s,o){function a(h){try{c(n.next(h))}catch(g){o(g)}}function l(h){try{c(n.throw(h))}catch(g){o(g)}}function c(h){h.done?s(h.value):r(h.value).then(a,l)}c((n=n.apply(i,e||[])).next())})};class Xn{constructor(e,t,n,r,s,o,a){this.method=e,this.requestHeaders=t,this.request=n,this.headers=r,this.responses=s,this.status=o,this.trailers=a}then(e,t){return this.promiseFinished().then(n=>e?Promise.resolve(e(n)):n,n=>t?Promise.resolve(t(n)):Promise.reject(n))}promiseFinished(){return Kn(this,void 0,void 0,function*(){let[e,t,n]=yield Promise.all([this.headers,this.status,this.trailers]);return{method:this.method,requestHeaders:this.requestHeaders,request:this.request,headers:e,status:t,trailers:n}})}}function ae(i,e,t,n,r){var s;{let o=(a,l,c)=>e.unary(a,l,c);for(const a of((s=n.interceptors)!==null&&s!==void 0?s:[]).filter(l=>l.interceptUnary).reverse()){const l=o;o=(c,h,g)=>a.interceptUnary(l,c,h,g)}return o(t,r,n)}}class Gn extends j{constructor(){super("com.hamropatro.grpc.cms.ImageUploadRequest",[])}create(e){const t=globalThis.Object.create(this.messagePrototype);return e!==void 0&&U(this,t,e),t}internalBinaryRead(e,t,n,r){return r??this.create()}internalBinaryWrite(e,t,n){let r=n.writeUnknownFields;return r!==!1&&(r==!0?N.onWrite:r)(this.typeName,e,t),t}}const Mt=new Gn;class Jn extends j{constructor(){super("com.hamropatro.grpc.cms.ImageUploadResponse",[{no:1,name:"key",kind:"scalar",T:9},{no:2,name:"url",kind:"scalar",T:9}])}create(e){const t=globalThis.Object.create(this.messagePrototype);return t.key="",t.url="",e!==void 0&&U(this,t,e),t}internalBinaryRead(e,t,n,r){let s=r??this.create(),o=e.pos+t;for(;e.pos<o;){let[a,l]=e.tag();switch(a){case 1:s.key=e.string();break;case 2:s.url=e.string();break;default:let c=n.readUnknownField;if(c==="throw")throw new globalThis.Error(`Unknown field ${a} (wire type ${l}) for ${this.typeName}`);let h=e.skip(l);c!==!1&&(c===!0?N.onRead:c)(this.typeName,s,a,l,h)}}return s}internalBinaryWrite(e,t,n){e.key!==""&&t.tag(1,m.LengthDelimited).string(e.key),e.url!==""&&t.tag(2,m.LengthDelimited).string(e.url);let r=n.writeUnknownFields;return r!==!1&&(r==!0?N.onWrite:r)(this.typeName,e,t),t}}const Yn=new Jn,ut=new ht("com.hamropatro.grpc.cms.ImageUploadService",[{name:"Upload",options:{},I:Mt,O:Yn}]);class zn{constructor(e){_(this,"typeName",ut.typeName);_(this,"methods",ut.methods);_(this,"options",ut.options);this._transport=e}upload(e,t){const n=this.methods[0],r=this._transport.mergeOptions(t);return ae("unary",this._transport,n,r,e)}}const Qn=async()=>{var i;try{const e=(i=window.ImageSalonSDK)==null?void 0:i.grpcConfig,t=new zn(e),n=Mt.create();return await t.upload(n)}catch(e){throw e}},ei=async(i,e)=>{try{const t=ti(i,e),r=(await Qn()).response.url;return await fetch(r,{method:"PUT",headers:{"Content-Type":"image/*","x-amz-acl":"public-read"},body:t}),r==null?void 0:r.split("?")[0]}catch(t){throw t}},ti=(i,e)=>{const t=e.type.split("/")[0];let n="";t==="video"?n=i==null?void 0:i.replace(/^data:video\/\w+;base64,/,""):t==="image"&&(n=i==null?void 0:i.replace(/^data:image\/\w+;base64,/,""));const r=atob(n),s=new Uint8Array(r.length);for(let o=0;o<r.length;o++)s[o]=r.charCodeAt(o);return s};class ni extends j{constructor(){super("com.hamropatro.grpc.cms.DeleteFolderRequest",[{no:1,name:"key",kind:"scalar",T:9}])}create(e){const t=globalThis.Object.create(this.messagePrototype);return t.key="",e!==void 0&&U(this,t,e),t}internalBinaryRead(e,t,n,r){let s=r??this.create(),o=e.pos+t;for(;e.pos<o;){let[a,l]=e.tag();switch(a){case 1:s.key=e.string();break;default:let c=n.readUnknownField;if(c==="throw")throw new globalThis.Error(`Unknown field ${a} (wire type ${l}) for ${this.typeName}`);let h=e.skip(l);c!==!1&&(c===!0?N.onRead:c)(this.typeName,s,a,l,h)}}return s}internalBinaryWrite(e,t,n){e.key!==""&&t.tag(1,m.LengthDelimited).string(e.key);let r=n.writeUnknownFields;return r!==!1&&(r==!0?N.onWrite:r)(this.typeName,e,t),t}}const Vt=new ni;class ii extends j{constructor(){super("com.hamropatro.grpc.cms.CreateFolderRequest",[{no:1,name:"name",kind:"scalar",T:9},{no:2,name:"nested_folder_name",kind:"scalar",T:9},{no:3,name:"created_by",kind:"scalar",T:9}])}create(e){const t=globalThis.Object.create(this.messagePrototype);return t.name="",t.nestedFolderName="",t.createdBy="",e!==void 0&&U(this,t,e),t}internalBinaryRead(e,t,n,r){let s=r??this.create(),o=e.pos+t;for(;e.pos<o;){let[a,l]=e.tag();switch(a){case 1:s.name=e.string();break;case 2:s.nestedFolderName=e.string();break;case 3:s.createdBy=e.string();break;default:let c=n.readUnknownField;if(c==="throw")throw new globalThis.Error(`Unknown field ${a} (wire type ${l}) for ${this.typeName}`);let h=e.skip(l);c!==!1&&(c===!0?N.onRead:c)(this.typeName,s,a,l,h)}}return s}internalBinaryWrite(e,t,n){e.name!==""&&t.tag(1,m.LengthDelimited).string(e.name),e.nestedFolderName!==""&&t.tag(2,m.LengthDelimited).string(e.nestedFolderName),e.createdBy!==""&&t.tag(3,m.LengthDelimited).string(e.createdBy);let r=n.writeUnknownFields;return r!==!1&&(r==!0?N.onWrite:r)(this.typeName,e,t),t}}const Ht=new ii;class ri extends j{constructor(){super("com.hamropatro.grpc.cms.GetAllFoldersRequest",[{no:1,name:"cursor",kind:"scalar",T:9},{no:2,name:"limit",kind:"scalar",T:5}])}create(e){const t=globalThis.Object.create(this.messagePrototype);return t.cursor="",t.limit=0,e!==void 0&&U(this,t,e),t}internalBinaryRead(e,t,n,r){let s=r??this.create(),o=e.pos+t;for(;e.pos<o;){let[a,l]=e.tag();switch(a){case 1:s.cursor=e.string();break;case 2:s.limit=e.int32();break;default:let c=n.readUnknownField;if(c==="throw")throw new globalThis.Error(`Unknown field ${a} (wire type ${l}) for ${this.typeName}`);let h=e.skip(l);c!==!1&&(c===!0?N.onRead:c)(this.typeName,s,a,l,h)}}return s}internalBinaryWrite(e,t,n){e.cursor!==""&&t.tag(1,m.LengthDelimited).string(e.cursor),e.limit!==0&&t.tag(2,m.Varint).int32(e.limit);let r=n.writeUnknownFields;return r!==!1&&(r==!0?N.onWrite:r)(this.typeName,e,t),t}}const $t=new ri;class si extends j{constructor(){super("com.hamropatro.grpc.cms.GetAllFoldersResponse",[{no:1,name:"folder",kind:"message",repeat:1,T:()=>Ce},{no:2,name:"next_cursor",kind:"scalar",T:9},{no:3,name:"has_more",kind:"scalar",T:8}])}create(e){const t=globalThis.Object.create(this.messagePrototype);return t.folder=[],t.nextCursor="",t.hasMore=!1,e!==void 0&&U(this,t,e),t}internalBinaryRead(e,t,n,r){let s=r??this.create(),o=e.pos+t;for(;e.pos<o;){let[a,l]=e.tag();switch(a){case 1:s.folder.push(Ce.internalBinaryRead(e,e.uint32(),n));break;case 2:s.nextCursor=e.string();break;case 3:s.hasMore=e.bool();break;default:let c=n.readUnknownField;if(c==="throw")throw new globalThis.Error(`Unknown field ${a} (wire type ${l}) for ${this.typeName}`);let h=e.skip(l);c!==!1&&(c===!0?N.onRead:c)(this.typeName,s,a,l,h)}}return s}internalBinaryWrite(e,t,n){for(let s=0;s<e.folder.length;s++)Ce.internalBinaryWrite(e.folder[s],t.tag(1,m.LengthDelimited).fork(),n).join();e.nextCursor!==""&&t.tag(2,m.LengthDelimited).string(e.nextCursor),e.hasMore!==!1&&t.tag(3,m.Varint).bool(e.hasMore);let r=n.writeUnknownFields;return r!==!1&&(r==!0?N.onWrite:r)(this.typeName,e,t),t}}const oi=new si;class ai extends j{constructor(){super("com.hamropatro.grpc.cms.Folder",[{no:1,name:"key",kind:"scalar",T:9},{no:2,name:"name",kind:"scalar",T:9},{no:3,name:"nested_folder_name",kind:"scalar",T:9},{no:4,name:"created_by",kind:"scalar",T:9}])}create(e){const t=globalThis.Object.create(this.messagePrototype);return t.key="",t.name="",t.nestedFolderName="",t.createdBy="",e!==void 0&&U(this,t,e),t}internalBinaryRead(e,t,n,r){let s=r??this.create(),o=e.pos+t;for(;e.pos<o;){let[a,l]=e.tag();switch(a){case 1:s.key=e.string();break;case 2:s.name=e.string();break;case 3:s.nestedFolderName=e.string();break;case 4:s.createdBy=e.string();break;default:let c=n.readUnknownField;if(c==="throw")throw new globalThis.Error(`Unknown field ${a} (wire type ${l}) for ${this.typeName}`);let h=e.skip(l);c!==!1&&(c===!0?N.onRead:c)(this.typeName,s,a,l,h)}}return s}internalBinaryWrite(e,t,n){e.key!==""&&t.tag(1,m.LengthDelimited).string(e.key),e.name!==""&&t.tag(2,m.LengthDelimited).string(e.name),e.nestedFolderName!==""&&t.tag(3,m.LengthDelimited).string(e.nestedFolderName),e.createdBy!==""&&t.tag(4,m.LengthDelimited).string(e.createdBy);let r=n.writeUnknownFields;return r!==!1&&(r==!0?N.onWrite:r)(this.typeName,e,t),t}}const Ce=new ai,ft=new ht("com.hamropatro.grpc.cms.FolderService",[{name:"createFolder",options:{},I:Ht,O:Ce},{name:"getFolders",options:{},I:$t,O:oi},{name:"updateFolder",options:{},I:Ce,O:Ce},{name:"deleteFolder",options:{},I:Vt,O:Ce}]);class it{constructor(e){_(this,"typeName",ft.typeName);_(this,"methods",ft.methods);_(this,"options",ft.options);this._transport=e}createFolder(e,t){const n=this.methods[0],r=this._transport.mergeOptions(t);return ae("unary",this._transport,n,r,e)}getFolders(e,t){const n=this.methods[1],r=this._transport.mergeOptions(t);return ae("unary",this._transport,n,r,e)}updateFolder(e,t){const n=this.methods[2],r=this._transport.mergeOptions(t);return ae("unary",this._transport,n,r,e)}deleteFolder(e,t){const n=this.methods[3],r=this._transport.mergeOptions(t);return ae("unary",this._transport,n,r,e)}}const li=async(i,e=20,t)=>{var o;const n=(o=window.ImageSalonSDK)==null?void 0:o.grpcConfig,r=new it(n),s=$t.create();try{return s.cursor=i,s.limit=e,await r.getFolders(s,t)}catch(a){throw a}},ci=async(i,e,t,n)=>{var r;try{const s=(r=window.ImageSalonSDK)==null?void 0:r.grpcConfig,o=new it(s),a=Ht.create();return a.name=i,a.nestedFolderName=e,a.createdBy=t,await o.createFolder(a,n)}catch(s){throw s}},di=async(i,e,t,n,r)=>{var s;try{const o=(s=window.ImageSalonSDK)==null?void 0:s.grpcConfig,a=new it(o),l=Ce.create();return l.name=e,l.key=i,l.nestedFolderName=t,l.createdBy=n,await a.updateFolder(l,r)}catch(o){throw o}},hi=async(i,e)=>{var t;try{const n=(t=window.ImageSalonSDK)==null?void 0:t.grpcConfig,r=new it(n),s=Vt.create();return s.key=i,await r.deleteFolder(s,e)}catch(n){throw n}};var pt=(i=>(i[i.IMAGE=0]="IMAGE",i[i.AUDIO=1]="AUDIO",i[i.VIDEO=2]="VIDEO",i[i.ALL=3]="ALL",i[i.FOLDER=4]="FOLDER",i))(pt||{});class ui extends j{constructor(){super("com.hamropatro.grpc.cms.SearchRequest",[{no:1,name:"search_value",kind:"scalar",T:9},{no:2,name:"cursor",kind:"scalar",T:9},{no:3,name:"limit",kind:"scalar",T:5}])}create(e){const t=globalThis.Object.create(this.messagePrototype);return t.searchValue="",t.cursor="",t.limit=0,e!==void 0&&U(this,t,e),t}internalBinaryRead(e,t,n,r){let s=r??this.create(),o=e.pos+t;for(;e.pos<o;){let[a,l]=e.tag();switch(a){case 1:s.searchValue=e.string();break;case 2:s.cursor=e.string();break;case 3:s.limit=e.int32();break;default:let c=n.readUnknownField;if(c==="throw")throw new globalThis.Error(`Unknown field ${a} (wire type ${l}) for ${this.typeName}`);let h=e.skip(l);c!==!1&&(c===!0?N.onRead:c)(this.typeName,s,a,l,h)}}return s}internalBinaryWrite(e,t,n){e.searchValue!==""&&t.tag(1,m.LengthDelimited).string(e.searchValue),e.cursor!==""&&t.tag(2,m.LengthDelimited).string(e.cursor),e.limit!==0&&t.tag(3,m.Varint).int32(e.limit);let r=n.writeUnknownFields;return r!==!1&&(r==!0?N.onWrite:r)(this.typeName,e,t),t}}const jt=new ui;class fi extends j{constructor(){super("com.hamropatro.grpc.cms.SearchResult",[{no:1,name:"items",kind:"message",repeat:1,T:()=>le},{no:2,name:"next_page_cursor",kind:"scalar",T:9}])}create(e){const t=globalThis.Object.create(this.messagePrototype);return t.items=[],t.nextPageCursor="",e!==void 0&&U(this,t,e),t}internalBinaryRead(e,t,n,r){let s=r??this.create(),o=e.pos+t;for(;e.pos<o;){let[a,l]=e.tag();switch(a){case 1:s.items.push(le.internalBinaryRead(e,e.uint32(),n));break;case 2:s.nextPageCursor=e.string();break;default:let c=n.readUnknownField;if(c==="throw")throw new globalThis.Error(`Unknown field ${a} (wire type ${l}) for ${this.typeName}`);let h=e.skip(l);c!==!1&&(c===!0?N.onRead:c)(this.typeName,s,a,l,h)}}return s}internalBinaryWrite(e,t,n){for(let s=0;s<e.items.length;s++)le.internalBinaryWrite(e.items[s],t.tag(1,m.LengthDelimited).fork(),n).join();e.nextPageCursor!==""&&t.tag(2,m.LengthDelimited).string(e.nextPageCursor);let r=n.writeUnknownFields;return r!==!1&&(r==!0?N.onWrite:r)(this.typeName,e,t),t}}const pi=new fi;class mi extends j{constructor(){super("com.hamropatro.grpc.cms.CreateFileRequest",[{no:1,name:"name",kind:"scalar",T:9},{no:2,name:"folder_name",kind:"scalar",T:9},{no:3,name:"nested_folder_name",kind:"scalar",T:9},{no:4,name:"url",kind:"scalar",T:9},{no:5,name:"type",kind:"enum",T:()=>["com.hamropatro.grpc.cms.FileType",pt]}])}create(e){const t=globalThis.Object.create(this.messagePrototype);return t.name="",t.folderName="",t.nestedFolderName="",t.url="",t.type=0,e!==void 0&&U(this,t,e),t}internalBinaryRead(e,t,n,r){let s=r??this.create(),o=e.pos+t;for(;e.pos<o;){let[a,l]=e.tag();switch(a){case 1:s.name=e.string();break;case 2:s.folderName=e.string();break;case 3:s.nestedFolderName=e.string();break;case 4:s.url=e.string();break;case 5:s.type=e.int32();break;default:let c=n.readUnknownField;if(c==="throw")throw new globalThis.Error(`Unknown field ${a} (wire type ${l}) for ${this.typeName}`);let h=e.skip(l);c!==!1&&(c===!0?N.onRead:c)(this.typeName,s,a,l,h)}}return s}internalBinaryWrite(e,t,n){e.name!==""&&t.tag(1,m.LengthDelimited).string(e.name),e.folderName!==""&&t.tag(2,m.LengthDelimited).string(e.folderName),e.nestedFolderName!==""&&t.tag(3,m.LengthDelimited).string(e.nestedFolderName),e.url!==""&&t.tag(4,m.LengthDelimited).string(e.url),e.type!==0&&t.tag(5,m.Varint).int32(e.type);let r=n.writeUnknownFields;return r!==!1&&(r==!0?N.onWrite:r)(this.typeName,e,t),t}}const Pt=new mi;class gi extends j{constructor(){super("com.hamropatro.grpc.cms.File",[{no:1,name:"key",kind:"scalar",T:9},{no:2,name:"name",kind:"scalar",T:9},{no:3,name:"folder_name",kind:"scalar",T:9},{no:4,name:"nested_folder_name",kind:"scalar",T:9},{no:5,name:"url",kind:"scalar",T:9},{no:6,name:"thumbor_url",kind:"scalar",T:9},{no:7,name:"proxy_url",kind:"scalar",T:9},{no:8,name:"type",kind:"enum",T:()=>["com.hamropatro.grpc.cms.FileType",pt]},{no:9,name:"metadata",kind:"message",T:()=>mt}])}create(e){const t=globalThis.Object.create(this.messagePrototype);return t.key="",t.name="",t.folderName="",t.nestedFolderName="",t.url="",t.thumborUrl="",t.proxyUrl="",t.type=0,e!==void 0&&U(this,t,e),t}internalBinaryRead(e,t,n,r){let s=r??this.create(),o=e.pos+t;for(;e.pos<o;){let[a,l]=e.tag();switch(a){case 1:s.key=e.string();break;case 2:s.name=e.string();break;case 3:s.folderName=e.string();break;case 4:s.nestedFolderName=e.string();break;case 5:s.url=e.string();break;case 6:s.thumborUrl=e.string();break;case 7:s.proxyUrl=e.string();break;case 8:s.type=e.int32();break;case 9:s.metadata=mt.internalBinaryRead(e,e.uint32(),n,s.metadata);break;default:let c=n.readUnknownField;if(c==="throw")throw new globalThis.Error(`Unknown field ${a} (wire type ${l}) for ${this.typeName}`);let h=e.skip(l);c!==!1&&(c===!0?N.onRead:c)(this.typeName,s,a,l,h)}}return s}internalBinaryWrite(e,t,n){e.key!==""&&t.tag(1,m.LengthDelimited).string(e.key),e.name!==""&&t.tag(2,m.LengthDelimited).string(e.name),e.folderName!==""&&t.tag(3,m.LengthDelimited).string(e.folderName),e.nestedFolderName!==""&&t.tag(4,m.LengthDelimited).string(e.nestedFolderName),e.url!==""&&t.tag(5,m.LengthDelimited).string(e.url),e.thumborUrl!==""&&t.tag(6,m.LengthDelimited).string(e.thumborUrl),e.proxyUrl!==""&&t.tag(7,m.LengthDelimited).string(e.proxyUrl),e.type!==0&&t.tag(8,m.Varint).int32(e.type),e.metadata&&mt.internalBinaryWrite(e.metadata,t.tag(9,m.LengthDelimited).fork(),n).join();let r=n.writeUnknownFields;return r!==!1&&(r==!0?N.onWrite:r)(this.typeName,e,t),t}}const le=new gi;class wi extends j{constructor(){super("com.hamropatro.grpc.cms.FileMetadata",[{no:1,name:"height",kind:"scalar",T:5},{no:2,name:"width",kind:"scalar",T:5},{no:3,name:"background_color",kind:"scalar",T:9},{no:4,name:"aspect_ratio",kind:"scalar",T:1}])}create(e){const t=globalThis.Object.create(this.messagePrototype);return t.height=0,t.width=0,t.backgroundColor="",t.aspectRatio=0,e!==void 0&&U(this,t,e),t}internalBinaryRead(e,t,n,r){let s=r??this.create(),o=e.pos+t;for(;e.pos<o;){let[a,l]=e.tag();switch(a){case 1:s.height=e.int32();break;case 2:s.width=e.int32();break;case 3:s.backgroundColor=e.string();break;case 4:s.aspectRatio=e.double();break;default:let c=n.readUnknownField;if(c==="throw")throw new globalThis.Error(`Unknown field ${a} (wire type ${l}) for ${this.typeName}`);let h=e.skip(l);c!==!1&&(c===!0?N.onRead:c)(this.typeName,s,a,l,h)}}return s}internalBinaryWrite(e,t,n){e.height!==0&&t.tag(1,m.Varint).int32(e.height),e.width!==0&&t.tag(2,m.Varint).int32(e.width),e.backgroundColor!==""&&t.tag(3,m.LengthDelimited).string(e.backgroundColor),e.aspectRatio!==0&&t.tag(4,m.Bit64).double(e.aspectRatio);let r=n.writeUnknownFields;return r!==!1&&(r==!0?N.onWrite:r)(this.typeName,e,t),t}}const mt=new wi;class bi extends j{constructor(){super("com.hamropatro.grpc.cms.DeleteFileRequest",[{no:1,name:"key",kind:"scalar",T:9}])}create(e){const t=globalThis.Object.create(this.messagePrototype);return t.key="",e!==void 0&&U(this,t,e),t}internalBinaryRead(e,t,n,r){let s=r??this.create(),o=e.pos+t;for(;e.pos<o;){let[a,l]=e.tag();switch(a){case 1:s.key=e.string();break;default:let c=n.readUnknownField;if(c==="throw")throw new globalThis.Error(`Unknown field ${a} (wire type ${l}) for ${this.typeName}`);let h=e.skip(l);c!==!1&&(c===!0?N.onRead:c)(this.typeName,s,a,l,h)}}return s}internalBinaryWrite(e,t,n){e.key!==""&&t.tag(1,m.LengthDelimited).string(e.key);let r=n.writeUnknownFields;return r!==!1&&(r==!0?N.onWrite:r)(this.typeName,e,t),t}}const Wt=new bi;class yi extends j{constructor(){super("com.hamropatro.grpc.cms.DeleteFileResponse",[{no:1,name:"is_deleted",kind:"scalar",T:8}])}create(e){const t=globalThis.Object.create(this.messagePrototype);return t.isDeleted=!1,e!==void 0&&U(this,t,e),t}internalBinaryRead(e,t,n,r){let s=r??this.create(),o=e.pos+t;for(;e.pos<o;){let[a,l]=e.tag();switch(a){case 1:s.isDeleted=e.bool();break;default:let c=n.readUnknownField;if(c==="throw")throw new globalThis.Error(`Unknown field ${a} (wire type ${l}) for ${this.typeName}`);let h=e.skip(l);c!==!1&&(c===!0?N.onRead:c)(this.typeName,s,a,l,h)}}return s}internalBinaryWrite(e,t,n){e.isDeleted!==!1&&t.tag(1,m.Varint).bool(e.isDeleted);let r=n.writeUnknownFields;return r!==!1&&(r==!0?N.onWrite:r)(this.typeName,e,t),t}}const Ci=new yi;class Ei extends j{constructor(){super("com.hamropatro.grpc.cms.GetFilesByFolderRequest",[{no:1,name:"folder_name",kind:"scalar",T:9},{no:2,name:"cursor",kind:"scalar",T:9},{no:3,name:"limit",kind:"scalar",T:5}])}create(e){const t=globalThis.Object.create(this.messagePrototype);return t.folderName="",t.cursor="",t.limit=0,e!==void 0&&U(this,t,e),t}internalBinaryRead(e,t,n,r){let s=r??this.create(),o=e.pos+t;for(;e.pos<o;){let[a,l]=e.tag();switch(a){case 1:s.folderName=e.string();break;case 2:s.cursor=e.string();break;case 3:s.limit=e.int32();break;default:let c=n.readUnknownField;if(c==="throw")throw new globalThis.Error(`Unknown field ${a} (wire type ${l}) for ${this.typeName}`);let h=e.skip(l);c!==!1&&(c===!0?N.onRead:c)(this.typeName,s,a,l,h)}}return s}internalBinaryWrite(e,t,n){e.folderName!==""&&t.tag(1,m.LengthDelimited).string(e.folderName),e.cursor!==""&&t.tag(2,m.LengthDelimited).string(e.cursor),e.limit!==0&&t.tag(3,m.Varint).int32(e.limit);let r=n.writeUnknownFields;return r!==!1&&(r==!0?N.onWrite:r)(this.typeName,e,t),t}}const Zt=new Ei;class Ni extends j{constructor(){super("com.hamropatro.grpc.cms.GetFilesByFolderResponse",[{no:1,name:"files",kind:"message",repeat:1,T:()=>le},{no:2,name:"next_cursor",kind:"scalar",T:9},{no:3,name:"has_more",kind:"scalar",T:8}])}create(e){const t=globalThis.Object.create(this.messagePrototype);return t.files=[],t.nextCursor="",t.hasMore=!1,e!==void 0&&U(this,t,e),t}internalBinaryRead(e,t,n,r){let s=r??this.create(),o=e.pos+t;for(;e.pos<o;){let[a,l]=e.tag();switch(a){case 1:s.files.push(le.internalBinaryRead(e,e.uint32(),n));break;case 2:s.nextCursor=e.string();break;case 3:s.hasMore=e.bool();break;default:let c=n.readUnknownField;if(c==="throw")throw new globalThis.Error(`Unknown field ${a} (wire type ${l}) for ${this.typeName}`);let h=e.skip(l);c!==!1&&(c===!0?N.onRead:c)(this.typeName,s,a,l,h)}}return s}internalBinaryWrite(e,t,n){for(let s=0;s<e.files.length;s++)le.internalBinaryWrite(e.files[s],t.tag(1,m.LengthDelimited).fork(),n).join();e.nextCursor!==""&&t.tag(2,m.LengthDelimited).string(e.nextCursor),e.hasMore!==!1&&t.tag(3,m.Varint).bool(e.hasMore);let r=n.writeUnknownFields;return r!==!1&&(r==!0?N.onWrite:r)(this.typeName,e,t),t}}const ki=new Ni,gt=new ht("com.hamropatro.grpc.cms.FileService",[{name:"createFile",options:{},I:Pt,O:le},{name:"updateFile",options:{},I:le,O:le},{name:"deleteFile",options:{},I:Wt,O:Ci},{name:"getFilesByFolder",options:{},I:Zt,O:ki},{name:"search",options:{},I:jt,O:pi}]);class Me{constructor(e){_(this,"typeName",gt.typeName);_(this,"methods",gt.methods);_(this,"options",gt.options);this._transport=e}createFile(e,t){const n=this.methods[0],r=this._transport.mergeOptions(t);return ae("unary",this._transport,n,r,e)}updateFile(e,t){const n=this.methods[1],r=this._transport.mergeOptions(t);return ae("unary",this._transport,n,r,e)}deleteFile(e,t){const n=this.methods[2],r=this._transport.mergeOptions(t);return ae("unary",this._transport,n,r,e)}getFilesByFolder(e,t){const n=this.methods[3],r=this._transport.mergeOptions(t);return ae("unary",this._transport,n,r,e)}search(e,t){const n=this.methods[4],r=this._transport.mergeOptions(t);return ae("unary",this._transport,n,r,e)}}const Li=async(i,e,t,n,r,s)=>{var o;try{const a=(o=window.ImageSalonSDK)==null?void 0:o.grpcConfig,l=new Me(a),c=Pt.create();return c.name=i,c.nestedFolderName=e,c.url=t,c.type=n,c.folderName=r,await l.createFile(c,s)}catch(a){throw a}},Ii=async(i,e,t,n)=>{var r;try{const s=(r=window.ImageSalonSDK)==null?void 0:r.grpcConfig,o=new Me(s),a=Zt.create();return a.folderName=i,a.cursor=e,a.limit=t,await o.getFilesByFolder(a,n)}catch(s){throw s}},Fi=async(i,e,t=20,n)=>{var r;try{const s=(r=window.ImageSalonSDK)==null?void 0:r.grpcConfig,o=new Me(s),a=jt.create();return a.searchValue=i,a.cursor=e,a.limit=t,await o.search(a,n)}catch(s){throw s}},Ai=async(i,e,t,n,r,s,o,a,l)=>{var c;try{const h=(c=window.ImageSalonSDK)==null?void 0:c.grpcConfig,g=new Me(h),w=le.create();return w.key=i,w.name=e,w.nestedFolderName=t,w.url=n,w.thumborUrl=r,w.proxyUrl=s,w.type=o,w.folderName=a,await g.updateFile(w,l)}catch(h){throw h}},Ti=async(i,e)=>{var t;try{const n=(t=window.ImageSalonSDK)==null?void 0:t.grpcConfig,r=new Me(n),s=Wt.create();return s.key=i,await r.deleteFile(s,e)}catch(n){throw n}};var fe=(i=>(i[i.IMAGE=0]="IMAGE",i[i.AUDIO=1]="AUDIO",i[i.VIDEO=2]="VIDEO",i[i.ALL=3]="ALL",i[i.FOLDER=4]="FOLDER",i))(fe||{});const rt={0:"IMAGE",1:"AUDIO",2:"VIDEO",3:"ALL",4:"FOLDER"};function Bi(i){switch(i){case"image":return rt[fe.IMAGE];case"video":return rt[fe.VIDEO];case"audio":return rt[fe.AUDIO];default:return rt[fe.ALL]}}function qt(){const i=document.createElementNS("http://www.w3.org/2000/svg","svg");i.setAttribute("xmlns","http://www.w3.org/2000/folder"),i.setAttribute("x","0px"),i.setAttribute("y","0px"),i.setAttribute("width","24"),i.setAttribute("height","24"),i.setAttribute("viewBox","0 0 48 48");const e=document.createElementNS("http://www.w3.org/2000/svg","path");e.setAttribute("fill","#FFA000"),e.setAttribute("d","M40,12H22l-4-4H8c-2.2,0-4,1.8-4,4v8h40v-4C44,13.8,42.2,12,40,12z");const t=document.createElementNS("http://www.w3.org/2000/svg","path");return t.setAttribute("fill","#FFCA28"),t.setAttribute("d","M40,12H8c-2.2,0-4,1.8-4,4v20c0,2.2,1.8,4,4,4h32c2.2,0,4-1.8,4-4V16C44,13.8,42.2,12,40,12z"),i.appendChild(e),i.appendChild(t),i}const G=document.createElementNS("http://www.w3.org/2000/svg","svg");G.setAttribute("xmlns","http://www.w3.org/2000/svg"),G.setAttribute("width","20"),G.setAttribute("height","20"),G.setAttribute("viewBox","0 0 24 24"),G.setAttribute("fill","none"),G.setAttribute("stroke","currentColor"),G.setAttribute("stroke-width","2"),G.setAttribute("stroke-linecap","round"),G.setAttribute("stroke-linejoin","round"),G.classList.add("lucide","lucide-circle-check-big");const Kt=document.createElementNS("http://www.w3.org/2000/svg","path");Kt.setAttribute("d","M21.801 10A10 10 0 1 1 17 3.335");const Xt=document.createElementNS("http://www.w3.org/2000/svg","path");Xt.setAttribute("d","m9 11 3 3L22 4"),G.appendChild(Kt),G.appendChild(Xt);const q=document.createElementNS("http://www.w3.org/2000/svg","svg");q.setAttribute("xmlns","http://www.w3.org/2000/svg"),q.setAttribute("width","20"),q.setAttribute("height","20"),q.setAttribute("viewBox","0 0 24 24"),q.setAttribute("fill","none"),q.setAttribute("stroke","#ee3f3f"),q.setAttribute("stroke-width","2"),q.setAttribute("stroke-linecap","round"),q.setAttribute("stroke-linejoin","round"),q.classList.add("lucide","lucide-circle-alert");const st=document.createElementNS("http://www.w3.org/2000/svg","circle");st.setAttribute("cx","12"),st.setAttribute("cy","12"),st.setAttribute("r","10");const Ve=document.createElementNS("http://www.w3.org/2000/svg","line");Ve.setAttribute("x1","12"),Ve.setAttribute("x2","12"),Ve.setAttribute("y1","8"),Ve.setAttribute("y2","12");const He=document.createElementNS("http://www.w3.org/2000/svg","line");He.setAttribute("x1","12"),He.setAttribute("x2","12.01"),He.setAttribute("y1","16"),He.setAttribute("y2","16"),q.appendChild(st),q.appendChild(Ve),q.appendChild(He);function Gt(){const i=document.createElementNS("http://www.w3.org/2000/svg","svg");i.setAttribute("xmlns","http://www.w3.org/2000/svg"),i.setAttribute("height","24px"),i.setAttribute("width","24px"),i.setAttribute("viewBox","0 -960 960 960"),i.setAttribute("fill","#333");const e=document.createElementNS("http://www.w3.org/2000/svg","path");return e.setAttribute("d","M504-480 320-664l56-56 240 240-240 240-56-56 184-184Z"),i.appendChild(e),i}function Jt(){const i=document.createElementNS("http://www.w3.org/2000/svg","svg");i.setAttribute("xmlns","http://www.w3.org/2000/svg"),i.setAttribute("fill","none"),i.setAttribute("width","20"),i.setAttribute("height","20"),i.setAttribute("viewBox","0 0 24 24"),i.setAttribute("stroke-width","1.5"),i.setAttribute("stroke","currentColor"),i.setAttribute("class","size-2");const e=document.createElementNS("http://www.w3.org/2000/svg","path");return e.setAttribute("stroke-linecap","round"),e.setAttribute("stroke-linejoin","round"),e.setAttribute("d","M12 4.5v15m7.5-7.5h-15"),i.appendChild(e),i}function vi(i){const e={};i.forEach(r=>{e[r.key]={...r,children:{}}});const t=r=>(Object.values(e).filter(o=>o.nestedFolderName==r.key).forEach(o=>{r.children[o.key]=t(o)}),r);return i.reduce((r,s)=>(s.nestedFolderName||r.push(t(e[s.key])),r),[])}function _i(i,e){const t=n=>{if(n.key===e.nestedFolderName)return n.children[e.key]={...e,children:{}},!0;for(const r in n.children){const s=n.children[r];if(t(s))return!0}return!1};for(const n of i)if(t(n))break;return i}function Oi(){const i=document.createElementNS("http://www.w3.org/2000/svg","svg");i.setAttribute("xmlns","http://www.w3.org/2000/svg"),i.setAttribute("height","24px"),i.setAttribute("width","24px"),i.setAttribute("viewBox","0 0 30 30"),i.setAttribute("fill","#999");const e=document.createElementNS("http://www.w3.org/2000/svg","path");return e.setAttribute("d","M 13 3 C 7.4889971 3 3 7.4889971 3 13 C 3 18.511003 7.4889971 23 13 23 C 15.396508 23 17.597385 22.148986 19.322266 20.736328 L 25.292969 26.707031 A 1.0001 1.0001 0 1 0 26.707031 25.292969 L 20.736328 19.322266 C 22.148986 17.597385 23 15.396508 23 13 C 23 7.4889971 18.511003 3 13 3 z M 13 5 C 17.430123 5 21 8.5698774 21 13 C 21 17.430123 17.430123 21 13 21 C 8.5698774 21 5 17.430123 5 13 C 5 8.5698774 8.5698774 5 13 5 z"),i.appendChild(e),i}function xi(){const i="http://www.w3.org/2000/svg",e=document.createElementNS(i,"svg");e.setAttribute("xmlns",i),e.setAttribute("height","20px"),e.setAttribute("viewBox","0 -960 960 960"),e.setAttribute("width","20px"),e.setAttribute("fill","#fff");const t=document.createElementNS(i,"path");return t.setAttribute("d","M440-320v-326L336-542l-56-58 200-200 200 200-56 58-104-104v326h-80ZM240-160q-33 0-56.5-23.5T160-240v-120h80v120h480v-120h80v120q0 33-23.5 56.5T720-160H240Z"),e.appendChild(t),e}function Di(){const i="http://www.w3.org/2000/svg",e=document.createElementNS(i,"svg");e.setAttribute("width","12"),e.setAttribute("height","12"),e.setAttribute("viewBox","0 0 24 24"),e.setAttribute("fill","none"),e.setAttribute("stroke","currentColor"),e.setAttribute("stroke-width","3"),e.setAttribute("stroke-linecap","round"),e.setAttribute("stroke-linejoin","round"),e.classList.add("lucide","lucide-video");const t=document.createElementNS(i,"path");t.setAttribute("d","m16 13 5.223 3.482a.5.5 0 0 0 .777-.416V7.87a.5.5 0 0 0-.752-.432L16 10.5");const n=document.createElementNS(i,"rect");return n.setAttribute("x","2"),n.setAttribute("y","6"),n.setAttribute("width","14"),n.setAttribute("height","12"),n.setAttribute("rx","2"),e.appendChild(t),e.appendChild(n),document.body.appendChild(e),e}function Si(){const i="http://www.w3.org/2000/svg",e=document.createElementNS(i,"svg");e.setAttribute("width","12"),e.setAttribute("height","12"),e.setAttribute("viewBox","0 0 24 24"),e.setAttribute("fill","none"),e.setAttribute("stroke","currentColor"),e.setAttribute("stroke-width","3"),e.setAttribute("stroke-linecap","round"),e.setAttribute("stroke-linejoin","round"),e.classList.add("lucide","lucide-image");const t=document.createElementNS(i,"rect");t.setAttribute("width","18"),t.setAttribute("height","18"),t.setAttribute("x","3"),t.setAttribute("y","3"),t.setAttribute("rx","2"),t.setAttribute("ry","2");const n=document.createElementNS(i,"circle");n.setAttribute("cx","9"),n.setAttribute("cy","9"),n.setAttribute("r","2");const r=document.createElementNS(i,"path");return r.setAttribute("d","m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21"),e.appendChild(t),e.appendChild(n),e.appendChild(r),document.body.appendChild(e),e}const Ui=async i=>{let e;try{i&&(e={Authorization:"Bearer "+i})}catch(n){if(n)throw n}return{meta:e}};class Ri{constructor(){_(this,"main");_(this,"dialogBody");this.main=y("div"),this.dialogBody=y("div"),this.hide()}show(e){this.main=y("div","popover",e.mainContainer),this.dialogBody=y("div","popover-body",this.main),this.main.id=e.divId,this.dialogBody.append(e.content)}hide(){this.main.remove()}}const pe=new Ri;function Mi(){const i=document.createElementNS("http://www.w3.org/2000/svg","svg");i.setAttribute("xmlns","http://www.w3.org/2000/svg"),i.setAttribute("width","12"),i.setAttribute("height","12"),i.setAttribute("viewBox","0 0 24 24"),i.setAttribute("fill","none"),i.setAttribute("stroke","currentColor"),i.setAttribute("stroke-width","2"),i.setAttribute("stroke-linecap","round"),i.setAttribute("stroke-linejoin","round"),i.classList.add("lucide","lucide-music-4");const e=document.createElementNS("http://www.w3.org/2000/svg","path");e.setAttribute("d","M9 18V5l12-2v13");const t=document.createElementNS("http://www.w3.org/2000/svg","path");t.setAttribute("d","m9 9 12-2");const n=document.createElementNS("http://www.w3.org/2000/svg","circle");n.setAttribute("cx","6"),n.setAttribute("cy","18"),n.setAttribute("r","3");const r=document.createElementNS("http://www.w3.org/2000/svg","circle");return r.setAttribute("cx","18"),r.setAttribute("cy","16"),r.setAttribute("r","3"),i.appendChild(e),i.appendChild(t),i.appendChild(n),i.appendChild(r),document.body.appendChild(i),i}var p;(function(i){i[i.OK=0]="OK",i[i.CANCELLED=1]="CANCELLED",i[i.UNKNOWN=2]="UNKNOWN",i[i.INVALID_ARGUMENT=3]="INVALID_ARGUMENT",i[i.DEADLINE_EXCEEDED=4]="DEADLINE_EXCEEDED",i[i.NOT_FOUND=5]="NOT_FOUND",i[i.ALREADY_EXISTS=6]="ALREADY_EXISTS",i[i.PERMISSION_DENIED=7]="PERMISSION_DENIED",i[i.UNAUTHENTICATED=16]="UNAUTHENTICATED",i[i.RESOURCE_EXHAUSTED=8]="RESOURCE_EXHAUSTED",i[i.FAILED_PRECONDITION=9]="FAILED_PRECONDITION",i[i.ABORTED=10]="ABORTED",i[i.OUT_OF_RANGE=11]="OUT_OF_RANGE",i[i.UNIMPLEMENTED=12]="UNIMPLEMENTED",i[i.INTERNAL=13]="INTERNAL",i[i.UNAVAILABLE=14]="UNAVAILABLE",i[i.DATA_LOSS=15]="DATA_LOSS"})(p||(p={}));var Vi=function(i,e,t,n){function r(s){return s instanceof t?s:new t(function(o){o(s)})}return new(t||(t=Promise))(function(s,o){function a(h){try{c(n.next(h))}catch(g){o(g)}}function l(h){try{c(n.throw(h))}catch(g){o(g)}}function c(h){h.done?s(h.value):r(h.value).then(a,l)}c((n=n.apply(i,e||[])).next())})};function Yt(i,e,t,n,r){if(n)for(let[s,o]of Object.entries(n))if(typeof o=="string")i.append(s,o);else for(let a of o)i.append(s,a);if(i.set("Content-Type",e==="text"?"application/grpc-web-text":"application/grpc-web+proto"),e=="text"&&i.set("Accept","application/grpc-web-text"),i.set("X-Grpc-Web","1"),typeof t=="number"){if(t<=0)throw new B(`timeout ${t} ms exceeded`,p[p.DEADLINE_EXCEEDED]);i.set("grpc-timeout",`${t}m`)}else if(t){const s=t.getTime(),o=Date.now();if(s<=o)throw new B(`deadline ${t} exceeded`,p[p.DEADLINE_EXCEEDED]);i.set("grpc-timeout",`${s-o}m`)}return i}function zt(i,e){let t=new Uint8Array(5+i.length);t[0]=ne.DATA;for(let n=i.length,r=4;r>0;r--)t[r]=n%256,n>>>=8;return t.set(i,5),e==="binary"?t:Lt(t)}function wt(i,e,t){if(arguments.length===1){let l=i,c;try{c=l.type}catch{}switch(c){case"error":case"opaque":case"opaqueredirect":throw new B(`fetch response type ${l.type}`,p[p.UNKNOWN])}return wt(Pi(l.headers),l.status,l.statusText)}let n=i,r=e>=200&&e<300,s=rn(n),[o,a]=nn(n);return(o===void 0||o===p.OK)&&!r&&(o=Wi(e),a=t),[o,a,s]}function Qt(i){let e=ji(i),[t,n]=nn(e),r=rn(e);return[t??p.OK,n,r]}var ne;(function(i){i[i.DATA=0]="DATA",i[i.TRAILER=128]="TRAILER"})(ne||(ne={}));function en(i,e,t){return Vi(this,void 0,void 0,function*(){let n,r="",s=new Uint8Array(0),o=$i(e);if(Hi(i)){let a=i.getReader();n={next:()=>a.read()}}else n=i[Symbol.asyncIterator]();for(;;){let a=yield n.next();if(a.value!==void 0){if(o==="text"){for(let c=0;c<a.value.length;c++)r+=String.fromCharCode(a.value[c]);let l=r.length-r.length%4;if(l===0)continue;s=tn(s,kt(r.substring(0,l))),r=r.substring(l)}else s=tn(s,a.value);for(;s.length>=5&&s[0]===ne.DATA;){let l=0;for(let c=1;c<5;c++)l=(l<<8)+s[c];if(s.length-5>=l)t(ne.DATA,s.subarray(5,5+l)),s=s.subarray(5+l);else break}}if(a.done){if(s.length===0)break;if(s[0]!==ne.TRAILER||s.length<5)throw new B("premature EOF",p[p.DATA_LOSS]);t(ne.TRAILER,s.subarray(5));break}}})}const Hi=i=>typeof i.getReader=="function";function tn(i,e){let t=new Uint8Array(i.length+e.length);return t.set(i),t.set(e,i.length),t}function $i(i){switch(i){case"application/grpc-web-text":case"application/grpc-web-text+proto":return"text";case"application/grpc-web":case"application/grpc-web+proto":return"binary";case void 0:case null:throw new B("missing response content type",p[p.INTERNAL]);default:throw new B("unexpected response content type: "+i,p[p.INTERNAL])}}function nn(i){let e,t,n=i["grpc-message"];if(n!==void 0){if(Array.isArray(n))return[p.INTERNAL,"invalid grpc-web message"];t=n}let r=i["grpc-status"];if(r!==void 0){if(Array.isArray(r))return[p.INTERNAL,"invalid grpc-web status"];if(e=parseInt(r,10),p[e]===void 0)return[p.INTERNAL,"invalid grpc-web status"]}return[e,t]}function rn(i){let e={};for(let[t,n]of Object.entries(i))switch(t){case"grpc-message":case"grpc-status":case"content-type":break;default:e[t]=n}return e}function ji(i){let e={};for(let t of String.fromCharCode.apply(String,i).trim().split(`\r
5
- `)){if(t=="")continue;let[n,...r]=t.split(":");const s=r.join(":").trim();n=n.trim();let o=e[n];typeof o=="string"?e[n]=[o,s]:Array.isArray(o)?o.push(s):e[n]=s}return e}function Pi(i){let e={};return i.forEach((t,n)=>{let r=e[n];typeof r=="string"?e[n]=[r,t]:Array.isArray(r)?r.push(t):e[n]=t}),e}function Wi(i){switch(i){case 200:return p.OK;case 400:return p.INVALID_ARGUMENT;case 401:return p.UNAUTHENTICATED;case 403:return p.PERMISSION_DENIED;case 404:return p.NOT_FOUND;case 409:return p.ABORTED;case 412:return p.FAILED_PRECONDITION;case 429:return p.RESOURCE_EXHAUSTED;case 499:return p.CANCELLED;case 500:return p.UNKNOWN;case 501:return p.UNIMPLEMENTED;case 503:return p.UNAVAILABLE;case 504:return p.DEADLINE_EXCEEDED;default:return p.UNKNOWN}}class Zi{constructor(e){this.defaultOptions=e}mergeOptions(e){return Pn(this.defaultOptions,e)}makeUrl(e,t){let n=t.baseUrl;return n.endsWith("/")&&(n=n.substring(0,n.length-1)),`${n}/${e.service.typeName}/${e.name}`}clientStreaming(e){const t=new B("Client streaming is not supported by grpc-web",p[p.UNIMPLEMENTED]);throw t.methodName=e.name,t.serviceName=e.service.typeName,t}duplex(e){const t=new B("Duplex streaming is not supported by grpc-web",p[p.UNIMPLEMENTED]);throw t.methodName=e.name,t.serviceName=e.service.typeName,t}serverStreaming(e,t,n){var r,s,o,a;let l=n,c=(r=l.format)!==null&&r!==void 0?r:"text",h=(s=l.fetchInit)!==null&&s!==void 0?s:{},g=this.makeUrl(e,l),w=e.I.toBinary(t,l.binaryOptions),F=new ye,v=new Wn,Z=!0,A,V=new ye,K,X=new ye;return globalThis.fetch(g,Object.assign(Object.assign({},h),{method:"POST",headers:Yt(new globalThis.Headers,c,l.timeout,l.meta),body:zt(w,c),signal:(o=n.abort)!==null&&o!==void 0?o:null})).then(C=>{let[b,O,P]=wt(C);if(F.resolve(P),b!=null&&b!==p.OK)throw new B(O??p[b],p[b],P);return b!=null&&(A={code:p[b],detail:O??p[b]}),C}).then(C=>{if(!C.body)throw new B("missing response body",p[p.INTERNAL]);return en(C.body,C.headers.get("content-type"),(b,O)=>{switch(b){case ne.DATA:v.notifyMessage(e.O.fromBinary(O,l.binaryOptions)),Z=!1;break;case ne.TRAILER:let P,se;[P,se,K]=Qt(O),A={code:p[P],detail:se??p[P]};break}})}).then(()=>{if(!K&&!Z)throw new B("missing trailers",p[p.DATA_LOSS]);if(!A)throw new B("missing status",p[p.INTERNAL]);if(A.code!=="OK")throw new B(A.detail,A.code,K);v.notifyComplete(),V.resolve(A),X.resolve(K||{})}).catch(C=>{let b;C instanceof B?b=C:C instanceof Error&&C.name==="AbortError"?b=new B(C.message,p[p.CANCELLED]):b=new B(C instanceof Error?C.message:""+C,p[p.INTERNAL]),b.methodName=e.name,b.serviceName=e.service.typeName,F.rejectPending(b),v.notifyError(b),V.rejectPending(b),X.rejectPending(b)}),new Xn(e,(a=l.meta)!==null&&a!==void 0?a:{},t,F.promise,v,V.promise,X.promise)}unary(e,t,n){var r,s,o,a;let l=n,c=(r=l.format)!==null&&r!==void 0?r:"text",h=(s=l.fetchInit)!==null&&s!==void 0?s:{},g=this.makeUrl(e,l),w=e.I.toBinary(t,l.binaryOptions),F=new ye,v,Z=new ye,A,V=new ye,K,X=new ye;return globalThis.fetch(g,Object.assign(Object.assign({},h),{method:"POST",headers:Yt(new globalThis.Headers,c,l.timeout,l.meta),body:zt(w,c),signal:(o=n.abort)!==null&&o!==void 0?o:null})).then(C=>{let[b,O,P]=wt(C);if(F.resolve(P),b!=null&&b!==p.OK)throw new B(O??p[b],p[b],P);return b!=null&&(A={code:p[b],detail:O??p[b]}),C}).then(C=>{if(!C.body)throw new B("missing response body",p[p.INTERNAL]);return en(C.body,C.headers.get("content-type"),(b,O)=>{switch(b){case ne.DATA:if(v)throw new B("unary call received 2nd message",p[p.DATA_LOSS]);v=e.O.fromBinary(O,l.binaryOptions);break;case ne.TRAILER:let P,se;[P,se,K]=Qt(O),A={code:p[P],detail:se??p[P]};break}})}).then(()=>{if(!K&&v)throw new B("missing trailers",p[p.DATA_LOSS]);if(!A)throw new B("missing status",p[p.INTERNAL]);if(!v&&A.code==="OK")throw new B("expected error status",p[p.DATA_LOSS]);if(!v)throw new B(A.detail,A.code,K);if(Z.resolve(v),A.code!=="OK")throw new B(A.detail,A.code,K);V.resolve(A),X.resolve(K||{})}).catch(C=>{let b;C instanceof B?b=C:C instanceof Error&&C.name==="AbortError"?b=new B(C.message,p[p.CANCELLED]):b=new B(C instanceof Error?C.message:""+C,p[p.INTERNAL]),b.methodName=e.name,b.serviceName=e.service.typeName,F.rejectPending(b),Z.rejectPending(b),V.rejectPending(b),X.rejectPending(b)}),new qn(e,(a=l.meta)!==null&&a!==void 0?a:{},t,F.promise,Z.promise,V.promise,X.promise)}}function sn(){const i=document.createElementNS("http://www.w3.org/2000/svg","svg");i.setAttribute("xmlns","http://www.w3.org/2000/svg"),i.setAttribute("width","16"),i.setAttribute("height","16"),i.setAttribute("viewBox","0 0 24 24"),i.setAttribute("fill","none"),i.setAttribute("stroke","#2c96f8"),i.setAttribute("stroke-width","2"),i.setAttribute("stroke-linecap","round"),i.setAttribute("stroke-linejoin","round"),i.classList.add("lucide","lucide-pencil");const e=document.createElementNS("http://www.w3.org/2000/svg","path");e.setAttribute("d","M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z");const t=document.createElementNS("http://www.w3.org/2000/svg","path");return t.setAttribute("d","m15 5 4 4"),i.appendChild(e),i.appendChild(t),document.body.appendChild(i),i}function on(){const i=document.createElementNS("http://www.w3.org/2000/svg","svg");i.setAttribute("xmlns","http://www.w3.org/2000/svg"),i.setAttribute("width","16"),i.setAttribute("height","16"),i.setAttribute("viewBox","0 0 24 24"),i.setAttribute("fill","none"),i.setAttribute("stroke","#f14b4b"),i.setAttribute("stroke-width","2"),i.setAttribute("stroke-linecap","round"),i.setAttribute("stroke-linejoin","round"),i.classList.add("lucide","lucide-trash-2");const e=document.createElementNS("http://www.w3.org/2000/svg","path");e.setAttribute("d","M3 6h18");const t=document.createElementNS("http://www.w3.org/2000/svg","path");t.setAttribute("d","M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6");const n=document.createElementNS("http://www.w3.org/2000/svg","path");n.setAttribute("d","M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2");const r=document.createElementNS("http://www.w3.org/2000/svg","line");r.setAttribute("x1","10"),r.setAttribute("x2","10"),r.setAttribute("y1","11"),r.setAttribute("y2","17");const s=document.createElementNS("http://www.w3.org/2000/svg","line");return s.setAttribute("x1","14"),s.setAttribute("x2","14"),s.setAttribute("y1","11"),s.setAttribute("y2","17"),i.appendChild(e),i.appendChild(t),i.appendChild(n),i.appendChild(r),i.appendChild(s),document.body.appendChild(i),i}class an{constructor(e){L(this,Be);L(this,ve);L(this,D);L(this,ge);L(this,S,[]);L(this,R,[]);L(this,Ee);L(this,z);L(this,_e);L(this,Ne);L(this,ce,[]);L(this,ie);L(this,ke);L(this,$e);L(this,Le);L(this,Ie);L(this,we);L(this,Oe);L(this,de);L(this,he);L(this,Fe);L(this,Ae);L(this,be);L(this,De);L(this,je);L(this,J);L(this,re);L(this,Pe,!1);L(this,We);L(this,Te);f(this,Ee,!1),f(this,z,!1),f(this,_e,!1),f(this,$e,e.handleUpload.bind(this)),f(this,Le,0),f(this,he,""),f(this,Fe,!1),f(this,be,!1),f(this,je,e.accessToken),f(this,re,null),f(this,Te,""),this._removeToastContainer(),this._grpcOptionInitializer(),this._init(e).then(()=>{f(this,Pe,!0),this._create(e),this.updateWindowObject({initialized:!0}),this._initializeGrpcConfig(e.mode)}),f(this,We,e.enableMultiSelect)}async _init(e){try{const{mode:t}=e;this.updateWindowObject({mode:t})}catch{throw Error("Initialization failed")}}_create(e){if(!d(this,Pe))return;const{parentContainerId:t,buttonProps:n}=e;f(this,Be,document.getElementById(t));const r=document.createElement("button");r.className=n!=null&&n.buttonClass?n==null?void 0:n.buttonClass:"browse-image-button";const s=document.createElement("span");s.textContent=n!=null&&n.buttonText?n==null?void 0:n.buttonText:"Browse Files";const o=document.createElement("span");return o.innerHTML=n!=null&&n.buttonIcon?n==null?void 0:n.buttonIcon:"",r.type="button",r.append(s,o),n!=null&&n.buttonStyle&&Object.assign(r.style,n==null?void 0:n.buttonStyle),r.addEventListener("click",()=>{this._selectedImageContainer()}),d(this,Be)&&d(this,Be).appendChild(r),d(this,Be)}async _grpcOptionInitializer(){f(this,J,await Ui(d(this,je)))}_selectedImageContainer(){var g;f(this,ke,ee(`Save (${(g=d(this,S))==null?void 0:g.length})`,"dialog-btn confirm")),f(this,Ie,k("folder-container")),f(this,we,k("folder-list-wrapper")),this._fetchAllFolders();const e=ee("Cancel","dialog-btn cancel");ee("","dialog-modal-close-btn","",!1,'<svg xmlns="http://www.w3.org/2000/svg" x="0px" y="0px" width="24" height="24" viewBox="0 0 50 50"> <path d="M 9.15625 6.3125 L 6.3125 9.15625 L 22.15625 25 L 6.21875 40.96875 L 9.03125 43.78125 L 25 27.84375 L 40.9375 43.78125 L 43.78125 40.9375 L 27.84375 25 L 43.6875 9.15625 L 40.84375 6.3125 L 25 22.15625 Z"></path> </svg>').addEventListener("click",()=>{Xe.hide(),f(this,S,[]),f(this,R,[])}),f(this,ve,k("browse-container"));const n=k();n.style.display="flex",n.style.alignItems="center",n.style.justifyContent="space-between",n.style.padding="10px 20px";const r=Ue("Folders","folder-title"),s=ee("","add-folder-btn");s.append(Jt()),this._createUpdateFolderDialog(s,"create"),n.append(r,s),d(this,Ie).append(n,d(this,we));const o=this._renderSearchField(),a=this._createBrowseMoreContainer(),l=this._createBrowseImageMain(),c=k("footer");e.onclick=()=>{Xe.hide(),f(this,R,[]),f(this,S,[])},d(this,ke).onclick=()=>{d(this,$e).call(this),Xe.hide(),f(this,S,[]),f(this,R,[])},c.append(d(this,ke),e);const h=k("container-right-main");h.append(o,a,l,c),d(this,ve).append(d(this,Ie),h),Xe.show({content:d(this,ve)})}_createAllAndSelectedTab(e){const t=k("select-options"),n=Ue("Browse","select"),r=Ue("Selected","select","selected-images-tab");n.classList.add("selected"),[n,r].forEach((o,a)=>{o.addEventListener("click",()=>{var l;f(this,Le,a),(l=document.querySelector(".select.selected"))==null||l.classList.remove("selected"),o.classList.add("selected"),this._updateSelectedImageListContainerUI()})}),t.append(n,r),e.appendChild(t)}_renderUploadButton(){const e=Et("file");e.style.display="none",e.setAttribute("multiple","true"),e.setAttribute("accept","image/*,video/*,audio/*,.gif"),f(this,ge,document.createElement("button")),d(this,ge).className="browse-more-btn";const t=document.createElement("span");return t.textContent="Upload",d(this,ge).append(xi(),t),d(this,ge).type="button",d(this,ge).addEventListener("click",()=>e.click()),e.addEventListener("change",()=>{const n=e.files;Object.values(n).forEach(r=>{const s=new FileReader;s.readAsDataURL(r),s.onload=async()=>{await this._uploadAndAddSelectedImageList(s.result,r)}}),e.value=""}),d(this,ge)}_renderCreateFolderBtn(){const e=document.createElement("button");e.className="create-folder-btn";const t=document.createElement("span");return t.textContent="Create",e.append(Jt(),t),this._createUpdateFolderDialog(e,"create"),e}_renderSearchField(){let e;const t=k("search-browse-container"),n=k("search-input-wrapper","search-input-wrapper");f(this,Ae,Et("search")),d(this,Ae).value="",d(this,Ae).addEventListener("input",s=>{f(this,R,[]);const o=s.target;e&&clearTimeout(e),e=setTimeout(()=>{if(!o.value){f(this,he,""),f(this,Fe,!1),f(this,be,!1),this._fetchFilesFromFolder(d(this,Ne));return}f(this,be,!0),f(this,De,o.value),this._search(d(this,De))},750)}),d(this,Ae).setAttribute("placeholder","Search");const r=Oi();return r.style.position="absolute",r.style.top="50%",r.style.left="5%",r.style.transform="translate(-5%, -50%)",n.append(r,d(this,Ae)),t.append(n),t}_createBrowseMoreContainer(){f(this,Oe,k("browse-more-btn-container")),this._createAllAndSelectedTab(d(this,Oe));const e=this._renderUploadButton(),t=this._renderCreateFolderBtn(),n=document.createElement("div");return n.style.display="flex",n.style.alignItems="center",n.style.gap="10px",n.append(e,t),d(this,Oe).appendChild(n),d(this,Oe)}_createBrowseImageMain(){const e=k("browse-image-main");return f(this,D,k("selected-image-container")),d(this,D).addEventListener("scroll",()=>{const t=d(this,D).clientHeight,n=d(this,D).scrollTop,r=d(this,D).scrollHeight;t+n>=r-5&&d(this,Fe)&&(d(this,be)?this._search(d(this,De)):this._fetchFilesFromFolder(d(this,Ne)))}),this._updateSelectedImageListContainerUI(),e.appendChild(d(this,D)),e}_renderFetchingSkeletonUI(){for(let e=0;e<6;e++){const t=k("skeleton");t.innerHTML="",d(this,D).append(t)}}_renderEmptyImageContainer(){if(d(this,z)||d(this,Ee))return;const e=k(),t=k(),n=document.createElement("p");d(this,be)&&d(this,Le)===0?(t.innerHTML=`
2
+ (function(I,y){typeof exports=="object"&&typeof module<"u"?module.exports=y():typeof define=="function"&&define.amd?define(y):(I=typeof globalThis<"u"?globalThis:I||self,I.ImageSalonSdk=y())})(this,function(){"use strict";var Gi=Object.defineProperty;var cn=I=>{throw TypeError(I)};var Ji=(I,y,H)=>y in I?Gi(I,y,{enumerable:!0,configurable:!0,writable:!0,value:H}):I[y]=H;var _=(I,y,H)=>Ji(I,typeof y!="symbol"?y+"":y,H),dn=(I,y,H)=>y.has(I)||cn("Cannot "+H);var d=(I,y,H)=>(dn(I,y,"read from private field"),H?H.call(I):y.get(I)),L=(I,y,H)=>y.has(I)?cn("Cannot add the same private member more than once"):y instanceof WeakSet?y.add(I):y.set(I,H),f=(I,y,H,Se)=>(dn(I,y,"write to private field"),Se?Se.call(I,H):y.set(I,H),H);var me,Be,ve,D,ge,S,R,Ee,z,_e,Ne,ce,ie,ke,$e,Le,Ie,we,Oe,de,he,Fe,Ae,be,De,je,J,re,Pe,We,Te;function I(i="#333"){const e=document.createElementNS("http://www.w3.org/2000/svg","svg");e.setAttribute("xmlns","http://www.w3.org/2000/svg"),e.setAttribute("x","0px"),e.setAttribute("y","0px"),e.setAttribute("width","18"),e.setAttribute("height","18"),e.setAttribute("viewBox","0 0 50 50"),e.setAttribute("fill",i);const t=document.createElementNS("http://www.w3.org/2000/svg","path");return t.setAttribute("d","M 9.15625 6.3125 L 6.3125 9.15625 L 22.15625 25 L 6.21875 40.96875 L 9.03125 43.78125 L 25 27.84375 L 40.9375 43.78125 L 43.78125 40.9375 L 27.84375 25 L 43.6875 9.15625 L 40.84375 6.3125 L 25 22.15625 Z"),e.appendChild(t),e}function y(i,e,t){let n=document.createElement(i);return n.className+=e,t&&t.appendChild(n),n}class H{constructor(){L(this,me);f(this,me,document.createElementNS("http://www.w3.org/2000/svg","svg")),d(this,me).setAttribute("viewBox","25 25 50 50"),d(this,me).classList.add("loader-svg");const e=document.createElementNS("http://www.w3.org/2000/svg","circle");e.setAttribute("r","20"),e.setAttribute("cy","50"),e.setAttribute("cx","50"),e.classList.add("loader-circle"),d(this,me).appendChild(e)}show(e){e.appendChild(d(this,me))}hide(){d(this,me).remove()}}me=new WeakMap;const Se=new H,Ke=document.body;class Ct{constructor(){_(this,"main");_(this,"dialogContainer");_(this,"dialog");_(this,"dialogBackdrop");_(this,"dialogContent");_(this,"dialogHeader");_(this,"dialogBody");_(this,"dialogFooter");_(this,"confirmButton");_(this,"cancelButton");_(this,"confirmCallback");_(this,"cancelCallback");this.main=y("div"),this.dialog=y("div"),this.confirmCallback=void 0,this.cancelCallback=void 0}_init(e){if(this.main=y("div","dialog-presentation",Ke),this.main.setAttribute("role","presentation"),this.dialogContainer=y("div","dialog-container",this.main),this.dialogBackdrop=y("div","dialog-backdrop",this.dialogContainer),this.dialog=y("div","dialog",this.dialogContainer),this.dialog.className="dialog",this.dialogContent=y("div","dialog-content",this.dialog),e!=null&&e.dialogContentStyle&&Object.assign(this.dialogContent.style,e.dialogContentStyle),this.confirmButton=y("button","dialog-btn confirm",this.dialogFooter),this.confirmButton.type="button",this.cancelButton=y("button","dialog-btn cancel",this.dialogFooter),this.cancelButton.type="button",e.showCloseBtn){const t=y("button","dialog-close-btn",this.dialogContent);t.appendChild(I()),t.onclick=()=>this.hide()}return e.header&&this._setHeader(e),this._setBody(e),this._setFooter(e),this.confirmButton.textContent=e.confirmButtonText||"Upload",this.cancelButton.textContent=e.cancelButtonText||"Cancel",Ke.style.overflow="hidden",this.confirmButton.textContent=e.confirmButtonText||"Upload",this.cancelButton.textContent=e.cancelButtonText||"Cancel",Ke.classList.add("dialog-visible"),new Promise(t=>{const n=r=>()=>{this.hide(),t(r==="confirm")};this.confirmCallback=e.onConfirm||n("confirm"),this.confirmButton.addEventListener("click",this.confirmCallback),this.cancelCallback=e.onCancel||n("cancel"),this.cancelButton.addEventListener("click",this.cancelCallback)})}_setHeader(e){if(this.dialogHeader=y("div","dialog-header",this.dialogContent),!e.header)this.dialogHeader.innerHTML="";else if(typeof e.header=="string"){const t=y("h4","dialog-header-text",this.dialogHeader);t.textContent=e.header}else this.dialogHeader.innerHTML="",this.dialogHeader.appendChild(e.header)}_setBody(e){this.dialogBody=y("div","dialog-body",this.dialogContent),typeof e.content=="string"?this.dialogBody.innerHTML=e.content:(this.dialogBody.innerHTML="",this.dialogBody.appendChild(e.content))}_setFooter(e){this.dialogFooter=y("div","dialog-footer",this.dialogContent),e.showFooter?this.dialogFooter.append(this.confirmButton,this.cancelButton):(this.dialogFooter.innerHTML="",this.dialogFooter.remove())}show(e){this._init(e),setTimeout(()=>{this.dialogContainer.style.opacity="1",this.dialog.style.transform="scale(1)",this.dialog.style.transition="transform 150ms ease-in",this.dialog.style.opacity="1",this.dialogBackdrop.style.opacity="1"},150)}hide(){this.main||Ke.style.removeProperty("overflow"),this.dialog.style.transform="scale(0.8)",this.dialog.style.transition="transform 150ms ease-out",this.dialogBackdrop.style.opacity="0",setTimeout(()=>{this.dialogContainer.style.opacity="0",this.dialog.style.opacity="0",this.dialogContent.style.opacity="0",this.main.remove()},150)}updateUploadBtn(e){e?(Se.show(this.confirmButton),this.confirmButton.disabled=!0):(Se.hide(),this.confirmButton.disabled=!1)}}const Xe=new Ct,M=new Ct;function k(i,e){const t=document.createElement("div");return i&&(t.className=i),e&&(t.id=e),t}function Ue(i,e,t){const n=document.createElement("p");return e&&(n.className=e),t&&(n.id=t),i&&(n.textContent=i),n}function Q(i,e){const t=document.createElement("span");return e&&(t.className=e),i&&(t.textContent=i),t}function hn(i,e,t,n){const r=document.createElement("img");return r.className=e,r.src=i,r}function un(i,e,t){const n=document.createElement("video"),r=document.createElement("source");return n.className=e,r.src=i,n.appendChild(r),n}function fn(i,e,t){const n=document.createElement("audio"),r=document.createElement("source");return n.className=e,n.controls=!0,r.src=i,n.appendChild(r),n}function ee(i,e,t,n,r){const s=document.createElement("button");return e&&(s.className=e),t&&(s.id=t),i&&(s.textContent=i),r&&(s.innerHTML=r),s.disabled=n,s}function Et(i,e,t){const n=document.createElement("input");return n.className=e,n.defaultValue=t,i&&(n.type=i),n}function Nt(i){let e=typeof i;if(e=="object"){if(Array.isArray(i))return"array";if(i===null)return"null"}return e}function pn(i){return i!==null&&typeof i=="object"&&!Array.isArray(i)}let ue="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".split(""),Ge=[];for(let i=0;i<ue.length;i++)Ge[ue[i].charCodeAt(0)]=i;Ge[45]=ue.indexOf("+"),Ge[95]=ue.indexOf("/");function kt(i){let e=i.length*3/4;i[i.length-2]=="="?e-=2:i[i.length-1]=="="&&(e-=1);let t=new Uint8Array(e),n=0,r=0,s,o=0;for(let a=0;a<i.length;a++){if(s=Ge[i.charCodeAt(a)],s===void 0)switch(i[a]){case"=":r=0;case`
3
+ `:case"\r":case" ":case" ":continue;default:throw Error("invalid base64 string.")}switch(r){case 0:o=s,r=1;break;case 1:t[n++]=o<<2|(s&48)>>4,o=s,r=2;break;case 2:t[n++]=(o&15)<<4|(s&60)>>2,o=s,r=3;break;case 3:t[n++]=(o&3)<<6|s,r=0;break}}if(r==1)throw Error("invalid base64 string.");return t.subarray(0,n)}function Lt(i){let e="",t=0,n,r=0;for(let s=0;s<i.length;s++)switch(n=i[s],t){case 0:e+=ue[n>>2],r=(n&3)<<4,t=1;break;case 1:e+=ue[r|n>>4],r=(n&15)<<2,t=2;break;case 2:e+=ue[r|n>>6],e+=ue[n&63],t=0;break}return t&&(e+=ue[r],e+="=",t==1&&(e+="=")),e}var N;(function(i){i.symbol=Symbol.for("protobuf-ts/unknown"),i.onRead=(t,n,r,s,o)=>{(e(n)?n[i.symbol]:n[i.symbol]=[]).push({no:r,wireType:s,data:o})},i.onWrite=(t,n,r)=>{for(let{no:s,wireType:o,data:a}of i.list(n))r.tag(s,o).raw(a)},i.list=(t,n)=>{if(e(t)){let r=t[i.symbol];return n?r.filter(s=>s.no==n):r}return[]},i.last=(t,n)=>i.list(t,n).slice(-1)[0];const e=t=>t&&Array.isArray(t[i.symbol])})(N||(N={}));function mn(i,e){return Object.assign(Object.assign({},i),e)}var m;(function(i){i[i.Varint=0]="Varint",i[i.Bit64=1]="Bit64",i[i.LengthDelimited=2]="LengthDelimited",i[i.StartGroup=3]="StartGroup",i[i.EndGroup=4]="EndGroup",i[i.Bit32=5]="Bit32"})(m||(m={}));function gn(){let i=0,e=0;for(let n=0;n<28;n+=7){let r=this.buf[this.pos++];if(i|=(r&127)<<n,!(r&128))return this.assertBounds(),[i,e]}let t=this.buf[this.pos++];if(i|=(t&15)<<28,e=(t&112)>>4,!(t&128))return this.assertBounds(),[i,e];for(let n=3;n<=31;n+=7){let r=this.buf[this.pos++];if(e|=(r&127)<<n,!(r&128))return this.assertBounds(),[i,e]}throw new Error("invalid varint")}function ot(i,e,t){for(let s=0;s<28;s=s+7){const o=i>>>s,a=!(!(o>>>7)&&e==0),l=(a?o|128:o)&255;if(t.push(l),!a)return}const n=i>>>28&15|(e&7)<<4,r=!!(e>>3);if(t.push((r?n|128:n)&255),!!r){for(let s=3;s<31;s=s+7){const o=e>>>s,a=!!(o>>>7),l=(a?o|128:o)&255;if(t.push(l),!a)return}t.push(e>>>31&1)}}const Je=65536*65536;function It(i){let e=i[0]=="-";e&&(i=i.slice(1));const t=1e6;let n=0,r=0;function s(o,a){const l=Number(i.slice(o,a));r*=t,n=n*t+l,n>=Je&&(r=r+(n/Je|0),n=n%Je)}return s(-24,-18),s(-18,-12),s(-12,-6),s(-6),[e,n,r]}function at(i,e){if(e>>>0<=2097151)return""+(Je*e+(i>>>0));let t=i&16777215,n=(i>>>24|e<<8)>>>0&16777215,r=e>>16&65535,s=t+n*6777216+r*6710656,o=n+r*8147497,a=r*2,l=1e7;s>=l&&(o+=Math.floor(s/l),s%=l),o>=l&&(a+=Math.floor(o/l),o%=l);function c(h,g){let w=h?String(h):"";return g?"0000000".slice(w.length)+w:w}return c(a,0)+c(o,a)+c(s,1)}function Ft(i,e){if(i>=0){for(;i>127;)e.push(i&127|128),i=i>>>7;e.push(i)}else{for(let t=0;t<9;t++)e.push(i&127|128),i=i>>7;e.push(1)}}function wn(){let i=this.buf[this.pos++],e=i&127;if(!(i&128))return this.assertBounds(),e;if(i=this.buf[this.pos++],e|=(i&127)<<7,!(i&128))return this.assertBounds(),e;if(i=this.buf[this.pos++],e|=(i&127)<<14,!(i&128))return this.assertBounds(),e;if(i=this.buf[this.pos++],e|=(i&127)<<21,!(i&128))return this.assertBounds(),e;i=this.buf[this.pos++],e|=(i&15)<<28;for(let t=5;i&128&&t<10;t++)i=this.buf[this.pos++];if(i&128)throw new Error("invalid varint");return this.assertBounds(),e>>>0}let T;function bn(){const i=new DataView(new ArrayBuffer(8));T=globalThis.BigInt!==void 0&&typeof i.getBigInt64=="function"&&typeof i.getBigUint64=="function"&&typeof i.setBigInt64=="function"&&typeof i.setBigUint64=="function"?{MIN:BigInt("-9223372036854775808"),MAX:BigInt("9223372036854775807"),UMIN:BigInt("0"),UMAX:BigInt("18446744073709551615"),C:BigInt,V:i}:void 0}bn();function At(i){if(!i)throw new Error("BigInt unavailable, see https://github.com/timostamm/protobuf-ts/blob/v1.0.8/MANUAL.md#bigint-support")}const Tt=/^-?[0-9]+$/,Ye=4294967296,ze=2147483648;class Bt{constructor(e,t){this.lo=e|0,this.hi=t|0}isZero(){return this.lo==0&&this.hi==0}toNumber(){let e=this.hi*Ye+(this.lo>>>0);if(!Number.isSafeInteger(e))throw new Error("cannot convert to safe number");return e}}class $ extends Bt{static from(e){if(T)switch(typeof e){case"string":if(e=="0")return this.ZERO;if(e=="")throw new Error("string is no integer");e=T.C(e);case"number":if(e===0)return this.ZERO;e=T.C(e);case"bigint":if(!e)return this.ZERO;if(e<T.UMIN)throw new Error("signed value for ulong");if(e>T.UMAX)throw new Error("ulong too large");return T.V.setBigUint64(0,e,!0),new $(T.V.getInt32(0,!0),T.V.getInt32(4,!0))}else switch(typeof e){case"string":if(e=="0")return this.ZERO;if(e=e.trim(),!Tt.test(e))throw new Error("string is no integer");let[t,n,r]=It(e);if(t)throw new Error("signed value for ulong");return new $(n,r);case"number":if(e==0)return this.ZERO;if(!Number.isSafeInteger(e))throw new Error("number is no integer");if(e<0)throw new Error("signed value for ulong");return new $(e,e/Ye)}throw new Error("unknown value "+typeof e)}toString(){return T?this.toBigInt().toString():at(this.lo,this.hi)}toBigInt(){return At(T),T.V.setInt32(0,this.lo,!0),T.V.setInt32(4,this.hi,!0),T.V.getBigUint64(0,!0)}}$.ZERO=new $(0,0);class x extends Bt{static from(e){if(T)switch(typeof e){case"string":if(e=="0")return this.ZERO;if(e=="")throw new Error("string is no integer");e=T.C(e);case"number":if(e===0)return this.ZERO;e=T.C(e);case"bigint":if(!e)return this.ZERO;if(e<T.MIN)throw new Error("signed long too small");if(e>T.MAX)throw new Error("signed long too large");return T.V.setBigInt64(0,e,!0),new x(T.V.getInt32(0,!0),T.V.getInt32(4,!0))}else switch(typeof e){case"string":if(e=="0")return this.ZERO;if(e=e.trim(),!Tt.test(e))throw new Error("string is no integer");let[t,n,r]=It(e);if(t){if(r>ze||r==ze&&n!=0)throw new Error("signed long too small")}else if(r>=ze)throw new Error("signed long too large");let s=new x(n,r);return t?s.negate():s;case"number":if(e==0)return this.ZERO;if(!Number.isSafeInteger(e))throw new Error("number is no integer");return e>0?new x(e,e/Ye):new x(-e,-e/Ye).negate()}throw new Error("unknown value "+typeof e)}isNegative(){return(this.hi&ze)!==0}negate(){let e=~this.hi,t=this.lo;return t?t=~t+1:e+=1,new x(t,e)}toString(){if(T)return this.toBigInt().toString();if(this.isNegative()){let e=this.negate();return"-"+at(e.lo,e.hi)}return at(this.lo,this.hi)}toBigInt(){return At(T),T.V.setInt32(0,this.lo,!0),T.V.setInt32(4,this.hi,!0),T.V.getBigInt64(0,!0)}}x.ZERO=new x(0,0);const vt={readUnknownField:!0,readerFactory:i=>new Cn(i)};function yn(i){return i?Object.assign(Object.assign({},vt),i):vt}class Cn{constructor(e,t){this.varint64=gn,this.uint32=wn,this.buf=e,this.len=e.length,this.pos=0,this.view=new DataView(e.buffer,e.byteOffset,e.byteLength),this.textDecoder=t??new TextDecoder("utf-8",{fatal:!0,ignoreBOM:!0})}tag(){let e=this.uint32(),t=e>>>3,n=e&7;if(t<=0||n<0||n>5)throw new Error("illegal tag: field no "+t+" wire type "+n);return[t,n]}skip(e){let t=this.pos;switch(e){case m.Varint:for(;this.buf[this.pos++]&128;);break;case m.Bit64:this.pos+=4;case m.Bit32:this.pos+=4;break;case m.LengthDelimited:let n=this.uint32();this.pos+=n;break;case m.StartGroup:let r;for(;(r=this.tag()[1])!==m.EndGroup;)this.skip(r);break;default:throw new Error("cant skip wire type "+e)}return this.assertBounds(),this.buf.subarray(t,this.pos)}assertBounds(){if(this.pos>this.len)throw new RangeError("premature EOF")}int32(){return this.uint32()|0}sint32(){let e=this.uint32();return e>>>1^-(e&1)}int64(){return new x(...this.varint64())}uint64(){return new $(...this.varint64())}sint64(){let[e,t]=this.varint64(),n=-(e&1);return e=(e>>>1|(t&1)<<31)^n,t=t>>>1^n,new x(e,t)}bool(){let[e,t]=this.varint64();return e!==0||t!==0}fixed32(){return this.view.getUint32((this.pos+=4)-4,!0)}sfixed32(){return this.view.getInt32((this.pos+=4)-4,!0)}fixed64(){return new $(this.sfixed32(),this.sfixed32())}sfixed64(){return new x(this.sfixed32(),this.sfixed32())}float(){return this.view.getFloat32((this.pos+=4)-4,!0)}double(){return this.view.getFloat64((this.pos+=8)-8,!0)}bytes(){let e=this.uint32(),t=this.pos;return this.pos+=e,this.assertBounds(),this.buf.subarray(t,t+e)}string(){return this.textDecoder.decode(this.bytes())}}function E(i,e){if(!i)throw new Error(e)}const En=34028234663852886e22,Nn=-34028234663852886e22,kn=4294967295,Ln=2147483647,In=-2147483648;function Re(i){if(typeof i!="number")throw new Error("invalid int 32: "+typeof i);if(!Number.isInteger(i)||i>Ln||i<In)throw new Error("invalid int 32: "+i)}function Qe(i){if(typeof i!="number")throw new Error("invalid uint 32: "+typeof i);if(!Number.isInteger(i)||i>kn||i<0)throw new Error("invalid uint 32: "+i)}function lt(i){if(typeof i!="number")throw new Error("invalid float 32: "+typeof i);if(Number.isFinite(i)&&(i>En||i<Nn))throw new Error("invalid float 32: "+i)}const _t={writeUnknownFields:!0,writerFactory:()=>new An};function Fn(i){return i?Object.assign(Object.assign({},_t),i):_t}class An{constructor(e){this.stack=[],this.textEncoder=e??new TextEncoder,this.chunks=[],this.buf=[]}finish(){this.chunks.push(new Uint8Array(this.buf));let e=0;for(let r=0;r<this.chunks.length;r++)e+=this.chunks[r].length;let t=new Uint8Array(e),n=0;for(let r=0;r<this.chunks.length;r++)t.set(this.chunks[r],n),n+=this.chunks[r].length;return this.chunks=[],t}fork(){return this.stack.push({chunks:this.chunks,buf:this.buf}),this.chunks=[],this.buf=[],this}join(){let e=this.finish(),t=this.stack.pop();if(!t)throw new Error("invalid state, fork stack empty");return this.chunks=t.chunks,this.buf=t.buf,this.uint32(e.byteLength),this.raw(e)}tag(e,t){return this.uint32((e<<3|t)>>>0)}raw(e){return this.buf.length&&(this.chunks.push(new Uint8Array(this.buf)),this.buf=[]),this.chunks.push(e),this}uint32(e){for(Qe(e);e>127;)this.buf.push(e&127|128),e=e>>>7;return this.buf.push(e),this}int32(e){return Re(e),Ft(e,this.buf),this}bool(e){return this.buf.push(e?1:0),this}bytes(e){return this.uint32(e.byteLength),this.raw(e)}string(e){let t=this.textEncoder.encode(e);return this.uint32(t.byteLength),this.raw(t)}float(e){lt(e);let t=new Uint8Array(4);return new DataView(t.buffer).setFloat32(0,e,!0),this.raw(t)}double(e){let t=new Uint8Array(8);return new DataView(t.buffer).setFloat64(0,e,!0),this.raw(t)}fixed32(e){Qe(e);let t=new Uint8Array(4);return new DataView(t.buffer).setUint32(0,e,!0),this.raw(t)}sfixed32(e){Re(e);let t=new Uint8Array(4);return new DataView(t.buffer).setInt32(0,e,!0),this.raw(t)}sint32(e){return Re(e),e=(e<<1^e>>31)>>>0,Ft(e,this.buf),this}sfixed64(e){let t=new Uint8Array(8),n=new DataView(t.buffer),r=x.from(e);return n.setInt32(0,r.lo,!0),n.setInt32(4,r.hi,!0),this.raw(t)}fixed64(e){let t=new Uint8Array(8),n=new DataView(t.buffer),r=$.from(e);return n.setInt32(0,r.lo,!0),n.setInt32(4,r.hi,!0),this.raw(t)}int64(e){let t=x.from(e);return ot(t.lo,t.hi,this.buf),this}sint64(e){let t=x.from(e),n=t.hi>>31,r=t.lo<<1^n,s=(t.hi<<1|t.lo>>>31)^n;return ot(r,s,this.buf),this}uint64(e){let t=$.from(e);return ot(t.lo,t.hi,this.buf),this}}const Ot={emitDefaultValues:!1,enumAsInteger:!1,useProtoFieldName:!1,prettySpaces:0},xt={ignoreUnknownFields:!1};function Tn(i){return i?Object.assign(Object.assign({},xt),i):xt}function Bn(i){return i?Object.assign(Object.assign({},Ot),i):Ot}function vn(i,e){var t,n;let r=Object.assign(Object.assign({},i),e);return r.typeRegistry=[...(t=i==null?void 0:i.typeRegistry)!==null&&t!==void 0?t:[],...(n=e==null?void 0:e.typeRegistry)!==null&&n!==void 0?n:[]],r}const Dt=Symbol.for("protobuf-ts/message-type");function ct(i){let e=!1;const t=[];for(let n=0;n<i.length;n++){let r=i.charAt(n);r=="_"?e=!0:/\d/.test(r)?(t.push(r),e=!0):e?(t.push(r.toUpperCase()),e=!1):n==0?t.push(r.toLowerCase()):t.push(r)}return t.join("")}var u;(function(i){i[i.DOUBLE=1]="DOUBLE",i[i.FLOAT=2]="FLOAT",i[i.INT64=3]="INT64",i[i.UINT64=4]="UINT64",i[i.INT32=5]="INT32",i[i.FIXED64=6]="FIXED64",i[i.FIXED32=7]="FIXED32",i[i.BOOL=8]="BOOL",i[i.STRING=9]="STRING",i[i.BYTES=12]="BYTES",i[i.UINT32=13]="UINT32",i[i.SFIXED32=15]="SFIXED32",i[i.SFIXED64=16]="SFIXED64",i[i.SINT32=17]="SINT32",i[i.SINT64=18]="SINT64"})(u||(u={}));var oe;(function(i){i[i.BIGINT=0]="BIGINT",i[i.STRING=1]="STRING",i[i.NUMBER=2]="NUMBER"})(oe||(oe={}));var et;(function(i){i[i.NO=0]="NO",i[i.PACKED=1]="PACKED",i[i.UNPACKED=2]="UNPACKED"})(et||(et={}));function _n(i){var e,t,n,r;return i.localName=(e=i.localName)!==null&&e!==void 0?e:ct(i.name),i.jsonName=(t=i.jsonName)!==null&&t!==void 0?t:ct(i.name),i.repeat=(n=i.repeat)!==null&&n!==void 0?n:et.NO,i.opt=(r=i.opt)!==null&&r!==void 0?r:i.repeat||i.oneof?!1:i.kind=="message",i}function On(i){if(typeof i!="object"||i===null||!i.hasOwnProperty("oneofKind"))return!1;switch(typeof i.oneofKind){case"string":return i[i.oneofKind]===void 0?!1:Object.keys(i).length==2;case"undefined":return Object.keys(i).length==1;default:return!1}}class xn{constructor(e){var t;this.fields=(t=e.fields)!==null&&t!==void 0?t:[]}prepare(){if(this.data)return;const e=[],t=[],n=[];for(let r of this.fields)if(r.oneof)n.includes(r.oneof)||(n.push(r.oneof),e.push(r.oneof),t.push(r.oneof));else switch(t.push(r.localName),r.kind){case"scalar":case"enum":(!r.opt||r.repeat)&&e.push(r.localName);break;case"message":r.repeat&&e.push(r.localName);break;case"map":e.push(r.localName);break}this.data={req:e,known:t,oneofs:Object.values(n)}}is(e,t,n=!1){if(t<0)return!0;if(e==null||typeof e!="object")return!1;this.prepare();let r=Object.keys(e),s=this.data;if(r.length<s.req.length||s.req.some(o=>!r.includes(o))||!n&&r.some(o=>!s.known.includes(o)))return!1;if(t<1)return!0;for(const o of s.oneofs){const a=e[o];if(!On(a))return!1;if(a.oneofKind===void 0)continue;const l=this.fields.find(c=>c.localName===a.oneofKind);if(!l||!this.field(a[a.oneofKind],l,n,t))return!1}for(const o of this.fields)if(o.oneof===void 0&&!this.field(e[o.localName],o,n,t))return!1;return!0}field(e,t,n,r){let s=t.repeat;switch(t.kind){case"scalar":return e===void 0?t.opt:s?this.scalars(e,t.T,r,t.L):this.scalar(e,t.T,t.L);case"enum":return e===void 0?t.opt:s?this.scalars(e,u.INT32,r):this.scalar(e,u.INT32);case"message":return e===void 0?!0:s?this.messages(e,t.T(),n,r):this.message(e,t.T(),n,r);case"map":if(typeof e!="object"||e===null)return!1;if(r<2)return!0;if(!this.mapKeys(e,t.K,r))return!1;switch(t.V.kind){case"scalar":return this.scalars(Object.values(e),t.V.T,r,t.V.L);case"enum":return this.scalars(Object.values(e),u.INT32,r);case"message":return this.messages(Object.values(e),t.V.T(),n,r)}break}return!0}message(e,t,n,r){return n?t.isAssignable(e,r):t.is(e,r)}messages(e,t,n,r){if(!Array.isArray(e))return!1;if(r<2)return!0;if(n){for(let s=0;s<e.length&&s<r;s++)if(!t.isAssignable(e[s],r-1))return!1}else for(let s=0;s<e.length&&s<r;s++)if(!t.is(e[s],r-1))return!1;return!0}scalar(e,t,n){let r=typeof e;switch(t){case u.UINT64:case u.FIXED64:case u.INT64:case u.SFIXED64:case u.SINT64:switch(n){case oe.BIGINT:return r=="bigint";case oe.NUMBER:return r=="number"&&!isNaN(e);default:return r=="string"}case u.BOOL:return r=="boolean";case u.STRING:return r=="string";case u.BYTES:return e instanceof Uint8Array;case u.DOUBLE:case u.FLOAT:return r=="number"&&!isNaN(e);default:return r=="number"&&Number.isInteger(e)}}scalars(e,t,n,r){if(!Array.isArray(e))return!1;if(n<2)return!0;if(Array.isArray(e)){for(let s=0;s<e.length&&s<n;s++)if(!this.scalar(e[s],t,r))return!1}return!0}mapKeys(e,t,n){let r=Object.keys(e);switch(t){case u.INT32:case u.FIXED32:case u.SFIXED32:case u.SINT32:case u.UINT32:return this.scalars(r.slice(0,n).map(s=>parseInt(s)),t,n);case u.BOOL:return this.scalars(r.slice(0,n).map(s=>s=="true"?!0:s=="false"?!1:s),t,n);default:return this.scalars(r,t,n,oe.STRING)}}}function te(i,e){switch(e){case oe.BIGINT:return i.toBigInt();case oe.NUMBER:return i.toNumber();default:return i.toString()}}class Dn{constructor(e){this.info=e}prepare(){var e;if(this.fMap===void 0){this.fMap={};const t=(e=this.info.fields)!==null&&e!==void 0?e:[];for(const n of t)this.fMap[n.name]=n,this.fMap[n.jsonName]=n,this.fMap[n.localName]=n}}assert(e,t,n){if(!e){let r=Nt(n);throw(r=="number"||r=="boolean")&&(r=n.toString()),new Error(`Cannot parse JSON ${r} for ${this.info.typeName}#${t}`)}}read(e,t,n){this.prepare();const r=[];for(const[s,o]of Object.entries(e)){const a=this.fMap[s];if(!a){if(!n.ignoreUnknownFields)throw new Error(`Found unknown field while reading ${this.info.typeName} from JSON format. JSON key: ${s}`);continue}const l=a.localName;let c;if(a.oneof){if(o===null&&(a.kind!=="enum"||a.T()[0]!=="google.protobuf.NullValue"))continue;if(r.includes(a.oneof))throw new Error(`Multiple members of the oneof group "${a.oneof}" of ${this.info.typeName} are present in JSON.`);r.push(a.oneof),c=t[a.oneof]={oneofKind:l}}else c=t;if(a.kind=="map"){if(o===null)continue;this.assert(pn(o),a.name,o);const h=c[l];for(const[g,w]of Object.entries(o)){this.assert(w!==null,a.name+" map value",null);let F;switch(a.V.kind){case"message":F=a.V.T().internalJsonRead(w,n);break;case"enum":if(F=this.enum(a.V.T(),w,a.name,n.ignoreUnknownFields),F===!1)continue;break;case"scalar":F=this.scalar(w,a.V.T,a.V.L,a.name);break}this.assert(F!==void 0,a.name+" map value",w);let v=g;a.K==u.BOOL&&(v=v=="true"?!0:v=="false"?!1:v),v=this.scalar(v,a.K,oe.STRING,a.name).toString(),h[v]=F}}else if(a.repeat){if(o===null)continue;this.assert(Array.isArray(o),a.name,o);const h=c[l];for(const g of o){this.assert(g!==null,a.name,null);let w;switch(a.kind){case"message":w=a.T().internalJsonRead(g,n);break;case"enum":if(w=this.enum(a.T(),g,a.name,n.ignoreUnknownFields),w===!1)continue;break;case"scalar":w=this.scalar(g,a.T,a.L,a.name);break}this.assert(w!==void 0,a.name,o),h.push(w)}}else switch(a.kind){case"message":if(o===null&&a.T().typeName!="google.protobuf.Value"){this.assert(a.oneof===void 0,a.name+" (oneof member)",null);continue}c[l]=a.T().internalJsonRead(o,n,c[l]);break;case"enum":let h=this.enum(a.T(),o,a.name,n.ignoreUnknownFields);if(h===!1)continue;c[l]=h;break;case"scalar":c[l]=this.scalar(o,a.T,a.L,a.name);break}}}enum(e,t,n,r){if(e[0]=="google.protobuf.NullValue"&&E(t===null||t==="NULL_VALUE",`Unable to parse field ${this.info.typeName}#${n}, enum ${e[0]} only accepts null.`),t===null)return 0;switch(typeof t){case"number":return E(Number.isInteger(t),`Unable to parse field ${this.info.typeName}#${n}, enum can only be integral number, got ${t}.`),t;case"string":let s=t;e[2]&&t.substring(0,e[2].length)===e[2]&&(s=t.substring(e[2].length));let o=e[1][s];return typeof o>"u"&&r?!1:(E(typeof o=="number",`Unable to parse field ${this.info.typeName}#${n}, enum ${e[0]} has no value for "${t}".`),o)}E(!1,`Unable to parse field ${this.info.typeName}#${n}, cannot parse enum value from ${typeof t}".`)}scalar(e,t,n,r){let s;try{switch(t){case u.DOUBLE:case u.FLOAT:if(e===null)return 0;if(e==="NaN")return Number.NaN;if(e==="Infinity")return Number.POSITIVE_INFINITY;if(e==="-Infinity")return Number.NEGATIVE_INFINITY;if(e===""){s="empty string";break}if(typeof e=="string"&&e.trim().length!==e.length){s="extra whitespace";break}if(typeof e!="string"&&typeof e!="number")break;let o=Number(e);if(Number.isNaN(o)){s="not a number";break}if(!Number.isFinite(o)){s="too large or small";break}return t==u.FLOAT&&lt(o),o;case u.INT32:case u.FIXED32:case u.SFIXED32:case u.SINT32:case u.UINT32:if(e===null)return 0;let a;if(typeof e=="number"?a=e:e===""?s="empty string":typeof e=="string"&&(e.trim().length!==e.length?s="extra whitespace":a=Number(e)),a===void 0)break;return t==u.UINT32?Qe(a):Re(a),a;case u.INT64:case u.SFIXED64:case u.SINT64:if(e===null)return te(x.ZERO,n);if(typeof e!="number"&&typeof e!="string")break;return te(x.from(e),n);case u.FIXED64:case u.UINT64:if(e===null)return te($.ZERO,n);if(typeof e!="number"&&typeof e!="string")break;return te($.from(e),n);case u.BOOL:if(e===null)return!1;if(typeof e!="boolean")break;return e;case u.STRING:if(e===null)return"";if(typeof e!="string"){s="extra whitespace";break}try{encodeURIComponent(e)}catch(l){l="invalid UTF8";break}return e;case u.BYTES:if(e===null||e==="")return new Uint8Array(0);if(typeof e!="string")break;return kt(e)}}catch(o){s=o.message}this.assert(!1,r+(s?" - "+s:""),e)}}class Sn{constructor(e){var t;this.fields=(t=e.fields)!==null&&t!==void 0?t:[]}write(e,t){const n={},r=e;for(const s of this.fields){if(!s.oneof){let c=this.field(s,r[s.localName],t);c!==void 0&&(n[t.useProtoFieldName?s.name:s.jsonName]=c);continue}const o=r[s.oneof];if(o.oneofKind!==s.localName)continue;const a=s.kind=="scalar"||s.kind=="enum"?Object.assign(Object.assign({},t),{emitDefaultValues:!0}):t;let l=this.field(s,o[s.localName],a);E(l!==void 0),n[t.useProtoFieldName?s.name:s.jsonName]=l}return n}field(e,t,n){let r;if(e.kind=="map"){E(typeof t=="object"&&t!==null);const s={};switch(e.V.kind){case"scalar":for(const[l,c]of Object.entries(t)){const h=this.scalar(e.V.T,c,e.name,!1,!0);E(h!==void 0),s[l.toString()]=h}break;case"message":const o=e.V.T();for(const[l,c]of Object.entries(t)){const h=this.message(o,c,e.name,n);E(h!==void 0),s[l.toString()]=h}break;case"enum":const a=e.V.T();for(const[l,c]of Object.entries(t)){E(c===void 0||typeof c=="number");const h=this.enum(a,c,e.name,!1,!0,n.enumAsInteger);E(h!==void 0),s[l.toString()]=h}break}(n.emitDefaultValues||Object.keys(s).length>0)&&(r=s)}else if(e.repeat){E(Array.isArray(t));const s=[];switch(e.kind){case"scalar":for(let l=0;l<t.length;l++){const c=this.scalar(e.T,t[l],e.name,e.opt,!0);E(c!==void 0),s.push(c)}break;case"enum":const o=e.T();for(let l=0;l<t.length;l++){E(t[l]===void 0||typeof t[l]=="number");const c=this.enum(o,t[l],e.name,e.opt,!0,n.enumAsInteger);E(c!==void 0),s.push(c)}break;case"message":const a=e.T();for(let l=0;l<t.length;l++){const c=this.message(a,t[l],e.name,n);E(c!==void 0),s.push(c)}break}(n.emitDefaultValues||s.length>0||n.emitDefaultValues)&&(r=s)}else switch(e.kind){case"scalar":r=this.scalar(e.T,t,e.name,e.opt,n.emitDefaultValues);break;case"enum":r=this.enum(e.T(),t,e.name,e.opt,n.emitDefaultValues,n.enumAsInteger);break;case"message":r=this.message(e.T(),t,e.name,n);break}return r}enum(e,t,n,r,s,o){if(e[0]=="google.protobuf.NullValue")return!s&&!r?void 0:null;if(t===void 0){E(r);return}if(!(t===0&&!s&&!r))return E(typeof t=="number"),E(Number.isInteger(t)),o||!e[1].hasOwnProperty(t)?t:e[2]?e[2]+e[1][t]:e[1][t]}message(e,t,n,r){return t===void 0?r.emitDefaultValues?null:void 0:e.internalJsonWrite(t,r)}scalar(e,t,n,r,s){if(t===void 0){E(r);return}const o=s||r;switch(e){case u.INT32:case u.SFIXED32:case u.SINT32:return t===0?o?0:void 0:(Re(t),t);case u.FIXED32:case u.UINT32:return t===0?o?0:void 0:(Qe(t),t);case u.FLOAT:lt(t);case u.DOUBLE:return t===0?o?0:void 0:(E(typeof t=="number"),Number.isNaN(t)?"NaN":t===Number.POSITIVE_INFINITY?"Infinity":t===Number.NEGATIVE_INFINITY?"-Infinity":t);case u.STRING:return t===""?o?"":void 0:(E(typeof t=="string"),t);case u.BOOL:return t===!1?o?!1:void 0:(E(typeof t=="boolean"),t);case u.UINT64:case u.FIXED64:E(typeof t=="number"||typeof t=="string"||typeof t=="bigint");let a=$.from(t);return a.isZero()&&!o?void 0:a.toString();case u.INT64:case u.SFIXED64:case u.SINT64:E(typeof t=="number"||typeof t=="string"||typeof t=="bigint");let l=x.from(t);return l.isZero()&&!o?void 0:l.toString();case u.BYTES:return E(t instanceof Uint8Array),t.byteLength?Lt(t):o?"":void 0}}}function dt(i,e=oe.STRING){switch(i){case u.BOOL:return!1;case u.UINT64:case u.FIXED64:return te($.ZERO,e);case u.INT64:case u.SFIXED64:case u.SINT64:return te(x.ZERO,e);case u.DOUBLE:case u.FLOAT:return 0;case u.BYTES:return new Uint8Array(0);case u.STRING:return"";default:return 0}}class Un{constructor(e){this.info=e}prepare(){var e;if(!this.fieldNoToField){const t=(e=this.info.fields)!==null&&e!==void 0?e:[];this.fieldNoToField=new Map(t.map(n=>[n.no,n]))}}read(e,t,n,r){this.prepare();const s=r===void 0?e.len:e.pos+r;for(;e.pos<s;){const[o,a]=e.tag(),l=this.fieldNoToField.get(o);if(!l){let w=n.readUnknownField;if(w=="throw")throw new Error(`Unknown field ${o} (wire type ${a}) for ${this.info.typeName}`);let F=e.skip(a);w!==!1&&(w===!0?N.onRead:w)(this.info.typeName,t,o,a,F);continue}let c=t,h=l.repeat,g=l.localName;switch(l.oneof&&(c=c[l.oneof],c.oneofKind!==g&&(c=t[l.oneof]={oneofKind:g})),l.kind){case"scalar":case"enum":let w=l.kind=="enum"?u.INT32:l.T,F=l.kind=="scalar"?l.L:void 0;if(h){let A=c[g];if(a==m.LengthDelimited&&w!=u.STRING&&w!=u.BYTES){let V=e.uint32()+e.pos;for(;e.pos<V;)A.push(this.scalar(e,w,F))}else A.push(this.scalar(e,w,F))}else c[g]=this.scalar(e,w,F);break;case"message":if(h){let A=c[g],V=l.T().internalBinaryRead(e,e.uint32(),n);A.push(V)}else c[g]=l.T().internalBinaryRead(e,e.uint32(),n,c[g]);break;case"map":let[v,Z]=this.mapEntry(l,e,n);c[g][v]=Z;break}}}mapEntry(e,t,n){let r=t.uint32(),s=t.pos+r,o,a;for(;t.pos<s;){let[l,c]=t.tag();switch(l){case 1:e.K==u.BOOL?o=t.bool().toString():o=this.scalar(t,e.K,oe.STRING);break;case 2:switch(e.V.kind){case"scalar":a=this.scalar(t,e.V.T,e.V.L);break;case"enum":a=t.int32();break;case"message":a=e.V.T().internalBinaryRead(t,t.uint32(),n);break}break;default:throw new Error(`Unknown field ${l} (wire type ${c}) in map entry for ${this.info.typeName}#${e.name}`)}}if(o===void 0){let l=dt(e.K);o=e.K==u.BOOL?l.toString():l}if(a===void 0)switch(e.V.kind){case"scalar":a=dt(e.V.T,e.V.L);break;case"enum":a=0;break;case"message":a=e.V.T().create();break}return[o,a]}scalar(e,t,n){switch(t){case u.INT32:return e.int32();case u.STRING:return e.string();case u.BOOL:return e.bool();case u.DOUBLE:return e.double();case u.FLOAT:return e.float();case u.INT64:return te(e.int64(),n);case u.UINT64:return te(e.uint64(),n);case u.FIXED64:return te(e.fixed64(),n);case u.FIXED32:return e.fixed32();case u.BYTES:return e.bytes();case u.UINT32:return e.uint32();case u.SFIXED32:return e.sfixed32();case u.SFIXED64:return te(e.sfixed64(),n);case u.SINT32:return e.sint32();case u.SINT64:return te(e.sint64(),n)}}}class Rn{constructor(e){this.info=e}prepare(){if(!this.fields){const e=this.info.fields?this.info.fields.concat():[];this.fields=e.sort((t,n)=>t.no-n.no)}}write(e,t,n){this.prepare();for(const s of this.fields){let o,a,l=s.repeat,c=s.localName;if(s.oneof){const h=e[s.oneof];if(h.oneofKind!==c)continue;o=h[c],a=!0}else o=e[c],a=!1;switch(s.kind){case"scalar":case"enum":let h=s.kind=="enum"?u.INT32:s.T;if(l)if(E(Array.isArray(o)),l==et.PACKED)this.packed(t,h,s.no,o);else for(const g of o)this.scalar(t,h,s.no,g,!0);else o===void 0?E(s.opt):this.scalar(t,h,s.no,o,a||s.opt);break;case"message":if(l){E(Array.isArray(o));for(const g of o)this.message(t,n,s.T(),s.no,g)}else this.message(t,n,s.T(),s.no,o);break;case"map":E(typeof o=="object"&&o!==null);for(const[g,w]of Object.entries(o))this.mapEntry(t,n,s,g,w);break}}let r=n.writeUnknownFields;r!==!1&&(r===!0?N.onWrite:r)(this.info.typeName,e,t)}mapEntry(e,t,n,r,s){e.tag(n.no,m.LengthDelimited),e.fork();let o=r;switch(n.K){case u.INT32:case u.FIXED32:case u.UINT32:case u.SFIXED32:case u.SINT32:o=Number.parseInt(r);break;case u.BOOL:E(r=="true"||r=="false"),o=r=="true";break}switch(this.scalar(e,n.K,1,o,!0),n.V.kind){case"scalar":this.scalar(e,n.V.T,2,s,!0);break;case"enum":this.scalar(e,u.INT32,2,s,!0);break;case"message":this.message(e,t,n.V.T(),2,s);break}e.join()}message(e,t,n,r,s){s!==void 0&&(n.internalBinaryWrite(s,e.tag(r,m.LengthDelimited).fork(),t),e.join())}scalar(e,t,n,r,s){let[o,a,l]=this.scalarInfo(t,r);(!l||s)&&(e.tag(n,o),e[a](r))}packed(e,t,n,r){if(!r.length)return;E(t!==u.BYTES&&t!==u.STRING),e.tag(n,m.LengthDelimited),e.fork();let[,s]=this.scalarInfo(t);for(let o=0;o<r.length;o++)e[s](r[o]);e.join()}scalarInfo(e,t){let n=m.Varint,r,s=t===void 0,o=t===0;switch(e){case u.INT32:r="int32";break;case u.STRING:o=s||!t.length,n=m.LengthDelimited,r="string";break;case u.BOOL:o=t===!1,r="bool";break;case u.UINT32:r="uint32";break;case u.DOUBLE:n=m.Bit64,r="double";break;case u.FLOAT:n=m.Bit32,r="float";break;case u.INT64:o=s||x.from(t).isZero(),r="int64";break;case u.UINT64:o=s||$.from(t).isZero(),r="uint64";break;case u.FIXED64:o=s||$.from(t).isZero(),n=m.Bit64,r="fixed64";break;case u.BYTES:o=s||!t.byteLength,n=m.LengthDelimited,r="bytes";break;case u.FIXED32:n=m.Bit32,r="fixed32";break;case u.SFIXED32:n=m.Bit32,r="sfixed32";break;case u.SFIXED64:o=s||x.from(t).isZero(),n=m.Bit64,r="sfixed64";break;case u.SINT32:r="sint32";break;case u.SINT64:o=s||x.from(t).isZero(),r="sint64";break}return[n,r,s||o]}}function Mn(i){const e=i.messagePrototype?Object.create(i.messagePrototype):Object.defineProperty({},Dt,{value:i});for(let t of i.fields){let n=t.localName;if(!t.opt)if(t.oneof)e[t.oneof]={oneofKind:void 0};else if(t.repeat)e[n]=[];else switch(t.kind){case"scalar":e[n]=dt(t.T,t.L);break;case"enum":e[n]=0;break;case"map":e[n]={};break}}return e}function U(i,e,t){let n,r=t,s;for(let o of i.fields){let a=o.localName;if(o.oneof){const l=r[o.oneof];if((l==null?void 0:l.oneofKind)==null)continue;if(n=l[a],s=e[o.oneof],s.oneofKind=l.oneofKind,n==null){delete s[a];continue}}else if(n=r[a],s=e,n==null)continue;switch(o.repeat&&(s[a].length=n.length),o.kind){case"scalar":case"enum":if(o.repeat)for(let c=0;c<n.length;c++)s[a][c]=n[c];else s[a]=n;break;case"message":let l=o.T();if(o.repeat)for(let c=0;c<n.length;c++)s[a][c]=l.create(n[c]);else s[a]===void 0?s[a]=l.create(n):l.mergePartial(s[a],n);break;case"map":switch(o.V.kind){case"scalar":case"enum":Object.assign(s[a],n);break;case"message":let c=o.V.T();for(let h of Object.keys(n))s[a][h]=c.create(n[h]);break}break}}}function Vn(i,e,t){if(e===t)return!0;if(!e||!t)return!1;for(let n of i.fields){let r=n.localName,s=n.oneof?e[n.oneof][r]:e[r],o=n.oneof?t[n.oneof][r]:t[r];switch(n.kind){case"enum":case"scalar":let a=n.kind=="enum"?u.INT32:n.T;if(!(n.repeat?Ut(a,s,o):St(a,s,o)))return!1;break;case"map":if(!(n.V.kind=="message"?Rt(n.V.T(),tt(s),tt(o)):Ut(n.V.kind=="enum"?u.INT32:n.V.T,tt(s),tt(o))))return!1;break;case"message":let l=n.T();if(!(n.repeat?Rt(l,s,o):l.equals(s,o)))return!1;break}}return!0}const tt=Object.values;function St(i,e,t){if(e===t)return!0;if(i!==u.BYTES)return!1;let n=e,r=t;if(n.length!==r.length)return!1;for(let s=0;s<n.length;s++)if(n[s]!=r[s])return!1;return!0}function Ut(i,e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(!St(i,e[n],t[n]))return!1;return!0}function Rt(i,e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(!i.equals(e[n],t[n]))return!1;return!0}const Hn=Object.getOwnPropertyDescriptors(Object.getPrototypeOf({}));class j{constructor(e,t,n){this.defaultCheckDepth=16,this.typeName=e,this.fields=t.map(_n),this.options=n??{},this.messagePrototype=Object.create(null,Object.assign(Object.assign({},Hn),{[Dt]:{value:this}})),this.refTypeCheck=new xn(this),this.refJsonReader=new Dn(this),this.refJsonWriter=new Sn(this),this.refBinReader=new Un(this),this.refBinWriter=new Rn(this)}create(e){let t=Mn(this);return e!==void 0&&U(this,t,e),t}clone(e){let t=this.create();return U(this,t,e),t}equals(e,t){return Vn(this,e,t)}is(e,t=this.defaultCheckDepth){return this.refTypeCheck.is(e,t,!1)}isAssignable(e,t=this.defaultCheckDepth){return this.refTypeCheck.is(e,t,!0)}mergePartial(e,t){U(this,e,t)}fromBinary(e,t){let n=yn(t);return this.internalBinaryRead(n.readerFactory(e),e.byteLength,n)}fromJson(e,t){return this.internalJsonRead(e,Tn(t))}fromJsonString(e,t){let n=JSON.parse(e);return this.fromJson(n,t)}toJson(e,t){return this.internalJsonWrite(e,Bn(t))}toJsonString(e,t){var n;let r=this.toJson(e,t);return JSON.stringify(r,null,(n=t==null?void 0:t.prettySpaces)!==null&&n!==void 0?n:0)}toBinary(e,t){let n=Fn(t);return this.internalBinaryWrite(e,n.writerFactory(),n).finish()}internalJsonRead(e,t,n){if(e!==null&&typeof e=="object"&&!Array.isArray(e)){let r=n??this.create();return this.refJsonReader.read(e,r,t),r}throw new Error(`Unable to parse message ${this.typeName} from JSON ${Nt(e)}.`)}internalJsonWrite(e,t){return this.refJsonWriter.write(e,t)}internalBinaryWrite(e,t,n){return this.refBinWriter.write(e,t,n),t}internalBinaryRead(e,t,n,r){let s=r??this.create();return this.refBinReader.read(e,s,n,t),s}}function $n(i,e){var t,n,r;let s=i;return s.service=e,s.localName=(t=s.localName)!==null&&t!==void 0?t:ct(s.name),s.serverStreaming=!!s.serverStreaming,s.clientStreaming=!!s.clientStreaming,s.options=(n=s.options)!==null&&n!==void 0?n:{},s.idempotency=(r=s.idempotency)!==null&&r!==void 0?r:void 0,s}class ht{constructor(e,t,n){this.typeName=e,this.methods=t.map(r=>$n(r,this)),this.options=n??{}}}class B extends Error{constructor(e,t="UNKNOWN",n){super(e),this.name="RpcError",Object.setPrototypeOf(this,new.target.prototype),this.code=t,this.meta=n??{}}toString(){const e=[this.name+": "+this.message];this.code&&(e.push(""),e.push("Code: "+this.code)),this.serviceName&&this.methodName&&e.push("Method: "+this.serviceName+"/"+this.methodName);let t=Object.entries(this.meta);if(t.length){e.push(""),e.push("Meta:");for(let[n,r]of t)e.push(` ${n}: ${r}`)}return e.join(`
4
+ `)}}function jn(i,e){if(!e)return i;let t={};nt(i,t),nt(e,t);for(let n of Object.keys(e)){let r=e[n];switch(n){case"jsonOptions":t.jsonOptions=vn(i.jsonOptions,t.jsonOptions);break;case"binaryOptions":t.binaryOptions=mn(i.binaryOptions,t.binaryOptions);break;case"meta":t.meta={},nt(i.meta,t.meta),nt(e.meta,t.meta);break;case"interceptors":t.interceptors=i.interceptors?i.interceptors.concat(r):r.concat();break}}return t}function nt(i,e){if(!i)return;let t=e;for(let[n,r]of Object.entries(i))r instanceof Date?t[n]=new Date(r.getTime()):Array.isArray(r)?t[n]=r.concat():t[n]=r}var Y;(function(i){i[i.PENDING=0]="PENDING",i[i.REJECTED=1]="REJECTED",i[i.RESOLVED=2]="RESOLVED"})(Y||(Y={}));class ye{constructor(e=!0){this._state=Y.PENDING,this._promise=new Promise((t,n)=>{this._resolve=t,this._reject=n}),e&&this._promise.catch(t=>{})}get state(){return this._state}get promise(){return this._promise}resolve(e){if(this.state!==Y.PENDING)throw new Error(`cannot resolve ${Y[this.state].toLowerCase()}`);this._resolve(e),this._state=Y.RESOLVED}reject(e){if(this.state!==Y.PENDING)throw new Error(`cannot reject ${Y[this.state].toLowerCase()}`);this._reject(e),this._state=Y.REJECTED}resolvePending(e){this._state===Y.PENDING&&this.resolve(e)}rejectPending(e){this._state===Y.PENDING&&this.reject(e)}}class Pn{constructor(){this._lis={nxt:[],msg:[],err:[],cmp:[]},this._closed=!1}onNext(e){return this.addLis(e,this._lis.nxt)}onMessage(e){return this.addLis(e,this._lis.msg)}onError(e){return this.addLis(e,this._lis.err)}onComplete(e){return this.addLis(e,this._lis.cmp)}addLis(e,t){return t.push(e),()=>{let n=t.indexOf(e);n>=0&&t.splice(n,1)}}clearLis(){for(let e of Object.values(this._lis))e.splice(0,e.length)}get closed(){return this._closed!==!1}notifyNext(e,t,n){E((e?1:0)+(t?1:0)+(n?1:0)<=1,"only one emission at a time"),e&&this.notifyMessage(e),t&&this.notifyError(t),n&&this.notifyComplete()}notifyMessage(e){E(!this.closed,"stream is closed"),this.pushIt({value:e,done:!1}),this._lis.msg.forEach(t=>t(e)),this._lis.nxt.forEach(t=>t(e,void 0,!1))}notifyError(e){E(!this.closed,"stream is closed"),this._closed=e,this.pushIt(e),this._lis.err.forEach(t=>t(e)),this._lis.nxt.forEach(t=>t(void 0,e,!1)),this.clearLis()}notifyComplete(){E(!this.closed,"stream is closed"),this._closed=!0,this.pushIt({value:null,done:!0}),this._lis.cmp.forEach(e=>e()),this._lis.nxt.forEach(e=>e(void 0,void 0,!0)),this.clearLis()}[Symbol.asyncIterator](){return this._itState||(this._itState={q:[]}),this._closed===!0?this.pushIt({value:null,done:!0}):this._closed!==!1&&this.pushIt(this._closed),{next:()=>{let e=this._itState;E(e,"bad state"),E(!e.p,"iterator contract broken");let t=e.q.shift();return t?"value"in t?Promise.resolve(t):Promise.reject(t):(e.p=new ye,e.p.promise)}}}pushIt(e){let t=this._itState;if(t)if(t.p){const n=t.p;E(n.state==Y.PENDING,"iterator contract broken"),"value"in e?n.resolve(e):n.reject(e),delete t.p}else t.q.push(e)}}var Wn=function(i,e,t,n){function r(s){return s instanceof t?s:new t(function(o){o(s)})}return new(t||(t=Promise))(function(s,o){function a(h){try{c(n.next(h))}catch(g){o(g)}}function l(h){try{c(n.throw(h))}catch(g){o(g)}}function c(h){h.done?s(h.value):r(h.value).then(a,l)}c((n=n.apply(i,e||[])).next())})};class Zn{constructor(e,t,n,r,s,o,a){this.method=e,this.requestHeaders=t,this.request=n,this.headers=r,this.response=s,this.status=o,this.trailers=a}then(e,t){return this.promiseFinished().then(n=>e?Promise.resolve(e(n)):n,n=>t?Promise.resolve(t(n)):Promise.reject(n))}promiseFinished(){return Wn(this,void 0,void 0,function*(){let[e,t,n,r]=yield Promise.all([this.headers,this.response,this.status,this.trailers]);return{method:this.method,requestHeaders:this.requestHeaders,request:this.request,headers:e,response:t,status:n,trailers:r}})}}var qn=function(i,e,t,n){function r(s){return s instanceof t?s:new t(function(o){o(s)})}return new(t||(t=Promise))(function(s,o){function a(h){try{c(n.next(h))}catch(g){o(g)}}function l(h){try{c(n.throw(h))}catch(g){o(g)}}function c(h){h.done?s(h.value):r(h.value).then(a,l)}c((n=n.apply(i,e||[])).next())})};class Kn{constructor(e,t,n,r,s,o,a){this.method=e,this.requestHeaders=t,this.request=n,this.headers=r,this.responses=s,this.status=o,this.trailers=a}then(e,t){return this.promiseFinished().then(n=>e?Promise.resolve(e(n)):n,n=>t?Promise.resolve(t(n)):Promise.reject(n))}promiseFinished(){return qn(this,void 0,void 0,function*(){let[e,t,n]=yield Promise.all([this.headers,this.status,this.trailers]);return{method:this.method,requestHeaders:this.requestHeaders,request:this.request,headers:e,status:t,trailers:n}})}}function ae(i,e,t,n,r){var s;{let o=(a,l,c)=>e.unary(a,l,c);for(const a of((s=n.interceptors)!==null&&s!==void 0?s:[]).filter(l=>l.interceptUnary).reverse()){const l=o;o=(c,h,g)=>a.interceptUnary(l,c,h,g)}return o(t,r,n)}}class Xn extends j{constructor(){super("com.hamropatro.grpc.cms.ImageUploadRequest",[])}create(e){const t=globalThis.Object.create(this.messagePrototype);return e!==void 0&&U(this,t,e),t}internalBinaryRead(e,t,n,r){return r??this.create()}internalBinaryWrite(e,t,n){let r=n.writeUnknownFields;return r!==!1&&(r==!0?N.onWrite:r)(this.typeName,e,t),t}}const Mt=new Xn;class Gn extends j{constructor(){super("com.hamropatro.grpc.cms.ImageUploadResponse",[{no:1,name:"key",kind:"scalar",T:9},{no:2,name:"url",kind:"scalar",T:9}])}create(e){const t=globalThis.Object.create(this.messagePrototype);return t.key="",t.url="",e!==void 0&&U(this,t,e),t}internalBinaryRead(e,t,n,r){let s=r??this.create(),o=e.pos+t;for(;e.pos<o;){let[a,l]=e.tag();switch(a){case 1:s.key=e.string();break;case 2:s.url=e.string();break;default:let c=n.readUnknownField;if(c==="throw")throw new globalThis.Error(`Unknown field ${a} (wire type ${l}) for ${this.typeName}`);let h=e.skip(l);c!==!1&&(c===!0?N.onRead:c)(this.typeName,s,a,l,h)}}return s}internalBinaryWrite(e,t,n){e.key!==""&&t.tag(1,m.LengthDelimited).string(e.key),e.url!==""&&t.tag(2,m.LengthDelimited).string(e.url);let r=n.writeUnknownFields;return r!==!1&&(r==!0?N.onWrite:r)(this.typeName,e,t),t}}const Jn=new Gn,ut=new ht("com.hamropatro.grpc.cms.ImageUploadService",[{name:"Upload",options:{},I:Mt,O:Jn}]);class Yn{constructor(e){_(this,"typeName",ut.typeName);_(this,"methods",ut.methods);_(this,"options",ut.options);this._transport=e}upload(e,t){const n=this.methods[0],r=this._transport.mergeOptions(t);return ae("unary",this._transport,n,r,e)}}const zn=async()=>{var i;try{const e=(i=window.ImageSalonSDK)==null?void 0:i.grpcConfig,t=new Yn(e),n=Mt.create();return await t.upload(n)}catch(e){throw e}},Qn=async(i,e)=>{try{const t=ei(i,e),r=(await zn()).response.url;return await fetch(r,{method:"PUT",headers:{"Content-Type":"image/*","x-amz-acl":"public-read"},body:t}),r==null?void 0:r.split("?")[0]}catch(t){throw t}},ei=(i,e)=>{const t=e.type.split("/")[0];let n="";t==="video"?n=i==null?void 0:i.replace(/^data:video\/\w+;base64,/,""):t==="image"&&(n=i==null?void 0:i.replace(/^data:image\/\w+;base64,/,""));const r=atob(n),s=new Uint8Array(r.length);for(let o=0;o<r.length;o++)s[o]=r.charCodeAt(o);return s};class ti extends j{constructor(){super("com.hamropatro.grpc.cms.DeleteFolderRequest",[{no:1,name:"key",kind:"scalar",T:9}])}create(e){const t=globalThis.Object.create(this.messagePrototype);return t.key="",e!==void 0&&U(this,t,e),t}internalBinaryRead(e,t,n,r){let s=r??this.create(),o=e.pos+t;for(;e.pos<o;){let[a,l]=e.tag();switch(a){case 1:s.key=e.string();break;default:let c=n.readUnknownField;if(c==="throw")throw new globalThis.Error(`Unknown field ${a} (wire type ${l}) for ${this.typeName}`);let h=e.skip(l);c!==!1&&(c===!0?N.onRead:c)(this.typeName,s,a,l,h)}}return s}internalBinaryWrite(e,t,n){e.key!==""&&t.tag(1,m.LengthDelimited).string(e.key);let r=n.writeUnknownFields;return r!==!1&&(r==!0?N.onWrite:r)(this.typeName,e,t),t}}const Vt=new ti;class ni extends j{constructor(){super("com.hamropatro.grpc.cms.CreateFolderRequest",[{no:1,name:"name",kind:"scalar",T:9},{no:2,name:"nested_folder_name",kind:"scalar",T:9},{no:3,name:"created_by",kind:"scalar",T:9}])}create(e){const t=globalThis.Object.create(this.messagePrototype);return t.name="",t.nestedFolderName="",t.createdBy="",e!==void 0&&U(this,t,e),t}internalBinaryRead(e,t,n,r){let s=r??this.create(),o=e.pos+t;for(;e.pos<o;){let[a,l]=e.tag();switch(a){case 1:s.name=e.string();break;case 2:s.nestedFolderName=e.string();break;case 3:s.createdBy=e.string();break;default:let c=n.readUnknownField;if(c==="throw")throw new globalThis.Error(`Unknown field ${a} (wire type ${l}) for ${this.typeName}`);let h=e.skip(l);c!==!1&&(c===!0?N.onRead:c)(this.typeName,s,a,l,h)}}return s}internalBinaryWrite(e,t,n){e.name!==""&&t.tag(1,m.LengthDelimited).string(e.name),e.nestedFolderName!==""&&t.tag(2,m.LengthDelimited).string(e.nestedFolderName),e.createdBy!==""&&t.tag(3,m.LengthDelimited).string(e.createdBy);let r=n.writeUnknownFields;return r!==!1&&(r==!0?N.onWrite:r)(this.typeName,e,t),t}}const Ht=new ni;class ii extends j{constructor(){super("com.hamropatro.grpc.cms.GetAllFoldersRequest",[{no:1,name:"cursor",kind:"scalar",T:9},{no:2,name:"limit",kind:"scalar",T:5}])}create(e){const t=globalThis.Object.create(this.messagePrototype);return t.cursor="",t.limit=0,e!==void 0&&U(this,t,e),t}internalBinaryRead(e,t,n,r){let s=r??this.create(),o=e.pos+t;for(;e.pos<o;){let[a,l]=e.tag();switch(a){case 1:s.cursor=e.string();break;case 2:s.limit=e.int32();break;default:let c=n.readUnknownField;if(c==="throw")throw new globalThis.Error(`Unknown field ${a} (wire type ${l}) for ${this.typeName}`);let h=e.skip(l);c!==!1&&(c===!0?N.onRead:c)(this.typeName,s,a,l,h)}}return s}internalBinaryWrite(e,t,n){e.cursor!==""&&t.tag(1,m.LengthDelimited).string(e.cursor),e.limit!==0&&t.tag(2,m.Varint).int32(e.limit);let r=n.writeUnknownFields;return r!==!1&&(r==!0?N.onWrite:r)(this.typeName,e,t),t}}const $t=new ii;class ri extends j{constructor(){super("com.hamropatro.grpc.cms.GetAllFoldersResponse",[{no:1,name:"folder",kind:"message",repeat:1,T:()=>Ce},{no:2,name:"next_cursor",kind:"scalar",T:9},{no:3,name:"has_more",kind:"scalar",T:8}])}create(e){const t=globalThis.Object.create(this.messagePrototype);return t.folder=[],t.nextCursor="",t.hasMore=!1,e!==void 0&&U(this,t,e),t}internalBinaryRead(e,t,n,r){let s=r??this.create(),o=e.pos+t;for(;e.pos<o;){let[a,l]=e.tag();switch(a){case 1:s.folder.push(Ce.internalBinaryRead(e,e.uint32(),n));break;case 2:s.nextCursor=e.string();break;case 3:s.hasMore=e.bool();break;default:let c=n.readUnknownField;if(c==="throw")throw new globalThis.Error(`Unknown field ${a} (wire type ${l}) for ${this.typeName}`);let h=e.skip(l);c!==!1&&(c===!0?N.onRead:c)(this.typeName,s,a,l,h)}}return s}internalBinaryWrite(e,t,n){for(let s=0;s<e.folder.length;s++)Ce.internalBinaryWrite(e.folder[s],t.tag(1,m.LengthDelimited).fork(),n).join();e.nextCursor!==""&&t.tag(2,m.LengthDelimited).string(e.nextCursor),e.hasMore!==!1&&t.tag(3,m.Varint).bool(e.hasMore);let r=n.writeUnknownFields;return r!==!1&&(r==!0?N.onWrite:r)(this.typeName,e,t),t}}const si=new ri;class oi extends j{constructor(){super("com.hamropatro.grpc.cms.Folder",[{no:1,name:"key",kind:"scalar",T:9},{no:2,name:"name",kind:"scalar",T:9},{no:3,name:"nested_folder_name",kind:"scalar",T:9},{no:4,name:"created_by",kind:"scalar",T:9}])}create(e){const t=globalThis.Object.create(this.messagePrototype);return t.key="",t.name="",t.nestedFolderName="",t.createdBy="",e!==void 0&&U(this,t,e),t}internalBinaryRead(e,t,n,r){let s=r??this.create(),o=e.pos+t;for(;e.pos<o;){let[a,l]=e.tag();switch(a){case 1:s.key=e.string();break;case 2:s.name=e.string();break;case 3:s.nestedFolderName=e.string();break;case 4:s.createdBy=e.string();break;default:let c=n.readUnknownField;if(c==="throw")throw new globalThis.Error(`Unknown field ${a} (wire type ${l}) for ${this.typeName}`);let h=e.skip(l);c!==!1&&(c===!0?N.onRead:c)(this.typeName,s,a,l,h)}}return s}internalBinaryWrite(e,t,n){e.key!==""&&t.tag(1,m.LengthDelimited).string(e.key),e.name!==""&&t.tag(2,m.LengthDelimited).string(e.name),e.nestedFolderName!==""&&t.tag(3,m.LengthDelimited).string(e.nestedFolderName),e.createdBy!==""&&t.tag(4,m.LengthDelimited).string(e.createdBy);let r=n.writeUnknownFields;return r!==!1&&(r==!0?N.onWrite:r)(this.typeName,e,t),t}}const Ce=new oi,ft=new ht("com.hamropatro.grpc.cms.FolderService",[{name:"createFolder",options:{},I:Ht,O:Ce},{name:"getFolders",options:{},I:$t,O:si},{name:"updateFolder",options:{},I:Ce,O:Ce},{name:"deleteFolder",options:{},I:Vt,O:Ce}]);class it{constructor(e){_(this,"typeName",ft.typeName);_(this,"methods",ft.methods);_(this,"options",ft.options);this._transport=e}createFolder(e,t){const n=this.methods[0],r=this._transport.mergeOptions(t);return ae("unary",this._transport,n,r,e)}getFolders(e,t){const n=this.methods[1],r=this._transport.mergeOptions(t);return ae("unary",this._transport,n,r,e)}updateFolder(e,t){const n=this.methods[2],r=this._transport.mergeOptions(t);return ae("unary",this._transport,n,r,e)}deleteFolder(e,t){const n=this.methods[3],r=this._transport.mergeOptions(t);return ae("unary",this._transport,n,r,e)}}const ai=async(i,e=20,t)=>{var o;const n=(o=window.ImageSalonSDK)==null?void 0:o.grpcConfig,r=new it(n),s=$t.create();try{return s.cursor=i,s.limit=e,await r.getFolders(s,t)}catch(a){throw a}},li=async(i,e,t,n)=>{var r;try{const s=(r=window.ImageSalonSDK)==null?void 0:r.grpcConfig,o=new it(s),a=Ht.create();return a.name=i,a.nestedFolderName=e,a.createdBy=t,await o.createFolder(a,n)}catch(s){throw s}},ci=async(i,e,t,n,r)=>{var s;try{const o=(s=window.ImageSalonSDK)==null?void 0:s.grpcConfig,a=new it(o),l=Ce.create();return l.name=e,l.key=i,l.nestedFolderName=t,l.createdBy=n,await a.updateFolder(l,r)}catch(o){throw o}},di=async(i,e)=>{var t;try{const n=(t=window.ImageSalonSDK)==null?void 0:t.grpcConfig,r=new it(n),s=Vt.create();return s.key=i,await r.deleteFolder(s,e)}catch(n){throw n}};var pt=(i=>(i[i.IMAGE=0]="IMAGE",i[i.AUDIO=1]="AUDIO",i[i.VIDEO=2]="VIDEO",i[i.ALL=3]="ALL",i[i.FOLDER=4]="FOLDER",i))(pt||{});class hi extends j{constructor(){super("com.hamropatro.grpc.cms.SearchRequest",[{no:1,name:"search_value",kind:"scalar",T:9},{no:2,name:"cursor",kind:"scalar",T:9},{no:3,name:"limit",kind:"scalar",T:5}])}create(e){const t=globalThis.Object.create(this.messagePrototype);return t.searchValue="",t.cursor="",t.limit=0,e!==void 0&&U(this,t,e),t}internalBinaryRead(e,t,n,r){let s=r??this.create(),o=e.pos+t;for(;e.pos<o;){let[a,l]=e.tag();switch(a){case 1:s.searchValue=e.string();break;case 2:s.cursor=e.string();break;case 3:s.limit=e.int32();break;default:let c=n.readUnknownField;if(c==="throw")throw new globalThis.Error(`Unknown field ${a} (wire type ${l}) for ${this.typeName}`);let h=e.skip(l);c!==!1&&(c===!0?N.onRead:c)(this.typeName,s,a,l,h)}}return s}internalBinaryWrite(e,t,n){e.searchValue!==""&&t.tag(1,m.LengthDelimited).string(e.searchValue),e.cursor!==""&&t.tag(2,m.LengthDelimited).string(e.cursor),e.limit!==0&&t.tag(3,m.Varint).int32(e.limit);let r=n.writeUnknownFields;return r!==!1&&(r==!0?N.onWrite:r)(this.typeName,e,t),t}}const jt=new hi;class ui extends j{constructor(){super("com.hamropatro.grpc.cms.SearchResult",[{no:1,name:"items",kind:"message",repeat:1,T:()=>le},{no:2,name:"next_page_cursor",kind:"scalar",T:9}])}create(e){const t=globalThis.Object.create(this.messagePrototype);return t.items=[],t.nextPageCursor="",e!==void 0&&U(this,t,e),t}internalBinaryRead(e,t,n,r){let s=r??this.create(),o=e.pos+t;for(;e.pos<o;){let[a,l]=e.tag();switch(a){case 1:s.items.push(le.internalBinaryRead(e,e.uint32(),n));break;case 2:s.nextPageCursor=e.string();break;default:let c=n.readUnknownField;if(c==="throw")throw new globalThis.Error(`Unknown field ${a} (wire type ${l}) for ${this.typeName}`);let h=e.skip(l);c!==!1&&(c===!0?N.onRead:c)(this.typeName,s,a,l,h)}}return s}internalBinaryWrite(e,t,n){for(let s=0;s<e.items.length;s++)le.internalBinaryWrite(e.items[s],t.tag(1,m.LengthDelimited).fork(),n).join();e.nextPageCursor!==""&&t.tag(2,m.LengthDelimited).string(e.nextPageCursor);let r=n.writeUnknownFields;return r!==!1&&(r==!0?N.onWrite:r)(this.typeName,e,t),t}}const fi=new ui;class pi extends j{constructor(){super("com.hamropatro.grpc.cms.CreateFileRequest",[{no:1,name:"name",kind:"scalar",T:9},{no:2,name:"folder_name",kind:"scalar",T:9},{no:3,name:"nested_folder_name",kind:"scalar",T:9},{no:4,name:"url",kind:"scalar",T:9},{no:5,name:"type",kind:"enum",T:()=>["com.hamropatro.grpc.cms.FileType",pt]}])}create(e){const t=globalThis.Object.create(this.messagePrototype);return t.name="",t.folderName="",t.nestedFolderName="",t.url="",t.type=0,e!==void 0&&U(this,t,e),t}internalBinaryRead(e,t,n,r){let s=r??this.create(),o=e.pos+t;for(;e.pos<o;){let[a,l]=e.tag();switch(a){case 1:s.name=e.string();break;case 2:s.folderName=e.string();break;case 3:s.nestedFolderName=e.string();break;case 4:s.url=e.string();break;case 5:s.type=e.int32();break;default:let c=n.readUnknownField;if(c==="throw")throw new globalThis.Error(`Unknown field ${a} (wire type ${l}) for ${this.typeName}`);let h=e.skip(l);c!==!1&&(c===!0?N.onRead:c)(this.typeName,s,a,l,h)}}return s}internalBinaryWrite(e,t,n){e.name!==""&&t.tag(1,m.LengthDelimited).string(e.name),e.folderName!==""&&t.tag(2,m.LengthDelimited).string(e.folderName),e.nestedFolderName!==""&&t.tag(3,m.LengthDelimited).string(e.nestedFolderName),e.url!==""&&t.tag(4,m.LengthDelimited).string(e.url),e.type!==0&&t.tag(5,m.Varint).int32(e.type);let r=n.writeUnknownFields;return r!==!1&&(r==!0?N.onWrite:r)(this.typeName,e,t),t}}const Pt=new pi;class mi extends j{constructor(){super("com.hamropatro.grpc.cms.File",[{no:1,name:"key",kind:"scalar",T:9},{no:2,name:"name",kind:"scalar",T:9},{no:3,name:"folder_name",kind:"scalar",T:9},{no:4,name:"nested_folder_name",kind:"scalar",T:9},{no:5,name:"url",kind:"scalar",T:9},{no:6,name:"thumbor_url",kind:"scalar",T:9},{no:7,name:"proxy_url",kind:"scalar",T:9},{no:8,name:"type",kind:"enum",T:()=>["com.hamropatro.grpc.cms.FileType",pt]},{no:9,name:"metadata",kind:"message",T:()=>mt}])}create(e){const t=globalThis.Object.create(this.messagePrototype);return t.key="",t.name="",t.folderName="",t.nestedFolderName="",t.url="",t.thumborUrl="",t.proxyUrl="",t.type=0,e!==void 0&&U(this,t,e),t}internalBinaryRead(e,t,n,r){let s=r??this.create(),o=e.pos+t;for(;e.pos<o;){let[a,l]=e.tag();switch(a){case 1:s.key=e.string();break;case 2:s.name=e.string();break;case 3:s.folderName=e.string();break;case 4:s.nestedFolderName=e.string();break;case 5:s.url=e.string();break;case 6:s.thumborUrl=e.string();break;case 7:s.proxyUrl=e.string();break;case 8:s.type=e.int32();break;case 9:s.metadata=mt.internalBinaryRead(e,e.uint32(),n,s.metadata);break;default:let c=n.readUnknownField;if(c==="throw")throw new globalThis.Error(`Unknown field ${a} (wire type ${l}) for ${this.typeName}`);let h=e.skip(l);c!==!1&&(c===!0?N.onRead:c)(this.typeName,s,a,l,h)}}return s}internalBinaryWrite(e,t,n){e.key!==""&&t.tag(1,m.LengthDelimited).string(e.key),e.name!==""&&t.tag(2,m.LengthDelimited).string(e.name),e.folderName!==""&&t.tag(3,m.LengthDelimited).string(e.folderName),e.nestedFolderName!==""&&t.tag(4,m.LengthDelimited).string(e.nestedFolderName),e.url!==""&&t.tag(5,m.LengthDelimited).string(e.url),e.thumborUrl!==""&&t.tag(6,m.LengthDelimited).string(e.thumborUrl),e.proxyUrl!==""&&t.tag(7,m.LengthDelimited).string(e.proxyUrl),e.type!==0&&t.tag(8,m.Varint).int32(e.type),e.metadata&&mt.internalBinaryWrite(e.metadata,t.tag(9,m.LengthDelimited).fork(),n).join();let r=n.writeUnknownFields;return r!==!1&&(r==!0?N.onWrite:r)(this.typeName,e,t),t}}const le=new mi;class gi extends j{constructor(){super("com.hamropatro.grpc.cms.FileMetadata",[{no:1,name:"height",kind:"scalar",T:5},{no:2,name:"width",kind:"scalar",T:5},{no:3,name:"background_color",kind:"scalar",T:9},{no:4,name:"aspect_ratio",kind:"scalar",T:1}])}create(e){const t=globalThis.Object.create(this.messagePrototype);return t.height=0,t.width=0,t.backgroundColor="",t.aspectRatio=0,e!==void 0&&U(this,t,e),t}internalBinaryRead(e,t,n,r){let s=r??this.create(),o=e.pos+t;for(;e.pos<o;){let[a,l]=e.tag();switch(a){case 1:s.height=e.int32();break;case 2:s.width=e.int32();break;case 3:s.backgroundColor=e.string();break;case 4:s.aspectRatio=e.double();break;default:let c=n.readUnknownField;if(c==="throw")throw new globalThis.Error(`Unknown field ${a} (wire type ${l}) for ${this.typeName}`);let h=e.skip(l);c!==!1&&(c===!0?N.onRead:c)(this.typeName,s,a,l,h)}}return s}internalBinaryWrite(e,t,n){e.height!==0&&t.tag(1,m.Varint).int32(e.height),e.width!==0&&t.tag(2,m.Varint).int32(e.width),e.backgroundColor!==""&&t.tag(3,m.LengthDelimited).string(e.backgroundColor),e.aspectRatio!==0&&t.tag(4,m.Bit64).double(e.aspectRatio);let r=n.writeUnknownFields;return r!==!1&&(r==!0?N.onWrite:r)(this.typeName,e,t),t}}const mt=new gi;class wi extends j{constructor(){super("com.hamropatro.grpc.cms.DeleteFileRequest",[{no:1,name:"key",kind:"scalar",T:9}])}create(e){const t=globalThis.Object.create(this.messagePrototype);return t.key="",e!==void 0&&U(this,t,e),t}internalBinaryRead(e,t,n,r){let s=r??this.create(),o=e.pos+t;for(;e.pos<o;){let[a,l]=e.tag();switch(a){case 1:s.key=e.string();break;default:let c=n.readUnknownField;if(c==="throw")throw new globalThis.Error(`Unknown field ${a} (wire type ${l}) for ${this.typeName}`);let h=e.skip(l);c!==!1&&(c===!0?N.onRead:c)(this.typeName,s,a,l,h)}}return s}internalBinaryWrite(e,t,n){e.key!==""&&t.tag(1,m.LengthDelimited).string(e.key);let r=n.writeUnknownFields;return r!==!1&&(r==!0?N.onWrite:r)(this.typeName,e,t),t}}const Wt=new wi;class bi extends j{constructor(){super("com.hamropatro.grpc.cms.DeleteFileResponse",[{no:1,name:"is_deleted",kind:"scalar",T:8}])}create(e){const t=globalThis.Object.create(this.messagePrototype);return t.isDeleted=!1,e!==void 0&&U(this,t,e),t}internalBinaryRead(e,t,n,r){let s=r??this.create(),o=e.pos+t;for(;e.pos<o;){let[a,l]=e.tag();switch(a){case 1:s.isDeleted=e.bool();break;default:let c=n.readUnknownField;if(c==="throw")throw new globalThis.Error(`Unknown field ${a} (wire type ${l}) for ${this.typeName}`);let h=e.skip(l);c!==!1&&(c===!0?N.onRead:c)(this.typeName,s,a,l,h)}}return s}internalBinaryWrite(e,t,n){e.isDeleted!==!1&&t.tag(1,m.Varint).bool(e.isDeleted);let r=n.writeUnknownFields;return r!==!1&&(r==!0?N.onWrite:r)(this.typeName,e,t),t}}const yi=new bi;class Ci extends j{constructor(){super("com.hamropatro.grpc.cms.GetFilesByFolderRequest",[{no:1,name:"folder_name",kind:"scalar",T:9},{no:2,name:"cursor",kind:"scalar",T:9},{no:3,name:"limit",kind:"scalar",T:5}])}create(e){const t=globalThis.Object.create(this.messagePrototype);return t.folderName="",t.cursor="",t.limit=0,e!==void 0&&U(this,t,e),t}internalBinaryRead(e,t,n,r){let s=r??this.create(),o=e.pos+t;for(;e.pos<o;){let[a,l]=e.tag();switch(a){case 1:s.folderName=e.string();break;case 2:s.cursor=e.string();break;case 3:s.limit=e.int32();break;default:let c=n.readUnknownField;if(c==="throw")throw new globalThis.Error(`Unknown field ${a} (wire type ${l}) for ${this.typeName}`);let h=e.skip(l);c!==!1&&(c===!0?N.onRead:c)(this.typeName,s,a,l,h)}}return s}internalBinaryWrite(e,t,n){e.folderName!==""&&t.tag(1,m.LengthDelimited).string(e.folderName),e.cursor!==""&&t.tag(2,m.LengthDelimited).string(e.cursor),e.limit!==0&&t.tag(3,m.Varint).int32(e.limit);let r=n.writeUnknownFields;return r!==!1&&(r==!0?N.onWrite:r)(this.typeName,e,t),t}}const Zt=new Ci;class Ei extends j{constructor(){super("com.hamropatro.grpc.cms.GetFilesByFolderResponse",[{no:1,name:"files",kind:"message",repeat:1,T:()=>le},{no:2,name:"next_cursor",kind:"scalar",T:9},{no:3,name:"has_more",kind:"scalar",T:8}])}create(e){const t=globalThis.Object.create(this.messagePrototype);return t.files=[],t.nextCursor="",t.hasMore=!1,e!==void 0&&U(this,t,e),t}internalBinaryRead(e,t,n,r){let s=r??this.create(),o=e.pos+t;for(;e.pos<o;){let[a,l]=e.tag();switch(a){case 1:s.files.push(le.internalBinaryRead(e,e.uint32(),n));break;case 2:s.nextCursor=e.string();break;case 3:s.hasMore=e.bool();break;default:let c=n.readUnknownField;if(c==="throw")throw new globalThis.Error(`Unknown field ${a} (wire type ${l}) for ${this.typeName}`);let h=e.skip(l);c!==!1&&(c===!0?N.onRead:c)(this.typeName,s,a,l,h)}}return s}internalBinaryWrite(e,t,n){for(let s=0;s<e.files.length;s++)le.internalBinaryWrite(e.files[s],t.tag(1,m.LengthDelimited).fork(),n).join();e.nextCursor!==""&&t.tag(2,m.LengthDelimited).string(e.nextCursor),e.hasMore!==!1&&t.tag(3,m.Varint).bool(e.hasMore);let r=n.writeUnknownFields;return r!==!1&&(r==!0?N.onWrite:r)(this.typeName,e,t),t}}const Ni=new Ei,gt=new ht("com.hamropatro.grpc.cms.FileService",[{name:"createFile",options:{},I:Pt,O:le},{name:"updateFile",options:{},I:le,O:le},{name:"deleteFile",options:{},I:Wt,O:yi},{name:"getFilesByFolder",options:{},I:Zt,O:Ni},{name:"search",options:{},I:jt,O:fi}]);class Me{constructor(e){_(this,"typeName",gt.typeName);_(this,"methods",gt.methods);_(this,"options",gt.options);this._transport=e}createFile(e,t){const n=this.methods[0],r=this._transport.mergeOptions(t);return ae("unary",this._transport,n,r,e)}updateFile(e,t){const n=this.methods[1],r=this._transport.mergeOptions(t);return ae("unary",this._transport,n,r,e)}deleteFile(e,t){const n=this.methods[2],r=this._transport.mergeOptions(t);return ae("unary",this._transport,n,r,e)}getFilesByFolder(e,t){const n=this.methods[3],r=this._transport.mergeOptions(t);return ae("unary",this._transport,n,r,e)}search(e,t){const n=this.methods[4],r=this._transport.mergeOptions(t);return ae("unary",this._transport,n,r,e)}}const ki=async(i,e,t,n,r,s)=>{var o;try{const a=(o=window.ImageSalonSDK)==null?void 0:o.grpcConfig,l=new Me(a),c=Pt.create();return c.name=i,c.nestedFolderName=e,c.url=t,c.type=n,c.folderName=r,await l.createFile(c,s)}catch(a){throw a}},Li=async(i,e,t,n)=>{var r;try{const s=(r=window.ImageSalonSDK)==null?void 0:r.grpcConfig,o=new Me(s),a=Zt.create();return a.folderName=i,a.cursor=e,a.limit=t,await o.getFilesByFolder(a,n)}catch(s){throw s}},Ii=async(i,e,t=20,n)=>{var r;try{const s=(r=window.ImageSalonSDK)==null?void 0:r.grpcConfig,o=new Me(s),a=jt.create();return a.searchValue=i,a.cursor=e,a.limit=t,await o.search(a,n)}catch(s){throw s}},Fi=async(i,e,t,n,r,s,o,a,l)=>{var c;try{const h=(c=window.ImageSalonSDK)==null?void 0:c.grpcConfig,g=new Me(h),w=le.create();return w.key=i,w.name=e,w.nestedFolderName=t,w.url=n,w.thumborUrl=r,w.proxyUrl=s,w.type=o,w.folderName=a,await g.updateFile(w,l)}catch(h){throw h}},Ai=async(i,e)=>{var t;try{const n=(t=window.ImageSalonSDK)==null?void 0:t.grpcConfig,r=new Me(n),s=Wt.create();return s.key=i,await r.deleteFile(s,e)}catch(n){throw n}};var fe=(i=>(i[i.IMAGE=0]="IMAGE",i[i.AUDIO=1]="AUDIO",i[i.VIDEO=2]="VIDEO",i[i.ALL=3]="ALL",i[i.FOLDER=4]="FOLDER",i))(fe||{});const rt={0:"IMAGE",1:"AUDIO",2:"VIDEO",3:"ALL",4:"FOLDER"};function Ti(i){switch(i){case"image":return rt[fe.IMAGE];case"video":return rt[fe.VIDEO];case"audio":return rt[fe.AUDIO];default:return rt[fe.ALL]}}function qt(){const i=document.createElementNS("http://www.w3.org/2000/svg","svg");i.setAttribute("xmlns","http://www.w3.org/2000/folder"),i.setAttribute("x","0px"),i.setAttribute("y","0px"),i.setAttribute("width","24"),i.setAttribute("height","24"),i.setAttribute("viewBox","0 0 48 48");const e=document.createElementNS("http://www.w3.org/2000/svg","path");e.setAttribute("fill","#FFA000"),e.setAttribute("d","M40,12H22l-4-4H8c-2.2,0-4,1.8-4,4v8h40v-4C44,13.8,42.2,12,40,12z");const t=document.createElementNS("http://www.w3.org/2000/svg","path");return t.setAttribute("fill","#FFCA28"),t.setAttribute("d","M40,12H8c-2.2,0-4,1.8-4,4v20c0,2.2,1.8,4,4,4h32c2.2,0,4-1.8,4-4V16C44,13.8,42.2,12,40,12z"),i.appendChild(e),i.appendChild(t),i}const G=document.createElementNS("http://www.w3.org/2000/svg","svg");G.setAttribute("xmlns","http://www.w3.org/2000/svg"),G.setAttribute("width","20"),G.setAttribute("height","20"),G.setAttribute("viewBox","0 0 24 24"),G.setAttribute("fill","none"),G.setAttribute("stroke","currentColor"),G.setAttribute("stroke-width","2"),G.setAttribute("stroke-linecap","round"),G.setAttribute("stroke-linejoin","round"),G.classList.add("lucide","lucide-circle-check-big");const Kt=document.createElementNS("http://www.w3.org/2000/svg","path");Kt.setAttribute("d","M21.801 10A10 10 0 1 1 17 3.335");const Xt=document.createElementNS("http://www.w3.org/2000/svg","path");Xt.setAttribute("d","m9 11 3 3L22 4"),G.appendChild(Kt),G.appendChild(Xt);const q=document.createElementNS("http://www.w3.org/2000/svg","svg");q.setAttribute("xmlns","http://www.w3.org/2000/svg"),q.setAttribute("width","20"),q.setAttribute("height","20"),q.setAttribute("viewBox","0 0 24 24"),q.setAttribute("fill","none"),q.setAttribute("stroke","#ee3f3f"),q.setAttribute("stroke-width","2"),q.setAttribute("stroke-linecap","round"),q.setAttribute("stroke-linejoin","round"),q.classList.add("lucide","lucide-circle-alert");const st=document.createElementNS("http://www.w3.org/2000/svg","circle");st.setAttribute("cx","12"),st.setAttribute("cy","12"),st.setAttribute("r","10");const Ve=document.createElementNS("http://www.w3.org/2000/svg","line");Ve.setAttribute("x1","12"),Ve.setAttribute("x2","12"),Ve.setAttribute("y1","8"),Ve.setAttribute("y2","12");const He=document.createElementNS("http://www.w3.org/2000/svg","line");He.setAttribute("x1","12"),He.setAttribute("x2","12.01"),He.setAttribute("y1","16"),He.setAttribute("y2","16"),q.appendChild(st),q.appendChild(Ve),q.appendChild(He);function Gt(){const i=document.createElementNS("http://www.w3.org/2000/svg","svg");i.setAttribute("xmlns","http://www.w3.org/2000/svg"),i.setAttribute("height","24px"),i.setAttribute("width","24px"),i.setAttribute("viewBox","0 -960 960 960"),i.setAttribute("fill","#333");const e=document.createElementNS("http://www.w3.org/2000/svg","path");return e.setAttribute("d","M504-480 320-664l56-56 240 240-240 240-56-56 184-184Z"),i.appendChild(e),i}function Jt(){const i=document.createElementNS("http://www.w3.org/2000/svg","svg");i.setAttribute("xmlns","http://www.w3.org/2000/svg"),i.setAttribute("fill","none"),i.setAttribute("width","20"),i.setAttribute("height","20"),i.setAttribute("viewBox","0 0 24 24"),i.setAttribute("stroke-width","1.5"),i.setAttribute("stroke","currentColor"),i.setAttribute("class","size-2");const e=document.createElementNS("http://www.w3.org/2000/svg","path");return e.setAttribute("stroke-linecap","round"),e.setAttribute("stroke-linejoin","round"),e.setAttribute("d","M12 4.5v15m7.5-7.5h-15"),i.appendChild(e),i}function Bi(i){const e={};i.forEach(r=>{e[r.key]={...r,children:{}}});const t=r=>(Object.values(e).filter(o=>o.nestedFolderName==r.key).forEach(o=>{r.children[o.key]=t(o)}),r);return i.reduce((r,s)=>(s.nestedFolderName||r.push(t(e[s.key])),r),[])}function vi(i,e){const t=n=>{if(n.key===e.nestedFolderName)return n.children[e.key]={...e,children:{}},!0;for(const r in n.children){const s=n.children[r];if(t(s))return!0}return!1};for(const n of i)if(t(n))break;return i}function _i(){const i=document.createElementNS("http://www.w3.org/2000/svg","svg");i.setAttribute("xmlns","http://www.w3.org/2000/svg"),i.setAttribute("height","24px"),i.setAttribute("width","24px"),i.setAttribute("viewBox","0 0 30 30"),i.setAttribute("fill","#999");const e=document.createElementNS("http://www.w3.org/2000/svg","path");return e.setAttribute("d","M 13 3 C 7.4889971 3 3 7.4889971 3 13 C 3 18.511003 7.4889971 23 13 23 C 15.396508 23 17.597385 22.148986 19.322266 20.736328 L 25.292969 26.707031 A 1.0001 1.0001 0 1 0 26.707031 25.292969 L 20.736328 19.322266 C 22.148986 17.597385 23 15.396508 23 13 C 23 7.4889971 18.511003 3 13 3 z M 13 5 C 17.430123 5 21 8.5698774 21 13 C 21 17.430123 17.430123 21 13 21 C 8.5698774 21 5 17.430123 5 13 C 5 8.5698774 8.5698774 5 13 5 z"),i.appendChild(e),i}function Oi(){const i="http://www.w3.org/2000/svg",e=document.createElementNS(i,"svg");e.setAttribute("xmlns",i),e.setAttribute("height","20px"),e.setAttribute("viewBox","0 -960 960 960"),e.setAttribute("width","20px"),e.setAttribute("fill","#fff");const t=document.createElementNS(i,"path");return t.setAttribute("d","M440-320v-326L336-542l-56-58 200-200 200 200-56 58-104-104v326h-80ZM240-160q-33 0-56.5-23.5T160-240v-120h80v120h480v-120h80v120q0 33-23.5 56.5T720-160H240Z"),e.appendChild(t),e}function xi(){const i="http://www.w3.org/2000/svg",e=document.createElementNS(i,"svg");e.setAttribute("width","12"),e.setAttribute("height","12"),e.setAttribute("viewBox","0 0 24 24"),e.setAttribute("fill","none"),e.setAttribute("stroke","currentColor"),e.setAttribute("stroke-width","3"),e.setAttribute("stroke-linecap","round"),e.setAttribute("stroke-linejoin","round"),e.classList.add("lucide","lucide-video");const t=document.createElementNS(i,"path");t.setAttribute("d","m16 13 5.223 3.482a.5.5 0 0 0 .777-.416V7.87a.5.5 0 0 0-.752-.432L16 10.5");const n=document.createElementNS(i,"rect");return n.setAttribute("x","2"),n.setAttribute("y","6"),n.setAttribute("width","14"),n.setAttribute("height","12"),n.setAttribute("rx","2"),e.appendChild(t),e.appendChild(n),document.body.appendChild(e),e}function Di(){const i="http://www.w3.org/2000/svg",e=document.createElementNS(i,"svg");e.setAttribute("width","12"),e.setAttribute("height","12"),e.setAttribute("viewBox","0 0 24 24"),e.setAttribute("fill","none"),e.setAttribute("stroke","currentColor"),e.setAttribute("stroke-width","3"),e.setAttribute("stroke-linecap","round"),e.setAttribute("stroke-linejoin","round"),e.classList.add("lucide","lucide-image");const t=document.createElementNS(i,"rect");t.setAttribute("width","18"),t.setAttribute("height","18"),t.setAttribute("x","3"),t.setAttribute("y","3"),t.setAttribute("rx","2"),t.setAttribute("ry","2");const n=document.createElementNS(i,"circle");n.setAttribute("cx","9"),n.setAttribute("cy","9"),n.setAttribute("r","2");const r=document.createElementNS(i,"path");return r.setAttribute("d","m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21"),e.appendChild(t),e.appendChild(n),e.appendChild(r),document.body.appendChild(e),e}const Si=async i=>{let e;try{i&&(e={Authorization:"Bearer "+i})}catch(n){if(n)throw n}return{meta:e}};class Ui{constructor(){_(this,"main");_(this,"dialogBody");this.main=y("div"),this.dialogBody=y("div"),this.hide()}show(e){this.main=y("div","popover",e.mainContainer),this.dialogBody=y("div","popover-body",this.main),this.main.id=e.divId,this.dialogBody.append(e.content)}hide(){this.main.remove()}}const pe=new Ui;function Ri(){const i=document.createElementNS("http://www.w3.org/2000/svg","svg");i.setAttribute("xmlns","http://www.w3.org/2000/svg"),i.setAttribute("width","12"),i.setAttribute("height","12"),i.setAttribute("viewBox","0 0 24 24"),i.setAttribute("fill","none"),i.setAttribute("stroke","currentColor"),i.setAttribute("stroke-width","2"),i.setAttribute("stroke-linecap","round"),i.setAttribute("stroke-linejoin","round"),i.classList.add("lucide","lucide-music-4");const e=document.createElementNS("http://www.w3.org/2000/svg","path");e.setAttribute("d","M9 18V5l12-2v13");const t=document.createElementNS("http://www.w3.org/2000/svg","path");t.setAttribute("d","m9 9 12-2");const n=document.createElementNS("http://www.w3.org/2000/svg","circle");n.setAttribute("cx","6"),n.setAttribute("cy","18"),n.setAttribute("r","3");const r=document.createElementNS("http://www.w3.org/2000/svg","circle");return r.setAttribute("cx","18"),r.setAttribute("cy","16"),r.setAttribute("r","3"),i.appendChild(e),i.appendChild(t),i.appendChild(n),i.appendChild(r),document.body.appendChild(i),i}var p;(function(i){i[i.OK=0]="OK",i[i.CANCELLED=1]="CANCELLED",i[i.UNKNOWN=2]="UNKNOWN",i[i.INVALID_ARGUMENT=3]="INVALID_ARGUMENT",i[i.DEADLINE_EXCEEDED=4]="DEADLINE_EXCEEDED",i[i.NOT_FOUND=5]="NOT_FOUND",i[i.ALREADY_EXISTS=6]="ALREADY_EXISTS",i[i.PERMISSION_DENIED=7]="PERMISSION_DENIED",i[i.UNAUTHENTICATED=16]="UNAUTHENTICATED",i[i.RESOURCE_EXHAUSTED=8]="RESOURCE_EXHAUSTED",i[i.FAILED_PRECONDITION=9]="FAILED_PRECONDITION",i[i.ABORTED=10]="ABORTED",i[i.OUT_OF_RANGE=11]="OUT_OF_RANGE",i[i.UNIMPLEMENTED=12]="UNIMPLEMENTED",i[i.INTERNAL=13]="INTERNAL",i[i.UNAVAILABLE=14]="UNAVAILABLE",i[i.DATA_LOSS=15]="DATA_LOSS"})(p||(p={}));var Mi=function(i,e,t,n){function r(s){return s instanceof t?s:new t(function(o){o(s)})}return new(t||(t=Promise))(function(s,o){function a(h){try{c(n.next(h))}catch(g){o(g)}}function l(h){try{c(n.throw(h))}catch(g){o(g)}}function c(h){h.done?s(h.value):r(h.value).then(a,l)}c((n=n.apply(i,e||[])).next())})};function Yt(i,e,t,n,r){if(n)for(let[s,o]of Object.entries(n))if(typeof o=="string")i.append(s,o);else for(let a of o)i.append(s,a);if(i.set("Content-Type",e==="text"?"application/grpc-web-text":"application/grpc-web+proto"),e=="text"&&i.set("Accept","application/grpc-web-text"),i.set("X-Grpc-Web","1"),typeof t=="number"){if(t<=0)throw new B(`timeout ${t} ms exceeded`,p[p.DEADLINE_EXCEEDED]);i.set("grpc-timeout",`${t}m`)}else if(t){const s=t.getTime(),o=Date.now();if(s<=o)throw new B(`deadline ${t} exceeded`,p[p.DEADLINE_EXCEEDED]);i.set("grpc-timeout",`${s-o}m`)}return i}function zt(i,e){let t=new Uint8Array(5+i.length);t[0]=ne.DATA;for(let n=i.length,r=4;r>0;r--)t[r]=n%256,n>>>=8;return t.set(i,5),e==="binary"?t:Lt(t)}function wt(i,e,t){if(arguments.length===1){let l=i,c;try{c=l.type}catch{}switch(c){case"error":case"opaque":case"opaqueredirect":throw new B(`fetch response type ${l.type}`,p[p.UNKNOWN])}return wt(ji(l.headers),l.status,l.statusText)}let n=i,r=e>=200&&e<300,s=rn(n),[o,a]=nn(n);return(o===void 0||o===p.OK)&&!r&&(o=Pi(e),a=t),[o,a,s]}function Qt(i){let e=$i(i),[t,n]=nn(e),r=rn(e);return[t??p.OK,n,r]}var ne;(function(i){i[i.DATA=0]="DATA",i[i.TRAILER=128]="TRAILER"})(ne||(ne={}));function en(i,e,t){return Mi(this,void 0,void 0,function*(){let n,r="",s=new Uint8Array(0),o=Hi(e);if(Vi(i)){let a=i.getReader();n={next:()=>a.read()}}else n=i[Symbol.asyncIterator]();for(;;){let a=yield n.next();if(a.value!==void 0){if(o==="text"){for(let c=0;c<a.value.length;c++)r+=String.fromCharCode(a.value[c]);let l=r.length-r.length%4;if(l===0)continue;s=tn(s,kt(r.substring(0,l))),r=r.substring(l)}else s=tn(s,a.value);for(;s.length>=5&&s[0]===ne.DATA;){let l=0;for(let c=1;c<5;c++)l=(l<<8)+s[c];if(s.length-5>=l)t(ne.DATA,s.subarray(5,5+l)),s=s.subarray(5+l);else break}}if(a.done){if(s.length===0)break;if(s[0]!==ne.TRAILER||s.length<5)throw new B("premature EOF",p[p.DATA_LOSS]);t(ne.TRAILER,s.subarray(5));break}}})}const Vi=i=>typeof i.getReader=="function";function tn(i,e){let t=new Uint8Array(i.length+e.length);return t.set(i),t.set(e,i.length),t}function Hi(i){switch(i){case"application/grpc-web-text":case"application/grpc-web-text+proto":return"text";case"application/grpc-web":case"application/grpc-web+proto":return"binary";case void 0:case null:throw new B("missing response content type",p[p.INTERNAL]);default:throw new B("unexpected response content type: "+i,p[p.INTERNAL])}}function nn(i){let e,t,n=i["grpc-message"];if(n!==void 0){if(Array.isArray(n))return[p.INTERNAL,"invalid grpc-web message"];t=n}let r=i["grpc-status"];if(r!==void 0){if(Array.isArray(r))return[p.INTERNAL,"invalid grpc-web status"];if(e=parseInt(r,10),p[e]===void 0)return[p.INTERNAL,"invalid grpc-web status"]}return[e,t]}function rn(i){let e={};for(let[t,n]of Object.entries(i))switch(t){case"grpc-message":case"grpc-status":case"content-type":break;default:e[t]=n}return e}function $i(i){let e={};for(let t of String.fromCharCode.apply(String,i).trim().split(`\r
5
+ `)){if(t=="")continue;let[n,...r]=t.split(":");const s=r.join(":").trim();n=n.trim();let o=e[n];typeof o=="string"?e[n]=[o,s]:Array.isArray(o)?o.push(s):e[n]=s}return e}function ji(i){let e={};return i.forEach((t,n)=>{let r=e[n];typeof r=="string"?e[n]=[r,t]:Array.isArray(r)?r.push(t):e[n]=t}),e}function Pi(i){switch(i){case 200:return p.OK;case 400:return p.INVALID_ARGUMENT;case 401:return p.UNAUTHENTICATED;case 403:return p.PERMISSION_DENIED;case 404:return p.NOT_FOUND;case 409:return p.ABORTED;case 412:return p.FAILED_PRECONDITION;case 429:return p.RESOURCE_EXHAUSTED;case 499:return p.CANCELLED;case 500:return p.UNKNOWN;case 501:return p.UNIMPLEMENTED;case 503:return p.UNAVAILABLE;case 504:return p.DEADLINE_EXCEEDED;default:return p.UNKNOWN}}class Wi{constructor(e){this.defaultOptions=e}mergeOptions(e){return jn(this.defaultOptions,e)}makeUrl(e,t){let n=t.baseUrl;return n.endsWith("/")&&(n=n.substring(0,n.length-1)),`${n}/${e.service.typeName}/${e.name}`}clientStreaming(e){const t=new B("Client streaming is not supported by grpc-web",p[p.UNIMPLEMENTED]);throw t.methodName=e.name,t.serviceName=e.service.typeName,t}duplex(e){const t=new B("Duplex streaming is not supported by grpc-web",p[p.UNIMPLEMENTED]);throw t.methodName=e.name,t.serviceName=e.service.typeName,t}serverStreaming(e,t,n){var r,s,o,a;let l=n,c=(r=l.format)!==null&&r!==void 0?r:"text",h=(s=l.fetchInit)!==null&&s!==void 0?s:{},g=this.makeUrl(e,l),w=e.I.toBinary(t,l.binaryOptions),F=new ye,v=new Pn,Z=!0,A,V=new ye,K,X=new ye;return globalThis.fetch(g,Object.assign(Object.assign({},h),{method:"POST",headers:Yt(new globalThis.Headers,c,l.timeout,l.meta),body:zt(w,c),signal:(o=n.abort)!==null&&o!==void 0?o:null})).then(C=>{let[b,O,P]=wt(C);if(F.resolve(P),b!=null&&b!==p.OK)throw new B(O??p[b],p[b],P);return b!=null&&(A={code:p[b],detail:O??p[b]}),C}).then(C=>{if(!C.body)throw new B("missing response body",p[p.INTERNAL]);return en(C.body,C.headers.get("content-type"),(b,O)=>{switch(b){case ne.DATA:v.notifyMessage(e.O.fromBinary(O,l.binaryOptions)),Z=!1;break;case ne.TRAILER:let P,se;[P,se,K]=Qt(O),A={code:p[P],detail:se??p[P]};break}})}).then(()=>{if(!K&&!Z)throw new B("missing trailers",p[p.DATA_LOSS]);if(!A)throw new B("missing status",p[p.INTERNAL]);if(A.code!=="OK")throw new B(A.detail,A.code,K);v.notifyComplete(),V.resolve(A),X.resolve(K||{})}).catch(C=>{let b;C instanceof B?b=C:C instanceof Error&&C.name==="AbortError"?b=new B(C.message,p[p.CANCELLED]):b=new B(C instanceof Error?C.message:""+C,p[p.INTERNAL]),b.methodName=e.name,b.serviceName=e.service.typeName,F.rejectPending(b),v.notifyError(b),V.rejectPending(b),X.rejectPending(b)}),new Kn(e,(a=l.meta)!==null&&a!==void 0?a:{},t,F.promise,v,V.promise,X.promise)}unary(e,t,n){var r,s,o,a;let l=n,c=(r=l.format)!==null&&r!==void 0?r:"text",h=(s=l.fetchInit)!==null&&s!==void 0?s:{},g=this.makeUrl(e,l),w=e.I.toBinary(t,l.binaryOptions),F=new ye,v,Z=new ye,A,V=new ye,K,X=new ye;return globalThis.fetch(g,Object.assign(Object.assign({},h),{method:"POST",headers:Yt(new globalThis.Headers,c,l.timeout,l.meta),body:zt(w,c),signal:(o=n.abort)!==null&&o!==void 0?o:null})).then(C=>{let[b,O,P]=wt(C);if(F.resolve(P),b!=null&&b!==p.OK)throw new B(O??p[b],p[b],P);return b!=null&&(A={code:p[b],detail:O??p[b]}),C}).then(C=>{if(!C.body)throw new B("missing response body",p[p.INTERNAL]);return en(C.body,C.headers.get("content-type"),(b,O)=>{switch(b){case ne.DATA:if(v)throw new B("unary call received 2nd message",p[p.DATA_LOSS]);v=e.O.fromBinary(O,l.binaryOptions);break;case ne.TRAILER:let P,se;[P,se,K]=Qt(O),A={code:p[P],detail:se??p[P]};break}})}).then(()=>{if(!K&&v)throw new B("missing trailers",p[p.DATA_LOSS]);if(!A)throw new B("missing status",p[p.INTERNAL]);if(!v&&A.code==="OK")throw new B("expected error status",p[p.DATA_LOSS]);if(!v)throw new B(A.detail,A.code,K);if(Z.resolve(v),A.code!=="OK")throw new B(A.detail,A.code,K);V.resolve(A),X.resolve(K||{})}).catch(C=>{let b;C instanceof B?b=C:C instanceof Error&&C.name==="AbortError"?b=new B(C.message,p[p.CANCELLED]):b=new B(C instanceof Error?C.message:""+C,p[p.INTERNAL]),b.methodName=e.name,b.serviceName=e.service.typeName,F.rejectPending(b),Z.rejectPending(b),V.rejectPending(b),X.rejectPending(b)}),new Zn(e,(a=l.meta)!==null&&a!==void 0?a:{},t,F.promise,Z.promise,V.promise,X.promise)}}function sn(){const i=document.createElementNS("http://www.w3.org/2000/svg","svg");i.setAttribute("xmlns","http://www.w3.org/2000/svg"),i.setAttribute("width","16"),i.setAttribute("height","16"),i.setAttribute("viewBox","0 0 24 24"),i.setAttribute("fill","none"),i.setAttribute("stroke","#2c96f8"),i.setAttribute("stroke-width","2"),i.setAttribute("stroke-linecap","round"),i.setAttribute("stroke-linejoin","round"),i.classList.add("lucide","lucide-pencil");const e=document.createElementNS("http://www.w3.org/2000/svg","path");e.setAttribute("d","M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z");const t=document.createElementNS("http://www.w3.org/2000/svg","path");return t.setAttribute("d","m15 5 4 4"),i.appendChild(e),i.appendChild(t),document.body.appendChild(i),i}function on(){const i=document.createElementNS("http://www.w3.org/2000/svg","svg");i.setAttribute("xmlns","http://www.w3.org/2000/svg"),i.setAttribute("width","16"),i.setAttribute("height","16"),i.setAttribute("viewBox","0 0 24 24"),i.setAttribute("fill","none"),i.setAttribute("stroke","#f14b4b"),i.setAttribute("stroke-width","2"),i.setAttribute("stroke-linecap","round"),i.setAttribute("stroke-linejoin","round"),i.classList.add("lucide","lucide-trash-2");const e=document.createElementNS("http://www.w3.org/2000/svg","path");e.setAttribute("d","M3 6h18");const t=document.createElementNS("http://www.w3.org/2000/svg","path");t.setAttribute("d","M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6");const n=document.createElementNS("http://www.w3.org/2000/svg","path");n.setAttribute("d","M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2");const r=document.createElementNS("http://www.w3.org/2000/svg","line");r.setAttribute("x1","10"),r.setAttribute("x2","10"),r.setAttribute("y1","11"),r.setAttribute("y2","17");const s=document.createElementNS("http://www.w3.org/2000/svg","line");return s.setAttribute("x1","14"),s.setAttribute("x2","14"),s.setAttribute("y1","11"),s.setAttribute("y2","17"),i.appendChild(e),i.appendChild(t),i.appendChild(n),i.appendChild(r),i.appendChild(s),document.body.appendChild(i),i}class Zi{constructor(e){L(this,Be);L(this,ve);L(this,D);L(this,ge);L(this,S,[]);L(this,R,[]);L(this,Ee);L(this,z);L(this,_e);L(this,Ne);L(this,ce,[]);L(this,ie);L(this,ke);L(this,$e);L(this,Le);L(this,Ie);L(this,we);L(this,Oe);L(this,de);L(this,he);L(this,Fe);L(this,Ae);L(this,be);L(this,De);L(this,je);L(this,J);L(this,re);L(this,Pe,!1);L(this,We);L(this,Te);f(this,Ee,!1),f(this,z,!1),f(this,_e,!1),f(this,$e,e.handleUpload.bind(this)),f(this,Le,0),f(this,he,""),f(this,Fe,!1),f(this,be,!1),f(this,je,e.accessToken),f(this,re,null),f(this,Te,""),this._removeToastContainer(),this._grpcOptionInitializer(),this._init(e).then(()=>{f(this,Pe,!0),this._create(e),this.updateWindowObject({initialized:!0}),this._initializeGrpcConfig(e.mode)}),f(this,We,e.enableMultiSelect)}async _init(e){try{const{mode:t}=e;this.updateWindowObject({mode:t})}catch{throw Error("Initialization failed")}}_create(e){if(!d(this,Pe))return;const{parentContainerId:t,buttonProps:n}=e;f(this,Be,document.getElementById(t));const r=document.createElement("button");r.className=n!=null&&n.buttonClass?n==null?void 0:n.buttonClass:"browse-image-button";const s=document.createElement("span");s.textContent=n!=null&&n.buttonText?n==null?void 0:n.buttonText:"Browse Files";const o=document.createElement("span");return o.innerHTML=n!=null&&n.buttonIcon?n==null?void 0:n.buttonIcon:"",r.type="button",r.append(s,o),n!=null&&n.buttonStyle&&Object.assign(r.style,n==null?void 0:n.buttonStyle),r.addEventListener("click",()=>{this._selectedImageContainer()}),d(this,Be)&&d(this,Be).appendChild(r),d(this,Be)}async _grpcOptionInitializer(){f(this,J,await Si(d(this,je)))}_selectedImageContainer(){var g;f(this,ke,ee(`Save (${(g=d(this,S))==null?void 0:g.length})`,"dialog-btn confirm")),f(this,Ie,k("folder-container")),f(this,we,k("folder-list-wrapper")),this._fetchAllFolders();const e=ee("Cancel","dialog-btn cancel");ee("","dialog-modal-close-btn","",!1,'<svg xmlns="http://www.w3.org/2000/svg" x="0px" y="0px" width="24" height="24" viewBox="0 0 50 50"> <path d="M 9.15625 6.3125 L 6.3125 9.15625 L 22.15625 25 L 6.21875 40.96875 L 9.03125 43.78125 L 25 27.84375 L 40.9375 43.78125 L 43.78125 40.9375 L 27.84375 25 L 43.6875 9.15625 L 40.84375 6.3125 L 25 22.15625 Z"></path> </svg>').addEventListener("click",()=>{Xe.hide(),f(this,S,[]),f(this,R,[])}),f(this,ve,k("browse-container"));const n=k();n.style.display="flex",n.style.alignItems="center",n.style.justifyContent="space-between",n.style.padding="10px 20px";const r=Ue("Folders","folder-title"),s=ee("","add-folder-btn");s.append(Jt()),this._createUpdateFolderDialog(s,"create"),n.append(r,s),d(this,Ie).append(n,d(this,we));const o=this._renderSearchField(),a=this._createBrowseMoreContainer(),l=this._createBrowseImageMain(),c=k("footer");e.onclick=()=>{Xe.hide(),f(this,R,[]),f(this,S,[])},d(this,ke).onclick=()=>{d(this,$e).call(this),Xe.hide(),f(this,S,[]),f(this,R,[])},c.append(d(this,ke),e);const h=k("container-right-main");h.append(o,a,l,c),d(this,ve).append(d(this,Ie),h),Xe.show({content:d(this,ve)})}_createAllAndSelectedTab(e){const t=k("select-options"),n=Ue("Browse","select"),r=Ue("Selected","select","selected-images-tab");n.classList.add("selected"),[n,r].forEach((o,a)=>{o.addEventListener("click",()=>{var l;f(this,Le,a),(l=document.querySelector(".select.selected"))==null||l.classList.remove("selected"),o.classList.add("selected"),this._updateSelectedImageListContainerUI()})}),t.append(n,r),e.appendChild(t)}_renderUploadButton(){const e=Et("file");e.style.display="none",e.setAttribute("multiple","true"),e.setAttribute("accept","image/*,video/*,audio/*,.gif"),f(this,ge,document.createElement("button")),d(this,ge).className="browse-more-btn";const t=document.createElement("span");return t.textContent="Upload",d(this,ge).append(Oi(),t),d(this,ge).type="button",d(this,ge).addEventListener("click",()=>e.click()),e.addEventListener("change",()=>{const n=e.files;Object.values(n).forEach(r=>{const s=new FileReader;s.readAsDataURL(r),s.onload=async()=>{await this._uploadAndAddSelectedImageList(s.result,r)}}),e.value=""}),d(this,ge)}_renderCreateFolderBtn(){const e=document.createElement("button");e.className="create-folder-btn";const t=document.createElement("span");return t.textContent="Create",e.append(Jt(),t),this._createUpdateFolderDialog(e,"create"),e}_renderSearchField(){let e;const t=k("search-browse-container"),n=k("search-input-wrapper","search-input-wrapper");f(this,Ae,Et("search")),d(this,Ae).value="",d(this,Ae).addEventListener("input",s=>{f(this,R,[]);const o=s.target;e&&clearTimeout(e),e=setTimeout(()=>{if(!o.value){f(this,he,""),f(this,Fe,!1),f(this,be,!1),this._fetchFilesFromFolder(d(this,Ne));return}f(this,be,!0),f(this,De,o.value),this._search(d(this,De))},750)}),d(this,Ae).setAttribute("placeholder","Search");const r=_i();return r.style.position="absolute",r.style.top="50%",r.style.left="5%",r.style.transform="translate(-5%, -50%)",n.append(r,d(this,Ae)),t.append(n),t}_createBrowseMoreContainer(){f(this,Oe,k("browse-more-btn-container")),this._createAllAndSelectedTab(d(this,Oe));const e=this._renderUploadButton(),t=this._renderCreateFolderBtn(),n=document.createElement("div");return n.style.display="flex",n.style.alignItems="center",n.style.gap="10px",n.append(e,t),d(this,Oe).appendChild(n),d(this,Oe)}_createBrowseImageMain(){const e=k("browse-image-main");return f(this,D,k("selected-image-container")),d(this,D).addEventListener("scroll",()=>{const t=d(this,D).clientHeight,n=d(this,D).scrollTop,r=d(this,D).scrollHeight;t+n>=r-5&&d(this,Fe)&&(d(this,be)?this._search(d(this,De)):this._fetchFilesFromFolder(d(this,Ne)))}),this._updateSelectedImageListContainerUI(),e.appendChild(d(this,D)),e}_renderFetchingSkeletonUI(){for(let e=0;e<6;e++){const t=k("skeleton");t.innerHTML="",d(this,D).append(t)}}_renderEmptyImageContainer(){if(d(this,z)||d(this,Ee))return;const e=k(),t=k(),n=document.createElement("p");d(this,be)&&d(this,Le)===0?(t.innerHTML=`
6
6
  <svg width="300" height="300" viewBox="0 0 1000 1000" fill="none" xmlns="http://www.w3.org/2000/svg">
7
7
  <g clip-path="url(#clip0_2304_257)">
8
8
  <path d="M564.829 772.4H336.658V948.386H564.829V772.4Z" fill="#EBEBEB"/>
@@ -86,4 +86,4 @@ import './style.css';
86
86
  </clipPath>
87
87
  </defs>
88
88
  </svg>
89
- `,n.textContent="Looks Empty!"),e.append(t,n),d(this,D).appendChild(e)}_renderLoadingUI(){const e=k("skeleton");e.innerHTML="",d(this,D).appendChild(e)}_fileCardBody(e){const t=k("selected-image-content"),n=k("selected-image-top-bar"),r=ee("","selected-image-btn","",!1,'<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-ellipsis"><circle cx="12" cy="12" r="1"/><circle cx="19" cy="12" r="1"/><circle cx="5" cy="12" r="1"/></svg>');let s,o;(e==null?void 0:e.type)===fe.IMAGE&&(s=un(e==null?void 0:e.url,"selected-image"),o=Si()),(e==null?void 0:e.type)===fe.VIDEO&&(s=fn(e==null?void 0:e.url,"uploaded-video"),o=Di()),(e==null?void 0:e.type)===fe.AUDIO&&(s=pn(e==null?void 0:e.url,"uploaded-audio"),o=Mi());const a=k("selected-image-wrapper",e==null?void 0:e.key),l=Ue(e==null?void 0:e.name,"selected-image-name"),c=Q("","selected-image-type");c.append(o),n.append(c,r);const h=k();h.style.marginTop="10px",h.style.display="flex",h.style.justifyContent="space-between",h.style.alignItems="center",h.append(l),t.append(n,s),a.append(t,h);const g=d(this,S).findIndex(W=>(W==null?void 0:W.key)===(e==null?void 0:e.key)),w=k("action-wrapper"),F=ee("","action-option edit"),v=Q("Edit",""),Z=sn();F.append(Z,v);const A=k("edit-form-wrapper"),V=k("form-control"),K=Q("File Name","input-label"),X=document.createElement("input");V.append(K,X),X.classList.add("input-field"),X.value=e.name;const C=k("form-control"),b=Q("File Destination","input-label"),O=document.createElement("input");O.classList.add("input-field"),O.value=e.folderName,C.append(b,O);const P=k("form-control"),se=Q("Folder List","input-label"),Ze=k();Ze.style.width="100%",Ze.style.maxHeight="250px",Ze.style.overflowY="auto";const bt=document.createElement("ul");bt.className="folders",Ze.append(bt),P.append(se,Ze),d(this,ce).forEach(W=>{const xe=this._renderEditFolderListContainer(W);bt.appendChild(xe)});const ln=k("form-control"),qi=Q("Move To","input-label"),cn=k("source-folder-wrapper","source-folder-wrapper");cn.innerHTML=d(this,Te)?d(this,Te):e.folderName;let qe="";ln.append(qi,cn),X.onchange=W=>{qe=W.target.value},qe=qe!==""?qe:e.name,A.append(V,C,P,ln),F.onclick=W=>{W.stopPropagation(),pe.hide(),M.show({content:A,header:"Update File",confirmButtonText:"Update",dialogContentStyle:{minWidth:"35rem",padding:"10px"},showCloseBtn:!0,showFooter:!0,onCancel:()=>{M.hide()},onConfirm:()=>{this._updateFile(qe,e)}})};const yt=ee("","action-option delete"),Ki=Q("Delete",""),Xi=on();yt.append(Xi,Ki),w.append(F,yt),yt.onclick=W=>{W.stopPropagation(),M.show({content:"",dialogContentStyle:{minWidth:"32rem",padding:"10px"},header:`Are you sure you want to delete the file "${e.name}"?`,showFooter:!0,confirmButtonText:"Yes",cancelButtonText:"No",onConfirm:()=>{this._deleteFile(e.key)}})},r.addEventListener("click",W=>{W.stopPropagation();const xe=document.querySelector(`#${e.key}`);d(this,re)===e.key&&xe!==null?(pe.hide(),f(this,re,null)):(pe.hide(),pe.show({content:w,mainContainer:n,divId:e.key}),f(this,re,e.key))}),s.addEventListener("click",()=>{t.classList.contains("checked")?(t.classList.remove("checked"),g!==-1&&(d(this,S).splice(g,1),d(this,Le)===1&&a.remove())):(t.classList.add("checked"),d(this,We)?d(this,S).push(e):f(this,S,[e])),this._updateSelectedImageListContainerUI()}),document.addEventListener("click",W=>{const xe=document.querySelector(`#${d(this,re)}`);xe&&(W.composedPath().includes(xe)||pe.hide())}),g!==-1?(t.classList.add("checked"),d(this,be)?d(this,D).prepend(a):d(this,D).appendChild(a)):d(this,D).appendChild(a)}_renderImageCard(e){this._fileCardBody(e)}_renderImageListContainer(){var e,t;((e=d(this,R))==null?void 0:e.length)>0&&((t=d(this,R))==null||t.forEach(n=>{this._renderImageCard(n)}))}_renderSelectedImageListContainer(){var e;((e=d(this,S))==null?void 0:e.length)>0&&d(this,S).forEach(t=>{this._renderImageCard(t)})}_renderFolderListLoadingUI(){const e=document.createElement("div");e.style.paddingInline="20px";for(let t=0;t<4;t++){const n=k("skeleton");n.className="skeleton folder",n.innerHTML="",e.appendChild(n)}return e}_renderFolderListContainer(e){var o;const t=document.createElement("li");t.className="folder";const n=document.createElement("div");n.style.position="relative",n.style.display="flex",n.style.alignItems="center",n.style.gap="2px";const r=document.createElement("span"),s=document.createElement("span");if(s.className="folder-name",s.textContent=e==null?void 0:e.name,r.appendChild(qt()),n.append(r,s),t.append(n),e.children&&Object.keys(e.children).length>0){const a=document.createElement("button");a.classList.add("expand-icon"),a.appendChild(Gt()),n.prepend(a);const l=document.createElement("ul");l.className="folders nested",t.appendChild(l),a.addEventListener("click",c=>{c.stopPropagation(),t.classList.toggle("active"),l.classList.toggle("visible")}),Object.values(e.children).forEach((c,h)=>{const g=this._renderFolderListContainer(c);l.appendChild(g)})}if(e.nestedFolderName){const a=ee("","folder-option-btn","moveToInputField.disabled",!1,'<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-ellipsis"><circle cx="12" cy="12" r="1"/><circle cx="19" cy="12" r="1"/><circle cx="5" cy="12" r="1"/></svg>'),l=k("action-wrapper"),c=ee("","action-option edit"),h=Q("Edit",""),g=sn();c.append(g,h);const w=k("edit-form-wrapper"),F=k("name-field-wrapper"),v=Q("Name","input-label"),Z=document.createElement("input");Z.classList.add("input-field"),Z.value=e.name,Z.onchange=C=>{C.target.value},F.append(v,Z),w.append(F);const A={key:e.key,name:e.name,nestedFolderName:e.nestedFolderName,createdBy:e.createdBy};this._createUpdateFolderDialog(c,"update",A);const V=ee("","action-option delete"),K=Q("Delete",""),X=on();V.append(X,K),l.append(c,V),V.onclick=C=>{C.stopPropagation(),M.show({content:"",dialogContentStyle:{minWidth:"32rem",padding:"10px"},header:"Are you sure you want to delete the folder",showFooter:!0,confirmButtonText:"Yes",cancelButtonText:"No",onConfirm:()=>{this._deleteFolder(e.key)}})},a.addEventListener("click",C=>{C.stopPropagation();const b=document.querySelector(`#${e.key}`);f(this,re,null),d(this,re)===e.key&&b!==null?pe.hide():(pe.hide(),pe.show({content:l,mainContainer:n,divId:e.key}),f(this,re,e.key))}),n.appendChild(a)}return t.addEventListener("click",a=>{var l;a.stopPropagation(),f(this,ie,e),f(this,Ne,e==null?void 0:e.name),f(this,S,[]),f(this,R,[]),f(this,he,""),f(this,Fe,!1),(l=document.querySelector(".folder.selected"))==null||l.classList.remove("selected"),t.classList.add("selected"),this._fetchFilesFromFolder(e.name)}),((o=d(this,ie))==null?void 0:o.key)===(e==null?void 0:e.key)&&t.classList.add("selected"),t}_renderEditFolderListContainer(e){var o;const t=document.createElement("li");t.className="folder-move";const n=document.createElement("div");n.style.position="relative",n.style.display="flex",n.style.alignItems="center",n.style.gap="2px";const r=document.createElement("span"),s=document.createElement("span");if(s.className="folder-name",s.textContent=e==null?void 0:e.name,r.appendChild(qt()),n.append(r,s),t.append(n),e.children&&Object.keys(e.children).length>0){const a=document.createElement("button");a.classList.add("expand-icon"),a.appendChild(Gt()),n.prepend(a);const l=document.createElement("ul");l.className="folders nested",t.appendChild(l),a.addEventListener("click",c=>{c.stopPropagation(),t.classList.toggle("active"),l.classList.toggle("visible")}),Object.values(e.children).forEach(c=>{const h=this._renderEditFolderListContainer(c);l.appendChild(h)})}return t.addEventListener("click",a=>{var c;a.stopPropagation(),f(this,Te,e==null?void 0:e.name);const l=document.querySelector("#source-folder-wrapper");l.innerHTML="",l.innerHTML=e==null?void 0:e.name,(c=document.querySelector(".folder-move.selected"))==null||c.classList.remove("selected"),t.classList.add("selected")}),((o=d(this,ie))==null?void 0:o.key)===(e==null?void 0:e.key)&&t.classList.add("selected"),t}_updateFolderListContainer(){if(d(this,Ie))if(d(this,we).innerHTML="",d(this,_e)){const e=this._renderFolderListLoadingUI();d(this,we).appendChild(e)}else{const e=document.createElement("ul");e.className="folders",d(this,we).appendChild(e),d(this,ce).forEach(t=>{const n=this._renderFolderListContainer(t);e.appendChild(n)}),d(this,Ie).appendChild(d(this,we))}}_renderToastContainer(e,t){this._removeToastContainer(),f(this,de,document.createElement("div")),d(this,de).className=`message-container ${t}`;const n=Ue(e,"message"),r=t==="success"?G:q,s=ee("");s.style.cursor="pointer",s.style.border="0",s.style.outline="none",s.style.background="transparent",s.appendChild(I(t==="error"?"#ee3f3f":"#4caf50")),s.setAttribute("fill",t==="error"?"#ee3f3f":"#4caf50"),s.onclick=()=>this._removeToastContainer(),d(this,de).append(r,n,s),d(this,ve).appendChild(d(this,de)),setTimeout(()=>{this._removeToastContainer()},5e3)}_removeToastContainer(){d(this,de)&&(d(this,de).remove(),f(this,de,null))}_updateSelectedImageListContainerUI(){var t,n;if(!d(this,D))return;d(this,D).innerHTML="",d(this,z)&&this._renderFetchingSkeletonUI(),d(this,Ee)&&this._renderLoadingUI();const e=document.getElementById("search-input-wrapper");d(this,Le)===0?(e&&(e.style.visibility="visible"),((t=d(this,R))==null?void 0:t.length)===0?(d(this,D).classList.add("no-selected-image-container"),this._renderEmptyImageContainer()):(d(this,D).classList.remove("no-selected-image-container"),this._renderImageListContainer())):(e&&(e.style.visibility="hidden"),((n=d(this,S))==null?void 0:n.length)===0?(d(this,D).classList.add("no-selected-image-container"),this._renderEmptyImageContainer()):(d(this,D).classList.remove("no-selected-image-container"),this._renderSelectedImageListContainer())),this._updateContent()}_updateContent(){var t,n,r;const e=document.getElementById("selected-images-tab");e&&(e.textContent=`Selected (${(t=d(this,S))==null?void 0:t.length})`),d(this,ke).textContent=`Save (${(n=d(this,S))==null?void 0:n.length})`,d(this,ke).disabled=((r=d(this,S))==null?void 0:r.length)<=0}async _uploadAndAddSelectedImageList(e,t){var n,r;f(this,Ee,!0),this._updateSelectedImageListContainerUI();try{const s=await ei(e,t),o=await Li(t==null?void 0:t.name,"",s,fe[Bi((n=t.type)==null?void 0:n.split("/")[0])],(r=d(this,ie))==null?void 0:r.name,d(this,J));d(this,R).unshift(o==null?void 0:o.response),this._renderToastContainer("File Uploaded Successfully","success")}catch{this._renderToastContainer("Something went wrong while uploading file. Please try again later.","error")}finally{f(this,Ee,!1),this._updateSelectedImageListContainerUI()}}async _updateFile(e,t){M.updateUploadBtn(!0);try{const n=await Ai(t.key,e,t.nestedFolderName,t.url,t.thumborUrl,t.proxyUrl,t.type,d(this,Te),d(this,J)),r=d(this,R).find(s=>s.key===n.response.key);r.name=e,this._fetchFilesFromFolder(d(this,ie).name),f(this,R,[]),f(this,S,[]),this._renderToastContainer("File Updated Successfully","success")}catch{this._renderToastContainer("Something went wrong while updating the file. Please try again later.","error")}finally{M.updateUploadBtn(!1),M.hide(),this._updateSelectedImageListContainerUI()}}async _deleteFile(e){M.updateUploadBtn(!0);try{await Ti(e,d(this,J)),f(this,R,d(this,R).filter(t=>e!==t.key)),this._renderToastContainer("File Deleted Successfully","success")}catch{this._renderToastContainer("Something went wrong while deleting the file. Please try again later.","error")}finally{M.updateUploadBtn(!1),M.hide(),this._updateSelectedImageListContainerUI()}}async _createFolder(e,t=2){var n;try{const r=await ci(e,(n=d(this,ie))==null?void 0:n.name,"",d(this,J));f(this,S,[]),f(this,R,[]);const s=_i(d(this,ce),r==null?void 0:r.response);f(this,ce,s),f(this,Ne,e),f(this,ie,{...r==null?void 0:r.response,children:{}}),this._fetchFilesFromFolder(e),this._renderToastContainer(`Folder ${e} created successfully`,"success")}catch{if(t>1)this._createFolder(e,--t);else throw this._renderToastContainer(`Error creating folder "${e}". Either folder already exist or failed to create folder`,"error"),new Error(`Error creating folder "${e}". Either folder already exist or failed to create folder`)}finally{this._updateFolderListContainer()}}async _upload(){return d(this,S)}async _fetchFilesFromFolder(e){var t,n,r;f(this,z,!0),this._updateSelectedImageListContainerUI();try{const s=await Ii(e,d(this,he),20,d(this,J)),o=(t=s.response)==null?void 0:t.files;d(this,R).push(...o),f(this,he,(n=s.response)==null?void 0:n.nextCursor),f(this,Fe,(r=s.response)==null?void 0:r.hasMore)}catch{throw this._renderToastContainer("Error while fetching files from folder"+e,"error"),new Error("Something went wrong. Error while fetching files from folder"+e)}finally{f(this,z,!1),this._updateSelectedImageListContainerUI()}}async _fetchAllFolders(){var e,t;f(this,z,!0),f(this,_e,!0),this._updateSelectedImageListContainerUI(),this._updateFolderListContainer(),this._removeToastContainer();try{const r=(await li("",100,d(this,J))).response.folder,s=vi(r);f(this,Ne,(e=s[0])==null?void 0:e.name),this._fetchFilesFromFolder((t=s[0])==null?void 0:t.name),f(this,ie,s[0]),f(this,ce,s)}catch{f(this,z,!1),this._renderToastContainer("Folder not found. Please create a folder or try again later","error")}finally{f(this,_e,!1),this._updateFolderListContainer()}}async _search(e){var t,n;f(this,z,!0),this._updateSelectedImageListContainerUI(),this._removeToastContainer();try{const r=await Fi(e,d(this,he),10,d(this,J)),s=(t=r.response)==null?void 0:t.items;d(this,R).push(...s),f(this,he,(n=r.response)==null?void 0:n.nextPageCursor)}catch{this._renderToastContainer("Error while searching files","error")}finally{f(this,z,!1),this._updateSelectedImageListContainerUI()}}async _updateFolder(e,t){M.updateUploadBtn(!0);try{const n=await di(t.key,e,t.nestedFolderName,t.createdBy,d(this,J))}catch{throw this._renderToastContainer("Something went wrong while updating the folder. Please try again later.","error"),new Error("Error updating the folder ")}finally{M.updateUploadBtn(!1),M.hide(),this._updateFolderListContainer()}}async _deleteFolder(e){M.updateUploadBtn(!0);try{await hi(e,d(this,J)),f(this,ce,d(this,ce).filter(t=>t.key!==e)),this._renderToastContainer("Folder Deleted Successfully","success")}catch{throw this._renderToastContainer("Something went wrong while deleting the folder. Please try again later.","error"),new Error("Error deleting the folder ")}finally{M.updateUploadBtn(!1),M.hide(),this._updateFolderListContainer()}}_createUpdateFolderDialog(e,t,n){e.addEventListener("click",r=>{r.stopPropagation(),pe.hide();let s;const o=k("edit-form-wrapper"),a=k("form-control"),l=Q("Folder Name","input-label"),c=document.createElement("input");c.classList.add("input-field"),t==="update"&&(c.value=n.name),c.onchange=h=>{s=h.target.value},a.append(l,c),o.append(a),M.show({content:o,header:t==="update"?"Update Folder":"Create Folder",confirmButtonText:t==="create"?"Save":"Update",dialogContentStyle:{minWidth:"35rem",padding:"10px"},showFooter:!0,showCloseBtn:!0,onConfirm:()=>{t==="create"?this._createFolder(s):this._updateFolder(s,n),M.hide()}})})}updateWindowObject(e){window.ImageSalonSDK={...window.ImageSalonSDK,...e}}_initializeGrpcConfig(e){const t=new Zi({baseUrl:e==="production"?"https://page-api-grpc.hamropatro.com":"https://hamro-cms-backend-grpc.hamrostack.com"});this.updateWindowObject({grpcConfig:t})}}return Be=new WeakMap,ve=new WeakMap,D=new WeakMap,ge=new WeakMap,S=new WeakMap,R=new WeakMap,Ee=new WeakMap,z=new WeakMap,_e=new WeakMap,Ne=new WeakMap,ce=new WeakMap,ie=new WeakMap,ke=new WeakMap,$e=new WeakMap,Le=new WeakMap,Ie=new WeakMap,we=new WeakMap,Oe=new WeakMap,de=new WeakMap,he=new WeakMap,Fe=new WeakMap,Ae=new WeakMap,be=new WeakMap,De=new WeakMap,je=new WeakMap,J=new WeakMap,re=new WeakMap,Pe=new WeakMap,We=new WeakMap,Te=new WeakMap,new an({handleUpload:()=>{},parentContainerId:"app",mode:"development",enableMultiSelect:!0}),an});
89
+ `,n.textContent="Looks Empty!"),e.append(t,n),d(this,D).appendChild(e)}_renderLoadingUI(){const e=k("skeleton");e.innerHTML="",d(this,D).appendChild(e)}_fileCardBody(e){const t=k("selected-image-content"),n=k("selected-image-top-bar"),r=ee("","selected-image-btn","",!1,'<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-ellipsis"><circle cx="12" cy="12" r="1"/><circle cx="19" cy="12" r="1"/><circle cx="5" cy="12" r="1"/></svg>');let s,o;(e==null?void 0:e.type)===fe.IMAGE&&(s=hn(e==null?void 0:e.url,"selected-image"),o=Di()),(e==null?void 0:e.type)===fe.VIDEO&&(s=un(e==null?void 0:e.url,"uploaded-video"),o=xi()),(e==null?void 0:e.type)===fe.AUDIO&&(s=fn(e==null?void 0:e.url,"uploaded-audio"),o=Ri());const a=k("selected-image-wrapper",e==null?void 0:e.key),l=Ue(e==null?void 0:e.name,"selected-image-name"),c=Q("","selected-image-type");c.append(o),n.append(c,r);const h=k();h.style.marginTop="10px",h.style.display="flex",h.style.justifyContent="space-between",h.style.alignItems="center",h.append(l),t.append(n,s),a.append(t,h);const g=d(this,S).findIndex(W=>(W==null?void 0:W.key)===(e==null?void 0:e.key)),w=k("action-wrapper"),F=ee("","action-option edit"),v=Q("Edit",""),Z=sn();F.append(Z,v);const A=k("edit-form-wrapper"),V=k("form-control"),K=Q("File Name","input-label"),X=document.createElement("input");V.append(K,X),X.classList.add("input-field"),X.value=e.name;const C=k("form-control"),b=Q("File Destination","input-label"),O=document.createElement("input");O.classList.add("input-field"),O.value=e.folderName,C.append(b,O);const P=k("form-control"),se=Q("Folder List","input-label"),Ze=k();Ze.style.width="100%",Ze.style.maxHeight="250px",Ze.style.overflowY="auto";const bt=document.createElement("ul");bt.className="folders",Ze.append(bt),P.append(se,Ze),d(this,ce).forEach(W=>{const xe=this._renderEditFolderListContainer(W);bt.appendChild(xe)});const an=k("form-control"),qi=Q("Move To","input-label"),ln=k("source-folder-wrapper","source-folder-wrapper");ln.innerHTML=d(this,Te)?d(this,Te):e.folderName;let qe="";an.append(qi,ln),X.onchange=W=>{qe=W.target.value},qe=qe!==""?qe:e.name,A.append(V,C,P,an),F.onclick=W=>{W.stopPropagation(),pe.hide(),M.show({content:A,header:"Update File",confirmButtonText:"Update",dialogContentStyle:{minWidth:"35rem",padding:"10px"},showCloseBtn:!0,showFooter:!0,onCancel:()=>{M.hide()},onConfirm:()=>{this._updateFile(qe,e)}})};const yt=ee("","action-option delete"),Ki=Q("Delete",""),Xi=on();yt.append(Xi,Ki),w.append(F,yt),yt.onclick=W=>{W.stopPropagation(),M.show({content:"",dialogContentStyle:{minWidth:"32rem",padding:"10px"},header:`Are you sure you want to delete the file "${e.name}"?`,showFooter:!0,confirmButtonText:"Yes",cancelButtonText:"No",onConfirm:()=>{this._deleteFile(e.key)}})},r.addEventListener("click",W=>{W.stopPropagation();const xe=document.querySelector(`#${e.key}`);d(this,re)===e.key&&xe!==null?(pe.hide(),f(this,re,null)):(pe.hide(),pe.show({content:w,mainContainer:n,divId:e.key}),f(this,re,e.key))}),s.addEventListener("click",()=>{t.classList.contains("checked")?(t.classList.remove("checked"),g!==-1&&(d(this,S).splice(g,1),d(this,Le)===1&&a.remove())):(t.classList.add("checked"),d(this,We)?d(this,S).push(e):f(this,S,[e])),this._updateSelectedImageListContainerUI()}),document.addEventListener("click",W=>{const xe=document.querySelector(`#${d(this,re)}`);xe&&(W.composedPath().includes(xe)||pe.hide())}),g!==-1?(t.classList.add("checked"),d(this,be)?d(this,D).prepend(a):d(this,D).appendChild(a)):d(this,D).appendChild(a)}_renderImageCard(e){this._fileCardBody(e)}_renderImageListContainer(){var e,t;((e=d(this,R))==null?void 0:e.length)>0&&((t=d(this,R))==null||t.forEach(n=>{this._renderImageCard(n)}))}_renderSelectedImageListContainer(){var e;((e=d(this,S))==null?void 0:e.length)>0&&d(this,S).forEach(t=>{this._renderImageCard(t)})}_renderFolderListLoadingUI(){const e=document.createElement("div");e.style.paddingInline="20px";for(let t=0;t<4;t++){const n=k("skeleton");n.className="skeleton folder",n.innerHTML="",e.appendChild(n)}return e}_renderFolderListContainer(e){var o;const t=document.createElement("li");t.className="folder";const n=document.createElement("div");n.style.position="relative",n.style.display="flex",n.style.alignItems="center",n.style.gap="2px";const r=document.createElement("span"),s=document.createElement("span");if(s.className="folder-name",s.textContent=e==null?void 0:e.name,r.appendChild(qt()),n.append(r,s),t.append(n),e.children&&Object.keys(e.children).length>0){const a=document.createElement("button");a.classList.add("expand-icon"),a.appendChild(Gt()),n.prepend(a);const l=document.createElement("ul");l.className="folders nested",t.appendChild(l),a.addEventListener("click",c=>{c.stopPropagation(),t.classList.toggle("active"),l.classList.toggle("visible")}),Object.values(e.children).forEach((c,h)=>{const g=this._renderFolderListContainer(c);l.appendChild(g)})}if(e.nestedFolderName){const a=ee("","folder-option-btn","moveToInputField.disabled",!1,'<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-ellipsis"><circle cx="12" cy="12" r="1"/><circle cx="19" cy="12" r="1"/><circle cx="5" cy="12" r="1"/></svg>'),l=k("action-wrapper"),c=ee("","action-option edit"),h=Q("Edit",""),g=sn();c.append(g,h);const w=k("edit-form-wrapper"),F=k("name-field-wrapper"),v=Q("Name","input-label"),Z=document.createElement("input");Z.classList.add("input-field"),Z.value=e.name,Z.onchange=C=>{C.target.value},F.append(v,Z),w.append(F);const A={key:e.key,name:e.name,nestedFolderName:e.nestedFolderName,createdBy:e.createdBy};this._createUpdateFolderDialog(c,"update",A);const V=ee("","action-option delete"),K=Q("Delete",""),X=on();V.append(X,K),l.append(c,V),V.onclick=C=>{C.stopPropagation(),M.show({content:"",dialogContentStyle:{minWidth:"32rem",padding:"10px"},header:"Are you sure you want to delete the folder",showFooter:!0,confirmButtonText:"Yes",cancelButtonText:"No",onConfirm:()=>{this._deleteFolder(e.key)}})},a.addEventListener("click",C=>{C.stopPropagation();const b=document.querySelector(`#${e.key}`);f(this,re,null),d(this,re)===e.key&&b!==null?pe.hide():(pe.hide(),pe.show({content:l,mainContainer:n,divId:e.key}),f(this,re,e.key))}),n.appendChild(a)}return t.addEventListener("click",a=>{var l;a.stopPropagation(),f(this,ie,e),f(this,Ne,e==null?void 0:e.name),f(this,S,[]),f(this,R,[]),f(this,he,""),f(this,Fe,!1),(l=document.querySelector(".folder.selected"))==null||l.classList.remove("selected"),t.classList.add("selected"),this._fetchFilesFromFolder(e.name)}),((o=d(this,ie))==null?void 0:o.key)===(e==null?void 0:e.key)&&t.classList.add("selected"),t}_renderEditFolderListContainer(e){var o;const t=document.createElement("li");t.className="folder-move";const n=document.createElement("div");n.style.position="relative",n.style.display="flex",n.style.alignItems="center",n.style.gap="2px";const r=document.createElement("span"),s=document.createElement("span");if(s.className="folder-name",s.textContent=e==null?void 0:e.name,r.appendChild(qt()),n.append(r,s),t.append(n),e.children&&Object.keys(e.children).length>0){const a=document.createElement("button");a.classList.add("expand-icon"),a.appendChild(Gt()),n.prepend(a);const l=document.createElement("ul");l.className="folders nested",t.appendChild(l),a.addEventListener("click",c=>{c.stopPropagation(),t.classList.toggle("active"),l.classList.toggle("visible")}),Object.values(e.children).forEach(c=>{const h=this._renderEditFolderListContainer(c);l.appendChild(h)})}return t.addEventListener("click",a=>{var c;a.stopPropagation(),f(this,Te,e==null?void 0:e.name);const l=document.querySelector("#source-folder-wrapper");l.innerHTML="",l.innerHTML=e==null?void 0:e.name,(c=document.querySelector(".folder-move.selected"))==null||c.classList.remove("selected"),t.classList.add("selected")}),((o=d(this,ie))==null?void 0:o.key)===(e==null?void 0:e.key)&&t.classList.add("selected"),t}_updateFolderListContainer(){if(d(this,Ie))if(d(this,we).innerHTML="",d(this,_e)){const e=this._renderFolderListLoadingUI();d(this,we).appendChild(e)}else{const e=document.createElement("ul");e.className="folders",d(this,we).appendChild(e),d(this,ce).forEach(t=>{const n=this._renderFolderListContainer(t);e.appendChild(n)}),d(this,Ie).appendChild(d(this,we))}}_renderToastContainer(e,t){this._removeToastContainer(),f(this,de,document.createElement("div")),d(this,de).className=`message-container ${t}`;const n=Ue(e,"message"),r=t==="success"?G:q,s=ee("");s.style.cursor="pointer",s.style.border="0",s.style.outline="none",s.style.background="transparent",s.appendChild(I(t==="error"?"#ee3f3f":"#4caf50")),s.setAttribute("fill",t==="error"?"#ee3f3f":"#4caf50"),s.onclick=()=>this._removeToastContainer(),d(this,de).append(r,n,s),d(this,ve).appendChild(d(this,de)),setTimeout(()=>{this._removeToastContainer()},5e3)}_removeToastContainer(){d(this,de)&&(d(this,de).remove(),f(this,de,null))}_updateSelectedImageListContainerUI(){var t,n;if(!d(this,D))return;d(this,D).innerHTML="",d(this,z)&&this._renderFetchingSkeletonUI(),d(this,Ee)&&this._renderLoadingUI();const e=document.getElementById("search-input-wrapper");d(this,Le)===0?(e&&(e.style.visibility="visible"),((t=d(this,R))==null?void 0:t.length)===0?(d(this,D).classList.add("no-selected-image-container"),this._renderEmptyImageContainer()):(d(this,D).classList.remove("no-selected-image-container"),this._renderImageListContainer())):(e&&(e.style.visibility="hidden"),((n=d(this,S))==null?void 0:n.length)===0?(d(this,D).classList.add("no-selected-image-container"),this._renderEmptyImageContainer()):(d(this,D).classList.remove("no-selected-image-container"),this._renderSelectedImageListContainer())),this._updateContent()}_updateContent(){var t,n,r;const e=document.getElementById("selected-images-tab");e&&(e.textContent=`Selected (${(t=d(this,S))==null?void 0:t.length})`),d(this,ke).textContent=`Save (${(n=d(this,S))==null?void 0:n.length})`,d(this,ke).disabled=((r=d(this,S))==null?void 0:r.length)<=0}async _uploadAndAddSelectedImageList(e,t){var n,r;f(this,Ee,!0),this._updateSelectedImageListContainerUI();try{const s=await Qn(e,t),o=await ki(t==null?void 0:t.name,"",s,fe[Ti((n=t.type)==null?void 0:n.split("/")[0])],(r=d(this,ie))==null?void 0:r.name,d(this,J));d(this,R).unshift(o==null?void 0:o.response),this._renderToastContainer("File Uploaded Successfully","success")}catch{this._renderToastContainer("Something went wrong while uploading file. Please try again later.","error")}finally{f(this,Ee,!1),this._updateSelectedImageListContainerUI()}}async _updateFile(e,t){M.updateUploadBtn(!0);try{const n=await Fi(t.key,e,t.nestedFolderName,t.url,t.thumborUrl,t.proxyUrl,t.type,d(this,Te),d(this,J)),r=d(this,R).find(s=>s.key===n.response.key);r.name=e,this._fetchFilesFromFolder(d(this,ie).name),f(this,R,[]),f(this,S,[]),this._renderToastContainer("File Updated Successfully","success")}catch{this._renderToastContainer("Something went wrong while updating the file. Please try again later.","error")}finally{M.updateUploadBtn(!1),M.hide(),this._updateSelectedImageListContainerUI()}}async _deleteFile(e){M.updateUploadBtn(!0);try{await Ai(e,d(this,J)),f(this,R,d(this,R).filter(t=>e!==t.key)),this._renderToastContainer("File Deleted Successfully","success")}catch{this._renderToastContainer("Something went wrong while deleting the file. Please try again later.","error")}finally{M.updateUploadBtn(!1),M.hide(),this._updateSelectedImageListContainerUI()}}async _createFolder(e,t=2){var n;try{const r=await li(e,(n=d(this,ie))==null?void 0:n.name,"",d(this,J));f(this,S,[]),f(this,R,[]);const s=vi(d(this,ce),r==null?void 0:r.response);f(this,ce,s),f(this,Ne,e),f(this,ie,{...r==null?void 0:r.response,children:{}}),this._fetchFilesFromFolder(e),this._renderToastContainer(`Folder ${e} created successfully`,"success")}catch{if(t>1)this._createFolder(e,--t);else throw this._renderToastContainer(`Error creating folder "${e}". Either folder already exist or failed to create folder`,"error"),new Error(`Error creating folder "${e}". Either folder already exist or failed to create folder`)}finally{this._updateFolderListContainer()}}async _upload(){return d(this,S)}async _fetchFilesFromFolder(e){var t,n,r;f(this,z,!0),this._updateSelectedImageListContainerUI();try{const s=await Li(e,d(this,he),20,d(this,J)),o=(t=s.response)==null?void 0:t.files;d(this,R).push(...o),f(this,he,(n=s.response)==null?void 0:n.nextCursor),f(this,Fe,(r=s.response)==null?void 0:r.hasMore)}catch{throw this._renderToastContainer("Error while fetching files from folder"+e,"error"),new Error("Something went wrong. Error while fetching files from folder"+e)}finally{f(this,z,!1),this._updateSelectedImageListContainerUI()}}async _fetchAllFolders(){var e,t;f(this,z,!0),f(this,_e,!0),this._updateSelectedImageListContainerUI(),this._updateFolderListContainer(),this._removeToastContainer();try{const r=(await ai("",100,d(this,J))).response.folder,s=Bi(r);f(this,Ne,(e=s[0])==null?void 0:e.name),this._fetchFilesFromFolder((t=s[0])==null?void 0:t.name),f(this,ie,s[0]),f(this,ce,s)}catch{f(this,z,!1),this._renderToastContainer("Folder not found. Please create a folder or try again later","error")}finally{f(this,_e,!1),this._updateFolderListContainer()}}async _search(e){var t,n;f(this,z,!0),this._updateSelectedImageListContainerUI(),this._removeToastContainer();try{const r=await Ii(e,d(this,he),10,d(this,J)),s=(t=r.response)==null?void 0:t.items;d(this,R).push(...s),f(this,he,(n=r.response)==null?void 0:n.nextPageCursor)}catch{this._renderToastContainer("Error while searching files","error")}finally{f(this,z,!1),this._updateSelectedImageListContainerUI()}}async _updateFolder(e,t){M.updateUploadBtn(!0);try{const n=await ci(t.key,e,t.nestedFolderName,t.createdBy,d(this,J))}catch{throw this._renderToastContainer("Something went wrong while updating the folder. Please try again later.","error"),new Error("Error updating the folder ")}finally{M.updateUploadBtn(!1),M.hide(),this._updateFolderListContainer()}}async _deleteFolder(e){M.updateUploadBtn(!0);try{await di(e,d(this,J)),f(this,ce,d(this,ce).filter(t=>t.key!==e)),this._renderToastContainer("Folder Deleted Successfully","success")}catch{throw this._renderToastContainer("Something went wrong while deleting the folder. Please try again later.","error"),new Error("Error deleting the folder ")}finally{M.updateUploadBtn(!1),M.hide(),this._updateFolderListContainer()}}_createUpdateFolderDialog(e,t,n){e.addEventListener("click",r=>{r.stopPropagation(),pe.hide();let s;const o=k("edit-form-wrapper"),a=k("form-control"),l=Q("Folder Name","input-label"),c=document.createElement("input");c.classList.add("input-field"),t==="update"&&(c.value=n.name),c.onchange=h=>{s=h.target.value},a.append(l,c),o.append(a),M.show({content:o,header:t==="update"?"Update Folder":"Create Folder",confirmButtonText:t==="create"?"Save":"Update",dialogContentStyle:{minWidth:"35rem",padding:"10px"},showFooter:!0,showCloseBtn:!0,onConfirm:()=>{t==="create"?this._createFolder(s):this._updateFolder(s,n),M.hide()}})})}updateWindowObject(e){window.ImageSalonSDK={...window.ImageSalonSDK,...e}}_initializeGrpcConfig(e){const t=new Wi({baseUrl:e==="production"?"https://page-api-grpc.hamropatro.com":"https://hamro-cms-backend-grpc.hamrostack.com"});this.updateWindowObject({grpcConfig:t})}}return Be=new WeakMap,ve=new WeakMap,D=new WeakMap,ge=new WeakMap,S=new WeakMap,R=new WeakMap,Ee=new WeakMap,z=new WeakMap,_e=new WeakMap,Ne=new WeakMap,ce=new WeakMap,ie=new WeakMap,ke=new WeakMap,$e=new WeakMap,Le=new WeakMap,Ie=new WeakMap,we=new WeakMap,Oe=new WeakMap,de=new WeakMap,he=new WeakMap,Fe=new WeakMap,Ae=new WeakMap,be=new WeakMap,De=new WeakMap,je=new WeakMap,J=new WeakMap,re=new WeakMap,Pe=new WeakMap,We=new WeakMap,Te=new WeakMap,Zi});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "image-salon-sdk",
3
- "version": "1.0.25",
3
+ "version": "1.0.26",
4
4
  "license": "ISC",
5
5
  "type": "module",
6
6
  "files": [