{"version":3,"file":"image.js","names":["colCache","require","Anchor","Image","constructor","worksheet","model","type","imageId","hyperlinks","range","tl","br","ext","editAs","Error","_ref","decoded","decode","col","left","row","top","right","bottom","module","exports"],"sources":["../../../lib/doc/image.js"],"sourcesContent":["const colCache = require('../utils/col-cache');\nconst Anchor = require('./anchor');\n\nclass Image {\n constructor(worksheet, model) {\n this.worksheet = worksheet;\n this.model = model;\n }\n\n get model() {\n switch (this.type) {\n case 'background':\n return {\n type: this.type,\n imageId: this.imageId,\n };\n case 'image':\n return {\n type: this.type,\n imageId: this.imageId,\n hyperlinks: this.range.hyperlinks,\n range: {\n tl: this.range.tl.model,\n br: this.range.br && this.range.br.model,\n ext: this.range.ext,\n editAs: this.range.editAs,\n },\n };\n default:\n throw new Error('Invalid Image Type');\n }\n }\n\n set model({type, imageId, range, hyperlinks}) {\n this.type = type;\n this.imageId = imageId;\n\n if (type === 'image') {\n if (typeof range === 'string') {\n const decoded = colCache.decode(range);\n this.range = {\n tl: new Anchor(this.worksheet, {col: decoded.left, row: decoded.top}, -1),\n br: new Anchor(this.worksheet, {col: decoded.right, row: decoded.bottom}, 0),\n editAs: 'oneCell',\n };\n } else {\n this.range = {\n tl: new Anchor(this.worksheet, range.tl, 0),\n br: range.br && new Anchor(this.worksheet, range.br, 0),\n ext: range.ext,\n editAs: range.editAs,\n hyperlinks: hyperlinks || range.hyperlinks,\n };\n }\n }\n }\n}\n\nmodule.exports = Image;\n"],"mappings":";;AAAA,MAAMA,QAAQ,GAAGC,OAAO,CAAC,oBAAoB,CAAC;AAC9C,MAAMC,MAAM,GAAGD,OAAO,CAAC,UAAU,CAAC;AAElC,MAAME,KAAK,CAAC;EACVC,WAAWA,CAACC,SAAS,EAAEC,KAAK,EAAE;IAC5B,IAAI,CAACD,SAAS,GAAGA,SAAS;IAC1B,IAAI,CAACC,KAAK,GAAGA,KAAK;EACpB;EAEA,IAAIA,KAAKA,CAAA,EAAG;IACV,QAAQ,IAAI,CAACC,IAAI;MACf,KA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