image-salon-sdk 1.0.36 → 1.0.37

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.
@@ -1,8 +1,8 @@
1
1
  import './style.css';
2
- (function(A,B){typeof exports=="object"&&typeof module<"u"?module.exports=B():typeof define=="function"&&define.amd?define(B):(A=typeof globalThis<"u"?globalThis:A||self,A.ImageSalonSdk=B())})(this,function(){"use strict";var Hr=Object.defineProperty;var Vn=A=>{throw TypeError(A)};var $r=(A,B,_)=>B in A?Hr(A,B,{enumerable:!0,configurable:!0,writable:!0,value:_}):A[B]=_;var D=(A,B,_)=>$r(A,typeof B!="symbol"?B+"":B,_),Hn=(A,B,_)=>B.has(A)||Vn("Cannot "+_);var d=(A,B,_)=>(Hn(A,B,"read from private field"),_?_.call(A):B.get(A)),N=(A,B,_)=>B.has(A)?Vn("Cannot add the same private member more than once"):B instanceof WeakSet?B.add(A):B.set(A,_),p=(A,B,_,Be)=>(Hn(A,B,"write to private field"),Be?Be.call(A,_):B.set(A,_),_);var pe,Ce,xe,V,fe,S,W,Ee,Y,_e,Ne,de,ie,ke,Se,Ae,Le,me,Oe,he,ue,Fe,Ie,ge,Ue,Ke,J,we,Xe,lt,Ge,X,Re,At,ve,Je,Me;function A(i){let e=typeof i;if(e=="object"){if(Array.isArray(i))return"array";if(i===null)return"null"}return e}function B(i){return i!==null&&typeof i=="object"&&!Array.isArray(i)}let _="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".split(""),Be=[];for(let i=0;i<_.length;i++)Be[_[i].charCodeAt(0)]=i;Be[45]=_.indexOf("+"),Be[95]=_.indexOf("/");function vt(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=Be[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 Tt(i){let e="",t=0,n,r=0;for(let s=0;s<i.length;s++)switch(n=i[s],t){case 0:e+=_[n>>2],r=(n&3)<<4,t=1;break;case 1:e+=_[r|n>>4],r=(n&15)<<2,t=2;break;case 2:e+=_[r|n>>6],e+=_[n&63],t=0;break}return t&&(e+=_[r],e+="=",t==1&&(e+="=")),e}var k;(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])})(k||(k={}));function $n(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 dt(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 Ye=65536*65536;function Bt(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>=Ye&&(r=r+(n/Ye|0),n=n%Ye)}return s(-24,-18),s(-18,-12),s(-12,-6),s(-6),[e,n,r]}function ht(i,e){if(e>>>0<=2097151)return""+(Ye*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 xt(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 jn(){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 L;function Zn(){const i=new DataView(new ArrayBuffer(8));L=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}Zn();function _t(i){if(!i)throw new Error("BigInt unavailable, see https://github.com/timostamm/protobuf-ts/blob/v1.0.8/MANUAL.md#bigint-support")}const Ot=/^-?[0-9]+$/,Qe=4294967296,et=2147483648;class Dt{constructor(e,t){this.lo=e|0,this.hi=t|0}isZero(){return this.lo==0&&this.hi==0}toNumber(){let e=this.hi*Qe+(this.lo>>>0);if(!Number.isSafeInteger(e))throw new Error("cannot convert to safe number");return e}}class q extends Dt{static from(e){if(L)switch(typeof e){case"string":if(e=="0")return this.ZERO;if(e=="")throw new Error("string is no integer");e=L.C(e);case"number":if(e===0)return this.ZERO;e=L.C(e);case"bigint":if(!e)return this.ZERO;if(e<L.UMIN)throw new Error("signed value for ulong");if(e>L.UMAX)throw new Error("ulong too large");return L.V.setBigUint64(0,e,!0),new q(L.V.getInt32(0,!0),L.V.getInt32(4,!0))}else switch(typeof e){case"string":if(e=="0")return this.ZERO;if(e=e.trim(),!Ot.test(e))throw new Error("string is no integer");let[t,n,r]=Bt(e);if(t)throw new Error("signed value for ulong");return new q(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 q(e,e/Qe)}throw new Error("unknown value "+typeof e)}toString(){return L?this.toBigInt().toString():ht(this.lo,this.hi)}toBigInt(){return _t(L),L.V.setInt32(0,this.lo,!0),L.V.setInt32(4,this.hi,!0),L.V.getBigUint64(0,!0)}}q.ZERO=new q(0,0);class R extends Dt{static from(e){if(L)switch(typeof e){case"string":if(e=="0")return this.ZERO;if(e=="")throw new Error("string is no integer");e=L.C(e);case"number":if(e===0)return this.ZERO;e=L.C(e);case"bigint":if(!e)return this.ZERO;if(e<L.MIN)throw new Error("signed long too small");if(e>L.MAX)throw new Error("signed long too large");return L.V.setBigInt64(0,e,!0),new R(L.V.getInt32(0,!0),L.V.getInt32(4,!0))}else switch(typeof e){case"string":if(e=="0")return this.ZERO;if(e=e.trim(),!Ot.test(e))throw new Error("string is no integer");let[t,n,r]=Bt(e);if(t){if(r>et||r==et&&n!=0)throw new Error("signed long too small")}else if(r>=et)throw new Error("signed long too large");let s=new R(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 R(e,e/Qe):new R(-e,-e/Qe).negate()}throw new Error("unknown value "+typeof e)}isNegative(){return(this.hi&et)!==0}negate(){let e=~this.hi,t=this.lo;return t?t=~t+1:e+=1,new R(t,e)}toString(){if(L)return this.toBigInt().toString();if(this.isNegative()){let e=this.negate();return"-"+ht(e.lo,e.hi)}return ht(this.lo,this.hi)}toBigInt(){return _t(L),L.V.setInt32(0,this.lo,!0),L.V.setInt32(4,this.hi,!0),L.V.getBigInt64(0,!0)}}R.ZERO=new R(0,0);const St={readUnknownField:!0,readerFactory:i=>new Pn(i)};function qn(i){return i?Object.assign(Object.assign({},St),i):St}class Pn{constructor(e,t){this.varint64=Wn,this.uint32=jn,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 R(...this.varint64())}uint64(){return new q(...this.varint64())}sint64(){let[e,t]=this.varint64(),n=-(e&1);return e=(e>>>1|(t&1)<<31)^n,t=t>>>1^n,new R(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 q(this.sfixed32(),this.sfixed32())}sfixed64(){return new R(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 Kn=34028234663852886e22,Xn=-34028234663852886e22,Gn=4294967295,Jn=2147483647,zn=-2147483648;function We(i){if(typeof i!="number")throw new Error("invalid int 32: "+typeof i);if(!Number.isInteger(i)||i>Jn||i<zn)throw new Error("invalid int 32: "+i)}function tt(i){if(typeof i!="number")throw new Error("invalid uint 32: "+typeof i);if(!Number.isInteger(i)||i>Gn||i<0)throw new Error("invalid uint 32: "+i)}function ut(i){if(typeof i!="number")throw new Error("invalid float 32: "+typeof i);if(Number.isFinite(i)&&(i>Kn||i<Xn))throw new Error("invalid float 32: "+i)}const Ut={writeUnknownFields:!0,writerFactory:()=>new Qn};function Yn(i){return i?Object.assign(Object.assign({},Ut),i):Ut}class Qn{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(tt(e);e>127;)this.buf.push(e&127|128),e=e>>>7;return this.buf.push(e),this}int32(e){return We(e),xt(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){ut(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){tt(e);let t=new Uint8Array(4);return new DataView(t.buffer).setUint32(0,e,!0),this.raw(t)}sfixed32(e){We(e);let t=new Uint8Array(4);return new DataView(t.buffer).setInt32(0,e,!0),this.raw(t)}sint32(e){return We(e),e=(e<<1^e>>31)>>>0,xt(e,this.buf),this}sfixed64(e){let t=new Uint8Array(8),n=new DataView(t.buffer),r=R.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=q.from(e);return n.setInt32(0,r.lo,!0),n.setInt32(4,r.hi,!0),this.raw(t)}int64(e){let t=R.from(e);return dt(t.lo,t.hi,this.buf),this}sint64(e){let t=R.from(e),n=t.hi>>31,r=t.lo<<1^n,s=(t.hi<<1|t.lo>>>31)^n;return dt(r,s,this.buf),this}uint64(e){let t=q.from(e);return dt(t.lo,t.hi,this.buf),this}}const Rt={emitDefaultValues:!1,enumAsInteger:!1,useProtoFieldName:!1,prettySpaces:0},Mt={ignoreUnknownFields:!1};function ei(i){return i?Object.assign(Object.assign({},Mt),i):Mt}function ti(i){return i?Object.assign(Object.assign({},Rt),i):Rt}function ni(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 Vt=Symbol.for("protobuf-ts/message-type");function pt(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 nt;(function(i){i[i.NO=0]="NO",i[i.PACKED=1]="PACKED",i[i.UNPACKED=2]="UNPACKED"})(nt||(nt={}));function ii(i){var e,t,n,r;return i.localName=(e=i.localName)!==null&&e!==void 0?e:pt(i.name),i.jsonName=(t=i.jsonName)!==null&&t!==void 0?t:pt(i.name),i.repeat=(n=i.repeat)!==null&&n!==void 0?n:nt.NO,i.opt=(r=i.opt)!==null&&r!==void 0?r:i.repeat||i.oneof?!1:i.kind=="message",i}function ri(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 si{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(!ri(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 oi{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=A(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(B(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 v;switch(a.V.kind){case"message":v=a.V.T().internalJsonRead(w,n);break;case"enum":if(v=this.enum(a.V.T(),w,a.name,n.ignoreUnknownFields),v===!1)continue;break;case"scalar":v=this.scalar(w,a.V.T,a.V.L,a.name);break}this.assert(v!==void 0,a.name+" map value",w);let O=g;a.K==u.BOOL&&(O=O=="true"?!0:O=="false"?!1:O),O=this.scalar(O,a.K,oe.STRING,a.name).toString(),h[O]=v}}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&&ut(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?tt(a):We(a),a;case u.INT64:case u.SFIXED64:case u.SINT64:if(e===null)return te(R.ZERO,n);if(typeof e!="number"&&typeof e!="string")break;return te(R.from(e),n);case u.FIXED64:case u.UINT64:if(e===null)return te(q.ZERO,n);if(typeof e!="number"&&typeof e!="string")break;return te(q.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 vt(e)}}catch(o){s=o.message}this.assert(!1,r+(s?" - "+s:""),e)}}class ai{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:(We(t),t);case u.FIXED32:case u.UINT32:return t===0?o?0:void 0:(tt(t),t);case u.FLOAT:ut(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=q.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=R.from(t);return l.isZero()&&!o?void 0:l.toString();case u.BYTES:return E(t instanceof Uint8Array),t.byteLength?Tt(t):o?"":void 0}}}function ft(i,e=oe.STRING){switch(i){case u.BOOL:return!1;case u.UINT64:case u.FIXED64:return te(q.ZERO,e);case u.INT64:case u.SFIXED64:case u.SINT64:return te(R.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 li{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 v=e.skip(a);w!==!1&&(w===!0?k.onRead:w)(this.info.typeName,t,o,a,v);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,v=l.kind=="scalar"?l.L:void 0;if(h){let T=c[g];if(a==m.LengthDelimited&&w!=u.STRING&&w!=u.BYTES){let Z=e.uint32()+e.pos;for(;e.pos<Z;)T.push(this.scalar(e,w,v))}else T.push(this.scalar(e,w,v))}else c[g]=this.scalar(e,w,v);break;case"message":if(h){let T=c[g],Z=l.T().internalBinaryRead(e,e.uint32(),n);T.push(Z)}else c[g]=l.T().internalBinaryRead(e,e.uint32(),n,c[g]);break;case"map":let[O,j]=this.mapEntry(l,e,n);c[g][O]=j;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=ft(e.K);o=e.K==u.BOOL?l.toString():l}if(a===void 0)switch(e.V.kind){case"scalar":a=ft(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 ci{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==nt.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?k.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||R.from(t).isZero(),r="int64";break;case u.UINT64:o=s||q.from(t).isZero(),r="uint64";break;case u.FIXED64:o=s||q.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||R.from(t).isZero(),n=m.Bit64,r="sfixed64";break;case u.SINT32:r="sint32";break;case u.SINT64:o=s||R.from(t).isZero(),r="sint64";break}return[n,r,s||o]}}function di(i){const e=i.messagePrototype?Object.create(i.messagePrototype):Object.defineProperty({},Vt,{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]=ft(t.T,t.L);break;case"enum":e[n]=0;break;case"map":e[n]={};break}}return e}function $(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 hi(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?$t(a,s,o):Ht(a,s,o)))return!1;break;case"map":if(!(n.V.kind=="message"?Wt(n.V.T(),it(s),it(o)):$t(n.V.kind=="enum"?u.INT32:n.V.T,it(s),it(o))))return!1;break;case"message":let l=n.T();if(!(n.repeat?Wt(l,s,o):l.equals(s,o)))return!1;break}}return!0}const it=Object.values;function Ht(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 $t(i,e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(!Ht(i,e[n],t[n]))return!1;return!0}function Wt(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 ui=Object.getOwnPropertyDescriptors(Object.getPrototypeOf({}));class P{constructor(e,t,n){this.defaultCheckDepth=16,this.typeName=e,this.fields=t.map(ii),this.options=n??{},this.messagePrototype=Object.create(null,Object.assign(Object.assign({},ui),{[Vt]:{value:this}})),this.refTypeCheck=new si(this),this.refJsonReader=new oi(this),this.refJsonWriter=new ai(this),this.refBinReader=new li(this),this.refBinWriter=new ci(this)}create(e){let t=di(this);return e!==void 0&&$(this,t,e),t}clone(e){let t=this.create();return $(this,t,e),t}equals(e,t){return hi(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){$(this,e,t)}fromBinary(e,t){let n=qn(t);return this.internalBinaryRead(n.readerFactory(e),e.byteLength,n)}fromJson(e,t){return this.internalJsonRead(e,ei(t))}fromJsonString(e,t){let n=JSON.parse(e);return this.fromJson(n,t)}toJson(e,t){return this.internalJsonWrite(e,ti(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=Yn(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 ${A(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 pi(i,e){var t,n,r;let s=i;return s.service=e,s.localName=(t=s.localName)!==null&&t!==void 0?t:pt(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 mt{constructor(e,t,n){this.typeName=e,this.methods=t.map(r=>pi(r,this)),this.options=n??{}}}class F 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 fi(i,e){if(!e)return i;let t={};rt(i,t),rt(e,t);for(let n of Object.keys(e)){let r=e[n];switch(n){case"jsonOptions":t.jsonOptions=ni(i.jsonOptions,t.jsonOptions);break;case"binaryOptions":t.binaryOptions=$n(i.binaryOptions,t.binaryOptions);break;case"meta":t.meta={},rt(i.meta,t.meta),rt(e.meta,t.meta);break;case"interceptors":t.interceptors=i.interceptors?i.interceptors.concat(r):r.concat();break}}return t}function rt(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 Q;(function(i){i[i.PENDING=0]="PENDING",i[i.REJECTED=1]="REJECTED",i[i.RESOLVED=2]="RESOLVED"})(Q||(Q={}));class ye{constructor(e=!0){this._state=Q.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!==Q.PENDING)throw new Error(`cannot resolve ${Q[this.state].toLowerCase()}`);this._resolve(e),this._state=Q.RESOLVED}reject(e){if(this.state!==Q.PENDING)throw new Error(`cannot reject ${Q[this.state].toLowerCase()}`);this._reject(e),this._state=Q.REJECTED}resolvePending(e){this._state===Q.PENDING&&this.resolve(e)}rejectPending(e){this._state===Q.PENDING&&this.reject(e)}}class mi{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==Q.PENDING,"iterator contract broken"),"value"in e?n.resolve(e):n.reject(e),delete t.p}else t.q.push(e)}}var gi=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 wi{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 gi(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 yi=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 bi{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 yi(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)}}var f;(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"})(f||(f={}));var Ci=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 jt(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 F(`timeout ${t} ms exceeded`,f[f.DEADLINE_EXCEEDED]);i.set("grpc-timeout",`${t}m`)}else if(t){const s=t.getTime(),o=Date.now();if(s<=o)throw new F(`deadline ${t} exceeded`,f[f.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:Tt(t)}function gt(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 F(`fetch response type ${l.type}`,f[f.UNKNOWN])}return gt(Ai(l.headers),l.status,l.statusText)}let n=i,r=e>=200&&e<300,s=Gt(n),[o,a]=Xt(n);return(o===void 0||o===f.OK)&&!r&&(o=Li(e),a=t),[o,a,s]}function qt(i){let e=ki(i),[t,n]=Xt(e),r=Gt(e);return[t??f.OK,n,r]}var ne;(function(i){i[i.DATA=0]="DATA",i[i.TRAILER=128]="TRAILER"})(ne||(ne={}));function Pt(i,e,t){return Ci(this,void 0,void 0,function*(){let n,r="",s=new Uint8Array(0),o=Ni(e);if(Ei(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=Kt(s,vt(r.substring(0,l))),r=r.substring(l)}else s=Kt(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 F("premature EOF",f[f.DATA_LOSS]);t(ne.TRAILER,s.subarray(5));break}}})}const Ei=i=>typeof i.getReader=="function";function Kt(i,e){let t=new Uint8Array(i.length+e.length);return t.set(i),t.set(e,i.length),t}function Ni(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 F("missing response content type",f[f.INTERNAL]);default:throw new F("unexpected response content type: "+i,f[f.INTERNAL])}}function Xt(i){let e,t,n=i["grpc-message"];if(n!==void 0){if(Array.isArray(n))return[f.INTERNAL,"invalid grpc-web message"];t=n}let r=i["grpc-status"];if(r!==void 0){if(Array.isArray(r))return[f.INTERNAL,"invalid grpc-web status"];if(e=parseInt(r,10),f[e]===void 0)return[f.INTERNAL,"invalid grpc-web status"]}return[e,t]}function Gt(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 ki(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 Ai(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 Li(i){switch(i){case 200:return f.OK;case 400:return f.INVALID_ARGUMENT;case 401:return f.UNAUTHENTICATED;case 403:return f.PERMISSION_DENIED;case 404:return f.NOT_FOUND;case 409:return f.ABORTED;case 412:return f.FAILED_PRECONDITION;case 429:return f.RESOURCE_EXHAUSTED;case 499:return f.CANCELLED;case 500:return f.UNKNOWN;case 501:return f.UNIMPLEMENTED;case 503:return f.UNAVAILABLE;case 504:return f.DEADLINE_EXCEEDED;default:return f.UNKNOWN}}class Fi{constructor(e){this.defaultOptions=e}mergeOptions(e){return fi(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 F("Client streaming is not supported by grpc-web",f[f.UNIMPLEMENTED]);throw t.methodName=e.name,t.serviceName=e.service.typeName,t}duplex(e){const t=new F("Duplex streaming is not supported by grpc-web",f[f.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),v=new ye,O=new mi,j=!0,T,Z=new ye,K,re=new ye;return globalThis.fetch(g,Object.assign(Object.assign({},h),{method:"POST",headers:jt(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,H,G]=gt(C);if(v.resolve(G),b!=null&&b!==f.OK)throw new F(H??f[b],f[b],G);return b!=null&&(T={code:f[b],detail:H??f[b]}),C}).then(C=>{if(!C.body)throw new F("missing response body",f[f.INTERNAL]);return Pt(C.body,C.headers.get("content-type"),(b,H)=>{switch(b){case ne.DATA:O.notifyMessage(e.O.fromBinary(H,l.binaryOptions)),j=!1;break;case ne.TRAILER:let G,se;[G,se,K]=qt(H),T={code:f[G],detail:se??f[G]};break}})}).then(()=>{if(!K&&!j)throw new F("missing trailers",f[f.DATA_LOSS]);if(!T)throw new F("missing status",f[f.INTERNAL]);if(T.code!=="OK")throw new F(T.detail,T.code,K);O.notifyComplete(),Z.resolve(T),re.resolve(K||{})}).catch(C=>{let b;C instanceof F?b=C:C instanceof Error&&C.name==="AbortError"?b=new F(C.message,f[f.CANCELLED]):b=new F(C instanceof Error?C.message:""+C,f[f.INTERNAL]),b.methodName=e.name,b.serviceName=e.service.typeName,v.rejectPending(b),O.notifyError(b),Z.rejectPending(b),re.rejectPending(b)}),new bi(e,(a=l.meta)!==null&&a!==void 0?a:{},t,v.promise,O,Z.promise,re.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),v=new ye,O,j=new ye,T,Z=new ye,K,re=new ye;return globalThis.fetch(g,Object.assign(Object.assign({},h),{method:"POST",headers:jt(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,H,G]=gt(C);if(v.resolve(G),b!=null&&b!==f.OK)throw new F(H??f[b],f[b],G);return b!=null&&(T={code:f[b],detail:H??f[b]}),C}).then(C=>{if(!C.body)throw new F("missing response body",f[f.INTERNAL]);return Pt(C.body,C.headers.get("content-type"),(b,H)=>{switch(b){case ne.DATA:if(O)throw new F("unary call received 2nd message",f[f.DATA_LOSS]);O=e.O.fromBinary(H,l.binaryOptions);break;case ne.TRAILER:let G,se;[G,se,K]=qt(H),T={code:f[G],detail:se??f[G]};break}})}).then(()=>{if(!K&&O)throw new F("missing trailers",f[f.DATA_LOSS]);if(!T)throw new F("missing status",f[f.INTERNAL]);if(!O&&T.code==="OK")throw new F("expected error status",f[f.DATA_LOSS]);if(!O)throw new F(T.detail,T.code,K);if(j.resolve(O),T.code!=="OK")throw new F(T.detail,T.code,K);Z.resolve(T),re.resolve(K||{})}).catch(C=>{let b;C instanceof F?b=C:C instanceof Error&&C.name==="AbortError"?b=new F(C.message,f[f.CANCELLED]):b=new F(C instanceof Error?C.message:""+C,f[f.INTERNAL]),b.methodName=e.name,b.serviceName=e.service.typeName,v.rejectPending(b),j.rejectPending(b),Z.rejectPending(b),re.rejectPending(b)}),new wi(e,(a=l.meta)!==null&&a!==void 0?a:{},t,v.promise,j.promise,Z.promise,re.promise)}}var wt=(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))(wt||{});class Ii extends P{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&&$(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?k.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?k.onWrite:r)(this.typeName,e,t),t}}const Jt=new Ii;class vi extends P{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&&$(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?k.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?k.onWrite:r)(this.typeName,e,t),t}}const Ti=new vi;class Bi extends P{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",wt]}])}create(e){const t=globalThis.Object.create(this.messagePrototype);return t.name="",t.folderName="",t.nestedFolderName="",t.url="",t.type=0,e!==void 0&&$(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?k.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?k.onWrite:r)(this.typeName,e,t),t}}const zt=new Bi;class xi extends P{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",wt]},{no:9,name:"metadata",kind:"message",T:()=>yt}])}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&&$(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=yt.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?k.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&&yt.internalBinaryWrite(e.metadata,t.tag(9,m.LengthDelimited).fork(),n).join();let r=n.writeUnknownFields;return r!==!1&&(r==!0?k.onWrite:r)(this.typeName,e,t),t}}const le=new xi;class _i extends P{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&&$(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?k.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?k.onWrite:r)(this.typeName,e,t),t}}const yt=new _i;class Oi extends P{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&&$(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?k.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?k.onWrite:r)(this.typeName,e,t),t}}const Yt=new Oi;class Di extends P{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&&$(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?k.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?k.onWrite:r)(this.typeName,e,t),t}}const Si=new Di;class Ui extends P{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&&$(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?k.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?k.onWrite:r)(this.typeName,e,t),t}}const Qt=new Ui;class Ri extends P{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&&$(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?k.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?k.onWrite:r)(this.typeName,e,t),t}}const Mi=new Ri,bt=new mt("com.hamropatro.grpc.cms.FileService",[{name:"createFile",options:{},I:zt,O:le},{name:"updateFile",options:{},I:le,O:le},{name:"deleteFile",options:{},I:Yt,O:Si},{name:"getFilesByFolder",options:{},I:Qt,O:Mi},{name:"search",options:{},I:Jt,O:Ti}]);class je{constructor(e){D(this,"typeName",bt.typeName);D(this,"methods",bt.methods);D(this,"options",bt.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 en=async(i,e,t,n,r,s)=>{var o;try{const a=(o=window.ImageSalonSDK)==null?void 0:o.grpcConfig,l=new je(a),c=zt.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}},Vi=async(i,e,t,n)=>{var r;try{const s=(r=window.ImageSalonSDK)==null?void 0:r.grpcConfig,o=new je(s),a=Qt.create();return a.folderName=i,a.cursor=e,a.limit=t,await o.getFilesByFolder(a,n)}catch(s){throw s}},Hi=async(i,e,t=20,n)=>{var r;try{const s=(r=window.ImageSalonSDK)==null?void 0:r.grpcConfig,o=new je(s),a=Jt.create();return a.searchValue=i,a.cursor=e,a.limit=t,await o.search(a,n)}catch(s){throw s}},$i=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 je(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}},Wi=async(i,e)=>{var t;try{const n=(t=window.ImageSalonSDK)==null?void 0:t.grpcConfig,r=new je(n),s=Yt.create();return s.key=i,await r.deleteFile(s,e)}catch(n){throw n}};class ji extends P{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&&$(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?k.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?k.onWrite:r)(this.typeName,e,t),t}}const tn=new ji;class Zi extends P{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&&$(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?k.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?k.onWrite:r)(this.typeName,e,t),t}}const nn=new Zi;class qi extends P{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&&$(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?k.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?k.onWrite:r)(this.typeName,e,t),t}}const rn=new qi;class Pi extends P{constructor(){super("com.hamropatro.grpc.cms.GetAllFoldersResponse",[{no:1,name:"folder",kind:"message",repeat:1,T:()=>be},{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&&$(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(be.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?k.onRead:c)(this.typeName,s,a,l,h)}}return s}internalBinaryWrite(e,t,n){for(let s=0;s<e.folder.length;s++)be.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?k.onWrite:r)(this.typeName,e,t),t}}const Ki=new Pi;class Xi extends P{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&&$(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?k.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?k.onWrite:r)(this.typeName,e,t),t}}const be=new Xi,Ct=new mt("com.hamropatro.grpc.cms.FolderService",[{name:"createFolder",options:{},I:nn,O:be},{name:"getFolders",options:{},I:rn,O:Ki},{name:"updateFolder",options:{},I:be,O:be},{name:"deleteFolder",options:{},I:tn,O:be}]);class st{constructor(e){D(this,"typeName",Ct.typeName);D(this,"methods",Ct.methods);D(this,"options",Ct.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 Gi=async(i,e=20,t)=>{var o;const n=(o=window.ImageSalonSDK)==null?void 0:o.grpcConfig,r=new st(n),s=rn.create();try{return s.cursor=i,s.limit=e,await r.getFolders(s,t)}catch(a){throw a}},Ji=async(i,e,t,n)=>{var r;try{const s=(r=window.ImageSalonSDK)==null?void 0:r.grpcConfig,o=new st(s),a=nn.create();return a.name=i,a.nestedFolderName=e,a.createdBy=t,await o.createFolder(a,n)}catch(s){throw s}},zi=async(i,e,t,n,r)=>{var s;try{const o=(s=window.ImageSalonSDK)==null?void 0:s.grpcConfig,a=new st(o),l=be.create();return l.name=e,l.key=i,l.nestedFolderName=t,l.createdBy=n,await a.updateFolder(l,r)}catch(o){throw o}},Yi=async(i,e)=>{var t;try{const n=(t=window.ImageSalonSDK)==null?void 0:t.grpcConfig,r=new st(n),s=tn.create();return s.key=i,await r.deleteFolder(s,e)}catch(n){throw n}},sn=(i,e,t)=>{const n=document.createElementNS("http://www.w3.org/2000/svg","svg");n.setAttribute("xmlns","http://www.w3.org/2000/svg"),n.setAttribute("width",i||"20"),n.setAttribute("height",e||"20"),n.setAttribute("viewBox","0 0 24 24"),n.setAttribute("fill","none"),n.setAttribute("stroke",t||"#ee3f3f"),n.setAttribute("stroke-width","2"),n.setAttribute("stroke-linecap","round"),n.setAttribute("stroke-linejoin","round"),n.classList.add("lucide","lucide-circle-alert");const r=document.createElementNS("http://www.w3.org/2000/svg","circle");r.setAttribute("cx","12"),r.setAttribute("cy","12"),r.setAttribute("r","10");const s=document.createElementNS("http://www.w3.org/2000/svg","line");s.setAttribute("x1","12"),s.setAttribute("x2","12"),s.setAttribute("y1","8"),s.setAttribute("y2","12");const o=document.createElementNS("http://www.w3.org/2000/svg","line");return o.setAttribute("x1","12"),o.setAttribute("x2","12.01"),o.setAttribute("y1","16"),o.setAttribute("y2","16"),n.appendChild(r),n.appendChild(s),n.appendChild(o),n};function on(){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 Qi(){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}const er=()=>{const i=document.createElementNS("http://www.w3.org/2000/svg","svg");i.setAttribute("xmlns","http://www.w3.org/2000/svg"),i.setAttribute("width","20"),i.setAttribute("height","20"),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-circle-check-big");const e=document.createElementNS("http://www.w3.org/2000/svg","path");e.setAttribute("d","M21.801 10A10 10 0 1 1 17 3.335");const t=document.createElementNS("http://www.w3.org/2000/svg","path");return t.setAttribute("d","m9 11 3 3L22 4"),i.appendChild(e),i.appendChild(t),i};function Et(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 an(){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 Ze(){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}function tr(){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}function nr(){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("viewBox","0 -960 960 960"),i.setAttribute("width","24px"),i.setAttribute("fill","currentColor");const e=document.createElementNS("http://www.w3.org/2000/svg","path");return e.setAttribute("d","m488-400-65 65 56 56 161-161-161-161-56 56 65 65H320v80h168ZM160-160q-33 0-56.5-23.5T80-240v-480q0-33 23.5-56.5T160-800h240l80 80h320q33 0 56.5 23.5T880-640v400q0 33-23.5 56.5T800-160H160Zm0-80h640v-400H447l-80-80H160v480Zm0 0v-480 480Z"),i.appendChild(e),i}function ln(){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 ir(){const i="http://www.w3.org/2000/svg",e=document.createElementNS(i,"svg");e.setAttribute("width","16"),e.setAttribute("height","16"),e.setAttribute("viewBox","0 0 24 24"),e.setAttribute("fill","none"),e.setAttribute("stroke","currentColor"),e.setAttribute("stroke-width","2"),e.setAttribute("stroke-linecap","round"),e.setAttribute("stroke-linejoin","round"),e.classList.add("lucide","lucide-eye");const t=document.createElementNS(i,"path");t.setAttribute("d","M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0"),e.appendChild(t);const n=document.createElementNS(i,"circle");return n.setAttribute("cx","12"),n.setAttribute("cy","12"),n.setAttribute("r","3"),e.appendChild(n),document.body.appendChild(e),e}function rr(){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 cn(){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}function sr(){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 or(){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 x(i,e,t,n,r){let s=document.createElement(i);return e&&(s.className+=e),t&&(s.style.cssText=t),n&&(s.textContent=n),r&&r.appendChild(s),s}class ar{constructor(){N(this,pe);p(this,pe,document.createElementNS("http://www.w3.org/2000/svg","svg")),d(this,pe).setAttribute("viewBox","25 25 50 50"),d(this,pe).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,pe).appendChild(e)}show(e){e.appendChild(d(this,pe))}hide(){d(this,pe).remove()}}pe=new WeakMap;const dn=new ar,ot=document.body;class hn{constructor(){D(this,"main");D(this,"dialogContainer");D(this,"dialog");D(this,"dialogBackdrop");D(this,"dialogContent");D(this,"dialogHeader");D(this,"dialogBody");D(this,"dialogFooter");D(this,"confirmButton");D(this,"cancelButton");D(this,"confirmCallback");D(this,"cancelCallback");this.main=x("div"),this.dialog=x("div"),this.confirmCallback=void 0,this.cancelCallback=void 0}_init(e){this.main=x("div","dialog-presentation","","",ot),this.main.setAttribute("role","presentation"),this.dialogContainer=x("div","dialog-container","","",this.main),this.dialogBackdrop=x("div","dialog-backdrop","","",this.dialogContainer),this.dialog=x("div","dialog","","",this.dialogContainer),this.dialog.setAttribute("tabIndex","-1");const t=document.activeElement;if(t&&t!==document.body&&(t.blur(),this.dialog.focus()),this.dialog.className="dialog",this.dialogContent=x("div","dialog-content","","",this.dialog),e!=null&&e.dialogContentStyle&&Object.assign(this.dialogContent.style,e.dialogContentStyle),this.confirmButton=x("button","dialog-btn confirm","","",this.dialogFooter),this.confirmButton.type="button",this.cancelButton=x("button","dialog-btn cancel","","",this.dialogFooter),this.cancelButton.type="button",e.showCloseBtn){const n=x("button","dialog-close-btn","","",this.dialogContent);n.appendChild(Et()),n.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",ot.style.overflow="hidden",this.confirmButton.textContent=e.confirmButtonText||"Upload",this.cancelButton.textContent=e.cancelButtonText||"Cancel",ot.classList.add("dialog-visible"),new Promise(n=>{const r=s=>()=>{this.hide(),n(s==="confirm")};this.confirmCallback=e.onConfirm||r("confirm"),this.confirmButton.addEventListener("click",this.confirmCallback),this.cancelCallback=e.onCancel||r("cancel"),this.cancelButton.addEventListener("click",this.cancelCallback)})}_setHeader(e){if(this.dialogHeader=x("div","dialog-header","","",this.dialogContent),!e.header)this.dialogHeader.innerHTML="";else if(typeof e.header=="string"){const t=x("h4","dialog-header-text","","",this.dialogHeader);t.textContent=e.header}else this.dialogHeader.innerHTML="",this.dialogHeader.appendChild(e.header)}_setBody(e){this.dialogBody=x("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=x("div","dialog-footer","","",this.dialogContent),e.showFooter?this.dialogFooter.append(this.cancelButton,this.confirmButton):(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||ot.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?(dn.show(this.confirmButton),this.confirmButton.disabled=!0):(dn.hide(),this.confirmButton.disabled=!1)}}const at=new hn,M=new hn;class lr{constructor(){D(this,"main");D(this,"dialogBody");this.main=x("div"),this.dialogBody=x("div"),this.hide()}show(e){this.main=x("div","popover","","",e.mainContainer),this.dialogBody=x("div","popover-body","","",this.main),this.main.id=e.divId,this.dialogBody.append(e.content)}hide(){this.main.remove()}}const ee=new lr;var ce=(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))(ce||{});const qe={0:"IMAGE",1:"AUDIO",2:"VIDEO",3:"ALL",4:"FOLDER"};function un(i){switch(i){case"image":return qe[ce.IMAGE];case"video":return qe[ce.VIDEO];case"audio":return qe[ce.AUDIO];default:return qe[ce.ALL]}}function cr(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 dr(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}const hr=async(i,e)=>{let t;try{i&&(t={Authorization:i,"app-id":e==="production"?"hamropatro":"hamropatro-android"})}catch(r){if(r)throw r}return{meta:t}};function y(i,e){const t=document.createElement("div");return i&&(t.className=i),e&&(t.id=e),t}function Pe(i,e,t){const n=document.createElement("p");return e&&(n.className=e),t&&(n.id=t),i&&(n.textContent=i),n}function I(i,e){const t=document.createElement("span");return e&&(t.className=e),i&&(t.textContent=i),t}function pn(i,e,t,n){const r=document.createElement("img");return e&&(r.className=e),r.src=i,r}function ur(i,e,t){const n=document.createElement("video"),r=document.createElement("source");return n.className=e,r.src=i,n.appendChild(r),n}function pr(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 z(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 Nt(i,e,t){const n=document.createElement("input");return n.className=e,n.defaultValue=t,i&&(n.type=i),n}class fr extends P{constructor(){super("com.hamropatro.grpc.cms.ImageUploadRequest",[{no:1,name:"mime_type",kind:"scalar",T:9}])}create(e){const t=globalThis.Object.create(this.messagePrototype);return t.mimeType="",e!==void 0&&$(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.mimeType=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?k.onRead:c)(this.typeName,s,a,l,h)}}return s}internalBinaryWrite(e,t,n){e.mimeType!==""&&t.tag(1,m.LengthDelimited).string(e.mimeType);let r=n.writeUnknownFields;return r!==!1&&(r==!0?k.onWrite:r)(this.typeName,e,t),t}}const fn=new fr;class mr extends P{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&&$(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?k.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?k.onWrite:r)(this.typeName,e,t),t}}const gr=new mr,kt=new mt("com.hamropatro.grpc.cms.ImageUploadService",[{name:"Upload",options:{},I:fn,O:gr}]);class wr{constructor(e){D(this,"typeName",kt.typeName);D(this,"methods",kt.methods);D(this,"options",kt.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 yr=async i=>{var r;const e=(r=window.ImageSalonSDK)==null?void 0:r.grpcConfig,t=new wr(e),n=fn.create();try{return n.mimeType=i,await t.upload(n)}catch(s){throw s}},mn=async(i,e)=>{try{const t=br(i,e),r=(await yr(e==null?void 0:e.type)).response.url;return await fetch(r,{method:"PUT",headers:{"Content-Type":e==null?void 0:e.type,"x-amz-acl":"public-read"},body:t}),r==null?void 0:r.split("?")[0]}catch(t){throw t}},br=(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,/,""):t==="audio"&&(n=i==null?void 0:i.replace(/^data:audio\/\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};function gn(){const i=document.createElementNS("http://www.w3.org/2000/svg","svg");i.setAttribute("xmlns","http://www.w3.org/2000/svg"),i.setAttribute("width","40"),i.setAttribute("height","40"),i.setAttribute("viewBox","0 0 24 24"),i.setAttribute("fill","none"),i.setAttribute("stroke","#777"),i.setAttribute("stroke-width","2"),i.setAttribute("stroke-linecap","round"),i.setAttribute("stroke-linejoin","round"),i.classList.add("lucide","lucide-image-up");const e=document.createElementNS("http://www.w3.org/2000/svg","path");e.setAttribute("d","M10.3 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2v10l-3.1-3.1a2 2 0 0 0-2.814.014L6 21");const t=document.createElementNS("http://www.w3.org/2000/svg","path");t.setAttribute("d","m14 19.5 3-3 3 3");const n=document.createElementNS("http://www.w3.org/2000/svg","path");n.setAttribute("d","M17 22v-5.5");const r=document.createElementNS("http://www.w3.org/2000/svg","circle");return r.setAttribute("cx","9"),r.setAttribute("cy","9"),r.setAttribute("r","2"),i.appendChild(e),i.appendChild(t),i.appendChild(n),i.appendChild(r),i}class Cr{constructor(e){N(this,Ce);N(this,xe);N(this,V);N(this,fe);N(this,S,[]);N(this,W,[]);N(this,Ee);N(this,Y);N(this,_e);N(this,Ne);N(this,de,[]);N(this,ie);N(this,ke);N(this,Se);N(this,Ae);N(this,Le);N(this,me);N(this,Oe);N(this,he);N(this,ue);N(this,Fe);N(this,Ie);N(this,ge);N(this,Ue);N(this,Ke);N(this,J);N(this,we);N(this,Xe,!1);N(this,lt);N(this,Ge);N(this,X);N(this,Re);N(this,At);N(this,ve);N(this,Je);N(this,Me);p(this,Ge,e.isAdmin),p(this,Ee,!1),p(this,Y,!1),p(this,_e,!1),p(this,Se,e.handleUpload.bind(this)),p(this,Ae,0),p(this,ue,""),p(this,ge,!1),p(this,Je,e.mode),p(this,Fe,!1),p(this,Ke,e.accessToken),p(this,we,null),p(this,ve,""),this._removeToastContainer(),this._grpcOptionInitializer(),this._init(e).then(()=>{p(this,Xe,!0),this._renderView(e),this.updateWindowObject({initialized:!0}),this._initializeGrpcConfig(e.mode,e.endPoint)}),p(this,Re,"")}async _init(e){try{const{mode:t}=e;this.updateWindowObject({mode:t})}catch{throw Error("Initialization failed")}}_isAdminOptions(e){return e.isAdmin===!0}_renderView(e){return this._isAdminOptions(e)?this._renderAdminView(e):this._renderUserView(e)}_renderAdminView(e){if(!d(this,Xe))return;const{parentContainerId:t}=e;if(e.isAdmin===!0)var{buttonProps:n}=e;p(this,Ce,document.getElementById(t));const r=document.createElement("button");r.className=n!=null&&n.buttonClass?n==null?void 0:n.buttonClass:"browse-image-button",r.addEventListener("focus",()=>{r.blur()});const s=document.createElement("span");s.textContent=n!=null&&n.buttonText?n==null?void 0:n.buttonText:"Browse Files";const o=document.createElement("span");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,Ce).appendChild(r)}async _grpcOptionInitializer(){p(this,J,await hr(d(this,Ke),d(this,Je)))}_selectedImageContainer(){var g;p(this,ke,z(`Save (${(g=d(this,S))==null?void 0:g.length})`,"dialog-btn confirm")),p(this,Le,y("folder-container")),p(this,me,y("folder-list-wrapper")),this._fetchAllFolders();const e=z("Cancel","dialog-btn cancel");z("","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",()=>{at.hide(),p(this,S,[]),p(this,W,[])}),p(this,xe,y("browse-container"));const n=y();n.style.display="flex",n.style.alignItems="center",n.style.justifyContent="space-between",n.style.padding="10px 20px";const r=Pe("Folders","folder-title"),s=z("","add-folder-btn");s.append(ln()),this._createUpdateFolderDialog(s,"create"),n.append(r,s),d(this,Le).append(n,d(this,me));const o=this._renderSearchField(),a=this._createBrowseMoreContainer(),l=this._createBrowseImageMain(),c=y("footer");e.onclick=()=>{at.hide(),p(this,W,[]),p(this,S,[])},d(this,ke).onclick=()=>{d(this,Se).call(this),at.hide(),p(this,S,[]),p(this,W,[])},c.append(e,d(this,ke));const h=y("container-right-main");h.append(o,a,l,c),d(this,xe).append(d(this,Le),h),at.show({content:d(this,xe)})}_renderUserView(e){const{parentContainerId:t,restrictedFileSize:n}=e;p(this,Ce,document.getElementById(t)),p(this,X,x("div","user-view-container"));const r=y("user-view-browse-wrapper"),s=x("span","",""," or drag & drop"),o=this._renderUserViewBrowseButton(),a=x("p","","margin-block: 0px; font-size: 18px");if(a.append(o,s),n){const l=x("p","","margin-block: 0px; font-size: 14px; color: #777",`Max File size: ${n}`);r.append(gn(),a,l)}else r.append(gn(),a);return this._setupDragAndDrop(d(this,X)),d(this,X).append(r),d(this,Ce).appendChild(d(this,X)),d(this,Ce)}_setupDragAndDrop(e){if(!e)return;["dragenter","dragover","dragleave","drop"].forEach(n=>{d(this,X).addEventListener(n,r=>{r.preventDefault(),r.stopPropagation()},!1)}),["dragenter","dragover"].forEach(n=>{d(this,X).addEventListener(n,()=>{d(this,X).classList.add("highlight")},!1)}),["dragleave","drop"].forEach(n=>{d(this,X).addEventListener(n,()=>{d(this,X).classList.remove("highlight")},!1)}),d(this,X).addEventListener("drop",n=>{var s;let r=(s=n.dataTransfer)==null?void 0:s.files[0];r&&this._handleDroppedFile(r)},!1)}_renderImagePreview(e,t){const n=x("div","user-image-preview"),r=x("img","","width: 280px;aspectRatio: auto; objectFit: cover");r.src=e,r.alt=t;const s=x("div","","width: 14px; height: 14px; display: flex; align-items: center; justify-content: center; padding: 4px; position: absolute; top: -5px; right: -5px; background: #ff6467; border-radius: 50%"),o=Et();o.style.fill="#fff",s.appendChild(o),s.addEventListener("click",()=>{var a;(a=d(this,X))==null||a.removeChild(n)}),n.append(r,s),d(this,X).append(n)}_handleDroppedFile(e){this._readFileAsBase64(e)}_readFileAsBase64(e){const t=new FileReader;t.readAsDataURL(e),t.onload=()=>{this._userViewUploadAndAddSelectedImageList(t.result,e)},t.onerror=()=>{console.error("Error reading file:",t.error)}}_renderUserViewBrowseButton(){const e=Nt("file");e.style.display="none",e.setAttribute("multiple","true"),e.setAttribute("accept","image/*");const t=x("a","user-upload-btn","","Click to upload");return t.classList.add("user-upload-btn"),t.role="button",t.addEventListener("click",()=>e.click()),e.addEventListener("change",()=>{const n=e.files[0];n&&this._readFileAsBase64(n),e.value=""}),t}async _userViewUploadAndAddSelectedImageList(e,t){try{p(this,Me,t),this._renderImagePreview(e,t.name);const n=await mn(e,t);p(this,Re,n),d(this,Se).call(this)}catch{}}_createAllAndSelectedTab(e){const t=y("select-options"),n=Pe("Browse","select"),r=Pe("Selected","select","selected-images-tab");n.classList.add("selected"),[n,r].forEach((o,a)=>{o.addEventListener("click",()=>{var l;p(this,Ae,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=Nt("file");e.style.display="none",e.setAttribute("multiple","true"),e.setAttribute("accept","image/*,video/*,audio/*,.gif"),p(this,fe,document.createElement("button")),d(this,fe).className="browse-more-btn";const t=document.createElement("span");return t.textContent="Upload",d(this,fe).append(sr(),t),d(this,fe).type="button",d(this,fe).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,fe)}_renderCreateFolderBtn(){const e=document.createElement("button");e.className="create-folder-btn";const t=document.createElement("span");return t.textContent="Create",e.append(ln(),t),this._createUpdateFolderDialog(e,"create"),e}_renderSearchField(){let e;const t=y("search-browse-container"),n=y("search-input-wrapper","search-input-wrapper");p(this,Ie,Nt("search")),d(this,Ie).value="",d(this,Ie).addEventListener("input",s=>{p(this,W,[]);const o=s.target;e&&clearTimeout(e),e=setTimeout(()=>{if(!o.value){p(this,ue,""),p(this,Fe,!1),p(this,ge,!1),this._fetchFilesFromFolder(d(this,Ne));return}p(this,ge,!0),p(this,Ue,o.value),this._search(d(this,Ue))},750)}),d(this,Ie).setAttribute("placeholder","Search");const r=rr();return r.style.position="absolute",r.style.top="50%",r.style.left="5%",r.style.transform="translate(-5%, -50%)",n.append(r,d(this,Ie)),t.append(n),t}_createBrowseMoreContainer(){p(this,Oe,y("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=y("browse-image-main");return p(this,V,y("selected-image-container")),d(this,V).addEventListener("scroll",()=>{const t=d(this,V).clientHeight,n=d(this,V).scrollTop,r=d(this,V).scrollHeight;t+n>=r-5&&d(this,Fe)&&(d(this,ge)?this._search(d(this,Ue)):this._fetchFilesFromFolder(d(this,Ne)))}),e.appendChild(d(this,V)),e}_renderFetchingSkeletonUI(){for(let e=0;e<20;e++){const t=y("skeleton");t.innerHTML="",d(this,V).append(t)}}_renderEmptyImageContainer(){if(d(this,Y)||d(this,Ee))return;const e=y(),t=y(),n=document.createElement("p");d(this,ge)&&d(this,Ae)===0?(t.innerHTML=`
2
+ (function(A,B){typeof exports=="object"&&typeof module<"u"?module.exports=B():typeof define=="function"&&define.amd?define(B):(A=typeof globalThis<"u"?globalThis:A||self,A.ImageSalonSdk=B())})(this,function(){"use strict";var Mr=Object.defineProperty;var Mn=A=>{throw TypeError(A)};var Vr=(A,B,_)=>B in A?Mr(A,B,{enumerable:!0,configurable:!0,writable:!0,value:_}):A[B]=_;var D=(A,B,_)=>Vr(A,typeof B!="symbol"?B+"":B,_),Vn=(A,B,_)=>B.has(A)||Mn("Cannot "+_);var d=(A,B,_)=>(Vn(A,B,"read from private field"),_?_.call(A):B.get(A)),k=(A,B,_)=>B.has(A)?Mn("Cannot add the same private member more than once"):B instanceof WeakSet?B.add(A):B.set(A,_),p=(A,B,_,Be)=>(Vn(A,B,"write to private field"),Be?Be.call(A,_):B.set(A,_),_);var pe,Ce,xe,V,fe,S,W,Ee,Y,_e,ke,de,ie,Ne,Se,Ae,Fe,me,Oe,he,ue,Le,Ie,ge,Ue,Ke,J,we,Xe,lt,Ge,X,Re,Te,Je,Me;function A(i){let e=typeof i;if(e=="object"){if(Array.isArray(i))return"array";if(i===null)return"null"}return e}function B(i){return i!==null&&typeof i=="object"&&!Array.isArray(i)}let _="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".split(""),Be=[];for(let i=0;i<_.length;i++)Be[_[i].charCodeAt(0)]=i;Be[45]=_.indexOf("+"),Be[95]=_.indexOf("/");function Tt(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=Be[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 vt(i){let e="",t=0,n,r=0;for(let s=0;s<i.length;s++)switch(n=i[s],t){case 0:e+=_[n>>2],r=(n&3)<<4,t=1;break;case 1:e+=_[r|n>>4],r=(n&15)<<2,t=2;break;case 2:e+=_[r|n>>6],e+=_[n&63],t=0;break}return t&&(e+=_[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 Hn(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 $n(){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 dt(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 Ye=65536*65536;function Bt(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>=Ye&&(r=r+(n/Ye|0),n=n%Ye)}return s(-24,-18),s(-18,-12),s(-12,-6),s(-6),[e,n,r]}function ht(i,e){if(e>>>0<=2097151)return""+(Ye*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 xt(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 F;function jn(){const i=new DataView(new ArrayBuffer(8));F=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}jn();function _t(i){if(!i)throw new Error("BigInt unavailable, see https://github.com/timostamm/protobuf-ts/blob/v1.0.8/MANUAL.md#bigint-support")}const Ot=/^-?[0-9]+$/,Qe=4294967296,et=2147483648;class Dt{constructor(e,t){this.lo=e|0,this.hi=t|0}isZero(){return this.lo==0&&this.hi==0}toNumber(){let e=this.hi*Qe+(this.lo>>>0);if(!Number.isSafeInteger(e))throw new Error("cannot convert to safe number");return e}}class q extends Dt{static from(e){if(F)switch(typeof e){case"string":if(e=="0")return this.ZERO;if(e=="")throw new Error("string is no integer");e=F.C(e);case"number":if(e===0)return this.ZERO;e=F.C(e);case"bigint":if(!e)return this.ZERO;if(e<F.UMIN)throw new Error("signed value for ulong");if(e>F.UMAX)throw new Error("ulong too large");return F.V.setBigUint64(0,e,!0),new q(F.V.getInt32(0,!0),F.V.getInt32(4,!0))}else switch(typeof e){case"string":if(e=="0")return this.ZERO;if(e=e.trim(),!Ot.test(e))throw new Error("string is no integer");let[t,n,r]=Bt(e);if(t)throw new Error("signed value for ulong");return new q(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 q(e,e/Qe)}throw new Error("unknown value "+typeof e)}toString(){return F?this.toBigInt().toString():ht(this.lo,this.hi)}toBigInt(){return _t(F),F.V.setInt32(0,this.lo,!0),F.V.setInt32(4,this.hi,!0),F.V.getBigUint64(0,!0)}}q.ZERO=new q(0,0);class R extends Dt{static from(e){if(F)switch(typeof e){case"string":if(e=="0")return this.ZERO;if(e=="")throw new Error("string is no integer");e=F.C(e);case"number":if(e===0)return this.ZERO;e=F.C(e);case"bigint":if(!e)return this.ZERO;if(e<F.MIN)throw new Error("signed long too small");if(e>F.MAX)throw new Error("signed long too large");return F.V.setBigInt64(0,e,!0),new R(F.V.getInt32(0,!0),F.V.getInt32(4,!0))}else switch(typeof e){case"string":if(e=="0")return this.ZERO;if(e=e.trim(),!Ot.test(e))throw new Error("string is no integer");let[t,n,r]=Bt(e);if(t){if(r>et||r==et&&n!=0)throw new Error("signed long too small")}else if(r>=et)throw new Error("signed long too large");let s=new R(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 R(e,e/Qe):new R(-e,-e/Qe).negate()}throw new Error("unknown value "+typeof e)}isNegative(){return(this.hi&et)!==0}negate(){let e=~this.hi,t=this.lo;return t?t=~t+1:e+=1,new R(t,e)}toString(){if(F)return this.toBigInt().toString();if(this.isNegative()){let e=this.negate();return"-"+ht(e.lo,e.hi)}return ht(this.lo,this.hi)}toBigInt(){return _t(F),F.V.setInt32(0,this.lo,!0),F.V.setInt32(4,this.hi,!0),F.V.getBigInt64(0,!0)}}R.ZERO=new R(0,0);const St={readUnknownField:!0,readerFactory:i=>new qn(i)};function Zn(i){return i?Object.assign(Object.assign({},St),i):St}class qn{constructor(e,t){this.varint64=$n,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 R(...this.varint64())}uint64(){return new q(...this.varint64())}sint64(){let[e,t]=this.varint64(),n=-(e&1);return e=(e>>>1|(t&1)<<31)^n,t=t>>>1^n,new R(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 q(this.sfixed32(),this.sfixed32())}sfixed64(){return new R(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 Pn=34028234663852886e22,Kn=-34028234663852886e22,Xn=4294967295,Gn=2147483647,Jn=-2147483648;function We(i){if(typeof i!="number")throw new Error("invalid int 32: "+typeof i);if(!Number.isInteger(i)||i>Gn||i<Jn)throw new Error("invalid int 32: "+i)}function tt(i){if(typeof i!="number")throw new Error("invalid uint 32: "+typeof i);if(!Number.isInteger(i)||i>Xn||i<0)throw new Error("invalid uint 32: "+i)}function ut(i){if(typeof i!="number")throw new Error("invalid float 32: "+typeof i);if(Number.isFinite(i)&&(i>Pn||i<Kn))throw new Error("invalid float 32: "+i)}const Ut={writeUnknownFields:!0,writerFactory:()=>new Yn};function zn(i){return i?Object.assign(Object.assign({},Ut),i):Ut}class Yn{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(tt(e);e>127;)this.buf.push(e&127|128),e=e>>>7;return this.buf.push(e),this}int32(e){return We(e),xt(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){ut(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){tt(e);let t=new Uint8Array(4);return new DataView(t.buffer).setUint32(0,e,!0),this.raw(t)}sfixed32(e){We(e);let t=new Uint8Array(4);return new DataView(t.buffer).setInt32(0,e,!0),this.raw(t)}sint32(e){return We(e),e=(e<<1^e>>31)>>>0,xt(e,this.buf),this}sfixed64(e){let t=new Uint8Array(8),n=new DataView(t.buffer),r=R.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=q.from(e);return n.setInt32(0,r.lo,!0),n.setInt32(4,r.hi,!0),this.raw(t)}int64(e){let t=R.from(e);return dt(t.lo,t.hi,this.buf),this}sint64(e){let t=R.from(e),n=t.hi>>31,r=t.lo<<1^n,s=(t.hi<<1|t.lo>>>31)^n;return dt(r,s,this.buf),this}uint64(e){let t=q.from(e);return dt(t.lo,t.hi,this.buf),this}}const Rt={emitDefaultValues:!1,enumAsInteger:!1,useProtoFieldName:!1,prettySpaces:0},Mt={ignoreUnknownFields:!1};function Qn(i){return i?Object.assign(Object.assign({},Mt),i):Mt}function ei(i){return i?Object.assign(Object.assign({},Rt),i):Rt}function ti(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 Vt=Symbol.for("protobuf-ts/message-type");function pt(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 nt;(function(i){i[i.NO=0]="NO",i[i.PACKED=1]="PACKED",i[i.UNPACKED=2]="UNPACKED"})(nt||(nt={}));function ni(i){var e,t,n,r;return i.localName=(e=i.localName)!==null&&e!==void 0?e:pt(i.name),i.jsonName=(t=i.jsonName)!==null&&t!==void 0?t:pt(i.name),i.repeat=(n=i.repeat)!==null&&n!==void 0?n:nt.NO,i.opt=(r=i.opt)!==null&&r!==void 0?r:i.repeat||i.oneof?!1:i.kind=="message",i}function ii(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 ri{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(!ii(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 si{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=A(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(B(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 T;switch(a.V.kind){case"message":T=a.V.T().internalJsonRead(w,n);break;case"enum":if(T=this.enum(a.V.T(),w,a.name,n.ignoreUnknownFields),T===!1)continue;break;case"scalar":T=this.scalar(w,a.V.T,a.V.L,a.name);break}this.assert(T!==void 0,a.name+" map value",w);let O=g;a.K==u.BOOL&&(O=O=="true"?!0:O=="false"?!1:O),O=this.scalar(O,a.K,oe.STRING,a.name).toString(),h[O]=T}}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&&ut(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?tt(a):We(a),a;case u.INT64:case u.SFIXED64:case u.SINT64:if(e===null)return te(R.ZERO,n);if(typeof e!="number"&&typeof e!="string")break;return te(R.from(e),n);case u.FIXED64:case u.UINT64:if(e===null)return te(q.ZERO,n);if(typeof e!="number"&&typeof e!="string")break;return te(q.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 Tt(e)}}catch(o){s=o.message}this.assert(!1,r+(s?" - "+s:""),e)}}class oi{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:(We(t),t);case u.FIXED32:case u.UINT32:return t===0?o?0:void 0:(tt(t),t);case u.FLOAT:ut(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=q.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=R.from(t);return l.isZero()&&!o?void 0:l.toString();case u.BYTES:return E(t instanceof Uint8Array),t.byteLength?vt(t):o?"":void 0}}}function ft(i,e=oe.STRING){switch(i){case u.BOOL:return!1;case u.UINT64:case u.FIXED64:return te(q.ZERO,e);case u.INT64:case u.SFIXED64:case u.SINT64:return te(R.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 ai{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 T=e.skip(a);w!==!1&&(w===!0?N.onRead:w)(this.info.typeName,t,o,a,T);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,T=l.kind=="scalar"?l.L:void 0;if(h){let v=c[g];if(a==m.LengthDelimited&&w!=u.STRING&&w!=u.BYTES){let Z=e.uint32()+e.pos;for(;e.pos<Z;)v.push(this.scalar(e,w,T))}else v.push(this.scalar(e,w,T))}else c[g]=this.scalar(e,w,T);break;case"message":if(h){let v=c[g],Z=l.T().internalBinaryRead(e,e.uint32(),n);v.push(Z)}else c[g]=l.T().internalBinaryRead(e,e.uint32(),n,c[g]);break;case"map":let[O,j]=this.mapEntry(l,e,n);c[g][O]=j;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=ft(e.K);o=e.K==u.BOOL?l.toString():l}if(a===void 0)switch(e.V.kind){case"scalar":a=ft(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 li{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==nt.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||R.from(t).isZero(),r="int64";break;case u.UINT64:o=s||q.from(t).isZero(),r="uint64";break;case u.FIXED64:o=s||q.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||R.from(t).isZero(),n=m.Bit64,r="sfixed64";break;case u.SINT32:r="sint32";break;case u.SINT64:o=s||R.from(t).isZero(),r="sint64";break}return[n,r,s||o]}}function ci(i){const e=i.messagePrototype?Object.create(i.messagePrototype):Object.defineProperty({},Vt,{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]=ft(t.T,t.L);break;case"enum":e[n]=0;break;case"map":e[n]={};break}}return e}function $(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 di(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?$t(a,s,o):Ht(a,s,o)))return!1;break;case"map":if(!(n.V.kind=="message"?Wt(n.V.T(),it(s),it(o)):$t(n.V.kind=="enum"?u.INT32:n.V.T,it(s),it(o))))return!1;break;case"message":let l=n.T();if(!(n.repeat?Wt(l,s,o):l.equals(s,o)))return!1;break}}return!0}const it=Object.values;function Ht(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 $t(i,e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(!Ht(i,e[n],t[n]))return!1;return!0}function Wt(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 hi=Object.getOwnPropertyDescriptors(Object.getPrototypeOf({}));class P{constructor(e,t,n){this.defaultCheckDepth=16,this.typeName=e,this.fields=t.map(ni),this.options=n??{},this.messagePrototype=Object.create(null,Object.assign(Object.assign({},hi),{[Vt]:{value:this}})),this.refTypeCheck=new ri(this),this.refJsonReader=new si(this),this.refJsonWriter=new oi(this),this.refBinReader=new ai(this),this.refBinWriter=new li(this)}create(e){let t=ci(this);return e!==void 0&&$(this,t,e),t}clone(e){let t=this.create();return $(this,t,e),t}equals(e,t){return di(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){$(this,e,t)}fromBinary(e,t){let n=Zn(t);return this.internalBinaryRead(n.readerFactory(e),e.byteLength,n)}fromJson(e,t){return this.internalJsonRead(e,Qn(t))}fromJsonString(e,t){let n=JSON.parse(e);return this.fromJson(n,t)}toJson(e,t){return this.internalJsonWrite(e,ei(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=zn(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 ${A(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 ui(i,e){var t,n,r;let s=i;return s.service=e,s.localName=(t=s.localName)!==null&&t!==void 0?t:pt(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 mt{constructor(e,t,n){this.typeName=e,this.methods=t.map(r=>ui(r,this)),this.options=n??{}}}class L 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 pi(i,e){if(!e)return i;let t={};rt(i,t),rt(e,t);for(let n of Object.keys(e)){let r=e[n];switch(n){case"jsonOptions":t.jsonOptions=ti(i.jsonOptions,t.jsonOptions);break;case"binaryOptions":t.binaryOptions=Hn(i.binaryOptions,t.binaryOptions);break;case"meta":t.meta={},rt(i.meta,t.meta),rt(e.meta,t.meta);break;case"interceptors":t.interceptors=i.interceptors?i.interceptors.concat(r):r.concat();break}}return t}function rt(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 Q;(function(i){i[i.PENDING=0]="PENDING",i[i.REJECTED=1]="REJECTED",i[i.RESOLVED=2]="RESOLVED"})(Q||(Q={}));class ye{constructor(e=!0){this._state=Q.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!==Q.PENDING)throw new Error(`cannot resolve ${Q[this.state].toLowerCase()}`);this._resolve(e),this._state=Q.RESOLVED}reject(e){if(this.state!==Q.PENDING)throw new Error(`cannot reject ${Q[this.state].toLowerCase()}`);this._reject(e),this._state=Q.REJECTED}resolvePending(e){this._state===Q.PENDING&&this.resolve(e)}rejectPending(e){this._state===Q.PENDING&&this.reject(e)}}class fi{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==Q.PENDING,"iterator contract broken"),"value"in e?n.resolve(e):n.reject(e),delete t.p}else t.q.push(e)}}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())})};class gi{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 mi(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 wi=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 yi{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 wi(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)}}var f;(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"})(f||(f={}));var bi=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 jt(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 L(`timeout ${t} ms exceeded`,f[f.DEADLINE_EXCEEDED]);i.set("grpc-timeout",`${t}m`)}else if(t){const s=t.getTime(),o=Date.now();if(s<=o)throw new L(`deadline ${t} exceeded`,f[f.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:vt(t)}function gt(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 L(`fetch response type ${l.type}`,f[f.UNKNOWN])}return gt(Ni(l.headers),l.status,l.statusText)}let n=i,r=e>=200&&e<300,s=Gt(n),[o,a]=Xt(n);return(o===void 0||o===f.OK)&&!r&&(o=Ai(e),a=t),[o,a,s]}function qt(i){let e=ki(i),[t,n]=Xt(e),r=Gt(e);return[t??f.OK,n,r]}var ne;(function(i){i[i.DATA=0]="DATA",i[i.TRAILER=128]="TRAILER"})(ne||(ne={}));function Pt(i,e,t){return bi(this,void 0,void 0,function*(){let n,r="",s=new Uint8Array(0),o=Ei(e);if(Ci(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=Kt(s,Tt(r.substring(0,l))),r=r.substring(l)}else s=Kt(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 L("premature EOF",f[f.DATA_LOSS]);t(ne.TRAILER,s.subarray(5));break}}})}const Ci=i=>typeof i.getReader=="function";function Kt(i,e){let t=new Uint8Array(i.length+e.length);return t.set(i),t.set(e,i.length),t}function Ei(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 L("missing response content type",f[f.INTERNAL]);default:throw new L("unexpected response content type: "+i,f[f.INTERNAL])}}function Xt(i){let e,t,n=i["grpc-message"];if(n!==void 0){if(Array.isArray(n))return[f.INTERNAL,"invalid grpc-web message"];t=n}let r=i["grpc-status"];if(r!==void 0){if(Array.isArray(r))return[f.INTERNAL,"invalid grpc-web status"];if(e=parseInt(r,10),f[e]===void 0)return[f.INTERNAL,"invalid grpc-web status"]}return[e,t]}function Gt(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 ki(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 Ni(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 Ai(i){switch(i){case 200:return f.OK;case 400:return f.INVALID_ARGUMENT;case 401:return f.UNAUTHENTICATED;case 403:return f.PERMISSION_DENIED;case 404:return f.NOT_FOUND;case 409:return f.ABORTED;case 412:return f.FAILED_PRECONDITION;case 429:return f.RESOURCE_EXHAUSTED;case 499:return f.CANCELLED;case 500:return f.UNKNOWN;case 501:return f.UNIMPLEMENTED;case 503:return f.UNAVAILABLE;case 504:return f.DEADLINE_EXCEEDED;default:return f.UNKNOWN}}class Fi{constructor(e){this.defaultOptions=e}mergeOptions(e){return pi(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 L("Client streaming is not supported by grpc-web",f[f.UNIMPLEMENTED]);throw t.methodName=e.name,t.serviceName=e.service.typeName,t}duplex(e){const t=new L("Duplex streaming is not supported by grpc-web",f[f.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),T=new ye,O=new fi,j=!0,v,Z=new ye,K,re=new ye;return globalThis.fetch(g,Object.assign(Object.assign({},h),{method:"POST",headers:jt(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,H,G]=gt(C);if(T.resolve(G),b!=null&&b!==f.OK)throw new L(H??f[b],f[b],G);return b!=null&&(v={code:f[b],detail:H??f[b]}),C}).then(C=>{if(!C.body)throw new L("missing response body",f[f.INTERNAL]);return Pt(C.body,C.headers.get("content-type"),(b,H)=>{switch(b){case ne.DATA:O.notifyMessage(e.O.fromBinary(H,l.binaryOptions)),j=!1;break;case ne.TRAILER:let G,se;[G,se,K]=qt(H),v={code:f[G],detail:se??f[G]};break}})}).then(()=>{if(!K&&!j)throw new L("missing trailers",f[f.DATA_LOSS]);if(!v)throw new L("missing status",f[f.INTERNAL]);if(v.code!=="OK")throw new L(v.detail,v.code,K);O.notifyComplete(),Z.resolve(v),re.resolve(K||{})}).catch(C=>{let b;C instanceof L?b=C:C instanceof Error&&C.name==="AbortError"?b=new L(C.message,f[f.CANCELLED]):b=new L(C instanceof Error?C.message:""+C,f[f.INTERNAL]),b.methodName=e.name,b.serviceName=e.service.typeName,T.rejectPending(b),O.notifyError(b),Z.rejectPending(b),re.rejectPending(b)}),new yi(e,(a=l.meta)!==null&&a!==void 0?a:{},t,T.promise,O,Z.promise,re.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),T=new ye,O,j=new ye,v,Z=new ye,K,re=new ye;return globalThis.fetch(g,Object.assign(Object.assign({},h),{method:"POST",headers:jt(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,H,G]=gt(C);if(T.resolve(G),b!=null&&b!==f.OK)throw new L(H??f[b],f[b],G);return b!=null&&(v={code:f[b],detail:H??f[b]}),C}).then(C=>{if(!C.body)throw new L("missing response body",f[f.INTERNAL]);return Pt(C.body,C.headers.get("content-type"),(b,H)=>{switch(b){case ne.DATA:if(O)throw new L("unary call received 2nd message",f[f.DATA_LOSS]);O=e.O.fromBinary(H,l.binaryOptions);break;case ne.TRAILER:let G,se;[G,se,K]=qt(H),v={code:f[G],detail:se??f[G]};break}})}).then(()=>{if(!K&&O)throw new L("missing trailers",f[f.DATA_LOSS]);if(!v)throw new L("missing status",f[f.INTERNAL]);if(!O&&v.code==="OK")throw new L("expected error status",f[f.DATA_LOSS]);if(!O)throw new L(v.detail,v.code,K);if(j.resolve(O),v.code!=="OK")throw new L(v.detail,v.code,K);Z.resolve(v),re.resolve(K||{})}).catch(C=>{let b;C instanceof L?b=C:C instanceof Error&&C.name==="AbortError"?b=new L(C.message,f[f.CANCELLED]):b=new L(C instanceof Error?C.message:""+C,f[f.INTERNAL]),b.methodName=e.name,b.serviceName=e.service.typeName,T.rejectPending(b),j.rejectPending(b),Z.rejectPending(b),re.rejectPending(b)}),new gi(e,(a=l.meta)!==null&&a!==void 0?a:{},t,T.promise,j.promise,Z.promise,re.promise)}}var wt=(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))(wt||{});class Li extends P{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&&$(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 Li;class Ii extends P{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&&$(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 Ti=new Ii;class vi extends P{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",wt]}])}create(e){const t=globalThis.Object.create(this.messagePrototype);return t.name="",t.folderName="",t.nestedFolderName="",t.url="",t.type=0,e!==void 0&&$(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 zt=new vi;class Bi extends P{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",wt]},{no:9,name:"metadata",kind:"message",T:()=>yt}])}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&&$(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=yt.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&&yt.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 Bi;class xi extends P{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&&$(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 yt=new xi;class _i extends P{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&&$(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 Yt=new _i;class Oi extends P{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&&$(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 Di=new Oi;class Si extends P{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&&$(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 Qt=new Si;class Ui extends P{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&&$(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 Ri=new Ui,bt=new mt("com.hamropatro.grpc.cms.FileService",[{name:"createFile",options:{},I:zt,O:le},{name:"updateFile",options:{},I:le,O:le},{name:"deleteFile",options:{},I:Yt,O:Di},{name:"getFilesByFolder",options:{},I:Qt,O:Ri},{name:"search",options:{},I:Jt,O:Ti}]);class je{constructor(e){D(this,"typeName",bt.typeName);D(this,"methods",bt.methods);D(this,"options",bt.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 en=async(i,e,t,n,r,s)=>{var o;try{const a=(o=window.ImageSalonSDK)==null?void 0:o.grpcConfig,l=new je(a),c=zt.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}},Mi=async(i,e,t,n)=>{var r;try{const s=(r=window.ImageSalonSDK)==null?void 0:r.grpcConfig,o=new je(s),a=Qt.create();return a.folderName=i,a.cursor=e,a.limit=t,await o.getFilesByFolder(a,n)}catch(s){throw s}},Vi=async(i,e,t=20,n)=>{var r;try{const s=(r=window.ImageSalonSDK)==null?void 0:r.grpcConfig,o=new je(s),a=Jt.create();return a.searchValue=i,a.cursor=e,a.limit=t,await o.search(a,n)}catch(s){throw s}},Hi=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 je(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}},$i=async(i,e)=>{var t;try{const n=(t=window.ImageSalonSDK)==null?void 0:t.grpcConfig,r=new je(n),s=Yt.create();return s.key=i,await r.deleteFile(s,e)}catch(n){throw n}};class Wi extends P{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&&$(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 tn=new Wi;class ji extends P{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&&$(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 nn=new ji;class Zi extends P{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&&$(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 rn=new Zi;class qi extends P{constructor(){super("com.hamropatro.grpc.cms.GetAllFoldersResponse",[{no:1,name:"folder",kind:"message",repeat:1,T:()=>be},{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&&$(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(be.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++)be.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 Pi=new qi;class Ki extends P{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&&$(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 be=new Ki,Ct=new mt("com.hamropatro.grpc.cms.FolderService",[{name:"createFolder",options:{},I:nn,O:be},{name:"getFolders",options:{},I:rn,O:Pi},{name:"updateFolder",options:{},I:be,O:be},{name:"deleteFolder",options:{},I:tn,O:be}]);class st{constructor(e){D(this,"typeName",Ct.typeName);D(this,"methods",Ct.methods);D(this,"options",Ct.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 Xi=async(i,e=20,t)=>{var o;const n=(o=window.ImageSalonSDK)==null?void 0:o.grpcConfig,r=new st(n),s=rn.create();try{return s.cursor=i,s.limit=e,await r.getFolders(s,t)}catch(a){throw a}},Gi=async(i,e,t,n)=>{var r;try{const s=(r=window.ImageSalonSDK)==null?void 0:r.grpcConfig,o=new st(s),a=nn.create();return a.name=i,a.nestedFolderName=e,a.createdBy=t,await o.createFolder(a,n)}catch(s){throw s}},Ji=async(i,e,t,n,r)=>{var s;try{const o=(s=window.ImageSalonSDK)==null?void 0:s.grpcConfig,a=new st(o),l=be.create();return l.name=e,l.key=i,l.nestedFolderName=t,l.createdBy=n,await a.updateFolder(l,r)}catch(o){throw o}},zi=async(i,e)=>{var t;try{const n=(t=window.ImageSalonSDK)==null?void 0:t.grpcConfig,r=new st(n),s=tn.create();return s.key=i,await r.deleteFolder(s,e)}catch(n){throw n}},sn=(i,e,t)=>{const n=document.createElementNS("http://www.w3.org/2000/svg","svg");n.setAttribute("xmlns","http://www.w3.org/2000/svg"),n.setAttribute("width",i||"20"),n.setAttribute("height",e||"20"),n.setAttribute("viewBox","0 0 24 24"),n.setAttribute("fill","none"),n.setAttribute("stroke",t||"#ee3f3f"),n.setAttribute("stroke-width","2"),n.setAttribute("stroke-linecap","round"),n.setAttribute("stroke-linejoin","round"),n.classList.add("lucide","lucide-circle-alert");const r=document.createElementNS("http://www.w3.org/2000/svg","circle");r.setAttribute("cx","12"),r.setAttribute("cy","12"),r.setAttribute("r","10");const s=document.createElementNS("http://www.w3.org/2000/svg","line");s.setAttribute("x1","12"),s.setAttribute("x2","12"),s.setAttribute("y1","8"),s.setAttribute("y2","12");const o=document.createElementNS("http://www.w3.org/2000/svg","line");return o.setAttribute("x1","12"),o.setAttribute("x2","12.01"),o.setAttribute("y1","16"),o.setAttribute("y2","16"),n.appendChild(r),n.appendChild(s),n.appendChild(o),n};function on(){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 Yi(){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}const Qi=()=>{const i=document.createElementNS("http://www.w3.org/2000/svg","svg");i.setAttribute("xmlns","http://www.w3.org/2000/svg"),i.setAttribute("width","20"),i.setAttribute("height","20"),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-circle-check-big");const e=document.createElementNS("http://www.w3.org/2000/svg","path");e.setAttribute("d","M21.801 10A10 10 0 1 1 17 3.335");const t=document.createElementNS("http://www.w3.org/2000/svg","path");return t.setAttribute("d","m9 11 3 3L22 4"),i.appendChild(e),i.appendChild(t),i};function Et(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 an(){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 Ze(){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}function er(){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}function tr(){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("viewBox","0 -960 960 960"),i.setAttribute("width","24px"),i.setAttribute("fill","currentColor");const e=document.createElementNS("http://www.w3.org/2000/svg","path");return e.setAttribute("d","m488-400-65 65 56 56 161-161-161-161-56 56 65 65H320v80h168ZM160-160q-33 0-56.5-23.5T80-240v-480q0-33 23.5-56.5T160-800h240l80 80h320q33 0 56.5 23.5T880-640v400q0 33-23.5 56.5T800-160H160Zm0-80h640v-400H447l-80-80H160v480Zm0 0v-480 480Z"),i.appendChild(e),i}function ln(){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 nr(){const i="http://www.w3.org/2000/svg",e=document.createElementNS(i,"svg");e.setAttribute("width","16"),e.setAttribute("height","16"),e.setAttribute("viewBox","0 0 24 24"),e.setAttribute("fill","none"),e.setAttribute("stroke","currentColor"),e.setAttribute("stroke-width","2"),e.setAttribute("stroke-linecap","round"),e.setAttribute("stroke-linejoin","round"),e.classList.add("lucide","lucide-eye");const t=document.createElementNS(i,"path");t.setAttribute("d","M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0"),e.appendChild(t);const n=document.createElementNS(i,"circle");return n.setAttribute("cx","12"),n.setAttribute("cy","12"),n.setAttribute("r","3"),e.appendChild(n),document.body.appendChild(e),e}function ir(){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 cn(){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}function kt(){const i=document.createElementNS("http://www.w3.org/2000/svg","svg");i.setAttribute("xmlns","http://www.w3.org/2000/svg"),i.setAttribute("width","24"),i.setAttribute("height","24"),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-upload");const e=document.createElementNS("http://www.w3.org/2000/svg","path");e.setAttribute("d","M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4");const t=document.createElementNS("http://www.w3.org/2000/svg","polyline");t.setAttribute("points","17 8 12 3 7 8");const n=document.createElementNS("http://www.w3.org/2000/svg","line");return n.setAttribute("x1","12"),n.setAttribute("x2","12"),n.setAttribute("y1","3"),n.setAttribute("y2","15"),i.appendChild(e),i.appendChild(t),i.appendChild(n),i}function rr(){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 x(i,e,t,n,r){let s=document.createElement(i);return e&&(s.className+=e),t&&(s.style.cssText=t),n&&(s.textContent=n),r&&r.appendChild(s),s}class sr{constructor(){k(this,pe);p(this,pe,document.createElementNS("http://www.w3.org/2000/svg","svg")),d(this,pe).setAttribute("viewBox","25 25 50 50"),d(this,pe).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,pe).appendChild(e)}show(e){e.appendChild(d(this,pe))}hide(){d(this,pe).remove()}}pe=new WeakMap;const dn=new sr,ot=document.body;class hn{constructor(){D(this,"main");D(this,"dialogContainer");D(this,"dialog");D(this,"dialogBackdrop");D(this,"dialogContent");D(this,"dialogHeader");D(this,"dialogBody");D(this,"dialogFooter");D(this,"confirmButton");D(this,"cancelButton");D(this,"confirmCallback");D(this,"cancelCallback");this.main=x("div"),this.dialog=x("div"),this.confirmCallback=void 0,this.cancelCallback=void 0}_init(e){this.main=x("div","dialog-presentation","","",ot),this.main.setAttribute("role","presentation"),this.dialogContainer=x("div","dialog-container","","",this.main),this.dialogBackdrop=x("div","dialog-backdrop","","",this.dialogContainer),this.dialog=x("div","dialog","","",this.dialogContainer),this.dialog.setAttribute("tabIndex","-1");const t=document.activeElement;if(t&&t!==document.body&&(t.blur(),this.dialog.focus()),this.dialog.className="dialog",this.dialogContent=x("div","dialog-content","","",this.dialog),e!=null&&e.dialogContentStyle&&Object.assign(this.dialogContent.style,e.dialogContentStyle),this.confirmButton=x("button","dialog-btn confirm","","",this.dialogFooter),this.confirmButton.type="button",this.cancelButton=x("button","dialog-btn cancel","","",this.dialogFooter),this.cancelButton.type="button",e.showCloseBtn){const n=x("button","dialog-close-btn","","",this.dialogContent);n.appendChild(Et()),n.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",ot.style.overflow="hidden",this.confirmButton.textContent=e.confirmButtonText||"Upload",this.cancelButton.textContent=e.cancelButtonText||"Cancel",ot.classList.add("dialog-visible"),new Promise(n=>{const r=s=>()=>{this.hide(),n(s==="confirm")};this.confirmCallback=e.onConfirm||r("confirm"),this.confirmButton.addEventListener("click",this.confirmCallback),this.cancelCallback=e.onCancel||r("cancel"),this.cancelButton.addEventListener("click",this.cancelCallback)})}_setHeader(e){if(this.dialogHeader=x("div","dialog-header","","",this.dialogContent),!e.header)this.dialogHeader.innerHTML="";else if(typeof e.header=="string"){const t=x("h4","dialog-header-text","","",this.dialogHeader);t.textContent=e.header}else this.dialogHeader.innerHTML="",this.dialogHeader.appendChild(e.header)}_setBody(e){this.dialogBody=x("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=x("div","dialog-footer","","",this.dialogContent),e.showFooter?this.dialogFooter.append(this.cancelButton,this.confirmButton):(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||ot.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?(dn.show(this.confirmButton),this.confirmButton.disabled=!0):(dn.hide(),this.confirmButton.disabled=!1)}}const at=new hn,M=new hn;class or{constructor(){D(this,"main");D(this,"dialogBody");this.main=x("div"),this.dialogBody=x("div"),this.hide()}show(e){this.main=x("div","popover","","",e.mainContainer),this.dialogBody=x("div","popover-body","","",this.main),this.main.id=e.divId,this.dialogBody.append(e.content)}hide(){this.main.remove()}}const ee=new or;var ce=(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))(ce||{});const qe={0:"IMAGE",1:"AUDIO",2:"VIDEO",3:"ALL",4:"FOLDER"};function un(i){switch(i){case"image":return qe[ce.IMAGE];case"video":return qe[ce.VIDEO];case"audio":return qe[ce.AUDIO];default:return qe[ce.ALL]}}function ar(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 lr(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}const cr=async(i,e)=>{let t;try{i&&(t={Authorization:i,"app-id":e==="production"?"hamropatro":"hamropatro-android"})}catch(r){if(r)throw r}return{meta:t}};function y(i,e){const t=document.createElement("div");return i&&(t.className=i),e&&(t.id=e),t}function Pe(i,e,t){const n=document.createElement("p");return e&&(n.className=e),t&&(n.id=t),i&&(n.textContent=i),n}function I(i,e){const t=document.createElement("span");return e&&(t.className=e),i&&(t.textContent=i),t}function pn(i,e,t,n){const r=document.createElement("img");return e&&(r.className=e),r.src=i,r}function dr(i,e,t){const n=document.createElement("video"),r=document.createElement("source");return n.className=e,r.src=i,n.appendChild(r),n}function hr(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 z(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 Nt(i,e,t){const n=document.createElement("input");return n.className=e,n.defaultValue=t,i&&(n.type=i),n}class ur extends P{constructor(){super("com.hamropatro.grpc.cms.ImageUploadRequest",[{no:1,name:"mime_type",kind:"scalar",T:9}])}create(e){const t=globalThis.Object.create(this.messagePrototype);return t.mimeType="",e!==void 0&&$(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.mimeType=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.mimeType!==""&&t.tag(1,m.LengthDelimited).string(e.mimeType);let r=n.writeUnknownFields;return r!==!1&&(r==!0?N.onWrite:r)(this.typeName,e,t),t}}const fn=new ur;class pr extends P{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&&$(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 fr=new pr,At=new mt("com.hamropatro.grpc.cms.ImageUploadService",[{name:"Upload",options:{},I:fn,O:fr}]);class mr{constructor(e){D(this,"typeName",At.typeName);D(this,"methods",At.methods);D(this,"options",At.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 gr=async i=>{var r;const e=(r=window.ImageSalonSDK)==null?void 0:r.grpcConfig,t=new mr(e),n=fn.create();try{return n.mimeType=i,await t.upload(n)}catch(s){throw s}},mn=async(i,e)=>{try{const t=wr(i,e),r=(await gr(e==null?void 0:e.type)).response.url;return await fetch(r,{method:"PUT",headers:{"Content-Type":e==null?void 0:e.type,"x-amz-acl":"public-read"},body:t}),r==null?void 0:r.split("?")[0]}catch(t){throw t}},wr=(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,/,""):t==="audio"&&(n=i==null?void 0:i.replace(/^data:audio\/\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 yr{constructor(e){k(this,Ce);k(this,xe);k(this,V);k(this,fe);k(this,S,[]);k(this,W,[]);k(this,Ee);k(this,Y);k(this,_e);k(this,ke);k(this,de,[]);k(this,ie);k(this,Ne);k(this,Se);k(this,Ae);k(this,Fe);k(this,me);k(this,Oe);k(this,he);k(this,ue);k(this,Le);k(this,Ie);k(this,ge);k(this,Ue);k(this,Ke);k(this,J);k(this,we);k(this,Xe,!1);k(this,lt);k(this,Ge);k(this,X);k(this,Re);k(this,Te);k(this,Je);k(this,Me);p(this,Ge,e.isAdmin),p(this,Ee,!1),p(this,Y,!1),p(this,_e,!1),p(this,Se,e.handleUpload.bind(this)),p(this,Ae,0),p(this,ue,""),p(this,ge,!1),p(this,Je,e.mode),p(this,Le,!1),p(this,Ke,e.accessToken),p(this,we,null),p(this,Te,""),this._removeToastContainer(),this._grpcOptionInitializer(),this._init(e).then(()=>{p(this,Xe,!0),this._renderView(e),this.updateWindowObject({initialized:!0}),this._initializeGrpcConfig(e.mode,e.endPoint)}),p(this,Re,"")}async _init(e){try{const{mode:t}=e;this.updateWindowObject({mode:t})}catch{throw Error("Initialization failed")}}_isAdminOptions(e){return e.isAdmin===!0}_renderView(e){return this._isAdminOptions(e)?this._renderAdminView(e):this._renderUserView(e)}_renderAdminView(e){if(!d(this,Xe))return;const{parentContainerId:t}=e;if(e.isAdmin===!0)var{buttonProps:n}=e;p(this,Ce,document.getElementById(t));const r=document.createElement("button");r.className=n!=null&&n.buttonClass?n==null?void 0:n.buttonClass:"browse-image-button",r.addEventListener("focus",()=>{r.blur()});const s=document.createElement("span");s.textContent=n!=null&&n.buttonText?n==null?void 0:n.buttonText:"Browse Files";const o=document.createElement("span");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,Ce).appendChild(r)}async _grpcOptionInitializer(){p(this,J,await cr(d(this,Ke),d(this,Je)))}_selectedImageContainer(){var g;p(this,Ne,z(`Save (${(g=d(this,S))==null?void 0:g.length})`,"dialog-btn confirm")),p(this,Fe,y("folder-container")),p(this,me,y("folder-list-wrapper")),this._fetchAllFolders();const e=z("Cancel","dialog-btn cancel");z("","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",()=>{at.hide(),p(this,S,[]),p(this,W,[])}),p(this,xe,y("browse-container"));const n=y();n.style.display="flex",n.style.alignItems="center",n.style.justifyContent="space-between",n.style.padding="10px 20px";const r=Pe("Folders","folder-title"),s=z("","add-folder-btn");s.append(ln()),this._createUpdateFolderDialog(s,"create"),n.append(r,s),d(this,Fe).append(n,d(this,me));const o=this._renderSearchField(),a=this._createBrowseMoreContainer(),l=this._createBrowseImageMain(),c=y("footer");e.onclick=()=>{at.hide(),p(this,W,[]),p(this,S,[])},d(this,Ne).onclick=()=>{d(this,Se).call(this),at.hide(),p(this,S,[]),p(this,W,[])},c.append(e,d(this,Ne));const h=y("container-right-main");h.append(o,a,l,c),d(this,xe).append(d(this,Fe),h),at.show({content:d(this,xe)})}_renderUserView(e){const{parentContainerId:t,restrictedFileSize:n}=e;p(this,Ce,document.getElementById(t)),p(this,X,x("div","user-view-container"));const r=y("user-view-browse-wrapper"),s=x("span","","","Drag & Drop or "),o=this._renderUserViewBrowseButton(),a=x("p","","margin-block: 0px");if(a.append(s,o),n){const l=x("p","","margin-block: 0px; font-size: 13px; color: #777",`Max File size: ${n}`);r.append(kt(),a,l)}else r.append(kt(),a);return this._setupDragAndDrop(d(this,X)),d(this,X).append(r),d(this,Ce).appendChild(d(this,X)),d(this,Ce)}_setupDragAndDrop(e){if(!e)return;["dragenter","dragover","dragleave","drop"].forEach(n=>{d(this,X).addEventListener(n,r=>{r.preventDefault(),r.stopPropagation()},!1)}),["dragenter","dragover"].forEach(n=>{d(this,X).addEventListener(n,()=>{d(this,X).classList.add("highlight")},!1)}),["dragleave","drop"].forEach(n=>{d(this,X).addEventListener(n,()=>{d(this,X).classList.remove("highlight")},!1)}),d(this,X).addEventListener("drop",n=>{var s;let r=(s=n.dataTransfer)==null?void 0:s.files[0];r&&this._handleDroppedFile(r)},!1)}_renderImagePreview(e,t){const n=x("div","user-image-preview"),r=x("img","","width: 280px;aspectRatio:16/9;objectFit:cover;border-radius: 8px;");r.src=e,r.alt=t;const s=x("div","","width: 18px; height: 18px; display: flex; align-items: center; justify-content: center; padding: 4px; position: absolute; top: -10px; right: -10px; background: #c10007; border-radius: 50%;z-index:1"),o=Et();o.style.fill="#fff",s.appendChild(o),s.addEventListener("click",()=>{var a;(a=d(this,X))==null||a.removeChild(n)}),n.append(r,s),d(this,X).append(n)}_handleDroppedFile(e){this._readFileAsBase64(e)}_readFileAsBase64(e){const t=new FileReader;t.readAsDataURL(e),t.onload=()=>{this._userViewUploadAndAddSelectedImageList(t.result,e)},t.onerror=()=>{console.error("Error reading file:",t.error)}}_renderUserViewBrowseButton(){const e=Nt("file");e.style.display="none",e.setAttribute("multiple","true"),e.setAttribute("accept","image/*");const t=x("a","user-upload-btn","","Click to upload");return t.classList.add("user-upload-btn"),t.role="button",t.addEventListener("click",()=>e.click()),e.addEventListener("change",()=>{const n=e.files[0];n&&this._readFileAsBase64(n),e.value=""}),t}async _userViewUploadAndAddSelectedImageList(e,t){try{p(this,Me,t),this._renderImagePreview(e,t.name);const n=await mn(e,t);p(this,Re,n),d(this,Se).call(this)}catch{}}_createAllAndSelectedTab(e){const t=y("select-options"),n=Pe("Browse","select"),r=Pe("Selected","select","selected-images-tab");n.classList.add("selected"),[n,r].forEach((o,a)=>{o.addEventListener("click",()=>{var l;p(this,Ae,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=Nt("file");e.style.display="none",e.setAttribute("multiple","true"),e.setAttribute("accept","image/*,video/*,audio/*,.gif"),p(this,fe,document.createElement("button")),d(this,fe).className="browse-more-btn";const t=document.createElement("span");return t.textContent="Upload",d(this,fe).append(kt(),t),d(this,fe).type="button",d(this,fe).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,fe)}_renderCreateFolderBtn(){const e=document.createElement("button");e.className="create-folder-btn";const t=document.createElement("span");return t.textContent="Create",e.append(ln(),t),this._createUpdateFolderDialog(e,"create"),e}_renderSearchField(){let e;const t=y("search-browse-container"),n=y("search-input-wrapper","search-input-wrapper");p(this,Ie,Nt("search")),d(this,Ie).value="",d(this,Ie).addEventListener("input",s=>{p(this,W,[]);const o=s.target;e&&clearTimeout(e),e=setTimeout(()=>{if(!o.value){p(this,ue,""),p(this,Le,!1),p(this,ge,!1),this._fetchFilesFromFolder(d(this,ke));return}p(this,ge,!0),p(this,Ue,o.value),this._search(d(this,Ue))},750)}),d(this,Ie).setAttribute("placeholder","Search");const r=ir();return r.style.position="absolute",r.style.top="50%",r.style.left="5%",r.style.transform="translate(-5%, -50%)",n.append(r,d(this,Ie)),t.append(n),t}_createBrowseMoreContainer(){p(this,Oe,y("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=y("browse-image-main");return p(this,V,y("selected-image-container")),d(this,V).addEventListener("scroll",()=>{const t=d(this,V).clientHeight,n=d(this,V).scrollTop,r=d(this,V).scrollHeight;t+n>=r-5&&d(this,Le)&&(d(this,ge)?this._search(d(this,Ue)):this._fetchFilesFromFolder(d(this,ke)))}),e.appendChild(d(this,V)),e}_renderFetchingSkeletonUI(){for(let e=0;e<20;e++){const t=y("skeleton");t.innerHTML="",d(this,V).append(t)}}_renderEmptyImageContainer(){if(d(this,Y)||d(this,Ee))return;const e=y(),t=y(),n=document.createElement("p");d(this,ge)&&d(this,Ae)===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,V).appendChild(e)}_renderLoadingUI(){const e=y("skeleton");e.innerHTML="",d(this,V).appendChild(e)}_fileCardBody(e){var Sn,Un,Rn,Mn;const t=y("selected-image-content"),n=y("selected-image-top-bar"),r=z("","selected-image-btn","",!1,'<svg width="20px" height="20px" viewBox="0 0 20 20" focusable="false" fill="currentColor"><path fill="none" d="M0 0h20v20H0V0z"></path><path d="M10 6c.82 0 1.5-.68 1.5-1.5S10.82 3 10 3s-1.5.67-1.5 1.5S9.18 6 10 6zm0 5.5c.82 0 1.5-.68 1.5-1.5s-.68-1.5-1.5-1.5-1.5.68-1.5 1.5.68 1.5 1.5 1.5zm0 5.5c.82 0 1.5-.67 1.5-1.5 0-.82-.68-1.5-1.5-1.5s-1.5.68-1.5 1.5c0 .83.68 1.5 1.5 1.5z"></path></svg>');let s,o;(e==null?void 0:e.type)===ce.IMAGE&&(s=pn(e==null?void 0:e.url,"selected-image"),o=tr()),(e==null?void 0:e.type)===ce.VIDEO&&(s=ur(e==null?void 0:e.url,"uploaded-video"),o=or()),(e==null?void 0:e.type)===ce.AUDIO&&(s=pr(e==null?void 0:e.url,"uploaded-audio"),o=Qi());const a=y("selected-image-wrapper");a.setAttribute("data-key",e==null?void 0:e.key);const l=Pe(e==null?void 0:e.name,"selected-image-name"),c=I("","selected-image-type");c.append(o),n.append(c,r);const h=y();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=y("action-wrapper"),w=z("","action-option preview"),v=I("Preview",""),O=ir();w.append(O,v);const j=z("","action-option move"),T=I("Move",""),Z=nr();j.append(Z,T);const K=z("","action-option rename"),re=I("Rename",""),C=an();K.append(C,re);const b=z("","action-option delete"),H=I("Delete",""),G=cn();b.append(G,H);const se=e.name.split(".")[0],Er=e.name.split(".")[1],Nr=qe[e.type],wn=y("edit-form-wrapper"),yn=y("move-form-wrapper"),bn=y("preview-details-container"),Cn=y("preview-details-wrapper"),En=y("preview-option-image-wrapper"),Nn=y("preview-option-wrapper"),kn=y("preview-option-wrapper"),An=y("preview-option-wrapper"),Ln=y("preview-option-wrapper"),Fn=y("preview-option-wrapper"),In=y("preview-option-wrapper"),vn=y("preview-option-wrapper"),kr=pn(e.url,"preview-option-image");En.append(kr);const Ar=I("File name","preview-title"),Tn=y("preview-option-name");Tn.innerHTML=e.name,Nn.append(Ar,Tn);const Lr=I("Folder name","preview-title"),Fr=I(e.folderName,"preview-option-name");kn.append(Lr,Fr);const Ir=I("File Extension","preview-title"),vr=I(Er,"preview-option-name extension");An.append(Ir,vr);const Tr=I("File type","preview-title"),Br=I(Nr,"preview-option-name");Ln.append(Tr,Br);const xr=I("Dimension","preview-title"),_r=I(`${(Sn=e==null?void 0:e.metadata)==null?void 0:Sn.width} * ${(Un=e==null?void 0:e.metadata)==null?void 0:Un.height}`,"preview-option-name");Fn.append(xr,_r);const Or=I("URL","preview-title"),Dr=I(e.url,"preview-option-name url");In.append(Or,Dr);const Sr=I("Parent folder","preview-title"),Ur=I(e.nestedFolderName,"preview-option-name");vn.append(Sr,Ur),Cn.append(kn,Nn,An,Ln,((Rn=e==null?void 0:e.metadata)==null?void 0:Rn.width)>0&&((Mn=e==null?void 0:e.metadata)==null?void 0:Mn.height)>0?Fn:"",In,e.nestedFolderName?vn:""),bn.append(En,Cn);const Bn=y("form-control"),ct=document.createElement("input");Bn.appendChild(ct),ct.classList.add("input-field"),ct.value=e.name;const xn=y("form-control"),Rr=I("Current Folder:","input-label"),Lt=y("folder-field current");Lt.textContent=e.folderName,Lt.prepend(Ze()),xn.append(Rr,Lt);const _n=y("form-control"),Ve=y();Ve.style.width="100%",Ve.style.display="flex",Ve.style.alignItems="center",Ve.style.justifyContent="space-between";const Mr=I("Suggested Folder List:","input-label"),De=I();De.style.display="flex",De.style.alignItems="center",De.style.gap="5px",De.style.fontSize="14px",De.textContent="Move the file in selected folder",De.appendChild(sn("14px","14px","#333")),Ve.append(Mr,De);const ze=y();ze.style.width="100%",ze.style.maxHeight="250px",ze.style.overflowY="auto";const Ft=document.createElement("ul");Ft.className="folders",ze.append(Ft),_n.append(Ve,ze),d(this,de).forEach(U=>{const $e=this._renderEditFolderListContainer(U);Ft.appendChild($e)});const On=y("form-control"),Vr=I("Destination Folder:","input-label"),Dn=y("folder-field source","source-folder-wrapper"),It=document.createElement("span");It.id="source-folder-name",It.textContent=d(this,ve)?d(this,ve):e.folderName,Dn.append(Ze(),It);let He="";On.append(Vr,Dn),ct.onchange=U=>{He=U.target.value},He=He!==""?He:e.name,wn.append(Bn),yn.append(xn,_n,On),g.append(w,j,K,b),w.onclick=U=>{U.stopPropagation(),ee.hide(),M.show({content:bn,header:se,dialogContentStyle:{minWidth:"60rem",padding:"10px"},showCloseBtn:!0})},j.onclick=U=>{U.stopPropagation(),ee.hide(),M.show({content:yn,header:`Move "${e.name}"`,confirmButtonText:"Move",dialogContentStyle:{minWidth:"35rem",padding:"10px"},showCloseBtn:!0,showFooter:!0,onCancel:()=>{M.hide()},onConfirm:()=>{this._updateFile(He,e)}})},K.onclick=U=>{U.stopPropagation(),ee.hide(),M.show({content:wn,header:"Rename",confirmButtonText:"Update",dialogContentStyle:{padding:"10px"},showCloseBtn:!0,showFooter:!0,onCancel:()=>{M.hide()},onConfirm:()=>{this._updateFile(He,e)}})},b.onclick=U=>{U.stopPropagation(),ee.hide(),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",U=>{U.stopPropagation(),ee.hide(),ee.show({content:g,mainContainer:n,divId:e.key}),p(this,we,e.key)}),s.addEventListener("click",()=>{const U=d(this,S).findIndex(Te=>(Te==null?void 0:Te.key)===(e==null?void 0:e.key));if(t.classList.contains("checked"))t.classList.remove("checked"),U!==-1&&(d(this,S).splice(U,1),d(this,Ae)===1&&a.remove());else{if(d(this,lt))d(this,S).push(e);else{const Te=document.querySelector(".selected-image-wrapper .checked");Te==null||Te.classList.remove("checked"),p(this,S,[e])}t.classList.add("checked")}this._updateContent()}),document.addEventListener("click",U=>{const $e=document.querySelector(`#${d(this,we)}`);$e&&(U.composedPath().includes($e)||ee.hide())}),d(this,S).findIndex(U=>(U==null?void 0:U.key)===(e==null?void 0:e.key))!==-1?(t.classList.add("checked"),d(this,ge)?d(this,V).prepend(a):d(this,V).appendChild(a)):d(this,V).appendChild(a)}_renderImageCard(e){this._fileCardBody(e)}_renderImageListContainer(){var e,t;((e=d(this,W))==null?void 0:e.length)>0&&((t=d(this,W))==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=y("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(Ze()),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(on()),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=z("","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=y("action-wrapper"),c=z("","action-option edit"),h=I("Edit",""),g=an();c.append(g,h);const w=y("edit-form-wrapper"),v=y("name-field-wrapper"),O=I("Name","input-label"),j=document.createElement("input");j.classList.add("input-field"),j.value=e.name,j.onchange=C=>{C.target.value},v.append(O,j),w.append(v);const T={key:e.key,name:e.name,nestedFolderName:e.nestedFolderName,createdBy:e.createdBy};this._createUpdateFolderDialog(c,"update",T);const Z=z("","action-option delete"),K=I("Delete",""),re=cn();Z.append(re,K),l.append(c,Z),Z.onclick=C=>{C.stopPropagation(),ee.hide(),M.show({content:"",dialogContentStyle:{minWidth:"32rem",padding:"10px"},header:`Are you sure you want to delete the folder "${e==null?void 0:e.name}"?`,showFooter:!0,confirmButtonText:"Yes",cancelButtonText:"No",onConfirm:()=>{this._deleteFolder(e.key)}})},a.addEventListener("click",C=>{C.stopPropagation();const b=document.querySelector(`#${e.key}`);p(this,we,null),d(this,we)===e.key&&b!==null?ee.hide():(ee.hide(),ee.show({content:l,mainContainer:n,divId:e.key}),p(this,we,e.key))}),n.appendChild(a)}return t.addEventListener("click",a=>{var l;a.stopPropagation(),p(this,ie,e),p(this,Ne,e==null?void 0:e.name),p(this,S,[]),p(this,W,[]),p(this,ue,""),p(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(Ze()),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(on()),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(),p(this,ve,e==null?void 0:e.name);const l=document.querySelector("#source-folder-name");l.textContent="",l.textContent=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,Le))if(d(this,me).innerHTML="",d(this,_e)){const e=this._renderFolderListLoadingUI();d(this,me).appendChild(e)}else{const e=document.createElement("ul");e.className="folders",d(this,me).appendChild(e),d(this,de).forEach(t=>{const n=this._renderFolderListContainer(t);e.appendChild(n)}),d(this,Le).appendChild(d(this,me))}}_renderToastContainer(e,t){this._removeToastContainer(),p(this,he,document.createElement("div")),d(this,he).className=`message-container ${t}`;const n=Pe(e,"message"),r=t==="success"?er():sn(),s=z("");s.style.cursor="pointer",s.style.border="0",s.style.outline="none",s.style.background="transparent",s.appendChild(Et(t==="error"?"#ee3f3f":"#4caf50")),s.setAttribute("fill",t==="error"?"#ee3f3f":"#4caf50"),s.onclick=()=>this._removeToastContainer(),d(this,he).append(r,n,s),d(this,xe).appendChild(d(this,he)),setTimeout(()=>{this._removeToastContainer()},5e3)}_removeToastContainer(){d(this,he)&&(d(this,he).remove(),p(this,he,null))}_updateSelectedImageListContainerUI(){var t,n;if(!d(this,V))return;d(this,V).innerHTML="",d(this,Y)&&this._renderFetchingSkeletonUI(),d(this,Ee)&&this._renderLoadingUI();const e=document.getElementById("search-input-wrapper");d(this,Ae)===0?(e&&(e.style.visibility="visible"),((t=d(this,W))==null?void 0:t.length)===0&&!d(this,Y)?(d(this,V).classList.add("no-selected-image-container"),this._renderEmptyImageContainer()):(d(this,V).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,V).classList.add("no-selected-image-container"),this._renderEmptyImageContainer()):(d(this,V).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;p(this,Ee,!0),this._updateSelectedImageListContainerUI();try{const s=await mn(e,t),o=await en(t==null?void 0:t.name,"",s,ce[un((n=t.type)==null?void 0:n.split("/")[0])],(r=d(this,ie))==null?void 0:r.name,d(this,J));d(this,W).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{p(this,Ee,!1),this._updateSelectedImageListContainerUI()}}async _updateFile(e,t){M.updateUploadBtn(!0);try{const n=await $i(t.key,e,t.nestedFolderName,t.url,t.thumborUrl,t.proxyUrl,t.type,d(this,ve),d(this,J)),r=d(this,W).find(s=>s.key===n.response.key);r.name=e,this._fetchFilesFromFolder(d(this,ie).name),p(this,W,[]),p(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 Wi(e,d(this,J)),p(this,W,d(this,W).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 Ji(e,(n=d(this,ie))==null?void 0:n.name,"",d(this,J));p(this,S,[]),p(this,W,[]);const s=dr(d(this,de),r==null?void 0:r.response);p(this,de,s),p(this,Ne,e),p(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 _userViewUpload(e,t){var n;try{return await en(d(this,Me).name,"",e,ce[un((n=d(this,Me).type)==null?void 0:n.split("/")[0])],t,d(this,J)),"Image saved successfully"}catch{return"Unable to save the image"}}async _upload(){return d(this,Ge)?d(this,S):d(this,Re)}async _fetchFilesFromFolder(e){var t,n,r;p(this,Y,!0),this._updateSelectedImageListContainerUI();try{const s=await Vi(e,d(this,ue),20,d(this,J)),o=(t=s.response)==null?void 0:t.files;d(this,W).push(...o),p(this,ue,(n=s.response)==null?void 0:n.nextCursor),p(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{p(this,Y,!1),this._updateSelectedImageListContainerUI()}}async _fetchAllFolders(){var e,t;p(this,Y,!0),p(this,_e,!0),this._updateSelectedImageListContainerUI(),this._updateFolderListContainer(),this._removeToastContainer();try{const r=(await Gi("",100,d(this,J))).response.folder,s=cr(r);p(this,Ne,(e=s[0])==null?void 0:e.name),this._fetchFilesFromFolder((t=s[0])==null?void 0:t.name),p(this,ie,s[0]),p(this,de,s)}catch{p(this,Y,!1),this._renderToastContainer("Folder not found. Please create a folder or try again later","error")}finally{p(this,_e,!1),this._updateFolderListContainer()}}async _search(e){var t,n;p(this,Y,!0),this._updateSelectedImageListContainerUI(),this._removeToastContainer();try{const r=await Hi(e,d(this,ue),10,d(this,J)),s=(t=r.response)==null?void 0:t.items;d(this,W).push(...s),p(this,ue,(n=r.response)==null?void 0:n.nextPageCursor)}catch{this._renderToastContainer("Error while searching files","error")}finally{p(this,Y,!1),this._updateSelectedImageListContainerUI()}}async _updateFolder(e,t){M.updateUploadBtn(!0);try{const n=await zi(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 Yi(e,d(this,J)),p(this,de,d(this,de).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(),ee.hide();let s;const o=y("edit-form-wrapper"),a=y("form-control"),l=I("Folder Name","input-label"),c=y();c.style.position="relative";const h=document.createElement("input");h.style.paddingLeft="40px";const g=I();g.appendChild(Ze()),g.style.position="absolute",g.style.top="50%",g.style.left="5%",g.style.transform="translate(-40%, -40%)",h.classList.add("input-field"),c.append(h,g),t==="update"&&(h.value=n.name),h.onchange=w=>{s=w.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,t){let n="https://hamro-cms-backend-grpc.hamrostack.com";t&&(e==="production"||e==="development")?n=t:e==="production"&&(n="https://page-api-grpc.hamropatro.com");const r=new Fi({baseUrl:n});this.updateWindowObject({grpcConfig:r})}}return Ce=new WeakMap,xe=new WeakMap,V=new WeakMap,fe=new WeakMap,S=new WeakMap,W=new WeakMap,Ee=new WeakMap,Y=new WeakMap,_e=new WeakMap,Ne=new WeakMap,de=new WeakMap,ie=new WeakMap,ke=new WeakMap,Se=new WeakMap,Ae=new WeakMap,Le=new WeakMap,me=new WeakMap,Oe=new WeakMap,he=new WeakMap,ue=new WeakMap,Fe=new WeakMap,Ie=new WeakMap,ge=new WeakMap,Ue=new WeakMap,Ke=new WeakMap,J=new WeakMap,we=new WeakMap,Xe=new WeakMap,lt=new WeakMap,Ge=new WeakMap,X=new WeakMap,Re=new WeakMap,At=new WeakMap,ve=new WeakMap,Je=new WeakMap,Me=new WeakMap,Cr});
89
+ `,n.textContent="Looks Empty!"),e.append(t,n),d(this,V).appendChild(e)}_renderLoadingUI(){const e=y("skeleton");e.innerHTML="",d(this,V).appendChild(e)}_fileCardBody(e){var Dn,Sn,Un,Rn;const t=y("selected-image-content"),n=y("selected-image-top-bar"),r=z("","selected-image-btn","",!1,'<svg width="20px" height="20px" viewBox="0 0 20 20" focusable="false" fill="currentColor"><path fill="none" d="M0 0h20v20H0V0z"></path><path d="M10 6c.82 0 1.5-.68 1.5-1.5S10.82 3 10 3s-1.5.67-1.5 1.5S9.18 6 10 6zm0 5.5c.82 0 1.5-.68 1.5-1.5s-.68-1.5-1.5-1.5-1.5.68-1.5 1.5.68 1.5 1.5 1.5zm0 5.5c.82 0 1.5-.67 1.5-1.5 0-.82-.68-1.5-1.5-1.5s-1.5.68-1.5 1.5c0 .83.68 1.5 1.5 1.5z"></path></svg>');let s,o;(e==null?void 0:e.type)===ce.IMAGE&&(s=pn(e==null?void 0:e.url,"selected-image"),o=er()),(e==null?void 0:e.type)===ce.VIDEO&&(s=dr(e==null?void 0:e.url,"uploaded-video"),o=rr()),(e==null?void 0:e.type)===ce.AUDIO&&(s=hr(e==null?void 0:e.url,"uploaded-audio"),o=Yi());const a=y("selected-image-wrapper");a.setAttribute("data-key",e==null?void 0:e.key);const l=Pe(e==null?void 0:e.name,"selected-image-name"),c=I("","selected-image-type");c.append(o),n.append(c,r);const h=y();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=y("action-wrapper"),w=z("","action-option preview"),T=I("Preview",""),O=nr();w.append(O,T);const j=z("","action-option move"),v=I("Move",""),Z=tr();j.append(Z,v);const K=z("","action-option rename"),re=I("Rename",""),C=an();K.append(C,re);const b=z("","action-option delete"),H=I("Delete",""),G=cn();b.append(G,H);const se=e.name.split(".")[0],br=e.name.split(".")[1],Cr=qe[e.type],gn=y("edit-form-wrapper"),wn=y("move-form-wrapper"),yn=y("preview-details-container"),bn=y("preview-details-wrapper"),Cn=y("preview-option-image-wrapper"),En=y("preview-option-wrapper"),kn=y("preview-option-wrapper"),Nn=y("preview-option-wrapper"),An=y("preview-option-wrapper"),Fn=y("preview-option-wrapper"),Ln=y("preview-option-wrapper"),In=y("preview-option-wrapper"),Er=pn(e.url,"preview-option-image");Cn.append(Er);const kr=I("File name","preview-title"),Tn=y("preview-option-name");Tn.innerHTML=e.name,En.append(kr,Tn);const Nr=I("Folder name","preview-title"),Ar=I(e.folderName,"preview-option-name");kn.append(Nr,Ar);const Fr=I("File Extension","preview-title"),Lr=I(br,"preview-option-name extension");Nn.append(Fr,Lr);const Ir=I("File type","preview-title"),Tr=I(Cr,"preview-option-name");An.append(Ir,Tr);const vr=I("Dimension","preview-title"),Br=I(`${(Dn=e==null?void 0:e.metadata)==null?void 0:Dn.width} * ${(Sn=e==null?void 0:e.metadata)==null?void 0:Sn.height}`,"preview-option-name");Fn.append(vr,Br);const xr=I("URL","preview-title"),_r=I(e.url,"preview-option-name url");Ln.append(xr,_r);const Or=I("Parent folder","preview-title"),Dr=I(e.nestedFolderName,"preview-option-name");In.append(Or,Dr),bn.append(kn,En,Nn,An,((Un=e==null?void 0:e.metadata)==null?void 0:Un.width)>0&&((Rn=e==null?void 0:e.metadata)==null?void 0:Rn.height)>0?Fn:"",Ln,e.nestedFolderName?In:""),yn.append(Cn,bn);const vn=y("form-control"),ct=document.createElement("input");vn.appendChild(ct),ct.classList.add("input-field"),ct.value=e.name;const Bn=y("form-control"),Sr=I("Current Folder:","input-label"),Ft=y("folder-field current");Ft.textContent=e.folderName,Ft.prepend(Ze()),Bn.append(Sr,Ft);const xn=y("form-control"),Ve=y();Ve.style.width="100%",Ve.style.display="flex",Ve.style.alignItems="center",Ve.style.justifyContent="space-between";const Ur=I("Suggested Folder List:","input-label"),De=I();De.style.display="flex",De.style.alignItems="center",De.style.gap="5px",De.style.fontSize="14px",De.textContent="Move the file in selected folder",De.appendChild(sn("14px","14px","#333")),Ve.append(Ur,De);const ze=y();ze.style.width="100%",ze.style.maxHeight="250px",ze.style.overflowY="auto";const Lt=document.createElement("ul");Lt.className="folders",ze.append(Lt),xn.append(Ve,ze),d(this,de).forEach(U=>{const $e=this._renderEditFolderListContainer(U);Lt.appendChild($e)});const _n=y("form-control"),Rr=I("Destination Folder:","input-label"),On=y("folder-field source","source-folder-wrapper"),It=document.createElement("span");It.id="source-folder-name",It.textContent=d(this,Te)?d(this,Te):e.folderName,On.append(Ze(),It);let He="";_n.append(Rr,On),ct.onchange=U=>{He=U.target.value},He=He!==""?He:e.name,gn.append(vn),wn.append(Bn,xn,_n),g.append(w,j,K,b),w.onclick=U=>{U.stopPropagation(),ee.hide(),M.show({content:yn,header:se,dialogContentStyle:{minWidth:"60rem",padding:"10px"},showCloseBtn:!0})},j.onclick=U=>{U.stopPropagation(),ee.hide(),M.show({content:wn,header:`Move "${e.name}"`,confirmButtonText:"Move",dialogContentStyle:{minWidth:"35rem",padding:"10px"},showCloseBtn:!0,showFooter:!0,onCancel:()=>{M.hide()},onConfirm:()=>{this._updateFile(He,e)}})},K.onclick=U=>{U.stopPropagation(),ee.hide(),M.show({content:gn,header:"Rename",confirmButtonText:"Update",dialogContentStyle:{padding:"10px"},showCloseBtn:!0,showFooter:!0,onCancel:()=>{M.hide()},onConfirm:()=>{this._updateFile(He,e)}})},b.onclick=U=>{U.stopPropagation(),ee.hide(),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",U=>{U.stopPropagation(),ee.hide(),ee.show({content:g,mainContainer:n,divId:e.key}),p(this,we,e.key)}),s.addEventListener("click",()=>{const U=d(this,S).findIndex(ve=>(ve==null?void 0:ve.key)===(e==null?void 0:e.key));if(t.classList.contains("checked"))t.classList.remove("checked"),U!==-1&&(d(this,S).splice(U,1),d(this,Ae)===1&&a.remove());else{if(d(this,lt))d(this,S).push(e);else{const ve=document.querySelector(".selected-image-wrapper .checked");ve==null||ve.classList.remove("checked"),p(this,S,[e])}t.classList.add("checked")}this._updateContent()}),document.addEventListener("click",U=>{const $e=document.querySelector(`#${d(this,we)}`);$e&&(U.composedPath().includes($e)||ee.hide())}),d(this,S).findIndex(U=>(U==null?void 0:U.key)===(e==null?void 0:e.key))!==-1?(t.classList.add("checked"),d(this,ge)?d(this,V).prepend(a):d(this,V).appendChild(a)):d(this,V).appendChild(a)}_renderImageCard(e){this._fileCardBody(e)}_renderImageListContainer(){var e,t;((e=d(this,W))==null?void 0:e.length)>0&&((t=d(this,W))==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=y("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(Ze()),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(on()),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=z("","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=y("action-wrapper"),c=z("","action-option edit"),h=I("Edit",""),g=an();c.append(g,h);const w=y("edit-form-wrapper"),T=y("name-field-wrapper"),O=I("Name","input-label"),j=document.createElement("input");j.classList.add("input-field"),j.value=e.name,j.onchange=C=>{C.target.value},T.append(O,j),w.append(T);const v={key:e.key,name:e.name,nestedFolderName:e.nestedFolderName,createdBy:e.createdBy};this._createUpdateFolderDialog(c,"update",v);const Z=z("","action-option delete"),K=I("Delete",""),re=cn();Z.append(re,K),l.append(c,Z),Z.onclick=C=>{C.stopPropagation(),ee.hide(),M.show({content:"",dialogContentStyle:{minWidth:"32rem",padding:"10px"},header:`Are you sure you want to delete the folder "${e==null?void 0:e.name}"?`,showFooter:!0,confirmButtonText:"Yes",cancelButtonText:"No",onConfirm:()=>{this._deleteFolder(e.key)}})},a.addEventListener("click",C=>{C.stopPropagation();const b=document.querySelector(`#${e.key}`);p(this,we,null),d(this,we)===e.key&&b!==null?ee.hide():(ee.hide(),ee.show({content:l,mainContainer:n,divId:e.key}),p(this,we,e.key))}),n.appendChild(a)}return t.addEventListener("click",a=>{var l;a.stopPropagation(),p(this,ie,e),p(this,ke,e==null?void 0:e.name),p(this,S,[]),p(this,W,[]),p(this,ue,""),p(this,Le,!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(Ze()),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(on()),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(),p(this,Te,e==null?void 0:e.name);const l=document.querySelector("#source-folder-name");l.textContent="",l.textContent=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,Fe))if(d(this,me).innerHTML="",d(this,_e)){const e=this._renderFolderListLoadingUI();d(this,me).appendChild(e)}else{const e=document.createElement("ul");e.className="folders",d(this,me).appendChild(e),d(this,de).forEach(t=>{const n=this._renderFolderListContainer(t);e.appendChild(n)}),d(this,Fe).appendChild(d(this,me))}}_renderToastContainer(e,t){this._removeToastContainer(),p(this,he,document.createElement("div")),d(this,he).className=`message-container ${t}`;const n=Pe(e,"message"),r=t==="success"?Qi():sn(),s=z("");s.style.cursor="pointer",s.style.border="0",s.style.outline="none",s.style.background="transparent",s.appendChild(Et(t==="error"?"#ee3f3f":"#4caf50")),s.setAttribute("fill",t==="error"?"#ee3f3f":"#4caf50"),s.onclick=()=>this._removeToastContainer(),d(this,he).append(r,n,s),d(this,xe).appendChild(d(this,he)),setTimeout(()=>{this._removeToastContainer()},5e3)}_removeToastContainer(){d(this,he)&&(d(this,he).remove(),p(this,he,null))}_updateSelectedImageListContainerUI(){var t,n;if(!d(this,V))return;d(this,V).innerHTML="",d(this,Y)&&this._renderFetchingSkeletonUI(),d(this,Ee)&&this._renderLoadingUI();const e=document.getElementById("search-input-wrapper");d(this,Ae)===0?(e&&(e.style.visibility="visible"),((t=d(this,W))==null?void 0:t.length)===0&&!d(this,Y)?(d(this,V).classList.add("no-selected-image-container"),this._renderEmptyImageContainer()):(d(this,V).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,V).classList.add("no-selected-image-container"),this._renderEmptyImageContainer()):(d(this,V).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,Ne).textContent=`Save (${(n=d(this,S))==null?void 0:n.length})`,d(this,Ne).disabled=((r=d(this,S))==null?void 0:r.length)===0}async _uploadAndAddSelectedImageList(e,t){var n,r;p(this,Ee,!0),this._updateSelectedImageListContainerUI();try{const s=await mn(e,t),o=await en(t==null?void 0:t.name,"",s,ce[un((n=t.type)==null?void 0:n.split("/")[0])],(r=d(this,ie))==null?void 0:r.name,d(this,J));d(this,W).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{p(this,Ee,!1),this._updateSelectedImageListContainerUI()}}async _updateFile(e,t){M.updateUploadBtn(!0);try{const n=await Hi(t.key,e,t.nestedFolderName,t.url,t.thumborUrl,t.proxyUrl,t.type,d(this,Te),d(this,J)),r=d(this,W).find(s=>s.key===n.response.key);r.name=e,this._fetchFilesFromFolder(d(this,ie).name),p(this,W,[]),p(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 $i(e,d(this,J)),p(this,W,d(this,W).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 Gi(e,(n=d(this,ie))==null?void 0:n.name,"",d(this,J));p(this,S,[]),p(this,W,[]);const s=lr(d(this,de),r==null?void 0:r.response);p(this,de,s),p(this,ke,e),p(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 _userViewUpload(e,t){var n;try{return await en(d(this,Me).name,"",e,ce[un((n=d(this,Me).type)==null?void 0:n.split("/")[0])],t,d(this,J)),"Image saved successfully"}catch{return"Unable to save the image"}}async _upload(){return d(this,Ge)?d(this,S):d(this,Re)}async _fetchFilesFromFolder(e){var t,n,r;p(this,Y,!0),this._updateSelectedImageListContainerUI();try{const s=await Mi(e,d(this,ue),20,d(this,J)),o=(t=s.response)==null?void 0:t.files;d(this,W).push(...o),p(this,ue,(n=s.response)==null?void 0:n.nextCursor),p(this,Le,(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{p(this,Y,!1),this._updateSelectedImageListContainerUI()}}async _fetchAllFolders(){var e,t;p(this,Y,!0),p(this,_e,!0),this._updateSelectedImageListContainerUI(),this._updateFolderListContainer(),this._removeToastContainer();try{const r=(await Xi("",100,d(this,J))).response.folder,s=ar(r);p(this,ke,(e=s[0])==null?void 0:e.name),this._fetchFilesFromFolder((t=s[0])==null?void 0:t.name),p(this,ie,s[0]),p(this,de,s)}catch{p(this,Y,!1),this._renderToastContainer("Folder not found. Please create a folder or try again later","error")}finally{p(this,_e,!1),this._updateFolderListContainer()}}async _search(e){var t,n;p(this,Y,!0),this._updateSelectedImageListContainerUI(),this._removeToastContainer();try{const r=await Vi(e,d(this,ue),10,d(this,J)),s=(t=r.response)==null?void 0:t.items;d(this,W).push(...s),p(this,ue,(n=r.response)==null?void 0:n.nextPageCursor)}catch{this._renderToastContainer("Error while searching files","error")}finally{p(this,Y,!1),this._updateSelectedImageListContainerUI()}}async _updateFolder(e,t){M.updateUploadBtn(!0);try{const n=await Ji(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 zi(e,d(this,J)),p(this,de,d(this,de).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(),ee.hide();let s;const o=y("edit-form-wrapper"),a=y("form-control"),l=I("Folder Name","input-label"),c=y();c.style.position="relative";const h=document.createElement("input");h.style.paddingLeft="40px";const g=I();g.appendChild(Ze()),g.style.position="absolute",g.style.top="50%",g.style.left="5%",g.style.transform="translate(-40%, -40%)",h.classList.add("input-field"),c.append(h,g),t==="update"&&(h.value=n.name),h.onchange=w=>{s=w.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,t){let n="https://hamro-cms-backend-grpc.hamrostack.com";t&&(e==="production"||e==="development")?n=t:e==="production"&&(n="https://page-api-grpc.hamropatro.com");const r=new Fi({baseUrl:n});this.updateWindowObject({grpcConfig:r})}}return Ce=new WeakMap,xe=new WeakMap,V=new WeakMap,fe=new WeakMap,S=new WeakMap,W=new WeakMap,Ee=new WeakMap,Y=new WeakMap,_e=new WeakMap,ke=new WeakMap,de=new WeakMap,ie=new WeakMap,Ne=new WeakMap,Se=new WeakMap,Ae=new WeakMap,Fe=new WeakMap,me=new WeakMap,Oe=new WeakMap,he=new WeakMap,ue=new WeakMap,Le=new WeakMap,Ie=new WeakMap,ge=new WeakMap,Ue=new WeakMap,Ke=new WeakMap,J=new WeakMap,we=new WeakMap,Xe=new WeakMap,lt=new WeakMap,Ge=new WeakMap,X=new WeakMap,Re=new WeakMap,Te=new WeakMap,Je=new WeakMap,Me=new WeakMap,yr});